alex-c-line 1.14.0 → 1.16.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.
- package/dist/configs/index.cjs +93 -0
- package/dist/configs/index.d.cts +87 -0
- package/dist/configs/index.d.ts +88 -0
- package/dist/configs/index.js +61 -0
- package/dist/index.cjs +167 -11
- package/dist/index.js +168 -13
- package/package.json +16 -7
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
let _alextheman_utility = require("@alextheman/utility");
|
|
29
|
+
let zod = require("zod");
|
|
30
|
+
zod = __toESM(zod);
|
|
31
|
+
|
|
32
|
+
//#region src/configs/internalConfig.ts
|
|
33
|
+
const internalConfig = { preCommit: {
|
|
34
|
+
packageManager: "pnpm",
|
|
35
|
+
steps: [
|
|
36
|
+
"format",
|
|
37
|
+
"lint",
|
|
38
|
+
"test"
|
|
39
|
+
]
|
|
40
|
+
} };
|
|
41
|
+
var internalConfig_default = internalConfig;
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/configs/types/PreCommitConfig.ts
|
|
45
|
+
const PackageManager = {
|
|
46
|
+
NPM: "npm",
|
|
47
|
+
PNPM: "pnpm"
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/configs/helpers/definePreCommitConfig.ts
|
|
52
|
+
const preCommitStepOptionsSchema = zod.default.object({ arguments: zod.default.array(zod.default.string()).optional() });
|
|
53
|
+
const preCommitConfigSchema = zod.default.object({
|
|
54
|
+
packageManager: zod.default.enum(PackageManager).optional(),
|
|
55
|
+
allowNoStagedChanges: zod.default.boolean().optional(),
|
|
56
|
+
steps: zod.default.union([zod.default.array(zod.default.string()), zod.default.array(zod.default.tuple([zod.default.string(), preCommitStepOptionsSchema]))])
|
|
57
|
+
});
|
|
58
|
+
function definePreCommitConfig(config) {
|
|
59
|
+
return (0, _alextheman_utility.parseZodSchema)(preCommitConfigSchema, config, new _alextheman_utility.DataError(config, "INVALID_PRE_COMMIT_CONFIG", "The config provided does not match the expected shape."));
|
|
60
|
+
}
|
|
61
|
+
var definePreCommitConfig_default = definePreCommitConfig;
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/configs/helpers/defineAlexCLineConfig.ts
|
|
65
|
+
const alexCLineConfigSchema = zod.default.object({ preCommit: preCommitConfigSchema });
|
|
66
|
+
function defineAlexCLineConfig(config) {
|
|
67
|
+
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."));
|
|
68
|
+
}
|
|
69
|
+
var defineAlexCLineConfig_default = defineAlexCLineConfig;
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/configs/helpers/definePreCommitPrivateConfig.ts
|
|
73
|
+
const preCommitPrivateConfigSchema = zod.default.object({ disableSteps: zod.default.array(zod.default.string()).optional() });
|
|
74
|
+
function definePreCommitPrivateConfig(config) {
|
|
75
|
+
return (0, _alextheman_utility.parseZodSchema)(preCommitPrivateConfigSchema, config, new _alextheman_utility.DataError(config, "INVALID_PRE_COMMIT_PRIVATE_CONFIG", "The config provided does not match the expected shape."));
|
|
76
|
+
}
|
|
77
|
+
var definePreCommitPrivateConfig_default = definePreCommitPrivateConfig;
|
|
78
|
+
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/configs/types/ConfigFileName.ts
|
|
81
|
+
const ConfigFileName = {
|
|
82
|
+
STANDARD_JAVASCRIPT: "alex-c-line.config.js",
|
|
83
|
+
ES_MODULES_JAVASCRIPT: "alex-c-line.config.mjs",
|
|
84
|
+
COMMON_JS_JAVASCRIPT: "alex-c-line.config.cjs"
|
|
85
|
+
};
|
|
86
|
+
var ConfigFileName_default = ConfigFileName;
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
exports.ConfigFileName = ConfigFileName_default;
|
|
90
|
+
exports.defineAlexCLineConfig = defineAlexCLineConfig_default;
|
|
91
|
+
exports.definePreCommitConfig = definePreCommitConfig_default;
|
|
92
|
+
exports.definePreCommitPrivateConfig = definePreCommitPrivateConfig_default;
|
|
93
|
+
exports.internalConfig = internalConfig_default;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { CreateEnumType } from "@alextheman/utility";
|
|
2
|
+
|
|
3
|
+
//#region src/configs/types/PreCommitConfig.d.ts
|
|
4
|
+
declare const PackageManager: {
|
|
5
|
+
NPM: string;
|
|
6
|
+
PNPM: string;
|
|
7
|
+
};
|
|
8
|
+
type PackageManager = CreateEnumType<typeof PackageManager>;
|
|
9
|
+
interface PreCommitStepOptions {
|
|
10
|
+
/** Arguments to pass to the given script */
|
|
11
|
+
arguments?: string[];
|
|
12
|
+
}
|
|
13
|
+
interface PreCommitConfig<ScriptName extends string = string> {
|
|
14
|
+
/** The name of the package manager being used (can choose from `npm` or `pnpm`). If not provided, can be inferred from the packageManager field in package.json. */
|
|
15
|
+
packageManager?: PackageManager;
|
|
16
|
+
/** Allow the hook to run even if there are no staged changes. */
|
|
17
|
+
allowNoStagedChanges?: boolean;
|
|
18
|
+
/** The steps to run in the pre-commit hook. */
|
|
19
|
+
steps: ScriptName[] | [ScriptName, PreCommitStepOptions][];
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/configs/types/AlexCLineConfig.d.ts
|
|
23
|
+
interface AlexCLineConfig<ScriptName extends string = string> {
|
|
24
|
+
preCommit: PreCommitConfig<ScriptName>;
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region package.d.ts
|
|
28
|
+
|
|
29
|
+
declare let scripts: {
|
|
30
|
+
build: string;
|
|
31
|
+
command: string;
|
|
32
|
+
"create-release-note-major": string;
|
|
33
|
+
"create-release-note-minor": string;
|
|
34
|
+
"create-release-note-patch": string;
|
|
35
|
+
format: string;
|
|
36
|
+
"format-eslint": string;
|
|
37
|
+
"format-prettier": string;
|
|
38
|
+
"format-prettier-javascript": string;
|
|
39
|
+
"format-prettier-typescript": string;
|
|
40
|
+
lint: string;
|
|
41
|
+
"lint-eslint": string;
|
|
42
|
+
"lint-prettier": string;
|
|
43
|
+
"lint-prettier-javascript": string;
|
|
44
|
+
"lint-prettier-typescript": string;
|
|
45
|
+
"lint-tsc": string;
|
|
46
|
+
"pre-commit": string;
|
|
47
|
+
prepare: string;
|
|
48
|
+
"prepare-live-eslint-plugin": string;
|
|
49
|
+
"prepare-live-utility": string;
|
|
50
|
+
"prepare-local-eslint-plugin": string;
|
|
51
|
+
"prepare-local-utility": string;
|
|
52
|
+
test: string;
|
|
53
|
+
"test-watch": string;
|
|
54
|
+
"update-dependencies": string;
|
|
55
|
+
"use-live-eslint-plugin": string;
|
|
56
|
+
"use-live-utility": string;
|
|
57
|
+
"use-local-eslint-plugin": string;
|
|
58
|
+
"use-local-utility": string;
|
|
59
|
+
};
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/configs/internalConfig.d.ts
|
|
62
|
+
declare const internalConfig: AlexCLineConfig<keyof typeof scripts>;
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/configs/helpers/defineAlexCLineConfig.d.ts
|
|
65
|
+
declare function defineAlexCLineConfig<ScriptName extends string = string>(config: AlexCLineConfig<ScriptName>): AlexCLineConfig;
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/configs/helpers/definePreCommitConfig.d.ts
|
|
68
|
+
declare function definePreCommitConfig<ScriptName extends string = string>(config: PreCommitConfig<ScriptName>): PreCommitConfig;
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/configs/types/PreCommitPrivateConfig.d.ts
|
|
71
|
+
interface PreCommitPrivateConfig<ScriptName extends string = string> {
|
|
72
|
+
/** List of script names to skip */
|
|
73
|
+
disableSteps?: ScriptName[];
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/configs/helpers/definePreCommitPrivateConfig.d.ts
|
|
77
|
+
declare function definePreCommitPrivateConfig<ScriptName extends string = string>(config: PreCommitPrivateConfig<ScriptName>): PreCommitPrivateConfig;
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/configs/types/ConfigFileName.d.ts
|
|
80
|
+
declare const ConfigFileName: {
|
|
81
|
+
readonly STANDARD_JAVASCRIPT: "alex-c-line.config.js";
|
|
82
|
+
readonly ES_MODULES_JAVASCRIPT: "alex-c-line.config.mjs";
|
|
83
|
+
readonly COMMON_JS_JAVASCRIPT: "alex-c-line.config.cjs";
|
|
84
|
+
};
|
|
85
|
+
type ConfigFileName = CreateEnumType<typeof ConfigFileName>;
|
|
86
|
+
//#endregion
|
|
87
|
+
export { AlexCLineConfig, ConfigFileName, PackageManager, PreCommitConfig, PreCommitStepOptions, defineAlexCLineConfig, definePreCommitConfig, definePreCommitPrivateConfig, internalConfig };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { CreateEnumType } from "@alextheman/utility";
|
|
2
|
+
import z from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/configs/types/PreCommitConfig.d.ts
|
|
5
|
+
declare const PackageManager: {
|
|
6
|
+
NPM: string;
|
|
7
|
+
PNPM: string;
|
|
8
|
+
};
|
|
9
|
+
type PackageManager = CreateEnumType<typeof PackageManager>;
|
|
10
|
+
interface PreCommitStepOptions {
|
|
11
|
+
/** Arguments to pass to the given script */
|
|
12
|
+
arguments?: string[];
|
|
13
|
+
}
|
|
14
|
+
interface PreCommitConfig<ScriptName extends string = string> {
|
|
15
|
+
/** The name of the package manager being used (can choose from `npm` or `pnpm`). If not provided, can be inferred from the packageManager field in package.json. */
|
|
16
|
+
packageManager?: PackageManager;
|
|
17
|
+
/** Allow the hook to run even if there are no staged changes. */
|
|
18
|
+
allowNoStagedChanges?: boolean;
|
|
19
|
+
/** The steps to run in the pre-commit hook. */
|
|
20
|
+
steps: ScriptName[] | [ScriptName, PreCommitStepOptions][];
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/configs/types/AlexCLineConfig.d.ts
|
|
24
|
+
interface AlexCLineConfig<ScriptName extends string = string> {
|
|
25
|
+
preCommit: PreCommitConfig<ScriptName>;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region package.d.ts
|
|
29
|
+
|
|
30
|
+
declare let scripts: {
|
|
31
|
+
build: string;
|
|
32
|
+
command: string;
|
|
33
|
+
"create-release-note-major": string;
|
|
34
|
+
"create-release-note-minor": string;
|
|
35
|
+
"create-release-note-patch": string;
|
|
36
|
+
format: string;
|
|
37
|
+
"format-eslint": string;
|
|
38
|
+
"format-prettier": string;
|
|
39
|
+
"format-prettier-javascript": string;
|
|
40
|
+
"format-prettier-typescript": string;
|
|
41
|
+
lint: string;
|
|
42
|
+
"lint-eslint": string;
|
|
43
|
+
"lint-prettier": string;
|
|
44
|
+
"lint-prettier-javascript": string;
|
|
45
|
+
"lint-prettier-typescript": string;
|
|
46
|
+
"lint-tsc": string;
|
|
47
|
+
"pre-commit": string;
|
|
48
|
+
prepare: string;
|
|
49
|
+
"prepare-live-eslint-plugin": string;
|
|
50
|
+
"prepare-live-utility": string;
|
|
51
|
+
"prepare-local-eslint-plugin": string;
|
|
52
|
+
"prepare-local-utility": string;
|
|
53
|
+
test: string;
|
|
54
|
+
"test-watch": string;
|
|
55
|
+
"update-dependencies": string;
|
|
56
|
+
"use-live-eslint-plugin": string;
|
|
57
|
+
"use-live-utility": string;
|
|
58
|
+
"use-local-eslint-plugin": string;
|
|
59
|
+
"use-local-utility": string;
|
|
60
|
+
};
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/configs/internalConfig.d.ts
|
|
63
|
+
declare const internalConfig: AlexCLineConfig<keyof typeof scripts>;
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/configs/helpers/defineAlexCLineConfig.d.ts
|
|
66
|
+
declare function defineAlexCLineConfig<ScriptName extends string = string>(config: AlexCLineConfig<ScriptName>): AlexCLineConfig;
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/configs/helpers/definePreCommitConfig.d.ts
|
|
69
|
+
declare function definePreCommitConfig<ScriptName extends string = string>(config: PreCommitConfig<ScriptName>): PreCommitConfig;
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/configs/types/PreCommitPrivateConfig.d.ts
|
|
72
|
+
interface PreCommitPrivateConfig<ScriptName extends string = string> {
|
|
73
|
+
/** List of script names to skip */
|
|
74
|
+
disableSteps?: ScriptName[];
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/configs/helpers/definePreCommitPrivateConfig.d.ts
|
|
78
|
+
declare function definePreCommitPrivateConfig<ScriptName extends string = string>(config: PreCommitPrivateConfig<ScriptName>): PreCommitPrivateConfig;
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/configs/types/ConfigFileName.d.ts
|
|
81
|
+
declare const ConfigFileName: {
|
|
82
|
+
readonly STANDARD_JAVASCRIPT: "alex-c-line.config.js";
|
|
83
|
+
readonly ES_MODULES_JAVASCRIPT: "alex-c-line.config.mjs";
|
|
84
|
+
readonly COMMON_JS_JAVASCRIPT: "alex-c-line.config.cjs";
|
|
85
|
+
};
|
|
86
|
+
type ConfigFileName = CreateEnumType<typeof ConfigFileName>;
|
|
87
|
+
//#endregion
|
|
88
|
+
export { AlexCLineConfig, ConfigFileName, PackageManager, PreCommitConfig, PreCommitStepOptions, defineAlexCLineConfig, definePreCommitConfig, definePreCommitPrivateConfig, internalConfig };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { DataError, parseZodSchema } from "@alextheman/utility";
|
|
2
|
+
import z from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/configs/internalConfig.ts
|
|
5
|
+
const internalConfig = { preCommit: {
|
|
6
|
+
packageManager: "pnpm",
|
|
7
|
+
steps: [
|
|
8
|
+
"format",
|
|
9
|
+
"lint",
|
|
10
|
+
"test"
|
|
11
|
+
]
|
|
12
|
+
} };
|
|
13
|
+
var internalConfig_default = internalConfig;
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/configs/types/PreCommitConfig.ts
|
|
17
|
+
const PackageManager = {
|
|
18
|
+
NPM: "npm",
|
|
19
|
+
PNPM: "pnpm"
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/configs/helpers/definePreCommitConfig.ts
|
|
24
|
+
const preCommitStepOptionsSchema = z.object({ arguments: z.array(z.string()).optional() });
|
|
25
|
+
const preCommitConfigSchema = z.object({
|
|
26
|
+
packageManager: z.enum(PackageManager).optional(),
|
|
27
|
+
allowNoStagedChanges: z.boolean().optional(),
|
|
28
|
+
steps: z.union([z.array(z.string()), z.array(z.tuple([z.string(), preCommitStepOptionsSchema]))])
|
|
29
|
+
});
|
|
30
|
+
function definePreCommitConfig(config) {
|
|
31
|
+
return parseZodSchema(preCommitConfigSchema, config, new DataError(config, "INVALID_PRE_COMMIT_CONFIG", "The config provided does not match the expected shape."));
|
|
32
|
+
}
|
|
33
|
+
var definePreCommitConfig_default = definePreCommitConfig;
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/configs/helpers/defineAlexCLineConfig.ts
|
|
37
|
+
const alexCLineConfigSchema = z.object({ preCommit: preCommitConfigSchema });
|
|
38
|
+
function defineAlexCLineConfig(config) {
|
|
39
|
+
return parseZodSchema(alexCLineConfigSchema, config, new DataError(config, "INVALID_ALEX_C_LINE_CONFIG", "The config provided does not match the expected shape."));
|
|
40
|
+
}
|
|
41
|
+
var defineAlexCLineConfig_default = defineAlexCLineConfig;
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/configs/helpers/definePreCommitPrivateConfig.ts
|
|
45
|
+
const preCommitPrivateConfigSchema = z.object({ disableSteps: z.array(z.string()).optional() });
|
|
46
|
+
function definePreCommitPrivateConfig(config) {
|
|
47
|
+
return parseZodSchema(preCommitPrivateConfigSchema, config, new DataError(config, "INVALID_PRE_COMMIT_PRIVATE_CONFIG", "The config provided does not match the expected shape."));
|
|
48
|
+
}
|
|
49
|
+
var definePreCommitPrivateConfig_default = definePreCommitPrivateConfig;
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/configs/types/ConfigFileName.ts
|
|
53
|
+
const ConfigFileName = {
|
|
54
|
+
STANDARD_JAVASCRIPT: "alex-c-line.config.js",
|
|
55
|
+
ES_MODULES_JAVASCRIPT: "alex-c-line.config.mjs",
|
|
56
|
+
COMMON_JS_JAVASCRIPT: "alex-c-line.config.cjs"
|
|
57
|
+
};
|
|
58
|
+
var ConfigFileName_default = ConfigFileName;
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
export { ConfigFileName_default as ConfigFileName, defineAlexCLineConfig_default as defineAlexCLineConfig, definePreCommitConfig_default as definePreCommitConfig, definePreCommitPrivateConfig_default as definePreCommitPrivateConfig, internalConfig_default as internalConfig };
|
package/dist/index.cjs
CHANGED
|
@@ -41,6 +41,10 @@ let dotenv_stringify = require("dotenv-stringify");
|
|
|
41
41
|
dotenv_stringify = __toESM(dotenv_stringify);
|
|
42
42
|
let node_os = require("node:os");
|
|
43
43
|
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");
|
|
44
48
|
|
|
45
49
|
//#region src/commands/check-for-file-dependencies.ts
|
|
46
50
|
function findFileDependencies(dependencies$1) {
|
|
@@ -442,8 +446,13 @@ var increment_version_default = incrementVersion;
|
|
|
442
446
|
|
|
443
447
|
//#endregion
|
|
444
448
|
//#region src/commands/pre-commit.ts
|
|
449
|
+
const deprecationMessage = "[DEPRECATED]: This command does not support the new alex-c-line config system. Please use `pre-commit-2` instead.";
|
|
445
450
|
function preCommit(program$1) {
|
|
446
|
-
program$1.command("pre-commit").description(
|
|
451
|
+
program$1.command("pre-commit").description(_alextheman_utility.normaliseIndents`
|
|
452
|
+
${deprecationMessage}
|
|
453
|
+
Run the standard pre-commits used across all my repositories.`).option("--no-build", "Skip the build").option("--no-tests", "Skip the tests").option("--allow-unstaged", "Run even if nothing is staged").option("--repository-manager <repositoryManager>", "The repository manager if it is a monorepo (Only Turborepo is supported as of now)").action(async ({ build: shouldIncludeBuild, tests: shouldIncludeTests, allowUnstaged, repositoryManager: rawRepositoryManager }) => {
|
|
454
|
+
console.warn(deprecationMessage);
|
|
455
|
+
const repositoryManager = rawRepositoryManager ? (0, _alextheman_utility.parseZodSchema)(zod.default.enum(["turborepo"]), rawRepositoryManager?.toLowerCase(), new _alextheman_utility.DataError(rawRepositoryManager, "INVALID_REPOSITORY_MANAGER", "The repository manager provided does not exist or is not currently supported. We currently support the following: `turborepo`.")) : void 0;
|
|
447
456
|
const { exitCode: diffExitCode } = await execaNoFail("git", [
|
|
448
457
|
"diff",
|
|
449
458
|
"--cached",
|
|
@@ -460,8 +469,10 @@ function preCommit(program$1) {
|
|
|
460
469
|
return;
|
|
461
470
|
}
|
|
462
471
|
async function runCommandAndLogToConsole(command, args) {
|
|
463
|
-
const
|
|
464
|
-
if (
|
|
472
|
+
const newArguments = [...args ?? []];
|
|
473
|
+
if (repositoryManager === "turborepo") newArguments.push("--ui=stream");
|
|
474
|
+
const result = await execaNoFail(command, newArguments, { stdio: "inherit" });
|
|
475
|
+
if (result.exitCode !== 0) program$1.error(`Command failed: ${command}${newArguments.length ? ` ${newArguments.join(" ")}` : ""}`, {
|
|
465
476
|
exitCode: result.exitCode ?? 1,
|
|
466
477
|
code: "PRE_COMMIT_FAILED"
|
|
467
478
|
});
|
|
@@ -476,6 +487,143 @@ function preCommit(program$1) {
|
|
|
476
487
|
}
|
|
477
488
|
var pre_commit_default = preCommit;
|
|
478
489
|
|
|
490
|
+
//#endregion
|
|
491
|
+
//#region src/configs/types/PreCommitConfig.ts
|
|
492
|
+
const PackageManager = {
|
|
493
|
+
NPM: "npm",
|
|
494
|
+
PNPM: "pnpm"
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
//#endregion
|
|
498
|
+
//#region src/configs/helpers/definePreCommitConfig.ts
|
|
499
|
+
const preCommitStepOptionsSchema = zod.default.object({ arguments: zod.default.array(zod.default.string()).optional() });
|
|
500
|
+
const preCommitConfigSchema = zod.default.object({
|
|
501
|
+
packageManager: zod.default.enum(PackageManager).optional(),
|
|
502
|
+
allowNoStagedChanges: zod.default.boolean().optional(),
|
|
503
|
+
steps: zod.default.union([zod.default.array(zod.default.string()), zod.default.array(zod.default.tuple([zod.default.string(), preCommitStepOptionsSchema]))])
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
//#endregion
|
|
507
|
+
//#region src/configs/helpers/defineAlexCLineConfig.ts
|
|
508
|
+
const alexCLineConfigSchema = zod.default.object({ preCommit: preCommitConfigSchema });
|
|
509
|
+
function defineAlexCLineConfig(config) {
|
|
510
|
+
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."));
|
|
511
|
+
}
|
|
512
|
+
var defineAlexCLineConfig_default = defineAlexCLineConfig;
|
|
513
|
+
|
|
514
|
+
//#endregion
|
|
515
|
+
//#region src/configs/helpers/definePreCommitPrivateConfig.ts
|
|
516
|
+
const preCommitPrivateConfigSchema = zod.default.object({ disableSteps: zod.default.array(zod.default.string()).optional() });
|
|
517
|
+
|
|
518
|
+
//#endregion
|
|
519
|
+
//#region src/configs/types/ConfigFileName.ts
|
|
520
|
+
const ConfigFileName = {
|
|
521
|
+
STANDARD_JAVASCRIPT: "alex-c-line.config.js",
|
|
522
|
+
ES_MODULES_JAVASCRIPT: "alex-c-line.config.mjs",
|
|
523
|
+
COMMON_JS_JAVASCRIPT: "alex-c-line.config.cjs"
|
|
524
|
+
};
|
|
525
|
+
var ConfigFileName_default = ConfigFileName;
|
|
526
|
+
|
|
527
|
+
//#endregion
|
|
528
|
+
//#region src/utility/configLoaders/loadAlexCLineConfig.ts
|
|
529
|
+
const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
530
|
+
async function loadAlexCLineConfig(filePath) {
|
|
531
|
+
if (filePath.endsWith(".cjs")) {
|
|
532
|
+
const module$3 = require$1(filePath);
|
|
533
|
+
return defineAlexCLineConfig_default(module$3.default ?? module$3);
|
|
534
|
+
}
|
|
535
|
+
const module$2 = await import((0, node_url.pathToFileURL)(filePath).href);
|
|
536
|
+
return defineAlexCLineConfig_default(module$2.default ?? module$2);
|
|
537
|
+
}
|
|
538
|
+
var loadAlexCLineConfig_default = loadAlexCLineConfig;
|
|
539
|
+
|
|
540
|
+
//#endregion
|
|
541
|
+
//#region src/utility/doesFileExist.ts
|
|
542
|
+
async function doesFileExist(filePath) {
|
|
543
|
+
try {
|
|
544
|
+
await (0, node_fs_promises.access)(filePath);
|
|
545
|
+
return true;
|
|
546
|
+
} catch (error) {
|
|
547
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") return false;
|
|
548
|
+
throw error;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
var doesFileExist_default = doesFileExist;
|
|
552
|
+
|
|
553
|
+
//#endregion
|
|
554
|
+
//#region src/utility/findAlexCLineConfig.ts
|
|
555
|
+
async function findAlexCLineConfig(cwd) {
|
|
556
|
+
const validConfigFileNames = [
|
|
557
|
+
ConfigFileName_default.ES_MODULES_JAVASCRIPT,
|
|
558
|
+
ConfigFileName_default.STANDARD_JAVASCRIPT,
|
|
559
|
+
ConfigFileName_default.COMMON_JS_JAVASCRIPT
|
|
560
|
+
];
|
|
561
|
+
for (const fileName of validConfigFileNames) {
|
|
562
|
+
const fullPath = node_path.default.join(cwd, fileName);
|
|
563
|
+
if (await doesFileExist_default(fullPath)) return fullPath;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
var findAlexCLineConfig_default = findAlexCLineConfig;
|
|
567
|
+
|
|
568
|
+
//#endregion
|
|
569
|
+
//#region src/commands/pre-commit-2.ts
|
|
570
|
+
function preCommit2(program$1) {
|
|
571
|
+
program$1.command("pre-commit-2").description("Run the pre-commit scripts specified in the alex-c-line config (v2 experiment).").option("--allow-no-staged-changes", "Run even if nothing is staged").action(async ({ allowNoStagedChanges }) => {
|
|
572
|
+
const configPath = await findAlexCLineConfig_default(process.cwd());
|
|
573
|
+
if (!configPath) program$1.error("Could not find the path to the alex-c-line config file. Does it exist?", {
|
|
574
|
+
exitCode: 1,
|
|
575
|
+
code: "ALEX_C_LINE_CONFIG_NOT_FOUND"
|
|
576
|
+
});
|
|
577
|
+
const { preCommit: preCommitConfig } = await loadAlexCLineConfig_default(configPath);
|
|
578
|
+
if (!preCommitConfig) program$1.error("Could not find the pre-commit config in alex-c-line config.", {
|
|
579
|
+
exitCode: 1,
|
|
580
|
+
code: "PRE_COMMIT_CONFIG_NOT_FOUND"
|
|
581
|
+
});
|
|
582
|
+
const { exitCode: diffExitCode } = await execaNoFail("git", [
|
|
583
|
+
"diff",
|
|
584
|
+
"--cached",
|
|
585
|
+
"--quiet"
|
|
586
|
+
]);
|
|
587
|
+
switch (diffExitCode) {
|
|
588
|
+
case 128: program$1.error("Not currently in a Git repository", {
|
|
589
|
+
exitCode: 1,
|
|
590
|
+
code: "GIT_DIFF_FAILED"
|
|
591
|
+
});
|
|
592
|
+
case 0:
|
|
593
|
+
if (allowNoStagedChanges ?? preCommitConfig.allowNoStagedChanges) break;
|
|
594
|
+
console.info("No staged changes found. Use --allow-no-staged-changes to run anyway.");
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
async function runCommandAndLogToConsole(command, args) {
|
|
598
|
+
const result = await execaNoFail(command, args, { stdio: "inherit" });
|
|
599
|
+
if (result.exitCode !== 0) program$1.error(`Command failed: ${command}${args?.length ? ` ${args.join(" ")}` : ""}`, {
|
|
600
|
+
exitCode: result.exitCode ?? 1,
|
|
601
|
+
code: "PRE_COMMIT_FAILED"
|
|
602
|
+
});
|
|
603
|
+
return result;
|
|
604
|
+
}
|
|
605
|
+
const { packageManager: packagePackageManager, scripts: scripts$1 } = JSON.parse(await (0, node_fs_promises.readFile)(node_path.default.join(process.cwd(), "package.json"), "utf8"));
|
|
606
|
+
const rawPackageManager = preCommitConfig.packageManager ?? (typeof packagePackageManager === "string" ? packagePackageManager.split("@")[0] : void 0);
|
|
607
|
+
const packageManager$1 = (0, _alextheman_utility.parseZodSchema)(zod.default.enum(PackageManager), rawPackageManager, new _alextheman_utility.DataError(rawPackageManager, "UNSUPPORTED_PACKAGE_MANAGER", `This repository manager is not currently supported. Only the following are supported: ${Object.values(PackageManager).join(", ")}`));
|
|
608
|
+
function getCommandArguments(script, args) {
|
|
609
|
+
if (!(script in (scripts$1 ?? {}))) program$1.error(`Could not find script \`${script}\` in package.json.`, {
|
|
610
|
+
exitCode: 1,
|
|
611
|
+
code: "SCRIPT_NOT_FOUND"
|
|
612
|
+
});
|
|
613
|
+
const result = script === "test" ? [script] : ["run", script];
|
|
614
|
+
if (args) result.push(...args);
|
|
615
|
+
return result;
|
|
616
|
+
}
|
|
617
|
+
for (const step of preCommitConfig.steps) if (typeof step === "string") await runCommandAndLogToConsole(packageManager$1, [...getCommandArguments(step)]);
|
|
618
|
+
else {
|
|
619
|
+
const [script, options] = step;
|
|
620
|
+
await runCommandAndLogToConsole(packageManager$1, [...getCommandArguments(script, options.arguments)]);
|
|
621
|
+
}
|
|
622
|
+
await execaNoFail("git", ["update-index", "--again"]);
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
var pre_commit_2_default = preCommit2;
|
|
626
|
+
|
|
479
627
|
//#endregion
|
|
480
628
|
//#region src/commands/say-hello.ts
|
|
481
629
|
function sayHello(program$1) {
|
|
@@ -542,6 +690,7 @@ function createCommands(program$1) {
|
|
|
542
690
|
gitPostMergeCleanup: git_post_merge_cleanup_default,
|
|
543
691
|
incrementVersion: increment_version_default,
|
|
544
692
|
preCommit: pre_commit_default,
|
|
693
|
+
preCommit2: pre_commit_2_default,
|
|
545
694
|
sayHello: say_hello_default,
|
|
546
695
|
setReleaseStatus: set_release_status_default
|
|
547
696
|
});
|
|
@@ -550,7 +699,7 @@ var commands_default = createCommands;
|
|
|
550
699
|
|
|
551
700
|
//#endregion
|
|
552
701
|
//#region package.json
|
|
553
|
-
var version = "1.
|
|
702
|
+
var version = "1.16.0";
|
|
554
703
|
var package_default = {
|
|
555
704
|
name: "alex-c-line",
|
|
556
705
|
version,
|
|
@@ -562,6 +711,12 @@ var package_default = {
|
|
|
562
711
|
license: "ISC",
|
|
563
712
|
author: "alextheman",
|
|
564
713
|
type: "module",
|
|
714
|
+
exports: { "./configs": {
|
|
715
|
+
"types": "./dist/configs/index.d.ts",
|
|
716
|
+
"require": "./dist/configs/index.cjs",
|
|
717
|
+
"import": "./dist/configs/index.js",
|
|
718
|
+
"default": "./dist/configs/index.js"
|
|
719
|
+
} },
|
|
565
720
|
main: "dist/index.js",
|
|
566
721
|
module: "dist/index.cjs",
|
|
567
722
|
types: "dist/index.d.ts",
|
|
@@ -584,7 +739,7 @@ var package_default = {
|
|
|
584
739
|
"lint-prettier-javascript": "prettier --check \"./**.js\"",
|
|
585
740
|
"lint-prettier-typescript": "prettier --check --parser typescript \"./**/*.ts\"",
|
|
586
741
|
"lint-tsc": "tsc --noEmit",
|
|
587
|
-
"pre-commit": "pnpm run command pre-commit
|
|
742
|
+
"pre-commit": "pnpm run command pre-commit-2",
|
|
588
743
|
"prepare": "husky",
|
|
589
744
|
"prepare-live-eslint-plugin": "pnpm uninstall @alextheman/eslint-plugin && pnpm install --save-dev @alextheman/eslint-plugin",
|
|
590
745
|
"prepare-live-utility": "pnpm uninstall @alextheman/utility && pnpm install @alextheman/utility",
|
|
@@ -599,31 +754,32 @@ var package_default = {
|
|
|
599
754
|
"use-local-utility": "pnpm run prepare-local-utility"
|
|
600
755
|
},
|
|
601
756
|
dependencies: {
|
|
602
|
-
"@alextheman/utility": "^4.3.
|
|
757
|
+
"@alextheman/utility": "^4.3.6",
|
|
603
758
|
"commander": "^14.0.2",
|
|
604
759
|
"dotenv": "^17.2.3",
|
|
605
760
|
"dotenv-stringify": "^3.0.1",
|
|
606
761
|
"execa": "^9.6.1",
|
|
607
|
-
"update-notifier": "^7.3.1"
|
|
762
|
+
"update-notifier": "^7.3.1",
|
|
763
|
+
"zod": "^4.3.4"
|
|
608
764
|
},
|
|
609
765
|
devDependencies: {
|
|
610
|
-
"@alextheman/eslint-plugin": "^5.4.
|
|
766
|
+
"@alextheman/eslint-plugin": "^5.4.2",
|
|
611
767
|
"@types/eslint": "^9.6.1",
|
|
612
768
|
"@types/node": "^25.0.3",
|
|
613
769
|
"@types/update-notifier": "^6.0.8",
|
|
614
770
|
"dotenv-cli": "^11.0.0",
|
|
615
771
|
"eslint": "^9.39.2",
|
|
616
|
-
"eslint-plugin-perfectionist": "^5.
|
|
772
|
+
"eslint-plugin-perfectionist": "^5.2.0",
|
|
617
773
|
"husky": "^9.1.7",
|
|
618
774
|
"prettier": "^3.7.4",
|
|
619
775
|
"tempy": "^3.1.0",
|
|
620
776
|
"ts-node": "^10.9.2",
|
|
621
|
-
"tsdown": "
|
|
777
|
+
"tsdown": "0.19.0-beta.1",
|
|
622
778
|
"typescript": "^5.9.3",
|
|
623
779
|
"vite-tsconfig-paths": "^6.0.3",
|
|
624
780
|
"vitest": "^4.0.16"
|
|
625
781
|
},
|
|
626
|
-
packageManager: "pnpm@10.
|
|
782
|
+
packageManager: "pnpm@10.27.0+sha512.72d699da16b1179c14ba9e64dc71c9a40988cbdc65c264cb0e489db7de917f20dcf4d64d8723625f2969ba52d4b7e2a1170682d9ac2a5dcaeaab732b7e16f04a"
|
|
627
783
|
};
|
|
628
784
|
|
|
629
785
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
2
3
|
import { Command } from "commander";
|
|
3
4
|
import updateNotifier from "update-notifier";
|
|
4
|
-
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
5
|
+
import { access, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
5
6
|
import path from "node:path";
|
|
6
7
|
import { readFileSync } from "node:fs";
|
|
7
|
-
import { VersionNumber, kebabToCamel, normaliseIndents, parseVersionType } from "@alextheman/utility";
|
|
8
|
+
import { DataError, VersionNumber, kebabToCamel, normaliseIndents, parseVersionType, parseZodSchema } from "@alextheman/utility";
|
|
8
9
|
import { ExecaError, execa } from "execa";
|
|
9
10
|
import dotenv from "dotenv";
|
|
10
11
|
import dotenvStringify from "dotenv-stringify";
|
|
11
12
|
import os from "node:os";
|
|
13
|
+
import z from "zod";
|
|
14
|
+
import { pathToFileURL } from "node:url";
|
|
12
15
|
|
|
13
16
|
//#region src/commands/check-for-file-dependencies.ts
|
|
14
17
|
function findFileDependencies(dependencies$1) {
|
|
@@ -410,8 +413,13 @@ var increment_version_default = incrementVersion;
|
|
|
410
413
|
|
|
411
414
|
//#endregion
|
|
412
415
|
//#region src/commands/pre-commit.ts
|
|
416
|
+
const deprecationMessage = "[DEPRECATED]: This command does not support the new alex-c-line config system. Please use `pre-commit-2` instead.";
|
|
413
417
|
function preCommit(program$1) {
|
|
414
|
-
program$1.command("pre-commit").description(
|
|
418
|
+
program$1.command("pre-commit").description(normaliseIndents`
|
|
419
|
+
${deprecationMessage}
|
|
420
|
+
Run the standard pre-commits used across all my repositories.`).option("--no-build", "Skip the build").option("--no-tests", "Skip the tests").option("--allow-unstaged", "Run even if nothing is staged").option("--repository-manager <repositoryManager>", "The repository manager if it is a monorepo (Only Turborepo is supported as of now)").action(async ({ build: shouldIncludeBuild, tests: shouldIncludeTests, allowUnstaged, repositoryManager: rawRepositoryManager }) => {
|
|
421
|
+
console.warn(deprecationMessage);
|
|
422
|
+
const repositoryManager = rawRepositoryManager ? parseZodSchema(z.enum(["turborepo"]), rawRepositoryManager?.toLowerCase(), new DataError(rawRepositoryManager, "INVALID_REPOSITORY_MANAGER", "The repository manager provided does not exist or is not currently supported. We currently support the following: `turborepo`.")) : void 0;
|
|
415
423
|
const { exitCode: diffExitCode } = await execaNoFail("git", [
|
|
416
424
|
"diff",
|
|
417
425
|
"--cached",
|
|
@@ -428,8 +436,10 @@ function preCommit(program$1) {
|
|
|
428
436
|
return;
|
|
429
437
|
}
|
|
430
438
|
async function runCommandAndLogToConsole(command, args) {
|
|
431
|
-
const
|
|
432
|
-
if (
|
|
439
|
+
const newArguments = [...args ?? []];
|
|
440
|
+
if (repositoryManager === "turborepo") newArguments.push("--ui=stream");
|
|
441
|
+
const result = await execaNoFail(command, newArguments, { stdio: "inherit" });
|
|
442
|
+
if (result.exitCode !== 0) program$1.error(`Command failed: ${command}${newArguments.length ? ` ${newArguments.join(" ")}` : ""}`, {
|
|
433
443
|
exitCode: result.exitCode ?? 1,
|
|
434
444
|
code: "PRE_COMMIT_FAILED"
|
|
435
445
|
});
|
|
@@ -444,6 +454,143 @@ function preCommit(program$1) {
|
|
|
444
454
|
}
|
|
445
455
|
var pre_commit_default = preCommit;
|
|
446
456
|
|
|
457
|
+
//#endregion
|
|
458
|
+
//#region src/configs/types/PreCommitConfig.ts
|
|
459
|
+
const PackageManager = {
|
|
460
|
+
NPM: "npm",
|
|
461
|
+
PNPM: "pnpm"
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
//#endregion
|
|
465
|
+
//#region src/configs/helpers/definePreCommitConfig.ts
|
|
466
|
+
const preCommitStepOptionsSchema = z.object({ arguments: z.array(z.string()).optional() });
|
|
467
|
+
const preCommitConfigSchema = z.object({
|
|
468
|
+
packageManager: z.enum(PackageManager).optional(),
|
|
469
|
+
allowNoStagedChanges: z.boolean().optional(),
|
|
470
|
+
steps: z.union([z.array(z.string()), z.array(z.tuple([z.string(), preCommitStepOptionsSchema]))])
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
//#endregion
|
|
474
|
+
//#region src/configs/helpers/defineAlexCLineConfig.ts
|
|
475
|
+
const alexCLineConfigSchema = z.object({ preCommit: preCommitConfigSchema });
|
|
476
|
+
function defineAlexCLineConfig(config) {
|
|
477
|
+
return parseZodSchema(alexCLineConfigSchema, config, new DataError(config, "INVALID_ALEX_C_LINE_CONFIG", "The config provided does not match the expected shape."));
|
|
478
|
+
}
|
|
479
|
+
var defineAlexCLineConfig_default = defineAlexCLineConfig;
|
|
480
|
+
|
|
481
|
+
//#endregion
|
|
482
|
+
//#region src/configs/helpers/definePreCommitPrivateConfig.ts
|
|
483
|
+
const preCommitPrivateConfigSchema = z.object({ disableSteps: z.array(z.string()).optional() });
|
|
484
|
+
|
|
485
|
+
//#endregion
|
|
486
|
+
//#region src/configs/types/ConfigFileName.ts
|
|
487
|
+
const ConfigFileName = {
|
|
488
|
+
STANDARD_JAVASCRIPT: "alex-c-line.config.js",
|
|
489
|
+
ES_MODULES_JAVASCRIPT: "alex-c-line.config.mjs",
|
|
490
|
+
COMMON_JS_JAVASCRIPT: "alex-c-line.config.cjs"
|
|
491
|
+
};
|
|
492
|
+
var ConfigFileName_default = ConfigFileName;
|
|
493
|
+
|
|
494
|
+
//#endregion
|
|
495
|
+
//#region src/utility/configLoaders/loadAlexCLineConfig.ts
|
|
496
|
+
const require = createRequire(import.meta.url);
|
|
497
|
+
async function loadAlexCLineConfig(filePath) {
|
|
498
|
+
if (filePath.endsWith(".cjs")) {
|
|
499
|
+
const module$2 = require(filePath);
|
|
500
|
+
return defineAlexCLineConfig_default(module$2.default ?? module$2);
|
|
501
|
+
}
|
|
502
|
+
const module$1 = await import(pathToFileURL(filePath).href);
|
|
503
|
+
return defineAlexCLineConfig_default(module$1.default ?? module$1);
|
|
504
|
+
}
|
|
505
|
+
var loadAlexCLineConfig_default = loadAlexCLineConfig;
|
|
506
|
+
|
|
507
|
+
//#endregion
|
|
508
|
+
//#region src/utility/doesFileExist.ts
|
|
509
|
+
async function doesFileExist(filePath) {
|
|
510
|
+
try {
|
|
511
|
+
await access(filePath);
|
|
512
|
+
return true;
|
|
513
|
+
} catch (error) {
|
|
514
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") return false;
|
|
515
|
+
throw error;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
var doesFileExist_default = doesFileExist;
|
|
519
|
+
|
|
520
|
+
//#endregion
|
|
521
|
+
//#region src/utility/findAlexCLineConfig.ts
|
|
522
|
+
async function findAlexCLineConfig(cwd) {
|
|
523
|
+
const validConfigFileNames = [
|
|
524
|
+
ConfigFileName_default.ES_MODULES_JAVASCRIPT,
|
|
525
|
+
ConfigFileName_default.STANDARD_JAVASCRIPT,
|
|
526
|
+
ConfigFileName_default.COMMON_JS_JAVASCRIPT
|
|
527
|
+
];
|
|
528
|
+
for (const fileName of validConfigFileNames) {
|
|
529
|
+
const fullPath = path.join(cwd, fileName);
|
|
530
|
+
if (await doesFileExist_default(fullPath)) return fullPath;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
var findAlexCLineConfig_default = findAlexCLineConfig;
|
|
534
|
+
|
|
535
|
+
//#endregion
|
|
536
|
+
//#region src/commands/pre-commit-2.ts
|
|
537
|
+
function preCommit2(program$1) {
|
|
538
|
+
program$1.command("pre-commit-2").description("Run the pre-commit scripts specified in the alex-c-line config (v2 experiment).").option("--allow-no-staged-changes", "Run even if nothing is staged").action(async ({ allowNoStagedChanges }) => {
|
|
539
|
+
const configPath = await findAlexCLineConfig_default(process.cwd());
|
|
540
|
+
if (!configPath) program$1.error("Could not find the path to the alex-c-line config file. Does it exist?", {
|
|
541
|
+
exitCode: 1,
|
|
542
|
+
code: "ALEX_C_LINE_CONFIG_NOT_FOUND"
|
|
543
|
+
});
|
|
544
|
+
const { preCommit: preCommitConfig } = await loadAlexCLineConfig_default(configPath);
|
|
545
|
+
if (!preCommitConfig) program$1.error("Could not find the pre-commit config in alex-c-line config.", {
|
|
546
|
+
exitCode: 1,
|
|
547
|
+
code: "PRE_COMMIT_CONFIG_NOT_FOUND"
|
|
548
|
+
});
|
|
549
|
+
const { exitCode: diffExitCode } = await execaNoFail("git", [
|
|
550
|
+
"diff",
|
|
551
|
+
"--cached",
|
|
552
|
+
"--quiet"
|
|
553
|
+
]);
|
|
554
|
+
switch (diffExitCode) {
|
|
555
|
+
case 128: program$1.error("Not currently in a Git repository", {
|
|
556
|
+
exitCode: 1,
|
|
557
|
+
code: "GIT_DIFF_FAILED"
|
|
558
|
+
});
|
|
559
|
+
case 0:
|
|
560
|
+
if (allowNoStagedChanges ?? preCommitConfig.allowNoStagedChanges) break;
|
|
561
|
+
console.info("No staged changes found. Use --allow-no-staged-changes to run anyway.");
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
async function runCommandAndLogToConsole(command, args) {
|
|
565
|
+
const result = await execaNoFail(command, args, { stdio: "inherit" });
|
|
566
|
+
if (result.exitCode !== 0) program$1.error(`Command failed: ${command}${args?.length ? ` ${args.join(" ")}` : ""}`, {
|
|
567
|
+
exitCode: result.exitCode ?? 1,
|
|
568
|
+
code: "PRE_COMMIT_FAILED"
|
|
569
|
+
});
|
|
570
|
+
return result;
|
|
571
|
+
}
|
|
572
|
+
const { packageManager: packagePackageManager, scripts: scripts$1 } = JSON.parse(await readFile(path.join(process.cwd(), "package.json"), "utf8"));
|
|
573
|
+
const rawPackageManager = preCommitConfig.packageManager ?? (typeof packagePackageManager === "string" ? packagePackageManager.split("@")[0] : void 0);
|
|
574
|
+
const packageManager$1 = parseZodSchema(z.enum(PackageManager), rawPackageManager, new DataError(rawPackageManager, "UNSUPPORTED_PACKAGE_MANAGER", `This repository manager is not currently supported. Only the following are supported: ${Object.values(PackageManager).join(", ")}`));
|
|
575
|
+
function getCommandArguments(script, args) {
|
|
576
|
+
if (!(script in (scripts$1 ?? {}))) program$1.error(`Could not find script \`${script}\` in package.json.`, {
|
|
577
|
+
exitCode: 1,
|
|
578
|
+
code: "SCRIPT_NOT_FOUND"
|
|
579
|
+
});
|
|
580
|
+
const result = script === "test" ? [script] : ["run", script];
|
|
581
|
+
if (args) result.push(...args);
|
|
582
|
+
return result;
|
|
583
|
+
}
|
|
584
|
+
for (const step of preCommitConfig.steps) if (typeof step === "string") await runCommandAndLogToConsole(packageManager$1, [...getCommandArguments(step)]);
|
|
585
|
+
else {
|
|
586
|
+
const [script, options] = step;
|
|
587
|
+
await runCommandAndLogToConsole(packageManager$1, [...getCommandArguments(script, options.arguments)]);
|
|
588
|
+
}
|
|
589
|
+
await execaNoFail("git", ["update-index", "--again"]);
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
var pre_commit_2_default = preCommit2;
|
|
593
|
+
|
|
447
594
|
//#endregion
|
|
448
595
|
//#region src/commands/say-hello.ts
|
|
449
596
|
function sayHello(program$1) {
|
|
@@ -510,6 +657,7 @@ function createCommands(program$1) {
|
|
|
510
657
|
gitPostMergeCleanup: git_post_merge_cleanup_default,
|
|
511
658
|
incrementVersion: increment_version_default,
|
|
512
659
|
preCommit: pre_commit_default,
|
|
660
|
+
preCommit2: pre_commit_2_default,
|
|
513
661
|
sayHello: say_hello_default,
|
|
514
662
|
setReleaseStatus: set_release_status_default
|
|
515
663
|
});
|
|
@@ -518,7 +666,7 @@ var commands_default = createCommands;
|
|
|
518
666
|
|
|
519
667
|
//#endregion
|
|
520
668
|
//#region package.json
|
|
521
|
-
var version = "1.
|
|
669
|
+
var version = "1.16.0";
|
|
522
670
|
var package_default = {
|
|
523
671
|
name: "alex-c-line",
|
|
524
672
|
version,
|
|
@@ -530,6 +678,12 @@ var package_default = {
|
|
|
530
678
|
license: "ISC",
|
|
531
679
|
author: "alextheman",
|
|
532
680
|
type: "module",
|
|
681
|
+
exports: { "./configs": {
|
|
682
|
+
"types": "./dist/configs/index.d.ts",
|
|
683
|
+
"require": "./dist/configs/index.cjs",
|
|
684
|
+
"import": "./dist/configs/index.js",
|
|
685
|
+
"default": "./dist/configs/index.js"
|
|
686
|
+
} },
|
|
533
687
|
main: "dist/index.js",
|
|
534
688
|
module: "dist/index.cjs",
|
|
535
689
|
types: "dist/index.d.ts",
|
|
@@ -552,7 +706,7 @@ var package_default = {
|
|
|
552
706
|
"lint-prettier-javascript": "prettier --check \"./**.js\"",
|
|
553
707
|
"lint-prettier-typescript": "prettier --check --parser typescript \"./**/*.ts\"",
|
|
554
708
|
"lint-tsc": "tsc --noEmit",
|
|
555
|
-
"pre-commit": "pnpm run command pre-commit
|
|
709
|
+
"pre-commit": "pnpm run command pre-commit-2",
|
|
556
710
|
"prepare": "husky",
|
|
557
711
|
"prepare-live-eslint-plugin": "pnpm uninstall @alextheman/eslint-plugin && pnpm install --save-dev @alextheman/eslint-plugin",
|
|
558
712
|
"prepare-live-utility": "pnpm uninstall @alextheman/utility && pnpm install @alextheman/utility",
|
|
@@ -567,31 +721,32 @@ var package_default = {
|
|
|
567
721
|
"use-local-utility": "pnpm run prepare-local-utility"
|
|
568
722
|
},
|
|
569
723
|
dependencies: {
|
|
570
|
-
"@alextheman/utility": "^4.3.
|
|
724
|
+
"@alextheman/utility": "^4.3.6",
|
|
571
725
|
"commander": "^14.0.2",
|
|
572
726
|
"dotenv": "^17.2.3",
|
|
573
727
|
"dotenv-stringify": "^3.0.1",
|
|
574
728
|
"execa": "^9.6.1",
|
|
575
|
-
"update-notifier": "^7.3.1"
|
|
729
|
+
"update-notifier": "^7.3.1",
|
|
730
|
+
"zod": "^4.3.4"
|
|
576
731
|
},
|
|
577
732
|
devDependencies: {
|
|
578
|
-
"@alextheman/eslint-plugin": "^5.4.
|
|
733
|
+
"@alextheman/eslint-plugin": "^5.4.2",
|
|
579
734
|
"@types/eslint": "^9.6.1",
|
|
580
735
|
"@types/node": "^25.0.3",
|
|
581
736
|
"@types/update-notifier": "^6.0.8",
|
|
582
737
|
"dotenv-cli": "^11.0.0",
|
|
583
738
|
"eslint": "^9.39.2",
|
|
584
|
-
"eslint-plugin-perfectionist": "^5.
|
|
739
|
+
"eslint-plugin-perfectionist": "^5.2.0",
|
|
585
740
|
"husky": "^9.1.7",
|
|
586
741
|
"prettier": "^3.7.4",
|
|
587
742
|
"tempy": "^3.1.0",
|
|
588
743
|
"ts-node": "^10.9.2",
|
|
589
|
-
"tsdown": "
|
|
744
|
+
"tsdown": "0.19.0-beta.1",
|
|
590
745
|
"typescript": "^5.9.3",
|
|
591
746
|
"vite-tsconfig-paths": "^6.0.3",
|
|
592
747
|
"vitest": "^4.0.16"
|
|
593
748
|
},
|
|
594
|
-
packageManager: "pnpm@10.
|
|
749
|
+
packageManager: "pnpm@10.27.0+sha512.72d699da16b1179c14ba9e64dc71c9a40988cbdc65c264cb0e489db7de917f20dcf4d64d8723625f2969ba52d4b7e2a1170682d9ac2a5dcaeaab732b7e16f04a"
|
|
595
750
|
};
|
|
596
751
|
|
|
597
752
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alex-c-line",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
4
4
|
"description": "Command-line tool with commands to streamline the developer workflow.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,6 +9,14 @@
|
|
|
9
9
|
"license": "ISC",
|
|
10
10
|
"author": "alextheman",
|
|
11
11
|
"type": "module",
|
|
12
|
+
"exports": {
|
|
13
|
+
"./configs": {
|
|
14
|
+
"types": "./dist/configs/index.d.ts",
|
|
15
|
+
"require": "./dist/configs/index.cjs",
|
|
16
|
+
"import": "./dist/configs/index.js",
|
|
17
|
+
"default": "./dist/configs/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
12
20
|
"main": "dist/index.js",
|
|
13
21
|
"module": "dist/index.cjs",
|
|
14
22
|
"types": "dist/index.d.ts",
|
|
@@ -19,26 +27,27 @@
|
|
|
19
27
|
"dist"
|
|
20
28
|
],
|
|
21
29
|
"dependencies": {
|
|
22
|
-
"@alextheman/utility": "^4.3.
|
|
30
|
+
"@alextheman/utility": "^4.3.6",
|
|
23
31
|
"commander": "^14.0.2",
|
|
24
32
|
"dotenv": "^17.2.3",
|
|
25
33
|
"dotenv-stringify": "^3.0.1",
|
|
26
34
|
"execa": "^9.6.1",
|
|
27
|
-
"update-notifier": "^7.3.1"
|
|
35
|
+
"update-notifier": "^7.3.1",
|
|
36
|
+
"zod": "^4.3.4"
|
|
28
37
|
},
|
|
29
38
|
"devDependencies": {
|
|
30
|
-
"@alextheman/eslint-plugin": "^5.4.
|
|
39
|
+
"@alextheman/eslint-plugin": "^5.4.2",
|
|
31
40
|
"@types/eslint": "^9.6.1",
|
|
32
41
|
"@types/node": "^25.0.3",
|
|
33
42
|
"@types/update-notifier": "^6.0.8",
|
|
34
43
|
"dotenv-cli": "^11.0.0",
|
|
35
44
|
"eslint": "^9.39.2",
|
|
36
|
-
"eslint-plugin-perfectionist": "^5.
|
|
45
|
+
"eslint-plugin-perfectionist": "^5.2.0",
|
|
37
46
|
"husky": "^9.1.7",
|
|
38
47
|
"prettier": "^3.7.4",
|
|
39
48
|
"tempy": "^3.1.0",
|
|
40
49
|
"ts-node": "^10.9.2",
|
|
41
|
-
"tsdown": "
|
|
50
|
+
"tsdown": "0.19.0-beta.1",
|
|
42
51
|
"typescript": "^5.9.3",
|
|
43
52
|
"vite-tsconfig-paths": "^6.0.3",
|
|
44
53
|
"vitest": "^4.0.16"
|
|
@@ -60,7 +69,7 @@
|
|
|
60
69
|
"lint-prettier-javascript": "prettier --check \"./**.js\"",
|
|
61
70
|
"lint-prettier-typescript": "prettier --check --parser typescript \"./**/*.ts\"",
|
|
62
71
|
"lint-tsc": "tsc --noEmit",
|
|
63
|
-
"pre-commit": "pnpm run command pre-commit
|
|
72
|
+
"pre-commit": "pnpm run command pre-commit-2",
|
|
64
73
|
"prepare-live-eslint-plugin": "pnpm uninstall @alextheman/eslint-plugin && pnpm install --save-dev @alextheman/eslint-plugin",
|
|
65
74
|
"prepare-live-utility": "pnpm uninstall @alextheman/utility && pnpm install @alextheman/utility",
|
|
66
75
|
"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\"'",
|