@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.
Files changed (89) hide show
  1. package/CHANGELOGS.md +52 -36
  2. package/LICENSE +1 -1
  3. package/README.md +32 -242
  4. package/bin/dev.cmd +3 -0
  5. package/bin/dev.js +6 -0
  6. package/bin/run.cmd +1 -1
  7. package/bin/run.js +8 -0
  8. package/lib/command.base.d.ts +9 -5
  9. package/lib/command.base.jira.d.ts +7 -8
  10. package/lib/command.base.jira.js +26 -24
  11. package/lib/command.base.js +69 -57
  12. package/lib/commands/docker/update-image-version.d.ts +6 -9
  13. package/lib/commands/docker/update-image-version.js +35 -34
  14. package/lib/commands/doctor.d.ts +15 -5
  15. package/lib/commands/doctor.js +219 -186
  16. package/lib/commands/download/client.d.ts +10 -7
  17. package/lib/commands/download/client.js +60 -52
  18. package/lib/commands/download/identity-server.d.ts +9 -7
  19. package/lib/commands/download/identity-server.js +59 -53
  20. package/lib/commands/download/jmeter.d.ts +5 -5
  21. package/lib/commands/download/jmeter.js +54 -49
  22. package/lib/commands/download/keycloak-scim.d.ts +6 -6
  23. package/lib/commands/download/keycloak-scim.js +56 -51
  24. package/lib/commands/download/platform.d.ts +9 -7
  25. package/lib/commands/download/platform.js +59 -53
  26. package/lib/commands/download/scheduler.d.ts +9 -7
  27. package/lib/commands/download/scheduler.js +59 -53
  28. package/lib/commands/download/server.d.ts +9 -7
  29. package/lib/commands/download/server.js +59 -53
  30. package/lib/commands/download/signalr.d.ts +9 -7
  31. package/lib/commands/download/signalr.js +59 -53
  32. package/lib/commands/download/studio.d.ts +12 -9
  33. package/lib/commands/download/studio.js +107 -82
  34. package/lib/commands/gitlab/get-tag-pipeline.d.ts +11 -14
  35. package/lib/commands/gitlab/get-tag-pipeline.js +95 -92
  36. package/lib/commands/gitlab/next-nightly-tag.d.ts +10 -12
  37. package/lib/commands/gitlab/next-nightly-tag.js +96 -98
  38. package/lib/commands/jira/issue.d.ts +6 -8
  39. package/lib/commands/jira/issue.js +25 -23
  40. package/lib/commands/jira/labels.d.ts +9 -12
  41. package/lib/commands/jira/labels.js +52 -51
  42. package/lib/commands/log/add.d.ts +6 -8
  43. package/lib/commands/log/add.js +92 -87
  44. package/lib/commands/log/generate.d.ts +9 -10
  45. package/lib/commands/log/generate.js +112 -107
  46. package/lib/commands/log/validate.d.ts +2 -2
  47. package/lib/commands/log/validate.js +47 -43
  48. package/lib/commands/login.d.ts +9 -10
  49. package/lib/commands/login.js +101 -97
  50. package/lib/commands/npm/check-publish.d.ts +7 -8
  51. package/lib/commands/npm/check-publish.js +59 -54
  52. package/lib/commands/npm/dependency-update.d.ts +14 -12
  53. package/lib/commands/npm/dependency-update.js +94 -86
  54. package/lib/commands/npm/publish.d.ts +8 -9
  55. package/lib/commands/npm/publish.js +154 -140
  56. package/lib/commands/nuget/dependency-update.d.ts +15 -10
  57. package/lib/commands/nuget/dependency-update.js +60 -49
  58. package/lib/commands/sql.d.ts +24 -20
  59. package/lib/commands/sql.js +245 -226
  60. package/lib/commands/translate.d.ts +15 -16
  61. package/lib/commands/translate.js +109 -104
  62. package/lib/commands/version.d.ts +29 -19
  63. package/lib/commands/version.js +215 -190
  64. package/lib/config.js +3 -6
  65. package/lib/hooks/init/version-override.d.ts +2 -2
  66. package/lib/hooks/init/version-override.js +15 -13
  67. package/lib/index.d.ts +1 -1
  68. package/lib/index.js +1 -4
  69. package/lib/lib/command.d.ts +2 -0
  70. package/lib/lib/command.js +65 -58
  71. package/lib/lib/gitlab.d.ts +8 -2
  72. package/lib/lib/gitlab.js +94 -82
  73. package/lib/lib/npm.d.ts +7 -3
  74. package/lib/lib/npm.js +72 -60
  75. package/lib/lib/npmrc.d.ts +5 -0
  76. package/lib/lib/npmrc.js +20 -13
  77. package/lib/lib/nuget.d.ts +2 -0
  78. package/lib/lib/nuget.js +20 -17
  79. package/lib/security/cache.js +31 -27
  80. package/lib/security/context.d.ts +2 -1
  81. package/lib/security/context.js +106 -103
  82. package/lib/types/changelog.types.js +1 -2
  83. package/lib/types/npm.types.d.ts +5 -5
  84. package/lib/types/npm.types.js +1 -2
  85. package/oclif.manifest.json +1223 -1
  86. package/package.json +50 -46
  87. package/bin/run +0 -5
  88. package/lib/commands/prepare-content.d.ts +0 -29
  89. package/lib/commands/prepare-content.js +0 -386
@@ -1,113 +1,121 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const command_1 = require("@oclif/command");
4
- const chalk_1 = require("chalk");
5
- const cli_ux_1 = require("cli-ux");
6
- const fs = require("fs-extra");
7
- const minimatch = require("minimatch");
8
- const semver = require("semver");
9
- const command_base_1 = require("../../command.base");
10
- const command_2 = require("../../lib/command");
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
- async updateDependencies(newVersion, filter = ['**/*'], packages, force = false) {
17
- // Find all package.json files that are not in node modules
18
- for (const path of packages) {
19
- try {
20
- let data = await fs.readJSON(path.jsonPath);
21
- let updatedKeys = [];
22
- if (data.hasOwnProperty('dependencies')) {
23
- for (const [key, value] of Object.entries(data.dependencies)) {
24
- let currentVersion = semver.valid(String(value));
25
- if (filter.some(pkg => minimatch(key, pkg))) {
26
- if (currentVersion && semver.gt(currentVersion, newVersion) && !force) {
27
- this.warn(`Lower of same version for dependency ${key} updated in file ${path.jsonPath}: ${newVersion} vs. ${currentVersion} is ${semver.gt(newVersion, currentVersion)}`);
28
- }
29
- else {
30
- data.dependencies[key] = newVersion;
31
- updatedKeys.push(key);
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
- fs.writeFileSync(path.jsonPath, JSON.stringify(data, null, 4));
36
- if (updatedKeys.length > 0) {
37
- this.log(`Dependencies ${updatedKeys} updated in file ${path.jsonPath}`);
38
- }
39
- }
40
- if (data.hasOwnProperty('devDependencies')) {
41
- for (const [key, value] of Object.entries(data.devDependencies)) {
42
- let currentVersion = semver.valid(String(value));
43
- if (filter.some(pkg => minimatch(key, pkg))) {
44
- if (currentVersion && semver.gt(currentVersion, newVersion) && !force) {
45
- this.warn(`Lower of same version for devDependency ${key} updated in file ${path.jsonPath}: ${newVersion} vs. ${currentVersion} is ${semver.gt(newVersion, currentVersion)}`);
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
- fs.writeFileSync(path.jsonPath, JSON.stringify(data, null, 4));
54
- if (updatedKeys.length > 0) {
55
- this.log(`devDependencies ${updatedKeys} updated in file ${path.jsonPath}`);
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
- catch (err) {
60
- this.warn(err.message);
61
- break;
62
- }
63
- }
69
+ });
64
70
  }
65
- async run() {
66
- const { args, flags } = this.parse(NpmDependencyUpdate);
67
- let newVersion = semver.valid(args.version);
68
- let npmContext = new npm_1.default();
69
- let command = new command_2.default();
70
- // Stop if version invalid
71
- if (!newVersion) {
72
- return this.error(`${chalk_1.default.red('Version in incorrect format')}`);
73
- }
74
- const packages = await npmContext.packageList(['**/*'], [''], this);
75
- try {
76
- await this.updateDependencies(newVersion, flags.filter, packages, flags.force);
77
- cli_ux_1.default.action.start(`running 'yarn install'`, undefined, { stdout: true });
78
- await command.runCommand(['yarn', 'install']);
79
- cli_ux_1.default.action.stop(`${chalk_1.default.green('done')}`);
80
- }
81
- catch (err) {
82
- this.error(err.message);
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: command_1.flags.string({
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: command_1.flags.string({
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: command_1.flags.boolean({
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 { flags } from '@oclif/command';
2
- import CommandBase from '../../command.base';
3
- import { AzurePackageArray, NpmPackage } from '../../types/npm.types';
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: flags.IOptionFlag<string[]>;
10
- exclude: flags.IOptionFlag<string[]>;
11
- version: flags.IOptionFlag<string>;
12
- pat: flags.IOptionFlag<string | undefined>;
13
- retry: import("@oclif/parser/lib/flags").IOptionFlag<number>;
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const command_1 = require("@oclif/command");
5
- const chalk_1 = require("chalk");
6
- const child_process_1 = require("child_process");
7
- const cli_ux_1 = require("cli-ux");
8
- const command_base_1 = require("../../command.base");
9
- const npm_1 = require("../../lib/npm");
10
- class NpmPublish extends command_base_1.default {
11
- async publishPackage(pkg, cmd = ['yarn', 'publish']) {
12
- var e_1, _a, e_2, _b;
13
- let sh;
14
- let args;
15
- // cross platform compatibility
16
- if (process.platform === 'win32') {
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
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
37
- finally {
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
- for (var _e = tslib_1.__asyncValues(this.cp.stderr), _f; _f = await _e.next(), !_f.done;) {
46
- const chunk = _f.value;
47
- error += chunk;
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
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
51
- finally {
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
- if (_f && !_f.done && (_b = _e.return)) await _b.call(_e);
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
- finally { if (e_2) throw e_2.error; }
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
- const exitCode = await new Promise((resolve, _reject) => {
58
- this.cp.on('close', resolve);
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
- return { data, error };
64
- }
65
- catch (err) {
66
- throw new Error(err.message);
67
- }
71
+ });
68
72
  }
69
- async checkPackageCanPublish(pkg, allPackages, version, retries) {
70
- this.log('');
71
- cli_ux_1.default.action.start(`${pkg.name}@${pkg.version}`, undefined, { stdout: true });
72
- let matchedPackage = allPackages.value.find(azurePackage => azurePackage.name === pkg.name);
73
- if (pkg.version !== version) {
74
- this.warn(`${pkg.name}@${pkg.version} doesn't match desired publish version!`);
75
- cli_ux_1.default.action.stop(chalk_1.default.red(`version doesn't match version ${version}`));
76
- throw new Error(`Version in package.json doesn't match desired published version`);
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
- catch (err) {
85
- if (err instanceof Error && err.message.includes('subprocess error exit')) {
86
- // Check if the error message contains 'subprocess error exit'
87
- // Extract the HTTP status code from the error message
88
- const statusCodeMatch = /\d{3}/.exec(err.message);
89
- const statusCode = statusCodeMatch ? parseInt(statusCodeMatch[0], 10) : null;
90
- if (statusCode && (statusCode >= 400 && statusCode < 600)) {
91
- for (let i = 0; i < retries - 1; i++) {
92
- await this.publishPackage(pkg);
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
- cli_ux_1.default.action.stop(`${chalk_1.default.green('done')}`);
98
- return true;
99
- }
100
- let matchVersion = matchedPackage.versions.find(azurePackageVersion => azurePackageVersion.version === pkg.version);
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
- async publishPackages(packages, allPackages, version, retries) {
113
- let errorCount = 0;
114
- this.log(`publishing ${packages.length} packages:`);
115
- this.log(packages.map(pkg => pkg.name).toString());
116
- for (const pkg of packages) {
117
- try {
118
- await this.checkPackageCanPublish(pkg, allPackages, version, retries);
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
- catch (err) {
121
- this.warn(err.message);
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
- async run() {
131
- try {
132
- const { flags } = this.parse(NpmPublish);
133
- let npmContext = new npm_1.default();
134
- cli_ux_1.default.action.start('Parsing packages to check', undefined, { stdout: true });
135
- const packages = await npmContext.packageList(flags.package, flags.exclude, this);
136
- cli_ux_1.default.action.stop(`${chalk_1.default.green('done')}`);
137
- cli_ux_1.default.action.start('Getting list of published packages', undefined, { stdout: true });
138
- const allPackages = JSON.parse(await npmContext.getAllNpmPackages(flags.pat));
139
- cli_ux_1.default.action.stop(`${chalk_1.default.green('done')}`);
140
- await this.publishPackages(packages, allPackages, flags.version, flags.retry);
141
- cli_ux_1.default.action.stop('success');
142
- }
143
- catch (err) {
144
- cli_ux_1.default.action.stop('error');
145
- this.error(`${err.message}`);
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: command_1.flags.string({
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: command_1.flags.string({
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: command_1.flags.string({
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: command_1.flags.string({
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: command_1.flags.integer({
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 { flags } from '@oclif/command';
2
- import CommandBase from '../../command.base';
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
- name: string;
9
- required: boolean;
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: flags.IOptionFlag<string>;
14
- exclude: flags.IOptionFlag<string[]>;
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, filter: string | undefined, packages: string[]): Promise<void>;
24
+ updateDependencies(newVersion: string, packages: string[], filter?: string): Promise<void>;
20
25
  run(): Promise<undefined>;
21
26
  }