@attalabs/vinaya 0.4.0 → 0.4.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/index.js +40 -35
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import { readFileSync as
|
|
4
|
+
import { readFileSync as readFileSync13 } from "node:fs";
|
|
5
5
|
import { dirname as dirname5, join as join15 } from "node:path";
|
|
6
6
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
7
7
|
|
|
@@ -2310,10 +2310,11 @@ async function demoBreakCommand(args) {
|
|
|
2310
2310
|
}
|
|
2311
2311
|
|
|
2312
2312
|
// src/commands/doctor.ts
|
|
2313
|
-
import { existsSync as existsSync8, readFileSync as
|
|
2313
|
+
import { existsSync as existsSync8, readFileSync as readFileSync6, statSync } from "node:fs";
|
|
2314
2314
|
import { join as join8 } from "node:path";
|
|
2315
2315
|
|
|
2316
2316
|
// src/lib/artifacts.ts
|
|
2317
|
+
import { readFileSync as readFileSync3 } from "node:fs";
|
|
2317
2318
|
import { join as join6 } from "node:path";
|
|
2318
2319
|
var CONFIG_PATH = "vinaya.config.json";
|
|
2319
2320
|
var DOCTRINE_POINTER_PATH = "VINAYA.md";
|
|
@@ -2597,14 +2598,18 @@ jobs:
|
|
|
2597
2598
|
}
|
|
2598
2599
|
var HOOK_PREAMBLE = `#!/usr/bin/env sh
|
|
2599
2600
|
`;
|
|
2601
|
+
function ownVersion() {
|
|
2602
|
+
const pkg = JSON.parse(readFileSync3(join6(packageRoot(import.meta.url), "package.json"), "utf-8"));
|
|
2603
|
+
return pkg.version;
|
|
2604
|
+
}
|
|
2600
2605
|
function preCommitBody() {
|
|
2601
2606
|
return `# Vinaya commit-time gate. Runs the deterministic checks over your staged
|
|
2602
2607
|
# diff before the commit lands.
|
|
2603
|
-
npx --
|
|
2608
|
+
npx --yes @attalabs/vinaya@${ownVersion()} check --all --diff-only || exit 1`;
|
|
2604
2609
|
}
|
|
2605
2610
|
function prePushBody() {
|
|
2606
2611
|
return `# Vinaya pre-push gate. Runs branch/dispatch checks before the push leaves.
|
|
2607
|
-
npx --
|
|
2612
|
+
npx --yes @attalabs/vinaya@${ownVersion()} check --all || exit 1`;
|
|
2608
2613
|
}
|
|
2609
2614
|
function doctrinePointer() {
|
|
2610
2615
|
const doctrineRoot = join6(packageRoot(import.meta.url), "aeg-root");
|
|
@@ -2777,7 +2782,7 @@ function buildInitProductOps(name) {
|
|
|
2777
2782
|
}
|
|
2778
2783
|
|
|
2779
2784
|
// src/lib/env-lint.ts
|
|
2780
|
-
import { existsSync as existsSync6, readFileSync as
|
|
2785
|
+
import { existsSync as existsSync6, readFileSync as readFileSync4 } from "node:fs";
|
|
2781
2786
|
var ENV_READ_PATTERN = /\b(?:process\.env|Bun\.env|Deno\.env)\b/;
|
|
2782
2787
|
function checksMissingEnvDeclaration(specs) {
|
|
2783
2788
|
const names = [];
|
|
@@ -2788,7 +2793,7 @@ function checksMissingEnvDeclaration(specs) {
|
|
|
2788
2793
|
continue;
|
|
2789
2794
|
let source;
|
|
2790
2795
|
try {
|
|
2791
|
-
source =
|
|
2796
|
+
source = readFileSync4(spec.run, "utf8");
|
|
2792
2797
|
} catch {
|
|
2793
2798
|
continue;
|
|
2794
2799
|
}
|
|
@@ -2802,7 +2807,7 @@ function envDeclarationWarning(name) {
|
|
|
2802
2807
|
}
|
|
2803
2808
|
|
|
2804
2809
|
// src/lib/ops.ts
|
|
2805
|
-
import { chmodSync, existsSync as existsSync7, mkdirSync as mkdirSync2, readFileSync as
|
|
2810
|
+
import { chmodSync, existsSync as existsSync7, mkdirSync as mkdirSync2, readFileSync as readFileSync5, rmSync as rmSync2, writeFileSync as writeFileSync3 } from "node:fs";
|
|
2806
2811
|
import { dirname as dirname3, join as join7, resolve, sep } from "node:path";
|
|
2807
2812
|
var MARKER_NS = "vinaya:managed";
|
|
2808
2813
|
function markerLines(marker, comment) {
|
|
@@ -2832,7 +2837,7 @@ function fileContains(repoRoot, relPath, needle) {
|
|
|
2832
2837
|
const p = abs(repoRoot, relPath);
|
|
2833
2838
|
if (!existsSync7(p))
|
|
2834
2839
|
return false;
|
|
2835
|
-
return
|
|
2840
|
+
return readFileSync5(p, "utf-8").includes(needle);
|
|
2836
2841
|
}
|
|
2837
2842
|
function planInstall(ops, repoRoot, ownedFiles = new Set) {
|
|
2838
2843
|
const entries = [];
|
|
@@ -2942,7 +2947,7 @@ function writeFileWithDirs(target, content, mode) {
|
|
|
2942
2947
|
}
|
|
2943
2948
|
function appendBlock(repoRoot, op) {
|
|
2944
2949
|
const target = abs(repoRoot, op.path);
|
|
2945
|
-
const existing =
|
|
2950
|
+
const existing = readFileSync5(target, "utf-8");
|
|
2946
2951
|
const sep2 = existing.endsWith(`
|
|
2947
2952
|
`) ? `
|
|
2948
2953
|
` : `
|
|
@@ -3064,7 +3069,7 @@ function planEject(manifest, repoRoot) {
|
|
|
3064
3069
|
});
|
|
3065
3070
|
continue;
|
|
3066
3071
|
}
|
|
3067
|
-
const content =
|
|
3072
|
+
const content = readFileSync5(p, "utf-8");
|
|
3068
3073
|
const stripped = stripBlockFromContent(content, b.marker, b.comment);
|
|
3069
3074
|
const removesHost = stripped !== null && blockStripLeavesEmpty(stripped);
|
|
3070
3075
|
actions.push({
|
|
@@ -3116,7 +3121,7 @@ function applyEject(plan, repoRoot) {
|
|
|
3116
3121
|
const p = containedAbs(repoRoot, a.path);
|
|
3117
3122
|
if (p === null)
|
|
3118
3123
|
continue;
|
|
3119
|
-
const content =
|
|
3124
|
+
const content = readFileSync5(p, "utf-8");
|
|
3120
3125
|
const stripped = stripBlockFromContent(content, a.marker, a.comment);
|
|
3121
3126
|
if (stripped === null)
|
|
3122
3127
|
continue;
|
|
@@ -3139,7 +3144,7 @@ function applyEject(plan, repoRoot) {
|
|
|
3139
3144
|
|
|
3140
3145
|
// src/commands/doctor.ts
|
|
3141
3146
|
function readVersion() {
|
|
3142
|
-
const pkg = JSON.parse(
|
|
3147
|
+
const pkg = JSON.parse(readFileSync6(join8(packageRoot(import.meta.url), "package.json"), "utf-8"));
|
|
3143
3148
|
return pkg.version;
|
|
3144
3149
|
}
|
|
3145
3150
|
function realDeps3() {
|
|
@@ -3163,7 +3168,7 @@ function readConfig(repoRoot) {
|
|
|
3163
3168
|
return { kind: "missing" };
|
|
3164
3169
|
let raw;
|
|
3165
3170
|
try {
|
|
3166
|
-
raw = JSON.parse(
|
|
3171
|
+
raw = JSON.parse(readFileSync6(p, "utf-8"));
|
|
3167
3172
|
} catch (err) {
|
|
3168
3173
|
return { kind: "invalid", error: `invalid JSON: ${err.message}` };
|
|
3169
3174
|
}
|
|
@@ -3199,7 +3204,7 @@ function diagnoseInstall(repoRoot, ctx, manifest) {
|
|
|
3199
3204
|
findings.push(owned ? error(check, `${op.path} is recorded as vinaya-managed but missing on disk — run \`vinaya upgrade\`.`) : error(check, `${op.path} is not installed — run \`vinaya init\`.`));
|
|
3200
3205
|
continue;
|
|
3201
3206
|
}
|
|
3202
|
-
const content =
|
|
3207
|
+
const content = readFileSync6(abs2, "utf-8");
|
|
3203
3208
|
if (!owned) {
|
|
3204
3209
|
findings.push(content === op.content ? warn(check, `${op.path} has vinaya's own content but isn't recorded in the manifest.`) : info(check, `${op.path} exists but is foreign content — not vinaya-managed, left untouched.`));
|
|
3205
3210
|
continue;
|
|
@@ -3222,7 +3227,7 @@ function diagnoseInstall(repoRoot, ctx, manifest) {
|
|
|
3222
3227
|
findings.push(owned ? error(check, `${op.path} is missing — likely a fresh clone (raw git hooks aren't tracked by git). Run \`vinaya upgrade\` to restore it.`) : info(check, `${op.path} is not installed.`));
|
|
3223
3228
|
continue;
|
|
3224
3229
|
}
|
|
3225
|
-
const content =
|
|
3230
|
+
const content = readFileSync6(abs2, "utf-8");
|
|
3226
3231
|
const { begin, end } = markerLines(op.marker, op.comment);
|
|
3227
3232
|
const hasMarkers = content.includes(begin) && content.includes(end);
|
|
3228
3233
|
if (!hasMarkers) {
|
|
@@ -3282,7 +3287,7 @@ function diagnoseGlobalConfigChecks() {
|
|
|
3282
3287
|
return [];
|
|
3283
3288
|
let raw;
|
|
3284
3289
|
try {
|
|
3285
|
-
raw = JSON.parse(
|
|
3290
|
+
raw = JSON.parse(readFileSync6(GLOBAL_CONFIG_PATH, "utf-8"));
|
|
3286
3291
|
} catch (err) {
|
|
3287
3292
|
return [info("checks", `${GLOBAL_CONFIG_PATH} is invalid JSON — ${err.message}`)];
|
|
3288
3293
|
}
|
|
@@ -3380,7 +3385,7 @@ async function doctorCommand(args) {
|
|
|
3380
3385
|
}
|
|
3381
3386
|
|
|
3382
3387
|
// src/commands/eject.ts
|
|
3383
|
-
import { existsSync as existsSync9, readFileSync as
|
|
3388
|
+
import { existsSync as existsSync9, readFileSync as readFileSync7 } from "node:fs";
|
|
3384
3389
|
import { join as join9 } from "node:path";
|
|
3385
3390
|
|
|
3386
3391
|
// src/lib/prompt.ts
|
|
@@ -3467,7 +3472,7 @@ function readManifest(repoRoot) {
|
|
|
3467
3472
|
return { kind: "none" };
|
|
3468
3473
|
let raw;
|
|
3469
3474
|
try {
|
|
3470
|
-
raw = JSON.parse(
|
|
3475
|
+
raw = JSON.parse(readFileSync7(p, "utf-8"));
|
|
3471
3476
|
} catch (err) {
|
|
3472
3477
|
return { kind: "orphan", reason: `vinaya.config.json is not valid JSON: ${err.message}` };
|
|
3473
3478
|
}
|
|
@@ -3550,7 +3555,7 @@ async function ejectCommand(args) {
|
|
|
3550
3555
|
}
|
|
3551
3556
|
|
|
3552
3557
|
// src/commands/init.ts
|
|
3553
|
-
import { existsSync as existsSync10, readFileSync as
|
|
3558
|
+
import { existsSync as existsSync10, readFileSync as readFileSync8, writeFileSync as writeFileSync4 } from "node:fs";
|
|
3554
3559
|
import { join as join10 } from "node:path";
|
|
3555
3560
|
function realDeps5() {
|
|
3556
3561
|
return {
|
|
@@ -3575,14 +3580,14 @@ function readManifest2(repoRoot) {
|
|
|
3575
3580
|
if (!existsSync10(p))
|
|
3576
3581
|
return null;
|
|
3577
3582
|
try {
|
|
3578
|
-
return VinayaConfigSchema.parse(JSON.parse(
|
|
3583
|
+
return VinayaConfigSchema.parse(JSON.parse(readFileSync8(p, "utf-8"))).managed ?? null;
|
|
3579
3584
|
} catch {
|
|
3580
3585
|
return null;
|
|
3581
3586
|
}
|
|
3582
3587
|
}
|
|
3583
3588
|
function writeManifest(repoRoot, manifest) {
|
|
3584
3589
|
const configAbs = join10(repoRoot, CONFIG_PATH);
|
|
3585
|
-
const seed = JSON.parse(
|
|
3590
|
+
const seed = JSON.parse(readFileSync8(configAbs, "utf-8"));
|
|
3586
3591
|
writeFileSync4(configAbs, `${JSON.stringify({ ...seed, managed: manifest }, null, 2)}
|
|
3587
3592
|
`, "utf-8");
|
|
3588
3593
|
}
|
|
@@ -3722,7 +3727,7 @@ import { execFileSync as execFileSync6 } from "node:child_process";
|
|
|
3722
3727
|
|
|
3723
3728
|
// src/lib/forge-write.ts
|
|
3724
3729
|
import { mkdtempSync, rmSync as rmSync3, writeFileSync as writeFileSync5 } from "node:fs";
|
|
3725
|
-
import { readFileSync as
|
|
3730
|
+
import { readFileSync as readFileSync9 } from "node:fs";
|
|
3726
3731
|
import { tmpdir } from "node:os";
|
|
3727
3732
|
import { join as join11 } from "node:path";
|
|
3728
3733
|
class ForgeArgError extends Error {
|
|
@@ -3734,13 +3739,13 @@ function locateBody(args) {
|
|
|
3734
3739
|
const p = args[i + 1];
|
|
3735
3740
|
if (!p)
|
|
3736
3741
|
throw new ForgeArgError("`--body-file` was given with no path.");
|
|
3737
|
-
return { body:
|
|
3742
|
+
return { body: readFileSync9(p, "utf8"), source: { kind: "file", argIndex: i + 1, inlineForm: false } };
|
|
3738
3743
|
}
|
|
3739
3744
|
if (a.startsWith("--body-file=")) {
|
|
3740
3745
|
const p = a.slice("--body-file=".length);
|
|
3741
3746
|
if (!p)
|
|
3742
3747
|
throw new ForgeArgError("`--body-file=` was given with no path.");
|
|
3743
|
-
return { body:
|
|
3748
|
+
return { body: readFileSync9(p, "utf8"), source: { kind: "file", argIndex: i, inlineForm: true } };
|
|
3744
3749
|
}
|
|
3745
3750
|
if (a === "--body" || a === "-b") {
|
|
3746
3751
|
const v = args[i + 1];
|
|
@@ -4030,7 +4035,7 @@ function issueEditCommand(args) {
|
|
|
4030
4035
|
}
|
|
4031
4036
|
|
|
4032
4037
|
// src/commands/new-check.ts
|
|
4033
|
-
import { chmodSync as chmodSync2, existsSync as existsSync11, mkdirSync as mkdirSync3, readFileSync as
|
|
4038
|
+
import { chmodSync as chmodSync2, existsSync as existsSync11, mkdirSync as mkdirSync3, readFileSync as readFileSync10, writeFileSync as writeFileSync6 } from "node:fs";
|
|
4034
4039
|
import { join as join12 } from "node:path";
|
|
4035
4040
|
var TEMPLATE_PATH = join12(packageRoot(import.meta.url), "templates", "custom-check.template.ts");
|
|
4036
4041
|
var CHECKS_DIR = join12("scripts", "vinaya-checks");
|
|
@@ -4049,7 +4054,7 @@ function newCheckCommand(args) {
|
|
|
4049
4054
|
console.error(`Error: ${targetPath} already exists.`);
|
|
4050
4055
|
process.exit(1);
|
|
4051
4056
|
}
|
|
4052
|
-
const template =
|
|
4057
|
+
const template = readFileSync10(TEMPLATE_PATH, "utf-8");
|
|
4053
4058
|
const contents = template.split("{{CHECK_NAME}}").join(name);
|
|
4054
4059
|
writeFileSync6(targetPath, contents, "utf-8");
|
|
4055
4060
|
chmodSync2(targetPath, 493);
|
|
@@ -4213,7 +4218,7 @@ function prEditCommand(args) {
|
|
|
4213
4218
|
|
|
4214
4219
|
// src/commands/studio.ts
|
|
4215
4220
|
import { spawn as spawn2 } from "node:child_process";
|
|
4216
|
-
import { existsSync as existsSync12, readFileSync as
|
|
4221
|
+
import { existsSync as existsSync12, readFileSync as readFileSync11 } from "node:fs";
|
|
4217
4222
|
import { dirname as dirname4, join as join13 } from "node:path";
|
|
4218
4223
|
function resolveStudioTarget(cwd) {
|
|
4219
4224
|
let dir = cwd;
|
|
@@ -4222,7 +4227,7 @@ function resolveStudioTarget(cwd) {
|
|
|
4222
4227
|
const pkgPath = join13(webDir, "package.json");
|
|
4223
4228
|
if (existsSync12(pkgPath)) {
|
|
4224
4229
|
try {
|
|
4225
|
-
const pkg = JSON.parse(
|
|
4230
|
+
const pkg = JSON.parse(readFileSync11(pkgPath, "utf-8"));
|
|
4226
4231
|
if (pkg.name === "@atta/vinaya-web") {
|
|
4227
4232
|
return { kind: "workspace", webDir };
|
|
4228
4233
|
}
|
|
@@ -4255,7 +4260,7 @@ async function runStudio(cwd, args) {
|
|
|
4255
4260
|
}
|
|
4256
4261
|
|
|
4257
4262
|
// src/commands/upgrade.ts
|
|
4258
|
-
import { existsSync as existsSync13, readFileSync as
|
|
4263
|
+
import { existsSync as existsSync13, readFileSync as readFileSync12, writeFileSync as writeFileSync7 } from "node:fs";
|
|
4259
4264
|
import { join as join14 } from "node:path";
|
|
4260
4265
|
function realDeps6() {
|
|
4261
4266
|
return {
|
|
@@ -4277,7 +4282,7 @@ function readManifest3(repoRoot) {
|
|
|
4277
4282
|
return { kind: "missing" };
|
|
4278
4283
|
let raw;
|
|
4279
4284
|
try {
|
|
4280
|
-
raw = JSON.parse(
|
|
4285
|
+
raw = JSON.parse(readFileSync12(p, "utf-8"));
|
|
4281
4286
|
} catch (err) {
|
|
4282
4287
|
return { kind: "invalid", error: `invalid JSON: ${err.message}` };
|
|
4283
4288
|
}
|
|
@@ -4294,7 +4299,7 @@ function readManifest3(repoRoot) {
|
|
|
4294
4299
|
}
|
|
4295
4300
|
function writeManifestVersion(repoRoot, manifest) {
|
|
4296
4301
|
const configAbs = join14(repoRoot, CONFIG_PATH);
|
|
4297
|
-
const seed = JSON.parse(
|
|
4302
|
+
const seed = JSON.parse(readFileSync12(configAbs, "utf-8"));
|
|
4298
4303
|
const updated = { ...manifest, version: MANAGED_MANIFEST_VERSION };
|
|
4299
4304
|
writeFileSync7(configAbs, `${JSON.stringify({ ...seed, managed: updated }, null, 2)}
|
|
4300
4305
|
`, "utf-8");
|
|
@@ -4318,7 +4323,7 @@ function planUpgrade(ops, repoRoot, manifest) {
|
|
|
4318
4323
|
} else if (!exists) {
|
|
4319
4324
|
action = "recreate";
|
|
4320
4325
|
hasChanges = true;
|
|
4321
|
-
} else if (
|
|
4326
|
+
} else if (readFileSync12(abs2, "utf-8") !== op.content) {
|
|
4322
4327
|
action = "regenerate";
|
|
4323
4328
|
hasChanges = true;
|
|
4324
4329
|
} else {
|
|
@@ -4335,7 +4340,7 @@ function planUpgrade(ops, repoRoot, manifest) {
|
|
|
4335
4340
|
action = "recreate-host";
|
|
4336
4341
|
hasChanges = true;
|
|
4337
4342
|
} else {
|
|
4338
|
-
const content =
|
|
4343
|
+
const content = readFileSync12(abs2, "utf-8");
|
|
4339
4344
|
const { begin, end } = markerLines(op.marker, op.comment);
|
|
4340
4345
|
if (!(content.includes(begin) && content.includes(end))) {
|
|
4341
4346
|
action = "recreate-append";
|
|
@@ -4412,7 +4417,7 @@ function renderUpgradeDiff(plan) {
|
|
|
4412
4417
|
}
|
|
4413
4418
|
function regenerateBlock(repoRoot, op) {
|
|
4414
4419
|
const abs2 = join14(repoRoot, op.path);
|
|
4415
|
-
const content =
|
|
4420
|
+
const content = readFileSync12(abs2, "utf-8");
|
|
4416
4421
|
const stripped = stripBlockFromContent(content, op.marker, op.comment);
|
|
4417
4422
|
if (stripped !== null) {
|
|
4418
4423
|
writeFileSync7(abs2, stripped.endsWith(`
|
|
@@ -4837,7 +4842,7 @@ function printHelp() {
|
|
|
4837
4842
|
// src/index.ts
|
|
4838
4843
|
var PACKAGE_ROOT = join15(dirname5(fileURLToPath2(import.meta.url)), "..");
|
|
4839
4844
|
function readVersion2() {
|
|
4840
|
-
const pkg = JSON.parse(
|
|
4845
|
+
const pkg = JSON.parse(readFileSync13(join15(PACKAGE_ROOT, "package.json"), "utf-8"));
|
|
4841
4846
|
return pkg.version;
|
|
4842
4847
|
}
|
|
4843
4848
|
var [, , command, ...args] = process.argv;
|
package/package.json
CHANGED