alex-c-line 1.17.3 → 1.18.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.
@@ -29,6 +29,25 @@ let _alextheman_utility = require("@alextheman/utility");
29
29
  let zod = require("zod");
30
30
  zod = __toESM(zod);
31
31
 
32
+ //#region src/configs/helpers/defineCreatePullRequestTemplateConfig.ts
33
+ const createPullRequestTemplateBaseSchema = zod.default.object({ projectName: zod.default.string().optional() });
34
+ const createPullRequestTemplateSchema = zod.default.discriminatedUnion("category", [createPullRequestTemplateBaseSchema.extend({
35
+ category: zod.default.literal("general"),
36
+ projectType: zod.default.string()
37
+ }), createPullRequestTemplateBaseSchema.extend({
38
+ category: zod.default.literal("infrastructure"),
39
+ infrastructureProvider: zod.default.string(),
40
+ requireConfirmationFrom: zod.default.string()
41
+ })]);
42
+ function parseCreatePullRequestTemplateConfig(input) {
43
+ return (0, _alextheman_utility.parseZodSchema)(createPullRequestTemplateSchema, input, new _alextheman_utility.DataError(input, "INVALID_PRE_COMMIT_CONFIG", "The config provided does not match the expected shape."));
44
+ }
45
+ function defineCreatePullRequestTemplateConfig(config) {
46
+ return parseCreatePullRequestTemplateConfig(config);
47
+ }
48
+ var defineCreatePullRequestTemplateConfig_default = defineCreatePullRequestTemplateConfig;
49
+
50
+ //#endregion
32
51
  //#region src/configs/types/PreCommitConfig.ts
33
52
  const PackageManager = {
34
53
  NPM: "npm",
@@ -50,7 +69,10 @@ var definePreCommitConfig_default = definePreCommitConfig;
50
69
 
51
70
  //#endregion
52
71
  //#region src/configs/helpers/defineAlexCLineConfig.ts
53
- const alexCLineConfigSchema = zod.default.object({ preCommit: preCommitConfigSchema });
72
+ const alexCLineConfigSchema = zod.default.object({
73
+ preCommit: preCommitConfigSchema,
74
+ createPullRequestTemplate: createPullRequestTemplateSchema
75
+ }).partial();
54
76
  function defineAlexCLineConfig(config) {
55
77
  return (0, _alextheman_utility.parseZodSchema)(alexCLineConfigSchema, config, new _alextheman_utility.DataError(config, "INVALID_ALEX_C_LINE_CONFIG", "The config provided does not match the expected shape."));
56
78
  }
@@ -73,8 +95,18 @@ const ConfigFileName = {
73
95
  };
74
96
  var ConfigFileName_default = ConfigFileName;
75
97
 
98
+ //#endregion
99
+ //#region src/configs/types/PullRequestTemplateCategory.ts
100
+ const PullRequestTemplateCategory = {
101
+ GENERAL: "general",
102
+ INFRASTRUCTURE: "infrastructure"
103
+ };
104
+ var PullRequestTemplateCategory_default = PullRequestTemplateCategory;
105
+
76
106
  //#endregion
77
107
  exports.ConfigFileName = ConfigFileName_default;
108
+ exports.PullRequestTemplateCategory = PullRequestTemplateCategory_default;
78
109
  exports.defineAlexCLineConfig = defineAlexCLineConfig_default;
110
+ exports.defineCreatePullRequestTemplateConfig = defineCreatePullRequestTemplateConfig_default;
79
111
  exports.definePreCommitConfig = definePreCommitConfig_default;
80
112
  exports.definePreCommitPrivateConfig = definePreCommitPrivateConfig_default;
@@ -1,5 +1,26 @@
1
1
  import { CreateEnumType } from "@alextheman/utility";
2
2
 
3
+ //#region src/configs/types/CreatePullRequestTemplateConfig.d.ts
4
+ interface CreatePullRequestTemplateBaseConfig {
5
+ /** The name of the project. */
6
+ projectName?: string;
7
+ }
8
+ interface CreatePullRequestTemplateGeneralConfig extends CreatePullRequestTemplateBaseConfig {
9
+ /** The category of pull requests to get. */
10
+ category: "general";
11
+ /** The type of the project (this is what will be used as the noun in the pull request templates themselves). */
12
+ projectType: string;
13
+ }
14
+ interface CreatePullRequestTemplateInfrastructureConfig extends CreatePullRequestTemplateBaseConfig {
15
+ /** The category of pull requests to get. */
16
+ category: "infrastructure";
17
+ /** The provider of the infrastructure */
18
+ infrastructureProvider: string;
19
+ /** Who to get confirmation from in the case of a manual change needed. */
20
+ requireConfirmationFrom: string;
21
+ }
22
+ type CreatePullRequestTemplateConfig = CreatePullRequestTemplateGeneralConfig | CreatePullRequestTemplateInfrastructureConfig;
23
+ //#endregion
3
24
  //#region src/configs/types/PreCommitConfig.d.ts
4
25
  declare const PackageManager: {
5
26
  readonly NPM: "npm";
@@ -21,12 +42,31 @@ interface PreCommitConfig<ScriptName extends string = string> {
21
42
  //#endregion
22
43
  //#region src/configs/types/AlexCLineConfig.d.ts
23
44
  interface AlexCLineConfig<ScriptName extends string = string> {
24
- preCommit: PreCommitConfig<ScriptName>;
45
+ createPullRequestTemplate?: CreatePullRequestTemplateConfig;
46
+ preCommit?: PreCommitConfig<ScriptName>;
25
47
  }
26
48
  //#endregion
27
49
  //#region src/configs/helpers/defineAlexCLineConfig.d.ts
28
50
  declare function defineAlexCLineConfig<ScriptName extends string = string>(config: AlexCLineConfig<ScriptName>): AlexCLineConfig;
29
51
  //#endregion
52
+ //#region src/configs/types/ConfigFileName.d.ts
53
+ declare const ConfigFileName: {
54
+ readonly STANDARD_JAVASCRIPT: "alex-c-line.config.js";
55
+ readonly ES_MODULES_JAVASCRIPT: "alex-c-line.config.mjs";
56
+ readonly COMMON_JS_JAVASCRIPT: "alex-c-line.config.cjs";
57
+ };
58
+ type ConfigFileName = CreateEnumType<typeof ConfigFileName>;
59
+ //#endregion
60
+ //#region src/configs/types/PullRequestTemplateCategory.d.ts
61
+ declare const PullRequestTemplateCategory: {
62
+ readonly GENERAL: "general";
63
+ readonly INFRASTRUCTURE: "infrastructure";
64
+ };
65
+ type PullRequestTemplateCategory = CreateEnumType<typeof PullRequestTemplateCategory>;
66
+ //#endregion
67
+ //#region src/configs/helpers/defineCreatePullRequestTemplateConfig.d.ts
68
+ declare function defineCreatePullRequestTemplateConfig(config: CreatePullRequestTemplateConfig): CreatePullRequestTemplateConfig;
69
+ //#endregion
30
70
  //#region src/configs/helpers/definePreCommitConfig.d.ts
31
71
  declare function definePreCommitConfig<ScriptName extends string = string>(config: PreCommitConfig<ScriptName>): PreCommitConfig;
32
72
  //#endregion
@@ -39,12 +79,4 @@ interface PreCommitPrivateConfig<ScriptName extends string = string> {
39
79
  //#region src/configs/helpers/definePreCommitPrivateConfig.d.ts
40
80
  declare function definePreCommitPrivateConfig<ScriptName extends string = string>(config: PreCommitPrivateConfig<ScriptName>): PreCommitPrivateConfig;
41
81
  //#endregion
42
- //#region src/configs/types/ConfigFileName.d.ts
43
- declare const ConfigFileName: {
44
- readonly STANDARD_JAVASCRIPT: "alex-c-line.config.js";
45
- readonly ES_MODULES_JAVASCRIPT: "alex-c-line.config.mjs";
46
- readonly COMMON_JS_JAVASCRIPT: "alex-c-line.config.cjs";
47
- };
48
- type ConfigFileName = CreateEnumType<typeof ConfigFileName>;
49
- //#endregion
50
- export { AlexCLineConfig, ConfigFileName, PackageManager, PreCommitConfig, PreCommitStepOptions, defineAlexCLineConfig, definePreCommitConfig, definePreCommitPrivateConfig };
82
+ export { AlexCLineConfig, ConfigFileName, CreatePullRequestTemplateBaseConfig, CreatePullRequestTemplateConfig, CreatePullRequestTemplateGeneralConfig, CreatePullRequestTemplateInfrastructureConfig, PackageManager, PreCommitConfig, PreCommitStepOptions, PullRequestTemplateCategory, defineAlexCLineConfig, defineCreatePullRequestTemplateConfig, definePreCommitConfig, definePreCommitPrivateConfig };
@@ -1,6 +1,27 @@
1
1
  import { CreateEnumType } from "@alextheman/utility";
2
2
  import z from "zod";
3
3
 
4
+ //#region src/configs/types/CreatePullRequestTemplateConfig.d.ts
5
+ interface CreatePullRequestTemplateBaseConfig {
6
+ /** The name of the project. */
7
+ projectName?: string;
8
+ }
9
+ interface CreatePullRequestTemplateGeneralConfig extends CreatePullRequestTemplateBaseConfig {
10
+ /** The category of pull requests to get. */
11
+ category: "general";
12
+ /** The type of the project (this is what will be used as the noun in the pull request templates themselves). */
13
+ projectType: string;
14
+ }
15
+ interface CreatePullRequestTemplateInfrastructureConfig extends CreatePullRequestTemplateBaseConfig {
16
+ /** The category of pull requests to get. */
17
+ category: "infrastructure";
18
+ /** The provider of the infrastructure */
19
+ infrastructureProvider: string;
20
+ /** Who to get confirmation from in the case of a manual change needed. */
21
+ requireConfirmationFrom: string;
22
+ }
23
+ type CreatePullRequestTemplateConfig = CreatePullRequestTemplateGeneralConfig | CreatePullRequestTemplateInfrastructureConfig;
24
+ //#endregion
4
25
  //#region src/configs/types/PreCommitConfig.d.ts
5
26
  declare const PackageManager: {
6
27
  readonly NPM: "npm";
@@ -22,12 +43,31 @@ interface PreCommitConfig<ScriptName extends string = string> {
22
43
  //#endregion
23
44
  //#region src/configs/types/AlexCLineConfig.d.ts
24
45
  interface AlexCLineConfig<ScriptName extends string = string> {
25
- preCommit: PreCommitConfig<ScriptName>;
46
+ createPullRequestTemplate?: CreatePullRequestTemplateConfig;
47
+ preCommit?: PreCommitConfig<ScriptName>;
26
48
  }
27
49
  //#endregion
28
50
  //#region src/configs/helpers/defineAlexCLineConfig.d.ts
29
51
  declare function defineAlexCLineConfig<ScriptName extends string = string>(config: AlexCLineConfig<ScriptName>): AlexCLineConfig;
30
52
  //#endregion
53
+ //#region src/configs/types/ConfigFileName.d.ts
54
+ declare const ConfigFileName: {
55
+ readonly STANDARD_JAVASCRIPT: "alex-c-line.config.js";
56
+ readonly ES_MODULES_JAVASCRIPT: "alex-c-line.config.mjs";
57
+ readonly COMMON_JS_JAVASCRIPT: "alex-c-line.config.cjs";
58
+ };
59
+ type ConfigFileName = CreateEnumType<typeof ConfigFileName>;
60
+ //#endregion
61
+ //#region src/configs/types/PullRequestTemplateCategory.d.ts
62
+ declare const PullRequestTemplateCategory: {
63
+ readonly GENERAL: "general";
64
+ readonly INFRASTRUCTURE: "infrastructure";
65
+ };
66
+ type PullRequestTemplateCategory = CreateEnumType<typeof PullRequestTemplateCategory>;
67
+ //#endregion
68
+ //#region src/configs/helpers/defineCreatePullRequestTemplateConfig.d.ts
69
+ declare function defineCreatePullRequestTemplateConfig(config: CreatePullRequestTemplateConfig): CreatePullRequestTemplateConfig;
70
+ //#endregion
31
71
  //#region src/configs/helpers/definePreCommitConfig.d.ts
32
72
  declare function definePreCommitConfig<ScriptName extends string = string>(config: PreCommitConfig<ScriptName>): PreCommitConfig;
33
73
  //#endregion
@@ -40,12 +80,4 @@ interface PreCommitPrivateConfig<ScriptName extends string = string> {
40
80
  //#region src/configs/helpers/definePreCommitPrivateConfig.d.ts
41
81
  declare function definePreCommitPrivateConfig<ScriptName extends string = string>(config: PreCommitPrivateConfig<ScriptName>): PreCommitPrivateConfig;
42
82
  //#endregion
43
- //#region src/configs/types/ConfigFileName.d.ts
44
- declare const ConfigFileName: {
45
- readonly STANDARD_JAVASCRIPT: "alex-c-line.config.js";
46
- readonly ES_MODULES_JAVASCRIPT: "alex-c-line.config.mjs";
47
- readonly COMMON_JS_JAVASCRIPT: "alex-c-line.config.cjs";
48
- };
49
- type ConfigFileName = CreateEnumType<typeof ConfigFileName>;
50
- //#endregion
51
- export { AlexCLineConfig, ConfigFileName, PackageManager, PreCommitConfig, PreCommitStepOptions, defineAlexCLineConfig, definePreCommitConfig, definePreCommitPrivateConfig };
83
+ export { AlexCLineConfig, ConfigFileName, CreatePullRequestTemplateBaseConfig, CreatePullRequestTemplateConfig, CreatePullRequestTemplateGeneralConfig, CreatePullRequestTemplateInfrastructureConfig, PackageManager, PreCommitConfig, PreCommitStepOptions, PullRequestTemplateCategory, defineAlexCLineConfig, defineCreatePullRequestTemplateConfig, definePreCommitConfig, definePreCommitPrivateConfig };
@@ -1,6 +1,25 @@
1
1
  import { DataError, parseZodSchema } from "@alextheman/utility";
2
2
  import z from "zod";
3
3
 
4
+ //#region src/configs/helpers/defineCreatePullRequestTemplateConfig.ts
5
+ const createPullRequestTemplateBaseSchema = z.object({ projectName: z.string().optional() });
6
+ const createPullRequestTemplateSchema = z.discriminatedUnion("category", [createPullRequestTemplateBaseSchema.extend({
7
+ category: z.literal("general"),
8
+ projectType: z.string()
9
+ }), createPullRequestTemplateBaseSchema.extend({
10
+ category: z.literal("infrastructure"),
11
+ infrastructureProvider: z.string(),
12
+ requireConfirmationFrom: z.string()
13
+ })]);
14
+ function parseCreatePullRequestTemplateConfig(input) {
15
+ return parseZodSchema(createPullRequestTemplateSchema, input, new DataError(input, "INVALID_PRE_COMMIT_CONFIG", "The config provided does not match the expected shape."));
16
+ }
17
+ function defineCreatePullRequestTemplateConfig(config) {
18
+ return parseCreatePullRequestTemplateConfig(config);
19
+ }
20
+ var defineCreatePullRequestTemplateConfig_default = defineCreatePullRequestTemplateConfig;
21
+
22
+ //#endregion
4
23
  //#region src/configs/types/PreCommitConfig.ts
5
24
  const PackageManager = {
6
25
  NPM: "npm",
@@ -22,7 +41,10 @@ var definePreCommitConfig_default = definePreCommitConfig;
22
41
 
23
42
  //#endregion
24
43
  //#region src/configs/helpers/defineAlexCLineConfig.ts
25
- const alexCLineConfigSchema = z.object({ preCommit: preCommitConfigSchema });
44
+ const alexCLineConfigSchema = z.object({
45
+ preCommit: preCommitConfigSchema,
46
+ createPullRequestTemplate: createPullRequestTemplateSchema
47
+ }).partial();
26
48
  function defineAlexCLineConfig(config) {
27
49
  return parseZodSchema(alexCLineConfigSchema, config, new DataError(config, "INVALID_ALEX_C_LINE_CONFIG", "The config provided does not match the expected shape."));
28
50
  }
@@ -46,4 +68,12 @@ const ConfigFileName = {
46
68
  var ConfigFileName_default = ConfigFileName;
47
69
 
48
70
  //#endregion
49
- export { ConfigFileName_default as ConfigFileName, defineAlexCLineConfig_default as defineAlexCLineConfig, definePreCommitConfig_default as definePreCommitConfig, definePreCommitPrivateConfig_default as definePreCommitPrivateConfig };
71
+ //#region src/configs/types/PullRequestTemplateCategory.ts
72
+ const PullRequestTemplateCategory = {
73
+ GENERAL: "general",
74
+ INFRASTRUCTURE: "infrastructure"
75
+ };
76
+ var PullRequestTemplateCategory_default = PullRequestTemplateCategory;
77
+
78
+ //#endregion
79
+ export { ConfigFileName_default as ConfigFileName, PullRequestTemplateCategory_default as PullRequestTemplateCategory, defineAlexCLineConfig_default as defineAlexCLineConfig, defineCreatePullRequestTemplateConfig_default as defineCreatePullRequestTemplateConfig, definePreCommitConfig_default as definePreCommitConfig, definePreCommitPrivateConfig_default as definePreCommitPrivateConfig };
@@ -1,13 +1,19 @@
1
1
 
2
2
  //#region src/configs/internal/alexCLineConfig.ts
3
- const alexCLineConfig = { preCommit: {
4
- packageManager: "pnpm",
5
- steps: [
6
- "format",
7
- "lint",
8
- "test"
9
- ]
10
- } };
3
+ const alexCLineConfig = {
4
+ preCommit: {
5
+ packageManager: "pnpm",
6
+ steps: [
7
+ "format",
8
+ "lint",
9
+ "test"
10
+ ]
11
+ },
12
+ createPullRequestTemplate: {
13
+ category: "general",
14
+ projectType: "package"
15
+ }
16
+ };
11
17
  var alexCLineConfig_default = alexCLineConfig;
12
18
 
13
19
  //#endregion
@@ -1,5 +1,26 @@
1
1
  import { CreateEnumType } from "@alextheman/utility";
2
2
 
3
+ //#region src/configs/types/CreatePullRequestTemplateConfig.d.ts
4
+ interface CreatePullRequestTemplateBaseConfig {
5
+ /** The name of the project. */
6
+ projectName?: string;
7
+ }
8
+ interface CreatePullRequestTemplateGeneralConfig extends CreatePullRequestTemplateBaseConfig {
9
+ /** The category of pull requests to get. */
10
+ category: "general";
11
+ /** The type of the project (this is what will be used as the noun in the pull request templates themselves). */
12
+ projectType: string;
13
+ }
14
+ interface CreatePullRequestTemplateInfrastructureConfig extends CreatePullRequestTemplateBaseConfig {
15
+ /** The category of pull requests to get. */
16
+ category: "infrastructure";
17
+ /** The provider of the infrastructure */
18
+ infrastructureProvider: string;
19
+ /** Who to get confirmation from in the case of a manual change needed. */
20
+ requireConfirmationFrom: string;
21
+ }
22
+ type CreatePullRequestTemplateConfig = CreatePullRequestTemplateGeneralConfig | CreatePullRequestTemplateInfrastructureConfig;
23
+ //#endregion
3
24
  //#region src/configs/types/PreCommitConfig.d.ts
4
25
  declare const PackageManager: {
5
26
  readonly NPM: "npm";
@@ -21,7 +42,8 @@ interface PreCommitConfig<ScriptName extends string = string> {
21
42
  //#endregion
22
43
  //#region src/configs/types/AlexCLineConfig.d.ts
23
44
  interface AlexCLineConfig<ScriptName extends string = string> {
24
- preCommit: PreCommitConfig<ScriptName>;
45
+ createPullRequestTemplate?: CreatePullRequestTemplateConfig;
46
+ preCommit?: PreCommitConfig<ScriptName>;
25
47
  }
26
48
  //#endregion
27
49
  //#region package.d.ts
@@ -1,5 +1,26 @@
1
1
  import { CreateEnumType } from "@alextheman/utility";
2
2
 
3
+ //#region src/configs/types/CreatePullRequestTemplateConfig.d.ts
4
+ interface CreatePullRequestTemplateBaseConfig {
5
+ /** The name of the project. */
6
+ projectName?: string;
7
+ }
8
+ interface CreatePullRequestTemplateGeneralConfig extends CreatePullRequestTemplateBaseConfig {
9
+ /** The category of pull requests to get. */
10
+ category: "general";
11
+ /** The type of the project (this is what will be used as the noun in the pull request templates themselves). */
12
+ projectType: string;
13
+ }
14
+ interface CreatePullRequestTemplateInfrastructureConfig extends CreatePullRequestTemplateBaseConfig {
15
+ /** The category of pull requests to get. */
16
+ category: "infrastructure";
17
+ /** The provider of the infrastructure */
18
+ infrastructureProvider: string;
19
+ /** Who to get confirmation from in the case of a manual change needed. */
20
+ requireConfirmationFrom: string;
21
+ }
22
+ type CreatePullRequestTemplateConfig = CreatePullRequestTemplateGeneralConfig | CreatePullRequestTemplateInfrastructureConfig;
23
+ //#endregion
3
24
  //#region src/configs/types/PreCommitConfig.d.ts
4
25
  declare const PackageManager: {
5
26
  readonly NPM: "npm";
@@ -21,7 +42,8 @@ interface PreCommitConfig<ScriptName extends string = string> {
21
42
  //#endregion
22
43
  //#region src/configs/types/AlexCLineConfig.d.ts
23
44
  interface AlexCLineConfig<ScriptName extends string = string> {
24
- preCommit: PreCommitConfig<ScriptName>;
45
+ createPullRequestTemplate?: CreatePullRequestTemplateConfig;
46
+ preCommit?: PreCommitConfig<ScriptName>;
25
47
  }
26
48
  //#endregion
27
49
  //#region package.d.ts
@@ -1,12 +1,18 @@
1
1
  //#region src/configs/internal/alexCLineConfig.ts
2
- const alexCLineConfig = { preCommit: {
3
- packageManager: "pnpm",
4
- steps: [
5
- "format",
6
- "lint",
7
- "test"
8
- ]
9
- } };
2
+ const alexCLineConfig = {
3
+ preCommit: {
4
+ packageManager: "pnpm",
5
+ steps: [
6
+ "format",
7
+ "lint",
8
+ "test"
9
+ ]
10
+ },
11
+ createPullRequestTemplate: {
12
+ category: "general",
13
+ projectType: "package"
14
+ }
15
+ };
10
16
  var alexCLineConfig_default = alexCLineConfig;
11
17
 
12
18
  //#endregion
package/dist/index.cjs CHANGED
@@ -35,16 +35,18 @@ node_path = __toESM(node_path);
35
35
  let node_fs = require("node:fs");
36
36
  let _alextheman_utility = require("@alextheman/utility");
37
37
  let execa = require("execa");
38
+ let zod = require("zod");
39
+ zod = __toESM(zod);
40
+ let node_module = require("node:module");
41
+ let node_url = require("node:url");
42
+ let gray_matter = require("gray-matter");
43
+ gray_matter = __toESM(gray_matter);
38
44
  let dotenv = require("dotenv");
39
45
  dotenv = __toESM(dotenv);
40
46
  let dotenv_stringify = require("dotenv-stringify");
41
47
  dotenv_stringify = __toESM(dotenv_stringify);
42
48
  let node_os = require("node:os");
43
49
  node_os = __toESM(node_os);
44
- let zod = require("zod");
45
- zod = __toESM(zod);
46
- let node_module = require("node:module");
47
- let node_url = require("node:url");
48
50
 
49
51
  //#region src/commands/check-for-file-dependencies.ts
50
52
  function findFileDependencies(dependencies$1) {
@@ -147,6 +149,205 @@ function checkVersionNumberChange(program) {
147
149
  }
148
150
  var check_version_number_change_default = checkVersionNumberChange;
149
151
 
152
+ //#endregion
153
+ //#region src/configs/helpers/defineCreatePullRequestTemplateConfig.ts
154
+ const createPullRequestTemplateBaseSchema = zod.default.object({ projectName: zod.default.string().optional() });
155
+ const createPullRequestTemplateSchema = zod.default.discriminatedUnion("category", [createPullRequestTemplateBaseSchema.extend({
156
+ category: zod.default.literal("general"),
157
+ projectType: zod.default.string()
158
+ }), createPullRequestTemplateBaseSchema.extend({
159
+ category: zod.default.literal("infrastructure"),
160
+ infrastructureProvider: zod.default.string(),
161
+ requireConfirmationFrom: zod.default.string()
162
+ })]);
163
+ function parseCreatePullRequestTemplateConfig(input) {
164
+ return (0, _alextheman_utility.parseZodSchema)(createPullRequestTemplateSchema, input, new _alextheman_utility.DataError(input, "INVALID_PRE_COMMIT_CONFIG", "The config provided does not match the expected shape."));
165
+ }
166
+
167
+ //#endregion
168
+ //#region src/configs/types/PreCommitConfig.ts
169
+ const PackageManager = {
170
+ NPM: "npm",
171
+ PNPM: "pnpm"
172
+ };
173
+
174
+ //#endregion
175
+ //#region src/configs/helpers/definePreCommitConfig.ts
176
+ const preCommitStepOptionsSchema = zod.default.object({ arguments: zod.default.array(zod.default.string()).optional() });
177
+ const preCommitConfigSchema = zod.default.object({
178
+ packageManager: zod.default.enum(PackageManager).optional(),
179
+ allowNoStagedChanges: zod.default.boolean().optional(),
180
+ steps: zod.default.union([zod.default.array(zod.default.string()), zod.default.array(zod.default.tuple([zod.default.string(), preCommitStepOptionsSchema]))])
181
+ });
182
+
183
+ //#endregion
184
+ //#region src/configs/helpers/defineAlexCLineConfig.ts
185
+ const alexCLineConfigSchema = zod.default.object({
186
+ preCommit: preCommitConfigSchema,
187
+ createPullRequestTemplate: createPullRequestTemplateSchema
188
+ }).partial();
189
+ function defineAlexCLineConfig(config) {
190
+ return (0, _alextheman_utility.parseZodSchema)(alexCLineConfigSchema, config, new _alextheman_utility.DataError(config, "INVALID_ALEX_C_LINE_CONFIG", "The config provided does not match the expected shape."));
191
+ }
192
+ var defineAlexCLineConfig_default = defineAlexCLineConfig;
193
+
194
+ //#endregion
195
+ //#region src/configs/helpers/definePreCommitPrivateConfig.ts
196
+ const preCommitPrivateConfigSchema = zod.default.object({ disableSteps: zod.default.array(zod.default.string()).optional() });
197
+
198
+ //#endregion
199
+ //#region src/configs/types/ConfigFileName.ts
200
+ const ConfigFileName = {
201
+ STANDARD_JAVASCRIPT: "alex-c-line.config.js",
202
+ ES_MODULES_JAVASCRIPT: "alex-c-line.config.mjs",
203
+ COMMON_JS_JAVASCRIPT: "alex-c-line.config.cjs"
204
+ };
205
+ var ConfigFileName_default = ConfigFileName;
206
+
207
+ //#endregion
208
+ //#region src/configs/types/PullRequestTemplateCategory.ts
209
+ const PullRequestTemplateCategory = {
210
+ GENERAL: "general",
211
+ INFRASTRUCTURE: "infrastructure"
212
+ };
213
+ var PullRequestTemplateCategory_default = PullRequestTemplateCategory;
214
+
215
+ //#endregion
216
+ //#region src/utility/configLoaders/loadAlexCLineConfig.ts
217
+ const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
218
+ async function loadAlexCLineConfig(filePath) {
219
+ if (filePath.endsWith(".cjs")) {
220
+ const module$3 = require$1(filePath);
221
+ return defineAlexCLineConfig_default(module$3.default ?? module$3);
222
+ }
223
+ const module$2 = await import((0, node_url.pathToFileURL)(filePath).href);
224
+ return defineAlexCLineConfig_default(module$2.default ?? module$2);
225
+ }
226
+ var loadAlexCLineConfig_default = loadAlexCLineConfig;
227
+
228
+ //#endregion
229
+ //#region src/utility/doesFileExist.ts
230
+ async function doesFileExist(filePath) {
231
+ try {
232
+ await (0, node_fs_promises.access)(filePath);
233
+ return true;
234
+ } catch (error) {
235
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") return false;
236
+ throw error;
237
+ }
238
+ }
239
+ var doesFileExist_default = doesFileExist;
240
+
241
+ //#endregion
242
+ //#region src/utility/findAlexCLineConfig.ts
243
+ async function findAlexCLineConfig(cwd) {
244
+ const validConfigFileNames = [
245
+ ConfigFileName_default.ES_MODULES_JAVASCRIPT,
246
+ ConfigFileName_default.STANDARD_JAVASCRIPT,
247
+ ConfigFileName_default.COMMON_JS_JAVASCRIPT
248
+ ];
249
+ for (const fileName of validConfigFileNames) {
250
+ const fullPath = node_path.default.join(cwd, fileName);
251
+ if (await doesFileExist_default(fullPath)) return fullPath;
252
+ }
253
+ }
254
+ var findAlexCLineConfig_default = findAlexCLineConfig;
255
+
256
+ //#endregion
257
+ //#region src/utility/findPackageRoot.ts
258
+ async function findPackageRoot(startDirectory, packageName) {
259
+ let directory = startDirectory;
260
+ while (true) {
261
+ const packagePath = node_path.default.join(directory, "package.json");
262
+ try {
263
+ if (JSON.parse(await (0, node_fs_promises.readFile)(packagePath, "utf-8"))?.name === packageName) return directory;
264
+ } catch {}
265
+ const parent = node_path.default.dirname(directory);
266
+ if (parent === directory) break;
267
+ directory = parent;
268
+ }
269
+ throw new _alextheman_utility.DataError(packageName, "PACKAGE_ROOT_NOT_FOUND", `Could not find package root for ${packageName}`);
270
+ }
271
+ var findPackageRoot_default = findPackageRoot;
272
+
273
+ //#endregion
274
+ //#region src/utility/getPullRequestTemplatesFromMarkdown.ts
275
+ const __filename$1 = (0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
276
+ function getTemplateVariables(config) {
277
+ if (config.category === "general") return {
278
+ projectName: config.projectName,
279
+ projectType: config.projectType
280
+ };
281
+ return {
282
+ projectName: config.projectName,
283
+ infrastructureProvider: config.infrastructureProvider,
284
+ requireConfirmationFrom: config.requireConfirmationFrom
285
+ };
286
+ }
287
+ async function getPullRequestTemplatesFromMarkdown(config) {
288
+ const templateVariables = getTemplateVariables(config);
289
+ const { category } = config;
290
+ const templatesPath = node_path.default.join(await findPackageRoot_default(node_path.default.dirname(__filename$1), "alex-c-line"), "templates", "pullRequest");
291
+ 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.");
292
+ const categoryPath = node_path.default.join(templatesPath, category);
293
+ const allCategoryTemplateNames = (await (0, node_fs_promises.readdir)(categoryPath)).filter((name$1) => {
294
+ return name$1.endsWith(".md");
295
+ });
296
+ const allTemplates = {};
297
+ for (const templateFileName of allCategoryTemplateNames) {
298
+ const { content, data } = (0, gray_matter.default)(await (0, node_fs_promises.readFile)(node_path.default.join(categoryPath, templateFileName), "utf-8"));
299
+ const templateName = (0, _alextheman_utility.parseZodSchema)(zod.default.string(), data.id === "base" ? "pull_request_template" : data.id);
300
+ const placeholders = (0, _alextheman_utility.parseZodSchema)(zod.default.array(zod.default.string()).default([]), data.placeholders);
301
+ let finalContent = content;
302
+ for (const placeholder of placeholders) {
303
+ if (!(placeholder in templateVariables)) throw new _alextheman_utility.DataError(placeholder, "INVALID_PLACEHOLDER", "The placeholder found in frontmatter can not be found in the metadata.");
304
+ finalContent = finalContent.replaceAll(`{{${placeholder}}}`, templateVariables[placeholder]);
305
+ }
306
+ allTemplates[templateName] = finalContent.trimStart();
307
+ }
308
+ return allTemplates;
309
+ }
310
+ var getPullRequestTemplatesFromMarkdown_default = getPullRequestTemplatesFromMarkdown;
311
+
312
+ //#endregion
313
+ //#region src/commands/create-pull-request-template-2.ts
314
+ function createPullRequestTemplate(program) {
315
+ program.command("create-pull-request-template").alias("create-pull-request-template-2").option("--category <category>", "The category of pull request templates to get (can be either `general` or `infrastructure`)", (rawValue) => {
316
+ return (0, _alextheman_utility.parseZodSchema)(zod.default.enum(PullRequestTemplateCategory_default), rawValue, () => {
317
+ program.error(`Invalid template category ${rawValue}. The category must be one of \`general\` or \`infrastructure\``);
318
+ });
319
+ }).option("--project-name <projectName>", "The name of the package to use in the templates (leave blank to default to name found in package.json)").option("--project-type <projectType>", "The type of project, used in phrases such as 'adds a new feature to the {{projectType}}'. This option must not be specified if category is `infrastructure`").option("--infrastructure-provider <infrastructureProvider>", "If category is `infrastructure`, this would be the name of the Infrastructure provider (e.g. Terraform)").option("--require-confirmation-from <requireConfirmationFrom>", "If category is `infrastructure`, this would be the name of the user to get approval from if a manual change was required").description("Create pull request template files for a category (currently generates all templates in that category).").action(async (commandLineOptions) => {
320
+ const configPath = await findAlexCLineConfig_default(process.cwd());
321
+ const { createPullRequestTemplate: config } = configPath ? await loadAlexCLineConfig_default(configPath) : {};
322
+ const packageInfo = JSON.parse(await (0, node_fs_promises.readFile)(node_path.default.join(process.cwd(), "package.json"), "utf-8"));
323
+ const { name: projectName } = commandLineOptions.projectName || config?.projectName ? { name: commandLineOptions.projectName ?? config?.projectName } : (0, _alextheman_utility.parseZodSchema)(zod.default.object({ name: zod.default.string() }), packageInfo, () => {
324
+ program.error("Invalid package.json - expected package.json to contain a `name` property.", {
325
+ exitCode: 1,
326
+ code: "INVALID_PACKAGE_JSON"
327
+ });
328
+ });
329
+ if (!projectName) throw new _alextheman_utility.DataError({ projectName }, "PROJECT_NAME_NOT_FOUND", "Could not resolve project name.");
330
+ const parsedOptions = parseCreatePullRequestTemplateConfig({
331
+ category: commandLineOptions.category ?? config?.category ?? "general",
332
+ projectType: commandLineOptions.projectType ?? (config?.category === "general" ? config?.projectType : void 0),
333
+ infrastructureProvider: commandLineOptions.infrastructureProvider ?? (config?.category === "infrastructure" ? config?.infrastructureProvider : void 0),
334
+ requireConfirmationFrom: commandLineOptions.requireConfirmationFrom ?? (config?.category === "infrastructure" ? config.requireConfirmationFrom : void 0)
335
+ });
336
+ const gitHubPath = node_path.default.join(process.cwd(), ".github");
337
+ const pullRequestTemplatePath = node_path.default.join(gitHubPath, "PULL_REQUEST_TEMPLATE");
338
+ const allTemplates = await getPullRequestTemplatesFromMarkdown_default({
339
+ ...parsedOptions,
340
+ projectName
341
+ });
342
+ await (0, node_fs_promises.mkdir)(gitHubPath, { recursive: true });
343
+ await (0, node_fs_promises.mkdir)(pullRequestTemplatePath, { recursive: true });
344
+ for (const templateName of Object.keys(allTemplates)) if (templateName === "pull_request_template") await (0, node_fs_promises.writeFile)(node_path.default.join(gitHubPath, "pull_request_template.md"), allTemplates[templateName]);
345
+ else await (0, node_fs_promises.writeFile)(node_path.default.join(pullRequestTemplatePath, `${templateName}.md`), allTemplates[templateName]);
346
+ console.info("Pull request templates created.");
347
+ });
348
+ }
349
+ var create_pull_request_template_2_default = createPullRequestTemplate;
350
+
150
351
  //#endregion
151
352
  //#region src/utility/basePullRequestTemplate.ts
152
353
  const basePullRequestTemplate = _alextheman_utility.normaliseIndents`
@@ -217,8 +418,12 @@ var getPullRequestTemplates_default = getPullRequestTemplates;
217
418
 
218
419
  //#endregion
219
420
  //#region src/commands/create-pull-request-templates.ts
421
+ const deprecationMessage$1 = "[DEPRECATED]: This command does not support the new markdown-native templates and alex-c-line config system. Please use `pre-commit-2` instead.";
220
422
  function createPullRequestTemplates(program) {
221
- program.command("create-pull-request-templates").description("Create the standard pull request templates as found in my repositories").action(async () => {
423
+ program.command("create-pull-request-templates").description(_alextheman_utility.normaliseIndents`
424
+ ${deprecationMessage$1}
425
+ Create the standard pull request templates as found in my repositories`).action(async () => {
426
+ console.warn(deprecationMessage$1);
222
427
  const { name: name$1 } = JSON.parse(await (0, node_fs_promises.readFile)(node_path.default.join(process.cwd(), "package.json"), "utf-8"));
223
428
  const gitHubPath = node_path.default.join(process.cwd(), ".github");
224
429
  const pullRequestTemplatePath = node_path.default.join(gitHubPath, "PULL_REQUEST_TEMPLATE");
@@ -507,84 +712,6 @@ function preCommit(program) {
507
712
  }
508
713
  var pre_commit_default = preCommit;
509
714
 
510
- //#endregion
511
- //#region src/configs/types/PreCommitConfig.ts
512
- const PackageManager = {
513
- NPM: "npm",
514
- PNPM: "pnpm"
515
- };
516
-
517
- //#endregion
518
- //#region src/configs/helpers/definePreCommitConfig.ts
519
- const preCommitStepOptionsSchema = zod.default.object({ arguments: zod.default.array(zod.default.string()).optional() });
520
- const preCommitConfigSchema = zod.default.object({
521
- packageManager: zod.default.enum(PackageManager).optional(),
522
- allowNoStagedChanges: zod.default.boolean().optional(),
523
- steps: zod.default.union([zod.default.array(zod.default.string()), zod.default.array(zod.default.tuple([zod.default.string(), preCommitStepOptionsSchema]))])
524
- });
525
-
526
- //#endregion
527
- //#region src/configs/helpers/defineAlexCLineConfig.ts
528
- const alexCLineConfigSchema = zod.default.object({ preCommit: preCommitConfigSchema });
529
- function defineAlexCLineConfig(config) {
530
- return (0, _alextheman_utility.parseZodSchema)(alexCLineConfigSchema, config, new _alextheman_utility.DataError(config, "INVALID_ALEX_C_LINE_CONFIG", "The config provided does not match the expected shape."));
531
- }
532
- var defineAlexCLineConfig_default = defineAlexCLineConfig;
533
-
534
- //#endregion
535
- //#region src/configs/helpers/definePreCommitPrivateConfig.ts
536
- const preCommitPrivateConfigSchema = zod.default.object({ disableSteps: zod.default.array(zod.default.string()).optional() });
537
-
538
- //#endregion
539
- //#region src/configs/types/ConfigFileName.ts
540
- const ConfigFileName = {
541
- STANDARD_JAVASCRIPT: "alex-c-line.config.js",
542
- ES_MODULES_JAVASCRIPT: "alex-c-line.config.mjs",
543
- COMMON_JS_JAVASCRIPT: "alex-c-line.config.cjs"
544
- };
545
- var ConfigFileName_default = ConfigFileName;
546
-
547
- //#endregion
548
- //#region src/utility/configLoaders/loadAlexCLineConfig.ts
549
- const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
550
- async function loadAlexCLineConfig(filePath) {
551
- if (filePath.endsWith(".cjs")) {
552
- const module$3 = require$1(filePath);
553
- return defineAlexCLineConfig_default(module$3.default ?? module$3);
554
- }
555
- const module$2 = await import((0, node_url.pathToFileURL)(filePath).href);
556
- return defineAlexCLineConfig_default(module$2.default ?? module$2);
557
- }
558
- var loadAlexCLineConfig_default = loadAlexCLineConfig;
559
-
560
- //#endregion
561
- //#region src/utility/doesFileExist.ts
562
- async function doesFileExist(filePath) {
563
- try {
564
- await (0, node_fs_promises.access)(filePath);
565
- return true;
566
- } catch (error) {
567
- if (error instanceof Error && "code" in error && error.code === "ENOENT") return false;
568
- throw error;
569
- }
570
- }
571
- var doesFileExist_default = doesFileExist;
572
-
573
- //#endregion
574
- //#region src/utility/findAlexCLineConfig.ts
575
- async function findAlexCLineConfig(cwd) {
576
- const validConfigFileNames = [
577
- ConfigFileName_default.ES_MODULES_JAVASCRIPT,
578
- ConfigFileName_default.STANDARD_JAVASCRIPT,
579
- ConfigFileName_default.COMMON_JS_JAVASCRIPT
580
- ];
581
- for (const fileName of validConfigFileNames) {
582
- const fullPath = node_path.default.join(cwd, fileName);
583
- if (await doesFileExist_default(fullPath)) return fullPath;
584
- }
585
- }
586
- var findAlexCLineConfig_default = findAlexCLineConfig;
587
-
588
715
  //#endregion
589
716
  //#region src/commands/pre-commit-2.ts
590
717
  function preCommit2(program) {
@@ -703,6 +830,7 @@ function createCommands(program) {
703
830
  checkForFileDependencies: check_for_file_dependencies_default,
704
831
  checkLockfileVersionDiscrepancy: check_lockfile_version_discrepancy_default,
705
832
  checkVersionNumberChange: check_version_number_change_default,
833
+ createPullRequestTemplate: create_pull_request_template_2_default,
706
834
  createPullRequestTemplates: create_pull_request_templates_default,
707
835
  createReleaseNote: create_release_note_default,
708
836
  editEnv: edit_env_default,
@@ -720,7 +848,7 @@ var commands_default = createCommands;
720
848
 
721
849
  //#endregion
722
850
  //#region package.json
723
- var version = "1.17.3";
851
+ var version = "1.18.1";
724
852
  var package_default = {
725
853
  name: "alex-c-line",
726
854
  version,
@@ -776,8 +904,8 @@ var package_default = {
776
904
  "prepare-live-utility": "pnpm uninstall @alextheman/utility && pnpm install @alextheman/utility",
777
905
  "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\"'",
778
906
  "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\"'",
779
- "test": "pnpm run build && vitest run",
780
- "test-watch": "pnpm run build && vitest",
907
+ "test": "vitest run",
908
+ "test-watch": "vitest",
781
909
  "update-dependencies": "pnpm update --latest && pnpm update",
782
910
  "use-live-eslint-plugin": "pnpm run prepare-live-eslint-plugin && pnpm run lint",
783
911
  "use-live-utility": "pnpm run prepare-live-utility",
@@ -785,11 +913,12 @@ var package_default = {
785
913
  "use-local-utility": "pnpm run prepare-local-utility"
786
914
  },
787
915
  dependencies: {
788
- "@alextheman/utility": "^4.5.1",
916
+ "@alextheman/utility": "^4.7.0",
789
917
  "commander": "^14.0.2",
790
918
  "dotenv": "^17.2.3",
791
919
  "dotenv-stringify": "^3.0.1",
792
920
  "execa": "^9.6.1",
921
+ "gray-matter": "^4.0.3",
793
922
  "libsodium-wrappers": "^0.8.0",
794
923
  "update-notifier": "^7.3.1",
795
924
  "zod": "^4.3.5"
@@ -799,21 +928,22 @@ var package_default = {
799
928
  "@commander-js/extra-typings": "^14.0.0",
800
929
  "@types/eslint": "^9.6.1",
801
930
  "@types/libsodium-wrappers": "^0.7.14",
802
- "@types/node": "^25.0.3",
931
+ "@types/node": "^25.0.9",
803
932
  "@types/update-notifier": "^6.0.8",
804
933
  "dotenv-cli": "^11.0.0",
805
934
  "eslint": "^9.39.2",
806
935
  "eslint-plugin-perfectionist": "^5.3.1",
807
936
  "husky": "^9.1.7",
808
- "prettier": "^3.7.4",
937
+ "prettier": "^3.8.0",
809
938
  "tempy": "^3.1.0",
810
939
  "ts-node": "^10.9.2",
811
940
  "tsdown": "^0.18.4",
812
941
  "typescript": "^5.9.3",
813
942
  "vite-tsconfig-paths": "^6.0.4",
814
- "vitest": "^4.0.16"
943
+ "vitest": "^4.0.17"
815
944
  },
816
945
  packageManager: "pnpm@10.28.0+sha512.05df71d1421f21399e053fde567cea34d446fa02c76571441bfc1c7956e98e363088982d940465fd34480d4d90a0668bc12362f8aa88000a64e83d0b0e47be48",
946
+ engines: { "node": ">=22.0.0" },
817
947
  pnpm: {
818
948
  "onlyBuiltDependencies": ["esbuild", "unrs-resolver"],
819
949
  "overrides": { "tsdown": "<0.19.0" }
package/dist/index.js CHANGED
@@ -2,16 +2,17 @@
2
2
  import { createRequire } from "node:module";
3
3
  import { Command } from "commander";
4
4
  import updateNotifier from "update-notifier";
5
- import { access, mkdir, readFile, writeFile } from "node:fs/promises";
5
+ import { access, mkdir, readFile, readdir, writeFile } from "node:fs/promises";
6
6
  import path from "node:path";
7
7
  import { readFileSync } from "node:fs";
8
8
  import { DataError, VersionNumber, encryptWithKey, kebabToCamel, normaliseIndents, parseVersionType, parseZodSchema } from "@alextheman/utility";
9
9
  import { ExecaError, execa } from "execa";
10
+ import z from "zod";
11
+ import { fileURLToPath, pathToFileURL } from "node:url";
12
+ import matter from "gray-matter";
10
13
  import dotenv from "dotenv";
11
14
  import dotenvStringify from "dotenv-stringify";
12
15
  import os from "node:os";
13
- import z from "zod";
14
- import { pathToFileURL } from "node:url";
15
16
 
16
17
  //#region src/commands/check-for-file-dependencies.ts
17
18
  function findFileDependencies(dependencies$1) {
@@ -114,6 +115,205 @@ function checkVersionNumberChange(program) {
114
115
  }
115
116
  var check_version_number_change_default = checkVersionNumberChange;
116
117
 
118
+ //#endregion
119
+ //#region src/configs/helpers/defineCreatePullRequestTemplateConfig.ts
120
+ const createPullRequestTemplateBaseSchema = z.object({ projectName: z.string().optional() });
121
+ const createPullRequestTemplateSchema = z.discriminatedUnion("category", [createPullRequestTemplateBaseSchema.extend({
122
+ category: z.literal("general"),
123
+ projectType: z.string()
124
+ }), createPullRequestTemplateBaseSchema.extend({
125
+ category: z.literal("infrastructure"),
126
+ infrastructureProvider: z.string(),
127
+ requireConfirmationFrom: z.string()
128
+ })]);
129
+ function parseCreatePullRequestTemplateConfig(input) {
130
+ return parseZodSchema(createPullRequestTemplateSchema, input, new DataError(input, "INVALID_PRE_COMMIT_CONFIG", "The config provided does not match the expected shape."));
131
+ }
132
+
133
+ //#endregion
134
+ //#region src/configs/types/PreCommitConfig.ts
135
+ const PackageManager = {
136
+ NPM: "npm",
137
+ PNPM: "pnpm"
138
+ };
139
+
140
+ //#endregion
141
+ //#region src/configs/helpers/definePreCommitConfig.ts
142
+ const preCommitStepOptionsSchema = z.object({ arguments: z.array(z.string()).optional() });
143
+ const preCommitConfigSchema = z.object({
144
+ packageManager: z.enum(PackageManager).optional(),
145
+ allowNoStagedChanges: z.boolean().optional(),
146
+ steps: z.union([z.array(z.string()), z.array(z.tuple([z.string(), preCommitStepOptionsSchema]))])
147
+ });
148
+
149
+ //#endregion
150
+ //#region src/configs/helpers/defineAlexCLineConfig.ts
151
+ const alexCLineConfigSchema = z.object({
152
+ preCommit: preCommitConfigSchema,
153
+ createPullRequestTemplate: createPullRequestTemplateSchema
154
+ }).partial();
155
+ function defineAlexCLineConfig(config) {
156
+ return parseZodSchema(alexCLineConfigSchema, config, new DataError(config, "INVALID_ALEX_C_LINE_CONFIG", "The config provided does not match the expected shape."));
157
+ }
158
+ var defineAlexCLineConfig_default = defineAlexCLineConfig;
159
+
160
+ //#endregion
161
+ //#region src/configs/helpers/definePreCommitPrivateConfig.ts
162
+ const preCommitPrivateConfigSchema = z.object({ disableSteps: z.array(z.string()).optional() });
163
+
164
+ //#endregion
165
+ //#region src/configs/types/ConfigFileName.ts
166
+ const ConfigFileName = {
167
+ STANDARD_JAVASCRIPT: "alex-c-line.config.js",
168
+ ES_MODULES_JAVASCRIPT: "alex-c-line.config.mjs",
169
+ COMMON_JS_JAVASCRIPT: "alex-c-line.config.cjs"
170
+ };
171
+ var ConfigFileName_default = ConfigFileName;
172
+
173
+ //#endregion
174
+ //#region src/configs/types/PullRequestTemplateCategory.ts
175
+ const PullRequestTemplateCategory = {
176
+ GENERAL: "general",
177
+ INFRASTRUCTURE: "infrastructure"
178
+ };
179
+ var PullRequestTemplateCategory_default = PullRequestTemplateCategory;
180
+
181
+ //#endregion
182
+ //#region src/utility/configLoaders/loadAlexCLineConfig.ts
183
+ const require = createRequire(import.meta.url);
184
+ async function loadAlexCLineConfig(filePath) {
185
+ if (filePath.endsWith(".cjs")) {
186
+ const module$2 = require(filePath);
187
+ return defineAlexCLineConfig_default(module$2.default ?? module$2);
188
+ }
189
+ const module$1 = await import(pathToFileURL(filePath).href);
190
+ return defineAlexCLineConfig_default(module$1.default ?? module$1);
191
+ }
192
+ var loadAlexCLineConfig_default = loadAlexCLineConfig;
193
+
194
+ //#endregion
195
+ //#region src/utility/doesFileExist.ts
196
+ async function doesFileExist(filePath) {
197
+ try {
198
+ await access(filePath);
199
+ return true;
200
+ } catch (error) {
201
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") return false;
202
+ throw error;
203
+ }
204
+ }
205
+ var doesFileExist_default = doesFileExist;
206
+
207
+ //#endregion
208
+ //#region src/utility/findAlexCLineConfig.ts
209
+ async function findAlexCLineConfig(cwd) {
210
+ const validConfigFileNames = [
211
+ ConfigFileName_default.ES_MODULES_JAVASCRIPT,
212
+ ConfigFileName_default.STANDARD_JAVASCRIPT,
213
+ ConfigFileName_default.COMMON_JS_JAVASCRIPT
214
+ ];
215
+ for (const fileName of validConfigFileNames) {
216
+ const fullPath = path.join(cwd, fileName);
217
+ if (await doesFileExist_default(fullPath)) return fullPath;
218
+ }
219
+ }
220
+ var findAlexCLineConfig_default = findAlexCLineConfig;
221
+
222
+ //#endregion
223
+ //#region src/utility/findPackageRoot.ts
224
+ async function findPackageRoot(startDirectory, packageName) {
225
+ let directory = startDirectory;
226
+ while (true) {
227
+ const packagePath = path.join(directory, "package.json");
228
+ try {
229
+ if (JSON.parse(await readFile(packagePath, "utf-8"))?.name === packageName) return directory;
230
+ } catch {}
231
+ const parent = path.dirname(directory);
232
+ if (parent === directory) break;
233
+ directory = parent;
234
+ }
235
+ throw new DataError(packageName, "PACKAGE_ROOT_NOT_FOUND", `Could not find package root for ${packageName}`);
236
+ }
237
+ var findPackageRoot_default = findPackageRoot;
238
+
239
+ //#endregion
240
+ //#region src/utility/getPullRequestTemplatesFromMarkdown.ts
241
+ const __filename = fileURLToPath(import.meta.url);
242
+ function getTemplateVariables(config) {
243
+ if (config.category === "general") return {
244
+ projectName: config.projectName,
245
+ projectType: config.projectType
246
+ };
247
+ return {
248
+ projectName: config.projectName,
249
+ infrastructureProvider: config.infrastructureProvider,
250
+ requireConfirmationFrom: config.requireConfirmationFrom
251
+ };
252
+ }
253
+ async function getPullRequestTemplatesFromMarkdown(config) {
254
+ const templateVariables = getTemplateVariables(config);
255
+ const { category } = config;
256
+ const templatesPath = path.join(await findPackageRoot_default(path.dirname(__filename), "alex-c-line"), "templates", "pullRequest");
257
+ if (!(await readdir(templatesPath)).includes(category)) throw new DataError(category, "CATEGORY_NOT_FOUND", "Category folder not found in the templates folder.");
258
+ const categoryPath = path.join(templatesPath, category);
259
+ const allCategoryTemplateNames = (await readdir(categoryPath)).filter((name$1) => {
260
+ return name$1.endsWith(".md");
261
+ });
262
+ const allTemplates = {};
263
+ for (const templateFileName of allCategoryTemplateNames) {
264
+ const { content, data } = matter(await readFile(path.join(categoryPath, templateFileName), "utf-8"));
265
+ const templateName = parseZodSchema(z.string(), data.id === "base" ? "pull_request_template" : data.id);
266
+ const placeholders = parseZodSchema(z.array(z.string()).default([]), data.placeholders);
267
+ let finalContent = content;
268
+ for (const placeholder of placeholders) {
269
+ if (!(placeholder in templateVariables)) throw new DataError(placeholder, "INVALID_PLACEHOLDER", "The placeholder found in frontmatter can not be found in the metadata.");
270
+ finalContent = finalContent.replaceAll(`{{${placeholder}}}`, templateVariables[placeholder]);
271
+ }
272
+ allTemplates[templateName] = finalContent.trimStart();
273
+ }
274
+ return allTemplates;
275
+ }
276
+ var getPullRequestTemplatesFromMarkdown_default = getPullRequestTemplatesFromMarkdown;
277
+
278
+ //#endregion
279
+ //#region src/commands/create-pull-request-template-2.ts
280
+ function createPullRequestTemplate(program) {
281
+ program.command("create-pull-request-template").alias("create-pull-request-template-2").option("--category <category>", "The category of pull request templates to get (can be either `general` or `infrastructure`)", (rawValue) => {
282
+ return parseZodSchema(z.enum(PullRequestTemplateCategory_default), rawValue, () => {
283
+ program.error(`Invalid template category ${rawValue}. The category must be one of \`general\` or \`infrastructure\``);
284
+ });
285
+ }).option("--project-name <projectName>", "The name of the package to use in the templates (leave blank to default to name found in package.json)").option("--project-type <projectType>", "The type of project, used in phrases such as 'adds a new feature to the {{projectType}}'. This option must not be specified if category is `infrastructure`").option("--infrastructure-provider <infrastructureProvider>", "If category is `infrastructure`, this would be the name of the Infrastructure provider (e.g. Terraform)").option("--require-confirmation-from <requireConfirmationFrom>", "If category is `infrastructure`, this would be the name of the user to get approval from if a manual change was required").description("Create pull request template files for a category (currently generates all templates in that category).").action(async (commandLineOptions) => {
286
+ const configPath = await findAlexCLineConfig_default(process.cwd());
287
+ const { createPullRequestTemplate: config } = configPath ? await loadAlexCLineConfig_default(configPath) : {};
288
+ const packageInfo = JSON.parse(await readFile(path.join(process.cwd(), "package.json"), "utf-8"));
289
+ const { name: projectName } = commandLineOptions.projectName || config?.projectName ? { name: commandLineOptions.projectName ?? config?.projectName } : parseZodSchema(z.object({ name: z.string() }), packageInfo, () => {
290
+ program.error("Invalid package.json - expected package.json to contain a `name` property.", {
291
+ exitCode: 1,
292
+ code: "INVALID_PACKAGE_JSON"
293
+ });
294
+ });
295
+ if (!projectName) throw new DataError({ projectName }, "PROJECT_NAME_NOT_FOUND", "Could not resolve project name.");
296
+ const parsedOptions = parseCreatePullRequestTemplateConfig({
297
+ category: commandLineOptions.category ?? config?.category ?? "general",
298
+ projectType: commandLineOptions.projectType ?? (config?.category === "general" ? config?.projectType : void 0),
299
+ infrastructureProvider: commandLineOptions.infrastructureProvider ?? (config?.category === "infrastructure" ? config?.infrastructureProvider : void 0),
300
+ requireConfirmationFrom: commandLineOptions.requireConfirmationFrom ?? (config?.category === "infrastructure" ? config.requireConfirmationFrom : void 0)
301
+ });
302
+ const gitHubPath = path.join(process.cwd(), ".github");
303
+ const pullRequestTemplatePath = path.join(gitHubPath, "PULL_REQUEST_TEMPLATE");
304
+ const allTemplates = await getPullRequestTemplatesFromMarkdown_default({
305
+ ...parsedOptions,
306
+ projectName
307
+ });
308
+ await mkdir(gitHubPath, { recursive: true });
309
+ await mkdir(pullRequestTemplatePath, { recursive: true });
310
+ for (const templateName of Object.keys(allTemplates)) if (templateName === "pull_request_template") await writeFile(path.join(gitHubPath, "pull_request_template.md"), allTemplates[templateName]);
311
+ else await writeFile(path.join(pullRequestTemplatePath, `${templateName}.md`), allTemplates[templateName]);
312
+ console.info("Pull request templates created.");
313
+ });
314
+ }
315
+ var create_pull_request_template_2_default = createPullRequestTemplate;
316
+
117
317
  //#endregion
118
318
  //#region src/utility/basePullRequestTemplate.ts
119
319
  const basePullRequestTemplate = normaliseIndents`
@@ -184,8 +384,12 @@ var getPullRequestTemplates_default = getPullRequestTemplates;
184
384
 
185
385
  //#endregion
186
386
  //#region src/commands/create-pull-request-templates.ts
387
+ const deprecationMessage$1 = "[DEPRECATED]: This command does not support the new markdown-native templates and alex-c-line config system. Please use `pre-commit-2` instead.";
187
388
  function createPullRequestTemplates(program) {
188
- program.command("create-pull-request-templates").description("Create the standard pull request templates as found in my repositories").action(async () => {
389
+ program.command("create-pull-request-templates").description(normaliseIndents`
390
+ ${deprecationMessage$1}
391
+ Create the standard pull request templates as found in my repositories`).action(async () => {
392
+ console.warn(deprecationMessage$1);
189
393
  const { name: name$1 } = JSON.parse(await readFile(path.join(process.cwd(), "package.json"), "utf-8"));
190
394
  const gitHubPath = path.join(process.cwd(), ".github");
191
395
  const pullRequestTemplatePath = path.join(gitHubPath, "PULL_REQUEST_TEMPLATE");
@@ -474,84 +678,6 @@ function preCommit(program) {
474
678
  }
475
679
  var pre_commit_default = preCommit;
476
680
 
477
- //#endregion
478
- //#region src/configs/types/PreCommitConfig.ts
479
- const PackageManager = {
480
- NPM: "npm",
481
- PNPM: "pnpm"
482
- };
483
-
484
- //#endregion
485
- //#region src/configs/helpers/definePreCommitConfig.ts
486
- const preCommitStepOptionsSchema = z.object({ arguments: z.array(z.string()).optional() });
487
- const preCommitConfigSchema = z.object({
488
- packageManager: z.enum(PackageManager).optional(),
489
- allowNoStagedChanges: z.boolean().optional(),
490
- steps: z.union([z.array(z.string()), z.array(z.tuple([z.string(), preCommitStepOptionsSchema]))])
491
- });
492
-
493
- //#endregion
494
- //#region src/configs/helpers/defineAlexCLineConfig.ts
495
- const alexCLineConfigSchema = z.object({ preCommit: preCommitConfigSchema });
496
- function defineAlexCLineConfig(config) {
497
- return parseZodSchema(alexCLineConfigSchema, config, new DataError(config, "INVALID_ALEX_C_LINE_CONFIG", "The config provided does not match the expected shape."));
498
- }
499
- var defineAlexCLineConfig_default = defineAlexCLineConfig;
500
-
501
- //#endregion
502
- //#region src/configs/helpers/definePreCommitPrivateConfig.ts
503
- const preCommitPrivateConfigSchema = z.object({ disableSteps: z.array(z.string()).optional() });
504
-
505
- //#endregion
506
- //#region src/configs/types/ConfigFileName.ts
507
- const ConfigFileName = {
508
- STANDARD_JAVASCRIPT: "alex-c-line.config.js",
509
- ES_MODULES_JAVASCRIPT: "alex-c-line.config.mjs",
510
- COMMON_JS_JAVASCRIPT: "alex-c-line.config.cjs"
511
- };
512
- var ConfigFileName_default = ConfigFileName;
513
-
514
- //#endregion
515
- //#region src/utility/configLoaders/loadAlexCLineConfig.ts
516
- const require = createRequire(import.meta.url);
517
- async function loadAlexCLineConfig(filePath) {
518
- if (filePath.endsWith(".cjs")) {
519
- const module$2 = require(filePath);
520
- return defineAlexCLineConfig_default(module$2.default ?? module$2);
521
- }
522
- const module$1 = await import(pathToFileURL(filePath).href);
523
- return defineAlexCLineConfig_default(module$1.default ?? module$1);
524
- }
525
- var loadAlexCLineConfig_default = loadAlexCLineConfig;
526
-
527
- //#endregion
528
- //#region src/utility/doesFileExist.ts
529
- async function doesFileExist(filePath) {
530
- try {
531
- await access(filePath);
532
- return true;
533
- } catch (error) {
534
- if (error instanceof Error && "code" in error && error.code === "ENOENT") return false;
535
- throw error;
536
- }
537
- }
538
- var doesFileExist_default = doesFileExist;
539
-
540
- //#endregion
541
- //#region src/utility/findAlexCLineConfig.ts
542
- async function findAlexCLineConfig(cwd) {
543
- const validConfigFileNames = [
544
- ConfigFileName_default.ES_MODULES_JAVASCRIPT,
545
- ConfigFileName_default.STANDARD_JAVASCRIPT,
546
- ConfigFileName_default.COMMON_JS_JAVASCRIPT
547
- ];
548
- for (const fileName of validConfigFileNames) {
549
- const fullPath = path.join(cwd, fileName);
550
- if (await doesFileExist_default(fullPath)) return fullPath;
551
- }
552
- }
553
- var findAlexCLineConfig_default = findAlexCLineConfig;
554
-
555
681
  //#endregion
556
682
  //#region src/commands/pre-commit-2.ts
557
683
  function preCommit2(program) {
@@ -670,6 +796,7 @@ function createCommands(program) {
670
796
  checkForFileDependencies: check_for_file_dependencies_default,
671
797
  checkLockfileVersionDiscrepancy: check_lockfile_version_discrepancy_default,
672
798
  checkVersionNumberChange: check_version_number_change_default,
799
+ createPullRequestTemplate: create_pull_request_template_2_default,
673
800
  createPullRequestTemplates: create_pull_request_templates_default,
674
801
  createReleaseNote: create_release_note_default,
675
802
  editEnv: edit_env_default,
@@ -687,7 +814,7 @@ var commands_default = createCommands;
687
814
 
688
815
  //#endregion
689
816
  //#region package.json
690
- var version = "1.17.3";
817
+ var version = "1.18.1";
691
818
  var package_default = {
692
819
  name: "alex-c-line",
693
820
  version,
@@ -743,8 +870,8 @@ var package_default = {
743
870
  "prepare-live-utility": "pnpm uninstall @alextheman/utility && pnpm install @alextheman/utility",
744
871
  "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\"'",
745
872
  "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\"'",
746
- "test": "pnpm run build && vitest run",
747
- "test-watch": "pnpm run build && vitest",
873
+ "test": "vitest run",
874
+ "test-watch": "vitest",
748
875
  "update-dependencies": "pnpm update --latest && pnpm update",
749
876
  "use-live-eslint-plugin": "pnpm run prepare-live-eslint-plugin && pnpm run lint",
750
877
  "use-live-utility": "pnpm run prepare-live-utility",
@@ -752,11 +879,12 @@ var package_default = {
752
879
  "use-local-utility": "pnpm run prepare-local-utility"
753
880
  },
754
881
  dependencies: {
755
- "@alextheman/utility": "^4.5.1",
882
+ "@alextheman/utility": "^4.7.0",
756
883
  "commander": "^14.0.2",
757
884
  "dotenv": "^17.2.3",
758
885
  "dotenv-stringify": "^3.0.1",
759
886
  "execa": "^9.6.1",
887
+ "gray-matter": "^4.0.3",
760
888
  "libsodium-wrappers": "^0.8.0",
761
889
  "update-notifier": "^7.3.1",
762
890
  "zod": "^4.3.5"
@@ -766,21 +894,22 @@ var package_default = {
766
894
  "@commander-js/extra-typings": "^14.0.0",
767
895
  "@types/eslint": "^9.6.1",
768
896
  "@types/libsodium-wrappers": "^0.7.14",
769
- "@types/node": "^25.0.3",
897
+ "@types/node": "^25.0.9",
770
898
  "@types/update-notifier": "^6.0.8",
771
899
  "dotenv-cli": "^11.0.0",
772
900
  "eslint": "^9.39.2",
773
901
  "eslint-plugin-perfectionist": "^5.3.1",
774
902
  "husky": "^9.1.7",
775
- "prettier": "^3.7.4",
903
+ "prettier": "^3.8.0",
776
904
  "tempy": "^3.1.0",
777
905
  "ts-node": "^10.9.2",
778
906
  "tsdown": "^0.18.4",
779
907
  "typescript": "^5.9.3",
780
908
  "vite-tsconfig-paths": "^6.0.4",
781
- "vitest": "^4.0.16"
909
+ "vitest": "^4.0.17"
782
910
  },
783
911
  packageManager: "pnpm@10.28.0+sha512.05df71d1421f21399e053fde567cea34d446fa02c76571441bfc1c7956e98e363088982d940465fd34480d4d90a0668bc12362f8aa88000a64e83d0b0e47be48",
912
+ engines: { "node": ">=22.0.0" },
784
913
  pnpm: {
785
914
  "onlyBuiltDependencies": ["esbuild", "unrs-resolver"],
786
915
  "overrides": { "tsdown": "<0.19.0" }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alex-c-line",
3
- "version": "1.17.3",
3
+ "version": "1.18.1",
4
4
  "description": "Command-line tool with commands to streamline the developer workflow.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,11 +33,12 @@
33
33
  "dist"
34
34
  ],
35
35
  "dependencies": {
36
- "@alextheman/utility": "^4.5.1",
36
+ "@alextheman/utility": "^4.7.0",
37
37
  "commander": "^14.0.2",
38
38
  "dotenv": "^17.2.3",
39
39
  "dotenv-stringify": "^3.0.1",
40
40
  "execa": "^9.6.1",
41
+ "gray-matter": "^4.0.3",
41
42
  "libsodium-wrappers": "^0.8.0",
42
43
  "update-notifier": "^7.3.1",
43
44
  "zod": "^4.3.5"
@@ -47,19 +48,22 @@
47
48
  "@commander-js/extra-typings": "^14.0.0",
48
49
  "@types/eslint": "^9.6.1",
49
50
  "@types/libsodium-wrappers": "^0.7.14",
50
- "@types/node": "^25.0.3",
51
+ "@types/node": "^25.0.9",
51
52
  "@types/update-notifier": "^6.0.8",
52
53
  "dotenv-cli": "^11.0.0",
53
54
  "eslint": "^9.39.2",
54
55
  "eslint-plugin-perfectionist": "^5.3.1",
55
56
  "husky": "^9.1.7",
56
- "prettier": "^3.7.4",
57
+ "prettier": "^3.8.0",
57
58
  "tempy": "^3.1.0",
58
59
  "ts-node": "^10.9.2",
59
60
  "tsdown": "^0.18.4",
60
61
  "typescript": "^5.9.3",
61
62
  "vite-tsconfig-paths": "^6.0.4",
62
- "vitest": "^4.0.16"
63
+ "vitest": "^4.0.17"
64
+ },
65
+ "engines": {
66
+ "node": ">=22.0.0"
63
67
  },
64
68
  "scripts": {
65
69
  "build": "tsdown",
@@ -85,8 +89,8 @@
85
89
  "prepare-live-utility": "pnpm uninstall @alextheman/utility && pnpm install @alextheman/utility",
86
90
  "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\"'",
87
91
  "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\"'",
88
- "test": "pnpm run build && vitest run",
89
- "test-watch": "pnpm run build && vitest",
92
+ "test": "vitest run",
93
+ "test-watch": "vitest",
90
94
  "update-dependencies": "pnpm update --latest && pnpm update",
91
95
  "use-live-eslint-plugin": "pnpm run prepare-live-eslint-plugin && pnpm run lint",
92
96
  "use-live-utility": "pnpm run prepare-live-utility",