@capraconsulting/cals-cli 3.11.4 → 3.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cache.d.ts +1 -1
- package/lib/cals-cli.mjs +84 -105
- package/lib/cals-cli.mjs.map +1 -1
- package/lib/cli/commands/definition/dump-setup.d.ts +1 -1
- package/lib/cli/commands/definition/validate.d.ts +1 -1
- package/lib/cli/commands/definition.d.ts +1 -1
- package/lib/cli/commands/delete-cache.d.ts +1 -1
- package/lib/cli/commands/getting-started.d.ts +1 -1
- package/lib/cli/commands/github/analyze-directory.d.ts +1 -1
- package/lib/cli/commands/github/configure.d.ts +1 -1
- package/lib/cli/commands/github/generate-clone-commands.d.ts +1 -1
- package/lib/cli/commands/github/list-pull-requests-stats.d.ts +1 -1
- package/lib/cli/commands/github/list-repos.d.ts +1 -1
- package/lib/cli/commands/github/list-webhooks.d.ts +1 -1
- package/lib/cli/commands/github/set-token.d.ts +1 -1
- package/lib/cli/commands/github/sync.d.ts +2 -2
- package/lib/cli/commands/github/util.d.ts +2 -2
- package/lib/cli/commands/github.d.ts +1 -1
- package/lib/cli/commands/snyk/report.d.ts +1 -1
- package/lib/cli/commands/snyk/set-token.d.ts +1 -1
- package/lib/cli/commands/snyk/sync.d.ts +1 -1
- package/lib/cli/commands/snyk.d.ts +1 -1
- package/lib/cli/util.d.ts +1 -1
- package/lib/config.d.ts +1 -1
- package/lib/definition/definition.d.ts +1 -1
- package/lib/definition/types.d.ts +1 -1
- package/lib/github/changeset/changeset.d.ts +4 -4
- package/lib/github/changeset/execute.d.ts +3 -3
- package/lib/github/changeset/types.d.ts +1 -1
- package/lib/github/index.d.ts +1 -1
- package/lib/github/service.d.ts +4 -4
- package/lib/github/types.d.ts +1 -1
- package/lib/github/util.d.ts +1 -1
- package/lib/index.es.js +32 -51
- package/lib/index.es.js.map +1 -1
- package/lib/index.js +32 -51
- package/lib/index.js.map +1 -1
- package/lib/snyk/service.d.ts +4 -4
- package/lib/snyk/util.d.ts +1 -1
- package/lib/sonarcloud/index.d.ts +1 -1
- package/lib/sonarcloud/service.d.ts +2 -2
- package/lib/testing/lib.d.ts +1 -1
- package/package.json +16 -23
package/lib/cache.d.ts
CHANGED
package/lib/cals-cli.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import process$2 from 'node:process';
|
|
2
3
|
import semver from 'semver';
|
|
3
4
|
import yargs from 'yargs';
|
|
4
5
|
import { hideBin } from 'yargs/helpers';
|
|
@@ -6,31 +7,50 @@ import fs from 'node:fs';
|
|
|
6
7
|
import yaml from 'js-yaml';
|
|
7
8
|
import pMap from 'p-map';
|
|
8
9
|
import AJV from 'ajv';
|
|
10
|
+
import { Buffer } from 'node:buffer';
|
|
11
|
+
import { performance } from 'node:perf_hooks';
|
|
9
12
|
import { Octokit } from '@octokit/rest';
|
|
10
13
|
import fetch from 'node-fetch';
|
|
11
14
|
import pLimit from 'p-limit';
|
|
12
|
-
import keytar from 'keytar';
|
|
13
|
-
import process$2 from 'node:process';
|
|
14
15
|
import * as process$1 from 'process';
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import
|
|
18
|
-
import
|
|
16
|
+
import keytar from 'keytar';
|
|
17
|
+
import { deprecate } from 'node:util';
|
|
18
|
+
import path from 'node:path';
|
|
19
|
+
import https from 'node:https';
|
|
20
|
+
import os from 'node:os';
|
|
19
21
|
import cachedir from 'cachedir';
|
|
20
|
-
import
|
|
21
|
-
import os from 'os';
|
|
22
|
+
import readline from 'node:readline';
|
|
22
23
|
import chalk from 'chalk';
|
|
23
|
-
import readline from 'readline';
|
|
24
24
|
import { sprintf } from 'sprintf-js';
|
|
25
25
|
import { read } from 'read';
|
|
26
26
|
import { findUp } from 'find-up';
|
|
27
27
|
import { execa } from 'execa';
|
|
28
28
|
|
|
29
|
-
var version = "3.
|
|
29
|
+
var version = "3.12.1";
|
|
30
30
|
var engines = {
|
|
31
31
|
node: ">=12.0.0"
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
+
function groupBy(array, iteratee) {
|
|
35
|
+
return array.reduce((result, item) => {
|
|
36
|
+
const key = iteratee(item);
|
|
37
|
+
if (!result[key]) {
|
|
38
|
+
result[key] = [];
|
|
39
|
+
}
|
|
40
|
+
result[key].push(item);
|
|
41
|
+
return result;
|
|
42
|
+
}, {});
|
|
43
|
+
}
|
|
44
|
+
function uniq(array) {
|
|
45
|
+
return Array.from(new Set(array));
|
|
46
|
+
}
|
|
47
|
+
function sortBy(arr, getKey) {
|
|
48
|
+
return [...arr].sort((a, b) => getKey(a).localeCompare(getKey(b)));
|
|
49
|
+
}
|
|
50
|
+
function sumBy(array, iteratee) {
|
|
51
|
+
return array.reduce((sum, item) => sum + iteratee(item), 0);
|
|
52
|
+
}
|
|
53
|
+
|
|
34
54
|
var type = "object";
|
|
35
55
|
var properties = {
|
|
36
56
|
snyk: {
|
|
@@ -325,26 +345,6 @@ var schema = {
|
|
|
325
345
|
$schema: $schema
|
|
326
346
|
};
|
|
327
347
|
|
|
328
|
-
function groupBy(array, iteratee) {
|
|
329
|
-
return array.reduce((result, item) => {
|
|
330
|
-
const key = iteratee(item);
|
|
331
|
-
if (!result[key]) {
|
|
332
|
-
result[key] = [];
|
|
333
|
-
}
|
|
334
|
-
result[key].push(item);
|
|
335
|
-
return result;
|
|
336
|
-
}, {});
|
|
337
|
-
}
|
|
338
|
-
function uniq(array) {
|
|
339
|
-
return Array.from(new Set(array));
|
|
340
|
-
}
|
|
341
|
-
function sortBy(arr, getKey) {
|
|
342
|
-
return [...arr].sort((a, b) => getKey(a).localeCompare(getKey(b)));
|
|
343
|
-
}
|
|
344
|
-
function sumBy(array, iteratee) {
|
|
345
|
-
return array.reduce((sum, item) => sum + iteratee(item), 0);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
348
|
function getTeamId(org, teamName) {
|
|
349
349
|
return `${org}/${teamName}`;
|
|
350
350
|
}
|
|
@@ -378,8 +378,7 @@ function requireValidDefinition(definition) {
|
|
|
378
378
|
}, []);
|
|
379
379
|
// Verify team members exists as users.
|
|
380
380
|
definition.github.teams
|
|
381
|
-
.
|
|
382
|
-
.flat()
|
|
381
|
+
.flatMap((it) => it.teams)
|
|
383
382
|
.forEach((team) => {
|
|
384
383
|
team.members.forEach((login) => {
|
|
385
384
|
if (!loginList.includes(login)) {
|
|
@@ -415,9 +414,7 @@ function requireValidDefinition(definition) {
|
|
|
415
414
|
});
|
|
416
415
|
// Verify no duplicates in repos.
|
|
417
416
|
definition.projects
|
|
418
|
-
.flatMap((project) => project.github
|
|
419
|
-
.map((org) => (org.repos || []).map((repo) => getRepoId(org.organization, repo.name)))
|
|
420
|
-
.flat())
|
|
417
|
+
.flatMap((project) => project.github.flatMap((org) => (org.repos || []).map((repo) => getRepoId(org.organization, repo.name))))
|
|
421
418
|
.reduce((acc, repoName) => {
|
|
422
419
|
if (acc.includes(repoName)) {
|
|
423
420
|
throw new Error(`Duplicate repo: ${repoName}`);
|
|
@@ -445,20 +442,18 @@ class DefinitionFile {
|
|
|
445
442
|
function parseDefinition(value) {
|
|
446
443
|
const result = checkAgainstSchema(yaml.load(value));
|
|
447
444
|
if ("error" in result) {
|
|
448
|
-
throw new Error(
|
|
445
|
+
throw new Error(`Definition content invalid: ${result.error}`);
|
|
449
446
|
}
|
|
450
447
|
requireValidDefinition(result.definition);
|
|
451
448
|
return result.definition;
|
|
452
449
|
}
|
|
453
450
|
function getRepos(definition) {
|
|
454
|
-
return definition.projects.flatMap((project) => project.github
|
|
455
|
-
.map((org) => (org.repos || []).map((repo) => ({
|
|
451
|
+
return definition.projects.flatMap((project) => project.github.flatMap((org) => (org.repos || []).map((repo) => ({
|
|
456
452
|
id: getRepoId(org.organization, repo.name),
|
|
457
453
|
orgName: org.organization,
|
|
458
454
|
project,
|
|
459
455
|
repo,
|
|
460
|
-
})))
|
|
461
|
-
.flat());
|
|
456
|
+
}))));
|
|
462
457
|
}
|
|
463
458
|
function getGitHubOrgs(definition) {
|
|
464
459
|
const githubOrganizations = definition.projects.flatMap((project) => project.github.map((it) => it.organization));
|
|
@@ -537,13 +532,10 @@ async function undefinedForNotFound(value) {
|
|
|
537
532
|
return await value;
|
|
538
533
|
}
|
|
539
534
|
catch (e) {
|
|
540
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
541
535
|
if (e.name === "HttpError" && e.status === 404) {
|
|
542
536
|
return undefined;
|
|
543
537
|
}
|
|
544
|
-
|
|
545
|
-
throw e;
|
|
546
|
-
}
|
|
538
|
+
throw e;
|
|
547
539
|
}
|
|
548
540
|
}
|
|
549
541
|
|
|
@@ -562,17 +554,14 @@ class GitHubService {
|
|
|
562
554
|
// can maximize concurrency all other places.
|
|
563
555
|
this.semaphore = pLimit(6);
|
|
564
556
|
this.octokit.hook.wrap("request", async (request, options) => {
|
|
565
|
-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
566
557
|
this._requestCount++;
|
|
567
558
|
if (options.method !== "GET") {
|
|
568
559
|
return this.semaphore(() => request(options));
|
|
569
560
|
}
|
|
570
561
|
// Try to cache ETag for GET requests to save on rate limiting.
|
|
571
562
|
// Hits on ETag does not count towards rate limiting.
|
|
572
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
573
563
|
const rest = {
|
|
574
564
|
...options,
|
|
575
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
576
565
|
};
|
|
577
566
|
delete rest.method;
|
|
578
567
|
delete rest.baseUrl;
|
|
@@ -623,7 +612,6 @@ class GitHubService {
|
|
|
623
612
|
});
|
|
624
613
|
}
|
|
625
614
|
return response;
|
|
626
|
-
/* eslint-enable @typescript-eslint/no-unsafe-member-access */
|
|
627
615
|
});
|
|
628
616
|
}
|
|
629
617
|
_requestCount = 0;
|
|
@@ -663,11 +651,11 @@ class GitHubService {
|
|
|
663
651
|
throw new Error(`Response from GitHub not OK (${response.status}): ${await response.text()}`);
|
|
664
652
|
}
|
|
665
653
|
const json = (await response.json());
|
|
666
|
-
if (
|
|
654
|
+
if (json.errors) {
|
|
667
655
|
throw new Error(`Error from GitHub GraphQL API: ${JSON.stringify(json.errors)}`);
|
|
668
656
|
}
|
|
669
657
|
if (json.data == null) {
|
|
670
|
-
throw new Error(
|
|
658
|
+
throw new Error("No data received from GitHub GraphQL API (unknown reason)");
|
|
671
659
|
}
|
|
672
660
|
return json.data;
|
|
673
661
|
}
|
|
@@ -900,7 +888,6 @@ class GitHubService {
|
|
|
900
888
|
return true;
|
|
901
889
|
}
|
|
902
890
|
catch (e) {
|
|
903
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
904
891
|
if (e.status === 404) {
|
|
905
892
|
return false;
|
|
906
893
|
}
|
|
@@ -1168,8 +1155,7 @@ function getGitHubRepo(snykProject) {
|
|
|
1168
1155
|
name: match[2],
|
|
1169
1156
|
};
|
|
1170
1157
|
}
|
|
1171
|
-
|
|
1172
|
-
snykProject.remoteRepoUrl != null) {
|
|
1158
|
+
if (snykProject.origin === "cli" && snykProject.remoteRepoUrl != null) {
|
|
1173
1159
|
// The remoteRepoUrl can be overridden when using the CLI, so don't
|
|
1174
1160
|
// fail if we cannot extract the value.
|
|
1175
1161
|
const match = /github.com\/([^/]+)\/(.+)\.git$/.exec(snykProject.remoteRepoUrl);
|
|
@@ -1181,9 +1167,7 @@ function getGitHubRepo(snykProject) {
|
|
|
1181
1167
|
name: match[2],
|
|
1182
1168
|
};
|
|
1183
1169
|
}
|
|
1184
|
-
|
|
1185
|
-
return undefined;
|
|
1186
|
-
}
|
|
1170
|
+
return undefined;
|
|
1187
1171
|
}
|
|
1188
1172
|
function getGitHubRepoId(repo) {
|
|
1189
1173
|
return repo ? `${repo.owner}/${repo.name}` : undefined;
|
|
@@ -1226,7 +1210,7 @@ class CacheProvider {
|
|
|
1226
1210
|
const cacheItem = this.mustValidate
|
|
1227
1211
|
? undefined
|
|
1228
1212
|
: this.retrieveJson(cachekey);
|
|
1229
|
-
const expire = new Date(
|
|
1213
|
+
const expire = new Date(Date.now() - cachetime * 1000).getTime();
|
|
1230
1214
|
if (cacheItem !== undefined && cacheItem.cacheTime > expire) {
|
|
1231
1215
|
return cacheItem.data;
|
|
1232
1216
|
}
|
|
@@ -1264,7 +1248,6 @@ class Config {
|
|
|
1264
1248
|
return {};
|
|
1265
1249
|
}
|
|
1266
1250
|
try {
|
|
1267
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
1268
1251
|
return JSON.parse(fs.readFileSync(this.configFile, "utf-8"));
|
|
1269
1252
|
}
|
|
1270
1253
|
catch (e) {
|
|
@@ -1575,7 +1558,7 @@ function buildGitHubUsersList(definition, members) {
|
|
|
1575
1558
|
});
|
|
1576
1559
|
return reorderListToSimilarAsBefore(definition.github.users, result, (it) => it.login);
|
|
1577
1560
|
}
|
|
1578
|
-
async function dumpSetup(
|
|
1561
|
+
async function dumpSetup(_config, reporter, github, snyk, outfile, definitionFile) {
|
|
1579
1562
|
reporter.info("Fetching data. This might take some time");
|
|
1580
1563
|
const definition = await definitionFile.getDefinition();
|
|
1581
1564
|
const orgs = await getOrgs(github, getGitHubOrgs(definition));
|
|
@@ -1593,13 +1576,9 @@ async function dumpSetup(config, reporter, github, snyk, outfile, definitionFile
|
|
|
1593
1576
|
// TODO: An earlier version we had preserved comments by using yawn-yaml
|
|
1594
1577
|
// package. However it often produced invalid yaml, so we have removed
|
|
1595
1578
|
// it. We might want to revisit it to preserve comments.
|
|
1596
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-explicit-any
|
|
1597
1579
|
const doc = yaml.load(await definitionFile.getContents());
|
|
1598
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
1599
1580
|
doc.snyk = generatedDefinition.snyk;
|
|
1600
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
1601
1581
|
doc.projects = generatedDefinition.projects;
|
|
1602
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
1603
1582
|
doc.github = generatedDefinition.github;
|
|
1604
1583
|
// Convert to/from plain JSON so that undefined elements are removed.
|
|
1605
1584
|
fs.writeFileSync(outfile, yaml.dump(JSON.parse(JSON.stringify(doc))));
|
|
@@ -1645,7 +1624,7 @@ const command$f = {
|
|
|
1645
1624
|
.command(command$h)
|
|
1646
1625
|
.command(command$g)
|
|
1647
1626
|
.demandCommand()
|
|
1648
|
-
.usage(
|
|
1627
|
+
.usage("cals definition"),
|
|
1649
1628
|
handler: () => {
|
|
1650
1629
|
yargs(hideBin(process$2.argv)).showHelp();
|
|
1651
1630
|
},
|
|
@@ -1717,7 +1696,7 @@ const command$c = {
|
|
|
1717
1696
|
cache: createCacheProvider(config, argv),
|
|
1718
1697
|
});
|
|
1719
1698
|
const reporter = createReporter(argv);
|
|
1720
|
-
return analyzeDirectory(reporter, config, github, argv
|
|
1699
|
+
return analyzeDirectory(reporter, config, github, argv.org);
|
|
1721
1700
|
},
|
|
1722
1701
|
};
|
|
1723
1702
|
|
|
@@ -2070,27 +2049,28 @@ async function executeChangeSetItem(github, changeItem, reporter, lookup) {
|
|
|
2070
2049
|
username: changeItem.user,
|
|
2071
2050
|
});
|
|
2072
2051
|
return true;
|
|
2073
|
-
case "repo-update":
|
|
2052
|
+
case "repo-update": {
|
|
2074
2053
|
const upd = {
|
|
2075
2054
|
owner: changeItem.org,
|
|
2076
2055
|
repo: changeItem.repo,
|
|
2077
2056
|
};
|
|
2078
2057
|
for (const attrib of changeItem.attribs) {
|
|
2079
2058
|
if ("archived" in attrib) {
|
|
2080
|
-
upd.archived = attrib
|
|
2059
|
+
upd.archived = attrib.archived;
|
|
2081
2060
|
}
|
|
2082
2061
|
else if ("issues" in attrib) {
|
|
2083
|
-
upd.has_issues = attrib
|
|
2062
|
+
upd.has_issues = attrib.issues;
|
|
2084
2063
|
}
|
|
2085
2064
|
else if ("wiki" in attrib) {
|
|
2086
|
-
upd.has_wiki = attrib
|
|
2065
|
+
upd.has_wiki = attrib.wiki;
|
|
2087
2066
|
}
|
|
2088
2067
|
else if ("private" in attrib) {
|
|
2089
|
-
upd.private = attrib
|
|
2068
|
+
upd.private = attrib.private;
|
|
2090
2069
|
}
|
|
2091
2070
|
}
|
|
2092
2071
|
await github.octokit.repos.update(upd);
|
|
2093
2072
|
return true;
|
|
2073
|
+
}
|
|
2094
2074
|
case "repo-team-remove":
|
|
2095
2075
|
await github.octokit.teams.removeRepoInOrg({
|
|
2096
2076
|
org: changeItem.org,
|
|
@@ -2135,18 +2115,16 @@ function createOrgGetter(github) {
|
|
|
2135
2115
|
}
|
|
2136
2116
|
return semaphores[orgName];
|
|
2137
2117
|
}
|
|
2138
|
-
return async
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
});
|
|
2149
|
-
};
|
|
2118
|
+
return async (orgName) => await getSemaphore(orgName)(async () => {
|
|
2119
|
+
if (!(orgName in orgs)) {
|
|
2120
|
+
const org = await github.getOrg(orgName);
|
|
2121
|
+
orgs[orgName] = {
|
|
2122
|
+
org,
|
|
2123
|
+
teams: await github.getTeamList(org),
|
|
2124
|
+
};
|
|
2125
|
+
}
|
|
2126
|
+
return orgs[orgName];
|
|
2127
|
+
});
|
|
2150
2128
|
}
|
|
2151
2129
|
async function process(reporter, github, definition, getOrg, execute, limitToOrg) {
|
|
2152
2130
|
let changes = [];
|
|
@@ -2174,16 +2152,16 @@ async function process(reporter, github, definition, getOrg, execute, limitToOrg
|
|
|
2174
2152
|
if (ignored.length > 0) {
|
|
2175
2153
|
reporter.info("Not implemented:");
|
|
2176
2154
|
for (const change of ignored) {
|
|
2177
|
-
reporter.info(
|
|
2155
|
+
reporter.info(` - ${JSON.stringify(change)}`);
|
|
2178
2156
|
}
|
|
2179
2157
|
}
|
|
2180
2158
|
if (changes.length === 0) {
|
|
2181
|
-
reporter.info(
|
|
2159
|
+
reporter.info("No actions to be performed");
|
|
2182
2160
|
}
|
|
2183
2161
|
else {
|
|
2184
|
-
reporter.info(
|
|
2162
|
+
reporter.info("To be performed:");
|
|
2185
2163
|
for (const change of changes) {
|
|
2186
|
-
reporter.info(
|
|
2164
|
+
reporter.info(` - ${JSON.stringify(change)}`);
|
|
2187
2165
|
}
|
|
2188
2166
|
}
|
|
2189
2167
|
if (execute && changes.length > 0) {
|
|
@@ -2224,7 +2202,7 @@ const command$b = {
|
|
|
2224
2202
|
const definition = await getDefinitionFile(argv).getDefinition();
|
|
2225
2203
|
await reportRateLimit(reporter, github, async () => {
|
|
2226
2204
|
const orgGetter = createOrgGetter(github);
|
|
2227
|
-
await process(reporter, github, definition, orgGetter, !!argv
|
|
2205
|
+
await process(reporter, github, definition, orgGetter, !!argv.execute, argv.org);
|
|
2228
2206
|
});
|
|
2229
2207
|
},
|
|
2230
2208
|
};
|
|
@@ -2315,7 +2293,7 @@ const command$a = {
|
|
|
2315
2293
|
topic: argv.topic,
|
|
2316
2294
|
excludeExisting: !!argv["exclude-existing"],
|
|
2317
2295
|
group: argv.group,
|
|
2318
|
-
org: argv
|
|
2296
|
+
org: argv.org,
|
|
2319
2297
|
});
|
|
2320
2298
|
},
|
|
2321
2299
|
};
|
|
@@ -2324,7 +2302,7 @@ async function listPullRequestsStats({ reporter, github, }) {
|
|
|
2324
2302
|
// This is only an initial attempt to get some insights into
|
|
2325
2303
|
// open pull requests. Feel free to change.
|
|
2326
2304
|
const pulls = await github.getSearchedPullRequestList("capralifecycle");
|
|
2327
|
-
const cutoffOld = new Date(
|
|
2305
|
+
const cutoffOld = new Date(Date.now() - 86400 * 1000 * 60);
|
|
2328
2306
|
const categories = pulls
|
|
2329
2307
|
.reduce((acc, cur) => {
|
|
2330
2308
|
const key = `${cur.baseRepository.owner.login}/${cur.baseRepository.name}`;
|
|
@@ -2502,13 +2480,13 @@ const command$8 = {
|
|
|
2502
2480
|
topic: argv.topic,
|
|
2503
2481
|
compact: !!argv.compact,
|
|
2504
2482
|
csv: !!argv.csv,
|
|
2505
|
-
org: argv
|
|
2483
|
+
org: argv.org,
|
|
2506
2484
|
});
|
|
2507
2485
|
},
|
|
2508
2486
|
};
|
|
2509
2487
|
|
|
2510
2488
|
const e = encodeURIComponent;
|
|
2511
|
-
async function listWebhooks(reporter,
|
|
2489
|
+
async function listWebhooks(reporter, _cache, github, org) {
|
|
2512
2490
|
const repos = (await github.getOrgRepoList({ org })).filter((it) => !it.isArchived);
|
|
2513
2491
|
for (const repo of repos) {
|
|
2514
2492
|
reporter.log("");
|
|
@@ -2549,7 +2527,7 @@ const command$7 = {
|
|
|
2549
2527
|
handler: async (argv) => {
|
|
2550
2528
|
const config = createConfig();
|
|
2551
2529
|
const cacheProvider = createCacheProvider(config, argv);
|
|
2552
|
-
await listWebhooks(createReporter(argv), cacheProvider, await createGitHubService({ config, cache: cacheProvider }), argv
|
|
2530
|
+
await listWebhooks(createReporter(argv), cacheProvider, await createGitHubService({ config, cache: cacheProvider }), argv.org);
|
|
2553
2531
|
},
|
|
2554
2532
|
};
|
|
2555
2533
|
|
|
@@ -2605,7 +2583,7 @@ function parseShortlogSummary(value) {
|
|
|
2605
2583
|
const matches = [...value.matchAll(/^\s*(\d+)\s+(.+)$/gm)];
|
|
2606
2584
|
return matches.map((it) => ({
|
|
2607
2585
|
name: it[2],
|
|
2608
|
-
count: parseInt(it[1]),
|
|
2586
|
+
count: Number.parseInt(it[1]),
|
|
2609
2587
|
}));
|
|
2610
2588
|
}
|
|
2611
2589
|
|
|
@@ -2636,7 +2614,6 @@ class GitRepo {
|
|
|
2636
2614
|
await this.logCommand(result);
|
|
2637
2615
|
}
|
|
2638
2616
|
catch (e) {
|
|
2639
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
2640
2617
|
await this.logCommand(e);
|
|
2641
2618
|
throw e;
|
|
2642
2619
|
}
|
|
@@ -2650,7 +2627,6 @@ class GitRepo {
|
|
|
2650
2627
|
return result;
|
|
2651
2628
|
}
|
|
2652
2629
|
catch (e) {
|
|
2653
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
2654
2630
|
await this.logCommand(e);
|
|
2655
2631
|
throw e;
|
|
2656
2632
|
}
|
|
@@ -2771,9 +2747,7 @@ function formatAuthorAndCount(reporter, name, count) {
|
|
|
2771
2747
|
if (isBotAuthor(name)) {
|
|
2772
2748
|
return reporter.format.grey(text);
|
|
2773
2749
|
}
|
|
2774
|
-
|
|
2775
|
-
return reporter.format.greenBright(text);
|
|
2776
|
-
}
|
|
2750
|
+
return reporter.format.greenBright(text);
|
|
2777
2751
|
}
|
|
2778
2752
|
async function updateRepos(reporter, foundRepos) {
|
|
2779
2753
|
const updateResults = await updateReposInParallel(reporter, foundRepos);
|
|
@@ -2860,12 +2834,12 @@ function getExpectedRepo(item) {
|
|
|
2860
2834
|
}
|
|
2861
2835
|
function getGitRepo(rootdir, relpath) {
|
|
2862
2836
|
return new GitRepo(path.resolve(rootdir, relpath), async (result) => {
|
|
2863
|
-
await appendFile(path.resolve(rootdir, CALS_LOG), JSON.stringify({
|
|
2837
|
+
await appendFile(path.resolve(rootdir, CALS_LOG), `${JSON.stringify({
|
|
2864
2838
|
time: new Date().toISOString(),
|
|
2865
2839
|
context: relpath,
|
|
2866
2840
|
type: "exec-result",
|
|
2867
2841
|
payload: result,
|
|
2868
|
-
})
|
|
2842
|
+
})}\n`);
|
|
2869
2843
|
});
|
|
2870
2844
|
}
|
|
2871
2845
|
function getDefinitionRepo(rootdir, reposInOrg, cals) {
|
|
@@ -3067,7 +3041,6 @@ async function loadCalsManifest(config, reporter) {
|
|
|
3067
3041
|
}
|
|
3068
3042
|
// TODO: Verify file has expected contents.
|
|
3069
3043
|
// (Can we easily generate schema for type and verify?)
|
|
3070
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-explicit-any
|
|
3071
3044
|
const cals = yaml.load(fs.readFileSync(p, "utf-8"));
|
|
3072
3045
|
if (cals.version !== 2) {
|
|
3073
3046
|
throw new Error(`Unexpected version in ${p}`);
|
|
@@ -3089,7 +3062,8 @@ const command$5 = {
|
|
|
3089
3062
|
.option("ask-move", {
|
|
3090
3063
|
describe: "Ask to actual move renamed repos",
|
|
3091
3064
|
type: "boolean",
|
|
3092
|
-
})
|
|
3065
|
+
})
|
|
3066
|
+
.usage(`cals github sync
|
|
3093
3067
|
|
|
3094
3068
|
Synchronize all checked out GitHub repositories within the working directory
|
|
3095
3069
|
grouped by the project in the resource definition file. The command can also
|
|
@@ -3157,7 +3131,8 @@ const command$4 = {
|
|
|
3157
3131
|
.command(command$7)
|
|
3158
3132
|
.command(command$6)
|
|
3159
3133
|
.command(command$5)
|
|
3160
|
-
.demandCommand()
|
|
3134
|
+
.demandCommand()
|
|
3135
|
+
.usage(`cals github
|
|
3161
3136
|
|
|
3162
3137
|
Notes:
|
|
3163
3138
|
Before doing anything against GitHub you need to configure a token
|
|
@@ -3311,7 +3286,11 @@ const command$1 = {
|
|
|
3311
3286
|
const command = {
|
|
3312
3287
|
command: "snyk",
|
|
3313
3288
|
describe: "Integration with Snyk",
|
|
3314
|
-
builder: (yargs) => yargs
|
|
3289
|
+
builder: (yargs) => yargs
|
|
3290
|
+
.command(command$2)
|
|
3291
|
+
.command(command$3)
|
|
3292
|
+
.command(command$1)
|
|
3293
|
+
.demandCommand()
|
|
3315
3294
|
.usage(`cals snyk
|
|
3316
3295
|
|
|
3317
3296
|
Notes:
|
|
@@ -3330,7 +3309,7 @@ async function main() {
|
|
|
3330
3309
|
process$2.exit(1);
|
|
3331
3310
|
}
|
|
3332
3311
|
await yargs(hideBin(process$2.argv))
|
|
3333
|
-
.usage(`cals-cli v${version} (build: ${"2025-
|
|
3312
|
+
.usage(`cals-cli v${version} (build: ${"2025-08-07T05:46:58+0000"})`)
|
|
3334
3313
|
.scriptName("cals")
|
|
3335
3314
|
.locale("en")
|
|
3336
3315
|
.help("help")
|
package/lib/cals-cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cals-cli.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cals-cli.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { GitHubService } from "../../../github";
|
|
2
|
-
import { Reporter } from "../../reporter";
|
|
1
|
+
import type { GitHubService } from "../../../github";
|
|
2
|
+
import type { Reporter } from "../../reporter";
|
|
3
3
|
export declare function reportRateLimit(reporter: Reporter, github: GitHubService, block: () => Promise<void>): Promise<void>;
|
package/lib/cli/util.d.ts
CHANGED