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.js
CHANGED
|
@@ -20,7 +20,6 @@ import { parseFilePath } from "@alextheman/utility/node";
|
|
|
20
20
|
import supportsColor from "supports-color";
|
|
21
21
|
import { randomUUID } from "node:crypto";
|
|
22
22
|
import { minVersion, prerelease } from "semver";
|
|
23
|
-
|
|
24
23
|
//#region src/utility/miscellaneous/centerLine.ts
|
|
25
24
|
function centerLine(text, width) {
|
|
26
25
|
const padding = Math.max(0, width - text.length);
|
|
@@ -28,7 +27,6 @@ function centerLine(text, width) {
|
|
|
28
27
|
const right = padding - left;
|
|
29
28
|
return " ".repeat(left) + text + " ".repeat(right);
|
|
30
29
|
}
|
|
31
|
-
|
|
32
30
|
//#endregion
|
|
33
31
|
//#region src/utility/miscellaneous/createAlexCLineArtwork.ts
|
|
34
32
|
async function createAlexCLineArtwork(options) {
|
|
@@ -49,7 +47,6 @@ async function createAlexCLineArtwork(options) {
|
|
|
49
47
|
borderColor: "cyanBright"
|
|
50
48
|
}) : output;
|
|
51
49
|
}
|
|
52
|
-
|
|
53
50
|
//#endregion
|
|
54
51
|
//#region src/cli/commands/artwork/log.ts
|
|
55
52
|
function artworkLog(program) {
|
|
@@ -67,7 +64,6 @@ function artworkLog(program) {
|
|
|
67
64
|
}));
|
|
68
65
|
});
|
|
69
66
|
}
|
|
70
|
-
|
|
71
67
|
//#endregion
|
|
72
68
|
//#region src/utility/miscellaneous/asciiToPng.ts
|
|
73
69
|
async function asciiToPng(ascii, options) {
|
|
@@ -100,7 +96,6 @@ async function asciiToPng(ascii, options) {
|
|
|
100
96
|
await mkdir(path.dirname(outputPath), { recursive: true });
|
|
101
97
|
await writeFile(outputPath, canvas.toBuffer("image/png"));
|
|
102
98
|
}
|
|
103
|
-
|
|
104
99
|
//#endregion
|
|
105
100
|
//#region src/cli/commands/artwork/save.ts
|
|
106
101
|
function artworkSave(program) {
|
|
@@ -119,13 +114,11 @@ function artworkSave(program) {
|
|
|
119
114
|
console.info(`Artwork saved successfully to ${path.resolve(filePath.endsWith(".png") ? filePath : `${filePath}.png`)}`);
|
|
120
115
|
});
|
|
121
116
|
}
|
|
122
|
-
|
|
123
117
|
//#endregion
|
|
124
118
|
//#region src/utility/miscellaneous/loadCommands.ts
|
|
125
119
|
function loadCommands(program, commandMap) {
|
|
126
120
|
for (const loader of Object.values(commandMap)) loader(program);
|
|
127
121
|
}
|
|
128
|
-
|
|
129
122
|
//#endregion
|
|
130
123
|
//#region src/cli/commands/artwork/index.ts
|
|
131
124
|
function artwork(program) {
|
|
@@ -134,13 +127,8 @@ function artwork(program) {
|
|
|
134
127
|
artworkSave
|
|
135
128
|
});
|
|
136
129
|
}
|
|
137
|
-
|
|
138
|
-
//#endregion
|
|
139
|
-
//#region src/cache/global/envPaths.ts
|
|
140
|
-
const alexCLineEnvPaths = envPaths("alex-c-line");
|
|
141
|
-
const { cache: ALEX_C_LINE_GLOBAL_CACHE_DIRECTORY } = alexCLineEnvPaths;
|
|
130
|
+
const { cache: ALEX_C_LINE_GLOBAL_CACHE_DIRECTORY } = envPaths("alex-c-line");
|
|
142
131
|
const ALEX_C_LINE_GLOBAL_CACHE_PATH = path.join(ALEX_C_LINE_GLOBAL_CACHE_DIRECTORY, "cache.json");
|
|
143
|
-
|
|
144
132
|
//#endregion
|
|
145
133
|
//#region src/cli/commands/cache/path.ts
|
|
146
134
|
function cachePath(program) {
|
|
@@ -148,36 +136,32 @@ function cachePath(program) {
|
|
|
148
136
|
console.info(ALEX_C_LINE_GLOBAL_CACHE_PATH);
|
|
149
137
|
});
|
|
150
138
|
}
|
|
151
|
-
|
|
152
139
|
//#endregion
|
|
153
140
|
//#region src/cli/commands/cache/index.ts
|
|
154
141
|
function cache(program) {
|
|
155
142
|
loadCommands(program.command("cache").description("Commands related to the alex-c-line cache"), { cachePath });
|
|
156
143
|
}
|
|
157
|
-
|
|
158
144
|
//#endregion
|
|
159
145
|
//#region src/utility/constants/errorPrefix.ts
|
|
160
|
-
const errorPrefix = "❌ ERROR";
|
|
161
|
-
|
|
146
|
+
const errorPrefix = "❌ ERROR:";
|
|
162
147
|
//#endregion
|
|
163
148
|
//#region src/utility/envFile/upsertDotenvFile.ts
|
|
164
149
|
async function upsertDotenvFile(contents, envFilePath) {
|
|
165
150
|
await writeFile(path.join(process.cwd(), envFilePath), stringifyDotenv(contents));
|
|
166
151
|
}
|
|
167
|
-
|
|
168
152
|
//#endregion
|
|
169
153
|
//#region src/cli/commands/env-file/edit/addVariable.ts
|
|
170
154
|
async function addVariable(program, envFileContents, file) {
|
|
171
155
|
const newVariableName = await input({ message: "Please enter the name of the environment variable you would like to add." });
|
|
172
156
|
if (newVariableName in envFileContents) program.error(`
|
|
173
|
-
${errorPrefix}
|
|
157
|
+
${errorPrefix} Error with chosen environment variable name ${newVariableName}.
|
|
174
158
|
Variable name already exists. If you wish to edit this variable, please select it from the initial menu instead.
|
|
175
159
|
`, {
|
|
176
160
|
exitCode: 2,
|
|
177
161
|
code: "DUPLICATE_ENVIRONMENT_VARIABLE_NAME"
|
|
178
162
|
});
|
|
179
163
|
if (/[ \t\r\n]/.test(newVariableName)) program.error(normaliseIndents`
|
|
180
|
-
${errorPrefix}
|
|
164
|
+
${errorPrefix} Error with chosen environment variable name ${newVariableName}.
|
|
181
165
|
Environment variables are not allowed to have whitespace.
|
|
182
166
|
`, {
|
|
183
167
|
exitCode: 2,
|
|
@@ -190,7 +174,6 @@ async function addVariable(program, envFileContents, file) {
|
|
|
190
174
|
}, file);
|
|
191
175
|
console.info(`${newVariableName} successfully added.`);
|
|
192
176
|
}
|
|
193
|
-
|
|
194
177
|
//#endregion
|
|
195
178
|
//#region src/cli/commands/env-file/edit/deleteVariable.ts
|
|
196
179
|
async function deleteVariable(envFileContents, variableToEdit, file) {
|
|
@@ -201,7 +184,6 @@ async function deleteVariable(envFileContents, variableToEdit, file) {
|
|
|
201
184
|
await upsertDotenvFile(omitProperties(envFileContents, variableToEdit), file);
|
|
202
185
|
console.info(`${String(variableToEdit)} successfully deleted.`);
|
|
203
186
|
}
|
|
204
|
-
|
|
205
187
|
//#endregion
|
|
206
188
|
//#region src/cli/commands/env-file/edit/editVariable.ts
|
|
207
189
|
async function editVariable(envFileContents, variableToEdit, file) {
|
|
@@ -212,7 +194,6 @@ async function editVariable(envFileContents, variableToEdit, file) {
|
|
|
212
194
|
}, file);
|
|
213
195
|
console.info(`${String(variableToEdit)} successfully updated.`);
|
|
214
196
|
}
|
|
215
|
-
|
|
216
197
|
//#endregion
|
|
217
198
|
//#region src/utility/envFile/redact.ts
|
|
218
199
|
function redact(secretString) {
|
|
@@ -220,7 +201,6 @@ function redact(secretString) {
|
|
|
220
201
|
return "*";
|
|
221
202
|
}, secretString.length).join("")} (redacted for security)>`;
|
|
222
203
|
}
|
|
223
|
-
|
|
224
204
|
//#endregion
|
|
225
205
|
//#region src/cli/commands/env-file/edit/changeExistingVariable.ts
|
|
226
206
|
async function changeExistingVariable(envFileContents, variableToEdit, file) {
|
|
@@ -247,7 +227,6 @@ async function changeExistingVariable(envFileContents, variableToEdit, file) {
|
|
|
247
227
|
default: console.error("Unrecognised option");
|
|
248
228
|
}
|
|
249
229
|
}
|
|
250
|
-
|
|
251
230
|
//#endregion
|
|
252
231
|
//#region src/utility/envFile/parseDotenvFile.ts
|
|
253
232
|
async function parseDotenvFile(envFilePath) {
|
|
@@ -258,7 +237,6 @@ async function parseDotenvFile(envFilePath) {
|
|
|
258
237
|
throw error;
|
|
259
238
|
}
|
|
260
239
|
}
|
|
261
|
-
|
|
262
240
|
//#endregion
|
|
263
241
|
//#region src/cli/commands/env-file/edit/index.ts
|
|
264
242
|
function envFileEdit(program) {
|
|
@@ -305,13 +283,11 @@ function envFileEdit(program) {
|
|
|
305
283
|
}
|
|
306
284
|
});
|
|
307
285
|
}
|
|
308
|
-
|
|
309
286
|
//#endregion
|
|
310
287
|
//#region src/cli/commands/env-file/index.ts
|
|
311
288
|
function envFile(program) {
|
|
312
289
|
loadCommands(program.command("env-file").description("Interact with a .env file"), { envFileEdit });
|
|
313
290
|
}
|
|
314
|
-
|
|
315
291
|
//#endregion
|
|
316
292
|
//#region src/cli/commands/internal/check-lockfile-version-discrepancy.ts
|
|
317
293
|
function checkLockfileVersionDiscrepancy(program) {
|
|
@@ -320,21 +296,20 @@ function checkLockfileVersionDiscrepancy(program) {
|
|
|
320
296
|
const { version: packageVersion } = JSON.parse(await readFile(path.resolve(process.cwd(), "package.json"), "utf-8"));
|
|
321
297
|
const { version: packageLockVersion } = JSON.parse(await readFile(path.resolve(process.cwd(), "package-lock.json"), "utf-8"));
|
|
322
298
|
if (packageVersion !== packageLockVersion) {
|
|
323
|
-
console.error(
|
|
299
|
+
console.error(`${errorPrefix} package.json and package-lock.json out of sync. Please run \`npm install\` to fix this.`);
|
|
324
300
|
process.exitCode = 1;
|
|
325
301
|
return;
|
|
326
302
|
}
|
|
327
303
|
console.info("package.json and package-lock.json versions in sync.");
|
|
328
304
|
});
|
|
329
305
|
}
|
|
330
|
-
|
|
331
306
|
//#endregion
|
|
332
307
|
//#region src/cli/commands/internal/git-post-merge-cleanup.ts
|
|
333
308
|
function gitPostMergeCleanup(program) {
|
|
334
309
|
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 }) => {
|
|
335
310
|
console.info(`Running git-post-merge-cleanup in ${rebase ? "rebase" : "merge"} mode...`);
|
|
336
311
|
const { stdout: currentBranch } = await execa`git branch --show-current`;
|
|
337
|
-
if (currentBranch === branch) program.error(
|
|
312
|
+
if (currentBranch === branch) program.error(`${errorPrefix} Cannot run cleanup on ${branch} branch!`, {
|
|
338
313
|
exitCode: 1,
|
|
339
314
|
code: "INVALID_BRANCH"
|
|
340
315
|
});
|
|
@@ -350,7 +325,7 @@ function gitPostMergeCleanup(program) {
|
|
|
350
325
|
const { stdout: changes } = await execa`git diff ${branch}..${currentBranch}`;
|
|
351
326
|
if (changes) {
|
|
352
327
|
await execa`git checkout ${currentBranch}`;
|
|
353
|
-
program.error(
|
|
328
|
+
program.error(`${errorPrefix} Changes on branch not fully merged!`, {
|
|
354
329
|
exitCode: 1,
|
|
355
330
|
code: "CHANGES_NOT_MERGED"
|
|
356
331
|
});
|
|
@@ -360,7 +335,7 @@ function gitPostMergeCleanup(program) {
|
|
|
360
335
|
const { stdout: branchDeletedMessage, exitCode } = await execa({ reject: false })`git branch --delete ${currentBranch}`;
|
|
361
336
|
if (exitCode !== 0) {
|
|
362
337
|
await execa`git checkout ${currentBranch}`;
|
|
363
|
-
program.error(
|
|
338
|
+
program.error(`${errorPrefix} Changes on branch not fully merged!`, {
|
|
364
339
|
exitCode: 1,
|
|
365
340
|
code: "CHANGES_NOT_MERGED"
|
|
366
341
|
});
|
|
@@ -369,7 +344,6 @@ function gitPostMergeCleanup(program) {
|
|
|
369
344
|
}
|
|
370
345
|
});
|
|
371
346
|
}
|
|
372
|
-
|
|
373
347
|
//#endregion
|
|
374
348
|
//#region src/utility/fileSystem/findPackageRoot.ts
|
|
375
349
|
async function findPackageRoot(startDirectory, packageName) {
|
|
@@ -385,12 +359,10 @@ async function findPackageRoot(startDirectory, packageName) {
|
|
|
385
359
|
}
|
|
386
360
|
throw new DataError({ packageName }, "PACKAGE_ROOT_NOT_FOUND", `Could not find package root for ${packageName}`);
|
|
387
361
|
}
|
|
388
|
-
|
|
389
362
|
//#endregion
|
|
390
363
|
//#region src/utility/constants/alexCLinePackageRoot.ts
|
|
391
364
|
const __filename$2 = fileURLToPath(import.meta.url);
|
|
392
365
|
const ALEX_C_LINE_PACKAGE_ROOT = findPackageRoot(path.dirname(__filename$2), "alex-c-line");
|
|
393
|
-
|
|
394
366
|
//#endregion
|
|
395
367
|
//#region src/cli/commands/internal/outdated-dependencies.ts
|
|
396
368
|
function outdatedDependencies(program) {
|
|
@@ -413,7 +385,6 @@ function outdatedDependencies(program) {
|
|
|
413
385
|
}).join("\n")));
|
|
414
386
|
});
|
|
415
387
|
}
|
|
416
|
-
|
|
417
388
|
//#endregion
|
|
418
389
|
//#region src/cli/commands/internal/index.ts
|
|
419
390
|
function internal(program) {
|
|
@@ -423,7 +394,6 @@ function internal(program) {
|
|
|
423
394
|
outdatedDependencies
|
|
424
395
|
});
|
|
425
396
|
}
|
|
426
|
-
|
|
427
397
|
//#endregion
|
|
428
398
|
//#region src/cache/project/createAlexCLineProjectCache.ts
|
|
429
399
|
async function createAlexCLineProjectCache(cacheContents) {
|
|
@@ -431,7 +401,6 @@ async function createAlexCLineProjectCache(cacheContents) {
|
|
|
431
401
|
await mkdir(path.dirname(cacheFilePath), { recursive: true });
|
|
432
402
|
await writeFile(cacheFilePath, JSON.stringify(cacheContents, void 0, 2));
|
|
433
403
|
}
|
|
434
|
-
|
|
435
404
|
//#endregion
|
|
436
405
|
//#region src/configs/helpers/preCommit/definePreCommitConfig.ts
|
|
437
406
|
const preCommitStepOptionsSchema = z.strictObject({ arguments: z.array(z.string()).optional() });
|
|
@@ -448,7 +417,6 @@ const preCommitConfigSchema = z.strictObject({
|
|
|
448
417
|
])),
|
|
449
418
|
updateIndex: z.boolean().optional()
|
|
450
419
|
});
|
|
451
|
-
|
|
452
420
|
//#endregion
|
|
453
421
|
//#region src/configs/helpers/template/pullRequest/defineTemplatePullRequestSchema.ts
|
|
454
422
|
const templatePullRequestBaseSchema = z.strictObject({ projectName: z.string().optional() });
|
|
@@ -463,7 +431,6 @@ const templatePullRequestSchema = z.discriminatedUnion("category", [templatePull
|
|
|
463
431
|
function parseTemplatePullRequestConfig(input) {
|
|
464
432
|
return parseZodSchema(templatePullRequestSchema, input);
|
|
465
433
|
}
|
|
466
|
-
|
|
467
434
|
//#endregion
|
|
468
435
|
//#region src/configs/helpers/defineAlexCLineConfig.ts
|
|
469
436
|
const alexCLineConfigSchema = z.strictObject({
|
|
@@ -473,7 +440,6 @@ const alexCLineConfigSchema = z.strictObject({
|
|
|
473
440
|
async function parseAlexCLineConfig(input) {
|
|
474
441
|
return await parseZodSchemaAsync(alexCLineConfigSchema, input);
|
|
475
442
|
}
|
|
476
|
-
|
|
477
443
|
//#endregion
|
|
478
444
|
//#region src/configs/types/ConfigFileName.ts
|
|
479
445
|
const ConfigFileName = {
|
|
@@ -486,14 +452,12 @@ const PrivateConfigFileName = {
|
|
|
486
452
|
ES_MODULES_JAVASCRIPT: ".alex-c-line.private.config.mjs",
|
|
487
453
|
COMMON_JS_JAVASCRIPT: ".alex-c-line.private.config.cjs"
|
|
488
454
|
};
|
|
489
|
-
|
|
490
455
|
//#endregion
|
|
491
456
|
//#region src/configs/types/template/pullRequest/PullRequestTemplateCategory.ts
|
|
492
457
|
const PullRequestTemplateCategory = {
|
|
493
458
|
GENERAL: "general",
|
|
494
459
|
INFRASTRUCTURE: "infrastructure"
|
|
495
460
|
};
|
|
496
|
-
|
|
497
461
|
//#endregion
|
|
498
462
|
//#region src/configs/helpers/defineAlexCLinePrivateConfig.ts
|
|
499
463
|
const alexCLinePrivateConfigSchema = z.object({ localPackage: z.strictObject({
|
|
@@ -509,7 +473,6 @@ const alexCLinePrivateConfigSchema = z.object({ localPackage: z.strictObject({
|
|
|
509
473
|
function parseAlexCLinePrivateConfig(data) {
|
|
510
474
|
return parseZodSchema(alexCLinePrivateConfigSchema, data);
|
|
511
475
|
}
|
|
512
|
-
|
|
513
476
|
//#endregion
|
|
514
477
|
//#region src/cache/project/types/AlexCLineProjectCache.ts
|
|
515
478
|
const alexCLineProjectCacheSchema = z.object({ useLocalPackage: z.object({ dependencies: z.record(z.string(), z.object({
|
|
@@ -519,13 +482,11 @@ const alexCLineProjectCacheSchema = z.object({ useLocalPackage: z.object({ depen
|
|
|
519
482
|
}),
|
|
520
483
|
dependencyGroup: z.enum(DependencyGroup)
|
|
521
484
|
})) }).partial() }).partial();
|
|
522
|
-
|
|
523
485
|
//#endregion
|
|
524
486
|
//#region src/cache/project/parseAlexCLineProjectCache.ts
|
|
525
487
|
function parseAlexCLineProjectCache(data) {
|
|
526
488
|
return parseZodSchema(alexCLineProjectCacheSchema, data);
|
|
527
489
|
}
|
|
528
|
-
|
|
529
490
|
//#endregion
|
|
530
491
|
//#region src/cache/project/loadAlexCLineProjectCache.ts
|
|
531
492
|
async function loadAlexCLineProjectCache(cachePath = path.join(".alex-c-line", "cache.json")) {
|
|
@@ -537,7 +498,6 @@ async function loadAlexCLineProjectCache(cachePath = path.join(".alex-c-line", "
|
|
|
537
498
|
throw error;
|
|
538
499
|
}
|
|
539
500
|
}
|
|
540
|
-
|
|
541
501
|
//#endregion
|
|
542
502
|
//#region src/utility/fileSystem/doesFileExist.ts
|
|
543
503
|
async function doesFileExist(filePath) {
|
|
@@ -549,7 +509,6 @@ async function doesFileExist(filePath) {
|
|
|
549
509
|
throw error;
|
|
550
510
|
}
|
|
551
511
|
}
|
|
552
|
-
|
|
553
512
|
//#endregion
|
|
554
513
|
//#region src/utility/configs/findAlexCLineConfig.ts
|
|
555
514
|
async function findAlexCLineConfig(cwd, validConfigFileNames = [
|
|
@@ -562,7 +521,6 @@ async function findAlexCLineConfig(cwd, validConfigFileNames = [
|
|
|
562
521
|
if (await doesFileExist(fullPath)) return fullPath;
|
|
563
522
|
}
|
|
564
523
|
}
|
|
565
|
-
|
|
566
524
|
//#endregion
|
|
567
525
|
//#region src/utility/configs/loadAlexCLinePrivateConfig.ts
|
|
568
526
|
const require$1 = createRequire(import.meta.url);
|
|
@@ -574,7 +532,6 @@ async function loadAlexCLinePrivateConfig(filePath) {
|
|
|
574
532
|
const module = await import(pathToFileURL(filePath).href);
|
|
575
533
|
return parseAlexCLinePrivateConfig(module.default ?? module);
|
|
576
534
|
}
|
|
577
|
-
|
|
578
535
|
//#endregion
|
|
579
536
|
//#region src/utility/fileSystem/findTgzFile.ts
|
|
580
537
|
async function findTgzFile(packagePath, packageManager) {
|
|
@@ -596,7 +553,6 @@ async function findTgzFile(packagePath, packageManager) {
|
|
|
596
553
|
}, "AMBIGUOUS_RESOLUTION", "There are too many .tgz files with the expected file name.");
|
|
597
554
|
return expectedTgzFileName;
|
|
598
555
|
}
|
|
599
|
-
|
|
600
556
|
//#endregion
|
|
601
557
|
//#region src/utility/miscellaneous/removeAllTarballs.ts
|
|
602
558
|
async function removeAllTarballs(packagePath, packageName) {
|
|
@@ -608,7 +564,6 @@ async function removeAllTarballs(packagePath, packageName) {
|
|
|
608
564
|
return rm(path.join(packagePath, file), { force: true });
|
|
609
565
|
}));
|
|
610
566
|
}
|
|
611
|
-
|
|
612
567
|
//#endregion
|
|
613
568
|
//#region src/cli/commands/local-package/use.ts
|
|
614
569
|
function localPackageUse(program) {
|
|
@@ -618,10 +573,7 @@ function localPackageUse(program) {
|
|
|
618
573
|
PrivateConfigFileName.ES_MODULES_JAVASCRIPT,
|
|
619
574
|
PrivateConfigFileName.STANDARD_JAVASCRIPT
|
|
620
575
|
]);
|
|
621
|
-
if (!configPath)
|
|
622
|
-
exitCode: 1,
|
|
623
|
-
code: "ALEX_C_LINE_PRIVATE_CONFIG_NOT_FOUND"
|
|
624
|
-
});
|
|
576
|
+
if (!configPath) throw new 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?");
|
|
625
577
|
const { localPackage: { enableCache, localPackages } } = await loadAlexCLinePrivateConfig(configPath);
|
|
626
578
|
const localPackage = localPackages[packageName];
|
|
627
579
|
if (!localPackage) throw new DataError({
|
|
@@ -658,8 +610,8 @@ function localPackageUse(program) {
|
|
|
658
610
|
stdio: "inherit",
|
|
659
611
|
reject: false
|
|
660
612
|
});
|
|
661
|
-
if (exitCode !== 0
|
|
662
|
-
exitCode
|
|
613
|
+
if (exitCode !== 0) program.error(`${errorPrefix} An error occurred during the local \`alex-c-line\` run.`, {
|
|
614
|
+
exitCode,
|
|
663
615
|
code: "LOCAL_ALEX_C_LINE_ERROR"
|
|
664
616
|
});
|
|
665
617
|
} else {
|
|
@@ -715,13 +667,11 @@ function localPackageUse(program) {
|
|
|
715
667
|
}
|
|
716
668
|
});
|
|
717
669
|
}
|
|
718
|
-
|
|
719
670
|
//#endregion
|
|
720
671
|
//#region src/cli/commands/local-package/index.ts
|
|
721
672
|
function localPackage(program) {
|
|
722
673
|
loadCommands(program.command("local-package").description("Manage the use of local packages in your JavaScript project."), { localPackageUse });
|
|
723
674
|
}
|
|
724
|
-
|
|
725
675
|
//#endregion
|
|
726
676
|
//#region src/cli/commands/root/encrypt-with-key.ts
|
|
727
677
|
function encryptWithKey$1(program) {
|
|
@@ -729,23 +679,22 @@ function encryptWithKey$1(program) {
|
|
|
729
679
|
try {
|
|
730
680
|
console.info(await encryptWithKey(publicKey, plaintextValue));
|
|
731
681
|
} catch {
|
|
732
|
-
program.error(
|
|
682
|
+
program.error(`${errorPrefix} Encryption failed. Please double-check that the given key is a valid base 64 string.`, {
|
|
733
683
|
exitCode: 1,
|
|
734
684
|
code: "ENCRYPTION_FAILED"
|
|
735
685
|
});
|
|
736
686
|
}
|
|
737
687
|
});
|
|
738
688
|
}
|
|
739
|
-
|
|
740
689
|
//#endregion
|
|
741
690
|
//#region src/cli/commands/root/pre-commit/createStepRunner.ts
|
|
742
691
|
const runCommandAndLogToConsole = execa({
|
|
743
692
|
stdio: "inherit",
|
|
744
693
|
reject: false
|
|
745
694
|
});
|
|
746
|
-
async function evaluateResult(program, promisedResult, failedCommand) {
|
|
695
|
+
async function evaluateResult(program, promisedResult, failedCommand, boundOptions) {
|
|
747
696
|
const result = await promisedResult;
|
|
748
|
-
if (result.exitCode !== 0) program.error(`Command failed: ${failedCommand}`, {
|
|
697
|
+
if (result.exitCode !== 0 && (boundOptions.reject ?? true)) program.error(`Command failed: ${failedCommand}`, {
|
|
749
698
|
exitCode: result.exitCode ?? 1,
|
|
750
699
|
code: "PRE_COMMIT_FAILED"
|
|
751
700
|
});
|
|
@@ -756,11 +705,11 @@ function bindStepRunner(program, boundOptions) {
|
|
|
756
705
|
if (typeof first === "string") {
|
|
757
706
|
const command = first;
|
|
758
707
|
const args = second[0] ?? [];
|
|
759
|
-
return evaluateResult(program, runCommandAndLogToConsole(boundOptions)(command, args), `${command}${args.length ? ` ${args.join(" ")}` : ""}
|
|
708
|
+
return evaluateResult(program, runCommandAndLogToConsole(boundOptions)(command, args), `${command}${args.length ? ` ${args.join(" ")}` : ""}`, boundOptions);
|
|
760
709
|
}
|
|
761
710
|
if (isTemplateStringsArray(first)) {
|
|
762
711
|
const args = getStringsAndInterpolations(first, ...second);
|
|
763
|
-
return evaluateResult(program, runCommandAndLogToConsole(boundOptions)(...args), interpolate(...args));
|
|
712
|
+
return evaluateResult(program, runCommandAndLogToConsole(boundOptions)(...args), interpolate(...args), boundOptions);
|
|
764
713
|
}
|
|
765
714
|
return bindStepRunner(program, {
|
|
766
715
|
...boundOptions,
|
|
@@ -772,11 +721,10 @@ function bindStepRunner(program, boundOptions) {
|
|
|
772
721
|
function createStepRunner(program) {
|
|
773
722
|
return bindStepRunner(program, {});
|
|
774
723
|
}
|
|
775
|
-
|
|
776
724
|
//#endregion
|
|
777
725
|
//#region src/cli/commands/root/pre-commit/getCommandArguments.ts
|
|
778
726
|
function getCommandArguments(program, script, scripts, args) {
|
|
779
|
-
if (!(script in (scripts ?? {}))) program.error(
|
|
727
|
+
if (!(script in (scripts ?? {}))) program.error(`${errorPrefix} Could not find script \`${script}\` in package.json.`, {
|
|
780
728
|
exitCode: 1,
|
|
781
729
|
code: "SCRIPT_NOT_FOUND"
|
|
782
730
|
});
|
|
@@ -784,7 +732,6 @@ function getCommandArguments(program, script, scripts, args) {
|
|
|
784
732
|
if (args) result.push(...args);
|
|
785
733
|
return result;
|
|
786
734
|
}
|
|
787
|
-
|
|
788
735
|
//#endregion
|
|
789
736
|
//#region src/utility/configs/loadAlexCLineConfig.ts
|
|
790
737
|
const require = createRequire(import.meta.url);
|
|
@@ -796,25 +743,21 @@ async function loadAlexCLineConfig(filePath) {
|
|
|
796
743
|
const module = await import(pathToFileURL(filePath).href);
|
|
797
744
|
return await parseAlexCLineConfig(module.default ?? module);
|
|
798
745
|
}
|
|
799
|
-
|
|
800
746
|
//#endregion
|
|
801
747
|
//#region src/cli/commands/root/pre-commit/pre-commit.ts
|
|
802
748
|
function preCommit(program) {
|
|
803
749
|
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) => {
|
|
804
750
|
const configPath = await findAlexCLineConfig(process.cwd());
|
|
805
|
-
if (!configPath)
|
|
806
|
-
exitCode: 1,
|
|
807
|
-
code: "ALEX_C_LINE_CONFIG_NOT_FOUND"
|
|
808
|
-
});
|
|
751
|
+
if (!configPath) throw new DataError({ configPath }, "ALEX_C_LINE_CONFIG_NOT_FOUND", "Could not find the path to the alex-c-line config file. Does it exist?");
|
|
809
752
|
const { preCommit: preCommitConfig } = await loadAlexCLineConfig(configPath);
|
|
810
|
-
if (!preCommitConfig)
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
});
|
|
753
|
+
if (!preCommitConfig) throw new DataError({
|
|
754
|
+
configPath,
|
|
755
|
+
preCommitConfig
|
|
756
|
+
}, "PRE_COMMIT_CONFIG_NOT_FOUND", "Could not find the pre-commit config in alex-c-line config.");
|
|
814
757
|
const { allowNoStagedChanges = options?.allowNoStagedChanges, updateIndex = options?.updateIndex } = preCommitConfig;
|
|
815
758
|
const { exitCode: diffExitCode } = await execa({ reject: false })`git diff --cached --quiet`;
|
|
816
759
|
switch (diffExitCode) {
|
|
817
|
-
case 128: program.error(
|
|
760
|
+
case 128: program.error(`${errorPrefix} Not currently in a Git repository`, {
|
|
818
761
|
exitCode: 1,
|
|
819
762
|
code: "GIT_DIFF_FAILED"
|
|
820
763
|
});
|
|
@@ -836,7 +779,6 @@ function preCommit(program) {
|
|
|
836
779
|
if (updateIndex) await stepRunner`git update-index --again`;
|
|
837
780
|
});
|
|
838
781
|
}
|
|
839
|
-
|
|
840
782
|
//#endregion
|
|
841
783
|
//#region src/cli/commands/root/say-hello.ts
|
|
842
784
|
function sayHello(program) {
|
|
@@ -844,7 +786,6 @@ function sayHello(program) {
|
|
|
844
786
|
console.info("Hello!");
|
|
845
787
|
});
|
|
846
788
|
}
|
|
847
|
-
|
|
848
789
|
//#endregion
|
|
849
790
|
//#region src/cli/commands/root/index.ts
|
|
850
791
|
function root(program) {
|
|
@@ -854,7 +795,6 @@ function root(program) {
|
|
|
854
795
|
sayHello
|
|
855
796
|
});
|
|
856
797
|
}
|
|
857
|
-
|
|
858
798
|
//#endregion
|
|
859
799
|
//#region src/utility/markdownTemplates/pullRequest/getPullRequestTemplatesFromMarkdown.ts
|
|
860
800
|
const __filename$1 = fileURLToPath(import.meta.url);
|
|
@@ -892,7 +832,6 @@ async function getPullRequestTemplatesFromMarkdown(config) {
|
|
|
892
832
|
}
|
|
893
833
|
return allTemplates;
|
|
894
834
|
}
|
|
895
|
-
|
|
896
835
|
//#endregion
|
|
897
836
|
//#region src/cli/commands/template/pullRequest/create.ts
|
|
898
837
|
function templatePullRequestCreate(program) {
|
|
@@ -904,12 +843,7 @@ function templatePullRequestCreate(program) {
|
|
|
904
843
|
const configPath = await findAlexCLineConfig(process.cwd());
|
|
905
844
|
const { template: { pullRequest: config } = {} } = configPath ? await loadAlexCLineConfig(configPath) : {};
|
|
906
845
|
const packageInfo = await getPackageJsonContents(process.cwd());
|
|
907
|
-
const { name: projectName } = commandLineOptions.projectName || config?.projectName ? { name: commandLineOptions.projectName ?? config?.projectName } : parseZodSchema(z.object({ name: z.string() }), packageInfo
|
|
908
|
-
program.error("Invalid package.json - expected package.json to contain a `name` property.", {
|
|
909
|
-
exitCode: 1,
|
|
910
|
-
code: "INVALID_PACKAGE_JSON"
|
|
911
|
-
});
|
|
912
|
-
});
|
|
846
|
+
const { name: projectName } = commandLineOptions.projectName || config?.projectName ? { name: commandLineOptions.projectName ?? config?.projectName } : parseZodSchema(z.object({ name: z.string() }), packageInfo);
|
|
913
847
|
if (!projectName) throw new DataError({ projectName }, "PROJECT_NAME_NOT_FOUND", "Could not resolve project name.");
|
|
914
848
|
const parsedOptions = parseTemplatePullRequestConfig(removeUndefinedFromObject({
|
|
915
849
|
category: commandLineOptions.category ?? config?.category ?? "general",
|
|
@@ -930,24 +864,28 @@ function templatePullRequestCreate(program) {
|
|
|
930
864
|
console.info("Pull request templates created.");
|
|
931
865
|
});
|
|
932
866
|
}
|
|
933
|
-
|
|
934
867
|
//#endregion
|
|
935
868
|
//#region src/cli/commands/template/pullRequest/index.ts
|
|
936
869
|
function templatePullRequest(program) {
|
|
937
870
|
loadCommands(program.command("pull-request").description("Manage the pull request templates."), { templatePullRequestCreate });
|
|
938
871
|
}
|
|
939
|
-
|
|
940
872
|
//#endregion
|
|
941
873
|
//#region src/utility/constants/successPrefix.ts
|
|
942
874
|
const successPrefix = chalk.green("✓");
|
|
943
|
-
|
|
875
|
+
//#endregion
|
|
876
|
+
//#region src/utility/errors/convertDataErrorToProgramError.ts
|
|
877
|
+
function convertDataErrorToProgramError(dataError, program, options) {
|
|
878
|
+
program.error(`${errorPrefix} ${dataError.message}`, {
|
|
879
|
+
exitCode: options?.exitCode ?? 1,
|
|
880
|
+
code: dataError.code
|
|
881
|
+
});
|
|
882
|
+
}
|
|
944
883
|
//#endregion
|
|
945
884
|
//#region src/utility/markdownTemplates/releaseNote/types/ReleaseStatus.ts
|
|
946
885
|
const ReleaseStatus = {
|
|
947
886
|
IN_PROGRESS: "In progress",
|
|
948
887
|
RELEASED: "Released"
|
|
949
888
|
};
|
|
950
|
-
|
|
951
889
|
//#endregion
|
|
952
890
|
//#region src/utility/markdownTemplates/releaseNote/parseReleaseStatus.ts
|
|
953
891
|
function parseReleaseStatus(data) {
|
|
@@ -955,20 +893,17 @@ function parseReleaseStatus(data) {
|
|
|
955
893
|
if (!Object.keys(ReleaseStatus).includes(normalisedStringifiedData)) new DataError({ data }, "INVALID_RELEASE_STATUS", "Invalid release status. The release status must be one of \"In progress\" or \"Released\"");
|
|
956
894
|
return ReleaseStatus[normalisedStringifiedData];
|
|
957
895
|
}
|
|
958
|
-
|
|
959
896
|
//#endregion
|
|
960
897
|
//#region src/utility/markdownTemplates/createMarkdownComment.ts
|
|
961
898
|
function createMarkdownComment(comment) {
|
|
962
899
|
if (comment.startsWith("<!--") && comment.endsWith("-->")) return comment;
|
|
963
900
|
return `<!-- ${comment} -->`;
|
|
964
901
|
}
|
|
965
|
-
|
|
966
902
|
//#endregion
|
|
967
903
|
//#region src/utility/markdownTemplates/createMarkdownCommentPair.ts
|
|
968
904
|
function createMarkdownCommentPair(comment) {
|
|
969
905
|
return [createMarkdownComment(`${comment}-start`), createMarkdownComment(`${comment}-end`)];
|
|
970
906
|
}
|
|
971
|
-
|
|
972
907
|
//#endregion
|
|
973
908
|
//#region src/utility/markdownTemplates/getMarkdownBlock.ts
|
|
974
909
|
function getMarkdownBlock(content, startMarker, endMarker) {
|
|
@@ -977,7 +912,6 @@ function getMarkdownBlock(content, startMarker, endMarker) {
|
|
|
977
912
|
if (startIndex === -1 || endIndex === -1 || endIndex < startIndex) return null;
|
|
978
913
|
return content.slice(startIndex + startMarker.length, endIndex).trim();
|
|
979
914
|
}
|
|
980
|
-
|
|
981
915
|
//#endregion
|
|
982
916
|
//#region src/utility/markdownTemplates/normaliseMarkdown.ts
|
|
983
917
|
function normaliseMarkdown(markdownString) {
|
|
@@ -985,7 +919,6 @@ function normaliseMarkdown(markdownString) {
|
|
|
985
919
|
return line.trim();
|
|
986
920
|
}).filter(Boolean).join(" ").trim();
|
|
987
921
|
}
|
|
988
|
-
|
|
989
922
|
//#endregion
|
|
990
923
|
//#region src/utility/markdownTemplates/releaseNote/getReleaseStatus.ts
|
|
991
924
|
function getReleaseStatus(content) {
|
|
@@ -993,7 +926,6 @@ function getReleaseStatus(content) {
|
|
|
993
926
|
if (releaseStatus === null) throw new DataError({ releaseStatus }, "RELEASE_STATUS_NOT_FOUND", "Could not find release status in document.");
|
|
994
927
|
return parseZodSchema(z.enum(ReleaseStatus), normaliseMarkdown(releaseStatus.split(":")[1]));
|
|
995
928
|
}
|
|
996
|
-
|
|
997
929
|
//#endregion
|
|
998
930
|
//#region src/utility/markdownTemplates/releaseNote/validateReleaseDocument.ts
|
|
999
931
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -1031,7 +963,6 @@ async function validateReleaseDocument(projectName, version, content, allowedRel
|
|
|
1031
963
|
if (!content.includes("## Description of Changes")) throw new DataError({ content }, "DESCRIPTION_NOT_FOUND", "Expected to find a description of changes but it was not found.");
|
|
1032
964
|
if (version.type === "major" && !content.includes("## Migration Notes")) throw new 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.");
|
|
1033
965
|
}
|
|
1034
|
-
|
|
1035
966
|
//#endregion
|
|
1036
967
|
//#region src/cli/commands/template/releaseNote/check.ts
|
|
1037
968
|
function templateReleaseNoteCheck(program) {
|
|
@@ -1047,34 +978,27 @@ function templateReleaseNoteCheck(program) {
|
|
|
1047
978
|
await validateReleaseDocument(name, documentVersion, fileContents, expectedReleaseStatus);
|
|
1048
979
|
console.info(`${successPrefix} Release document is valid!`);
|
|
1049
980
|
} catch (error) {
|
|
1050
|
-
if (DataError.check(error)) program
|
|
1051
|
-
exitCode: 1,
|
|
1052
|
-
code: error.code
|
|
1053
|
-
});
|
|
981
|
+
if (DataError.check(error)) convertDataErrorToProgramError(error, program, { exitCode: 2 });
|
|
1054
982
|
else throw error;
|
|
1055
983
|
}
|
|
1056
984
|
});
|
|
1057
985
|
}
|
|
1058
|
-
|
|
1059
986
|
//#endregion
|
|
1060
987
|
//#region src/utility/markdownTemplates/releaseNote/getReleaseNotePath.ts
|
|
1061
988
|
function getReleaseNotePath(versionNumber) {
|
|
1062
989
|
return path.join("docs", "releases", versionNumber.format({ omitMinor: true }), versionNumber.format({ omitPatch: true }), `${versionNumber}.md`);
|
|
1063
990
|
}
|
|
1064
|
-
|
|
1065
991
|
//#endregion
|
|
1066
992
|
//#region src/utility/markdownTemplates/getReleaseNoteTemplatesPath.ts
|
|
1067
993
|
async function getReleaseNoteTemplatesPath() {
|
|
1068
994
|
return path.join(await ALEX_C_LINE_PACKAGE_ROOT, "templates", "releases");
|
|
1069
995
|
}
|
|
1070
|
-
|
|
1071
996
|
//#endregion
|
|
1072
997
|
//#region src/utility/markdownTemplates/getEditableSectionFromTemplate.ts
|
|
1073
998
|
async function getEditableSectionFromTemplate(version) {
|
|
1074
999
|
const templatesPath = await getReleaseNoteTemplatesPath();
|
|
1075
1000
|
return await readFile(path.join(templatesPath, version.type === "major" ? "editableSectionMajor.md" : "editableSection.md"), "utf-8");
|
|
1076
1001
|
}
|
|
1077
|
-
|
|
1078
1002
|
//#endregion
|
|
1079
1003
|
//#region src/utility/markdownTemplates/replaceMarkdownPlaceholders.ts
|
|
1080
1004
|
function replaceMarkdownPlaceholders(rawContent, templateVariables) {
|
|
@@ -1087,7 +1011,6 @@ function replaceMarkdownPlaceholders(rawContent, templateVariables) {
|
|
|
1087
1011
|
}
|
|
1088
1012
|
return finalContent;
|
|
1089
1013
|
}
|
|
1090
|
-
|
|
1091
1014
|
//#endregion
|
|
1092
1015
|
//#region src/utility/markdownTemplates/releaseNote/getReleaseNoteTemplateFromMarkdown.ts
|
|
1093
1016
|
async function getTemplateVariables(projectName, version, templateVariables) {
|
|
@@ -1118,7 +1041,6 @@ async function getReleaseNoteTemplateFromMarkdown(projectName, version, metadata
|
|
|
1118
1041
|
const templatesPath = path.join(await ALEX_C_LINE_PACKAGE_ROOT, "templates", "releases");
|
|
1119
1042
|
return replaceMarkdownPlaceholders(await readFile(path.join(templatesPath, `${version.type}.md`), "utf-8"), templateVariables);
|
|
1120
1043
|
}
|
|
1121
|
-
|
|
1122
1044
|
//#endregion
|
|
1123
1045
|
//#region src/cli/commands/template/releaseNote/create.ts
|
|
1124
1046
|
function templateReleaseNoteCreate(program) {
|
|
@@ -1138,12 +1060,7 @@ function templateReleaseNoteCreate(program) {
|
|
|
1138
1060
|
const { name, version: packageVersion } = parseZodSchema(z.object({
|
|
1139
1061
|
name: z.string(),
|
|
1140
1062
|
version: z.string()
|
|
1141
|
-
}), packageInfo
|
|
1142
|
-
program.error("Invalid package.json - expected package.json to contain a `name` and `version` property.", {
|
|
1143
|
-
exitCode: 1,
|
|
1144
|
-
code: "INVALID_PACKAGE_JSON"
|
|
1145
|
-
});
|
|
1146
|
-
});
|
|
1063
|
+
}), packageInfo);
|
|
1147
1064
|
const versionNumber = target instanceof VersionNumber ? target : target ? new VersionNumber(packageVersion).increment(target) : new VersionNumber(packageVersion);
|
|
1148
1065
|
const releaseNotePath = getReleaseNotePath(versionNumber);
|
|
1149
1066
|
const releaseNoteTemplate = await getReleaseNoteTemplateFromMarkdown(name, versionNumber, { status: "In progress" });
|
|
@@ -1151,7 +1068,7 @@ function templateReleaseNoteCreate(program) {
|
|
|
1151
1068
|
await mkdir(path.dirname(releaseNotePath), { recursive: true });
|
|
1152
1069
|
await writeFile(releaseNotePath, releaseNoteTemplate, { flag: "wx" });
|
|
1153
1070
|
} catch (error) {
|
|
1154
|
-
if (error instanceof Error && "code" in error && error.code === "EEXIST") program.error(
|
|
1071
|
+
if (error instanceof Error && "code" in error && error.code === "EEXIST") program.error(`${errorPrefix} Release notes already exist.`, {
|
|
1155
1072
|
exitCode: 1,
|
|
1156
1073
|
code: "RELEASE_NOTE_EXISTS"
|
|
1157
1074
|
});
|
|
@@ -1160,7 +1077,6 @@ function templateReleaseNoteCreate(program) {
|
|
|
1160
1077
|
console.info(`Release notes for ${versionNumber} have been created in ${path.relative(process.cwd(), releaseNotePath)}`);
|
|
1161
1078
|
});
|
|
1162
1079
|
}
|
|
1163
|
-
|
|
1164
1080
|
//#endregion
|
|
1165
1081
|
//#region src/cli/commands/template/releaseNote/migrate.ts
|
|
1166
1082
|
function templateReleaseNoteMigrate(program) {
|
|
@@ -1216,7 +1132,6 @@ function templateReleaseNoteMigrate(program) {
|
|
|
1216
1132
|
console.info(dryRun ? `Dry run complete! ${filesMovedCount} files would be moved.` : `Migration complete! ${filesMovedCount} files moved.`);
|
|
1217
1133
|
});
|
|
1218
1134
|
}
|
|
1219
|
-
|
|
1220
1135
|
//#endregion
|
|
1221
1136
|
//#region src/cli/commands/template/releaseNote/path.ts
|
|
1222
1137
|
function templateReleaseNotePath(program) {
|
|
@@ -1231,17 +1146,13 @@ function templateReleaseNotePath(program) {
|
|
|
1231
1146
|
console.info(getReleaseNotePath(version));
|
|
1232
1147
|
});
|
|
1233
1148
|
}
|
|
1234
|
-
|
|
1235
1149
|
//#endregion
|
|
1236
1150
|
//#region src/cli/commands/template/releaseNote/set-status.ts
|
|
1237
1151
|
function templateReleaseNoteSetStatus(program) {
|
|
1238
1152
|
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) => {
|
|
1239
1153
|
const packageInfo = await getPackageJsonContents(process.cwd());
|
|
1240
1154
|
const { name } = parseZodSchema(z.object({ name: z.string() }), packageInfo, new DataError({ name: packageInfo?.name }, "INVALID_PACKAGE_JSON", "Invalid package.json - expected package.json to contain a `name` property."));
|
|
1241
|
-
if (!documentPath.endsWith("md"))
|
|
1242
|
-
exitCode: 1,
|
|
1243
|
-
code: "INVALID_FILE_PATH"
|
|
1244
|
-
});
|
|
1155
|
+
if (!documentPath.endsWith("md")) throw new DataError({ documentPath }, "INVALID_FILE_PATH", "Invalid file path. Path must lead to a .md file.");
|
|
1245
1156
|
const versionNumber = new VersionNumber(path.basename(documentPath).split(".").filter((part) => {
|
|
1246
1157
|
return part !== "md";
|
|
1247
1158
|
}).join("."));
|
|
@@ -1261,7 +1172,6 @@ function templateReleaseNoteSetStatus(program) {
|
|
|
1261
1172
|
console.info(`Setting the status of ${documentPath} to "${status}"`);
|
|
1262
1173
|
});
|
|
1263
1174
|
}
|
|
1264
|
-
|
|
1265
1175
|
//#endregion
|
|
1266
1176
|
//#region src/cli/commands/template/releaseNote/index.ts
|
|
1267
1177
|
function templateReleaseNote(program) {
|
|
@@ -1273,7 +1183,6 @@ function templateReleaseNote(program) {
|
|
|
1273
1183
|
templateReleaseNoteSetStatus
|
|
1274
1184
|
});
|
|
1275
1185
|
}
|
|
1276
|
-
|
|
1277
1186
|
//#endregion
|
|
1278
1187
|
//#region src/cli/commands/template/index.ts
|
|
1279
1188
|
function template(program) {
|
|
@@ -1282,13 +1191,11 @@ function template(program) {
|
|
|
1282
1191
|
templateReleaseNote
|
|
1283
1192
|
});
|
|
1284
1193
|
}
|
|
1285
|
-
|
|
1286
1194
|
//#endregion
|
|
1287
1195
|
//#region package.json
|
|
1288
1196
|
var name = "alex-c-line";
|
|
1289
|
-
var version$1 = "2.0.
|
|
1197
|
+
var version$1 = "2.0.2";
|
|
1290
1198
|
var description = "Command-line tool with commands to streamline the developer workflow.";
|
|
1291
|
-
|
|
1292
1199
|
//#endregion
|
|
1293
1200
|
//#region src/utility/updates/checkUpdate.ts
|
|
1294
1201
|
async function checkUpdate(options) {
|
|
@@ -1320,7 +1227,6 @@ async function checkUpdate(options) {
|
|
|
1320
1227
|
} else console.info(messageWithArtwork);
|
|
1321
1228
|
} else if (options?.logNoUpdates) console.info(`alex-c-line is up to date (${currentVersion}).`);
|
|
1322
1229
|
}
|
|
1323
|
-
|
|
1324
1230
|
//#endregion
|
|
1325
1231
|
//#region src/cli/commands/update/check.ts
|
|
1326
1232
|
function checkUpdateCommand(program) {
|
|
@@ -1331,13 +1237,11 @@ function checkUpdateCommand(program) {
|
|
|
1331
1237
|
});
|
|
1332
1238
|
});
|
|
1333
1239
|
}
|
|
1334
|
-
|
|
1335
1240
|
//#endregion
|
|
1336
1241
|
//#region src/cli/commands/update/index.ts
|
|
1337
1242
|
function update(program) {
|
|
1338
1243
|
loadCommands(program.command("update").description("Handle updates of the currently installed alex-c-line"), { checkUpdateCommand });
|
|
1339
1244
|
}
|
|
1340
|
-
|
|
1341
1245
|
//#endregion
|
|
1342
1246
|
//#region src/cli/commands/uuid/generate.ts
|
|
1343
1247
|
function generateUUID(program) {
|
|
@@ -1345,22 +1249,11 @@ function generateUUID(program) {
|
|
|
1345
1249
|
console.info(randomUUID());
|
|
1346
1250
|
});
|
|
1347
1251
|
}
|
|
1348
|
-
|
|
1349
1252
|
//#endregion
|
|
1350
1253
|
//#region src/cli/commands/uuid/index.ts
|
|
1351
1254
|
function uuid(program) {
|
|
1352
1255
|
loadCommands(program.command("uuid").description("Commands to help manage UUIDs"), { generateUUID });
|
|
1353
1256
|
}
|
|
1354
|
-
|
|
1355
|
-
//#endregion
|
|
1356
|
-
//#region src/utility/errors/convertDataErrorToProgramError.ts
|
|
1357
|
-
function convertDataErrorToProgramError(dataError, program, options) {
|
|
1358
|
-
program.error(dataError.message, {
|
|
1359
|
-
exitCode: options?.exitCode ?? 1,
|
|
1360
|
-
code: dataError.code
|
|
1361
|
-
});
|
|
1362
|
-
}
|
|
1363
|
-
|
|
1364
1257
|
//#endregion
|
|
1365
1258
|
//#region src/utility/miscellaneous/parseZodSchemaForProgram.ts
|
|
1366
1259
|
function parseZodSchemaForProgram(program, schema, data) {
|
|
@@ -1371,7 +1264,6 @@ function parseZodSchemaForProgram(program, schema, data) {
|
|
|
1371
1264
|
throw error;
|
|
1372
1265
|
}
|
|
1373
1266
|
}
|
|
1374
|
-
|
|
1375
1267
|
//#endregion
|
|
1376
1268
|
//#region src/cli/commands/version/format.ts
|
|
1377
1269
|
const versionFormatOptionsBaseSchema = z.object({ prefix: z.boolean().optional() });
|
|
@@ -1396,7 +1288,6 @@ function versionFormat(program) {
|
|
|
1396
1288
|
}));
|
|
1397
1289
|
});
|
|
1398
1290
|
}
|
|
1399
|
-
|
|
1400
1291
|
//#endregion
|
|
1401
1292
|
//#region src/cli/commands/version/increment.ts
|
|
1402
1293
|
function versionIncrement(program) {
|
|
@@ -1412,7 +1303,6 @@ function versionIncrement(program) {
|
|
|
1412
1303
|
console.info(version.increment(incrementType).format({ omitPrefix: !prefix }));
|
|
1413
1304
|
});
|
|
1414
1305
|
}
|
|
1415
|
-
|
|
1416
1306
|
//#endregion
|
|
1417
1307
|
//#region src/cli/commands/version/type.ts
|
|
1418
1308
|
function versionType(program) {
|
|
@@ -1422,7 +1312,6 @@ function versionType(program) {
|
|
|
1422
1312
|
console.info(version.type);
|
|
1423
1313
|
});
|
|
1424
1314
|
}
|
|
1425
|
-
|
|
1426
1315
|
//#endregion
|
|
1427
1316
|
//#region src/cli/commands/version/index.ts
|
|
1428
1317
|
function version(program) {
|
|
@@ -1432,7 +1321,6 @@ function version(program) {
|
|
|
1432
1321
|
versionType
|
|
1433
1322
|
});
|
|
1434
1323
|
}
|
|
1435
|
-
|
|
1436
1324
|
//#endregion
|
|
1437
1325
|
//#region src/cli/commands/package-json/check/noFileDependencies.ts
|
|
1438
1326
|
function findFileDependencies(dependencies) {
|
|
@@ -1452,14 +1340,13 @@ async function noFileDependencies(program) {
|
|
|
1452
1340
|
};
|
|
1453
1341
|
if (Object.keys(allFileDependencies.dependencies ?? {}).length === 0) delete allFileDependencies.dependencies;
|
|
1454
1342
|
if (Object.keys(allFileDependencies.devDependencies ?? {}).length === 0) delete allFileDependencies.devDependencies;
|
|
1455
|
-
if (Object.keys(allFileDependencies).length !== 0) program.error(`${errorPrefix}
|
|
1343
|
+
if (Object.keys(allFileDependencies).length !== 0) program.error(`${errorPrefix} File dependencies found:\n\n${JSON.stringify(allFileDependencies, void 0, 2)}
|
|
1456
1344
|
`, {
|
|
1457
1345
|
exitCode: 2,
|
|
1458
1346
|
code: "FILE_DEPENDENCIES_FOUND"
|
|
1459
1347
|
});
|
|
1460
1348
|
console.info(`${successPrefix} No file dependencies found!`);
|
|
1461
1349
|
}
|
|
1462
|
-
|
|
1463
1350
|
//#endregion
|
|
1464
1351
|
//#region src/cli/commands/package-json/check/noPreReleaseDependencies.ts
|
|
1465
1352
|
function isPreRelease(dependencyVersionRange) {
|
|
@@ -1476,7 +1363,7 @@ async function noPreReleaseDependencies(program) {
|
|
|
1476
1363
|
for (const [dependencyName, dependencyVersionRange] of Object.entries(dependencies)) if (isPreRelease(dependencyVersionRange)) preReleaseDependencies[dependencyName] = dependencyVersionRange;
|
|
1477
1364
|
for (const [dependencyName, dependencyVersionRange] of Object.entries(devDependencies)) if (isPreRelease(dependencyVersionRange)) preReleaseDevDependencies[dependencyName] = dependencyVersionRange;
|
|
1478
1365
|
if (Object.keys(preReleaseDependencies).length !== 0 || Object.keys(preReleaseDevDependencies).length !== 0) program.error(normaliseIndents`
|
|
1479
|
-
${errorPrefix}
|
|
1366
|
+
${errorPrefix} Pre-release version pinning is not allowed. Found the following violations:
|
|
1480
1367
|
|
|
1481
1368
|
` + JSON.stringify({
|
|
1482
1369
|
dependencies: preReleaseDependencies,
|
|
@@ -1487,7 +1374,6 @@ async function noPreReleaseDependencies(program) {
|
|
|
1487
1374
|
});
|
|
1488
1375
|
console.info(`${successPrefix} No pre-release versions found!`);
|
|
1489
1376
|
}
|
|
1490
|
-
|
|
1491
1377
|
//#endregion
|
|
1492
1378
|
//#region src/cli/commands/package-json/check/index.ts
|
|
1493
1379
|
const RuleName = {
|
|
@@ -1504,13 +1390,11 @@ function packageJsonCheck(program) {
|
|
|
1504
1390
|
console.info(`${successPrefix} Success! All checks passed!`);
|
|
1505
1391
|
});
|
|
1506
1392
|
}
|
|
1507
|
-
|
|
1508
1393
|
//#endregion
|
|
1509
1394
|
//#region src/cli/commands/package-json/index.ts
|
|
1510
1395
|
function packageJson(program) {
|
|
1511
1396
|
loadCommands(program.command("package-json").description("Manage the package.json file"), { packageJsonCheck });
|
|
1512
1397
|
}
|
|
1513
|
-
|
|
1514
1398
|
//#endregion
|
|
1515
1399
|
//#region src/cli/commands/index.ts
|
|
1516
1400
|
function createCommands(program) {
|
|
@@ -1528,7 +1412,6 @@ function createCommands(program) {
|
|
|
1528
1412
|
version
|
|
1529
1413
|
});
|
|
1530
1414
|
}
|
|
1531
|
-
|
|
1532
1415
|
//#endregion
|
|
1533
1416
|
//#region src/utility/errors/formatError.ts
|
|
1534
1417
|
function formatError(error) {
|
|
@@ -1551,24 +1434,20 @@ function formatError(error) {
|
|
|
1551
1434
|
}
|
|
1552
1435
|
throw error;
|
|
1553
1436
|
}
|
|
1554
|
-
|
|
1555
1437
|
//#endregion
|
|
1556
1438
|
//#region src/cache/global/createAlexCLineGlobalCache.ts
|
|
1557
1439
|
async function createAlexCLineGlobalCache(cacheData) {
|
|
1558
1440
|
await mkdir(ALEX_C_LINE_GLOBAL_CACHE_DIRECTORY, { recursive: true });
|
|
1559
1441
|
await writeFile(ALEX_C_LINE_GLOBAL_CACHE_PATH, `${JSON.stringify(cacheData, null, 2)}\n`);
|
|
1560
1442
|
}
|
|
1561
|
-
|
|
1562
1443
|
//#endregion
|
|
1563
1444
|
//#region src/cache/global/types/AlexCLineGlobalCache.ts
|
|
1564
1445
|
const alexCLineGlobalCacheSchema = z.looseObject({ updateChecks: z.record(z.string(), z.string()).optional() });
|
|
1565
|
-
|
|
1566
1446
|
//#endregion
|
|
1567
1447
|
//#region src/cache/global/parseAlexCLineGlobalCache.ts
|
|
1568
1448
|
function parseAlexCLineGlobalCache(input) {
|
|
1569
1449
|
return parseZodSchema(alexCLineGlobalCacheSchema, input);
|
|
1570
1450
|
}
|
|
1571
|
-
|
|
1572
1451
|
//#endregion
|
|
1573
1452
|
//#region src/cache/global/loadAlexCLineGlobalCache.ts
|
|
1574
1453
|
async function loadAlexCLineGlobalCache() {
|
|
@@ -1579,7 +1458,6 @@ async function loadAlexCLineGlobalCache() {
|
|
|
1579
1458
|
throw error;
|
|
1580
1459
|
}
|
|
1581
1460
|
}
|
|
1582
|
-
|
|
1583
1461
|
//#endregion
|
|
1584
1462
|
//#region src/utility/updates/runAutomatedUpdateCheck.ts
|
|
1585
1463
|
async function runAutomatedUpdateCheck() {
|
|
@@ -1599,7 +1477,6 @@ async function runAutomatedUpdateCheck() {
|
|
|
1599
1477
|
}
|
|
1600
1478
|
} catch {}
|
|
1601
1479
|
}
|
|
1602
|
-
|
|
1603
1480
|
//#endregion
|
|
1604
1481
|
//#region src/cli/index.ts
|
|
1605
1482
|
(async () => {
|
|
@@ -1613,6 +1490,5 @@ async function runAutomatedUpdateCheck() {
|
|
|
1613
1490
|
formatError(error);
|
|
1614
1491
|
}
|
|
1615
1492
|
})();
|
|
1616
|
-
|
|
1617
1493
|
//#endregion
|
|
1618
|
-
export {
|
|
1494
|
+
export {};
|