From ef167613e664d1ac24d46116cdfa09b276079a4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gordan=20Neki=C4=87?= Date: Fri, 4 Mar 2022 20:41:09 +0100 Subject: [PATCH] feat: release v0.0.11 --- .github/workflows/github-actions-tests.yaml | 32 +++++++++++++++++++++ CHANGELOG.md | 7 +++++ package.json | 2 +- src/commands/environment/add.js | 2 +- src/commands/init.js | 18 ++++++++++++ src/commands/server.js | 7 +++-- src/templates/index.js | 14 +++++++-- 7 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/github-actions-tests.yaml diff --git a/.github/workflows/github-actions-tests.yaml b/.github/workflows/github-actions-tests.yaml new file mode 100644 index 0000000..b13b5e0 --- /dev/null +++ b/.github/workflows/github-actions-tests.yaml @@ -0,0 +1,32 @@ +name: Testing + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + workflow_dispatch: + +jobs: + testing: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [14.x, 16.x, 17.x] + steps: + - name: Git checkout + uses: actions/checkout@v2 + + - uses: actions/setup-node@v2 + with: + node-version: '16.x' + registry-url: 'https://registry.npmjs.org' + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - run: npm install + + - run: npm test diff --git a/CHANGELOG.md b/CHANGELOG.md index 19025e2..9ee3fd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# Release 0.0.11 + +- Bugfix for Node LTS version, ERR_UNKNOWN_BUILTIN_MODULE +- Update github actions & npm publish +- Improve init template, add .gitignore, .env +- Improve creation of the env variables for new environments + # Release 0.0.10 - Tests diff --git a/package.json b/package.json index 1a237c8..f25276c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "hlambda-cli", "type": "module", - "version": "0.0.10", + "version": "0.0.11", "description": "CLI for hlambda server.", "main": "src/index.js", "bin": { diff --git a/src/commands/environment/add.js b/src/commands/environment/add.js index 9282991..5aae27a 100644 --- a/src/commands/environment/add.js +++ b/src/commands/environment/add.js @@ -67,7 +67,7 @@ export const addEnv = async (envName, options, program) => { console.log(`Create folder failed`.red); }); - await writeFile(`${initEnvFilePath}/config.yaml`, configEnvTemplate, 'utf-8') + await writeFile(`${initEnvFilePath}/config.yaml`, configEnvTemplate(envName), 'utf-8') .then(() => { // console.log(`File write ${initEnvFilePath}/config.yaml successfull!`.green); }) diff --git a/src/commands/init.js b/src/commands/init.js index 8255460..41b7a6d 100644 --- a/src/commands/init.js +++ b/src/commands/init.js @@ -11,6 +11,8 @@ import { errorTemplate, hlambdaYamlTemplate, hlambdaREADMETemplate, + rootGitIgnoreTemplate, + rootDotenvTemplate, } from './../templates/index.js'; import CLIErrorHandler from './../utils/CLIErrorHandler.js'; @@ -90,6 +92,22 @@ export const init = async (dirName, options, program) => { console.log(`File write ${`./${dirName}/config.yaml`} failed`.red); }); + await writeFile(`./${dirName}/.gitignore`, rootGitIgnoreTemplate, 'utf-8') + .then(() => { + // console.log(`File write ${`./${dirName}/.gitignore`} successfull!`.green); + }) + .catch(() => { + console.log(`File write ${`./${dirName}/.gitignore`} failed`.red); + }); + + await writeFile(`./${dirName}/.env`, rootDotenvTemplate, 'utf-8') + .then(() => { + // console.log(`File write ${`./${dirName}/.env`} successfull!`.green); + }) + .catch(() => { + console.log(`File write ${`./${dirName}/.env`} failed`.red); + }); + if (includeDemoApp) { await writeFile(`./${dirName}/README.md`, hlambdaREADMETemplate, 'utf-8') .then(() => { diff --git a/src/commands/server.js b/src/commands/server.js index 1832d51..d2d7531 100644 --- a/src/commands/server.js +++ b/src/commands/server.js @@ -1,7 +1,7 @@ import path from 'path'; import fetch from 'node-fetch'; -import * as readline from 'node:readline/promises'; -import { stdin as input, stdout as output } from 'node:process'; +import * as readline from 'readline'; +import { stdin as input, stdout as output } from 'process'; import { FormData, File } from 'formdata-node'; @@ -161,8 +161,9 @@ export const serverShell = async (options, program) => { // console.log(`Thank you for your valuable feedback: ${answer}`); rl.on('line', async (terminalInput) => { - if (terminalInput === 'exit' || terminalInput === 'quit') { + if (terminalInput.toLowerCase() === 'exit' || terminalInput.toLowerCase() === 'quit') { rl.close(); + process.exit(0); return; } if (terminalInput.toLowerCase().startsWith('cd')) { diff --git a/src/templates/index.js b/src/templates/index.js index b28fb53..5cf3470 100644 --- a/src/templates/index.js +++ b/src/templates/index.js @@ -16,11 +16,19 @@ metadata_directory: metadata `; -export const configEnvTemplate = `version: 1 -endpoint: "{{ENV_DEV_HLAMBDA_ENDPOINT}}" -admin_secret: "{{ENV_DEV_HLAMBDA_ADMIN_SECRET}}" +export const rootDotenvTemplate = ` `; +export const rootGitIgnoreTemplate = `.env +`; + +export const configEnvTemplate = (envName) => { + return `version: 1 +endpoint: "{{ENV_${`${envName}`.toUpperCase()}_HLAMBDA_ENDPOINT}}" +admin_secret: "{{ENV_${`${envName}`.toUpperCase()}_HLAMBDA_ADMIN_SECRET}}" +`; +}; + export const packageJsonTemplate = `{ "type": "module", "dependencies": {}