rman 0.29.0 → 0.30.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 (58) hide show
  1. package/cjs/cli.js +3 -3
  2. package/cjs/commands/ci-command.js +3 -3
  3. package/cjs/commands/execute-command.js +3 -3
  4. package/cjs/commands/info-command.js +7 -7
  5. package/cjs/commands/list-command.js +5 -5
  6. package/cjs/commands/publish-command.js +7 -7
  7. package/cjs/commands/run-command.js +4 -4
  8. package/cjs/commands/version-command.js +6 -6
  9. package/cjs/core/command.js +3 -3
  10. package/cjs/utils/npm-run-path.js +14 -5
  11. package/esm/cli.js +40 -36
  12. package/esm/commands/build-command.js +9 -5
  13. package/esm/commands/changed-command.js +10 -6
  14. package/esm/commands/ci-command.js +28 -23
  15. package/esm/commands/execute-command.js +20 -15
  16. package/esm/commands/info-command.js +20 -15
  17. package/esm/commands/list-command.js +30 -25
  18. package/esm/commands/multi-task-command.js +16 -11
  19. package/esm/commands/publish-command.js +28 -23
  20. package/esm/commands/run-command.js +24 -19
  21. package/esm/commands/version-command.js +35 -30
  22. package/esm/core/command.js +24 -19
  23. package/esm/core/constants.js +4 -1
  24. package/esm/core/logger.js +5 -2
  25. package/esm/core/package.js +11 -6
  26. package/esm/core/repository.js +33 -28
  27. package/esm/index.js +4 -1
  28. package/esm/utils/exec.js +10 -7
  29. package/esm/utils/file-utils.js +17 -11
  30. package/esm/utils/get-dirname.js +13 -8
  31. package/esm/utils/git-utils.js +14 -9
  32. package/esm/utils/npm-run-path.js +30 -16
  33. package/esm/utils/npm-utils.js +9 -4
  34. package/package.json +35 -35
  35. package/types/cli.d.ts +4 -0
  36. package/types/commands/build-command.d.ts +11 -0
  37. package/types/commands/changed-command.d.ts +16 -0
  38. package/types/commands/ci-command.d.ts +24 -0
  39. package/types/commands/execute-command.d.ts +19 -0
  40. package/types/commands/info-command.d.ts +10 -0
  41. package/types/commands/list-command.d.ts +38 -0
  42. package/types/commands/multi-task-command.d.ts +22 -0
  43. package/types/commands/publish-command.d.ts +22 -0
  44. package/types/commands/run-command.d.ts +28 -0
  45. package/types/commands/version-command.d.ts +25 -0
  46. package/types/core/command.d.ts +35 -0
  47. package/types/core/constants.d.ts +1 -0
  48. package/types/core/logger.d.ts +12 -0
  49. package/types/core/package.d.ts +13 -0
  50. package/types/core/repository.d.ts +19 -0
  51. package/types/index.d.ts +1 -0
  52. package/types/utils/exec.d.ts +18 -0
  53. package/types/utils/file-utils.d.ts +4 -0
  54. package/types/utils/get-dirname.d.ts +2 -0
  55. package/types/utils/git-utils.d.ts +25 -0
  56. package/types/utils/npm-run-path.d.ts +67 -0
  57. package/types/utils/npm-utils.d.ts +11 -0
  58. package/cjs/package.json +0 -3
@@ -1,10 +1,14 @@
1
- import chalk from 'chalk';
2
- import logger from 'npmlog';
3
- import { Task } from 'power-tasks';
4
- import { Command } from '../core/command.js';
5
- import { exec } from '../utils/exec.js';
6
- import { MultiTaskCommand } from './multi-task-command.js';
7
- export class ExecuteCommand extends MultiTaskCommand {
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 {
8
12
  constructor(repository, cmd, argv, options) {
9
13
  super(repository, options);
10
14
  this.repository = repository;
@@ -14,15 +18,15 @@ export class ExecuteCommand extends MultiTaskCommand {
14
18
  _prepareTasks(packages) {
15
19
  const tasks = [];
16
20
  for (const p of packages) {
17
- const task = new Task(async () => {
21
+ const task = new power_tasks_1.Task(async () => {
18
22
  const t = Date.now();
19
- logger.verbose(this.commandName, p.name, chalk.cyanBright.bold('executing'), logger.separator, this.cmd + ' ' + (this.argv?.join(' ') || ''));
20
- const r = await exec(this.cmd, {
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, {
21
25
  cwd: p.dirname,
22
26
  argv: this.argv,
23
- stdio: logger.levelIndex < 1000 ? 'inherit' : 'pipe',
27
+ stdio: npmlog_1.default.levelIndex < 1000 ? 'inherit' : 'pipe',
24
28
  });
25
- logger.log(r.error ? 'error' : 'info', this.commandName, p.name, r.error ? chalk.red.bold('failed') : chalk.green.bold('success'), logger.separator, this.cmd, chalk.yellow(' (' + (Date.now() - t) + ' ms') + ')');
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') + ')');
26
30
  }, {
27
31
  name: p.name,
28
32
  dependencies: this.options.parallel ? undefined : p.dependencies,
@@ -34,10 +38,11 @@ export class ExecuteCommand extends MultiTaskCommand {
34
38
  return tasks;
35
39
  }
36
40
  }
41
+ exports.ExecuteCommand = ExecuteCommand;
37
42
  ExecuteCommand.commandName = 'exec';
38
43
  (function (ExecuteCommand) {
39
44
  ExecuteCommand.cliCommandOptions = {
40
- ...MultiTaskCommand.cliCommandOptions,
45
+ ...multi_task_command_js_1.MultiTaskCommand.cliCommandOptions,
41
46
  };
42
47
  function initCli(repository, program) {
43
48
  program.command({
@@ -60,10 +65,10 @@ ExecuteCommand.commandName = 'exec';
60
65
  .option(ExecuteCommand.cliCommandOptions),
61
66
  handler: async (args) => {
62
67
  const argv = args['--'] || [];
63
- const options = Command.composeOptions(ExecuteCommand.commandName, args, repository.config);
68
+ const options = command_js_1.Command.composeOptions(ExecuteCommand.commandName, args, repository.config);
64
69
  await new ExecuteCommand(repository, '' + argv.shift(), argv, options).execute();
65
70
  },
66
71
  });
67
72
  }
68
73
  ExecuteCommand.initCli = initCli;
69
- })(ExecuteCommand || (ExecuteCommand = {}));
74
+ })(ExecuteCommand || (exports.ExecuteCommand = ExecuteCommand = {}));
@@ -1,10 +1,14 @@
1
- import chalk from 'chalk';
2
- import envinfo from 'envinfo';
3
- import semver from 'semver';
4
- import { Command } from '../core/command.js';
5
- export class InfoCommand extends Command {
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 {
6
10
  async _execute() {
7
- const systemInfo = JSON.parse(await envinfo.run({
11
+ const systemInfo = JSON.parse(await envinfo_1.default.run({
8
12
  System: ['OS', 'CPU', 'Memory', 'Shell'],
9
13
  Binaries: ['Node', 'Yarn', 'npm'],
10
14
  Utilities: ['Git'],
@@ -17,27 +21,28 @@ export class InfoCommand extends Command {
17
21
  }
18
22
  const maxName = Object.keys(systemInfo).reduce((l, p) => Object.keys(systemInfo[p]).reduce((i, x) => (l = Math.max(i, x.length)), l), 0);
19
23
  for (const [categoryName, category] of Object.entries(systemInfo)) {
20
- this.logger.output('', '', chalk.whiteBright(categoryName) + ':');
24
+ this.logger.output('', '', ansi_colors_1.default.whiteBright(categoryName) + ':');
21
25
  for (const [n, v] of Object.entries(category)) {
22
- const label = ' ' + chalk.reset(n) + ' '.repeat(maxName - n.length) + ' :';
26
+ const label = ' ' + ansi_colors_1.default.reset(n) + ' '.repeat(maxName - n.length) + ' :';
23
27
  if (typeof v === 'string') {
24
- this.logger.output('', label, chalk.yellowBright(v));
28
+ this.logger.output('', label, ansi_colors_1.default.yellowBright(v));
25
29
  continue;
26
30
  }
27
31
  if (v.version) {
28
- this.logger.output('', label, chalk.yellowBright(v.version), v.path ? ' ' + chalk.yellow(v.path) : '');
32
+ this.logger.output('', label, ansi_colors_1.default.yellowBright(v.version), v.path ? ' ' + ansi_colors_1.default.yellow(v.path) : '');
29
33
  }
30
34
  if (v.installed) {
31
- if (v.wanted === 'latest' || semver.intersects(v.installed, v.wanted)) {
32
- this.logger.output('', label, chalk.yellowBright(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));
33
37
  }
34
38
  else
35
- this.logger.output('', label, chalk.red(v.installed), ' => ', chalk.yellowBright(v.wanted));
39
+ this.logger.output('', label, ansi_colors_1.default.red(v.installed), ' => ', ansi_colors_1.default.yellowBright(v.wanted));
36
40
  }
37
41
  }
38
42
  }
39
43
  }
40
44
  }
45
+ exports.InfoCommand = InfoCommand;
41
46
  InfoCommand.commandName = 'info';
42
47
  (function (InfoCommand) {
43
48
  function initCli(repository, program) {
@@ -46,10 +51,10 @@ InfoCommand.commandName = 'info';
46
51
  describe: 'Prints local environment information',
47
52
  builder: cmd => cmd.example('$0 info', '# Prints information').example('$0 info --json', '# Prints information in JSON format'),
48
53
  handler: async (args) => {
49
- const options = Command.composeOptions(InfoCommand.commandName, args, repository.config);
54
+ const options = command_js_1.Command.composeOptions(InfoCommand.commandName, args, repository.config);
50
55
  await new InfoCommand(options).execute();
51
56
  },
52
57
  });
53
58
  }
54
59
  InfoCommand.initCli = initCli;
55
- })(InfoCommand || (InfoCommand = {}));
60
+ })(InfoCommand || (exports.InfoCommand = InfoCommand = {}));
@@ -1,10 +1,14 @@
1
- import chalk from 'chalk';
2
- import EasyTable from 'easy-table';
3
- import logger from 'npmlog';
4
- import path from 'path';
5
- import { Command } from '../core/command.js';
6
- import { GitHelper } from '../utils/git-utils.js';
7
- export class ListCommand extends Command {
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 {
8
12
  constructor(repository, options) {
9
13
  super(options);
10
14
  this.repository = repository;
@@ -16,16 +20,16 @@ export class ListCommand extends Command {
16
20
  async _execute() {
17
21
  const { repository } = this;
18
22
  const packages = repository.getPackages({ toposort: this.options.toposort });
19
- const git = new GitHelper({ cwd: repository.dirname });
23
+ const git = new git_utils_js_1.GitHelper({ cwd: repository.dirname });
20
24
  const dirtyFiles = await git.listDirtyFiles({ absolute: true });
21
25
  const committedFiles = await git.listCommittedFiles({ absolute: true });
22
- const table = new EasyTable();
26
+ const table = new easy_table_1.default();
23
27
  const arr = [];
24
28
  const obj = {};
25
29
  let count = 0;
26
30
  for (const p of packages) {
27
- const isDirty = !!dirtyFiles.find(f => !path.relative(p.dirname, f).startsWith('..'));
28
- const isCommitted = !!committedFiles.find(f => !path.relative(p.dirname, f).startsWith('..'));
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('..'));
29
33
  if (!this._filter(p, { isDirty, isCommitted }))
30
34
  continue;
31
35
  if (this.options.graph) {
@@ -33,7 +37,7 @@ export class ListCommand extends Command {
33
37
  obj[p.name] = [...p.dependencies];
34
38
  continue;
35
39
  }
36
- const location = path.relative(repository.dirname, p.dirname);
40
+ const location = path_1.default.relative(repository.dirname, p.dirname);
37
41
  let o = {
38
42
  name: p.name,
39
43
  version: p.version,
@@ -56,43 +60,44 @@ export class ListCommand extends Command {
56
60
  p.isPrivate ? 'PRIVATE' : '',
57
61
  isDirty ? 'DIRTY' : isCommitted ? ':COMMITTED' : '',
58
62
  ];
59
- logger.output('', a.join('::'));
63
+ npmlog_1.default.output('', a.join('::'));
60
64
  }
61
65
  else if (this.options.short) {
62
- logger.output('', p.name);
66
+ npmlog_1.default.output('', p.name);
63
67
  }
64
68
  else {
65
69
  if (this.onPrintTable)
66
70
  this.onPrintTable(p, o, table);
67
71
  else {
68
- table.cell('Package', chalk.yellowBright(p.name));
69
- table.cell('Version', chalk.yellow(p.version));
70
- table.cell('Private', p.isPrivate ? chalk.magentaBright('yes') : '');
71
- table.cell('Changed', isDirty ? chalk.magenta('dirty') : isCommitted ? chalk.yellow('committed') : '');
72
- table.cell('Path', path.relative(repository.dirname, p.dirname));
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));
73
77
  table.newRow();
74
78
  }
75
79
  }
76
80
  }
77
81
  }
78
82
  if (this.options.graph) {
79
- logger.output('', '%j', obj);
83
+ npmlog_1.default.output('', '%j', obj);
80
84
  return obj;
81
85
  }
82
86
  if (this.options.json) {
83
- logger.output('', '%j', arr);
87
+ npmlog_1.default.output('', '%j', arr);
84
88
  return arr;
85
89
  }
86
90
  if (table.rows.length) {
87
- logger.output('', '%s', table.toString().trim());
91
+ npmlog_1.default.output('', '%s', table.toString().trim());
88
92
  // eslint-disable-next-line no-console
89
93
  console.log('');
90
- logger.info('list', '%i Package(s) found', count);
94
+ npmlog_1.default.info('list', '%i Package(s) found', count);
91
95
  return arr;
92
96
  }
93
97
  return arr;
94
98
  }
95
99
  }
100
+ exports.ListCommand = ListCommand;
96
101
  ListCommand.commandName = 'list';
97
102
  (function (ListCommand) {
98
103
  ListCommand.cliCommandOptions = {
@@ -125,10 +130,10 @@ ListCommand.commandName = 'list';
125
130
  .conflicts('short', ['parseable', 'json'])
126
131
  .option(ListCommand.cliCommandOptions),
127
132
  handler: async (args) => {
128
- const options = Command.composeOptions(ListCommand.commandName, args, repository.config);
133
+ const options = command_js_1.Command.composeOptions(ListCommand.commandName, args, repository.config);
129
134
  await new ListCommand(repository, options).execute();
130
135
  },
131
136
  });
132
137
  }
133
138
  ListCommand.initCli = initCli;
134
- })(ListCommand || (ListCommand = {}));
139
+ })(ListCommand || (exports.ListCommand = ListCommand = {}));
@@ -1,16 +1,20 @@
1
- import os from 'os';
2
- import { Task } from 'power-tasks';
3
- import { toNumber } from 'putil-varhelpers';
4
- import { Command } from '../core/command.js';
5
- import { isTTY } from '../core/constants.js';
6
- export class MultiTaskCommand extends Command {
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 {
7
11
  constructor(repository, options) {
8
12
  super(options);
9
13
  this.repository = repository;
10
- if (this.options.ci || !isTTY)
14
+ if (this.options.ci || !constants_js_1.isTTY)
11
15
  this.options.progress = false;
12
16
  // noinspection SuspiciousTypeOfGuard
13
- this.options.concurrency = toNumber(options?.concurrency);
17
+ this.options.concurrency = (0, putil_varhelpers_1.toNumber)(options?.concurrency);
14
18
  if (this.options.bail == null)
15
19
  this.options.bail = true;
16
20
  }
@@ -21,9 +25,9 @@ export class MultiTaskCommand extends Command {
21
25
  return;
22
26
  }
23
27
  // this.enableProgress();
24
- this._task = new Task(childTasks, {
28
+ this._task = new power_tasks_1.Task(childTasks, {
25
29
  name: '$project-root',
26
- concurrency: this.options.concurrency || os.cpus().length,
30
+ concurrency: this.options.concurrency || os_1.default.cpus().length,
27
31
  bail: this.options.bail,
28
32
  });
29
33
  await this._task.toPromise();
@@ -32,6 +36,7 @@ export class MultiTaskCommand extends Command {
32
36
  return this.repository.getPackages({ toposort: !this.options.parallel });
33
37
  }
34
38
  }
39
+ exports.MultiTaskCommand = MultiTaskCommand;
35
40
  (function (MultiTaskCommand) {
36
41
  MultiTaskCommand.cliCommandOptions = {
37
42
  concurrency: {
@@ -60,4 +65,4 @@ export class MultiTaskCommand extends Command {
60
65
  default: true,
61
66
  },
62
67
  };
63
- })(MultiTaskCommand || (MultiTaskCommand = {}));
68
+ })(MultiTaskCommand || (exports.MultiTaskCommand = MultiTaskCommand = {}));
@@ -1,10 +1,14 @@
1
- import chalk from 'chalk';
2
- import logger from 'npmlog';
3
- import path from 'path';
4
- import { Command } from '../core/command.js';
5
- import { NpmHelper } from '../utils/npm-utils.js';
6
- import { RunCommand } from './run-command.js';
7
- export class PublishCommand extends RunCommand {
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 run_command_js_1 = require("./run-command.js");
11
+ class PublishCommand extends run_command_js_1.RunCommand {
8
12
  constructor(repository, options) {
9
13
  super(repository, 'publish', {
10
14
  ...options,
@@ -18,32 +22,32 @@ export class PublishCommand extends RunCommand {
18
22
  const selectedPackages = [];
19
23
  const promises = [];
20
24
  for (const p of packages) {
21
- const logPkgName = chalk.yellow(p.name);
25
+ const logPkgName = ansi_colors_1.default.yellow(p.name);
22
26
  if (p.json.private) {
23
- logger.info(this.commandName, logPkgName, logger.separator, `Ignored. Package is set to "private"`);
27
+ npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, `Ignored. Package is set to "private"`);
24
28
  continue;
25
29
  }
26
- logger.info(this.commandName, logPkgName, logger.separator, `Fetching package information from repository`);
27
- const npmHelper = new NpmHelper({ cwd: p.dirname });
30
+ npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, `Fetching package information from repository`);
31
+ const npmHelper = new npm_utils_js_1.NpmHelper({ cwd: p.dirname });
28
32
  promises.push(npmHelper
29
33
  .getPackageInfo(p.json.name)
30
34
  .then(r => {
31
35
  const sameVersion = !!(r && r.version === p.version);
32
36
  if (this.options.checkOnly) {
33
- logger.info(this.commandName, logPkgName, logger.separator, !r.version
34
- ? chalk.yellow('No package information found in repository')
37
+ npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, !r.version
38
+ ? ansi_colors_1.default.yellow('No package information found in repository')
35
39
  : sameVersion
36
- ? `No publish needed. Version (${chalk.magenta(p.version)}) same in repository`
40
+ ? `No publish needed. Version (${ansi_colors_1.default.magenta(p.version)}) same in repository`
37
41
  : `Publishing is possible.` +
38
- ` Version "${chalk.magenta(p.version)}" differs from version in repository (${chalk.magenta(r.version)})`);
42
+ ` Version "${ansi_colors_1.default.magenta(p.version)}" differs from version in repository (${ansi_colors_1.default.magenta(r.version)})`);
39
43
  return;
40
44
  }
41
45
  if (r && r.version === p.version) {
42
- logger.info(this.commandName, logPkgName, logger.separator, `No publish needed. Version (${chalk.magenta(p.version)}) same in repository`);
46
+ npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, `No publish needed. Version (${ansi_colors_1.default.magenta(p.version)}) same in repository`);
43
47
  }
44
48
  else {
45
- logger.verbose(this.commandName, logPkgName, logger.separator, `Publishing is possible.` +
46
- ` Version "${chalk.magenta(p.version)}" differs from version in repository (${chalk.magenta(r.version)})`);
49
+ npmlog_1.default.verbose(this.commandName, logPkgName, npmlog_1.default.separator, `Publishing is possible.` +
50
+ ` Version "${ansi_colors_1.default.magenta(p.version)}" differs from version in repository (${ansi_colors_1.default.magenta(r.version)})`);
47
51
  selectedPackages.push(p);
48
52
  }
49
53
  })
@@ -60,21 +64,22 @@ export class PublishCommand extends RunCommand {
60
64
  if (pkg === this.repository.rootPackage)
61
65
  return { code: 0 };
62
66
  const cwd = this.options.contents
63
- ? path.resolve(this.repository.dirname, path.join(this.options.contents, path.basename(pkg.dirname)))
67
+ ? path_1.default.resolve(this.repository.dirname, path_1.default.join(this.options.contents, path_1.default.basename(pkg.dirname)))
64
68
  : pkg.dirname;
65
69
  return super._exec(pkg, 'npm publish' + (this.options.access ? ' --access=' + this.options.access : ''), {
66
70
  ...args,
67
71
  cwd,
68
- stdio: logger.levelIndex < 1000 ? 'inherit' : 'pipe',
72
+ stdio: npmlog_1.default.levelIndex < 1000 ? 'inherit' : 'pipe',
69
73
  }, options);
70
74
  }
71
75
  return super._exec(pkg, command, args, options);
72
76
  }
73
77
  }
78
+ exports.PublishCommand = PublishCommand;
74
79
  PublishCommand.commandName = 'publish';
75
80
  (function (PublishCommand) {
76
81
  PublishCommand.cliCommandOptions = {
77
- ...RunCommand.cliCommandOptions,
82
+ ...run_command_js_1.RunCommand.cliCommandOptions,
78
83
  contents: {
79
84
  describe: '# Subdirectory to publish',
80
85
  type: 'string',
@@ -100,10 +105,10 @@ PublishCommand.commandName = 'publish';
100
105
  .example('$0 publish --contents dist', '# publish package from built directory')
101
106
  .option(PublishCommand.cliCommandOptions),
102
107
  handler: async (args) => {
103
- const options = Command.composeOptions(PublishCommand.commandName, args, repository.config);
108
+ const options = command_js_1.Command.composeOptions(PublishCommand.commandName, args, repository.config);
104
109
  await new PublishCommand(repository, options).execute();
105
110
  },
106
111
  });
107
112
  }
108
113
  PublishCommand.initCli = initCli;
109
- })(PublishCommand || (PublishCommand = {}));
114
+ })(PublishCommand || (exports.PublishCommand = PublishCommand = {}));
@@ -1,11 +1,15 @@
1
- import parseNpmScript from '@netlify/parse-npm-script';
2
- import chalk from 'chalk';
3
- import logger from 'npmlog';
4
- import { Task } from 'power-tasks';
5
- import { Command } from '../core/command.js';
6
- import { exec } from '../utils/exec.js';
7
- import { MultiTaskCommand } from './multi-task-command.js';
8
- export class RunCommand extends MultiTaskCommand {
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 {
9
13
  constructor(repository, script, options) {
10
14
  super(repository, options);
11
15
  this.repository = repository;
@@ -38,16 +42,16 @@ export class RunCommand extends MultiTaskCommand {
38
42
  const json = { ...pkg.json };
39
43
  json.scripts = json.scripts || {};
40
44
  json.scripts[this.script] = json.scripts[this.script] || '#';
41
- const scriptInfo = parseNpmScript(json, 'npm run ' + this.script);
45
+ const scriptInfo = (0, parse_npm_script_1.default)(json, 'npm run ' + this.script);
42
46
  if (!(scriptInfo && scriptInfo.raw))
43
47
  return;
44
48
  const children = [];
45
49
  for (const s of scriptInfo.steps) {
46
50
  const parsed = Array.isArray(s.parsed) ? s.parsed : [s.parsed];
47
51
  for (const cmd of parsed) {
48
- const task = new Task(async () => await this._exec(pkg, cmd, {
52
+ const task = new power_tasks_1.Task(async () => await this._exec(pkg, cmd, {
49
53
  script: s.name,
50
- stdio: logger.levelIndex < 1000 ? 'inherit' : 'pipe',
54
+ stdio: npmlog_1.default.levelIndex < 1000 ? 'inherit' : 'pipe',
51
55
  }, options), {
52
56
  name: pkg.name + ':' + s.name,
53
57
  dependencies: this.options.parallel || s.name.startsWith('pre') || s.name.startsWith('post')
@@ -58,7 +62,7 @@ export class RunCommand extends MultiTaskCommand {
58
62
  }
59
63
  }
60
64
  if (children.length) {
61
- return new Task(children, {
65
+ return new power_tasks_1.Task(children, {
62
66
  name: pkg.name,
63
67
  bail: true,
64
68
  serial: true,
@@ -71,17 +75,17 @@ export class RunCommand extends MultiTaskCommand {
71
75
  const name = pkg === this.repository.rootPackage ? 'root' : pkg.name;
72
76
  const logLevel = args.logLevel == null ? 'info' : args.logLevel;
73
77
  if (logLevel) {
74
- logger.verbose(this.commandName, chalk.cyan(name), logger.separator, chalk.cyanBright.bold(args.script), chalk.cyanBright.bold('executing'), logger.separator, command);
78
+ 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);
75
79
  }
76
80
  const t = Date.now();
77
81
  const cwd = args.cwd || pkg.dirname;
78
- const r = await exec(command, { cwd, stdio: args.stdio, throwOnError: false });
82
+ const r = await (0, exec_js_1.exec)(command, { cwd, stdio: args.stdio, throwOnError: false });
79
83
  if (logLevel) {
80
84
  if (r.error) {
81
- logger.error(this.commandName, chalk.cyan(name), logger.separator, chalk.cyanBright.bold(args.script), chalk.red.bold('failed'), logger.separator, command, logger.separator, r.error.message.trim() + ('\n' + r.stdout).trim());
85
+ 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());
82
86
  }
83
87
  else {
84
- logger.log(logLevel, this.commandName, chalk.cyan(name), logger.separator, chalk.cyanBright.bold(args.script), chalk.green.bold('success'), logger.separator, command, chalk.yellow(' (' + (Date.now() - t) + ' ms)'));
88
+ 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)'));
85
89
  }
86
90
  }
87
91
  if (r.error && !args.noThrow)
@@ -89,10 +93,11 @@ export class RunCommand extends MultiTaskCommand {
89
93
  return r;
90
94
  }
91
95
  }
96
+ exports.RunCommand = RunCommand;
92
97
  RunCommand.commandName = 'run';
93
98
  (function (RunCommand) {
94
99
  RunCommand.cliCommandOptions = {
95
- ...MultiTaskCommand.cliCommandOptions,
100
+ ...multi_task_command_js_1.MultiTaskCommand.cliCommandOptions,
96
101
  };
97
102
  function initCli(repository, program) {
98
103
  program.command({
@@ -114,11 +119,11 @@ RunCommand.commandName = 'run';
114
119
  }
115
120
  });
116
121
  }
117
- const options = Command.composeOptions(RunCommand.commandName, args, repository.config);
122
+ const options = command_js_1.Command.composeOptions(RunCommand.commandName, args, repository.config);
118
123
  const script = '' + args.script;
119
124
  await new RunCommand(repository, script, options).execute();
120
125
  },
121
126
  });
122
127
  }
123
128
  RunCommand.initCli = initCli;
124
- })(RunCommand || (RunCommand = {}));
129
+ })(RunCommand || (exports.RunCommand = RunCommand = {}));