@nestjs/cli
Advanced tools
Comparing version 1.6.2 to 1.7.0
@@ -0,3 +1,6 @@ | ||
import { CommandArguments } from '../../program/interfaces/command.aguments.interface'; | ||
import { CommandOptions } from '../../program/interfaces/command.options.interface'; | ||
export interface Processor { | ||
process(): Promise<void>; | ||
processV2(args: CommandArguments, options: CommandOptions): Promise<void>; | ||
} |
export interface CommandArguments { | ||
} | ||
export interface CreateCommandArguments extends CommandArguments { | ||
name: string; | ||
destination?: string; | ||
} | ||
export interface GenerateCommandArguments extends CommandArguments { | ||
assetType: string; | ||
assetName: string; | ||
moduleName: string; | ||
} | ||
export interface UpdateCommandArguments extends CommandArguments { | ||
} |
import { Logger } from '../../logger/interfaces/logger.interface'; | ||
import { CommandArguments } from './command.aguments.interface'; | ||
import { CommandOptions } from './command.options.interface'; | ||
export interface CommandHandler { | ||
execute(args: any, options: any, logger: Logger): Promise<void>; | ||
execute(args: CommandArguments, options: CommandOptions, logger: Logger): Promise<void>; | ||
} |
export interface CommandOptions { | ||
} | ||
export interface CreateCommandOptions extends CommandOptions { | ||
repository: string; | ||
} | ||
export interface GenerateCommandOptions extends CommandOptions { | ||
} | ||
export interface UpdateCommandOptions extends CommandOptions { | ||
} |
import { Processor } from '../../../common/asset/interfaces/processor.interface'; | ||
import { CommandArguments } from '../../../common/program/interfaces/command.aguments.interface'; | ||
import { CommandOptions } from '../../../common/program/interfaces/command.options.interface'; | ||
export declare class ComponentProcessor implements Processor { | ||
@@ -10,2 +12,3 @@ private _name; | ||
constructor(_name: string, _moduleName: string, _extension: string); | ||
processV2(args: CommandArguments, options: CommandOptions): Promise<void>; | ||
process(): Promise<void>; | ||
@@ -12,0 +15,0 @@ private buildAssets(moduleFilename); |
@@ -21,2 +21,5 @@ "use strict"; | ||
} | ||
processV2(args, options) { | ||
throw new Error("Method not implemented."); | ||
} | ||
process() { | ||
@@ -23,0 +26,0 @@ return this._finder.find(this._moduleName) |
import { Processor } from '../../../common/asset/interfaces/processor.interface'; | ||
import { CommandArguments } from '../../../common/program/interfaces/command.aguments.interface'; | ||
import { CommandOptions } from '../../../common/program/interfaces/command.options.interface'; | ||
export declare class ControllerProcessor implements Processor { | ||
@@ -10,2 +12,3 @@ private _name; | ||
constructor(_name: string, _moduleName: string, _extension: string); | ||
processV2(args: CommandArguments, options: CommandOptions): Promise<void>; | ||
process(): Promise<void>; | ||
@@ -12,0 +15,0 @@ private buildAssets(moduleFilename); |
@@ -21,2 +21,5 @@ "use strict"; | ||
} | ||
processV2(args, options) { | ||
throw new Error("Method not implemented."); | ||
} | ||
process() { | ||
@@ -23,0 +26,0 @@ return this._finder.find(this._moduleName) |
import { Processor } from '../../../common/asset/interfaces/processor.interface'; | ||
import { CommandOptions } from '../../../common/program/interfaces/command.options.interface'; | ||
import { CommandArguments } from '../../../common/program/interfaces/command.aguments.interface'; | ||
export declare class GatewayProcessor implements Processor { | ||
@@ -10,2 +12,3 @@ private _assetName; | ||
constructor(_assetName: string, _moduleName: string, _extension: string); | ||
processV2(args: CommandArguments, options: CommandOptions): Promise<void>; | ||
process(): Promise<void>; | ||
@@ -12,0 +15,0 @@ private buildAssets(moduleFilename); |
@@ -21,2 +21,5 @@ "use strict"; | ||
} | ||
processV2(args, options) { | ||
throw new Error("Method not implemented."); | ||
} | ||
process() { | ||
@@ -23,0 +26,0 @@ return this._finder.find(this._moduleName) |
import { Processor } from '../../../common/asset/interfaces/processor.interface'; | ||
import { CommandArguments } from '../../../common/program/interfaces/command.aguments.interface'; | ||
import { CommandOptions } from '../../../common/program/interfaces/command.options.interface'; | ||
export declare class MiddlewareProcessor implements Processor { | ||
@@ -9,2 +11,3 @@ private _assetName; | ||
constructor(_assetName: string, _moduleName: string, _extension: string); | ||
processV2(args: CommandArguments, options: CommandOptions): Promise<void>; | ||
process(): Promise<void>; | ||
@@ -11,0 +14,0 @@ private buildAssets(moduleFilename); |
@@ -19,2 +19,5 @@ "use strict"; | ||
} | ||
processV2(args, options) { | ||
return undefined; | ||
} | ||
process() { | ||
@@ -21,0 +24,0 @@ return this._finder.find(this._moduleName) |
import { Processor } from '../../../common/asset/interfaces/processor.interface'; | ||
import { CommandArguments } from '../../../common/program/interfaces/command.aguments.interface'; | ||
import { CommandOptions } from '../../../common/program/interfaces/command.options.interface'; | ||
export declare class ModuleProcessor implements Processor { | ||
@@ -9,2 +11,3 @@ private _assetName; | ||
constructor(_assetName: string, _moduleName: string, _extension: string); | ||
processV2(args: CommandArguments, options: CommandOptions): Promise<void>; | ||
process(): Promise<void>; | ||
@@ -11,0 +14,0 @@ private buildAssets(moduleFilename); |
@@ -19,2 +19,5 @@ "use strict"; | ||
} | ||
processV2(args, options) { | ||
throw new Error("Method not implemented."); | ||
} | ||
process() { | ||
@@ -21,0 +24,0 @@ return this._finder.find(this._moduleName) |
import { Processor } from '../../../common/asset/interfaces/processor.interface'; | ||
import { CommandArguments } from '../../../common/program/interfaces/command.aguments.interface'; | ||
import { CommandOptions } from '../../../common/program/interfaces/command.options.interface'; | ||
export declare class PipeProcessor implements Processor { | ||
@@ -9,2 +11,3 @@ private _assetName; | ||
constructor(_assetName: string, _moduleName: string, _extension: string); | ||
processV2(args: CommandArguments, options: CommandOptions): Promise<void>; | ||
process(): Promise<void>; | ||
@@ -11,0 +14,0 @@ private buildAsset(moduleFilename); |
@@ -19,2 +19,5 @@ "use strict"; | ||
} | ||
processV2(args, options) { | ||
throw new Error("Method not implemented."); | ||
} | ||
process() { | ||
@@ -21,0 +24,0 @@ return this._finder.find(this._moduleName) |
import { Command } from '../../../common/program/interfaces/command.interface'; | ||
import { CommandHandler } from '../../../common/program/interfaces/command.handler.interface'; | ||
export declare class CaporalCommand implements Command { | ||
private command; | ||
constructor(command: any); | ||
private _command; | ||
constructor(_command: any); | ||
alias(name: string): Command; | ||
@@ -7,0 +7,0 @@ argument(name: string, description: string): Command; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class CaporalCommand { | ||
constructor(command) { | ||
this.command = command; | ||
constructor(_command) { | ||
this._command = _command; | ||
} | ||
alias(name) { | ||
this.command.alias(name); | ||
this._command.alias(name); | ||
return this; | ||
} | ||
argument(name, description) { | ||
this.command.argument(name, description); | ||
this._command.argument(name, description); | ||
return this; | ||
} | ||
option(name, description) { | ||
this.command.option(name, description); | ||
this._command.option(name, description); | ||
return this; | ||
} | ||
handler(handler) { | ||
this.command.action(handler.execute); | ||
this._command.action(handler.execute.bind(handler)); | ||
return this; | ||
@@ -22,0 +22,0 @@ } |
import { Program } from '../../../common/program/interfaces/program.interface'; | ||
import { Command } from '../../../common/program/interfaces/command.interface'; | ||
export declare class CaporalProgram implements Program { | ||
private program; | ||
constructor(program?: any); | ||
private _program; | ||
constructor(_program?: any); | ||
version(version: string): Program; | ||
@@ -7,0 +7,0 @@ help(content: string): Program; |
@@ -6,11 +6,11 @@ "use strict"; | ||
class CaporalProgram { | ||
constructor(program = caporal) { | ||
this.program = program; | ||
constructor(_program = caporal) { | ||
this._program = _program; | ||
} | ||
version(version) { | ||
this.program.version(version); | ||
this._program.version(version); | ||
return this; | ||
} | ||
help(content) { | ||
this.program.help(content); | ||
this._program.help(content); | ||
return this; | ||
@@ -23,8 +23,8 @@ } | ||
command(name, description) { | ||
return new caporal_command_1.CaporalCommand(this.program.command(name, description)); | ||
return new caporal_command_1.CaporalCommand(this._program.command(name, description)); | ||
} | ||
listen() { | ||
this.program.parse(process.argv); | ||
this._program.parse(process.argv); | ||
} | ||
} | ||
exports.CaporalProgram = CaporalProgram; |
@@ -95,3 +95,3 @@ "use strict"; | ||
return new Promise((resolve, reject) => { | ||
fs.readFile(filename, 'utf-8', (error, data) => { | ||
fs.readFile(filename, (error, data) => { | ||
if (!util_1.isNullOrUndefined(error)) | ||
@@ -98,0 +98,0 @@ reject(error); |
@@ -168,3 +168,3 @@ "use strict"; | ||
it('can call readFile()', () => { | ||
readFileStub.callsFake((filename, encoding, callback) => callback(null, Buffer.from('content'))); | ||
readFileStub.callsFake((filename, callback) => callback(null, Buffer.from('content'))); | ||
const filename = 'filename'; | ||
@@ -174,3 +174,3 @@ return file_system_utils_1.FileSystemUtils.readFile(filename); | ||
it('should return the read file content', () => { | ||
readFileStub.callsFake((filename, encoding, callback) => callback(null, Buffer.from('content'))); | ||
readFileStub.callsFake((filename, callback) => callback(null, Buffer.from('content'))); | ||
const filename = 'filename'; | ||
@@ -183,3 +183,3 @@ return file_system_utils_1.FileSystemUtils.readFile(filename) | ||
it('should reject an error if something wrong', () => { | ||
readFileStub.callsFake((filename, encoding, callback) => callback('reject message', null)); | ||
readFileStub.callsFake((filename, callback) => callback('reject message', null)); | ||
const filename = 'filename'; | ||
@@ -186,0 +186,0 @@ return file_system_utils_1.FileSystemUtils.readFile(filename) |
import { Command } from '../../common/program/interfaces/command.interface'; | ||
export declare class CreateCommandDescriptor { | ||
static declare(command: Command): void; | ||
import { CommandDescriptor } from '../../common/program/interfaces/command.descriptor.interface'; | ||
import { CommandHandler } from '../../common/program/interfaces/command.handler.interface'; | ||
export declare class CreateCommandDescriptor implements CommandDescriptor { | ||
private _handler; | ||
constructor(_handler?: CommandHandler); | ||
describe(command: Command): void; | ||
} |
@@ -5,3 +5,6 @@ "use strict"; | ||
class CreateCommandDescriptor { | ||
static declare(command) { | ||
constructor(_handler = new create_command_handler_1.CreateCommandHandler()) { | ||
this._handler = _handler; | ||
} | ||
describe(command) { | ||
command | ||
@@ -11,5 +14,5 @@ .argument('<name>', 'Nest application name') | ||
.option('-r, --repository <repository>', 'Github repository where the project template is') | ||
.handler(new create_command_handler_1.CreateCommandHandler()); | ||
.handler(this._handler); | ||
} | ||
} | ||
exports.CreateCommandDescriptor = CreateCommandDescriptor; |
import { Command } from '../../common/program/interfaces/command.interface'; | ||
export declare class GenerateCommandDescriptor { | ||
static declare(command: Command): void; | ||
import { GenerateCommandHandler } from '../handlers/generate-command.handler'; | ||
import { CommandDescriptor } from '../../common/program/interfaces/command.descriptor.interface'; | ||
export declare class GenerateCommandDescriptor implements CommandDescriptor { | ||
private _handler; | ||
constructor(_handler?: GenerateCommandHandler); | ||
describe(command: Command): void; | ||
} |
@@ -5,3 +5,6 @@ "use strict"; | ||
class GenerateCommandDescriptor { | ||
static declare(command) { | ||
constructor(_handler = new generate_command_handler_1.GenerateCommandHandler()) { | ||
this._handler = _handler; | ||
} | ||
describe(command) { | ||
command | ||
@@ -12,5 +15,5 @@ .alias('g') | ||
.argument('[moduleName]', 'The module name where the asset will be declared in') | ||
.handler(new generate_command_handler_1.GenerateCommandHandler()); | ||
.handler(this._handler); | ||
} | ||
} | ||
exports.GenerateCommandDescriptor = GenerateCommandDescriptor; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const sinon = require("sinon"); | ||
const caporal_1 = require("../../../core/program/caporal"); | ||
const chai_1 = require("chai"); | ||
const create_command_descriptor_1 = require("../create.command-descriptor"); | ||
const create_command_handler_1 = require("../../handlers/create-command.handler"); | ||
const caporal_program_1 = require("../../../core/program/caporal/caporal.program"); | ||
describe('CreateCommandDescriptor', () => { | ||
@@ -18,3 +17,3 @@ let sandbox; | ||
beforeEach(() => { | ||
const program = new caporal_1.CaporalProgram(); | ||
const program = new caporal_program_1.CaporalProgram(); | ||
command = program.command('name', 'description'); | ||
@@ -31,18 +30,21 @@ }); | ||
}); | ||
let handler; | ||
beforeEach(() => { | ||
create_command_descriptor_1.CreateCommandDescriptor.declare(command); | ||
handler = new create_command_handler_1.CreateCommandHandler(); | ||
const descriptor = new create_command_descriptor_1.CreateCommandDescriptor(handler); | ||
descriptor.describe(command); | ||
}); | ||
it('should declare the mandatory name argument with the right description', () => { | ||
chai_1.expect(argumentStub.calledWith('<name>', 'Nest application name')).to.be.true; | ||
sinon.assert.calledWith(argumentStub, '<name>', 'Nest application name'); | ||
}); | ||
it('should declare the optional destination argument with the right description', () => { | ||
chai_1.expect(argumentStub.calledWith('[destination]', 'Where the Nest application will be created')).to.be.true; | ||
sinon.assert.calledWith(argumentStub, '[destination]', 'Where the Nest application will be created'); | ||
}); | ||
it('should declare the repository option with the right description', () => { | ||
chai_1.expect(optionStub.calledWith('-r, --repository <repository>', 'Github repository where the project template is')).to.be.true; | ||
sinon.assert.calledWith(optionStub, '-r, --repository <repository>', 'Github repository where the project template is'); | ||
}); | ||
it('should call handler() with the CreateCommandHandler', () => { | ||
chai_1.expect(handlerStub.calledWith(new create_command_handler_1.CreateCommandHandler())).to.be.true; | ||
sinon.assert.calledWith(handlerStub, handler); | ||
}); | ||
}); | ||
}); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const caporal_1 = require("../../../core/program/caporal"); | ||
const sinon = require("sinon"); | ||
const generate_command_descriptor_1 = require("../generate.command-descriptor"); | ||
const generate_command_handler_1 = require("../../handlers/generate-command.handler"); | ||
const caporal_program_1 = require("../../../core/program/caporal/caporal.program"); | ||
describe('GenerateCommandDescriptor', () => { | ||
@@ -17,3 +17,3 @@ let sandbox; | ||
beforeEach(() => { | ||
const program = new caporal_1.CaporalProgram(); | ||
const program = new caporal_program_1.CaporalProgram(); | ||
command = program.command('name', 'description'); | ||
@@ -32,4 +32,7 @@ }); | ||
}); | ||
let handler; | ||
beforeEach(() => { | ||
generate_command_descriptor_1.GenerateCommandDescriptor.declare(command); | ||
handler = new generate_command_handler_1.GenerateCommandHandler(); | ||
const descriptor = new generate_command_descriptor_1.GenerateCommandDescriptor(handler); | ||
descriptor.describe(command); | ||
}); | ||
@@ -49,5 +52,5 @@ it('should declare the command alias g', () => { | ||
it('should call handler() with the GenerateCommandHandler', () => { | ||
sinon.assert.calledWith(handlerStub, new generate_command_handler_1.GenerateCommandHandler()); | ||
sinon.assert.calledWith(handlerStub, handler); | ||
}); | ||
}); | ||
}); |
import { CommandHandler } from '../../common/program/interfaces/command.handler.interface'; | ||
import { CommandArguments } from '../../common/program/interfaces/command.aguments.interface'; | ||
import { CommandOptions } from '../../common/program/interfaces/command.options.interface'; | ||
import { Logger } from '../../common/logger/interfaces/logger.interface'; | ||
export interface CreateCommandArguments extends CommandArguments { | ||
name: string; | ||
destination?: string; | ||
} | ||
export interface CreateCommandOptions extends CommandOptions { | ||
repository: string; | ||
} | ||
import { CreateCommandArguments } from '../../common/program/interfaces/command.aguments.interface'; | ||
import { CreateCommandOptions } from '../../common/program/interfaces/command.options.interface'; | ||
export declare class CreateCommandHandler implements CommandHandler { | ||
@@ -13,0 +6,0 @@ private static DEFAULT_REPOSITORY; |
@@ -11,3 +11,3 @@ "use strict"; | ||
logger_service_1.LoggerService.setLogger(logger); | ||
logger.debug(color_service_1.ColorService.blue('[DEBUG]'), 'launch new command'); | ||
logger.debug(color_service_1.ColorService.blue('[DEBUG]'), 'execute new command'); | ||
logger.debug(color_service_1.ColorService.blue('[DEBUG]'), 'arguments :', JSON.stringify(args, null, 2)); | ||
@@ -14,0 +14,0 @@ logger.debug(color_service_1.ColorService.blue('[DEBUG]'), 'options :', JSON.stringify(options, null, 2)); |
import { CommandHandler } from '../../common/program/interfaces/command.handler.interface'; | ||
import { CommandArguments } from '../../common/program/interfaces/command.aguments.interface'; | ||
import { CommandOptions } from '../../common/program/interfaces/command.options.interface'; | ||
import { GenerateCommandArguments } from '../../common/program/interfaces/command.aguments.interface'; | ||
import { Logger } from '../../common/logger/interfaces/logger.interface'; | ||
export interface GenerateCommandArguments extends CommandArguments { | ||
assetType: string; | ||
assetName: string; | ||
moduleName: string; | ||
} | ||
export interface GenerateCommandOptions extends CommandOptions { | ||
} | ||
import { GenerateCommandOptions } from '../../common/program/interfaces/command.options.interface'; | ||
export declare class GenerateCommandHandler implements CommandHandler { | ||
execute(args: GenerateCommandArguments, options: GenerateCommandOptions, logger: Logger): Promise<void>; | ||
} |
@@ -24,3 +24,3 @@ "use strict"; | ||
logger_service_1.LoggerService.setLogger(logger); | ||
logger.debug(color_service_1.ColorService.blue('[DEBUG]'), 'launch generate command'); | ||
logger.debug(color_service_1.ColorService.blue('[DEBUG]'), 'execute generate command'); | ||
logger.debug(color_service_1.ColorService.blue('[DEBUG]'), 'arguments :', JSON.stringify(args, null, 2)); | ||
@@ -27,0 +27,0 @@ logger.debug(color_service_1.ColorService.blue('[DEBUG]'), 'options :', JSON.stringify(options, null, 2)); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const caporal_1 = require("./core/program/caporal"); | ||
const create_command_descriptor_1 = require("./lib/command-descriptors/create.command-descriptor"); | ||
const generate_command_descriptor_1 = require("./lib/command-descriptors/generate.command-descriptor"); | ||
const update_command_descriptor_1 = require("./lib/command-descriptors/update.command-descriptor"); | ||
const caporal_program_1 = require("./core/program/caporal/caporal.program"); | ||
class NestCliApplication { | ||
static run() { | ||
new caporal_1.CaporalProgram() | ||
new caporal_program_1.CaporalProgram() | ||
.version('1.0.0') | ||
.help('Nest.js CLI') | ||
.declare(program => { | ||
create_command_descriptor_1.CreateCommandDescriptor.declare(program.command('new', 'Create a new Nest application')); | ||
generate_command_descriptor_1.GenerateCommandDescriptor.declare(program.command('generate', 'Generate a new Nest asset')); | ||
new create_command_descriptor_1.CreateCommandDescriptor().describe(program.command('new', 'Create a new Nest application')); | ||
new generate_command_descriptor_1.GenerateCommandDescriptor().describe(program.command('generate', 'Generate a new Nest asset')); | ||
new update_command_descriptor_1.UpdateCommandDescriptor().describe(program.command('update', 'Update the Nest project')); | ||
}) | ||
@@ -15,0 +17,0 @@ .listen(); |
{ | ||
"name": "@nestjs/cli", | ||
"version": "1.6.2", | ||
"version": "1.7.0", | ||
"license": "MIT", | ||
@@ -35,4 +35,4 @@ "publishConfig": { | ||
"@types/mocha": "^2.2.41", | ||
"@types/node": "^7.0.18", | ||
"@types/sinon": "^2.2.2", | ||
"@types/node": "^7.0.33", | ||
"@types/sinon": "^2.3.2", | ||
"chai": "^4.0.0", | ||
@@ -42,5 +42,5 @@ "coveralls": "^2.13.1", | ||
"nyc": "^10.3.2", | ||
"sinon": "^2.3.2", | ||
"ts-node": "^3.0.4", | ||
"typescript": "^2.3.3" | ||
"sinon": "^2.3.6", | ||
"ts-node": "^3.2.0", | ||
"typescript": "^2.4.1" | ||
}, | ||
@@ -47,0 +47,0 @@ "nyc": { |
@@ -30,3 +30,3 @@ Tool to manage Nest projects: Modern, powerful web application framework for [Node.js](http://nodejs.org). | ||
###npm | ||
### npm : | ||
@@ -48,3 +48,3 @@ ```npm install -g @nestjs/cli``` | ||
* `$ nest new my-app myapp/` | ||
* `$ nest new my-app --repo https://github.com/ThomRick/nest-typescript-starter` | ||
* `$ nest new my-app --repository https://github.com/ThomRick/nest-typescript-starter` | ||
Creates a new Nest application by cloning `https://github.com/ThomRick/nest-typescript-starter` Git repository. | ||
@@ -134,3 +134,3 @@ | ||
* `src/app/services/<assetName>.service.ts` | ||
* `src/app/modules/[moduleName]/modules/services/<assetName>.controller.ts` | ||
* `src/app/modules/[moduleName]/modules/services/<assetName>.service.ts` | ||
* `src/app/modules/[moduleName1]>/modules/[moduleName2]>/modules/[moduleName3]>/services/<assetName>.service.ts` | ||
@@ -258,2 +258,7 @@ ```typescript | ||
### update (not implemented) | ||
### update | ||
Examples : | ||
* `$ nest update` | ||
Used to update project : | ||
* @nestjs dependencies | ||
* devDependencies |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
195434
217
4358
261
4