Socket
Socket
Sign inDemoInstall

event-sourcing-generator

Package Overview
Dependencies
106
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.13 to 1.0.14

dist/utils/bash-comand.d.ts

69

dist/actions/config.action.js

@@ -15,4 +15,6 @@ "use strict";

const inquirer = require("inquirer");
const prettyjson = require("prettyjson");
const config_store_1 = require("../utils/config.store");
const path = require("path");
const config_printer_1 = require("../utils/config-printer");
const bin_utils_1 = require("../utils/bin-utils");
function createConfigCommand(program) {

@@ -22,3 +24,3 @@ const listCmd = new commander.Command('list')

.action(() => {
prettyPrintConfigValues();
config_printer_1.prettyPrintConfigValues();
});

@@ -29,14 +31,24 @@ program.addCommand(listCmd);

const options = config_store_1.config.all[schematic];
const schematicConfigCmd = program.command(`${schematic}`);
const schematicConfigCmd = program.command(`${schematic}`).description(options.description || "");
schematicConfigCmd.action(() => __awaiter(this, void 0, void 0, function* () {
const questions = [];
for (const option in options) {
if (options.hasOwnProperty(option)) {
const value = options[option];
questions.push({
type: value.type,
name: option,
message: value.description,
default: false,
});
if (options.type) {
questions.push({
type: options.type,
name: schematic,
message: options.description,
default: options.value,
});
}
else {
for (const option in options) {
if (options.hasOwnProperty(option) && option !== "description") {
const value = options[option];
questions.push({
type: value.type,
name: option,
message: value.description,
default: value.value,
});
}
}

@@ -46,3 +58,17 @@ }

for (const option in response) {
config_store_1.config.set(`${schematic}.${option}.value`, response[option]);
if (schematic === 'collection' && option === "name" &&
config_store_1.config.all[schematic] &&
config_store_1.config.all[schematic].name &&
config_store_1.config.all[schematic].name.value) {
try {
bin_utils_1.getLibPath(path.join(response[option]));
config_store_1.config.set(`${schematic}.name.value`, response[option]);
}
catch (error) {
console.error(chalk.redBright(`The collection ${response[option]} is not installed in the current project. Please install it using npm i ${response[option]}`));
}
}
else {
config_store_1.config.set(`${schematic}.${option}.value`, response[option]);
}
}

@@ -54,18 +80,1 @@ }));

exports.createConfigCommand = createConfigCommand;
function prettyPrintConfigValues() {
console.log(chalk.blue('CONFIG'));
const printObject = {};
Object.keys(config_store_1.config.all).map(val => {
if (typeof config_store_1.config.all[val] == 'object') {
const subObject = {};
for (const iterator of Object.keys(config_store_1.config.all[val])) {
subObject[iterator] = config_store_1.config.all[val][iterator].value;
}
printObject[val] = subObject;
}
else {
printObject[val] = config_store_1.config.all[val];
}
});
console.log(prettyjson.render(printObject, { noColor: false }));
}

@@ -26,4 +26,4 @@ #!/usr/bin/env node

const configCommand = new commander.Command('config').action(() => configCommand.outputHelp());
config_action_1.createConfigCommand(configCommand);
program.addCommand(configCommand);
config_action_1.createConfigCommand(configCommand);
yield commands_generator_1.generateCommands(program);

@@ -30,0 +30,0 @@ yield program.parseAsync(process.argv);

import commander = require('commander');
export declare const generateCommands: (program: commander.Command) => Promise<void>;
export declare function parseCommandOptions(options: any): string[];
export declare function getSchematicsBinary(): string;

@@ -13,62 +13,62 @@ "use strict";

const jsonfile = require("jsonfile");
const glob = require("glob-promise");
const path = require("path");
const bash_1 = require("./bash");
const bash_comand_1 = require("./bash-comand");
const bin_utils_1 = require("./bin-utils");
const command_options_parser_1 = require("./command-options-parser");
const config_store_1 = require("./config.store");
const path_1 = require("path");
const fs_1 = require("fs");
exports.generateCommands = (program) => __awaiter(void 0, void 0, void 0, function* () {
const result = yield bash_1.bashCommand(`${getSchematicsBinary()} ${path_1.join(__dirname, "../../node_modules/" + config_store_1.config.get('collection'))}:.`, ['--list-schematics'], true);
const result = yield bash_comand_1.bashCommand(`${bin_utils_1.getBinaryPath('schematics')} ${config_store_1.config.get('collection.name').value}:.`, ['--list-schematics'], true);
const schematics = result.toString().split('\n');
const filteredSchematics = schematics.filter(val => val !== '');
filteredSchematics.map(schematic => {
const filePath = path.join(__dirname, `../../node_modules/${config_store_1.config.get('collection')}/dist/${schematic}/schema.json`);
const schema = jsonfile.readFileSync(filePath);
const properties = schema['properties'];
let optionString = '';
Object.keys(properties).forEach(key => {
if (properties[key].$default && properties[key].$default.$source) {
optionString += `[${key}] `;
}
filteredSchematics.map((schematic) => __awaiter(void 0, void 0, void 0, function* () {
const schematicDirPath = path.join(bin_utils_1.getLibPath(config_store_1.config.get('collection.name').value), config_store_1.config.get('collection.outDir').value);
const files = glob.sync(`**/${schematic}/schema.json`, {
cwd: schematicDirPath,
absolute: true,
});
const cmd = program.command(`${schematic} ${optionString}`);
cmd.description(schema['description']);
const options = config_store_1.getConfigForSchematic(schematic);
const args = parseCommandOptions(options);
Object.keys(properties).forEach(key => {
cmd.option('--' + key, properties[key].description);
});
cmd.option('--dry-run', 'Run the schematic without merging it with the current file tree.', false);
cmd.action((name, module, cmd) => __awaiter(void 0, void 0, void 0, function* () {
if (!cmd.dryRun) {
args.push('--debug=false');
if (files.length >= 0 && files[0]) {
try {
const schema = jsonfile.readFileSync(files[0]);
const properties = schema['properties'];
let optionString = '';
const cmdArgsKeys = [];
Object.keys(properties).forEach(key => {
if (properties[key].$default && properties[key].$default.$source) {
cmdArgsKeys.push(key);
optionString += `[${key}] `;
}
});
const cmd = program
.command(`${schematic} ${optionString}`)
.passCommandToAction(true)
.storeOptionsAsProperties(true);
cmd
.description(schema['description']);
const options = config_store_1.getConfigForSchematic(schematic);
const args = command_options_parser_1.parseCommandOptions(options);
Object.keys(properties).forEach(key => {
cmd.option('--' + key, properties[key].description);
});
cmd.option('--dry-run', 'Run the schematic without merging it with the current file tree.', false);
cmd.action(() => __awaiter(void 0, void 0, void 0, function* () {
if (!cmd.dryRun) {
args.push('--debug=false');
}
const allArgs = [];
for (let i = 0; i < cmd.args.length; i++) {
if (i < cmdArgsKeys.length) {
allArgs.push(cmd.args[i]);
}
}
allArgs.push(...args);
yield bash_comand_1.bashCommand(`${bin_utils_1.getBinaryPath('schematics')} ${config_store_1.config.get('collection.name').value}:${schematic}`, allArgs, false);
}));
}
const allArgs = [];
allArgs.push(name);
allArgs.push(module);
allArgs.push(...args);
yield bash_1.bashCommand(`${getSchematicsBinary()} ${path_1.join(__dirname, "../../node_modules/" + config_store_1.config.get('collection'))}:${schematic}`, allArgs, false);
}));
});
catch (err) {
console.log(err);
throw err;
}
}
}));
});
function parseCommandOptions(options) {
const args = [];
for (const key in options) {
if (options.hasOwnProperty(key)) {
const element = options[key];
args.push(`--${key}=${element}`);
}
}
return args;
}
exports.parseCommandOptions = parseCommandOptions;
function getSchematicsBinary() {
const subPath = path_1.join('.bin', 'schematics');
for (const path of module.paths) {
const binaryPath = path_1.resolve(path, subPath);
if (fs_1.existsSync(binaryPath)) {
return binaryPath;
}
}
throw new Error('Could not find the schematics cli');
}
exports.getSchematicsBinary = getSchematicsBinary;

@@ -6,4 +6,17 @@ "use strict";

exports.config = new configStore(packageJson.name, {
collection: '@arkerlabs/es-schematics',
collection: {
description: 'Specifies the default schematics collection to use.',
name: {
type: 'string',
value: '@arkerlabs/es-schematics',
description: 'The collection name to use schematics from.',
},
outDir: {
type: 'string',
value: 'dist',
description: 'The directory where your schematic output is located. It will be used for parsing the schema.json file.',
},
},
event: {
description: 'Specifies the default config for @arkerlabs/es-schematics event.',
createHandler: {

@@ -22,5 +35,7 @@ type: 'boolean',

query: {
description: 'Specifies the default config for @arkerlabs/es-schematics query.',
spec: { type: 'boolean', value: true, description: 'Create a spec file.' },
},
command: {
description: 'Specifies the default config for @arkerlabs/es-schematics command.',
spec: { type: 'boolean', value: true, description: 'Create a spec file.' },

@@ -27,0 +42,0 @@ },

{
"name": "event-sourcing-generator",
"version": "1.0.13",
"version": "1.0.14",
"description": "Utils for generating CQRS + Event Sourcing classes for NestJS",

@@ -46,2 +46,3 @@ "main": "dist/index.js",

"figlet": "^1.3.0",
"glob-promise": "^3.4.0",
"inquirer": "^7.1.0",

@@ -48,0 +49,0 @@ "jsonfile": "^6.0.1",

@@ -10,3 +10,2 @@ # โœจ Event Sourcing Generator

$ npm install -g event-sourcing-generator
```

@@ -13,0 +12,0 @@

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