alex-c-line 2.0.3 → 2.2.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/dist/index.cjs +69 -63
- package/dist/index.js +69 -64
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -21,8 +21,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
23
|
//#endregion
|
|
24
|
-
let _alextheman_utility = require("@alextheman/utility");
|
|
25
24
|
let commander = require("commander");
|
|
25
|
+
let _alextheman_utility = require("@alextheman/utility");
|
|
26
26
|
let chalk = require("chalk");
|
|
27
27
|
chalk = __toESM(chalk);
|
|
28
28
|
let boxen = require("boxen");
|
|
@@ -46,6 +46,8 @@ let node_module = require("node:module");
|
|
|
46
46
|
let gray_matter = require("gray-matter");
|
|
47
47
|
gray_matter = __toESM(gray_matter);
|
|
48
48
|
let _alextheman_utility_node = require("@alextheman/utility/node");
|
|
49
|
+
let axios = require("axios");
|
|
50
|
+
axios = __toESM(axios);
|
|
49
51
|
let supports_color = require("supports-color");
|
|
50
52
|
supports_color = __toESM(supports_color);
|
|
51
53
|
let node_crypto = require("node:crypto");
|
|
@@ -375,6 +377,34 @@ function gitPostMergeCleanup(program) {
|
|
|
375
377
|
});
|
|
376
378
|
}
|
|
377
379
|
//#endregion
|
|
380
|
+
//#region src/cli/commands/internal/media/generate.ts
|
|
381
|
+
function internalMediaGenerate(program) {
|
|
382
|
+
program.command("generate").argument("[directory]", "The directory to generate from", process.cwd()).action(async (directory) => {
|
|
383
|
+
async function readDirectory(directory) {
|
|
384
|
+
const directoryContents = await (0, node_fs_promises.readdir)(directory, { withFileTypes: true });
|
|
385
|
+
for (const entry of directoryContents) {
|
|
386
|
+
const fullPath = node_path.default.join(directory, entry.name);
|
|
387
|
+
if (entry.isDirectory() && ![
|
|
388
|
+
".git",
|
|
389
|
+
"node_modules",
|
|
390
|
+
"__pycache__",
|
|
391
|
+
".venv"
|
|
392
|
+
].includes(entry.name)) await readDirectory(fullPath);
|
|
393
|
+
if (entry.isFile() && entry.name.endsWith(".py")) {
|
|
394
|
+
console.info(`Rendering ${node_path.default.relative(process.cwd(), fullPath)}...`);
|
|
395
|
+
await (0, execa.execa)({ stdio: "inherit" })`manim -pql ${fullPath}`;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
await readDirectory(directory);
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
//#endregion
|
|
403
|
+
//#region src/cli/commands/internal/media/index.ts
|
|
404
|
+
function internalMedia(program) {
|
|
405
|
+
loadCommands(program.command("media"), { internalMediaGenerate });
|
|
406
|
+
}
|
|
407
|
+
//#endregion
|
|
378
408
|
//#region src/utility/fileSystem/findPackageRoot.ts
|
|
379
409
|
async function findPackageRoot(startDirectory, packageName) {
|
|
380
410
|
let directory = startDirectory;
|
|
@@ -421,6 +451,7 @@ function internal(program) {
|
|
|
421
451
|
loadCommands(program.command("internal").description("Commands meant more for internal use by me and is not recommended for production usage."), {
|
|
422
452
|
checkLockfileVersionDiscrepancy,
|
|
423
453
|
gitPostMergeCleanup,
|
|
454
|
+
internalMedia,
|
|
424
455
|
outdatedDependencies
|
|
425
456
|
});
|
|
426
457
|
}
|
|
@@ -1108,61 +1139,6 @@ function templateReleaseNoteCreate(program) {
|
|
|
1108
1139
|
});
|
|
1109
1140
|
}
|
|
1110
1141
|
//#endregion
|
|
1111
|
-
//#region src/cli/commands/template/releaseNote/migrate.ts
|
|
1112
|
-
function templateReleaseNoteMigrate(program) {
|
|
1113
|
-
program.command("migrate").description(_alextheman_utility.normaliseIndents`
|
|
1114
|
-
Migrate the docs/releases folder generated from \`create-release-note\` to be more compatible with v2.
|
|
1115
|
-
The release documents will now be structured as docs/releases/vX/vX.Y/vX.Y.Z.md, rather than docs/releases/<major|minor|patch>/vX.Y.Z`).option("--dry-run", "Perform a dry run of the migration without changing any files.").action(async ({ dryRun }) => {
|
|
1116
|
-
if (dryRun) {
|
|
1117
|
-
console.info("Running migration in dry-run mode. Existing files will not be altered.");
|
|
1118
|
-
console.info();
|
|
1119
|
-
}
|
|
1120
|
-
const oldReleasesPath = node_path.default.join(process.cwd(), "docs", "releases");
|
|
1121
|
-
const oldReleasesDirectory = await (0, node_fs_promises.readdir)(oldReleasesPath);
|
|
1122
|
-
const versionTypes = Object.values(_alextheman_utility.VersionType).filter((value) => {
|
|
1123
|
-
return oldReleasesDirectory.includes(value);
|
|
1124
|
-
});
|
|
1125
|
-
let filesMovedCount = 0;
|
|
1126
|
-
for (const versionType of versionTypes) {
|
|
1127
|
-
const versionPath = node_path.default.join(oldReleasesPath, versionType);
|
|
1128
|
-
const versionNumbers = (await (0, node_fs_promises.readdir)(versionPath)).filter((fileName) => {
|
|
1129
|
-
return fileName.endsWith(".md");
|
|
1130
|
-
}).map((fileName) => {
|
|
1131
|
-
const fileNameNoExtension = fileName.slice(0, -3);
|
|
1132
|
-
try {
|
|
1133
|
-
return new _alextheman_utility.VersionNumber(fileNameNoExtension);
|
|
1134
|
-
} catch {}
|
|
1135
|
-
}).filter((item) => {
|
|
1136
|
-
return item !== void 0;
|
|
1137
|
-
});
|
|
1138
|
-
for (const versionNumber of versionNumbers) {
|
|
1139
|
-
const oldFilePath = node_path.default.join(versionPath, `${versionNumber}.md`);
|
|
1140
|
-
const newFilePath = node_path.default.join(oldReleasesPath, `v${versionNumber.major}`, `v${versionNumber.major}.${versionNumber.minor}`, `${versionNumber}.md`);
|
|
1141
|
-
const relativeOldFilePath = node_path.default.relative(process.cwd(), oldFilePath);
|
|
1142
|
-
const relativeNewFilePath = node_path.default.relative(process.cwd(), newFilePath);
|
|
1143
|
-
if (dryRun) console.info(`Would move \`${relativeOldFilePath}\` to \`${relativeNewFilePath}\``);
|
|
1144
|
-
else {
|
|
1145
|
-
await (0, node_fs_promises.mkdir)(node_path.default.dirname(newFilePath), { recursive: true });
|
|
1146
|
-
await (0, node_fs_promises.rename)(oldFilePath, newFilePath);
|
|
1147
|
-
console.info(`Moved \`${relativeOldFilePath}\` to \`${relativeNewFilePath}\``);
|
|
1148
|
-
}
|
|
1149
|
-
filesMovedCount++;
|
|
1150
|
-
}
|
|
1151
|
-
}
|
|
1152
|
-
console.info();
|
|
1153
|
-
if (!dryRun) for (const oldFolderName of versionTypes) {
|
|
1154
|
-
const oldFolderPath = node_path.default.join(oldReleasesPath, oldFolderName);
|
|
1155
|
-
const relativeOldFolderPath = node_path.default.relative(process.cwd(), oldFolderPath);
|
|
1156
|
-
if ((await (0, node_fs_promises.readdir)(oldFolderPath)).length === 0) {
|
|
1157
|
-
await (0, node_fs_promises.rmdir)(oldFolderPath);
|
|
1158
|
-
console.info(`All files from \`${relativeOldFolderPath}\` removed. Deleting \`${relativeOldFolderPath}\`.`);
|
|
1159
|
-
}
|
|
1160
|
-
}
|
|
1161
|
-
console.info();
|
|
1162
|
-
console.info(dryRun ? `Dry run complete! ${filesMovedCount} files would be moved.` : `Migration complete! ${filesMovedCount} files moved.`);
|
|
1163
|
-
});
|
|
1164
|
-
}
|
|
1165
|
-
//#endregion
|
|
1166
1142
|
//#region src/cli/commands/template/releaseNote/path.ts
|
|
1167
1143
|
function templateReleaseNotePath(program) {
|
|
1168
1144
|
program.command("path").description("Get the path to the release note for a given version.").argument("[version]", "The version number to get the release note path for (leave blank to default to the current directory's package.json version)", (rawVersion) => {
|
|
@@ -1208,7 +1184,6 @@ function templateReleaseNote(program) {
|
|
|
1208
1184
|
loadCommands(program.command("release-note").description("Manage the release notes"), {
|
|
1209
1185
|
templateReleaseNoteCheck,
|
|
1210
1186
|
templateReleaseNoteCreate,
|
|
1211
|
-
templateReleaseNoteMigrate,
|
|
1212
1187
|
templateReleaseNotePath,
|
|
1213
1188
|
templateReleaseNoteSetStatus
|
|
1214
1189
|
});
|
|
@@ -1224,14 +1199,14 @@ function template(program) {
|
|
|
1224
1199
|
//#endregion
|
|
1225
1200
|
//#region package.json
|
|
1226
1201
|
var name = "alex-c-line";
|
|
1227
|
-
var version$1 = "2.0
|
|
1202
|
+
var version$1 = "2.2.0";
|
|
1228
1203
|
var description = "Command-line tool with commands to streamline the developer workflow.";
|
|
1229
1204
|
//#endregion
|
|
1230
1205
|
//#region src/utility/updates/checkUpdate.ts
|
|
1231
1206
|
async function checkUpdate(options) {
|
|
1232
1207
|
const currentVersion = new _alextheman_utility.VersionNumber(version$1);
|
|
1233
|
-
const {
|
|
1234
|
-
const latestVersion = new _alextheman_utility.VersionNumber(
|
|
1208
|
+
const { data } = await axios.default.get("https://registry.npmjs.org/alex-c-line/latest", { timeout: 5e3 });
|
|
1209
|
+
const latestVersion = new _alextheman_utility.VersionNumber(data.version);
|
|
1235
1210
|
if (!_alextheman_utility.VersionNumber.isEqual(currentVersion, latestVersion)) {
|
|
1236
1211
|
const message = _alextheman_utility.normaliseIndents`
|
|
1237
1212
|
A new update of \`alex-c-line\` is available!
|
|
@@ -1254,7 +1229,10 @@ async function checkUpdate(options) {
|
|
|
1254
1229
|
exitCode: 2,
|
|
1255
1230
|
code: "OUTDATED_VERSION"
|
|
1256
1231
|
});
|
|
1257
|
-
} else
|
|
1232
|
+
} else {
|
|
1233
|
+
const { updateLogger = console.info } = options ?? {};
|
|
1234
|
+
updateLogger(messageWithArtwork);
|
|
1235
|
+
}
|
|
1258
1236
|
} else if (options?.logNoUpdates) console.info(`alex-c-line is up to date (${currentVersion}).`);
|
|
1259
1237
|
}
|
|
1260
1238
|
//#endregion
|
|
@@ -1465,6 +1443,25 @@ function formatError(error) {
|
|
|
1465
1443
|
throw error;
|
|
1466
1444
|
}
|
|
1467
1445
|
//#endregion
|
|
1446
|
+
//#region src/utility/updates/pendingUpdateMessage.ts
|
|
1447
|
+
let pendingUpdateMessage = null;
|
|
1448
|
+
let registered = false;
|
|
1449
|
+
function setPendingUpdateMessage(message) {
|
|
1450
|
+
pendingUpdateMessage = message;
|
|
1451
|
+
}
|
|
1452
|
+
function registerUpdateMessagePrinter() {
|
|
1453
|
+
if (registered) return;
|
|
1454
|
+
registered = true;
|
|
1455
|
+
function print() {
|
|
1456
|
+
if (pendingUpdateMessage) {
|
|
1457
|
+
console.info(`\n${pendingUpdateMessage}`);
|
|
1458
|
+
pendingUpdateMessage = null;
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
process.once("beforeExit", print);
|
|
1462
|
+
process.once("exit", print);
|
|
1463
|
+
}
|
|
1464
|
+
//#endregion
|
|
1468
1465
|
//#region src/cache/global/createAlexCLineGlobalCache.ts
|
|
1469
1466
|
async function createAlexCLineGlobalCache(cacheData) {
|
|
1470
1467
|
await (0, node_fs_promises.mkdir)(ALEX_C_LINE_GLOBAL_CACHE_DIRECTORY, { recursive: true });
|
|
@@ -1496,7 +1493,10 @@ async function runAutomatedUpdateCheck() {
|
|
|
1496
1493
|
const lastChecked = cacheData?.updateChecks?.[version$1] ? new Date(cacheData?.updateChecks?.[version$1]) : void 0;
|
|
1497
1494
|
const currentDate = /* @__PURE__ */ new Date();
|
|
1498
1495
|
if (lastChecked === void 0 || currentDate.getTime() - lastChecked.getTime() >= _alextheman_utility.ONE_DAY_IN_MILLISECONDS) {
|
|
1499
|
-
await checkUpdate({
|
|
1496
|
+
await checkUpdate({
|
|
1497
|
+
logNoUpdates: false,
|
|
1498
|
+
updateLogger: setPendingUpdateMessage
|
|
1499
|
+
});
|
|
1500
1500
|
await createAlexCLineGlobalCache({
|
|
1501
1501
|
...cacheData ?? {},
|
|
1502
1502
|
updateChecks: {
|
|
@@ -1508,12 +1508,18 @@ async function runAutomatedUpdateCheck() {
|
|
|
1508
1508
|
} catch {}
|
|
1509
1509
|
}
|
|
1510
1510
|
//#endregion
|
|
1511
|
+
//#region src/utility/updates/shouldRunAutomatedUpdateCheck.ts
|
|
1512
|
+
const shouldRunAutomatedUpdateCheck = !(process.env.NODE_ENV === "test" || (0, _alextheman_utility.parseBoolean)(process.env.RUN_END_TO_END ?? "false") || (0, _alextheman_utility.parseBoolean)(process.env.CI ?? "false"));
|
|
1513
|
+
//#endregion
|
|
1511
1514
|
//#region src/cli/index.ts
|
|
1512
1515
|
(async () => {
|
|
1513
1516
|
try {
|
|
1514
1517
|
const program = new commander.Command();
|
|
1515
1518
|
program.name(name).description(description).version(version$1);
|
|
1516
|
-
|
|
1519
|
+
registerUpdateMessagePrinter();
|
|
1520
|
+
if (shouldRunAutomatedUpdateCheck) setTimeout(() => {
|
|
1521
|
+
runAutomatedUpdateCheck();
|
|
1522
|
+
}, 0);
|
|
1517
1523
|
createCommands(program);
|
|
1518
1524
|
await program.parseAsync(process.argv);
|
|
1519
1525
|
} catch (error) {
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
import { DataError, ONE_DAY_IN_MILLISECONDS, VersionNumber, VersionType, encryptWithKey, fillArray, getStringsAndInterpolations, interpolate, isTemplateStringsArray, kebabToCamel, normaliseIndents, omitProperties, parseBoolean, parseVersionType, parseZodSchema, parseZodSchemaAsync, removeDuplicates, removeUndefinedFromObject, stringifyDotenv } from "@alextheman/utility";
|
|
4
3
|
import { Command } from "commander";
|
|
4
|
+
import { DataError, ONE_DAY_IN_MILLISECONDS, VersionNumber, encryptWithKey, fillArray, getStringsAndInterpolations, interpolate, isTemplateStringsArray, kebabToCamel, normaliseIndents, omitProperties, parseBoolean, parseVersionType, parseZodSchema, parseZodSchemaAsync, removeDuplicates, removeUndefinedFromObject, stringifyDotenv } from "@alextheman/utility";
|
|
5
5
|
import chalk from "chalk";
|
|
6
6
|
import boxen from "boxen";
|
|
7
7
|
import figlet from "figlet";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import { createCanvas } from "canvas";
|
|
10
|
-
import { access, mkdir, readFile, readdir,
|
|
10
|
+
import { access, mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
|
|
11
11
|
import envPaths from "env-paths";
|
|
12
12
|
import { confirm, input, password, select } from "@inquirer/prompts";
|
|
13
13
|
import { parse } from "dotenv";
|
|
@@ -17,6 +17,7 @@ import { DependencyGroup, PackageManager, getDependenciesFromGroup, getExpectedT
|
|
|
17
17
|
import z from "zod";
|
|
18
18
|
import matter from "gray-matter";
|
|
19
19
|
import { parseFilePath } from "@alextheman/utility/node";
|
|
20
|
+
import axios from "axios";
|
|
20
21
|
import supportsColor from "supports-color";
|
|
21
22
|
import { randomUUID } from "node:crypto";
|
|
22
23
|
import { minVersion, prerelease } from "semver";
|
|
@@ -345,6 +346,34 @@ function gitPostMergeCleanup(program) {
|
|
|
345
346
|
});
|
|
346
347
|
}
|
|
347
348
|
//#endregion
|
|
349
|
+
//#region src/cli/commands/internal/media/generate.ts
|
|
350
|
+
function internalMediaGenerate(program) {
|
|
351
|
+
program.command("generate").argument("[directory]", "The directory to generate from", process.cwd()).action(async (directory) => {
|
|
352
|
+
async function readDirectory(directory) {
|
|
353
|
+
const directoryContents = await readdir(directory, { withFileTypes: true });
|
|
354
|
+
for (const entry of directoryContents) {
|
|
355
|
+
const fullPath = path.join(directory, entry.name);
|
|
356
|
+
if (entry.isDirectory() && ![
|
|
357
|
+
".git",
|
|
358
|
+
"node_modules",
|
|
359
|
+
"__pycache__",
|
|
360
|
+
".venv"
|
|
361
|
+
].includes(entry.name)) await readDirectory(fullPath);
|
|
362
|
+
if (entry.isFile() && entry.name.endsWith(".py")) {
|
|
363
|
+
console.info(`Rendering ${path.relative(process.cwd(), fullPath)}...`);
|
|
364
|
+
await execa({ stdio: "inherit" })`manim -pql ${fullPath}`;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
await readDirectory(directory);
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
//#endregion
|
|
372
|
+
//#region src/cli/commands/internal/media/index.ts
|
|
373
|
+
function internalMedia(program) {
|
|
374
|
+
loadCommands(program.command("media"), { internalMediaGenerate });
|
|
375
|
+
}
|
|
376
|
+
//#endregion
|
|
348
377
|
//#region src/utility/fileSystem/findPackageRoot.ts
|
|
349
378
|
async function findPackageRoot(startDirectory, packageName) {
|
|
350
379
|
let directory = startDirectory;
|
|
@@ -391,6 +420,7 @@ function internal(program) {
|
|
|
391
420
|
loadCommands(program.command("internal").description("Commands meant more for internal use by me and is not recommended for production usage."), {
|
|
392
421
|
checkLockfileVersionDiscrepancy,
|
|
393
422
|
gitPostMergeCleanup,
|
|
423
|
+
internalMedia,
|
|
394
424
|
outdatedDependencies
|
|
395
425
|
});
|
|
396
426
|
}
|
|
@@ -1078,61 +1108,6 @@ function templateReleaseNoteCreate(program) {
|
|
|
1078
1108
|
});
|
|
1079
1109
|
}
|
|
1080
1110
|
//#endregion
|
|
1081
|
-
//#region src/cli/commands/template/releaseNote/migrate.ts
|
|
1082
|
-
function templateReleaseNoteMigrate(program) {
|
|
1083
|
-
program.command("migrate").description(normaliseIndents`
|
|
1084
|
-
Migrate the docs/releases folder generated from \`create-release-note\` to be more compatible with v2.
|
|
1085
|
-
The release documents will now be structured as docs/releases/vX/vX.Y/vX.Y.Z.md, rather than docs/releases/<major|minor|patch>/vX.Y.Z`).option("--dry-run", "Perform a dry run of the migration without changing any files.").action(async ({ dryRun }) => {
|
|
1086
|
-
if (dryRun) {
|
|
1087
|
-
console.info("Running migration in dry-run mode. Existing files will not be altered.");
|
|
1088
|
-
console.info();
|
|
1089
|
-
}
|
|
1090
|
-
const oldReleasesPath = path.join(process.cwd(), "docs", "releases");
|
|
1091
|
-
const oldReleasesDirectory = await readdir(oldReleasesPath);
|
|
1092
|
-
const versionTypes = Object.values(VersionType).filter((value) => {
|
|
1093
|
-
return oldReleasesDirectory.includes(value);
|
|
1094
|
-
});
|
|
1095
|
-
let filesMovedCount = 0;
|
|
1096
|
-
for (const versionType of versionTypes) {
|
|
1097
|
-
const versionPath = path.join(oldReleasesPath, versionType);
|
|
1098
|
-
const versionNumbers = (await readdir(versionPath)).filter((fileName) => {
|
|
1099
|
-
return fileName.endsWith(".md");
|
|
1100
|
-
}).map((fileName) => {
|
|
1101
|
-
const fileNameNoExtension = fileName.slice(0, -3);
|
|
1102
|
-
try {
|
|
1103
|
-
return new VersionNumber(fileNameNoExtension);
|
|
1104
|
-
} catch {}
|
|
1105
|
-
}).filter((item) => {
|
|
1106
|
-
return item !== void 0;
|
|
1107
|
-
});
|
|
1108
|
-
for (const versionNumber of versionNumbers) {
|
|
1109
|
-
const oldFilePath = path.join(versionPath, `${versionNumber}.md`);
|
|
1110
|
-
const newFilePath = path.join(oldReleasesPath, `v${versionNumber.major}`, `v${versionNumber.major}.${versionNumber.minor}`, `${versionNumber}.md`);
|
|
1111
|
-
const relativeOldFilePath = path.relative(process.cwd(), oldFilePath);
|
|
1112
|
-
const relativeNewFilePath = path.relative(process.cwd(), newFilePath);
|
|
1113
|
-
if (dryRun) console.info(`Would move \`${relativeOldFilePath}\` to \`${relativeNewFilePath}\``);
|
|
1114
|
-
else {
|
|
1115
|
-
await mkdir(path.dirname(newFilePath), { recursive: true });
|
|
1116
|
-
await rename(oldFilePath, newFilePath);
|
|
1117
|
-
console.info(`Moved \`${relativeOldFilePath}\` to \`${relativeNewFilePath}\``);
|
|
1118
|
-
}
|
|
1119
|
-
filesMovedCount++;
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1122
|
-
console.info();
|
|
1123
|
-
if (!dryRun) for (const oldFolderName of versionTypes) {
|
|
1124
|
-
const oldFolderPath = path.join(oldReleasesPath, oldFolderName);
|
|
1125
|
-
const relativeOldFolderPath = path.relative(process.cwd(), oldFolderPath);
|
|
1126
|
-
if ((await readdir(oldFolderPath)).length === 0) {
|
|
1127
|
-
await rmdir(oldFolderPath);
|
|
1128
|
-
console.info(`All files from \`${relativeOldFolderPath}\` removed. Deleting \`${relativeOldFolderPath}\`.`);
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
|
-
console.info();
|
|
1132
|
-
console.info(dryRun ? `Dry run complete! ${filesMovedCount} files would be moved.` : `Migration complete! ${filesMovedCount} files moved.`);
|
|
1133
|
-
});
|
|
1134
|
-
}
|
|
1135
|
-
//#endregion
|
|
1136
1111
|
//#region src/cli/commands/template/releaseNote/path.ts
|
|
1137
1112
|
function templateReleaseNotePath(program) {
|
|
1138
1113
|
program.command("path").description("Get the path to the release note for a given version.").argument("[version]", "The version number to get the release note path for (leave blank to default to the current directory's package.json version)", (rawVersion) => {
|
|
@@ -1178,7 +1153,6 @@ function templateReleaseNote(program) {
|
|
|
1178
1153
|
loadCommands(program.command("release-note").description("Manage the release notes"), {
|
|
1179
1154
|
templateReleaseNoteCheck,
|
|
1180
1155
|
templateReleaseNoteCreate,
|
|
1181
|
-
templateReleaseNoteMigrate,
|
|
1182
1156
|
templateReleaseNotePath,
|
|
1183
1157
|
templateReleaseNoteSetStatus
|
|
1184
1158
|
});
|
|
@@ -1194,14 +1168,14 @@ function template(program) {
|
|
|
1194
1168
|
//#endregion
|
|
1195
1169
|
//#region package.json
|
|
1196
1170
|
var name = "alex-c-line";
|
|
1197
|
-
var version$1 = "2.0
|
|
1171
|
+
var version$1 = "2.2.0";
|
|
1198
1172
|
var description = "Command-line tool with commands to streamline the developer workflow.";
|
|
1199
1173
|
//#endregion
|
|
1200
1174
|
//#region src/utility/updates/checkUpdate.ts
|
|
1201
1175
|
async function checkUpdate(options) {
|
|
1202
1176
|
const currentVersion = new VersionNumber(version$1);
|
|
1203
|
-
const {
|
|
1204
|
-
const latestVersion = new VersionNumber(
|
|
1177
|
+
const { data } = await axios.get("https://registry.npmjs.org/alex-c-line/latest", { timeout: 5e3 });
|
|
1178
|
+
const latestVersion = new VersionNumber(data.version);
|
|
1205
1179
|
if (!VersionNumber.isEqual(currentVersion, latestVersion)) {
|
|
1206
1180
|
const message = normaliseIndents`
|
|
1207
1181
|
A new update of \`alex-c-line\` is available!
|
|
@@ -1224,7 +1198,10 @@ async function checkUpdate(options) {
|
|
|
1224
1198
|
exitCode: 2,
|
|
1225
1199
|
code: "OUTDATED_VERSION"
|
|
1226
1200
|
});
|
|
1227
|
-
} else
|
|
1201
|
+
} else {
|
|
1202
|
+
const { updateLogger = console.info } = options ?? {};
|
|
1203
|
+
updateLogger(messageWithArtwork);
|
|
1204
|
+
}
|
|
1228
1205
|
} else if (options?.logNoUpdates) console.info(`alex-c-line is up to date (${currentVersion}).`);
|
|
1229
1206
|
}
|
|
1230
1207
|
//#endregion
|
|
@@ -1435,6 +1412,25 @@ function formatError(error) {
|
|
|
1435
1412
|
throw error;
|
|
1436
1413
|
}
|
|
1437
1414
|
//#endregion
|
|
1415
|
+
//#region src/utility/updates/pendingUpdateMessage.ts
|
|
1416
|
+
let pendingUpdateMessage = null;
|
|
1417
|
+
let registered = false;
|
|
1418
|
+
function setPendingUpdateMessage(message) {
|
|
1419
|
+
pendingUpdateMessage = message;
|
|
1420
|
+
}
|
|
1421
|
+
function registerUpdateMessagePrinter() {
|
|
1422
|
+
if (registered) return;
|
|
1423
|
+
registered = true;
|
|
1424
|
+
function print() {
|
|
1425
|
+
if (pendingUpdateMessage) {
|
|
1426
|
+
console.info(`\n${pendingUpdateMessage}`);
|
|
1427
|
+
pendingUpdateMessage = null;
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
process.once("beforeExit", print);
|
|
1431
|
+
process.once("exit", print);
|
|
1432
|
+
}
|
|
1433
|
+
//#endregion
|
|
1438
1434
|
//#region src/cache/global/createAlexCLineGlobalCache.ts
|
|
1439
1435
|
async function createAlexCLineGlobalCache(cacheData) {
|
|
1440
1436
|
await mkdir(ALEX_C_LINE_GLOBAL_CACHE_DIRECTORY, { recursive: true });
|
|
@@ -1466,7 +1462,10 @@ async function runAutomatedUpdateCheck() {
|
|
|
1466
1462
|
const lastChecked = cacheData?.updateChecks?.[version$1] ? new Date(cacheData?.updateChecks?.[version$1]) : void 0;
|
|
1467
1463
|
const currentDate = /* @__PURE__ */ new Date();
|
|
1468
1464
|
if (lastChecked === void 0 || currentDate.getTime() - lastChecked.getTime() >= ONE_DAY_IN_MILLISECONDS) {
|
|
1469
|
-
await checkUpdate({
|
|
1465
|
+
await checkUpdate({
|
|
1466
|
+
logNoUpdates: false,
|
|
1467
|
+
updateLogger: setPendingUpdateMessage
|
|
1468
|
+
});
|
|
1470
1469
|
await createAlexCLineGlobalCache({
|
|
1471
1470
|
...cacheData ?? {},
|
|
1472
1471
|
updateChecks: {
|
|
@@ -1478,12 +1477,18 @@ async function runAutomatedUpdateCheck() {
|
|
|
1478
1477
|
} catch {}
|
|
1479
1478
|
}
|
|
1480
1479
|
//#endregion
|
|
1480
|
+
//#region src/utility/updates/shouldRunAutomatedUpdateCheck.ts
|
|
1481
|
+
const shouldRunAutomatedUpdateCheck = !(process.env.NODE_ENV === "test" || parseBoolean(process.env.RUN_END_TO_END ?? "false") || parseBoolean(process.env.CI ?? "false"));
|
|
1482
|
+
//#endregion
|
|
1481
1483
|
//#region src/cli/index.ts
|
|
1482
1484
|
(async () => {
|
|
1483
1485
|
try {
|
|
1484
1486
|
const program = new Command();
|
|
1485
1487
|
program.name(name).description(description).version(version$1);
|
|
1486
|
-
|
|
1488
|
+
registerUpdateMessagePrinter();
|
|
1489
|
+
if (shouldRunAutomatedUpdateCheck) setTimeout(() => {
|
|
1490
|
+
runAutomatedUpdateCheck();
|
|
1491
|
+
}, 0);
|
|
1487
1492
|
createCommands(program);
|
|
1488
1493
|
await program.parseAsync(process.argv);
|
|
1489
1494
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alex-c-line",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Command-line tool with commands to streamline the developer workflow.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -34,8 +34,9 @@
|
|
|
34
34
|
"templates"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@alextheman/utility": "^5.6.
|
|
37
|
+
"@alextheman/utility": "^5.6.2",
|
|
38
38
|
"@inquirer/prompts": "^8.3.0",
|
|
39
|
+
"axios": "^1.13.6",
|
|
39
40
|
"boxen": "^8.0.1",
|
|
40
41
|
"canvas": "^3.2.1",
|
|
41
42
|
"chalk": "^5.6.2",
|