@adinsure-ops/ops-cli 4.8.3 → 5.0.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.
Files changed (89) hide show
  1. package/CHANGELOGS.md +52 -36
  2. package/LICENSE +1 -1
  3. package/README.md +32 -242
  4. package/bin/dev.cmd +3 -0
  5. package/bin/dev.js +6 -0
  6. package/bin/run.cmd +1 -1
  7. package/bin/run.js +8 -0
  8. package/lib/command.base.d.ts +9 -5
  9. package/lib/command.base.jira.d.ts +7 -8
  10. package/lib/command.base.jira.js +26 -24
  11. package/lib/command.base.js +69 -57
  12. package/lib/commands/docker/update-image-version.d.ts +6 -9
  13. package/lib/commands/docker/update-image-version.js +35 -34
  14. package/lib/commands/doctor.d.ts +15 -5
  15. package/lib/commands/doctor.js +219 -186
  16. package/lib/commands/download/client.d.ts +10 -7
  17. package/lib/commands/download/client.js +60 -52
  18. package/lib/commands/download/identity-server.d.ts +9 -7
  19. package/lib/commands/download/identity-server.js +59 -53
  20. package/lib/commands/download/jmeter.d.ts +5 -5
  21. package/lib/commands/download/jmeter.js +54 -49
  22. package/lib/commands/download/keycloak-scim.d.ts +6 -6
  23. package/lib/commands/download/keycloak-scim.js +56 -51
  24. package/lib/commands/download/platform.d.ts +9 -7
  25. package/lib/commands/download/platform.js +59 -53
  26. package/lib/commands/download/scheduler.d.ts +9 -7
  27. package/lib/commands/download/scheduler.js +59 -53
  28. package/lib/commands/download/server.d.ts +9 -7
  29. package/lib/commands/download/server.js +59 -53
  30. package/lib/commands/download/signalr.d.ts +9 -7
  31. package/lib/commands/download/signalr.js +59 -53
  32. package/lib/commands/download/studio.d.ts +12 -9
  33. package/lib/commands/download/studio.js +107 -82
  34. package/lib/commands/gitlab/get-tag-pipeline.d.ts +11 -14
  35. package/lib/commands/gitlab/get-tag-pipeline.js +95 -92
  36. package/lib/commands/gitlab/next-nightly-tag.d.ts +10 -12
  37. package/lib/commands/gitlab/next-nightly-tag.js +96 -98
  38. package/lib/commands/jira/issue.d.ts +6 -8
  39. package/lib/commands/jira/issue.js +25 -23
  40. package/lib/commands/jira/labels.d.ts +9 -12
  41. package/lib/commands/jira/labels.js +52 -51
  42. package/lib/commands/log/add.d.ts +6 -8
  43. package/lib/commands/log/add.js +92 -87
  44. package/lib/commands/log/generate.d.ts +9 -10
  45. package/lib/commands/log/generate.js +112 -107
  46. package/lib/commands/log/validate.d.ts +2 -2
  47. package/lib/commands/log/validate.js +47 -43
  48. package/lib/commands/login.d.ts +9 -10
  49. package/lib/commands/login.js +101 -97
  50. package/lib/commands/npm/check-publish.d.ts +7 -8
  51. package/lib/commands/npm/check-publish.js +59 -54
  52. package/lib/commands/npm/dependency-update.d.ts +14 -12
  53. package/lib/commands/npm/dependency-update.js +94 -86
  54. package/lib/commands/npm/publish.d.ts +8 -9
  55. package/lib/commands/npm/publish.js +154 -140
  56. package/lib/commands/nuget/dependency-update.d.ts +15 -10
  57. package/lib/commands/nuget/dependency-update.js +60 -49
  58. package/lib/commands/sql.d.ts +24 -20
  59. package/lib/commands/sql.js +245 -226
  60. package/lib/commands/translate.d.ts +15 -16
  61. package/lib/commands/translate.js +109 -104
  62. package/lib/commands/version.d.ts +29 -19
  63. package/lib/commands/version.js +215 -190
  64. package/lib/config.js +3 -6
  65. package/lib/hooks/init/version-override.d.ts +2 -2
  66. package/lib/hooks/init/version-override.js +15 -13
  67. package/lib/index.d.ts +1 -1
  68. package/lib/index.js +1 -4
  69. package/lib/lib/command.d.ts +2 -0
  70. package/lib/lib/command.js +65 -58
  71. package/lib/lib/gitlab.d.ts +8 -2
  72. package/lib/lib/gitlab.js +94 -82
  73. package/lib/lib/npm.d.ts +7 -3
  74. package/lib/lib/npm.js +72 -60
  75. package/lib/lib/npmrc.d.ts +5 -0
  76. package/lib/lib/npmrc.js +20 -13
  77. package/lib/lib/nuget.d.ts +2 -0
  78. package/lib/lib/nuget.js +20 -17
  79. package/lib/security/cache.js +31 -27
  80. package/lib/security/context.d.ts +2 -1
  81. package/lib/security/context.js +106 -103
  82. package/lib/types/changelog.types.js +1 -2
  83. package/lib/types/npm.types.d.ts +5 -5
  84. package/lib/types/npm.types.js +1 -2
  85. package/oclif.manifest.json +1223 -1
  86. package/package.json +50 -46
  87. package/bin/run +0 -5
  88. package/lib/commands/prepare-content.d.ts +0 -29
  89. package/lib/commands/prepare-content.js +0 -386
package/lib/lib/nuget.js CHANGED
@@ -1,23 +1,26 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const chalk_1 = require("chalk");
4
- const globby = require("globby");
5
- class NugetContext {
1
+ import { __awaiter } from "tslib";
2
+ import chalk from 'chalk';
3
+ import { globby } from 'globby';
4
+ export default class NugetContext {
6
5
  /**
7
6
  * Get package names
7
+ * @param exclude List of excluded packages
8
+ * @returns {Promise<string>} Array of package names
8
9
  */
9
- async projectList(exclude = []) {
10
- try {
11
- let searchPattern = ['**/*.csproj'];
12
- for (const exc of exclude) {
13
- searchPattern.push('!**/*' + exc + '*');
10
+ projectList(exclude = []) {
11
+ return __awaiter(this, void 0, void 0, function* () {
12
+ try {
13
+ const searchPattern = ['**/*.csproj'];
14
+ for (const exc of exclude) {
15
+ searchPattern.push('!**/*' + exc + '*');
16
+ }
17
+ const pkgPaths = yield globby(searchPattern);
18
+ return pkgPaths; // return array of values
19
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
20
  }
15
- const pkgPaths = await globby(searchPattern);
16
- return pkgPaths; // return array of values
17
- }
18
- catch (err) {
19
- throw new Error(`Unknown error: ${chalk_1.default.red(err)}`);
20
- }
21
+ catch (error) {
22
+ throw new Error(`Unknown error: ${chalk.red(error)}`);
23
+ }
24
+ });
21
25
  }
22
26
  }
23
- exports.default = NugetContext;
@@ -1,33 +1,37 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const fs = require("fs-extra");
4
- const path = require("path");
5
- class LocalCachePlugin {
1
+ import { __awaiter } from "tslib";
2
+ import fs from 'fs-extra';
3
+ import path from 'path';
4
+ export default class LocalCachePlugin {
6
5
  constructor(path) {
7
6
  this._accessTokenPath = path;
8
7
  }
9
- async beforeCacheAccess(cacheContext) {
10
- // Create folder if doesn't exists
11
- if (!fs.pathExistsSync(path.dirname(this._accessTokenPath))) {
12
- fs.mkdirSync(path.dirname(this._accessTokenPath), {
13
- recursive: true
14
- });
15
- }
16
- // Load file only if exists
17
- if (fs.existsSync(this._accessTokenPath)) {
18
- cacheContext.tokenCache.deserialize(await fs.readFile(this._accessTokenPath, 'utf-8'));
19
- }
8
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
+ beforeCacheAccess(cacheContext) {
10
+ return __awaiter(this, void 0, void 0, function* () {
11
+ // Create folder if doesn't exists
12
+ if (!fs.pathExistsSync(path.dirname(this._accessTokenPath))) {
13
+ fs.mkdirSync(path.dirname(this._accessTokenPath), {
14
+ recursive: true,
15
+ });
16
+ }
17
+ // Load file only if exists
18
+ if (fs.existsSync(this._accessTokenPath)) {
19
+ cacheContext.tokenCache.deserialize(yield fs.readFile(this._accessTokenPath, 'utf8'));
20
+ }
21
+ });
20
22
  }
21
- async afterCacheAccess(cacheContext) {
22
- // Create folder if doesn't exists
23
- if (!fs.pathExistsSync(path.dirname(this._accessTokenPath))) {
24
- fs.mkdirSync(path.dirname(this._accessTokenPath), {
25
- recursive: true
26
- });
27
- }
28
- if (cacheContext.cacheHasChanged) {
29
- await fs.writeFile(this._accessTokenPath, cacheContext.tokenCache.serialize());
30
- }
23
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
+ afterCacheAccess(cacheContext) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ // Create folder if doesn't exists
27
+ if (!fs.pathExistsSync(path.dirname(this._accessTokenPath))) {
28
+ fs.mkdirSync(path.dirname(this._accessTokenPath), {
29
+ recursive: true,
30
+ });
31
+ }
32
+ if (cacheContext.cacheHasChanged) {
33
+ yield fs.writeFile(this._accessTokenPath, cacheContext.tokenCache.serialize());
34
+ }
35
+ });
31
36
  }
32
37
  }
33
- exports.default = LocalCachePlugin;
@@ -23,6 +23,7 @@ export default class SecurityContext {
23
23
  constructor(configDir: string);
24
24
  /**
25
25
  * Get the accessTokenPath, as it is a private variable
26
+ * @returns {string} Returns access token path
26
27
  */
27
28
  getTokenPath(): string;
28
29
  /**
@@ -43,7 +44,7 @@ export default class SecurityContext {
43
44
  /**
44
45
  * Contacts authority server, fetches and saves the authentication token to be used in subsequent requests.
45
46
  *
46
- * @param code Authorization code used to fetch the token.
47
+ * @param query Authorization query used to fetch the token.
47
48
  * @returns [[Promise<TokenResponse>]]
48
49
  */
49
50
  acquireToken(query: ParsedUrlQuery): Promise<string>;
@@ -1,14 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const msal_node_1 = require("@azure/msal-node");
4
- const lodash_1 = require("lodash");
5
- const path = require("path");
6
- const cache_1 = require("./cache");
1
+ import { __awaiter } from "tslib";
2
+ import { ConfidentialClientApplication, CryptoProvider, PublicClientApplication } from '@azure/msal-node';
3
+ import { reject } from 'lodash-es';
4
+ import path from 'path';
5
+ import LocalCachePlugin from './cache.js';
7
6
  /**
8
7
  * Security context that keeps track of current authentication token.
9
8
  * It's not recommended you instantiate this class on your own but rather inherit your commands from [[CommandBase]].
10
9
  */
11
- class SecurityContext {
10
+ export default class SecurityContext {
12
11
  /**
13
12
  * Initializes [[SecurityContext]] with config directory where access token JSON will be stored.
14
13
  * @param configDir Directory where CLI configuration is stored
@@ -24,19 +23,20 @@ class SecurityContext {
24
23
  this._verifier = null;
25
24
  this._challenge = null;
26
25
  this._accessTokenPath = path.resolve(configDir, 'accessToken.json');
27
- this._cryptoProvider = new msal_node_1.CryptoProvider();
28
- this._pca = new msal_node_1.PublicClientApplication({
26
+ this._cryptoProvider = new CryptoProvider();
27
+ this._pca = new PublicClientApplication({
29
28
  auth: {
30
29
  clientId: this.clientId,
31
- authority: this.authorityUrl
30
+ authority: this.authorityUrl,
32
31
  },
33
32
  cache: {
34
- cachePlugin: new cache_1.default(this._accessTokenPath),
35
- }
33
+ cachePlugin: new LocalCachePlugin(this._accessTokenPath),
34
+ },
36
35
  });
37
36
  }
38
37
  /**
39
38
  * Get the accessTokenPath, as it is a private variable
39
+ * @returns {string} Returns access token path
40
40
  */
41
41
  getTokenPath() {
42
42
  return this._accessTokenPath;
@@ -57,16 +57,16 @@ class SecurityContext {
57
57
  scopes: [this.resource + '/.default'],
58
58
  redirectUri: this.redirectUri,
59
59
  codeChallenge: this._challenge,
60
- codeChallengeMethod: 'S256'
60
+ codeChallengeMethod: 'S256',
61
61
  };
62
62
  // Get url to sign user in and consent to scopes needed for applicatio
63
63
  this._pca.getAuthCodeUrl(authCodeUrlParameters).then(url => {
64
64
  resolve(url);
65
65
  }).catch(error => {
66
- lodash_1.reject(JSON.stringify(error));
66
+ reject(JSON.stringify(error));
67
67
  });
68
- }).catch(reason => {
69
- lodash_1.reject(reason);
68
+ }).catch(error => {
69
+ reject(error);
70
70
  });
71
71
  });
72
72
  }
@@ -77,80 +77,82 @@ class SecurityContext {
77
77
  * @throws Error when authentication failed and/or call to login is needed
78
78
  * @returns Promise that resolves bearer authentication token
79
79
  */
80
- async getToken() {
81
- const msalTokenCache = this._pca.getTokenCache();
82
- const cachedAccounts = await msalTokenCache.getAllAccounts();
83
- return new Promise(async (resolve, reject) => {
84
- if (cachedAccounts.length > 0) {
85
- this._pca.acquireTokenSilent({
86
- account: cachedAccounts[0],
87
- scopes: [this.resource + '/.default', 'offline_access']
88
- }).then(response => {
89
- if (response) {
90
- let accessToken = response.accessToken;
91
- resolve(accessToken);
92
- }
93
- else {
94
- reject(new Error('Error getting token, please call `ops login`.'));
95
- }
96
- }).catch(err => {
97
- reject(new Error(err));
98
- });
99
- }
100
- else if (process.env.AZURE_CLIENT_ID && process.env.AZURE_CLIENT_SECRET) {
101
- const cca = new msal_node_1.ConfidentialClientApplication({
102
- auth: {
103
- clientId: process.env.AZURE_CLIENT_ID,
104
- clientSecret: process.env.AZURE_CLIENT_SECRET,
105
- authority: this.authorityUrl,
106
- },
107
- cache: {
108
- cachePlugin: new cache_1.default(this._accessTokenPath),
109
- }
110
- });
111
- const msalCcaTokenCache = cca.getTokenCache();
112
- const ccaCachedAccounts = await msalCcaTokenCache.getAllAccounts();
113
- if (ccaCachedAccounts.length > 0) {
114
- cca.acquireTokenSilent({
115
- account: ccaCachedAccounts[0],
116
- scopes: [this.resource + '/.default']
80
+ getToken() {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ const msalTokenCache = this._pca.getTokenCache();
83
+ const cachedAccounts = yield msalTokenCache.getAllAccounts();
84
+ return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
85
+ if (cachedAccounts.length > 0) {
86
+ this._pca.acquireTokenSilent({
87
+ account: cachedAccounts[0],
88
+ scopes: [this.resource + '/.default', 'offline_access'],
117
89
  }).then(response => {
118
90
  if (response) {
119
- let accessToken = response.accessToken;
91
+ const accessToken = response.accessToken;
120
92
  resolve(accessToken);
121
93
  }
122
94
  else {
123
95
  reject(new Error('Error getting token, please call `ops login`.'));
124
96
  }
125
- }).catch(err => {
126
- reject(new Error(err));
97
+ }).catch(error => {
98
+ reject(new Error(error));
127
99
  });
128
100
  }
129
- else {
130
- cca.acquireTokenByClientCredential({
131
- scopes: [this.resource + '/.default', 'offline_access']
132
- }).then(response => {
133
- if (response) {
134
- let accessToken = response.accessToken;
135
- resolve(accessToken);
136
- }
137
- else {
138
- reject(new Error('Error getting token, please call `ops login`.'));
139
- }
140
- }).catch(err => {
141
- reject(new Error(err));
101
+ else if (process.env.AZURE_CLIENT_ID && process.env.AZURE_CLIENT_SECRET) {
102
+ const cca = new ConfidentialClientApplication({
103
+ auth: {
104
+ clientId: process.env.AZURE_CLIENT_ID,
105
+ clientSecret: process.env.AZURE_CLIENT_SECRET,
106
+ authority: this.authorityUrl,
107
+ },
108
+ cache: {
109
+ cachePlugin: new LocalCachePlugin(this._accessTokenPath),
110
+ },
142
111
  });
112
+ const msalCcaTokenCache = cca.getTokenCache();
113
+ const ccaCachedAccounts = yield msalCcaTokenCache.getAllAccounts();
114
+ if (ccaCachedAccounts.length > 0) {
115
+ cca.acquireTokenSilent({
116
+ account: ccaCachedAccounts[0],
117
+ scopes: [this.resource + '/.default'],
118
+ }).then(response => {
119
+ if (response) {
120
+ const accessToken = response.accessToken;
121
+ resolve(accessToken);
122
+ }
123
+ else {
124
+ reject(new Error('Error getting token, please call `ops login`.'));
125
+ }
126
+ }).catch(error => {
127
+ reject(new Error(error));
128
+ });
129
+ }
130
+ else {
131
+ cca.acquireTokenByClientCredential({
132
+ scopes: [this.resource + '/.default', 'offline_access'],
133
+ }).then(response => {
134
+ if (response) {
135
+ const accessToken = response.accessToken;
136
+ resolve(accessToken);
137
+ }
138
+ else {
139
+ reject(new Error('Error getting token, please call `ops login`.'));
140
+ }
141
+ }).catch(error => {
142
+ reject(new Error(error));
143
+ });
144
+ }
143
145
  }
144
- }
145
- else {
146
- throw new Error('You are not authenticated, please call `ops login`.');
147
- }
146
+ else {
147
+ throw new Error('You are not authenticated, please call `ops login`.');
148
+ }
149
+ }));
148
150
  });
149
151
  }
150
152
  /**
151
153
  * Contacts authority server, fetches and saves the authentication token to be used in subsequent requests.
152
154
  *
153
- * @param code Authorization code used to fetch the token.
155
+ * @param query Authorization query used to fetch the token.
154
156
  * @returns [[Promise<TokenResponse>]]
155
157
  */
156
158
  acquireToken(query) {
@@ -164,15 +166,15 @@ class SecurityContext {
164
166
  scopes: [this.resource + '/.default', 'offline_access'],
165
167
  redirectUri: this.redirectUri,
166
168
  codeVerifier: this._verifier,
167
- clientInfo: query.client_info
169
+ clientInfo: query.client_info,
168
170
  };
169
171
  this._pca.acquireTokenByCode(tokenRequest).then(token => {
170
172
  var _a;
171
173
  if ((_a = token.account) === null || _a === void 0 ? void 0 : _a.name) {
172
174
  resolve(token.account.name);
173
175
  }
174
- }).catch(err => {
175
- throw new Error(err);
176
+ }).catch(error => {
177
+ throw new Error(error);
176
178
  });
177
179
  });
178
180
  }
@@ -190,11 +192,11 @@ class SecurityContext {
190
192
  console.log(response.message);
191
193
  }
192
194
  },
193
- scopes: [this.resource + '/.default', 'offline_access']
195
+ scopes: [this.resource + '/.default', 'offline_access'],
194
196
  }).then(_response => {
195
197
  resolve();
196
- }).catch(err => {
197
- reject(err);
198
+ }).catch(error => {
199
+ reject(error);
198
200
  });
199
201
  });
200
202
  }
@@ -203,29 +205,30 @@ class SecurityContext {
203
205
  *
204
206
  * @returns [[Promise<string>]]
205
207
  */
206
- async getNPMToken() {
207
- const msalTokenCache = this._pca.getTokenCache();
208
- const cachedAccounts = await msalTokenCache.getAllAccounts();
209
- return new Promise((resolve, reject) => {
210
- if (cachedAccounts.length > 0) {
211
- this._pca.acquireTokenSilent({
212
- account: cachedAccounts[0],
213
- scopes: [this.devopsResourceId + '/.default', 'offline_access']
214
- }).then(response => {
215
- if (response) {
216
- resolve(response.accessToken);
217
- }
218
- else {
219
- reject(new Error('Error getting token, please call `ops login`.'));
220
- }
221
- }).catch(err => {
222
- reject(new Error(err));
223
- });
224
- }
225
- else {
226
- reject();
227
- }
208
+ getNPMToken() {
209
+ return __awaiter(this, void 0, void 0, function* () {
210
+ const msalTokenCache = this._pca.getTokenCache();
211
+ const cachedAccounts = yield msalTokenCache.getAllAccounts();
212
+ return new Promise((resolve, reject) => {
213
+ if (cachedAccounts.length > 0) {
214
+ this._pca.acquireTokenSilent({
215
+ account: cachedAccounts[0],
216
+ scopes: [this.devopsResourceId + '/.default', 'offline_access'],
217
+ }).then(response => {
218
+ if (response) {
219
+ resolve(response.accessToken);
220
+ }
221
+ else {
222
+ reject(new Error('Error getting token, please call `ops login`.'));
223
+ }
224
+ }).catch(error => {
225
+ reject(new Error(error));
226
+ });
227
+ }
228
+ else {
229
+ reject();
230
+ }
231
+ });
228
232
  });
229
233
  }
230
234
  }
231
- exports.default = SecurityContext;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,8 +1,8 @@
1
- export declare type AzurePackageArray = {
1
+ export type AzurePackageArray = {
2
2
  count: number;
3
3
  value: AzurePackage[];
4
4
  };
5
- export declare type AzurePackage = {
5
+ export type AzurePackage = {
6
6
  id: string;
7
7
  normalizedName: string;
8
8
  name: string;
@@ -10,7 +10,7 @@ export declare type AzurePackage = {
10
10
  url: string;
11
11
  versions: AzurePackageVersion[];
12
12
  };
13
- export declare type AzurePackageVersion = {
13
+ export type AzurePackageVersion = {
14
14
  id: string;
15
15
  normalizedVersion: string;
16
16
  version: string;
@@ -20,13 +20,13 @@ export declare type AzurePackageVersion = {
20
20
  views: AzurePackageView[];
21
21
  publishDate: string;
22
22
  };
23
- export declare type AzurePackageView = {
23
+ export type AzurePackageView = {
24
24
  id: string;
25
25
  name: string;
26
26
  url: string;
27
27
  type: boolean;
28
28
  };
29
- export declare type NpmPackage = {
29
+ export type NpmPackage = {
30
30
  name: string;
31
31
  version: string;
32
32
  path: string;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};