@adinsure-ops/ops-cli 5.3.0 → 5.3.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.
|
@@ -7,7 +7,7 @@ export default class DownloadStudio extends CommandBase<typeof DownloadStudio> {
|
|
|
7
7
|
static flags: {
|
|
8
8
|
source: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
9
9
|
version: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
10
|
-
output: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string
|
|
10
|
+
output: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
11
|
install: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
12
12
|
skip: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
13
13
|
keep: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
@@ -75,16 +75,13 @@ class DownloadStudio extends CommandBase {
|
|
|
75
75
|
});
|
|
76
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
77
77
|
_super.run.call(this);
|
|
78
|
+
// Set default based on config, else use './' as final fallback
|
|
79
|
+
const config = new OpsConfig(this.security.getConfigPath());
|
|
80
|
+
const defaultFolder = config.get('download_folder');
|
|
81
|
+
DownloadStudio.flags.output.default = defaultFolder || './';
|
|
78
82
|
const { flags } = yield this.parse(DownloadStudio);
|
|
79
83
|
// The os.homedir expands the ~ char, as the node path.resolve method does not expand it
|
|
80
84
|
let outputDir = flags.output;
|
|
81
|
-
if (!outputDir) {
|
|
82
|
-
// If the user didn't provide the output flag, try to get the default from config.
|
|
83
|
-
const config = new OpsConfig(this.security.getConfigPath());
|
|
84
|
-
const defaultFolder = config.get('download_folder');
|
|
85
|
-
outputDir = defaultFolder || './'; // no flag -> DEFAULT output is "./"
|
|
86
|
-
}
|
|
87
|
-
// Expand tilde if present
|
|
88
85
|
const basePath = outputDir.charAt(0) === '~'
|
|
89
86
|
? os.homedir() + outputDir.split('~')[1]
|
|
90
87
|
: outputDir;
|
|
@@ -181,6 +178,7 @@ DownloadStudio.flags = {
|
|
|
181
178
|
output: Flags.string({
|
|
182
179
|
char: 'o',
|
|
183
180
|
description: 'output directory',
|
|
181
|
+
default: './',
|
|
184
182
|
}),
|
|
185
183
|
install: Flags.boolean({
|
|
186
184
|
char: 'i',
|
|
@@ -15,7 +15,9 @@ export default class NpmPublish extends CommandBase<typeof NpmPublish> {
|
|
|
15
15
|
publishPackage(pkg: NpmPackage, cmd?: string[]): Promise<{
|
|
16
16
|
data: string;
|
|
17
17
|
error: string;
|
|
18
|
+
exitCode: unknown;
|
|
18
19
|
}>;
|
|
20
|
+
wasPublished(data: string, error: string, exitCode: unknown): Promise<boolean>;
|
|
19
21
|
checkPackageCanPublish(pkg: NpmPackage, allPackages: AzurePackageArray, version: string, retries: number): Promise<boolean>;
|
|
20
22
|
publishPackages(packages: NpmPackage[], allPackages: AzurePackageArray, version: string, retries: number): Promise<void>;
|
|
21
23
|
run(): Promise<void>;
|
|
@@ -18,56 +18,61 @@ class NpmPublish extends CommandBase {
|
|
|
18
18
|
else {
|
|
19
19
|
[sh, ...args] = cmd;
|
|
20
20
|
}
|
|
21
|
+
this.cp = spawn(sh, args, {
|
|
22
|
+
cwd: pkg.path,
|
|
23
|
+
env: Object.assign(Object.assign({}, process.env), process.stdout.isTTY ? { FORCE_COLOR: process.env.FORCE_COLOR || '1' } : {}),
|
|
24
|
+
stdio: 'pipe',
|
|
25
|
+
});
|
|
26
|
+
let data = '';
|
|
21
27
|
try {
|
|
22
|
-
this.cp =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
}
|
|
35
|
-
}
|
|
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; }
|
|
28
|
+
for (var _g = true, _h = __asyncValues(this.cp.stdout), _j; _j = yield _h.next(), _a = _j.done, !_a; _g = true) {
|
|
29
|
+
_c = _j.value;
|
|
30
|
+
_g = false;
|
|
31
|
+
const chunk = _c;
|
|
32
|
+
data += chunk;
|
|
42
33
|
}
|
|
43
|
-
|
|
34
|
+
}
|
|
35
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
36
|
+
finally {
|
|
44
37
|
try {
|
|
45
|
-
|
|
46
|
-
_f = _m.value;
|
|
47
|
-
_k = false;
|
|
48
|
-
const chunk = _f;
|
|
49
|
-
error += chunk;
|
|
50
|
-
}
|
|
38
|
+
if (!_g && !_a && (_b = _h.return)) yield _b.call(_h);
|
|
51
39
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
40
|
+
finally { if (e_1) throw e_1.error; }
|
|
41
|
+
}
|
|
42
|
+
let error = '';
|
|
43
|
+
try {
|
|
44
|
+
for (var _k = true, _l = __asyncValues(this.cp.stderr), _m; _m = yield _l.next(), _d = _m.done, !_d; _k = true) {
|
|
45
|
+
_f = _m.value;
|
|
46
|
+
_k = false;
|
|
47
|
+
const chunk = _f;
|
|
48
|
+
error += chunk;
|
|
58
49
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
50
|
+
}
|
|
51
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
52
|
+
finally {
|
|
53
|
+
try {
|
|
54
|
+
if (!_k && !_d && (_e = _l.return)) yield _e.call(_l);
|
|
64
55
|
}
|
|
65
|
-
|
|
66
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
56
|
+
finally { if (e_2) throw e_2.error; }
|
|
67
57
|
}
|
|
68
|
-
|
|
69
|
-
|
|
58
|
+
const exitCode = yield new Promise((resolve) => {
|
|
59
|
+
this.cp.on('close', resolve);
|
|
60
|
+
});
|
|
61
|
+
return { data, error, exitCode };
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
wasPublished(data, error, exitCode) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
if (exitCode) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
// Extract the HTTP status code from the error message
|
|
70
|
+
const statusCodeMatch = /\d{3}/.exec(error);
|
|
71
|
+
const statusCode = statusCodeMatch ? Number.parseInt(statusCodeMatch[0], 10) : null;
|
|
72
|
+
if (statusCode && (statusCode >= 400 && statusCode < 600)) {
|
|
73
|
+
return false;
|
|
70
74
|
}
|
|
75
|
+
return true;
|
|
71
76
|
});
|
|
72
77
|
}
|
|
73
78
|
checkPackageCanPublish(pkg, allPackages, version, retries) {
|
|
@@ -83,22 +88,17 @@ class NpmPublish extends CommandBase {
|
|
|
83
88
|
if (!matchedPackage) {
|
|
84
89
|
ux.action.stop(`${chalk.green('new package')}`);
|
|
85
90
|
ux.action.start(`publish new package ${pkg.name}@${pkg.version} from ${pkg.jsonPath}`, undefined, { stdout: true });
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
}
|
|
100
|
-
}
|
|
91
|
+
let published = false;
|
|
92
|
+
for (let i = 0; i < retries - 1; i++) {
|
|
93
|
+
const { data, error, exitCode } = yield this.publishPackage(pkg);
|
|
94
|
+
if (!this.wasPublished(data, error, exitCode)) {
|
|
95
|
+
continue;
|
|
101
96
|
}
|
|
97
|
+
published = true;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
if (!published) {
|
|
101
|
+
throw new Error(`publishing of ${pkg.name}@${pkg.version} failed`);
|
|
102
102
|
}
|
|
103
103
|
ux.action.stop(`${chalk.green('done')}`);
|
|
104
104
|
return true;
|
|
@@ -107,7 +107,10 @@ class NpmPublish extends CommandBase {
|
|
|
107
107
|
if (!matchVersion) {
|
|
108
108
|
ux.action.stop(`${chalk.yellow('version missing')}`);
|
|
109
109
|
ux.action.start(`publish new version ${pkg.name}@${pkg.version} from ${pkg.jsonPath}`, undefined, { stdout: true });
|
|
110
|
-
yield this.publishPackage(pkg);
|
|
110
|
+
const { data, error, exitCode } = yield this.publishPackage(pkg);
|
|
111
|
+
if (!this.wasPublished(data, error, exitCode)) {
|
|
112
|
+
throw new Error(`publishing of ${pkg.name}@${pkg.version} failed`);
|
|
113
|
+
}
|
|
111
114
|
ux.action.stop(`${chalk.green('done')}`);
|
|
112
115
|
return true;
|
|
113
116
|
}
|
package/oclif.manifest.json
CHANGED
|
@@ -1095,6 +1095,7 @@
|
|
|
1095
1095
|
"char": "o",
|
|
1096
1096
|
"description": "output directory",
|
|
1097
1097
|
"name": "output",
|
|
1098
|
+
"default": "./",
|
|
1098
1099
|
"hasDynamicHelp": false,
|
|
1099
1100
|
"multiple": false,
|
|
1100
1101
|
"type": "option"
|
|
@@ -1852,5 +1853,5 @@
|
|
|
1852
1853
|
]
|
|
1853
1854
|
}
|
|
1854
1855
|
},
|
|
1855
|
-
"version": "5.3.
|
|
1856
|
+
"version": "5.3.1"
|
|
1856
1857
|
}
|