Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/github-actions-tests.yaml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/environment/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
})
Expand Down
18 changes: 18 additions & 0 deletions src/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
errorTemplate,
hlambdaYamlTemplate,
hlambdaREADMETemplate,
rootGitIgnoreTemplate,
rootDotenvTemplate,
} from './../templates/index.js';

import CLIErrorHandler from './../utils/CLIErrorHandler.js';
Expand Down Expand Up @@ -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(() => {
Expand Down
7 changes: 4 additions & 3 deletions src/commands/server.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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')) {
Expand Down
14 changes: 11 additions & 3 deletions src/templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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": {}
Expand Down