@adinsure-ops/ops-cli 5.2.2 → 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.
Files changed (42) hide show
  1. package/README.md +123 -9
  2. package/lib/commands/config/get.d.ts +11 -0
  3. package/lib/commands/config/get.js +40 -0
  4. package/lib/commands/config/list.d.ts +8 -0
  5. package/lib/commands/config/list.js +26 -0
  6. package/lib/commands/config/set.d.ts +12 -0
  7. package/lib/commands/config/set.js +60 -0
  8. package/lib/commands/config/unset.d.ts +11 -0
  9. package/lib/commands/config/unset.js +42 -0
  10. package/lib/commands/download/client.d.ts +11 -3
  11. package/lib/commands/download/client.js +52 -8
  12. package/lib/commands/download/identity-server.d.ts +11 -3
  13. package/lib/commands/download/identity-server.js +53 -8
  14. package/lib/commands/download/jmeter.d.ts +1 -1
  15. package/lib/commands/download/jmeter.js +13 -3
  16. package/lib/commands/download/keycloak-scim.d.ts +1 -1
  17. package/lib/commands/download/keycloak-scim.js +13 -3
  18. package/lib/commands/download/platform.d.ts +11 -3
  19. package/lib/commands/download/platform.js +53 -8
  20. package/lib/commands/download/scheduler.d.ts +11 -3
  21. package/lib/commands/download/scheduler.js +52 -8
  22. package/lib/commands/download/server.d.ts +11 -3
  23. package/lib/commands/download/server.js +53 -9
  24. package/lib/commands/download/signalr.d.ts +11 -3
  25. package/lib/commands/download/signalr.js +52 -8
  26. package/lib/commands/download/studio.d.ts +10 -2
  27. package/lib/commands/download/studio.js +49 -7
  28. package/lib/commands/login.d.ts +9 -0
  29. package/lib/commands/login.js +60 -1
  30. package/lib/commands/login.ru.d.ts +12 -0
  31. package/lib/commands/login.ru.js +42 -0
  32. package/lib/commands/npm/check-publish.js +1 -1
  33. package/lib/commands/npm/publish.d.ts +2 -0
  34. package/lib/commands/npm/publish.js +61 -58
  35. package/lib/lib/config.d.ts +10 -0
  36. package/lib/lib/config.js +33 -0
  37. package/lib/lib/yarnrc.d.ts +22 -0
  38. package/lib/lib/yarnrc.js +40 -0
  39. package/lib/security/context.d.ts +22 -0
  40. package/lib/security/context.js +113 -0
  41. package/oclif.manifest.json +275 -11
  42. package/package.json +1 -1
@@ -6,10 +6,12 @@ import fs from 'fs-extra';
6
6
  import os from 'os';
7
7
  import path from 'path';
8
8
  import CommandBase from '../../command.base.js';
9
+ import OpsConfig from '../../lib/config.js';
9
10
  class DownloadServer extends CommandBase {
10
11
  constructor() {
11
12
  super(...arguments);
12
- this.url = 'https://ops.adinsure.com/api/storage/binaries/';
13
+ this.url_azure = 'https://ops.adinsure.com/api/storage/binaries/';
14
+ this.url_gitlabru = 'https://gitlabru.adacta-fintech.ru/api/v4/projects/2/packages/generic';
13
15
  }
14
16
  /**
15
17
  * Get unique AdInsure Server zip by specified version
@@ -17,9 +19,9 @@ class DownloadServer extends CommandBase {
17
19
  * @returns {Promise<AxiosResponse<any, any>>}
18
20
  */
19
21
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
- downloadFile(version) {
22
+ downloadFileFromAzure(version) {
21
23
  return __awaiter(this, void 0, void 0, function* () {
22
- return axios.get(`${this.url}/AdInsure-server-${version}.zip`, {
24
+ return axios.get(`${this.url_azure}/AdInsure-server-${version}.zip`, {
23
25
  headers: {
24
26
  Authorization: 'Bearer ' + (yield this.security.getToken()),
25
27
  'Content-Type': 'application/octet-stream',
@@ -28,6 +30,24 @@ class DownloadServer extends CommandBase {
28
30
  });
29
31
  });
30
32
  }
33
+ /**
34
+ * Get unique AdInsure Server zip by specified version
35
+ * @param {string} version The version of AdInsure Server
36
+ * @returns {Promise<AxiosResponse<any, any>>}
37
+ */
38
+ //eslint-disable-next-line @typescript-eslint/no-explicit-any
39
+ downloadFileFromGitLabRu(version) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const packageName = 'AdInsure-server';
42
+ const fileName = `${packageName}-${version}.zip`;
43
+ return axios.get(`${this.url_gitlabru}/${packageName}/${version}/${fileName}`, {
44
+ headers: {
45
+ 'PRIVATE-TOKEN': this.security.getTokenRu(),
46
+ },
47
+ responseType: 'arraybuffer',
48
+ });
49
+ });
50
+ }
31
51
  run() {
32
52
  const _super = Object.create(null, {
33
53
  run: { get: () => super.run }
@@ -35,14 +55,34 @@ class DownloadServer extends CommandBase {
35
55
  return __awaiter(this, void 0, void 0, function* () {
36
56
  _super.run.call(this);
37
57
  const { flags } = yield this.parse(DownloadServer);
38
- const basePath = flags.output.charAt(0) === '~' ? os.homedir() + flags.output.split('~')[1] : flags.output;
58
+ let outputDir = flags.output;
59
+ if (!outputDir) {
60
+ // If the user didn't provide the output flag, try to get the default from config.
61
+ const config = new OpsConfig(this.security.getConfigPath());
62
+ const defaultFolder = config.get('download_folder');
63
+ outputDir = defaultFolder || './'; // no flag -> DEFAULT output is "./"
64
+ }
65
+ // Expand tilde if present
66
+ const basePath = outputDir.charAt(0) === '~'
67
+ ? os.homedir() + outputDir.split('~')[1]
68
+ : outputDir;
39
69
  const filename = `AdInsure-server-${flags.version}.zip`;
40
70
  const filePath = path.resolve(basePath, filename);
41
71
  ux.action.start(`Downloading AdInsure Server version ${flags.version} to ${filePath}`, undefined, { stdout: true });
42
72
  try {
43
- const file = yield this.downloadFile(flags.version);
73
+ var file;
74
+ if (!flags.source) {
75
+ const config = new OpsConfig(this.security.getConfigPath());
76
+ flags.source = config.get('endpoint') || 'azure'; // no flag -> DEFAULT source is azure
77
+ }
78
+ if (flags.source === 'azure') {
79
+ file = yield this.downloadFileFromAzure(flags.version);
80
+ }
81
+ else {
82
+ file = yield this.downloadFileFromGitLabRu(flags.version);
83
+ }
44
84
  const writeStream = fs.createWriteStream(filePath);
45
- writeStream.write(file, 'binary');
85
+ writeStream.write(file.data, 'binary');
46
86
  writeStream.on('finish', () => {
47
87
  ux.action.stop(`${chalk.green('OK')}`);
48
88
  });
@@ -52,10 +92,10 @@ class DownloadServer extends CommandBase {
52
92
  catch (error) {
53
93
  switch (error.statusCode) {
54
94
  case 404: {
55
- this.error('Does not exists.', { exit: 1 });
95
+ this.error('Does not exist.', { exit: 1 });
56
96
  }
57
97
  case 400: {
58
- this.error('Try refreshing your login credentials with "ops login".', { exit: 1 });
98
+ this.error('Try refreshing your login credentials with "ops login" or "ops login:ru".', { exit: 1 });
59
99
  }
60
100
  default: {
61
101
  this.error(error.message);
@@ -71,6 +111,11 @@ DownloadServer.examples = [
71
111
  `$ ops download:server -v 3.2.0 -o ~/Downloads`,
72
112
  ];
73
113
  DownloadServer.flags = {
114
+ source: Flags.string({
115
+ char: 's',
116
+ description: '[default: azure] artifact source, configurable with config:set endpoint <option>',
117
+ options: ['azure', 'gitlabru'],
118
+ }),
74
119
  version: Flags.string({
75
120
  char: 'v',
76
121
  description: 'version we want to download',
@@ -79,7 +124,6 @@ DownloadServer.flags = {
79
124
  output: Flags.string({
80
125
  char: 'o',
81
126
  description: 'output directory',
82
- default: './',
83
127
  }),
84
128
  };
85
129
  export default DownloadServer;
@@ -5,15 +5,23 @@ export default class DownloadSignalrServer extends CommandBase<typeof DownloadSi
5
5
  static usage: string;
6
6
  static examples: string[];
7
7
  static flags: {
8
+ source: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
8
9
  version: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
9
- output: 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 | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
10
11
  };
11
- private readonly url;
12
+ private readonly url_azure;
13
+ private readonly url_gitlabru;
12
14
  /**
13
15
  * Get unique AdInsure SignalR Server zip by specified version
14
16
  * @param {string} version The version of AdInsure SignalR Server
15
17
  * @returns {Promise<AxiosResponse<any, any>>}
16
18
  */
17
- downloadFile(version: string): Promise<AxiosResponse<any, any>>;
19
+ downloadFileFromAzure(version: string): Promise<AxiosResponse<any, any>>;
20
+ /**
21
+ * Get unique AdInsure SignalR zip by specified version
22
+ * @param {string} version The version of AdInsure SignalR
23
+ * @returns {Promise<AxiosResponse<any, any>>}
24
+ */
25
+ downloadFileFromGitLabRu(version: string): Promise<AxiosResponse<any>>;
18
26
  run(): Promise<void>;
19
27
  }
@@ -6,10 +6,12 @@ import fs from 'fs-extra';
6
6
  import os from 'os';
7
7
  import path from 'path';
8
8
  import CommandBase from '../../command.base.js';
9
+ import OpsConfig from '../../lib/config.js';
9
10
  class DownloadSignalrServer extends CommandBase {
10
11
  constructor() {
11
12
  super(...arguments);
12
- this.url = 'https://ops.adinsure.com/api/storage/binaries/';
13
+ this.url_azure = 'https://ops.adinsure.com/api/storage/binaries/';
14
+ this.url_gitlabru = 'https://gitlabru.adacta-fintech.ru/api/v4/projects/2/packages/generic';
13
15
  }
14
16
  /**
15
17
  * Get unique AdInsure SignalR Server zip by specified version
@@ -17,9 +19,9 @@ class DownloadSignalrServer extends CommandBase {
17
19
  * @returns {Promise<AxiosResponse<any, any>>}
18
20
  */
19
21
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
- downloadFile(version) {
22
+ downloadFileFromAzure(version) {
21
23
  return __awaiter(this, void 0, void 0, function* () {
22
- return axios.get(`${this.url}/AdInsure-signalr-${version}.zip`, {
24
+ return axios.get(`${this.url_azure}/AdInsure-signalr-${version}.zip`, {
23
25
  headers: {
24
26
  Authorization: 'Bearer ' + (yield this.security.getToken()),
25
27
  'Content-Type': 'application/octet-stream',
@@ -28,6 +30,24 @@ class DownloadSignalrServer extends CommandBase {
28
30
  });
29
31
  });
30
32
  }
33
+ /**
34
+ * Get unique AdInsure SignalR zip by specified version
35
+ * @param {string} version The version of AdInsure SignalR
36
+ * @returns {Promise<AxiosResponse<any, any>>}
37
+ */
38
+ //eslint-disable-next-line @typescript-eslint/no-explicit-any
39
+ downloadFileFromGitLabRu(version) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const packageName = 'AdInsure-signalr';
42
+ const fileName = `${packageName}-${version}.zip`;
43
+ return axios.get(`${this.url_gitlabru}/${packageName}/${version}/${fileName}`, {
44
+ headers: {
45
+ 'PRIVATE-TOKEN': this.security.getTokenRu(),
46
+ },
47
+ responseType: 'arraybuffer',
48
+ });
49
+ });
50
+ }
31
51
  run() {
32
52
  const _super = Object.create(null, {
33
53
  run: { get: () => super.run }
@@ -35,12 +55,32 @@ class DownloadSignalrServer extends CommandBase {
35
55
  return __awaiter(this, void 0, void 0, function* () {
36
56
  _super.run.call(this);
37
57
  const { flags } = yield this.parse(DownloadSignalrServer);
38
- const basePath = flags.output.charAt(0) === '~' ? os.homedir() + flags.output.split('~')[1] : flags.output;
58
+ let outputDir = flags.output;
59
+ if (!outputDir) {
60
+ // If the user didn't provide the output flag, try to get the default from config.
61
+ const config = new OpsConfig(this.security.getConfigPath());
62
+ const defaultFolder = config.get('download_folder');
63
+ outputDir = defaultFolder || './'; // no flag -> DEFAULT output is "./"
64
+ }
65
+ // Expand tilde if present
66
+ const basePath = outputDir.charAt(0) === '~'
67
+ ? os.homedir() + outputDir.split('~')[1]
68
+ : outputDir;
39
69
  const filename = `AdInsure-signalr-${flags.version}.zip`;
40
70
  const filePath = path.resolve(basePath, filename);
41
71
  ux.action.start(`Downloading AdInsure SignalR Server version ${flags.version} to ${filePath}`, undefined, { stdout: true });
42
72
  try {
43
- const file = yield this.downloadFile(flags.version);
73
+ var file;
74
+ if (!flags.source) {
75
+ const config = new OpsConfig(this.security.getConfigPath());
76
+ flags.source = config.get('endpoint') || 'azure'; // no flag -> DEFAULT source is azure
77
+ }
78
+ if (flags.source === 'azure') {
79
+ file = yield this.downloadFileFromAzure(flags.version);
80
+ }
81
+ else {
82
+ file = yield this.downloadFileFromGitLabRu(flags.version);
83
+ }
44
84
  const writeStream = fs.createWriteStream(filePath);
45
85
  writeStream.write(file.data, 'binary');
46
86
  writeStream.on('finish', () => {
@@ -52,10 +92,10 @@ class DownloadSignalrServer extends CommandBase {
52
92
  catch (error) {
53
93
  switch (error.statusCode) {
54
94
  case 404: {
55
- this.error('Does not exists.', { exit: 1 });
95
+ this.error('Does not exist.', { exit: 1 });
56
96
  }
57
97
  case 400: {
58
- this.error('Try refreshing your login credentials with "ops login".', { exit: 1 });
98
+ this.error('Try refreshing your login credentials with "ops login" or "ops login:ru".', { exit: 1 });
59
99
  }
60
100
  default: {
61
101
  this.error(error.message);
@@ -71,6 +111,11 @@ DownloadSignalrServer.examples = [
71
111
  `$ ops download:signalr -v 18.0.0 -o ~/Downloads`,
72
112
  ];
73
113
  DownloadSignalrServer.flags = {
114
+ source: Flags.string({
115
+ char: 's',
116
+ description: '[default: azure] artifact source, configurable with config:set endpoint <option>',
117
+ options: ['azure', 'gitlabru'],
118
+ }),
74
119
  version: Flags.string({
75
120
  char: 'v',
76
121
  description: 'version we want to download',
@@ -79,7 +124,6 @@ DownloadSignalrServer.flags = {
79
124
  output: Flags.string({
80
125
  char: 'o',
81
126
  description: 'output directory',
82
- default: './',
83
127
  }),
84
128
  };
85
129
  export default DownloadSignalrServer;
@@ -5,6 +5,7 @@ export default class DownloadStudio extends CommandBase<typeof DownloadStudio> {
5
5
  static usage: string;
6
6
  static examples: string[];
7
7
  static flags: {
8
+ source: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
8
9
  version: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
9
10
  output: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
10
11
  install: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
@@ -12,13 +13,20 @@ export default class DownloadStudio extends CommandBase<typeof DownloadStudio> {
12
13
  keep: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
13
14
  force: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
14
15
  };
15
- private readonly url;
16
+ private readonly url_azure;
17
+ private readonly url_gitlabru;
16
18
  /**
17
19
  * Get unique AdInsure Studio vsix zip by specified version
18
20
  * @param {string} version The version of AdInsure Studio vsix
19
21
  * @returns {Promise<AxiosResponse<any, any>>}
20
22
  */
21
- downloadFile(version: string): Promise<AxiosResponse<any, any>>;
23
+ downloadFileFromAzure(version: string): Promise<AxiosResponse<any, any>>;
24
+ /**
25
+ * Get unique AdInsure Studio zip by specified version
26
+ * @param {string} version The version of AdInsure Studio
27
+ * @returns {Promise<AxiosResponse<any, any>>}
28
+ */
29
+ downloadFileFromGitLabRu(version: string): Promise<AxiosResponse<any>>;
22
30
  installExtension(extensionPath: string): Promise<void>;
23
31
  findExtensionIfEnabled(studioVersion: string, enabled: boolean): Promise<boolean>;
24
32
  run(): Promise<0 | undefined>;
@@ -7,10 +7,12 @@ import os from 'os';
7
7
  import path from 'path';
8
8
  import CommandBase from '../../command.base.js';
9
9
  import ChildProcessCommand from '../../lib/command.js';
10
+ import OpsConfig from '../../lib/config.js';
10
11
  class DownloadStudio extends CommandBase {
11
12
  constructor() {
12
13
  super(...arguments);
13
- this.url = 'https://ops.adinsure.com/api/storage/extensions/';
14
+ this.url_azure = 'https://ops.adinsure.com/api/storage/extensions/';
15
+ this.url_gitlabru = 'https://gitlabru.adacta-fintech.ru/api/v4/projects/2/packages/generic';
14
16
  }
15
17
  /**
16
18
  * Get unique AdInsure Studio vsix zip by specified version
@@ -18,9 +20,9 @@ class DownloadStudio extends CommandBase {
18
20
  * @returns {Promise<AxiosResponse<any, any>>}
19
21
  */
20
22
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
- downloadFile(version) {
23
+ downloadFileFromAzure(version) {
22
24
  return __awaiter(this, void 0, void 0, function* () {
23
- return axios.get(`${this.url}/adinsure-studio-${version}.vsix`, {
25
+ return axios.get(`${this.url_azure}/adinsure-studio-${version}.vsix`, {
24
26
  headers: {
25
27
  Authorization: 'Bearer ' + (yield this.security.getToken()),
26
28
  'Content-Type': 'application/octet-stream',
@@ -29,6 +31,24 @@ class DownloadStudio extends CommandBase {
29
31
  });
30
32
  });
31
33
  }
34
+ /**
35
+ * Get unique AdInsure Studio zip by specified version
36
+ * @param {string} version The version of AdInsure Studio
37
+ * @returns {Promise<AxiosResponse<any, any>>}
38
+ */
39
+ //eslint-disable-next-line @typescript-eslint/no-explicit-any
40
+ downloadFileFromGitLabRu(version) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ const packageName = 'adinsure-studio';
43
+ const fileName = `${packageName}-${version}.vsix`;
44
+ return axios.get(`${this.url_gitlabru}/${packageName}/${version}/${fileName}`, {
45
+ headers: {
46
+ 'PRIVATE-TOKEN': this.security.getTokenRu(),
47
+ },
48
+ responseType: 'arraybuffer',
49
+ });
50
+ });
51
+ }
32
52
  installExtension(extensionPath) {
33
53
  return __awaiter(this, void 0, void 0, function* () {
34
54
  const cp = new ChildProcessCommand();
@@ -55,9 +75,16 @@ class DownloadStudio extends CommandBase {
55
75
  });
56
76
  return __awaiter(this, void 0, void 0, function* () {
57
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 || './';
58
82
  const { flags } = yield this.parse(DownloadStudio);
59
83
  // The os.homedir expands the ~ char, as the node path.resolve method does not expand it
60
- const basePath = flags.output.charAt(0) === '~' ? os.homedir() + flags.output.split('~')[1] : flags.output;
84
+ let outputDir = flags.output;
85
+ const basePath = outputDir.charAt(0) === '~'
86
+ ? os.homedir() + outputDir.split('~')[1]
87
+ : outputDir;
61
88
  if (flags.force && !(yield fs.pathExists(basePath))) {
62
89
  yield fs.mkdirp(basePath);
63
90
  }
@@ -82,7 +109,17 @@ class DownloadStudio extends CommandBase {
82
109
  return;
83
110
  }
84
111
  ux.action.start(`Downloading AdInsure Studio version ${flags.version} to ${filePath}`, undefined, { stdout: true });
85
- const file = yield this.downloadFile(flags.version);
112
+ var file;
113
+ if (!flags.source) {
114
+ const config = new OpsConfig(this.security.getConfigPath());
115
+ flags.source = config.get('endpoint') || 'azure'; // no flag -> DEFAULT source is azure
116
+ }
117
+ if (flags.source === 'azure') {
118
+ file = yield this.downloadFileFromAzure(flags.version);
119
+ }
120
+ else {
121
+ file = yield this.downloadFileFromGitLabRu(flags.version);
122
+ }
86
123
  const writeStream = fs.createWriteStream(filePath);
87
124
  writeStream.write(file.data, 'binary');
88
125
  writeStream.on('finish', () => __awaiter(this, void 0, void 0, function* () {
@@ -105,10 +142,10 @@ class DownloadStudio extends CommandBase {
105
142
  catch (error) {
106
143
  switch (error.statusCode) {
107
144
  case 404: {
108
- this.error('Does not exists.', { exit: 1 });
145
+ this.error('Does not exist.', { exit: 1 });
109
146
  }
110
147
  case 400: {
111
- this.error('Try refreshing your login credentials with "ops login".', { exit: 1 });
148
+ this.error('Try refreshing your login credentials with "ops login" or "ops login:ru".', { exit: 1 });
112
149
  }
113
150
  default: {
114
151
  this.error(error.message);
@@ -126,8 +163,13 @@ DownloadStudio.examples = [
126
163
  `$ ops download:studio -v 15.0.0 -i`,
127
164
  `$ ops download:studio -v 15.0.0 -i -s`,
128
165
  `$ ops download:studio -v 15.0.0 -i -k`,
166
+ `$ ops download:studio -v 15.0.0 --source=gitlabru`,
129
167
  ];
130
168
  DownloadStudio.flags = {
169
+ source: Flags.string({
170
+ description: '[default: azure] artifact source, configurable with config:set endpoint <option>',
171
+ options: ['azure', 'gitlabru'],
172
+ }),
131
173
  version: Flags.string({
132
174
  char: 'v',
133
175
  description: 'version we want to download',
@@ -8,6 +8,7 @@ export default class Login extends CommandBase<typeof Login> {
8
8
  npm: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
9
9
  skipCI: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
10
10
  force: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
11
+ docker: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
11
12
  };
12
13
  static responsePageContent: string;
13
14
  private readonly npmRegistries;
@@ -17,5 +18,13 @@ export default class Login extends CommandBase<typeof Login> {
17
18
  * @returns [[Promise<string>]]
18
19
  */
19
20
  setNPM(): Promise<void>;
21
+ /**
22
+ * Handle Docker login by:
23
+ * 1. Checking if Docker is available.
24
+ * 2. Ensuring user is logged in.
25
+ * 3. Generating a Docker token for adinsure.azurecr.io.
26
+ * 4. Running 'docker login' with the generated token.
27
+ */
28
+ private handleDockerLogin;
20
29
  run(): Promise<void>;
21
30
  }
@@ -6,8 +6,10 @@ import http from 'http';
6
6
  import open from 'open';
7
7
  import path from 'path';
8
8
  import url from 'url';
9
+ import { execSync } from 'child_process';
9
10
  import CommandBase from '../command.base.js';
10
11
  import NpmRc from '../lib/npmrc.js';
12
+ import YarnRc from '../lib/yarnrc.js';
11
13
  class Login extends CommandBase {
12
14
  constructor() {
13
15
  super(...arguments);
@@ -26,12 +28,15 @@ class Login extends CommandBase {
26
28
  return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
27
29
  try {
28
30
  const npmRc = new NpmRc();
31
+ const yarnRc = new YarnRc();
29
32
  const token = yield this.security.getNPMToken();
30
33
  for (const registry of this.npmRegistries) {
31
34
  const registryUrl = new url.URL(registry);
32
35
  npmRc.set(`//${registryUrl.hostname}${registryUrl.pathname}:_authToken`, token);
36
+ yarnRc.set("npmAuthToken", token);
33
37
  }
34
38
  npmRc.save();
39
+ yarnRc.save();
35
40
  this.log(`${chalk.green('NPM token generated!')}`);
36
41
  resolve();
37
42
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -42,6 +47,52 @@ class Login extends CommandBase {
42
47
  }));
43
48
  });
44
49
  }
50
+ /**
51
+ * Handle Docker login by:
52
+ * 1. Checking if Docker is available.
53
+ * 2. Ensuring user is logged in.
54
+ * 3. Generating a Docker token for adinsure.azurecr.io.
55
+ * 4. Running 'docker login' with the generated token.
56
+ */
57
+ handleDockerLogin() {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ // 1. Check if Docker command is available
60
+ try {
61
+ execSync('docker --version', { stdio: 'ignore' });
62
+ }
63
+ catch (err) {
64
+ this.error('Docker is not installed or not in PATH. Please install Docker first.', { exit: 1 });
65
+ }
66
+ // 2. Ensure the user is logged in (using your existing token retrieval logic)
67
+ try {
68
+ yield this.security.getToken();
69
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
70
+ }
71
+ catch (err) {
72
+ this.error('User is not logged in. Please run "ops login" without --docker first.', { exit: 1 });
73
+ }
74
+ // 3. generate token from `adinsure.azurecr.io`
75
+ this.log(chalk.yellow('Generating Docker authentication token for adinsure.azurecr.io...'));
76
+ let acrToken;
77
+ try {
78
+ acrToken = yield this.security.getACRToken();
79
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
80
+ }
81
+ catch (err) {
82
+ this.error('Failed to generate Docker token: ' + err.message, { exit: 1 });
83
+ }
84
+ // 4. call docker login command
85
+ this.log(chalk.yellow('Logging in to adinsure.azurecr.io via Docker...'));
86
+ try {
87
+ execSync(`docker login adinsure.azurecr.io -u 00000000-0000-0000-0000-000000000000 --password "${acrToken}" `);
88
+ this.log(chalk.green('Docker login successful!'));
89
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
90
+ }
91
+ catch (err) {
92
+ this.error('Docker login failed: ' + err.message, { exit: 1 });
93
+ }
94
+ });
95
+ }
45
96
  run() {
46
97
  const _super = Object.create(null, {
47
98
  run: { get: () => super.run }
@@ -49,6 +100,10 @@ class Login extends CommandBase {
49
100
  return __awaiter(this, void 0, void 0, function* () {
50
101
  _super.run.call(this);
51
102
  const { flags } = yield this.parse(Login);
103
+ if (flags.docker) {
104
+ yield this.handleDockerLogin();
105
+ return;
106
+ }
52
107
  if (flags.force) {
53
108
  fs.unlink(path.resolve(this.security.getTokenPath()), () => {
54
109
  this.log(`${chalk.yellow('Note: We have launched a browser for you to login.')}`);
@@ -115,7 +170,7 @@ class Login extends CommandBase {
115
170
  });
116
171
  }
117
172
  }
118
- Login.description = 'log in to use ops services';
173
+ Login.description = 'log in to use ops services with AzureAD';
119
174
  Login.usage = 'login';
120
175
  Login.examples = [
121
176
  `$ ops login`,
@@ -139,6 +194,10 @@ Login.flags = {
139
194
  description: 'Force a change of login token',
140
195
  default: false,
141
196
  }),
197
+ docker: Flags.boolean({
198
+ description: 'Authenticate with adinsure.azurecr.io for Docker',
199
+ default: false,
200
+ }),
142
201
  };
143
202
  Login.responsePageContent = `
144
203
  <!DOCTYPE html>
@@ -0,0 +1,12 @@
1
+ import CommandBase from '../command.base.js';
2
+ export default class LoginRu extends CommandBase<typeof LoginRu> {
3
+ static aliases: string[];
4
+ static description: string;
5
+ static usage: string;
6
+ static examples: string[];
7
+ static flags: {
8
+ token: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
9
+ force: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
10
+ };
11
+ run(): Promise<void>;
12
+ }
@@ -0,0 +1,42 @@
1
+ import { __awaiter } from "tslib";
2
+ import { Flags } from '@oclif/core';
3
+ import chalk from 'chalk';
4
+ import fs from 'fs';
5
+ import CommandBase from '../command.base.js';
6
+ class LoginRu extends CommandBase {
7
+ run() {
8
+ const _super = Object.create(null, {
9
+ run: { get: () => super.run }
10
+ });
11
+ return __awaiter(this, void 0, void 0, function* () {
12
+ _super.run.call(this);
13
+ const { flags } = yield this.parse(LoginRu);
14
+ // const configDir = this.config.configDir; // should work?
15
+ // Instantiate SecurityContext with a custom token file name
16
+ // const security = new SecurityContext(configDir, 'accessTokenRu.json');
17
+ const tokenFile = this.security.getTokenRuPath();
18
+ if (flags.force && fs.existsSync(tokenFile)) {
19
+ fs.unlinkSync(tokenFile);
20
+ this.log(chalk.yellow('Existing GitLabRu token removed due to force flag.'));
21
+ }
22
+ // Here we simply store the token in the same JSON format
23
+ fs.writeFileSync(tokenFile, JSON.stringify({ accessTokenRu: flags.token }), 'utf8');
24
+ this.log(chalk.green('GitLabRu token stored successfully!'));
25
+ });
26
+ }
27
+ }
28
+ LoginRu.aliases = ['login:ru'];
29
+ LoginRu.description = 'Log in to use ops services with GitLabRu token';
30
+ LoginRu.usage = 'login:ru --token <token>';
31
+ LoginRu.examples = [`$ ops login:ru --token abc123`];
32
+ LoginRu.flags = {
33
+ token: Flags.string({
34
+ description: 'The GitLabRu token to store',
35
+ required: true,
36
+ }),
37
+ force: Flags.boolean({
38
+ description: 'Force update of token',
39
+ default: false,
40
+ }),
41
+ };
42
+ export default LoginRu;
@@ -35,7 +35,7 @@ class NpmCheckPublish extends CommandBase {
35
35
  return __awaiter(this, void 0, void 0, function* () {
36
36
  _super.run.call(this);
37
37
  try {
38
- const { flags } = (yield this.parse(NpmCheckPublish)).flags;
38
+ const { flags } = (yield this.parse(NpmCheckPublish));
39
39
  const npmContext = new NpmContext();
40
40
  ux.action.start('Parsing packages to check', undefined, { stdout: true });
41
41
  const packages = yield npmContext.packageList(this, flags.package, flags.exclude);
@@ -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>;