rman 0.35.0 → 0.36.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.
- package/cjs/commands/publish-command.js +24 -20
- package/cjs/commands/run-command.js +4 -3
- package/cjs/tsconfig-build-cjs.tsbuildinfo +1 -1
- package/cjs/utils/npm-utils.js +9 -8
- package/cjs/utils/package-not-found-error.js +6 -0
- package/esm/commands/publish-command.js +24 -20
- package/esm/commands/run-command.js +4 -3
- package/esm/tsconfig-build-esm.tsbuildinfo +1 -1
- package/esm/utils/npm-utils.js +7 -6
- package/esm/utils/package-not-found-error.js +2 -0
- package/package.json +1 -1
- package/types/utils/npm-utils.d.ts +3 -5
- package/types/utils/package-not-found-error.d.ts +2 -0
|
@@ -7,6 +7,7 @@ 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");
|
|
9
9
|
const npm_utils_js_1 = require("../utils/npm-utils.js");
|
|
10
|
+
const package_not_found_error_js_1 = require("../utils/package-not-found-error.js");
|
|
10
11
|
const run_command_js_1 = require("./run-command.js");
|
|
11
12
|
class PublishCommand extends run_command_js_1.RunCommand {
|
|
12
13
|
constructor(repository, options) {
|
|
@@ -28,35 +29,37 @@ class PublishCommand extends run_command_js_1.RunCommand {
|
|
|
28
29
|
continue;
|
|
29
30
|
}
|
|
30
31
|
npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, `Fetching package information from repository`);
|
|
31
|
-
const npmHelper = new npm_utils_js_1.NpmHelper({ cwd: p.dirname });
|
|
32
|
+
const npmHelper = new npm_utils_js_1.NpmHelper({ cwd: p.dirname, userconfig: this.options.userconfig });
|
|
32
33
|
promises.push(npmHelper
|
|
33
|
-
.getPackageInfo(p.json.name
|
|
34
|
+
.getPackageInfo(p.json.name)
|
|
34
35
|
.then(r => {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
` Version "${ansi_colors_1.default.magenta(p.version)}" differs from version in repository (${ansi_colors_1.default.magenta(r.version)})`);
|
|
36
|
+
const fetchedVersion = r.version;
|
|
37
|
+
const sameVersion = fetchedVersion === p.version;
|
|
38
|
+
npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, sameVersion
|
|
39
|
+
? `No publish needed. Version (${ansi_colors_1.default.magenta(p.version)}) same in repository`
|
|
40
|
+
: `Publishing is possible.` +
|
|
41
|
+
` Version "${ansi_colors_1.default.magenta(p.version)}" differs from version in repository (${ansi_colors_1.default.magenta(fetchedVersion)})`);
|
|
42
|
+
if (this.options.checkOnly)
|
|
43
43
|
return;
|
|
44
|
-
|
|
45
|
-
if (r && r.version === p.version) {
|
|
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
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
npmlog_1.default.verbose(this.commandName, logPkgName, npmlog_1.default.separator, `Publishing is possible.` +
|
|
50
|
-
` Version "${ansi_colors_1.default.magenta(p.version)}" differs from version in repository (${ansi_colors_1.default.magenta(r.version)})`);
|
|
44
|
+
if (fetchedVersion === p.version) {
|
|
51
45
|
selectedPackages.push(p);
|
|
52
46
|
}
|
|
53
47
|
})
|
|
54
48
|
.catch(e => {
|
|
55
|
-
if (e
|
|
49
|
+
if (e instanceof package_not_found_error_js_1.PackageNotFoundError) {
|
|
50
|
+
npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, 'Publishing is possible. No package information found in repository');
|
|
51
|
+
selectedPackages.push(p);
|
|
52
|
+
}
|
|
53
|
+
else
|
|
56
54
|
throw e;
|
|
57
55
|
}));
|
|
58
56
|
}
|
|
59
57
|
await Promise.all(promises);
|
|
58
|
+
npmlog_1.default.verbose(this.commandName, '', npmlog_1.default.separator, `${selectedPackages.length} packages will be published`);
|
|
59
|
+
selectedPackages.forEach(p => {
|
|
60
|
+
p.json.scripts = p.json.scripts || {};
|
|
61
|
+
p.json.scripts.publish = '#';
|
|
62
|
+
});
|
|
60
63
|
return super._prepareTasks(selectedPackages, { newVersions });
|
|
61
64
|
}
|
|
62
65
|
async _exec(pkg, command, args, options) {
|
|
@@ -71,9 +74,10 @@ class PublishCommand extends run_command_js_1.RunCommand {
|
|
|
71
74
|
else
|
|
72
75
|
cwd = path_1.default.join(pkg.dirname, contents);
|
|
73
76
|
}
|
|
74
|
-
|
|
77
|
+
const npmHelper = new npm_utils_js_1.NpmHelper({ cwd: pkg.dirname, userconfig: this.options.userconfig });
|
|
78
|
+
return super._exec(pkg, 'echo npm publish' +
|
|
75
79
|
(this.options.access ? ' --access=' + this.options.access : '') +
|
|
76
|
-
(
|
|
80
|
+
(npmHelper.userconfig ? ` --userconfig="${npmHelper.userconfig}"` : ''), {
|
|
77
81
|
...args,
|
|
78
82
|
cwd,
|
|
79
83
|
stdio: npmlog_1.default.levelIndex < 1000 ? 'inherit' : 'pipe',
|
|
@@ -26,11 +26,12 @@ class RunCommand extends multi_task_command_js_1.MultiTaskCommand {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
const rootTask = this._prepareScriptTask(this.repository.rootPackage);
|
|
29
|
-
|
|
29
|
+
const children = rootTask?.options.children;
|
|
30
|
+
if (!children)
|
|
30
31
|
return packageTasks;
|
|
31
32
|
const tasks = [];
|
|
32
|
-
const pre =
|
|
33
|
-
const post =
|
|
33
|
+
const pre = children.filter(t => t.name?.endsWith(':pre' + this.script));
|
|
34
|
+
const post = children.filter(t => t.name?.endsWith(':post' + this.script));
|
|
34
35
|
pre.forEach(t => (t.options.exclusive = true));
|
|
35
36
|
post.forEach(t => (t.options.exclusive = true));
|
|
36
37
|
tasks.push(...pre);
|
|
@@ -1 +1 @@
|
|
|
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"],"version":"5.7.3"}
|
|
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/npm-utils.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NpmHelper =
|
|
3
|
+
exports.NpmHelper = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
4
6
|
const exec_js_1 = require("./exec.js");
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
exports.PackageNotFoundError = PackageNotFoundError;
|
|
7
|
+
const package_not_found_error_js_1 = require("./package-not-found-error.js");
|
|
8
8
|
class NpmHelper {
|
|
9
9
|
constructor(options) {
|
|
10
10
|
this.cwd = options?.cwd || process.cwd();
|
|
11
|
+
this.userconfig = options?.userconfig ? path_1.default.resolve(this.cwd, options.userconfig) : undefined;
|
|
11
12
|
}
|
|
12
|
-
async getPackageInfo(packageName
|
|
13
|
+
async getPackageInfo(packageName) {
|
|
13
14
|
const argv = ['view', packageName, '--json'];
|
|
14
|
-
if (
|
|
15
|
-
argv.push('--userconfig',
|
|
15
|
+
if (this.userconfig)
|
|
16
|
+
argv.push('--userconfig', this.userconfig);
|
|
16
17
|
const x = await (0, exec_js_1.exec)('npm', { cwd: this.cwd, argv });
|
|
17
18
|
if (x && x.stdout) {
|
|
18
19
|
if (x.code && x.stdout.includes('404')) {
|
|
19
|
-
|
|
20
|
+
throw new package_not_found_error_js_1.PackageNotFoundError('Package ' + packageName + ' not found in repository');
|
|
20
21
|
}
|
|
21
22
|
const b = x.stdout.indexOf('{');
|
|
22
23
|
const e = x.stdout.lastIndexOf('}');
|
|
@@ -3,6 +3,7 @@ import logger from 'npmlog';
|
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { Command } from '../core/command.js';
|
|
5
5
|
import { NpmHelper } from '../utils/npm-utils.js';
|
|
6
|
+
import { PackageNotFoundError } from '../utils/package-not-found-error.js';
|
|
6
7
|
import { RunCommand } from './run-command.js';
|
|
7
8
|
export class PublishCommand extends RunCommand {
|
|
8
9
|
constructor(repository, options) {
|
|
@@ -24,35 +25,37 @@ export class PublishCommand extends RunCommand {
|
|
|
24
25
|
continue;
|
|
25
26
|
}
|
|
26
27
|
logger.info(this.commandName, logPkgName, logger.separator, `Fetching package information from repository`);
|
|
27
|
-
const npmHelper = new NpmHelper({ cwd: p.dirname });
|
|
28
|
+
const npmHelper = new NpmHelper({ cwd: p.dirname, userconfig: this.options.userconfig });
|
|
28
29
|
promises.push(npmHelper
|
|
29
|
-
.getPackageInfo(p.json.name
|
|
30
|
+
.getPackageInfo(p.json.name)
|
|
30
31
|
.then(r => {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
` Version "${colors.magenta(p.version)}" differs from version in repository (${colors.magenta(r.version)})`);
|
|
32
|
+
const fetchedVersion = r.version;
|
|
33
|
+
const sameVersion = fetchedVersion === p.version;
|
|
34
|
+
logger.info(this.commandName, logPkgName, logger.separator, sameVersion
|
|
35
|
+
? `No publish needed. Version (${colors.magenta(p.version)}) same in repository`
|
|
36
|
+
: `Publishing is possible.` +
|
|
37
|
+
` Version "${colors.magenta(p.version)}" differs from version in repository (${colors.magenta(fetchedVersion)})`);
|
|
38
|
+
if (this.options.checkOnly)
|
|
39
39
|
return;
|
|
40
|
-
|
|
41
|
-
if (r && r.version === p.version) {
|
|
42
|
-
logger.info(this.commandName, logPkgName, logger.separator, `No publish needed. Version (${colors.magenta(p.version)}) same in repository`);
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
logger.verbose(this.commandName, logPkgName, logger.separator, `Publishing is possible.` +
|
|
46
|
-
` Version "${colors.magenta(p.version)}" differs from version in repository (${colors.magenta(r.version)})`);
|
|
40
|
+
if (fetchedVersion === p.version) {
|
|
47
41
|
selectedPackages.push(p);
|
|
48
42
|
}
|
|
49
43
|
})
|
|
50
44
|
.catch(e => {
|
|
51
|
-
if (e
|
|
45
|
+
if (e instanceof PackageNotFoundError) {
|
|
46
|
+
logger.info(this.commandName, logPkgName, logger.separator, 'Publishing is possible. No package information found in repository');
|
|
47
|
+
selectedPackages.push(p);
|
|
48
|
+
}
|
|
49
|
+
else
|
|
52
50
|
throw e;
|
|
53
51
|
}));
|
|
54
52
|
}
|
|
55
53
|
await Promise.all(promises);
|
|
54
|
+
logger.verbose(this.commandName, '', logger.separator, `${selectedPackages.length} packages will be published`);
|
|
55
|
+
selectedPackages.forEach(p => {
|
|
56
|
+
p.json.scripts = p.json.scripts || {};
|
|
57
|
+
p.json.scripts.publish = '#';
|
|
58
|
+
});
|
|
56
59
|
return super._prepareTasks(selectedPackages, { newVersions });
|
|
57
60
|
}
|
|
58
61
|
async _exec(pkg, command, args, options) {
|
|
@@ -67,9 +70,10 @@ export class PublishCommand extends RunCommand {
|
|
|
67
70
|
else
|
|
68
71
|
cwd = path.join(pkg.dirname, contents);
|
|
69
72
|
}
|
|
70
|
-
|
|
73
|
+
const npmHelper = new NpmHelper({ cwd: pkg.dirname, userconfig: this.options.userconfig });
|
|
74
|
+
return super._exec(pkg, 'echo npm publish' +
|
|
71
75
|
(this.options.access ? ' --access=' + this.options.access : '') +
|
|
72
|
-
(
|
|
76
|
+
(npmHelper.userconfig ? ` --userconfig="${npmHelper.userconfig}"` : ''), {
|
|
73
77
|
...args,
|
|
74
78
|
cwd,
|
|
75
79
|
stdio: logger.levelIndex < 1000 ? 'inherit' : 'pipe',
|
|
@@ -22,11 +22,12 @@ export class RunCommand extends MultiTaskCommand {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
const rootTask = this._prepareScriptTask(this.repository.rootPackage);
|
|
25
|
-
|
|
25
|
+
const children = rootTask?.options.children;
|
|
26
|
+
if (!children)
|
|
26
27
|
return packageTasks;
|
|
27
28
|
const tasks = [];
|
|
28
|
-
const pre =
|
|
29
|
-
const post =
|
|
29
|
+
const pre = children.filter(t => t.name?.endsWith(':pre' + this.script));
|
|
30
|
+
const post = children.filter(t => t.name?.endsWith(':post' + this.script));
|
|
30
31
|
pre.forEach(t => (t.options.exclusive = true));
|
|
31
32
|
post.forEach(t => (t.options.exclusive = true));
|
|
32
33
|
tasks.push(...pre);
|
|
@@ -1 +1 @@
|
|
|
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"],"version":"5.7.3"}
|
|
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/esm/utils/npm-utils.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
+
import path from 'path';
|
|
1
2
|
import { exec } from './exec.js';
|
|
2
|
-
|
|
3
|
-
}
|
|
3
|
+
import { PackageNotFoundError } from './package-not-found-error.js';
|
|
4
4
|
export class NpmHelper {
|
|
5
5
|
constructor(options) {
|
|
6
6
|
this.cwd = options?.cwd || process.cwd();
|
|
7
|
+
this.userconfig = options?.userconfig ? path.resolve(this.cwd, options.userconfig) : undefined;
|
|
7
8
|
}
|
|
8
|
-
async getPackageInfo(packageName
|
|
9
|
+
async getPackageInfo(packageName) {
|
|
9
10
|
const argv = ['view', packageName, '--json'];
|
|
10
|
-
if (
|
|
11
|
-
argv.push('--userconfig',
|
|
11
|
+
if (this.userconfig)
|
|
12
|
+
argv.push('--userconfig', this.userconfig);
|
|
12
13
|
const x = await exec('npm', { cwd: this.cwd, argv });
|
|
13
14
|
if (x && x.stdout) {
|
|
14
15
|
if (x.code && x.stdout.includes('404')) {
|
|
15
|
-
|
|
16
|
+
throw new PackageNotFoundError('Package ' + packageName + ' not found in repository');
|
|
16
17
|
}
|
|
17
18
|
const b = x.stdout.indexOf('{');
|
|
18
19
|
const e = x.stdout.lastIndexOf('}');
|
package/package.json
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
export declare class PackageNotFoundError extends Error {
|
|
2
|
-
}
|
|
3
1
|
export declare namespace NpmHelper { }
|
|
4
2
|
export interface NpmOptions {
|
|
5
3
|
cwd?: string;
|
|
4
|
+
userconfig?: string;
|
|
6
5
|
}
|
|
7
6
|
export declare class NpmHelper {
|
|
8
7
|
cwd: string;
|
|
8
|
+
userconfig?: string;
|
|
9
9
|
constructor(options?: NpmOptions);
|
|
10
|
-
getPackageInfo(packageName: string
|
|
11
|
-
userconfig?: string;
|
|
12
|
-
}): Promise<any>;
|
|
10
|
+
getPackageInfo(packageName: string): Promise<any>;
|
|
13
11
|
}
|