alex-c-line 1.15.0 → 1.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/configs/index.cjs +80 -0
- package/dist/configs/index.d.cts +50 -0
- package/dist/configs/index.d.ts +51 -0
- package/dist/configs/index.js +49 -0
- package/dist/configs/internal/index.cjs +28 -0
- package/dist/configs/internal/index.d.cts +67 -0
- package/dist/configs/internal/index.d.ts +67 -0
- package/dist/configs/internal/index.js +26 -0
- package/dist/index.cjs +166 -8
- package/dist/index.js +167 -9
- package/package.json +20 -6
|
@@ -0,0 +1,80 @@
|
|
|
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/types/PreCommitConfig.ts
|
|
33
|
+
const PackageManager = {
|
|
34
|
+
NPM: "npm",
|
|
35
|
+
PNPM: "pnpm"
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/configs/helpers/definePreCommitConfig.ts
|
|
40
|
+
const preCommitStepOptionsSchema = zod.default.object({ arguments: zod.default.array(zod.default.string()).optional() });
|
|
41
|
+
const preCommitConfigSchema = zod.default.object({
|
|
42
|
+
packageManager: zod.default.enum(PackageManager).optional(),
|
|
43
|
+
allowNoStagedChanges: zod.default.boolean().optional(),
|
|
44
|
+
steps: zod.default.union([zod.default.array(zod.default.string()), zod.default.array(zod.default.tuple([zod.default.string(), preCommitStepOptionsSchema]))])
|
|
45
|
+
});
|
|
46
|
+
function definePreCommitConfig(config) {
|
|
47
|
+
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."));
|
|
48
|
+
}
|
|
49
|
+
var definePreCommitConfig_default = definePreCommitConfig;
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/configs/helpers/defineAlexCLineConfig.ts
|
|
53
|
+
const alexCLineConfigSchema = zod.default.object({ preCommit: preCommitConfigSchema });
|
|
54
|
+
function defineAlexCLineConfig(config) {
|
|
55
|
+
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
|
+
}
|
|
57
|
+
var defineAlexCLineConfig_default = defineAlexCLineConfig;
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/configs/helpers/definePreCommitPrivateConfig.ts
|
|
61
|
+
const preCommitPrivateConfigSchema = zod.default.object({ disableSteps: zod.default.array(zod.default.string()).optional() });
|
|
62
|
+
function definePreCommitPrivateConfig(config) {
|
|
63
|
+
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."));
|
|
64
|
+
}
|
|
65
|
+
var definePreCommitPrivateConfig_default = definePreCommitPrivateConfig;
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/configs/types/ConfigFileName.ts
|
|
69
|
+
const ConfigFileName = {
|
|
70
|
+
STANDARD_JAVASCRIPT: "alex-c-line.config.js",
|
|
71
|
+
ES_MODULES_JAVASCRIPT: "alex-c-line.config.mjs",
|
|
72
|
+
COMMON_JS_JAVASCRIPT: "alex-c-line.config.cjs"
|
|
73
|
+
};
|
|
74
|
+
var ConfigFileName_default = ConfigFileName;
|
|
75
|
+
|
|
76
|
+
//#endregion
|
|
77
|
+
exports.ConfigFileName = ConfigFileName_default;
|
|
78
|
+
exports.defineAlexCLineConfig = defineAlexCLineConfig_default;
|
|
79
|
+
exports.definePreCommitConfig = definePreCommitConfig_default;
|
|
80
|
+
exports.definePreCommitPrivateConfig = definePreCommitPrivateConfig_default;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { CreateEnumType } from "@alextheman/utility";
|
|
2
|
+
|
|
3
|
+
//#region src/configs/types/PreCommitConfig.d.ts
|
|
4
|
+
declare const PackageManager: {
|
|
5
|
+
readonly NPM: "npm";
|
|
6
|
+
readonly PNPM: "pnpm";
|
|
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 src/configs/helpers/defineAlexCLineConfig.d.ts
|
|
28
|
+
declare function defineAlexCLineConfig<ScriptName extends string = string>(config: AlexCLineConfig<ScriptName>): AlexCLineConfig;
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/configs/helpers/definePreCommitConfig.d.ts
|
|
31
|
+
declare function definePreCommitConfig<ScriptName extends string = string>(config: PreCommitConfig<ScriptName>): PreCommitConfig;
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/configs/types/PreCommitPrivateConfig.d.ts
|
|
34
|
+
interface PreCommitPrivateConfig<ScriptName extends string = string> {
|
|
35
|
+
/** List of script names to skip */
|
|
36
|
+
disableSteps?: ScriptName[];
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/configs/helpers/definePreCommitPrivateConfig.d.ts
|
|
40
|
+
declare function definePreCommitPrivateConfig<ScriptName extends string = string>(config: PreCommitPrivateConfig<ScriptName>): PreCommitPrivateConfig;
|
|
41
|
+
//#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 };
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
readonly NPM: "npm";
|
|
7
|
+
readonly PNPM: "pnpm";
|
|
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 src/configs/helpers/defineAlexCLineConfig.d.ts
|
|
29
|
+
declare function defineAlexCLineConfig<ScriptName extends string = string>(config: AlexCLineConfig<ScriptName>): AlexCLineConfig;
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/configs/helpers/definePreCommitConfig.d.ts
|
|
32
|
+
declare function definePreCommitConfig<ScriptName extends string = string>(config: PreCommitConfig<ScriptName>): PreCommitConfig;
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/configs/types/PreCommitPrivateConfig.d.ts
|
|
35
|
+
interface PreCommitPrivateConfig<ScriptName extends string = string> {
|
|
36
|
+
/** List of script names to skip */
|
|
37
|
+
disableSteps?: ScriptName[];
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/configs/helpers/definePreCommitPrivateConfig.d.ts
|
|
41
|
+
declare function definePreCommitPrivateConfig<ScriptName extends string = string>(config: PreCommitPrivateConfig<ScriptName>): PreCommitPrivateConfig;
|
|
42
|
+
//#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 };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { DataError, parseZodSchema } from "@alextheman/utility";
|
|
2
|
+
import z from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/configs/types/PreCommitConfig.ts
|
|
5
|
+
const PackageManager = {
|
|
6
|
+
NPM: "npm",
|
|
7
|
+
PNPM: "pnpm"
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/configs/helpers/definePreCommitConfig.ts
|
|
12
|
+
const preCommitStepOptionsSchema = z.object({ arguments: z.array(z.string()).optional() });
|
|
13
|
+
const preCommitConfigSchema = z.object({
|
|
14
|
+
packageManager: z.enum(PackageManager).optional(),
|
|
15
|
+
allowNoStagedChanges: z.boolean().optional(),
|
|
16
|
+
steps: z.union([z.array(z.string()), z.array(z.tuple([z.string(), preCommitStepOptionsSchema]))])
|
|
17
|
+
});
|
|
18
|
+
function definePreCommitConfig(config) {
|
|
19
|
+
return parseZodSchema(preCommitConfigSchema, config, new DataError(config, "INVALID_PRE_COMMIT_CONFIG", "The config provided does not match the expected shape."));
|
|
20
|
+
}
|
|
21
|
+
var definePreCommitConfig_default = definePreCommitConfig;
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/configs/helpers/defineAlexCLineConfig.ts
|
|
25
|
+
const alexCLineConfigSchema = z.object({ preCommit: preCommitConfigSchema });
|
|
26
|
+
function defineAlexCLineConfig(config) {
|
|
27
|
+
return parseZodSchema(alexCLineConfigSchema, config, new DataError(config, "INVALID_ALEX_C_LINE_CONFIG", "The config provided does not match the expected shape."));
|
|
28
|
+
}
|
|
29
|
+
var defineAlexCLineConfig_default = defineAlexCLineConfig;
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/configs/helpers/definePreCommitPrivateConfig.ts
|
|
33
|
+
const preCommitPrivateConfigSchema = z.object({ disableSteps: z.array(z.string()).optional() });
|
|
34
|
+
function definePreCommitPrivateConfig(config) {
|
|
35
|
+
return parseZodSchema(preCommitPrivateConfigSchema, config, new DataError(config, "INVALID_PRE_COMMIT_PRIVATE_CONFIG", "The config provided does not match the expected shape."));
|
|
36
|
+
}
|
|
37
|
+
var definePreCommitPrivateConfig_default = definePreCommitPrivateConfig;
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/configs/types/ConfigFileName.ts
|
|
41
|
+
const ConfigFileName = {
|
|
42
|
+
STANDARD_JAVASCRIPT: "alex-c-line.config.js",
|
|
43
|
+
ES_MODULES_JAVASCRIPT: "alex-c-line.config.mjs",
|
|
44
|
+
COMMON_JS_JAVASCRIPT: "alex-c-line.config.cjs"
|
|
45
|
+
};
|
|
46
|
+
var ConfigFileName_default = ConfigFileName;
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
export { ConfigFileName_default as ConfigFileName, defineAlexCLineConfig_default as defineAlexCLineConfig, definePreCommitConfig_default as definePreCommitConfig, definePreCommitPrivateConfig_default as definePreCommitPrivateConfig };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/configs/internal/alexCLineConfig.ts
|
|
3
|
+
const alexCLineConfig = { preCommit: {
|
|
4
|
+
packageManager: "pnpm",
|
|
5
|
+
steps: [
|
|
6
|
+
"format",
|
|
7
|
+
"lint",
|
|
8
|
+
"test"
|
|
9
|
+
]
|
|
10
|
+
} };
|
|
11
|
+
var alexCLineConfig_default = alexCLineConfig;
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/configs/internal/packageConfig.ts
|
|
15
|
+
const packageConfig = { preCommit: {
|
|
16
|
+
packageManager: "pnpm",
|
|
17
|
+
steps: [
|
|
18
|
+
"build",
|
|
19
|
+
"format",
|
|
20
|
+
"lint",
|
|
21
|
+
"test"
|
|
22
|
+
]
|
|
23
|
+
} };
|
|
24
|
+
var packageConfig_default = packageConfig;
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
exports.alexCLineConfig = alexCLineConfig_default;
|
|
28
|
+
exports.packageConfig = packageConfig_default;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { CreateEnumType } from "@alextheman/utility";
|
|
2
|
+
|
|
3
|
+
//#region src/configs/types/PreCommitConfig.d.ts
|
|
4
|
+
declare const PackageManager: {
|
|
5
|
+
readonly NPM: "npm";
|
|
6
|
+
readonly PNPM: "pnpm";
|
|
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/internal/alexCLineConfig.d.ts
|
|
62
|
+
declare const alexCLineConfig: AlexCLineConfig<keyof typeof scripts>;
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/configs/internal/packageConfig.d.ts
|
|
65
|
+
declare const packageConfig: AlexCLineConfig<"build" | "format" | "lint" | "test">;
|
|
66
|
+
//#endregion
|
|
67
|
+
export { alexCLineConfig, packageConfig };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { CreateEnumType } from "@alextheman/utility";
|
|
2
|
+
|
|
3
|
+
//#region src/configs/types/PreCommitConfig.d.ts
|
|
4
|
+
declare const PackageManager: {
|
|
5
|
+
readonly NPM: "npm";
|
|
6
|
+
readonly PNPM: "pnpm";
|
|
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/internal/alexCLineConfig.d.ts
|
|
62
|
+
declare const alexCLineConfig: AlexCLineConfig<keyof typeof scripts>;
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/configs/internal/packageConfig.d.ts
|
|
65
|
+
declare const packageConfig: AlexCLineConfig<"build" | "format" | "lint" | "test">;
|
|
66
|
+
//#endregion
|
|
67
|
+
export { alexCLineConfig, packageConfig };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/configs/internal/alexCLineConfig.ts
|
|
2
|
+
const alexCLineConfig = { preCommit: {
|
|
3
|
+
packageManager: "pnpm",
|
|
4
|
+
steps: [
|
|
5
|
+
"format",
|
|
6
|
+
"lint",
|
|
7
|
+
"test"
|
|
8
|
+
]
|
|
9
|
+
} };
|
|
10
|
+
var alexCLineConfig_default = alexCLineConfig;
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/configs/internal/packageConfig.ts
|
|
14
|
+
const packageConfig = { preCommit: {
|
|
15
|
+
packageManager: "pnpm",
|
|
16
|
+
steps: [
|
|
17
|
+
"build",
|
|
18
|
+
"format",
|
|
19
|
+
"lint",
|
|
20
|
+
"test"
|
|
21
|
+
]
|
|
22
|
+
} };
|
|
23
|
+
var packageConfig_default = packageConfig;
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { alexCLineConfig_default as alexCLineConfig, packageConfig_default as packageConfig };
|
package/dist/index.cjs
CHANGED
|
@@ -43,6 +43,8 @@ let node_os = require("node:os");
|
|
|
43
43
|
node_os = __toESM(node_os);
|
|
44
44
|
let zod = require("zod");
|
|
45
45
|
zod = __toESM(zod);
|
|
46
|
+
let node_module = require("node:module");
|
|
47
|
+
let node_url = require("node:url");
|
|
46
48
|
|
|
47
49
|
//#region src/commands/check-for-file-dependencies.ts
|
|
48
50
|
function findFileDependencies(dependencies$1) {
|
|
@@ -444,8 +446,12 @@ var increment_version_default = incrementVersion;
|
|
|
444
446
|
|
|
445
447
|
//#endregion
|
|
446
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.";
|
|
447
450
|
function preCommit(program$1) {
|
|
448
|
-
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);
|
|
449
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;
|
|
450
456
|
const { exitCode: diffExitCode } = await execaNoFail("git", [
|
|
451
457
|
"diff",
|
|
@@ -481,6 +487,143 @@ function preCommit(program$1) {
|
|
|
481
487
|
}
|
|
482
488
|
var pre_commit_default = preCommit;
|
|
483
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
|
+
|
|
484
627
|
//#endregion
|
|
485
628
|
//#region src/commands/say-hello.ts
|
|
486
629
|
function sayHello(program$1) {
|
|
@@ -547,6 +690,7 @@ function createCommands(program$1) {
|
|
|
547
690
|
gitPostMergeCleanup: git_post_merge_cleanup_default,
|
|
548
691
|
incrementVersion: increment_version_default,
|
|
549
692
|
preCommit: pre_commit_default,
|
|
693
|
+
preCommit2: pre_commit_2_default,
|
|
550
694
|
sayHello: say_hello_default,
|
|
551
695
|
setReleaseStatus: set_release_status_default
|
|
552
696
|
});
|
|
@@ -555,7 +699,7 @@ var commands_default = createCommands;
|
|
|
555
699
|
|
|
556
700
|
//#endregion
|
|
557
701
|
//#region package.json
|
|
558
|
-
var version = "1.
|
|
702
|
+
var version = "1.16.1";
|
|
559
703
|
var package_default = {
|
|
560
704
|
name: "alex-c-line",
|
|
561
705
|
version,
|
|
@@ -567,6 +711,20 @@ var package_default = {
|
|
|
567
711
|
license: "ISC",
|
|
568
712
|
author: "alextheman",
|
|
569
713
|
type: "module",
|
|
714
|
+
exports: {
|
|
715
|
+
"./configs": {
|
|
716
|
+
"types": "./dist/configs/index.d.ts",
|
|
717
|
+
"require": "./dist/configs/index.cjs",
|
|
718
|
+
"import": "./dist/configs/index.js",
|
|
719
|
+
"default": "./dist/configs/index.js"
|
|
720
|
+
},
|
|
721
|
+
"./configs/internal": {
|
|
722
|
+
"types": "./dist/configs/internal/index.d.ts",
|
|
723
|
+
"require": "./dist/configs/internal/index.cjs",
|
|
724
|
+
"import": "./dist/configs/internal/index.js",
|
|
725
|
+
"default": "./dist/configs/internal/index.js"
|
|
726
|
+
}
|
|
727
|
+
},
|
|
570
728
|
main: "dist/index.js",
|
|
571
729
|
module: "dist/index.cjs",
|
|
572
730
|
types: "dist/index.d.ts",
|
|
@@ -589,7 +747,7 @@ var package_default = {
|
|
|
589
747
|
"lint-prettier-javascript": "prettier --check \"./**.js\"",
|
|
590
748
|
"lint-prettier-typescript": "prettier --check --parser typescript \"./**/*.ts\"",
|
|
591
749
|
"lint-tsc": "tsc --noEmit",
|
|
592
|
-
"pre-commit": "pnpm run command pre-commit
|
|
750
|
+
"pre-commit": "pnpm run command pre-commit-2",
|
|
593
751
|
"prepare": "husky",
|
|
594
752
|
"prepare-live-eslint-plugin": "pnpm uninstall @alextheman/eslint-plugin && pnpm install --save-dev @alextheman/eslint-plugin",
|
|
595
753
|
"prepare-live-utility": "pnpm uninstall @alextheman/utility && pnpm install @alextheman/utility",
|
|
@@ -604,7 +762,7 @@ var package_default = {
|
|
|
604
762
|
"use-local-utility": "pnpm run prepare-local-utility"
|
|
605
763
|
},
|
|
606
764
|
dependencies: {
|
|
607
|
-
"@alextheman/utility": "^4.3.
|
|
765
|
+
"@alextheman/utility": "^4.3.6",
|
|
608
766
|
"commander": "^14.0.2",
|
|
609
767
|
"dotenv": "^17.2.3",
|
|
610
768
|
"dotenv-stringify": "^3.0.1",
|
|
@@ -613,23 +771,23 @@ var package_default = {
|
|
|
613
771
|
"zod": "^4.3.4"
|
|
614
772
|
},
|
|
615
773
|
devDependencies: {
|
|
616
|
-
"@alextheman/eslint-plugin": "^5.4.
|
|
774
|
+
"@alextheman/eslint-plugin": "^5.4.2",
|
|
617
775
|
"@types/eslint": "^9.6.1",
|
|
618
776
|
"@types/node": "^25.0.3",
|
|
619
777
|
"@types/update-notifier": "^6.0.8",
|
|
620
778
|
"dotenv-cli": "^11.0.0",
|
|
621
779
|
"eslint": "^9.39.2",
|
|
622
|
-
"eslint-plugin-perfectionist": "^5.
|
|
780
|
+
"eslint-plugin-perfectionist": "^5.2.0",
|
|
623
781
|
"husky": "^9.1.7",
|
|
624
782
|
"prettier": "^3.7.4",
|
|
625
783
|
"tempy": "^3.1.0",
|
|
626
784
|
"ts-node": "^10.9.2",
|
|
627
|
-
"tsdown": "
|
|
785
|
+
"tsdown": "0.19.0-beta.1",
|
|
628
786
|
"typescript": "^5.9.3",
|
|
629
787
|
"vite-tsconfig-paths": "^6.0.3",
|
|
630
788
|
"vitest": "^4.0.16"
|
|
631
789
|
},
|
|
632
|
-
packageManager: "pnpm@10.
|
|
790
|
+
packageManager: "pnpm@10.27.0+sha512.72d699da16b1179c14ba9e64dc71c9a40988cbdc65c264cb0e489db7de917f20dcf4d64d8723625f2969ba52d4b7e2a1170682d9ac2a5dcaeaab732b7e16f04a"
|
|
633
791
|
};
|
|
634
792
|
|
|
635
793
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
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
8
|
import { DataError, VersionNumber, kebabToCamel, normaliseIndents, parseVersionType, parseZodSchema } from "@alextheman/utility";
|
|
@@ -10,6 +11,7 @@ import dotenv from "dotenv";
|
|
|
10
11
|
import dotenvStringify from "dotenv-stringify";
|
|
11
12
|
import os from "node:os";
|
|
12
13
|
import z from "zod";
|
|
14
|
+
import { pathToFileURL } from "node:url";
|
|
13
15
|
|
|
14
16
|
//#region src/commands/check-for-file-dependencies.ts
|
|
15
17
|
function findFileDependencies(dependencies$1) {
|
|
@@ -411,8 +413,12 @@ var increment_version_default = incrementVersion;
|
|
|
411
413
|
|
|
412
414
|
//#endregion
|
|
413
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.";
|
|
414
417
|
function preCommit(program$1) {
|
|
415
|
-
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);
|
|
416
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;
|
|
417
423
|
const { exitCode: diffExitCode } = await execaNoFail("git", [
|
|
418
424
|
"diff",
|
|
@@ -448,6 +454,143 @@ function preCommit(program$1) {
|
|
|
448
454
|
}
|
|
449
455
|
var pre_commit_default = preCommit;
|
|
450
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
|
+
|
|
451
594
|
//#endregion
|
|
452
595
|
//#region src/commands/say-hello.ts
|
|
453
596
|
function sayHello(program$1) {
|
|
@@ -514,6 +657,7 @@ function createCommands(program$1) {
|
|
|
514
657
|
gitPostMergeCleanup: git_post_merge_cleanup_default,
|
|
515
658
|
incrementVersion: increment_version_default,
|
|
516
659
|
preCommit: pre_commit_default,
|
|
660
|
+
preCommit2: pre_commit_2_default,
|
|
517
661
|
sayHello: say_hello_default,
|
|
518
662
|
setReleaseStatus: set_release_status_default
|
|
519
663
|
});
|
|
@@ -522,7 +666,7 @@ var commands_default = createCommands;
|
|
|
522
666
|
|
|
523
667
|
//#endregion
|
|
524
668
|
//#region package.json
|
|
525
|
-
var version = "1.
|
|
669
|
+
var version = "1.16.1";
|
|
526
670
|
var package_default = {
|
|
527
671
|
name: "alex-c-line",
|
|
528
672
|
version,
|
|
@@ -534,6 +678,20 @@ var package_default = {
|
|
|
534
678
|
license: "ISC",
|
|
535
679
|
author: "alextheman",
|
|
536
680
|
type: "module",
|
|
681
|
+
exports: {
|
|
682
|
+
"./configs": {
|
|
683
|
+
"types": "./dist/configs/index.d.ts",
|
|
684
|
+
"require": "./dist/configs/index.cjs",
|
|
685
|
+
"import": "./dist/configs/index.js",
|
|
686
|
+
"default": "./dist/configs/index.js"
|
|
687
|
+
},
|
|
688
|
+
"./configs/internal": {
|
|
689
|
+
"types": "./dist/configs/internal/index.d.ts",
|
|
690
|
+
"require": "./dist/configs/internal/index.cjs",
|
|
691
|
+
"import": "./dist/configs/internal/index.js",
|
|
692
|
+
"default": "./dist/configs/internal/index.js"
|
|
693
|
+
}
|
|
694
|
+
},
|
|
537
695
|
main: "dist/index.js",
|
|
538
696
|
module: "dist/index.cjs",
|
|
539
697
|
types: "dist/index.d.ts",
|
|
@@ -556,7 +714,7 @@ var package_default = {
|
|
|
556
714
|
"lint-prettier-javascript": "prettier --check \"./**.js\"",
|
|
557
715
|
"lint-prettier-typescript": "prettier --check --parser typescript \"./**/*.ts\"",
|
|
558
716
|
"lint-tsc": "tsc --noEmit",
|
|
559
|
-
"pre-commit": "pnpm run command pre-commit
|
|
717
|
+
"pre-commit": "pnpm run command pre-commit-2",
|
|
560
718
|
"prepare": "husky",
|
|
561
719
|
"prepare-live-eslint-plugin": "pnpm uninstall @alextheman/eslint-plugin && pnpm install --save-dev @alextheman/eslint-plugin",
|
|
562
720
|
"prepare-live-utility": "pnpm uninstall @alextheman/utility && pnpm install @alextheman/utility",
|
|
@@ -571,7 +729,7 @@ var package_default = {
|
|
|
571
729
|
"use-local-utility": "pnpm run prepare-local-utility"
|
|
572
730
|
},
|
|
573
731
|
dependencies: {
|
|
574
|
-
"@alextheman/utility": "^4.3.
|
|
732
|
+
"@alextheman/utility": "^4.3.6",
|
|
575
733
|
"commander": "^14.0.2",
|
|
576
734
|
"dotenv": "^17.2.3",
|
|
577
735
|
"dotenv-stringify": "^3.0.1",
|
|
@@ -580,23 +738,23 @@ var package_default = {
|
|
|
580
738
|
"zod": "^4.3.4"
|
|
581
739
|
},
|
|
582
740
|
devDependencies: {
|
|
583
|
-
"@alextheman/eslint-plugin": "^5.4.
|
|
741
|
+
"@alextheman/eslint-plugin": "^5.4.2",
|
|
584
742
|
"@types/eslint": "^9.6.1",
|
|
585
743
|
"@types/node": "^25.0.3",
|
|
586
744
|
"@types/update-notifier": "^6.0.8",
|
|
587
745
|
"dotenv-cli": "^11.0.0",
|
|
588
746
|
"eslint": "^9.39.2",
|
|
589
|
-
"eslint-plugin-perfectionist": "^5.
|
|
747
|
+
"eslint-plugin-perfectionist": "^5.2.0",
|
|
590
748
|
"husky": "^9.1.7",
|
|
591
749
|
"prettier": "^3.7.4",
|
|
592
750
|
"tempy": "^3.1.0",
|
|
593
751
|
"ts-node": "^10.9.2",
|
|
594
|
-
"tsdown": "
|
|
752
|
+
"tsdown": "0.19.0-beta.1",
|
|
595
753
|
"typescript": "^5.9.3",
|
|
596
754
|
"vite-tsconfig-paths": "^6.0.3",
|
|
597
755
|
"vitest": "^4.0.16"
|
|
598
756
|
},
|
|
599
|
-
packageManager: "pnpm@10.
|
|
757
|
+
packageManager: "pnpm@10.27.0+sha512.72d699da16b1179c14ba9e64dc71c9a40988cbdc65c264cb0e489db7de917f20dcf4d64d8723625f2969ba52d4b7e2a1170682d9ac2a5dcaeaab732b7e16f04a"
|
|
600
758
|
};
|
|
601
759
|
|
|
602
760
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alex-c-line",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.1",
|
|
4
4
|
"description": "Command-line tool with commands to streamline the developer workflow.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,6 +9,20 @@
|
|
|
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
|
+
"./configs/internal": {
|
|
20
|
+
"types": "./dist/configs/internal/index.d.ts",
|
|
21
|
+
"require": "./dist/configs/internal/index.cjs",
|
|
22
|
+
"import": "./dist/configs/internal/index.js",
|
|
23
|
+
"default": "./dist/configs/internal/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
12
26
|
"main": "dist/index.js",
|
|
13
27
|
"module": "dist/index.cjs",
|
|
14
28
|
"types": "dist/index.d.ts",
|
|
@@ -19,7 +33,7 @@
|
|
|
19
33
|
"dist"
|
|
20
34
|
],
|
|
21
35
|
"dependencies": {
|
|
22
|
-
"@alextheman/utility": "^4.3.
|
|
36
|
+
"@alextheman/utility": "^4.3.6",
|
|
23
37
|
"commander": "^14.0.2",
|
|
24
38
|
"dotenv": "^17.2.3",
|
|
25
39
|
"dotenv-stringify": "^3.0.1",
|
|
@@ -28,18 +42,18 @@
|
|
|
28
42
|
"zod": "^4.3.4"
|
|
29
43
|
},
|
|
30
44
|
"devDependencies": {
|
|
31
|
-
"@alextheman/eslint-plugin": "^5.4.
|
|
45
|
+
"@alextheman/eslint-plugin": "^5.4.2",
|
|
32
46
|
"@types/eslint": "^9.6.1",
|
|
33
47
|
"@types/node": "^25.0.3",
|
|
34
48
|
"@types/update-notifier": "^6.0.8",
|
|
35
49
|
"dotenv-cli": "^11.0.0",
|
|
36
50
|
"eslint": "^9.39.2",
|
|
37
|
-
"eslint-plugin-perfectionist": "^5.
|
|
51
|
+
"eslint-plugin-perfectionist": "^5.2.0",
|
|
38
52
|
"husky": "^9.1.7",
|
|
39
53
|
"prettier": "^3.7.4",
|
|
40
54
|
"tempy": "^3.1.0",
|
|
41
55
|
"ts-node": "^10.9.2",
|
|
42
|
-
"tsdown": "
|
|
56
|
+
"tsdown": "0.19.0-beta.1",
|
|
43
57
|
"typescript": "^5.9.3",
|
|
44
58
|
"vite-tsconfig-paths": "^6.0.3",
|
|
45
59
|
"vitest": "^4.0.16"
|
|
@@ -61,7 +75,7 @@
|
|
|
61
75
|
"lint-prettier-javascript": "prettier --check \"./**.js\"",
|
|
62
76
|
"lint-prettier-typescript": "prettier --check --parser typescript \"./**/*.ts\"",
|
|
63
77
|
"lint-tsc": "tsc --noEmit",
|
|
64
|
-
"pre-commit": "pnpm run command pre-commit
|
|
78
|
+
"pre-commit": "pnpm run command pre-commit-2",
|
|
65
79
|
"prepare-live-eslint-plugin": "pnpm uninstall @alextheman/eslint-plugin && pnpm install --save-dev @alextheman/eslint-plugin",
|
|
66
80
|
"prepare-live-utility": "pnpm uninstall @alextheman/utility && pnpm install @alextheman/utility",
|
|
67
81
|
"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\"'",
|