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
package/cjs/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runCli = runCli;
4
4
  const tslib_1 = require("tslib");
5
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
5
+ const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
6
6
  const promises_1 = tslib_1.__importDefault(require("fs/promises"));
7
7
  const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
8
8
  const path_1 = tslib_1.__importDefault(require("path"));
@@ -38,12 +38,12 @@ async function runCli(options) {
38
38
  .fail((msg, err) => {
39
39
  if (!err?.logged) {
40
40
  const text = msg
41
- ? msg + '\n\n' + chalk_1.default.whiteBright('Run with --help for available options')
41
+ ? msg + '\n\n' + ansi_colors_1.default.whiteBright('Run with --help for available options')
42
42
  : err
43
43
  ? err.message
44
44
  : '';
45
45
  // eslint-disable-next-line no-console
46
- console.log('\n' + chalk_1.default.red(text));
46
+ console.log('\n' + ansi_colors_1.default.red(text));
47
47
  throw msg;
48
48
  }
49
49
  else
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CleanInstallCommand = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
5
+ const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
6
6
  const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
7
7
  const path_1 = tslib_1.__importDefault(require("path"));
8
8
  const power_tasks_1 = require("power-tasks");
@@ -24,7 +24,7 @@ class CleanInstallCommand extends run_command_js_1.RunCommand {
24
24
  await this._fsDelete(path_1.default.join(dirname, 'node_modules'));
25
25
  await this._fsDelete(path_1.default.join(dirname, 'package-lock.json'));
26
26
  await this._fsDelete(path_1.default.join(dirname, 'yarn-lock.json'));
27
- npmlog_1.default.info(this.commandName, chalk_1.default.yellow('install'), 'Running ' + client + ' install');
27
+ npmlog_1.default.info(this.commandName, ansi_colors_1.default.yellow('install'), 'Running ' + client + ' install');
28
28
  return super._exec(this.repository.rootPackage, client + ' install', {
29
29
  stdio: 'inherit',
30
30
  });
@@ -46,7 +46,7 @@ class CleanInstallCommand extends run_command_js_1.RunCommand {
46
46
  }
47
47
  async _fsDelete(fileOrDir) {
48
48
  if (await (0, file_utils_js_1.fsExists)(fileOrDir)) {
49
- npmlog_1.default.info(this.commandName, chalk_1.default.yellow('rmdir'), path_1.default.relative(this.repository.dirname, fileOrDir));
49
+ npmlog_1.default.info(this.commandName, ansi_colors_1.default.yellow('rmdir'), path_1.default.relative(this.repository.dirname, fileOrDir));
50
50
  await (0, file_utils_js_1.fsDelete)(fileOrDir);
51
51
  }
52
52
  }
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ExecuteCommand = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
5
+ const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
6
6
  const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
7
7
  const power_tasks_1 = require("power-tasks");
8
8
  const command_js_1 = require("../core/command.js");
@@ -20,13 +20,13 @@ class ExecuteCommand extends multi_task_command_js_1.MultiTaskCommand {
20
20
  for (const p of packages) {
21
21
  const task = new power_tasks_1.Task(async () => {
22
22
  const t = Date.now();
23
- npmlog_1.default.verbose(this.commandName, p.name, chalk_1.default.cyanBright.bold('executing'), npmlog_1.default.separator, this.cmd + ' ' + (this.argv?.join(' ') || ''));
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
24
  const r = await (0, exec_js_1.exec)(this.cmd, {
25
25
  cwd: p.dirname,
26
26
  argv: this.argv,
27
27
  stdio: npmlog_1.default.levelIndex < 1000 ? 'inherit' : 'pipe',
28
28
  });
29
- npmlog_1.default.log(r.error ? 'error' : 'info', this.commandName, p.name, r.error ? chalk_1.default.red.bold('failed') : chalk_1.default.green.bold('success'), npmlog_1.default.separator, this.cmd, chalk_1.default.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') + ')');
30
30
  }, {
31
31
  name: p.name,
32
32
  dependencies: this.options.parallel ? undefined : p.dependencies,
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InfoCommand = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
5
+ const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
6
6
  const envinfo_1 = tslib_1.__importDefault(require("envinfo"));
7
7
  const semver_1 = tslib_1.__importDefault(require("semver"));
8
8
  const command_js_1 = require("../core/command.js");
@@ -21,22 +21,22 @@ class InfoCommand extends command_js_1.Command {
21
21
  }
22
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
23
  for (const [categoryName, category] of Object.entries(systemInfo)) {
24
- this.logger.output('', '', chalk_1.default.whiteBright(categoryName) + ':');
24
+ this.logger.output('', '', ansi_colors_1.default.whiteBright(categoryName) + ':');
25
25
  for (const [n, v] of Object.entries(category)) {
26
- const label = ' ' + chalk_1.default.reset(n) + ' '.repeat(maxName - n.length) + ' :';
26
+ const label = ' ' + ansi_colors_1.default.reset(n) + ' '.repeat(maxName - n.length) + ' :';
27
27
  if (typeof v === 'string') {
28
- this.logger.output('', label, chalk_1.default.yellowBright(v));
28
+ this.logger.output('', label, ansi_colors_1.default.yellowBright(v));
29
29
  continue;
30
30
  }
31
31
  if (v.version) {
32
- this.logger.output('', label, chalk_1.default.yellowBright(v.version), v.path ? ' ' + chalk_1.default.yellow(v.path) : '');
32
+ this.logger.output('', label, ansi_colors_1.default.yellowBright(v.version), v.path ? ' ' + ansi_colors_1.default.yellow(v.path) : '');
33
33
  }
34
34
  if (v.installed) {
35
35
  if (v.wanted === 'latest' || semver_1.default.intersects(v.installed, v.wanted)) {
36
- this.logger.output('', label, chalk_1.default.yellowBright(v.installed));
36
+ this.logger.output('', label, ansi_colors_1.default.yellowBright(v.installed));
37
37
  }
38
38
  else
39
- this.logger.output('', label, chalk_1.default.red(v.installed), ' => ', chalk_1.default.yellowBright(v.wanted));
39
+ this.logger.output('', label, ansi_colors_1.default.red(v.installed), ' => ', ansi_colors_1.default.yellowBright(v.wanted));
40
40
  }
41
41
  }
42
42
  }
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ListCommand = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
5
+ const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
6
6
  const easy_table_1 = tslib_1.__importDefault(require("easy-table"));
7
7
  const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
8
8
  const path_1 = tslib_1.__importDefault(require("path"));
@@ -69,10 +69,10 @@ class ListCommand extends command_js_1.Command {
69
69
  if (this.onPrintTable)
70
70
  this.onPrintTable(p, o, table);
71
71
  else {
72
- table.cell('Package', chalk_1.default.yellowBright(p.name));
73
- table.cell('Version', chalk_1.default.yellow(p.version));
74
- table.cell('Private', p.isPrivate ? chalk_1.default.magentaBright('yes') : '');
75
- table.cell('Changed', isDirty ? chalk_1.default.magenta('dirty') : isCommitted ? chalk_1.default.yellow('committed') : '');
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
76
  table.cell('Path', path_1.default.relative(repository.dirname, p.dirname));
77
77
  table.newRow();
78
78
  }
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PublishCommand = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
5
+ const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
6
6
  const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
7
7
  const path_1 = tslib_1.__importDefault(require("path"));
8
8
  const command_js_1 = require("../core/command.js");
@@ -22,7 +22,7 @@ class PublishCommand extends run_command_js_1.RunCommand {
22
22
  const selectedPackages = [];
23
23
  const promises = [];
24
24
  for (const p of packages) {
25
- const logPkgName = chalk_1.default.yellow(p.name);
25
+ const logPkgName = ansi_colors_1.default.yellow(p.name);
26
26
  if (p.json.private) {
27
27
  npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, `Ignored. Package is set to "private"`);
28
28
  continue;
@@ -35,19 +35,19 @@ class PublishCommand extends run_command_js_1.RunCommand {
35
35
  const sameVersion = !!(r && r.version === p.version);
36
36
  if (this.options.checkOnly) {
37
37
  npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, !r.version
38
- ? chalk_1.default.yellow('No package information found in repository')
38
+ ? ansi_colors_1.default.yellow('No package information found in repository')
39
39
  : sameVersion
40
- ? `No publish needed. Version (${chalk_1.default.magenta(p.version)}) same in repository`
40
+ ? `No publish needed. Version (${ansi_colors_1.default.magenta(p.version)}) same in repository`
41
41
  : `Publishing is possible.` +
42
- ` Version "${chalk_1.default.magenta(p.version)}" differs from version in repository (${chalk_1.default.magenta(r.version)})`);
42
+ ` Version "${ansi_colors_1.default.magenta(p.version)}" differs from version in repository (${ansi_colors_1.default.magenta(r.version)})`);
43
43
  return;
44
44
  }
45
45
  if (r && r.version === p.version) {
46
- npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, `No publish needed. Version (${chalk_1.default.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`);
47
47
  }
48
48
  else {
49
49
  npmlog_1.default.verbose(this.commandName, logPkgName, npmlog_1.default.separator, `Publishing is possible.` +
50
- ` Version "${chalk_1.default.magenta(p.version)}" differs from version in repository (${chalk_1.default.magenta(r.version)})`);
50
+ ` Version "${ansi_colors_1.default.magenta(p.version)}" differs from version in repository (${ansi_colors_1.default.magenta(r.version)})`);
51
51
  selectedPackages.push(p);
52
52
  }
53
53
  })
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RunCommand = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const parse_npm_script_1 = tslib_1.__importDefault(require("@netlify/parse-npm-script"));
6
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
+ const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
7
7
  const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
8
8
  const power_tasks_1 = require("power-tasks");
9
9
  const command_js_1 = require("../core/command.js");
@@ -75,17 +75,17 @@ class RunCommand extends multi_task_command_js_1.MultiTaskCommand {
75
75
  const name = pkg === this.repository.rootPackage ? 'root' : pkg.name;
76
76
  const logLevel = args.logLevel == null ? 'info' : args.logLevel;
77
77
  if (logLevel) {
78
- npmlog_1.default.verbose(this.commandName, chalk_1.default.cyan(name), npmlog_1.default.separator, chalk_1.default.cyanBright.bold(args.script), chalk_1.default.cyanBright.bold('executing'), npmlog_1.default.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);
79
79
  }
80
80
  const t = Date.now();
81
81
  const cwd = args.cwd || pkg.dirname;
82
82
  const r = await (0, exec_js_1.exec)(command, { cwd, stdio: args.stdio, throwOnError: false });
83
83
  if (logLevel) {
84
84
  if (r.error) {
85
- npmlog_1.default.error(this.commandName, chalk_1.default.cyan(name), npmlog_1.default.separator, chalk_1.default.cyanBright.bold(args.script), chalk_1.default.red.bold('failed'), npmlog_1.default.separator, command, npmlog_1.default.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());
86
86
  }
87
87
  else {
88
- npmlog_1.default.log(logLevel, this.commandName, chalk_1.default.cyan(name), npmlog_1.default.separator, chalk_1.default.cyanBright.bold(args.script), chalk_1.default.green.bold('success'), npmlog_1.default.separator, command, chalk_1.default.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)'));
89
89
  }
90
90
  }
91
91
  if (r.error && !args.noThrow)
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VersionCommand = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
5
+ const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
6
6
  const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
7
7
  const path_1 = tslib_1.__importDefault(require("path"));
8
8
  const power_tasks_1 = require("power-tasks");
@@ -32,13 +32,13 @@ class VersionCommand extends run_command_js_1.RunCommand {
32
32
  let status = '';
33
33
  let message = '';
34
34
  let newVer = '';
35
- const logPkgName = chalk_1.default.yellow(p.name);
35
+ const logPkgName = ansi_colors_1.default.yellow(p.name);
36
36
  if (!this.options.noTag) {
37
37
  const isDirty = dirtyFiles.find(f => !path_1.default.relative(relDir, f).startsWith('..'));
38
38
  if (isDirty) {
39
39
  if (!this.options.ignoreDirty)
40
40
  errorCount++;
41
- status = this.options.ignoreDirty ? chalk_1.default.cyan.bold('skip') : chalk_1.default.redBright.bold('error');
41
+ status = this.options.ignoreDirty ? ansi_colors_1.default.cyan.bold('skip') : ansi_colors_1.default.redBright.bold('error');
42
42
  message = 'Git directory is not clean';
43
43
  }
44
44
  }
@@ -51,7 +51,7 @@ class VersionCommand extends run_command_js_1.RunCommand {
51
51
  if (newVer)
52
52
  newVersions[p.name] = newVer;
53
53
  else {
54
- status = chalk_1.default.cyanBright.bold('no-change');
54
+ status = ansi_colors_1.default.cyanBright.bold('no-change');
55
55
  message = 'No change detected';
56
56
  }
57
57
  }
@@ -66,7 +66,7 @@ class VersionCommand extends run_command_js_1.RunCommand {
66
66
  });
67
67
  }
68
68
  else {
69
- npmlog_1.default.log(this.options.ignoreDirty ? 'info' : 'error', this.commandName, logPkgName, chalk_1.default.whiteBright(p.version), status, npmlog_1.default.separator, message);
69
+ npmlog_1.default.log(this.options.ignoreDirty ? 'info' : 'error', this.commandName, logPkgName, ansi_colors_1.default.whiteBright(p.version), status, npmlog_1.default.separator, message);
70
70
  }
71
71
  continue;
72
72
  }
@@ -147,7 +147,7 @@ class VersionCommand extends run_command_js_1.RunCommand {
147
147
  this._updatedPackages.add(p);
148
148
  }
149
149
  }
150
- npmlog_1.default.info(this.commandName, pkg.name, npmlog_1.default.separator, 'Version changed from ' + chalk_1.default.cyan(oldVer) + ' to ' + chalk_1.default.cyan(newVer));
150
+ npmlog_1.default.info(this.commandName, pkg.name, npmlog_1.default.separator, 'Version changed from ' + ansi_colors_1.default.cyan(oldVer) + ' to ' + ansi_colors_1.default.cyan(newVer));
151
151
  return { code: 0 };
152
152
  }
153
153
  return super._exec(pkg, command, args, options);
@@ -3,14 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Command = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  require("./logger.js");
6
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
- const figures_1 = tslib_1.__importDefault(require("figures"));
6
+ const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
8
7
  const is_ci_1 = tslib_1.__importDefault(require("is-ci"));
9
8
  const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
10
9
  const putil_merge_1 = tslib_1.__importDefault(require("putil-merge"));
11
10
  const strict_typed_events_1 = require("strict-typed-events");
12
11
  const constants_js_1 = require("./constants.js");
13
12
  const noOp = () => undefined;
13
+ const lineVerticalDashed0 = '┆';
14
14
  class Command extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict_typed_events_1.AsyncEventEmitter) {
15
15
  constructor(options) {
16
16
  super();
@@ -20,7 +20,7 @@ class Command extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict_t
20
20
  this._options = options || {};
21
21
  if (is_ci_1.default)
22
22
  this.options.ci = true;
23
- this.logger.separator = chalk_1.default.gray(figures_1.default.lineVerticalDashed0);
23
+ this.logger.separator = ansi_colors_1.default.gray(lineVerticalDashed0);
24
24
  Object.defineProperty(this.logger, 'levelIndex', {
25
25
  get() {
26
26
  return npmlog_1.default.levels[npmlog_1.default.level] || 0;
@@ -8,7 +8,6 @@ const tslib_1 = require("tslib");
8
8
  * Inspired from [npm-run-path](https://github.com/sindresorhus/npm-run-path)
9
9
  */
10
10
  const path_1 = tslib_1.__importDefault(require("path"));
11
- const path_key_1 = tslib_1.__importDefault(require("path-key"));
12
11
  const process_1 = tslib_1.__importDefault(require("process"));
13
12
  /**
14
13
  Get your [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) prepended with locally installed binaries.
@@ -25,7 +24,7 @@ const process_1 = tslib_1.__importDefault(require("process"));
25
24
  */
26
25
  function npmRunPath(options = {}) {
27
26
  const cwd = options.cwd || process_1.default.cwd();
28
- const path_ = options.path || process_1.default.env[(0, path_key_1.default)()];
27
+ const path_ = options.path || process_1.default.env[pathKey()];
29
28
  const execPath = options.execPath || process_1.default.execPath;
30
29
  let previous;
31
30
  let cwdPath = path_1.default.resolve(cwd);
@@ -39,6 +38,16 @@ function npmRunPath(options = {}) {
39
38
  result.push(path_1.default.resolve(cwd, execPath, '..'));
40
39
  return [...result, path_].join(path_1.default.delimiter);
41
40
  }
41
+ function pathKey(options) {
42
+ const env = options?.env || process_1.default.env;
43
+ const platform = options?.platform || process_1.default.platform;
44
+ if (platform !== 'win32') {
45
+ return 'PATH';
46
+ }
47
+ return (Object.keys(env)
48
+ .reverse()
49
+ .find(key => key.toUpperCase() === 'PATH') || 'Path');
50
+ }
42
51
  /**
43
52
  @returns The augmented [`process.env`](https://nodejs.org/api/process.html#process_process_env) object.
44
53
  @example
@@ -47,13 +56,13 @@ function npmRunPath(options = {}) {
47
56
  import {npmRunPathEnv} from 'npm-run-path';
48
57
  // `foo` is a locally installed binary
49
58
  childProcess.execFileSync('foo', {
50
- env: npmRunPathEnv()
51
- });
59
+ env: npmRunPathEnv()
60
+ });
52
61
  ```
53
62
  */
54
63
  function npmRunPathEnv(options = {}) {
55
64
  const env = { ...(options.env || process_1.default.env) };
56
- const path_ = (0, path_key_1.default)({ env });
65
+ const path_ = pathKey({ env });
57
66
  const opts = { ...options, path: env[path_] };
58
67
  env[path_] = npmRunPath(opts);
59
68
  return env;
package/esm/cli.js CHANGED
@@ -1,28 +1,32 @@
1
- import chalk from 'chalk';
2
- import fs from 'fs/promises';
3
- import logger from 'npmlog';
4
- import path from 'path';
5
- import yargs from 'yargs';
6
- import { BuildCommand } from './commands/build-command.js';
7
- import { ChangedCommand } from './commands/changed-command.js';
8
- import { CleanInstallCommand } from './commands/ci-command.js';
9
- import { ExecuteCommand } from './commands/execute-command.js';
10
- import { InfoCommand } from './commands/info-command.js';
11
- import { ListCommand } from './commands/list-command.js';
12
- import { PublishCommand } from './commands/publish-command.js';
13
- import { RunCommand } from './commands/run-command.js';
14
- import { VersionCommand } from './commands/version-command.js';
15
- import { Command } from './core/command.js';
16
- import { Repository } from './core/repository.js';
17
- import { getDirname } from './utils/get-dirname.js';
18
- export async function runCli(options) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runCli = runCli;
4
+ const tslib_1 = require("tslib");
5
+ const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
6
+ const promises_1 = tslib_1.__importDefault(require("fs/promises"));
7
+ const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
8
+ const path_1 = tslib_1.__importDefault(require("path"));
9
+ const yargs_1 = tslib_1.__importDefault(require("yargs"));
10
+ const build_command_js_1 = require("./commands/build-command.js");
11
+ const changed_command_js_1 = require("./commands/changed-command.js");
12
+ const ci_command_js_1 = require("./commands/ci-command.js");
13
+ const execute_command_js_1 = require("./commands/execute-command.js");
14
+ const info_command_js_1 = require("./commands/info-command.js");
15
+ const list_command_js_1 = require("./commands/list-command.js");
16
+ const publish_command_js_1 = require("./commands/publish-command.js");
17
+ const run_command_js_1 = require("./commands/run-command.js");
18
+ const version_command_js_1 = require("./commands/version-command.js");
19
+ const command_js_1 = require("./core/command.js");
20
+ const repository_js_1 = require("./core/repository.js");
21
+ const get_dirname_js_1 = require("./utils/get-dirname.js");
22
+ async function runCli(options) {
19
23
  try {
20
- const s = path.resolve(getDirname(), '../package.json');
21
- const pkgJson = JSON.parse(await fs.readFile(s, 'utf-8'));
22
- const repository = Repository.create(options?.cwd);
24
+ const s = path_1.default.resolve((0, get_dirname_js_1.getDirname)(), '../package.json');
25
+ const pkgJson = JSON.parse(await promises_1.default.readFile(s, 'utf-8'));
26
+ const repository = repository_js_1.Repository.create(options?.cwd);
23
27
  const _argv = options?.argv || process.argv.slice(2);
24
- const globalKeys = Object.keys(Command.globalOptions).concat(['help', 'version']);
25
- const program = yargs(_argv)
28
+ const globalKeys = Object.keys(command_js_1.Command.globalOptions).concat(['help', 'version']);
29
+ const program = (0, yargs_1.default)(_argv)
26
30
  // .scriptName('rman')
27
31
  .strict()
28
32
  .version(pkgJson.version || '')
@@ -34,35 +38,35 @@ export async function runCli(options) {
34
38
  .fail((msg, err) => {
35
39
  if (!err?.logged) {
36
40
  const text = msg
37
- ? msg + '\n\n' + chalk.whiteBright('Run with --help for available options')
41
+ ? msg + '\n\n' + ansi_colors_1.default.whiteBright('Run with --help for available options')
38
42
  : err
39
43
  ? err.message
40
44
  : '';
41
45
  // eslint-disable-next-line no-console
42
- console.log('\n' + chalk.red(text));
46
+ console.log('\n' + ansi_colors_1.default.red(text));
43
47
  throw msg;
44
48
  }
45
49
  else
46
50
  process.exit(1);
47
51
  })
48
52
  // group options under "Global Options:" header
49
- .options(Command.globalOptions)
53
+ .options(command_js_1.Command.globalOptions)
50
54
  .group(globalKeys, 'Global Options:');
51
- InfoCommand.initCli(repository, program);
52
- ListCommand.initCli(repository, program);
53
- ChangedCommand.initCli(repository, program);
54
- ExecuteCommand.initCli(repository, program);
55
- RunCommand.initCli(repository, program);
56
- VersionCommand.initCli(repository, program);
57
- PublishCommand.initCli(repository, program);
58
- CleanInstallCommand.initCli(repository, program);
59
- BuildCommand.initCli(repository, program);
55
+ info_command_js_1.InfoCommand.initCli(repository, program);
56
+ list_command_js_1.ListCommand.initCli(repository, program);
57
+ changed_command_js_1.ChangedCommand.initCli(repository, program);
58
+ execute_command_js_1.ExecuteCommand.initCli(repository, program);
59
+ run_command_js_1.RunCommand.initCli(repository, program);
60
+ version_command_js_1.VersionCommand.initCli(repository, program);
61
+ publish_command_js_1.PublishCommand.initCli(repository, program);
62
+ ci_command_js_1.CleanInstallCommand.initCli(repository, program);
63
+ build_command_js_1.BuildCommand.initCli(repository, program);
60
64
  if (!_argv.length)
61
65
  program.showHelp();
62
66
  else
63
67
  await program.parseAsync().catch(() => process.exit(1));
64
68
  }
65
69
  catch (e) {
66
- logger.error('rman', e);
70
+ npmlog_1.default.error('rman', e);
67
71
  }
68
72
  }
@@ -1,11 +1,15 @@
1
- import { Command } from '../core/command.js';
2
- import { RunCommand } from './run-command.js';
3
- export class BuildCommand extends RunCommand {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BuildCommand = void 0;
4
+ const command_js_1 = require("../core/command.js");
5
+ const run_command_js_1 = require("./run-command.js");
6
+ class BuildCommand extends run_command_js_1.RunCommand {
4
7
  constructor(repository, options) {
5
8
  super(repository, 'build', options);
6
9
  this.repository = repository;
7
10
  }
8
11
  }
12
+ exports.BuildCommand = BuildCommand;
9
13
  BuildCommand.commandName = 'build';
10
14
  (function (BuildCommand) {
11
15
  function initCli(repository, program) {
@@ -14,10 +18,10 @@ BuildCommand.commandName = 'build';
14
18
  describe: 'Alias for "run build"',
15
19
  builder: cmd => cmd.example('$0 build', '# Builds packages').option(BuildCommand.cliCommandOptions),
16
20
  handler: async (args) => {
17
- const options = Command.composeOptions(BuildCommand.commandName, args, repository.config);
21
+ const options = command_js_1.Command.composeOptions(BuildCommand.commandName, args, repository.config);
18
22
  await new BuildCommand(repository, options).execute();
19
23
  },
20
24
  });
21
25
  }
22
26
  BuildCommand.initCli = initCli;
23
- })(BuildCommand || (BuildCommand = {}));
27
+ })(BuildCommand || (exports.BuildCommand = BuildCommand = {}));
@@ -1,6 +1,9 @@
1
- import { Command } from '../core/command.js';
2
- import { ListCommand } from './list-command.js';
3
- export class ChangedCommand extends ListCommand {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChangedCommand = void 0;
4
+ const command_js_1 = require("../core/command.js");
5
+ const list_command_js_1 = require("./list-command.js");
6
+ class ChangedCommand extends list_command_js_1.ListCommand {
4
7
  constructor(repository, options) {
5
8
  super(repository, options);
6
9
  this.repository = repository;
@@ -11,6 +14,7 @@ export class ChangedCommand extends ListCommand {
11
14
  return !!(inf.isDirty || inf.isCommitted);
12
15
  }
13
16
  }
17
+ exports.ChangedCommand = ChangedCommand;
14
18
  ChangedCommand.commandName = 'changed';
15
19
  (function (ChangedCommand) {
16
20
  function initCli(repository, program) {
@@ -20,12 +24,12 @@ ChangedCommand.commandName = 'changed';
20
24
  builder: cmd => cmd
21
25
  .example('$0 changed', '# List changed packages')
22
26
  .example('$0 changed --json', '# List changed packages in JSON format')
23
- .option(ListCommand.cliCommandOptions),
27
+ .option(list_command_js_1.ListCommand.cliCommandOptions),
24
28
  handler: async (args) => {
25
- const options = Command.composeOptions(ChangedCommand.commandName, args, repository.config);
29
+ const options = command_js_1.Command.composeOptions(ChangedCommand.commandName, args, repository.config);
26
30
  await new ChangedCommand(repository, options).execute();
27
31
  },
28
32
  });
29
33
  }
30
34
  ChangedCommand.initCli = initCli;
31
- })(ChangedCommand || (ChangedCommand = {}));
35
+ })(ChangedCommand || (exports.ChangedCommand = ChangedCommand = {}));
@@ -1,11 +1,15 @@
1
- import chalk from 'chalk';
2
- import logger from 'npmlog';
3
- import path from 'path';
4
- import { Task } from 'power-tasks';
5
- import { Command } from '../core/command.js';
6
- import { fsDelete, fsExists } from '../utils/file-utils.js';
7
- import { RunCommand } from './run-command.js';
8
- export class CleanInstallCommand extends RunCommand {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CleanInstallCommand = 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 power_tasks_1 = require("power-tasks");
9
+ const command_js_1 = require("../core/command.js");
10
+ const file_utils_js_1 = require("../utils/file-utils.js");
11
+ const run_command_js_1 = require("./run-command.js");
12
+ class CleanInstallCommand extends run_command_js_1.RunCommand {
9
13
  constructor(repository, options) {
10
14
  super(repository, 'ci', options);
11
15
  this.repository = repository;
@@ -15,12 +19,12 @@ export class CleanInstallCommand extends RunCommand {
15
19
  const client = this.repository.config.client || 'npm';
16
20
  if (!(client === 'npm' || client === 'yargs'))
17
21
  throw new Error(`Invalid npm client "${client}"`);
18
- tasks.push(new Task(async () => {
22
+ tasks.push(new power_tasks_1.Task(async () => {
19
23
  const dirname = this.repository.dirname;
20
- await this._fsDelete(path.join(dirname, 'node_modules'));
21
- await this._fsDelete(path.join(dirname, 'package-lock.json'));
22
- await this._fsDelete(path.join(dirname, 'yarn-lock.json'));
23
- logger.info(this.commandName, chalk.yellow('install'), 'Running ' + client + ' install');
24
+ await this._fsDelete(path_1.default.join(dirname, 'node_modules'));
25
+ await this._fsDelete(path_1.default.join(dirname, 'package-lock.json'));
26
+ await this._fsDelete(path_1.default.join(dirname, 'yarn-lock.json'));
27
+ npmlog_1.default.info(this.commandName, ansi_colors_1.default.yellow('install'), 'Running ' + client + ' install');
24
28
  return super._exec(this.repository.rootPackage, client + ' install', {
25
29
  stdio: 'inherit',
26
30
  });
@@ -31,26 +35,27 @@ export class CleanInstallCommand extends RunCommand {
31
35
  if (command === '#') {
32
36
  if (pkg === this.repository.rootPackage)
33
37
  return { code: 0 };
34
- logger.info(this.commandName, 'Clearing ' + pkg.name);
38
+ npmlog_1.default.info(this.commandName, 'Clearing ' + pkg.name);
35
39
  const cwd = args.cwd || pkg.dirname;
36
- await this._fsDelete(path.join(cwd, 'node_modules'));
37
- await this._fsDelete(path.join(cwd, 'package-lock.json'));
38
- await this._fsDelete(path.join(cwd, 'yarn-lock.json'));
40
+ await this._fsDelete(path_1.default.join(cwd, 'node_modules'));
41
+ await this._fsDelete(path_1.default.join(cwd, 'package-lock.json'));
42
+ await this._fsDelete(path_1.default.join(cwd, 'yarn-lock.json'));
39
43
  return { code: 0 };
40
44
  }
41
45
  return super._exec(pkg, command, args, ctx);
42
46
  }
43
47
  async _fsDelete(fileOrDir) {
44
- if (await fsExists(fileOrDir)) {
45
- logger.info(this.commandName, chalk.yellow('rmdir'), path.relative(this.repository.dirname, fileOrDir));
46
- await fsDelete(fileOrDir);
48
+ if (await (0, file_utils_js_1.fsExists)(fileOrDir)) {
49
+ npmlog_1.default.info(this.commandName, ansi_colors_1.default.yellow('rmdir'), path_1.default.relative(this.repository.dirname, fileOrDir));
50
+ await (0, file_utils_js_1.fsDelete)(fileOrDir);
47
51
  }
48
52
  }
49
53
  }
54
+ exports.CleanInstallCommand = CleanInstallCommand;
50
55
  CleanInstallCommand.commandName = 'ci';
51
56
  (function (CleanInstallCommand) {
52
57
  CleanInstallCommand.cliCommandOptions = {
53
- ...RunCommand.cliCommandOptions,
58
+ ...run_command_js_1.RunCommand.cliCommandOptions,
54
59
  };
55
60
  function initCli(repository, program) {
56
61
  program.command({
@@ -58,10 +63,10 @@ CleanInstallCommand.commandName = 'ci';
58
63
  describe: 'Deletes all dependency modules and re-installs',
59
64
  builder: cmd => cmd.example('$0 ci', '').option(CleanInstallCommand.cliCommandOptions),
60
65
  handler: async (args) => {
61
- const options = Command.composeOptions(CleanInstallCommand.commandName, args, repository.config);
66
+ const options = command_js_1.Command.composeOptions(CleanInstallCommand.commandName, args, repository.config);
62
67
  await new CleanInstallCommand(repository, options).execute();
63
68
  },
64
69
  });
65
70
  }
66
71
  CleanInstallCommand.initCli = initCli;
67
- })(CleanInstallCommand || (CleanInstallCommand = {}));
72
+ })(CleanInstallCommand || (exports.CleanInstallCommand = CleanInstallCommand = {}));