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
package/esm/utils/exec.js CHANGED
@@ -1,18 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.exec = exec;
4
- const child_process_1 = require("child_process");
5
- const signal_exit_1 = require("signal-exit");
6
- const npm_run_path_js_1 = require("./npm-run-path.js");
1
+ import { spawn } from 'child_process';
2
+ import { onExit } from 'signal-exit';
3
+ import { npmRunPathEnv } from './npm-run-path.js';
7
4
  const runningChildren = new Map();
8
- async function exec(command, options) {
5
+ export async function exec(command, options) {
9
6
  const opts = {
10
7
  shell: true,
11
8
  throwOnError: true,
12
9
  ...options,
13
10
  };
14
11
  opts.env = {
15
- ...(0, npm_run_path_js_1.npmRunPathEnv)({ cwd: opts.cwd }),
12
+ ...npmRunPathEnv({ cwd: opts.cwd }),
16
13
  ...opts.env,
17
14
  };
18
15
  if (process.env.TS_NODE_PROJECT)
@@ -49,7 +46,7 @@ async function exec(command, options) {
49
46
  }
50
47
  buffer = chunk;
51
48
  };
52
- const child = (0, child_process_1.spawn)(command, opts.argv || [], spawnOptions);
49
+ const child = spawn(command, opts.argv || [], spawnOptions);
53
50
  if (child.pid) {
54
51
  runningChildren.set(child.pid, child);
55
52
  if (opts.onSpawn)
@@ -102,7 +99,7 @@ async function exec(command, options) {
102
99
  });
103
100
  });
104
101
  }
105
- (0, signal_exit_1.onExit)(() => {
102
+ onExit(() => {
106
103
  runningChildren.forEach(child => {
107
104
  child.kill();
108
105
  });
@@ -1,32 +1,26 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fsExists = fsExists;
4
- exports.tryStat = tryStat;
5
- exports.fsDelete = fsDelete;
6
- const tslib_1 = require("tslib");
7
- const promises_1 = tslib_1.__importDefault(require("fs/promises"));
8
- const path_1 = tslib_1.__importDefault(require("path"));
9
- async function fsExists(s) {
10
- return promises_1.default
1
+ import fsa from 'fs/promises';
2
+ import path from 'path';
3
+ export async function fsExists(s) {
4
+ return fsa
11
5
  .lstat(s)
12
6
  .then(() => true)
13
7
  .catch(() => false);
14
8
  }
15
- async function tryStat(s) {
16
- return promises_1.default.lstat(s).catch(() => undefined);
9
+ export async function tryStat(s) {
10
+ return fsa.lstat(s).catch(() => undefined);
17
11
  }
18
- async function fsDelete(fileOrDir) {
12
+ export async function fsDelete(fileOrDir) {
19
13
  const stat = await tryStat(fileOrDir);
20
14
  if (stat) {
21
15
  if (stat.isFile() || stat.isSymbolicLink()) {
22
- await promises_1.default.unlink(fileOrDir);
16
+ await fsa.unlink(fileOrDir);
23
17
  return true;
24
18
  }
25
19
  if (stat.isDirectory()) {
26
- const list = await promises_1.default.readdir(fileOrDir);
20
+ const list = await fsa.readdir(fileOrDir);
27
21
  for (const file of list)
28
- await fsDelete(path_1.default.join(fileOrDir, file));
29
- await promises_1.default.rmdir(fileOrDir);
22
+ await fsDelete(path.join(fileOrDir, file));
23
+ await fsa.rmdir(fileOrDir);
30
24
  return true;
31
25
  }
32
26
  }
@@ -1,11 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDirname = getDirname;
4
- exports.getPackageJson = getPackageJson;
5
- const tslib_1 = require("tslib");
6
- const fs_1 = tslib_1.__importDefault(require("fs"));
7
- const path_1 = tslib_1.__importDefault(require("path"));
8
- function getDirname() {
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ export function getDirname() {
9
4
  const pst = Error.prepareStackTrace;
10
5
  Error.prepareStackTrace = function (_, stack) {
11
6
  Error.prepareStackTrace = pst;
@@ -19,13 +14,13 @@ function getDirname() {
19
14
  const frame = stack.shift();
20
15
  const filename = frame && frame.getFileName();
21
16
  if (filename)
22
- return path_1.default.dirname(filename).replace('file://', '');
17
+ return path.dirname(filename).replace('file://', '');
23
18
  }
24
19
  throw Error('Can not parse stack');
25
20
  }
26
- function getPackageJson(dirname) {
27
- const f = path_1.default.resolve(dirname, 'package.json');
28
- if (!fs_1.default.existsSync(f))
21
+ export function getPackageJson(dirname) {
22
+ const f = path.resolve(dirname, 'package.json');
23
+ if (!fs.existsSync(f))
29
24
  return;
30
- return JSON.parse(fs_1.default.readFileSync(f, 'utf-8'));
25
+ return JSON.parse(fs.readFileSync(f, 'utf-8'));
31
26
  }
@@ -1,15 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GitHelper = void 0;
4
- const tslib_1 = require("tslib");
5
- const path_1 = tslib_1.__importDefault(require("path"));
6
- const exec_js_1 = require("./exec.js");
7
- class GitHelper {
1
+ import path from 'path';
2
+ import { exec } from './exec.js';
3
+ export class GitHelper {
8
4
  constructor(options) {
9
5
  this.cwd = options?.cwd || process.cwd();
10
6
  }
11
7
  async listDirtyFileStatus(options) {
12
- const x = await (0, exec_js_1.exec)('git', {
8
+ const x = await exec('git', {
13
9
  cwd: this.cwd,
14
10
  argv: ['status', '--porcelain'],
15
11
  });
@@ -19,7 +15,7 @@ class GitHelper {
19
15
  const m = f.match(/^(\w+) (.+)$/);
20
16
  if (m) {
21
17
  result.push({
22
- filename: options?.absolute ? path_1.default.join(this.cwd, m[2]) : m[2],
18
+ filename: options?.absolute ? path.join(this.cwd, m[2]) : m[2],
23
19
  status: m[1],
24
20
  });
25
21
  }
@@ -30,7 +26,7 @@ class GitHelper {
30
26
  return (await this.listDirtyFileStatus(options)).map(x => x.filename);
31
27
  }
32
28
  async listCommitSha() {
33
- const x = await (0, exec_js_1.exec)('git', {
29
+ const x = await exec('git', {
34
30
  cwd: this.cwd,
35
31
  argv: ['cherry'],
36
32
  });
@@ -49,22 +45,21 @@ class GitHelper {
49
45
  : await this.listCommitSha();
50
46
  let result = [];
51
47
  for (const s of shaArr) {
52
- const x = await (0, exec_js_1.exec)('git', {
48
+ const x = await exec('git', {
53
49
  cwd: this.cwd,
54
50
  argv: ['show', s, '--name-only', '--pretty="format:"'],
55
51
  });
56
52
  result.push(...(x.stdout ? x.stdout.trim().split(/\s*\n\s*/) : []));
57
53
  }
58
54
  if (options?.absolute)
59
- result = result.map(f => path_1.default.join(this.cwd, f));
55
+ result = result.map(f => path.join(this.cwd, f));
60
56
  return result;
61
57
  }
62
58
  async readFileLastPublished(filePath, commitSha) {
63
- const x = await (0, exec_js_1.exec)('git', {
59
+ const x = await exec('git', {
64
60
  cwd: this.cwd,
65
61
  argv: ['show', (commitSha || 'HEAD') + ':"' + filePath + '"'],
66
62
  });
67
63
  return x.stdout || '';
68
64
  }
69
65
  }
70
- exports.GitHelper = GitHelper;
@@ -1,14 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.npmRunPath = npmRunPath;
4
- exports.npmRunPathEnv = npmRunPathEnv;
5
- const tslib_1 = require("tslib");
6
1
  /* eslint-disable max-len */
7
2
  /**
8
3
  * Inspired from [npm-run-path](https://github.com/sindresorhus/npm-run-path)
9
4
  */
10
- const path_1 = tslib_1.__importDefault(require("path"));
11
- const process_1 = tslib_1.__importDefault(require("process"));
5
+ import path from 'path';
6
+ import process from 'process';
12
7
  /**
13
8
  Get your [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) prepended with locally installed binaries.
14
9
  @returns The augmented path string.
@@ -22,25 +17,25 @@ const process_1 = tslib_1.__importDefault(require("process"));
22
17
  //=> '/Users/sindresorhus/dev/foo/node_modules/.bin:/Users/sindresorhus/dev/node_modules/.bin:/Users/sindresorhus/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/usr/local/bin'
23
18
  ```
24
19
  */
25
- function npmRunPath(options = {}) {
26
- const cwd = options.cwd || process_1.default.cwd();
27
- const path_ = options.path || process_1.default.env[pathKey()];
28
- const execPath = options.execPath || process_1.default.execPath;
20
+ export function npmRunPath(options = {}) {
21
+ const cwd = options.cwd || process.cwd();
22
+ const path_ = options.path || process.env[pathKey()];
23
+ const execPath = options.execPath || process.execPath;
29
24
  let previous;
30
- let cwdPath = path_1.default.resolve(cwd);
25
+ let cwdPath = path.resolve(cwd);
31
26
  const result = [];
32
27
  while (previous !== cwdPath) {
33
- result.push(path_1.default.join(cwdPath, 'node_modules/.bin'));
28
+ result.push(path.join(cwdPath, 'node_modules/.bin'));
34
29
  previous = cwdPath;
35
- cwdPath = path_1.default.resolve(cwdPath, '..');
30
+ cwdPath = path.resolve(cwdPath, '..');
36
31
  }
37
32
  // Ensure the running `node` binary is used.
38
- result.push(path_1.default.resolve(cwd, execPath, '..'));
39
- return [...result, path_].join(path_1.default.delimiter);
33
+ result.push(path.resolve(cwd, execPath, '..'));
34
+ return [...result, path_].join(path.delimiter);
40
35
  }
41
36
  function pathKey(options) {
42
- const env = options?.env || process_1.default.env;
43
- const platform = options?.platform || process_1.default.platform;
37
+ const env = options?.env || process.env;
38
+ const platform = options?.platform || process.platform;
44
39
  if (platform !== 'win32') {
45
40
  return 'PATH';
46
41
  }
@@ -60,8 +55,8 @@ function pathKey(options) {
60
55
  });
61
56
  ```
62
57
  */
63
- function npmRunPathEnv(options = {}) {
64
- const env = { ...(options.env || process_1.default.env) };
58
+ export function npmRunPathEnv(options = {}) {
59
+ const env = { ...(options.env || process.env) };
65
60
  const path_ = pathKey({ env });
66
61
  const opts = { ...options, path: env[path_] };
67
62
  env[path_] = npmRunPath(opts);
@@ -1,16 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NpmHelper = exports.PackageNotFoundError = void 0;
4
- const exec_js_1 = require("./exec.js");
5
- class PackageNotFoundError extends Error {
1
+ import { exec } from './exec.js';
2
+ export class PackageNotFoundError extends Error {
6
3
  }
7
- exports.PackageNotFoundError = PackageNotFoundError;
8
- class NpmHelper {
4
+ export class NpmHelper {
9
5
  constructor(options) {
10
6
  this.cwd = options?.cwd || process.cwd();
11
7
  }
12
8
  async getPackageInfo(packageName) {
13
- const x = await (0, exec_js_1.exec)('npm', {
9
+ const x = await exec('npm', {
14
10
  cwd: this.cwd,
15
11
  argv: ['view', packageName, '--json'],
16
12
  });
@@ -32,4 +28,3 @@ class NpmHelper {
32
28
  throw new Error('Unable to fetch version info');
33
29
  }
34
30
  }
35
- exports.NpmHelper = NpmHelper;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rman",
3
3
  "description": "Monorepo repository manager",
4
- "version": "0.30.0",
4
+ "version": "0.31.1",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
7
7
  "dependencies": {
@@ -14,26 +14,34 @@
14
14
  "is-ci": "^3.0.1",
15
15
  "js-yaml": "^4.1.0",
16
16
  "npmlog": "^7.0.1",
17
- "power-tasks": "^1.8.0",
17
+ "power-tasks": "^1.10.1",
18
18
  "putil-merge": "^3.13.0",
19
19
  "putil-varhelpers": "^1.6.5",
20
20
  "semver": "^7.6.3",
21
21
  "signal-exit": "^4.1.0",
22
- "strict-typed-events": "^2.5.0",
22
+ "strict-typed-events": "^2.7.2",
23
23
  "strip-color": "^0.1.0",
24
24
  "tslib": "^2.6.3",
25
25
  "yargs": "^17.7.2"
26
26
  },
27
- "main": "./cjs/index.js",
28
- "module": "./esm/index.js",
29
- "types": "./types/index.d.ts",
27
+ "type": "module",
30
28
  "exports": {
31
29
  ".": {
32
- "require": "./cjs/index.js",
33
- "import": "./esm/index.js",
34
- "types": "./types/index.d.ts"
35
- }
30
+ "import": {
31
+ "types": "./types/index.d.ts",
32
+ "default": "./esm/index.js"
33
+ },
34
+ "require": {
35
+ "types": "./types/index.d.ts",
36
+ "default": "./cjs/index.js"
37
+ },
38
+ "default": "./esm/index.js"
39
+ },
40
+ "./package.json": "./package.json"
36
41
  },
42
+ "main": "./cjs/index.js",
43
+ "module": "./esm/index.js",
44
+ "types": "./types/index.d.ts",
37
45
  "bin": {
38
46
  "rman": "bin/rman.mjs"
39
47
  },
@@ -1,4 +1,4 @@
1
- import yargs from 'yargs';
1
+ import * as yargs from 'yargs';
2
2
  import { Repository } from '../core/repository.js';
3
3
  import { RunCommand } from './run-command.js';
4
4
  export declare class BuildCommand extends RunCommand<any> {
@@ -1,4 +1,4 @@
1
- import yargs from 'yargs';
1
+ import * as yargs from 'yargs';
2
2
  import { Package } from '../core/package.js';
3
3
  import { Repository } from '../core/repository.js';
4
4
  import { ListCommand } from './list-command.js';
@@ -1,5 +1,5 @@
1
1
  import { Task } from 'power-tasks';
2
- import yargs from 'yargs';
2
+ import * as yargs from 'yargs';
3
3
  import { Package } from '../core/package.js';
4
4
  import { Repository } from '../core/repository.js';
5
5
  import { ExecuteCommandResult } from '../utils/exec.js';
@@ -1,5 +1,5 @@
1
1
  import { Task } from 'power-tasks';
2
- import yargs from 'yargs';
2
+ import * as yargs from 'yargs';
3
3
  import { Package } from '../core/package.js';
4
4
  import { Repository } from '../core/repository.js';
5
5
  import { MultiTaskCommand } from './multi-task-command.js';
@@ -1,4 +1,4 @@
1
- import yargs from 'yargs';
1
+ import * as yargs from 'yargs';
2
2
  import { Command } from '../core/command.js';
3
3
  import { Repository } from '../core/repository.js';
4
4
  export declare class InfoCommand extends Command {
@@ -1,5 +1,5 @@
1
1
  import EasyTable from 'easy-table';
2
- import yargs from 'yargs';
2
+ import * as yargs from 'yargs';
3
3
  import { Command } from '../core/command.js';
4
4
  import { Package } from '../core/package.js';
5
5
  import { Repository } from '../core/repository.js';
@@ -1,5 +1,5 @@
1
1
  import { Task } from 'power-tasks';
2
- import yargs from 'yargs';
2
+ import * as yargs from 'yargs';
3
3
  import { Command } from '../core/command.js';
4
4
  import { Package } from '../core/package.js';
5
5
  import { Repository } from '../core/repository.js';
@@ -1,5 +1,5 @@
1
1
  import { Task } from 'power-tasks';
2
- import yargs from 'yargs';
2
+ import * as yargs from 'yargs';
3
3
  import { Package } from '../core/package.js';
4
4
  import { Repository } from '../core/repository.js';
5
5
  import { ExecuteCommandResult } from '../utils/exec.js';
@@ -1,5 +1,5 @@
1
1
  import { Task } from 'power-tasks';
2
- import yargs from 'yargs';
2
+ import * as yargs from 'yargs';
3
3
  import { Package } from '../core/package.js';
4
4
  import { Repository } from '../core/repository.js';
5
5
  import { ExecuteCommandResult } from '../utils/exec.js';
@@ -1,5 +1,5 @@
1
1
  import { Task } from 'power-tasks';
2
- import yargs from 'yargs';
2
+ import * as yargs from 'yargs';
3
3
  import { Package } from '../core/package.js';
4
4
  import { Repository } from '../core/repository.js';
5
5
  import { ExecuteCommandResult } from '../utils/exec.js';
@@ -1,6 +1,6 @@
1
1
  import './logger.js';
2
2
  import npmlog from 'npmlog';
3
- import yargs from 'yargs';
3
+ import * as yargs from 'yargs';
4
4
  export interface CommandEvents {
5
5
  start: () => void | Promise<void>;
6
6
  finish: (error?: any, result?: any) => void | Promise<void>;