config-vp 1.2.0 → 1.2.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/README.md +19 -0
- package/dist/index.mjs +12 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -213,6 +213,25 @@ Run any task with `vp run <task>`. Tasks are cached and run in dependency order
|
|
|
213
213
|
|
|
214
214
|
> For a whole-workspace lint/format, use the built-in `vp check`. To build every package, use `vp run -r build`.
|
|
215
215
|
|
|
216
|
+
### Overriding a task with a package.json script
|
|
217
|
+
|
|
218
|
+
**Your `package.json` scripts win.** If a package defines a script with the same name as a generated task, config-vp drops its own task and your script takes over — no clash, no config needed:
|
|
219
|
+
|
|
220
|
+
```jsonc
|
|
221
|
+
// package.json
|
|
222
|
+
{
|
|
223
|
+
"scripts": {
|
|
224
|
+
"build": "tsx scripts/build.ts", // replaces the generated `build` task
|
|
225
|
+
},
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
```sh
|
|
230
|
+
vp run build # runs your script, not `vp pack`
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
This is the simplest way to special-case one task while keeping every other default. (Without it, `vp` errors with _"Task `build` conflicts with a package.json script of the same name"_.) For richer changes — tweaking a task's command, cache behavior, or adding new tasks — use the [`config` hook](#customizing) instead; reach for a script only when you want to shadow a task outright.
|
|
234
|
+
|
|
216
235
|
## Customizing
|
|
217
236
|
|
|
218
237
|
There's one customization hook: **`config`**. It receives the fully built config — lint, fmt, staged, run tasks, and (for `lib*`) pack, all already populated — and you change whatever you want with plain JS. Mutate it in place, or return a new object (a returned value wins; otherwise the mutated argument is used). It's fully typed, so autocomplete shows you exactly what's there.
|
package/dist/index.mjs
CHANGED
|
@@ -531,6 +531,16 @@ function callerPackageDir() {
|
|
|
531
531
|
if (direct && !direct[1].includes("/node_modules/")) return direct[1];
|
|
532
532
|
}
|
|
533
533
|
}
|
|
534
|
+
/** Script names in the calling package's package.json — these override our generated tasks. */
|
|
535
|
+
function packageScriptNames() {
|
|
536
|
+
const dir = callerPackageDir() ?? process.cwd();
|
|
537
|
+
try {
|
|
538
|
+
const pkg = JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
|
|
539
|
+
return new Set(Object.keys(pkg.scripts ?? {}));
|
|
540
|
+
} catch {
|
|
541
|
+
return /* @__PURE__ */ new Set();
|
|
542
|
+
}
|
|
543
|
+
}
|
|
534
544
|
/** True when the calling config's package is the workspace root (or a standalone project). */
|
|
535
545
|
function isProjectRoot() {
|
|
536
546
|
const dir = callerPackageDir() ?? process.cwd();
|
|
@@ -590,7 +600,8 @@ function buildRunConfig(options = {}) {
|
|
|
590
600
|
command: "vp-setup-vscode",
|
|
591
601
|
cache: false
|
|
592
602
|
};
|
|
593
|
-
|
|
603
|
+
const scripts = packageScriptNames();
|
|
604
|
+
return { tasks: Object.fromEntries(Object.entries(tasks).filter(([name]) => !scripts.has(name))) };
|
|
594
605
|
}
|
|
595
606
|
//#endregion
|
|
596
607
|
//#region src/staged.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "config-vp",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Shared vite-plus configuration — opinionated defaults for linting, formatting, task running, staged checks, and VSCode setup. Optional Vue and pack layers with deep-merge overrides.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"config",
|