rman 0.36.3 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/{esm/commands → commands}/build-command.js +2 -1
  2. package/{esm/commands → commands}/changed-command.js +2 -1
  3. package/{esm/commands → commands}/ci-command.js +2 -1
  4. package/{esm/commands → commands}/execute-command.js +4 -1
  5. package/{esm/commands → commands}/info-command.js +1 -1
  6. package/{esm/commands → commands}/list-command.js +2 -1
  7. package/{esm/commands → commands}/multi-task-command.js +2 -0
  8. package/{types/commands → commands}/publish-command.d.ts +1 -0
  9. package/{esm/commands → commands}/publish-command.js +7 -1
  10. package/{esm/commands → commands}/run-command.js +3 -1
  11. package/{esm/commands → commands}/version-command.js +4 -2
  12. package/{esm/core → core}/command.js +5 -3
  13. package/{esm/core → core}/package.js +3 -1
  14. package/{types/core → core}/repository.d.ts +2 -1
  15. package/{esm/core → core}/repository.js +22 -9
  16. package/package.json +16 -33
  17. package/{esm/utils → utils}/git-utils.js +1 -0
  18. package/{esm/utils → utils}/npm-utils.js +2 -0
  19. package/cjs/cli.js +0 -71
  20. package/cjs/commands/build-command.js +0 -27
  21. package/cjs/commands/changed-command.js +0 -35
  22. package/cjs/commands/ci-command.js +0 -72
  23. package/cjs/commands/execute-command.js +0 -74
  24. package/cjs/commands/info-command.js +0 -60
  25. package/cjs/commands/list-command.js +0 -138
  26. package/cjs/commands/multi-task-command.js +0 -68
  27. package/cjs/commands/publish-command.js +0 -130
  28. package/cjs/commands/run-command.js +0 -134
  29. package/cjs/commands/version-command.js +0 -198
  30. package/cjs/core/command.js +0 -119
  31. package/cjs/core/constants.js +0 -5
  32. package/cjs/core/logger.js +0 -5
  33. package/cjs/core/package.js +0 -42
  34. package/cjs/core/repository.js +0 -139
  35. package/cjs/index.js +0 -4
  36. package/cjs/package.json +0 -3
  37. package/cjs/tsconfig-build-cjs.tsbuildinfo +0 -1
  38. package/cjs/utils/exec.js +0 -109
  39. package/cjs/utils/file-utils.js +0 -34
  40. package/cjs/utils/get-dirname.js +0 -31
  41. package/cjs/utils/git-utils.js +0 -70
  42. package/cjs/utils/npm-run-path.js +0 -68
  43. package/cjs/utils/npm-utils.js +0 -36
  44. package/cjs/utils/package-not-found-error.js +0 -6
  45. package/esm/package.json +0 -3
  46. package/esm/tsconfig-build-esm.tsbuildinfo +0 -1
  47. package/types/index.d.cts +0 -1
  48. /package/{types/cli.d.ts → cli.d.ts} +0 -0
  49. /package/{esm/cli.js → cli.js} +0 -0
  50. /package/{types/commands → commands}/build-command.d.ts +0 -0
  51. /package/{types/commands → commands}/changed-command.d.ts +0 -0
  52. /package/{types/commands → commands}/ci-command.d.ts +0 -0
  53. /package/{types/commands → commands}/execute-command.d.ts +0 -0
  54. /package/{types/commands → commands}/info-command.d.ts +0 -0
  55. /package/{types/commands → commands}/list-command.d.ts +0 -0
  56. /package/{types/commands → commands}/multi-task-command.d.ts +0 -0
  57. /package/{types/commands → commands}/run-command.d.ts +0 -0
  58. /package/{types/commands → commands}/version-command.d.ts +0 -0
  59. /package/{types/core → core}/command.d.ts +0 -0
  60. /package/{types/core → core}/constants.d.ts +0 -0
  61. /package/{esm/core → core}/constants.js +0 -0
  62. /package/{types/core → core}/logger.d.ts +0 -0
  63. /package/{esm/core → core}/logger.js +0 -0
  64. /package/{types/core → core}/package.d.ts +0 -0
  65. /package/{types/index.d.ts → index.d.ts} +0 -0
  66. /package/{esm/index.js → index.js} +0 -0
  67. /package/{types/utils → utils}/exec.d.ts +0 -0
  68. /package/{esm/utils → utils}/exec.js +0 -0
  69. /package/{types/utils → utils}/file-utils.d.ts +0 -0
  70. /package/{esm/utils → utils}/file-utils.js +0 -0
  71. /package/{types/utils → utils}/get-dirname.d.ts +0 -0
  72. /package/{esm/utils → utils}/get-dirname.js +0 -0
  73. /package/{types/utils → utils}/git-utils.d.ts +0 -0
  74. /package/{types/utils → utils}/npm-run-path.d.ts +0 -0
  75. /package/{esm/utils → utils}/npm-run-path.js +0 -0
  76. /package/{types/utils → utils}/npm-utils.d.ts +0 -0
  77. /package/{types/utils → utils}/package-not-found-error.d.ts +0 -0
  78. /package/{esm/utils → utils}/package-not-found-error.js +0 -0
@@ -1,198 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VersionCommand = 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 semver_1 = tslib_1.__importDefault(require("semver"));
10
- const strip_color_1 = tslib_1.__importDefault(require("strip-color"));
11
- const command_js_1 = require("../core/command.js");
12
- const git_utils_js_1 = require("../utils/git-utils.js");
13
- const run_command_js_1 = require("./run-command.js");
14
- class VersionCommand extends run_command_js_1.RunCommand {
15
- constructor(repository, bump, options) {
16
- super(repository, 'version', options);
17
- this.repository = repository;
18
- this.bump = bump;
19
- this._updatedPackages = new Set();
20
- }
21
- async _prepareTasks(packages) {
22
- const { repository } = this;
23
- const git = new git_utils_js_1.GitHelper({ cwd: repository.dirname });
24
- const dirtyFiles = await git.listDirtyFiles();
25
- const committedFiles = await git.listCommittedFiles();
26
- const newVersions = {};
27
- let errorCount = 0;
28
- const selectedPackages = [];
29
- const dependentPackages = [];
30
- for (const p of packages) {
31
- const relDir = path_1.default.relative(repository.dirname, p.dirname);
32
- let status = '';
33
- let message = '';
34
- let newVer = '';
35
- const logPkgName = ansi_colors_1.default.yellow(p.name);
36
- if (!this.options.noTag) {
37
- const isDirty = dirtyFiles.find(f => !path_1.default.relative(relDir, f).startsWith('..'));
38
- if (isDirty) {
39
- if (!this.options.ignoreDirty)
40
- errorCount++;
41
- status = this.options.ignoreDirty ? ansi_colors_1.default.cyan.bold('skip') : ansi_colors_1.default.redBright.bold('error');
42
- message = 'Git directory is not clean';
43
- }
44
- }
45
- if (!status) {
46
- const isChanged = committedFiles.find(f => !path_1.default.relative(relDir, f).startsWith('..'));
47
- newVer =
48
- isChanged || this.options.all || this.options.unified
49
- ? semver_1.default.inc(p.version, this.bump)
50
- : undefined;
51
- if (newVer)
52
- newVersions[p.name] = newVer;
53
- else {
54
- status = ansi_colors_1.default.cyanBright.bold('no-change');
55
- message = 'No change detected';
56
- }
57
- }
58
- if (status) {
59
- if (this.options.json) {
60
- npmlog_1.default.info(this.commandName, '%j', {
61
- package: p.name,
62
- version: p.version,
63
- newVersion: newVer,
64
- status: (0, strip_color_1.default)(status),
65
- message: (0, strip_color_1.default)(message),
66
- });
67
- }
68
- else {
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
- }
71
- continue;
72
- }
73
- selectedPackages.push(p);
74
- packages.forEach(p2 => {
75
- if (p2.dependencies.includes(p.name) && !dependentPackages.includes(p2))
76
- dependentPackages.push(p2);
77
- });
78
- }
79
- if (errorCount)
80
- throw new Error('Unable to bump version due to error(s)');
81
- const maxVer = Object.values(newVersions).reduce((m, v) => (semver_1.default.gt(m, v) ? m : v), '0.0.0');
82
- if (this.options.unified) {
83
- Object.keys(newVersions).forEach(k => (newVersions[k] = maxVer));
84
- }
85
- dependentPackages.forEach(p2 => {
86
- if (!selectedPackages.includes(p2))
87
- selectedPackages.push(p2);
88
- });
89
- const tasks = await super._prepareTasks(selectedPackages, { newVersions });
90
- tasks.forEach(t => (t.options.exclusive = true));
91
- if (!this.options.noTag) {
92
- tasks.push(new power_tasks_1.Task(async () => {
93
- while (this._updatedPackages.size) {
94
- const filenames = [];
95
- const [first] = this._updatedPackages;
96
- for (const pkg of this._updatedPackages) {
97
- if (pkg.version === first.version) {
98
- filenames.push(path_1.default.relative(this.repository.rootPackage.dirname, pkg.jsonFileName));
99
- this._updatedPackages.delete(pkg);
100
- }
101
- }
102
- await super._exec(this.repository.rootPackage, 'git commit -m "' + first.version + '" ' + filenames.map(s => '"' + s + '"').join(' '), {
103
- stdio: npmlog_1.default.levelIndex < 1000 ? 'inherit' : 'pipe',
104
- logLevel: 'silly',
105
- });
106
- }
107
- if (this.options.unified) {
108
- try {
109
- await super._exec(this.repository.rootPackage, 'git tag -a "v' + maxVer + '" -m "version ' + maxVer + '"', {
110
- cwd: this.repository.dirname,
111
- stdio: npmlog_1.default.levelIndex < 1000 ? 'inherit' : 'pipe',
112
- logLevel: 'silly',
113
- });
114
- }
115
- catch {
116
- //
117
- }
118
- }
119
- }, { exclusive: true }));
120
- }
121
- return tasks;
122
- }
123
- async _exec(pkg, command, args, options) {
124
- if (pkg === this.repository.rootPackage)
125
- return { code: 0 };
126
- if (command === '#') {
127
- const { newVersions } = options;
128
- pkg.reloadJson();
129
- const oldVer = pkg.json.version;
130
- const newVer = newVersions[pkg.name];
131
- pkg.json.version = newVer;
132
- delete pkg.json.scripts.version;
133
- pkg.writeJson();
134
- if (!this._updatedPackages.has(pkg))
135
- this._updatedPackages.add(pkg);
136
- const packages = this.repository.getPackages();
137
- for (const p of packages) {
138
- if (p.dependencies.includes(pkg.name)) {
139
- p.reloadJson();
140
- for (const k of ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']) {
141
- if (p.json[k]?.[pkg.name]) {
142
- p.json[k][pkg.name] = '^' + newVer;
143
- }
144
- }
145
- p.writeJson();
146
- if (!this._updatedPackages.has(p))
147
- this._updatedPackages.add(p);
148
- }
149
- }
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
- return { code: 0 };
152
- }
153
- return super._exec(pkg, command, args, options);
154
- }
155
- }
156
- exports.VersionCommand = VersionCommand;
157
- VersionCommand.commandName = 'version';
158
- (function (VersionCommand) {
159
- VersionCommand.cliCommandOptions = {
160
- unified: {
161
- alias: 'u',
162
- describe: '# Keep all package versions same',
163
- type: 'boolean',
164
- },
165
- all: {
166
- alias: 'a',
167
- describe: '# Bump version for all packages even no commits',
168
- type: 'boolean',
169
- },
170
- 'ignore-dirty': {
171
- alias: 'i',
172
- describe: '# Do not bump version for dirty packages',
173
- type: 'boolean',
174
- },
175
- 'no-tag': {
176
- alias: 'n',
177
- describe: '# Do not crate git version tag. (Ignores dirty check)',
178
- type: 'boolean',
179
- },
180
- };
181
- function initCli(repository, program) {
182
- program.command({
183
- command: 'version [bump] [...options]',
184
- describe: 'Bump version of packages',
185
- builder: cmd => cmd
186
- .example('$0 version patch', '# semver keyword')
187
- .example('$0 version 1.0.1', '# explicit')
188
- .conflicts('ignore-dirty', ['force-dirty', 'unified'])
189
- .option(VersionCommand.cliCommandOptions),
190
- handler: async (args) => {
191
- const bump = args.bump;
192
- const options = command_js_1.Command.composeOptions(VersionCommand.commandName, args, repository.config);
193
- await new VersionCommand(repository, bump, options).execute();
194
- },
195
- });
196
- }
197
- VersionCommand.initCli = initCli;
198
- })(VersionCommand || (exports.VersionCommand = VersionCommand = {}));
@@ -1,119 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Command = void 0;
4
- const tslib_1 = require("tslib");
5
- require("./logger.js");
6
- const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
7
- const is_ci_1 = tslib_1.__importDefault(require("is-ci"));
8
- const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
9
- const putil_merge_1 = tslib_1.__importDefault(require("putil-merge"));
10
- const strict_typed_events_1 = require("strict-typed-events");
11
- const constants_js_1 = require("./constants.js");
12
- const noOp = () => undefined;
13
- const lineVerticalDashed0 = '┆';
14
- class Command extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict_typed_events_1.AsyncEventEmitter) {
15
- constructor(options) {
16
- super();
17
- this._started = false;
18
- this._finished = false;
19
- this.logger = npmlog_1.default;
20
- this._options = options || {};
21
- if (is_ci_1.default)
22
- this.options.ci = true;
23
- this.logger.separator = ansi_colors_1.default.gray(lineVerticalDashed0);
24
- Object.defineProperty(this.logger, 'levelIndex', {
25
- get() {
26
- return npmlog_1.default.levels[npmlog_1.default.level] || 0;
27
- },
28
- });
29
- }
30
- get options() {
31
- return this._options;
32
- }
33
- get commandName() {
34
- return Object.getPrototypeOf(this).constructor.commandName;
35
- }
36
- async execute() {
37
- if (this._finished) {
38
- this._finished = false;
39
- this._started = false;
40
- }
41
- if (!this._started) {
42
- this._started = true;
43
- await this.emitAsync('start');
44
- }
45
- this._started = true;
46
- try {
47
- this.logger.level = this.options.logLevel || (this.options.ci ? 'error' : 'info');
48
- if (this.options.ci || !constants_js_1.isTTY) {
49
- this.logger.disableColor();
50
- this.logger.disableUnicode();
51
- }
52
- else {
53
- this.logger.enableColor();
54
- this.logger.enableUnicode();
55
- }
56
- if (this._preExecute)
57
- await this._preExecute();
58
- const v = await this._execute();
59
- if (this._postExecute)
60
- await this._postExecute();
61
- await this.emitAsync('finish', undefined, v).catch(noOp);
62
- this.disableProgress();
63
- this.logger.resume();
64
- this.logger.info('', 'Command completed');
65
- return v;
66
- }
67
- catch (e) {
68
- this.disableProgress();
69
- await this.emitAsync('finish', e).catch(noOp);
70
- if (this.listenerCount('error'))
71
- await this.emitAsync('error', e).catch(noOp);
72
- this.logger.resume();
73
- this.logger.error(this.commandName, this.logger.separator, e.message.trim());
74
- e.logged = true;
75
- throw e;
76
- }
77
- finally {
78
- this._finished = true;
79
- }
80
- }
81
- async enableProgress() {
82
- // if (this.options.ci || !isTTY || (this._screen && this._screen.visible)) return;
83
- }
84
- disableProgress() {
85
- //
86
- }
87
- async _preExecute() {
88
- npmlog_1.default.info('rman', `Executing "${this.commandName}" command`);
89
- }
90
- }
91
- exports.Command = Command;
92
- (function (Command) {
93
- Command.globalOptions = {
94
- 'log-level': {
95
- defaultDescription: 'info',
96
- describe: 'Set log level',
97
- choices: ['silly', 'verbose', 'info', 'output', 'notice', 'success', 'warn', 'error', 'silent'],
98
- requiresArg: true,
99
- },
100
- json: {
101
- alias: 'j',
102
- describe: '# Stream log as json',
103
- type: 'boolean',
104
- },
105
- ci: {
106
- hidden: true,
107
- type: 'boolean',
108
- },
109
- };
110
- function composeOptions(commandName, yargArgs, config) {
111
- const result = (0, putil_merge_1.default)({}, config, { filter: (_, key) => key !== 'command' });
112
- (0, putil_merge_1.default)(result, yargArgs);
113
- const cfgCmd = config.command && typeof config.command === 'object' ? config.command[commandName] : undefined;
114
- if (cfgCmd && typeof cfgCmd === 'object')
115
- (0, putil_merge_1.default)(result, cfgCmd);
116
- return result;
117
- }
118
- Command.composeOptions = composeOptions;
119
- })(Command || (exports.Command = Command = {}));
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isTTY = void 0;
4
- // export const DOTS = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
5
- exports.isTTY = process.stdout.isTTY && process.env.TERM !== 'dumb';
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
5
- npmlog_1.default.addLevel('output', 3300, {}, '');
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Package = void 0;
4
- const tslib_1 = require("tslib");
5
- const fs_1 = tslib_1.__importDefault(require("fs"));
6
- const path_1 = tslib_1.__importDefault(require("path"));
7
- class Package {
8
- constructor(dirname) {
9
- this.dirname = dirname;
10
- this.dependencies = [];
11
- this.reloadJson();
12
- }
13
- get basename() {
14
- return path_1.default.basename(this.dirname);
15
- }
16
- get name() {
17
- return this._json.name;
18
- }
19
- get version() {
20
- return this._json.version;
21
- }
22
- get json() {
23
- return this._json;
24
- }
25
- get jsonFileName() {
26
- return path_1.default.join(this.dirname, 'package.json');
27
- }
28
- get isPrivate() {
29
- return !!this._json.private;
30
- }
31
- reloadJson() {
32
- const f = this.jsonFileName;
33
- this._json = JSON.parse(fs_1.default.readFileSync(f, 'utf-8'));
34
- return this._json;
35
- }
36
- writeJson() {
37
- const f = this.jsonFileName;
38
- const data = JSON.stringify(this._json, undefined, 2);
39
- fs_1.default.writeFileSync(f, data, 'utf-8');
40
- }
41
- }
42
- exports.Package = Package;
@@ -1,139 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Repository = void 0;
4
- const tslib_1 = require("tslib");
5
- const fast_glob_1 = tslib_1.__importDefault(require("fast-glob"));
6
- const fs_1 = tslib_1.__importDefault(require("fs"));
7
- const yaml = tslib_1.__importStar(require("js-yaml"));
8
- const path_1 = tslib_1.__importDefault(require("path"));
9
- const putil_merge_1 = tslib_1.__importDefault(require("putil-merge"));
10
- const get_dirname_js_1 = require("../utils/get-dirname.js");
11
- const package_js_1 = require("./package.js");
12
- class Repository extends package_js_1.Package {
13
- constructor(dirname, config, packages) {
14
- super(dirname);
15
- this.dirname = dirname;
16
- this.config = config;
17
- this.packages = packages;
18
- this.rootPackage = new package_js_1.Package(dirname);
19
- }
20
- getPackages(options) {
21
- const result = [...this.packages];
22
- if (options?.toposort)
23
- topoSortPackages(result);
24
- return result;
25
- }
26
- getPackage(name) {
27
- return this.packages.find(p => p.name === name);
28
- }
29
- _updateDependencies() {
30
- const deps = {};
31
- for (const pkg of this.packages) {
32
- const o = {
33
- ...pkg.json.dependencies,
34
- ...pkg.json.devDependencies,
35
- ...pkg.json.peerDependencies,
36
- ...pkg.json.optionalDependencies,
37
- };
38
- const configDeps = this.config.packages?.[pkg.name]?.dependencies;
39
- if (configDeps) {
40
- if (Array.isArray(configDeps))
41
- configDeps.forEach(x => (o[x] = o[x] || '*'));
42
- else
43
- Object.assign(o, configDeps);
44
- }
45
- const dependencies = [];
46
- for (const k of Object.keys(o)) {
47
- const p = this.getPackage(k);
48
- if (p)
49
- dependencies.push(k);
50
- }
51
- deps[pkg.name] = dependencies;
52
- pkg.dependencies = dependencies;
53
- }
54
- let circularCheck;
55
- const deepFindDependencies = (pkg, target) => {
56
- if (circularCheck.includes(pkg.name))
57
- return;
58
- circularCheck.push(pkg.name);
59
- for (const s of pkg.dependencies) {
60
- if (!target.includes(s)) {
61
- target.push(s);
62
- const p = this.getPackage(s);
63
- if (p) {
64
- deepFindDependencies(p, target);
65
- }
66
- }
67
- }
68
- };
69
- for (const pkg of this.packages) {
70
- circularCheck = [];
71
- deepFindDependencies(pkg, pkg.dependencies);
72
- }
73
- }
74
- static create(root, options) {
75
- let dirname = root || process.cwd();
76
- let deep = options?.deep ?? 10;
77
- while (deep-- >= 0 && fs_1.default.existsSync(dirname)) {
78
- const f = path_1.default.join(dirname, 'package.json');
79
- if (fs_1.default.existsSync(f)) {
80
- const pkgJson = JSON.parse(fs_1.default.readFileSync(f, 'utf-8'));
81
- if (Array.isArray(pkgJson.workspaces)) {
82
- const packages = this._resolvePackages(dirname, pkgJson.workspaces);
83
- const config = this._readConfig(dirname);
84
- const repo = new Repository(dirname, config, packages);
85
- repo._updateDependencies();
86
- return repo;
87
- }
88
- }
89
- dirname = path_1.default.resolve(dirname, '..');
90
- }
91
- throw new Error('No monorepo project detected');
92
- }
93
- static _resolvePackages(dirname, patterns) {
94
- const packages = [];
95
- for (const pattern of patterns) {
96
- const dirs = fast_glob_1.default.sync(pattern, {
97
- cwd: dirname,
98
- absolute: true,
99
- deep: 0,
100
- onlyDirectories: true,
101
- });
102
- for (const dir of dirs) {
103
- const f = path_1.default.join(dir, 'package.json');
104
- if (fs_1.default.existsSync(f))
105
- packages.push(new package_js_1.Package(dir));
106
- }
107
- }
108
- return packages;
109
- }
110
- static _readConfig(dirname) {
111
- const result = {};
112
- const pkgJson = (0, get_dirname_js_1.getPackageJson)(dirname);
113
- if (pkgJson && typeof pkgJson.rman === 'object')
114
- (0, putil_merge_1.default)(result, pkgJson.rman, { deep: true });
115
- let filename = path_1.default.resolve(dirname, '.rman.yml');
116
- if (fs_1.default.existsSync(filename)) {
117
- const obj = yaml.load(fs_1.default.readFileSync(filename, 'utf-8'));
118
- if (obj && typeof obj === 'object')
119
- (0, putil_merge_1.default)(result, obj, { deep: true });
120
- }
121
- filename = path_1.default.resolve(dirname, '.rmanrc');
122
- if (fs_1.default.existsSync(filename)) {
123
- const obj = JSON.parse(fs_1.default.readFileSync(filename, 'utf-8'));
124
- if (obj && typeof obj === 'object')
125
- (0, putil_merge_1.default)(result, obj, { deep: true });
126
- }
127
- return result;
128
- }
129
- }
130
- exports.Repository = Repository;
131
- function topoSortPackages(packages) {
132
- packages.sort((a, b) => {
133
- if (b.dependencies.includes(a.name))
134
- return -1;
135
- if (a.dependencies.includes(b.name))
136
- return 1;
137
- return 0;
138
- });
139
- }
package/cjs/index.js DELETED
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./core/repository.js"), exports);
package/cjs/package.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
@@ -1 +0,0 @@
1
- {"root":["../../src/cli.ts","../../src/index.ts","../../src/commands/build-command.ts","../../src/commands/changed-command.ts","../../src/commands/ci-command.ts","../../src/commands/execute-command.ts","../../src/commands/info-command.ts","../../src/commands/list-command.ts","../../src/commands/multi-task-command.ts","../../src/commands/publish-command.ts","../../src/commands/run-command.ts","../../src/commands/version-command.ts","../../src/core/command.ts","../../src/core/constants.ts","../../src/core/logger.ts","../../src/core/package.ts","../../src/core/repository.ts","../../src/utils/exec.ts","../../src/utils/file-utils.ts","../../src/utils/get-dirname.ts","../../src/utils/git-utils.ts","../../src/utils/npm-run-path.ts","../../src/utils/npm-utils.ts","../../src/utils/package-not-found-error.ts"],"version":"5.7.3"}
package/cjs/utils/exec.js DELETED
@@ -1,109 +0,0 @@
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");
7
- const runningChildren = new Map();
8
- async function exec(command, options) {
9
- const opts = {
10
- shell: true,
11
- throwOnError: true,
12
- ...options,
13
- };
14
- opts.env = {
15
- ...(0, npm_run_path_js_1.npmRunPathEnv)({ cwd: opts.cwd }),
16
- ...opts.env,
17
- };
18
- if (process.env.TS_NODE_PROJECT)
19
- delete opts.env.TS_NODE_PROJECT;
20
- opts.cwd = opts.cwd || process.cwd();
21
- const spawnOptions = {
22
- stdio: opts.stdio || 'pipe',
23
- env: opts.env,
24
- cwd: opts.cwd,
25
- shell: opts.shell,
26
- windowsHide: true,
27
- };
28
- const result = {
29
- code: undefined,
30
- stdout: '',
31
- };
32
- let buffer = '';
33
- const processData = (data, stdio) => {
34
- buffer += '' + data;
35
- result.stdout += '' + data;
36
- if (opts.onData)
37
- opts.onData(data, stdio);
38
- };
39
- const processLines = (stdio, flush) => {
40
- let chunk = buffer;
41
- let i;
42
- if (flush && !chunk.endsWith('\n'))
43
- chunk += '\n';
44
- while ((i = chunk.indexOf('\n')) >= 0) {
45
- const line = chunk.substring(0, i);
46
- chunk = chunk.substring(i + 1);
47
- if (opts.onLine)
48
- opts.onLine(line, stdio);
49
- }
50
- buffer = chunk;
51
- };
52
- const child = (0, child_process_1.spawn)(command, opts.argv || [], spawnOptions);
53
- if (child.pid) {
54
- runningChildren.set(child.pid, child);
55
- if (opts.onSpawn)
56
- opts.onSpawn(child);
57
- }
58
- child.stdout?.on('data', data => {
59
- processData(data, 'stdout');
60
- processLines('stdout');
61
- });
62
- child.stderr?.on('data', data => {
63
- processData(data, 'stderr');
64
- processLines('stderr');
65
- });
66
- return new Promise((resolve, reject) => {
67
- let resolved;
68
- child.on('error', (err) => {
69
- if (child.pid)
70
- runningChildren.delete(child.pid);
71
- processLines('stdout', true);
72
- processLines('stderr', true);
73
- if (resolved)
74
- return;
75
- result.code = err.code || 1;
76
- if (!err) {
77
- const text = `Command failed (${result.code})`;
78
- err = new Error(text);
79
- }
80
- if (typeof err === 'string')
81
- err = new Error(err);
82
- result.error = err;
83
- resolved = true;
84
- if (opts.throwOnError)
85
- return reject(result.error);
86
- resolve(result);
87
- });
88
- child.on('close', (code) => {
89
- if (child.pid)
90
- runningChildren.delete(child.pid);
91
- processLines('stdout', true);
92
- processLines('stderr', true);
93
- if (resolved)
94
- return;
95
- result.code = code;
96
- resolved = true;
97
- if (code) {
98
- const text = `Command failed (${result.code})`;
99
- result.error = new Error(text);
100
- }
101
- return resolve(result);
102
- });
103
- });
104
- }
105
- (0, signal_exit_1.onExit)(() => {
106
- runningChildren.forEach(child => {
107
- child.kill();
108
- });
109
- });
@@ -1,34 +0,0 @@
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
11
- .lstat(s)
12
- .then(() => true)
13
- .catch(() => false);
14
- }
15
- async function tryStat(s) {
16
- return promises_1.default.lstat(s).catch(() => undefined);
17
- }
18
- async function fsDelete(fileOrDir) {
19
- const stat = await tryStat(fileOrDir);
20
- if (stat) {
21
- if (stat.isFile() || stat.isSymbolicLink()) {
22
- await promises_1.default.unlink(fileOrDir);
23
- return true;
24
- }
25
- if (stat.isDirectory()) {
26
- const list = await promises_1.default.readdir(fileOrDir);
27
- for (const file of list)
28
- await fsDelete(path_1.default.join(fileOrDir, file));
29
- await promises_1.default.rmdir(fileOrDir);
30
- return true;
31
- }
32
- }
33
- return false;
34
- }