alex-c-line 1.28.1 → 1.30.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/configs/index.cjs +10 -7
- package/dist/configs/index.d.cts +2 -0
- package/dist/configs/index.d.ts +2 -0
- package/dist/configs/index.js +10 -7
- package/dist/index.cjs +133 -164
- package/dist/index.js +131 -162
- package/package.json +4 -4
package/dist/configs/index.cjs
CHANGED
|
@@ -99,13 +99,16 @@ const PullRequestTemplateCategory = {
|
|
|
99
99
|
|
|
100
100
|
//#endregion
|
|
101
101
|
//#region src/configs/helpers/defineAlexCLinePrivateConfig.ts
|
|
102
|
-
const alexCLinePrivateConfigSchema = zod.default.object({ useLocalPackage: zod.default.strictObject({
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
102
|
+
const alexCLinePrivateConfigSchema = zod.default.object({ useLocalPackage: zod.default.strictObject({
|
|
103
|
+
enableCache: zod.default.boolean().optional(),
|
|
104
|
+
localPackages: zod.default.record(zod.default.string(), zod.default.strictObject({
|
|
105
|
+
packageManager: zod.default.enum(_alextheman_utility_internal.PackageManager),
|
|
106
|
+
path: zod.default.string(),
|
|
107
|
+
prepareScript: zod.default.string().optional(),
|
|
108
|
+
dependencyGroup: zod.default.enum(DependencyGroup).optional(),
|
|
109
|
+
keepOldTarballs: zod.default.boolean().optional()
|
|
110
|
+
}))
|
|
111
|
+
}) });
|
|
109
112
|
function defineAlexCLinePrivateConfig(config) {
|
|
110
113
|
return config;
|
|
111
114
|
}
|
package/dist/configs/index.d.cts
CHANGED
|
@@ -81,6 +81,8 @@ interface LocalPackage<ScriptName extends string = string> {
|
|
|
81
81
|
keepOldTarballs?: boolean;
|
|
82
82
|
}
|
|
83
83
|
interface UseLocalPackageConfig<ScriptName extends string = string> {
|
|
84
|
+
/** Enable caching of the previous version number. */
|
|
85
|
+
enableCache?: boolean;
|
|
84
86
|
/** A record of all packages that we may want to consider using locally. */
|
|
85
87
|
localPackages: Record<string, LocalPackage<ScriptName>>;
|
|
86
88
|
}
|
package/dist/configs/index.d.ts
CHANGED
|
@@ -82,6 +82,8 @@ interface LocalPackage<ScriptName extends string = string> {
|
|
|
82
82
|
keepOldTarballs?: boolean;
|
|
83
83
|
}
|
|
84
84
|
interface UseLocalPackageConfig<ScriptName extends string = string> {
|
|
85
|
+
/** Enable caching of the previous version number. */
|
|
86
|
+
enableCache?: boolean;
|
|
85
87
|
/** A record of all packages that we may want to consider using locally. */
|
|
86
88
|
localPackages: Record<string, LocalPackage<ScriptName>>;
|
|
87
89
|
}
|
package/dist/configs/index.js
CHANGED
|
@@ -70,13 +70,16 @@ const PullRequestTemplateCategory = {
|
|
|
70
70
|
|
|
71
71
|
//#endregion
|
|
72
72
|
//#region src/configs/helpers/defineAlexCLinePrivateConfig.ts
|
|
73
|
-
const alexCLinePrivateConfigSchema = z.object({ useLocalPackage: z.strictObject({
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
const alexCLinePrivateConfigSchema = z.object({ useLocalPackage: z.strictObject({
|
|
74
|
+
enableCache: z.boolean().optional(),
|
|
75
|
+
localPackages: z.record(z.string(), z.strictObject({
|
|
76
|
+
packageManager: z.enum(PackageManager),
|
|
77
|
+
path: z.string(),
|
|
78
|
+
prepareScript: z.string().optional(),
|
|
79
|
+
dependencyGroup: z.enum(DependencyGroup).optional(),
|
|
80
|
+
keepOldTarballs: z.boolean().optional()
|
|
81
|
+
}))
|
|
82
|
+
}) });
|
|
80
83
|
function defineAlexCLinePrivateConfig(config) {
|
|
81
84
|
return config;
|
|
82
85
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -28,20 +28,18 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
//#endregion
|
|
29
29
|
let _alextheman_utility = require("@alextheman/utility");
|
|
30
30
|
let commander = require("commander");
|
|
31
|
-
let
|
|
32
|
-
|
|
33
|
-
let update_notifier = require("update-notifier");
|
|
34
|
-
update_notifier = __toESM(update_notifier);
|
|
31
|
+
let chalk = require("chalk");
|
|
32
|
+
chalk = __toESM(chalk);
|
|
35
33
|
let canvas = require("canvas");
|
|
36
34
|
let node_fs_promises = require("node:fs/promises");
|
|
37
35
|
let node_path = require("node:path");
|
|
38
36
|
node_path = __toESM(node_path);
|
|
39
37
|
let boxen = require("boxen");
|
|
40
38
|
boxen = __toESM(boxen);
|
|
41
|
-
let chalk = require("chalk");
|
|
42
|
-
chalk = __toESM(chalk);
|
|
43
39
|
let figlet = require("figlet");
|
|
44
40
|
figlet = __toESM(figlet);
|
|
41
|
+
let env_paths = require("env-paths");
|
|
42
|
+
env_paths = __toESM(env_paths);
|
|
45
43
|
let execa = require("execa");
|
|
46
44
|
let dotenv = require("dotenv");
|
|
47
45
|
dotenv = __toESM(dotenv);
|
|
@@ -58,6 +56,8 @@ let node_url = require("node:url");
|
|
|
58
56
|
let gray_matter = require("gray-matter");
|
|
59
57
|
gray_matter = __toESM(gray_matter);
|
|
60
58
|
let _alextheman_utility_node = require("@alextheman/utility/node");
|
|
59
|
+
let supports_color = require("supports-color");
|
|
60
|
+
supports_color = __toESM(supports_color);
|
|
61
61
|
|
|
62
62
|
//#region src/utility/miscellaneous/asciiToPng.ts
|
|
63
63
|
async function asciiToPng(ascii, options) {
|
|
@@ -120,8 +120,17 @@ async function createAlexCLineArtwork(options) {
|
|
|
120
120
|
//#endregion
|
|
121
121
|
//#region src/commands/artwork.ts
|
|
122
122
|
function artwork(program) {
|
|
123
|
-
program.command("artwork").description("Create the artwork for alex-c-line").option("--
|
|
124
|
-
|
|
123
|
+
program.command("artwork").description("Create the artwork for alex-c-line").option("--subtitle-text <subtitleText>", "Customise the subtitle text").option("--subtitle-color <subtitleColor>", "Customise the subtitle color", (subtitleColor) => {
|
|
124
|
+
return {
|
|
125
|
+
green: chalk.default.green,
|
|
126
|
+
white: chalk.default.white
|
|
127
|
+
}[subtitleColor];
|
|
128
|
+
}).option("--save-png [fileName]", "Save the artwork as a PNG file, optionally specifying the path").action(async ({ savePng: fileName, subtitleText, subtitleColor }) => {
|
|
129
|
+
console.info(await createAlexCLineArtwork({
|
|
130
|
+
includeColors: true,
|
|
131
|
+
subtitleText,
|
|
132
|
+
subtitleColor
|
|
133
|
+
}));
|
|
125
134
|
if (fileName) await asciiToPng(await createAlexCLineArtwork({ includeColors: false }), {
|
|
126
135
|
fileName: typeof fileName === "string" ? fileName : void 0,
|
|
127
136
|
fontSize: 90
|
|
@@ -129,6 +138,20 @@ function artwork(program) {
|
|
|
129
138
|
});
|
|
130
139
|
}
|
|
131
140
|
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/cache/global/envPaths.ts
|
|
143
|
+
const alexCLineEnvPaths = (0, env_paths.default)("alex-c-line");
|
|
144
|
+
const { cache: ALEX_C_LINE_GLOBAL_CACHE_DIRECTORY } = alexCLineEnvPaths;
|
|
145
|
+
const ALEX_C_LINE_GLOBAL_CACHE_PATH = node_path.default.join(ALEX_C_LINE_GLOBAL_CACHE_DIRECTORY, "cache.json");
|
|
146
|
+
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/commands/cache-path.ts
|
|
149
|
+
function cachePath(program) {
|
|
150
|
+
program.command("cache-path").description("Log the path to the alex-c-line cache files.").action(() => {
|
|
151
|
+
console.info(ALEX_C_LINE_GLOBAL_CACHE_PATH);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
132
155
|
//#endregion
|
|
133
156
|
//#region src/commands/check-for-file-dependencies.ts
|
|
134
157
|
function findFileDependencies(dependencies) {
|
|
@@ -904,13 +927,16 @@ const PullRequestTemplateCategory = {
|
|
|
904
927
|
|
|
905
928
|
//#endregion
|
|
906
929
|
//#region src/configs/helpers/defineAlexCLinePrivateConfig.ts
|
|
907
|
-
const alexCLinePrivateConfigSchema = zod.default.object({ useLocalPackage: zod.default.strictObject({
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
930
|
+
const alexCLinePrivateConfigSchema = zod.default.object({ useLocalPackage: zod.default.strictObject({
|
|
931
|
+
enableCache: zod.default.boolean().optional(),
|
|
932
|
+
localPackages: zod.default.record(zod.default.string(), zod.default.strictObject({
|
|
933
|
+
packageManager: zod.default.enum(_alextheman_utility_internal.PackageManager),
|
|
934
|
+
path: zod.default.string(),
|
|
935
|
+
prepareScript: zod.default.string().optional(),
|
|
936
|
+
dependencyGroup: zod.default.enum(DependencyGroup).optional(),
|
|
937
|
+
keepOldTarballs: zod.default.boolean().optional()
|
|
938
|
+
}))
|
|
939
|
+
}) });
|
|
914
940
|
function parseAlexCLinePrivateConfig(data) {
|
|
915
941
|
return (0, _alextheman_utility.parseZodSchema)(alexCLinePrivateConfigSchema, data);
|
|
916
942
|
}
|
|
@@ -1255,121 +1281,35 @@ function setReleaseStatus2(program) {
|
|
|
1255
1281
|
});
|
|
1256
1282
|
}
|
|
1257
1283
|
|
|
1284
|
+
//#endregion
|
|
1285
|
+
//#region src/utility/errors/convertDataErrorToProgramError.ts
|
|
1286
|
+
function convertDataErrorToProgramError(dataError, programError, options) {
|
|
1287
|
+
programError(dataError.message, {
|
|
1288
|
+
exitCode: options?.exitCode ?? 1,
|
|
1289
|
+
code: dataError.code
|
|
1290
|
+
});
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
//#endregion
|
|
1294
|
+
//#region src/utility/miscellaneous/parseZodSchemaForProgram.ts
|
|
1295
|
+
function parseZodSchemaForProgram(programError, schema, data) {
|
|
1296
|
+
try {
|
|
1297
|
+
return (0, _alextheman_utility.parseZodSchema)(schema, data);
|
|
1298
|
+
} catch (error) {
|
|
1299
|
+
if (_alextheman_utility.DataError.check(error)) convertDataErrorToProgramError(error, programError);
|
|
1300
|
+
throw error;
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1258
1304
|
//#endregion
|
|
1259
1305
|
//#region package.json
|
|
1260
1306
|
var name = "alex-c-line";
|
|
1261
|
-
var version = "1.
|
|
1307
|
+
var version = "1.30.0";
|
|
1262
1308
|
var description = "Command-line tool with commands to streamline the developer workflow.";
|
|
1263
|
-
var package_default = {
|
|
1264
|
-
name,
|
|
1265
|
-
version,
|
|
1266
|
-
description,
|
|
1267
|
-
repository: {
|
|
1268
|
-
"type": "git",
|
|
1269
|
-
"url": "git+https://github.com/alextheman231/alex-c-line.git"
|
|
1270
|
-
},
|
|
1271
|
-
sideEffects: ["./dist/index.js"],
|
|
1272
|
-
license: "MIT",
|
|
1273
|
-
author: "alextheman",
|
|
1274
|
-
type: "module",
|
|
1275
|
-
exports: {
|
|
1276
|
-
"./configs": {
|
|
1277
|
-
"types": "./dist/configs/index.d.ts",
|
|
1278
|
-
"require": "./dist/configs/index.cjs",
|
|
1279
|
-
"import": "./dist/configs/index.js",
|
|
1280
|
-
"default": "./dist/configs/index.js"
|
|
1281
|
-
},
|
|
1282
|
-
"./configs/internal": {
|
|
1283
|
-
"types": "./dist/configs/internal/index.d.ts",
|
|
1284
|
-
"require": "./dist/configs/internal/index.cjs",
|
|
1285
|
-
"import": "./dist/configs/internal/index.js",
|
|
1286
|
-
"default": "./dist/configs/internal/index.js"
|
|
1287
|
-
}
|
|
1288
|
-
},
|
|
1289
|
-
bin: { "alex-c-line": "./dist/index.js" },
|
|
1290
|
-
files: ["dist", "templates"],
|
|
1291
|
-
scripts: {
|
|
1292
|
-
"build": "tsdown",
|
|
1293
|
-
"command": "bash -c 'pnpm run build && echo && echo \"Command output:\" && node dist/index.js $@' --",
|
|
1294
|
-
"create-local-package": "pnpm run build && rm -f alex-c-line-*.tgz && pnpm pack",
|
|
1295
|
-
"create-release-note": "bash -c 'git pull origin main && pnpm run command create-release-note-2 $@' --",
|
|
1296
|
-
"format": "pnpm run format-prettier && pnpm run format-eslint",
|
|
1297
|
-
"format-eslint": "eslint --fix --suppress-all \"package.json\" \"src/**/*.ts\" \"tests/**/*.ts\" && rm -f eslint-suppressions.json",
|
|
1298
|
-
"format-prettier": "pnpm run format-prettier-typescript && pnpm run format-prettier-javascript && pnpm run format-prettier-yml",
|
|
1299
|
-
"format-prettier-javascript": "prettier --write \"./**/*.js\"",
|
|
1300
|
-
"format-prettier-typescript": "prettier --write --parser typescript \"./**/*.ts\"",
|
|
1301
|
-
"format-prettier-yml": "prettier --write \"./**/*.{yml,yaml}\"",
|
|
1302
|
-
"lint": "pnpm run lint-tsc && pnpm run lint-eslint && pnpm run lint-prettier",
|
|
1303
|
-
"lint-eslint": "eslint \"package.json\" \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
1304
|
-
"lint-prettier": "pnpm run lint-prettier-typescript && pnpm run lint-prettier-javascript && pnpm run lint-prettier-yml",
|
|
1305
|
-
"lint-prettier-javascript": "prettier --check \"./**.js\"",
|
|
1306
|
-
"lint-prettier-typescript": "prettier --check --parser typescript \"./**/*.ts\"",
|
|
1307
|
-
"lint-prettier-yml": "prettier --check \"./**/*.{yml,yaml}\"",
|
|
1308
|
-
"lint-tsc": "tsc --noEmit",
|
|
1309
|
-
"pre-commit": "pnpm run command pre-commit-2",
|
|
1310
|
-
"prepare": "husky",
|
|
1311
|
-
"prepare-live-eslint-plugin": "pnpm uninstall @alextheman/eslint-plugin && pnpm install --save-dev @alextheman/eslint-plugin",
|
|
1312
|
-
"prepare-live-utility": "pnpm uninstall @alextheman/utility && pnpm install @alextheman/utility",
|
|
1313
|
-
"prepare-local-eslint-plugin": "dotenv -e .env -- sh -c 'ESLINT_PLUGIN_PATH=${LOCAL_ESLINT_PLUGIN_PATH:-../eslint-plugin}; pnpm --prefix \"$ESLINT_PLUGIN_PATH\" run build && pnpm uninstall @alextheman/eslint-plugin && pnpm install --save-dev file:\"$ESLINT_PLUGIN_PATH\"'",
|
|
1314
|
-
"prepare-local-utility": "dotenv -e .env -- sh -c 'UTILITY_PATH=${LOCAL_UTILITY_PATH:-../utility}; pnpm --prefix \"$UTILITY_PATH\" run build && pnpm uninstall @alextheman/utility && pnpm install file:\"$UTILITY_PATH\"'",
|
|
1315
|
-
"test": "vitest run",
|
|
1316
|
-
"test-end-to-end": "RUN_END_TO_END=true vitest run tests/end-to-end --reporter verbose",
|
|
1317
|
-
"test-watch": "vitest",
|
|
1318
|
-
"update-dependencies": "pnpm update --latest && pnpm update",
|
|
1319
|
-
"use-live-eslint-plugin": "pnpm run prepare-live-eslint-plugin && pnpm run lint",
|
|
1320
|
-
"use-live-utility": "pnpm run prepare-live-utility",
|
|
1321
|
-
"use-local-eslint-plugin": "pnpm run prepare-local-eslint-plugin && pnpm run lint",
|
|
1322
|
-
"use-local-utility": "pnpm run prepare-local-utility"
|
|
1323
|
-
},
|
|
1324
|
-
dependencies: {
|
|
1325
|
-
"@alextheman/utility": "^5.1.4",
|
|
1326
|
-
"@inquirer/prompts": "^8.2.1",
|
|
1327
|
-
"boxen": "^8.0.1",
|
|
1328
|
-
"canvas": "^3.2.1",
|
|
1329
|
-
"chalk": "^5.6.2",
|
|
1330
|
-
"commander": "^14.0.3",
|
|
1331
|
-
"dotenv": "^17.3.1",
|
|
1332
|
-
"dotenv-stringify": "^3.0.1",
|
|
1333
|
-
"execa": "^9.6.1",
|
|
1334
|
-
"figlet": "^1.10.0",
|
|
1335
|
-
"gray-matter": "^4.0.3",
|
|
1336
|
-
"libsodium-wrappers": "^0.8.2",
|
|
1337
|
-
"supports-color": "^10.2.2",
|
|
1338
|
-
"update-notifier": "^7.3.1",
|
|
1339
|
-
"zod": "^4.3.6"
|
|
1340
|
-
},
|
|
1341
|
-
devDependencies: {
|
|
1342
|
-
"@alextheman/eslint-plugin": "^5.8.1",
|
|
1343
|
-
"@commander-js/extra-typings": "^14.0.0",
|
|
1344
|
-
"@types/eslint": "^9.6.1",
|
|
1345
|
-
"@types/node": "^25.3.0",
|
|
1346
|
-
"@types/update-notifier": "^6.0.8",
|
|
1347
|
-
"dotenv-cli": "^11.0.0",
|
|
1348
|
-
"eslint": "^10.0.1",
|
|
1349
|
-
"husky": "^9.1.7",
|
|
1350
|
-
"prettier": "^3.8.1",
|
|
1351
|
-
"tempy": "^3.2.0",
|
|
1352
|
-
"ts-node": "^10.9.2",
|
|
1353
|
-
"tsdown": "^0.20.3",
|
|
1354
|
-
"typescript": "^5.9.3",
|
|
1355
|
-
"typescript-eslint": "^8.56.0",
|
|
1356
|
-
"vite-tsconfig-paths": "^6.1.1",
|
|
1357
|
-
"vitest": "^4.0.18"
|
|
1358
|
-
},
|
|
1359
|
-
packageManager: "pnpm@10.30.1+sha512.3590e550d5384caa39bd5c7c739f72270234b2f6059e13018f975c313b1eb9fefcc09714048765d4d9efe961382c312e624572c0420762bdc5d5940cdf9be73a",
|
|
1360
|
-
engines: { "node": ">=22.0.0" },
|
|
1361
|
-
pnpm: { "onlyBuiltDependencies": [
|
|
1362
|
-
"canvas",
|
|
1363
|
-
"core-js",
|
|
1364
|
-
"esbuild",
|
|
1365
|
-
"fsevents",
|
|
1366
|
-
"unrs-resolver"
|
|
1367
|
-
] }
|
|
1368
|
-
};
|
|
1369
1309
|
|
|
1370
1310
|
//#endregion
|
|
1371
|
-
//#region src/
|
|
1372
|
-
async function checkUpdate(
|
|
1311
|
+
//#region src/utility/updates/checkUpdate.ts
|
|
1312
|
+
async function checkUpdate(options) {
|
|
1373
1313
|
const currentVersion = new _alextheman_utility.VersionNumber(version);
|
|
1374
1314
|
const { stdout: npmViewResult } = await execa.execa`npm view alex-c-line version`;
|
|
1375
1315
|
const latestVersion = new _alextheman_utility.VersionNumber(npmViewResult.trim());
|
|
@@ -1389,40 +1329,25 @@ async function checkUpdate(program) {
|
|
|
1389
1329
|
return centerLine(line, width);
|
|
1390
1330
|
}).join("\n")
|
|
1391
1331
|
});
|
|
1392
|
-
if (program)
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
//#endregion
|
|
1401
|
-
//#region src/utility/errors/convertDataErrorToProgramError.ts
|
|
1402
|
-
function convertDataErrorToProgramError(dataError, programError, options) {
|
|
1403
|
-
programError(dataError.message, {
|
|
1404
|
-
exitCode: options?.exitCode ?? 1,
|
|
1405
|
-
code: dataError.code
|
|
1406
|
-
});
|
|
1407
|
-
}
|
|
1408
|
-
|
|
1409
|
-
//#endregion
|
|
1410
|
-
//#region src/utility/miscellaneous/parseZodSchemaForProgram.ts
|
|
1411
|
-
function parseZodSchemaForProgram(programError, schema, data) {
|
|
1412
|
-
try {
|
|
1413
|
-
return (0, _alextheman_utility.parseZodSchema)(schema, data);
|
|
1414
|
-
} catch (error) {
|
|
1415
|
-
if (_alextheman_utility.DataError.check(error)) convertDataErrorToProgramError(error, programError);
|
|
1416
|
-
throw error;
|
|
1417
|
-
}
|
|
1332
|
+
if (options?.program) {
|
|
1333
|
+
const { program } = options;
|
|
1334
|
+
program.error(messageWithArtwork, {
|
|
1335
|
+
exitCode: 2,
|
|
1336
|
+
code: "OUTDATED_VERSION"
|
|
1337
|
+
});
|
|
1338
|
+
} else console.info(messageWithArtwork);
|
|
1339
|
+
} else if (options?.logNoUpdates) console.info(`alex-c-line is up to date (${currentVersion}).`);
|
|
1418
1340
|
}
|
|
1419
1341
|
|
|
1420
1342
|
//#endregion
|
|
1421
|
-
//#region src/commands/update
|
|
1343
|
+
//#region src/commands/update.ts
|
|
1422
1344
|
const optionsSchema = zod.default.object({ check: zod.default.boolean().optional() });
|
|
1423
1345
|
function update(program) {
|
|
1424
|
-
program.command("update").description("Handle updates of the currently installed alex-c-line").option("--check", "Check for available updates").action(async (rawOptions) => {
|
|
1425
|
-
if (parseZodSchemaForProgram(program.error, optionsSchema, rawOptions).check) await checkUpdate(
|
|
1346
|
+
program.command("update").description("Handle updates of the currently installed alex-c-line").option("--check", "Check for available updates").option("--apply", "Apply the latest update").action(async (rawOptions) => {
|
|
1347
|
+
if (parseZodSchemaForProgram(program.error, optionsSchema, rawOptions).check) await checkUpdate({
|
|
1348
|
+
program,
|
|
1349
|
+
logNoUpdates: true
|
|
1350
|
+
});
|
|
1426
1351
|
else console.info("Unsupported option. Expected `--check`.");
|
|
1427
1352
|
});
|
|
1428
1353
|
}
|
|
@@ -1446,7 +1371,7 @@ const alexCLineProjectCacheSchema = zod.default.object({ useLocalPackage: zod.de
|
|
|
1446
1371
|
})) }).partial() }).partial();
|
|
1447
1372
|
|
|
1448
1373
|
//#endregion
|
|
1449
|
-
//#region src/cache/project/
|
|
1374
|
+
//#region src/cache/project/parseAlexCLineProjectCache.ts
|
|
1450
1375
|
function parseAlexCLineProjectCache(data) {
|
|
1451
1376
|
return (0, _alextheman_utility.parseZodSchema)(alexCLineProjectCacheSchema, data);
|
|
1452
1377
|
}
|
|
@@ -1529,7 +1454,7 @@ function useLocalPackage(program) {
|
|
|
1529
1454
|
exitCode: 1,
|
|
1530
1455
|
code: "ALEX_C_LINE_PRIVATE_CONFIG_NOT_FOUND"
|
|
1531
1456
|
});
|
|
1532
|
-
const { useLocalPackage: { localPackages } } = await loadAlexCLinePrivateConfig(configPath);
|
|
1457
|
+
const { useLocalPackage: { enableCache, localPackages } } = await loadAlexCLinePrivateConfig(configPath);
|
|
1533
1458
|
const localPackage = localPackages[packageName];
|
|
1534
1459
|
if (!localPackage) throw new _alextheman_utility.DataError({
|
|
1535
1460
|
packageName,
|
|
@@ -1566,7 +1491,7 @@ function useLocalPackage(program) {
|
|
|
1566
1491
|
code: "LOCAL_ALEX_C_LINE_ERROR"
|
|
1567
1492
|
});
|
|
1568
1493
|
} else {
|
|
1569
|
-
const cacheContents = await loadAlexCLineProjectCache();
|
|
1494
|
+
const cacheContents = enableCache ? await loadAlexCLineProjectCache() : {};
|
|
1570
1495
|
if (!reverse) {
|
|
1571
1496
|
if (prepareScript) await (0, execa.execa)({ cwd: localPackagePath })`${packageManager} run ${prepareScript}`;
|
|
1572
1497
|
if (!keepOldTarballs) await removeAllTarballs(localPackagePath, packageName);
|
|
@@ -1588,7 +1513,7 @@ function useLocalPackage(program) {
|
|
|
1588
1513
|
cwd: process.cwd(),
|
|
1589
1514
|
stdio: "inherit"
|
|
1590
1515
|
});
|
|
1591
|
-
if (!reverse) {
|
|
1516
|
+
if (!reverse && enableCache) {
|
|
1592
1517
|
const packageCacheData = {
|
|
1593
1518
|
...cacheContents?.useLocalPackage?.dependencies?.[packageName] ?? {},
|
|
1594
1519
|
previousVersion: dependencies[packageName],
|
|
@@ -1605,7 +1530,7 @@ function useLocalPackage(program) {
|
|
|
1605
1530
|
}
|
|
1606
1531
|
}
|
|
1607
1532
|
});
|
|
1608
|
-
} else await createAlexCLineProjectCache({
|
|
1533
|
+
} else if (enableCache) await createAlexCLineProjectCache({
|
|
1609
1534
|
...cacheContents ?? {},
|
|
1610
1535
|
useLocalPackage: {
|
|
1611
1536
|
...cacheContents?.useLocalPackage,
|
|
@@ -1673,6 +1598,7 @@ function loadCommands(program, commandMap) {
|
|
|
1673
1598
|
function createCommands(program) {
|
|
1674
1599
|
loadCommands(program, {
|
|
1675
1600
|
artwork,
|
|
1601
|
+
cachePath,
|
|
1676
1602
|
checkForFileDependencies,
|
|
1677
1603
|
checkLockfileVersionDiscrepancy,
|
|
1678
1604
|
checkReleaseNote,
|
|
@@ -1723,18 +1649,61 @@ function formatError(error) {
|
|
|
1723
1649
|
throw error;
|
|
1724
1650
|
}
|
|
1725
1651
|
|
|
1652
|
+
//#endregion
|
|
1653
|
+
//#region src/cache/global/createAlexCLineGlobalCache.ts
|
|
1654
|
+
async function createAlexCLineGlobalCache(cacheData) {
|
|
1655
|
+
await (0, node_fs_promises.mkdir)(ALEX_C_LINE_GLOBAL_CACHE_DIRECTORY, { recursive: true });
|
|
1656
|
+
await (0, node_fs_promises.writeFile)(ALEX_C_LINE_GLOBAL_CACHE_PATH, JSON.stringify(cacheData, null, 2));
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1659
|
+
//#endregion
|
|
1660
|
+
//#region src/cache/global/types/AlexCLineGlobalCache.ts
|
|
1661
|
+
const alexCLineGlobalCacheSchema = zod.default.looseObject({ updateChecks: zod.default.record(zod.default.string(), zod.default.string()).optional() });
|
|
1662
|
+
|
|
1663
|
+
//#endregion
|
|
1664
|
+
//#region src/cache/global/parseAlexCLineGlobalCache.ts
|
|
1665
|
+
function parseAlexCLineGlobalCache(input) {
|
|
1666
|
+
return (0, _alextheman_utility.parseZodSchema)(alexCLineGlobalCacheSchema, input);
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
//#endregion
|
|
1670
|
+
//#region src/cache/global/loadAlexCLineGlobalCache.ts
|
|
1671
|
+
async function loadAlexCLineGlobalCache() {
|
|
1672
|
+
try {
|
|
1673
|
+
return parseAlexCLineGlobalCache(JSON.parse(await (0, node_fs_promises.readFile)(ALEX_C_LINE_GLOBAL_CACHE_PATH, "utf-8")));
|
|
1674
|
+
} catch (error) {
|
|
1675
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") return null;
|
|
1676
|
+
throw error;
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
//#endregion
|
|
1681
|
+
//#region src/utility/updates/runAutomatedUpdateCheck.ts
|
|
1682
|
+
async function runAutomatedUpdateCheck() {
|
|
1683
|
+
try {
|
|
1684
|
+
const cacheData = await loadAlexCLineGlobalCache();
|
|
1685
|
+
const lastChecked = cacheData?.updateChecks?.[version] ? new Date(cacheData?.updateChecks?.[version]) : void 0;
|
|
1686
|
+
const currentDate = /* @__PURE__ */ new Date();
|
|
1687
|
+
if (lastChecked === void 0 || currentDate.getTime() - lastChecked.getTime() >= _alextheman_utility.ONE_DAY_IN_MILLISECONDS) {
|
|
1688
|
+
await checkUpdate({ logNoUpdates: false });
|
|
1689
|
+
await createAlexCLineGlobalCache({
|
|
1690
|
+
...cacheData ?? {},
|
|
1691
|
+
updateChecks: {
|
|
1692
|
+
...cacheData?.updateChecks ?? {},
|
|
1693
|
+
[version]: currentDate.toISOString()
|
|
1694
|
+
}
|
|
1695
|
+
});
|
|
1696
|
+
}
|
|
1697
|
+
} catch {}
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1726
1700
|
//#endregion
|
|
1727
1701
|
//#region src/index.ts
|
|
1728
1702
|
(async () => {
|
|
1729
1703
|
try {
|
|
1730
1704
|
const program = new commander.Command();
|
|
1731
1705
|
program.name(name).description(description).version(version);
|
|
1732
|
-
if (!(process.env.NODE_ENV === "test" || (0, _alextheman_utility.parseBoolean)(process.env.RUN_END_TO_END ?? "false") || (0, _alextheman_utility.parseBoolean)(process.env.CI ?? "false")))
|
|
1733
|
-
${await createAlexCLineArtwork({ includeColors: Boolean(supports_color.default.stdout) })}
|
|
1734
|
-
A new update of \`alex-c-line\` is available!
|
|
1735
|
-
{currentVersion} → {latestVersion}
|
|
1736
|
-
Run \`{updateCommand}\` to update.
|
|
1737
|
-
` });
|
|
1706
|
+
if (!(process.env.NODE_ENV === "test" || (0, _alextheman_utility.parseBoolean)(process.env.RUN_END_TO_END ?? "false") || (0, _alextheman_utility.parseBoolean)(process.env.CI ?? "false"))) await runAutomatedUpdateCheck();
|
|
1738
1707
|
createCommands(program);
|
|
1739
1708
|
await program.parseAsync(process.argv);
|
|
1740
1709
|
} catch (error) {
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
import { DataError, VersionNumber, VersionType, encryptWithKey, fillArray, getStringsAndInterpolations, interpolate, isTemplateStringsArray, kebabToCamel, normaliseIndents, omitProperties, parseBoolean, parseVersionType, parseZodSchema, parseZodSchemaAsync, removeDuplicates, removeUndefinedFromObject, stringifyDotenv } from "@alextheman/utility";
|
|
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
4
|
import { Command } from "commander";
|
|
5
|
-
import
|
|
6
|
-
import updateNotifier from "update-notifier";
|
|
5
|
+
import chalk from "chalk";
|
|
7
6
|
import { createCanvas } from "canvas";
|
|
8
7
|
import { access, mkdir, readFile, readdir, rename, rm, rmdir, writeFile } from "node:fs/promises";
|
|
9
8
|
import path from "node:path";
|
|
10
9
|
import boxen from "boxen";
|
|
11
|
-
import chalk from "chalk";
|
|
12
10
|
import figlet from "figlet";
|
|
11
|
+
import envPaths from "env-paths";
|
|
13
12
|
import { ExecaError, execa } from "execa";
|
|
14
13
|
import dotenv, { parse } from "dotenv";
|
|
15
14
|
import dotenvStringify from "dotenv-stringify";
|
|
@@ -20,6 +19,7 @@ import { PackageManager, getDependenciesFromGroup, getExpectedTgzName, getPackag
|
|
|
20
19
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
21
20
|
import matter from "gray-matter";
|
|
22
21
|
import { parseFilePath } from "@alextheman/utility/node";
|
|
22
|
+
import supportsColor from "supports-color";
|
|
23
23
|
|
|
24
24
|
//#region src/utility/miscellaneous/asciiToPng.ts
|
|
25
25
|
async function asciiToPng(ascii, options) {
|
|
@@ -82,8 +82,17 @@ async function createAlexCLineArtwork(options) {
|
|
|
82
82
|
//#endregion
|
|
83
83
|
//#region src/commands/artwork.ts
|
|
84
84
|
function artwork(program) {
|
|
85
|
-
program.command("artwork").description("Create the artwork for alex-c-line").option("--
|
|
86
|
-
|
|
85
|
+
program.command("artwork").description("Create the artwork for alex-c-line").option("--subtitle-text <subtitleText>", "Customise the subtitle text").option("--subtitle-color <subtitleColor>", "Customise the subtitle color", (subtitleColor) => {
|
|
86
|
+
return {
|
|
87
|
+
green: chalk.green,
|
|
88
|
+
white: chalk.white
|
|
89
|
+
}[subtitleColor];
|
|
90
|
+
}).option("--save-png [fileName]", "Save the artwork as a PNG file, optionally specifying the path").action(async ({ savePng: fileName, subtitleText, subtitleColor }) => {
|
|
91
|
+
console.info(await createAlexCLineArtwork({
|
|
92
|
+
includeColors: true,
|
|
93
|
+
subtitleText,
|
|
94
|
+
subtitleColor
|
|
95
|
+
}));
|
|
87
96
|
if (fileName) await asciiToPng(await createAlexCLineArtwork({ includeColors: false }), {
|
|
88
97
|
fileName: typeof fileName === "string" ? fileName : void 0,
|
|
89
98
|
fontSize: 90
|
|
@@ -91,6 +100,20 @@ function artwork(program) {
|
|
|
91
100
|
});
|
|
92
101
|
}
|
|
93
102
|
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/cache/global/envPaths.ts
|
|
105
|
+
const alexCLineEnvPaths = envPaths("alex-c-line");
|
|
106
|
+
const { cache: ALEX_C_LINE_GLOBAL_CACHE_DIRECTORY } = alexCLineEnvPaths;
|
|
107
|
+
const ALEX_C_LINE_GLOBAL_CACHE_PATH = path.join(ALEX_C_LINE_GLOBAL_CACHE_DIRECTORY, "cache.json");
|
|
108
|
+
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/commands/cache-path.ts
|
|
111
|
+
function cachePath(program) {
|
|
112
|
+
program.command("cache-path").description("Log the path to the alex-c-line cache files.").action(() => {
|
|
113
|
+
console.info(ALEX_C_LINE_GLOBAL_CACHE_PATH);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
94
117
|
//#endregion
|
|
95
118
|
//#region src/commands/check-for-file-dependencies.ts
|
|
96
119
|
function findFileDependencies(dependencies) {
|
|
@@ -866,13 +889,16 @@ const PullRequestTemplateCategory = {
|
|
|
866
889
|
|
|
867
890
|
//#endregion
|
|
868
891
|
//#region src/configs/helpers/defineAlexCLinePrivateConfig.ts
|
|
869
|
-
const alexCLinePrivateConfigSchema = z.object({ useLocalPackage: z.strictObject({
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
892
|
+
const alexCLinePrivateConfigSchema = z.object({ useLocalPackage: z.strictObject({
|
|
893
|
+
enableCache: z.boolean().optional(),
|
|
894
|
+
localPackages: z.record(z.string(), z.strictObject({
|
|
895
|
+
packageManager: z.enum(PackageManager),
|
|
896
|
+
path: z.string(),
|
|
897
|
+
prepareScript: z.string().optional(),
|
|
898
|
+
dependencyGroup: z.enum(DependencyGroup).optional(),
|
|
899
|
+
keepOldTarballs: z.boolean().optional()
|
|
900
|
+
}))
|
|
901
|
+
}) });
|
|
876
902
|
function parseAlexCLinePrivateConfig(data) {
|
|
877
903
|
return parseZodSchema(alexCLinePrivateConfigSchema, data);
|
|
878
904
|
}
|
|
@@ -1217,121 +1243,35 @@ function setReleaseStatus2(program) {
|
|
|
1217
1243
|
});
|
|
1218
1244
|
}
|
|
1219
1245
|
|
|
1246
|
+
//#endregion
|
|
1247
|
+
//#region src/utility/errors/convertDataErrorToProgramError.ts
|
|
1248
|
+
function convertDataErrorToProgramError(dataError, programError, options) {
|
|
1249
|
+
programError(dataError.message, {
|
|
1250
|
+
exitCode: options?.exitCode ?? 1,
|
|
1251
|
+
code: dataError.code
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
//#endregion
|
|
1256
|
+
//#region src/utility/miscellaneous/parseZodSchemaForProgram.ts
|
|
1257
|
+
function parseZodSchemaForProgram(programError, schema, data) {
|
|
1258
|
+
try {
|
|
1259
|
+
return parseZodSchema(schema, data);
|
|
1260
|
+
} catch (error) {
|
|
1261
|
+
if (DataError.check(error)) convertDataErrorToProgramError(error, programError);
|
|
1262
|
+
throw error;
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1220
1266
|
//#endregion
|
|
1221
1267
|
//#region package.json
|
|
1222
1268
|
var name = "alex-c-line";
|
|
1223
|
-
var version = "1.
|
|
1269
|
+
var version = "1.30.0";
|
|
1224
1270
|
var description = "Command-line tool with commands to streamline the developer workflow.";
|
|
1225
|
-
var package_default = {
|
|
1226
|
-
name,
|
|
1227
|
-
version,
|
|
1228
|
-
description,
|
|
1229
|
-
repository: {
|
|
1230
|
-
"type": "git",
|
|
1231
|
-
"url": "git+https://github.com/alextheman231/alex-c-line.git"
|
|
1232
|
-
},
|
|
1233
|
-
sideEffects: ["./dist/index.js"],
|
|
1234
|
-
license: "MIT",
|
|
1235
|
-
author: "alextheman",
|
|
1236
|
-
type: "module",
|
|
1237
|
-
exports: {
|
|
1238
|
-
"./configs": {
|
|
1239
|
-
"types": "./dist/configs/index.d.ts",
|
|
1240
|
-
"require": "./dist/configs/index.cjs",
|
|
1241
|
-
"import": "./dist/configs/index.js",
|
|
1242
|
-
"default": "./dist/configs/index.js"
|
|
1243
|
-
},
|
|
1244
|
-
"./configs/internal": {
|
|
1245
|
-
"types": "./dist/configs/internal/index.d.ts",
|
|
1246
|
-
"require": "./dist/configs/internal/index.cjs",
|
|
1247
|
-
"import": "./dist/configs/internal/index.js",
|
|
1248
|
-
"default": "./dist/configs/internal/index.js"
|
|
1249
|
-
}
|
|
1250
|
-
},
|
|
1251
|
-
bin: { "alex-c-line": "./dist/index.js" },
|
|
1252
|
-
files: ["dist", "templates"],
|
|
1253
|
-
scripts: {
|
|
1254
|
-
"build": "tsdown",
|
|
1255
|
-
"command": "bash -c 'pnpm run build && echo && echo \"Command output:\" && node dist/index.js $@' --",
|
|
1256
|
-
"create-local-package": "pnpm run build && rm -f alex-c-line-*.tgz && pnpm pack",
|
|
1257
|
-
"create-release-note": "bash -c 'git pull origin main && pnpm run command create-release-note-2 $@' --",
|
|
1258
|
-
"format": "pnpm run format-prettier && pnpm run format-eslint",
|
|
1259
|
-
"format-eslint": "eslint --fix --suppress-all \"package.json\" \"src/**/*.ts\" \"tests/**/*.ts\" && rm -f eslint-suppressions.json",
|
|
1260
|
-
"format-prettier": "pnpm run format-prettier-typescript && pnpm run format-prettier-javascript && pnpm run format-prettier-yml",
|
|
1261
|
-
"format-prettier-javascript": "prettier --write \"./**/*.js\"",
|
|
1262
|
-
"format-prettier-typescript": "prettier --write --parser typescript \"./**/*.ts\"",
|
|
1263
|
-
"format-prettier-yml": "prettier --write \"./**/*.{yml,yaml}\"",
|
|
1264
|
-
"lint": "pnpm run lint-tsc && pnpm run lint-eslint && pnpm run lint-prettier",
|
|
1265
|
-
"lint-eslint": "eslint \"package.json\" \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
1266
|
-
"lint-prettier": "pnpm run lint-prettier-typescript && pnpm run lint-prettier-javascript && pnpm run lint-prettier-yml",
|
|
1267
|
-
"lint-prettier-javascript": "prettier --check \"./**.js\"",
|
|
1268
|
-
"lint-prettier-typescript": "prettier --check --parser typescript \"./**/*.ts\"",
|
|
1269
|
-
"lint-prettier-yml": "prettier --check \"./**/*.{yml,yaml}\"",
|
|
1270
|
-
"lint-tsc": "tsc --noEmit",
|
|
1271
|
-
"pre-commit": "pnpm run command pre-commit-2",
|
|
1272
|
-
"prepare": "husky",
|
|
1273
|
-
"prepare-live-eslint-plugin": "pnpm uninstall @alextheman/eslint-plugin && pnpm install --save-dev @alextheman/eslint-plugin",
|
|
1274
|
-
"prepare-live-utility": "pnpm uninstall @alextheman/utility && pnpm install @alextheman/utility",
|
|
1275
|
-
"prepare-local-eslint-plugin": "dotenv -e .env -- sh -c 'ESLINT_PLUGIN_PATH=${LOCAL_ESLINT_PLUGIN_PATH:-../eslint-plugin}; pnpm --prefix \"$ESLINT_PLUGIN_PATH\" run build && pnpm uninstall @alextheman/eslint-plugin && pnpm install --save-dev file:\"$ESLINT_PLUGIN_PATH\"'",
|
|
1276
|
-
"prepare-local-utility": "dotenv -e .env -- sh -c 'UTILITY_PATH=${LOCAL_UTILITY_PATH:-../utility}; pnpm --prefix \"$UTILITY_PATH\" run build && pnpm uninstall @alextheman/utility && pnpm install file:\"$UTILITY_PATH\"'",
|
|
1277
|
-
"test": "vitest run",
|
|
1278
|
-
"test-end-to-end": "RUN_END_TO_END=true vitest run tests/end-to-end --reporter verbose",
|
|
1279
|
-
"test-watch": "vitest",
|
|
1280
|
-
"update-dependencies": "pnpm update --latest && pnpm update",
|
|
1281
|
-
"use-live-eslint-plugin": "pnpm run prepare-live-eslint-plugin && pnpm run lint",
|
|
1282
|
-
"use-live-utility": "pnpm run prepare-live-utility",
|
|
1283
|
-
"use-local-eslint-plugin": "pnpm run prepare-local-eslint-plugin && pnpm run lint",
|
|
1284
|
-
"use-local-utility": "pnpm run prepare-local-utility"
|
|
1285
|
-
},
|
|
1286
|
-
dependencies: {
|
|
1287
|
-
"@alextheman/utility": "^5.1.4",
|
|
1288
|
-
"@inquirer/prompts": "^8.2.1",
|
|
1289
|
-
"boxen": "^8.0.1",
|
|
1290
|
-
"canvas": "^3.2.1",
|
|
1291
|
-
"chalk": "^5.6.2",
|
|
1292
|
-
"commander": "^14.0.3",
|
|
1293
|
-
"dotenv": "^17.3.1",
|
|
1294
|
-
"dotenv-stringify": "^3.0.1",
|
|
1295
|
-
"execa": "^9.6.1",
|
|
1296
|
-
"figlet": "^1.10.0",
|
|
1297
|
-
"gray-matter": "^4.0.3",
|
|
1298
|
-
"libsodium-wrappers": "^0.8.2",
|
|
1299
|
-
"supports-color": "^10.2.2",
|
|
1300
|
-
"update-notifier": "^7.3.1",
|
|
1301
|
-
"zod": "^4.3.6"
|
|
1302
|
-
},
|
|
1303
|
-
devDependencies: {
|
|
1304
|
-
"@alextheman/eslint-plugin": "^5.8.1",
|
|
1305
|
-
"@commander-js/extra-typings": "^14.0.0",
|
|
1306
|
-
"@types/eslint": "^9.6.1",
|
|
1307
|
-
"@types/node": "^25.3.0",
|
|
1308
|
-
"@types/update-notifier": "^6.0.8",
|
|
1309
|
-
"dotenv-cli": "^11.0.0",
|
|
1310
|
-
"eslint": "^10.0.1",
|
|
1311
|
-
"husky": "^9.1.7",
|
|
1312
|
-
"prettier": "^3.8.1",
|
|
1313
|
-
"tempy": "^3.2.0",
|
|
1314
|
-
"ts-node": "^10.9.2",
|
|
1315
|
-
"tsdown": "^0.20.3",
|
|
1316
|
-
"typescript": "^5.9.3",
|
|
1317
|
-
"typescript-eslint": "^8.56.0",
|
|
1318
|
-
"vite-tsconfig-paths": "^6.1.1",
|
|
1319
|
-
"vitest": "^4.0.18"
|
|
1320
|
-
},
|
|
1321
|
-
packageManager: "pnpm@10.30.1+sha512.3590e550d5384caa39bd5c7c739f72270234b2f6059e13018f975c313b1eb9fefcc09714048765d4d9efe961382c312e624572c0420762bdc5d5940cdf9be73a",
|
|
1322
|
-
engines: { "node": ">=22.0.0" },
|
|
1323
|
-
pnpm: { "onlyBuiltDependencies": [
|
|
1324
|
-
"canvas",
|
|
1325
|
-
"core-js",
|
|
1326
|
-
"esbuild",
|
|
1327
|
-
"fsevents",
|
|
1328
|
-
"unrs-resolver"
|
|
1329
|
-
] }
|
|
1330
|
-
};
|
|
1331
1271
|
|
|
1332
1272
|
//#endregion
|
|
1333
|
-
//#region src/
|
|
1334
|
-
async function checkUpdate(
|
|
1273
|
+
//#region src/utility/updates/checkUpdate.ts
|
|
1274
|
+
async function checkUpdate(options) {
|
|
1335
1275
|
const currentVersion = new VersionNumber(version);
|
|
1336
1276
|
const { stdout: npmViewResult } = await execa`npm view alex-c-line version`;
|
|
1337
1277
|
const latestVersion = new VersionNumber(npmViewResult.trim());
|
|
@@ -1351,40 +1291,25 @@ async function checkUpdate(program) {
|
|
|
1351
1291
|
return centerLine(line, width);
|
|
1352
1292
|
}).join("\n")
|
|
1353
1293
|
});
|
|
1354
|
-
if (program)
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
}
|
|
1361
|
-
|
|
1362
|
-
//#endregion
|
|
1363
|
-
//#region src/utility/errors/convertDataErrorToProgramError.ts
|
|
1364
|
-
function convertDataErrorToProgramError(dataError, programError, options) {
|
|
1365
|
-
programError(dataError.message, {
|
|
1366
|
-
exitCode: options?.exitCode ?? 1,
|
|
1367
|
-
code: dataError.code
|
|
1368
|
-
});
|
|
1369
|
-
}
|
|
1370
|
-
|
|
1371
|
-
//#endregion
|
|
1372
|
-
//#region src/utility/miscellaneous/parseZodSchemaForProgram.ts
|
|
1373
|
-
function parseZodSchemaForProgram(programError, schema, data) {
|
|
1374
|
-
try {
|
|
1375
|
-
return parseZodSchema(schema, data);
|
|
1376
|
-
} catch (error) {
|
|
1377
|
-
if (DataError.check(error)) convertDataErrorToProgramError(error, programError);
|
|
1378
|
-
throw error;
|
|
1379
|
-
}
|
|
1294
|
+
if (options?.program) {
|
|
1295
|
+
const { program } = options;
|
|
1296
|
+
program.error(messageWithArtwork, {
|
|
1297
|
+
exitCode: 2,
|
|
1298
|
+
code: "OUTDATED_VERSION"
|
|
1299
|
+
});
|
|
1300
|
+
} else console.info(messageWithArtwork);
|
|
1301
|
+
} else if (options?.logNoUpdates) console.info(`alex-c-line is up to date (${currentVersion}).`);
|
|
1380
1302
|
}
|
|
1381
1303
|
|
|
1382
1304
|
//#endregion
|
|
1383
|
-
//#region src/commands/update
|
|
1305
|
+
//#region src/commands/update.ts
|
|
1384
1306
|
const optionsSchema = z.object({ check: z.boolean().optional() });
|
|
1385
1307
|
function update(program) {
|
|
1386
|
-
program.command("update").description("Handle updates of the currently installed alex-c-line").option("--check", "Check for available updates").action(async (rawOptions) => {
|
|
1387
|
-
if (parseZodSchemaForProgram(program.error, optionsSchema, rawOptions).check) await checkUpdate(
|
|
1308
|
+
program.command("update").description("Handle updates of the currently installed alex-c-line").option("--check", "Check for available updates").option("--apply", "Apply the latest update").action(async (rawOptions) => {
|
|
1309
|
+
if (parseZodSchemaForProgram(program.error, optionsSchema, rawOptions).check) await checkUpdate({
|
|
1310
|
+
program,
|
|
1311
|
+
logNoUpdates: true
|
|
1312
|
+
});
|
|
1388
1313
|
else console.info("Unsupported option. Expected `--check`.");
|
|
1389
1314
|
});
|
|
1390
1315
|
}
|
|
@@ -1408,7 +1333,7 @@ const alexCLineProjectCacheSchema = z.object({ useLocalPackage: z.object({ depen
|
|
|
1408
1333
|
})) }).partial() }).partial();
|
|
1409
1334
|
|
|
1410
1335
|
//#endregion
|
|
1411
|
-
//#region src/cache/project/
|
|
1336
|
+
//#region src/cache/project/parseAlexCLineProjectCache.ts
|
|
1412
1337
|
function parseAlexCLineProjectCache(data) {
|
|
1413
1338
|
return parseZodSchema(alexCLineProjectCacheSchema, data);
|
|
1414
1339
|
}
|
|
@@ -1491,7 +1416,7 @@ function useLocalPackage(program) {
|
|
|
1491
1416
|
exitCode: 1,
|
|
1492
1417
|
code: "ALEX_C_LINE_PRIVATE_CONFIG_NOT_FOUND"
|
|
1493
1418
|
});
|
|
1494
|
-
const { useLocalPackage: { localPackages } } = await loadAlexCLinePrivateConfig(configPath);
|
|
1419
|
+
const { useLocalPackage: { enableCache, localPackages } } = await loadAlexCLinePrivateConfig(configPath);
|
|
1495
1420
|
const localPackage = localPackages[packageName];
|
|
1496
1421
|
if (!localPackage) throw new DataError({
|
|
1497
1422
|
packageName,
|
|
@@ -1528,7 +1453,7 @@ function useLocalPackage(program) {
|
|
|
1528
1453
|
code: "LOCAL_ALEX_C_LINE_ERROR"
|
|
1529
1454
|
});
|
|
1530
1455
|
} else {
|
|
1531
|
-
const cacheContents = await loadAlexCLineProjectCache();
|
|
1456
|
+
const cacheContents = enableCache ? await loadAlexCLineProjectCache() : {};
|
|
1532
1457
|
if (!reverse) {
|
|
1533
1458
|
if (prepareScript) await execa({ cwd: localPackagePath })`${packageManager} run ${prepareScript}`;
|
|
1534
1459
|
if (!keepOldTarballs) await removeAllTarballs(localPackagePath, packageName);
|
|
@@ -1550,7 +1475,7 @@ function useLocalPackage(program) {
|
|
|
1550
1475
|
cwd: process.cwd(),
|
|
1551
1476
|
stdio: "inherit"
|
|
1552
1477
|
});
|
|
1553
|
-
if (!reverse) {
|
|
1478
|
+
if (!reverse && enableCache) {
|
|
1554
1479
|
const packageCacheData = {
|
|
1555
1480
|
...cacheContents?.useLocalPackage?.dependencies?.[packageName] ?? {},
|
|
1556
1481
|
previousVersion: dependencies[packageName],
|
|
@@ -1567,7 +1492,7 @@ function useLocalPackage(program) {
|
|
|
1567
1492
|
}
|
|
1568
1493
|
}
|
|
1569
1494
|
});
|
|
1570
|
-
} else await createAlexCLineProjectCache({
|
|
1495
|
+
} else if (enableCache) await createAlexCLineProjectCache({
|
|
1571
1496
|
...cacheContents ?? {},
|
|
1572
1497
|
useLocalPackage: {
|
|
1573
1498
|
...cacheContents?.useLocalPackage,
|
|
@@ -1635,6 +1560,7 @@ function loadCommands(program, commandMap) {
|
|
|
1635
1560
|
function createCommands(program) {
|
|
1636
1561
|
loadCommands(program, {
|
|
1637
1562
|
artwork,
|
|
1563
|
+
cachePath,
|
|
1638
1564
|
checkForFileDependencies,
|
|
1639
1565
|
checkLockfileVersionDiscrepancy,
|
|
1640
1566
|
checkReleaseNote,
|
|
@@ -1685,18 +1611,61 @@ function formatError(error) {
|
|
|
1685
1611
|
throw error;
|
|
1686
1612
|
}
|
|
1687
1613
|
|
|
1614
|
+
//#endregion
|
|
1615
|
+
//#region src/cache/global/createAlexCLineGlobalCache.ts
|
|
1616
|
+
async function createAlexCLineGlobalCache(cacheData) {
|
|
1617
|
+
await mkdir(ALEX_C_LINE_GLOBAL_CACHE_DIRECTORY, { recursive: true });
|
|
1618
|
+
await writeFile(ALEX_C_LINE_GLOBAL_CACHE_PATH, JSON.stringify(cacheData, null, 2));
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
//#endregion
|
|
1622
|
+
//#region src/cache/global/types/AlexCLineGlobalCache.ts
|
|
1623
|
+
const alexCLineGlobalCacheSchema = z.looseObject({ updateChecks: z.record(z.string(), z.string()).optional() });
|
|
1624
|
+
|
|
1625
|
+
//#endregion
|
|
1626
|
+
//#region src/cache/global/parseAlexCLineGlobalCache.ts
|
|
1627
|
+
function parseAlexCLineGlobalCache(input) {
|
|
1628
|
+
return parseZodSchema(alexCLineGlobalCacheSchema, input);
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
//#endregion
|
|
1632
|
+
//#region src/cache/global/loadAlexCLineGlobalCache.ts
|
|
1633
|
+
async function loadAlexCLineGlobalCache() {
|
|
1634
|
+
try {
|
|
1635
|
+
return parseAlexCLineGlobalCache(JSON.parse(await readFile(ALEX_C_LINE_GLOBAL_CACHE_PATH, "utf-8")));
|
|
1636
|
+
} catch (error) {
|
|
1637
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") return null;
|
|
1638
|
+
throw error;
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
//#endregion
|
|
1643
|
+
//#region src/utility/updates/runAutomatedUpdateCheck.ts
|
|
1644
|
+
async function runAutomatedUpdateCheck() {
|
|
1645
|
+
try {
|
|
1646
|
+
const cacheData = await loadAlexCLineGlobalCache();
|
|
1647
|
+
const lastChecked = cacheData?.updateChecks?.[version] ? new Date(cacheData?.updateChecks?.[version]) : void 0;
|
|
1648
|
+
const currentDate = /* @__PURE__ */ new Date();
|
|
1649
|
+
if (lastChecked === void 0 || currentDate.getTime() - lastChecked.getTime() >= ONE_DAY_IN_MILLISECONDS) {
|
|
1650
|
+
await checkUpdate({ logNoUpdates: false });
|
|
1651
|
+
await createAlexCLineGlobalCache({
|
|
1652
|
+
...cacheData ?? {},
|
|
1653
|
+
updateChecks: {
|
|
1654
|
+
...cacheData?.updateChecks ?? {},
|
|
1655
|
+
[version]: currentDate.toISOString()
|
|
1656
|
+
}
|
|
1657
|
+
});
|
|
1658
|
+
}
|
|
1659
|
+
} catch {}
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1688
1662
|
//#endregion
|
|
1689
1663
|
//#region src/index.ts
|
|
1690
1664
|
(async () => {
|
|
1691
1665
|
try {
|
|
1692
1666
|
const program = new Command();
|
|
1693
1667
|
program.name(name).description(description).version(version);
|
|
1694
|
-
if (!(process.env.NODE_ENV === "test" || parseBoolean(process.env.RUN_END_TO_END ?? "false") || parseBoolean(process.env.CI ?? "false")))
|
|
1695
|
-
${await createAlexCLineArtwork({ includeColors: Boolean(supportsColor.stdout) })}
|
|
1696
|
-
A new update of \`alex-c-line\` is available!
|
|
1697
|
-
{currentVersion} → {latestVersion}
|
|
1698
|
-
Run \`{updateCommand}\` to update.
|
|
1699
|
-
` });
|
|
1668
|
+
if (!(process.env.NODE_ENV === "test" || parseBoolean(process.env.RUN_END_TO_END ?? "false") || parseBoolean(process.env.CI ?? "false"))) await runAutomatedUpdateCheck();
|
|
1700
1669
|
createCommands(program);
|
|
1701
1670
|
await program.parseAsync(process.argv);
|
|
1702
1671
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alex-c-line",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.30.0",
|
|
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.3.0",
|
|
38
38
|
"@inquirer/prompts": "^8.2.1",
|
|
39
39
|
"boxen": "^8.0.1",
|
|
40
40
|
"canvas": "^3.2.1",
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"commander": "^14.0.3",
|
|
43
43
|
"dotenv": "^17.3.1",
|
|
44
44
|
"dotenv-stringify": "^3.0.1",
|
|
45
|
+
"env-paths": "^4.0.0",
|
|
45
46
|
"execa": "^9.6.1",
|
|
46
47
|
"figlet": "^1.10.0",
|
|
47
48
|
"gray-matter": "^4.0.3",
|
|
48
49
|
"libsodium-wrappers": "^0.8.2",
|
|
49
50
|
"supports-color": "^10.2.2",
|
|
50
|
-
"update-notifier": "^7.3.1",
|
|
51
51
|
"zod": "^4.3.6"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
},
|
|
74
74
|
"scripts": {
|
|
75
75
|
"build": "tsdown",
|
|
76
|
-
"command": "bash -c 'pnpm run build && echo && echo \"Command output:\" && node dist/index.js
|
|
76
|
+
"command": "bash -c 'pnpm run build && echo && echo \"Command output:\" && node dist/index.js \"$@\"' --",
|
|
77
77
|
"create-local-package": "pnpm run build && rm -f alex-c-line-*.tgz && pnpm pack",
|
|
78
78
|
"create-release-note": "bash -c 'git pull origin main && pnpm run command create-release-note-2 $@' --",
|
|
79
79
|
"format": "pnpm run format-prettier && pnpm run format-eslint",
|