@nrwl/tao
Advanced tools
Comparing version 8.5.2 to 8.6.0-beta.1
#!/usr/bin/env node | ||
import './src/compat/compat'; | ||
export declare function invokeCommand(command: string, root: string, commandArgs: string[]): Promise<any>; | ||
export declare function invokeCommand(command: string, root: string, commandArgs?: string[]): Promise<any>; | ||
export declare function invokeCli(root: string, args: string[]): Promise<void>; |
25
index.js
@@ -13,3 +13,3 @@ #!/usr/bin/env node | ||
require("./src/compat/compat"); | ||
function invokeCommand(command, root, commandArgs) { | ||
function invokeCommand(command, root, commandArgs = []) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -19,23 +19,28 @@ if (command === undefined) { | ||
} | ||
let verboseFlagIndex = commandArgs.indexOf('--verbose'); | ||
if (verboseFlagIndex < 0) { | ||
verboseFlagIndex = commandArgs.indexOf('-v'); | ||
} | ||
const isVerbose = verboseFlagIndex >= 0; | ||
if (isVerbose) { | ||
commandArgs.splice(verboseFlagIndex, 1); | ||
} | ||
switch (command) { | ||
case 'new': | ||
return (yield Promise.resolve().then(() => require('./src/commands/generate'))).taoNew(root, commandArgs); | ||
return (yield Promise.resolve().then(() => require('./src/commands/generate'))).taoNew(root, commandArgs, isVerbose); | ||
case 'generate': | ||
case 'g': | ||
return (yield Promise.resolve().then(() => require('./src/commands/generate'))).generate(root, commandArgs); | ||
return (yield Promise.resolve().then(() => require('./src/commands/generate'))).generate(root, commandArgs, isVerbose); | ||
case 'run': | ||
case 'r': | ||
return (yield Promise.resolve().then(() => require('./src/commands/run'))).run(root, commandArgs); | ||
return (yield Promise.resolve().then(() => require('./src/commands/run'))).run(root, commandArgs, isVerbose); | ||
case 'migrate': | ||
return (yield Promise.resolve().then(() => require('./src/commands/migrate'))).migrate(root, commandArgs); | ||
return (yield Promise.resolve().then(() => require('./src/commands/migrate'))).migrate(root, commandArgs, isVerbose); | ||
case 'help': | ||
case '--help': | ||
return (yield Promise.resolve().then(() => require('./src/commands/help'))).printHelp(); | ||
return (yield Promise.resolve().then(() => require('./src/commands/help'))).help(); | ||
default: | ||
const projectName = commandArgs[0] ? commandArgs[0] : ''; | ||
// this is to make `tao test mylib` same as `tao run mylib:test` | ||
return (yield Promise.resolve().then(() => require('./src/commands/run'))).run(root, [ | ||
`${projectName}:${command}`, | ||
...commandArgs.slice(1) | ||
]); | ||
return (yield Promise.resolve().then(() => require('./src/commands/run'))).run(root, [`${projectName}:${command}`, ...commandArgs.slice(1)], isVerbose); | ||
} | ||
@@ -42,0 +47,0 @@ }); |
{ | ||
"name": "@nrwl/tao", | ||
"version": "8.5.2", | ||
"version": "8.6.0-beta.1", | ||
"description": "CLI for generating code and running commands", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -168,3 +168,3 @@ <p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/nx-logo.png" width="450"></p> | ||
- [Building React full-stack applications in a monorepo.](https://www.youtube.com/watch?v=Jxh_--FeJeY&t=2s) | ||
- [Video course on using Nx Workspaces](https://angularplaybook.com/p/nx-workspaces) | ||
- [Video course on using Nx Workspaces](https://connect.nrwl.io/app/courses/nx-workspaces/intro) | ||
@@ -171,0 +171,0 @@ ### Talks |
@@ -1,2 +0,2 @@ | ||
export declare function generate(root: string, args: string[]): Promise<any>; | ||
export declare function taoNew(root: string, args: string[]): Promise<any>; | ||
export declare function generate(root: string, args: string[], isVerbose?: boolean): Promise<any>; | ||
export declare function taoNew(root: string, args: string[], isVerbose?: boolean): Promise<any>; |
@@ -11,12 +11,12 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const params_1 = require("../shared/params"); | ||
const core_1 = require("@angular-devkit/core"); | ||
const node_1 = require("@angular-devkit/core/node"); | ||
const schematics_1 = require("@angular-devkit/schematics"); | ||
const node_1 = require("@angular-devkit/core/node"); | ||
const tools_1 = require("@angular-devkit/schematics/tools"); | ||
const child_process_1 = require("child_process"); | ||
const inquirer = require("inquirer"); | ||
const logger_1 = require("../shared/logger"); | ||
const params_1 = require("../shared/params"); | ||
const print_help_1 = require("../shared/print-help"); | ||
const minimist = require("minimist"); | ||
const child_process_1 = require("child_process"); | ||
function throwInvalidInvocation() { | ||
@@ -219,4 +219,4 @@ throw new Error(`Specify the schematic name (e.g., ${print_help_1.commandName} generate collection-name:schematic-name)`); | ||
} | ||
function printGenHelp(opts, schema) { | ||
print_help_1.printHelp(`${print_help_1.commandName} generate ${opts.collectionName}:${opts.schematicName}`, Object.assign({}, schema, { properties: Object.assign({}, schema.properties, { dryRun: `Runs through and reports activity without writing to disk.` }) })); | ||
function printGenHelp(opts, schema, logger) { | ||
print_help_1.printHelp(`${print_help_1.commandName} generate ${opts.collectionName}:${opts.schematicName}`, Object.assign({}, schema, { properties: Object.assign({}, schema.properties, { dryRun: `Runs through and reports activity without writing to disk.` }) }), logger); | ||
} | ||
@@ -249,3 +249,3 @@ function getSchematicDefaults(root, collection, schematic) { | ||
if (opts.help) { | ||
printGenHelp(opts, flattenedSchema); | ||
printGenHelp(opts, flattenedSchema, logger); | ||
} | ||
@@ -278,5 +278,6 @@ else { | ||
} | ||
function generate(root, args) { | ||
function generate(root, args, isVerbose = false) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return params_1.handleErrors(logger_1.logger, () => __awaiter(this, void 0, void 0, function* () { | ||
const logger = logger_1.getLogger(isVerbose); | ||
return params_1.handleErrors(logger, isVerbose, () => __awaiter(this, void 0, void 0, function* () { | ||
const fsHost = new core_1.virtualFs.ScopedHost(new node_1.NodeJsSyncHost(), core_1.normalize(root)); | ||
@@ -287,3 +288,3 @@ const opts = parseGenerateOpts(args, 'generate', yield readDefaultCollection(fsHost)); | ||
const schematic = collection.createSchematic(opts.schematicName, true); | ||
return runSchematic(root, workflow, logger_1.logger, Object.assign({}, opts, { schematicName: schematic.description.name }), schematic); | ||
return runSchematic(root, workflow, logger, Object.assign({}, opts, { schematicName: schematic.description.name }), schematic); | ||
})); | ||
@@ -299,5 +300,6 @@ }); | ||
} | ||
function taoNew(root, args) { | ||
function taoNew(root, args, isVerbose = false) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return params_1.handleErrors(logger_1.logger, () => __awaiter(this, void 0, void 0, function* () { | ||
const logger = logger_1.getLogger(isVerbose); | ||
return params_1.handleErrors(logger, isVerbose, () => __awaiter(this, void 0, void 0, function* () { | ||
const fsHost = new core_1.virtualFs.ScopedHost(new node_1.NodeJsSyncHost(), core_1.normalize(root)); | ||
@@ -308,3 +310,3 @@ const opts = parseGenerateOpts(args, 'new', null); | ||
const schematic = collection.createSchematic('tao-new', true); | ||
return runSchematic(root, workflow, logger_1.logger, Object.assign({}, opts, { schematicName: schematic.description.name }), schematic); | ||
return runSchematic(root, workflow, logger, Object.assign({}, opts, { schematicName: schematic.description.name }), schematic); | ||
})); | ||
@@ -311,0 +313,0 @@ }); |
@@ -1,1 +0,1 @@ | ||
export declare function printHelp(): number; | ||
export declare function help(): number; |
@@ -6,17 +6,17 @@ "use strict"; | ||
const print_help_1 = require("../shared/print-help"); | ||
const core_2 = require("@angular-devkit/core"); | ||
function printHelp() { | ||
logger_1.logger.info(core_1.tags.stripIndent ` | ||
${core_2.terminal.bold(print_help_1.toolDescription)} | ||
function help() { | ||
const logger = logger_1.getLogger(true); | ||
logger.info(core_1.tags.stripIndent ` | ||
${core_1.terminal.bold(print_help_1.toolDescription)} | ||
${core_2.terminal.bold('Create a new project.')} | ||
${print_help_1.commandName} new ${core_2.terminal.grey('[project-name] [--collection=schematic-collection] [options, ...]')} | ||
${core_1.terminal.bold('Create a new project.')} | ||
${print_help_1.commandName} new ${core_1.terminal.grey('[project-name] [--collection=schematic-collection] [options, ...]')} | ||
${core_2.terminal.bold('Generate code.')} | ||
${print_help_1.commandName} generate ${core_2.terminal.grey('[schematic-collection:][schematic] [options, ...]')} | ||
${print_help_1.commandName} g ${core_2.terminal.grey('[schematic-collection:][schematic] [options, ...]')} | ||
${core_1.terminal.bold('Generate code.')} | ||
${print_help_1.commandName} generate ${core_1.terminal.grey('[schematic-collection:][schematic] [options, ...]')} | ||
${print_help_1.commandName} g ${core_1.terminal.grey('[schematic-collection:][schematic] [options, ...]')} | ||
${core_2.terminal.bold('Run target.')} | ||
${print_help_1.commandName} run ${core_2.terminal.grey('[project][:target][:configuration] [options, ...]')} | ||
${print_help_1.commandName} r ${core_2.terminal.grey('[project][:target][:configuration] [options, ...]')} | ||
${core_1.terminal.bold('Run target.')} | ||
${print_help_1.commandName} run ${core_1.terminal.grey('[project][:target][:configuration] [options, ...]')} | ||
${print_help_1.commandName} r ${core_1.terminal.grey('[project][:target][:configuration] [options, ...]')} | ||
@@ -26,6 +26,6 @@ You can also use the infix notation to run a target: | ||
${core_2.terminal.bold('Migrate packages and create migrations.json.')} | ||
${print_help_1.commandName} migrate ${core_2.terminal.grey('[package-name]')} | ||
${core_1.terminal.bold('Migrate packages and create migrations.json.')} | ||
${print_help_1.commandName} migrate ${core_1.terminal.grey('[package-name]')} | ||
${core_2.terminal.bold('Run migrations.')} | ||
${core_1.terminal.bold('Run migrations.')} | ||
${print_help_1.commandName} migrate --run-migrations=[filename]')} | ||
@@ -37,2 +37,2 @@ )} | ||
} | ||
exports.printHelp = printHelp; | ||
exports.help = help; |
@@ -48,2 +48,2 @@ export declare type MigrationsJson = { | ||
} | ||
export declare function migrate(root: string, args: string[]): Promise<any>; | ||
export declare function migrate(root: string, args: string[], isVerbose?: boolean): Promise<any>; |
@@ -11,17 +11,17 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const semver_1 = require("semver"); | ||
const params_1 = require("../shared/params"); | ||
const logger_1 = require("../shared/logger"); | ||
const minimist = require("minimist"); | ||
const print_help_1 = require("../shared/print-help"); | ||
const core_1 = require("@angular-devkit/core"); | ||
const core = require("@angular-devkit/core/node"); | ||
const node_1 = require("@angular-devkit/core/node"); | ||
const tmp_1 = require("tmp"); | ||
const workflow_1 = require("@angular-devkit/schematics/src/workflow"); | ||
const tools_1 = require("@angular-devkit/schematics/tools"); | ||
const child_process_1 = require("child_process"); | ||
const fs_1 = require("fs"); | ||
const tools_1 = require("@angular-devkit/schematics/tools"); | ||
const workflow_1 = require("@angular-devkit/schematics/src/workflow"); | ||
const path = require("path"); | ||
const semver_1 = require("semver"); | ||
const stripJsonComments = require("strip-json-comments"); | ||
const path = require("path"); | ||
const core = require("@angular-devkit/core/node"); | ||
const child_process_1 = require("child_process"); | ||
const tmp_1 = require("tmp"); | ||
const logger_1 = require("../shared/logger"); | ||
const params_1 = require("../shared/params"); | ||
const print_help_1 = require("../shared/print-help"); | ||
const minimist = require("minimist"); | ||
class Migrator { | ||
@@ -217,16 +217,16 @@ constructor(opts) { | ||
} | ||
function updatePackageJson(root, packageJson) { | ||
function updatePackageJson(root, updatedPackages) { | ||
const packageJsonPath = path.join(root, 'package.json'); | ||
const json = JSON.parse(stripJsonComments(fs_1.readFileSync(packageJsonPath).toString())); | ||
Object.keys(packageJson).forEach(p => { | ||
Object.keys(updatedPackages).forEach(p => { | ||
if (json.devDependencies && json.devDependencies[p]) { | ||
json.devDependencies[p] = packageJson[p].version; | ||
json.devDependencies[p] = updatedPackages[p].version; | ||
} | ||
else if (json.dependencies && json.dependencies[p]) { | ||
json.dependencies[p] = packageJson[p].version; | ||
json.dependencies[p] = updatedPackages[p].version; | ||
} | ||
else if (packageJson[p].alwaysAddToPackageJson) { | ||
else if (updatedPackages[p].alwaysAddToPackageJson) { | ||
if (!json.dependencies) | ||
json.dependencies = {}; | ||
json.dependencies[p] = packageJson[p].version; | ||
json.dependencies[p] = updatedPackages[p].version; | ||
} | ||
@@ -339,11 +339,12 @@ }); | ||
} | ||
function migrate(root, args) { | ||
function migrate(root, args, isVerbose = false) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return params_1.handleErrors(logger_1.logger, () => __awaiter(this, void 0, void 0, function* () { | ||
const logger = logger_1.getLogger(isVerbose); | ||
return params_1.handleErrors(logger, isVerbose, () => __awaiter(this, void 0, void 0, function* () { | ||
const opts = parseMigrationsOptions(args); | ||
if (opts.type === 'generateMigrations') { | ||
yield generateMigrationsJsonAndUpdatePackageJson(logger_1.logger, root, opts); | ||
yield generateMigrationsJsonAndUpdatePackageJson(logger, root, opts); | ||
} | ||
else { | ||
yield runMigrations(logger_1.logger, root, opts); | ||
yield runMigrations(logger, root, opts); | ||
} | ||
@@ -350,0 +351,0 @@ })); |
@@ -10,2 +10,2 @@ export interface RunOptions { | ||
} | ||
export declare function run(root: string, args: string[]): Promise<any>; | ||
export declare function run(root: string, args: string[], isVerbose: boolean): Promise<any>; |
@@ -11,10 +11,10 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const params_1 = require("../shared/params"); | ||
const architect_1 = require("@angular-devkit/architect"); | ||
const node_1 = require("@angular-devkit/architect/node"); | ||
const core_1 = require("@angular-devkit/core"); | ||
const node_1 = require("@angular-devkit/core/node"); | ||
const node_2 = require("@angular-devkit/architect/node"); | ||
const architect_1 = require("@angular-devkit/architect"); | ||
const node_2 = require("@angular-devkit/core/node"); | ||
const logger_1 = require("../shared/logger"); | ||
const params_1 = require("../shared/params"); | ||
const print_help_1 = require("../shared/print-help"); | ||
const minimist = require("minimist"); | ||
const print_help_1 = require("../shared/print-help"); | ||
function throwInvalidInvocation() { | ||
@@ -55,9 +55,10 @@ throw new Error(`Specify the project name and the target (e.g., ${print_help_1.commandName} run proj:build)`); | ||
} | ||
function printRunHelp(opts, schema) { | ||
print_help_1.printHelp(`${print_help_1.commandName} run ${opts.project}:${opts.target}`, schema); | ||
function printRunHelp(opts, schema, logger) { | ||
print_help_1.printHelp(`${print_help_1.commandName} run ${opts.project}:${opts.target}`, schema, logger); | ||
} | ||
function run(root, args) { | ||
function run(root, args, isVerbose) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return params_1.handleErrors(logger_1.logger, () => __awaiter(this, void 0, void 0, function* () { | ||
const fsHost = new node_1.NodeJsSyncHost(); | ||
const logger = logger_1.getLogger(isVerbose); | ||
return params_1.handleErrors(logger, isVerbose, () => __awaiter(this, void 0, void 0, function* () { | ||
const fsHost = new node_2.NodeJsSyncHost(); | ||
const workspace = yield new core_1.experimental.workspace.Workspace(core_1.normalize(root), fsHost) | ||
@@ -69,3 +70,3 @@ .loadWorkspaceFromHost('workspace.json') | ||
registry.addPostTransform(core_1.schema.transforms.addUndefinedDefaults); | ||
const architectHost = new node_2.WorkspaceNodeModulesArchitectHost(workspace, root); | ||
const architectHost = new node_1.WorkspaceNodeModulesArchitectHost(workspace, root); | ||
const architect = new architect_1.Architect(architectHost, registry); | ||
@@ -81,3 +82,3 @@ const builderConf = yield architectHost.getBuilderNameForTarget({ | ||
if (opts.help) { | ||
printRunHelp(opts, flattenedSchema); | ||
printRunHelp(opts, flattenedSchema, logger); | ||
return 0; | ||
@@ -91,3 +92,3 @@ } | ||
configuration: opts.configuration | ||
}, runOptions, { logger: logger_1.logger }); | ||
}, runOptions, { logger }); | ||
const result = yield run.output.toPromise(); | ||
@@ -94,0 +95,0 @@ yield run.stop(); |
@@ -1,1 +0,2 @@ | ||
export declare const logger: import("@angular-devkit/core/src/logger").Logger; | ||
import { logging } from '@angular-devkit/core'; | ||
export declare const getLogger: (isVerbose?: boolean) => logging.Logger; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const core_1 = require("@angular-devkit/core"); | ||
const node_1 = require("@angular-devkit/core/node"); | ||
const core_1 = require("@angular-devkit/core"); | ||
exports.logger = node_1.createConsoleLogger(false, process.stdout, process.stderr, { | ||
warn: s => core_1.terminal.bold(core_1.terminal.yellow(s)), | ||
error: s => core_1.terminal.bold(core_1.terminal.red(s)), | ||
fatal: s => core_1.terminal.bold(core_1.terminal.red(s)) | ||
}); | ||
let logger; | ||
exports.getLogger = (isVerbose = false) => { | ||
if (!logger) { | ||
logger = node_1.createConsoleLogger(isVerbose, process.stdout, process.stderr, { | ||
warn: s => core_1.terminal.bold(core_1.terminal.yellow(s)), | ||
error: s => core_1.terminal.bold(core_1.terminal.red(s)), | ||
fatal: s => core_1.terminal.bold(core_1.terminal.red(s)) | ||
}); | ||
} | ||
return logger; | ||
}; |
@@ -9,3 +9,3 @@ import { logging } from '@angular-devkit/core'; | ||
}; | ||
export declare function handleErrors(logger: logging.Logger, fn: Function): Promise<any>; | ||
export declare function handleErrors(logger: logging.Logger, isVerbose: boolean, fn: Function): Promise<any>; | ||
export declare function convertToCamelCase(parsed: { | ||
@@ -12,0 +12,0 @@ [k: string]: any; |
@@ -12,3 +12,3 @@ "use strict"; | ||
const schematics_1 = require("@angular-devkit/schematics"); | ||
function handleErrors(logger, fn) { | ||
function handleErrors(logger, isVerbose, fn) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -25,2 +25,5 @@ try { | ||
} | ||
if (isVerbose && err.stack) { | ||
logger.info(err.stack); | ||
} | ||
return 1; | ||
@@ -27,0 +30,0 @@ } |
@@ -0,5 +1,6 @@ | ||
import { logging } from '@angular-devkit/core'; | ||
import { Schema } from './params'; | ||
export declare function printHelp(header: string, schema: Schema): void; | ||
export declare function printHelp(header: string, schema: Schema, logger: logging.Logger): void; | ||
export declare let commandName: string; | ||
export declare let toolDescription: string; | ||
export declare function setCommandNameAndDescription(name: string, description: string): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const logger_1 = require("./logger"); | ||
const core_1 = require("@angular-devkit/core"); | ||
const core_2 = require("@angular-devkit/core"); | ||
function printHelp(header, schema) { | ||
function printHelp(header, schema, logger) { | ||
const allPositional = Object.keys(schema.properties).filter(key => { | ||
@@ -19,6 +17,6 @@ const p = schema.properties[key]; | ||
.join('\n'); | ||
logger_1.logger.info(core_1.tags.stripIndent ` | ||
${core_2.terminal.bold(header + positional + ' [options,...]')} | ||
logger.info(core_1.tags.stripIndent ` | ||
${core_1.terminal.bold(header + positional + ' [options,...]')} | ||
${core_2.terminal.bold('Options')}: | ||
${core_1.terminal.bold('Options')}: | ||
${args} | ||
@@ -30,3 +28,3 @@ ${formatOption('help', 'Show available options for project target.')} | ||
function formatOption(name, description) { | ||
return ` --${(name + ' ').substr(0, 22)}${core_2.terminal.grey(description)}`; | ||
return ` --${(name + ' ').substr(0, 22)}${core_1.terminal.grey(description)}`; | ||
} | ||
@@ -33,0 +31,0 @@ exports.commandName = 'nx'; |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
73859
1505
1