alex-c-line 1.15.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 +158 -8
- package/dist/index.js +159 -9
- package/package.json +14 -6
|
@@ -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
|
@@ -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.0";
|
|
559
703
|
var package_default = {
|
|
560
704
|
name: "alex-c-line",
|
|
561
705
|
version,
|
|
@@ -567,6 +711,12 @@ var package_default = {
|
|
|
567
711
|
license: "ISC",
|
|
568
712
|
author: "alextheman",
|
|
569
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
|
+
} },
|
|
570
720
|
main: "dist/index.js",
|
|
571
721
|
module: "dist/index.cjs",
|
|
572
722
|
types: "dist/index.d.ts",
|
|
@@ -589,7 +739,7 @@ var package_default = {
|
|
|
589
739
|
"lint-prettier-javascript": "prettier --check \"./**.js\"",
|
|
590
740
|
"lint-prettier-typescript": "prettier --check --parser typescript \"./**/*.ts\"",
|
|
591
741
|
"lint-tsc": "tsc --noEmit",
|
|
592
|
-
"pre-commit": "pnpm run command pre-commit
|
|
742
|
+
"pre-commit": "pnpm run command pre-commit-2",
|
|
593
743
|
"prepare": "husky",
|
|
594
744
|
"prepare-live-eslint-plugin": "pnpm uninstall @alextheman/eslint-plugin && pnpm install --save-dev @alextheman/eslint-plugin",
|
|
595
745
|
"prepare-live-utility": "pnpm uninstall @alextheman/utility && pnpm install @alextheman/utility",
|
|
@@ -604,7 +754,7 @@ var package_default = {
|
|
|
604
754
|
"use-local-utility": "pnpm run prepare-local-utility"
|
|
605
755
|
},
|
|
606
756
|
dependencies: {
|
|
607
|
-
"@alextheman/utility": "^4.3.
|
|
757
|
+
"@alextheman/utility": "^4.3.6",
|
|
608
758
|
"commander": "^14.0.2",
|
|
609
759
|
"dotenv": "^17.2.3",
|
|
610
760
|
"dotenv-stringify": "^3.0.1",
|
|
@@ -613,23 +763,23 @@ var package_default = {
|
|
|
613
763
|
"zod": "^4.3.4"
|
|
614
764
|
},
|
|
615
765
|
devDependencies: {
|
|
616
|
-
"@alextheman/eslint-plugin": "^5.4.
|
|
766
|
+
"@alextheman/eslint-plugin": "^5.4.2",
|
|
617
767
|
"@types/eslint": "^9.6.1",
|
|
618
768
|
"@types/node": "^25.0.3",
|
|
619
769
|
"@types/update-notifier": "^6.0.8",
|
|
620
770
|
"dotenv-cli": "^11.0.0",
|
|
621
771
|
"eslint": "^9.39.2",
|
|
622
|
-
"eslint-plugin-perfectionist": "^5.
|
|
772
|
+
"eslint-plugin-perfectionist": "^5.2.0",
|
|
623
773
|
"husky": "^9.1.7",
|
|
624
774
|
"prettier": "^3.7.4",
|
|
625
775
|
"tempy": "^3.1.0",
|
|
626
776
|
"ts-node": "^10.9.2",
|
|
627
|
-
"tsdown": "
|
|
777
|
+
"tsdown": "0.19.0-beta.1",
|
|
628
778
|
"typescript": "^5.9.3",
|
|
629
779
|
"vite-tsconfig-paths": "^6.0.3",
|
|
630
780
|
"vitest": "^4.0.16"
|
|
631
781
|
},
|
|
632
|
-
packageManager: "pnpm@10.
|
|
782
|
+
packageManager: "pnpm@10.27.0+sha512.72d699da16b1179c14ba9e64dc71c9a40988cbdc65c264cb0e489db7de917f20dcf4d64d8723625f2969ba52d4b7e2a1170682d9ac2a5dcaeaab732b7e16f04a"
|
|
633
783
|
};
|
|
634
784
|
|
|
635
785
|
//#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.0";
|
|
526
670
|
var package_default = {
|
|
527
671
|
name: "alex-c-line",
|
|
528
672
|
version,
|
|
@@ -534,6 +678,12 @@ var package_default = {
|
|
|
534
678
|
license: "ISC",
|
|
535
679
|
author: "alextheman",
|
|
536
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
|
+
} },
|
|
537
687
|
main: "dist/index.js",
|
|
538
688
|
module: "dist/index.cjs",
|
|
539
689
|
types: "dist/index.d.ts",
|
|
@@ -556,7 +706,7 @@ var package_default = {
|
|
|
556
706
|
"lint-prettier-javascript": "prettier --check \"./**.js\"",
|
|
557
707
|
"lint-prettier-typescript": "prettier --check --parser typescript \"./**/*.ts\"",
|
|
558
708
|
"lint-tsc": "tsc --noEmit",
|
|
559
|
-
"pre-commit": "pnpm run command pre-commit
|
|
709
|
+
"pre-commit": "pnpm run command pre-commit-2",
|
|
560
710
|
"prepare": "husky",
|
|
561
711
|
"prepare-live-eslint-plugin": "pnpm uninstall @alextheman/eslint-plugin && pnpm install --save-dev @alextheman/eslint-plugin",
|
|
562
712
|
"prepare-live-utility": "pnpm uninstall @alextheman/utility && pnpm install @alextheman/utility",
|
|
@@ -571,7 +721,7 @@ var package_default = {
|
|
|
571
721
|
"use-local-utility": "pnpm run prepare-local-utility"
|
|
572
722
|
},
|
|
573
723
|
dependencies: {
|
|
574
|
-
"@alextheman/utility": "^4.3.
|
|
724
|
+
"@alextheman/utility": "^4.3.6",
|
|
575
725
|
"commander": "^14.0.2",
|
|
576
726
|
"dotenv": "^17.2.3",
|
|
577
727
|
"dotenv-stringify": "^3.0.1",
|
|
@@ -580,23 +730,23 @@ var package_default = {
|
|
|
580
730
|
"zod": "^4.3.4"
|
|
581
731
|
},
|
|
582
732
|
devDependencies: {
|
|
583
|
-
"@alextheman/eslint-plugin": "^5.4.
|
|
733
|
+
"@alextheman/eslint-plugin": "^5.4.2",
|
|
584
734
|
"@types/eslint": "^9.6.1",
|
|
585
735
|
"@types/node": "^25.0.3",
|
|
586
736
|
"@types/update-notifier": "^6.0.8",
|
|
587
737
|
"dotenv-cli": "^11.0.0",
|
|
588
738
|
"eslint": "^9.39.2",
|
|
589
|
-
"eslint-plugin-perfectionist": "^5.
|
|
739
|
+
"eslint-plugin-perfectionist": "^5.2.0",
|
|
590
740
|
"husky": "^9.1.7",
|
|
591
741
|
"prettier": "^3.7.4",
|
|
592
742
|
"tempy": "^3.1.0",
|
|
593
743
|
"ts-node": "^10.9.2",
|
|
594
|
-
"tsdown": "
|
|
744
|
+
"tsdown": "0.19.0-beta.1",
|
|
595
745
|
"typescript": "^5.9.3",
|
|
596
746
|
"vite-tsconfig-paths": "^6.0.3",
|
|
597
747
|
"vitest": "^4.0.16"
|
|
598
748
|
},
|
|
599
|
-
packageManager: "pnpm@10.
|
|
749
|
+
packageManager: "pnpm@10.27.0+sha512.72d699da16b1179c14ba9e64dc71c9a40988cbdc65c264cb0e489db7de917f20dcf4d64d8723625f2969ba52d4b7e2a1170682d9ac2a5dcaeaab732b7e16f04a"
|
|
600
750
|
};
|
|
601
751
|
|
|
602
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,7 +27,7 @@
|
|
|
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",
|
|
@@ -28,18 +36,18 @@
|
|
|
28
36
|
"zod": "^4.3.4"
|
|
29
37
|
},
|
|
30
38
|
"devDependencies": {
|
|
31
|
-
"@alextheman/eslint-plugin": "^5.4.
|
|
39
|
+
"@alextheman/eslint-plugin": "^5.4.2",
|
|
32
40
|
"@types/eslint": "^9.6.1",
|
|
33
41
|
"@types/node": "^25.0.3",
|
|
34
42
|
"@types/update-notifier": "^6.0.8",
|
|
35
43
|
"dotenv-cli": "^11.0.0",
|
|
36
44
|
"eslint": "^9.39.2",
|
|
37
|
-
"eslint-plugin-perfectionist": "^5.
|
|
45
|
+
"eslint-plugin-perfectionist": "^5.2.0",
|
|
38
46
|
"husky": "^9.1.7",
|
|
39
47
|
"prettier": "^3.7.4",
|
|
40
48
|
"tempy": "^3.1.0",
|
|
41
49
|
"ts-node": "^10.9.2",
|
|
42
|
-
"tsdown": "
|
|
50
|
+
"tsdown": "0.19.0-beta.1",
|
|
43
51
|
"typescript": "^5.9.3",
|
|
44
52
|
"vite-tsconfig-paths": "^6.0.3",
|
|
45
53
|
"vitest": "^4.0.16"
|
|
@@ -61,7 +69,7 @@
|
|
|
61
69
|
"lint-prettier-javascript": "prettier --check \"./**.js\"",
|
|
62
70
|
"lint-prettier-typescript": "prettier --check --parser typescript \"./**/*.ts\"",
|
|
63
71
|
"lint-tsc": "tsc --noEmit",
|
|
64
|
-
"pre-commit": "pnpm run command pre-commit
|
|
72
|
+
"pre-commit": "pnpm run command pre-commit-2",
|
|
65
73
|
"prepare-live-eslint-plugin": "pnpm uninstall @alextheman/eslint-plugin && pnpm install --save-dev @alextheman/eslint-plugin",
|
|
66
74
|
"prepare-live-utility": "pnpm uninstall @alextheman/utility && pnpm install @alextheman/utility",
|
|
67
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\"'",
|