@depup/nestjs__cli 11.0.24-depup.8 → 12.0.0-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -14
- package/actions/abstract.action.d.ts +1 -2
- package/actions/abstract.action.js +1 -5
- package/actions/add.action.d.ts +3 -4
- package/actions/add.action.js +44 -53
- package/actions/build.action.d.ts +18 -11
- package/actions/build.action.js +172 -79
- package/actions/deploy.action.d.ts +6 -0
- package/actions/deploy.action.js +51 -0
- package/actions/generate.action.d.ts +3 -3
- package/actions/generate.action.js +61 -59
- package/actions/index.d.ts +9 -7
- package/actions/index.js +9 -23
- package/actions/info.action.d.ts +18 -28
- package/actions/info.action.js +80 -60
- package/actions/new.action.d.ts +3 -3
- package/actions/new.action.js +108 -104
- package/actions/start.action.d.ts +4 -7
- package/actions/start.action.js +40 -47
- package/actions/upgrade.action.d.ts +6 -0
- package/actions/upgrade.action.js +53 -0
- package/bin/nest.js +11 -10
- package/changes.json +6 -38
- package/commands/abstract.command.d.ts +3 -3
- package/commands/abstract.command.js +2 -5
- package/commands/add.command.d.ts +3 -3
- package/commands/add.command.js +17 -20
- package/commands/build.command.d.ts +3 -3
- package/commands/build.command.js +52 -56
- package/commands/command.input.js +1 -2
- package/commands/command.loader.d.ts +2 -2
- package/commands/command.loader.js +29 -22
- package/commands/context/add.context.d.ts +7 -0
- package/commands/context/add.context.js +1 -0
- package/commands/context/build.context.d.ts +17 -0
- package/commands/context/build.context.js +1 -0
- package/commands/context/deploy.context.d.ts +7 -0
- package/commands/context/deploy.context.js +1 -0
- package/commands/context/generate.context.d.ts +18 -0
- package/commands/context/generate.context.js +1 -0
- package/commands/context/index.d.ts +7 -0
- package/commands/context/index.js +7 -0
- package/commands/context/new.context.d.ts +19 -0
- package/commands/context/new.context.js +1 -0
- package/commands/context/start.context.d.ts +22 -0
- package/commands/context/start.context.js +1 -0
- package/commands/context/upgrade.context.d.ts +11 -0
- package/commands/context/upgrade.context.js +1 -0
- package/commands/deploy.command.d.ts +5 -0
- package/commands/deploy.command.js +22 -0
- package/commands/generate.command.d.ts +3 -3
- package/commands/generate.command.js +35 -66
- package/commands/index.d.ts +3 -2
- package/commands/index.js +3 -18
- package/commands/info.command.d.ts +3 -3
- package/commands/info.command.js +4 -8
- package/commands/new.command.d.ts +3 -3
- package/commands/new.command.js +34 -36
- package/commands/start.command.d.ts +3 -3
- package/commands/start.command.js +48 -73
- package/commands/upgrade.command.d.ts +5 -0
- package/commands/upgrade.command.js +32 -0
- package/lib/compiler/assets-manager.d.ts +20 -8
- package/lib/compiler/assets-manager.js +199 -63
- package/lib/compiler/base-compiler.d.ts +5 -5
- package/lib/compiler/base-compiler.js +10 -13
- package/lib/compiler/compiler.d.ts +6 -6
- package/lib/compiler/compiler.js +7 -9
- package/lib/compiler/defaults/rspack-defaults.d.ts +3 -0
- package/lib/compiler/defaults/rspack-defaults.js +179 -0
- package/lib/compiler/defaults/swc-defaults.d.ts +5 -2
- package/lib/compiler/defaults/swc-defaults.js +22 -6
- package/lib/compiler/defaults/webpack-defaults.d.ts +2 -2
- package/lib/compiler/defaults/webpack-defaults.js +59 -19
- package/lib/compiler/helpers/append-extension.js +3 -6
- package/lib/compiler/helpers/copy-path-resolve.js +2 -5
- package/lib/compiler/helpers/delete-out-dir.d.ts +1 -1
- package/lib/compiler/helpers/delete-out-dir.js +45 -10
- package/lib/compiler/helpers/get-builder.d.ts +9 -7
- package/lib/compiler/helpers/get-builder.js +3 -6
- package/lib/compiler/helpers/get-effective-root-dir.d.ts +16 -0
- package/lib/compiler/helpers/get-effective-root-dir.js +56 -0
- package/lib/compiler/helpers/get-rspack-config-path.d.ts +10 -0
- package/lib/compiler/helpers/get-rspack-config-path.js +19 -0
- package/lib/compiler/helpers/get-tsc-config.path.d.ts +2 -3
- package/lib/compiler/helpers/get-tsc-config.path.js +6 -9
- package/lib/compiler/helpers/get-value-or-default.d.ts +2 -3
- package/lib/compiler/helpers/get-value-or-default.js +3 -8
- package/lib/compiler/helpers/get-webpack-config-path.d.ts +2 -3
- package/lib/compiler/helpers/get-webpack-config-path.js +4 -7
- package/lib/compiler/helpers/glob.d.ts +19 -0
- package/lib/compiler/helpers/glob.js +185 -0
- package/lib/compiler/helpers/manual-restart.js +4 -8
- package/lib/compiler/helpers/path-confinement.d.ts +33 -0
- package/lib/compiler/helpers/path-confinement.js +63 -0
- package/lib/compiler/helpers/tsconfig-provider.d.ts +7 -6
- package/lib/compiler/helpers/tsconfig-provider.js +32 -13
- package/lib/compiler/hooks/tsconfig-paths.hook.js +13 -13
- package/lib/compiler/interfaces/readonly-visitor.interface.js +1 -2
- package/lib/compiler/plugins/plugin-metadata-generator.d.ts +37 -1
- package/lib/compiler/plugins/plugin-metadata-generator.js +113 -13
- package/lib/compiler/plugins/plugin-metadata-printer.d.ts +1 -1
- package/lib/compiler/plugins/plugin-metadata-printer.js +5 -9
- package/lib/compiler/plugins/plugins-loader.d.ts +2 -2
- package/lib/compiler/plugins/plugins-loader.js +12 -12
- package/lib/compiler/rspack-compiler.d.ts +21 -0
- package/lib/compiler/rspack-compiler.js +111 -0
- package/lib/compiler/swc/constants.d.ts +0 -1
- package/lib/compiler/swc/constants.js +9 -13
- package/lib/compiler/swc/forked-type-checker.js +13 -18
- package/lib/compiler/swc/swc-compiler.d.ts +13 -6
- package/lib/compiler/swc/swc-compiler.js +116 -70
- package/lib/compiler/swc/type-checker-host.js +31 -24
- package/lib/compiler/typescript-loader.js +7 -9
- package/lib/compiler/watch-compiler.d.ts +5 -5
- package/lib/compiler/watch-compiler.js +13 -15
- package/lib/compiler/watchers/recursive-directory-watcher.d.ts +37 -0
- package/lib/compiler/watchers/recursive-directory-watcher.js +334 -0
- package/lib/compiler/webpack-compiler.d.ts +6 -7
- package/lib/compiler/webpack-compiler.js +46 -23
- package/lib/configuration/configuration.d.ts +16 -3
- package/lib/configuration/configuration.js +1 -2
- package/lib/configuration/configuration.loader.d.ts +1 -1
- package/lib/configuration/configuration.loader.js +1 -2
- package/lib/configuration/defaults.d.ts +2 -1
- package/lib/configuration/defaults.js +8 -10
- package/lib/configuration/index.d.ts +3 -3
- package/lib/configuration/index.js +3 -19
- package/lib/configuration/nest-configuration.loader.d.ts +3 -3
- package/lib/configuration/nest-configuration.loader.js +28 -29
- package/lib/package-managers/abstract.package-manager.d.ts +4 -4
- package/lib/package-managers/abstract.package-manager.js +21 -32
- package/lib/package-managers/bun.package-manager.d.ts +7 -0
- package/lib/package-managers/bun.package-manager.js +22 -0
- package/lib/package-managers/index.d.ts +9 -8
- package/lib/package-managers/index.js +9 -24
- package/lib/package-managers/npm.package-manager.d.ts +2 -2
- package/lib/package-managers/npm.package-manager.js +6 -10
- package/lib/package-managers/package-manager-commands.js +1 -2
- package/lib/package-managers/package-manager.d.ts +2 -1
- package/lib/package-managers/package-manager.factory.d.ts +2 -2
- package/lib/package-managers/package-manager.factory.js +23 -20
- package/lib/package-managers/package-manager.js +3 -5
- package/lib/package-managers/pnpm.package-manager.d.ts +2 -2
- package/lib/package-managers/pnpm.package-manager.js +6 -10
- package/lib/package-managers/project.dependency.js +1 -2
- package/lib/package-managers/yarn.package-manager.d.ts +2 -2
- package/lib/package-managers/yarn.package-manager.js +6 -10
- package/lib/questions/questions.d.ts +5 -1
- package/lib/questions/questions.js +2 -7
- package/lib/readers/file-system.reader.d.ts +1 -1
- package/lib/readers/file-system.reader.js +6 -9
- package/lib/readers/index.d.ts +2 -2
- package/lib/readers/index.js +2 -18
- package/lib/readers/reader.js +3 -5
- package/lib/runners/abstract.runner.js +40 -21
- package/lib/runners/bun.runner.d.ts +4 -0
- package/lib/runners/bun.runner.js +6 -0
- package/lib/runners/git.runner.d.ts +1 -1
- package/lib/runners/git.runner.js +2 -6
- package/lib/runners/index.d.ts +3 -3
- package/lib/runners/index.js +3 -19
- package/lib/runners/mau.runner.d.ts +8 -0
- package/lib/runners/mau.runner.js +10 -0
- package/lib/runners/npm.runner.d.ts +1 -1
- package/lib/runners/npm.runner.js +2 -6
- package/lib/runners/pnpm.runner.d.ts +1 -1
- package/lib/runners/pnpm.runner.js +2 -6
- package/lib/runners/runner.d.ts +2 -1
- package/lib/runners/runner.factory.d.ts +7 -6
- package/lib/runners/runner.factory.js +18 -20
- package/lib/runners/runner.js +3 -5
- package/lib/runners/schematic.runner.d.ts +1 -1
- package/lib/runners/schematic.runner.js +5 -7
- package/lib/runners/yarn.runner.d.ts +1 -1
- package/lib/runners/yarn.runner.js +2 -6
- package/lib/schematics/abstract.collection.d.ts +3 -3
- package/lib/schematics/abstract.collection.js +3 -5
- package/lib/schematics/collection.factory.d.ts +2 -2
- package/lib/schematics/collection.factory.js +9 -13
- package/lib/schematics/collection.js +2 -5
- package/lib/schematics/custom.collection.d.ts +2 -2
- package/lib/schematics/custom.collection.js +4 -8
- package/lib/schematics/index.d.ts +4 -4
- package/lib/schematics/index.js +4 -20
- package/lib/schematics/nest.collection.d.ts +3 -3
- package/lib/schematics/nest.collection.js +113 -109
- package/lib/schematics/schematic.option.js +10 -9
- package/lib/ui/banner.js +1 -4
- package/lib/ui/emojis.d.ts +17 -17
- package/lib/ui/emojis.js +19 -22
- package/lib/ui/errors.js +1 -4
- package/lib/ui/index.d.ts +5 -5
- package/lib/ui/index.js +5 -21
- package/lib/ui/messages.d.ts +8 -0
- package/lib/ui/messages.js +23 -18
- package/lib/ui/prefixes.js +3 -6
- package/lib/utils/extra-args-warning.js +3 -6
- package/lib/utils/formatting.js +1 -4
- package/lib/utils/get-default-tsconfig-path.js +4 -7
- package/lib/utils/gracefully-exit-on-prompt-error.js +1 -4
- package/lib/utils/is-esm-project.d.ts +5 -0
- package/lib/utils/is-esm-project.js +16 -0
- package/lib/utils/is-interactive.d.ts +8 -0
- package/lib/utils/is-interactive.js +10 -0
- package/lib/utils/is-module-available.js +3 -4
- package/lib/utils/load-configuration.d.ts +1 -1
- package/lib/utils/load-configuration.js +4 -7
- package/lib/utils/local-binaries.d.ts +2 -2
- package/lib/utils/local-binaries.js +8 -11
- package/lib/utils/mau.d.ts +14 -0
- package/lib/utils/mau.js +46 -0
- package/lib/utils/os-info.utils.js +1 -4
- package/lib/utils/project-utils.d.ts +1 -3
- package/lib/utils/project-utils.js +16 -28
- package/lib/utils/remaining-flags.d.ts +2 -2
- package/lib/utils/remaining-flags.js +13 -8
- package/lib/utils/tree-kill.js +7 -10
- package/lib/utils/type-assertions.js +1 -4
- package/package.json +64 -77
package/commands/add.command.js
CHANGED
|
@@ -1,36 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const remaining_flags_1 = require("../lib/utils/remaining-flags");
|
|
5
|
-
const abstract_command_1 = require("./abstract.command");
|
|
6
|
-
class AddCommand extends abstract_command_1.AbstractCommand {
|
|
1
|
+
import { getRemainingFlags } from '../lib/utils/remaining-flags.js';
|
|
2
|
+
import { AbstractCommand } from './abstract.command.js';
|
|
3
|
+
export class AddCommand extends AbstractCommand {
|
|
7
4
|
load(program) {
|
|
8
5
|
program
|
|
9
6
|
.command('add <library>')
|
|
10
7
|
.allowUnknownOption()
|
|
8
|
+
// Unknown options are collected into `args`, which commander otherwise
|
|
9
|
+
// rejects as excess arguments — that would break the documented
|
|
10
|
+
// library-specific options this command forwards via `extraFlags`.
|
|
11
|
+
.allowExcessArguments()
|
|
11
12
|
.description('Adds support for an external library to your project.')
|
|
12
13
|
.option('-d, --dry-run', 'Report actions that would be performed without writing out results.')
|
|
13
14
|
.option('-s, --skip-install', 'Skip package installation.', false)
|
|
14
15
|
.option('-p, --project [project]', 'Project in which to generate files.')
|
|
15
16
|
.usage('<library> [options] [library-specific-options]')
|
|
16
|
-
.action(async (library,
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
const inputs = [];
|
|
25
|
-
inputs.push({ name: 'library', value: library });
|
|
26
|
-
const flags = (0, remaining_flags_1.getRemainingFlags)(program);
|
|
17
|
+
.action(async (library, options) => {
|
|
18
|
+
const context = {
|
|
19
|
+
library,
|
|
20
|
+
dryRun: !!options.dryRun,
|
|
21
|
+
skipInstall: options.skipInstall,
|
|
22
|
+
project: options.project,
|
|
23
|
+
extraFlags: getRemainingFlags(program),
|
|
24
|
+
};
|
|
27
25
|
try {
|
|
28
|
-
await this.action.handle(
|
|
26
|
+
await this.action.handle(context);
|
|
29
27
|
}
|
|
30
|
-
catch
|
|
28
|
+
catch {
|
|
31
29
|
process.exit(1);
|
|
32
30
|
}
|
|
33
31
|
});
|
|
34
32
|
}
|
|
35
33
|
}
|
|
36
|
-
exports.AddCommand = AddCommand;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AbstractCommand } from './abstract.command';
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { AbstractCommand } from './abstract.command.js';
|
|
3
3
|
export declare class BuildCommand extends AbstractCommand {
|
|
4
|
-
load(program:
|
|
4
|
+
load(program: Command): void;
|
|
5
5
|
}
|
|
@@ -1,74 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const ui_1 = require("../lib/ui");
|
|
5
|
-
const abstract_command_1 = require("./abstract.command");
|
|
6
|
-
class BuildCommand extends abstract_command_1.AbstractCommand {
|
|
1
|
+
import { ERROR_PREFIX } from '../lib/ui/index.js';
|
|
2
|
+
import { AbstractCommand } from './abstract.command.js';
|
|
3
|
+
export class BuildCommand extends AbstractCommand {
|
|
7
4
|
load(program) {
|
|
8
5
|
program
|
|
9
6
|
.command('build [apps...]')
|
|
10
7
|
.option('-c, --config [path]', 'Path to nest-cli configuration file.')
|
|
11
8
|
.option('-p, --path [path]', 'Path to tsconfig file.')
|
|
12
9
|
.option('-w, --watch', 'Run in watch mode (live-reload).')
|
|
13
|
-
.option('-b, --builder [name]', 'Builder to be used (tsc, webpack, swc).')
|
|
10
|
+
.option('-b, --builder [name]', 'Builder to be used (tsc, webpack, swc, rspack).')
|
|
14
11
|
.option('--watchAssets', 'Watch non-ts (e.g., .graphql) files mode.')
|
|
15
12
|
.option('--webpack', 'Use webpack for compilation (deprecated option, use --builder instead).')
|
|
16
|
-
.option('--type-check', 'Enable type checking (when SWC is used).')
|
|
13
|
+
.option('--type-check', 'Enable type checking (when SWC is used).', () => true)
|
|
14
|
+
.option('--no-type-check', 'Disable type checking (when SWC is used).', () => false)
|
|
15
|
+
.option('--emit-declarations', 'Emit declaration files (.d.ts) when using SWC builder.')
|
|
16
|
+
.option('--silent', 'Suppress informational compiler logs.')
|
|
17
17
|
.option('--webpackPath [path]', 'Path to webpack configuration.')
|
|
18
|
+
.option('--rspackPath [path]', 'Path to rspack configuration.')
|
|
18
19
|
.option('--tsc', 'Use typescript compiler for compilation.')
|
|
19
20
|
.option('--preserveWatchOutput', 'Use "preserveWatchOutput" option when using tsc watch mode.')
|
|
20
21
|
.option('--all', 'Build all projects in a monorepo.')
|
|
22
|
+
.option('--parallel [concurrency]', 'Build projects in parallel (with --all). Optionally limit concurrency.')
|
|
21
23
|
.description('Build Nest application.')
|
|
22
|
-
.action(async (apps,
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
options.push({ name: 'webpack', value: isWebpackEnabled });
|
|
30
|
-
options.push({ name: 'watch', value: !!command.watch });
|
|
31
|
-
options.push({ name: 'watchAssets', value: !!command.watchAssets });
|
|
32
|
-
options.push({
|
|
33
|
-
name: 'path',
|
|
34
|
-
value: command.path,
|
|
35
|
-
});
|
|
36
|
-
options.push({
|
|
37
|
-
name: 'webpackPath',
|
|
38
|
-
value: command.webpackPath,
|
|
39
|
-
});
|
|
40
|
-
const availableBuilders = ['tsc', 'webpack', 'swc'];
|
|
41
|
-
if (command.builder && !availableBuilders.includes(command.builder)) {
|
|
42
|
-
console.error(ui_1.ERROR_PREFIX +
|
|
43
|
-
` Invalid builder option: ${command.builder}. Available builders: ${availableBuilders.join(', ')}`);
|
|
44
|
-
return;
|
|
24
|
+
.action(async (apps, options) => {
|
|
25
|
+
const isWebpackEnabled = options.tsc ? false : options.webpack;
|
|
26
|
+
const availableBuilders = ['tsc', 'webpack', 'swc', 'rspack'];
|
|
27
|
+
if (options.builder && !availableBuilders.includes(options.builder)) {
|
|
28
|
+
console.error(ERROR_PREFIX +
|
|
29
|
+
` Invalid builder option: ${options.builder}. Available builders: ${availableBuilders.join(', ')}`);
|
|
30
|
+
process.exit(1);
|
|
45
31
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
value
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
});
|
|
60
|
-
options.push({ name: 'all', value: !!command.all });
|
|
61
|
-
const inputs = apps.map((app) => ({
|
|
62
|
-
name: 'app',
|
|
63
|
-
value: app,
|
|
64
|
-
}));
|
|
65
|
-
// Handle the default project for `nest build` with no args
|
|
66
|
-
// The action instance will pick up the default project when value is `undefined`
|
|
67
|
-
if (inputs.length === 0) {
|
|
68
|
-
inputs.push({ name: 'app', value: undefined });
|
|
32
|
+
let parallel;
|
|
33
|
+
if (options.parallel === true || options.parallel === undefined) {
|
|
34
|
+
// `--parallel` with no value means unlimited; absent means sequential.
|
|
35
|
+
parallel = options.parallel;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
const parsed = parseInt(options.parallel, 10);
|
|
39
|
+
if (!Number.isFinite(parsed) || parsed < 1) {
|
|
40
|
+
console.error(ERROR_PREFIX +
|
|
41
|
+
` Invalid --parallel value: "${options.parallel}". Expected a positive integer (e.g. --parallel 4) or no value for unlimited concurrency.`);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
parallel = parsed;
|
|
69
45
|
}
|
|
70
|
-
|
|
46
|
+
const context = {
|
|
47
|
+
apps: apps.length > 0 ? apps : [],
|
|
48
|
+
config: options.config,
|
|
49
|
+
webpack: isWebpackEnabled,
|
|
50
|
+
watch: !!options.watch,
|
|
51
|
+
watchAssets: !!options.watchAssets,
|
|
52
|
+
path: options.path,
|
|
53
|
+
webpackPath: options.webpackPath,
|
|
54
|
+
rspackPath: options.rspackPath,
|
|
55
|
+
builder: options.builder,
|
|
56
|
+
typeCheck: options.typeCheck,
|
|
57
|
+
// Left undefined when the flag is absent so `getValueOrDefault` can
|
|
58
|
+
// still fall through to `compilerOptions.emitDeclarations`.
|
|
59
|
+
emitDeclarations: options.emitDeclarations,
|
|
60
|
+
silent: !!options.silent,
|
|
61
|
+
preserveWatchOutput: !!options.preserveWatchOutput &&
|
|
62
|
+
!!options.watch &&
|
|
63
|
+
!isWebpackEnabled,
|
|
64
|
+
all: !!options.all,
|
|
65
|
+
parallel,
|
|
66
|
+
};
|
|
67
|
+
await this.action.handle(context);
|
|
71
68
|
});
|
|
72
69
|
}
|
|
73
70
|
}
|
|
74
|
-
exports.BuildCommand = BuildCommand;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Command } from 'commander';
|
|
2
2
|
export declare class CommandLoader {
|
|
3
|
-
static load(program:
|
|
3
|
+
static load(program: Command): Promise<void>;
|
|
4
4
|
private static handleInvalidCommand;
|
|
5
5
|
}
|
|
@@ -1,31 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class CommandLoader {
|
|
1
|
+
import { red } from 'ansis';
|
|
2
|
+
import { AddAction, BuildAction, DeployAction, GenerateAction, InfoAction, NewAction, StartAction, UpgradeAction, } from '../actions/index.js';
|
|
3
|
+
import { ERROR_PREFIX } from '../lib/ui/index.js';
|
|
4
|
+
import { AddCommand } from './add.command.js';
|
|
5
|
+
import { BuildCommand } from './build.command.js';
|
|
6
|
+
import { DeployCommand } from './deploy.command.js';
|
|
7
|
+
import { GenerateCommand } from './generate.command.js';
|
|
8
|
+
import { InfoCommand } from './info.command.js';
|
|
9
|
+
import { NewCommand } from './new.command.js';
|
|
10
|
+
import { StartCommand } from './start.command.js';
|
|
11
|
+
import { UpgradeCommand } from './upgrade.command.js';
|
|
12
|
+
export class CommandLoader {
|
|
14
13
|
static async load(program) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
if (!program.__nestCliEsm) {
|
|
15
|
+
console.error(`\n${ERROR_PREFIX} The globally installed ${red('@nestjs/cli')} is outdated and ` +
|
|
16
|
+
'incompatible with the local version (which requires ESM).\n' +
|
|
17
|
+
'Please upgrade your global installation:\n\n' +
|
|
18
|
+
` ${red('npm i -g @nestjs/cli')}\n`);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
new NewCommand(new NewAction()).load(program);
|
|
22
|
+
new BuildCommand(new BuildAction()).load(program);
|
|
23
|
+
new StartCommand(new StartAction()).load(program);
|
|
24
|
+
new InfoCommand(new InfoAction()).load(program);
|
|
25
|
+
new AddCommand(new AddAction()).load(program);
|
|
26
|
+
new DeployCommand(new DeployAction()).load(program);
|
|
27
|
+
new UpgradeCommand(new UpgradeAction()).load(program);
|
|
28
|
+
await new GenerateCommand(new GenerateAction()).load(program);
|
|
21
29
|
this.handleInvalidCommand(program);
|
|
22
30
|
}
|
|
23
31
|
static handleInvalidCommand(program) {
|
|
24
32
|
program.on('command:*', () => {
|
|
25
|
-
console.error(`\n${
|
|
26
|
-
console.
|
|
33
|
+
console.error(`\n${ERROR_PREFIX} Invalid command: ${red `%s`}`, program.args.join(' '));
|
|
34
|
+
console.error(`See ${red `--help`} for a list of available commands.\n`);
|
|
27
35
|
process.exit(1);
|
|
28
36
|
});
|
|
29
37
|
}
|
|
30
38
|
}
|
|
31
|
-
exports.CommandLoader = CommandLoader;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface BuildCommandContext {
|
|
2
|
+
apps: string[];
|
|
3
|
+
config?: string;
|
|
4
|
+
webpack?: boolean;
|
|
5
|
+
watch: boolean;
|
|
6
|
+
watchAssets: boolean;
|
|
7
|
+
path?: string;
|
|
8
|
+
webpackPath?: string;
|
|
9
|
+
rspackPath?: string;
|
|
10
|
+
builder?: string;
|
|
11
|
+
typeCheck?: boolean;
|
|
12
|
+
emitDeclarations?: boolean;
|
|
13
|
+
silent?: boolean;
|
|
14
|
+
preserveWatchOutput: boolean;
|
|
15
|
+
all: boolean;
|
|
16
|
+
parallel?: number | boolean;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface GenerateCommandContext {
|
|
2
|
+
schematic: string;
|
|
3
|
+
name?: string;
|
|
4
|
+
path?: string;
|
|
5
|
+
dryRun: boolean;
|
|
6
|
+
flat?: boolean;
|
|
7
|
+
spec: boolean | {
|
|
8
|
+
value: boolean;
|
|
9
|
+
passedAsInput: boolean;
|
|
10
|
+
};
|
|
11
|
+
specFileSuffix?: string;
|
|
12
|
+
collection?: string;
|
|
13
|
+
project?: string;
|
|
14
|
+
skipImport: boolean;
|
|
15
|
+
format: boolean;
|
|
16
|
+
type?: string;
|
|
17
|
+
crud?: boolean;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface NewCommandContext {
|
|
2
|
+
name?: string;
|
|
3
|
+
directory?: string;
|
|
4
|
+
dryRun: boolean;
|
|
5
|
+
skipGit: boolean;
|
|
6
|
+
skipInstall: boolean;
|
|
7
|
+
skipTests: boolean;
|
|
8
|
+
packageManager?: string;
|
|
9
|
+
language: string;
|
|
10
|
+
collection: string;
|
|
11
|
+
strict: boolean;
|
|
12
|
+
format: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Whether to auto-configure `@nestjs/observe`. Left `undefined` when the
|
|
15
|
+
* user passed neither `--observe` nor `--no-observe`, so the action knows it
|
|
16
|
+
* still has to ask.
|
|
17
|
+
*/
|
|
18
|
+
observe?: boolean;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface StartCommandContext {
|
|
2
|
+
app?: string;
|
|
3
|
+
config?: string;
|
|
4
|
+
webpack?: boolean;
|
|
5
|
+
watch: boolean;
|
|
6
|
+
watchAssets: boolean;
|
|
7
|
+
path?: string;
|
|
8
|
+
webpackPath?: string;
|
|
9
|
+
rspackPath?: string;
|
|
10
|
+
builder?: string;
|
|
11
|
+
typeCheck?: boolean;
|
|
12
|
+
emitDeclarations?: boolean;
|
|
13
|
+
silent?: boolean;
|
|
14
|
+
preserveWatchOutput: boolean;
|
|
15
|
+
debug?: boolean | string;
|
|
16
|
+
exec?: string;
|
|
17
|
+
sourceRoot?: string;
|
|
18
|
+
entryFile?: string;
|
|
19
|
+
shell: boolean;
|
|
20
|
+
envFile: string[];
|
|
21
|
+
extraFlags: string[];
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface UpgradeCommandContext {
|
|
2
|
+
dryRun: boolean;
|
|
3
|
+
skipInstall: boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Tri-state on purpose: `undefined` means neither `--observe` nor
|
|
6
|
+
* `--no-observe` was passed, which lets the schematic's own `x-prompt` ask.
|
|
7
|
+
*/
|
|
8
|
+
observe?: boolean;
|
|
9
|
+
tag?: string;
|
|
10
|
+
collection?: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AbstractCommand } from './abstract.command.js';
|
|
2
|
+
export class DeployCommand extends AbstractCommand {
|
|
3
|
+
load(program) {
|
|
4
|
+
program
|
|
5
|
+
.command('deploy')
|
|
6
|
+
// Every option belongs to `mau deploy`, so nothing is claimed here and
|
|
7
|
+
// whatever the user typed is passed straight through.
|
|
8
|
+
.allowUnknownOption()
|
|
9
|
+
.allowExcessArguments()
|
|
10
|
+
.usage('[mau-options]')
|
|
11
|
+
.description('Deploy your application to the cloud (powered by Mau).')
|
|
12
|
+
.action(async (_options, command) => {
|
|
13
|
+
const context = { args: command.args };
|
|
14
|
+
try {
|
|
15
|
+
await this.action.handle(context);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AbstractCommand } from './abstract.command';
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { AbstractCommand } from './abstract.command.js';
|
|
3
3
|
export declare class GenerateCommand extends AbstractCommand {
|
|
4
|
-
load(program:
|
|
4
|
+
load(program: Command): Promise<void>;
|
|
5
5
|
private buildDescription;
|
|
6
6
|
private buildSchematicsListAsTable;
|
|
7
7
|
private getCollection;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const extra_args_warning_1 = require("../lib/utils/extra-args-warning");
|
|
8
|
-
const load_configuration_1 = require("../lib/utils/load-configuration");
|
|
9
|
-
const abstract_command_1 = require("./abstract.command");
|
|
10
|
-
class GenerateCommand extends abstract_command_1.AbstractCommand {
|
|
1
|
+
import { bold, cyan, green } from 'ansis';
|
|
2
|
+
import Table from 'cli-table3';
|
|
3
|
+
import { CollectionFactory, } from '../lib/schematics/index.js';
|
|
4
|
+
import { loadConfiguration } from '../lib/utils/load-configuration.js';
|
|
5
|
+
import { AbstractCommand } from './abstract.command.js';
|
|
6
|
+
export class GenerateCommand extends AbstractCommand {
|
|
11
7
|
async load(program) {
|
|
12
8
|
program
|
|
13
9
|
.command('generate <schematic> [name] [path]')
|
|
@@ -19,70 +15,44 @@ class GenerateCommand extends abstract_command_1.AbstractCommand {
|
|
|
19
15
|
.option('--no-flat', 'Enforce that directories are generated.', () => false)
|
|
20
16
|
.option('--spec', 'Enforce spec files generation.', () => {
|
|
21
17
|
return { value: true, passedAsInput: true };
|
|
22
|
-
}, true)
|
|
18
|
+
}, { value: true, passedAsInput: false })
|
|
23
19
|
.option('--spec-file-suffix [suffix]', 'Use a custom suffix for spec files.')
|
|
24
20
|
.option('--skip-import', 'Skip importing', () => true, false)
|
|
21
|
+
.option('--format', 'Format generated files using Prettier.', false)
|
|
25
22
|
.option('--no-spec', 'Disable spec files generation.', () => {
|
|
26
23
|
return { value: false, passedAsInput: true };
|
|
27
24
|
})
|
|
28
25
|
.option('-c, --collection [collectionName]', 'Schematics collection to use.')
|
|
29
26
|
.option('--type <type>', 'Transport layer type (rest, graphql, microservice)')
|
|
30
27
|
.option('--crud [value]', 'Generate CRUD entry points')
|
|
31
|
-
.action(async (schematic, name, path,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
options.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
options.push({
|
|
54
|
-
name: 'collection',
|
|
55
|
-
value: command.collection,
|
|
56
|
-
});
|
|
57
|
-
options.push({
|
|
58
|
-
name: 'project',
|
|
59
|
-
value: command.project,
|
|
60
|
-
});
|
|
61
|
-
options.push({
|
|
62
|
-
name: 'skipImport',
|
|
63
|
-
value: command.skipImport,
|
|
64
|
-
});
|
|
65
|
-
options.push({
|
|
66
|
-
name: 'type',
|
|
67
|
-
value: command.type,
|
|
68
|
-
});
|
|
69
|
-
if (command.crud !== undefined) {
|
|
70
|
-
options.push({
|
|
71
|
-
name: 'crud',
|
|
72
|
-
value: command.crud === true || command.crud === 'true',
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
const inputs = [];
|
|
76
|
-
inputs.push({ name: 'schematic', value: schematic });
|
|
77
|
-
inputs.push({ name: 'name', value: name });
|
|
78
|
-
inputs.push({ name: 'path', value: path });
|
|
79
|
-
await this.action.handle(inputs, options);
|
|
28
|
+
.action(async (schematic, name, path, options) => {
|
|
29
|
+
const context = {
|
|
30
|
+
schematic,
|
|
31
|
+
name,
|
|
32
|
+
path,
|
|
33
|
+
dryRun: !!options.dryRun,
|
|
34
|
+
flat: options.flat,
|
|
35
|
+
spec: options.spec,
|
|
36
|
+
specFileSuffix: options.specFileSuffix,
|
|
37
|
+
collection: options.collection,
|
|
38
|
+
project: options.project,
|
|
39
|
+
skipImport: options.skipImport,
|
|
40
|
+
format: options.format === true,
|
|
41
|
+
type: options.type,
|
|
42
|
+
// `--crud [value]` yields a string whenever a value is supplied,
|
|
43
|
+
// so `--crud false` must still be forwarded (as false) rather than
|
|
44
|
+
// dropped, which would let the schematic apply its own default.
|
|
45
|
+
crud: options.crud === undefined
|
|
46
|
+
? undefined
|
|
47
|
+
: options.crud === true || options.crud === 'true',
|
|
48
|
+
};
|
|
49
|
+
await this.action.handle(context);
|
|
80
50
|
});
|
|
81
51
|
}
|
|
82
52
|
async buildDescription() {
|
|
83
53
|
const collection = await this.getCollection();
|
|
84
54
|
return ('Generate a Nest element.\n' +
|
|
85
|
-
` Schematics available on ${
|
|
55
|
+
` Schematics available on ${bold(collection)} collection:\n` +
|
|
86
56
|
this.buildSchematicsListAsTable(await this.getSchematics(collection)));
|
|
87
57
|
}
|
|
88
58
|
buildSchematicsListAsTable(schematics) {
|
|
@@ -102,20 +72,19 @@ class GenerateCommand extends abstract_command_1.AbstractCommand {
|
|
|
102
72
|
const table = new Table(tableConfig);
|
|
103
73
|
for (const schematic of schematics) {
|
|
104
74
|
table.push([
|
|
105
|
-
|
|
106
|
-
|
|
75
|
+
green(schematic.name),
|
|
76
|
+
cyan(schematic.alias),
|
|
107
77
|
schematic.description,
|
|
108
78
|
]);
|
|
109
79
|
}
|
|
110
80
|
return table.toString();
|
|
111
81
|
}
|
|
112
82
|
async getCollection() {
|
|
113
|
-
const configuration = await
|
|
83
|
+
const configuration = await loadConfiguration();
|
|
114
84
|
return configuration.collection;
|
|
115
85
|
}
|
|
116
86
|
async getSchematics(collection) {
|
|
117
|
-
const abstractCollection =
|
|
87
|
+
const abstractCollection = CollectionFactory.create(collection);
|
|
118
88
|
return abstractCollection.getSchematics();
|
|
119
89
|
}
|
|
120
90
|
}
|
|
121
|
-
exports.GenerateCommand = GenerateCommand;
|
package/commands/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export * from './command.
|
|
2
|
-
export * from './command.
|
|
1
|
+
export * from './command.input.js';
|
|
2
|
+
export * from './command.loader.js';
|
|
3
|
+
export * from './context/index.js';
|
package/commands/index.js
CHANGED
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./command.loader"), exports);
|
|
18
|
-
__exportStar(require("./command.input"), exports);
|
|
1
|
+
export * from './command.input.js';
|
|
2
|
+
export * from './command.loader.js';
|
|
3
|
+
export * from './context/index.js';
|