Socket
Socket
Sign inDemoInstall

@nestjs/cli

Package Overview
Dependencies
Maintainers
3
Versions
222
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nestjs/cli - npm Package Compare versions

Comparing version 5.2.0 to 5.3.0

lib/configuration/configuration.js

10

actions/generate.action.js

@@ -12,2 +12,4 @@ "use strict";

const chalk_1 = require("chalk");
const nest_configuration_loader_1 = require("../lib/configuration/nest-configuration.loader");
const readers_1 = require("../lib/readers");
const schematics_1 = require("../lib/schematics");

@@ -24,4 +26,6 @@ const abstract_action_1 = require("./abstract.action");

const generateFiles = (inputs) => __awaiter(this, void 0, void 0, function* () {
const collection = schematics_1.CollectionFactory.create(schematics_1.Collection.NESTJS);
const configuration = yield loadConfiguration();
const collection = schematics_1.CollectionFactory.create(configuration.collection);
const schematicOptions = mapSchematicOptions(inputs);
schematicOptions.push(new schematics_1.SchematicOption('language', configuration.language));
try {

@@ -38,2 +42,6 @@ const schematicInput = inputs.find((input) => input.name === 'schematic');

});
const loadConfiguration = () => __awaiter(this, void 0, void 0, function* () {
const loader = new nest_configuration_loader_1.NestConfigurationLoader(new readers_1.FileSystemReader(process.cwd()));
return loader.load();
});
const mapSchematicOptions = (inputs) => {

@@ -40,0 +48,0 @@ const options = [];

15

actions/generate.action.ts
import chalk from 'chalk';
import { Input } from '../commands';
import { Configuration, ConfigurationLoader } from '../lib/configuration';
import { NestConfigurationLoader } from '../lib/configuration/nest-configuration.loader';
import { FileSystemReader } from '../lib/readers';
import { AbstractCollection, Collection, CollectionFactory, SchematicOption } from '../lib/schematics';

@@ -13,12 +16,11 @@ import { AbstractAction } from './abstract.action';

const generateFiles = async (inputs: Input[]) => {
const collection: AbstractCollection = CollectionFactory.create(Collection.NESTJS);
const configuration: Configuration = await loadConfiguration();
const collection: AbstractCollection = CollectionFactory.create(configuration.collection);
const schematicOptions: SchematicOption[] = mapSchematicOptions(inputs);
schematicOptions.push(new SchematicOption('language', configuration.language));
try {
const schematicInput = inputs.find((input) => input.name === 'schematic');
if (!schematicInput) {
throw new Error('Unable to find a schematic for this configuration');
}
await collection.execute(schematicInput.value as string, schematicOptions);

@@ -30,2 +32,7 @@ } catch (error) {

const loadConfiguration = async (): Promise<Configuration> => {
const loader: ConfigurationLoader = new NestConfigurationLoader(new FileSystemReader(process.cwd()));
return loader.load();
};
const mapSchematicOptions = (inputs: Input[]): SchematicOption[] => {

@@ -32,0 +39,0 @@ const options: SchematicOption[] = [];

@@ -11,2 +11,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const strings_1 = require("@angular-devkit/core/src/utils/strings");
const chalk_1 = require("chalk");

@@ -71,2 +72,3 @@ const inquirer = require("inquirer");

yield collection.execute('application', schematicOptions);
yield generateConfigurationFile(args, options, collection);
console.info();

@@ -82,4 +84,20 @@ });

};
const generateConfigurationFile = (args, options, collection) => __awaiter(this, void 0, void 0, function* () {
const schematicOptions = mapConfigurationSchematicOptions(args.concat(options));
schematicOptions.push(new schematics_1.SchematicOption('collection', '@nestjs/schematics'));
yield collection.execute('configuration', schematicOptions);
});
const mapConfigurationSchematicOptions = (inputs) => {
return inputs.reduce((schematicsOptions, option) => {
if (option.name === 'name') {
schematicsOptions.push(new schematics_1.SchematicOption('project', strings_1.dasherize(option.value)));
}
if (option.name === 'language') {
schematicsOptions.push(new schematics_1.SchematicOption(option.name, option.value));
}
return schematicsOptions;
}, []);
};
const installPackages = (inputs, options) => __awaiter(this, void 0, void 0, function* () {
const installDirectory = inputs.find((input) => input.name === 'name').value;
const installDirectory = strings_1.dasherize(inputs.find((input) => input.name === 'name').value);
const dryRunMode = options.find((option) => option.name === 'dry-run').value;

@@ -86,0 +104,0 @@ const inputPackageManager = options.find((option) => option.name === 'package-manager').value;

@@ -0,1 +1,2 @@

import { dasherize } from '@angular-devkit/core/src/utils/strings';
import chalk from 'chalk';

@@ -65,2 +66,3 @@ import * as inquirer from 'inquirer';

await collection.execute('application', schematicOptions);
await generateConfigurationFile(args, options, collection);
console.info();

@@ -78,4 +80,22 @@ };

const generateConfigurationFile = async (args: Input[], options: Input[], collection: AbstractCollection) => {
const schematicOptions: SchematicOption[] = mapConfigurationSchematicOptions(args.concat(options));
schematicOptions.push(new SchematicOption('collection', '@nestjs/schematics'));
await collection.execute('configuration', schematicOptions);
};
const mapConfigurationSchematicOptions = (inputs: Input[]): SchematicOption[] => {
return inputs.reduce((schematicsOptions: SchematicOption[], option: Input) => {
if (option.name === 'name') {
schematicsOptions.push(new SchematicOption('project', dasherize(option.value as string)));
}
if (option.name === 'language') {
schematicsOptions.push(new SchematicOption(option.name, option.value));
}
return schematicsOptions;
}, []);
};
const installPackages = async (inputs: Input[], options: Input[]) => {
const installDirectory = inputs.find((input) => input.name === 'name')!.value as string;
const installDirectory = dasherize(inputs.find((input) => input.name === 'name')!.value as string);
const dryRunMode = options.find((option) => option.name === 'dry-run')!.value as boolean;

@@ -82,0 +102,0 @@ const inputPackageManager: string = options.find((option) => option.name === 'package-manager')!.value as string;

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

.option('-p, --package-manager [package-manager]', 'Allow to specify package manager to skip package-manager selection.')
.option('-l, --language [language]', 'Specify ts or js language to use')
.action((name, description, version, author, command) => __awaiter(this, void 0, void 0, function* () {

@@ -27,2 +28,3 @@ const options = [];

options.push({ name: 'package-manager', value: command.packageManager });
options.push({ name: 'language', value: !!command.language ? command.language : 'ts' });
const inputs = [];

@@ -29,0 +31,0 @@ inputs.push({ name: 'name', value: name });

@@ -17,2 +17,3 @@ import { Command, CommanderStatic } from 'commander';

)
.option('-l, --language [language]', 'Specify ts or js language to use')
.action(async (name: string, description: string, version: string, author: string, command: Command) => {

@@ -23,2 +24,3 @@ const options: Input[] = [];

options.push({ name: 'package-manager', value: command.packageManager });
options.push({ name: 'language', value: !!command.language ? command.language : 'ts' });
const inputs: Input[] = [];

@@ -25,0 +27,0 @@ inputs.push({ name: 'name', value: name });

@@ -9,1 +9,3 @@ "use strict";

__export(require("./abstract.package-manager"));
__export(require("./npm.package-manager"));
__export(require("./yarn.package-manager"));
export * from './package-manager';
export * from './package-manager.factory';
export * from './abstract.package-manager';
export * from './npm.package-manager';
export * from './yarn.package-manager';
export * from './project.dependency';
export * from './package-manager-commands';

@@ -27,3 +27,3 @@ "use strict";

return new Promise((resolve, reject) => {
const child = child_process_1.spawn(`"${this.binary}"`, args, options);
const child = child_process_1.spawn(`${this.binary}`, args, options);
if (collect) {

@@ -30,0 +30,0 @@ child.stdout.on('data', (data) => resolve(data.toString().replace(/\r\n|\n/, '')));

@@ -16,3 +16,3 @@ import chalk from 'chalk';

return new Promise<null | string>((resolve, reject) => {
const child: ChildProcess = spawn(`"${ this.binary }"`, args, options);
const child: ChildProcess = spawn(`${ this.binary }`, args, options);
if (collect) {

@@ -19,0 +19,0 @@ child.stdout.on('data', (data) => resolve(data.toString().replace(/\r\n|\n/, '')));

@@ -7,5 +7,5 @@ "use strict";

constructor() {
super(path_1.join(__dirname, '../..', 'node_modules/.bin/schematics'));
super(`"${path_1.join(__dirname, '../..', 'node_modules/.bin/schematics')}"`);
}
}
exports.SchematicRunner = SchematicRunner;

@@ -6,4 +6,4 @@ import { join } from 'path';

constructor() {
super(join(__dirname, '../..', 'node_modules/.bin/schematics'));
super(`"${ join(__dirname, '../..', 'node_modules/.bin/schematics') }"`);
}
}

@@ -5,3 +5,3 @@ "use strict";

(function (Collection) {
Collection[Collection["NESTJS"] = 0] = "NESTJS";
Collection["NESTJS"] = "@nestjs/schematics";
})(Collection = exports.Collection || (exports.Collection = {}));
export enum Collection {
NESTJS,
NESTJS = '@nestjs/schematics',
}

@@ -18,2 +18,3 @@ "use strict";

{ name: 'class', alias: 'cl' },
{ name: 'configuration', alias: 'config' },
{ name: 'controller', alias: 'co' },

@@ -20,0 +21,0 @@ { name: 'decorator', alias: 'd' },

@@ -14,2 +14,3 @@ import { AbstractRunner } from '../runners';

{ name: 'class', alias: 'cl' },
{ name: 'configuration', alias: 'config' },
{ name: 'controller', alias: 'co' },

@@ -16,0 +17,0 @@ { name: 'decorator', alias: 'd' },

{
"name": "@nestjs/cli",
"version": "5.2.0",
"version": "5.3.0",
"description": "Nest CLI",

@@ -19,3 +19,4 @@ "publishConfig": {

"start": "node bin/nest.js",
"test": "jest --config test/jest-config.json"
"test": "jest --config test/jest-config.json",
"test:dev": "jest --config test/jest-config.json --watchAll"
},

@@ -35,3 +36,3 @@ "repository": {

"@angular-devkit/schematics-cli": "^0.4.9",
"@nestjs/schematics": "^5.4.0",
"@nestjs/schematics": "^5.6.0",
"@types/jest": "^22.2.3",

@@ -38,0 +39,0 @@ "chalk": "^2.4.1",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc