alex-c-line 1.17.3 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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,209 @@ 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
+ if (!configPath) program.error("Could not find the path to the alex-c-line config file. Does it exist?", {
322
+ exitCode: 1,
323
+ code: "ALEX_C_LINE_CONFIG_NOT_FOUND"
324
+ });
325
+ const { createPullRequestTemplate: config } = await loadAlexCLineConfig_default(configPath);
326
+ const packageInfo = JSON.parse(await (0, node_fs_promises.readFile)(node_path.default.join(process.cwd(), "package.json"), "utf-8"));
327
+ const { name: projectName } = commandLineOptions.projectName || config?.projectName ? { name: commandLineOptions.projectName ?? config?.projectName } : (0, _alextheman_utility.parseZodSchema)(zod.default.object({ name: zod.default.string() }), packageInfo, () => {
328
+ program.error("Invalid package.json - expected package.json to contain a `name` property.", {
329
+ exitCode: 1,
330
+ code: "INVALID_PACKAGE_JSON"
331
+ });
332
+ });
333
+ if (!projectName) throw new _alextheman_utility.DataError({ projectName }, "PROJECT_NAME_NOT_FOUND", "Could not resolve project name.");
334
+ const parsedOptions = parseCreatePullRequestTemplateConfig({
335
+ category: commandLineOptions.category ?? config?.category ?? "general",
336
+ projectType: commandLineOptions.projectType ?? (config?.category === "general" ? config?.projectType : void 0),
337
+ infrastructureProvider: commandLineOptions.infrastructureProvider ?? (config?.category === "infrastructure" ? config?.infrastructureProvider : void 0),
338
+ requireConfirmationFrom: commandLineOptions.requireConfirmationFrom ?? (config?.category === "infrastructure" ? config.requireConfirmationFrom : void 0)
339
+ });
340
+ const gitHubPath = node_path.default.join(process.cwd(), ".github");
341
+ const pullRequestTemplatePath = node_path.default.join(gitHubPath, "PULL_REQUEST_TEMPLATE");
342
+ const allTemplates = await getPullRequestTemplatesFromMarkdown_default({
343
+ ...parsedOptions,
344
+ projectName
345
+ });
346
+ await (0, node_fs_promises.mkdir)(gitHubPath, { recursive: true });
347
+ await (0, node_fs_promises.mkdir)(pullRequestTemplatePath, { recursive: true });
348
+ 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]);
349
+ else await (0, node_fs_promises.writeFile)(node_path.default.join(pullRequestTemplatePath, `${templateName}.md`), allTemplates[templateName]);
350
+ console.info("Pull request templates created.");
351
+ });
352
+ }
353
+ var create_pull_request_template_2_default = createPullRequestTemplate;
354
+
150
355
  //#endregion
151
356
  //#region src/utility/basePullRequestTemplate.ts
152
357
  const basePullRequestTemplate = _alextheman_utility.normaliseIndents`
@@ -217,8 +422,12 @@ var getPullRequestTemplates_default = getPullRequestTemplates;
217
422
 
218
423
  //#endregion
219
424
  //#region src/commands/create-pull-request-templates.ts
425
+ 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
426
  function createPullRequestTemplates(program) {
221
- program.command("create-pull-request-templates").description("Create the standard pull request templates as found in my repositories").action(async () => {
427
+ program.command("create-pull-request-templates").description(_alextheman_utility.normaliseIndents`
428
+ ${deprecationMessage$1}
429
+ Create the standard pull request templates as found in my repositories`).action(async () => {
430
+ console.warn(deprecationMessage$1);
222
431
  const { name: name$1 } = JSON.parse(await (0, node_fs_promises.readFile)(node_path.default.join(process.cwd(), "package.json"), "utf-8"));
223
432
  const gitHubPath = node_path.default.join(process.cwd(), ".github");
224
433
  const pullRequestTemplatePath = node_path.default.join(gitHubPath, "PULL_REQUEST_TEMPLATE");
@@ -507,84 +716,6 @@ function preCommit(program) {
507
716
  }
508
717
  var pre_commit_default = preCommit;
509
718
 
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
719
  //#endregion
589
720
  //#region src/commands/pre-commit-2.ts
590
721
  function preCommit2(program) {
@@ -703,6 +834,7 @@ function createCommands(program) {
703
834
  checkForFileDependencies: check_for_file_dependencies_default,
704
835
  checkLockfileVersionDiscrepancy: check_lockfile_version_discrepancy_default,
705
836
  checkVersionNumberChange: check_version_number_change_default,
837
+ createPullRequestTemplate: create_pull_request_template_2_default,
706
838
  createPullRequestTemplates: create_pull_request_templates_default,
707
839
  createReleaseNote: create_release_note_default,
708
840
  editEnv: edit_env_default,
@@ -720,7 +852,7 @@ var commands_default = createCommands;
720
852
 
721
853
  //#endregion
722
854
  //#region package.json
723
- var version = "1.17.3";
855
+ var version = "1.18.0";
724
856
  var package_default = {
725
857
  name: "alex-c-line",
726
858
  version,
@@ -776,8 +908,8 @@ var package_default = {
776
908
  "prepare-live-utility": "pnpm uninstall @alextheman/utility && pnpm install @alextheman/utility",
777
909
  "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
910
  "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",
911
+ "test": "vitest run",
912
+ "test-watch": "vitest",
781
913
  "update-dependencies": "pnpm update --latest && pnpm update",
782
914
  "use-live-eslint-plugin": "pnpm run prepare-live-eslint-plugin && pnpm run lint",
783
915
  "use-live-utility": "pnpm run prepare-live-utility",
@@ -785,11 +917,12 @@ var package_default = {
785
917
  "use-local-utility": "pnpm run prepare-local-utility"
786
918
  },
787
919
  dependencies: {
788
- "@alextheman/utility": "^4.5.1",
920
+ "@alextheman/utility": "^4.7.0",
789
921
  "commander": "^14.0.2",
790
922
  "dotenv": "^17.2.3",
791
923
  "dotenv-stringify": "^3.0.1",
792
924
  "execa": "^9.6.1",
925
+ "gray-matter": "^4.0.3",
793
926
  "libsodium-wrappers": "^0.8.0",
794
927
  "update-notifier": "^7.3.1",
795
928
  "zod": "^4.3.5"
@@ -799,21 +932,22 @@ var package_default = {
799
932
  "@commander-js/extra-typings": "^14.0.0",
800
933
  "@types/eslint": "^9.6.1",
801
934
  "@types/libsodium-wrappers": "^0.7.14",
802
- "@types/node": "^25.0.3",
935
+ "@types/node": "^25.0.9",
803
936
  "@types/update-notifier": "^6.0.8",
804
937
  "dotenv-cli": "^11.0.0",
805
938
  "eslint": "^9.39.2",
806
939
  "eslint-plugin-perfectionist": "^5.3.1",
807
940
  "husky": "^9.1.7",
808
- "prettier": "^3.7.4",
941
+ "prettier": "^3.8.0",
809
942
  "tempy": "^3.1.0",
810
943
  "ts-node": "^10.9.2",
811
944
  "tsdown": "^0.18.4",
812
945
  "typescript": "^5.9.3",
813
946
  "vite-tsconfig-paths": "^6.0.4",
814
- "vitest": "^4.0.16"
947
+ "vitest": "^4.0.17"
815
948
  },
816
949
  packageManager: "pnpm@10.28.0+sha512.05df71d1421f21399e053fde567cea34d446fa02c76571441bfc1c7956e98e363088982d940465fd34480d4d90a0668bc12362f8aa88000a64e83d0b0e47be48",
950
+ engines: { "node": ">=22.0.0" },
817
951
  pnpm: {
818
952
  "onlyBuiltDependencies": ["esbuild", "unrs-resolver"],
819
953
  "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,209 @@ 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
+ if (!configPath) program.error("Could not find the path to the alex-c-line config file. Does it exist?", {
288
+ exitCode: 1,
289
+ code: "ALEX_C_LINE_CONFIG_NOT_FOUND"
290
+ });
291
+ const { createPullRequestTemplate: config } = await loadAlexCLineConfig_default(configPath);
292
+ const packageInfo = JSON.parse(await readFile(path.join(process.cwd(), "package.json"), "utf-8"));
293
+ const { name: projectName } = commandLineOptions.projectName || config?.projectName ? { name: commandLineOptions.projectName ?? config?.projectName } : parseZodSchema(z.object({ name: z.string() }), packageInfo, () => {
294
+ program.error("Invalid package.json - expected package.json to contain a `name` property.", {
295
+ exitCode: 1,
296
+ code: "INVALID_PACKAGE_JSON"
297
+ });
298
+ });
299
+ if (!projectName) throw new DataError({ projectName }, "PROJECT_NAME_NOT_FOUND", "Could not resolve project name.");
300
+ const parsedOptions = parseCreatePullRequestTemplateConfig({
301
+ category: commandLineOptions.category ?? config?.category ?? "general",
302
+ projectType: commandLineOptions.projectType ?? (config?.category === "general" ? config?.projectType : void 0),
303
+ infrastructureProvider: commandLineOptions.infrastructureProvider ?? (config?.category === "infrastructure" ? config?.infrastructureProvider : void 0),
304
+ requireConfirmationFrom: commandLineOptions.requireConfirmationFrom ?? (config?.category === "infrastructure" ? config.requireConfirmationFrom : void 0)
305
+ });
306
+ const gitHubPath = path.join(process.cwd(), ".github");
307
+ const pullRequestTemplatePath = path.join(gitHubPath, "PULL_REQUEST_TEMPLATE");
308
+ const allTemplates = await getPullRequestTemplatesFromMarkdown_default({
309
+ ...parsedOptions,
310
+ projectName
311
+ });
312
+ await mkdir(gitHubPath, { recursive: true });
313
+ await mkdir(pullRequestTemplatePath, { recursive: true });
314
+ for (const templateName of Object.keys(allTemplates)) if (templateName === "pull_request_template") await writeFile(path.join(gitHubPath, "pull_request_template.md"), allTemplates[templateName]);
315
+ else await writeFile(path.join(pullRequestTemplatePath, `${templateName}.md`), allTemplates[templateName]);
316
+ console.info("Pull request templates created.");
317
+ });
318
+ }
319
+ var create_pull_request_template_2_default = createPullRequestTemplate;
320
+
117
321
  //#endregion
118
322
  //#region src/utility/basePullRequestTemplate.ts
119
323
  const basePullRequestTemplate = normaliseIndents`
@@ -184,8 +388,12 @@ var getPullRequestTemplates_default = getPullRequestTemplates;
184
388
 
185
389
  //#endregion
186
390
  //#region src/commands/create-pull-request-templates.ts
391
+ 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
392
  function createPullRequestTemplates(program) {
188
- program.command("create-pull-request-templates").description("Create the standard pull request templates as found in my repositories").action(async () => {
393
+ program.command("create-pull-request-templates").description(normaliseIndents`
394
+ ${deprecationMessage$1}
395
+ Create the standard pull request templates as found in my repositories`).action(async () => {
396
+ console.warn(deprecationMessage$1);
189
397
  const { name: name$1 } = JSON.parse(await readFile(path.join(process.cwd(), "package.json"), "utf-8"));
190
398
  const gitHubPath = path.join(process.cwd(), ".github");
191
399
  const pullRequestTemplatePath = path.join(gitHubPath, "PULL_REQUEST_TEMPLATE");
@@ -474,84 +682,6 @@ function preCommit(program) {
474
682
  }
475
683
  var pre_commit_default = preCommit;
476
684
 
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
685
  //#endregion
556
686
  //#region src/commands/pre-commit-2.ts
557
687
  function preCommit2(program) {
@@ -670,6 +800,7 @@ function createCommands(program) {
670
800
  checkForFileDependencies: check_for_file_dependencies_default,
671
801
  checkLockfileVersionDiscrepancy: check_lockfile_version_discrepancy_default,
672
802
  checkVersionNumberChange: check_version_number_change_default,
803
+ createPullRequestTemplate: create_pull_request_template_2_default,
673
804
  createPullRequestTemplates: create_pull_request_templates_default,
674
805
  createReleaseNote: create_release_note_default,
675
806
  editEnv: edit_env_default,
@@ -687,7 +818,7 @@ var commands_default = createCommands;
687
818
 
688
819
  //#endregion
689
820
  //#region package.json
690
- var version = "1.17.3";
821
+ var version = "1.18.0";
691
822
  var package_default = {
692
823
  name: "alex-c-line",
693
824
  version,
@@ -743,8 +874,8 @@ var package_default = {
743
874
  "prepare-live-utility": "pnpm uninstall @alextheman/utility && pnpm install @alextheman/utility",
744
875
  "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
876
  "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",
877
+ "test": "vitest run",
878
+ "test-watch": "vitest",
748
879
  "update-dependencies": "pnpm update --latest && pnpm update",
749
880
  "use-live-eslint-plugin": "pnpm run prepare-live-eslint-plugin && pnpm run lint",
750
881
  "use-live-utility": "pnpm run prepare-live-utility",
@@ -752,11 +883,12 @@ var package_default = {
752
883
  "use-local-utility": "pnpm run prepare-local-utility"
753
884
  },
754
885
  dependencies: {
755
- "@alextheman/utility": "^4.5.1",
886
+ "@alextheman/utility": "^4.7.0",
756
887
  "commander": "^14.0.2",
757
888
  "dotenv": "^17.2.3",
758
889
  "dotenv-stringify": "^3.0.1",
759
890
  "execa": "^9.6.1",
891
+ "gray-matter": "^4.0.3",
760
892
  "libsodium-wrappers": "^0.8.0",
761
893
  "update-notifier": "^7.3.1",
762
894
  "zod": "^4.3.5"
@@ -766,21 +898,22 @@ var package_default = {
766
898
  "@commander-js/extra-typings": "^14.0.0",
767
899
  "@types/eslint": "^9.6.1",
768
900
  "@types/libsodium-wrappers": "^0.7.14",
769
- "@types/node": "^25.0.3",
901
+ "@types/node": "^25.0.9",
770
902
  "@types/update-notifier": "^6.0.8",
771
903
  "dotenv-cli": "^11.0.0",
772
904
  "eslint": "^9.39.2",
773
905
  "eslint-plugin-perfectionist": "^5.3.1",
774
906
  "husky": "^9.1.7",
775
- "prettier": "^3.7.4",
907
+ "prettier": "^3.8.0",
776
908
  "tempy": "^3.1.0",
777
909
  "ts-node": "^10.9.2",
778
910
  "tsdown": "^0.18.4",
779
911
  "typescript": "^5.9.3",
780
912
  "vite-tsconfig-paths": "^6.0.4",
781
- "vitest": "^4.0.16"
913
+ "vitest": "^4.0.17"
782
914
  },
783
915
  packageManager: "pnpm@10.28.0+sha512.05df71d1421f21399e053fde567cea34d446fa02c76571441bfc1c7956e98e363088982d940465fd34480d4d90a0668bc12362f8aa88000a64e83d0b0e47be48",
916
+ engines: { "node": ">=22.0.0" },
784
917
  pnpm: {
785
918
  "onlyBuiltDependencies": ["esbuild", "unrs-resolver"],
786
919
  "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.0",
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",