alex-c-line 2.0.0 → 2.0.2
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/README.md +16 -12
- package/dist/configs/index.cjs +16 -35
- package/dist/configs/index.d.cts +5 -5
- package/dist/configs/index.d.ts +5 -5
- package/dist/configs/index.js +4 -18
- package/dist/configs/internal/index.cjs +2 -7
- package/dist/configs/internal/index.d.cts +5 -5
- package/dist/configs/internal/index.d.ts +5 -7
- package/dist/configs/internal/index.js +1 -5
- package/dist/index.cjs +46 -175
- package/dist/index.js +40 -164
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -7,16 +7,12 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
20
16
|
}
|
|
21
17
|
return to;
|
|
22
18
|
};
|
|
@@ -24,7 +20,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
20
|
value: mod,
|
|
25
21
|
enumerable: true
|
|
26
22
|
}) : target, mod));
|
|
27
|
-
|
|
28
23
|
//#endregion
|
|
29
24
|
let _alextheman_utility = require("@alextheman/utility");
|
|
30
25
|
let commander = require("commander");
|
|
@@ -55,7 +50,6 @@ let supports_color = require("supports-color");
|
|
|
55
50
|
supports_color = __toESM(supports_color);
|
|
56
51
|
let node_crypto = require("node:crypto");
|
|
57
52
|
let semver = require("semver");
|
|
58
|
-
|
|
59
53
|
//#region src/utility/miscellaneous/centerLine.ts
|
|
60
54
|
function centerLine(text, width) {
|
|
61
55
|
const padding = Math.max(0, width - text.length);
|
|
@@ -63,7 +57,6 @@ function centerLine(text, width) {
|
|
|
63
57
|
const right = padding - left;
|
|
64
58
|
return " ".repeat(left) + text + " ".repeat(right);
|
|
65
59
|
}
|
|
66
|
-
|
|
67
60
|
//#endregion
|
|
68
61
|
//#region src/utility/miscellaneous/createAlexCLineArtwork.ts
|
|
69
62
|
async function createAlexCLineArtwork(options) {
|
|
@@ -84,7 +77,6 @@ async function createAlexCLineArtwork(options) {
|
|
|
84
77
|
borderColor: "cyanBright"
|
|
85
78
|
}) : output;
|
|
86
79
|
}
|
|
87
|
-
|
|
88
80
|
//#endregion
|
|
89
81
|
//#region src/cli/commands/artwork/log.ts
|
|
90
82
|
function artworkLog(program) {
|
|
@@ -102,7 +94,6 @@ function artworkLog(program) {
|
|
|
102
94
|
}));
|
|
103
95
|
});
|
|
104
96
|
}
|
|
105
|
-
|
|
106
97
|
//#endregion
|
|
107
98
|
//#region src/utility/miscellaneous/asciiToPng.ts
|
|
108
99
|
async function asciiToPng(ascii, options) {
|
|
@@ -135,7 +126,6 @@ async function asciiToPng(ascii, options) {
|
|
|
135
126
|
await (0, node_fs_promises.mkdir)(node_path.default.dirname(outputPath), { recursive: true });
|
|
136
127
|
await (0, node_fs_promises.writeFile)(outputPath, canvas$1.toBuffer("image/png"));
|
|
137
128
|
}
|
|
138
|
-
|
|
139
129
|
//#endregion
|
|
140
130
|
//#region src/cli/commands/artwork/save.ts
|
|
141
131
|
function artworkSave(program) {
|
|
@@ -154,13 +144,11 @@ function artworkSave(program) {
|
|
|
154
144
|
console.info(`Artwork saved successfully to ${node_path.default.resolve(filePath.endsWith(".png") ? filePath : `${filePath}.png`)}`);
|
|
155
145
|
});
|
|
156
146
|
}
|
|
157
|
-
|
|
158
147
|
//#endregion
|
|
159
148
|
//#region src/utility/miscellaneous/loadCommands.ts
|
|
160
149
|
function loadCommands(program, commandMap) {
|
|
161
150
|
for (const loader of Object.values(commandMap)) loader(program);
|
|
162
151
|
}
|
|
163
|
-
|
|
164
152
|
//#endregion
|
|
165
153
|
//#region src/cli/commands/artwork/index.ts
|
|
166
154
|
function artwork(program) {
|
|
@@ -169,13 +157,8 @@ function artwork(program) {
|
|
|
169
157
|
artworkSave
|
|
170
158
|
});
|
|
171
159
|
}
|
|
172
|
-
|
|
173
|
-
//#endregion
|
|
174
|
-
//#region src/cache/global/envPaths.ts
|
|
175
|
-
const alexCLineEnvPaths = (0, env_paths.default)("alex-c-line");
|
|
176
|
-
const { cache: ALEX_C_LINE_GLOBAL_CACHE_DIRECTORY } = alexCLineEnvPaths;
|
|
160
|
+
const { cache: ALEX_C_LINE_GLOBAL_CACHE_DIRECTORY } = (0, env_paths.default)("alex-c-line");
|
|
177
161
|
const ALEX_C_LINE_GLOBAL_CACHE_PATH = node_path.default.join(ALEX_C_LINE_GLOBAL_CACHE_DIRECTORY, "cache.json");
|
|
178
|
-
|
|
179
162
|
//#endregion
|
|
180
163
|
//#region src/cli/commands/cache/path.ts
|
|
181
164
|
function cachePath(program) {
|
|
@@ -183,36 +166,32 @@ function cachePath(program) {
|
|
|
183
166
|
console.info(ALEX_C_LINE_GLOBAL_CACHE_PATH);
|
|
184
167
|
});
|
|
185
168
|
}
|
|
186
|
-
|
|
187
169
|
//#endregion
|
|
188
170
|
//#region src/cli/commands/cache/index.ts
|
|
189
171
|
function cache(program) {
|
|
190
172
|
loadCommands(program.command("cache").description("Commands related to the alex-c-line cache"), { cachePath });
|
|
191
173
|
}
|
|
192
|
-
|
|
193
174
|
//#endregion
|
|
194
175
|
//#region src/utility/constants/errorPrefix.ts
|
|
195
|
-
const errorPrefix = "❌ ERROR";
|
|
196
|
-
|
|
176
|
+
const errorPrefix = "❌ ERROR:";
|
|
197
177
|
//#endregion
|
|
198
178
|
//#region src/utility/envFile/upsertDotenvFile.ts
|
|
199
179
|
async function upsertDotenvFile(contents, envFilePath) {
|
|
200
180
|
await (0, node_fs_promises.writeFile)(node_path.default.join(process.cwd(), envFilePath), (0, _alextheman_utility.stringifyDotenv)(contents));
|
|
201
181
|
}
|
|
202
|
-
|
|
203
182
|
//#endregion
|
|
204
183
|
//#region src/cli/commands/env-file/edit/addVariable.ts
|
|
205
184
|
async function addVariable(program, envFileContents, file) {
|
|
206
185
|
const newVariableName = await (0, _inquirer_prompts.input)({ message: "Please enter the name of the environment variable you would like to add." });
|
|
207
186
|
if (newVariableName in envFileContents) program.error(`
|
|
208
|
-
${errorPrefix}
|
|
187
|
+
${errorPrefix} Error with chosen environment variable name ${newVariableName}.
|
|
209
188
|
Variable name already exists. If you wish to edit this variable, please select it from the initial menu instead.
|
|
210
189
|
`, {
|
|
211
190
|
exitCode: 2,
|
|
212
191
|
code: "DUPLICATE_ENVIRONMENT_VARIABLE_NAME"
|
|
213
192
|
});
|
|
214
193
|
if (/[ \t\r\n]/.test(newVariableName)) program.error(_alextheman_utility.normaliseIndents`
|
|
215
|
-
${errorPrefix}
|
|
194
|
+
${errorPrefix} Error with chosen environment variable name ${newVariableName}.
|
|
216
195
|
Environment variables are not allowed to have whitespace.
|
|
217
196
|
`, {
|
|
218
197
|
exitCode: 2,
|
|
@@ -225,7 +204,6 @@ async function addVariable(program, envFileContents, file) {
|
|
|
225
204
|
}, file);
|
|
226
205
|
console.info(`${newVariableName} successfully added.`);
|
|
227
206
|
}
|
|
228
|
-
|
|
229
207
|
//#endregion
|
|
230
208
|
//#region src/cli/commands/env-file/edit/deleteVariable.ts
|
|
231
209
|
async function deleteVariable(envFileContents, variableToEdit, file) {
|
|
@@ -236,7 +214,6 @@ async function deleteVariable(envFileContents, variableToEdit, file) {
|
|
|
236
214
|
await upsertDotenvFile((0, _alextheman_utility.omitProperties)(envFileContents, variableToEdit), file);
|
|
237
215
|
console.info(`${String(variableToEdit)} successfully deleted.`);
|
|
238
216
|
}
|
|
239
|
-
|
|
240
217
|
//#endregion
|
|
241
218
|
//#region src/cli/commands/env-file/edit/editVariable.ts
|
|
242
219
|
async function editVariable(envFileContents, variableToEdit, file) {
|
|
@@ -247,7 +224,6 @@ async function editVariable(envFileContents, variableToEdit, file) {
|
|
|
247
224
|
}, file);
|
|
248
225
|
console.info(`${String(variableToEdit)} successfully updated.`);
|
|
249
226
|
}
|
|
250
|
-
|
|
251
227
|
//#endregion
|
|
252
228
|
//#region src/utility/envFile/redact.ts
|
|
253
229
|
function redact(secretString) {
|
|
@@ -255,7 +231,6 @@ function redact(secretString) {
|
|
|
255
231
|
return "*";
|
|
256
232
|
}, secretString.length).join("")} (redacted for security)>`;
|
|
257
233
|
}
|
|
258
|
-
|
|
259
234
|
//#endregion
|
|
260
235
|
//#region src/cli/commands/env-file/edit/changeExistingVariable.ts
|
|
261
236
|
async function changeExistingVariable(envFileContents, variableToEdit, file) {
|
|
@@ -282,7 +257,6 @@ async function changeExistingVariable(envFileContents, variableToEdit, file) {
|
|
|
282
257
|
default: console.error("Unrecognised option");
|
|
283
258
|
}
|
|
284
259
|
}
|
|
285
|
-
|
|
286
260
|
//#endregion
|
|
287
261
|
//#region src/utility/envFile/parseDotenvFile.ts
|
|
288
262
|
async function parseDotenvFile(envFilePath) {
|
|
@@ -293,7 +267,6 @@ async function parseDotenvFile(envFilePath) {
|
|
|
293
267
|
throw error;
|
|
294
268
|
}
|
|
295
269
|
}
|
|
296
|
-
|
|
297
270
|
//#endregion
|
|
298
271
|
//#region src/cli/commands/env-file/edit/index.ts
|
|
299
272
|
function envFileEdit(program) {
|
|
@@ -340,13 +313,11 @@ function envFileEdit(program) {
|
|
|
340
313
|
}
|
|
341
314
|
});
|
|
342
315
|
}
|
|
343
|
-
|
|
344
316
|
//#endregion
|
|
345
317
|
//#region src/cli/commands/env-file/index.ts
|
|
346
318
|
function envFile(program) {
|
|
347
319
|
loadCommands(program.command("env-file").description("Interact with a .env file"), { envFileEdit });
|
|
348
320
|
}
|
|
349
|
-
|
|
350
321
|
//#endregion
|
|
351
322
|
//#region src/cli/commands/internal/check-lockfile-version-discrepancy.ts
|
|
352
323
|
function checkLockfileVersionDiscrepancy(program) {
|
|
@@ -355,21 +326,20 @@ function checkLockfileVersionDiscrepancy(program) {
|
|
|
355
326
|
const { version: packageVersion } = JSON.parse(await (0, node_fs_promises.readFile)(node_path.default.resolve(process.cwd(), "package.json"), "utf-8"));
|
|
356
327
|
const { version: packageLockVersion } = JSON.parse(await (0, node_fs_promises.readFile)(node_path.default.resolve(process.cwd(), "package-lock.json"), "utf-8"));
|
|
357
328
|
if (packageVersion !== packageLockVersion) {
|
|
358
|
-
console.error(
|
|
329
|
+
console.error(`${errorPrefix} package.json and package-lock.json out of sync. Please run \`npm install\` to fix this.`);
|
|
359
330
|
process.exitCode = 1;
|
|
360
331
|
return;
|
|
361
332
|
}
|
|
362
333
|
console.info("package.json and package-lock.json versions in sync.");
|
|
363
334
|
});
|
|
364
335
|
}
|
|
365
|
-
|
|
366
336
|
//#endregion
|
|
367
337
|
//#region src/cli/commands/internal/git-post-merge-cleanup.ts
|
|
368
338
|
function gitPostMergeCleanup(program) {
|
|
369
339
|
program.command("git-post-merge-cleanup").alias("git-cleanup").description("Run after merging into a given branch to quickly clean up").argument("[branch]", "The branch you want to merge into", "main").option("--rebase", "Enable if your repository mainly rebases into main", true).action(async (branch, { rebase }) => {
|
|
370
340
|
console.info(`Running git-post-merge-cleanup in ${rebase ? "rebase" : "merge"} mode...`);
|
|
371
341
|
const { stdout: currentBranch } = await execa.execa`git branch --show-current`;
|
|
372
|
-
if (currentBranch === branch) program.error(
|
|
342
|
+
if (currentBranch === branch) program.error(`${errorPrefix} Cannot run cleanup on ${branch} branch!`, {
|
|
373
343
|
exitCode: 1,
|
|
374
344
|
code: "INVALID_BRANCH"
|
|
375
345
|
});
|
|
@@ -385,7 +355,7 @@ function gitPostMergeCleanup(program) {
|
|
|
385
355
|
const { stdout: changes } = await execa.execa`git diff ${branch}..${currentBranch}`;
|
|
386
356
|
if (changes) {
|
|
387
357
|
await execa.execa`git checkout ${currentBranch}`;
|
|
388
|
-
program.error(
|
|
358
|
+
program.error(`${errorPrefix} Changes on branch not fully merged!`, {
|
|
389
359
|
exitCode: 1,
|
|
390
360
|
code: "CHANGES_NOT_MERGED"
|
|
391
361
|
});
|
|
@@ -395,7 +365,7 @@ function gitPostMergeCleanup(program) {
|
|
|
395
365
|
const { stdout: branchDeletedMessage, exitCode } = await (0, execa.execa)({ reject: false })`git branch --delete ${currentBranch}`;
|
|
396
366
|
if (exitCode !== 0) {
|
|
397
367
|
await execa.execa`git checkout ${currentBranch}`;
|
|
398
|
-
program.error(
|
|
368
|
+
program.error(`${errorPrefix} Changes on branch not fully merged!`, {
|
|
399
369
|
exitCode: 1,
|
|
400
370
|
code: "CHANGES_NOT_MERGED"
|
|
401
371
|
});
|
|
@@ -404,7 +374,6 @@ function gitPostMergeCleanup(program) {
|
|
|
404
374
|
}
|
|
405
375
|
});
|
|
406
376
|
}
|
|
407
|
-
|
|
408
377
|
//#endregion
|
|
409
378
|
//#region src/utility/fileSystem/findPackageRoot.ts
|
|
410
379
|
async function findPackageRoot(startDirectory, packageName) {
|
|
@@ -420,12 +389,10 @@ async function findPackageRoot(startDirectory, packageName) {
|
|
|
420
389
|
}
|
|
421
390
|
throw new _alextheman_utility.DataError({ packageName }, "PACKAGE_ROOT_NOT_FOUND", `Could not find package root for ${packageName}`);
|
|
422
391
|
}
|
|
423
|
-
|
|
424
392
|
//#endregion
|
|
425
393
|
//#region src/utility/constants/alexCLinePackageRoot.ts
|
|
426
394
|
const __filename$3 = (0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
|
|
427
395
|
const ALEX_C_LINE_PACKAGE_ROOT = findPackageRoot(node_path.default.dirname(__filename$3), "alex-c-line");
|
|
428
|
-
|
|
429
396
|
//#endregion
|
|
430
397
|
//#region src/cli/commands/internal/outdated-dependencies.ts
|
|
431
398
|
function outdatedDependencies(program) {
|
|
@@ -448,7 +415,6 @@ function outdatedDependencies(program) {
|
|
|
448
415
|
}).join("\n")));
|
|
449
416
|
});
|
|
450
417
|
}
|
|
451
|
-
|
|
452
418
|
//#endregion
|
|
453
419
|
//#region src/cli/commands/internal/index.ts
|
|
454
420
|
function internal(program) {
|
|
@@ -458,7 +424,6 @@ function internal(program) {
|
|
|
458
424
|
outdatedDependencies
|
|
459
425
|
});
|
|
460
426
|
}
|
|
461
|
-
|
|
462
427
|
//#endregion
|
|
463
428
|
//#region src/cache/project/createAlexCLineProjectCache.ts
|
|
464
429
|
async function createAlexCLineProjectCache(cacheContents) {
|
|
@@ -466,7 +431,6 @@ async function createAlexCLineProjectCache(cacheContents) {
|
|
|
466
431
|
await (0, node_fs_promises.mkdir)(node_path.default.dirname(cacheFilePath), { recursive: true });
|
|
467
432
|
await (0, node_fs_promises.writeFile)(cacheFilePath, JSON.stringify(cacheContents, void 0, 2));
|
|
468
433
|
}
|
|
469
|
-
|
|
470
434
|
//#endregion
|
|
471
435
|
//#region src/configs/helpers/preCommit/definePreCommitConfig.ts
|
|
472
436
|
const preCommitStepOptionsSchema = zod.default.strictObject({ arguments: zod.default.array(zod.default.string()).optional() });
|
|
@@ -483,7 +447,6 @@ const preCommitConfigSchema = zod.default.strictObject({
|
|
|
483
447
|
])),
|
|
484
448
|
updateIndex: zod.default.boolean().optional()
|
|
485
449
|
});
|
|
486
|
-
|
|
487
450
|
//#endregion
|
|
488
451
|
//#region src/configs/helpers/template/pullRequest/defineTemplatePullRequestSchema.ts
|
|
489
452
|
const templatePullRequestBaseSchema = zod.default.strictObject({ projectName: zod.default.string().optional() });
|
|
@@ -498,7 +461,6 @@ const templatePullRequestSchema = zod.default.discriminatedUnion("category", [te
|
|
|
498
461
|
function parseTemplatePullRequestConfig(input) {
|
|
499
462
|
return (0, _alextheman_utility.parseZodSchema)(templatePullRequestSchema, input);
|
|
500
463
|
}
|
|
501
|
-
|
|
502
464
|
//#endregion
|
|
503
465
|
//#region src/configs/helpers/defineAlexCLineConfig.ts
|
|
504
466
|
const alexCLineConfigSchema = zod.default.strictObject({
|
|
@@ -508,7 +470,6 @@ const alexCLineConfigSchema = zod.default.strictObject({
|
|
|
508
470
|
async function parseAlexCLineConfig(input) {
|
|
509
471
|
return await (0, _alextheman_utility.parseZodSchemaAsync)(alexCLineConfigSchema, input);
|
|
510
472
|
}
|
|
511
|
-
|
|
512
473
|
//#endregion
|
|
513
474
|
//#region src/configs/types/ConfigFileName.ts
|
|
514
475
|
const ConfigFileName = {
|
|
@@ -521,14 +482,12 @@ const PrivateConfigFileName = {
|
|
|
521
482
|
ES_MODULES_JAVASCRIPT: ".alex-c-line.private.config.mjs",
|
|
522
483
|
COMMON_JS_JAVASCRIPT: ".alex-c-line.private.config.cjs"
|
|
523
484
|
};
|
|
524
|
-
|
|
525
485
|
//#endregion
|
|
526
486
|
//#region src/configs/types/template/pullRequest/PullRequestTemplateCategory.ts
|
|
527
487
|
const PullRequestTemplateCategory = {
|
|
528
488
|
GENERAL: "general",
|
|
529
489
|
INFRASTRUCTURE: "infrastructure"
|
|
530
490
|
};
|
|
531
|
-
|
|
532
491
|
//#endregion
|
|
533
492
|
//#region src/configs/helpers/defineAlexCLinePrivateConfig.ts
|
|
534
493
|
const alexCLinePrivateConfigSchema = zod.default.object({ localPackage: zod.default.strictObject({
|
|
@@ -544,7 +503,6 @@ const alexCLinePrivateConfigSchema = zod.default.object({ localPackage: zod.defa
|
|
|
544
503
|
function parseAlexCLinePrivateConfig(data) {
|
|
545
504
|
return (0, _alextheman_utility.parseZodSchema)(alexCLinePrivateConfigSchema, data);
|
|
546
505
|
}
|
|
547
|
-
|
|
548
506
|
//#endregion
|
|
549
507
|
//#region src/cache/project/types/AlexCLineProjectCache.ts
|
|
550
508
|
const alexCLineProjectCacheSchema = zod.default.object({ useLocalPackage: zod.default.object({ dependencies: zod.default.record(zod.default.string(), zod.default.object({
|
|
@@ -554,13 +512,11 @@ const alexCLineProjectCacheSchema = zod.default.object({ useLocalPackage: zod.de
|
|
|
554
512
|
}),
|
|
555
513
|
dependencyGroup: zod.default.enum(_alextheman_utility_internal.DependencyGroup)
|
|
556
514
|
})) }).partial() }).partial();
|
|
557
|
-
|
|
558
515
|
//#endregion
|
|
559
516
|
//#region src/cache/project/parseAlexCLineProjectCache.ts
|
|
560
517
|
function parseAlexCLineProjectCache(data) {
|
|
561
518
|
return (0, _alextheman_utility.parseZodSchema)(alexCLineProjectCacheSchema, data);
|
|
562
519
|
}
|
|
563
|
-
|
|
564
520
|
//#endregion
|
|
565
521
|
//#region src/cache/project/loadAlexCLineProjectCache.ts
|
|
566
522
|
async function loadAlexCLineProjectCache(cachePath = node_path.default.join(".alex-c-line", "cache.json")) {
|
|
@@ -572,7 +528,6 @@ async function loadAlexCLineProjectCache(cachePath = node_path.default.join(".al
|
|
|
572
528
|
throw error;
|
|
573
529
|
}
|
|
574
530
|
}
|
|
575
|
-
|
|
576
531
|
//#endregion
|
|
577
532
|
//#region src/utility/fileSystem/doesFileExist.ts
|
|
578
533
|
async function doesFileExist(filePath) {
|
|
@@ -584,7 +539,6 @@ async function doesFileExist(filePath) {
|
|
|
584
539
|
throw error;
|
|
585
540
|
}
|
|
586
541
|
}
|
|
587
|
-
|
|
588
542
|
//#endregion
|
|
589
543
|
//#region src/utility/configs/findAlexCLineConfig.ts
|
|
590
544
|
async function findAlexCLineConfig(cwd, validConfigFileNames = [
|
|
@@ -597,7 +551,6 @@ async function findAlexCLineConfig(cwd, validConfigFileNames = [
|
|
|
597
551
|
if (await doesFileExist(fullPath)) return fullPath;
|
|
598
552
|
}
|
|
599
553
|
}
|
|
600
|
-
|
|
601
554
|
//#endregion
|
|
602
555
|
//#region src/utility/configs/loadAlexCLinePrivateConfig.ts
|
|
603
556
|
const require$2 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
@@ -609,7 +562,6 @@ async function loadAlexCLinePrivateConfig(filePath) {
|
|
|
609
562
|
const module = await import((0, node_url.pathToFileURL)(filePath).href);
|
|
610
563
|
return parseAlexCLinePrivateConfig(module.default ?? module);
|
|
611
564
|
}
|
|
612
|
-
|
|
613
565
|
//#endregion
|
|
614
566
|
//#region src/utility/fileSystem/findTgzFile.ts
|
|
615
567
|
async function findTgzFile(packagePath, packageManager) {
|
|
@@ -631,7 +583,6 @@ async function findTgzFile(packagePath, packageManager) {
|
|
|
631
583
|
}, "AMBIGUOUS_RESOLUTION", "There are too many .tgz files with the expected file name.");
|
|
632
584
|
return expectedTgzFileName;
|
|
633
585
|
}
|
|
634
|
-
|
|
635
586
|
//#endregion
|
|
636
587
|
//#region src/utility/miscellaneous/removeAllTarballs.ts
|
|
637
588
|
async function removeAllTarballs(packagePath, packageName) {
|
|
@@ -643,7 +594,6 @@ async function removeAllTarballs(packagePath, packageName) {
|
|
|
643
594
|
return (0, node_fs_promises.rm)(node_path.default.join(packagePath, file), { force: true });
|
|
644
595
|
}));
|
|
645
596
|
}
|
|
646
|
-
|
|
647
597
|
//#endregion
|
|
648
598
|
//#region src/cli/commands/local-package/use.ts
|
|
649
599
|
function localPackageUse(program) {
|
|
@@ -653,10 +603,7 @@ function localPackageUse(program) {
|
|
|
653
603
|
PrivateConfigFileName.ES_MODULES_JAVASCRIPT,
|
|
654
604
|
PrivateConfigFileName.STANDARD_JAVASCRIPT
|
|
655
605
|
]);
|
|
656
|
-
if (!configPath)
|
|
657
|
-
exitCode: 1,
|
|
658
|
-
code: "ALEX_C_LINE_PRIVATE_CONFIG_NOT_FOUND"
|
|
659
|
-
});
|
|
606
|
+
if (!configPath) throw new _alextheman_utility.DataError({ configPath }, "ALEX_C_LINE_PRIVATE_CONFIG_NOT_FOUND", "Could not find the path to the alex-c-line private config file (should be `.alex-c-line.private.config.js`). Does it exist?");
|
|
660
607
|
const { localPackage: { enableCache, localPackages } } = await loadAlexCLinePrivateConfig(configPath);
|
|
661
608
|
const localPackage = localPackages[packageName];
|
|
662
609
|
if (!localPackage) throw new _alextheman_utility.DataError({
|
|
@@ -693,8 +640,8 @@ function localPackageUse(program) {
|
|
|
693
640
|
stdio: "inherit",
|
|
694
641
|
reject: false
|
|
695
642
|
});
|
|
696
|
-
if (exitCode !== 0
|
|
697
|
-
exitCode
|
|
643
|
+
if (exitCode !== 0) program.error(`${errorPrefix} An error occurred during the local \`alex-c-line\` run.`, {
|
|
644
|
+
exitCode,
|
|
698
645
|
code: "LOCAL_ALEX_C_LINE_ERROR"
|
|
699
646
|
});
|
|
700
647
|
} else {
|
|
@@ -750,13 +697,11 @@ function localPackageUse(program) {
|
|
|
750
697
|
}
|
|
751
698
|
});
|
|
752
699
|
}
|
|
753
|
-
|
|
754
700
|
//#endregion
|
|
755
701
|
//#region src/cli/commands/local-package/index.ts
|
|
756
702
|
function localPackage(program) {
|
|
757
703
|
loadCommands(program.command("local-package").description("Manage the use of local packages in your JavaScript project."), { localPackageUse });
|
|
758
704
|
}
|
|
759
|
-
|
|
760
705
|
//#endregion
|
|
761
706
|
//#region src/cli/commands/root/encrypt-with-key.ts
|
|
762
707
|
function encryptWithKey(program) {
|
|
@@ -764,23 +709,22 @@ function encryptWithKey(program) {
|
|
|
764
709
|
try {
|
|
765
710
|
console.info(await (0, _alextheman_utility.encryptWithKey)(publicKey, plaintextValue));
|
|
766
711
|
} catch {
|
|
767
|
-
program.error(
|
|
712
|
+
program.error(`${errorPrefix} Encryption failed. Please double-check that the given key is a valid base 64 string.`, {
|
|
768
713
|
exitCode: 1,
|
|
769
714
|
code: "ENCRYPTION_FAILED"
|
|
770
715
|
});
|
|
771
716
|
}
|
|
772
717
|
});
|
|
773
718
|
}
|
|
774
|
-
|
|
775
719
|
//#endregion
|
|
776
720
|
//#region src/cli/commands/root/pre-commit/createStepRunner.ts
|
|
777
721
|
const runCommandAndLogToConsole = (0, execa.execa)({
|
|
778
722
|
stdio: "inherit",
|
|
779
723
|
reject: false
|
|
780
724
|
});
|
|
781
|
-
async function evaluateResult(program, promisedResult, failedCommand) {
|
|
725
|
+
async function evaluateResult(program, promisedResult, failedCommand, boundOptions) {
|
|
782
726
|
const result = await promisedResult;
|
|
783
|
-
if (result.exitCode !== 0) program.error(`Command failed: ${failedCommand}`, {
|
|
727
|
+
if (result.exitCode !== 0 && (boundOptions.reject ?? true)) program.error(`Command failed: ${failedCommand}`, {
|
|
784
728
|
exitCode: result.exitCode ?? 1,
|
|
785
729
|
code: "PRE_COMMIT_FAILED"
|
|
786
730
|
});
|
|
@@ -791,11 +735,11 @@ function bindStepRunner(program, boundOptions) {
|
|
|
791
735
|
if (typeof first === "string") {
|
|
792
736
|
const command = first;
|
|
793
737
|
const args = second[0] ?? [];
|
|
794
|
-
return evaluateResult(program, runCommandAndLogToConsole(boundOptions)(command, args), `${command}${args.length ? ` ${args.join(" ")}` : ""}
|
|
738
|
+
return evaluateResult(program, runCommandAndLogToConsole(boundOptions)(command, args), `${command}${args.length ? ` ${args.join(" ")}` : ""}`, boundOptions);
|
|
795
739
|
}
|
|
796
740
|
if ((0, _alextheman_utility.isTemplateStringsArray)(first)) {
|
|
797
741
|
const args = (0, _alextheman_utility.getStringsAndInterpolations)(first, ...second);
|
|
798
|
-
return evaluateResult(program, runCommandAndLogToConsole(boundOptions)(...args), (0, _alextheman_utility.interpolate)(...args));
|
|
742
|
+
return evaluateResult(program, runCommandAndLogToConsole(boundOptions)(...args), (0, _alextheman_utility.interpolate)(...args), boundOptions);
|
|
799
743
|
}
|
|
800
744
|
return bindStepRunner(program, {
|
|
801
745
|
...boundOptions,
|
|
@@ -807,11 +751,10 @@ function bindStepRunner(program, boundOptions) {
|
|
|
807
751
|
function createStepRunner(program) {
|
|
808
752
|
return bindStepRunner(program, {});
|
|
809
753
|
}
|
|
810
|
-
|
|
811
754
|
//#endregion
|
|
812
755
|
//#region src/cli/commands/root/pre-commit/getCommandArguments.ts
|
|
813
756
|
function getCommandArguments(program, script, scripts, args) {
|
|
814
|
-
if (!(script in (scripts ?? {}))) program.error(
|
|
757
|
+
if (!(script in (scripts ?? {}))) program.error(`${errorPrefix} Could not find script \`${script}\` in package.json.`, {
|
|
815
758
|
exitCode: 1,
|
|
816
759
|
code: "SCRIPT_NOT_FOUND"
|
|
817
760
|
});
|
|
@@ -819,7 +762,6 @@ function getCommandArguments(program, script, scripts, args) {
|
|
|
819
762
|
if (args) result.push(...args);
|
|
820
763
|
return result;
|
|
821
764
|
}
|
|
822
|
-
|
|
823
765
|
//#endregion
|
|
824
766
|
//#region src/utility/configs/loadAlexCLineConfig.ts
|
|
825
767
|
const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
@@ -831,25 +773,21 @@ async function loadAlexCLineConfig(filePath) {
|
|
|
831
773
|
const module = await import((0, node_url.pathToFileURL)(filePath).href);
|
|
832
774
|
return await parseAlexCLineConfig(module.default ?? module);
|
|
833
775
|
}
|
|
834
|
-
|
|
835
776
|
//#endregion
|
|
836
777
|
//#region src/cli/commands/root/pre-commit/pre-commit.ts
|
|
837
778
|
function preCommit(program) {
|
|
838
779
|
program.command("pre-commit").description("Run the pre-commit scripts specified in the alex-c-line config (v2 experiment).").option("--allow-no-staged-changes", "Run even if nothing is staged").option("--no-update-index").option("--update-index", "Update the git index after the run").action(async (options) => {
|
|
839
780
|
const configPath = await findAlexCLineConfig(process.cwd());
|
|
840
|
-
if (!configPath)
|
|
841
|
-
exitCode: 1,
|
|
842
|
-
code: "ALEX_C_LINE_CONFIG_NOT_FOUND"
|
|
843
|
-
});
|
|
781
|
+
if (!configPath) throw new _alextheman_utility.DataError({ configPath }, "ALEX_C_LINE_CONFIG_NOT_FOUND", "Could not find the path to the alex-c-line config file. Does it exist?");
|
|
844
782
|
const { preCommit: preCommitConfig } = await loadAlexCLineConfig(configPath);
|
|
845
|
-
if (!preCommitConfig)
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
});
|
|
783
|
+
if (!preCommitConfig) throw new _alextheman_utility.DataError({
|
|
784
|
+
configPath,
|
|
785
|
+
preCommitConfig
|
|
786
|
+
}, "PRE_COMMIT_CONFIG_NOT_FOUND", "Could not find the pre-commit config in alex-c-line config.");
|
|
849
787
|
const { allowNoStagedChanges = options?.allowNoStagedChanges, updateIndex = options?.updateIndex } = preCommitConfig;
|
|
850
788
|
const { exitCode: diffExitCode } = await (0, execa.execa)({ reject: false })`git diff --cached --quiet`;
|
|
851
789
|
switch (diffExitCode) {
|
|
852
|
-
case 128: program.error(
|
|
790
|
+
case 128: program.error(`${errorPrefix} Not currently in a Git repository`, {
|
|
853
791
|
exitCode: 1,
|
|
854
792
|
code: "GIT_DIFF_FAILED"
|
|
855
793
|
});
|
|
@@ -871,7 +809,6 @@ function preCommit(program) {
|
|
|
871
809
|
if (updateIndex) await stepRunner`git update-index --again`;
|
|
872
810
|
});
|
|
873
811
|
}
|
|
874
|
-
|
|
875
812
|
//#endregion
|
|
876
813
|
//#region src/cli/commands/root/say-hello.ts
|
|
877
814
|
function sayHello(program) {
|
|
@@ -879,7 +816,6 @@ function sayHello(program) {
|
|
|
879
816
|
console.info("Hello!");
|
|
880
817
|
});
|
|
881
818
|
}
|
|
882
|
-
|
|
883
819
|
//#endregion
|
|
884
820
|
//#region src/cli/commands/root/index.ts
|
|
885
821
|
function root(program) {
|
|
@@ -889,7 +825,6 @@ function root(program) {
|
|
|
889
825
|
sayHello
|
|
890
826
|
});
|
|
891
827
|
}
|
|
892
|
-
|
|
893
828
|
//#endregion
|
|
894
829
|
//#region src/utility/markdownTemplates/pullRequest/getPullRequestTemplatesFromMarkdown.ts
|
|
895
830
|
const __filename$2 = (0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
|
|
@@ -927,7 +862,6 @@ async function getPullRequestTemplatesFromMarkdown(config) {
|
|
|
927
862
|
}
|
|
928
863
|
return allTemplates;
|
|
929
864
|
}
|
|
930
|
-
|
|
931
865
|
//#endregion
|
|
932
866
|
//#region src/cli/commands/template/pullRequest/create.ts
|
|
933
867
|
function templatePullRequestCreate(program) {
|
|
@@ -939,12 +873,7 @@ function templatePullRequestCreate(program) {
|
|
|
939
873
|
const configPath = await findAlexCLineConfig(process.cwd());
|
|
940
874
|
const { template: { pullRequest: config } = {} } = configPath ? await loadAlexCLineConfig(configPath) : {};
|
|
941
875
|
const packageInfo = await (0, _alextheman_utility_internal.getPackageJsonContents)(process.cwd());
|
|
942
|
-
const { name: projectName } = commandLineOptions.projectName || config?.projectName ? { name: commandLineOptions.projectName ?? config?.projectName } : (0, _alextheman_utility.parseZodSchema)(zod.default.object({ name: zod.default.string() }), packageInfo
|
|
943
|
-
program.error("Invalid package.json - expected package.json to contain a `name` property.", {
|
|
944
|
-
exitCode: 1,
|
|
945
|
-
code: "INVALID_PACKAGE_JSON"
|
|
946
|
-
});
|
|
947
|
-
});
|
|
876
|
+
const { name: projectName } = commandLineOptions.projectName || config?.projectName ? { name: commandLineOptions.projectName ?? config?.projectName } : (0, _alextheman_utility.parseZodSchema)(zod.default.object({ name: zod.default.string() }), packageInfo);
|
|
948
877
|
if (!projectName) throw new _alextheman_utility.DataError({ projectName }, "PROJECT_NAME_NOT_FOUND", "Could not resolve project name.");
|
|
949
878
|
const parsedOptions = parseTemplatePullRequestConfig((0, _alextheman_utility.removeUndefinedFromObject)({
|
|
950
879
|
category: commandLineOptions.category ?? config?.category ?? "general",
|
|
@@ -965,24 +894,28 @@ function templatePullRequestCreate(program) {
|
|
|
965
894
|
console.info("Pull request templates created.");
|
|
966
895
|
});
|
|
967
896
|
}
|
|
968
|
-
|
|
969
897
|
//#endregion
|
|
970
898
|
//#region src/cli/commands/template/pullRequest/index.ts
|
|
971
899
|
function templatePullRequest(program) {
|
|
972
900
|
loadCommands(program.command("pull-request").description("Manage the pull request templates."), { templatePullRequestCreate });
|
|
973
901
|
}
|
|
974
|
-
|
|
975
902
|
//#endregion
|
|
976
903
|
//#region src/utility/constants/successPrefix.ts
|
|
977
904
|
const successPrefix = chalk.default.green("✓");
|
|
978
|
-
|
|
905
|
+
//#endregion
|
|
906
|
+
//#region src/utility/errors/convertDataErrorToProgramError.ts
|
|
907
|
+
function convertDataErrorToProgramError(dataError, program, options) {
|
|
908
|
+
program.error(`${errorPrefix} ${dataError.message}`, {
|
|
909
|
+
exitCode: options?.exitCode ?? 1,
|
|
910
|
+
code: dataError.code
|
|
911
|
+
});
|
|
912
|
+
}
|
|
979
913
|
//#endregion
|
|
980
914
|
//#region src/utility/markdownTemplates/releaseNote/types/ReleaseStatus.ts
|
|
981
915
|
const ReleaseStatus = {
|
|
982
916
|
IN_PROGRESS: "In progress",
|
|
983
917
|
RELEASED: "Released"
|
|
984
918
|
};
|
|
985
|
-
|
|
986
919
|
//#endregion
|
|
987
920
|
//#region src/utility/markdownTemplates/releaseNote/parseReleaseStatus.ts
|
|
988
921
|
function parseReleaseStatus(data) {
|
|
@@ -990,20 +923,17 @@ function parseReleaseStatus(data) {
|
|
|
990
923
|
if (!Object.keys(ReleaseStatus).includes(normalisedStringifiedData)) new _alextheman_utility.DataError({ data }, "INVALID_RELEASE_STATUS", "Invalid release status. The release status must be one of \"In progress\" or \"Released\"");
|
|
991
924
|
return ReleaseStatus[normalisedStringifiedData];
|
|
992
925
|
}
|
|
993
|
-
|
|
994
926
|
//#endregion
|
|
995
927
|
//#region src/utility/markdownTemplates/createMarkdownComment.ts
|
|
996
928
|
function createMarkdownComment(comment) {
|
|
997
929
|
if (comment.startsWith("<!--") && comment.endsWith("-->")) return comment;
|
|
998
930
|
return `<!-- ${comment} -->`;
|
|
999
931
|
}
|
|
1000
|
-
|
|
1001
932
|
//#endregion
|
|
1002
933
|
//#region src/utility/markdownTemplates/createMarkdownCommentPair.ts
|
|
1003
934
|
function createMarkdownCommentPair(comment) {
|
|
1004
935
|
return [createMarkdownComment(`${comment}-start`), createMarkdownComment(`${comment}-end`)];
|
|
1005
936
|
}
|
|
1006
|
-
|
|
1007
937
|
//#endregion
|
|
1008
938
|
//#region src/utility/markdownTemplates/getMarkdownBlock.ts
|
|
1009
939
|
function getMarkdownBlock(content, startMarker, endMarker) {
|
|
@@ -1012,7 +942,6 @@ function getMarkdownBlock(content, startMarker, endMarker) {
|
|
|
1012
942
|
if (startIndex === -1 || endIndex === -1 || endIndex < startIndex) return null;
|
|
1013
943
|
return content.slice(startIndex + startMarker.length, endIndex).trim();
|
|
1014
944
|
}
|
|
1015
|
-
|
|
1016
945
|
//#endregion
|
|
1017
946
|
//#region src/utility/markdownTemplates/normaliseMarkdown.ts
|
|
1018
947
|
function normaliseMarkdown(markdownString) {
|
|
@@ -1020,7 +949,6 @@ function normaliseMarkdown(markdownString) {
|
|
|
1020
949
|
return line.trim();
|
|
1021
950
|
}).filter(Boolean).join(" ").trim();
|
|
1022
951
|
}
|
|
1023
|
-
|
|
1024
952
|
//#endregion
|
|
1025
953
|
//#region src/utility/markdownTemplates/releaseNote/getReleaseStatus.ts
|
|
1026
954
|
function getReleaseStatus(content) {
|
|
@@ -1028,7 +956,6 @@ function getReleaseStatus(content) {
|
|
|
1028
956
|
if (releaseStatus === null) throw new _alextheman_utility.DataError({ releaseStatus }, "RELEASE_STATUS_NOT_FOUND", "Could not find release status in document.");
|
|
1029
957
|
return (0, _alextheman_utility.parseZodSchema)(zod.default.enum(ReleaseStatus), normaliseMarkdown(releaseStatus.split(":")[1]));
|
|
1030
958
|
}
|
|
1031
|
-
|
|
1032
959
|
//#endregion
|
|
1033
960
|
//#region src/utility/markdownTemplates/releaseNote/validateReleaseDocument.ts
|
|
1034
961
|
const __filename$1 = (0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
|
|
@@ -1066,7 +993,6 @@ async function validateReleaseDocument(projectName, version, content, allowedRel
|
|
|
1066
993
|
if (!content.includes("## Description of Changes")) throw new _alextheman_utility.DataError({ content }, "DESCRIPTION_NOT_FOUND", "Expected to find a description of changes but it was not found.");
|
|
1067
994
|
if (version.type === "major" && !content.includes("## Migration Notes")) throw new _alextheman_utility.DataError({ content }, "MIGRATION_NOTES_NOT_FOUND", "Major version notes must have migration notes as major versions are expected to be breaking changes that require users to migrate and refactor their code.");
|
|
1068
995
|
}
|
|
1069
|
-
|
|
1070
996
|
//#endregion
|
|
1071
997
|
//#region src/cli/commands/template/releaseNote/check.ts
|
|
1072
998
|
function templateReleaseNoteCheck(program) {
|
|
@@ -1082,34 +1008,27 @@ function templateReleaseNoteCheck(program) {
|
|
|
1082
1008
|
await validateReleaseDocument(name, documentVersion, fileContents, expectedReleaseStatus);
|
|
1083
1009
|
console.info(`${successPrefix} Release document is valid!`);
|
|
1084
1010
|
} catch (error) {
|
|
1085
|
-
if (_alextheman_utility.DataError.check(error)) program
|
|
1086
|
-
exitCode: 1,
|
|
1087
|
-
code: error.code
|
|
1088
|
-
});
|
|
1011
|
+
if (_alextheman_utility.DataError.check(error)) convertDataErrorToProgramError(error, program, { exitCode: 2 });
|
|
1089
1012
|
else throw error;
|
|
1090
1013
|
}
|
|
1091
1014
|
});
|
|
1092
1015
|
}
|
|
1093
|
-
|
|
1094
1016
|
//#endregion
|
|
1095
1017
|
//#region src/utility/markdownTemplates/releaseNote/getReleaseNotePath.ts
|
|
1096
1018
|
function getReleaseNotePath(versionNumber) {
|
|
1097
1019
|
return node_path.default.join("docs", "releases", versionNumber.format({ omitMinor: true }), versionNumber.format({ omitPatch: true }), `${versionNumber}.md`);
|
|
1098
1020
|
}
|
|
1099
|
-
|
|
1100
1021
|
//#endregion
|
|
1101
1022
|
//#region src/utility/markdownTemplates/getReleaseNoteTemplatesPath.ts
|
|
1102
1023
|
async function getReleaseNoteTemplatesPath() {
|
|
1103
1024
|
return node_path.default.join(await ALEX_C_LINE_PACKAGE_ROOT, "templates", "releases");
|
|
1104
1025
|
}
|
|
1105
|
-
|
|
1106
1026
|
//#endregion
|
|
1107
1027
|
//#region src/utility/markdownTemplates/getEditableSectionFromTemplate.ts
|
|
1108
1028
|
async function getEditableSectionFromTemplate(version) {
|
|
1109
1029
|
const templatesPath = await getReleaseNoteTemplatesPath();
|
|
1110
1030
|
return await (0, node_fs_promises.readFile)(node_path.default.join(templatesPath, version.type === "major" ? "editableSectionMajor.md" : "editableSection.md"), "utf-8");
|
|
1111
1031
|
}
|
|
1112
|
-
|
|
1113
1032
|
//#endregion
|
|
1114
1033
|
//#region src/utility/markdownTemplates/replaceMarkdownPlaceholders.ts
|
|
1115
1034
|
function replaceMarkdownPlaceholders(rawContent, templateVariables) {
|
|
@@ -1122,7 +1041,6 @@ function replaceMarkdownPlaceholders(rawContent, templateVariables) {
|
|
|
1122
1041
|
}
|
|
1123
1042
|
return finalContent;
|
|
1124
1043
|
}
|
|
1125
|
-
|
|
1126
1044
|
//#endregion
|
|
1127
1045
|
//#region src/utility/markdownTemplates/releaseNote/getReleaseNoteTemplateFromMarkdown.ts
|
|
1128
1046
|
async function getTemplateVariables(projectName, version, templateVariables) {
|
|
@@ -1153,7 +1071,6 @@ async function getReleaseNoteTemplateFromMarkdown(projectName, version, metadata
|
|
|
1153
1071
|
const templatesPath = node_path.default.join(await ALEX_C_LINE_PACKAGE_ROOT, "templates", "releases");
|
|
1154
1072
|
return replaceMarkdownPlaceholders(await (0, node_fs_promises.readFile)(node_path.default.join(templatesPath, `${version.type}.md`), "utf-8"), templateVariables);
|
|
1155
1073
|
}
|
|
1156
|
-
|
|
1157
1074
|
//#endregion
|
|
1158
1075
|
//#region src/cli/commands/template/releaseNote/create.ts
|
|
1159
1076
|
function templateReleaseNoteCreate(program) {
|
|
@@ -1173,12 +1090,7 @@ function templateReleaseNoteCreate(program) {
|
|
|
1173
1090
|
const { name, version: packageVersion } = (0, _alextheman_utility.parseZodSchema)(zod.default.object({
|
|
1174
1091
|
name: zod.default.string(),
|
|
1175
1092
|
version: zod.default.string()
|
|
1176
|
-
}), packageInfo
|
|
1177
|
-
program.error("Invalid package.json - expected package.json to contain a `name` and `version` property.", {
|
|
1178
|
-
exitCode: 1,
|
|
1179
|
-
code: "INVALID_PACKAGE_JSON"
|
|
1180
|
-
});
|
|
1181
|
-
});
|
|
1093
|
+
}), packageInfo);
|
|
1182
1094
|
const versionNumber = target instanceof _alextheman_utility.VersionNumber ? target : target ? new _alextheman_utility.VersionNumber(packageVersion).increment(target) : new _alextheman_utility.VersionNumber(packageVersion);
|
|
1183
1095
|
const releaseNotePath = getReleaseNotePath(versionNumber);
|
|
1184
1096
|
const releaseNoteTemplate = await getReleaseNoteTemplateFromMarkdown(name, versionNumber, { status: "In progress" });
|
|
@@ -1186,7 +1098,7 @@ function templateReleaseNoteCreate(program) {
|
|
|
1186
1098
|
await (0, node_fs_promises.mkdir)(node_path.default.dirname(releaseNotePath), { recursive: true });
|
|
1187
1099
|
await (0, node_fs_promises.writeFile)(releaseNotePath, releaseNoteTemplate, { flag: "wx" });
|
|
1188
1100
|
} catch (error) {
|
|
1189
|
-
if (error instanceof Error && "code" in error && error.code === "EEXIST") program.error(
|
|
1101
|
+
if (error instanceof Error && "code" in error && error.code === "EEXIST") program.error(`${errorPrefix} Release notes already exist.`, {
|
|
1190
1102
|
exitCode: 1,
|
|
1191
1103
|
code: "RELEASE_NOTE_EXISTS"
|
|
1192
1104
|
});
|
|
@@ -1195,7 +1107,6 @@ function templateReleaseNoteCreate(program) {
|
|
|
1195
1107
|
console.info(`Release notes for ${versionNumber} have been created in ${node_path.default.relative(process.cwd(), releaseNotePath)}`);
|
|
1196
1108
|
});
|
|
1197
1109
|
}
|
|
1198
|
-
|
|
1199
1110
|
//#endregion
|
|
1200
1111
|
//#region src/cli/commands/template/releaseNote/migrate.ts
|
|
1201
1112
|
function templateReleaseNoteMigrate(program) {
|
|
@@ -1251,7 +1162,6 @@ function templateReleaseNoteMigrate(program) {
|
|
|
1251
1162
|
console.info(dryRun ? `Dry run complete! ${filesMovedCount} files would be moved.` : `Migration complete! ${filesMovedCount} files moved.`);
|
|
1252
1163
|
});
|
|
1253
1164
|
}
|
|
1254
|
-
|
|
1255
1165
|
//#endregion
|
|
1256
1166
|
//#region src/cli/commands/template/releaseNote/path.ts
|
|
1257
1167
|
function templateReleaseNotePath(program) {
|
|
@@ -1266,17 +1176,13 @@ function templateReleaseNotePath(program) {
|
|
|
1266
1176
|
console.info(getReleaseNotePath(version));
|
|
1267
1177
|
});
|
|
1268
1178
|
}
|
|
1269
|
-
|
|
1270
1179
|
//#endregion
|
|
1271
1180
|
//#region src/cli/commands/template/releaseNote/set-status.ts
|
|
1272
1181
|
function templateReleaseNoteSetStatus(program) {
|
|
1273
1182
|
program.command("set-status").description("Change the release status on a given release document initially generated from the `create-release-note` command.").argument("<documentPath>", "The path to the document").argument("[status]", "The status to set the document to", parseReleaseStatus, ReleaseStatus.RELEASED).action(async (documentPath, status) => {
|
|
1274
1183
|
const packageInfo = await (0, _alextheman_utility_internal.getPackageJsonContents)(process.cwd());
|
|
1275
1184
|
const { name } = (0, _alextheman_utility.parseZodSchema)(zod.default.object({ name: zod.default.string() }), packageInfo, new _alextheman_utility.DataError({ name: packageInfo?.name }, "INVALID_PACKAGE_JSON", "Invalid package.json - expected package.json to contain a `name` property."));
|
|
1276
|
-
if (!documentPath.endsWith("md"))
|
|
1277
|
-
exitCode: 1,
|
|
1278
|
-
code: "INVALID_FILE_PATH"
|
|
1279
|
-
});
|
|
1185
|
+
if (!documentPath.endsWith("md")) throw new _alextheman_utility.DataError({ documentPath }, "INVALID_FILE_PATH", "Invalid file path. Path must lead to a .md file.");
|
|
1280
1186
|
const versionNumber = new _alextheman_utility.VersionNumber(node_path.default.basename(documentPath).split(".").filter((part) => {
|
|
1281
1187
|
return part !== "md";
|
|
1282
1188
|
}).join("."));
|
|
@@ -1296,7 +1202,6 @@ function templateReleaseNoteSetStatus(program) {
|
|
|
1296
1202
|
console.info(`Setting the status of ${documentPath} to "${status}"`);
|
|
1297
1203
|
});
|
|
1298
1204
|
}
|
|
1299
|
-
|
|
1300
1205
|
//#endregion
|
|
1301
1206
|
//#region src/cli/commands/template/releaseNote/index.ts
|
|
1302
1207
|
function templateReleaseNote(program) {
|
|
@@ -1308,7 +1213,6 @@ function templateReleaseNote(program) {
|
|
|
1308
1213
|
templateReleaseNoteSetStatus
|
|
1309
1214
|
});
|
|
1310
1215
|
}
|
|
1311
|
-
|
|
1312
1216
|
//#endregion
|
|
1313
1217
|
//#region src/cli/commands/template/index.ts
|
|
1314
1218
|
function template(program) {
|
|
@@ -1317,13 +1221,11 @@ function template(program) {
|
|
|
1317
1221
|
templateReleaseNote
|
|
1318
1222
|
});
|
|
1319
1223
|
}
|
|
1320
|
-
|
|
1321
1224
|
//#endregion
|
|
1322
1225
|
//#region package.json
|
|
1323
1226
|
var name = "alex-c-line";
|
|
1324
|
-
var version$1 = "2.0.
|
|
1227
|
+
var version$1 = "2.0.2";
|
|
1325
1228
|
var description = "Command-line tool with commands to streamline the developer workflow.";
|
|
1326
|
-
|
|
1327
1229
|
//#endregion
|
|
1328
1230
|
//#region src/utility/updates/checkUpdate.ts
|
|
1329
1231
|
async function checkUpdate(options) {
|
|
@@ -1355,7 +1257,6 @@ async function checkUpdate(options) {
|
|
|
1355
1257
|
} else console.info(messageWithArtwork);
|
|
1356
1258
|
} else if (options?.logNoUpdates) console.info(`alex-c-line is up to date (${currentVersion}).`);
|
|
1357
1259
|
}
|
|
1358
|
-
|
|
1359
1260
|
//#endregion
|
|
1360
1261
|
//#region src/cli/commands/update/check.ts
|
|
1361
1262
|
function checkUpdateCommand(program) {
|
|
@@ -1366,13 +1267,11 @@ function checkUpdateCommand(program) {
|
|
|
1366
1267
|
});
|
|
1367
1268
|
});
|
|
1368
1269
|
}
|
|
1369
|
-
|
|
1370
1270
|
//#endregion
|
|
1371
1271
|
//#region src/cli/commands/update/index.ts
|
|
1372
1272
|
function update(program) {
|
|
1373
1273
|
loadCommands(program.command("update").description("Handle updates of the currently installed alex-c-line"), { checkUpdateCommand });
|
|
1374
1274
|
}
|
|
1375
|
-
|
|
1376
1275
|
//#endregion
|
|
1377
1276
|
//#region src/cli/commands/uuid/generate.ts
|
|
1378
1277
|
function generateUUID(program) {
|
|
@@ -1380,22 +1279,11 @@ function generateUUID(program) {
|
|
|
1380
1279
|
console.info((0, node_crypto.randomUUID)());
|
|
1381
1280
|
});
|
|
1382
1281
|
}
|
|
1383
|
-
|
|
1384
1282
|
//#endregion
|
|
1385
1283
|
//#region src/cli/commands/uuid/index.ts
|
|
1386
1284
|
function uuid(program) {
|
|
1387
1285
|
loadCommands(program.command("uuid").description("Commands to help manage UUIDs"), { generateUUID });
|
|
1388
1286
|
}
|
|
1389
|
-
|
|
1390
|
-
//#endregion
|
|
1391
|
-
//#region src/utility/errors/convertDataErrorToProgramError.ts
|
|
1392
|
-
function convertDataErrorToProgramError(dataError, program, options) {
|
|
1393
|
-
program.error(dataError.message, {
|
|
1394
|
-
exitCode: options?.exitCode ?? 1,
|
|
1395
|
-
code: dataError.code
|
|
1396
|
-
});
|
|
1397
|
-
}
|
|
1398
|
-
|
|
1399
1287
|
//#endregion
|
|
1400
1288
|
//#region src/utility/miscellaneous/parseZodSchemaForProgram.ts
|
|
1401
1289
|
function parseZodSchemaForProgram(program, schema, data) {
|
|
@@ -1406,7 +1294,6 @@ function parseZodSchemaForProgram(program, schema, data) {
|
|
|
1406
1294
|
throw error;
|
|
1407
1295
|
}
|
|
1408
1296
|
}
|
|
1409
|
-
|
|
1410
1297
|
//#endregion
|
|
1411
1298
|
//#region src/cli/commands/version/format.ts
|
|
1412
1299
|
const versionFormatOptionsBaseSchema = zod.default.object({ prefix: zod.default.boolean().optional() });
|
|
@@ -1431,7 +1318,6 @@ function versionFormat(program) {
|
|
|
1431
1318
|
}));
|
|
1432
1319
|
});
|
|
1433
1320
|
}
|
|
1434
|
-
|
|
1435
1321
|
//#endregion
|
|
1436
1322
|
//#region src/cli/commands/version/increment.ts
|
|
1437
1323
|
function versionIncrement(program) {
|
|
@@ -1447,7 +1333,6 @@ function versionIncrement(program) {
|
|
|
1447
1333
|
console.info(version.increment(incrementType).format({ omitPrefix: !prefix }));
|
|
1448
1334
|
});
|
|
1449
1335
|
}
|
|
1450
|
-
|
|
1451
1336
|
//#endregion
|
|
1452
1337
|
//#region src/cli/commands/version/type.ts
|
|
1453
1338
|
function versionType(program) {
|
|
@@ -1457,7 +1342,6 @@ function versionType(program) {
|
|
|
1457
1342
|
console.info(version.type);
|
|
1458
1343
|
});
|
|
1459
1344
|
}
|
|
1460
|
-
|
|
1461
1345
|
//#endregion
|
|
1462
1346
|
//#region src/cli/commands/version/index.ts
|
|
1463
1347
|
function version(program) {
|
|
@@ -1467,7 +1351,6 @@ function version(program) {
|
|
|
1467
1351
|
versionType
|
|
1468
1352
|
});
|
|
1469
1353
|
}
|
|
1470
|
-
|
|
1471
1354
|
//#endregion
|
|
1472
1355
|
//#region src/cli/commands/package-json/check/noFileDependencies.ts
|
|
1473
1356
|
function findFileDependencies(dependencies) {
|
|
@@ -1487,14 +1370,13 @@ async function noFileDependencies(program) {
|
|
|
1487
1370
|
};
|
|
1488
1371
|
if (Object.keys(allFileDependencies.dependencies ?? {}).length === 0) delete allFileDependencies.dependencies;
|
|
1489
1372
|
if (Object.keys(allFileDependencies.devDependencies ?? {}).length === 0) delete allFileDependencies.devDependencies;
|
|
1490
|
-
if (Object.keys(allFileDependencies).length !== 0) program.error(`${errorPrefix}
|
|
1373
|
+
if (Object.keys(allFileDependencies).length !== 0) program.error(`${errorPrefix} File dependencies found:\n\n${JSON.stringify(allFileDependencies, void 0, 2)}
|
|
1491
1374
|
`, {
|
|
1492
1375
|
exitCode: 2,
|
|
1493
1376
|
code: "FILE_DEPENDENCIES_FOUND"
|
|
1494
1377
|
});
|
|
1495
1378
|
console.info(`${successPrefix} No file dependencies found!`);
|
|
1496
1379
|
}
|
|
1497
|
-
|
|
1498
1380
|
//#endregion
|
|
1499
1381
|
//#region src/cli/commands/package-json/check/noPreReleaseDependencies.ts
|
|
1500
1382
|
function isPreRelease(dependencyVersionRange) {
|
|
@@ -1511,7 +1393,7 @@ async function noPreReleaseDependencies(program) {
|
|
|
1511
1393
|
for (const [dependencyName, dependencyVersionRange] of Object.entries(dependencies)) if (isPreRelease(dependencyVersionRange)) preReleaseDependencies[dependencyName] = dependencyVersionRange;
|
|
1512
1394
|
for (const [dependencyName, dependencyVersionRange] of Object.entries(devDependencies)) if (isPreRelease(dependencyVersionRange)) preReleaseDevDependencies[dependencyName] = dependencyVersionRange;
|
|
1513
1395
|
if (Object.keys(preReleaseDependencies).length !== 0 || Object.keys(preReleaseDevDependencies).length !== 0) program.error(_alextheman_utility.normaliseIndents`
|
|
1514
|
-
${errorPrefix}
|
|
1396
|
+
${errorPrefix} Pre-release version pinning is not allowed. Found the following violations:
|
|
1515
1397
|
|
|
1516
1398
|
` + JSON.stringify({
|
|
1517
1399
|
dependencies: preReleaseDependencies,
|
|
@@ -1522,7 +1404,6 @@ async function noPreReleaseDependencies(program) {
|
|
|
1522
1404
|
});
|
|
1523
1405
|
console.info(`${successPrefix} No pre-release versions found!`);
|
|
1524
1406
|
}
|
|
1525
|
-
|
|
1526
1407
|
//#endregion
|
|
1527
1408
|
//#region src/cli/commands/package-json/check/index.ts
|
|
1528
1409
|
const RuleName = {
|
|
@@ -1539,13 +1420,11 @@ function packageJsonCheck(program) {
|
|
|
1539
1420
|
console.info(`${successPrefix} Success! All checks passed!`);
|
|
1540
1421
|
});
|
|
1541
1422
|
}
|
|
1542
|
-
|
|
1543
1423
|
//#endregion
|
|
1544
1424
|
//#region src/cli/commands/package-json/index.ts
|
|
1545
1425
|
function packageJson(program) {
|
|
1546
1426
|
loadCommands(program.command("package-json").description("Manage the package.json file"), { packageJsonCheck });
|
|
1547
1427
|
}
|
|
1548
|
-
|
|
1549
1428
|
//#endregion
|
|
1550
1429
|
//#region src/cli/commands/index.ts
|
|
1551
1430
|
function createCommands(program) {
|
|
@@ -1563,7 +1442,6 @@ function createCommands(program) {
|
|
|
1563
1442
|
version
|
|
1564
1443
|
});
|
|
1565
1444
|
}
|
|
1566
|
-
|
|
1567
1445
|
//#endregion
|
|
1568
1446
|
//#region src/utility/errors/formatError.ts
|
|
1569
1447
|
function formatError(error) {
|
|
@@ -1586,24 +1464,20 @@ function formatError(error) {
|
|
|
1586
1464
|
}
|
|
1587
1465
|
throw error;
|
|
1588
1466
|
}
|
|
1589
|
-
|
|
1590
1467
|
//#endregion
|
|
1591
1468
|
//#region src/cache/global/createAlexCLineGlobalCache.ts
|
|
1592
1469
|
async function createAlexCLineGlobalCache(cacheData) {
|
|
1593
1470
|
await (0, node_fs_promises.mkdir)(ALEX_C_LINE_GLOBAL_CACHE_DIRECTORY, { recursive: true });
|
|
1594
1471
|
await (0, node_fs_promises.writeFile)(ALEX_C_LINE_GLOBAL_CACHE_PATH, `${JSON.stringify(cacheData, null, 2)}\n`);
|
|
1595
1472
|
}
|
|
1596
|
-
|
|
1597
1473
|
//#endregion
|
|
1598
1474
|
//#region src/cache/global/types/AlexCLineGlobalCache.ts
|
|
1599
1475
|
const alexCLineGlobalCacheSchema = zod.default.looseObject({ updateChecks: zod.default.record(zod.default.string(), zod.default.string()).optional() });
|
|
1600
|
-
|
|
1601
1476
|
//#endregion
|
|
1602
1477
|
//#region src/cache/global/parseAlexCLineGlobalCache.ts
|
|
1603
1478
|
function parseAlexCLineGlobalCache(input) {
|
|
1604
1479
|
return (0, _alextheman_utility.parseZodSchema)(alexCLineGlobalCacheSchema, input);
|
|
1605
1480
|
}
|
|
1606
|
-
|
|
1607
1481
|
//#endregion
|
|
1608
1482
|
//#region src/cache/global/loadAlexCLineGlobalCache.ts
|
|
1609
1483
|
async function loadAlexCLineGlobalCache() {
|
|
@@ -1614,7 +1488,6 @@ async function loadAlexCLineGlobalCache() {
|
|
|
1614
1488
|
throw error;
|
|
1615
1489
|
}
|
|
1616
1490
|
}
|
|
1617
|
-
|
|
1618
1491
|
//#endregion
|
|
1619
1492
|
//#region src/utility/updates/runAutomatedUpdateCheck.ts
|
|
1620
1493
|
async function runAutomatedUpdateCheck() {
|
|
@@ -1634,7 +1507,6 @@ async function runAutomatedUpdateCheck() {
|
|
|
1634
1507
|
}
|
|
1635
1508
|
} catch {}
|
|
1636
1509
|
}
|
|
1637
|
-
|
|
1638
1510
|
//#endregion
|
|
1639
1511
|
//#region src/cli/index.ts
|
|
1640
1512
|
(async () => {
|
|
@@ -1648,5 +1520,4 @@ async function runAutomatedUpdateCheck() {
|
|
|
1648
1520
|
formatError(error);
|
|
1649
1521
|
}
|
|
1650
1522
|
})();
|
|
1651
|
-
|
|
1652
|
-
//#endregion
|
|
1523
|
+
//#endregion
|