alex-c-line 1.28.0 → 1.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/configs/index.cjs +5 -10
- package/dist/configs/index.d.cts +5 -7
- package/dist/configs/index.d.ts +4 -6
- package/dist/configs/index.js +3 -8
- package/dist/configs/internal/index.cjs +18 -2
- package/dist/configs/internal/index.d.cts +8 -7
- package/dist/configs/internal/index.d.ts +8 -7
- package/dist/configs/internal/index.js +17 -2
- package/dist/index.cjs +48 -98
- package/dist/index.js +39 -89
- package/package.json +12 -10
package/dist/configs/index.cjs
CHANGED
|
@@ -29,6 +29,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
29
|
require("@alextheman/utility");
|
|
30
30
|
let zod = require("zod");
|
|
31
31
|
zod = __toESM(zod);
|
|
32
|
+
let _alextheman_utility_internal = require("@alextheman/utility/internal");
|
|
32
33
|
|
|
33
34
|
//#region src/configs/helpers/defineCreatePullRequestTemplateConfig.ts
|
|
34
35
|
const createPullRequestTemplateBaseSchema = zod.default.strictObject({ projectName: zod.default.string().optional() });
|
|
@@ -44,18 +45,11 @@ function defineCreatePullRequestTemplateConfig(config) {
|
|
|
44
45
|
return config;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region src/configs/types/PreCommitConfig.ts
|
|
49
|
-
const PackageManager = {
|
|
50
|
-
NPM: "npm",
|
|
51
|
-
PNPM: "pnpm"
|
|
52
|
-
};
|
|
53
|
-
|
|
54
48
|
//#endregion
|
|
55
49
|
//#region src/configs/helpers/definePreCommitConfig.ts
|
|
56
50
|
const preCommitStepOptionsSchema = zod.default.strictObject({ arguments: zod.default.array(zod.default.string()).optional() });
|
|
57
51
|
const preCommitConfigSchema = zod.default.strictObject({
|
|
58
|
-
packageManager: zod.default.enum(PackageManager).optional(),
|
|
52
|
+
packageManager: zod.default.enum(_alextheman_utility_internal.PackageManager).optional(),
|
|
59
53
|
allowNoStagedChanges: zod.default.boolean().optional(),
|
|
60
54
|
steps: zod.default.array(zod.default.union([
|
|
61
55
|
zod.default.function({
|
|
@@ -64,7 +58,8 @@ const preCommitConfigSchema = zod.default.strictObject({
|
|
|
64
58
|
}),
|
|
65
59
|
zod.default.string(),
|
|
66
60
|
zod.default.tuple([zod.default.string(), preCommitStepOptionsSchema])
|
|
67
|
-
]))
|
|
61
|
+
])),
|
|
62
|
+
updateIndex: zod.default.boolean().optional()
|
|
68
63
|
});
|
|
69
64
|
function definePreCommitConfig(config) {
|
|
70
65
|
return config;
|
|
@@ -105,7 +100,7 @@ const PullRequestTemplateCategory = {
|
|
|
105
100
|
//#endregion
|
|
106
101
|
//#region src/configs/helpers/defineAlexCLinePrivateConfig.ts
|
|
107
102
|
const alexCLinePrivateConfigSchema = zod.default.object({ useLocalPackage: zod.default.strictObject({ localPackages: zod.default.record(zod.default.string(), zod.default.strictObject({
|
|
108
|
-
packageManager: zod.default.enum(PackageManager),
|
|
103
|
+
packageManager: zod.default.enum(_alextheman_utility_internal.PackageManager),
|
|
109
104
|
path: zod.default.string(),
|
|
110
105
|
prepareScript: zod.default.string().optional(),
|
|
111
106
|
dependencyGroup: zod.default.enum(DependencyGroup).optional(),
|
package/dist/configs/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PackageManager } from "@alextheman/utility/internal";
|
|
2
2
|
import { Options, Result, TemplateExpression } from "execa";
|
|
3
|
+
import { CreateEnumType } from "@alextheman/utility";
|
|
3
4
|
|
|
4
5
|
//#region src/configs/types/CreatePullRequestTemplateConfig.d.ts
|
|
5
6
|
interface CreatePullRequestTemplateBaseConfig {
|
|
@@ -34,11 +35,6 @@ interface StepRunner<ExecaOptions extends Options = BaseOptions> {
|
|
|
34
35
|
}
|
|
35
36
|
//#endregion
|
|
36
37
|
//#region src/configs/types/PreCommitConfig.d.ts
|
|
37
|
-
declare const PackageManager: {
|
|
38
|
-
readonly NPM: "npm";
|
|
39
|
-
readonly PNPM: "pnpm";
|
|
40
|
-
};
|
|
41
|
-
type PackageManager = CreateEnumType<typeof PackageManager>;
|
|
42
38
|
interface PreCommitStepOptions {
|
|
43
39
|
/** Arguments to pass to the given script */
|
|
44
40
|
arguments?: string[];
|
|
@@ -51,6 +47,8 @@ interface PreCommitConfig<ScriptName extends string = string> {
|
|
|
51
47
|
allowNoStagedChanges?: boolean;
|
|
52
48
|
/** The steps to run in the pre-commit hook. */
|
|
53
49
|
steps: (StepFunction | ScriptName | [ScriptName, PreCommitStepOptions])[];
|
|
50
|
+
/** Update the git index after the run */
|
|
51
|
+
updateIndex?: boolean;
|
|
54
52
|
}
|
|
55
53
|
//#endregion
|
|
56
54
|
//#region src/configs/types/AlexCLineConfig.d.ts
|
|
@@ -123,4 +121,4 @@ interface PreCommitPrivateConfig<ScriptName extends string = string> {
|
|
|
123
121
|
//#region src/configs/helpers/definePreCommitPrivateConfig.d.ts
|
|
124
122
|
declare function definePreCommitPrivateConfig<ScriptName extends string = string>(config: PreCommitPrivateConfig<ScriptName>): PreCommitPrivateConfig<ScriptName>;
|
|
125
123
|
//#endregion
|
|
126
|
-
export { AlexCLineConfig, ConfigFileName, CreatePullRequestTemplateBaseConfig, CreatePullRequestTemplateConfig, CreatePullRequestTemplateGeneralConfig, CreatePullRequestTemplateInfrastructureConfig, DependencyGroup,
|
|
124
|
+
export { AlexCLineConfig, ConfigFileName, CreatePullRequestTemplateBaseConfig, CreatePullRequestTemplateConfig, CreatePullRequestTemplateGeneralConfig, CreatePullRequestTemplateInfrastructureConfig, DependencyGroup, PreCommitConfig, PreCommitStepOptions, PullRequestTemplateCategory, StepFunction, defineAlexCLineConfig, defineAlexCLinePrivateConfig, defineCreatePullRequestTemplateConfig, definePreCommitConfig, definePreCommitPrivateConfig };
|
package/dist/configs/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CreateEnumType } from "@alextheman/utility";
|
|
2
2
|
import z from "zod";
|
|
3
|
+
import { PackageManager } from "@alextheman/utility/internal";
|
|
3
4
|
import { Options, Result, TemplateExpression } from "execa";
|
|
4
5
|
|
|
5
6
|
//#region src/configs/types/CreatePullRequestTemplateConfig.d.ts
|
|
@@ -35,11 +36,6 @@ interface StepRunner<ExecaOptions extends Options = BaseOptions> {
|
|
|
35
36
|
}
|
|
36
37
|
//#endregion
|
|
37
38
|
//#region src/configs/types/PreCommitConfig.d.ts
|
|
38
|
-
declare const PackageManager: {
|
|
39
|
-
readonly NPM: "npm";
|
|
40
|
-
readonly PNPM: "pnpm";
|
|
41
|
-
};
|
|
42
|
-
type PackageManager = CreateEnumType<typeof PackageManager>;
|
|
43
39
|
interface PreCommitStepOptions {
|
|
44
40
|
/** Arguments to pass to the given script */
|
|
45
41
|
arguments?: string[];
|
|
@@ -52,6 +48,8 @@ interface PreCommitConfig<ScriptName extends string = string> {
|
|
|
52
48
|
allowNoStagedChanges?: boolean;
|
|
53
49
|
/** The steps to run in the pre-commit hook. */
|
|
54
50
|
steps: (StepFunction | ScriptName | [ScriptName, PreCommitStepOptions])[];
|
|
51
|
+
/** Update the git index after the run */
|
|
52
|
+
updateIndex?: boolean;
|
|
55
53
|
}
|
|
56
54
|
//#endregion
|
|
57
55
|
//#region src/configs/types/AlexCLineConfig.d.ts
|
|
@@ -124,4 +122,4 @@ interface PreCommitPrivateConfig<ScriptName extends string = string> {
|
|
|
124
122
|
//#region src/configs/helpers/definePreCommitPrivateConfig.d.ts
|
|
125
123
|
declare function definePreCommitPrivateConfig<ScriptName extends string = string>(config: PreCommitPrivateConfig<ScriptName>): PreCommitPrivateConfig<ScriptName>;
|
|
126
124
|
//#endregion
|
|
127
|
-
export { AlexCLineConfig, ConfigFileName, CreatePullRequestTemplateBaseConfig, CreatePullRequestTemplateConfig, CreatePullRequestTemplateGeneralConfig, CreatePullRequestTemplateInfrastructureConfig, DependencyGroup,
|
|
125
|
+
export { AlexCLineConfig, ConfigFileName, CreatePullRequestTemplateBaseConfig, CreatePullRequestTemplateConfig, CreatePullRequestTemplateGeneralConfig, CreatePullRequestTemplateInfrastructureConfig, DependencyGroup, PreCommitConfig, PreCommitStepOptions, PullRequestTemplateCategory, StepFunction, defineAlexCLineConfig, defineAlexCLinePrivateConfig, defineCreatePullRequestTemplateConfig, definePreCommitConfig, definePreCommitPrivateConfig };
|
package/dist/configs/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "@alextheman/utility";
|
|
2
2
|
import z from "zod";
|
|
3
|
+
import { PackageManager } from "@alextheman/utility/internal";
|
|
3
4
|
|
|
4
5
|
//#region src/configs/helpers/defineCreatePullRequestTemplateConfig.ts
|
|
5
6
|
const createPullRequestTemplateBaseSchema = z.strictObject({ projectName: z.string().optional() });
|
|
@@ -15,13 +16,6 @@ function defineCreatePullRequestTemplateConfig(config) {
|
|
|
15
16
|
return config;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/configs/types/PreCommitConfig.ts
|
|
20
|
-
const PackageManager = {
|
|
21
|
-
NPM: "npm",
|
|
22
|
-
PNPM: "pnpm"
|
|
23
|
-
};
|
|
24
|
-
|
|
25
19
|
//#endregion
|
|
26
20
|
//#region src/configs/helpers/definePreCommitConfig.ts
|
|
27
21
|
const preCommitStepOptionsSchema = z.strictObject({ arguments: z.array(z.string()).optional() });
|
|
@@ -35,7 +29,8 @@ const preCommitConfigSchema = z.strictObject({
|
|
|
35
29
|
}),
|
|
36
30
|
z.string(),
|
|
37
31
|
z.tuple([z.string(), preCommitStepOptionsSchema])
|
|
38
|
-
]))
|
|
32
|
+
])),
|
|
33
|
+
updateIndex: z.boolean().optional()
|
|
39
34
|
});
|
|
40
35
|
function definePreCommitConfig(config) {
|
|
41
36
|
return config;
|
|
@@ -12,7 +12,8 @@ const alexCLineConfig = {
|
|
|
12
12
|
"format",
|
|
13
13
|
"lint",
|
|
14
14
|
"test"
|
|
15
|
-
]
|
|
15
|
+
],
|
|
16
|
+
updateIndex: true
|
|
16
17
|
}
|
|
17
18
|
};
|
|
18
19
|
|
|
@@ -56,7 +57,22 @@ function packageConfig(steps = [
|
|
|
56
57
|
};
|
|
57
58
|
}
|
|
58
59
|
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/configs/internal/testConfig.ts
|
|
62
|
+
const testConfig = {
|
|
63
|
+
createPullRequestTemplate: {
|
|
64
|
+
category: "general",
|
|
65
|
+
projectType: "package"
|
|
66
|
+
},
|
|
67
|
+
preCommit: {
|
|
68
|
+
packageManager: "pnpm",
|
|
69
|
+
steps: ["artwork"],
|
|
70
|
+
updateIndex: false
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
59
74
|
//#endregion
|
|
60
75
|
exports.alexCLineConfig = alexCLineConfig;
|
|
61
76
|
exports.infrastructureConfig = infrastructureConfig;
|
|
62
|
-
exports.packageConfig = packageConfig;
|
|
77
|
+
exports.packageConfig = packageConfig;
|
|
78
|
+
exports.testConfig = testConfig;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PackageManager } from "@alextheman/utility/internal";
|
|
2
2
|
import { Options, Result, TemplateExpression } from "execa";
|
|
3
3
|
|
|
4
4
|
//#region src/configs/types/CreatePullRequestTemplateConfig.d.ts
|
|
@@ -34,11 +34,6 @@ interface StepRunner<ExecaOptions extends Options = BaseOptions> {
|
|
|
34
34
|
}
|
|
35
35
|
//#endregion
|
|
36
36
|
//#region src/configs/types/PreCommitConfig.d.ts
|
|
37
|
-
declare const PackageManager: {
|
|
38
|
-
readonly NPM: "npm";
|
|
39
|
-
readonly PNPM: "pnpm";
|
|
40
|
-
};
|
|
41
|
-
type PackageManager = CreateEnumType<typeof PackageManager>;
|
|
42
37
|
interface PreCommitStepOptions {
|
|
43
38
|
/** Arguments to pass to the given script */
|
|
44
39
|
arguments?: string[];
|
|
@@ -51,6 +46,8 @@ interface PreCommitConfig<ScriptName extends string = string> {
|
|
|
51
46
|
allowNoStagedChanges?: boolean;
|
|
52
47
|
/** The steps to run in the pre-commit hook. */
|
|
53
48
|
steps: (StepFunction | ScriptName | [ScriptName, PreCommitStepOptions])[];
|
|
49
|
+
/** Update the git index after the run */
|
|
50
|
+
updateIndex?: boolean;
|
|
54
51
|
}
|
|
55
52
|
//#endregion
|
|
56
53
|
//#region src/configs/types/AlexCLineConfig.d.ts
|
|
@@ -85,6 +82,7 @@ declare let scripts: {
|
|
|
85
82
|
"prepare-local-eslint-plugin": string;
|
|
86
83
|
"prepare-local-utility": string;
|
|
87
84
|
test: string;
|
|
85
|
+
"test-end-to-end": string;
|
|
88
86
|
"test-watch": string;
|
|
89
87
|
"update-dependencies": string;
|
|
90
88
|
"use-live-eslint-plugin": string;
|
|
@@ -111,4 +109,7 @@ type PreCommitStep = "build" | "format" | "lint" | "test";
|
|
|
111
109
|
//#region src/configs/internal/packageConfig.d.ts
|
|
112
110
|
declare function packageConfig<ScriptName extends string = PreCommitStep>(steps?: (StepFunction | ScriptName | PreCommitStep | [ScriptName | PreCommitStep, PreCommitStepOptions])[]): AlexCLineConfig<PreCommitStep>;
|
|
113
111
|
//#endregion
|
|
114
|
-
|
|
112
|
+
//#region src/configs/internal/testConfig.d.ts
|
|
113
|
+
declare const testConfig: AlexCLineConfig<"artwork">;
|
|
114
|
+
//#endregion
|
|
115
|
+
export { alexCLineConfig, infrastructureConfig, packageConfig, testConfig };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PackageManager } from "@alextheman/utility/internal";
|
|
2
2
|
import { Options, Result, TemplateExpression } from "execa";
|
|
3
3
|
|
|
4
4
|
//#region src/configs/types/CreatePullRequestTemplateConfig.d.ts
|
|
@@ -34,11 +34,6 @@ interface StepRunner<ExecaOptions extends Options = BaseOptions> {
|
|
|
34
34
|
}
|
|
35
35
|
//#endregion
|
|
36
36
|
//#region src/configs/types/PreCommitConfig.d.ts
|
|
37
|
-
declare const PackageManager: {
|
|
38
|
-
readonly NPM: "npm";
|
|
39
|
-
readonly PNPM: "pnpm";
|
|
40
|
-
};
|
|
41
|
-
type PackageManager = CreateEnumType<typeof PackageManager>;
|
|
42
37
|
interface PreCommitStepOptions {
|
|
43
38
|
/** Arguments to pass to the given script */
|
|
44
39
|
arguments?: string[];
|
|
@@ -51,6 +46,8 @@ interface PreCommitConfig<ScriptName extends string = string> {
|
|
|
51
46
|
allowNoStagedChanges?: boolean;
|
|
52
47
|
/** The steps to run in the pre-commit hook. */
|
|
53
48
|
steps: (StepFunction | ScriptName | [ScriptName, PreCommitStepOptions])[];
|
|
49
|
+
/** Update the git index after the run */
|
|
50
|
+
updateIndex?: boolean;
|
|
54
51
|
}
|
|
55
52
|
//#endregion
|
|
56
53
|
//#region src/configs/types/AlexCLineConfig.d.ts
|
|
@@ -85,6 +82,7 @@ declare let scripts: {
|
|
|
85
82
|
"prepare-local-eslint-plugin": string;
|
|
86
83
|
"prepare-local-utility": string;
|
|
87
84
|
test: string;
|
|
85
|
+
"test-end-to-end": string;
|
|
88
86
|
"test-watch": string;
|
|
89
87
|
"update-dependencies": string;
|
|
90
88
|
"use-live-eslint-plugin": string;
|
|
@@ -111,4 +109,7 @@ type PreCommitStep = "build" | "format" | "lint" | "test";
|
|
|
111
109
|
//#region src/configs/internal/packageConfig.d.ts
|
|
112
110
|
declare function packageConfig<ScriptName extends string = PreCommitStep>(steps?: (StepFunction | ScriptName | PreCommitStep | [ScriptName | PreCommitStep, PreCommitStepOptions])[]): AlexCLineConfig<PreCommitStep>;
|
|
113
111
|
//#endregion
|
|
114
|
-
|
|
112
|
+
//#region src/configs/internal/testConfig.d.ts
|
|
113
|
+
declare const testConfig: AlexCLineConfig<"artwork">;
|
|
114
|
+
//#endregion
|
|
115
|
+
export { alexCLineConfig, infrastructureConfig, packageConfig, testConfig };
|
|
@@ -10,7 +10,8 @@ const alexCLineConfig = {
|
|
|
10
10
|
"format",
|
|
11
11
|
"lint",
|
|
12
12
|
"test"
|
|
13
|
-
]
|
|
13
|
+
],
|
|
14
|
+
updateIndex: true
|
|
14
15
|
}
|
|
15
16
|
};
|
|
16
17
|
|
|
@@ -55,4 +56,18 @@ function packageConfig(steps = [
|
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
//#endregion
|
|
58
|
-
|
|
59
|
+
//#region src/configs/internal/testConfig.ts
|
|
60
|
+
const testConfig = {
|
|
61
|
+
createPullRequestTemplate: {
|
|
62
|
+
category: "general",
|
|
63
|
+
projectType: "package"
|
|
64
|
+
},
|
|
65
|
+
preCommit: {
|
|
66
|
+
packageManager: "pnpm",
|
|
67
|
+
steps: ["artwork"],
|
|
68
|
+
updateIndex: false
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
export { alexCLineConfig, infrastructureConfig, packageConfig, testConfig };
|
package/dist/index.cjs
CHANGED
|
@@ -26,6 +26,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
}) : target, mod));
|
|
27
27
|
|
|
28
28
|
//#endregion
|
|
29
|
+
let _alextheman_utility = require("@alextheman/utility");
|
|
29
30
|
let commander = require("commander");
|
|
30
31
|
let supports_color = require("supports-color");
|
|
31
32
|
supports_color = __toESM(supports_color);
|
|
@@ -41,7 +42,6 @@ let chalk = require("chalk");
|
|
|
41
42
|
chalk = __toESM(chalk);
|
|
42
43
|
let figlet = require("figlet");
|
|
43
44
|
figlet = __toESM(figlet);
|
|
44
|
-
let _alextheman_utility = require("@alextheman/utility");
|
|
45
45
|
let execa = require("execa");
|
|
46
46
|
let dotenv = require("dotenv");
|
|
47
47
|
dotenv = __toESM(dotenv);
|
|
@@ -52,10 +52,12 @@ zod = __toESM(zod);
|
|
|
52
52
|
let _inquirer_prompts = require("@inquirer/prompts");
|
|
53
53
|
let node_os = require("node:os");
|
|
54
54
|
node_os = __toESM(node_os);
|
|
55
|
+
let _alextheman_utility_internal = require("@alextheman/utility/internal");
|
|
55
56
|
let node_module = require("node:module");
|
|
56
57
|
let node_url = require("node:url");
|
|
57
58
|
let gray_matter = require("gray-matter");
|
|
58
59
|
gray_matter = __toESM(gray_matter);
|
|
60
|
+
let _alextheman_utility_node = require("@alextheman/utility/node");
|
|
59
61
|
|
|
60
62
|
//#region src/utility/miscellaneous/asciiToPng.ts
|
|
61
63
|
async function asciiToPng(ascii, options) {
|
|
@@ -418,7 +420,7 @@ function preCommit(program) {
|
|
|
418
420
|
${deprecationMessage}
|
|
419
421
|
Run the standard pre-commits used across all my repositories.`).option("--no-build", "Skip the build").option("--no-tests", "Skip the tests").option("--allow-unstaged", "Run even if nothing is staged").option("--repository-manager <repositoryManager>", "The repository manager if it is a monorepo (Only Turborepo is supported as of now)").action(async ({ build: shouldIncludeBuild, tests: shouldIncludeTests, allowUnstaged, repositoryManager: rawRepositoryManager }) => {
|
|
420
422
|
console.warn(deprecationMessage);
|
|
421
|
-
const repositoryManager = rawRepositoryManager ? (0, _alextheman_utility.parseZodSchema)(zod.default.enum(["turborepo"]), rawRepositoryManager?.toLowerCase(), new _alextheman_utility.DataError(rawRepositoryManager, "INVALID_REPOSITORY_MANAGER", "The repository manager provided does not exist or is not currently supported. We currently support the following: `turborepo`.")) : void 0;
|
|
423
|
+
const repositoryManager = rawRepositoryManager ? (0, _alextheman_utility.parseZodSchema)(zod.default.enum(["turborepo"]), rawRepositoryManager?.toLowerCase(), new _alextheman_utility.DataError({ repositoryManager: rawRepositoryManager }, "INVALID_REPOSITORY_MANAGER", "The repository manager provided does not exist or is not currently supported. We currently support the following: `turborepo`.")) : void 0;
|
|
422
424
|
const execaNoFail = (0, execa.execa)({ reject: false });
|
|
423
425
|
const { exitCode: diffExitCode } = await execaNoFail`git diff --cached --quiet`;
|
|
424
426
|
switch (diffExitCode) {
|
|
@@ -746,13 +748,6 @@ function getCommandArguments(program, script, scripts, args) {
|
|
|
746
748
|
return result;
|
|
747
749
|
}
|
|
748
750
|
|
|
749
|
-
//#endregion
|
|
750
|
-
//#region src/configs/types/PreCommitConfig.ts
|
|
751
|
-
const PackageManager = {
|
|
752
|
-
NPM: "npm",
|
|
753
|
-
PNPM: "pnpm"
|
|
754
|
-
};
|
|
755
|
-
|
|
756
751
|
//#endregion
|
|
757
752
|
//#region src/configs/types/ConfigFileName.ts
|
|
758
753
|
const ConfigFileName = {
|
|
@@ -810,7 +805,7 @@ function parseCreatePullRequestTemplateConfig(input) {
|
|
|
810
805
|
//#region src/configs/helpers/definePreCommitConfig.ts
|
|
811
806
|
const preCommitStepOptionsSchema = zod.default.strictObject({ arguments: zod.default.array(zod.default.string()).optional() });
|
|
812
807
|
const preCommitConfigSchema = zod.default.strictObject({
|
|
813
|
-
packageManager: zod.default.enum(PackageManager).optional(),
|
|
808
|
+
packageManager: zod.default.enum(_alextheman_utility_internal.PackageManager).optional(),
|
|
814
809
|
allowNoStagedChanges: zod.default.boolean().optional(),
|
|
815
810
|
steps: zod.default.array(zod.default.union([
|
|
816
811
|
zod.default.function({
|
|
@@ -819,7 +814,8 @@ const preCommitConfigSchema = zod.default.strictObject({
|
|
|
819
814
|
}),
|
|
820
815
|
zod.default.string(),
|
|
821
816
|
zod.default.tuple([zod.default.string(), preCommitStepOptionsSchema])
|
|
822
|
-
]))
|
|
817
|
+
])),
|
|
818
|
+
updateIndex: zod.default.boolean().optional()
|
|
823
819
|
});
|
|
824
820
|
|
|
825
821
|
//#endregion
|
|
@@ -847,7 +843,7 @@ async function loadAlexCLineConfig(filePath) {
|
|
|
847
843
|
//#endregion
|
|
848
844
|
//#region src/commands/pre-commit/pre-commit-2.ts
|
|
849
845
|
function preCommit2(program) {
|
|
850
|
-
program.command("pre-commit-2").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").action(async (
|
|
846
|
+
program.command("pre-commit-2").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) => {
|
|
851
847
|
const configPath = await findAlexCLineConfig(process.cwd());
|
|
852
848
|
if (!configPath) program.error("Could not find the path to the alex-c-line config file. Does it exist?", {
|
|
853
849
|
exitCode: 1,
|
|
@@ -858,6 +854,7 @@ function preCommit2(program) {
|
|
|
858
854
|
exitCode: 1,
|
|
859
855
|
code: "PRE_COMMIT_CONFIG_NOT_FOUND"
|
|
860
856
|
});
|
|
857
|
+
const { allowNoStagedChanges = options?.allowNoStagedChanges, updateIndex = options?.updateIndex } = preCommitConfig;
|
|
861
858
|
const { exitCode: diffExitCode } = await (0, execa.execa)({ reject: false })`git diff --cached --quiet`;
|
|
862
859
|
switch (diffExitCode) {
|
|
863
860
|
case 128: program.error("Not currently in a Git repository", {
|
|
@@ -871,7 +868,7 @@ function preCommit2(program) {
|
|
|
871
868
|
}
|
|
872
869
|
const { packageManager: packagePackageManager, scripts } = JSON.parse(await (0, node_fs_promises.readFile)(node_path.default.join(process.cwd(), "package.json"), "utf8"));
|
|
873
870
|
const rawPackageManager = preCommitConfig.packageManager ?? (typeof packagePackageManager === "string" ? packagePackageManager.split("@")[0] : void 0);
|
|
874
|
-
const packageManager = (0, _alextheman_utility.parseZodSchema)(zod.default.enum(PackageManager), rawPackageManager, new _alextheman_utility.DataError(rawPackageManager, "UNSUPPORTED_PACKAGE_MANAGER", `This package manager is not currently supported. Only the following are supported: ${Object.values(PackageManager).join(", ")}`));
|
|
871
|
+
const packageManager = (0, _alextheman_utility.parseZodSchema)(zod.default.enum(_alextheman_utility_internal.PackageManager), rawPackageManager, new _alextheman_utility.DataError({ packageManager: rawPackageManager }, "UNSUPPORTED_PACKAGE_MANAGER", `This package manager is not currently supported. Only the following are supported: ${Object.values(_alextheman_utility_internal.PackageManager).join(", ")}`));
|
|
875
872
|
const stepRunner = createStepRunner(program);
|
|
876
873
|
for (const step of preCommitConfig.steps) if (typeof step === "function") await step(stepRunner);
|
|
877
874
|
else if (typeof step === "string") await stepRunner(packageManager, getCommandArguments(program, step, scripts));
|
|
@@ -879,7 +876,7 @@ function preCommit2(program) {
|
|
|
879
876
|
const [script, options] = step;
|
|
880
877
|
await stepRunner(packageManager, getCommandArguments(program, script, scripts, options.arguments));
|
|
881
878
|
}
|
|
882
|
-
await stepRunner`git update-index --again`;
|
|
879
|
+
if (updateIndex) await stepRunner`git update-index --again`;
|
|
883
880
|
});
|
|
884
881
|
}
|
|
885
882
|
|
|
@@ -908,7 +905,7 @@ const PullRequestTemplateCategory = {
|
|
|
908
905
|
//#endregion
|
|
909
906
|
//#region src/configs/helpers/defineAlexCLinePrivateConfig.ts
|
|
910
907
|
const alexCLinePrivateConfigSchema = zod.default.object({ useLocalPackage: zod.default.strictObject({ localPackages: zod.default.record(zod.default.string(), zod.default.strictObject({
|
|
911
|
-
packageManager: zod.default.enum(PackageManager),
|
|
908
|
+
packageManager: zod.default.enum(_alextheman_utility_internal.PackageManager),
|
|
912
909
|
path: zod.default.string(),
|
|
913
910
|
prepareScript: zod.default.string().optional(),
|
|
914
911
|
dependencyGroup: zod.default.enum(DependencyGroup).optional(),
|
|
@@ -918,10 +915,6 @@ function parseAlexCLinePrivateConfig(data) {
|
|
|
918
915
|
return (0, _alextheman_utility.parseZodSchema)(alexCLinePrivateConfigSchema, data);
|
|
919
916
|
}
|
|
920
917
|
|
|
921
|
-
//#endregion
|
|
922
|
-
//#region src/configs/helpers/definePreCommitPrivateConfig.ts
|
|
923
|
-
const preCommitPrivateConfigSchema = zod.default.strictObject({ disableSteps: zod.default.array(zod.default.string()).optional() });
|
|
924
|
-
|
|
925
918
|
//#endregion
|
|
926
919
|
//#region src/utility/fileSystem/findPackageRoot.ts
|
|
927
920
|
async function findPackageRoot(startDirectory, packageName) {
|
|
@@ -935,7 +928,7 @@ async function findPackageRoot(startDirectory, packageName) {
|
|
|
935
928
|
if (parent === directory) break;
|
|
936
929
|
directory = parent;
|
|
937
930
|
}
|
|
938
|
-
throw new _alextheman_utility.DataError(packageName, "PACKAGE_ROOT_NOT_FOUND", `Could not find package root for ${packageName}`);
|
|
931
|
+
throw new _alextheman_utility.DataError({ packageName }, "PACKAGE_ROOT_NOT_FOUND", `Could not find package root for ${packageName}`);
|
|
939
932
|
}
|
|
940
933
|
|
|
941
934
|
//#endregion
|
|
@@ -956,7 +949,7 @@ async function getPullRequestTemplatesFromMarkdown(config) {
|
|
|
956
949
|
const templateVariables = getTemplateVariables$1(config);
|
|
957
950
|
const { category } = config;
|
|
958
951
|
const templatesPath = node_path.default.join(await findPackageRoot(node_path.default.dirname(__filename$3), "alex-c-line"), "templates", "pullRequest");
|
|
959
|
-
if (!(await (0, node_fs_promises.readdir)(templatesPath)).includes(category)) throw new _alextheman_utility.DataError(category, "CATEGORY_NOT_FOUND", "Category folder not found in the templates folder.");
|
|
952
|
+
if (!(await (0, node_fs_promises.readdir)(templatesPath)).includes(category)) throw new _alextheman_utility.DataError({ category }, "CATEGORY_NOT_FOUND", "Category folder not found in the templates folder.");
|
|
960
953
|
const categoryPath = node_path.default.join(templatesPath, category);
|
|
961
954
|
const allCategoryTemplateNames = (await (0, node_fs_promises.readdir)(categoryPath)).filter((name) => {
|
|
962
955
|
return name.endsWith(".md");
|
|
@@ -968,7 +961,7 @@ async function getPullRequestTemplatesFromMarkdown(config) {
|
|
|
968
961
|
const placeholders = (0, _alextheman_utility.parseZodSchema)(zod.default.array(zod.default.string()).default([]), data.placeholders);
|
|
969
962
|
let finalContent = content;
|
|
970
963
|
for (const placeholder of placeholders) {
|
|
971
|
-
if (!(placeholder in templateVariables)) throw new _alextheman_utility.DataError(placeholder, "INVALID_PLACEHOLDER", "The placeholder found in frontmatter can not be found in the metadata.");
|
|
964
|
+
if (!(placeholder in templateVariables)) throw new _alextheman_utility.DataError({ placeholder }, "INVALID_PLACEHOLDER", "The placeholder found in frontmatter can not be found in the metadata.");
|
|
972
965
|
finalContent = finalContent.replaceAll(`{{${placeholder}}}`, templateVariables[placeholder]);
|
|
973
966
|
}
|
|
974
967
|
allTemplates[templateName] = finalContent.trimStart();
|
|
@@ -1014,17 +1007,6 @@ function createPullRequestTemplate(program) {
|
|
|
1014
1007
|
});
|
|
1015
1008
|
}
|
|
1016
1009
|
|
|
1017
|
-
//#endregion
|
|
1018
|
-
//#region src/utility/fileSystem/getPackageJsonContents.ts
|
|
1019
|
-
async function getPackageJsonContents(directory) {
|
|
1020
|
-
try {
|
|
1021
|
-
return JSON.parse(await (0, node_fs_promises.readFile)(node_path.default.resolve(...directory.endsWith("package.json") ? [directory] : [directory, "package.json"]), "utf-8"));
|
|
1022
|
-
} catch (error) {
|
|
1023
|
-
if (error instanceof Error && "code" in error && error.code === "ENOENT") return null;
|
|
1024
|
-
throw error;
|
|
1025
|
-
}
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
1010
|
//#endregion
|
|
1029
1011
|
//#region src/utility/markdownTemplates/releaseNote/types/ReleaseStatus.ts
|
|
1030
1012
|
const ReleaseStatus = {
|
|
@@ -1071,7 +1053,7 @@ const __filename$2 = (0, node_url.fileURLToPath)(require("url").pathToFileURL(__
|
|
|
1071
1053
|
async function validateReleaseDocument(projectName, version, content, allowedReleaseStatus = ["In progress", "Released"]) {
|
|
1072
1054
|
if (!normaliseMarkdown(content).startsWith(normaliseMarkdown(_alextheman_utility.normaliseIndents`
|
|
1073
1055
|
# ${version} (${(0, _alextheman_utility.kebabToCamel)(version.type, { startWithUpper: true })} Release)
|
|
1074
|
-
`))) throw new _alextheman_utility.DataError(content.split("\n").slice(0, 3).join("\n"), "INVALID_HEADING", _alextheman_utility.normaliseIndents`
|
|
1056
|
+
`))) throw new _alextheman_utility.DataError({ heading: content.split("\n").slice(0, 3).join("\n") }, "INVALID_HEADING", _alextheman_utility.normaliseIndents`
|
|
1075
1057
|
Expected heading to be:
|
|
1076
1058
|
|
|
1077
1059
|
# ${version} (${(0, _alextheman_utility.kebabToCamel)(version.type, { startWithUpper: true })} Release)
|
|
@@ -1084,27 +1066,27 @@ async function validateReleaseDocument(projectName, version, content, allowedRel
|
|
|
1084
1066
|
const summary = getMarkdownBlock(content, "<!-- alex-c-line-start-release-summary -->", "<!-- alex-c-line-end-release-summary -->");
|
|
1085
1067
|
const templateContent = await (0, node_fs_promises.readFile)(node_path.default.join(await findPackageRoot(node_path.default.dirname(__filename$2), "alex-c-line"), "templates", "releases", `${version.type}.md`), "utf-8");
|
|
1086
1068
|
const templateSummary = getMarkdownBlock(templateContent, "<!-- alex-c-line-start-release-summary -->", "<!-- alex-c-line-end-release-summary -->")?.replaceAll(`{{projectName}}`, projectName);
|
|
1087
|
-
if (!templateSummary) throw new _alextheman_utility.DataError(templateContent, "SUMMARY_NOT_FOUND", "Expected to find a release summary but it was not found.");
|
|
1088
|
-
if (!summary) throw new _alextheman_utility.DataError(content, "SUMMARY_NOT_FOUND", _alextheman_utility.normaliseIndents`
|
|
1069
|
+
if (!templateSummary) throw new _alextheman_utility.DataError({ templateContent }, "SUMMARY_NOT_FOUND", "Expected to find a release summary but it was not found.");
|
|
1070
|
+
if (!summary) throw new _alextheman_utility.DataError({ content }, "SUMMARY_NOT_FOUND", _alextheman_utility.normaliseIndents`
|
|
1089
1071
|
Expected to find a release summary but it was not found. Expected release summary to be:
|
|
1090
1072
|
|
|
1091
1073
|
${templateSummary}
|
|
1092
1074
|
`);
|
|
1093
|
-
if (normaliseMarkdown(summary) !== normaliseMarkdown(templateSummary)) throw new _alextheman_utility.DataError(summary, "INVALID_SUMMARY", _alextheman_utility.normaliseIndents`
|
|
1075
|
+
if (normaliseMarkdown(summary) !== normaliseMarkdown(templateSummary)) throw new _alextheman_utility.DataError({ summary }, "INVALID_SUMMARY", _alextheman_utility.normaliseIndents`
|
|
1094
1076
|
Summary does not match what was expected. Expected release summary to be:
|
|
1095
1077
|
|
|
1096
1078
|
${templateSummary}
|
|
1097
1079
|
`);
|
|
1098
|
-
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.");
|
|
1099
|
-
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.");
|
|
1080
|
+
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.");
|
|
1081
|
+
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.");
|
|
1100
1082
|
}
|
|
1101
1083
|
|
|
1102
1084
|
//#endregion
|
|
1103
1085
|
//#region src/commands/template/releaseNote/check-release-note.ts
|
|
1104
1086
|
function checkReleaseNote(program) {
|
|
1105
|
-
program.command("check-release-note").argument("<documentPath>", "The path to the document",
|
|
1087
|
+
program.command("check-release-note").argument("<documentPath>", "The path to the document", _alextheman_utility_node.parseFilePath).option("--expected-release-status <expectedReleaseStatus>", "The expected release status of the document once we read it in.", parseReleaseStatus).description("Check whether a given release note is valid according to the templates or not. Returns exit code 0 for valid release note and non-zero otherwise.").action(async (documentPath, { expectedReleaseStatus }) => {
|
|
1106
1088
|
const fileContents = await (0, node_fs_promises.readFile)(node_path.default.join(process.cwd(), documentPath.fullPath), "utf-8");
|
|
1107
|
-
const { name } = (0, _alextheman_utility.parseZodSchema)(zod.default.object({ name: zod.default.string() }), await getPackageJsonContents(process.cwd()), () => {
|
|
1089
|
+
const { name } = (0, _alextheman_utility.parseZodSchema)(zod.default.object({ name: zod.default.string() }), await (0, _alextheman_utility_internal.getPackageJsonContents)(process.cwd()), () => {
|
|
1108
1090
|
program.error("Your package.json is invalid");
|
|
1109
1091
|
});
|
|
1110
1092
|
const documentVersion = new _alextheman_utility.VersionNumber(documentPath.base.split(".").filter((part) => {
|
|
@@ -1143,7 +1125,7 @@ async function getReleaseNoteTemplateFromMarkdown(projectName, version, metadata
|
|
|
1143
1125
|
const placeholders = (0, _alextheman_utility.parseZodSchema)(zod.default.array(zod.default.string()).default([]), data.placeholders);
|
|
1144
1126
|
let finalContent = content;
|
|
1145
1127
|
for (const placeholder of placeholders) {
|
|
1146
|
-
if (!(placeholder in templateVariables)) throw new _alextheman_utility.DataError(placeholder, "INVALID_PLACEHOLDER", "The placeholder found in frontmatter can not be found in the metadata.");
|
|
1128
|
+
if (!(placeholder in templateVariables)) throw new _alextheman_utility.DataError({ placeholder }, "INVALID_PLACEHOLDER", "The placeholder found in frontmatter can not be found in the metadata.");
|
|
1147
1129
|
finalContent = finalContent.replaceAll(`{{${placeholder}}}`, templateVariables[placeholder]);
|
|
1148
1130
|
}
|
|
1149
1131
|
return finalContent.trimStart();
|
|
@@ -1276,7 +1258,7 @@ function setReleaseStatus2(program) {
|
|
|
1276
1258
|
//#endregion
|
|
1277
1259
|
//#region package.json
|
|
1278
1260
|
var name = "alex-c-line";
|
|
1279
|
-
var version = "1.28.
|
|
1261
|
+
var version = "1.28.1";
|
|
1280
1262
|
var description = "Command-line tool with commands to streamline the developer workflow.";
|
|
1281
1263
|
var package_default = {
|
|
1282
1264
|
name,
|
|
@@ -1286,6 +1268,7 @@ var package_default = {
|
|
|
1286
1268
|
"type": "git",
|
|
1287
1269
|
"url": "git+https://github.com/alextheman231/alex-c-line.git"
|
|
1288
1270
|
},
|
|
1271
|
+
sideEffects: ["./dist/index.js"],
|
|
1289
1272
|
license: "MIT",
|
|
1290
1273
|
author: "alextheman",
|
|
1291
1274
|
type: "module",
|
|
@@ -1303,10 +1286,7 @@ var package_default = {
|
|
|
1303
1286
|
"default": "./dist/configs/internal/index.js"
|
|
1304
1287
|
}
|
|
1305
1288
|
},
|
|
1306
|
-
|
|
1307
|
-
module: "dist/index.cjs",
|
|
1308
|
-
types: "dist/index.d.ts",
|
|
1309
|
-
bin: { "alex-c-line": "dist/index.js" },
|
|
1289
|
+
bin: { "alex-c-line": "./dist/index.js" },
|
|
1310
1290
|
files: ["dist", "templates"],
|
|
1311
1291
|
scripts: {
|
|
1312
1292
|
"build": "tsdown",
|
|
@@ -1333,6 +1313,7 @@ var package_default = {
|
|
|
1333
1313
|
"prepare-local-eslint-plugin": "dotenv -e .env -- sh -c 'ESLINT_PLUGIN_PATH=${LOCAL_ESLINT_PLUGIN_PATH:-../eslint-plugin}; pnpm --prefix \"$ESLINT_PLUGIN_PATH\" run build && pnpm uninstall @alextheman/eslint-plugin && pnpm install --save-dev file:\"$ESLINT_PLUGIN_PATH\"'",
|
|
1334
1314
|
"prepare-local-utility": "dotenv -e .env -- sh -c 'UTILITY_PATH=${LOCAL_UTILITY_PATH:-../utility}; pnpm --prefix \"$UTILITY_PATH\" run build && pnpm uninstall @alextheman/utility && pnpm install file:\"$UTILITY_PATH\"'",
|
|
1335
1315
|
"test": "vitest run",
|
|
1316
|
+
"test-end-to-end": "RUN_END_TO_END=true vitest run tests/end-to-end --reporter verbose",
|
|
1336
1317
|
"test-watch": "vitest",
|
|
1337
1318
|
"update-dependencies": "pnpm update --latest && pnpm update",
|
|
1338
1319
|
"use-live-eslint-plugin": "pnpm run prepare-live-eslint-plugin && pnpm run lint",
|
|
@@ -1341,8 +1322,8 @@ var package_default = {
|
|
|
1341
1322
|
"use-local-utility": "pnpm run prepare-local-utility"
|
|
1342
1323
|
},
|
|
1343
1324
|
dependencies: {
|
|
1344
|
-
"@alextheman/utility": "^
|
|
1345
|
-
"@inquirer/prompts": "^8.2.
|
|
1325
|
+
"@alextheman/utility": "^5.1.4",
|
|
1326
|
+
"@inquirer/prompts": "^8.2.1",
|
|
1346
1327
|
"boxen": "^8.0.1",
|
|
1347
1328
|
"canvas": "^3.2.1",
|
|
1348
1329
|
"chalk": "^5.6.2",
|
|
@@ -1358,23 +1339,24 @@ var package_default = {
|
|
|
1358
1339
|
"zod": "^4.3.6"
|
|
1359
1340
|
},
|
|
1360
1341
|
devDependencies: {
|
|
1361
|
-
"@alextheman/eslint-plugin": "^5.
|
|
1342
|
+
"@alextheman/eslint-plugin": "^5.8.1",
|
|
1362
1343
|
"@commander-js/extra-typings": "^14.0.0",
|
|
1363
1344
|
"@types/eslint": "^9.6.1",
|
|
1364
|
-
"@types/node": "^25.
|
|
1345
|
+
"@types/node": "^25.3.0",
|
|
1365
1346
|
"@types/update-notifier": "^6.0.8",
|
|
1366
1347
|
"dotenv-cli": "^11.0.0",
|
|
1367
|
-
"eslint": "^10.0.
|
|
1348
|
+
"eslint": "^10.0.1",
|
|
1368
1349
|
"husky": "^9.1.7",
|
|
1369
1350
|
"prettier": "^3.8.1",
|
|
1370
1351
|
"tempy": "^3.2.0",
|
|
1371
1352
|
"ts-node": "^10.9.2",
|
|
1372
1353
|
"tsdown": "^0.20.3",
|
|
1373
1354
|
"typescript": "^5.9.3",
|
|
1355
|
+
"typescript-eslint": "^8.56.0",
|
|
1374
1356
|
"vite-tsconfig-paths": "^6.1.1",
|
|
1375
1357
|
"vitest": "^4.0.18"
|
|
1376
1358
|
},
|
|
1377
|
-
packageManager: "pnpm@10.
|
|
1359
|
+
packageManager: "pnpm@10.30.1+sha512.3590e550d5384caa39bd5c7c739f72270234b2f6059e13018f975c313b1eb9fefcc09714048765d4d9efe961382c312e624572c0420762bdc5d5940cdf9be73a",
|
|
1378
1360
|
engines: { "node": ">=22.0.0" },
|
|
1379
1361
|
pnpm: { "onlyBuiltDependencies": [
|
|
1380
1362
|
"canvas",
|
|
@@ -1458,7 +1440,7 @@ async function createAlexCLineProjectCache(cacheContents) {
|
|
|
1458
1440
|
const alexCLineProjectCacheSchema = zod.default.object({ useLocalPackage: zod.default.object({ dependencies: zod.default.record(zod.default.string(), zod.default.object({
|
|
1459
1441
|
currentVersion: zod.default.string(),
|
|
1460
1442
|
previousVersion: zod.default.union([zod.default.instanceof(_alextheman_utility.VersionNumber), zod.default.string()]).transform((value) => {
|
|
1461
|
-
return value instanceof _alextheman_utility.VersionNumber ? value.
|
|
1443
|
+
return value instanceof _alextheman_utility.VersionNumber ? value.format({ omitPrefix: true }) : value;
|
|
1462
1444
|
}),
|
|
1463
1445
|
dependencyGroup: zod.default.enum(DependencyGroup)
|
|
1464
1446
|
})) }).partial() }).partial();
|
|
@@ -1497,29 +1479,6 @@ async function loadAlexCLinePrivateConfig(filePath) {
|
|
|
1497
1479
|
//#region src/utility/constants/experimentalHeader.ts
|
|
1498
1480
|
const experimentalHeader = "[EXPERIMENTAL]: This feature is experimental and may change across patch versions. Feel free to try it out and provide feedback, but do not rely on it in production code yet.";
|
|
1499
1481
|
|
|
1500
|
-
//#endregion
|
|
1501
|
-
//#region src/utility/miscellaneous/parseJSONFromStdout.ts
|
|
1502
|
-
function parseJsonFromStdout(stdout) {
|
|
1503
|
-
const start = Math.min(...["[", "{"].map((character) => {
|
|
1504
|
-
return stdout.indexOf(character);
|
|
1505
|
-
}).filter((index) => {
|
|
1506
|
-
return index !== -1;
|
|
1507
|
-
}));
|
|
1508
|
-
if (!Number.isFinite(start)) throw new _alextheman_utility.DataError({ stdout }, "NO_JSON_FOUND_IN_OUTPUT", "No JSON found in output");
|
|
1509
|
-
return JSON.parse(stdout.slice(start));
|
|
1510
|
-
}
|
|
1511
|
-
|
|
1512
|
-
//#endregion
|
|
1513
|
-
//#region src/utility/fileSystem/getExpectedTgzName.ts
|
|
1514
|
-
async function getExpectedTgzName(packagePath, packageManager) {
|
|
1515
|
-
const { stdout: rawPackedTgzData } = await (0, execa.execa)({ cwd: packagePath })`${packageManager} pack --json --dry-run`;
|
|
1516
|
-
const packedTgzData = parseJsonFromStdout(rawPackedTgzData);
|
|
1517
|
-
const parsedPackedTgzData = (0, _alextheman_utility.parseZodSchema)(packageManager === "pnpm" ? zod.default.object({ filename: zod.default.string() }) : zod.default.array(zod.default.object({ filename: zod.default.string() })), packedTgzData, new _alextheman_utility.DataError(packedTgzData, "AMBIGUOUS_EXPECTED_FILE_NAME", "Could not figire out the expected filename."));
|
|
1518
|
-
const [normalisedTgzMetadata] = Array.isArray(parsedPackedTgzData) ? parsedPackedTgzData : [parsedPackedTgzData];
|
|
1519
|
-
const { filename: expectedTgzFileName } = normalisedTgzMetadata;
|
|
1520
|
-
return expectedTgzFileName;
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
1482
|
//#endregion
|
|
1524
1483
|
//#region src/utility/fileSystem/findTgzFile.ts
|
|
1525
1484
|
async function findTgzFile(packagePath, packageManager) {
|
|
@@ -1527,7 +1486,7 @@ async function findTgzFile(packagePath, packageManager) {
|
|
|
1527
1486
|
return fileName.endsWith(".tgz");
|
|
1528
1487
|
});
|
|
1529
1488
|
if (tgzFiles.length === 0) throw new _alextheman_utility.DataError({ tgzFiles }, "TGZ_FILE_NOT_FOUND", "Could not find any .tgz files");
|
|
1530
|
-
const expectedTgzFileName = await getExpectedTgzName(packagePath, packageManager);
|
|
1489
|
+
const expectedTgzFileName = await (0, _alextheman_utility_internal.getExpectedTgzName)(packagePath, packageManager);
|
|
1531
1490
|
const amountOfMatchingFiles = tgzFiles.filter((fileName) => {
|
|
1532
1491
|
return fileName === expectedTgzFileName;
|
|
1533
1492
|
}).length;
|
|
@@ -1542,15 +1501,6 @@ async function findTgzFile(packagePath, packageManager) {
|
|
|
1542
1501
|
return expectedTgzFileName;
|
|
1543
1502
|
}
|
|
1544
1503
|
|
|
1545
|
-
//#endregion
|
|
1546
|
-
//#region src/utility/fileSystem/getDependenciesFromPackageInfo.ts
|
|
1547
|
-
function getDependenciesFromGroup(packageInfo, dependencyGroup) {
|
|
1548
|
-
return {
|
|
1549
|
-
dependencies: (0, _alextheman_utility.parseZodSchema)(zod.default.record(zod.default.string(), zod.default.string()), packageInfo.dependencies ?? {}),
|
|
1550
|
-
devDependencies: (0, _alextheman_utility.parseZodSchema)(zod.default.record(zod.default.string(), zod.default.string()), packageInfo.devDependencies ?? {})
|
|
1551
|
-
}[dependencyGroup];
|
|
1552
|
-
}
|
|
1553
|
-
|
|
1554
1504
|
//#endregion
|
|
1555
1505
|
//#region src/utility/miscellaneous/removeAllTarballs.ts
|
|
1556
1506
|
async function removeAllTarballs(packagePath, packageName) {
|
|
@@ -1586,16 +1536,16 @@ function useLocalPackage(program) {
|
|
|
1586
1536
|
configPath
|
|
1587
1537
|
}, "PACKAGE_NOT_FOUND", `Could not find ${packageName} in your private config.`);
|
|
1588
1538
|
const { packageManager, prepareScript = "build", dependencyGroup = "dependencies", keepOldTarballs } = localPackage;
|
|
1589
|
-
const packageInfo = await getPackageJsonContents(process.cwd());
|
|
1539
|
+
const packageInfo = await (0, _alextheman_utility_internal.getPackageJsonContents)(process.cwd());
|
|
1590
1540
|
if (packageInfo === null) throw new _alextheman_utility.DataError({ currentDirectory: process.cwd() }, "MISSING_CURRENT_REPOSITORY_PACKAGE_JSON", "Could not find package.json in the current location");
|
|
1591
|
-
const dependencies = getDependenciesFromGroup(packageInfo, dependencyGroup);
|
|
1541
|
+
const dependencies = (0, _alextheman_utility_internal.getDependenciesFromGroup)(packageInfo, dependencyGroup);
|
|
1592
1542
|
if (!(packageName in dependencies) && packageName !== "alex-c-line") throw new _alextheman_utility.DataError({
|
|
1593
1543
|
packageName,
|
|
1594
1544
|
dependencyGroup,
|
|
1595
1545
|
packagePath: process.cwd()
|
|
1596
1546
|
}, "PACKAGE_NOT_FOUND", `Could not find ${packageName} in the ${dependencyGroup} of your package.json.`);
|
|
1597
1547
|
const localPackagePath = node_path.default.resolve(process.cwd(), localPackage.path);
|
|
1598
|
-
const localPackageInfo = await getPackageJsonContents(localPackagePath);
|
|
1548
|
+
const localPackageInfo = await (0, _alextheman_utility_internal.getPackageJsonContents)(localPackagePath);
|
|
1599
1549
|
if (localPackageInfo === null) throw new _alextheman_utility.DataError({ localPackagePath }, "MISSING_PACKAGE_REPOSITORY_PACKAGE_JSON", "Could not find package.json in the package repository.");
|
|
1600
1550
|
const localPackageRepositoryName = (0, _alextheman_utility.parseZodSchema)(zod.default.string(), localPackageInfo.name);
|
|
1601
1551
|
if (localPackageRepositoryName !== packageName) throw new _alextheman_utility.DataError({
|
|
@@ -1643,7 +1593,7 @@ function useLocalPackage(program) {
|
|
|
1643
1593
|
...cacheContents?.useLocalPackage?.dependencies?.[packageName] ?? {},
|
|
1644
1594
|
previousVersion: dependencies[packageName],
|
|
1645
1595
|
dependencyGroup,
|
|
1646
|
-
currentVersion: getDependenciesFromGroup(await getPackageJsonContents(process.cwd()) ?? {}, dependencyGroup)[packageName]
|
|
1596
|
+
currentVersion: (0, _alextheman_utility_internal.getDependenciesFromGroup)(await (0, _alextheman_utility_internal.getPackageJsonContents)(process.cwd()) ?? {}, dependencyGroup)[packageName]
|
|
1647
1597
|
};
|
|
1648
1598
|
await createAlexCLineProjectCache({
|
|
1649
1599
|
...cacheContents ?? {},
|
|
@@ -1708,7 +1658,7 @@ function incrementVersion(program) {
|
|
|
1708
1658
|
- "minor": Change the minor version v1.2.3 → v1.3.0
|
|
1709
1659
|
- "patch": Change the patch version v1.2.3 → v1.2.4
|
|
1710
1660
|
`, _alextheman_utility.parseVersionType).option("--no-prefix").option("--prefix", "Whether to add the `v` prefix from the output version or not (defaults to true).").action((version, incrementType, { prefix }) => {
|
|
1711
|
-
console.info(version.increment(incrementType).
|
|
1661
|
+
console.info(version.increment(incrementType).format({ omitPrefix: !prefix }));
|
|
1712
1662
|
});
|
|
1713
1663
|
}
|
|
1714
1664
|
|
|
@@ -1779,12 +1729,12 @@ function formatError(error) {
|
|
|
1779
1729
|
try {
|
|
1780
1730
|
const program = new commander.Command();
|
|
1781
1731
|
program.name(name).description(description).version(version);
|
|
1782
|
-
(0, update_notifier.default)({ pkg: package_default }).notify({ message: `
|
|
1783
|
-
${await createAlexCLineArtwork({ includeColors: Boolean(supports_color.default.stdout) })}
|
|
1784
|
-
A new update of \`alex-c-line\` is available!
|
|
1785
|
-
|
|
1786
|
-
Run \`{updateCommand}\` to update.
|
|
1787
|
-
` });
|
|
1732
|
+
if (!(process.env.NODE_ENV === "test" || (0, _alextheman_utility.parseBoolean)(process.env.RUN_END_TO_END ?? "false") || (0, _alextheman_utility.parseBoolean)(process.env.CI ?? "false"))) (0, update_notifier.default)({ pkg: package_default }).notify({ message: `
|
|
1733
|
+
${await createAlexCLineArtwork({ includeColors: Boolean(supports_color.default.stdout) })}
|
|
1734
|
+
A new update of \`alex-c-line\` is available!
|
|
1735
|
+
{currentVersion} → {latestVersion}
|
|
1736
|
+
Run \`{updateCommand}\` to update.
|
|
1737
|
+
` });
|
|
1788
1738
|
createCommands(program);
|
|
1789
1739
|
await program.parseAsync(process.argv);
|
|
1790
1740
|
} catch (error) {
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
+
import { DataError, VersionNumber, VersionType, encryptWithKey, fillArray, getStringsAndInterpolations, interpolate, isTemplateStringsArray, kebabToCamel, normaliseIndents, omitProperties, parseBoolean, parseVersionType, parseZodSchema, parseZodSchemaAsync, removeDuplicates, removeUndefinedFromObject, stringifyDotenv } from "@alextheman/utility";
|
|
3
4
|
import { Command } from "commander";
|
|
4
5
|
import supportsColor from "supports-color";
|
|
5
6
|
import updateNotifier from "update-notifier";
|
|
@@ -9,15 +10,16 @@ import path from "node:path";
|
|
|
9
10
|
import boxen from "boxen";
|
|
10
11
|
import chalk from "chalk";
|
|
11
12
|
import figlet from "figlet";
|
|
12
|
-
import { DataError, VersionNumber, VersionType, encryptWithKey, fillArray, getStringsAndInterpolations, interpolate, isTemplateStringsArray, kebabToCamel, normaliseIndents, omitProperties, parseFilePath, parseVersionType, parseZodSchema, parseZodSchemaAsync, removeDuplicates, removeUndefinedFromObject, stringifyDotenv } from "@alextheman/utility";
|
|
13
13
|
import { ExecaError, execa } from "execa";
|
|
14
14
|
import dotenv, { parse } from "dotenv";
|
|
15
15
|
import dotenvStringify from "dotenv-stringify";
|
|
16
16
|
import z from "zod";
|
|
17
17
|
import { confirm, input, password, select } from "@inquirer/prompts";
|
|
18
18
|
import os from "node:os";
|
|
19
|
+
import { PackageManager, getDependenciesFromGroup, getExpectedTgzName, getPackageJsonContents } from "@alextheman/utility/internal";
|
|
19
20
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
20
21
|
import matter from "gray-matter";
|
|
22
|
+
import { parseFilePath } from "@alextheman/utility/node";
|
|
21
23
|
|
|
22
24
|
//#region src/utility/miscellaneous/asciiToPng.ts
|
|
23
25
|
async function asciiToPng(ascii, options) {
|
|
@@ -380,7 +382,7 @@ function preCommit(program) {
|
|
|
380
382
|
${deprecationMessage}
|
|
381
383
|
Run the standard pre-commits used across all my repositories.`).option("--no-build", "Skip the build").option("--no-tests", "Skip the tests").option("--allow-unstaged", "Run even if nothing is staged").option("--repository-manager <repositoryManager>", "The repository manager if it is a monorepo (Only Turborepo is supported as of now)").action(async ({ build: shouldIncludeBuild, tests: shouldIncludeTests, allowUnstaged, repositoryManager: rawRepositoryManager }) => {
|
|
382
384
|
console.warn(deprecationMessage);
|
|
383
|
-
const repositoryManager = rawRepositoryManager ? parseZodSchema(z.enum(["turborepo"]), rawRepositoryManager?.toLowerCase(), new DataError(rawRepositoryManager, "INVALID_REPOSITORY_MANAGER", "The repository manager provided does not exist or is not currently supported. We currently support the following: `turborepo`.")) : void 0;
|
|
385
|
+
const repositoryManager = rawRepositoryManager ? parseZodSchema(z.enum(["turborepo"]), rawRepositoryManager?.toLowerCase(), new DataError({ repositoryManager: rawRepositoryManager }, "INVALID_REPOSITORY_MANAGER", "The repository manager provided does not exist or is not currently supported. We currently support the following: `turborepo`.")) : void 0;
|
|
384
386
|
const execaNoFail = execa({ reject: false });
|
|
385
387
|
const { exitCode: diffExitCode } = await execaNoFail`git diff --cached --quiet`;
|
|
386
388
|
switch (diffExitCode) {
|
|
@@ -708,13 +710,6 @@ function getCommandArguments(program, script, scripts, args) {
|
|
|
708
710
|
return result;
|
|
709
711
|
}
|
|
710
712
|
|
|
711
|
-
//#endregion
|
|
712
|
-
//#region src/configs/types/PreCommitConfig.ts
|
|
713
|
-
const PackageManager = {
|
|
714
|
-
NPM: "npm",
|
|
715
|
-
PNPM: "pnpm"
|
|
716
|
-
};
|
|
717
|
-
|
|
718
713
|
//#endregion
|
|
719
714
|
//#region src/configs/types/ConfigFileName.ts
|
|
720
715
|
const ConfigFileName = {
|
|
@@ -781,7 +776,8 @@ const preCommitConfigSchema = z.strictObject({
|
|
|
781
776
|
}),
|
|
782
777
|
z.string(),
|
|
783
778
|
z.tuple([z.string(), preCommitStepOptionsSchema])
|
|
784
|
-
]))
|
|
779
|
+
])),
|
|
780
|
+
updateIndex: z.boolean().optional()
|
|
785
781
|
});
|
|
786
782
|
|
|
787
783
|
//#endregion
|
|
@@ -809,7 +805,7 @@ async function loadAlexCLineConfig(filePath) {
|
|
|
809
805
|
//#endregion
|
|
810
806
|
//#region src/commands/pre-commit/pre-commit-2.ts
|
|
811
807
|
function preCommit2(program) {
|
|
812
|
-
program.command("pre-commit-2").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").action(async (
|
|
808
|
+
program.command("pre-commit-2").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) => {
|
|
813
809
|
const configPath = await findAlexCLineConfig(process.cwd());
|
|
814
810
|
if (!configPath) program.error("Could not find the path to the alex-c-line config file. Does it exist?", {
|
|
815
811
|
exitCode: 1,
|
|
@@ -820,6 +816,7 @@ function preCommit2(program) {
|
|
|
820
816
|
exitCode: 1,
|
|
821
817
|
code: "PRE_COMMIT_CONFIG_NOT_FOUND"
|
|
822
818
|
});
|
|
819
|
+
const { allowNoStagedChanges = options?.allowNoStagedChanges, updateIndex = options?.updateIndex } = preCommitConfig;
|
|
823
820
|
const { exitCode: diffExitCode } = await execa({ reject: false })`git diff --cached --quiet`;
|
|
824
821
|
switch (diffExitCode) {
|
|
825
822
|
case 128: program.error("Not currently in a Git repository", {
|
|
@@ -833,7 +830,7 @@ function preCommit2(program) {
|
|
|
833
830
|
}
|
|
834
831
|
const { packageManager: packagePackageManager, scripts } = JSON.parse(await readFile(path.join(process.cwd(), "package.json"), "utf8"));
|
|
835
832
|
const rawPackageManager = preCommitConfig.packageManager ?? (typeof packagePackageManager === "string" ? packagePackageManager.split("@")[0] : void 0);
|
|
836
|
-
const packageManager = parseZodSchema(z.enum(PackageManager), rawPackageManager, new DataError(rawPackageManager, "UNSUPPORTED_PACKAGE_MANAGER", `This package manager is not currently supported. Only the following are supported: ${Object.values(PackageManager).join(", ")}`));
|
|
833
|
+
const packageManager = parseZodSchema(z.enum(PackageManager), rawPackageManager, new DataError({ packageManager: rawPackageManager }, "UNSUPPORTED_PACKAGE_MANAGER", `This package manager is not currently supported. Only the following are supported: ${Object.values(PackageManager).join(", ")}`));
|
|
837
834
|
const stepRunner = createStepRunner(program);
|
|
838
835
|
for (const step of preCommitConfig.steps) if (typeof step === "function") await step(stepRunner);
|
|
839
836
|
else if (typeof step === "string") await stepRunner(packageManager, getCommandArguments(program, step, scripts));
|
|
@@ -841,7 +838,7 @@ function preCommit2(program) {
|
|
|
841
838
|
const [script, options] = step;
|
|
842
839
|
await stepRunner(packageManager, getCommandArguments(program, script, scripts, options.arguments));
|
|
843
840
|
}
|
|
844
|
-
await stepRunner`git update-index --again`;
|
|
841
|
+
if (updateIndex) await stepRunner`git update-index --again`;
|
|
845
842
|
});
|
|
846
843
|
}
|
|
847
844
|
|
|
@@ -880,10 +877,6 @@ function parseAlexCLinePrivateConfig(data) {
|
|
|
880
877
|
return parseZodSchema(alexCLinePrivateConfigSchema, data);
|
|
881
878
|
}
|
|
882
879
|
|
|
883
|
-
//#endregion
|
|
884
|
-
//#region src/configs/helpers/definePreCommitPrivateConfig.ts
|
|
885
|
-
const preCommitPrivateConfigSchema = z.strictObject({ disableSteps: z.array(z.string()).optional() });
|
|
886
|
-
|
|
887
880
|
//#endregion
|
|
888
881
|
//#region src/utility/fileSystem/findPackageRoot.ts
|
|
889
882
|
async function findPackageRoot(startDirectory, packageName) {
|
|
@@ -897,7 +890,7 @@ async function findPackageRoot(startDirectory, packageName) {
|
|
|
897
890
|
if (parent === directory) break;
|
|
898
891
|
directory = parent;
|
|
899
892
|
}
|
|
900
|
-
throw new DataError(packageName, "PACKAGE_ROOT_NOT_FOUND", `Could not find package root for ${packageName}`);
|
|
893
|
+
throw new DataError({ packageName }, "PACKAGE_ROOT_NOT_FOUND", `Could not find package root for ${packageName}`);
|
|
901
894
|
}
|
|
902
895
|
|
|
903
896
|
//#endregion
|
|
@@ -918,7 +911,7 @@ async function getPullRequestTemplatesFromMarkdown(config) {
|
|
|
918
911
|
const templateVariables = getTemplateVariables$1(config);
|
|
919
912
|
const { category } = config;
|
|
920
913
|
const templatesPath = path.join(await findPackageRoot(path.dirname(__filename$2), "alex-c-line"), "templates", "pullRequest");
|
|
921
|
-
if (!(await readdir(templatesPath)).includes(category)) throw new DataError(category, "CATEGORY_NOT_FOUND", "Category folder not found in the templates folder.");
|
|
914
|
+
if (!(await readdir(templatesPath)).includes(category)) throw new DataError({ category }, "CATEGORY_NOT_FOUND", "Category folder not found in the templates folder.");
|
|
922
915
|
const categoryPath = path.join(templatesPath, category);
|
|
923
916
|
const allCategoryTemplateNames = (await readdir(categoryPath)).filter((name) => {
|
|
924
917
|
return name.endsWith(".md");
|
|
@@ -930,7 +923,7 @@ async function getPullRequestTemplatesFromMarkdown(config) {
|
|
|
930
923
|
const placeholders = parseZodSchema(z.array(z.string()).default([]), data.placeholders);
|
|
931
924
|
let finalContent = content;
|
|
932
925
|
for (const placeholder of placeholders) {
|
|
933
|
-
if (!(placeholder in templateVariables)) throw new DataError(placeholder, "INVALID_PLACEHOLDER", "The placeholder found in frontmatter can not be found in the metadata.");
|
|
926
|
+
if (!(placeholder in templateVariables)) throw new DataError({ placeholder }, "INVALID_PLACEHOLDER", "The placeholder found in frontmatter can not be found in the metadata.");
|
|
934
927
|
finalContent = finalContent.replaceAll(`{{${placeholder}}}`, templateVariables[placeholder]);
|
|
935
928
|
}
|
|
936
929
|
allTemplates[templateName] = finalContent.trimStart();
|
|
@@ -976,17 +969,6 @@ function createPullRequestTemplate(program) {
|
|
|
976
969
|
});
|
|
977
970
|
}
|
|
978
971
|
|
|
979
|
-
//#endregion
|
|
980
|
-
//#region src/utility/fileSystem/getPackageJsonContents.ts
|
|
981
|
-
async function getPackageJsonContents(directory) {
|
|
982
|
-
try {
|
|
983
|
-
return JSON.parse(await readFile(path.resolve(...directory.endsWith("package.json") ? [directory] : [directory, "package.json"]), "utf-8"));
|
|
984
|
-
} catch (error) {
|
|
985
|
-
if (error instanceof Error && "code" in error && error.code === "ENOENT") return null;
|
|
986
|
-
throw error;
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
|
|
990
972
|
//#endregion
|
|
991
973
|
//#region src/utility/markdownTemplates/releaseNote/types/ReleaseStatus.ts
|
|
992
974
|
const ReleaseStatus = {
|
|
@@ -1033,7 +1015,7 @@ const __filename$1 = fileURLToPath(import.meta.url);
|
|
|
1033
1015
|
async function validateReleaseDocument(projectName, version, content, allowedReleaseStatus = ["In progress", "Released"]) {
|
|
1034
1016
|
if (!normaliseMarkdown(content).startsWith(normaliseMarkdown(normaliseIndents`
|
|
1035
1017
|
# ${version} (${kebabToCamel(version.type, { startWithUpper: true })} Release)
|
|
1036
|
-
`))) throw new DataError(content.split("\n").slice(0, 3).join("\n"), "INVALID_HEADING", normaliseIndents`
|
|
1018
|
+
`))) throw new DataError({ heading: content.split("\n").slice(0, 3).join("\n") }, "INVALID_HEADING", normaliseIndents`
|
|
1037
1019
|
Expected heading to be:
|
|
1038
1020
|
|
|
1039
1021
|
# ${version} (${kebabToCamel(version.type, { startWithUpper: true })} Release)
|
|
@@ -1046,19 +1028,19 @@ async function validateReleaseDocument(projectName, version, content, allowedRel
|
|
|
1046
1028
|
const summary = getMarkdownBlock(content, "<!-- alex-c-line-start-release-summary -->", "<!-- alex-c-line-end-release-summary -->");
|
|
1047
1029
|
const templateContent = await readFile(path.join(await findPackageRoot(path.dirname(__filename$1), "alex-c-line"), "templates", "releases", `${version.type}.md`), "utf-8");
|
|
1048
1030
|
const templateSummary = getMarkdownBlock(templateContent, "<!-- alex-c-line-start-release-summary -->", "<!-- alex-c-line-end-release-summary -->")?.replaceAll(`{{projectName}}`, projectName);
|
|
1049
|
-
if (!templateSummary) throw new DataError(templateContent, "SUMMARY_NOT_FOUND", "Expected to find a release summary but it was not found.");
|
|
1050
|
-
if (!summary) throw new DataError(content, "SUMMARY_NOT_FOUND", normaliseIndents`
|
|
1031
|
+
if (!templateSummary) throw new DataError({ templateContent }, "SUMMARY_NOT_FOUND", "Expected to find a release summary but it was not found.");
|
|
1032
|
+
if (!summary) throw new DataError({ content }, "SUMMARY_NOT_FOUND", normaliseIndents`
|
|
1051
1033
|
Expected to find a release summary but it was not found. Expected release summary to be:
|
|
1052
1034
|
|
|
1053
1035
|
${templateSummary}
|
|
1054
1036
|
`);
|
|
1055
|
-
if (normaliseMarkdown(summary) !== normaliseMarkdown(templateSummary)) throw new DataError(summary, "INVALID_SUMMARY", normaliseIndents`
|
|
1037
|
+
if (normaliseMarkdown(summary) !== normaliseMarkdown(templateSummary)) throw new DataError({ summary }, "INVALID_SUMMARY", normaliseIndents`
|
|
1056
1038
|
Summary does not match what was expected. Expected release summary to be:
|
|
1057
1039
|
|
|
1058
1040
|
${templateSummary}
|
|
1059
1041
|
`);
|
|
1060
|
-
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.");
|
|
1061
|
-
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.");
|
|
1042
|
+
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.");
|
|
1043
|
+
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.");
|
|
1062
1044
|
}
|
|
1063
1045
|
|
|
1064
1046
|
//#endregion
|
|
@@ -1105,7 +1087,7 @@ async function getReleaseNoteTemplateFromMarkdown(projectName, version, metadata
|
|
|
1105
1087
|
const placeholders = parseZodSchema(z.array(z.string()).default([]), data.placeholders);
|
|
1106
1088
|
let finalContent = content;
|
|
1107
1089
|
for (const placeholder of placeholders) {
|
|
1108
|
-
if (!(placeholder in templateVariables)) throw new DataError(placeholder, "INVALID_PLACEHOLDER", "The placeholder found in frontmatter can not be found in the metadata.");
|
|
1090
|
+
if (!(placeholder in templateVariables)) throw new DataError({ placeholder }, "INVALID_PLACEHOLDER", "The placeholder found in frontmatter can not be found in the metadata.");
|
|
1109
1091
|
finalContent = finalContent.replaceAll(`{{${placeholder}}}`, templateVariables[placeholder]);
|
|
1110
1092
|
}
|
|
1111
1093
|
return finalContent.trimStart();
|
|
@@ -1238,7 +1220,7 @@ function setReleaseStatus2(program) {
|
|
|
1238
1220
|
//#endregion
|
|
1239
1221
|
//#region package.json
|
|
1240
1222
|
var name = "alex-c-line";
|
|
1241
|
-
var version = "1.28.
|
|
1223
|
+
var version = "1.28.1";
|
|
1242
1224
|
var description = "Command-line tool with commands to streamline the developer workflow.";
|
|
1243
1225
|
var package_default = {
|
|
1244
1226
|
name,
|
|
@@ -1248,6 +1230,7 @@ var package_default = {
|
|
|
1248
1230
|
"type": "git",
|
|
1249
1231
|
"url": "git+https://github.com/alextheman231/alex-c-line.git"
|
|
1250
1232
|
},
|
|
1233
|
+
sideEffects: ["./dist/index.js"],
|
|
1251
1234
|
license: "MIT",
|
|
1252
1235
|
author: "alextheman",
|
|
1253
1236
|
type: "module",
|
|
@@ -1265,10 +1248,7 @@ var package_default = {
|
|
|
1265
1248
|
"default": "./dist/configs/internal/index.js"
|
|
1266
1249
|
}
|
|
1267
1250
|
},
|
|
1268
|
-
|
|
1269
|
-
module: "dist/index.cjs",
|
|
1270
|
-
types: "dist/index.d.ts",
|
|
1271
|
-
bin: { "alex-c-line": "dist/index.js" },
|
|
1251
|
+
bin: { "alex-c-line": "./dist/index.js" },
|
|
1272
1252
|
files: ["dist", "templates"],
|
|
1273
1253
|
scripts: {
|
|
1274
1254
|
"build": "tsdown",
|
|
@@ -1295,6 +1275,7 @@ var package_default = {
|
|
|
1295
1275
|
"prepare-local-eslint-plugin": "dotenv -e .env -- sh -c 'ESLINT_PLUGIN_PATH=${LOCAL_ESLINT_PLUGIN_PATH:-../eslint-plugin}; pnpm --prefix \"$ESLINT_PLUGIN_PATH\" run build && pnpm uninstall @alextheman/eslint-plugin && pnpm install --save-dev file:\"$ESLINT_PLUGIN_PATH\"'",
|
|
1296
1276
|
"prepare-local-utility": "dotenv -e .env -- sh -c 'UTILITY_PATH=${LOCAL_UTILITY_PATH:-../utility}; pnpm --prefix \"$UTILITY_PATH\" run build && pnpm uninstall @alextheman/utility && pnpm install file:\"$UTILITY_PATH\"'",
|
|
1297
1277
|
"test": "vitest run",
|
|
1278
|
+
"test-end-to-end": "RUN_END_TO_END=true vitest run tests/end-to-end --reporter verbose",
|
|
1298
1279
|
"test-watch": "vitest",
|
|
1299
1280
|
"update-dependencies": "pnpm update --latest && pnpm update",
|
|
1300
1281
|
"use-live-eslint-plugin": "pnpm run prepare-live-eslint-plugin && pnpm run lint",
|
|
@@ -1303,8 +1284,8 @@ var package_default = {
|
|
|
1303
1284
|
"use-local-utility": "pnpm run prepare-local-utility"
|
|
1304
1285
|
},
|
|
1305
1286
|
dependencies: {
|
|
1306
|
-
"@alextheman/utility": "^
|
|
1307
|
-
"@inquirer/prompts": "^8.2.
|
|
1287
|
+
"@alextheman/utility": "^5.1.4",
|
|
1288
|
+
"@inquirer/prompts": "^8.2.1",
|
|
1308
1289
|
"boxen": "^8.0.1",
|
|
1309
1290
|
"canvas": "^3.2.1",
|
|
1310
1291
|
"chalk": "^5.6.2",
|
|
@@ -1320,23 +1301,24 @@ var package_default = {
|
|
|
1320
1301
|
"zod": "^4.3.6"
|
|
1321
1302
|
},
|
|
1322
1303
|
devDependencies: {
|
|
1323
|
-
"@alextheman/eslint-plugin": "^5.
|
|
1304
|
+
"@alextheman/eslint-plugin": "^5.8.1",
|
|
1324
1305
|
"@commander-js/extra-typings": "^14.0.0",
|
|
1325
1306
|
"@types/eslint": "^9.6.1",
|
|
1326
|
-
"@types/node": "^25.
|
|
1307
|
+
"@types/node": "^25.3.0",
|
|
1327
1308
|
"@types/update-notifier": "^6.0.8",
|
|
1328
1309
|
"dotenv-cli": "^11.0.0",
|
|
1329
|
-
"eslint": "^10.0.
|
|
1310
|
+
"eslint": "^10.0.1",
|
|
1330
1311
|
"husky": "^9.1.7",
|
|
1331
1312
|
"prettier": "^3.8.1",
|
|
1332
1313
|
"tempy": "^3.2.0",
|
|
1333
1314
|
"ts-node": "^10.9.2",
|
|
1334
1315
|
"tsdown": "^0.20.3",
|
|
1335
1316
|
"typescript": "^5.9.3",
|
|
1317
|
+
"typescript-eslint": "^8.56.0",
|
|
1336
1318
|
"vite-tsconfig-paths": "^6.1.1",
|
|
1337
1319
|
"vitest": "^4.0.18"
|
|
1338
1320
|
},
|
|
1339
|
-
packageManager: "pnpm@10.
|
|
1321
|
+
packageManager: "pnpm@10.30.1+sha512.3590e550d5384caa39bd5c7c739f72270234b2f6059e13018f975c313b1eb9fefcc09714048765d4d9efe961382c312e624572c0420762bdc5d5940cdf9be73a",
|
|
1340
1322
|
engines: { "node": ">=22.0.0" },
|
|
1341
1323
|
pnpm: { "onlyBuiltDependencies": [
|
|
1342
1324
|
"canvas",
|
|
@@ -1420,7 +1402,7 @@ async function createAlexCLineProjectCache(cacheContents) {
|
|
|
1420
1402
|
const alexCLineProjectCacheSchema = z.object({ useLocalPackage: z.object({ dependencies: z.record(z.string(), z.object({
|
|
1421
1403
|
currentVersion: z.string(),
|
|
1422
1404
|
previousVersion: z.union([z.instanceof(VersionNumber), z.string()]).transform((value) => {
|
|
1423
|
-
return value instanceof VersionNumber ? value.
|
|
1405
|
+
return value instanceof VersionNumber ? value.format({ omitPrefix: true }) : value;
|
|
1424
1406
|
}),
|
|
1425
1407
|
dependencyGroup: z.enum(DependencyGroup)
|
|
1426
1408
|
})) }).partial() }).partial();
|
|
@@ -1459,29 +1441,6 @@ async function loadAlexCLinePrivateConfig(filePath) {
|
|
|
1459
1441
|
//#region src/utility/constants/experimentalHeader.ts
|
|
1460
1442
|
const experimentalHeader = "[EXPERIMENTAL]: This feature is experimental and may change across patch versions. Feel free to try it out and provide feedback, but do not rely on it in production code yet.";
|
|
1461
1443
|
|
|
1462
|
-
//#endregion
|
|
1463
|
-
//#region src/utility/miscellaneous/parseJSONFromStdout.ts
|
|
1464
|
-
function parseJsonFromStdout(stdout) {
|
|
1465
|
-
const start = Math.min(...["[", "{"].map((character) => {
|
|
1466
|
-
return stdout.indexOf(character);
|
|
1467
|
-
}).filter((index) => {
|
|
1468
|
-
return index !== -1;
|
|
1469
|
-
}));
|
|
1470
|
-
if (!Number.isFinite(start)) throw new DataError({ stdout }, "NO_JSON_FOUND_IN_OUTPUT", "No JSON found in output");
|
|
1471
|
-
return JSON.parse(stdout.slice(start));
|
|
1472
|
-
}
|
|
1473
|
-
|
|
1474
|
-
//#endregion
|
|
1475
|
-
//#region src/utility/fileSystem/getExpectedTgzName.ts
|
|
1476
|
-
async function getExpectedTgzName(packagePath, packageManager) {
|
|
1477
|
-
const { stdout: rawPackedTgzData } = await execa({ cwd: packagePath })`${packageManager} pack --json --dry-run`;
|
|
1478
|
-
const packedTgzData = parseJsonFromStdout(rawPackedTgzData);
|
|
1479
|
-
const parsedPackedTgzData = parseZodSchema(packageManager === "pnpm" ? z.object({ filename: z.string() }) : z.array(z.object({ filename: z.string() })), packedTgzData, new DataError(packedTgzData, "AMBIGUOUS_EXPECTED_FILE_NAME", "Could not figire out the expected filename."));
|
|
1480
|
-
const [normalisedTgzMetadata] = Array.isArray(parsedPackedTgzData) ? parsedPackedTgzData : [parsedPackedTgzData];
|
|
1481
|
-
const { filename: expectedTgzFileName } = normalisedTgzMetadata;
|
|
1482
|
-
return expectedTgzFileName;
|
|
1483
|
-
}
|
|
1484
|
-
|
|
1485
1444
|
//#endregion
|
|
1486
1445
|
//#region src/utility/fileSystem/findTgzFile.ts
|
|
1487
1446
|
async function findTgzFile(packagePath, packageManager) {
|
|
@@ -1504,15 +1463,6 @@ async function findTgzFile(packagePath, packageManager) {
|
|
|
1504
1463
|
return expectedTgzFileName;
|
|
1505
1464
|
}
|
|
1506
1465
|
|
|
1507
|
-
//#endregion
|
|
1508
|
-
//#region src/utility/fileSystem/getDependenciesFromPackageInfo.ts
|
|
1509
|
-
function getDependenciesFromGroup(packageInfo, dependencyGroup) {
|
|
1510
|
-
return {
|
|
1511
|
-
dependencies: parseZodSchema(z.record(z.string(), z.string()), packageInfo.dependencies ?? {}),
|
|
1512
|
-
devDependencies: parseZodSchema(z.record(z.string(), z.string()), packageInfo.devDependencies ?? {})
|
|
1513
|
-
}[dependencyGroup];
|
|
1514
|
-
}
|
|
1515
|
-
|
|
1516
1466
|
//#endregion
|
|
1517
1467
|
//#region src/utility/miscellaneous/removeAllTarballs.ts
|
|
1518
1468
|
async function removeAllTarballs(packagePath, packageName) {
|
|
@@ -1670,7 +1620,7 @@ function incrementVersion(program) {
|
|
|
1670
1620
|
- "minor": Change the minor version v1.2.3 → v1.3.0
|
|
1671
1621
|
- "patch": Change the patch version v1.2.3 → v1.2.4
|
|
1672
1622
|
`, parseVersionType).option("--no-prefix").option("--prefix", "Whether to add the `v` prefix from the output version or not (defaults to true).").action((version, incrementType, { prefix }) => {
|
|
1673
|
-
console.info(version.increment(incrementType).
|
|
1623
|
+
console.info(version.increment(incrementType).format({ omitPrefix: !prefix }));
|
|
1674
1624
|
});
|
|
1675
1625
|
}
|
|
1676
1626
|
|
|
@@ -1741,12 +1691,12 @@ function formatError(error) {
|
|
|
1741
1691
|
try {
|
|
1742
1692
|
const program = new Command();
|
|
1743
1693
|
program.name(name).description(description).version(version);
|
|
1744
|
-
updateNotifier({ pkg: package_default }).notify({ message: `
|
|
1745
|
-
${await createAlexCLineArtwork({ includeColors: Boolean(supportsColor.stdout) })}
|
|
1746
|
-
A new update of \`alex-c-line\` is available!
|
|
1747
|
-
|
|
1748
|
-
Run \`{updateCommand}\` to update.
|
|
1749
|
-
` });
|
|
1694
|
+
if (!(process.env.NODE_ENV === "test" || parseBoolean(process.env.RUN_END_TO_END ?? "false") || parseBoolean(process.env.CI ?? "false"))) updateNotifier({ pkg: package_default }).notify({ message: `
|
|
1695
|
+
${await createAlexCLineArtwork({ includeColors: Boolean(supportsColor.stdout) })}
|
|
1696
|
+
A new update of \`alex-c-line\` is available!
|
|
1697
|
+
{currentVersion} → {latestVersion}
|
|
1698
|
+
Run \`{updateCommand}\` to update.
|
|
1699
|
+
` });
|
|
1750
1700
|
createCommands(program);
|
|
1751
1701
|
await program.parseAsync(process.argv);
|
|
1752
1702
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alex-c-line",
|
|
3
|
-
"version": "1.28.
|
|
3
|
+
"version": "1.28.1",
|
|
4
4
|
"description": "Command-line tool with commands to streamline the developer workflow.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/alextheman231/alex-c-line.git"
|
|
8
8
|
},
|
|
9
|
+
"sideEffects": [
|
|
10
|
+
"./dist/index.js"
|
|
11
|
+
],
|
|
9
12
|
"license": "MIT",
|
|
10
13
|
"author": "alextheman",
|
|
11
14
|
"type": "module",
|
|
@@ -23,19 +26,16 @@
|
|
|
23
26
|
"default": "./dist/configs/internal/index.js"
|
|
24
27
|
}
|
|
25
28
|
},
|
|
26
|
-
"main": "dist/index.js",
|
|
27
|
-
"module": "dist/index.cjs",
|
|
28
|
-
"types": "dist/index.d.ts",
|
|
29
29
|
"bin": {
|
|
30
|
-
"alex-c-line": "dist/index.js"
|
|
30
|
+
"alex-c-line": "./dist/index.js"
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
33
33
|
"dist",
|
|
34
34
|
"templates"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@alextheman/utility": "^
|
|
38
|
-
"@inquirer/prompts": "^8.2.
|
|
37
|
+
"@alextheman/utility": "^5.1.4",
|
|
38
|
+
"@inquirer/prompts": "^8.2.1",
|
|
39
39
|
"boxen": "^8.0.1",
|
|
40
40
|
"canvas": "^3.2.1",
|
|
41
41
|
"chalk": "^5.6.2",
|
|
@@ -51,19 +51,20 @@
|
|
|
51
51
|
"zod": "^4.3.6"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@alextheman/eslint-plugin": "^5.
|
|
54
|
+
"@alextheman/eslint-plugin": "^5.8.1",
|
|
55
55
|
"@commander-js/extra-typings": "^14.0.0",
|
|
56
56
|
"@types/eslint": "^9.6.1",
|
|
57
|
-
"@types/node": "^25.
|
|
57
|
+
"@types/node": "^25.3.0",
|
|
58
58
|
"@types/update-notifier": "^6.0.8",
|
|
59
59
|
"dotenv-cli": "^11.0.0",
|
|
60
|
-
"eslint": "^10.0.
|
|
60
|
+
"eslint": "^10.0.1",
|
|
61
61
|
"husky": "^9.1.7",
|
|
62
62
|
"prettier": "^3.8.1",
|
|
63
63
|
"tempy": "^3.2.0",
|
|
64
64
|
"ts-node": "^10.9.2",
|
|
65
65
|
"tsdown": "^0.20.3",
|
|
66
66
|
"typescript": "^5.9.3",
|
|
67
|
+
"typescript-eslint": "^8.56.0",
|
|
67
68
|
"vite-tsconfig-paths": "^6.1.1",
|
|
68
69
|
"vitest": "^4.0.18"
|
|
69
70
|
},
|
|
@@ -94,6 +95,7 @@
|
|
|
94
95
|
"prepare-local-eslint-plugin": "dotenv -e .env -- sh -c 'ESLINT_PLUGIN_PATH=${LOCAL_ESLINT_PLUGIN_PATH:-../eslint-plugin}; pnpm --prefix \"$ESLINT_PLUGIN_PATH\" run build && pnpm uninstall @alextheman/eslint-plugin && pnpm install --save-dev file:\"$ESLINT_PLUGIN_PATH\"'",
|
|
95
96
|
"prepare-local-utility": "dotenv -e .env -- sh -c 'UTILITY_PATH=${LOCAL_UTILITY_PATH:-../utility}; pnpm --prefix \"$UTILITY_PATH\" run build && pnpm uninstall @alextheman/utility && pnpm install file:\"$UTILITY_PATH\"'",
|
|
96
97
|
"test": "vitest run",
|
|
98
|
+
"test-end-to-end": "RUN_END_TO_END=true vitest run tests/end-to-end --reporter verbose",
|
|
97
99
|
"test-watch": "vitest",
|
|
98
100
|
"update-dependencies": "pnpm update --latest && pnpm update",
|
|
99
101
|
"use-live-eslint-plugin": "pnpm run prepare-live-eslint-plugin && pnpm run lint",
|