Socket
Socket
Sign inDemoInstall

@cyklang/cli

Package Overview
Dependencies
69
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.1 to 0.2.2

6

build/InitCommand.d.ts
import { Command } from "commander";
export declare class InitCommand extends Command {
PGPORT: string;
USER_NAME: string;
USER_PASSWORD: string;
USER_EMAIL: string;
CYK_PORT: string;
constructor(name: string);
commandInit(options: any): Promise<void>;
promptParameters(): Promise<void>;
getRandomInt(min: number, max: number): number;

@@ -6,0 +12,0 @@ generateToken(): string;

44

build/InitCommand.js

@@ -21,2 +21,5 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -26,2 +29,3 @@ exports.InitCommand = void 0;

const fs = __importStar(require("fs"));
const inquirer_1 = __importDefault(require("inquirer"));
const loglevel_1 = require("loglevel");

@@ -33,2 +37,7 @@ const logger = (0, loglevel_1.getLogger)('InitCommand.ts');

super(name);
this.PGPORT = "5432";
this.USER_NAME = "cyk";
this.USER_PASSWORD = "cyk";
this.USER_EMAIL = "my-email@my-domain";
this.CYK_PORT = "3000";
this.description('initialize a folder with files necessary for a cyklang project')

@@ -41,2 +50,3 @@ .action(async (options) => {

try {
await this.promptParameters();
await this.writeEnvFile();

@@ -49,2 +59,20 @@ await this.writeDockerComposeFile();

}
async promptParameters() {
const reply = await inquirer_1.default.prompt([
{ type: "number", name: 'PGPORT', default: this.PGPORT, message: 'Postgresql Port' },
{ type: 'number', name: 'CYK_PORT', default: this.CYK_PORT, message: 'NodeJS Port' },
{ type: 'input', name: 'USER_NAME', default: this.USER_NAME, message: 'Admin User Login' },
{ type: 'input', name: 'USER_PASSWORD', default: this.USER_PASSWORD, message: 'Admin User Password' },
{ type: 'input', name: 'USER_EMAIL', default: this.USER_EMAIL, message: 'Admin Use Email' },
{ type: "confirm", name: 'confirm' }
]);
// logger.debug(reply)
if (reply.confirm === false)
throw 'Command cancelled';
this.PGPORT = reply.PGPORT;
this.CYK_PORT = reply.CYK_PORT;
this.USER_NAME = reply.USER_NAME;
this.USER_PASSWORD = reply.USER_PASSWORD;
this.USER_EMAIL = reply.USER_EMAIL;
}
// developer.mozilla.org Math.random()

@@ -77,3 +105,3 @@ // On renvoie un entier aléatoire entre une valeur min (incluse)

PGHOST="localhost"
PGPORT="4321"
PGPORT="${this.PGPORT}"
PGUSER="postgres"

@@ -89,5 +117,5 @@ PGPASSWORD="postgres"

# created at database initialization
ADMIN_NAME=cyk
ADMIN_PASSWORD=cyk
ADMIN_EMAIL=my-email@my-domain
ADMIN_NAME=${this.USER_NAME}
ADMIN_PASSWORD=${this.USER_PASSWORD}
ADMIN_EMAIL=${this.USER_EMAIL}

@@ -109,6 +137,6 @@ # JWT token generation

USER_NAME=cyk
USER_PASSWORD=cyk
CYK_PORT="3000"
DBREMOTE_URL="http://localhost:3000"
USER_NAME=${this.USER_NAME}
USER_PASSWORD=${this.USER_PASSWORD}
CYK_PORT="${this.CYK_PORT}"
DBREMOTE_URL="http://localhost:${this.CYK_PORT}"
`;

@@ -115,0 +143,0 @@ fs.writeFileSync(envFilename, content);

4

package.json
{
"name": "@cyklang/cli",
"version": "0.2.1",
"version": "0.2.2",
"description": "cyklang CLI",

@@ -24,2 +24,3 @@ "main": "build/index.js",

"form-data": "^4.0.0",
"inquirer": "^8.2.5",
"loglevel": "^1.8.0",

@@ -31,2 +32,3 @@ "mime-types": "^2.1.35",

"devDependencies": {
"@types/inquirer": "^8.2.4",
"@types/mime-types": "^2.1.1",

@@ -33,0 +35,0 @@ "@types/pako": "^2.0.0",

import { Command } from "commander";
import * as fs from 'fs'
import inquirer from "inquirer";
import { getLogger } from "loglevel";
const logger = getLogger('InitCommand.ts')

@@ -9,2 +11,9 @@

export class InitCommand extends Command {
PGPORT="5432"
USER_NAME="cyk"
USER_PASSWORD="cyk"
USER_EMAIL="my-email@my-domain"
CYK_PORT="3000"
constructor(name: string) {

@@ -19,2 +28,3 @@ super(name)

try {
await this.promptParameters()
await this.writeEnvFile()

@@ -28,2 +38,22 @@ await this.writeDockerComposeFile()

async promptParameters() {
const reply = await inquirer.prompt([
{type: "number", name: 'PGPORT', default: this.PGPORT, message: 'Postgresql Port' },
{type: 'number', name: 'CYK_PORT', default: this.CYK_PORT, message: 'NodeJS Port'},
{type: 'input', name: 'USER_NAME', default: this.USER_NAME, message: 'Admin User Login'},
{type: 'input', name: 'USER_PASSWORD', default: this.USER_PASSWORD, message: 'Admin User Password'},
{type: 'input', name: 'USER_EMAIL', default: this.USER_EMAIL, message: 'Admin Use Email'},
{type: "confirm", name: 'confirm'}
])
// logger.debug(reply)
if (reply.confirm === false) throw 'Command cancelled'
this.PGPORT = reply.PGPORT
this.CYK_PORT = reply.CYK_PORT
this.USER_NAME = reply.USER_NAME
this.USER_PASSWORD = reply.USER_PASSWORD
this.USER_EMAIL = reply.USER_EMAIL
}
// developer.mozilla.org Math.random()

@@ -55,2 +85,3 @@ // On renvoie un entier aléatoire entre une valeur min (incluse)

}
Math.random()

@@ -60,3 +91,3 @@ const content = `# PostgreSql connection

PGHOST="localhost"
PGPORT="4321"
PGPORT="${this.PGPORT}"
PGUSER="postgres"

@@ -72,5 +103,5 @@ PGPASSWORD="postgres"

# created at database initialization
ADMIN_NAME=cyk
ADMIN_PASSWORD=cyk
ADMIN_EMAIL=my-email@my-domain
ADMIN_NAME=${this.USER_NAME}
ADMIN_PASSWORD=${this.USER_PASSWORD}
ADMIN_EMAIL=${this.USER_EMAIL}

@@ -92,6 +123,6 @@ # JWT token generation

USER_NAME=cyk
USER_PASSWORD=cyk
CYK_PORT="3000"
DBREMOTE_URL="http://localhost:3000"
USER_NAME=${this.USER_NAME}
USER_PASSWORD=${this.USER_PASSWORD}
CYK_PORT="${this.CYK_PORT}"
DBREMOTE_URL="http://localhost:${this.CYK_PORT}"
`

@@ -98,0 +129,0 @@ fs.writeFileSync(envFilename, content)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc