@oxiul/configs 0.3.2 → 0.4.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/README.md +51 -0
- package/dist/bin.d.mts +1 -0
- package/dist/bin.mjs +99 -0
- package/dist/generate-BGCgStVl.mjs +103 -0
- package/dist/hook/install.mjs +1 -1
- package/dist/hook/pre-commit.mjs +2 -8
- package/dist/index-DqMadVlO.d.mts +44 -0
- package/dist/index.d.mts +18 -2
- package/dist/index.mjs +18 -11
- package/dist/parse-DnOcFJT0.mjs +14 -0
- package/dist/schema-BuCl21uv.mjs +23 -0
- package/dist/workflows/index.d.mts +2 -0
- package/dist/workflows/index.mjs +1 -0
- package/package.json +23 -5
- package/dist/schema-DM8wm8HH.mjs +0 -5
package/README.md
CHANGED
|
@@ -8,6 +8,57 @@ A shared config for oxlint
|
|
|
8
8
|
|
|
9
9
|
A shared config for oxfmt
|
|
10
10
|
|
|
11
|
+
## GitHub Actions
|
|
12
|
+
|
|
13
|
+
Configure generation in `oxiul.config.ts`:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import type { Config } from "@oxiul/configs";
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
workflows: {
|
|
20
|
+
workflows: [], // Optional { name, workflow } objects for project workflows.
|
|
21
|
+
jobs: {}, // Optional { jobName: <job> } object with CI jobs descriptions.
|
|
22
|
+
},
|
|
23
|
+
} satisfies Config;
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Package.json verification
|
|
27
|
+
|
|
28
|
+
Run `oxiul verify` to require a pinned Bun version of at least 1.4.4,
|
|
29
|
+
a Node.js engine range starting at 26 or higher, and these exact scripts:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"lint": "oxlint",
|
|
34
|
+
"lint:fix": "oxlint --fix",
|
|
35
|
+
"format": "oxfmt --write",
|
|
36
|
+
"format:verify": "oxfmt --check",
|
|
37
|
+
"workflows": "oxiul workflows --verify",
|
|
38
|
+
"workflows:generate": "oxiul workflows --generate",
|
|
39
|
+
"typecheck": "bun check",
|
|
40
|
+
"deps": "knip",
|
|
41
|
+
"oxiul:verify": "oxiul verify"
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Add requirements or override commands in `oxiul.config.ts`:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
export default {
|
|
49
|
+
verify: {
|
|
50
|
+
scripts: {
|
|
51
|
+
build: "bun build src/index.ts",
|
|
52
|
+
test: "*", // Required script, any command.
|
|
53
|
+
lint: "oxlint --deny-warnings",
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
} satisfies Config;
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Other scripts are allowed and left unchecked. Verification reads `package.json`
|
|
60
|
+
from the current directory and never modifies it.
|
|
61
|
+
|
|
11
62
|
## Development
|
|
12
63
|
|
|
13
64
|
### Prerequisites
|
package/dist/bin.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/bin.mjs
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { t as parse } from "./parse-DnOcFJT0.mjs";
|
|
3
|
+
import { a as getDepsJob, c as getPackageJsonVerifyJob, d as getWorkflowsVerifyJob, i as getDefaultWorkflow, l as getSetupAction, o as getFormatVerifyJob, s as getLintJob, t as generateWorkflows, u as getTypecheckJob } from "./generate-BGCgStVl.mjs";
|
|
4
|
+
import { gte, subset, valid, validRange } from "semver";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { Crust, defineCommand } from "@crustjs/core";
|
|
7
|
+
import { help } from "@crustjs/extensions";
|
|
8
|
+
import { readFile } from "node:fs/promises";
|
|
9
|
+
//#region src/schemas.ts
|
|
10
|
+
const packageJsonSchema = z.object({
|
|
11
|
+
engines: z.object({ node: z.string() }),
|
|
12
|
+
packageManager: z.string(),
|
|
13
|
+
scripts: z.record(z.string(), z.string())
|
|
14
|
+
}).partial();
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/verify/package-json.ts
|
|
17
|
+
const defaultScripts = {
|
|
18
|
+
deps: "knip",
|
|
19
|
+
format: "oxfmt --write",
|
|
20
|
+
"format:verify": "oxfmt --check",
|
|
21
|
+
lint: "oxlint",
|
|
22
|
+
"lint:fix": "oxlint --fix",
|
|
23
|
+
"oxiul:verify": "oxiul verify",
|
|
24
|
+
typecheck: "bun check",
|
|
25
|
+
workflows: "oxiul workflows --verify",
|
|
26
|
+
"workflows:generate": "oxiul workflows --generate"
|
|
27
|
+
};
|
|
28
|
+
const verifyPackageJson = (packageJson, { scripts: extraScripts, minBunVersion, minNodeVersion }) => {
|
|
29
|
+
const { scripts = {}, packageManager = "", engines: { node: nodeVersionRaw = "" } = { node: "" } } = packageJson;
|
|
30
|
+
const errors = [];
|
|
31
|
+
const bunVersion = /^bun@(?<version>[^+]+)(?:\+sha\d+\.[a-f\d]+)?$/u.exec(packageManager)?.groups?.version;
|
|
32
|
+
if (!bunVersion || !valid(bunVersion) || !gte(bunVersion, minBunVersion)) errors.push(`packageManager must pin bun@${minBunVersion} or higher`);
|
|
33
|
+
const nodeRange = validRange(nodeVersionRaw);
|
|
34
|
+
if (!nodeRange || !subset(nodeRange, `>=${minNodeVersion}`)) errors.push(`engines.node must require Node.js ${minNodeVersion} or higher`);
|
|
35
|
+
for (const [name, command] of Object.entries({
|
|
36
|
+
...defaultScripts,
|
|
37
|
+
...extraScripts
|
|
38
|
+
})) if (!scripts[name]) errors.push(`Missing script: ${name}`);
|
|
39
|
+
else if (command !== "*" && scripts[name] !== command) errors.push(`scripts[${name}] must be ${JSON.stringify(command)}`);
|
|
40
|
+
if (errors.length !== 0) throw new Error(`Package.json verification failed:\n${errors.join("\n")}`);
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/verify/bin.ts
|
|
44
|
+
const command$1 = defineCommand("verify", { description: "Verify package.json" }, (def) => def.action(async ({ stdout }) => {
|
|
45
|
+
stdout("Verifying package.json...");
|
|
46
|
+
const config = await parse();
|
|
47
|
+
const parseResult = packageJsonSchema.safeParse(JSON.parse(await readFile("package.json", "utf8")));
|
|
48
|
+
if (!parseResult.success) throw new Error(`Invalid package.json: ${parseResult.error.message}`);
|
|
49
|
+
verifyPackageJson(parseResult.data, config.verify);
|
|
50
|
+
stdout("package.json verified successfully!");
|
|
51
|
+
}));
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/workflows/bin.ts
|
|
54
|
+
const command = defineCommand("workflows", { description: "Workflows" }, (def) => def.flags({
|
|
55
|
+
name: "verify",
|
|
56
|
+
short: "r",
|
|
57
|
+
type: "boolean"
|
|
58
|
+
}).flags({
|
|
59
|
+
name: "generate",
|
|
60
|
+
short: "g",
|
|
61
|
+
type: "boolean"
|
|
62
|
+
}).action(async ({ flags, stdout }) => {
|
|
63
|
+
const config = await parse();
|
|
64
|
+
const options = {
|
|
65
|
+
actions: { "setup-env": getSetupAction() },
|
|
66
|
+
workflows: [getDefaultWorkflow({
|
|
67
|
+
jobs: {
|
|
68
|
+
deps: getDepsJob(),
|
|
69
|
+
format: getFormatVerifyJob(),
|
|
70
|
+
lint: getLintJob(),
|
|
71
|
+
typecheck: getTypecheckJob(),
|
|
72
|
+
verify: getPackageJsonVerifyJob(),
|
|
73
|
+
workflows: getWorkflowsVerifyJob(),
|
|
74
|
+
...config.workflows?.jobs
|
|
75
|
+
},
|
|
76
|
+
name: "CI"
|
|
77
|
+
}), ...config.workflows?.workflows ?? []]
|
|
78
|
+
};
|
|
79
|
+
if (flags.generate) {
|
|
80
|
+
stdout(`Generating the workflows..`);
|
|
81
|
+
await generateWorkflows({
|
|
82
|
+
...options,
|
|
83
|
+
check: false
|
|
84
|
+
});
|
|
85
|
+
stdout(`Workflows generated successfully!`);
|
|
86
|
+
} else {
|
|
87
|
+
stdout(`Verifying the workflows..`);
|
|
88
|
+
await generateWorkflows({
|
|
89
|
+
...options,
|
|
90
|
+
check: true
|
|
91
|
+
});
|
|
92
|
+
stdout(`Workflows verified successfully!`);
|
|
93
|
+
}
|
|
94
|
+
}));
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/bin.ts
|
|
97
|
+
await new Crust("oxiul", { description: "Oxiul runner" }).add(command$1).add(command).extend(help()).execute();
|
|
98
|
+
//#endregion
|
|
99
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { stringify } from "yaml";
|
|
4
|
+
//#region src/workflows/default.ts
|
|
5
|
+
const DEFAULT_MACHINE = "ubuntu-26.04";
|
|
6
|
+
const getSetupAction = () => ({
|
|
7
|
+
description: "Setup runtime",
|
|
8
|
+
name: "Runtime setup",
|
|
9
|
+
runs: {
|
|
10
|
+
steps: [
|
|
11
|
+
{
|
|
12
|
+
name: "Setup Node.js",
|
|
13
|
+
uses: "actions/setup-node@v7",
|
|
14
|
+
with: { "node-version-file": "package.json" }
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: "Setup Bun",
|
|
18
|
+
uses: "oven-sh/setup-bun@v2",
|
|
19
|
+
with: { "bun-version-file": "package.json" }
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "Install dependencies",
|
|
23
|
+
run: "bun install --frozen-lockfile",
|
|
24
|
+
shell: "bash"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
using: "composite"
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const getDefaultWorkflow = ({ concurrency, on, name = "Default workflow", ...rest }) => ({
|
|
31
|
+
concurrency: {
|
|
32
|
+
"cancel-in-progress": true,
|
|
33
|
+
group: "${{ github.workflow }}-${{ github.ref }}",
|
|
34
|
+
...concurrency
|
|
35
|
+
},
|
|
36
|
+
name,
|
|
37
|
+
on: {
|
|
38
|
+
pull_request: {},
|
|
39
|
+
push: { branches: ["main"] },
|
|
40
|
+
workflow_dispatch: {},
|
|
41
|
+
...on
|
|
42
|
+
},
|
|
43
|
+
...rest
|
|
44
|
+
});
|
|
45
|
+
const getCheckJob = ({ "runs-on": runsOn = DEFAULT_MACHINE, steps, overrideSteps = false, ...rest }) => ({
|
|
46
|
+
"runs-on": runsOn,
|
|
47
|
+
steps: overrideSteps ? steps : [
|
|
48
|
+
{ uses: "actions/checkout@v7" },
|
|
49
|
+
{ uses: "./.github/actions/setup-env" },
|
|
50
|
+
...steps
|
|
51
|
+
],
|
|
52
|
+
...rest
|
|
53
|
+
});
|
|
54
|
+
const getFormatVerifyJob = () => getCheckJob({
|
|
55
|
+
name: "Format verification",
|
|
56
|
+
steps: [{ run: "bun run format:verify" }]
|
|
57
|
+
});
|
|
58
|
+
const getDepsJob = () => getCheckJob({
|
|
59
|
+
name: "Dependencies check",
|
|
60
|
+
steps: [{ run: "bun run deps" }]
|
|
61
|
+
});
|
|
62
|
+
const getTypecheckJob = () => getCheckJob({
|
|
63
|
+
name: "Typecheck",
|
|
64
|
+
steps: [{ run: "bun run typecheck" }]
|
|
65
|
+
});
|
|
66
|
+
const getLintJob = () => getCheckJob({
|
|
67
|
+
name: "Lint",
|
|
68
|
+
steps: [{ run: "bun run lint" }]
|
|
69
|
+
});
|
|
70
|
+
const getWorkflowsVerifyJob = () => getCheckJob({
|
|
71
|
+
name: "Workflows verification",
|
|
72
|
+
steps: [{ run: "bun run workflows" }]
|
|
73
|
+
});
|
|
74
|
+
const getPackageJsonVerifyJob = () => getCheckJob({
|
|
75
|
+
name: "Package.json verification",
|
|
76
|
+
steps: [{ run: "bun run oxiul:verify" }]
|
|
77
|
+
});
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/workflows/generate.ts
|
|
80
|
+
const generateWorkflows = async ({ workflows = [], actions = {}, directory = ".", check = false }) => {
|
|
81
|
+
const files = /* @__PURE__ */ new Map();
|
|
82
|
+
const addFile = (name, filePath, value) => {
|
|
83
|
+
if (!name || !/^[\w-]+$/u.test(name)) throw new Error(`Invalid generated file name: ${name}`);
|
|
84
|
+
if (files.has(filePath)) throw new Error(`Duplicate generated file: ${filePath}`);
|
|
85
|
+
files.set(filePath, `# Generated by @oxiul/configs/workflows. Do not edit.\n${stringify(value, { lineWidth: 0 })}`);
|
|
86
|
+
};
|
|
87
|
+
for (const workflow of workflows) addFile(workflow.name, `.github/workflows/${workflow.name.toLowerCase()}.yml`, workflow);
|
|
88
|
+
for (const [name, action] of Object.entries(actions)) addFile(name, `.github/actions/${name}/action.yml`, action);
|
|
89
|
+
for (const [filePath, content] of files) {
|
|
90
|
+
const target = path.resolve(directory, filePath);
|
|
91
|
+
if (check) {
|
|
92
|
+
if (await readFile(target, "utf8").catch((error) => {
|
|
93
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") return;
|
|
94
|
+
throw error;
|
|
95
|
+
}) !== content) throw new Error(`Generated file is out of date: ${filePath}`);
|
|
96
|
+
} else {
|
|
97
|
+
await mkdir(path.dirname(target), { recursive: true });
|
|
98
|
+
await writeFile(target, content);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
//#endregion
|
|
103
|
+
export { getDepsJob as a, getPackageJsonVerifyJob as c, getWorkflowsVerifyJob as d, getDefaultWorkflow as i, getSetupAction as l, DEFAULT_MACHINE as n, getFormatVerifyJob as o, getCheckJob as r, getLintJob as s, generateWorkflows as t, getTypecheckJob as u };
|
package/dist/hook/install.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as packageName } from "../common-B9SE4GL9.mjs";
|
|
2
|
-
import { exec } from "node:child_process";
|
|
3
2
|
import fs from "node:fs/promises";
|
|
4
3
|
import path from "node:path";
|
|
4
|
+
import { exec } from "node:child_process";
|
|
5
5
|
import { promisify } from "node:util";
|
|
6
6
|
//#region src/hook/install.ts
|
|
7
7
|
const promisifiedExec = promisify(exec);
|
package/dist/hook/pre-commit.mjs
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as configSchema } from "../schema-DM8wm8HH.mjs";
|
|
3
|
-
import { z } from "zod";
|
|
1
|
+
import { t as parse } from "../parse-DnOcFJT0.mjs";
|
|
4
2
|
import { spawn } from "node:child_process";
|
|
5
|
-
import { cosmiconfig } from "cosmiconfig";
|
|
6
3
|
import { Listr } from "listr2";
|
|
7
4
|
//#region src/hook/pre-commit.ts
|
|
8
5
|
const failedOutputs = /* @__PURE__ */ new Map();
|
|
@@ -34,11 +31,8 @@ const run = (command, task) => new Promise((resolve, reject) => {
|
|
|
34
31
|
reject(/* @__PURE__ */ new Error(signal ? `killed by ${signal}` : `exited with code ${code}`));
|
|
35
32
|
});
|
|
36
33
|
});
|
|
37
|
-
const rawConfig = await cosmiconfig(moduleName).search();
|
|
38
|
-
const parsedConfig = z.safeParse(configSchema, rawConfig?.config);
|
|
39
|
-
if (!parsedConfig.success) throw new Error(`Validation error: ${parsedConfig.error.message}`);
|
|
40
34
|
try {
|
|
41
|
-
const config =
|
|
35
|
+
const config = await parse();
|
|
42
36
|
if (config.preCommitCommands && config.preCommitCommands.length !== 0) await new Listr(config.preCommitCommands.map((command) => ({
|
|
43
37
|
rendererOptions: {
|
|
44
38
|
outputBar: 5,
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { GeneratedWorkflowTypes, GeneratedWorkflowTypes as GeneratedWorkflowTypes$1 } from "@github-actions-workflow-ts/lib";
|
|
2
|
+
//#region src/workflows/types.d.ts
|
|
3
|
+
type CompositeAction = {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
runs: {
|
|
7
|
+
using: "composite";
|
|
8
|
+
steps: GeneratedWorkflowTypes.Step[];
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
type Workflow = GeneratedWorkflowTypes.Workflow;
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/workflows/default.d.ts
|
|
14
|
+
declare const DEFAULT_MACHINE = "ubuntu-26.04";
|
|
15
|
+
declare const getSetupAction: () => CompositeAction;
|
|
16
|
+
declare const getDefaultWorkflow: ({ concurrency, on, name, ...rest }: Omit<GeneratedWorkflowTypes.Workflow, "on" | "concurrency"> & {
|
|
17
|
+
on?: Exclude<GeneratedWorkflowTypes.Workflow["on"], GeneratedWorkflowTypes.Event | GeneratedWorkflowTypes.Event[]>;
|
|
18
|
+
concurrency?: Exclude<GeneratedWorkflowTypes.Workflow["concurrency"], string>;
|
|
19
|
+
}) => Omit<GeneratedWorkflowTypes.Workflow, "name"> & {
|
|
20
|
+
name: string;
|
|
21
|
+
};
|
|
22
|
+
declare const getCheckJob: ({ "runs-on": runsOn, steps, overrideSteps, ...rest }: Omit<GeneratedWorkflowTypes.NormalJob, "runs-on"> & {
|
|
23
|
+
overrideSteps?: boolean;
|
|
24
|
+
"runs-on"?: GeneratedWorkflowTypes.NormalJob["runs-on"];
|
|
25
|
+
steps: Exclude<GeneratedWorkflowTypes.NormalJob["steps"], undefined>;
|
|
26
|
+
}) => GeneratedWorkflowTypes.NormalJob;
|
|
27
|
+
declare const getFormatVerifyJob: () => GeneratedWorkflowTypes.NormalJob;
|
|
28
|
+
declare const getDepsJob: () => GeneratedWorkflowTypes.NormalJob;
|
|
29
|
+
declare const getTypecheckJob: () => GeneratedWorkflowTypes.NormalJob;
|
|
30
|
+
declare const getLintJob: () => GeneratedWorkflowTypes.NormalJob;
|
|
31
|
+
declare const getWorkflowsVerifyJob: () => GeneratedWorkflowTypes.NormalJob;
|
|
32
|
+
declare const getPackageJsonVerifyJob: () => GeneratedWorkflowTypes.NormalJob;
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/workflows/generate.d.ts
|
|
35
|
+
declare const generateWorkflows: ({ workflows, actions, directory, check }: {
|
|
36
|
+
workflows?: (Omit<GeneratedWorkflowTypes.Workflow, "name"> & {
|
|
37
|
+
name: string;
|
|
38
|
+
})[];
|
|
39
|
+
actions?: Record<string, CompositeAction>;
|
|
40
|
+
directory?: string;
|
|
41
|
+
check?: boolean;
|
|
42
|
+
}) => Promise<void>;
|
|
43
|
+
//#endregion
|
|
44
|
+
export { getDefaultWorkflow as a, getLintJob as c, getTypecheckJob as d, getWorkflowsVerifyJob as f, getCheckJob as i, getPackageJsonVerifyJob as l, Workflow as m, generateWorkflows as n, getDepsJob as o, CompositeAction as p, DEFAULT_MACHINE as r, getFormatVerifyJob as s, GeneratedWorkflowTypes$1 as t, getSetupAction as u };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { t as GeneratedWorkflowTypes } from "./index-DqMadVlO.mjs";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
import { OxlintConfig } from "oxlint";
|
|
3
4
|
import { OxfmtConfig } from "oxfmt";
|
|
@@ -146,7 +147,22 @@ declare const getConfig$1: ({ options, ...overrides }?: ConfigOptions) => Promis
|
|
|
146
147
|
//#region src/config/schema.d.ts
|
|
147
148
|
export declare const configSchema: z.ZodObject<{
|
|
148
149
|
preCommitCommands: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
150
|
+
verify: z.ZodDefault<z.ZodObject<{
|
|
151
|
+
minBunVersion: z.ZodDefault<z.ZodString>;
|
|
152
|
+
minNodeVersion: z.ZodDefault<z.ZodString>;
|
|
153
|
+
scripts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
154
|
+
}, z.core.$strip>>;
|
|
155
|
+
workflows: z.ZodOptional<z.ZodObject<{
|
|
156
|
+
branch: z.ZodOptional<z.ZodString>;
|
|
157
|
+
jobs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodCustom<GeneratedWorkflowTypes.NormalJob, GeneratedWorkflowTypes.NormalJob>>>;
|
|
158
|
+
workflows: z.ZodOptional<z.ZodArray<z.ZodCustom<Omit<GeneratedWorkflowTypes.Workflow, "name"> & {
|
|
159
|
+
name: string;
|
|
160
|
+
}, Omit<GeneratedWorkflowTypes.Workflow, "name"> & {
|
|
161
|
+
name: string;
|
|
162
|
+
}>>>;
|
|
163
|
+
}, z.core.$strip>>;
|
|
149
164
|
}, z.core.$strip>;
|
|
150
|
-
type
|
|
165
|
+
type ConfigInput = z.input<typeof configSchema>;
|
|
166
|
+
type ConfigOutput = z.output<typeof configSchema>;
|
|
151
167
|
//#endregion
|
|
152
|
-
export { type Config, getConfig as getFormatConfig, getConfig$1 as getKnipConfig, getConfig$2 as getLintConfig };
|
|
168
|
+
export { type ConfigInput as Config, type ConfigOutput, getConfig as getFormatConfig, getConfig$1 as getKnipConfig, getConfig$2 as getLintConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as baseIgnorePatterns, t as arraify } from "./common-B9SE4GL9.mjs";
|
|
2
|
-
import { t as configSchema } from "./schema-
|
|
2
|
+
import { t as configSchema } from "./schema-BuCl21uv.mjs";
|
|
3
3
|
import { isNonNullish, mapValues, omitBy } from "remeda";
|
|
4
4
|
//#region src/oxlint.ts
|
|
5
5
|
const disabledRules = {
|
|
@@ -330,17 +330,24 @@ const getBaseConfig$1 = () => ({
|
|
|
330
330
|
reportUnusedDisableDirectives: "error",
|
|
331
331
|
typeAware: true
|
|
332
332
|
},
|
|
333
|
-
overrides: [
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
333
|
+
overrides: [
|
|
334
|
+
{
|
|
335
|
+
files: ["**/*.config.{j,t}s"],
|
|
336
|
+
rules: {
|
|
337
|
+
"import/no-default-export": "off",
|
|
338
|
+
"import/no-nodejs-modules": "off",
|
|
339
|
+
"node/no-top-level-await": "off"
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
files: ["**/*.d.ts"],
|
|
344
|
+
rules: { "typescript/triple-slash-reference": "off" }
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
files: ["workflows.config.ts"],
|
|
348
|
+
rules: { "eslint/no-template-curly-in-string": "off" }
|
|
339
349
|
}
|
|
340
|
-
|
|
341
|
-
files: ["**/*.d.ts"],
|
|
342
|
-
rules: { "typescript/triple-slash-reference": "off" }
|
|
343
|
-
}],
|
|
350
|
+
],
|
|
344
351
|
plugins: {
|
|
345
352
|
eslint: true,
|
|
346
353
|
import: true,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { r as moduleName } from "./common-B9SE4GL9.mjs";
|
|
2
|
+
import { t as configSchema } from "./schema-BuCl21uv.mjs";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { cosmiconfig } from "cosmiconfig";
|
|
5
|
+
//#region src/config/parse.ts
|
|
6
|
+
const explorer = cosmiconfig(moduleName);
|
|
7
|
+
const parse = async () => {
|
|
8
|
+
const rawConfig = await explorer.search();
|
|
9
|
+
const parsedConfig = z.safeParse(configSchema, rawConfig?.config ?? {});
|
|
10
|
+
if (!parsedConfig.success) throw new Error(`Validation error: ${parsedConfig.error.message}`);
|
|
11
|
+
return parsedConfig.data;
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { parse as t };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { valid } from "semver";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/config/schema.ts
|
|
4
|
+
const MIN_NODE_VERSION = "26.0.0";
|
|
5
|
+
const MIN_BUN_VERSION = "1.4.4";
|
|
6
|
+
const configSchema = z.object({
|
|
7
|
+
preCommitCommands: z.string().array().optional(),
|
|
8
|
+
verify: z.object({
|
|
9
|
+
minBunVersion: z.string().refine((version) => valid(version)).default(() => MIN_BUN_VERSION),
|
|
10
|
+
minNodeVersion: z.string().refine((version) => valid(version)).default(() => MIN_NODE_VERSION),
|
|
11
|
+
scripts: z.record(z.string(), z.string()).optional()
|
|
12
|
+
}).default(() => ({
|
|
13
|
+
minBunVersion: MIN_BUN_VERSION,
|
|
14
|
+
minNodeVersion: MIN_NODE_VERSION
|
|
15
|
+
})),
|
|
16
|
+
workflows: z.object({
|
|
17
|
+
branch: z.string().optional(),
|
|
18
|
+
jobs: z.record(z.string(), z.custom()).optional(),
|
|
19
|
+
workflows: z.custom().array().optional()
|
|
20
|
+
}).optional()
|
|
21
|
+
});
|
|
22
|
+
//#endregion
|
|
23
|
+
export { configSchema as t };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as getDefaultWorkflow, c as getLintJob, d as getTypecheckJob, f as getWorkflowsVerifyJob, i as getCheckJob, l as getPackageJsonVerifyJob, m as Workflow, n as generateWorkflows, o as getDepsJob, p as CompositeAction, r as DEFAULT_MACHINE, s as getFormatVerifyJob, t as GeneratedWorkflowTypes, u as getSetupAction } from "../index-DqMadVlO.mjs";
|
|
2
|
+
export { type CompositeAction, DEFAULT_MACHINE, type GeneratedWorkflowTypes, type Workflow, generateWorkflows, getCheckJob, getDefaultWorkflow, getDepsJob, getFormatVerifyJob, getLintJob, getPackageJsonVerifyJob, getSetupAction, getTypecheckJob, getWorkflowsVerifyJob };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { n as DEFAULT_MACHINE, t as generateWorkflows, r as getCheckJob, i as getDefaultWorkflow, a as getDepsJob, o as getFormatVerifyJob, s as getLintJob, c as getPackageJsonVerifyJob, l as getSetupAction, u as getTypecheckJob, d as getWorkflowsVerifyJob } from "../generate-BGCgStVl.mjs";
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxiul/configs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/oxiul/configs.git"
|
|
8
8
|
},
|
|
9
|
+
"bin": {
|
|
10
|
+
"oxiul": "./dist/bin.mjs"
|
|
11
|
+
},
|
|
9
12
|
"files": [
|
|
10
13
|
"dist/**",
|
|
11
14
|
"scripts/postinstall.mjs"
|
|
@@ -15,8 +18,14 @@
|
|
|
15
18
|
"main": "./dist/index.mjs",
|
|
16
19
|
"module": "./dist/index.mjs",
|
|
17
20
|
"exports": {
|
|
18
|
-
"
|
|
19
|
-
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.mts",
|
|
23
|
+
"default": "./dist/index.mjs"
|
|
24
|
+
},
|
|
25
|
+
"./workflows": {
|
|
26
|
+
"types": "./dist/workflows/index.d.mts",
|
|
27
|
+
"default": "./dist/workflows/index.mjs"
|
|
28
|
+
}
|
|
20
29
|
},
|
|
21
30
|
"publishConfig": {
|
|
22
31
|
"access": "public"
|
|
@@ -29,13 +38,21 @@
|
|
|
29
38
|
"format:verify": "oxfmt --check",
|
|
30
39
|
"lint": "oxlint",
|
|
31
40
|
"lint:fix": "oxlint --fix",
|
|
41
|
+
"oxiul:verify": "bun src/bin.ts verify",
|
|
32
42
|
"postinstall": "node scripts/postinstall.mjs",
|
|
33
|
-
"typecheck": "bun check"
|
|
43
|
+
"typecheck": "bun check",
|
|
44
|
+
"workflows": "bun src/bin.ts workflows --verify",
|
|
45
|
+
"workflows:generate": "bun src/bin.ts workflows --generate"
|
|
34
46
|
},
|
|
35
47
|
"dependencies": {
|
|
48
|
+
"@crustjs/core": "^0.5.6",
|
|
49
|
+
"@crustjs/extensions": "^0.5.6",
|
|
50
|
+
"@github-actions-workflow-ts/lib": "^2.6.1",
|
|
36
51
|
"cosmiconfig": "^10.0.1",
|
|
37
52
|
"listr2": "^11.4.0",
|
|
38
53
|
"oxlint-plugin-eslint": "^1.88.0",
|
|
54
|
+
"semver": "^7.8.5",
|
|
55
|
+
"yaml": "^2.9.1",
|
|
39
56
|
"zod": "^4.6.7"
|
|
40
57
|
},
|
|
41
58
|
"devDependencies": {
|
|
@@ -44,6 +61,7 @@
|
|
|
44
61
|
"@changesets/cli": "^3.0.3",
|
|
45
62
|
"@tanstack/eslint-plugin-router": "^1.162.0",
|
|
46
63
|
"@types/bun": "1.4.3",
|
|
64
|
+
"@types/semver": "^7.8.0",
|
|
47
65
|
"eslint-plugin-better-tailwindcss": "^4.9.1",
|
|
48
66
|
"eslint-plugin-package-json": "^1.10.1",
|
|
49
67
|
"eslint-plugin-playwright": "^2.12.1",
|
|
@@ -63,5 +81,5 @@
|
|
|
63
81
|
"engines": {
|
|
64
82
|
"node": "26"
|
|
65
83
|
},
|
|
66
|
-
"packageManager": "bun@1.4.
|
|
84
|
+
"packageManager": "bun@1.4.4"
|
|
67
85
|
}
|