rman 0.36.3 → 0.37.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.
Files changed (78) hide show
  1. package/{esm/commands → commands}/build-command.js +2 -1
  2. package/{esm/commands → commands}/changed-command.js +2 -1
  3. package/{esm/commands → commands}/ci-command.js +2 -1
  4. package/{esm/commands → commands}/execute-command.js +4 -1
  5. package/{esm/commands → commands}/info-command.js +1 -1
  6. package/{esm/commands → commands}/list-command.js +2 -1
  7. package/{esm/commands → commands}/multi-task-command.js +2 -0
  8. package/{types/commands → commands}/publish-command.d.ts +1 -0
  9. package/{esm/commands → commands}/publish-command.js +7 -1
  10. package/{esm/commands → commands}/run-command.js +3 -1
  11. package/{esm/commands → commands}/version-command.js +4 -2
  12. package/{esm/core → core}/command.js +5 -3
  13. package/{esm/core → core}/package.js +3 -1
  14. package/{types/core → core}/repository.d.ts +2 -1
  15. package/{esm/core → core}/repository.js +22 -9
  16. package/package.json +16 -33
  17. package/{esm/utils → utils}/git-utils.js +1 -0
  18. package/{esm/utils → utils}/npm-utils.js +2 -0
  19. package/cjs/cli.js +0 -71
  20. package/cjs/commands/build-command.js +0 -27
  21. package/cjs/commands/changed-command.js +0 -35
  22. package/cjs/commands/ci-command.js +0 -72
  23. package/cjs/commands/execute-command.js +0 -74
  24. package/cjs/commands/info-command.js +0 -60
  25. package/cjs/commands/list-command.js +0 -138
  26. package/cjs/commands/multi-task-command.js +0 -68
  27. package/cjs/commands/publish-command.js +0 -130
  28. package/cjs/commands/run-command.js +0 -134
  29. package/cjs/commands/version-command.js +0 -198
  30. package/cjs/core/command.js +0 -119
  31. package/cjs/core/constants.js +0 -5
  32. package/cjs/core/logger.js +0 -5
  33. package/cjs/core/package.js +0 -42
  34. package/cjs/core/repository.js +0 -139
  35. package/cjs/index.js +0 -4
  36. package/cjs/package.json +0 -3
  37. package/cjs/tsconfig-build-cjs.tsbuildinfo +0 -1
  38. package/cjs/utils/exec.js +0 -109
  39. package/cjs/utils/file-utils.js +0 -34
  40. package/cjs/utils/get-dirname.js +0 -31
  41. package/cjs/utils/git-utils.js +0 -70
  42. package/cjs/utils/npm-run-path.js +0 -68
  43. package/cjs/utils/npm-utils.js +0 -36
  44. package/cjs/utils/package-not-found-error.js +0 -6
  45. package/esm/package.json +0 -3
  46. package/esm/tsconfig-build-esm.tsbuildinfo +0 -1
  47. package/types/index.d.cts +0 -1
  48. /package/{types/cli.d.ts → cli.d.ts} +0 -0
  49. /package/{esm/cli.js → cli.js} +0 -0
  50. /package/{types/commands → commands}/build-command.d.ts +0 -0
  51. /package/{types/commands → commands}/changed-command.d.ts +0 -0
  52. /package/{types/commands → commands}/ci-command.d.ts +0 -0
  53. /package/{types/commands → commands}/execute-command.d.ts +0 -0
  54. /package/{types/commands → commands}/info-command.d.ts +0 -0
  55. /package/{types/commands → commands}/list-command.d.ts +0 -0
  56. /package/{types/commands → commands}/multi-task-command.d.ts +0 -0
  57. /package/{types/commands → commands}/run-command.d.ts +0 -0
  58. /package/{types/commands → commands}/version-command.d.ts +0 -0
  59. /package/{types/core → core}/command.d.ts +0 -0
  60. /package/{types/core → core}/constants.d.ts +0 -0
  61. /package/{esm/core → core}/constants.js +0 -0
  62. /package/{types/core → core}/logger.d.ts +0 -0
  63. /package/{esm/core → core}/logger.js +0 -0
  64. /package/{types/core → core}/package.d.ts +0 -0
  65. /package/{types/index.d.ts → index.d.ts} +0 -0
  66. /package/{esm/index.js → index.js} +0 -0
  67. /package/{types/utils → utils}/exec.d.ts +0 -0
  68. /package/{esm/utils → utils}/exec.js +0 -0
  69. /package/{types/utils → utils}/file-utils.d.ts +0 -0
  70. /package/{esm/utils → utils}/file-utils.js +0 -0
  71. /package/{types/utils → utils}/get-dirname.d.ts +0 -0
  72. /package/{esm/utils → utils}/get-dirname.js +0 -0
  73. /package/{types/utils → utils}/git-utils.d.ts +0 -0
  74. /package/{types/utils → utils}/npm-run-path.d.ts +0 -0
  75. /package/{esm/utils → utils}/npm-run-path.js +0 -0
  76. /package/{types/utils → utils}/npm-utils.d.ts +0 -0
  77. /package/{types/utils → utils}/package-not-found-error.d.ts +0 -0
  78. /package/{esm/utils → utils}/package-not-found-error.js +0 -0
@@ -1,74 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExecuteCommand = void 0;
4
- const tslib_1 = require("tslib");
5
- const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
6
- const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
7
- const power_tasks_1 = require("power-tasks");
8
- const command_js_1 = require("../core/command.js");
9
- const exec_js_1 = require("../utils/exec.js");
10
- const multi_task_command_js_1 = require("./multi-task-command.js");
11
- class ExecuteCommand extends multi_task_command_js_1.MultiTaskCommand {
12
- constructor(repository, cmd, argv, options) {
13
- super(repository, options);
14
- this.repository = repository;
15
- this.cmd = cmd;
16
- this.argv = argv;
17
- }
18
- _prepareTasks(packages) {
19
- const tasks = [];
20
- for (const p of packages) {
21
- const task = new power_tasks_1.Task(async () => {
22
- const t = Date.now();
23
- npmlog_1.default.verbose(this.commandName, p.name, ansi_colors_1.default.cyanBright.bold('executing'), npmlog_1.default.separator, this.cmd + ' ' + (this.argv?.join(' ') || ''));
24
- const r = await (0, exec_js_1.exec)(this.cmd, {
25
- cwd: p.dirname,
26
- argv: this.argv,
27
- stdio: npmlog_1.default.levelIndex < 1000 ? 'inherit' : 'pipe',
28
- });
29
- npmlog_1.default.log(r.error ? 'error' : 'info', this.commandName, p.name, r.error ? ansi_colors_1.default.red.bold('failed') : ansi_colors_1.default.green.bold('success'), npmlog_1.default.separator, this.cmd, ansi_colors_1.default.yellow(' (' + (Date.now() - t) + ' ms') + ')');
30
- }, {
31
- name: p.name,
32
- dependencies: this.options.parallel ? undefined : p.dependencies,
33
- bail: this.options.bail,
34
- concurrency: this.options.concurrency,
35
- });
36
- tasks.push(task);
37
- }
38
- return tasks;
39
- }
40
- }
41
- exports.ExecuteCommand = ExecuteCommand;
42
- ExecuteCommand.commandName = 'exec';
43
- (function (ExecuteCommand) {
44
- ExecuteCommand.cliCommandOptions = {
45
- ...multi_task_command_js_1.MultiTaskCommand.cliCommandOptions,
46
- };
47
- function initCli(repository, program) {
48
- program.command({
49
- command: 'exec [cmd] [args..]',
50
- describe: 'Execute an arbitrary command in each package',
51
- builder: cmd => cmd
52
- .example('$0 exec -- ls', '')
53
- .example('$0 exec -- rm -rf ./node_modules', '')
54
- .parserConfiguration({
55
- 'populate--': true,
56
- })
57
- .positional('cmd', {
58
- describe: 'The command to execute. Any command flags must be passed after --',
59
- type: 'string',
60
- })
61
- .positional('args', {
62
- describe: 'Positional arguments to send to command',
63
- type: 'string',
64
- })
65
- .option(ExecuteCommand.cliCommandOptions),
66
- handler: async (args) => {
67
- const argv = args['--'] || [];
68
- const options = command_js_1.Command.composeOptions(ExecuteCommand.commandName, args, repository.config);
69
- await new ExecuteCommand(repository, '' + argv.shift(), argv, options).execute();
70
- },
71
- });
72
- }
73
- ExecuteCommand.initCli = initCli;
74
- })(ExecuteCommand || (exports.ExecuteCommand = ExecuteCommand = {}));
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InfoCommand = void 0;
4
- const tslib_1 = require("tslib");
5
- const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
6
- const envinfo_1 = tslib_1.__importDefault(require("envinfo"));
7
- const semver_1 = tslib_1.__importDefault(require("semver"));
8
- const command_js_1 = require("../core/command.js");
9
- class InfoCommand extends command_js_1.Command {
10
- async _execute() {
11
- const systemInfo = JSON.parse(await envinfo_1.default.run({
12
- System: ['OS', 'CPU', 'Memory', 'Shell'],
13
- Binaries: ['Node', 'Yarn', 'npm'],
14
- Utilities: ['Git'],
15
- npmPackages: ['rman', 'typescript'],
16
- npmGlobalPackages: ['typescript'],
17
- }, { json: true }));
18
- if (this.options.json) {
19
- this.logger.output('', '%j', systemInfo);
20
- return;
21
- }
22
- const maxName = Object.keys(systemInfo).reduce((l, p) => Object.keys(systemInfo[p]).reduce((i, x) => (l = Math.max(i, x.length)), l), 0);
23
- for (const [categoryName, category] of Object.entries(systemInfo)) {
24
- this.logger.output('', '', ansi_colors_1.default.whiteBright(categoryName) + ':');
25
- for (const [n, v] of Object.entries(category)) {
26
- const label = ' ' + ansi_colors_1.default.reset(n) + ' '.repeat(maxName - n.length) + ' :';
27
- if (typeof v === 'string') {
28
- this.logger.output('', label, ansi_colors_1.default.yellowBright(v));
29
- continue;
30
- }
31
- if (v.version) {
32
- this.logger.output('', label, ansi_colors_1.default.yellowBright(v.version), v.path ? ' ' + ansi_colors_1.default.yellow(v.path) : '');
33
- }
34
- if (v.installed) {
35
- if (v.wanted === 'latest' || semver_1.default.intersects(v.installed, v.wanted)) {
36
- this.logger.output('', label, ansi_colors_1.default.yellowBright(v.installed));
37
- }
38
- else
39
- this.logger.output('', label, ansi_colors_1.default.red(v.installed), ' => ', ansi_colors_1.default.yellowBright(v.wanted));
40
- }
41
- }
42
- }
43
- }
44
- }
45
- exports.InfoCommand = InfoCommand;
46
- InfoCommand.commandName = 'info';
47
- (function (InfoCommand) {
48
- function initCli(repository, program) {
49
- program.command({
50
- command: 'info [options...]',
51
- describe: 'Prints local environment information',
52
- builder: cmd => cmd.example('$0 info', '# Prints information').example('$0 info --json', '# Prints information in JSON format'),
53
- handler: async (args) => {
54
- const options = command_js_1.Command.composeOptions(InfoCommand.commandName, args, repository.config);
55
- await new InfoCommand(options).execute();
56
- },
57
- });
58
- }
59
- InfoCommand.initCli = initCli;
60
- })(InfoCommand || (exports.InfoCommand = InfoCommand = {}));
@@ -1,138 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ListCommand = void 0;
4
- const tslib_1 = require("tslib");
5
- const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
6
- const easy_table_1 = tslib_1.__importDefault(require("easy-table"));
7
- const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
8
- const path_1 = tslib_1.__importDefault(require("path"));
9
- const command_js_1 = require("../core/command.js");
10
- const git_utils_js_1 = require("../utils/git-utils.js");
11
- class ListCommand extends command_js_1.Command {
12
- constructor(repository, options) {
13
- super(options);
14
- this.repository = repository;
15
- }
16
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
17
- _filter(pkg, inf) {
18
- return true;
19
- }
20
- async _execute() {
21
- const { repository } = this;
22
- const packages = repository.getPackages({ toposort: this.options.toposort });
23
- const git = new git_utils_js_1.GitHelper({ cwd: repository.dirname });
24
- const dirtyFiles = await git.listDirtyFiles({ absolute: true });
25
- const committedFiles = await git.listCommittedFiles({ absolute: true });
26
- const table = new easy_table_1.default();
27
- const arr = [];
28
- const obj = {};
29
- let count = 0;
30
- for (const p of packages) {
31
- const isDirty = !!dirtyFiles.find(f => !path_1.default.relative(p.dirname, f).startsWith('..'));
32
- const isCommitted = !!committedFiles.find(f => !path_1.default.relative(p.dirname, f).startsWith('..'));
33
- if (!this._filter(p, { isDirty, isCommitted }))
34
- continue;
35
- if (this.options.graph) {
36
- count++;
37
- obj[p.name] = [...p.dependencies];
38
- continue;
39
- }
40
- const location = path_1.default.relative(repository.dirname, p.dirname);
41
- let o = {
42
- name: p.name,
43
- version: p.version,
44
- location,
45
- private: p.isPrivate,
46
- isDirty,
47
- isCommitted,
48
- };
49
- o = this.onPrepare ? this.onPrepare(p, o) : o;
50
- if (!o)
51
- continue;
52
- arr.push(o);
53
- count++;
54
- if (!this.options.json) {
55
- if (this.options.parseable) {
56
- const a = [
57
- location,
58
- p.name,
59
- p.version,
60
- p.isPrivate ? 'PRIVATE' : '',
61
- isDirty ? 'DIRTY' : isCommitted ? ':COMMITTED' : '',
62
- ];
63
- npmlog_1.default.output('', a.join('::'));
64
- }
65
- else if (this.options.short) {
66
- npmlog_1.default.output('', p.name);
67
- }
68
- else {
69
- if (this.onPrintTable)
70
- this.onPrintTable(p, o, table);
71
- else {
72
- table.cell('Package', ansi_colors_1.default.yellowBright(p.name));
73
- table.cell('Version', ansi_colors_1.default.yellow(p.version));
74
- table.cell('Private', p.isPrivate ? ansi_colors_1.default.magentaBright('yes') : '');
75
- table.cell('Changed', isDirty ? ansi_colors_1.default.magenta('dirty') : isCommitted ? ansi_colors_1.default.yellow('committed') : '');
76
- table.cell('Path', path_1.default.relative(repository.dirname, p.dirname));
77
- table.newRow();
78
- }
79
- }
80
- }
81
- }
82
- if (this.options.graph) {
83
- npmlog_1.default.output('', '%j', obj);
84
- return obj;
85
- }
86
- if (this.options.json) {
87
- npmlog_1.default.output('', '%j', arr);
88
- return arr;
89
- }
90
- if (table.rows.length) {
91
- npmlog_1.default.output('', '%s', table.toString().trim());
92
- console.log('');
93
- npmlog_1.default.info('list', '%i Package(s) found', count);
94
- return arr;
95
- }
96
- return arr;
97
- }
98
- }
99
- exports.ListCommand = ListCommand;
100
- ListCommand.commandName = 'list';
101
- (function (ListCommand) {
102
- ListCommand.cliCommandOptions = {
103
- short: {
104
- alias: 's',
105
- describe: '# Do not show extended information',
106
- },
107
- parseable: {
108
- alias: 'p',
109
- describe: '# Show parseable output',
110
- },
111
- toposort: {
112
- alias: 't',
113
- describe: '# Sort packages in topological order (dependencies before dependents) instead of lexical by directory',
114
- },
115
- graph: {
116
- alias: 'g',
117
- describe: '# Show dependency graph as a JSON-formatted adjacency list',
118
- },
119
- };
120
- function initCli(repository, program) {
121
- program.command({
122
- command: 'list [options...]',
123
- describe: 'Lists packages in repository',
124
- aliases: ['ls'],
125
- builder: cmd => cmd
126
- .example('$0 list', '# List all packages')
127
- .example('$0 list --json', '# List all packages in JSON format')
128
- .conflicts('graph', ['parseable', 'json'])
129
- .conflicts('short', ['parseable', 'json'])
130
- .option(ListCommand.cliCommandOptions),
131
- handler: async (args) => {
132
- const options = command_js_1.Command.composeOptions(ListCommand.commandName, args, repository.config);
133
- await new ListCommand(repository, options).execute();
134
- },
135
- });
136
- }
137
- ListCommand.initCli = initCli;
138
- })(ListCommand || (exports.ListCommand = ListCommand = {}));
@@ -1,68 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MultiTaskCommand = void 0;
4
- const tslib_1 = require("tslib");
5
- const os_1 = tslib_1.__importDefault(require("os"));
6
- const power_tasks_1 = require("power-tasks");
7
- const putil_varhelpers_1 = require("putil-varhelpers");
8
- const command_js_1 = require("../core/command.js");
9
- const constants_js_1 = require("../core/constants.js");
10
- class MultiTaskCommand extends command_js_1.Command {
11
- constructor(repository, options) {
12
- super(options);
13
- this.repository = repository;
14
- if (this.options.ci || !constants_js_1.isTTY)
15
- this.options.progress = false;
16
- // noinspection SuspiciousTypeOfGuard
17
- this.options.concurrency = (0, putil_varhelpers_1.toNumber)(options?.concurrency);
18
- if (this.options.bail == null)
19
- this.options.bail = true;
20
- }
21
- async _execute() {
22
- const packages = await this._getPackages();
23
- const childTasks = await this._prepareTasks(packages);
24
- if (!(childTasks && childTasks.length)) {
25
- return;
26
- }
27
- // this.enableProgress();
28
- this._task = new power_tasks_1.Task(childTasks, {
29
- name: '$project-root',
30
- concurrency: this.options.concurrency || os_1.default.cpus().length,
31
- bail: this.options.bail,
32
- });
33
- await this._task.toPromise();
34
- }
35
- async _getPackages() {
36
- return this.repository.getPackages({ toposort: !this.options.parallel });
37
- }
38
- }
39
- exports.MultiTaskCommand = MultiTaskCommand;
40
- (function (MultiTaskCommand) {
41
- MultiTaskCommand.cliCommandOptions = {
42
- concurrency: {
43
- describe: '# Set processes count to parallelize tasks. (CPU count if not defined)',
44
- type: 'number',
45
- },
46
- parallel: {
47
- describe: '# Disregards dependency checking and runs the command for every package at same time.',
48
- type: 'boolean',
49
- },
50
- 'no-bail': {
51
- describe: '# Continue execution even one fails.',
52
- type: 'boolean',
53
- },
54
- bail: {
55
- hidden: true,
56
- type: 'boolean',
57
- },
58
- 'no-progress': {
59
- describe: 'Disable progress bars',
60
- type: 'boolean',
61
- },
62
- progress: {
63
- hidden: true,
64
- type: 'boolean',
65
- default: true,
66
- },
67
- };
68
- })(MultiTaskCommand || (exports.MultiTaskCommand = MultiTaskCommand = {}));
@@ -1,130 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PublishCommand = void 0;
4
- const tslib_1 = require("tslib");
5
- const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
6
- const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
7
- const path_1 = tslib_1.__importDefault(require("path"));
8
- const command_js_1 = require("../core/command.js");
9
- const npm_utils_js_1 = require("../utils/npm-utils.js");
10
- const package_not_found_error_js_1 = require("../utils/package-not-found-error.js");
11
- const run_command_js_1 = require("./run-command.js");
12
- class PublishCommand extends run_command_js_1.RunCommand {
13
- constructor(repository, options) {
14
- super(repository, 'publish', {
15
- ...options,
16
- bail: false,
17
- parallel: true,
18
- });
19
- this.repository = repository;
20
- }
21
- async _prepareTasks(packages) {
22
- const newVersions = {};
23
- const selectedPackages = [];
24
- const promises = [];
25
- for (const p of packages) {
26
- const logPkgName = ansi_colors_1.default.yellow(p.name);
27
- if (p.json.private) {
28
- npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, `Ignored. Package is set to "private"`);
29
- continue;
30
- }
31
- npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, `Fetching package information from repository`);
32
- const npmHelper = new npm_utils_js_1.NpmHelper({ cwd: p.dirname, userconfig: this.options.userconfig });
33
- promises.push(npmHelper
34
- .getPackageInfo(p.json.name)
35
- .then(r => {
36
- const fetchedVersion = r.version;
37
- const sameVersion = fetchedVersion === p.version;
38
- npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, sameVersion
39
- ? `No publish needed. Version (${ansi_colors_1.default.magenta(p.version)}) same in repository`
40
- : `Publishing is possible.` +
41
- ` Version "${ansi_colors_1.default.magenta(p.version)}" differs from version in repository (${ansi_colors_1.default.magenta(fetchedVersion)})`);
42
- if (!sameVersion) {
43
- selectedPackages.push(p);
44
- }
45
- })
46
- .catch(e => {
47
- if (e instanceof package_not_found_error_js_1.PackageNotFoundError) {
48
- npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, 'Publishing is possible. No package information found in repository');
49
- selectedPackages.push(p);
50
- }
51
- else
52
- throw e;
53
- }));
54
- }
55
- await Promise.all(promises);
56
- if (this.options.checkOnly)
57
- npmlog_1.default.verbose(this.commandName, '', npmlog_1.default.separator, `${selectedPackages.length} packages can be be published`);
58
- else
59
- npmlog_1.default.verbose(this.commandName, '', npmlog_1.default.separator, `${selectedPackages.length} packages will be published`);
60
- selectedPackages.forEach(p => {
61
- p.json.scripts = p.json.scripts || {};
62
- p.json.scripts.publish = '#';
63
- });
64
- return super._prepareTasks(selectedPackages, { newVersions });
65
- }
66
- async _exec(pkg, command, args, options) {
67
- if (command === '#') {
68
- if (pkg === this.repository.rootPackage)
69
- return { code: 0 };
70
- let cwd = pkg.dirname;
71
- if (this.options.contents) {
72
- const contents = this.options.contents.replaceAll('${package.basename}', pkg.basename);
73
- if (contents.startsWith('/'))
74
- cwd = path_1.default.join(this.repository.dirname, contents);
75
- else
76
- cwd = path_1.default.join(pkg.dirname, contents);
77
- }
78
- const npmHelper = new npm_utils_js_1.NpmHelper({ cwd: pkg.dirname, userconfig: this.options.userconfig });
79
- return super._exec(pkg, 'npm publish' +
80
- (this.options.access ? ' --access=' + this.options.access : '') +
81
- (npmHelper.userconfig ? ` --userconfig="${npmHelper.userconfig}"` : ''), {
82
- ...args,
83
- cwd,
84
- stdio: npmlog_1.default.levelIndex < 1000 ? 'inherit' : 'pipe',
85
- }, options);
86
- }
87
- return super._exec(pkg, command, args, options);
88
- }
89
- }
90
- exports.PublishCommand = PublishCommand;
91
- PublishCommand.commandName = 'publish';
92
- (function (PublishCommand) {
93
- PublishCommand.cliCommandOptions = {
94
- ...run_command_js_1.RunCommand.cliCommandOptions,
95
- contents: {
96
- describe: '# Subdirectory to publish',
97
- type: 'string',
98
- },
99
- access: {
100
- describe: '# Tells the registry whether this package should be published as public or restricted. ' +
101
- "Only applies to scoped packages, which default to restricted. If you don't have a paid account, " +
102
- 'you must publish with --access public to publish scoped packages.',
103
- type: 'string',
104
- choices: ['public', 'restricted'],
105
- },
106
- userconfig: {
107
- describe: '# Path of .npmrc file to use for authentication',
108
- type: 'string',
109
- },
110
- 'check-only': {
111
- describe: '# Only performs version checking and do not apply "publish" to the registry.',
112
- type: 'boolean',
113
- },
114
- };
115
- function initCli(repository, program) {
116
- program.command({
117
- command: 'publish [...options]',
118
- describe: 'Publish packages in the current project',
119
- builder: cmd => cmd
120
- .example('$0 publish', '')
121
- .example('$0 publish --contents dist', '# publish package from built directory')
122
- .option(PublishCommand.cliCommandOptions),
123
- handler: async (args) => {
124
- const options = command_js_1.Command.composeOptions(PublishCommand.commandName, args, repository.config);
125
- await new PublishCommand(repository, options).execute();
126
- },
127
- });
128
- }
129
- PublishCommand.initCli = initCli;
130
- })(PublishCommand || (exports.PublishCommand = PublishCommand = {}));
@@ -1,134 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RunCommand = void 0;
4
- const tslib_1 = require("tslib");
5
- const parse_npm_script_1 = tslib_1.__importDefault(require("@netlify/parse-npm-script"));
6
- const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
7
- const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
8
- const power_tasks_1 = require("power-tasks");
9
- const command_js_1 = require("../core/command.js");
10
- const exec_js_1 = require("../utils/exec.js");
11
- const multi_task_command_js_1 = require("./multi-task-command.js");
12
- class RunCommand extends multi_task_command_js_1.MultiTaskCommand {
13
- constructor(repository, script, options) {
14
- super(repository, options);
15
- this.repository = repository;
16
- this.script = script;
17
- }
18
- _prepareTasks(packages, options) {
19
- const packageTasks = [];
20
- for (const p of packages) {
21
- if (p.json.scripts) {
22
- const childTask = this._prepareScriptTask(p, options);
23
- if (childTask) {
24
- packageTasks.push(childTask);
25
- }
26
- }
27
- }
28
- const rootTask = this._prepareScriptTask(this.repository.rootPackage);
29
- const children = rootTask?.options.children;
30
- if (!children)
31
- return packageTasks;
32
- const tasks = [];
33
- const pre = children.filter(t => t.name?.endsWith(':pre' + this.script));
34
- const post = children.filter(t => t.name?.endsWith(':post' + this.script));
35
- pre.forEach(t => (t.options.exclusive = true));
36
- post.forEach(t => (t.options.exclusive = true));
37
- tasks.push(...pre);
38
- tasks.push(...packageTasks);
39
- tasks.push(...post);
40
- return tasks;
41
- }
42
- _prepareScriptTask(pkg, options) {
43
- const json = { ...pkg.json };
44
- json.scripts = json.scripts || {};
45
- json.scripts[this.script] = json.scripts[this.script] || '#';
46
- const scriptInfo = (0, parse_npm_script_1.default)(json, 'npm run ' + this.script);
47
- if (!(scriptInfo && scriptInfo.raw))
48
- return;
49
- const children = [];
50
- for (const s of scriptInfo.steps) {
51
- const parsed = Array.isArray(s.parsed) ? s.parsed : [s.parsed];
52
- for (const cmd of parsed) {
53
- const task = new power_tasks_1.Task(async () => await this._exec(pkg, cmd, {
54
- script: s.name,
55
- stdio: npmlog_1.default.levelIndex < 1000 ? 'inherit' : 'pipe',
56
- }, options), {
57
- name: pkg.name + ':' + s.name,
58
- dependencies: this.options.parallel || s.name.startsWith('pre') || s.name.startsWith('post')
59
- ? undefined
60
- : pkg.dependencies,
61
- });
62
- children.push(task);
63
- }
64
- }
65
- if (children.length) {
66
- return new power_tasks_1.Task(children, {
67
- name: pkg.name,
68
- bail: true,
69
- serial: true,
70
- });
71
- }
72
- }
73
- async _exec(pkg, command, args,
74
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
75
- options) {
76
- const name = pkg === this.repository.rootPackage ? 'root' : pkg.name;
77
- const logLevel = args.logLevel == null ? 'info' : args.logLevel;
78
- if (logLevel) {
79
- npmlog_1.default.verbose(this.commandName, ansi_colors_1.default.cyan(name), npmlog_1.default.separator, ansi_colors_1.default.cyanBright.bold(args.script || ''), ansi_colors_1.default.cyanBright.bold('executing'), npmlog_1.default.separator, command);
80
- }
81
- const t = Date.now();
82
- const cwd = args.cwd || pkg.dirname;
83
- const r = await (0, exec_js_1.exec)(command, {
84
- cwd,
85
- stdio: args.stdio,
86
- throwOnError: false,
87
- });
88
- if (logLevel) {
89
- if (r.error) {
90
- npmlog_1.default.error(this.commandName, ansi_colors_1.default.cyan(name), npmlog_1.default.separator, ansi_colors_1.default.cyanBright.bold(args.script || ''), ansi_colors_1.default.red.bold('failed'), npmlog_1.default.separator, command, npmlog_1.default.separator, r.error.message.trim() + ('\n' + r.stdout).trim());
91
- }
92
- else {
93
- npmlog_1.default.log(logLevel, this.commandName, ansi_colors_1.default.cyan(name), npmlog_1.default.separator, ansi_colors_1.default.cyanBright.bold(args.script || ''), ansi_colors_1.default.green.bold('success'), npmlog_1.default.separator, command, ansi_colors_1.default.yellow(' (' + (Date.now() - t) + ' ms)'));
94
- }
95
- }
96
- if (r.error && !args.noThrow)
97
- throw r.error;
98
- return r;
99
- }
100
- }
101
- exports.RunCommand = RunCommand;
102
- RunCommand.commandName = 'run';
103
- (function (RunCommand) {
104
- RunCommand.cliCommandOptions = {
105
- ...multi_task_command_js_1.MultiTaskCommand.cliCommandOptions,
106
- };
107
- function initCli(repository, program) {
108
- program.command({
109
- command: 'run <script>',
110
- describe: 'Execute an arbitrary script in each package',
111
- builder: cmd => cmd
112
- .example('$0 run build', '')
113
- .positional('script', {
114
- describe: '# The script to execute. Any command flags must be passed after --',
115
- type: 'string',
116
- })
117
- .option(RunCommand.cliCommandOptions),
118
- handler: async (args) => {
119
- const runCfg = repository.config?.command?.run;
120
- if (args.script && runCfg && typeof runCfg === 'object') {
121
- ['parallel', 'bail', 'progress'].forEach(n => {
122
- if (typeof runCfg[n] === 'string') {
123
- runCfg[n] = runCfg[n].split(/\s*,\s*/).includes(String(args.script));
124
- }
125
- });
126
- }
127
- const options = command_js_1.Command.composeOptions(RunCommand.commandName, args, repository.config);
128
- const script = '' + args.script;
129
- await new RunCommand(repository, script, options).execute();
130
- },
131
- });
132
- }
133
- RunCommand.initCli = initCli;
134
- })(RunCommand || (exports.RunCommand = RunCommand = {}));