@ingram-tech/nk-dev 0.6.1 → 0.7.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/guide.md +12 -0
- package/lib/doctor.js +45 -4
- package/package.json +1 -1
package/guide.md
CHANGED
|
@@ -77,6 +77,18 @@ the UI/page tree, and never expose internal plumbing under `/api/`.
|
|
|
77
77
|
`@ingram-tech/nk-db`'s drift-aware runner (`@ingram-tech/nk-db/migrate`), which
|
|
78
78
|
surfaces the real Postgres error and pre-flights journal drift. Generate **and
|
|
79
79
|
apply** in the same step; don't leave "run the migration" as a handoff.
|
|
80
|
+
- **`drizzle-kit` is GENERATE-ONLY — it must never apply schema.** Use it for
|
|
81
|
+
`drizzle-kit generate` (and `generate --custom` for a package-owned/raw SQL
|
|
82
|
+
migration). Applying is always **`nk-pg-migrate`** (the bin from
|
|
83
|
+
`@ingram-tech/nk-db`): `bun run db:migrate`, and check first with
|
|
84
|
+
`db:migrate:status`. Two commands are banned, and `nk doctor` fails on either:
|
|
85
|
+
- **`drizzle-kit push`** applies a diff straight to the live DB with no
|
|
86
|
+
migration file and no journal entry. It is the schema-drift source — it has
|
|
87
|
+
already drifted a production database in this fleet, and where the dev DB is
|
|
88
|
+
shared it rewrites everyone's. To iterate locally, rebuild from migrations
|
|
89
|
+
(the PGlite harness / your `dev:*fresh` script), don't push.
|
|
90
|
+
- **`drizzle-kit migrate`** is opaque: it exits non-zero with no message (even
|
|
91
|
+
on a clean no-op) and hides journal drift.
|
|
80
92
|
|
|
81
93
|
## Large-scale / structural edits
|
|
82
94
|
|
package/lib/doctor.js
CHANGED
|
@@ -36,7 +36,7 @@ function writeJson(file, value) {
|
|
|
36
36
|
* returns a short past-tense note. `level` is "error" (breaks the model) or
|
|
37
37
|
* "warn" (cosmetic / cleanup).
|
|
38
38
|
*/
|
|
39
|
-
function findings(cwd) {
|
|
39
|
+
export function findings(cwd) {
|
|
40
40
|
const out = [];
|
|
41
41
|
const pkgPath = resolve(cwd, "package.json");
|
|
42
42
|
const pkg = readJson(pkgPath);
|
|
@@ -202,7 +202,47 @@ function findings(cwd) {
|
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
// 7.
|
|
205
|
+
// 7. drizzle-kit is GENERATE-ONLY — it must never apply schema.
|
|
206
|
+
// `drizzle-kit push` diffs the live DB and applies straight to it with no
|
|
207
|
+
// migration file and no journal entry: the schema-drift source (it has
|
|
208
|
+
// already drifted one production database in this fleet, and on sites
|
|
209
|
+
// whose dev DB is shared it rewrites everyone's).
|
|
210
|
+
// `drizzle-kit migrate` is opaque — it exits non-zero with no message
|
|
211
|
+
// (even on a clean no-op) and hides journal drift.
|
|
212
|
+
// `nk-pg-migrate` (@ingram-tech/nk-db) is the one runner that applies:
|
|
213
|
+
// it surfaces the real Postgres error and pre-flights drift.
|
|
214
|
+
for (const [name, cmd] of Object.entries(scripts)) {
|
|
215
|
+
if (typeof cmd !== "string") continue;
|
|
216
|
+
if (/\bdrizzle-kit\s+push\b/.test(cmd)) {
|
|
217
|
+
out.push({
|
|
218
|
+
id: `script:drizzle-push:${name}`,
|
|
219
|
+
level: "error",
|
|
220
|
+
message: `\`${name}\` runs \`drizzle-kit push\` — it applies schema to the live DB with no migration (drift). Generate a migration and apply it with \`nk-pg-migrate\`.`,
|
|
221
|
+
fix: (dir) => {
|
|
222
|
+
const p = resolve(dir, "package.json");
|
|
223
|
+
const j = readJson(p);
|
|
224
|
+
delete j.scripts?.[name];
|
|
225
|
+
writeJson(p, j);
|
|
226
|
+
return `removed \`${name}\` (drizzle-kit push)`;
|
|
227
|
+
},
|
|
228
|
+
});
|
|
229
|
+
} else if (/\bdrizzle-kit\s+migrate\b/.test(cmd)) {
|
|
230
|
+
out.push({
|
|
231
|
+
id: `script:drizzle-migrate:${name}`,
|
|
232
|
+
level: "error",
|
|
233
|
+
message: `\`${name}\` runs \`drizzle-kit migrate\` — apply with \`nk-pg-migrate\` instead (it surfaces the real error and pre-flights journal drift).`,
|
|
234
|
+
fix: (dir) => {
|
|
235
|
+
const p = resolve(dir, "package.json");
|
|
236
|
+
const j = readJson(p);
|
|
237
|
+
j.scripts[name] = "nk-pg-migrate";
|
|
238
|
+
writeJson(p, j);
|
|
239
|
+
return `set \`${name}\` → "nk-pg-migrate"`;
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// 8. .prettierignore is now dead weight (nk no longer formats SQL).
|
|
206
246
|
const prettierIgnore = resolve(cwd, ".prettierignore");
|
|
207
247
|
if (existsSync(prettierIgnore)) {
|
|
208
248
|
out.push({
|
|
@@ -223,8 +263,9 @@ function findings(cwd) {
|
|
|
223
263
|
/**
|
|
224
264
|
* `nk doctor [--fix]` — report drift from the canonical nk-dev model (scripts,
|
|
225
265
|
* dependencies, oxlint/tsconfig extends, the CLAUDE.md guide import, stale knip
|
|
226
|
-
* ignores,
|
|
227
|
-
* finding, then remind
|
|
266
|
+
* ignores, forbidden schema-applying drizzle-kit scripts, a dead
|
|
267
|
+
* .prettierignore). With `--fix`, apply every auto-fixable finding, then remind
|
|
268
|
+
* to reinstall.
|
|
228
269
|
*/
|
|
229
270
|
export function doctor(args = []) {
|
|
230
271
|
const fix = args.includes("--fix");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ingram-tech/nk-dev",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "The nextkit dev toolchain in one package: the `nk` CLI plus shared oxlint/oxfmt, TypeScript, and Vitest config, the format-on-commit hook, and the AI agent guide. `nk init` scaffolds a site to use it.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|