create-jigo 1.15.18 → 2.0.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/cli.mjs +4 -4
- package/github.mjs +1 -0
- package/package.json +1 -1
- package/setup.mjs +6 -1
- package/typescript.mjs +53 -13
package/cli.mjs
CHANGED
|
@@ -176,13 +176,13 @@ function existingSource(root) {
|
|
|
176
176
|
return { url, repo: githubRepo(url) };
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
function setupBody(check, local) {
|
|
179
|
+
function setupBody({ check, layers }, local) {
|
|
180
180
|
return `## Summary
|
|
181
181
|
|
|
182
182
|
\`\`\`text
|
|
183
183
|
Repository
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
layers: ${layers.join(", ")}
|
|
185
|
+
pr and capture skills, ${check}
|
|
186
186
|
Squash merge
|
|
187
187
|
\`\`\`
|
|
188
188
|
|
|
@@ -264,7 +264,7 @@ async function adopt(root, kind, scratch) {
|
|
|
264
264
|
setup.scripts.length > 0
|
|
265
265
|
? "Applicable local project checks passed."
|
|
266
266
|
: "The setup diff preserves the repository’s files and checks.";
|
|
267
|
-
const pr = host.createPull(base, branch, SETUP_TITLE, setupBody(
|
|
267
|
+
const pr = host.createPull(base, branch, SETUP_TITLE, setupBody(setup, evidence));
|
|
268
268
|
print(`Setup PR: ${pr}\n${root}`);
|
|
269
269
|
if (!flags["no-wait"]) await host.waitForCheck(head, check);
|
|
270
270
|
configureProtection(host, base, check);
|
package/github.mjs
CHANGED
package/package.json
CHANGED
package/setup.mjs
CHANGED
|
@@ -262,5 +262,10 @@ export function configure(root, name, { kind = "plain", initial = false } = {})
|
|
|
262
262
|
const check = configureCheck(root, Boolean(typescript));
|
|
263
263
|
dependabot(root, Boolean(typescript));
|
|
264
264
|
automerge(root, check.workflow);
|
|
265
|
-
return {
|
|
265
|
+
return {
|
|
266
|
+
check: check.name,
|
|
267
|
+
updateLock: typescript?.updateLock ?? false,
|
|
268
|
+
scripts: typescript?.scripts ?? [],
|
|
269
|
+
layers: ["core", ...(typescript?.layers ?? [])],
|
|
270
|
+
};
|
|
266
271
|
}
|
package/typescript.mjs
CHANGED
|
@@ -7,17 +7,34 @@ import { read, write, YAML } from "./files.mjs";
|
|
|
7
7
|
import { releasePeers, releaseTag } from "./release.mjs";
|
|
8
8
|
|
|
9
9
|
export const PACKAGE = "@mapringg/jigo";
|
|
10
|
-
const
|
|
10
|
+
const JIGO = "node_modules/@mapringg/jigo";
|
|
11
|
+
const CONFIGS = `${JIGO}/typescript`;
|
|
11
12
|
const RULES = "jigo rules";
|
|
12
13
|
const SCRIPTS = {
|
|
13
14
|
lint: "oxlint",
|
|
14
15
|
format: `oxfmt -c ${CONFIGS}/oxfmt.json`,
|
|
15
16
|
"format:check": `oxfmt -c ${CONFIGS}/oxfmt.json --check`,
|
|
16
17
|
knip: `knip -c ${CONFIGS}/knip.json && knip -c ${CONFIGS}/knip.json --production`,
|
|
18
|
+
dupes: `jscpd -c ${CONFIGS}/jscpd.json .`,
|
|
17
19
|
};
|
|
18
|
-
const
|
|
20
|
+
const RENAMED = {
|
|
21
|
+
"agent-docs": "no-unstructured-docs",
|
|
22
|
+
"design-system": "no-loosened-rules",
|
|
23
|
+
"feature-imports": "no-cross-feature-imports",
|
|
24
|
+
hono: "no-loose-handlers",
|
|
25
|
+
"next-data": "no-router-refresh",
|
|
26
|
+
"next-routes": "no-async-pages",
|
|
27
|
+
"no-put-routes": "no-unknown-methods",
|
|
28
|
+
params: "no-custom-params",
|
|
29
|
+
reducer: "no-multiple-reducers",
|
|
30
|
+
"repo-shape": "no-stray-files",
|
|
31
|
+
"server-actions": "no-inline-actions",
|
|
32
|
+
tests: "no-impure-tests",
|
|
33
|
+
};
|
|
34
|
+
const LAYERS = { web: ["react", "next"], api: ["hono"] };
|
|
19
35
|
const MIGRATIONS = [
|
|
20
|
-
[
|
|
36
|
+
...Object.entries(RENAMED).map(([from, to]) => [new RegExp(`"(?:standard|jigo)/${from}"`, "g"), `"jigo/${to}"`]),
|
|
37
|
+
[/node_modules\/@mapringg\/(?:standard|jigo)\/(oxlint|oxfmt|knip)\.json/g, `${CONFIGS}/$1.json`],
|
|
21
38
|
[/\bstandard-rules\b/g, RULES],
|
|
22
39
|
[/"standard\//g, '"jigo/'],
|
|
23
40
|
[/@mapringg\/standard\b/g, PACKAGE],
|
|
@@ -44,20 +61,42 @@ const HOOKS = {
|
|
|
44
61
|
],
|
|
45
62
|
};
|
|
46
63
|
|
|
47
|
-
function
|
|
64
|
+
function walk(root, visit, dir = "") {
|
|
48
65
|
for (const entry of readdirSync(join(root, dir), { withFileTypes: true })) {
|
|
49
66
|
if (entry.name === "node_modules" || entry.name === ".git") continue;
|
|
50
67
|
const rel = dir ? `${dir}/${entry.name}` : entry.name;
|
|
51
|
-
if (entry.isDirectory())
|
|
52
|
-
else
|
|
53
|
-
|
|
54
|
-
|
|
68
|
+
if (entry.isDirectory()) walk(root, visit, rel);
|
|
69
|
+
else visit(entry.name, join(root, rel));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function migrate(root) {
|
|
74
|
+
walk(root, (name, path) => {
|
|
75
|
+
if (MIGRATED.test(name))
|
|
55
76
|
write(
|
|
56
77
|
path,
|
|
57
|
-
MIGRATIONS.reduce((next, [from, to]) => next.replace(from, to),
|
|
78
|
+
MIGRATIONS.reduce((next, [from, to]) => next.replace(from, to), read(path)),
|
|
58
79
|
);
|
|
59
|
-
|
|
60
|
-
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function layers(root) {
|
|
84
|
+
const deps = new Set();
|
|
85
|
+
walk(root, (name, path) => {
|
|
86
|
+
if (name !== "package.json") return;
|
|
87
|
+
const manifest = JSON.parse(read(path));
|
|
88
|
+
for (const field of ["dependencies", "devDependencies", "peerDependencies"])
|
|
89
|
+
for (const dep of Object.keys(manifest[field] ?? {})) deps.add(dep);
|
|
90
|
+
});
|
|
91
|
+
return ["typescript", ...Object.keys(LAYERS).filter((layer) => LAYERS[layer].some((dep) => deps.has(dep)))];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function extend(root, wanted) {
|
|
95
|
+
const path = join(root, ".oxlintrc.json");
|
|
96
|
+
const config = JSON.parse(read(path) ?? "{}");
|
|
97
|
+
const current = config.extends ?? [];
|
|
98
|
+
const missing = wanted.map((layer) => `./${JIGO}/${layer}/oxlint.json`).filter((entry) => !current.includes(entry));
|
|
99
|
+
if (missing.length > 0) write(path, `${JSON.stringify({ ...config, extends: [...current, ...missing] }, null, 2)}\n`);
|
|
61
100
|
}
|
|
62
101
|
|
|
63
102
|
function install(root, manifest, text) {
|
|
@@ -122,9 +161,10 @@ export function configureTypescript(root) {
|
|
|
122
161
|
const text = read(path);
|
|
123
162
|
const manifest = JSON.parse(text);
|
|
124
163
|
const updateLock = install(root, manifest, text);
|
|
125
|
-
|
|
164
|
+
const included = layers(root);
|
|
165
|
+
extend(root, included);
|
|
126
166
|
trust(root);
|
|
127
167
|
addHooks(join(root, ".claude", "settings.json"), "claude");
|
|
128
168
|
addHooks(join(root, ".codex", "hooks.json"), "codex");
|
|
129
|
-
return { updateLock, scripts: Object.keys(manifest.scripts ?? {}) };
|
|
169
|
+
return { updateLock, scripts: Object.keys(manifest.scripts ?? {}), layers: included };
|
|
130
170
|
}
|