rman 0.30.0 → 0.31.1

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 (37) hide show
  1. package/cjs/package.json +3 -0
  2. package/esm/cli.js +36 -40
  3. package/esm/commands/build-command.js +5 -9
  4. package/esm/commands/changed-command.js +6 -10
  5. package/esm/commands/ci-command.js +23 -28
  6. package/esm/commands/execute-command.js +15 -20
  7. package/esm/commands/info-command.js +15 -20
  8. package/esm/commands/list-command.js +25 -30
  9. package/esm/commands/multi-task-command.js +11 -16
  10. package/esm/commands/publish-command.js +23 -28
  11. package/esm/commands/run-command.js +19 -24
  12. package/esm/commands/version-command.js +30 -35
  13. package/esm/core/command.js +18 -23
  14. package/esm/core/constants.js +1 -4
  15. package/esm/core/logger.js +2 -5
  16. package/esm/core/package.js +6 -11
  17. package/esm/core/repository.js +28 -33
  18. package/esm/index.js +1 -4
  19. package/esm/package.json +3 -0
  20. package/esm/utils/exec.js +7 -10
  21. package/esm/utils/file-utils.js +11 -17
  22. package/esm/utils/get-dirname.js +8 -13
  23. package/esm/utils/git-utils.js +9 -14
  24. package/esm/utils/npm-run-path.js +15 -20
  25. package/esm/utils/npm-utils.js +4 -9
  26. package/package.json +18 -10
  27. package/types/commands/build-command.d.ts +1 -1
  28. package/types/commands/changed-command.d.ts +1 -1
  29. package/types/commands/ci-command.d.ts +1 -1
  30. package/types/commands/execute-command.d.ts +1 -1
  31. package/types/commands/info-command.d.ts +1 -1
  32. package/types/commands/list-command.d.ts +1 -1
  33. package/types/commands/multi-task-command.d.ts +1 -1
  34. package/types/commands/publish-command.d.ts +1 -1
  35. package/types/commands/run-command.d.ts +1 -1
  36. package/types/commands/version-command.d.ts +1 -1
  37. package/types/core/command.d.ts +1 -1
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
package/esm/cli.js CHANGED
@@ -1,32 +1,28 @@
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) {
1
+ import colors from 'ansi-colors';
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) {
23
19
  try {
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);
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);
27
23
  const _argv = options?.argv || process.argv.slice(2);
28
- const globalKeys = Object.keys(command_js_1.Command.globalOptions).concat(['help', 'version']);
29
- const program = (0, yargs_1.default)(_argv)
24
+ const globalKeys = Object.keys(Command.globalOptions).concat(['help', 'version']);
25
+ const program = yargs(_argv)
30
26
  // .scriptName('rman')
31
27
  .strict()
32
28
  .version(pkgJson.version || '')
@@ -38,35 +34,35 @@ async function runCli(options) {
38
34
  .fail((msg, err) => {
39
35
  if (!err?.logged) {
40
36
  const text = msg
41
- ? msg + '\n\n' + ansi_colors_1.default.whiteBright('Run with --help for available options')
37
+ ? msg + '\n\n' + colors.whiteBright('Run with --help for available options')
42
38
  : err
43
39
  ? err.message
44
40
  : '';
45
41
  // eslint-disable-next-line no-console
46
- console.log('\n' + ansi_colors_1.default.red(text));
42
+ console.log('\n' + colors.red(text));
47
43
  throw msg;
48
44
  }
49
45
  else
50
46
  process.exit(1);
51
47
  })
52
48
  // group options under "Global Options:" header
53
- .options(command_js_1.Command.globalOptions)
49
+ .options(Command.globalOptions)
54
50
  .group(globalKeys, 'Global Options:');
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);
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);
64
60
  if (!_argv.length)
65
61
  program.showHelp();
66
62
  else
67
63
  await program.parseAsync().catch(() => process.exit(1));
68
64
  }
69
65
  catch (e) {
70
- npmlog_1.default.error('rman', e);
66
+ logger.error('rman', e);
71
67
  }
72
68
  }
@@ -1,15 +1,11 @@
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 {
1
+ import { Command } from '../core/command.js';
2
+ import { RunCommand } from './run-command.js';
3
+ export class BuildCommand extends RunCommand {
7
4
  constructor(repository, options) {
8
5
  super(repository, 'build', options);
9
6
  this.repository = repository;
10
7
  }
11
8
  }
12
- exports.BuildCommand = BuildCommand;
13
9
  BuildCommand.commandName = 'build';
14
10
  (function (BuildCommand) {
15
11
  function initCli(repository, program) {
@@ -18,10 +14,10 @@ BuildCommand.commandName = 'build';
18
14
  describe: 'Alias for "run build"',
19
15
  builder: cmd => cmd.example('$0 build', '# Builds packages').option(BuildCommand.cliCommandOptions),
20
16
  handler: async (args) => {
21
- const options = command_js_1.Command.composeOptions(BuildCommand.commandName, args, repository.config);
17
+ const options = Command.composeOptions(BuildCommand.commandName, args, repository.config);
22
18
  await new BuildCommand(repository, options).execute();
23
19
  },
24
20
  });
25
21
  }
26
22
  BuildCommand.initCli = initCli;
27
- })(BuildCommand || (exports.BuildCommand = BuildCommand = {}));
23
+ })(BuildCommand || (BuildCommand = {}));
@@ -1,9 +1,6 @@
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 {
1
+ import { Command } from '../core/command.js';
2
+ import { ListCommand } from './list-command.js';
3
+ export class ChangedCommand extends ListCommand {
7
4
  constructor(repository, options) {
8
5
  super(repository, options);
9
6
  this.repository = repository;
@@ -14,7 +11,6 @@ class ChangedCommand extends list_command_js_1.ListCommand {
14
11
  return !!(inf.isDirty || inf.isCommitted);
15
12
  }
16
13
  }
17
- exports.ChangedCommand = ChangedCommand;
18
14
  ChangedCommand.commandName = 'changed';
19
15
  (function (ChangedCommand) {
20
16
  function initCli(repository, program) {
@@ -24,12 +20,12 @@ ChangedCommand.commandName = 'changed';
24
20
  builder: cmd => cmd
25
21
  .example('$0 changed', '# List changed packages')
26
22
  .example('$0 changed --json', '# List changed packages in JSON format')
27
- .option(list_command_js_1.ListCommand.cliCommandOptions),
23
+ .option(ListCommand.cliCommandOptions),
28
24
  handler: async (args) => {
29
- const options = command_js_1.Command.composeOptions(ChangedCommand.commandName, args, repository.config);
25
+ const options = Command.composeOptions(ChangedCommand.commandName, args, repository.config);
30
26
  await new ChangedCommand(repository, options).execute();
31
27
  },
32
28
  });
33
29
  }
34
30
  ChangedCommand.initCli = initCli;
35
- })(ChangedCommand || (exports.ChangedCommand = ChangedCommand = {}));
31
+ })(ChangedCommand || (ChangedCommand = {}));
@@ -1,15 +1,11 @@
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 {
1
+ import colors from 'ansi-colors';
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 {
13
9
  constructor(repository, options) {
14
10
  super(repository, 'ci', options);
15
11
  this.repository = repository;
@@ -19,12 +15,12 @@ class CleanInstallCommand extends run_command_js_1.RunCommand {
19
15
  const client = this.repository.config.client || 'npm';
20
16
  if (!(client === 'npm' || client === 'yargs'))
21
17
  throw new Error(`Invalid npm client "${client}"`);
22
- tasks.push(new power_tasks_1.Task(async () => {
18
+ tasks.push(new Task(async () => {
23
19
  const dirname = this.repository.dirname;
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');
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, colors.yellow('install'), 'Running ' + client + ' install');
28
24
  return super._exec(this.repository.rootPackage, client + ' install', {
29
25
  stdio: 'inherit',
30
26
  });
@@ -35,27 +31,26 @@ class CleanInstallCommand extends run_command_js_1.RunCommand {
35
31
  if (command === '#') {
36
32
  if (pkg === this.repository.rootPackage)
37
33
  return { code: 0 };
38
- npmlog_1.default.info(this.commandName, 'Clearing ' + pkg.name);
34
+ logger.info(this.commandName, 'Clearing ' + pkg.name);
39
35
  const cwd = args.cwd || pkg.dirname;
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'));
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'));
43
39
  return { code: 0 };
44
40
  }
45
41
  return super._exec(pkg, command, args, ctx);
46
42
  }
47
43
  async _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);
44
+ if (await fsExists(fileOrDir)) {
45
+ logger.info(this.commandName, colors.yellow('rmdir'), path.relative(this.repository.dirname, fileOrDir));
46
+ await fsDelete(fileOrDir);
51
47
  }
52
48
  }
53
49
  }
54
- exports.CleanInstallCommand = CleanInstallCommand;
55
50
  CleanInstallCommand.commandName = 'ci';
56
51
  (function (CleanInstallCommand) {
57
52
  CleanInstallCommand.cliCommandOptions = {
58
- ...run_command_js_1.RunCommand.cliCommandOptions,
53
+ ...RunCommand.cliCommandOptions,
59
54
  };
60
55
  function initCli(repository, program) {
61
56
  program.command({
@@ -63,10 +58,10 @@ CleanInstallCommand.commandName = 'ci';
63
58
  describe: 'Deletes all dependency modules and re-installs',
64
59
  builder: cmd => cmd.example('$0 ci', '').option(CleanInstallCommand.cliCommandOptions),
65
60
  handler: async (args) => {
66
- const options = command_js_1.Command.composeOptions(CleanInstallCommand.commandName, args, repository.config);
61
+ const options = Command.composeOptions(CleanInstallCommand.commandName, args, repository.config);
67
62
  await new CleanInstallCommand(repository, options).execute();
68
63
  },
69
64
  });
70
65
  }
71
66
  CleanInstallCommand.initCli = initCli;
72
- })(CleanInstallCommand || (exports.CleanInstallCommand = CleanInstallCommand = {}));
67
+ })(CleanInstallCommand || (CleanInstallCommand = {}));
@@ -1,14 +1,10 @@
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 {
1
+ import colors from 'ansi-colors';
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 {
12
8
  constructor(repository, cmd, argv, options) {
13
9
  super(repository, options);
14
10
  this.repository = repository;
@@ -18,15 +14,15 @@ class ExecuteCommand extends multi_task_command_js_1.MultiTaskCommand {
18
14
  _prepareTasks(packages) {
19
15
  const tasks = [];
20
16
  for (const p of packages) {
21
- const task = new power_tasks_1.Task(async () => {
17
+ const task = new Task(async () => {
22
18
  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, {
19
+ logger.verbose(this.commandName, p.name, colors.cyanBright.bold('executing'), logger.separator, this.cmd + ' ' + (this.argv?.join(' ') || ''));
20
+ const r = await exec(this.cmd, {
25
21
  cwd: p.dirname,
26
22
  argv: this.argv,
27
- stdio: npmlog_1.default.levelIndex < 1000 ? 'inherit' : 'pipe',
23
+ stdio: logger.levelIndex < 1000 ? 'inherit' : 'pipe',
28
24
  });
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') + ')');
25
+ logger.log(r.error ? 'error' : 'info', this.commandName, p.name, r.error ? colors.red.bold('failed') : colors.green.bold('success'), logger.separator, this.cmd, colors.yellow(' (' + (Date.now() - t) + ' ms') + ')');
30
26
  }, {
31
27
  name: p.name,
32
28
  dependencies: this.options.parallel ? undefined : p.dependencies,
@@ -38,11 +34,10 @@ class ExecuteCommand extends multi_task_command_js_1.MultiTaskCommand {
38
34
  return tasks;
39
35
  }
40
36
  }
41
- exports.ExecuteCommand = ExecuteCommand;
42
37
  ExecuteCommand.commandName = 'exec';
43
38
  (function (ExecuteCommand) {
44
39
  ExecuteCommand.cliCommandOptions = {
45
- ...multi_task_command_js_1.MultiTaskCommand.cliCommandOptions,
40
+ ...MultiTaskCommand.cliCommandOptions,
46
41
  };
47
42
  function initCli(repository, program) {
48
43
  program.command({
@@ -65,10 +60,10 @@ ExecuteCommand.commandName = 'exec';
65
60
  .option(ExecuteCommand.cliCommandOptions),
66
61
  handler: async (args) => {
67
62
  const argv = args['--'] || [];
68
- const options = command_js_1.Command.composeOptions(ExecuteCommand.commandName, args, repository.config);
63
+ const options = Command.composeOptions(ExecuteCommand.commandName, args, repository.config);
69
64
  await new ExecuteCommand(repository, '' + argv.shift(), argv, options).execute();
70
65
  },
71
66
  });
72
67
  }
73
68
  ExecuteCommand.initCli = initCli;
74
- })(ExecuteCommand || (exports.ExecuteCommand = ExecuteCommand = {}));
69
+ })(ExecuteCommand || (ExecuteCommand = {}));
@@ -1,14 +1,10 @@
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 {
1
+ import colors from 'ansi-colors';
2
+ import envinfo from 'envinfo';
3
+ import semver from 'semver';
4
+ import { Command } from '../core/command.js';
5
+ export class InfoCommand extends Command {
10
6
  async _execute() {
11
- const systemInfo = JSON.parse(await envinfo_1.default.run({
7
+ const systemInfo = JSON.parse(await envinfo.run({
12
8
  System: ['OS', 'CPU', 'Memory', 'Shell'],
13
9
  Binaries: ['Node', 'Yarn', 'npm'],
14
10
  Utilities: ['Git'],
@@ -21,28 +17,27 @@ class InfoCommand extends command_js_1.Command {
21
17
  }
22
18
  const maxName = Object.keys(systemInfo).reduce((l, p) => Object.keys(systemInfo[p]).reduce((i, x) => (l = Math.max(i, x.length)), l), 0);
23
19
  for (const [categoryName, category] of Object.entries(systemInfo)) {
24
- this.logger.output('', '', ansi_colors_1.default.whiteBright(categoryName) + ':');
20
+ this.logger.output('', '', colors.whiteBright(categoryName) + ':');
25
21
  for (const [n, v] of Object.entries(category)) {
26
- const label = ' ' + ansi_colors_1.default.reset(n) + ' '.repeat(maxName - n.length) + ' :';
22
+ const label = ' ' + colors.reset(n) + ' '.repeat(maxName - n.length) + ' :';
27
23
  if (typeof v === 'string') {
28
- this.logger.output('', label, ansi_colors_1.default.yellowBright(v));
24
+ this.logger.output('', label, colors.yellowBright(v));
29
25
  continue;
30
26
  }
31
27
  if (v.version) {
32
- this.logger.output('', label, ansi_colors_1.default.yellowBright(v.version), v.path ? ' ' + ansi_colors_1.default.yellow(v.path) : '');
28
+ this.logger.output('', label, colors.yellowBright(v.version), v.path ? ' ' + colors.yellow(v.path) : '');
33
29
  }
34
30
  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));
31
+ if (v.wanted === 'latest' || semver.intersects(v.installed, v.wanted)) {
32
+ this.logger.output('', label, colors.yellowBright(v.installed));
37
33
  }
38
34
  else
39
- this.logger.output('', label, ansi_colors_1.default.red(v.installed), ' => ', ansi_colors_1.default.yellowBright(v.wanted));
35
+ this.logger.output('', label, colors.red(v.installed), ' => ', colors.yellowBright(v.wanted));
40
36
  }
41
37
  }
42
38
  }
43
39
  }
44
40
  }
45
- exports.InfoCommand = InfoCommand;
46
41
  InfoCommand.commandName = 'info';
47
42
  (function (InfoCommand) {
48
43
  function initCli(repository, program) {
@@ -51,10 +46,10 @@ InfoCommand.commandName = 'info';
51
46
  describe: 'Prints local environment information',
52
47
  builder: cmd => cmd.example('$0 info', '# Prints information').example('$0 info --json', '# Prints information in JSON format'),
53
48
  handler: async (args) => {
54
- const options = command_js_1.Command.composeOptions(InfoCommand.commandName, args, repository.config);
49
+ const options = Command.composeOptions(InfoCommand.commandName, args, repository.config);
55
50
  await new InfoCommand(options).execute();
56
51
  },
57
52
  });
58
53
  }
59
54
  InfoCommand.initCli = initCli;
60
- })(InfoCommand || (exports.InfoCommand = InfoCommand = {}));
55
+ })(InfoCommand || (InfoCommand = {}));
@@ -1,14 +1,10 @@
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 {
1
+ import colors from 'ansi-colors';
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 {
12
8
  constructor(repository, options) {
13
9
  super(options);
14
10
  this.repository = repository;
@@ -20,16 +16,16 @@ class ListCommand extends command_js_1.Command {
20
16
  async _execute() {
21
17
  const { repository } = this;
22
18
  const packages = repository.getPackages({ toposort: this.options.toposort });
23
- const git = new git_utils_js_1.GitHelper({ cwd: repository.dirname });
19
+ const git = new GitHelper({ cwd: repository.dirname });
24
20
  const dirtyFiles = await git.listDirtyFiles({ absolute: true });
25
21
  const committedFiles = await git.listCommittedFiles({ absolute: true });
26
- const table = new easy_table_1.default();
22
+ const table = new EasyTable();
27
23
  const arr = [];
28
24
  const obj = {};
29
25
  let count = 0;
30
26
  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('..'));
27
+ const isDirty = !!dirtyFiles.find(f => !path.relative(p.dirname, f).startsWith('..'));
28
+ const isCommitted = !!committedFiles.find(f => !path.relative(p.dirname, f).startsWith('..'));
33
29
  if (!this._filter(p, { isDirty, isCommitted }))
34
30
  continue;
35
31
  if (this.options.graph) {
@@ -37,7 +33,7 @@ class ListCommand extends command_js_1.Command {
37
33
  obj[p.name] = [...p.dependencies];
38
34
  continue;
39
35
  }
40
- const location = path_1.default.relative(repository.dirname, p.dirname);
36
+ const location = path.relative(repository.dirname, p.dirname);
41
37
  let o = {
42
38
  name: p.name,
43
39
  version: p.version,
@@ -60,44 +56,43 @@ class ListCommand extends command_js_1.Command {
60
56
  p.isPrivate ? 'PRIVATE' : '',
61
57
  isDirty ? 'DIRTY' : isCommitted ? ':COMMITTED' : '',
62
58
  ];
63
- npmlog_1.default.output('', a.join('::'));
59
+ logger.output('', a.join('::'));
64
60
  }
65
61
  else if (this.options.short) {
66
- npmlog_1.default.output('', p.name);
62
+ logger.output('', p.name);
67
63
  }
68
64
  else {
69
65
  if (this.onPrintTable)
70
66
  this.onPrintTable(p, o, table);
71
67
  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));
68
+ table.cell('Package', colors.yellowBright(p.name));
69
+ table.cell('Version', colors.yellow(p.version));
70
+ table.cell('Private', p.isPrivate ? colors.magentaBright('yes') : '');
71
+ table.cell('Changed', isDirty ? colors.magenta('dirty') : isCommitted ? colors.yellow('committed') : '');
72
+ table.cell('Path', path.relative(repository.dirname, p.dirname));
77
73
  table.newRow();
78
74
  }
79
75
  }
80
76
  }
81
77
  }
82
78
  if (this.options.graph) {
83
- npmlog_1.default.output('', '%j', obj);
79
+ logger.output('', '%j', obj);
84
80
  return obj;
85
81
  }
86
82
  if (this.options.json) {
87
- npmlog_1.default.output('', '%j', arr);
83
+ logger.output('', '%j', arr);
88
84
  return arr;
89
85
  }
90
86
  if (table.rows.length) {
91
- npmlog_1.default.output('', '%s', table.toString().trim());
87
+ logger.output('', '%s', table.toString().trim());
92
88
  // eslint-disable-next-line no-console
93
89
  console.log('');
94
- npmlog_1.default.info('list', '%i Package(s) found', count);
90
+ logger.info('list', '%i Package(s) found', count);
95
91
  return arr;
96
92
  }
97
93
  return arr;
98
94
  }
99
95
  }
100
- exports.ListCommand = ListCommand;
101
96
  ListCommand.commandName = 'list';
102
97
  (function (ListCommand) {
103
98
  ListCommand.cliCommandOptions = {
@@ -130,10 +125,10 @@ ListCommand.commandName = 'list';
130
125
  .conflicts('short', ['parseable', 'json'])
131
126
  .option(ListCommand.cliCommandOptions),
132
127
  handler: async (args) => {
133
- const options = command_js_1.Command.composeOptions(ListCommand.commandName, args, repository.config);
128
+ const options = Command.composeOptions(ListCommand.commandName, args, repository.config);
134
129
  await new ListCommand(repository, options).execute();
135
130
  },
136
131
  });
137
132
  }
138
133
  ListCommand.initCli = initCli;
139
- })(ListCommand || (exports.ListCommand = ListCommand = {}));
134
+ })(ListCommand || (ListCommand = {}));
@@ -1,20 +1,16 @@
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 {
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 {
11
7
  constructor(repository, options) {
12
8
  super(options);
13
9
  this.repository = repository;
14
- if (this.options.ci || !constants_js_1.isTTY)
10
+ if (this.options.ci || !isTTY)
15
11
  this.options.progress = false;
16
12
  // noinspection SuspiciousTypeOfGuard
17
- this.options.concurrency = (0, putil_varhelpers_1.toNumber)(options?.concurrency);
13
+ this.options.concurrency = toNumber(options?.concurrency);
18
14
  if (this.options.bail == null)
19
15
  this.options.bail = true;
20
16
  }
@@ -25,9 +21,9 @@ class MultiTaskCommand extends command_js_1.Command {
25
21
  return;
26
22
  }
27
23
  // this.enableProgress();
28
- this._task = new power_tasks_1.Task(childTasks, {
24
+ this._task = new Task(childTasks, {
29
25
  name: '$project-root',
30
- concurrency: this.options.concurrency || os_1.default.cpus().length,
26
+ concurrency: this.options.concurrency || os.cpus().length,
31
27
  bail: this.options.bail,
32
28
  });
33
29
  await this._task.toPromise();
@@ -36,7 +32,6 @@ class MultiTaskCommand extends command_js_1.Command {
36
32
  return this.repository.getPackages({ toposort: !this.options.parallel });
37
33
  }
38
34
  }
39
- exports.MultiTaskCommand = MultiTaskCommand;
40
35
  (function (MultiTaskCommand) {
41
36
  MultiTaskCommand.cliCommandOptions = {
42
37
  concurrency: {
@@ -65,4 +60,4 @@ exports.MultiTaskCommand = MultiTaskCommand;
65
60
  default: true,
66
61
  },
67
62
  };
68
- })(MultiTaskCommand || (exports.MultiTaskCommand = MultiTaskCommand = {}));
63
+ })(MultiTaskCommand || (MultiTaskCommand = {}));