alex-c-line 2.9.3 → 2.10.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/dist/index.cjs +80 -13
- package/dist/index.js +81 -14
- package/package.json +2 -2
- package/templates/dependencyAudit/licenseCheck/invalid/list.html +3 -0
- package/templates/dependencyAudit/licenseCheck/invalid/listItem.html +1 -0
- package/templates/dependencyAudit/licenseCheck/invalid/table.html +12 -0
- package/templates/dependencyAudit/licenseCheck/invalid/tableRow.html +10 -0
- package/templates/dependencyAudit/licenseCheck/summary/table.html +11 -0
- package/templates/dependencyAudit/licenseCheck/summary/tableRow.html +4 -0
package/dist/index.cjs
CHANGED
|
@@ -40,8 +40,8 @@ let dotenv = require("dotenv");
|
|
|
40
40
|
let execa = require("execa");
|
|
41
41
|
let zod = require("zod");
|
|
42
42
|
zod = __toESM(zod, 1);
|
|
43
|
-
let _alextheman_utility_internal = require("@alextheman/utility/internal");
|
|
44
43
|
let node_url = require("node:url");
|
|
44
|
+
let _alextheman_utility_internal = require("@alextheman/utility/internal");
|
|
45
45
|
let node_module = require("node:module");
|
|
46
46
|
let toml = require("toml");
|
|
47
47
|
let gray_matter = require("gray-matter");
|
|
@@ -284,12 +284,6 @@ function internalCheckLockfileVersionDiscrepancy(program) {
|
|
|
284
284
|
});
|
|
285
285
|
}
|
|
286
286
|
//#endregion
|
|
287
|
-
//#region src/configs/types/template/pullRequest/PullRequestTemplateCategory.ts
|
|
288
|
-
const PullRequestTemplateCategory = {
|
|
289
|
-
GENERAL: "general",
|
|
290
|
-
INFRASTRUCTURE: "infrastructure"
|
|
291
|
-
};
|
|
292
|
-
//#endregion
|
|
293
287
|
//#region src/utility/fileSystem/findPackageRoot.ts
|
|
294
288
|
async function findPackageRoot(startDirectory, packageName) {
|
|
295
289
|
let directory = startDirectory;
|
|
@@ -309,6 +303,75 @@ async function findPackageRoot(startDirectory, packageName) {
|
|
|
309
303
|
const __filename$3 = (0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
|
|
310
304
|
const ALEX_C_LINE_PACKAGE_ROOT = findPackageRoot(node_path.default.dirname(__filename$3), "alex-c-line");
|
|
311
305
|
//#endregion
|
|
306
|
+
//#region src/cli/commands/internal/dependency-audit/helpers/getLicenseCheck.ts
|
|
307
|
+
const ALLOWED_LICENSES = [
|
|
308
|
+
"MIT",
|
|
309
|
+
"ISC",
|
|
310
|
+
"Apache-2.0",
|
|
311
|
+
"BSD-2-Clause",
|
|
312
|
+
"BSD-3-Clause"
|
|
313
|
+
];
|
|
314
|
+
const pnpmLicensesSchema = zod.default.record(zod.default.string(), zod.default.array(zod.default.object({
|
|
315
|
+
name: zod.default.string(),
|
|
316
|
+
versions: zod.default.array(zod.default.string())
|
|
317
|
+
})));
|
|
318
|
+
function parseLicenseCheck(input) {
|
|
319
|
+
return _alextheman_utility.az.with(pnpmLicensesSchema).parse(input);
|
|
320
|
+
}
|
|
321
|
+
async function getLicenseCheck(program) {
|
|
322
|
+
const { exitCode, stdout, stderr } = await (0, execa.execa)({ reject: false })`pnpm licenses ls --json`;
|
|
323
|
+
if (![0, 1].includes(exitCode)) program.error(stderr ?? stdout, {
|
|
324
|
+
exitCode,
|
|
325
|
+
code: "LICENSE_CHECK_ERROR"
|
|
326
|
+
});
|
|
327
|
+
const licenseCheck = parseLicenseCheck(JSON.parse(stdout.trim()));
|
|
328
|
+
const licenseEntries = Object.entries(licenseCheck);
|
|
329
|
+
if (licenseEntries.length === 0) return "No licenses found.";
|
|
330
|
+
const licenseCheckSummaryPath = node_path.default.join(await ALEX_C_LINE_PACKAGE_ROOT, "templates", "dependencyAudit", "licenseCheck", "summary");
|
|
331
|
+
const summaryTableTemplate = await (0, node_fs_promises.readFile)(node_path.default.join(licenseCheckSummaryPath, "table.html"), "utf-8");
|
|
332
|
+
const summaryTableRowTemplate = await (0, node_fs_promises.readFile)(node_path.default.join(licenseCheckSummaryPath, "tableRow.html"), "utf-8");
|
|
333
|
+
const summary = summaryTableTemplate.replace("{{tableRows}}", licenseEntries.toSorted((0, _alextheman_utility.sortBy)(([_, data]) => {
|
|
334
|
+
return data.length;
|
|
335
|
+
}, "desc")).map(([license, data]) => {
|
|
336
|
+
return summaryTableRowTemplate.replace("{{license}}", (0, _alextheman_utility.escapeHTML)(license)).replace("{{count}}", (0, _alextheman_utility.escapeHTML)(data.length.toString()));
|
|
337
|
+
}).join("\n"));
|
|
338
|
+
const invalidLicenses = licenseEntries.filter(([license, _]) => {
|
|
339
|
+
return !ALLOWED_LICENSES.includes(license);
|
|
340
|
+
});
|
|
341
|
+
let invalidSummary;
|
|
342
|
+
if (invalidLicenses.length === 0) invalidSummary = "No licenses requiring review.";
|
|
343
|
+
else {
|
|
344
|
+
const invalidLicensesInvalidPath = node_path.default.join(await ALEX_C_LINE_PACKAGE_ROOT, "templates", "dependencyAudit", "licenseCheck", "invalid");
|
|
345
|
+
const invalidLicensesTableTemplate = await (0, node_fs_promises.readFile)(node_path.default.join(invalidLicensesInvalidPath, "table.html"), "utf-8");
|
|
346
|
+
const invalidLicensesTableRowTemplate = await (0, node_fs_promises.readFile)(node_path.default.join(invalidLicensesInvalidPath, "tableRow.html"), "utf-8");
|
|
347
|
+
const invalidLicensesListTemplate = await (0, node_fs_promises.readFile)(node_path.default.join(invalidLicensesInvalidPath, "list.html"), "utf-8");
|
|
348
|
+
const invalidLicensesListItemTemplate = await (0, node_fs_promises.readFile)(node_path.default.join(invalidLicensesInvalidPath, "listItem.html"), "utf-8");
|
|
349
|
+
invalidSummary = invalidLicensesTableTemplate.replace("{{tableRows}}", invalidLicenses.map(([license, data]) => {
|
|
350
|
+
return invalidLicensesTableRowTemplate.replaceAll("{{license}}", (0, _alextheman_utility.escapeHTML)(license)).replace("{{count}}", (0, _alextheman_utility.escapeHTML)(data.length.toString())).replace("{{dependencies}}", invalidLicensesListTemplate.replace("{{listItems}}", data.flatMap((item) => {
|
|
351
|
+
return item.versions.map((version) => {
|
|
352
|
+
return invalidLicensesListItemTemplate.replace("{{name}}", (0, _alextheman_utility.escapeHTML)(item.name)).replace("{{version}}", (0, _alextheman_utility.escapeHTML)(version));
|
|
353
|
+
});
|
|
354
|
+
}).join("")));
|
|
355
|
+
}).join("\n"));
|
|
356
|
+
}
|
|
357
|
+
return _alextheman_utility.normaliseIndents`
|
|
358
|
+
|
|
359
|
+
### Summary
|
|
360
|
+
|
|
361
|
+
${summary}
|
|
362
|
+
|
|
363
|
+
### Requires Review
|
|
364
|
+
|
|
365
|
+
${invalidSummary}
|
|
366
|
+
`;
|
|
367
|
+
}
|
|
368
|
+
//#endregion
|
|
369
|
+
//#region src/configs/types/template/pullRequest/PullRequestTemplateCategory.ts
|
|
370
|
+
const PullRequestTemplateCategory = {
|
|
371
|
+
GENERAL: "general",
|
|
372
|
+
INFRASTRUCTURE: "infrastructure"
|
|
373
|
+
};
|
|
374
|
+
//#endregion
|
|
312
375
|
//#region src/cli/commands/internal/dependency-audit/helpers/getOutdatedDependencies.ts
|
|
313
376
|
const pnpmOutdatedSchema = zod.default.record(zod.default.string(), zod.default.object({
|
|
314
377
|
current: _alextheman_utility.az.versionNumber(),
|
|
@@ -331,7 +394,7 @@ async function getOutdatedDependencies(program) {
|
|
|
331
394
|
const tableTemplate = await (0, node_fs_promises.readFile)(node_path.default.join(outdatedTemplatesPath, "table.html"), "utf-8");
|
|
332
395
|
const tableRowTemplate = await (0, node_fs_promises.readFile)(node_path.default.join(outdatedTemplatesPath, "tableRow.html"), "utf-8");
|
|
333
396
|
return tableTemplate.replace("{{tableRows}}", Object.entries(outdatedDependencies).map(([packageName, data]) => {
|
|
334
|
-
return tableRowTemplate.replace("{{packageName}}", packageName).replace("{{currentVersion}}", data.current.toString()).replace("{{latestVersion}}", data.latest.toString()).replace("{{isDeprecated}}", data.isDeprecated ? "Yes" : "No").replace("{{dependencyGroup}}", data.dependencyType);
|
|
397
|
+
return tableRowTemplate.replace("{{packageName}}", (0, _alextheman_utility.escapeHTML)(packageName)).replace("{{currentVersion}}", (0, _alextheman_utility.escapeHTML)(data.current.toString())).replace("{{latestVersion}}", (0, _alextheman_utility.escapeHTML)(data.latest.toString())).replace("{{isDeprecated}}", data.isDeprecated ? "Yes" : "No").replace("{{dependencyGroup}}", (0, _alextheman_utility.escapeHTML)(data.dependencyType));
|
|
335
398
|
}).join("\n"));
|
|
336
399
|
}
|
|
337
400
|
//#endregion
|
|
@@ -361,8 +424,8 @@ async function getPeerCheck(program) {
|
|
|
361
424
|
if (Object.keys(peerCheck["."].bad).length === 0) return "No peer dependency issues found";
|
|
362
425
|
return peerCheckTableTemplate.replace("{{tableRows}}", Object.entries(peerCheck["."].bad).flatMap(([packageName, data]) => {
|
|
363
426
|
return data.map((item) => {
|
|
364
|
-
return peerCheckTableRowTemplate.replace("{{packageName}}", packageName).replace("{{currentVersion}}", item.foundVersion.toString()).replace("{{wantedRange}}", item.wantedRange).replace("{{parentDependencies}}", item.parents.map((parent) => {
|
|
365
|
-
return `${parent.name}@${parent.version}`;
|
|
427
|
+
return peerCheckTableRowTemplate.replace("{{packageName}}", (0, _alextheman_utility.escapeHTML)(packageName)).replace("{{currentVersion}}", (0, _alextheman_utility.escapeHTML)(item.foundVersion.toString())).replace("{{wantedRange}}", (0, _alextheman_utility.escapeHTML)(item.wantedRange)).replace("{{parentDependencies}}", item.parents.map((parent) => {
|
|
428
|
+
return `${(0, _alextheman_utility.escapeHTML)(parent.name)}@${parent.version}`;
|
|
366
429
|
}).join(", "));
|
|
367
430
|
});
|
|
368
431
|
}).join("\n"));
|
|
@@ -416,12 +479,12 @@ async function getSecurityAudit(program) {
|
|
|
416
479
|
const auditTable = tableTemplate.replace("{{tableRows}}", Object.entries(securityAudit.advisories).toSorted((0, _alextheman_utility.sortBy)(([_, advisory]) => {
|
|
417
480
|
return severityOrder[advisory.severity];
|
|
418
481
|
}, "desc")).map(([id, data]) => {
|
|
419
|
-
return tableRowTemplate.replace("{{advisoryId}}", id).replace("{{severity}}", data.severity).replace("{{packageName}}", data.module_name).replace("{{title}}", data.title).replace("{{affected}}", data.vulnerable_versions).replace("{{patched}}", data.patched_versions).replace("{{url}}", data.url);
|
|
482
|
+
return tableRowTemplate.replace("{{advisoryId}}", (0, _alextheman_utility.escapeHTML)(id)).replace("{{severity}}", (0, _alextheman_utility.escapeHTML)(data.severity)).replace("{{packageName}}", (0, _alextheman_utility.escapeHTML)(data.module_name)).replace("{{title}}", (0, _alextheman_utility.escapeHTML)(data.title)).replace("{{affected}}", (0, _alextheman_utility.escapeHTML)(data.vulnerable_versions)).replace("{{patched}}", (0, _alextheman_utility.escapeHTML)(data.patched_versions)).replace("{{url}}", (0, _alextheman_utility.escapeHTML)(data.url));
|
|
420
483
|
}).join("\n"));
|
|
421
484
|
return _alextheman_utility.normaliseIndents`
|
|
422
485
|
### Summary
|
|
423
486
|
|
|
424
|
-
${(await (0, node_fs_promises.readFile)(node_path.default.join(auditTemplatesPath, "summary.html"), "utf-8")).replace("{{info}}", securityAudit.metadata.vulnerabilities.info.toString()).replace("{{low}}", securityAudit.metadata.vulnerabilities.low.toString()).replace("{{moderate}}", securityAudit.metadata.vulnerabilities.moderate.toString()).replace("{{high}}", securityAudit.metadata.vulnerabilities.high.toString()).replace("{{critical}}", securityAudit.metadata.vulnerabilities.critical.toString())}
|
|
487
|
+
${(await (0, node_fs_promises.readFile)(node_path.default.join(auditTemplatesPath, "summary.html"), "utf-8")).replace("{{info}}", (0, _alextheman_utility.escapeHTML)(securityAudit.metadata.vulnerabilities.info.toString())).replace("{{low}}", (0, _alextheman_utility.escapeHTML)(securityAudit.metadata.vulnerabilities.low.toString())).replace("{{moderate}}", (0, _alextheman_utility.escapeHTML)(securityAudit.metadata.vulnerabilities.moderate.toString())).replace("{{high}}", (0, _alextheman_utility.escapeHTML)(securityAudit.metadata.vulnerabilities.high.toString())).replace("{{critical}}", (0, _alextheman_utility.escapeHTML)(securityAudit.metadata.vulnerabilities.critical.toString()))}
|
|
425
488
|
|
|
426
489
|
### Audit Results
|
|
427
490
|
|
|
@@ -446,6 +509,10 @@ function internalDependencyAudit(program) {
|
|
|
446
509
|
## Outdated Dependencies
|
|
447
510
|
|
|
448
511
|
${await getOutdatedDependencies(program)}
|
|
512
|
+
|
|
513
|
+
## Licenses
|
|
514
|
+
|
|
515
|
+
${await getLicenseCheck(program)}
|
|
449
516
|
`;
|
|
450
517
|
console.info(content);
|
|
451
518
|
if (output) {
|
|
@@ -1356,7 +1423,7 @@ function template(program) {
|
|
|
1356
1423
|
//#endregion
|
|
1357
1424
|
//#region package.json
|
|
1358
1425
|
var name = "alex-c-line";
|
|
1359
|
-
var version$1 = "2.
|
|
1426
|
+
var version$1 = "2.10.1";
|
|
1360
1427
|
var description = "Command-line tool with commands to streamline the developer workflow.";
|
|
1361
1428
|
//#endregion
|
|
1362
1429
|
//#region src/utility/updates/checkUpdate.ts
|
package/dist/index.js
CHANGED
|
@@ -7,14 +7,14 @@ import boxen from "boxen";
|
|
|
7
7
|
import figlet from "figlet";
|
|
8
8
|
import envPaths from "env-paths";
|
|
9
9
|
import path from "node:path";
|
|
10
|
-
import { ONE_DAY_IN_MILLISECONDS, VersionNumber, az, fillArray, getStringsAndInterpolations, interpolate, isTemplateStringsArray, kebabToCamel, normaliseIndents, omitProperties, parseBoolean, parseVersionType, removeDuplicates, removeUndefinedFromObject, sortBy, stringifyDotenv } from "@alextheman/utility";
|
|
10
|
+
import { ONE_DAY_IN_MILLISECONDS, VersionNumber, az, escapeHTML, fillArray, getStringsAndInterpolations, interpolate, isTemplateStringsArray, kebabToCamel, normaliseIndents, omitProperties, parseBoolean, parseVersionType, removeDuplicates, removeUndefinedFromObject, sortBy, stringifyDotenv } from "@alextheman/utility";
|
|
11
11
|
import { confirm, input, password, select } from "@inquirer/prompts";
|
|
12
12
|
import { access, mkdir, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
|
|
13
13
|
import { parse } from "dotenv";
|
|
14
14
|
import { ExecaError, execa } from "execa";
|
|
15
15
|
import z from "zod";
|
|
16
|
-
import { DependencyGroup, PackageManager, getDependenciesFromGroup, getExpectedTgzName, getPackageJsonContents, packageJsonNotFoundError } from "@alextheman/utility/internal";
|
|
17
16
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
17
|
+
import { DependencyGroup, PackageManager, getDependenciesFromGroup, getExpectedTgzName, getPackageJsonContents, packageJsonNotFoundError } from "@alextheman/utility/internal";
|
|
18
18
|
import { parse as parse$1 } from "toml";
|
|
19
19
|
import matter from "gray-matter";
|
|
20
20
|
import { parseFilePath } from "@alextheman/utility/node";
|
|
@@ -253,12 +253,6 @@ function internalCheckLockfileVersionDiscrepancy(program) {
|
|
|
253
253
|
});
|
|
254
254
|
}
|
|
255
255
|
//#endregion
|
|
256
|
-
//#region src/configs/types/template/pullRequest/PullRequestTemplateCategory.ts
|
|
257
|
-
const PullRequestTemplateCategory = {
|
|
258
|
-
GENERAL: "general",
|
|
259
|
-
INFRASTRUCTURE: "infrastructure"
|
|
260
|
-
};
|
|
261
|
-
//#endregion
|
|
262
256
|
//#region src/utility/fileSystem/findPackageRoot.ts
|
|
263
257
|
async function findPackageRoot(startDirectory, packageName) {
|
|
264
258
|
let directory = startDirectory;
|
|
@@ -278,6 +272,75 @@ async function findPackageRoot(startDirectory, packageName) {
|
|
|
278
272
|
const __filename$2 = fileURLToPath(import.meta.url);
|
|
279
273
|
const ALEX_C_LINE_PACKAGE_ROOT = findPackageRoot(path.dirname(__filename$2), "alex-c-line");
|
|
280
274
|
//#endregion
|
|
275
|
+
//#region src/cli/commands/internal/dependency-audit/helpers/getLicenseCheck.ts
|
|
276
|
+
const ALLOWED_LICENSES = [
|
|
277
|
+
"MIT",
|
|
278
|
+
"ISC",
|
|
279
|
+
"Apache-2.0",
|
|
280
|
+
"BSD-2-Clause",
|
|
281
|
+
"BSD-3-Clause"
|
|
282
|
+
];
|
|
283
|
+
const pnpmLicensesSchema = z.record(z.string(), z.array(z.object({
|
|
284
|
+
name: z.string(),
|
|
285
|
+
versions: z.array(z.string())
|
|
286
|
+
})));
|
|
287
|
+
function parseLicenseCheck(input) {
|
|
288
|
+
return az.with(pnpmLicensesSchema).parse(input);
|
|
289
|
+
}
|
|
290
|
+
async function getLicenseCheck(program) {
|
|
291
|
+
const { exitCode, stdout, stderr } = await execa({ reject: false })`pnpm licenses ls --json`;
|
|
292
|
+
if (![0, 1].includes(exitCode)) program.error(stderr ?? stdout, {
|
|
293
|
+
exitCode,
|
|
294
|
+
code: "LICENSE_CHECK_ERROR"
|
|
295
|
+
});
|
|
296
|
+
const licenseCheck = parseLicenseCheck(JSON.parse(stdout.trim()));
|
|
297
|
+
const licenseEntries = Object.entries(licenseCheck);
|
|
298
|
+
if (licenseEntries.length === 0) return "No licenses found.";
|
|
299
|
+
const licenseCheckSummaryPath = path.join(await ALEX_C_LINE_PACKAGE_ROOT, "templates", "dependencyAudit", "licenseCheck", "summary");
|
|
300
|
+
const summaryTableTemplate = await readFile(path.join(licenseCheckSummaryPath, "table.html"), "utf-8");
|
|
301
|
+
const summaryTableRowTemplate = await readFile(path.join(licenseCheckSummaryPath, "tableRow.html"), "utf-8");
|
|
302
|
+
const summary = summaryTableTemplate.replace("{{tableRows}}", licenseEntries.toSorted(sortBy(([_, data]) => {
|
|
303
|
+
return data.length;
|
|
304
|
+
}, "desc")).map(([license, data]) => {
|
|
305
|
+
return summaryTableRowTemplate.replace("{{license}}", escapeHTML(license)).replace("{{count}}", escapeHTML(data.length.toString()));
|
|
306
|
+
}).join("\n"));
|
|
307
|
+
const invalidLicenses = licenseEntries.filter(([license, _]) => {
|
|
308
|
+
return !ALLOWED_LICENSES.includes(license);
|
|
309
|
+
});
|
|
310
|
+
let invalidSummary;
|
|
311
|
+
if (invalidLicenses.length === 0) invalidSummary = "No licenses requiring review.";
|
|
312
|
+
else {
|
|
313
|
+
const invalidLicensesInvalidPath = path.join(await ALEX_C_LINE_PACKAGE_ROOT, "templates", "dependencyAudit", "licenseCheck", "invalid");
|
|
314
|
+
const invalidLicensesTableTemplate = await readFile(path.join(invalidLicensesInvalidPath, "table.html"), "utf-8");
|
|
315
|
+
const invalidLicensesTableRowTemplate = await readFile(path.join(invalidLicensesInvalidPath, "tableRow.html"), "utf-8");
|
|
316
|
+
const invalidLicensesListTemplate = await readFile(path.join(invalidLicensesInvalidPath, "list.html"), "utf-8");
|
|
317
|
+
const invalidLicensesListItemTemplate = await readFile(path.join(invalidLicensesInvalidPath, "listItem.html"), "utf-8");
|
|
318
|
+
invalidSummary = invalidLicensesTableTemplate.replace("{{tableRows}}", invalidLicenses.map(([license, data]) => {
|
|
319
|
+
return invalidLicensesTableRowTemplate.replaceAll("{{license}}", escapeHTML(license)).replace("{{count}}", escapeHTML(data.length.toString())).replace("{{dependencies}}", invalidLicensesListTemplate.replace("{{listItems}}", data.flatMap((item) => {
|
|
320
|
+
return item.versions.map((version) => {
|
|
321
|
+
return invalidLicensesListItemTemplate.replace("{{name}}", escapeHTML(item.name)).replace("{{version}}", escapeHTML(version));
|
|
322
|
+
});
|
|
323
|
+
}).join("")));
|
|
324
|
+
}).join("\n"));
|
|
325
|
+
}
|
|
326
|
+
return normaliseIndents`
|
|
327
|
+
|
|
328
|
+
### Summary
|
|
329
|
+
|
|
330
|
+
${summary}
|
|
331
|
+
|
|
332
|
+
### Requires Review
|
|
333
|
+
|
|
334
|
+
${invalidSummary}
|
|
335
|
+
`;
|
|
336
|
+
}
|
|
337
|
+
//#endregion
|
|
338
|
+
//#region src/configs/types/template/pullRequest/PullRequestTemplateCategory.ts
|
|
339
|
+
const PullRequestTemplateCategory = {
|
|
340
|
+
GENERAL: "general",
|
|
341
|
+
INFRASTRUCTURE: "infrastructure"
|
|
342
|
+
};
|
|
343
|
+
//#endregion
|
|
281
344
|
//#region src/cli/commands/internal/dependency-audit/helpers/getOutdatedDependencies.ts
|
|
282
345
|
const pnpmOutdatedSchema = z.record(z.string(), z.object({
|
|
283
346
|
current: az.versionNumber(),
|
|
@@ -300,7 +363,7 @@ async function getOutdatedDependencies(program) {
|
|
|
300
363
|
const tableTemplate = await readFile(path.join(outdatedTemplatesPath, "table.html"), "utf-8");
|
|
301
364
|
const tableRowTemplate = await readFile(path.join(outdatedTemplatesPath, "tableRow.html"), "utf-8");
|
|
302
365
|
return tableTemplate.replace("{{tableRows}}", Object.entries(outdatedDependencies).map(([packageName, data]) => {
|
|
303
|
-
return tableRowTemplate.replace("{{packageName}}", packageName).replace("{{currentVersion}}", data.current.toString()).replace("{{latestVersion}}", data.latest.toString()).replace("{{isDeprecated}}", data.isDeprecated ? "Yes" : "No").replace("{{dependencyGroup}}", data.dependencyType);
|
|
366
|
+
return tableRowTemplate.replace("{{packageName}}", escapeHTML(packageName)).replace("{{currentVersion}}", escapeHTML(data.current.toString())).replace("{{latestVersion}}", escapeHTML(data.latest.toString())).replace("{{isDeprecated}}", data.isDeprecated ? "Yes" : "No").replace("{{dependencyGroup}}", escapeHTML(data.dependencyType));
|
|
304
367
|
}).join("\n"));
|
|
305
368
|
}
|
|
306
369
|
//#endregion
|
|
@@ -330,8 +393,8 @@ async function getPeerCheck(program) {
|
|
|
330
393
|
if (Object.keys(peerCheck["."].bad).length === 0) return "No peer dependency issues found";
|
|
331
394
|
return peerCheckTableTemplate.replace("{{tableRows}}", Object.entries(peerCheck["."].bad).flatMap(([packageName, data]) => {
|
|
332
395
|
return data.map((item) => {
|
|
333
|
-
return peerCheckTableRowTemplate.replace("{{packageName}}", packageName).replace("{{currentVersion}}", item.foundVersion.toString()).replace("{{wantedRange}}", item.wantedRange).replace("{{parentDependencies}}", item.parents.map((parent) => {
|
|
334
|
-
return `${parent.name}@${parent.version}`;
|
|
396
|
+
return peerCheckTableRowTemplate.replace("{{packageName}}", escapeHTML(packageName)).replace("{{currentVersion}}", escapeHTML(item.foundVersion.toString())).replace("{{wantedRange}}", escapeHTML(item.wantedRange)).replace("{{parentDependencies}}", item.parents.map((parent) => {
|
|
397
|
+
return `${escapeHTML(parent.name)}@${parent.version}`;
|
|
335
398
|
}).join(", "));
|
|
336
399
|
});
|
|
337
400
|
}).join("\n"));
|
|
@@ -385,12 +448,12 @@ async function getSecurityAudit(program) {
|
|
|
385
448
|
const auditTable = tableTemplate.replace("{{tableRows}}", Object.entries(securityAudit.advisories).toSorted(sortBy(([_, advisory]) => {
|
|
386
449
|
return severityOrder[advisory.severity];
|
|
387
450
|
}, "desc")).map(([id, data]) => {
|
|
388
|
-
return tableRowTemplate.replace("{{advisoryId}}", id).replace("{{severity}}", data.severity).replace("{{packageName}}", data.module_name).replace("{{title}}", data.title).replace("{{affected}}", data.vulnerable_versions).replace("{{patched}}", data.patched_versions).replace("{{url}}", data.url);
|
|
451
|
+
return tableRowTemplate.replace("{{advisoryId}}", escapeHTML(id)).replace("{{severity}}", escapeHTML(data.severity)).replace("{{packageName}}", escapeHTML(data.module_name)).replace("{{title}}", escapeHTML(data.title)).replace("{{affected}}", escapeHTML(data.vulnerable_versions)).replace("{{patched}}", escapeHTML(data.patched_versions)).replace("{{url}}", escapeHTML(data.url));
|
|
389
452
|
}).join("\n"));
|
|
390
453
|
return normaliseIndents`
|
|
391
454
|
### Summary
|
|
392
455
|
|
|
393
|
-
${(await readFile(path.join(auditTemplatesPath, "summary.html"), "utf-8")).replace("{{info}}", securityAudit.metadata.vulnerabilities.info.toString()).replace("{{low}}", securityAudit.metadata.vulnerabilities.low.toString()).replace("{{moderate}}", securityAudit.metadata.vulnerabilities.moderate.toString()).replace("{{high}}", securityAudit.metadata.vulnerabilities.high.toString()).replace("{{critical}}", securityAudit.metadata.vulnerabilities.critical.toString())}
|
|
456
|
+
${(await readFile(path.join(auditTemplatesPath, "summary.html"), "utf-8")).replace("{{info}}", escapeHTML(securityAudit.metadata.vulnerabilities.info.toString())).replace("{{low}}", escapeHTML(securityAudit.metadata.vulnerabilities.low.toString())).replace("{{moderate}}", escapeHTML(securityAudit.metadata.vulnerabilities.moderate.toString())).replace("{{high}}", escapeHTML(securityAudit.metadata.vulnerabilities.high.toString())).replace("{{critical}}", escapeHTML(securityAudit.metadata.vulnerabilities.critical.toString()))}
|
|
394
457
|
|
|
395
458
|
### Audit Results
|
|
396
459
|
|
|
@@ -415,6 +478,10 @@ function internalDependencyAudit(program) {
|
|
|
415
478
|
## Outdated Dependencies
|
|
416
479
|
|
|
417
480
|
${await getOutdatedDependencies(program)}
|
|
481
|
+
|
|
482
|
+
## Licenses
|
|
483
|
+
|
|
484
|
+
${await getLicenseCheck(program)}
|
|
418
485
|
`;
|
|
419
486
|
console.info(content);
|
|
420
487
|
if (output) {
|
|
@@ -1325,7 +1392,7 @@ function template(program) {
|
|
|
1325
1392
|
//#endregion
|
|
1326
1393
|
//#region package.json
|
|
1327
1394
|
var name = "alex-c-line";
|
|
1328
|
-
var version$1 = "2.
|
|
1395
|
+
var version$1 = "2.10.1";
|
|
1329
1396
|
var description = "Command-line tool with commands to streamline the developer workflow.";
|
|
1330
1397
|
//#endregion
|
|
1331
1398
|
//#region src/utility/updates/checkUpdate.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alex-c-line",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.1",
|
|
4
4
|
"description": "Command-line tool with commands to streamline the developer workflow.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"templates"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@alextheman/utility": "5.
|
|
37
|
+
"@alextheman/utility": "5.22.0",
|
|
38
38
|
"@inquirer/prompts": "8.5.2",
|
|
39
39
|
"axios": "1.17.0",
|
|
40
40
|
"boxen": "8.0.1",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<li>{{name}}@{{version}}</li>
|