@capraconsulting/cals-cli 2.23.0 → 2.24.0
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/lib/cals-cli.js +100 -97
- package/lib/cals-cli.js.map +1 -1
- package/lib/github/types.d.ts +1 -0
- package/lib/index.es.js +2 -1
- package/lib/index.es.js.map +1 -1
- package/lib/index.js +50 -49
- package/lib/index.js.map +1 -1
- package/package.json +28 -28
package/lib/cals-cli.js
CHANGED
|
@@ -47,7 +47,7 @@ var read__default = /*#__PURE__*/_interopDefaultLegacy(read);
|
|
|
47
47
|
var findUp__default = /*#__PURE__*/_interopDefaultLegacy(findUp);
|
|
48
48
|
var execa__default = /*#__PURE__*/_interopDefaultLegacy(execa);
|
|
49
49
|
|
|
50
|
-
var version = "2.
|
|
50
|
+
var version = "2.24.0";
|
|
51
51
|
var engines = {
|
|
52
52
|
node: ">=12.0.0"
|
|
53
53
|
};
|
|
@@ -357,7 +357,7 @@ function getRepoId(orgName, repoName) {
|
|
|
357
357
|
}
|
|
358
358
|
function checkAgainstSchema(value) {
|
|
359
359
|
var _a;
|
|
360
|
-
const ajv = new AJV__default[
|
|
360
|
+
const ajv = new AJV__default["default"]({ allErrors: true });
|
|
361
361
|
const valid = ajv.validate(schema, value);
|
|
362
362
|
return valid
|
|
363
363
|
? { definition: value }
|
|
@@ -434,7 +434,7 @@ class DefinitionFile {
|
|
|
434
434
|
this.path = path;
|
|
435
435
|
}
|
|
436
436
|
async getContents() {
|
|
437
|
-
return new Promise((resolve, reject) => fs__default[
|
|
437
|
+
return new Promise((resolve, reject) => fs__default["default"].readFile(this.path, "utf-8", (err, data) => {
|
|
438
438
|
if (err)
|
|
439
439
|
reject(err);
|
|
440
440
|
else
|
|
@@ -446,7 +446,7 @@ class DefinitionFile {
|
|
|
446
446
|
}
|
|
447
447
|
}
|
|
448
448
|
function parseDefinition(value) {
|
|
449
|
-
const result = checkAgainstSchema(yaml__default[
|
|
449
|
+
const result = checkAgainstSchema(yaml__default["default"].load(value));
|
|
450
450
|
if ("error" in result) {
|
|
451
451
|
throw new Error("Definition content invalid: " + result.error);
|
|
452
452
|
}
|
|
@@ -476,7 +476,7 @@ class GitHubTokenCliProvider {
|
|
|
476
476
|
if (process.env.CALS_GITHUB_TOKEN) {
|
|
477
477
|
return process.env.CALS_GITHUB_TOKEN;
|
|
478
478
|
}
|
|
479
|
-
const result = await keytar__default[
|
|
479
|
+
const result = await keytar__default["default"].getPassword(this.keyringService, this.keyringAccount);
|
|
480
480
|
if (result == null) {
|
|
481
481
|
process.stderr.write("No token found. Register using `cals github set-token`\n");
|
|
482
482
|
return undefined;
|
|
@@ -484,10 +484,10 @@ class GitHubTokenCliProvider {
|
|
|
484
484
|
return result;
|
|
485
485
|
}
|
|
486
486
|
async markInvalid() {
|
|
487
|
-
await keytar__default[
|
|
487
|
+
await keytar__default["default"].deletePassword(this.keyringService, this.keyringAccount);
|
|
488
488
|
}
|
|
489
489
|
async setToken(value) {
|
|
490
|
-
await keytar__default[
|
|
490
|
+
await keytar__default["default"].setPassword(this.keyringService, this.keyringAccount, value);
|
|
491
491
|
}
|
|
492
492
|
}
|
|
493
493
|
|
|
@@ -560,7 +560,7 @@ class GitHubService {
|
|
|
560
560
|
this.tokenProvider = props.tokenProvider;
|
|
561
561
|
// Control concurrency to GitHub API at service level so we
|
|
562
562
|
// can maximize concurrency all other places.
|
|
563
|
-
this.semaphore = pLimit__default[
|
|
563
|
+
this.semaphore = pLimit__default["default"](6);
|
|
564
564
|
this.octokit.hook.wrap("request", async (request, options) => {
|
|
565
565
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
566
566
|
this._requestCount++;
|
|
@@ -640,7 +640,7 @@ class GitHubService {
|
|
|
640
640
|
const headers = {
|
|
641
641
|
Authorization: `Bearer ${token}`,
|
|
642
642
|
};
|
|
643
|
-
const response = await this.semaphore(() => fetch__default[
|
|
643
|
+
const response = await this.semaphore(() => fetch__default["default"](url, {
|
|
644
644
|
method: "POST",
|
|
645
645
|
headers,
|
|
646
646
|
body: JSON.stringify({ query }),
|
|
@@ -918,6 +918,7 @@ class GitHubService {
|
|
|
918
918
|
}
|
|
919
919
|
edges {
|
|
920
920
|
node {
|
|
921
|
+
state
|
|
921
922
|
dismissReason
|
|
922
923
|
vulnerableManifestFilename
|
|
923
924
|
vulnerableManifestPath
|
|
@@ -1049,7 +1050,7 @@ class SnykTokenCliProvider {
|
|
|
1049
1050
|
if (process.env.CALS_SNYK_TOKEN) {
|
|
1050
1051
|
return process.env.CALS_SNYK_TOKEN;
|
|
1051
1052
|
}
|
|
1052
|
-
const result = await keytar__default[
|
|
1053
|
+
const result = await keytar__default["default"].getPassword(this.keyringService, this.keyringAccount);
|
|
1053
1054
|
if (result == null) {
|
|
1054
1055
|
process.stderr.write("No token found. Register using `cals snyk set-token`\n");
|
|
1055
1056
|
return undefined;
|
|
@@ -1057,10 +1058,10 @@ class SnykTokenCliProvider {
|
|
|
1057
1058
|
return result;
|
|
1058
1059
|
}
|
|
1059
1060
|
async markInvalid() {
|
|
1060
|
-
await keytar__default[
|
|
1061
|
+
await keytar__default["default"].deletePassword(this.keyringService, this.keyringAccount);
|
|
1061
1062
|
}
|
|
1062
1063
|
async setToken(value) {
|
|
1063
|
-
await keytar__default[
|
|
1064
|
+
await keytar__default["default"].setPassword(this.keyringService, this.keyringAccount, value);
|
|
1064
1065
|
}
|
|
1065
1066
|
}
|
|
1066
1067
|
|
|
@@ -1082,7 +1083,7 @@ class SnykService {
|
|
|
1082
1083
|
if (token === undefined) {
|
|
1083
1084
|
throw new Error("Missing token for Snyk");
|
|
1084
1085
|
}
|
|
1085
|
-
const response = await fetch__default[
|
|
1086
|
+
const response = await fetch__default["default"](`https://snyk.io/api/v1/org/${encodeURIComponent(snykAccountId)}/projects`, {
|
|
1086
1087
|
method: "GET",
|
|
1087
1088
|
headers: {
|
|
1088
1089
|
Accept: "application/json",
|
|
@@ -1153,13 +1154,13 @@ class CacheProvider {
|
|
|
1153
1154
|
* The caller is responsible for handling proper validation,
|
|
1154
1155
|
*/
|
|
1155
1156
|
retrieveJson(cachekey) {
|
|
1156
|
-
const cachefile = path__default[
|
|
1157
|
-
if (!fs__default[
|
|
1157
|
+
const cachefile = path__default["default"].join(this.config.cacheDir, `${cachekey}.json`);
|
|
1158
|
+
if (!fs__default["default"].existsSync(cachefile)) {
|
|
1158
1159
|
return undefined;
|
|
1159
1160
|
}
|
|
1160
|
-
const data = fs__default[
|
|
1161
|
+
const data = fs__default["default"].readFileSync(cachefile, "utf-8");
|
|
1161
1162
|
return {
|
|
1162
|
-
cacheTime: fs__default[
|
|
1163
|
+
cacheTime: fs__default["default"].statSync(cachefile).mtime.getTime(),
|
|
1163
1164
|
data: (data === "undefined" ? undefined : JSON.parse(data)),
|
|
1164
1165
|
};
|
|
1165
1166
|
}
|
|
@@ -1167,11 +1168,11 @@ class CacheProvider {
|
|
|
1167
1168
|
* Save data to cache.
|
|
1168
1169
|
*/
|
|
1169
1170
|
storeJson(cachekey, data) {
|
|
1170
|
-
const cachefile = path__default[
|
|
1171
|
-
if (!fs__default[
|
|
1172
|
-
fs__default[
|
|
1171
|
+
const cachefile = path__default["default"].join(this.config.cacheDir, `${cachekey}.json`);
|
|
1172
|
+
if (!fs__default["default"].existsSync(this.config.cacheDir)) {
|
|
1173
|
+
fs__default["default"].mkdirSync(this.config.cacheDir, { recursive: true });
|
|
1173
1174
|
}
|
|
1174
|
-
fs__default[
|
|
1175
|
+
fs__default["default"].writeFileSync(cachefile, data === undefined ? "undefined" : JSON.stringify(data));
|
|
1175
1176
|
}
|
|
1176
1177
|
async json(cachekey, block, cachetime = this.defaultCacheTime) {
|
|
1177
1178
|
const cacheItem = this.mustValidate
|
|
@@ -1189,16 +1190,16 @@ class CacheProvider {
|
|
|
1189
1190
|
* Delete all cached data.
|
|
1190
1191
|
*/
|
|
1191
1192
|
cleanup() {
|
|
1192
|
-
rimraf__default[
|
|
1193
|
+
rimraf__default["default"].sync(this.config.cacheDir);
|
|
1193
1194
|
}
|
|
1194
1195
|
}
|
|
1195
1196
|
|
|
1196
1197
|
class Config {
|
|
1197
1198
|
constructor() {
|
|
1198
|
-
this.cwd = path__default[
|
|
1199
|
-
this.configFile = path__default[
|
|
1200
|
-
this.cacheDir = cachedir__default[
|
|
1201
|
-
this.agent = new https__default[
|
|
1199
|
+
this.cwd = path__default["default"].resolve(process.cwd());
|
|
1200
|
+
this.configFile = path__default["default"].join(os__default["default"].homedir(), ".cals-config.json");
|
|
1201
|
+
this.cacheDir = cachedir__default["default"]("cals-cli");
|
|
1202
|
+
this.agent = new https__default["default"].Agent({
|
|
1202
1203
|
keepAlive: true,
|
|
1203
1204
|
});
|
|
1204
1205
|
this.configCached = undefined;
|
|
@@ -1213,12 +1214,12 @@ class Config {
|
|
|
1213
1214
|
return config;
|
|
1214
1215
|
}
|
|
1215
1216
|
readConfig() {
|
|
1216
|
-
if (!fs__default[
|
|
1217
|
+
if (!fs__default["default"].existsSync(this.configFile)) {
|
|
1217
1218
|
return {};
|
|
1218
1219
|
}
|
|
1219
1220
|
try {
|
|
1220
1221
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
1221
|
-
return JSON.parse(fs__default[
|
|
1222
|
+
return JSON.parse(fs__default["default"].readFileSync(this.configFile, "utf-8"));
|
|
1222
1223
|
}
|
|
1223
1224
|
catch (e) {
|
|
1224
1225
|
console.error("Failed", e);
|
|
@@ -1240,15 +1241,15 @@ class Config {
|
|
|
1240
1241
|
...this.readConfig(),
|
|
1241
1242
|
[key]: value, // undefined will remove
|
|
1242
1243
|
};
|
|
1243
|
-
fs__default[
|
|
1244
|
+
fs__default["default"].writeFileSync(this.configFile, JSON.stringify(updatedConfig, null, " "));
|
|
1244
1245
|
this.configCached = updatedConfig;
|
|
1245
1246
|
}
|
|
1246
1247
|
}
|
|
1247
1248
|
|
|
1248
1249
|
const CLEAR_WHOLE_LINE = 0;
|
|
1249
1250
|
function clearLine(stdout) {
|
|
1250
|
-
readline__default[
|
|
1251
|
-
readline__default[
|
|
1251
|
+
readline__default["default"].clearLine(stdout, CLEAR_WHOLE_LINE);
|
|
1252
|
+
readline__default["default"].cursorTo(stdout, 0);
|
|
1252
1253
|
}
|
|
1253
1254
|
class Reporter {
|
|
1254
1255
|
constructor(opts = {}) {
|
|
@@ -1256,7 +1257,7 @@ class Reporter {
|
|
|
1256
1257
|
this.stderr = process.stderr;
|
|
1257
1258
|
this.stdin = process.stdin;
|
|
1258
1259
|
this.isTTY = this.stdout.isTTY;
|
|
1259
|
-
this.format = chalk__default[
|
|
1260
|
+
this.format = chalk__default["default"];
|
|
1260
1261
|
this.startTime = Date.now();
|
|
1261
1262
|
this.nonInteractive = !!opts.nonInteractive;
|
|
1262
1263
|
this.isVerbose = !!opts.verbose;
|
|
@@ -1317,7 +1318,7 @@ function getDefinitionFile(argv) {
|
|
|
1317
1318
|
throw Error("Missing --definition-file option");
|
|
1318
1319
|
}
|
|
1319
1320
|
const definitionFile = argv.definitionFile;
|
|
1320
|
-
if (!fs__default[
|
|
1321
|
+
if (!fs__default["default"].existsSync(definitionFile)) {
|
|
1321
1322
|
throw Error(`The file ${definitionFile} does not exist`);
|
|
1322
1323
|
}
|
|
1323
1324
|
return new DefinitionFile(definitionFile);
|
|
@@ -1374,9 +1375,9 @@ function reorderListToSimilarAsBefore(oldList, updatedList, selector, insertLast
|
|
|
1374
1375
|
}
|
|
1375
1376
|
|
|
1376
1377
|
async function getReposFromGitHub(github, orgs) {
|
|
1377
|
-
return (await pMap__default[
|
|
1378
|
+
return (await pMap__default["default"](orgs, async (org) => {
|
|
1378
1379
|
const repos = await github.getOrgRepoList({ org: org.login });
|
|
1379
|
-
return pMap__default[
|
|
1380
|
+
return pMap__default["default"](repos, async (repo) => {
|
|
1380
1381
|
const detailedRepo = await github.getRepository(repo.owner.login, repo.name);
|
|
1381
1382
|
if (detailedRepo === undefined) {
|
|
1382
1383
|
throw Error(`Repo not found: ${repo.owner.login}/${repo.name}`);
|
|
@@ -1390,11 +1391,11 @@ async function getReposFromGitHub(github, orgs) {
|
|
|
1390
1391
|
})).flat();
|
|
1391
1392
|
}
|
|
1392
1393
|
async function getTeams(github, orgs) {
|
|
1393
|
-
const intermediate = await pMap__default[
|
|
1394
|
+
const intermediate = await pMap__default["default"](orgs, async (org) => {
|
|
1394
1395
|
const teams = await github.getTeamList(org);
|
|
1395
1396
|
return {
|
|
1396
1397
|
org,
|
|
1397
|
-
teams: await pMap__default[
|
|
1398
|
+
teams: await pMap__default["default"](teams, async (team) => ({
|
|
1398
1399
|
team,
|
|
1399
1400
|
users: await github.getTeamMemberListIncludingInvited(org, team),
|
|
1400
1401
|
})),
|
|
@@ -1427,7 +1428,7 @@ function getFormattedTeams(oldTeams, teams) {
|
|
|
1427
1428
|
: undefined;
|
|
1428
1429
|
}
|
|
1429
1430
|
async function getOrgs(github, orgs) {
|
|
1430
|
-
return pMap__default[
|
|
1431
|
+
return pMap__default["default"](orgs, (it) => github.getOrg(it));
|
|
1431
1432
|
}
|
|
1432
1433
|
function removeDuplicates(items, selector) {
|
|
1433
1434
|
const ids = [];
|
|
@@ -1442,7 +1443,7 @@ function removeDuplicates(items, selector) {
|
|
|
1442
1443
|
return result;
|
|
1443
1444
|
}
|
|
1444
1445
|
async function getMembers(github, orgs) {
|
|
1445
|
-
return removeDuplicates((await pMap__default[
|
|
1446
|
+
return removeDuplicates((await pMap__default["default"](orgs, (org) => github.getOrgMembersListIncludingInvited(org.login)))
|
|
1446
1447
|
.flat()
|
|
1447
1448
|
.map((it) => it.login), (it) => it);
|
|
1448
1449
|
}
|
|
@@ -1557,7 +1558,7 @@ async function dumpSetup(config, reporter, github, snyk, outfile, definitionFile
|
|
|
1557
1558
|
// package. However it often produced invalid yaml, so we have removed
|
|
1558
1559
|
// it. We might want to revisit it to preserve comments.
|
|
1559
1560
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-explicit-any
|
|
1560
|
-
const doc = yaml__default[
|
|
1561
|
+
const doc = yaml__default["default"].load(await definitionFile.getContents());
|
|
1561
1562
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
1562
1563
|
doc.snyk = generatedDefinition.snyk;
|
|
1563
1564
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
@@ -1565,7 +1566,7 @@ async function dumpSetup(config, reporter, github, snyk, outfile, definitionFile
|
|
|
1565
1566
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
1566
1567
|
doc.github = generatedDefinition.github;
|
|
1567
1568
|
// Convert to/from plain JSON so that undefined elements are removed.
|
|
1568
|
-
fs__default[
|
|
1569
|
+
fs__default["default"].writeFileSync(outfile, yaml__default["default"].dump(JSON.parse(JSON.stringify(doc))));
|
|
1569
1570
|
reporter.info(`Saved to ${outfile}`);
|
|
1570
1571
|
reporter.info(`Number of GitHub requests: ${github.requestCount}`);
|
|
1571
1572
|
}
|
|
@@ -1610,7 +1611,7 @@ const command$i = {
|
|
|
1610
1611
|
.demandCommand()
|
|
1611
1612
|
.usage(`cals definition`),
|
|
1612
1613
|
handler: () => {
|
|
1613
|
-
yargs__default[
|
|
1614
|
+
yargs__default["default"].showHelp();
|
|
1614
1615
|
},
|
|
1615
1616
|
};
|
|
1616
1617
|
|
|
@@ -1635,7 +1636,7 @@ class DetectifyTokenCliProvider {
|
|
|
1635
1636
|
if (process.env.CALS_DETECTIFY_TOKEN) {
|
|
1636
1637
|
return process.env.CALS_DETECTIFY_TOKEN;
|
|
1637
1638
|
}
|
|
1638
|
-
const result = await keytar__default[
|
|
1639
|
+
const result = await keytar__default["default"].getPassword(this.keyringService, this.keyringAccount);
|
|
1639
1640
|
if (result == null) {
|
|
1640
1641
|
process.stderr.write("No token found. Register using `cals detectify set-token`\n");
|
|
1641
1642
|
return undefined;
|
|
@@ -1643,10 +1644,10 @@ class DetectifyTokenCliProvider {
|
|
|
1643
1644
|
return result;
|
|
1644
1645
|
}
|
|
1645
1646
|
async markInvalid() {
|
|
1646
|
-
await keytar__default[
|
|
1647
|
+
await keytar__default["default"].deletePassword(this.keyringService, this.keyringAccount);
|
|
1647
1648
|
}
|
|
1648
1649
|
async setToken(value) {
|
|
1649
|
-
await keytar__default[
|
|
1650
|
+
await keytar__default["default"].setPassword(this.keyringService, this.keyringAccount, value);
|
|
1650
1651
|
}
|
|
1651
1652
|
}
|
|
1652
1653
|
|
|
@@ -1666,7 +1667,7 @@ class DetectifyService {
|
|
|
1666
1667
|
if (token === undefined) {
|
|
1667
1668
|
throw new Error("Missing token for Detectify");
|
|
1668
1669
|
}
|
|
1669
|
-
const response = await fetch__default[
|
|
1670
|
+
const response = await fetch__default["default"](url, {
|
|
1670
1671
|
method: "GET",
|
|
1671
1672
|
headers: {
|
|
1672
1673
|
Accept: "application/json",
|
|
@@ -1744,7 +1745,7 @@ async function setToken$2({ reporter, token, tokenProvider, }) {
|
|
|
1744
1745
|
reporter.info("Need API token to talk to Detectify");
|
|
1745
1746
|
reporter.info("See API keys under https://detectify.com/dashboard/team");
|
|
1746
1747
|
token = await new Promise((resolve, reject) => {
|
|
1747
|
-
read__default[
|
|
1748
|
+
read__default["default"]({
|
|
1748
1749
|
prompt: "Enter new Detectify API token: ",
|
|
1749
1750
|
silent: true,
|
|
1750
1751
|
}, (err, answer) => {
|
|
@@ -1785,7 +1786,7 @@ Notes:
|
|
|
1785
1786
|
and provide a link to generate one:
|
|
1786
1787
|
$ cals detectify set-token`),
|
|
1787
1788
|
handler: () => {
|
|
1788
|
-
yargs__default[
|
|
1789
|
+
yargs__default["default"].showHelp();
|
|
1789
1790
|
},
|
|
1790
1791
|
};
|
|
1791
1792
|
|
|
@@ -1801,9 +1802,9 @@ const command$d = {
|
|
|
1801
1802
|
async function analyzeDirectory(reporter, config, github, org) {
|
|
1802
1803
|
const repos = await github.getOrgRepoList({ org });
|
|
1803
1804
|
const reposDict = repos.reduce((acc, cur) => ({ ...acc, [cur.name]: cur }), {});
|
|
1804
|
-
const dirs = fs__default[
|
|
1805
|
+
const dirs = fs__default["default"]
|
|
1805
1806
|
.readdirSync(config.cwd)
|
|
1806
|
-
.filter((it) => fs__default[
|
|
1807
|
+
.filter((it) => fs__default["default"].statSync(path__default["default"].join(config.cwd, it)).isDirectory())
|
|
1807
1808
|
// Skip hidden folders
|
|
1808
1809
|
.filter((it) => !it.startsWith("."))
|
|
1809
1810
|
.sort((a, b) => a.localeCompare(b));
|
|
@@ -1879,7 +1880,7 @@ function getChangedRepoAttribs(definitionRepo, actualRepo) {
|
|
|
1879
1880
|
async function getUnknownRepos(github, definition, limitToOrg) {
|
|
1880
1881
|
const knownRepos = getRepos(definition).map((it) => it.id);
|
|
1881
1882
|
const orgs = getGitHubOrgs(definition).filter((orgName) => limitToOrg === undefined || limitToOrg === orgName);
|
|
1882
|
-
return lodash.sortBy((await pMap__default[
|
|
1883
|
+
return lodash.sortBy((await pMap__default["default"](orgs, (orgName) => github.getOrgRepoList({ org: orgName })))
|
|
1883
1884
|
.flat()
|
|
1884
1885
|
.filter((it) => !knownRepos.includes(`${it.owner.login}/${it.name}`)), (it) => `${it.owner.login}/${it.name}`);
|
|
1885
1886
|
}
|
|
@@ -1974,7 +1975,7 @@ async function createChangeSetItemsForProjects(github, definition, limitToOrg) {
|
|
|
1974
1975
|
const orgs = definition.projects
|
|
1975
1976
|
.flatMap((it) => it.github)
|
|
1976
1977
|
.filter((org) => limitToOrg === undefined || limitToOrg === org.organization);
|
|
1977
|
-
changes.push(...(await pMap__default[
|
|
1978
|
+
changes.push(...(await pMap__default["default"](orgs, async (org) => pMap__default["default"](org.repos || [], (projectRepo) => getProjectRepoChanges({
|
|
1978
1979
|
github,
|
|
1979
1980
|
org,
|
|
1980
1981
|
projectRepo,
|
|
@@ -2072,7 +2073,7 @@ async function createChangeSetItemsForTeams(github, definition, org) {
|
|
|
2072
2073
|
}
|
|
2073
2074
|
});
|
|
2074
2075
|
const overlappingTeams = actualTeams.filter((it) => wantedTeamNames.includes(it.name));
|
|
2075
|
-
await pMap__default[
|
|
2076
|
+
await pMap__default["default"](overlappingTeams, async (actualTeam) => {
|
|
2076
2077
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
2077
2078
|
const wantedTeam = teams.find((it) => it.name === actualTeam.name);
|
|
2078
2079
|
const actualMembers = await github.getTeamMemberListIncludingInvited(org, actualTeam);
|
|
@@ -2270,7 +2271,7 @@ function createOrgGetter(github) {
|
|
|
2270
2271
|
const semaphores = {};
|
|
2271
2272
|
function getSemaphore(orgName) {
|
|
2272
2273
|
if (!(orgName in semaphores)) {
|
|
2273
|
-
semaphores[orgName] = pLimit__default[
|
|
2274
|
+
semaphores[orgName] = pLimit__default["default"](1);
|
|
2274
2275
|
}
|
|
2275
2276
|
return semaphores[orgName];
|
|
2276
2277
|
}
|
|
@@ -2327,7 +2328,7 @@ async function process$1(reporter, github, definition, getOrg, execute, limitToO
|
|
|
2327
2328
|
}
|
|
2328
2329
|
if (execute && changes.length > 0) {
|
|
2329
2330
|
const cont = await new Promise((resolve, reject) => {
|
|
2330
|
-
read__default[
|
|
2331
|
+
read__default["default"]({
|
|
2331
2332
|
prompt: "Confirm you want to execute the changes [y/N]: ",
|
|
2332
2333
|
timeout: 60000,
|
|
2333
2334
|
}, (err, answer) => {
|
|
@@ -2377,7 +2378,7 @@ const command$b = {
|
|
|
2377
2378
|
|
|
2378
2379
|
async function generateCloneCommands({ reporter, config, github, org, ...opt }) {
|
|
2379
2380
|
if (!opt.listGroups && !opt.all && opt.group === undefined) {
|
|
2380
|
-
yargs__default[
|
|
2381
|
+
yargs__default["default"].showHelp();
|
|
2381
2382
|
return;
|
|
2382
2383
|
}
|
|
2383
2384
|
const repos = await github.getOrgRepoList({ org });
|
|
@@ -2397,7 +2398,7 @@ async function generateCloneCommands({ reporter, config, github, org, ...opt })
|
|
|
2397
2398
|
.filter((it) => opt.name === undefined || it.name.includes(opt.name))
|
|
2398
2399
|
.filter((it) => opt.topic === undefined || includesTopic(it, opt.topic))
|
|
2399
2400
|
.filter((it) => !opt.excludeExisting ||
|
|
2400
|
-
!fs__default[
|
|
2401
|
+
!fs__default["default"].existsSync(path__default["default"].resolve(config.cwd, it.name)))
|
|
2401
2402
|
.forEach((repo) => {
|
|
2402
2403
|
// The output of this is used to pipe into e.g. bash.
|
|
2403
2404
|
// We cannot use reporter.log as it adds additional characters.
|
|
@@ -2704,7 +2705,7 @@ async function setToken$1({ reporter, token, tokenProvider, }) {
|
|
|
2704
2705
|
reporter.info("Need API token to talk to GitHub");
|
|
2705
2706
|
reporter.info("https://github.com/settings/tokens/new?scopes=repo:status,read:repo_hook");
|
|
2706
2707
|
token = await new Promise((resolve, reject) => {
|
|
2707
|
-
read__default[
|
|
2708
|
+
read__default["default"]({
|
|
2708
2709
|
prompt: "Enter new GitHub API token: ",
|
|
2709
2710
|
silent: true,
|
|
2710
2711
|
}, (err, answer) => {
|
|
@@ -2772,33 +2773,35 @@ class GitRepo {
|
|
|
2772
2773
|
this.logCommand = logCommand;
|
|
2773
2774
|
}
|
|
2774
2775
|
async cloneGitHubRepo(org, name, cloneType) {
|
|
2775
|
-
const parent = path__default[
|
|
2776
|
-
if (!fs__default[
|
|
2777
|
-
await fs__default[
|
|
2776
|
+
const parent = path__default["default"].dirname(this.path);
|
|
2777
|
+
if (!fs__default["default"].existsSync(parent)) {
|
|
2778
|
+
await fs__default["default"].promises.mkdir(parent, { recursive: true });
|
|
2778
2779
|
}
|
|
2779
2780
|
const cloneUrl = cloneType === CloneType.SSH
|
|
2780
2781
|
? `git@github.com:${org}/${name}.git`
|
|
2781
2782
|
: `https://github.com/${org}/${name}.git`;
|
|
2782
2783
|
try {
|
|
2783
|
-
const result = await execa__default[
|
|
2784
|
+
const result = await execa__default["default"]("git", ["clone", cloneUrl, this.path], {
|
|
2784
2785
|
cwd: parent,
|
|
2785
2786
|
});
|
|
2786
2787
|
await this.logCommand(result);
|
|
2787
2788
|
}
|
|
2788
2789
|
catch (e) {
|
|
2790
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
2789
2791
|
await this.logCommand(e);
|
|
2790
2792
|
throw e;
|
|
2791
2793
|
}
|
|
2792
2794
|
}
|
|
2793
2795
|
async git(args) {
|
|
2794
2796
|
try {
|
|
2795
|
-
const result = await execa__default[
|
|
2797
|
+
const result = await execa__default["default"]("git", args, {
|
|
2796
2798
|
cwd: this.path,
|
|
2797
2799
|
});
|
|
2798
2800
|
await this.logCommand(result);
|
|
2799
2801
|
return result;
|
|
2800
2802
|
}
|
|
2801
2803
|
catch (e) {
|
|
2804
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
2802
2805
|
await this.logCommand(e);
|
|
2803
2806
|
throw e;
|
|
2804
2807
|
}
|
|
@@ -2859,11 +2862,11 @@ const CALS_LOG = ".cals.log";
|
|
|
2859
2862
|
* backward slashes in paths.
|
|
2860
2863
|
*/
|
|
2861
2864
|
function getRelpath(it) {
|
|
2862
|
-
return path__default[
|
|
2865
|
+
return path__default["default"].join(it.group, it.name);
|
|
2863
2866
|
}
|
|
2864
2867
|
async function appendFile(path, data) {
|
|
2865
2868
|
return new Promise((resolve, reject) => {
|
|
2866
|
-
fs__default[
|
|
2869
|
+
fs__default["default"].appendFile(path, data, { encoding: "utf-8" }, (err) => {
|
|
2867
2870
|
if (err !== null) {
|
|
2868
2871
|
reject(err);
|
|
2869
2872
|
}
|
|
@@ -2880,7 +2883,7 @@ function getAliases(repo) {
|
|
|
2880
2883
|
}
|
|
2881
2884
|
async function updateReposInParallel(reporter, items) {
|
|
2882
2885
|
// Perform git operations in parallel, but limit how much.
|
|
2883
|
-
const semaphore = pLimit__default[
|
|
2886
|
+
const semaphore = pLimit__default["default"](30);
|
|
2884
2887
|
const promises = items.map((repo) => semaphore(async () => {
|
|
2885
2888
|
try {
|
|
2886
2889
|
return {
|
|
@@ -2942,8 +2945,8 @@ async function updateRepos(reporter, foundRepos) {
|
|
|
2942
2945
|
}
|
|
2943
2946
|
}
|
|
2944
2947
|
function guessDefinitionRepoName(rootdir, cals) {
|
|
2945
|
-
const p = path__default[
|
|
2946
|
-
const relativePath = path__default[
|
|
2948
|
+
const p = path__default["default"].resolve(rootdir, cals.resourcesDefinition.path);
|
|
2949
|
+
const relativePath = path__default["default"].relative(rootdir, p);
|
|
2947
2950
|
if (relativePath.slice(0, 1) == ".") {
|
|
2948
2951
|
return null;
|
|
2949
2952
|
}
|
|
@@ -2956,8 +2959,8 @@ function guessDefinitionRepoName(rootdir, cals) {
|
|
|
2956
2959
|
return parts[1];
|
|
2957
2960
|
}
|
|
2958
2961
|
async function getDefinition(rootdir, cals) {
|
|
2959
|
-
const p = path__default[
|
|
2960
|
-
if (!fs__default[
|
|
2962
|
+
const p = path__default["default"].resolve(rootdir, cals.resourcesDefinition.path);
|
|
2963
|
+
if (!fs__default["default"].existsSync(p)) {
|
|
2961
2964
|
throw Error(`The file ${p} does not exist`);
|
|
2962
2965
|
}
|
|
2963
2966
|
return new DefinitionFile(p).getDefinition();
|
|
@@ -2966,9 +2969,9 @@ async function getDefinition(rootdir, cals) {
|
|
|
2966
2969
|
* Get directory names within a directory.
|
|
2967
2970
|
*/
|
|
2968
2971
|
function getDirNames(parent) {
|
|
2969
|
-
return (fs__default[
|
|
2972
|
+
return (fs__default["default"]
|
|
2970
2973
|
.readdirSync(parent)
|
|
2971
|
-
.filter((it) => fs__default[
|
|
2974
|
+
.filter((it) => fs__default["default"].statSync(path__default["default"].join(parent, it)).isDirectory())
|
|
2972
2975
|
// Skip hidden folders
|
|
2973
2976
|
.filter((it) => !it.startsWith("."))
|
|
2974
2977
|
.sort((a, b) => a.localeCompare(b)));
|
|
@@ -2980,7 +2983,7 @@ async function getReposInOrg(cals, rootdir) {
|
|
|
2980
2983
|
.filter((it) => cals.resourcesDefinition.tags === undefined ||
|
|
2981
2984
|
(it.project.tags || []).some((tag) => { var _a; return (_a = cals.resourcesDefinition.tags) === null || _a === void 0 ? void 0 : _a.includes(tag); }) ||
|
|
2982
2985
|
// Always include if already checked out to avoid stale state.
|
|
2983
|
-
fs__default[
|
|
2986
|
+
fs__default["default"].existsSync(path__default["default"].join(rootdir, it.project.name, it.repo.name)));
|
|
2984
2987
|
}
|
|
2985
2988
|
function getExpectedRepo(item) {
|
|
2986
2989
|
return {
|
|
@@ -2993,8 +2996,8 @@ function getExpectedRepo(item) {
|
|
|
2993
2996
|
};
|
|
2994
2997
|
}
|
|
2995
2998
|
function getGitRepo(rootdir, relpath) {
|
|
2996
|
-
return new GitRepo(path__default[
|
|
2997
|
-
await appendFile(path__default[
|
|
2999
|
+
return new GitRepo(path__default["default"].resolve(rootdir, relpath), async (result) => {
|
|
3000
|
+
await appendFile(path__default["default"].resolve(rootdir, CALS_LOG), JSON.stringify({
|
|
2998
3001
|
time: new Date().toISOString(),
|
|
2999
3002
|
context: relpath,
|
|
3000
3003
|
type: "exec-result",
|
|
@@ -3048,7 +3051,7 @@ async function getExpectedRepos(reporter, github, cals, rootdir) {
|
|
|
3048
3051
|
}
|
|
3049
3052
|
async function getInput(prompt) {
|
|
3050
3053
|
return new Promise((resolve, reject) => {
|
|
3051
|
-
read__default[
|
|
3054
|
+
read__default["default"]({
|
|
3052
3055
|
prompt,
|
|
3053
3056
|
timeout: 60000,
|
|
3054
3057
|
}, (err, answer) => {
|
|
@@ -3085,15 +3088,15 @@ async function sync$1({ reporter, github, cals, rootdir, askClone, askMove, }) {
|
|
|
3085
3088
|
const foundRepos = [];
|
|
3086
3089
|
// Categorize all dirs.
|
|
3087
3090
|
for (const topdir of getDirNames(rootdir)) {
|
|
3088
|
-
const isGitDir = fs__default[
|
|
3091
|
+
const isGitDir = fs__default["default"].existsSync(path__default["default"].join(rootdir, topdir, ".git"));
|
|
3089
3092
|
if (isGitDir) {
|
|
3090
3093
|
// Do not traverse deeper inside another Git repo, as that might
|
|
3091
3094
|
// mean we do not have the proper grouped structure.
|
|
3092
3095
|
unknownDirs.push(topdir);
|
|
3093
3096
|
continue;
|
|
3094
3097
|
}
|
|
3095
|
-
for (const subdir of getDirNames(path__default[
|
|
3096
|
-
const p = path__default[
|
|
3098
|
+
for (const subdir of getDirNames(path__default["default"].join(rootdir, topdir))) {
|
|
3099
|
+
const p = path__default["default"].join(topdir, subdir);
|
|
3097
3100
|
const expectedRepo = expectedRepos.find((it) => getRelpath(it) === p ||
|
|
3098
3101
|
it.aliases.some((alias) => getRelpath(alias) === p));
|
|
3099
3102
|
if (expectedRepo === undefined) {
|
|
@@ -3121,9 +3124,9 @@ async function sync$1({ reporter, github, cals, rootdir, askClone, askMove, }) {
|
|
|
3121
3124
|
for (const it of archivedRepos) {
|
|
3122
3125
|
reporter.info(` ${it.actualRelpath}`);
|
|
3123
3126
|
}
|
|
3124
|
-
const thisDirName = path__default[
|
|
3127
|
+
const thisDirName = path__default["default"].basename(process.cwd());
|
|
3125
3128
|
const archiveDir = `../${thisDirName}-archive`;
|
|
3126
|
-
const hasArchiveDir = fs__default[
|
|
3129
|
+
const hasArchiveDir = fs__default["default"].existsSync(archiveDir);
|
|
3127
3130
|
if (hasArchiveDir) {
|
|
3128
3131
|
reporter.info("To move these:");
|
|
3129
3132
|
for (const it of archivedRepos) {
|
|
@@ -3146,17 +3149,17 @@ async function sync$1({ reporter, github, cals, rootdir, askClone, askMove, }) {
|
|
|
3146
3149
|
const shouldMove = await askMoveConfirm();
|
|
3147
3150
|
if (shouldMove) {
|
|
3148
3151
|
for (const it of movedRepos) {
|
|
3149
|
-
const src = path__default[
|
|
3150
|
-
const dest = path__default[
|
|
3151
|
-
const destParent = path__default[
|
|
3152
|
-
if (fs__default[
|
|
3152
|
+
const src = path__default["default"].join(rootdir, it.actualRelpath);
|
|
3153
|
+
const dest = path__default["default"].join(rootdir, getRelpath(it));
|
|
3154
|
+
const destParent = path__default["default"].join(rootdir, it.group);
|
|
3155
|
+
if (fs__default["default"].existsSync(dest)) {
|
|
3153
3156
|
throw new Error(`Target directory already exists: ${dest} - cannot move ${it.actualRelpath}`);
|
|
3154
3157
|
}
|
|
3155
3158
|
reporter.info(`Moving ${it.actualRelpath} -> ${getRelpath(it)}`);
|
|
3156
|
-
if (!fs__default[
|
|
3157
|
-
await fs__default[
|
|
3159
|
+
if (!fs__default["default"].existsSync(destParent)) {
|
|
3160
|
+
await fs__default["default"].promises.mkdir(destParent, { recursive: true });
|
|
3158
3161
|
}
|
|
3159
|
-
await fs__default[
|
|
3162
|
+
await fs__default["default"].promises.rename(src, dest);
|
|
3160
3163
|
}
|
|
3161
3164
|
// We would have to update expectedRepos if we want to continue.
|
|
3162
3165
|
// Let's try keeping this simple.
|
|
@@ -3200,7 +3203,7 @@ async function sync$1({ reporter, github, cals, rootdir, askClone, askMove, }) {
|
|
|
3200
3203
|
}
|
|
3201
3204
|
}
|
|
3202
3205
|
async function loadCalsManifest(config, reporter) {
|
|
3203
|
-
const p = await findUp__default[
|
|
3206
|
+
const p = await findUp__default["default"](CALS_YAML, { cwd: config.cwd });
|
|
3204
3207
|
if (p === undefined) {
|
|
3205
3208
|
reporter.error(`File ${CALS_YAML} not found. See help`);
|
|
3206
3209
|
process.exitCode = 1;
|
|
@@ -3209,12 +3212,12 @@ async function loadCalsManifest(config, reporter) {
|
|
|
3209
3212
|
// TODO: Verify file has expected contents.
|
|
3210
3213
|
// (Can we easily generate schema for type and verify?)
|
|
3211
3214
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-explicit-any
|
|
3212
|
-
const cals = yaml__default[
|
|
3215
|
+
const cals = yaml__default["default"].load(fs__default["default"].readFileSync(p, "utf-8"));
|
|
3213
3216
|
if (cals.version !== 2) {
|
|
3214
3217
|
throw new Error(`Unexpected version in ${p}`);
|
|
3215
3218
|
}
|
|
3216
3219
|
return {
|
|
3217
|
-
dir: path__default[
|
|
3220
|
+
dir: path__default["default"].dirname(p),
|
|
3218
3221
|
cals,
|
|
3219
3222
|
};
|
|
3220
3223
|
}
|
|
@@ -3319,7 +3322,7 @@ Notes:
|
|
|
3319
3322
|
option to avoid stale cache. The cache can also be cleared with
|
|
3320
3323
|
the "cals delete-cache" command.`),
|
|
3321
3324
|
handler: () => {
|
|
3322
|
-
yargs__default[
|
|
3325
|
+
yargs__default["default"].showHelp();
|
|
3323
3326
|
},
|
|
3324
3327
|
};
|
|
3325
3328
|
|
|
@@ -3397,7 +3400,7 @@ async function setToken({ reporter, token, tokenProvider, }) {
|
|
|
3397
3400
|
reporter.info("Need API token to talk to Snyk");
|
|
3398
3401
|
reporter.info("See https://app.snyk.io/account");
|
|
3399
3402
|
token = await new Promise((resolve, reject) => {
|
|
3400
|
-
read__default[
|
|
3403
|
+
read__default["default"]({
|
|
3401
3404
|
prompt: "Enter new Snyk API token: ",
|
|
3402
3405
|
silent: true,
|
|
3403
3406
|
}, (err, answer) => {
|
|
@@ -3468,12 +3471,12 @@ Notes:
|
|
|
3468
3471
|
and provide a link to generate one:
|
|
3469
3472
|
$ cals snyk set-token`),
|
|
3470
3473
|
handler: () => {
|
|
3471
|
-
yargs__default[
|
|
3474
|
+
yargs__default["default"].showHelp();
|
|
3472
3475
|
},
|
|
3473
3476
|
};
|
|
3474
3477
|
|
|
3475
3478
|
async function main() {
|
|
3476
|
-
if (!semver__default[
|
|
3479
|
+
if (!semver__default["default"].satisfies(process.version, engines.node)) {
|
|
3477
3480
|
console.error(`Required node version ${engines.node} not satisfied with current version ${process.version}.`);
|
|
3478
3481
|
process.exit(1);
|
|
3479
3482
|
}
|
|
@@ -3485,12 +3488,12 @@ async function main() {
|
|
|
3485
3488
|
/ /___/ ___ |/ /______/ /
|
|
3486
3489
|
\\____/_/ |_/_____/____/
|
|
3487
3490
|
cli ${version}
|
|
3488
|
-
built ${"
|
|
3491
|
+
built ${"2022-02-23T11:41:21+0000"}
|
|
3489
3492
|
|
|
3490
3493
|
https://github.com/capralifecycle/cals-cli/
|
|
3491
3494
|
|
|
3492
3495
|
Usage: cals <command>`;
|
|
3493
|
-
await yargs__default[
|
|
3496
|
+
await yargs__default["default"]
|
|
3494
3497
|
.usage(header)
|
|
3495
3498
|
.scriptName("cals")
|
|
3496
3499
|
.locale("en")
|
package/lib/cals-cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cals-cli.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cals-cli.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/lib/github/types.d.ts
CHANGED
package/lib/index.es.js
CHANGED
|
@@ -22,7 +22,7 @@ import execa from 'execa';
|
|
|
22
22
|
import { performance } from 'perf_hooks';
|
|
23
23
|
import { Transform } from 'stream';
|
|
24
24
|
|
|
25
|
-
var version = "2.
|
|
25
|
+
var version = "2.24.0";
|
|
26
26
|
|
|
27
27
|
class CacheProvider {
|
|
28
28
|
constructor(config) {
|
|
@@ -994,6 +994,7 @@ class GitHubService {
|
|
|
994
994
|
}
|
|
995
995
|
edges {
|
|
996
996
|
node {
|
|
997
|
+
state
|
|
997
998
|
dismissReason
|
|
998
999
|
vulnerableManifestFilename
|
|
999
1000
|
vulnerableManifestPath
|
package/lib/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version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;;;;;;;;;;;;;;"}
|
package/lib/index.js
CHANGED
|
@@ -44,7 +44,7 @@ var keytar__default = /*#__PURE__*/_interopDefaultLegacy(keytar);
|
|
|
44
44
|
var read__default = /*#__PURE__*/_interopDefaultLegacy(read);
|
|
45
45
|
var execa__default = /*#__PURE__*/_interopDefaultLegacy(execa);
|
|
46
46
|
|
|
47
|
-
var version = "2.
|
|
47
|
+
var version = "2.24.0";
|
|
48
48
|
|
|
49
49
|
class CacheProvider {
|
|
50
50
|
constructor(config) {
|
|
@@ -58,13 +58,13 @@ class CacheProvider {
|
|
|
58
58
|
* The caller is responsible for handling proper validation,
|
|
59
59
|
*/
|
|
60
60
|
retrieveJson(cachekey) {
|
|
61
|
-
const cachefile = path__default[
|
|
62
|
-
if (!fs__default[
|
|
61
|
+
const cachefile = path__default["default"].join(this.config.cacheDir, `${cachekey}.json`);
|
|
62
|
+
if (!fs__default["default"].existsSync(cachefile)) {
|
|
63
63
|
return undefined;
|
|
64
64
|
}
|
|
65
|
-
const data = fs__default[
|
|
65
|
+
const data = fs__default["default"].readFileSync(cachefile, "utf-8");
|
|
66
66
|
return {
|
|
67
|
-
cacheTime: fs__default[
|
|
67
|
+
cacheTime: fs__default["default"].statSync(cachefile).mtime.getTime(),
|
|
68
68
|
data: (data === "undefined" ? undefined : JSON.parse(data)),
|
|
69
69
|
};
|
|
70
70
|
}
|
|
@@ -72,11 +72,11 @@ class CacheProvider {
|
|
|
72
72
|
* Save data to cache.
|
|
73
73
|
*/
|
|
74
74
|
storeJson(cachekey, data) {
|
|
75
|
-
const cachefile = path__default[
|
|
76
|
-
if (!fs__default[
|
|
77
|
-
fs__default[
|
|
75
|
+
const cachefile = path__default["default"].join(this.config.cacheDir, `${cachekey}.json`);
|
|
76
|
+
if (!fs__default["default"].existsSync(this.config.cacheDir)) {
|
|
77
|
+
fs__default["default"].mkdirSync(this.config.cacheDir, { recursive: true });
|
|
78
78
|
}
|
|
79
|
-
fs__default[
|
|
79
|
+
fs__default["default"].writeFileSync(cachefile, data === undefined ? "undefined" : JSON.stringify(data));
|
|
80
80
|
}
|
|
81
81
|
async json(cachekey, block, cachetime = this.defaultCacheTime) {
|
|
82
82
|
const cacheItem = this.mustValidate
|
|
@@ -94,14 +94,14 @@ class CacheProvider {
|
|
|
94
94
|
* Delete all cached data.
|
|
95
95
|
*/
|
|
96
96
|
cleanup() {
|
|
97
|
-
rimraf__default[
|
|
97
|
+
rimraf__default["default"].sync(this.config.cacheDir);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
const CLEAR_WHOLE_LINE = 0;
|
|
102
102
|
function clearLine(stdout) {
|
|
103
|
-
readline__default[
|
|
104
|
-
readline__default[
|
|
103
|
+
readline__default["default"].clearLine(stdout, CLEAR_WHOLE_LINE);
|
|
104
|
+
readline__default["default"].cursorTo(stdout, 0);
|
|
105
105
|
}
|
|
106
106
|
class Reporter {
|
|
107
107
|
constructor(opts = {}) {
|
|
@@ -109,7 +109,7 @@ class Reporter {
|
|
|
109
109
|
this.stderr = process.stderr;
|
|
110
110
|
this.stdin = process.stdin;
|
|
111
111
|
this.isTTY = this.stdout.isTTY;
|
|
112
|
-
this.format = chalk__default[
|
|
112
|
+
this.format = chalk__default["default"];
|
|
113
113
|
this.startTime = Date.now();
|
|
114
114
|
this.nonInteractive = !!opts.nonInteractive;
|
|
115
115
|
this.isVerbose = !!opts.verbose;
|
|
@@ -138,10 +138,10 @@ class Reporter {
|
|
|
138
138
|
|
|
139
139
|
class Config {
|
|
140
140
|
constructor() {
|
|
141
|
-
this.cwd = path__default[
|
|
142
|
-
this.configFile = path__default[
|
|
143
|
-
this.cacheDir = cachedir__default[
|
|
144
|
-
this.agent = new https__default[
|
|
141
|
+
this.cwd = path__default["default"].resolve(process.cwd());
|
|
142
|
+
this.configFile = path__default["default"].join(os__default["default"].homedir(), ".cals-config.json");
|
|
143
|
+
this.cacheDir = cachedir__default["default"]("cals-cli");
|
|
144
|
+
this.agent = new https__default["default"].Agent({
|
|
145
145
|
keepAlive: true,
|
|
146
146
|
});
|
|
147
147
|
this.configCached = undefined;
|
|
@@ -156,12 +156,12 @@ class Config {
|
|
|
156
156
|
return config;
|
|
157
157
|
}
|
|
158
158
|
readConfig() {
|
|
159
|
-
if (!fs__default[
|
|
159
|
+
if (!fs__default["default"].existsSync(this.configFile)) {
|
|
160
160
|
return {};
|
|
161
161
|
}
|
|
162
162
|
try {
|
|
163
163
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
164
|
-
return JSON.parse(fs__default[
|
|
164
|
+
return JSON.parse(fs__default["default"].readFileSync(this.configFile, "utf-8"));
|
|
165
165
|
}
|
|
166
166
|
catch (e) {
|
|
167
167
|
console.error("Failed", e);
|
|
@@ -183,7 +183,7 @@ class Config {
|
|
|
183
183
|
...this.readConfig(),
|
|
184
184
|
[key]: value, // undefined will remove
|
|
185
185
|
};
|
|
186
|
-
fs__default[
|
|
186
|
+
fs__default["default"].writeFileSync(this.configFile, JSON.stringify(updatedConfig, null, " "));
|
|
187
187
|
this.configCached = updatedConfig;
|
|
188
188
|
}
|
|
189
189
|
}
|
|
@@ -493,7 +493,7 @@ function getRepoId(orgName, repoName) {
|
|
|
493
493
|
}
|
|
494
494
|
function checkAgainstSchema(value) {
|
|
495
495
|
var _a;
|
|
496
|
-
const ajv = new AJV__default[
|
|
496
|
+
const ajv = new AJV__default["default"]({ allErrors: true });
|
|
497
497
|
const valid = ajv.validate(schema, value);
|
|
498
498
|
return valid
|
|
499
499
|
? { definition: value }
|
|
@@ -570,7 +570,7 @@ class DefinitionFile {
|
|
|
570
570
|
this.path = path;
|
|
571
571
|
}
|
|
572
572
|
async getContents() {
|
|
573
|
-
return new Promise((resolve, reject) => fs__default[
|
|
573
|
+
return new Promise((resolve, reject) => fs__default["default"].readFile(this.path, "utf-8", (err, data) => {
|
|
574
574
|
if (err)
|
|
575
575
|
reject(err);
|
|
576
576
|
else
|
|
@@ -582,7 +582,7 @@ class DefinitionFile {
|
|
|
582
582
|
}
|
|
583
583
|
}
|
|
584
584
|
function parseDefinition(value) {
|
|
585
|
-
const result = checkAgainstSchema(yaml__default[
|
|
585
|
+
const result = checkAgainstSchema(yaml__default["default"].load(value));
|
|
586
586
|
if ("error" in result) {
|
|
587
587
|
throw new Error("Definition content invalid: " + result.error);
|
|
588
588
|
}
|
|
@@ -619,7 +619,7 @@ class GitHubTokenCliProvider {
|
|
|
619
619
|
if (process.env.CALS_GITHUB_TOKEN) {
|
|
620
620
|
return process.env.CALS_GITHUB_TOKEN;
|
|
621
621
|
}
|
|
622
|
-
const result = await keytar__default[
|
|
622
|
+
const result = await keytar__default["default"].getPassword(this.keyringService, this.keyringAccount);
|
|
623
623
|
if (result == null) {
|
|
624
624
|
process.stderr.write("No token found. Register using `cals github set-token`\n");
|
|
625
625
|
return undefined;
|
|
@@ -627,10 +627,10 @@ class GitHubTokenCliProvider {
|
|
|
627
627
|
return result;
|
|
628
628
|
}
|
|
629
629
|
async markInvalid() {
|
|
630
|
-
await keytar__default[
|
|
630
|
+
await keytar__default["default"].deletePassword(this.keyringService, this.keyringAccount);
|
|
631
631
|
}
|
|
632
632
|
async setToken(value) {
|
|
633
|
-
await keytar__default[
|
|
633
|
+
await keytar__default["default"].setPassword(this.keyringService, this.keyringAccount, value);
|
|
634
634
|
}
|
|
635
635
|
}
|
|
636
636
|
|
|
@@ -658,7 +658,7 @@ class GitHubService {
|
|
|
658
658
|
this.tokenProvider = props.tokenProvider;
|
|
659
659
|
// Control concurrency to GitHub API at service level so we
|
|
660
660
|
// can maximize concurrency all other places.
|
|
661
|
-
this.semaphore = pLimit__default[
|
|
661
|
+
this.semaphore = pLimit__default["default"](6);
|
|
662
662
|
this.octokit.hook.wrap("request", async (request, options) => {
|
|
663
663
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
664
664
|
this._requestCount++;
|
|
@@ -738,7 +738,7 @@ class GitHubService {
|
|
|
738
738
|
const headers = {
|
|
739
739
|
Authorization: `Bearer ${token}`,
|
|
740
740
|
};
|
|
741
|
-
const response = await this.semaphore(() => fetch__default[
|
|
741
|
+
const response = await this.semaphore(() => fetch__default["default"](url, {
|
|
742
742
|
method: "POST",
|
|
743
743
|
headers,
|
|
744
744
|
body: JSON.stringify({ query }),
|
|
@@ -1016,6 +1016,7 @@ class GitHubService {
|
|
|
1016
1016
|
}
|
|
1017
1017
|
edges {
|
|
1018
1018
|
node {
|
|
1019
|
+
state
|
|
1019
1020
|
dismissReason
|
|
1020
1021
|
vulnerableManifestFilename
|
|
1021
1022
|
vulnerableManifestPath
|
|
@@ -1173,7 +1174,7 @@ class LoadSecrets {
|
|
|
1173
1174
|
}
|
|
1174
1175
|
async getInput(options) {
|
|
1175
1176
|
return new Promise((resolve, reject) => {
|
|
1176
|
-
read__default[
|
|
1177
|
+
read__default["default"](options, (err, answer) => {
|
|
1177
1178
|
if (err) {
|
|
1178
1179
|
reject(err);
|
|
1179
1180
|
}
|
|
@@ -1438,7 +1439,7 @@ class SnykTokenCliProvider {
|
|
|
1438
1439
|
if (process.env.CALS_SNYK_TOKEN) {
|
|
1439
1440
|
return process.env.CALS_SNYK_TOKEN;
|
|
1440
1441
|
}
|
|
1441
|
-
const result = await keytar__default[
|
|
1442
|
+
const result = await keytar__default["default"].getPassword(this.keyringService, this.keyringAccount);
|
|
1442
1443
|
if (result == null) {
|
|
1443
1444
|
process.stderr.write("No token found. Register using `cals snyk set-token`\n");
|
|
1444
1445
|
return undefined;
|
|
@@ -1446,10 +1447,10 @@ class SnykTokenCliProvider {
|
|
|
1446
1447
|
return result;
|
|
1447
1448
|
}
|
|
1448
1449
|
async markInvalid() {
|
|
1449
|
-
await keytar__default[
|
|
1450
|
+
await keytar__default["default"].deletePassword(this.keyringService, this.keyringAccount);
|
|
1450
1451
|
}
|
|
1451
1452
|
async setToken(value) {
|
|
1452
|
-
await keytar__default[
|
|
1453
|
+
await keytar__default["default"].setPassword(this.keyringService, this.keyringAccount, value);
|
|
1453
1454
|
}
|
|
1454
1455
|
}
|
|
1455
1456
|
|
|
@@ -1471,7 +1472,7 @@ class SnykService {
|
|
|
1471
1472
|
if (token === undefined) {
|
|
1472
1473
|
throw new Error("Missing token for Snyk");
|
|
1473
1474
|
}
|
|
1474
|
-
const response = await fetch__default[
|
|
1475
|
+
const response = await fetch__default["default"](`https://snyk.io/api/v1/org/${encodeURIComponent(snykAccountId)}/projects`, {
|
|
1475
1476
|
method: "GET",
|
|
1476
1477
|
headers: {
|
|
1477
1478
|
Accept: "application/json",
|
|
@@ -1662,8 +1663,8 @@ function generateName(extra) {
|
|
|
1662
1663
|
async function createNetwork(executor) {
|
|
1663
1664
|
executor.checkCanContinue();
|
|
1664
1665
|
const networkName = generateName();
|
|
1665
|
-
await execa__default[
|
|
1666
|
-
const lsRes = await execa__default[
|
|
1666
|
+
await execa__default["default"]("docker", ["network", "create", networkName]);
|
|
1667
|
+
const lsRes = await execa__default["default"]("docker", [
|
|
1667
1668
|
"network",
|
|
1668
1669
|
"ls",
|
|
1669
1670
|
"-q",
|
|
@@ -1673,7 +1674,7 @@ async function createNetwork(executor) {
|
|
|
1673
1674
|
const networkId = lsRes.stdout.trim();
|
|
1674
1675
|
console.log(`Network ${networkName} (${networkId}) created`);
|
|
1675
1676
|
executor.registerCleanupTask(async () => {
|
|
1676
|
-
await execa__default[
|
|
1677
|
+
await execa__default["default"]("docker", ["network", "rm", networkId]);
|
|
1677
1678
|
console.log(`Network ${networkName} (${networkId}) deleted`);
|
|
1678
1679
|
});
|
|
1679
1680
|
return {
|
|
@@ -1685,7 +1686,7 @@ async function createNetwork(executor) {
|
|
|
1685
1686
|
*/
|
|
1686
1687
|
async function curl(executor, network, ...args) {
|
|
1687
1688
|
executor.checkCanContinue();
|
|
1688
|
-
const result = await execa__default[
|
|
1689
|
+
const result = await execa__default["default"]("docker", [
|
|
1689
1690
|
"run",
|
|
1690
1691
|
"-i",
|
|
1691
1692
|
"--rm",
|
|
@@ -1750,7 +1751,7 @@ async function waitForPostgresAvailable({ container, attempts = 30, waitInterval
|
|
|
1750
1751
|
attempts,
|
|
1751
1752
|
waitIntervalSec,
|
|
1752
1753
|
condition: async () => {
|
|
1753
|
-
await execa__default[
|
|
1754
|
+
await execa__default["default"]("docker", [
|
|
1754
1755
|
"exec",
|
|
1755
1756
|
"-e",
|
|
1756
1757
|
`PGPASSWORD=${password}`,
|
|
@@ -1771,7 +1772,7 @@ async function waitForPostgresAvailable({ container, attempts = 30, waitInterval
|
|
|
1771
1772
|
async function isRunning(executor, container) {
|
|
1772
1773
|
executor.checkCanContinue();
|
|
1773
1774
|
try {
|
|
1774
|
-
await execa__default[
|
|
1775
|
+
await execa__default["default"]("docker", ["inspect", container.name]);
|
|
1775
1776
|
return true;
|
|
1776
1777
|
}
|
|
1777
1778
|
catch (e) {
|
|
@@ -1826,14 +1827,14 @@ async function getContainerId({ executor, name, hasFailed, pid, }) {
|
|
|
1826
1827
|
async function check() {
|
|
1827
1828
|
let result;
|
|
1828
1829
|
try {
|
|
1829
|
-
result = (await execa__default[
|
|
1830
|
+
result = (await execa__default["default"]("docker", ["inspect", name, "-f", "{{.Id}}"]))
|
|
1830
1831
|
.stdout;
|
|
1831
1832
|
}
|
|
1832
1833
|
catch (e) {
|
|
1833
1834
|
result = null;
|
|
1834
1835
|
}
|
|
1835
1836
|
// Debugging to help us solve CALS-366.
|
|
1836
|
-
const ps = execa__default[
|
|
1837
|
+
const ps = execa__default["default"]("docker", ["ps"]);
|
|
1837
1838
|
pipeToConsole(ps, `${name} (ps)`);
|
|
1838
1839
|
await ps;
|
|
1839
1840
|
// Debugging to help us solve CALS-366.
|
|
@@ -1866,12 +1867,12 @@ async function getContainerId({ executor, name, hasFailed, pid, }) {
|
|
|
1866
1867
|
}
|
|
1867
1868
|
async function pullImage({ imageId }) {
|
|
1868
1869
|
console.log(`Pulling ${imageId}`);
|
|
1869
|
-
const process = execa__default[
|
|
1870
|
+
const process = execa__default["default"]("docker", ["pull", imageId]);
|
|
1870
1871
|
pipeToConsole(process, `pull-image (${imageId})`);
|
|
1871
1872
|
await process;
|
|
1872
1873
|
}
|
|
1873
1874
|
async function checkImageExistsLocally({ imageId, }) {
|
|
1874
|
-
const result = await execa__default[
|
|
1875
|
+
const result = await execa__default["default"]("docker", ["images", "-q", imageId]);
|
|
1875
1876
|
const found = result.stdout != "";
|
|
1876
1877
|
console.log(`image ${imageId} ${found ? "was present locally" : "was not found locally"}`);
|
|
1877
1878
|
return found;
|
|
@@ -1907,7 +1908,7 @@ async function startContainer({ executor, network, imageId, alias, env, dockerAr
|
|
|
1907
1908
|
}
|
|
1908
1909
|
args.push(imageId);
|
|
1909
1910
|
console.log(`Starting ${imageId}`);
|
|
1910
|
-
const process = execa__default[
|
|
1911
|
+
const process = execa__default["default"]("docker", args);
|
|
1911
1912
|
pipeToConsole(process, alias !== null && alias !== void 0 ? alias : containerName);
|
|
1912
1913
|
let failed = false;
|
|
1913
1914
|
process.catch(() => {
|
|
@@ -1921,7 +1922,7 @@ async function startContainer({ executor, network, imageId, alias, env, dockerAr
|
|
|
1921
1922
|
});
|
|
1922
1923
|
executor.registerCleanupTask(async () => {
|
|
1923
1924
|
console.log(`Stopping container ${containerName}`);
|
|
1924
|
-
const r = execa__default[
|
|
1925
|
+
const r = execa__default["default"]("docker", ["stop", containerName]);
|
|
1925
1926
|
pipeToConsole(r, (alias !== null && alias !== void 0 ? alias : containerName) + " (stop)");
|
|
1926
1927
|
try {
|
|
1927
1928
|
await r;
|
|
@@ -1942,7 +1943,7 @@ async function startContainer({ executor, network, imageId, alias, env, dockerAr
|
|
|
1942
1943
|
};
|
|
1943
1944
|
}
|
|
1944
1945
|
async function runNpmRunScript(name, options) {
|
|
1945
|
-
const result = execa__default[
|
|
1946
|
+
const result = execa__default["default"]("npm", ["run", name], {
|
|
1946
1947
|
env: options === null || options === void 0 ? void 0 : options.env,
|
|
1947
1948
|
});
|
|
1948
1949
|
pipeToConsole(result, `npm run ${name}`);
|
|
@@ -1955,8 +1956,8 @@ async function getDockerHostAddress() {
|
|
|
1955
1956
|
if (process.platform === "darwin" || process.platform === "win32") {
|
|
1956
1957
|
return "host.docker.internal";
|
|
1957
1958
|
}
|
|
1958
|
-
if (fs__default[
|
|
1959
|
-
const process = execa__default[
|
|
1959
|
+
if (fs__default["default"].existsSync("/.dockerenv")) {
|
|
1960
|
+
const process = execa__default["default"]("ip", ["route"]);
|
|
1960
1961
|
pipeToConsole(process, "ip route");
|
|
1961
1962
|
const res = await process;
|
|
1962
1963
|
try {
|
|
@@ -1974,7 +1975,7 @@ async function getDockerHostAddress() {
|
|
|
1974
1975
|
}
|
|
1975
1976
|
async function waitForEnterToContinue(prompt = "Press enter to continue") {
|
|
1976
1977
|
return new Promise((resolve, reject) => {
|
|
1977
|
-
read__default[
|
|
1978
|
+
read__default["default"]({
|
|
1978
1979
|
prompt,
|
|
1979
1980
|
silent: true,
|
|
1980
1981
|
}, (err) => {
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capraconsulting/cals-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.24.0",
|
|
4
4
|
"description": "CLI for repeatable tasks in CALS",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepare": "node scripts/create-definition-schema.js && husky install",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"execa": "^5.0.0",
|
|
31
31
|
"find-up": "^5.0.0",
|
|
32
32
|
"js-yaml": "^4.0.0",
|
|
33
|
-
"keytar": "^7.
|
|
33
|
+
"keytar": "^7.8.0",
|
|
34
34
|
"lodash": "^4.17.15",
|
|
35
35
|
"node-fetch": "^2.6.0",
|
|
36
36
|
"p-limit": "^3.0.0",
|
|
@@ -42,41 +42,41 @@
|
|
|
42
42
|
"yargs": "^17.0.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@commitlint/cli": "
|
|
46
|
-
"@commitlint/config-conventional": "
|
|
45
|
+
"@commitlint/cli": "16.2.1",
|
|
46
|
+
"@commitlint/config-conventional": "16.2.1",
|
|
47
47
|
"@octokit/types": "6.16.7",
|
|
48
|
-
"@rollup/plugin-alias": "3.1.
|
|
48
|
+
"@rollup/plugin-alias": "3.1.9",
|
|
49
49
|
"@rollup/plugin-json": "4.1.0",
|
|
50
|
-
"@rollup/plugin-replace": "
|
|
51
|
-
"@types/jest": "27.0
|
|
52
|
-
"@types/js-yaml": "4.0.
|
|
53
|
-
"@types/lodash": "4.14.
|
|
54
|
-
"@types/node": "14.
|
|
55
|
-
"@types/node-fetch": "2.
|
|
50
|
+
"@rollup/plugin-replace": "3.1.0",
|
|
51
|
+
"@types/jest": "27.4.0",
|
|
52
|
+
"@types/js-yaml": "4.0.5",
|
|
53
|
+
"@types/lodash": "4.14.178",
|
|
54
|
+
"@types/node": "14.18.12",
|
|
55
|
+
"@types/node-fetch": "2.6.1",
|
|
56
56
|
"@types/read": "0.0.29",
|
|
57
57
|
"@types/rimraf": "3.0.2",
|
|
58
|
-
"@types/semver": "7.3.
|
|
58
|
+
"@types/semver": "7.3.9",
|
|
59
59
|
"@types/sprintf-js": "1.1.2",
|
|
60
|
-
"@types/yargs": "17.0.
|
|
61
|
-
"@typescript-eslint/eslint-plugin": "
|
|
62
|
-
"@typescript-eslint/parser": "
|
|
63
|
-
"dateformat": "4.
|
|
60
|
+
"@types/yargs": "17.0.8",
|
|
61
|
+
"@typescript-eslint/eslint-plugin": "5.12.0",
|
|
62
|
+
"@typescript-eslint/parser": "5.12.0",
|
|
63
|
+
"dateformat": "4.6.3",
|
|
64
64
|
"del": "6.0.0",
|
|
65
|
-
"eslint": "
|
|
66
|
-
"eslint-config-prettier": "8.
|
|
67
|
-
"eslint-plugin-deprecation": "1.2.1",
|
|
65
|
+
"eslint": "8.9.0",
|
|
66
|
+
"eslint-config-prettier": "8.4.0",
|
|
68
67
|
"eslint-plugin-prettier": "4.0.0",
|
|
69
|
-
"husky": "7.0.
|
|
70
|
-
"jest": "27.
|
|
71
|
-
"prettier": "2.
|
|
72
|
-
"rollup": "2.
|
|
73
|
-
"rollup-plugin-typescript2": "0.
|
|
74
|
-
"semantic-release": "
|
|
68
|
+
"husky": "7.0.4",
|
|
69
|
+
"jest": "27.5.1",
|
|
70
|
+
"prettier": "2.5.1",
|
|
71
|
+
"rollup": "2.67.3",
|
|
72
|
+
"rollup-plugin-typescript2": "0.31.2",
|
|
73
|
+
"semantic-release": "19.0.2",
|
|
75
74
|
"tempy": "1.0.1",
|
|
76
|
-
"ts-jest": "27.
|
|
77
|
-
"typescript": "4.
|
|
78
|
-
"typescript-json-schema": "0.
|
|
75
|
+
"ts-jest": "27.1.3",
|
|
76
|
+
"typescript": "4.5.5",
|
|
77
|
+
"typescript-json-schema": "0.53.0"
|
|
79
78
|
},
|
|
79
|
+
"peerDependencies": {},
|
|
80
80
|
"files": [
|
|
81
81
|
"lib/**/*"
|
|
82
82
|
],
|