@adinsure-ops/ops-cli 5.4.1 → 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,20 +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
- if (output.error) {
37
- ux.action.stop(`${chalk.red(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}"`);
38
42
  }
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.`);
43
+ return version;
49
44
  });
50
45
  }
51
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 });
@@ -1859,5 +1859,5 @@
1859
1859
  ]
1860
1860
  }
1861
1861
  },
1862
- "version": "5.4.1"
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",
4
+ "version": "5.4.2-rc1",
5
5
  "author": "Adacta Digital Service Department",
6
6
  "bin": {
7
7
  "ops": "./bin/run.js"