@adinsure-ops/ops-cli 4.0.0-rc10
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/CHANGELOGS.md +56 -0
- package/LICENSE +1 -0
- package/README.md +725 -0
- package/bin/run +5 -0
- package/bin/run.cmd +3 -0
- package/lib/command.base.d.ts +17 -0
- package/lib/command.base.jira.d.ts +11 -0
- package/lib/command.base.jira.js +37 -0
- package/lib/command.base.js +73 -0
- package/lib/commands/doctor.d.ts +54 -0
- package/lib/commands/doctor.js +311 -0
- package/lib/commands/download/client.d.ts +17 -0
- package/lib/commands/download/client.js +71 -0
- package/lib/commands/download/identity-server.d.ts +17 -0
- package/lib/commands/download/identity-server.js +71 -0
- package/lib/commands/download/platform.d.ts +18 -0
- package/lib/commands/download/platform.js +72 -0
- package/lib/commands/download/scheduler.d.ts +17 -0
- package/lib/commands/download/scheduler.js +71 -0
- package/lib/commands/download/server.d.ts +17 -0
- package/lib/commands/download/server.js +71 -0
- package/lib/commands/download/studio.d.ts +19 -0
- package/lib/commands/download/studio.js +88 -0
- package/lib/commands/gitlab/next-nightly-tag.d.ts +29 -0
- package/lib/commands/gitlab/next-nightly-tag.js +169 -0
- package/lib/commands/jira/issue.d.ts +17 -0
- package/lib/commands/jira/issue.js +31 -0
- package/lib/commands/jira/labels.d.ts +22 -0
- package/lib/commands/jira/labels.js +70 -0
- package/lib/commands/log/add.d.ts +17 -0
- package/lib/commands/log/add.js +107 -0
- package/lib/commands/log/generate.d.ts +22 -0
- package/lib/commands/log/generate.js +155 -0
- package/lib/commands/log/validate.d.ts +11 -0
- package/lib/commands/log/validate.js +58 -0
- package/lib/commands/login.d.ts +24 -0
- package/lib/commands/login.js +154 -0
- package/lib/commands/npm/check-publish.d.ts +16 -0
- package/lib/commands/npm/check-publish.js +77 -0
- package/lib/commands/npm/publish.d.ts +22 -0
- package/lib/commands/npm/publish.js +162 -0
- package/lib/commands/prepare-content.d.ts +29 -0
- package/lib/commands/prepare-content.js +386 -0
- package/lib/commands/sql.d.ts +24 -0
- package/lib/commands/sql.js +147 -0
- package/lib/commands/translate.d.ts +37 -0
- package/lib/commands/translate.js +149 -0
- package/lib/commands/version.d.ts +48 -0
- package/lib/commands/version.js +267 -0
- package/lib/config.d.ts +7 -0
- package/lib/config.js +9 -0
- package/lib/hooks/init/version-override.d.ts +2 -0
- package/lib/hooks/init/version-override.js +15 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +4 -0
- package/lib/lib/command.d.ts +9 -0
- package/lib/lib/command.js +71 -0
- package/lib/lib/npm.d.ts +15 -0
- package/lib/lib/npm.js +79 -0
- package/lib/lib/npmrc.d.ts +17 -0
- package/lib/lib/npmrc.js +44 -0
- package/lib/security/cache.d.ts +7 -0
- package/lib/security/cache.js +33 -0
- package/lib/security/context.d.ts +58 -0
- package/lib/security/context.js +228 -0
- package/lib/types/changelog.types.d.ts +6 -0
- package/lib/types/changelog.types.js +2 -0
- package/lib/types/npm.types.d.ts +34 -0
- package/lib/types/npm.types.js +2 -0
- package/oclif.manifest.json +1 -0
- package/package.json +116 -0
package/lib/lib/npm.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chalk_1 = require("chalk");
|
|
4
|
+
const fs = require("fs-extra");
|
|
5
|
+
const globby = require("globby");
|
|
6
|
+
const minimatch = require("minimatch");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
const request = require("request-promise");
|
|
9
|
+
class NpmContext {
|
|
10
|
+
/**
|
|
11
|
+
* Get all workspaces
|
|
12
|
+
*/
|
|
13
|
+
async getWorkspaces() {
|
|
14
|
+
let workspaces = [];
|
|
15
|
+
try {
|
|
16
|
+
let data = await fs.readJSON('./package.json');
|
|
17
|
+
if (!data.workspaces) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
for (const workspace of data.workspaces.packages) {
|
|
21
|
+
workspaces.push(`${workspace}/+(package.json|yarn.json)`);
|
|
22
|
+
}
|
|
23
|
+
return workspaces;
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
throw new Error(err.message);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get package names
|
|
31
|
+
*/
|
|
32
|
+
async packageList(packages = ['**/*'], excludes = [''], context) {
|
|
33
|
+
try {
|
|
34
|
+
let workspaces = await this.getWorkspaces();
|
|
35
|
+
let searchPattern = ['**/package.json', '!**/node_modules'];
|
|
36
|
+
let pkgs = [];
|
|
37
|
+
if (workspaces.length > 0) {
|
|
38
|
+
searchPattern = workspaces.concat(['!**/node_modules']);
|
|
39
|
+
}
|
|
40
|
+
const pkgPaths = await globby(searchPattern);
|
|
41
|
+
for (const pkgPath of pkgPaths) {
|
|
42
|
+
try {
|
|
43
|
+
let data = await fs.readJSON(pkgPath);
|
|
44
|
+
if (!data.version || !data.name || excludes.indexOf(data.name) >= 0 || !packages.some(pkg => minimatch(data.name, pkg))) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
// create object to simply remove duplicates
|
|
48
|
+
pkgs[data.name] = {
|
|
49
|
+
name: data.name,
|
|
50
|
+
path: path.dirname(pkgPath),
|
|
51
|
+
jsonPath: pkgPath,
|
|
52
|
+
version: data.version
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
context.warn(`Error reading package.json: ${chalk_1.default.yellow(err.message)}.`);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return Object.values(pkgs); // return array of values
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
throw new Error(`Unknown error: ${chalk_1.default.red(err)}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get package all packages
|
|
68
|
+
*/
|
|
69
|
+
async getAllNpmPackages(patToken = '') {
|
|
70
|
+
let options = {
|
|
71
|
+
uri: `https://feeds.dev.azure.com/adacta-fintech/adinsure/_apis/packaging/Feeds/feed/packages?api-version=6.0-preview.1&includeAllVersions=true&protocolType=Npm`,
|
|
72
|
+
headers: {
|
|
73
|
+
Authorization: 'Basic ' + Buffer.from(`:${patToken}`).toString('base64')
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
return request.get(options);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.default = NpmContext;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export default class NpmRc {
|
|
2
|
+
private readonly filePath;
|
|
3
|
+
private config;
|
|
4
|
+
constructor(createIfNotExists?: boolean);
|
|
5
|
+
/**
|
|
6
|
+
* Load config file
|
|
7
|
+
*/
|
|
8
|
+
load(): void;
|
|
9
|
+
/**
|
|
10
|
+
* Add registry to config file
|
|
11
|
+
*/
|
|
12
|
+
set(key: string, value: string): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Set token for Registry
|
|
15
|
+
*/
|
|
16
|
+
save(): Promise<void>;
|
|
17
|
+
}
|
package/lib/lib/npmrc.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const child_process_1 = require("child_process");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const ini = require("ini");
|
|
6
|
+
const os = require("os");
|
|
7
|
+
class NpmRc {
|
|
8
|
+
constructor(createIfNotExists = true) {
|
|
9
|
+
this.config = {};
|
|
10
|
+
try {
|
|
11
|
+
this.filePath = child_process_1.execSync('npm config get userconfig', { stdio: ['pipe', 'pipe', 'ignore'] })
|
|
12
|
+
.toString()
|
|
13
|
+
.trim();
|
|
14
|
+
}
|
|
15
|
+
catch (_a) {
|
|
16
|
+
this.filePath = os.homedir();
|
|
17
|
+
}
|
|
18
|
+
if (!fs.existsSync(this.filePath) && createIfNotExists) {
|
|
19
|
+
fs.writeFileSync(this.filePath, JSON.stringify({}));
|
|
20
|
+
}
|
|
21
|
+
if (fs.existsSync(this.filePath)) {
|
|
22
|
+
this.load();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Load config file
|
|
27
|
+
*/
|
|
28
|
+
load() {
|
|
29
|
+
this.config = ini.parse(fs.readFileSync(this.filePath, 'utf8'));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Add registry to config file
|
|
33
|
+
*/
|
|
34
|
+
async set(key, value) {
|
|
35
|
+
this.config[key] = value;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Set token for Registry
|
|
39
|
+
*/
|
|
40
|
+
async save() {
|
|
41
|
+
fs.writeFileSync(this.filePath, ini.encode(this.config));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.default = NpmRc;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ICachePlugin } from '@azure/msal-node';
|
|
2
|
+
export default class LocalCachePlugin implements ICachePlugin {
|
|
3
|
+
private readonly _accessTokenPath;
|
|
4
|
+
constructor(path: string);
|
|
5
|
+
beforeCacheAccess(cacheContext: any): Promise<void>;
|
|
6
|
+
afterCacheAccess(cacheContext: any): Promise<void>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fs = require("fs-extra");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
class LocalCachePlugin {
|
|
6
|
+
constructor(path) {
|
|
7
|
+
this._accessTokenPath = path;
|
|
8
|
+
}
|
|
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
|
+
}
|
|
20
|
+
}
|
|
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
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.default = LocalCachePlugin;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ParsedUrlQuery } from 'querystring';
|
|
3
|
+
/**
|
|
4
|
+
* Security context that keeps track of current authentication token.
|
|
5
|
+
* It's not recommended you instantiate this class on your own but rather inherit your commands from [[CommandBase]].
|
|
6
|
+
*/
|
|
7
|
+
export default class SecurityContext {
|
|
8
|
+
private readonly clientId;
|
|
9
|
+
private readonly devopsResourceId;
|
|
10
|
+
private readonly tenant;
|
|
11
|
+
private readonly authorityUrl;
|
|
12
|
+
private readonly redirectUri;
|
|
13
|
+
private readonly resource;
|
|
14
|
+
private readonly _accessTokenPath;
|
|
15
|
+
private readonly _pca;
|
|
16
|
+
private readonly _cryptoProvider;
|
|
17
|
+
private _verifier;
|
|
18
|
+
private _challenge;
|
|
19
|
+
/**
|
|
20
|
+
* Initializes [[SecurityContext]] with config directory where access token JSON will be stored.
|
|
21
|
+
* @param configDir Directory where CLI configuration is stored
|
|
22
|
+
*/
|
|
23
|
+
constructor(configDir: string);
|
|
24
|
+
/**
|
|
25
|
+
* Contacts authority server, fetches and saves the authentication token to be used in subsequent requests.
|
|
26
|
+
*
|
|
27
|
+
* @param code Authorization code used to fetch the token.
|
|
28
|
+
* @returns [[Promise<TokenResponse>]]
|
|
29
|
+
*/
|
|
30
|
+
getLoginUrl(): Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Gets the current authentication token.
|
|
33
|
+
* This function will also automatically try to refresh token if expired.
|
|
34
|
+
*
|
|
35
|
+
* @throws Error when authentication failed and/or call to login is needed
|
|
36
|
+
* @returns Promise that resolves bearer authentication token
|
|
37
|
+
*/
|
|
38
|
+
getToken(): Promise<string>;
|
|
39
|
+
/**
|
|
40
|
+
* Contacts authority server, fetches and saves the authentication token to be used in subsequent requests.
|
|
41
|
+
*
|
|
42
|
+
* @param code Authorization code used to fetch the token.
|
|
43
|
+
* @returns [[Promise<TokenResponse>]]
|
|
44
|
+
*/
|
|
45
|
+
acquireToken(query: ParsedUrlQuery): Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Acquires token using device flow.
|
|
48
|
+
*
|
|
49
|
+
* @returns [[Promise<TokenResponse>]]
|
|
50
|
+
*/
|
|
51
|
+
acquireTokenDeviceFlow(): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Get NPM token for adinsure npm repositories
|
|
54
|
+
*
|
|
55
|
+
* @returns [[Promise<string>]]
|
|
56
|
+
*/
|
|
57
|
+
getNPMToken(): Promise<string>;
|
|
58
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
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");
|
|
7
|
+
/**
|
|
8
|
+
* Security context that keeps track of current authentication token.
|
|
9
|
+
* It's not recommended you instantiate this class on your own but rather inherit your commands from [[CommandBase]].
|
|
10
|
+
*/
|
|
11
|
+
class SecurityContext {
|
|
12
|
+
/**
|
|
13
|
+
* Initializes [[SecurityContext]] with config directory where access token JSON will be stored.
|
|
14
|
+
* @param configDir Directory where CLI configuration is stored
|
|
15
|
+
*/
|
|
16
|
+
constructor(configDir) {
|
|
17
|
+
this.clientId = 'bed40d09-53d7-4af8-bf63-3288658b65fb';
|
|
18
|
+
this.devopsResourceId = '499b84ac-1321-427f-aa17-267ca6975798';
|
|
19
|
+
this.tenant = 'adfintech.onmicrosoft.com';
|
|
20
|
+
this.authorityUrl = `https://login.microsoftonline.com/${this.tenant}/`;
|
|
21
|
+
// tslint:disable-next-line: no-http-string
|
|
22
|
+
this.redirectUri = 'http://localhost:3044';
|
|
23
|
+
this.resource = 'https://ops.adinsure.com';
|
|
24
|
+
this._verifier = null;
|
|
25
|
+
this._challenge = null;
|
|
26
|
+
this._accessTokenPath = path.resolve(configDir, 'accessToken.json');
|
|
27
|
+
this._cryptoProvider = new msal_node_1.CryptoProvider();
|
|
28
|
+
this._pca = new msal_node_1.PublicClientApplication({
|
|
29
|
+
auth: {
|
|
30
|
+
clientId: this.clientId,
|
|
31
|
+
authority: this.authorityUrl
|
|
32
|
+
},
|
|
33
|
+
cache: {
|
|
34
|
+
cachePlugin: new cache_1.default(this._accessTokenPath),
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Contacts authority server, fetches and saves the authentication token to be used in subsequent requests.
|
|
40
|
+
*
|
|
41
|
+
* @param code Authorization code used to fetch the token.
|
|
42
|
+
* @returns [[Promise<TokenResponse>]]
|
|
43
|
+
*/
|
|
44
|
+
getLoginUrl() {
|
|
45
|
+
return new Promise((resolve, _reject) => {
|
|
46
|
+
// Generate PKCE Codes before starting the authorization flow
|
|
47
|
+
this._cryptoProvider.generatePkceCodes().then(({ verifier, challenge }) => {
|
|
48
|
+
this._verifier = verifier;
|
|
49
|
+
this._challenge = challenge;
|
|
50
|
+
const authCodeUrlParameters = {
|
|
51
|
+
scopes: [this.resource + '/.default'],
|
|
52
|
+
redirectUri: this.redirectUri,
|
|
53
|
+
codeChallenge: this._challenge,
|
|
54
|
+
codeChallengeMethod: 'S256'
|
|
55
|
+
};
|
|
56
|
+
// Get url to sign user in and consent to scopes needed for applicatio
|
|
57
|
+
this._pca.getAuthCodeUrl(authCodeUrlParameters).then(url => {
|
|
58
|
+
resolve(url);
|
|
59
|
+
}).catch(error => {
|
|
60
|
+
lodash_1.reject(JSON.stringify(error));
|
|
61
|
+
});
|
|
62
|
+
}).catch(reason => {
|
|
63
|
+
lodash_1.reject(reason);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Gets the current authentication token.
|
|
69
|
+
* This function will also automatically try to refresh token if expired.
|
|
70
|
+
*
|
|
71
|
+
* @throws Error when authentication failed and/or call to login is needed
|
|
72
|
+
* @returns Promise that resolves bearer authentication token
|
|
73
|
+
*/
|
|
74
|
+
async getToken() {
|
|
75
|
+
const msalTokenCache = this._pca.getTokenCache();
|
|
76
|
+
const cachedAccounts = await msalTokenCache.getAllAccounts();
|
|
77
|
+
return new Promise(async (resolve, reject) => {
|
|
78
|
+
if (cachedAccounts.length > 0) {
|
|
79
|
+
this._pca.acquireTokenSilent({
|
|
80
|
+
account: cachedAccounts[0],
|
|
81
|
+
scopes: [this.resource + '/.default', 'offline_access']
|
|
82
|
+
}).then(response => {
|
|
83
|
+
if (response) {
|
|
84
|
+
let accessToken = response.accessToken;
|
|
85
|
+
resolve(accessToken);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
reject(new Error('Error getting token, please call `ops login`.'));
|
|
89
|
+
}
|
|
90
|
+
}).catch(err => {
|
|
91
|
+
reject(new Error(err));
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
else if (process.env.AZURE_CLIENT_ID && process.env.AZURE_CLIENT_SECRET) {
|
|
95
|
+
const cca = new msal_node_1.ConfidentialClientApplication({
|
|
96
|
+
auth: {
|
|
97
|
+
clientId: process.env.AZURE_CLIENT_ID,
|
|
98
|
+
clientSecret: process.env.AZURE_CLIENT_SECRET,
|
|
99
|
+
authority: this.authorityUrl,
|
|
100
|
+
},
|
|
101
|
+
cache: {
|
|
102
|
+
cachePlugin: new cache_1.default(this._accessTokenPath),
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
const msalCcaTokenCache = cca.getTokenCache();
|
|
106
|
+
const ccaCachedAccounts = await msalCcaTokenCache.getAllAccounts();
|
|
107
|
+
if (ccaCachedAccounts.length > 0) {
|
|
108
|
+
cca.acquireTokenSilent({
|
|
109
|
+
account: ccaCachedAccounts[0],
|
|
110
|
+
scopes: [this.resource + '/.default']
|
|
111
|
+
}).then(response => {
|
|
112
|
+
if (response) {
|
|
113
|
+
let accessToken = response.accessToken;
|
|
114
|
+
resolve(accessToken);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
reject(new Error('Error getting token, please call `ops login`.'));
|
|
118
|
+
}
|
|
119
|
+
}).catch(err => {
|
|
120
|
+
reject(new Error(err));
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
cca.acquireTokenByClientCredential({
|
|
125
|
+
scopes: [this.resource + '/.default', 'offline_access']
|
|
126
|
+
}).then(response => {
|
|
127
|
+
if (response) {
|
|
128
|
+
let accessToken = response.accessToken;
|
|
129
|
+
resolve(accessToken);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
reject(new Error('Error getting token, please call `ops login`.'));
|
|
133
|
+
}
|
|
134
|
+
}).catch(err => {
|
|
135
|
+
reject(new Error(err));
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
throw new Error('You are not authenticated, please call `ops login`.');
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Contacts authority server, fetches and saves the authentication token to be used in subsequent requests.
|
|
146
|
+
*
|
|
147
|
+
* @param code Authorization code used to fetch the token.
|
|
148
|
+
* @returns [[Promise<TokenResponse>]]
|
|
149
|
+
*/
|
|
150
|
+
acquireToken(query) {
|
|
151
|
+
return new Promise((resolve, _reject) => {
|
|
152
|
+
if (this._verifier === null) {
|
|
153
|
+
throw new Error(`PKCE verifier missing.`);
|
|
154
|
+
}
|
|
155
|
+
// Add PKCE code verifier to token request object
|
|
156
|
+
const tokenRequest = {
|
|
157
|
+
code: query.code,
|
|
158
|
+
scopes: [this.resource + '/.default', 'offline_access'],
|
|
159
|
+
redirectUri: this.redirectUri,
|
|
160
|
+
codeVerifier: this._verifier,
|
|
161
|
+
clientInfo: query.client_info
|
|
162
|
+
};
|
|
163
|
+
this._pca.acquireTokenByCode(tokenRequest).then(token => {
|
|
164
|
+
var _a;
|
|
165
|
+
if (token === null) {
|
|
166
|
+
throw new Error(`PKCE getting token.`);
|
|
167
|
+
}
|
|
168
|
+
if ((_a = token.account) === null || _a === void 0 ? void 0 : _a.name) {
|
|
169
|
+
resolve(token.account.name);
|
|
170
|
+
}
|
|
171
|
+
}).catch(err => {
|
|
172
|
+
throw new Error(err);
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Acquires token using device flow.
|
|
178
|
+
*
|
|
179
|
+
* @returns [[Promise<TokenResponse>]]
|
|
180
|
+
*/
|
|
181
|
+
acquireTokenDeviceFlow() {
|
|
182
|
+
return new Promise((resolve, reject) => {
|
|
183
|
+
this._pca.acquireTokenByDeviceCode({
|
|
184
|
+
deviceCodeCallback: response => {
|
|
185
|
+
if (response.message) {
|
|
186
|
+
// tslint:disable-next-line: no-console
|
|
187
|
+
console.log(response.message);
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
scopes: [this.resource + '/.default', 'offline_access']
|
|
191
|
+
}).then(_response => {
|
|
192
|
+
resolve();
|
|
193
|
+
}).catch(err => {
|
|
194
|
+
reject(err);
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Get NPM token for adinsure npm repositories
|
|
200
|
+
*
|
|
201
|
+
* @returns [[Promise<string>]]
|
|
202
|
+
*/
|
|
203
|
+
async getNPMToken() {
|
|
204
|
+
const msalTokenCache = this._pca.getTokenCache();
|
|
205
|
+
const cachedAccounts = await msalTokenCache.getAllAccounts();
|
|
206
|
+
return new Promise((resolve, reject) => {
|
|
207
|
+
if (cachedAccounts.length > 0) {
|
|
208
|
+
this._pca.acquireTokenSilent({
|
|
209
|
+
account: cachedAccounts[0],
|
|
210
|
+
scopes: [this.devopsResourceId + '/.default', 'offline_access']
|
|
211
|
+
}).then(response => {
|
|
212
|
+
if (response) {
|
|
213
|
+
resolve(response.accessToken);
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
reject(new Error('Error getting token, please call `ops login`.'));
|
|
217
|
+
}
|
|
218
|
+
}).catch(err => {
|
|
219
|
+
reject(new Error(err));
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
reject();
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
exports.default = SecurityContext;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare type AzurePackageArray = {
|
|
2
|
+
count: number;
|
|
3
|
+
value: AzurePackage[];
|
|
4
|
+
};
|
|
5
|
+
export declare type AzurePackage = {
|
|
6
|
+
id: string;
|
|
7
|
+
normalizedName: string;
|
|
8
|
+
name: string;
|
|
9
|
+
protocolType: string;
|
|
10
|
+
url: string;
|
|
11
|
+
versions: AzurePackageVersion[];
|
|
12
|
+
};
|
|
13
|
+
export declare type AzurePackageVersion = {
|
|
14
|
+
id: string;
|
|
15
|
+
normalizedVersion: string;
|
|
16
|
+
version: string;
|
|
17
|
+
isLatest: boolean;
|
|
18
|
+
isListed: boolean;
|
|
19
|
+
storageId: string;
|
|
20
|
+
views: AzurePackageView[];
|
|
21
|
+
publishDate: string;
|
|
22
|
+
};
|
|
23
|
+
export declare type AzurePackageView = {
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
url: string;
|
|
27
|
+
type: boolean;
|
|
28
|
+
};
|
|
29
|
+
export declare type NpmPackage = {
|
|
30
|
+
name: string;
|
|
31
|
+
version: string;
|
|
32
|
+
path: string;
|
|
33
|
+
jsonPath: string;
|
|
34
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"4.0.0-rc10","commands":{"doctor":{"id":"doctor","description":"check if everyting is installed","usage":"doctor","pluginName":"@adinsure-ops/ops-cli","pluginType":"core","aliases":[],"examples":["$ ops doctor"],"flags":{"fix":{"name":"fix","type":"boolean","char":"p","description":"try to install missing packages","allowNo":false}},"args":[]},"login":{"id":"login","description":"log in to use ops services","usage":"login","pluginName":"@adinsure-ops/ops-cli","pluginType":"core","aliases":[],"examples":["$ ops login","$ ops login --npm","$ ops login --skipCi CI","$ ops login --deviceFlow"],"flags":{"servicePrincipal":{"name":"servicePrincipal","type":"boolean","description":"authenticate using service principal credentials","allowNo":false},"deviceFlow":{"name":"deviceFlow","type":"boolean","description":"authenticate using device flow","allowNo":false},"clientId":{"name":"clientId","type":"option","char":"c","description":"[DEPRECATED] (application) client id"},"secret":{"name":"secret","type":"option","char":"s","description":"[DEPRECATED] client secret"},"npm":{"name":"npm","type":"boolean","description":"register also for npm","allowNo":false},"skipCI":{"name":"skipCI","type":"option","description":"Skip login if environment variables is set"}},"args":[]},"prepare-content":{"id":"prepare-content","description":"copies files as described in .opsprepare which is at root of source directory","usage":"prepare-content -d <destination> [-s <source>]","pluginName":"@adinsure-ops/ops-cli","pluginType":"core","aliases":[],"examples":["$ ops prepare-content -d .\\my_workspace","$ ops prepare-content -d .\\my_workspace -s .\\my_repository","$ ops prepare-content -d C:\\git\\my_workspace","$ ops prepare-content -d C:\\git\\my_workspace -s C:\\git\\my_repository\\my_repository"],"flags":{"destination":{"name":"destination","type":"option","char":"d","description":"where to copy the workspace files","required":true},"source":{"name":"source","type":"option","char":"s","description":"[optional] source directory, default: current dir","required":false,"default":"."}},"args":[]},"sql":{"id":"sql","description":"creates a new database script","usage":"sql <type> <module> [flags]","pluginName":"@adinsure-ops/ops-cli","pluginType":"core","aliases":[],"examples":["$ ops sql schema ","$ ops sql data shared --layer basic"],"flags":{"version":{"name":"version","type":"option","char":"v","description":"version for which you're generating database script"},"layer":{"name":"layer","type":"option","char":"l","description":"name of the configuration layer for which you are generating database script"}},"args":[{"name":"type","description":"Type of database scripts","options":["schema","data","migration"]},{"name":"module","description":"Module of data database scripts","options":["acc","claims","core","pas","reins","shared"]}]},"translate":{"id":"translate","description":"downloads translate from AdDictionary service","usage":"translate <language> [flags]","pluginName":"@adinsure-ops/ops-cli","pluginType":"core","aliases":[],"examples":["$ ops translate \"en-US=en-US;ru-Ru=ru-RU\" -f json -m \"Client business accounting;Client business base;\"","$ ops translate \"en-US=en-US;ru-Ru=ru-RU\" -f xml -o translationDestination"],"flags":{"format":{"name":"format","type":"option","char":"f","description":"translations format [xml - server translations, json - client translations]","required":true,"options":["json","xml"]},"module":{"name":"module","type":"option","char":"m","description":"module name you want to download. Values must be semi-colon (;) separated."},"output":{"name":"output","type":"option","char":"o","description":"absolute or relative destination path to a folder where translations are extracted.","default":"."},"filename":{"name":"filename","type":"option","description":"specify filename of output (XML only)."},"respectServerFilename":{"name":"respectServerFilename","type":"boolean","description":"respect filename that is returned from AdDictionary server (XML only).","allowNo":false}},"args":[{"name":"language","description":"language id you want to download. Values must be semi-colon (;) separated.","required":true}]},"version":{"id":"version","description":"release new version","usage":"version <type> [flags]","pluginName":"@adinsure-ops/ops-cli","pluginType":"core","aliases":[],"examples":["$ ops version patch","$ ops version prerelease -i","$ ops version new -v 3.4.3"],"flags":{"independent":{"name":"independent","type":"boolean","char":"i","description":"increment npm packages independent of VERSION file","allowNo":false},"version":{"name":"version","type":"option","char":"v","description":"force version"},"script-prefix":{"name":"script-prefix","type":"option","description":"prefix for db script version creation. (default: 7.10)","default":"7.10"},"no-deps":{"name":"no-deps","type":"boolean","description":"skip dependency update","allowNo":false},"no-script":{"name":"no-script","type":"boolean","description":"skip creation of script","allowNo":false},"only-npm-packages":{"name":"only-npm-packages","type":"option","description":"regular expression for which NPM packages to include","default":".*"},"exclude-dir":{"name":"exclude-dir","type":"option","description":"exclude directories where to search for package.json"}},"args":[{"name":"type","description":"Type of release","required":true,"options":["patch","minor","major","prerelease","preminor","premajor","new"]}]},"download:client":{"id":"download:client","description":"download AdInsure Client zip from Azure storage","usage":"download:client <flags>","pluginName":"@adinsure-ops/ops-cli","pluginType":"core","aliases":[],"examples":["$ ops download:client -v 3.2.0 -o ~/Downloads"],"flags":{"version":{"name":"version","type":"option","char":"v","description":"version we want to download","required":true},"output":{"name":"output","type":"option","char":"o","description":"output directory","default":"./"}},"args":[]},"download:identity-server":{"id":"download:identity-server","description":"download AdInsure Identity Server zip from Azure storage","usage":"download:identity-server <flags>","pluginName":"@adinsure-ops/ops-cli","pluginType":"core","aliases":[],"examples":["$ ops download:identity-server -v 3.0.3 -o ~/Downloads"],"flags":{"version":{"name":"version","type":"option","char":"v","description":"version we want to download","required":true},"output":{"name":"output","type":"option","char":"o","description":"output directory","default":"./"}},"args":[]},"download:platform":{"id":"download:platform","description":"download AdInsure Platform bundle containing zip of Client, Server and IdentityServer from azure storage","usage":"download <flags>","pluginName":"@adinsure-ops/ops-cli","pluginType":"core","aliases":["download"],"examples":["$ ops download -v 6.0.0 -o ~/Downloads"],"flags":{"version":{"name":"version","type":"option","char":"v","description":"version we want to download","required":true},"output":{"name":"output","type":"option","char":"o","description":"output directory","default":"./"}},"args":[]},"download:scheduler":{"id":"download:scheduler","description":"download AdInsure Scheduler zip from azure storage","usage":"download:scheduler <flags>","pluginName":"@adinsure-ops/ops-cli","pluginType":"core","aliases":[],"examples":["$ ops download:scheduler -v 3.2.0 -o ~/Downloads"],"flags":{"version":{"name":"version","type":"option","char":"v","description":"version we want to download","required":true},"output":{"name":"output","type":"option","char":"o","description":"output directory","default":"./"}},"args":[]},"download:server":{"id":"download:server","description":"download AdInsure Server zip from Azure storage","usage":"download:server <flags>","pluginName":"@adinsure-ops/ops-cli","pluginType":"core","aliases":[],"examples":["$ ops download:server -v 3.2.0 -o ~/Downloads"],"flags":{"version":{"name":"version","type":"option","char":"v","description":"version we want to download","required":true},"output":{"name":"output","type":"option","char":"o","description":"output directory","default":"./"}},"args":[]},"download:studio":{"id":"download:studio","description":"download AdInsure Studio vsix from azure storage","usage":"download:studio <flags>","pluginName":"@adinsure-ops/ops-cli","pluginType":"core","aliases":[],"examples":["$ ops download:studio -v 15.0.0 -o ~/Downloads","$ ops download:studio -v 15.0.0 -i"],"flags":{"version":{"name":"version","type":"option","char":"v","description":"version we want to download","required":true},"output":{"name":"output","type":"option","char":"o","description":"output directory","default":"./"},"install":{"name":"install","type":"boolean","char":"i","description":"install plugin to vscode. save to temp folder and remove vsix after.","allowNo":false}},"args":[]},"gitlab:next-nightly-tag":{"id":"gitlab:next-nightly-tag","description":"creates new gitlab tag","usage":"gitlab:next-nightly-tag <version>","pluginName":"@adinsure-ops/ops-cli","pluginType":"core","aliases":[],"examples":["$ ops gitlab:next-nightly-tag 17.0.0"],"flags":{"pat":{"name":"pat","type":"option","description":"Token from user that has permissions to list and create tags","required":true},"host":{"name":"host","type":"option","description":"Server hostname","required":true,"default":"https://git.adacta-fintech.com"},"project":{"name":"project","type":"option","description":"Project ID","required":true,"default":"413"},"reference":{"name":"reference","type":"option","description":"Reference to create tag on (branch, commit, tag)","required":true},"dryRun":{"name":"dryRun","type":"boolean","description":"Only printout version and don't create it","allowNo":false}},"args":[{"name":"version","description":"Tag version"}]},"jira:issue":{"id":"jira:issue","description":"get Jira issue","usage":"jira:issue <issue>","pluginName":"@adinsure-ops/ops-cli","pluginType":"core","aliases":[],"examples":["$ ops jira:issue LJADIRD-1337"],"flags":{"username":{"name":"username","type":"option","description":"jira username","required":true},"password":{"name":"password","type":"option","description":"jira password","required":true},"hostname":{"name":"hostname","type":"option","description":"jira hostname","default":"https://jira.adacta-fintech.com"}},"args":[{"name":"issue","description":"Jira issue number","required":true}]},"jira:labels":{"id":"jira:labels","description":"list or edit labels on Jira issue","usage":"jira:labels <issue> -a [label] -r [label]","pluginName":"@adinsure-ops/ops-cli","pluginType":"core","aliases":[],"examples":["$ ops jira:labels LJADIRD-1337"],"flags":{"username":{"name":"username","type":"option","description":"jira username","required":true},"password":{"name":"password","type":"option","description":"jira password","required":true},"hostname":{"name":"hostname","type":"option","description":"jira hostname","default":"https://jira.adacta-fintech.com"},"add":{"name":"add","type":"option","char":"a","description":"add label"},"remove":{"name":"remove","type":"option","char":"r","description":"remove label"}},"args":[{"name":"issue","description":"Jira issue number","required":true}]},"log:add":{"id":"log:add","description":"creates a new changelog entry","usage":"log <issue> -t [type] -c [options]","pluginName":"@adinsure-ops/ops-cli","pluginType":"core","aliases":["log","log:add"],"examples":["$ ops log LJADIRD-1234 -t feature","$ ops log LJADIRD-5678 -t fixed","$ ops log LJADIRD-8765 -t breaking -c Platform","$ ops log LJADIRD-4321 -t improve -c Configuration"],"flags":{"type":{"name":"type","type":"option","char":"t","description":"type of changelog","options":["feature","fixed","improve","breaking"]},"component":{"name":"component","type":"option","char":"c","description":"Component for which new changelog should be generated","default":""}},"args":[{"name":"issue","description":"Jira issue number"}]},"log:generate":{"id":"log:generate","description":"generates final changelog from unreleased notes","usage":"log:gen [options]","pluginName":"@adinsure-ops/ops-cli","pluginType":"core","aliases":["log:gen"],"examples":["$ ops log:gen","$ ops log:gen -p","$ ops log:gen -c Platform","$ ops log:gen -c Platform,Configuration","$ ops log:gen -c Implementation -f CHANGELOG.Implementation.md"],"flags":{"components":{"name":"components","type":"option","char":"c","description":"components separated by comma (,) to process for final changelog","default":""},"file":{"name":"file","type":"option","char":"f","description":"file to update with new changelogs","default":"CHANGELOG.md"},"force":{"name":"force","type":"boolean","description":"update target file without prompting for confirmation","allowNo":false},"preview":{"name":"preview","type":"boolean","char":"p","description":"generates a preview markdown of current unreleased changelogs","allowNo":false},"version":{"name":"version","type":"option","char":"v","description":"version for which you're generating changelogs"},"ignore-no-changelogs":{"name":"ignore-no-changelogs","type":"boolean","description":"generate final changelog even if no unreleased changelogs exist","allowNo":false}},"args":[]},"log:validate":{"id":"log:validate","description":"validates formatting of all unreleased changelogs","usage":"log:validate [options]","pluginName":"@adinsure-ops/ops-cli","pluginType":"core","aliases":["log:validate"],"examples":["$ ops log:validate"],"flags":{},"args":[]},"npm:check-publish":{"id":"npm:check-publish","description":"check if npm packages were published","usage":"npm:check-publish [options]","pluginName":"@adinsure-ops/ops-cli","pluginType":"core","aliases":[],"examples":["$ ops npm:check-publish -v 6.0.1","$ ops npm:check-publish -p @adinsure/* -v 6.0.0","$ ops npm:check-publish -p @adinsure/* -x @adisure/demo -v 6.0.0"],"flags":{"package":{"name":"package","type":"option","char":"p","description":"package name filter you want to check"},"exclude":{"name":"exclude","type":"option","char":"x","description":"exclude packages from filter"},"version":{"name":"version","type":"option","char":"v","description":"version we want to check if published","required":true},"pat":{"name":"pat","type":"option","description":"PAT token or AZURE_DEVOPS_EXT_PAT environment variable"}},"args":[]},"npm:publish":{"id":"npm:publish","description":"Publish npm packages","usage":"npm:publish [options]","pluginName":"@adinsure-ops/ops-cli","pluginType":"core","aliases":[],"examples":["$ ops npm:publish -v 15.0.0","$ ops npm:publish -v 15.0.0","$ ops npm:publish -p @adinsure-tooling/* -v 15.0.0","$ ops npm:publish -p @adinsure-tooling/* -x @adisure-tooling/studio-services -v 6.0.0"],"flags":{"package":{"name":"package","type":"option","char":"p","description":"package name filter you want to check"},"exclude":{"name":"exclude","type":"option","char":"x","description":"exclude packages from filter"},"version":{"name":"version","type":"option","char":"v","description":"version we want to check if published","required":true},"pat":{"name":"pat","type":"option","description":"PAT token or AZURE_DEVOPS_EXT_PAT environment variable"}},"args":[]}}}
|