@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.
- package/CHANGELOGS.md +52 -36
- package/LICENSE +1 -1
- package/README.md +32 -242
- package/bin/dev.cmd +3 -0
- package/bin/dev.js +6 -0
- package/bin/run.cmd +1 -1
- package/bin/run.js +8 -0
- package/lib/command.base.d.ts +9 -5
- package/lib/command.base.jira.d.ts +7 -8
- package/lib/command.base.jira.js +26 -24
- package/lib/command.base.js +69 -57
- package/lib/commands/docker/update-image-version.d.ts +6 -9
- package/lib/commands/docker/update-image-version.js +35 -34
- package/lib/commands/doctor.d.ts +15 -5
- package/lib/commands/doctor.js +219 -186
- package/lib/commands/download/client.d.ts +10 -7
- package/lib/commands/download/client.js +60 -52
- package/lib/commands/download/identity-server.d.ts +9 -7
- package/lib/commands/download/identity-server.js +59 -53
- package/lib/commands/download/jmeter.d.ts +5 -5
- package/lib/commands/download/jmeter.js +54 -49
- package/lib/commands/download/keycloak-scim.d.ts +6 -6
- package/lib/commands/download/keycloak-scim.js +56 -51
- package/lib/commands/download/platform.d.ts +9 -7
- package/lib/commands/download/platform.js +59 -53
- package/lib/commands/download/scheduler.d.ts +9 -7
- package/lib/commands/download/scheduler.js +59 -53
- package/lib/commands/download/server.d.ts +9 -7
- package/lib/commands/download/server.js +59 -53
- package/lib/commands/download/signalr.d.ts +9 -7
- package/lib/commands/download/signalr.js +59 -53
- package/lib/commands/download/studio.d.ts +12 -9
- package/lib/commands/download/studio.js +107 -82
- package/lib/commands/gitlab/get-tag-pipeline.d.ts +11 -14
- package/lib/commands/gitlab/get-tag-pipeline.js +95 -92
- package/lib/commands/gitlab/next-nightly-tag.d.ts +10 -12
- package/lib/commands/gitlab/next-nightly-tag.js +96 -98
- package/lib/commands/jira/issue.d.ts +6 -8
- package/lib/commands/jira/issue.js +25 -23
- package/lib/commands/jira/labels.d.ts +9 -12
- package/lib/commands/jira/labels.js +52 -51
- package/lib/commands/log/add.d.ts +6 -8
- package/lib/commands/log/add.js +92 -87
- package/lib/commands/log/generate.d.ts +9 -10
- package/lib/commands/log/generate.js +112 -107
- package/lib/commands/log/validate.d.ts +2 -2
- package/lib/commands/log/validate.js +47 -43
- package/lib/commands/login.d.ts +9 -10
- package/lib/commands/login.js +101 -97
- package/lib/commands/npm/check-publish.d.ts +7 -8
- package/lib/commands/npm/check-publish.js +59 -54
- package/lib/commands/npm/dependency-update.d.ts +14 -12
- package/lib/commands/npm/dependency-update.js +94 -86
- package/lib/commands/npm/publish.d.ts +8 -9
- package/lib/commands/npm/publish.js +154 -140
- package/lib/commands/nuget/dependency-update.d.ts +15 -10
- package/lib/commands/nuget/dependency-update.js +60 -49
- package/lib/commands/sql.d.ts +24 -20
- package/lib/commands/sql.js +245 -226
- package/lib/commands/translate.d.ts +15 -16
- package/lib/commands/translate.js +109 -104
- package/lib/commands/version.d.ts +29 -19
- package/lib/commands/version.js +215 -190
- package/lib/config.js +3 -6
- package/lib/hooks/init/version-override.d.ts +2 -2
- package/lib/hooks/init/version-override.js +15 -13
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -4
- package/lib/lib/command.d.ts +2 -0
- package/lib/lib/command.js +65 -58
- package/lib/lib/gitlab.d.ts +8 -2
- package/lib/lib/gitlab.js +94 -82
- package/lib/lib/npm.d.ts +7 -3
- package/lib/lib/npm.js +72 -60
- package/lib/lib/npmrc.d.ts +5 -0
- package/lib/lib/npmrc.js +20 -13
- package/lib/lib/nuget.d.ts +2 -0
- package/lib/lib/nuget.js +20 -17
- package/lib/security/cache.js +31 -27
- package/lib/security/context.d.ts +2 -1
- package/lib/security/context.js +106 -103
- package/lib/types/changelog.types.js +1 -2
- package/lib/types/npm.types.d.ts +5 -5
- package/lib/types/npm.types.js +1 -2
- package/oclif.manifest.json +1223 -1
- package/package.json +50 -46
- package/bin/run +0 -5
- package/lib/commands/prepare-content.d.ts +0 -29
- package/lib/commands/prepare-content.js +0 -386
package/lib/lib/command.js
CHANGED
|
@@ -1,71 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const child_process_1 = require("child_process");
|
|
5
|
-
class ChildProcessCommand {
|
|
1
|
+
import { __asyncValues, __awaiter } from "tslib";
|
|
2
|
+
import { spawn } from 'child_process';
|
|
3
|
+
export default class ChildProcessCommand {
|
|
6
4
|
/**
|
|
7
5
|
* Only Windows supported at this point
|
|
6
|
+
* @param cmd Command to run
|
|
7
|
+
* @return {void}
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
var e_1,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
[sh, ...args] = cmd;
|
|
21
|
-
}
|
|
22
|
-
try {
|
|
23
|
-
cp = child_process_1.spawn(sh, args, {
|
|
24
|
-
// cwd:
|
|
25
|
-
// pkg.path,
|
|
26
|
-
env: Object.assign(Object.assign({}, process.env), process.stdout.isTTY ? { FORCE_COLOR: process.env.FORCE_COLOR || '1' } : {}),
|
|
27
|
-
stdio: 'pipe',
|
|
28
|
-
shell: true
|
|
29
|
-
});
|
|
30
|
-
let data = '';
|
|
31
|
-
try {
|
|
32
|
-
for (var _c = tslib_1.__asyncValues(cp.stdout), _d; _d = await _c.next(), !_d.done;) {
|
|
33
|
-
const chunk = _d.value;
|
|
34
|
-
data += chunk;
|
|
35
|
-
}
|
|
9
|
+
runCommand(cmd) {
|
|
10
|
+
var _a, e_1, _b, _c, _d, e_2, _e, _f;
|
|
11
|
+
var _g;
|
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
let sh;
|
|
14
|
+
let args;
|
|
15
|
+
let cp;
|
|
16
|
+
// cross platform compatibility
|
|
17
|
+
if (process.platform === 'win32') {
|
|
18
|
+
sh = 'cmd';
|
|
19
|
+
args = ['/c', ...cmd];
|
|
36
20
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
if (_d && !_d.done && (_a = _c.return)) await _a.call(_c);
|
|
41
|
-
}
|
|
42
|
-
finally { if (e_1) throw e_1.error; }
|
|
21
|
+
else {
|
|
22
|
+
[sh, ...args] = cmd;
|
|
43
23
|
}
|
|
44
|
-
let error = '';
|
|
45
24
|
try {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
25
|
+
cp = spawn(sh, args, {
|
|
26
|
+
// cwd:
|
|
27
|
+
// pkg.path,
|
|
28
|
+
env: Object.assign(Object.assign({}, process.env), process.stdout.isTTY ? { FORCE_COLOR: (_g = process.env.FORCE_COLOR) !== null && _g !== void 0 ? _g : '1' } : {}),
|
|
29
|
+
stdio: 'pipe',
|
|
30
|
+
shell: true,
|
|
31
|
+
});
|
|
32
|
+
let data = '';
|
|
33
|
+
try {
|
|
34
|
+
for (var _h = true, _j = __asyncValues(cp.stdout), _k; _k = yield _j.next(), _a = _k.done, !_a; _h = true) {
|
|
35
|
+
_c = _k.value;
|
|
36
|
+
_h = false;
|
|
37
|
+
const chunk = _c;
|
|
38
|
+
data += chunk;
|
|
39
|
+
}
|
|
49
40
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
41
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
42
|
+
finally {
|
|
43
|
+
try {
|
|
44
|
+
if (!_h && !_a && (_b = _j.return)) yield _b.call(_j);
|
|
45
|
+
}
|
|
46
|
+
finally { if (e_1) throw e_1.error; }
|
|
47
|
+
}
|
|
48
|
+
let error = '';
|
|
53
49
|
try {
|
|
54
|
-
|
|
50
|
+
for (var _l = true, _m = __asyncValues(cp.stderr), _o; _o = yield _m.next(), _d = _o.done, !_d; _l = true) {
|
|
51
|
+
_f = _o.value;
|
|
52
|
+
_l = false;
|
|
53
|
+
const chunk = _f;
|
|
54
|
+
error += chunk;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
58
|
+
finally {
|
|
59
|
+
try {
|
|
60
|
+
if (!_l && !_d && (_e = _m.return)) yield _e.call(_m);
|
|
61
|
+
}
|
|
62
|
+
finally { if (e_2) throw e_2.error; }
|
|
63
|
+
}
|
|
64
|
+
const exitCode = yield new Promise((resolve, _reject) => {
|
|
65
|
+
cp.on('close', resolve);
|
|
66
|
+
});
|
|
67
|
+
if (exitCode) {
|
|
68
|
+
throw new Error(`subprocess error exit ${exitCode}, ${error}`);
|
|
55
69
|
}
|
|
56
|
-
|
|
70
|
+
return { data, error };
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
72
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
});
|
|
61
|
-
if (exitCode) {
|
|
62
|
-
throw new Error(`subprocess error exit ${exitCode}, ${error}`);
|
|
73
|
+
catch (error) {
|
|
74
|
+
throw new Error(error.message);
|
|
63
75
|
}
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
catch (err) {
|
|
67
|
-
throw new Error(err.message);
|
|
68
|
-
}
|
|
76
|
+
});
|
|
69
77
|
}
|
|
70
78
|
}
|
|
71
|
-
exports.default = ChildProcessCommand;
|
package/lib/lib/gitlab.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import semver from 'semver';
|
|
2
2
|
export default class GitLab {
|
|
3
3
|
private readonly pat;
|
|
4
4
|
private readonly host;
|
|
@@ -7,11 +7,17 @@ export default class GitLab {
|
|
|
7
7
|
constructor(host: string, project: string, pat: string);
|
|
8
8
|
/**
|
|
9
9
|
* Try to figure out latest available version already created
|
|
10
|
+
* @param searchVersion Version to search for
|
|
11
|
+
* @param prefix Prefix
|
|
12
|
+
* @returns {semver.SemVer} Version object
|
|
10
13
|
*/
|
|
11
14
|
getLatestVersion(searchVersion: string, prefix?: string): Promise<semver.SemVer>;
|
|
12
15
|
/**
|
|
13
16
|
* Try to figure out latest available version already created
|
|
17
|
+
* @param tagName Tag name
|
|
18
|
+
* @param ref Reference
|
|
19
|
+
* @returns {void}
|
|
14
20
|
*/
|
|
15
|
-
createNewTag(
|
|
21
|
+
createNewTag(tagName: string, ref: string): Promise<void>;
|
|
16
22
|
getTagPipelineStatus(tag: string): Promise<string>;
|
|
17
23
|
}
|
package/lib/lib/gitlab.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class GitLab {
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import semver from 'semver';
|
|
4
|
+
export default class GitLab {
|
|
6
5
|
constructor(host, project, pat) {
|
|
7
6
|
this.apiBase = '/api/v4/projects';
|
|
8
7
|
this.pat = pat;
|
|
@@ -11,89 +10,102 @@ class GitLab {
|
|
|
11
10
|
}
|
|
12
11
|
/**
|
|
13
12
|
* Try to figure out latest available version already created
|
|
13
|
+
* @param searchVersion Version to search for
|
|
14
|
+
* @param prefix Prefix
|
|
15
|
+
* @returns {semver.SemVer} Version object
|
|
14
16
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
searchTag =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
17
|
+
getLatestVersion(searchVersion, prefix = '') {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const versions = [];
|
|
20
|
+
try {
|
|
21
|
+
let page = 1;
|
|
22
|
+
let totalPages = 1;
|
|
23
|
+
do {
|
|
24
|
+
const response = yield axios.get(`${this.host}${this.apiBase}/${this.project}/repository/tags`, {
|
|
25
|
+
headers: {
|
|
26
|
+
Authorization: `Bearer ${this.pat}`,
|
|
27
|
+
},
|
|
28
|
+
params: {
|
|
29
|
+
search: `^${prefix}v${searchVersion}`,
|
|
30
|
+
// eslint-disable-next-line camelcase
|
|
31
|
+
per_page: 100,
|
|
32
|
+
page,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
// eslint-disable-next-line unicorn/no-array-for-each, @typescript-eslint/no-explicit-any
|
|
36
|
+
response.data.forEach((tag) => {
|
|
37
|
+
const regex = new RegExp(`${prefix}(.*)`);
|
|
38
|
+
let searchTag = tag;
|
|
39
|
+
const match = tag.name.match(regex);
|
|
40
|
+
if (match[1]) {
|
|
41
|
+
searchTag = match[1];
|
|
42
|
+
}
|
|
43
|
+
const customOptions = {
|
|
44
|
+
includePrerelease: true,
|
|
45
|
+
};
|
|
46
|
+
const semanticVersion = semver.parse(searchTag, customOptions);
|
|
47
|
+
if (semanticVersion && semanticVersion.prerelease.length === 0) {
|
|
48
|
+
versions.push(semanticVersion);
|
|
49
|
+
// ignore versions that that doesn't have number for prerelease identifier (skip qa and test prereleases)
|
|
50
|
+
}
|
|
51
|
+
else if (semanticVersion && semanticVersion.prerelease.length === 2 && /^\d+$/.test(semanticVersion.prerelease[1].toString())) {
|
|
52
|
+
versions.push(semanticVersion);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
totalPages = Number.parseInt(response.headers['x-total-pages'], 10);
|
|
56
|
+
page++;
|
|
57
|
+
} while (page <= totalPages);
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
throw new Error(error);
|
|
62
|
+
}
|
|
63
|
+
return semver.rsort(versions)[0];
|
|
64
|
+
});
|
|
58
65
|
}
|
|
59
66
|
/**
|
|
60
67
|
* Try to figure out latest available version already created
|
|
68
|
+
* @param tagName Tag name
|
|
69
|
+
* @param ref Reference
|
|
70
|
+
* @returns {void}
|
|
61
71
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
createNewTag(tagName, ref) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
try {
|
|
75
|
+
yield axios.post(`${this.host}${this.apiBase}/${this.project}/repository/tags`, {
|
|
76
|
+
tagName,
|
|
77
|
+
ref,
|
|
78
|
+
}, {
|
|
79
|
+
headers: {
|
|
80
|
+
Authorization: `Bearer ${this.pat}`,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
throw new Error(error);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
77
89
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
getTagPipelineStatus(tag) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
let pipelines = null;
|
|
93
|
+
tag = tag.replaceAll(/^v/g, ''); // trim if tag starts with v because already include it in search
|
|
94
|
+
try {
|
|
95
|
+
pipelines = yield axios.get(`${this.host}${this.apiBase}/${this.project}/pipelines?ref=v${tag}`, {
|
|
96
|
+
headers: {
|
|
97
|
+
Authorization: `Bearer ${this.pat}`,
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
throw new Error(error);
|
|
104
|
+
}
|
|
105
|
+
if (pipelines.data.length > 0) {
|
|
106
|
+
return pipelines.data[0].status;
|
|
107
|
+
}
|
|
95
108
|
return 'unknown';
|
|
96
|
-
}
|
|
109
|
+
});
|
|
97
110
|
}
|
|
98
111
|
}
|
|
99
|
-
exports.default = GitLab;
|
package/lib/lib/npm.d.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
import { NpmPackage } from '../types/npm.types.js';
|
|
2
3
|
export default class NpmContext {
|
|
3
4
|
/**
|
|
4
5
|
* Get all workspaces
|
|
6
|
+
* @returns {Promise<string[]>} String array of all workspaces
|
|
5
7
|
*/
|
|
6
8
|
getWorkspaces(): Promise<string[]>;
|
|
7
9
|
/**
|
|
8
10
|
* Get package names
|
|
9
11
|
*/
|
|
10
|
-
packageList(
|
|
12
|
+
packageList(context: any, packages?: string[], excludes?: string[]): Promise<NpmPackage[]>;
|
|
11
13
|
/**
|
|
12
14
|
* Get package all packages
|
|
15
|
+
* @param patToken Auth token
|
|
16
|
+
* @returns {Promise<string>} Returns all the NPM packages
|
|
13
17
|
*/
|
|
14
|
-
getAllNpmPackages(patToken?: string): Promise<
|
|
18
|
+
getAllNpmPackages(patToken?: string): Promise<AxiosResponse<any, any>>;
|
|
15
19
|
}
|
package/lib/lib/npm.js
CHANGED
|
@@ -1,79 +1,91 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class NpmContext {
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
import { globby } from 'globby';
|
|
6
|
+
import { minimatch } from 'minimatch';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
export default class NpmContext {
|
|
10
9
|
/**
|
|
11
10
|
* Get all workspaces
|
|
11
|
+
* @returns {Promise<string[]>} String array of all workspaces
|
|
12
12
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
getWorkspaces() {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
const workspaces = [];
|
|
16
|
+
try {
|
|
17
|
+
const data = yield fs.readJSON('./package.json');
|
|
18
|
+
if (!data.workspaces) {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
for (const workspace of data.workspaces.packages) {
|
|
22
|
+
workspaces.push(`${workspace}/+(package.json|yarn.json)`);
|
|
23
|
+
}
|
|
24
|
+
return workspaces;
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
26
|
}
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
catch (error) {
|
|
28
|
+
throw new Error(error.message);
|
|
22
29
|
}
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
catch (err) {
|
|
26
|
-
throw new Error(err.message);
|
|
27
|
-
}
|
|
30
|
+
});
|
|
28
31
|
}
|
|
29
32
|
/**
|
|
30
33
|
* Get package names
|
|
31
34
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
|
+
packageList(context, packages = ['**/*'], excludes = ['']) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
try {
|
|
39
|
+
const workspaces = yield this.getWorkspaces();
|
|
40
|
+
let searchPattern = ['package.json', '**/package.json', '!**/node_modules'];
|
|
41
|
+
const pkgs = [];
|
|
42
|
+
if (workspaces.length > 0) {
|
|
43
|
+
searchPattern = [...workspaces, 'package.json', '!**/node_modules'];
|
|
44
|
+
}
|
|
45
|
+
const pkgPaths = yield globby(searchPattern);
|
|
46
|
+
for (const pkgPath of pkgPaths) {
|
|
47
|
+
try {
|
|
48
|
+
const data = yield fs.readJSON(pkgPath);
|
|
49
|
+
if (!data.version || !data.name || excludes.includes(data.name) || !packages.some(pkg => minimatch(data.name, pkg))) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
// create object to simply remove duplicates
|
|
53
|
+
pkgs[data.name] = {
|
|
54
|
+
name: data.name,
|
|
55
|
+
path: path.dirname(pkgPath),
|
|
56
|
+
jsonPath: pkgPath,
|
|
57
|
+
version: data.version,
|
|
58
|
+
};
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
context.warn(`Error reading package.json: ${chalk.yellow(error.message)}.`);
|
|
45
63
|
continue;
|
|
46
64
|
}
|
|
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
65
|
}
|
|
66
|
+
return Object.values(pkgs); // return array of values
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
59
68
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
throw new Error(`Unknown error: ${chalk.red(error)}`);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
65
73
|
}
|
|
66
74
|
/**
|
|
67
75
|
* Get package all packages
|
|
76
|
+
* @param patToken Auth token
|
|
77
|
+
* @returns {Promise<string>} Returns all the NPM packages
|
|
68
78
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
80
|
+
getAllNpmPackages(patToken = '') {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
const uri = `https://feeds.dev.azure.com/adacta-fintech/adinsure/_apis/packaging/Feeds/feed/packages?api-version=6.0-preview.1&includeAllVersions=true&protocolType=Npm`;
|
|
83
|
+
return axios.get(uri, {
|
|
84
|
+
headers: {
|
|
85
|
+
Authorization: 'Basic ' + Buffer.from(`:${patToken}`).toString('base64'),
|
|
86
|
+
'Content-Type': 'application/octet-strem',
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
});
|
|
77
90
|
}
|
|
78
91
|
}
|
|
79
|
-
exports.default = NpmContext;
|
package/lib/lib/npmrc.d.ts
CHANGED
|
@@ -4,14 +4,19 @@ export default class NpmRc {
|
|
|
4
4
|
constructor(createIfNotExists?: boolean);
|
|
5
5
|
/**
|
|
6
6
|
* Load config file
|
|
7
|
+
* @returns {void}
|
|
7
8
|
*/
|
|
8
9
|
load(): void;
|
|
9
10
|
/**
|
|
10
11
|
* Add registry to config file
|
|
12
|
+
* @param key Config key
|
|
13
|
+
* @param value Config value
|
|
14
|
+
* @returns {void}
|
|
11
15
|
*/
|
|
12
16
|
set(key: string, value: string): Promise<void>;
|
|
13
17
|
/**
|
|
14
18
|
* Set token for Registry
|
|
19
|
+
* @returns {void}
|
|
15
20
|
*/
|
|
16
21
|
save(): Promise<void>;
|
|
17
22
|
}
|
package/lib/lib/npmrc.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class NpmRc {
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { execSync } from 'child_process';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import ini from 'ini';
|
|
5
|
+
import os from 'os';
|
|
6
|
+
export default class NpmRc {
|
|
8
7
|
constructor(createIfNotExists = true) {
|
|
9
8
|
this.config = {};
|
|
10
9
|
try {
|
|
11
|
-
this.filePath =
|
|
10
|
+
this.filePath = execSync('npm config get userconfig', { stdio: ['pipe', 'pipe', 'ignore'] })
|
|
12
11
|
.toString()
|
|
13
12
|
.trim();
|
|
14
13
|
}
|
|
@@ -24,21 +23,29 @@ class NpmRc {
|
|
|
24
23
|
}
|
|
25
24
|
/**
|
|
26
25
|
* Load config file
|
|
26
|
+
* @returns {void}
|
|
27
27
|
*/
|
|
28
28
|
load() {
|
|
29
29
|
this.config = ini.parse(fs.readFileSync(this.filePath, 'utf8'));
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Add registry to config file
|
|
33
|
+
* @param key Config key
|
|
34
|
+
* @param value Config value
|
|
35
|
+
* @returns {void}
|
|
33
36
|
*/
|
|
34
|
-
|
|
35
|
-
this
|
|
37
|
+
set(key, value) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
this.config[key] = value;
|
|
40
|
+
});
|
|
36
41
|
}
|
|
37
42
|
/**
|
|
38
43
|
* Set token for Registry
|
|
44
|
+
* @returns {void}
|
|
39
45
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
save() {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
fs.writeFileSync(this.filePath, ini.encode(this.config));
|
|
49
|
+
});
|
|
42
50
|
}
|
|
43
51
|
}
|
|
44
|
-
exports.default = NpmRc;
|