clispark 1.17.1 → 1.19.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 CHANGED
@@ -63,6 +63,50 @@ npx clispark releasenotes
63
63
 
64
64
  shows what changed between the clispark version your project last updated to and the latest one available, pulled straight from the project's GitHub releases.
65
65
 
66
+ ## Post-scaffold hooks
67
+
68
+ Right after a new project finishes scaffolding, clispark checks for a single, globally-configured hook file and runs it automatically if present — useful for anything you always want to happen after a fresh project, without answering a wizard question every time (auto-creating a GitHub repo, copying in a company-standard CI config, registering the project in an internal catalog, and so on).
69
+
70
+ ```bash
71
+ npx clispark hook
72
+ ```
73
+
74
+ prints the exact file location for your OS and whether one is currently configured. The location is fixed and not configurable:
75
+
76
+ | OS | Location |
77
+ |---|---|
78
+ | Linux | `~/.config/clispark/hooks/post-scaffold.mjs` (or `$XDG_CONFIG_HOME/clispark/hooks/post-scaffold.mjs`) |
79
+ | macOS | `~/Library/Preferences/clispark/hooks/post-scaffold.mjs` |
80
+ | Windows | `%APPDATA%\clispark\Config\hooks\post-scaffold.mjs` |
81
+
82
+ If the file doesn't exist, nothing happens — most users will never have one. If it exists, it must be an ES module with a default-exported function (sync or async), which receives one argument:
83
+
84
+ ```js
85
+ export default async function postScaffold({ projectName, targetDir, language, registryUrl, publishIntent }) {
86
+ // your code here
87
+ }
88
+ ```
89
+
90
+ If clispark has the `clispark` package installed as a dev dependency, the shape of that argument is available as a type: `import type { PostScaffoldHookContext } from 'clispark'`.
91
+
92
+ A failing hook (throws, rejects, or doesn't export a function) prints a clear warning but never affects the outcome of the scaffold itself — your new project is already fully created by the time the hook runs. Pass `--no-hook` to skip it for a single run even if one is configured.
93
+
94
+ **Example** — push the new project to a freshly created GitHub repo:
95
+
96
+ ```js
97
+ // post-scaffold.mjs
98
+ import { execFileSync } from 'node:child_process';
99
+
100
+ export default function postScaffold({ projectName, targetDir }) {
101
+ execFileSync('gh', ['repo', 'create', projectName, '--private', '--source', targetDir, '--push'], {
102
+ cwd: targetDir,
103
+ stdio: 'inherit',
104
+ });
105
+ }
106
+ ```
107
+
108
+ Hooks only run after a fresh `clispark` scaffold — never after `clispark update` or `clispark add`.
109
+
66
110
  ## Tech stack
67
111
 
68
112
  **Generator itself (`clispark`):** TypeScript, [commander](https://github.com/tj/commander.js) (CLI structure), [@clack/prompts](https://github.com/bombshell-dev/clack) (interactive wizard), `cross-spawn` (cross-platform shelling out to git/npm), `pino` + `env-paths` (own logging), `tsup` + `vitest`.