@adinsure-ops/ops-cli 5.3.2 → 5.4.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/lib/command.base.d.ts +3 -0
- package/lib/command.base.js +24 -1
- package/lib/commands/doctor.d.ts +8 -1
- package/lib/commands/doctor.js +42 -2
- package/lib/commands/download/studio.d.ts +1 -0
- package/lib/commands/download/studio.js +15 -2
- package/lib/commands/npm/dependency-update.js +11 -2
- package/oclif.manifest.json +1 -1
- package/package.json +11 -3
package/lib/command.base.d.ts
CHANGED
|
@@ -2,8 +2,11 @@ import { Command, Config } from '@oclif/core';
|
|
|
2
2
|
import SecurityContext from './security/context.js';
|
|
3
3
|
export default abstract class CommandBase<T extends typeof Command> extends Command {
|
|
4
4
|
protected readonly security: SecurityContext;
|
|
5
|
+
private readonly childProcess;
|
|
5
6
|
constructor(argv: string[], config: Config);
|
|
6
7
|
getGitRoot(startDir?: string): Promise<string>;
|
|
8
|
+
getYarnVersion(): Promise<string>;
|
|
9
|
+
yarnIsBerryVersion(version: string): boolean;
|
|
7
10
|
getVersion(versionFile?: string, ...filesToCheck: string[]): Promise<string>;
|
|
8
11
|
/**
|
|
9
12
|
* Resolve path to Changelog folder from current execution directory
|
package/lib/command.base.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import { Command } from '@oclif/core';
|
|
2
|
+
import { Command, ux } from '@oclif/core';
|
|
3
3
|
import axios from 'axios';
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
import fs from 'fs-extra';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import SecurityContext from './security/context.js';
|
|
8
|
+
import ChildProcessCommand from './lib/command.js';
|
|
8
9
|
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
9
10
|
export default class CommandBase extends Command {
|
|
10
11
|
constructor(argv, config) {
|
|
11
12
|
super(argv, config);
|
|
13
|
+
this.childProcess = new ChildProcessCommand();
|
|
12
14
|
this.security = new SecurityContext(this.config.configDir);
|
|
13
15
|
}
|
|
14
16
|
getGitRoot(startDir) {
|
|
@@ -28,6 +30,27 @@ export default class CommandBase extends Command {
|
|
|
28
30
|
}
|
|
29
31
|
});
|
|
30
32
|
}
|
|
33
|
+
getYarnVersion() {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const output = yield this.childProcess.runCommand(['yarn', '--version']);
|
|
36
|
+
if (output.error) {
|
|
37
|
+
ux.action.stop(`${chalk.red(output.error)}`);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const version = output.data.split('\n')[0];
|
|
41
|
+
if (version) {
|
|
42
|
+
return version;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
ux.action.stop(`${chalk.red('failed getting yarn version')}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
throw new Error(`Could not resolve yarn version.`);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
yarnIsBerryVersion(version) {
|
|
52
|
+
return version.startsWith('v4');
|
|
53
|
+
}
|
|
31
54
|
getVersion() {
|
|
32
55
|
return __awaiter(this, arguments, void 0, function* (versionFile = 'VERSION', ...filesToCheck) {
|
|
33
56
|
filesToCheck.unshift(versionFile);
|
package/lib/commands/doctor.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export default class Doctor extends CommandBase<typeof Doctor> {
|
|
|
10
10
|
private nvm;
|
|
11
11
|
private yarn;
|
|
12
12
|
private node;
|
|
13
|
+
private corepack;
|
|
13
14
|
private missingPackages;
|
|
14
15
|
/**
|
|
15
16
|
* Check if Git is installed
|
|
@@ -43,7 +44,13 @@ export default class Doctor extends CommandBase<typeof Doctor> {
|
|
|
43
44
|
*/
|
|
44
45
|
yarnCheck(fix: boolean): Promise<void>;
|
|
45
46
|
/**
|
|
46
|
-
* Check
|
|
47
|
+
* Check corepack is installed
|
|
48
|
+
* @param {boolean} fix Try to install yarn if found missing
|
|
49
|
+
* @returns {void}
|
|
50
|
+
*/
|
|
51
|
+
corepackCheck(fix: boolean): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Install yarn via corepack.
|
|
47
54
|
* @returns {void}
|
|
48
55
|
*/
|
|
49
56
|
yarnInstall(): Promise<void>;
|
package/lib/commands/doctor.js
CHANGED
|
@@ -11,6 +11,7 @@ class Doctor extends CommandBase {
|
|
|
11
11
|
this.nvm = false;
|
|
12
12
|
this.yarn = false;
|
|
13
13
|
this.node = false;
|
|
14
|
+
this.corepack = false;
|
|
14
15
|
this.missingPackages = 0;
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
@@ -137,6 +138,7 @@ class Doctor extends CommandBase {
|
|
|
137
138
|
ux.action.stop(`${chalk.green(version)}`);
|
|
138
139
|
this.node = true;
|
|
139
140
|
// only check yarn if node is installed
|
|
141
|
+
yield this.corepackCheck(fix);
|
|
140
142
|
yield this.yarnCheck(fix);
|
|
141
143
|
}
|
|
142
144
|
else {
|
|
@@ -217,14 +219,52 @@ class Doctor extends CommandBase {
|
|
|
217
219
|
});
|
|
218
220
|
}
|
|
219
221
|
/**
|
|
220
|
-
* Check
|
|
222
|
+
* Check corepack is installed
|
|
223
|
+
* @param {boolean} fix Try to install yarn if found missing
|
|
224
|
+
* @returns {void}
|
|
225
|
+
*/
|
|
226
|
+
corepackCheck(fix) {
|
|
227
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
228
|
+
ux.action.start('Checking corepack', undefined, { stdout: true });
|
|
229
|
+
try {
|
|
230
|
+
const output = yield this.cp.runCommand(['corepack', '--version']);
|
|
231
|
+
if (output.error) {
|
|
232
|
+
ux.action.stop(`${chalk.red(output.error)}`);
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
const version = output.data.split('\n')[0];
|
|
236
|
+
if (version) {
|
|
237
|
+
this.corepack = true;
|
|
238
|
+
ux.action.stop(`${chalk.green(version)}`);
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
ux.action.stop(`${chalk.red('corepack is missing')}`);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
catch (_a) {
|
|
246
|
+
this.missingPackages++;
|
|
247
|
+
ux.action.stop(`${chalk.red('corepack is missing')}`);
|
|
248
|
+
if (fix) {
|
|
249
|
+
yield this.yarnInstall();
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Install yarn via corepack.
|
|
221
256
|
* @returns {void}
|
|
222
257
|
*/
|
|
223
258
|
yarnInstall() {
|
|
224
259
|
return __awaiter(this, void 0, void 0, function* () {
|
|
225
260
|
ux.action.start('Install yarn', undefined, { stdout: true });
|
|
226
261
|
try {
|
|
227
|
-
const output = yield this.cp.runCommand([
|
|
262
|
+
const output = yield this.cp.runCommand([
|
|
263
|
+
'npm',
|
|
264
|
+
'-g',
|
|
265
|
+
'install',
|
|
266
|
+
'corepack',
|
|
267
|
+
]);
|
|
228
268
|
if (output.error) {
|
|
229
269
|
ux.action.stop(`${chalk.red(output.error)}`);
|
|
230
270
|
}
|
|
@@ -15,6 +15,7 @@ export default class DownloadStudio extends CommandBase<typeof DownloadStudio> {
|
|
|
15
15
|
};
|
|
16
16
|
private readonly url_azure;
|
|
17
17
|
private readonly url_gitlabru;
|
|
18
|
+
private get vscodeExecutable();
|
|
18
19
|
/**
|
|
19
20
|
* Get unique AdInsure Studio vsix zip by specified version
|
|
20
21
|
* @param {string} version The version of AdInsure Studio vsix
|
|
@@ -14,6 +14,19 @@ class DownloadStudio extends CommandBase {
|
|
|
14
14
|
this.url_azure = 'https://ops.adinsure.com/api/storage/extensions/';
|
|
15
15
|
this.url_gitlabru = 'https://gitlabru.adacta-fintech.ru/api/v4/projects/2/packages/generic';
|
|
16
16
|
}
|
|
17
|
+
get vscodeExecutable() {
|
|
18
|
+
if (process.platform === 'win32') {
|
|
19
|
+
const pathEnv = process.env.PATH || process.env.Path;
|
|
20
|
+
if (pathEnv) {
|
|
21
|
+
for (const dir of pathEnv.split(path.delimiter)) {
|
|
22
|
+
if (fs.existsSync(path.join(dir, 'code.cmd'))) {
|
|
23
|
+
return 'code.cmd';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return 'code';
|
|
29
|
+
}
|
|
17
30
|
/**
|
|
18
31
|
* Get unique AdInsure Studio vsix zip by specified version
|
|
19
32
|
* @param {string} version The version of AdInsure Studio vsix
|
|
@@ -52,7 +65,7 @@ class DownloadStudio extends CommandBase {
|
|
|
52
65
|
installExtension(extensionPath) {
|
|
53
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
67
|
const cp = new ChildProcessCommand();
|
|
55
|
-
const commandResult = yield cp.runCommand([
|
|
68
|
+
const commandResult = yield cp.runCommand([this.vscodeExecutable, '--install-extension', extensionPath, '--force']);
|
|
56
69
|
if (commandResult.error) {
|
|
57
70
|
this.error(`${chalk.redBright('Installing into VSCode failed!')}\n${commandResult.error}`);
|
|
58
71
|
}
|
|
@@ -65,7 +78,7 @@ class DownloadStudio extends CommandBase {
|
|
|
65
78
|
return false;
|
|
66
79
|
}
|
|
67
80
|
const cp = new ChildProcessCommand();
|
|
68
|
-
const result = yield cp.runCommand([
|
|
81
|
+
const result = yield cp.runCommand([this.vscodeExecutable, '--list-extensions', '--show-versions']);
|
|
69
82
|
return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.includes(studioVersion);
|
|
70
83
|
});
|
|
71
84
|
}
|
|
@@ -85,8 +85,17 @@ class NpmDependencyUpdate extends CommandBase {
|
|
|
85
85
|
const packages = yield npmContext.packageList(this);
|
|
86
86
|
try {
|
|
87
87
|
yield this.updateDependencies(newVersion, packages, flags.force, flags.filter);
|
|
88
|
-
ux.action.start(`running 'yarn install'`, undefined, {
|
|
89
|
-
|
|
88
|
+
ux.action.start(`running 'yarn install'`, undefined, {
|
|
89
|
+
stdout: true,
|
|
90
|
+
});
|
|
91
|
+
const yarnVersion = yield this.getYarnVersion();
|
|
92
|
+
if (this.yarnIsBerryVersion(yarnVersion)) {
|
|
93
|
+
yield command.runCommand(['yarn', 'install', '--mode=update-lockfile']);
|
|
94
|
+
yield command.runCommand(['yarn', 'install', '--immutable']);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
yield command.runCommand(['yarn', 'install']);
|
|
98
|
+
}
|
|
90
99
|
ux.action.stop(`${chalk.green('done')}`);
|
|
91
100
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
101
|
}
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adinsure-ops/ops-cli",
|
|
3
3
|
"description": "Operations CLI for working with AdInsure",
|
|
4
|
-
"version": "5.
|
|
4
|
+
"version": "5.4.0-rc4",
|
|
5
5
|
"author": "Adacta Digital Service Department",
|
|
6
6
|
"bin": {
|
|
7
7
|
"ops": "./bin/run.js"
|
|
@@ -70,10 +70,10 @@
|
|
|
70
70
|
"typescript-eslint": "^7.9.0"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
|
-
"@types/node": "^
|
|
73
|
+
"@types/node": "^24.0.0"
|
|
74
74
|
},
|
|
75
75
|
"engines": {
|
|
76
|
-
"node": ">=
|
|
76
|
+
"node": ">=20"
|
|
77
77
|
},
|
|
78
78
|
"files": [
|
|
79
79
|
"/bin",
|
|
@@ -100,6 +100,14 @@
|
|
|
100
100
|
"@oclif/plugin-not-found",
|
|
101
101
|
"@oclif/plugin-warn-if-update-available"
|
|
102
102
|
],
|
|
103
|
+
"update": {
|
|
104
|
+
"node": {
|
|
105
|
+
"targets": [
|
|
106
|
+
"linux-x64",
|
|
107
|
+
"linux-arm64"
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
},
|
|
103
111
|
"topics": {
|
|
104
112
|
"download": {
|
|
105
113
|
"description": "download AdInsure platform bundle zip from Azure storage. Use download:[client, identity-server, scheduler, server, signalr, studio] for individual components"
|