@adinsure-ops/ops-cli 4.8.3 → 5.0.0-rc4
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/CHANGELOGS.md +52 -36
- package/LICENSE +1 -1
- package/README.md +32 -242
- package/bin/dev.cmd +3 -0
- package/bin/dev.js +6 -0
- package/bin/run.cmd +1 -1
- package/bin/run.js +8 -0
- package/lib/command.base.d.ts +9 -5
- package/lib/command.base.jira.d.ts +7 -8
- package/lib/command.base.jira.js +26 -24
- package/lib/command.base.js +69 -57
- package/lib/commands/docker/update-image-version.d.ts +6 -9
- package/lib/commands/docker/update-image-version.js +35 -34
- package/lib/commands/doctor.d.ts +15 -5
- package/lib/commands/doctor.js +219 -186
- package/lib/commands/download/client.d.ts +10 -7
- package/lib/commands/download/client.js +60 -52
- package/lib/commands/download/identity-server.d.ts +9 -7
- package/lib/commands/download/identity-server.js +59 -53
- package/lib/commands/download/jmeter.d.ts +5 -5
- package/lib/commands/download/jmeter.js +54 -49
- package/lib/commands/download/keycloak-scim.d.ts +6 -6
- package/lib/commands/download/keycloak-scim.js +56 -51
- package/lib/commands/download/platform.d.ts +9 -7
- package/lib/commands/download/platform.js +59 -53
- package/lib/commands/download/scheduler.d.ts +9 -7
- package/lib/commands/download/scheduler.js +59 -53
- package/lib/commands/download/server.d.ts +9 -7
- package/lib/commands/download/server.js +59 -53
- package/lib/commands/download/signalr.d.ts +9 -7
- package/lib/commands/download/signalr.js +59 -53
- package/lib/commands/download/studio.d.ts +12 -9
- package/lib/commands/download/studio.js +107 -82
- package/lib/commands/gitlab/get-tag-pipeline.d.ts +11 -14
- package/lib/commands/gitlab/get-tag-pipeline.js +95 -92
- package/lib/commands/gitlab/next-nightly-tag.d.ts +10 -12
- package/lib/commands/gitlab/next-nightly-tag.js +96 -98
- package/lib/commands/jira/issue.d.ts +6 -8
- package/lib/commands/jira/issue.js +25 -23
- package/lib/commands/jira/labels.d.ts +9 -12
- package/lib/commands/jira/labels.js +52 -51
- package/lib/commands/log/add.d.ts +6 -8
- package/lib/commands/log/add.js +92 -87
- package/lib/commands/log/generate.d.ts +9 -10
- package/lib/commands/log/generate.js +112 -107
- package/lib/commands/log/validate.d.ts +2 -2
- package/lib/commands/log/validate.js +47 -43
- package/lib/commands/login.d.ts +9 -10
- package/lib/commands/login.js +101 -97
- package/lib/commands/npm/check-publish.d.ts +7 -8
- package/lib/commands/npm/check-publish.js +59 -54
- package/lib/commands/npm/dependency-update.d.ts +14 -12
- package/lib/commands/npm/dependency-update.js +94 -86
- package/lib/commands/npm/publish.d.ts +8 -9
- package/lib/commands/npm/publish.js +154 -140
- package/lib/commands/nuget/dependency-update.d.ts +15 -10
- package/lib/commands/nuget/dependency-update.js +60 -49
- package/lib/commands/sql.d.ts +24 -20
- package/lib/commands/sql.js +245 -226
- package/lib/commands/translate.d.ts +15 -16
- package/lib/commands/translate.js +109 -104
- package/lib/commands/version.d.ts +29 -19
- package/lib/commands/version.js +215 -190
- package/lib/config.js +3 -6
- package/lib/hooks/init/version-override.d.ts +2 -2
- package/lib/hooks/init/version-override.js +15 -13
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -4
- package/lib/lib/command.d.ts +2 -0
- package/lib/lib/command.js +65 -58
- package/lib/lib/gitlab.d.ts +8 -2
- package/lib/lib/gitlab.js +94 -82
- package/lib/lib/npm.d.ts +7 -3
- package/lib/lib/npm.js +72 -60
- package/lib/lib/npmrc.d.ts +5 -0
- package/lib/lib/npmrc.js +20 -13
- package/lib/lib/nuget.d.ts +2 -0
- package/lib/lib/nuget.js +20 -17
- package/lib/security/cache.js +31 -27
- package/lib/security/context.d.ts +2 -1
- package/lib/security/context.js +106 -103
- package/lib/types/changelog.types.js +1 -2
- package/lib/types/npm.types.d.ts +5 -5
- package/lib/types/npm.types.js +1 -2
- package/oclif.manifest.json +1223 -1
- package/package.json +50 -46
- package/bin/run +0 -5
- package/lib/commands/prepare-content.d.ts +0 -29
- package/lib/commands/prepare-content.js +0 -386
|
@@ -1,113 +1,121 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const npm_1 = require("../../lib/npm");
|
|
12
|
-
class NpmDependencyUpdate extends command_base_1.default {
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { Args, Flags, ux } from '@oclif/core';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
import { minimatch } from 'minimatch';
|
|
6
|
+
import semver from 'semver';
|
|
7
|
+
import CommandBase from '../../command.base.js';
|
|
8
|
+
import ChildProcessCommand from '../../lib/command.js';
|
|
9
|
+
import NpmContext from '../../lib/npm.js';
|
|
10
|
+
class NpmDependencyUpdate extends CommandBase {
|
|
13
11
|
/**
|
|
14
12
|
* Update dependencies in package.json files for @adinsure packages
|
|
13
|
+
* @param {string} newVersion New version to update to
|
|
14
|
+
* @param {NpmPackage[]} packages Packages to update
|
|
15
|
+
* @param {boolean} [force=false] Force the update
|
|
16
|
+
* @param {string[]} filter Regular expressions filter for packages
|
|
17
|
+
* @returns {Prmoise<void>} Void Promise
|
|
15
18
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
updateDependencies(newVersion, packages, force = false, filter = ['**/*']) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
// Find all package.json files that are not in node modules
|
|
22
|
+
for (const path of packages) {
|
|
23
|
+
try {
|
|
24
|
+
const data = yield fs.readJSON(path.jsonPath);
|
|
25
|
+
const updatedKeys = [];
|
|
26
|
+
if (Object.prototype.hasOwnProperty.call(data, 'dependencies')) {
|
|
27
|
+
for (const [key, value] of Object.entries(data.dependencies)) {
|
|
28
|
+
const currentVersion = semver.valid(String(value));
|
|
29
|
+
if (filter.some(pkg => minimatch(key, pkg))) {
|
|
30
|
+
if (currentVersion && semver.gt(currentVersion, newVersion) && !force) {
|
|
31
|
+
this.warn(`Lower of same version for dependency ${key} updated in file ${path.jsonPath}: ${newVersion} vs. ${currentVersion} is ${semver.gt(newVersion, currentVersion)}`);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
data.dependencies[key] = newVersion;
|
|
35
|
+
updatedKeys.push(key);
|
|
36
|
+
}
|
|
32
37
|
}
|
|
33
38
|
}
|
|
39
|
+
fs.writeFileSync(path.jsonPath, JSON.stringify(data, null, 4));
|
|
40
|
+
if (updatedKeys.length > 0) {
|
|
41
|
+
this.log(`Dependencies ${updatedKeys} updated in file ${path.jsonPath}`);
|
|
42
|
+
}
|
|
34
43
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
data.devDependencies[key] = newVersion;
|
|
49
|
-
updatedKeys.push(key);
|
|
44
|
+
if (Object.prototype.hasOwnProperty.call(data, 'devDependencies')) {
|
|
45
|
+
for (const [key, value] of Object.entries(data.devDependencies)) {
|
|
46
|
+
const currentVersion = semver.valid(String(value));
|
|
47
|
+
if (filter.some(pkg => minimatch(key, pkg))) {
|
|
48
|
+
if (currentVersion && semver.gt(currentVersion, newVersion) && !force) {
|
|
49
|
+
this.warn(`Lower of same version for devDependency ${key} updated in file ${path.jsonPath}: ${newVersion} vs. ${currentVersion} is ${semver.gt(newVersion, currentVersion)}`);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
data.devDependencies[key] = newVersion;
|
|
53
|
+
updatedKeys.push(key);
|
|
54
|
+
}
|
|
50
55
|
}
|
|
51
56
|
}
|
|
57
|
+
fs.writeFileSync(path.jsonPath, JSON.stringify(data, null, 4));
|
|
58
|
+
if (updatedKeys.length > 0) {
|
|
59
|
+
this.log(`devDependencies ${updatedKeys} updated in file ${path.jsonPath}`);
|
|
60
|
+
}
|
|
52
61
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
this.warn(error.message);
|
|
66
|
+
break;
|
|
57
67
|
}
|
|
58
68
|
}
|
|
59
|
-
|
|
60
|
-
this.warn(err.message);
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
69
|
+
});
|
|
64
70
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
71
|
+
run() {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
const { args, flags } = yield this.parse(NpmDependencyUpdate);
|
|
74
|
+
const newVersion = semver.valid(args.version);
|
|
75
|
+
const npmContext = new NpmContext();
|
|
76
|
+
const command = new ChildProcessCommand();
|
|
77
|
+
// Stop if version invalid
|
|
78
|
+
if (!newVersion) {
|
|
79
|
+
return this.error(`${chalk.red('Version in incorrect format')}`);
|
|
80
|
+
}
|
|
81
|
+
const packages = yield npmContext.packageList(this);
|
|
82
|
+
try {
|
|
83
|
+
yield this.updateDependencies(newVersion, packages, flags.force, flags.filter);
|
|
84
|
+
ux.action.start(`running 'yarn install'`, undefined, { stdout: true });
|
|
85
|
+
yield command.runCommand(['yarn', 'install']);
|
|
86
|
+
ux.action.stop(`${chalk.green('done')}`);
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
this.error(error.message);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
84
93
|
}
|
|
85
94
|
}
|
|
86
|
-
exports.default = NpmDependencyUpdate;
|
|
87
95
|
NpmDependencyUpdate.description = 'update npm dependencies per package filter';
|
|
88
96
|
NpmDependencyUpdate.usage = 'npm:dependency-update <type> [flags]';
|
|
89
97
|
NpmDependencyUpdate.examples = [
|
|
90
|
-
`$ ops npm:dependency-update 3.4.3 --filter @adinsure
|
|
98
|
+
`$ ops npm:dependency-update 3.4.3 --filter @adinsure/*`,
|
|
91
99
|
];
|
|
92
|
-
NpmDependencyUpdate.args =
|
|
93
|
-
{
|
|
94
|
-
name: 'version',
|
|
100
|
+
NpmDependencyUpdate.args = {
|
|
101
|
+
version: Args.string({
|
|
95
102
|
required: true,
|
|
96
|
-
description: 'Type of release'
|
|
97
|
-
}
|
|
98
|
-
|
|
103
|
+
description: 'Type of release',
|
|
104
|
+
}),
|
|
105
|
+
};
|
|
99
106
|
NpmDependencyUpdate.flags = {
|
|
100
|
-
filter:
|
|
107
|
+
filter: Flags.string({
|
|
101
108
|
description: 'regular expression for which NPM packages to update',
|
|
102
109
|
required: true,
|
|
103
|
-
multiple: true
|
|
110
|
+
multiple: true,
|
|
104
111
|
}),
|
|
105
|
-
exclude:
|
|
112
|
+
exclude: Flags.string({
|
|
106
113
|
description: 'exclude directories where to search for package.json',
|
|
107
|
-
multiple: true
|
|
114
|
+
multiple: true,
|
|
108
115
|
}),
|
|
109
|
-
force:
|
|
116
|
+
force: Flags.boolean({
|
|
110
117
|
description: 'force update of version regardless of lower vs higher version check',
|
|
111
|
-
default: false
|
|
112
|
-
})
|
|
118
|
+
default: false,
|
|
119
|
+
}),
|
|
113
120
|
};
|
|
121
|
+
export default NpmDependencyUpdate;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
export default class NpmPublish extends CommandBase {
|
|
1
|
+
import CommandBase from '../../command.base.js';
|
|
2
|
+
import { AzurePackageArray, NpmPackage } from '../../types/npm.types.js';
|
|
3
|
+
export default class NpmPublish extends CommandBase<typeof NpmPublish> {
|
|
5
4
|
static description: string;
|
|
6
5
|
static usage: string;
|
|
7
6
|
static examples: string[];
|
|
8
7
|
static flags: {
|
|
9
|
-
package:
|
|
10
|
-
exclude:
|
|
11
|
-
version:
|
|
12
|
-
pat:
|
|
13
|
-
retry: import("@oclif/
|
|
8
|
+
package: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
9
|
+
exclude: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
10
|
+
version: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
|
+
pat: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
12
|
+
retry: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
14
13
|
};
|
|
15
14
|
private cp;
|
|
16
15
|
publishPackage(pkg: NpmPackage, cmd?: string[]): Promise<{
|
|
@@ -1,182 +1,196 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
sh = 'cmd';
|
|
18
|
-
args = ['/c'].concat(cmd);
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
[sh, ...args] = cmd;
|
|
22
|
-
}
|
|
23
|
-
try {
|
|
24
|
-
this.cp = child_process_1.spawn(sh, args, {
|
|
25
|
-
cwd: pkg.path,
|
|
26
|
-
env: Object.assign(Object.assign({}, process.env), process.stdout.isTTY ? { FORCE_COLOR: process.env.FORCE_COLOR || '1' } : {}),
|
|
27
|
-
stdio: 'pipe'
|
|
28
|
-
});
|
|
29
|
-
let data = '';
|
|
30
|
-
try {
|
|
31
|
-
for (var _c = tslib_1.__asyncValues(this.cp.stdout), _d; _d = await _c.next(), !_d.done;) {
|
|
32
|
-
const chunk = _d.value;
|
|
33
|
-
data += chunk;
|
|
34
|
-
}
|
|
1
|
+
import { __asyncValues, __awaiter } from "tslib";
|
|
2
|
+
import { Flags, ux } from '@oclif/core';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { spawn } from 'child_process';
|
|
5
|
+
import CommandBase from '../../command.base.js';
|
|
6
|
+
import NpmContext from '../../lib/npm.js';
|
|
7
|
+
class NpmPublish extends CommandBase {
|
|
8
|
+
publishPackage(pkg, cmd = ['yarn', 'publish']) {
|
|
9
|
+
var _a, e_1, _b, _c, _d, e_2, _e, _f;
|
|
10
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11
|
+
let sh;
|
|
12
|
+
let args;
|
|
13
|
+
// cross platform compatibility
|
|
14
|
+
if (process.platform === 'win32') {
|
|
15
|
+
sh = 'cmd';
|
|
16
|
+
args = ['/c', ...cmd];
|
|
35
17
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
if (_d && !_d.done && (_a = _c.return)) await _a.call(_c);
|
|
40
|
-
}
|
|
41
|
-
finally { if (e_1) throw e_1.error; }
|
|
18
|
+
else {
|
|
19
|
+
[sh, ...args] = cmd;
|
|
42
20
|
}
|
|
43
|
-
let error = '';
|
|
44
21
|
try {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
22
|
+
this.cp = spawn(sh, args, {
|
|
23
|
+
cwd: pkg.path,
|
|
24
|
+
env: Object.assign(Object.assign({}, process.env), process.stdout.isTTY ? { FORCE_COLOR: process.env.FORCE_COLOR || '1' } : {}),
|
|
25
|
+
stdio: 'pipe',
|
|
26
|
+
});
|
|
27
|
+
let data = '';
|
|
28
|
+
try {
|
|
29
|
+
for (var _g = true, _h = __asyncValues(this.cp.stdout), _j; _j = yield _h.next(), _a = _j.done, !_a; _g = true) {
|
|
30
|
+
_c = _j.value;
|
|
31
|
+
_g = false;
|
|
32
|
+
const chunk = _c;
|
|
33
|
+
data += chunk;
|
|
34
|
+
}
|
|
48
35
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
36
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
37
|
+
finally {
|
|
38
|
+
try {
|
|
39
|
+
if (!_g && !_a && (_b = _h.return)) yield _b.call(_h);
|
|
40
|
+
}
|
|
41
|
+
finally { if (e_1) throw e_1.error; }
|
|
42
|
+
}
|
|
43
|
+
let error = '';
|
|
52
44
|
try {
|
|
53
|
-
|
|
45
|
+
for (var _k = true, _l = __asyncValues(this.cp.stderr), _m; _m = yield _l.next(), _d = _m.done, !_d; _k = true) {
|
|
46
|
+
_f = _m.value;
|
|
47
|
+
_k = false;
|
|
48
|
+
const chunk = _f;
|
|
49
|
+
error += chunk;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
53
|
+
finally {
|
|
54
|
+
try {
|
|
55
|
+
if (!_k && !_d && (_e = _l.return)) yield _e.call(_l);
|
|
56
|
+
}
|
|
57
|
+
finally { if (e_2) throw e_2.error; }
|
|
54
58
|
}
|
|
55
|
-
|
|
59
|
+
const exitCode = yield new Promise((resolve, _reject) => {
|
|
60
|
+
this.cp.on('close', resolve);
|
|
61
|
+
});
|
|
62
|
+
if (exitCode) {
|
|
63
|
+
throw new Error(`subprocess error exit ${exitCode}, ${error}`);
|
|
64
|
+
}
|
|
65
|
+
return { data, error };
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
56
67
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
});
|
|
60
|
-
if (exitCode) {
|
|
61
|
-
throw new Error(`subprocess error exit ${exitCode}, ${error}`);
|
|
68
|
+
catch (error) {
|
|
69
|
+
throw new Error(error.message);
|
|
62
70
|
}
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
catch (err) {
|
|
66
|
-
throw new Error(err.message);
|
|
67
|
-
}
|
|
71
|
+
});
|
|
68
72
|
}
|
|
69
|
-
|
|
70
|
-
this
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (!matchedPackage) {
|
|
79
|
-
cli_ux_1.default.action.stop(`${chalk_1.default.green('new package')}`);
|
|
80
|
-
cli_ux_1.default.action.start(`publish new package ${pkg.name}@${pkg.version} from ${pkg.jsonPath}`, undefined, { stdout: true });
|
|
81
|
-
try {
|
|
82
|
-
await this.publishPackage(pkg);
|
|
73
|
+
checkPackageCanPublish(pkg, allPackages, version, retries) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
this.log('');
|
|
76
|
+
ux.action.start(`${pkg.name}@${pkg.version}`, undefined, { stdout: true });
|
|
77
|
+
const matchedPackage = allPackages.value.find(azurePackage => azurePackage.name === pkg.name);
|
|
78
|
+
if (pkg.version !== version) {
|
|
79
|
+
this.warn(`${pkg.name}@${pkg.version} doesn't match desired publish version!`);
|
|
80
|
+
ux.action.stop(chalk.red(`version doesn't match version ${version}`));
|
|
81
|
+
throw new Error(`Version in package.json doesn't match desired published version`);
|
|
83
82
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
83
|
+
if (!matchedPackage) {
|
|
84
|
+
ux.action.stop(`${chalk.green('new package')}`);
|
|
85
|
+
ux.action.start(`publish new package ${pkg.name}@${pkg.version} from ${pkg.jsonPath}`, undefined, { stdout: true });
|
|
86
|
+
try {
|
|
87
|
+
yield this.publishPackage(pkg);
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
if (error instanceof Error && error.message.includes('subprocess error exit')) {
|
|
92
|
+
// Check if the error message contains 'subprocess error exit'
|
|
93
|
+
// Extract the HTTP status code from the error message
|
|
94
|
+
const statusCodeMatch = /\d{3}/.exec(error.message);
|
|
95
|
+
const statusCode = statusCodeMatch ? Number.parseInt(statusCodeMatch[0], 10) : null;
|
|
96
|
+
if (statusCode && (statusCode >= 400 && statusCode < 600)) {
|
|
97
|
+
for (let i = 0; i < retries - 1; i++) {
|
|
98
|
+
yield this.publishPackage(pkg);
|
|
99
|
+
}
|
|
93
100
|
}
|
|
94
101
|
}
|
|
95
102
|
}
|
|
103
|
+
ux.action.stop(`${chalk.green('done')}`);
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
const matchVersion = matchedPackage.versions.find(azurePackageVersion => azurePackageVersion.version === pkg.version);
|
|
107
|
+
if (!matchVersion) {
|
|
108
|
+
ux.action.stop(`${chalk.yellow('version missing')}`);
|
|
109
|
+
ux.action.start(`publish new version ${pkg.name}@${pkg.version} from ${pkg.jsonPath}`, undefined, { stdout: true });
|
|
110
|
+
yield this.publishPackage(pkg);
|
|
111
|
+
ux.action.stop(`${chalk.green('done')}`);
|
|
112
|
+
return true;
|
|
96
113
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (!matchVersion) {
|
|
102
|
-
cli_ux_1.default.action.stop(`${chalk_1.default.yellow('version missing')}`);
|
|
103
|
-
cli_ux_1.default.action.start(`publish new version ${pkg.name}@${pkg.version} from ${pkg.jsonPath}`, undefined, { stdout: true });
|
|
104
|
-
await this.publishPackage(pkg);
|
|
105
|
-
cli_ux_1.default.action.stop(`${chalk_1.default.green('done')}`);
|
|
106
|
-
return true;
|
|
107
|
-
}
|
|
108
|
-
this.warn(`${pkg.name}@${pkg.version} already exists`);
|
|
109
|
-
cli_ux_1.default.action.stop(`${chalk_1.default.blue('skipping')}`);
|
|
110
|
-
return false;
|
|
114
|
+
this.warn(`${pkg.name}@${pkg.version} already exists`);
|
|
115
|
+
ux.action.stop(`${chalk.blue('skipping')}`);
|
|
116
|
+
return false;
|
|
117
|
+
});
|
|
111
118
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
+
publishPackages(packages, allPackages, version, retries) {
|
|
120
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
+
let errorCount = 0;
|
|
122
|
+
this.log(`publishing ${packages.length} packages:`);
|
|
123
|
+
this.log(packages.map(pkg => pkg.name).toString());
|
|
124
|
+
for (const pkg of packages) {
|
|
125
|
+
try {
|
|
126
|
+
yield this.checkPackageCanPublish(pkg, allPackages, version, retries);
|
|
127
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
this.warn(error.message);
|
|
131
|
+
errorCount++;
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
119
134
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
errorCount++;
|
|
123
|
-
continue;
|
|
135
|
+
if (errorCount > 0) {
|
|
136
|
+
throw new Error(`${errorCount} with Errors!`);
|
|
124
137
|
}
|
|
125
|
-
}
|
|
126
|
-
if (errorCount > 0) {
|
|
127
|
-
throw new Error(`${errorCount} with Errors!`);
|
|
128
|
-
}
|
|
138
|
+
});
|
|
129
139
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
140
|
+
run() {
|
|
141
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
142
|
+
try {
|
|
143
|
+
const { flags } = yield this.parse(NpmPublish);
|
|
144
|
+
const npmContext = new NpmContext();
|
|
145
|
+
ux.action.start('Parsing packages to check', undefined, { stdout: true });
|
|
146
|
+
const packages = yield npmContext.packageList(this, flags.package, flags.exclude);
|
|
147
|
+
ux.action.stop(`${chalk.green('done')}`);
|
|
148
|
+
ux.action.start('Getting list of published packages', undefined, { stdout: true });
|
|
149
|
+
// eslint-disable-next-line unicorn/no-await-expression-member
|
|
150
|
+
const allPackages = JSON.parse((yield npmContext.getAllNpmPackages(flags.pat)).data);
|
|
151
|
+
ux.action.stop(`${chalk.green('done')}`);
|
|
152
|
+
yield this.publishPackages(packages, allPackages, flags.version, flags.retry);
|
|
153
|
+
ux.action.stop('success');
|
|
154
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
ux.action.stop('error');
|
|
158
|
+
this.error(`${error.message}`);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
147
161
|
}
|
|
148
162
|
}
|
|
149
|
-
exports.default = NpmPublish;
|
|
150
163
|
NpmPublish.description = 'Publish npm packages';
|
|
151
164
|
NpmPublish.usage = 'npm:publish [options]';
|
|
152
165
|
NpmPublish.examples = [
|
|
153
166
|
'$ ops npm:publish -v 15.0.0',
|
|
154
167
|
'$ ops npm:publish -v 15.0.0',
|
|
155
168
|
'$ ops npm:publish -p @adinsure-tooling/* -v 15.0.0',
|
|
156
|
-
'$ ops npm:publish -p @adinsure-tooling/* -x @adisure-tooling/studio-services -v 6.0.0'
|
|
169
|
+
'$ ops npm:publish -p @adinsure-tooling/* -x @adisure-tooling/studio-services -v 6.0.0',
|
|
157
170
|
];
|
|
158
171
|
NpmPublish.flags = {
|
|
159
|
-
package:
|
|
172
|
+
package: Flags.string({
|
|
160
173
|
char: 'p',
|
|
161
174
|
description: 'package name filter you want to check',
|
|
162
|
-
multiple: true
|
|
175
|
+
multiple: true,
|
|
163
176
|
}),
|
|
164
|
-
exclude:
|
|
177
|
+
exclude: Flags.string({
|
|
165
178
|
char: 'x',
|
|
166
179
|
description: 'exclude packages from filter',
|
|
167
|
-
multiple: true
|
|
180
|
+
multiple: true,
|
|
168
181
|
}),
|
|
169
|
-
version:
|
|
182
|
+
version: Flags.string({
|
|
170
183
|
char: 'v',
|
|
171
184
|
description: 'version we want to check if published',
|
|
172
|
-
required: true
|
|
185
|
+
required: true,
|
|
173
186
|
}),
|
|
174
|
-
pat:
|
|
187
|
+
pat: Flags.string({
|
|
175
188
|
description: 'PAT token or AZURE_DEVOPS_EXT_PAT environment variable',
|
|
176
|
-
env: 'AZURE_DEVOPS_EXT_PAT'
|
|
189
|
+
env: 'AZURE_DEVOPS_EXT_PAT',
|
|
177
190
|
}),
|
|
178
|
-
retry:
|
|
191
|
+
retry: Flags.integer({
|
|
179
192
|
description: 'Number of npm publishing retries in case of 4xx or 5xx http errors',
|
|
180
|
-
default: 3
|
|
193
|
+
default: 3,
|
|
181
194
|
}),
|
|
182
195
|
};
|
|
196
|
+
export default NpmPublish;
|
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export default class NuGetDependencyUpdate extends CommandBase {
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class NuGetDependencyUpdate extends Command {
|
|
4
3
|
static description: string;
|
|
5
4
|
static usage: string;
|
|
6
5
|
static examples: string[];
|
|
7
6
|
static args: {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
description: string;
|
|
11
|
-
}[];
|
|
7
|
+
version: import("@oclif/core/lib/interfaces/parser.js").Arg<string, Record<string, unknown>>;
|
|
8
|
+
};
|
|
12
9
|
static flags: {
|
|
13
|
-
filter:
|
|
14
|
-
exclude:
|
|
10
|
+
filter: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
|
+
exclude: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
15
12
|
};
|
|
16
13
|
/**
|
|
17
14
|
* Update dependencies in csproj files for @adinsure packages
|
|
15
|
+
* @param
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Update dependencies in csproj files for @adinsure packages
|
|
19
|
+
* @param {string} newVersion New version to update to
|
|
20
|
+
* @param {NpmPackage[]} packages Packages to update
|
|
21
|
+
* @param {string[]} filter Regular expressions filter for packages
|
|
22
|
+
* @returns {Prmoise<void>} Void Promise
|
|
18
23
|
*/
|
|
19
|
-
updateDependencies(newVersion: string,
|
|
24
|
+
updateDependencies(newVersion: string, packages: string[], filter?: string): Promise<void>;
|
|
20
25
|
run(): Promise<undefined>;
|
|
21
26
|
}
|