@adinsure-ops/ops-cli 5.4.1-rc5 → 5.4.2-rc1

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.
@@ -3,6 +3,7 @@ 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
5
  private readonly childProcess;
6
+ private readonly _yarnVersionRegex;
6
7
  constructor(argv: string[], config: Config);
7
8
  getGitRoot(startDir?: string): Promise<string>;
8
9
  getYarnVersion(): Promise<string>;
@@ -11,6 +11,7 @@ export default class CommandBase extends Command {
11
11
  constructor(argv, config) {
12
12
  super(argv, config);
13
13
  this.childProcess = new ChildProcessCommand();
14
+ this._yarnVersionRegex = /^\d+\.\d+\.\d+/;
14
15
  this.security = new SecurityContext(this.config.configDir);
15
16
  }
16
17
  getGitRoot(startDir) {
@@ -32,18 +33,14 @@ export default class CommandBase extends Command {
32
33
  }
33
34
  getYarnVersion() {
34
35
  return __awaiter(this, void 0, void 0, function* () {
36
+ this.log(`Getting workspace yarn version`);
35
37
  const output = yield this.childProcess.runCommand(['yarn', '--version']);
36
- // NOTE: When corepack downloads new version of yarn the log is sent to stderr.
37
- if (output.error && !output.error.includes('Corepack is about to download')) {
38
- ux.action.stop(`${chalk.red(output.error)}`);
39
- throw new Error(`Getting yarn version command error: ${output.error}`);
38
+ const version = output.data.trim().split('\n')[0];
39
+ if (!this._yarnVersionRegex.test(version)) {
40
+ ux.action.stop(`${chalk.red('yarn version resolution failure')}`);
41
+ throw new Error(`Resolved yarn version "${version}" is not in correct format expected "${this._yarnVersionRegex.source}". Command output:\nstdout: "${output.data}",\nstderr: "${output.error}"`);
40
42
  }
41
- const version = output.data.split('\n')[0];
42
- if (version) {
43
- return version;
44
- }
45
- ux.action.stop(`${chalk.red('failed getting yarn version')}`);
46
- throw new Error(`Could not resolve yarn version, from "${output.data}"`);
43
+ return version;
47
44
  });
48
45
  }
49
46
  yarnIsBerryVersion(version) {
@@ -65,9 +65,14 @@ class DownloadStudio extends CommandBase {
65
65
  installExtension(extensionPath) {
66
66
  return __awaiter(this, void 0, void 0, function* () {
67
67
  const cp = new ChildProcessCommand();
68
- const commandResult = yield cp.runCommand([this.vscodeExecutable, '--install-extension', extensionPath, '--force']);
69
- if (commandResult.error) {
70
- this.error(`${chalk.redBright('Installing into VSCode failed!')}\n${commandResult.error}`);
68
+ // Success is decided by the exit code only (runCommand throws on non-zero exit).
69
+ // VS Code may write warnings (e.g. Node deprecation warnings) to stderr on a successful install.
70
+ try {
71
+ yield cp.runCommand([this.vscodeExecutable, '--install-extension', extensionPath, '--force']);
72
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
73
+ }
74
+ catch (error) {
75
+ this.error(`${chalk.redBright('Installing into VSCode failed!')}\n${error.message}`);
71
76
  }
72
77
  });
73
78
  }
@@ -133,26 +138,26 @@ class DownloadStudio extends CommandBase {
133
138
  else {
134
139
  file = yield this.downloadFileFromGitLabRu(flags.version);
135
140
  }
136
- const writeStream = fs.createWriteStream(filePath);
137
- writeStream.write(file.data, 'binary');
138
- writeStream.on('finish', () => __awaiter(this, void 0, void 0, function* () {
139
- ux.action.stop(`${chalk.green('OK')}`);
140
- if (flags.install) {
141
- ux.action.start(`Installing into VSCode`, undefined, { stdout: true });
142
- yield this.installExtension(filePath);
143
- ux.action.stop(`${chalk.green('Done')}`);
144
- if (!flags.keep) {
145
- ux.action.start(`Removing VSIX file`, undefined, { stdout: true });
146
- fs.removeSync(filePath);
147
- }
141
+ yield fs.writeFile(filePath, file.data);
142
+ ux.action.stop(`${chalk.green('OK')}`);
143
+ if (flags.install) {
144
+ ux.action.start(`Installing into VSCode`, undefined, { stdout: true });
145
+ yield this.installExtension(filePath);
146
+ ux.action.stop(`${chalk.green('Done')}`);
147
+ if (!flags.keep) {
148
+ ux.action.start(`Removing VSIX file`, undefined, { stdout: true });
149
+ fs.removeSync(filePath);
148
150
  ux.action.stop(`${chalk.green('Done')}`);
149
- this.log(`${chalk.yellow('Use \'CRTL + SHIFT + P\' and select reload windows to apply this studio version.')}`);
150
151
  }
151
- }));
152
- writeStream.end();
152
+ this.log(`${chalk.yellow('Use \'CRTL + SHIFT + P\' and select reload windows to apply this studio version.')}`);
153
+ }
153
154
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
154
155
  }
155
156
  catch (error) {
157
+ // Errors raised via this.error() are already formatted for oclif
158
+ if (error.oclif) {
159
+ throw error;
160
+ }
156
161
  switch (error.statusCode) {
157
162
  case 404: {
158
163
  this.error('Does not exist.', { exit: 1 });
@@ -618,6 +618,53 @@
618
618
  "unset.js"
619
619
  ]
620
620
  },
621
+ "docker:update-image-version": {
622
+ "aliases": [],
623
+ "args": {
624
+ "version": {
625
+ "description": "Version",
626
+ "name": "version",
627
+ "required": true
628
+ }
629
+ },
630
+ "description": "update docker image version docker compose file",
631
+ "examples": [
632
+ "$ ops docker:update-image-version 17.0.0 --service server client"
633
+ ],
634
+ "flags": {
635
+ "services": {
636
+ "description": "list of services to update",
637
+ "name": "services",
638
+ "required": true,
639
+ "hasDynamicHelp": false,
640
+ "multiple": true,
641
+ "type": "option"
642
+ },
643
+ "file-path": {
644
+ "description": "list of services to update",
645
+ "name": "file-path",
646
+ "default": "./docker-compose.yml",
647
+ "hasDynamicHelp": false,
648
+ "multiple": false,
649
+ "type": "option"
650
+ }
651
+ },
652
+ "hasDynamicHelp": false,
653
+ "hiddenAliases": [],
654
+ "id": "docker:update-image-version",
655
+ "pluginAlias": "@adinsure-ops/ops-cli",
656
+ "pluginName": "@adinsure-ops/ops-cli",
657
+ "pluginType": "core",
658
+ "strict": true,
659
+ "usage": "docker:update-image-version <tag>",
660
+ "isESM": true,
661
+ "relativePath": [
662
+ "lib",
663
+ "commands",
664
+ "docker",
665
+ "update-image-version.js"
666
+ ]
667
+ },
621
668
  "download:client": {
622
669
  "aliases": [
623
670
  "download:client"
@@ -1117,53 +1164,6 @@
1117
1164
  "studio.js"
1118
1165
  ]
1119
1166
  },
1120
- "docker:update-image-version": {
1121
- "aliases": [],
1122
- "args": {
1123
- "version": {
1124
- "description": "Version",
1125
- "name": "version",
1126
- "required": true
1127
- }
1128
- },
1129
- "description": "update docker image version docker compose file",
1130
- "examples": [
1131
- "$ ops docker:update-image-version 17.0.0 --service server client"
1132
- ],
1133
- "flags": {
1134
- "services": {
1135
- "description": "list of services to update",
1136
- "name": "services",
1137
- "required": true,
1138
- "hasDynamicHelp": false,
1139
- "multiple": true,
1140
- "type": "option"
1141
- },
1142
- "file-path": {
1143
- "description": "list of services to update",
1144
- "name": "file-path",
1145
- "default": "./docker-compose.yml",
1146
- "hasDynamicHelp": false,
1147
- "multiple": false,
1148
- "type": "option"
1149
- }
1150
- },
1151
- "hasDynamicHelp": false,
1152
- "hiddenAliases": [],
1153
- "id": "docker:update-image-version",
1154
- "pluginAlias": "@adinsure-ops/ops-cli",
1155
- "pluginName": "@adinsure-ops/ops-cli",
1156
- "pluginType": "core",
1157
- "strict": true,
1158
- "usage": "docker:update-image-version <tag>",
1159
- "isESM": true,
1160
- "relativePath": [
1161
- "lib",
1162
- "commands",
1163
- "docker",
1164
- "update-image-version.js"
1165
- ]
1166
- },
1167
1167
  "gitlab:get-tag-pipeline": {
1168
1168
  "aliases": [],
1169
1169
  "args": {
@@ -1859,5 +1859,5 @@
1859
1859
  ]
1860
1860
  }
1861
1861
  },
1862
- "version": "5.4.1-rc5"
1862
+ "version": "5.4.2-rc1"
1863
1863
  }
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.1-rc5",
4
+ "version": "5.4.2-rc1",
5
5
  "author": "Adacta Digital Service Department",
6
6
  "bin": {
7
7
  "ops": "./bin/run.js"