viberails 0.5.3 → 0.5.4
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.cjs +30 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -12
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -66,7 +66,7 @@ var clack5 = __toESM(require("@clack/prompts"), 1);
|
|
|
66
66
|
// src/utils/prompt-integrations.ts
|
|
67
67
|
var import_node_child_process = require("child_process");
|
|
68
68
|
var clack = __toESM(require("@clack/prompts"), 1);
|
|
69
|
-
async function promptHookManagerInstall(projectRoot, packageManager) {
|
|
69
|
+
async function promptHookManagerInstall(projectRoot, packageManager, isWorkspace) {
|
|
70
70
|
const choice = await clack.select({
|
|
71
71
|
message: "No git hook manager detected. Install Lefthook for shareable pre-commit hooks?",
|
|
72
72
|
options: [
|
|
@@ -85,7 +85,7 @@ async function promptHookManagerInstall(projectRoot, packageManager) {
|
|
|
85
85
|
assertNotCancelled(choice);
|
|
86
86
|
if (choice !== "install") return void 0;
|
|
87
87
|
const pm = packageManager || "npm";
|
|
88
|
-
const installCmd = pm === "yarn" ? "yarn add -D lefthook" : pm === "pnpm" ?
|
|
88
|
+
const installCmd = pm === "yarn" ? "yarn add -D lefthook" : pm === "pnpm" ? `pnpm add -D${isWorkspace ? " -w" : ""} lefthook` : "npm install -D lefthook";
|
|
89
89
|
const s = clack.spinner();
|
|
90
90
|
s.start("Installing Lefthook...");
|
|
91
91
|
const result = (0, import_node_child_process.spawnSync)(installCmd, {
|
|
@@ -113,7 +113,8 @@ async function promptIntegrations(projectRoot, hookManager, tools) {
|
|
|
113
113
|
if (!resolvedHookManager) {
|
|
114
114
|
resolvedHookManager = await promptHookManagerInstall(
|
|
115
115
|
projectRoot,
|
|
116
|
-
tools?.packageManager ?? "npm"
|
|
116
|
+
tools?.packageManager ?? "npm",
|
|
117
|
+
tools?.isWorkspace
|
|
117
118
|
);
|
|
118
119
|
}
|
|
119
120
|
const isBareHook = !resolvedHookManager;
|
|
@@ -2500,7 +2501,8 @@ function checkCoveragePrereqs(projectRoot, scanResult) {
|
|
|
2500
2501
|
return hasDependency(pkgDir, "@vitest/coverage-v8") || hasDependency(pkgDir, "@vitest/coverage-istanbul");
|
|
2501
2502
|
});
|
|
2502
2503
|
}
|
|
2503
|
-
const
|
|
2504
|
+
const isWorkspace = scanResult.packages.length > 1;
|
|
2505
|
+
const addCmd = pm === "yarn" ? "yarn add -D" : pm === "pnpm" && isWorkspace ? "pnpm add -D -w" : pm === "npm" ? "npm install -D" : `${pm} add -D`;
|
|
2504
2506
|
const affectedPackages = vitestPackages.length > 1 ? vitestPackages : void 0;
|
|
2505
2507
|
const reason = affectedPackages ? `Required for coverage in: ${affectedPackages.join(", ")}` : "Required for coverage percentage checks with vitest";
|
|
2506
2508
|
return [
|
|
@@ -2701,7 +2703,6 @@ function addLefthookPreCommit(lefthookPath) {
|
|
|
2701
2703
|
function detectHookManager(projectRoot) {
|
|
2702
2704
|
if (fs16.existsSync(path16.join(projectRoot, "lefthook.yml"))) return "Lefthook";
|
|
2703
2705
|
if (fs16.existsSync(path16.join(projectRoot, ".husky"))) return "Husky";
|
|
2704
|
-
if (fs16.existsSync(path16.join(projectRoot, ".git"))) return "git hook";
|
|
2705
2706
|
return void 0;
|
|
2706
2707
|
}
|
|
2707
2708
|
function setupClaudeCodeHook(projectRoot) {
|
|
@@ -2755,7 +2756,7 @@ function setupClaudeMdReference(projectRoot) {
|
|
|
2755
2756
|
fs16.writeFileSync(claudeMdPath, prefix + ref);
|
|
2756
2757
|
console.log(` ${import_chalk9.default.green("\u2713")} CLAUDE.md \u2014 added @.viberails/context.md reference`);
|
|
2757
2758
|
}
|
|
2758
|
-
function setupGithubAction(projectRoot, packageManager) {
|
|
2759
|
+
function setupGithubAction(projectRoot, packageManager, options) {
|
|
2759
2760
|
const workflowDir = path16.join(projectRoot, ".github", "workflows");
|
|
2760
2761
|
const workflowPath = path16.join(workflowDir, "viberails.yml");
|
|
2761
2762
|
if (fs16.existsSync(workflowPath)) {
|
|
@@ -2791,7 +2792,16 @@ function setupGithubAction(projectRoot, packageManager) {
|
|
|
2791
2792
|
" node-version: 22",
|
|
2792
2793
|
pm !== "npm" ? ` cache: ${pm}` : "",
|
|
2793
2794
|
"",
|
|
2794
|
-
` - run: ${installCmd}
|
|
2795
|
+
` - run: ${installCmd}`
|
|
2796
|
+
);
|
|
2797
|
+
if (options?.typecheck) {
|
|
2798
|
+
lines.push(` - run: ${runPrefix} tsc --noEmit`);
|
|
2799
|
+
}
|
|
2800
|
+
if (options?.linter) {
|
|
2801
|
+
const lintCmd = options.linter === "biome" ? "biome check ." : "eslint .";
|
|
2802
|
+
lines.push(` - run: ${runPrefix} ${lintCmd}`);
|
|
2803
|
+
}
|
|
2804
|
+
lines.push(
|
|
2795
2805
|
` - run: ${runPrefix} viberails check --enforce --diff-base origin/\${{ github.event.pull_request.base.ref }}`,
|
|
2796
2806
|
""
|
|
2797
2807
|
);
|
|
@@ -2912,7 +2922,10 @@ function setupSelectedIntegrations(projectRoot, integrations, opts) {
|
|
|
2912
2922
|
created.push("CLAUDE.md \u2014 added @.viberails/context.md reference");
|
|
2913
2923
|
}
|
|
2914
2924
|
if (integrations.githubAction) {
|
|
2915
|
-
const t = setupGithubAction(projectRoot, opts.packageManager ?? "npm"
|
|
2925
|
+
const t = setupGithubAction(projectRoot, opts.packageManager ?? "npm", {
|
|
2926
|
+
linter: integrations.lintHook ? opts.linter : void 0,
|
|
2927
|
+
typecheck: integrations.typecheckHook
|
|
2928
|
+
});
|
|
2916
2929
|
if (t) created.push(`${t} \u2014 blocks PRs on violations`);
|
|
2917
2930
|
}
|
|
2918
2931
|
return created;
|
|
@@ -2980,11 +2993,15 @@ async function initNonInteractive(projectRoot, configPath) {
|
|
|
2980
2993
|
setupClaudeMdReference(projectRoot);
|
|
2981
2994
|
const rootPkg = config.packages[0];
|
|
2982
2995
|
const rootPkgPm = rootPkg?.stack?.packageManager ?? "npm";
|
|
2983
|
-
const
|
|
2996
|
+
const linter = rootPkg?.stack?.linter?.split("@")[0];
|
|
2997
|
+
const isTypeScript = rootPkg?.stack?.language === "typescript";
|
|
2998
|
+
const actionTarget = setupGithubAction(projectRoot, rootPkgPm, {
|
|
2999
|
+
linter,
|
|
3000
|
+
typecheck: isTypeScript
|
|
3001
|
+
});
|
|
2984
3002
|
const hookManager = detectHookManager(projectRoot);
|
|
2985
3003
|
const hasHookManager = hookManager === "Lefthook" || hookManager === "Husky";
|
|
2986
3004
|
const preCommitTarget = hasHookManager ? setupPreCommitHook(projectRoot) : void 0;
|
|
2987
|
-
const linter = rootPkg?.stack?.linter?.split("@")[0];
|
|
2988
3005
|
const ok = import_chalk11.default.green("\u2713");
|
|
2989
3006
|
const created = [
|
|
2990
3007
|
`${ok} ${path18.basename(configPath)}`,
|
|
@@ -3077,7 +3094,8 @@ async function initInteractive(projectRoot, configPath, options) {
|
|
|
3077
3094
|
const integrations = await promptIntegrations(projectRoot, hookManager, {
|
|
3078
3095
|
isTypeScript: rootPkgStack?.language === "typescript",
|
|
3079
3096
|
linter: rootPkgStack?.linter?.split("@")[0],
|
|
3080
|
-
packageManager: rootPkgStack?.packageManager
|
|
3097
|
+
packageManager: rootPkgStack?.packageManager,
|
|
3098
|
+
isWorkspace: config.packages.length > 1
|
|
3081
3099
|
});
|
|
3082
3100
|
const shouldWrite = await confirm3("Write configuration and set up selected integrations?");
|
|
3083
3101
|
if (!shouldWrite) {
|
|
@@ -3213,7 +3231,7 @@ ${import_chalk12.default.bold("Synced:")}`);
|
|
|
3213
3231
|
}
|
|
3214
3232
|
|
|
3215
3233
|
// src/index.ts
|
|
3216
|
-
var VERSION = "0.5.
|
|
3234
|
+
var VERSION = "0.5.4";
|
|
3217
3235
|
var program = new import_commander.Command();
|
|
3218
3236
|
program.name("viberails").description("Guardrails for vibe coding").version(VERSION);
|
|
3219
3237
|
program.command("init", { isDefault: true }).description("Scan your project and set up enforcement guardrails").option("-y, --yes", "Non-interactive mode (use defaults, high-confidence only)").option("-f, --force", "Re-initialize, replacing existing config").action(async (options) => {
|