@verndale/ai-commit 2.1.0 → 2.2.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 +2 -2
- package/bin/cli.js +19 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,13 +18,13 @@ The same package works with **npm** or **yarn** (for example `npm install -D @ve
|
|
|
18
18
|
## Quick setup (deterministic order)
|
|
19
19
|
|
|
20
20
|
1. **Install** the dev dependency (see [Install](#install)).
|
|
21
|
-
2. **Init** — From the **git repo root** (where **`package.json`** lives), run **`pnpm exec ai-commit init`**. That merges **`.env`**
|
|
21
|
+
2. **Init** — From the **git repo root** (where **`package.json`** lives), run **`pnpm exec ai-commit init`**. That merges **`.env`** and **`.env.example`** (creates **`.env.example`** from the bundled template if it is missing; see [`.env.example`](.env.example) for keys and comments), runs **`npx husky@9 init`** if Husky is not present, adds missing **`commit`** / **`prepare`** / **`husky`** entries to **`package.json`** when the file exists, and writes **`.husky`** hooks. **Install dependencies** afterward if **`package.json`** changed (`pnpm install`, `npm install`, etc.).
|
|
22
22
|
- Not in a git repo? **init** only updates env files and explains that Git/Husky were skipped.
|
|
23
23
|
- Env files only? Use **`pnpm exec ai-commit init --env-only`**.
|
|
24
24
|
- Hooks only (no **`package.json`** changes)? Use **`pnpm exec ai-commit init --husky`**.
|
|
25
25
|
3. **Secrets** — Set **`OPENAI_API_KEY`** in `.env` and/or `.env.local` (`.env.local` overrides `.env` for duplicate keys).
|
|
26
26
|
|
|
27
|
-
Use **`ai-commit init --force`** to replace **`.env`** with the bundled template (destructive) or to overwrite existing Husky hook files.
|
|
27
|
+
Use **`ai-commit init --force`** to replace **`.env`** and **`.env.example`** with the bundled template (destructive) or to overwrite existing Husky hook files. Without **`--force`**, **init** creates **`.env.example`** when missing and otherwise appends missing ai-commit keys (same as **`.env`**).
|
|
28
28
|
|
|
29
29
|
## Environment
|
|
30
30
|
|
package/bin/cli.js
CHANGED
|
@@ -115,22 +115,25 @@ function cmdInit(argv) {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
const envExampleDest = path.join(cwd, ".env.example");
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
118
|
+
const exResult = mergeAiCommitEnvFile(envExampleDest, examplePath, { force });
|
|
119
|
+
const exRel = path.relative(cwd, envExampleDest) || ".env.example";
|
|
120
|
+
switch (exResult.kind) {
|
|
121
|
+
case "replaced":
|
|
122
|
+
process.stdout.write(`Replaced ${exRel} with bundled template (--force).\n`);
|
|
123
|
+
break;
|
|
124
|
+
case "wrote":
|
|
125
|
+
process.stdout.write(`Wrote ${exRel} from bundled template.\n`);
|
|
126
|
+
break;
|
|
127
|
+
case "merged":
|
|
128
|
+
process.stdout.write(`Appended missing @verndale/ai-commit keys to ${exRel}.\n`);
|
|
129
|
+
break;
|
|
130
|
+
case "unchanged":
|
|
131
|
+
process.stdout.write(
|
|
132
|
+
`No missing @verndale/ai-commit keys in ${exRel}; left unchanged. Use --force to replace the file with the bundled template.\n`,
|
|
133
|
+
);
|
|
134
|
+
break;
|
|
135
|
+
default:
|
|
136
|
+
break;
|
|
134
137
|
}
|
|
135
138
|
|
|
136
139
|
if (envOnly) {
|