@grove-dev/cli 0.7.0 → 0.9.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.
Files changed (187) hide show
  1. package/README.md +53 -13
  2. package/dist/audit-cli.d.ts +1 -1
  3. package/dist/audit-cli.d.ts.map +1 -1
  4. package/dist/audit-cli.js +11 -11
  5. package/dist/audit-cli.js.map +1 -1
  6. package/dist/audit.d.ts +4 -4
  7. package/dist/audit.d.ts.map +1 -1
  8. package/dist/audit.js +91 -51
  9. package/dist/audit.js.map +1 -1
  10. package/dist/collection-cli.d.ts.map +1 -1
  11. package/dist/collection-cli.js +1 -1
  12. package/dist/collection-cli.js.map +1 -1
  13. package/dist/diff.d.ts +43 -0
  14. package/dist/diff.d.ts.map +1 -0
  15. package/dist/diff.js +70 -0
  16. package/dist/diff.js.map +1 -0
  17. package/dist/hash.d.ts +36 -0
  18. package/dist/hash.d.ts.map +1 -0
  19. package/dist/hash.js +82 -0
  20. package/dist/hash.js.map +1 -0
  21. package/dist/health-cli.d.ts +3 -0
  22. package/dist/health-cli.d.ts.map +1 -0
  23. package/dist/health-cli.js +15 -0
  24. package/dist/health-cli.js.map +1 -0
  25. package/dist/health.d.ts +7 -0
  26. package/dist/health.d.ts.map +1 -0
  27. package/dist/health.js +68 -0
  28. package/dist/health.js.map +1 -0
  29. package/dist/icons-cli.d.ts +1 -1
  30. package/dist/icons-cli.d.ts.map +1 -1
  31. package/dist/icons-cli.js +33 -14
  32. package/dist/icons-cli.js.map +1 -1
  33. package/dist/import-cli.d.ts +1 -1
  34. package/dist/import-cli.d.ts.map +1 -1
  35. package/dist/import-cli.js +6 -6
  36. package/dist/import-cli.js.map +1 -1
  37. package/dist/index.js +114 -70
  38. package/dist/index.js.map +1 -1
  39. package/dist/init.d.ts +52 -4
  40. package/dist/init.d.ts.map +1 -1
  41. package/dist/init.js +378 -57
  42. package/dist/init.js.map +1 -1
  43. package/dist/package-manager.d.ts +57 -0
  44. package/dist/package-manager.d.ts.map +1 -0
  45. package/dist/package-manager.js +157 -0
  46. package/dist/package-manager.js.map +1 -0
  47. package/dist/package.json +3 -2
  48. package/dist/r/about.json +23 -0
  49. package/dist/r/browse.json +90 -0
  50. package/dist/r/collections.json +60 -0
  51. package/dist/r/contributors.json +23 -0
  52. package/dist/r/default.json +439 -0
  53. package/dist/r/home.json +68 -0
  54. package/dist/r/not-found.json +23 -0
  55. package/dist/r/project-card.json +49 -0
  56. package/dist/r/record.json +60 -0
  57. package/dist/r/registry.json +916 -0
  58. package/dist/r/shell.json +76 -0
  59. package/dist/r/submit.json +29 -0
  60. package/dist/r/taxonomy.json +66 -0
  61. package/dist/r/ui.json +55 -0
  62. package/dist/readme-cli.d.ts +1 -1
  63. package/dist/readme-cli.d.ts.map +1 -1
  64. package/dist/readme-cli.js +37 -47
  65. package/dist/readme-cli.js.map +1 -1
  66. package/dist/registry.d.ts +80 -0
  67. package/dist/registry.d.ts.map +1 -0
  68. package/dist/registry.js +180 -0
  69. package/dist/registry.js.map +1 -0
  70. package/dist/run.d.ts +7 -0
  71. package/dist/run.d.ts.map +1 -0
  72. package/dist/run.js +20 -0
  73. package/dist/run.js.map +1 -0
  74. package/dist/unified-diff.d.ts +14 -0
  75. package/dist/unified-diff.d.ts.map +1 -0
  76. package/dist/unified-diff.js +103 -0
  77. package/dist/unified-diff.js.map +1 -0
  78. package/dist/update.d.ts +66 -0
  79. package/dist/update.d.ts.map +1 -0
  80. package/dist/update.js +311 -0
  81. package/dist/update.js.map +1 -0
  82. package/package.json +5 -4
  83. package/dist/site/.github/ISSUE_TEMPLATE/bug_report.md +0 -33
  84. package/dist/site/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  85. package/dist/site/.github/ISSUE_TEMPLATE/record_submission.md +0 -48
  86. package/dist/site/.github/pull_request_template.md +0 -27
  87. package/dist/site/.github/workflows/ci.yml +0 -21
  88. package/dist/site/.github/workflows/cleanup.yml +0 -27
  89. package/dist/site/.github/workflows/deploy.yml +0 -36
  90. package/dist/site/.github/workflows/readme.yml +0 -41
  91. package/dist/site/.github/workflows/sync-contributors.yml +0 -28
  92. package/dist/site/.github/workflows/sync-github.yml +0 -31
  93. package/dist/site/README.md +0 -89
  94. package/dist/site/astro.config.mjs +0 -26
  95. package/dist/site/content/records/crewai.md +0 -898
  96. package/dist/site/content/records/dify.md +0 -35
  97. package/dist/site/content/records/flowise.md +0 -38
  98. package/dist/site/content/records/llamaindex.md +0 -45
  99. package/dist/site/content/records/ollama.md +0 -39
  100. package/dist/site/content/records/open-webui.md +0 -35
  101. package/dist/site/data/collections/top-ai-agents.yml +0 -14
  102. package/dist/site/data/collections/top-flutter.yml +0 -12
  103. package/dist/site/data/health.yml +0 -13
  104. package/dist/site/data/records/.gitkeep +0 -0
  105. package/dist/site/data/records/crewai.yml +0 -23
  106. package/dist/site/data/records/dify.yml +0 -23
  107. package/dist/site/data/records/flowise.yml +0 -23
  108. package/dist/site/data/records/llamaindex.yml +0 -23
  109. package/dist/site/data/records/ollama.yml +0 -30
  110. package/dist/site/data/records/open-webui.yml +0 -23
  111. package/dist/site/data/taxonomy/categories.yml +0 -10
  112. package/dist/site/data/taxonomy/distribution-channels.yml +0 -43
  113. package/dist/site/data/taxonomy/licenses.yml +0 -16
  114. package/dist/site/data/taxonomy/platforms.yml +0 -20
  115. package/dist/site/data/taxonomy/stacks.yml +0 -15
  116. package/dist/site/data/taxonomy/topics.yml +0 -29
  117. package/dist/site/grove.config.ts +0 -110
  118. package/dist/site/package.json +0 -34
  119. package/dist/site/public/icons/.grove-icons.json +0 -47
  120. package/dist/site/public/icons/platforms/android.svg +0 -1
  121. package/dist/site/public/icons/platforms/app.svg +0 -4
  122. package/dist/site/public/icons/platforms/chrome.svg +0 -1
  123. package/dist/site/public/icons/platforms/desktop.svg +0 -4
  124. package/dist/site/public/icons/platforms/embedded.svg +0 -5
  125. package/dist/site/public/icons/platforms/ios.svg +0 -1
  126. package/dist/site/public/icons/platforms/linux.svg +0 -1
  127. package/dist/site/public/icons/platforms/macos.svg +0 -1
  128. package/dist/site/public/icons/platforms/ubuntu.svg +0 -1
  129. package/dist/site/public/icons/platforms/web.svg +0 -5
  130. package/dist/site/public/icons/platforms/windows.svg +0 -1
  131. package/dist/site/public/icons/stacks/android.svg +0 -1
  132. package/dist/site/public/icons/stacks/apple.svg +0 -1
  133. package/dist/site/public/icons/stacks/bun.svg +0 -1
  134. package/dist/site/public/icons/stacks/capacitor.svg +0 -1
  135. package/dist/site/public/icons/stacks/clojure.svg +0 -1
  136. package/dist/site/public/icons/stacks/dart.svg +0 -1
  137. package/dist/site/public/icons/stacks/deno.svg +0 -1
  138. package/dist/site/public/icons/stacks/django.svg +0 -1
  139. package/dist/site/public/icons/stacks/docker.svg +0 -1
  140. package/dist/site/public/icons/stacks/firebase.svg +0 -1
  141. package/dist/site/public/icons/stacks/flutter.svg +0 -1
  142. package/dist/site/public/icons/stacks/go.svg +0 -1
  143. package/dist/site/public/icons/stacks/graphql.svg +0 -1
  144. package/dist/site/public/icons/stacks/ionic.svg +0 -1
  145. package/dist/site/public/icons/stacks/java.svg +0 -1
  146. package/dist/site/public/icons/stacks/javascript.svg +0 -1
  147. package/dist/site/public/icons/stacks/kotlin.svg +0 -1
  148. package/dist/site/public/icons/stacks/llm.svg +0 -4
  149. package/dist/site/public/icons/stacks/mongodb.svg +0 -1
  150. package/dist/site/public/icons/stacks/nodejs.svg +0 -1
  151. package/dist/site/public/icons/stacks/python.svg +0 -1
  152. package/dist/site/public/icons/stacks/rag.svg +0 -6
  153. package/dist/site/public/icons/stacks/react-native.svg +0 -1
  154. package/dist/site/public/icons/stacks/react.svg +0 -1
  155. package/dist/site/public/icons/stacks/rust.svg +0 -1
  156. package/dist/site/public/icons/stacks/solidity.svg +0 -1
  157. package/dist/site/public/icons/stacks/sveltekit.svg +0 -1
  158. package/dist/site/public/icons/stacks/swift.svg +0 -1
  159. package/dist/site/public/icons/stacks/tauri.svg +0 -1
  160. package/dist/site/public/icons/stacks/tensorflow.svg +0 -1
  161. package/dist/site/public/icons/stacks/typescript.svg +0 -1
  162. package/dist/site/public/icons/stacks/vue.svg +0 -1
  163. package/dist/site/public/logo.svg +0 -16
  164. package/dist/site/src/components/DirectoryBrowse.astro +0 -246
  165. package/dist/site/src/components/PipelineStrip.astro +0 -121
  166. package/dist/site/src/components/TaxonomyList.astro +0 -108
  167. package/dist/site/src/pages/404.astro +0 -63
  168. package/dist/site/src/pages/[slug]/[recordSlug].astro +0 -71
  169. package/dist/site/src/pages/[slug]/index.astro +0 -19
  170. package/dist/site/src/pages/[slug]/page/[page].astro +0 -32
  171. package/dist/site/src/pages/[slug]/page/cards.astro +0 -50
  172. package/dist/site/src/pages/[slug]/page/records.json.ts +0 -24
  173. package/dist/site/src/pages/about.astro +0 -130
  174. package/dist/site/src/pages/categories/[name].astro +0 -35
  175. package/dist/site/src/pages/categories/index.astro +0 -33
  176. package/dist/site/src/pages/collections/[slug].astro +0 -45
  177. package/dist/site/src/pages/collections/index.astro +0 -32
  178. package/dist/site/src/pages/contributors.astro +0 -115
  179. package/dist/site/src/pages/empty.astro +0 -24
  180. package/dist/site/src/pages/index.astro +0 -161
  181. package/dist/site/src/pages/licenses/[name].astro +0 -35
  182. package/dist/site/src/pages/stacks/[name].astro +0 -35
  183. package/dist/site/src/pages/stacks/index.astro +0 -35
  184. package/dist/site/src/pages/submit.astro +0 -183
  185. package/dist/site/src/styles/global.css +0 -21
  186. package/dist/site/tsconfig.json +0 -13
  187. /package/{dist/site/LICENSE → LICENSE} +0 -0
package/dist/init.js CHANGED
@@ -1,20 +1,82 @@
1
- import { cp, mkdir, readFile, readdir, writeFile } from "node:fs/promises";
2
- import { existsSync } from "node:fs";
3
- import { dirname, relative, resolve } from "node:path";
4
- import { fileURLToPath } from "node:url";
5
- const SKIP_NAMES = new Set(["node_modules", "dist", ".astro", ".DS_Store"]);
6
- const GENERATED_PUBLIC_NAMES = new Set([
7
- "llms.txt",
8
- "llms-full.txt",
9
- "sitemap.xml",
10
- "robots.txt",
11
- "og-image.svg",
12
- "og",
13
- ]);
14
- const GROVE_PACKAGES = ["@grove-dev/astro", "@grove-dev/cli", "@grove-dev/core"];
1
+ // SPDX-License-Identifier: MIT
2
+ /**
3
+ * `grove init` — scaffold a Grove project from the registry.
4
+ *
5
+ * The UI is a shadcn registry (`@grove-dev/registry`); the full
6
+ * scaffold is its generated `default` item, and the official shadcn
7
+ * CLI installs it. `grove init` only has to set the table, in this
8
+ * order:
9
+ *
10
+ * 1. Refuse a non-empty directory.
11
+ * 2. Write package.json (name, `astro dev/build/check` scripts, no
12
+ * dependencies yet).
13
+ * 3. Write the project files shadcn needs to install into a bare
14
+ * directory — tsconfig.json (`@/*` alias, Bundler resolution,
15
+ * the `@grove/generated/*` alias the scaffold's code relies on)
16
+ * and components.json (registers the `@grove` registry URL so
17
+ * `npx shadcn add @grove/<item>` works later) — plus the files
18
+ * the scaffold does not ship because they are project-specific:
19
+ * grove.config.ts, astro.config.mjs, and an empty data/records/.
20
+ * Last of these, for pnpm projects only, is pnpm-workspace.yaml,
21
+ * which approves the dependency build scripts pnpm 11 refuses to
22
+ * skip silently.
23
+ * 4. `<pm> dlx shadcn@<pinned> add <bundled default.json> --yes`,
24
+ * where `<pm>` is whichever package manager the user has —
25
+ * detected, not assumed. shadcn writes every scaffold file under
26
+ * src/ and runs the package manager to install the item's deps
27
+ * (astro, tailwindcss, …) with real version ranges. If shadcn
28
+ * fails, the bundled item is written in-process instead — it
29
+ * inlines every file and names its own dependencies, so nothing
30
+ * about the result depends on a third-party CLI staying healthy.
31
+ * 5. Add `@grove-dev/{core,astro,cli}` to package.json,
32
+ * pinned to this CLI's version. After step 4 on purpose: shadcn
33
+ * installs whatever package.json declares, and Grove's own
34
+ * packages may not be resolvable at that moment (the scaffold
35
+ * smoke test points them at local tarballs afterwards).
36
+ * 6. Write `.grove/registry.lock.json` with the install-time hashes
37
+ * of the item's files, which `grove update` diffs against later.
38
+ *
39
+ * `grove init` does NOT scaffold `content/`, `public/`, `.github/`, or
40
+ * anything under `data/` besides the empty `records/` directory —
41
+ * those are content/workflow concerns, not UI-registry concerns. The
42
+ * CLI wrapper in index.ts runs `<pm> install` and `git init` after
43
+ * this returns, per its own `--no-install`/`--no-git` flags.
44
+ *
45
+ * Steps 2-6 are transactional: if any of them throws, everything
46
+ * written since step 1 is removed again, so the obvious retry is just
47
+ * `grove init` and not `rm -rf` first.
48
+ */
49
+ import { mkdir, readdir, readFile, rm, writeFile } from 'node:fs/promises';
50
+ import { dirname, resolve } from 'node:path';
51
+ import { fileURLToPath } from 'node:url';
52
+ import { writeLockfile } from './hash.js';
53
+ import { detectPackageManager, dlxCommand, requirePackageManager, } from './package-manager.js';
54
+ import { buildLockfile, loadItem, REGISTRY_NAMESPACE, REGISTRY_URL_TEMPLATE, resolveBundledItemPath, SHADCN_VERSION, writeItemFiles, } from './registry.js';
55
+ import { run } from './run.js';
56
+ const SKIP_NAMES = new Set(['node_modules', 'dist', '.astro', '.DS_Store', '.grove']);
57
+ // The registry is not in this list on purpose: shadcn installed the UI
58
+ // source into `src/`, so the consumer owns those files outright and never
59
+ // imports a registry package at runtime.
60
+ const GROVE_PACKAGES = ['@grove-dev/core', '@grove-dev/astro', '@grove-dev/cli'];
61
+ const PROJECT_SCRIPTS = {
62
+ dev: 'astro dev',
63
+ build: 'astro build',
64
+ check: 'astro check',
65
+ };
66
+ /**
67
+ * Dependency install scripts the generated project approves up front.
68
+ *
69
+ * astro pulls in vite, which pulls in esbuild, whose install script
70
+ * links esbuild's platform binary. pnpm 11 fails any install that
71
+ * skipped a build script (`ERR_PNPM_IGNORED_BUILDS`, exit 1) — which
72
+ * killed shadcn's `pnpm add` before it wrote a single scaffold file
73
+ * and left `grove init` with a package.json and no src/. pnpm 10 only
74
+ * warned, which is why CI, pinned to 10.12.1, never saw it.
75
+ */
76
+ const APPROVED_BUILD_SCRIPTS = ['esbuild'];
15
77
  export function readCliVersion() {
16
78
  const here = dirname(fileURLToPath(import.meta.url));
17
- for (const candidate of [resolve(here, "package.json"), resolve(here, "../package.json")]) {
79
+ for (const candidate of [resolve(here, 'package.json'), resolve(here, '../package.json')]) {
18
80
  try {
19
81
  const pkg = JSON.parse(requireText(candidate));
20
82
  if (pkg.version)
@@ -24,31 +86,23 @@ export function readCliVersion() {
24
86
  // Source and published layouts intentionally use different paths.
25
87
  }
26
88
  }
27
- return "0.0.0-dev";
89
+ return '0.0.0-dev';
28
90
  }
29
91
  function requireText(path) {
30
92
  // Synchronous version lookup happens once while constructing the CLI.
31
- return globalThis.process.getBuiltinModule("node:fs").readFileSync(path, "utf8");
32
- }
33
- export function scaffoldSource() {
34
- const here = dirname(fileURLToPath(import.meta.url));
35
- const candidates = [resolve(here, "site"), resolve(here, "../../../apps/example")];
36
- const found = candidates.find((candidate) => existsSync(resolve(candidate, "package.json")));
37
- if (!found)
38
- throw new Error("Grove site scaffold is missing. Reinstall @grove-dev/cli.");
39
- return found;
93
+ return globalThis.process.getBuiltinModule('node:fs').readFileSync(path, 'utf8');
40
94
  }
41
95
  function titleCase(value) {
42
96
  return value
43
- .replace(/[-_]+/g, " ")
97
+ .replace(/[-_]+/g, ' ')
44
98
  .replace(/\b\w/g, (letter) => letter.toUpperCase())
45
99
  .trim();
46
100
  }
47
101
  function packageName(value) {
48
- return value
102
+ return (value
49
103
  .toLowerCase()
50
- .replace(/[^a-z0-9._-]+/g, "-")
51
- .replace(/^-+|-+$/g, "") || "grove-directory";
104
+ .replace(/[^a-z0-9._-]+/g, '-')
105
+ .replace(/^-+|-+$/g, '') || 'grove-directory');
52
106
  }
53
107
  async function ensureEmpty(targetDir) {
54
108
  await mkdir(targetDir, { recursive: true });
@@ -57,39 +111,306 @@ async function ensureEmpty(targetDir) {
57
111
  throw new Error(`${targetDir} is not empty. Choose a new directory.`);
58
112
  }
59
113
  }
114
+ /**
115
+ * pnpm's two spellings of the same build-script approval. pnpm 11 reads
116
+ * `allowBuilds` and ignores `onlyBuiltDependencies`; pnpm 10 does the
117
+ * reverse. Writing both keeps one generated project working on either.
118
+ */
119
+ function pnpmWorkspaceYaml() {
120
+ return [
121
+ '# Dependency install scripts this project approves.',
122
+ '#',
123
+ '# astro pulls in vite, which pulls in esbuild, whose install script',
124
+ "# links esbuild's platform binary. pnpm 11 refuses to finish an",
125
+ '# install that skipped a build script; pnpm 10 spells the same',
126
+ '# approval differently and ignores the key it does not know.',
127
+ 'allowBuilds:',
128
+ ...APPROVED_BUILD_SCRIPTS.map((name) => ` ${name}: true`),
129
+ 'onlyBuiltDependencies:',
130
+ ...APPROVED_BUILD_SCRIPTS.map((name) => ` - ${name}`),
131
+ '',
132
+ ].join('\n');
133
+ }
134
+ /** Write a file only if it is not already there — never clobber a consumer's. */
135
+ async function writeIfAbsent(path, content) {
136
+ await writeFile(path, content, { encoding: 'utf8', flag: 'wx' }).catch((err) => {
137
+ if (err.code !== 'EEXIST')
138
+ throw err;
139
+ });
140
+ }
141
+ /** Read-modify-write a package.json, always through a fresh `dependencies`. */
142
+ async function updatePackageJson(path, mutate) {
143
+ const pkg = JSON.parse(await readFile(path, 'utf8'));
144
+ const next = { ...pkg, dependencies: { ...(pkg.dependencies ?? {}) } };
145
+ mutate(next);
146
+ await writeJson(path, next);
147
+ }
148
+ /** `@astrojs/check@^0.9.9` → `['@astrojs/check', '^0.9.9']`. Splits on the LAST `@`. */
149
+ function parseDependencySpec(spec) {
150
+ const at = spec.lastIndexOf('@');
151
+ if (at <= 0)
152
+ return [spec, 'latest'];
153
+ return [spec.slice(0, at), spec.slice(at + 1)];
154
+ }
155
+ /**
156
+ * What `shadcn add` would have done, done in-process.
157
+ *
158
+ * shadcn is a third-party CLI fetched at run time: a bad release, an
159
+ * offline machine, or a package manager it cannot drive takes it down —
160
+ * and used to take the whole scaffold with it, because it aborts before
161
+ * writing anything. Nothing it does here is out of reach: the bundled
162
+ * item inlines all of its files and names its own npm dependencies, and
163
+ * `writeItemFiles` is the same writer `grove update` already trusts. So
164
+ * record the dependencies and let the `pnpm install` that follows
165
+ * resolve them.
166
+ */
167
+ async function installScaffoldDirectly(item, target, packagePath) {
168
+ await writeItemFiles(item, target);
169
+ await updatePackageJson(packagePath, (pkg) => {
170
+ for (const spec of item.dependencies ?? []) {
171
+ const [name, range] = parseDependencySpec(spec);
172
+ pkg.dependencies[name] ??= range;
173
+ }
174
+ });
175
+ }
176
+ /**
177
+ * Undo a failed init. `ensureEmpty()` proved the directory held nothing
178
+ * but SKIP_NAMES entries, so everything that appeared since is ours to
179
+ * remove — and leaving it behind is worse than useless: the obvious
180
+ * retry then trips `ensureEmpty` with "not empty" and the user has to
181
+ * clean up by hand before trying again.
182
+ */
183
+ async function rollback(target, preexisting) {
184
+ const entries = await readdir(target).catch(() => []);
185
+ for (const entry of entries) {
186
+ if (preexisting.has(entry))
187
+ continue;
188
+ await rm(resolve(target, entry), { recursive: true, force: true });
189
+ }
190
+ }
191
+ /**
192
+ * Default scaffold installer: the official shadcn CLI, pinned, fetched
193
+ * with whichever package manager this project is being scaffolded for.
194
+ * The item path must be absolute — shadcn rejects relative local paths
195
+ * as unsafe. `--yes` skips the confirmation prompts; stdio is inherited
196
+ * so the user sees the install output.
197
+ *
198
+ * shadcn picks the package manager for the item's dependencies from the
199
+ * lockfile or the `packageManager` field it finds in the project, and
200
+ * its `add` path has no user-agent fallback — a fresh directory has
201
+ * neither, so it would silently default to npm. Step 2 writes
202
+ * `packageManager` for exactly that reason; without it a bun project
203
+ * would come back with a package-lock.json in it.
204
+ */
205
+ export async function installScaffoldWithShadcn({ target, itemPath, packageManager, }) {
206
+ const [command, args] = dlxCommand(packageManager, `shadcn@${SHADCN_VERSION}`, [
207
+ 'add',
208
+ itemPath,
209
+ '--yes',
210
+ '--cwd',
211
+ target,
212
+ ]);
213
+ await run(command, args, target);
214
+ }
215
+ async function writeJson(path, value) {
216
+ await writeFile(path, `${JSON.stringify(value, null, 2)}\n`, 'utf8');
217
+ }
218
+ /**
219
+ * Bootstrap a Grove project by installing the `@grove/default`
220
+ * registry scaffold. Returns the installed item so callers can report
221
+ * what landed.
222
+ */
60
223
  export async function initDirectory(targetDir, options = {}) {
61
- const source = scaffoldSource();
62
224
  const target = resolve(targetDir);
225
+ // 1. Never install over someone's work.
63
226
  await ensureEmpty(target);
64
- await cp(source, target, {
65
- recursive: true,
66
- filter: (sourcePath) => {
67
- const pathFromRoot = relative(source, sourcePath);
68
- const parts = pathFromRoot.split(/[\\/]/);
69
- if (parts.some((part) => SKIP_NAMES.has(part)))
70
- return false;
71
- if (parts[0] === "data" && parts[1] === "generated")
72
- return false;
73
- if (parts[0] === "public" && GENERATED_PUBLIC_NAMES.has(parts[1] ?? "")) {
74
- return false;
75
- }
76
- return true;
77
- },
78
- });
227
+ // 1b. Settle the package manager and confirm it is really there before
228
+ // writing anything, rather than dying partway through.
229
+ const detected = options.packageManager ?? detectPackageManager();
230
+ const packageManager = options.installScaffold === undefined ? requirePackageManager(detected, target) : detected;
231
+ // 1c. Whatever is here now (only SKIP_NAMES entries, per ensureEmpty)
232
+ // is not ours; everything else that appears is, and comes back off
233
+ // again if a later step throws.
234
+ const preexisting = new Set(await readdir(target));
235
+ try {
236
+ return await scaffold(target, options, packageManager);
237
+ }
238
+ catch (error) {
239
+ await rollback(target, preexisting);
240
+ console.error(`\nRemoved the partial scaffold in ${target}; ` +
241
+ 'run grove init again once the error below is fixed.\n');
242
+ throw error;
243
+ }
244
+ }
245
+ /** Steps 2-6. Only called through `initDirectory`, which owns the rollback. */
246
+ async function scaffold(target, options, packageManager) {
79
247
  const version = options.version ?? readCliVersion();
80
- const fallbackName = target.split(/[\\/]/).at(-1) ?? "grove-directory";
248
+ const fallbackName = target.split(/[\\/]/).at(-1) ?? 'grove-directory';
81
249
  const rawName = options.projectName ?? fallbackName;
82
250
  const projectName = packageName(rawName);
83
- const packagePath = resolve(target, "package.json");
84
- const pkg = JSON.parse(await readFile(packagePath, "utf8"));
85
- pkg.name = projectName;
86
- pkg.dependencies ??= {};
87
- for (const dependency of GROVE_PACKAGES)
88
- pkg.dependencies[dependency] = `^${version}`;
89
- await writeFile(packagePath, `${JSON.stringify(pkg, null, 2)}\n`, "utf8");
90
- const configPath = resolve(target, "grove.config.ts");
91
- const config = await readFile(configPath, "utf8");
92
- await writeFile(configPath, config.replace(/name:\s*"[^"]+"/, `name: ${JSON.stringify(titleCase(rawName))}`), "utf8");
93
- return { targetDir: target, projectName };
251
+ const installScaffold = options.installScaffold ?? installScaffoldWithShadcn;
252
+ // 2. package.json. Scripts are fixed here — registry items carry
253
+ // files and npm dependency names, not scripts. Dependencies are
254
+ // filled in by shadcn (step 4) and by us (step 5).
255
+ // `packageManager` is the one signal shadcn's package-manager
256
+ // detector can read in an otherwise empty directory, and it is
257
+ // what keeps a bun or yarn scaffold from being installed by npm.
258
+ const packagePath = resolve(target, 'package.json');
259
+ await writeJson(packagePath, {
260
+ name: projectName,
261
+ type: 'module',
262
+ ...(packageManager.version
263
+ ? { packageManager: `${packageManager.name}@${packageManager.version}` }
264
+ : {}),
265
+ scripts: { ...PROJECT_SCRIPTS },
266
+ dependencies: {},
267
+ });
268
+ // 3a. tsconfig.json. Not shipped via the registry — everything the
269
+ // item writes lands under src/, but a tsconfig has to sit at the
270
+ // project root. The scaffold's own code relies on two settings
271
+ // Astro's default (when no tsconfig exists) doesn't set:
272
+ // "Bundler" resolution (registry components import package
273
+ // subpaths like `@grove-dev/astro/server` whose declaration file
274
+ // lives in the package's own src/) and the `@grove/generated/*`
275
+ // alias (so `astro check` resolves the JSON `prepareDirectory()`
276
+ // writes to `data/generated/`). The `@/*` alias is what shadcn
277
+ // reads to locate src/. `strict` is pinned off explicitly:
278
+ // Astro's `base` preset leaves it unset, which TypeScript 5
279
+ // treats as off and TypeScript 6 as on, and the scaffold's
280
+ // sources are checked against the former — a fresh project
281
+ // should type-check the same way whichever TypeScript the
282
+ // package manager resolves for `astro check`.
283
+ await writeFile(resolve(target, 'tsconfig.json'), `{
284
+ "extends": "astro/tsconfigs/base",
285
+ "compilerOptions": {
286
+ "strict": false,
287
+ "moduleResolution": "Bundler",
288
+ "allowImportingTsExtensions": true,
289
+ "types": ["node"],
290
+ "baseUrl": ".",
291
+ "paths": {
292
+ "@/*": ["./src/*"],
293
+ "@grove/generated/*": ["data/generated/*"]
294
+ }
295
+ },
296
+ "include": [".astro/types.d.ts", "**/*"],
297
+ "exclude": ["dist"]
298
+ }
299
+ `, 'utf8');
300
+ // 3b. components.json — the shadcn project config. shadcn needs it
301
+ // to install anything; the `registries` entry is what makes
302
+ // `npx shadcn add @grove/<item>` resolve later.
303
+ await writeJson(resolve(target, 'components.json'), {
304
+ $schema: 'https://ui.shadcn.com/schema.json',
305
+ style: 'new-york',
306
+ rsc: false,
307
+ tsx: true,
308
+ tailwind: {
309
+ config: '',
310
+ css: 'src/styles/system.css',
311
+ baseColor: 'neutral',
312
+ cssVariables: true,
313
+ },
314
+ aliases: {
315
+ components: '@/components',
316
+ utils: '@/lib/utils',
317
+ ui: '@/components/ui',
318
+ lib: '@/lib',
319
+ hooks: '@/hooks',
320
+ },
321
+ registries: { [REGISTRY_NAMESPACE]: REGISTRY_URL_TEMPLATE },
322
+ });
323
+ // 3c. grove.config.ts. Project-specific, so the scaffold doesn't
324
+ // ship one — generate a fresh template with the project name.
325
+ await writeFile(resolve(target, 'grove.config.ts'), `import { defineConfig } from "@grove-dev/core";
326
+
327
+ export default defineConfig({
328
+ blueprint: "project-directory",
329
+
330
+ site: {
331
+ name: ${JSON.stringify(titleCase(rawName))},
332
+ tagline: "A Grove-powered directory.",
333
+ description: "",
334
+ url: "https://example.com",
335
+ },
336
+
337
+ nav: [
338
+ { label: "Home", href: "/" },
339
+ { label: "Browse", href: "/projects" },
340
+ { label: "About", href: "/about" },
341
+ ],
342
+
343
+ browse: {
344
+ facets: ["category", "stack", "platform", "license"],
345
+ },
346
+
347
+ theme: { radius: "soft", density: "comfortable", containerWidth: "72rem" },
348
+ });
349
+ `, 'utf8');
350
+ // 3d. astro.config.mjs. Without this the scaffold's Tailwind v4
351
+ // styles (`@import "tailwindcss"` in styles/system.css) never get
352
+ // processed — the Vite plugin has to be registered somewhere.
353
+ await writeFile(resolve(target, 'astro.config.mjs'), `// @ts-check
354
+ import { defineConfig } from "astro/config";
355
+ import tailwindcss from "@tailwindcss/vite";
356
+ import groveAstro from "@grove-dev/astro";
357
+ import { loadConfig } from "@grove-dev/core";
358
+
359
+ // \`site\` is the canonical URL the build uses for absolute links
360
+ // (sitemap, OpenGraph, canonical tags, JSON-LD). Read from
361
+ // grove.config.ts and overridable per build via SITE_URL.
362
+ const groveConfig = await loadConfig();
363
+
364
+ export default defineConfig({
365
+ site: process.env.SITE_URL || groveConfig.site.url,
366
+ trailingSlash: "ignore",
367
+ integrations: [groveAstro()],
368
+ vite: {
369
+ plugins: [tailwindcss()],
370
+ },
371
+ build: {
372
+ format: "directory",
373
+ },
374
+ });
375
+ `, 'utf8');
376
+ // 3e. Empty data/records/. `validateProject()` treats an ABSENT
377
+ // records directory as a hard error — deliberately — but a fresh
378
+ // scaffold with zero records is a supported starting state.
379
+ // Empty directories aren't tracked by git, hence the placeholder.
380
+ const recordsDir = resolve(target, 'data', 'records');
381
+ await mkdir(recordsDir, { recursive: true });
382
+ await writeFile(resolve(recordsDir, '.gitkeep'), '# Add one YAML file per record here — see /getting-started/first-record/.\n', 'utf8');
383
+ // 3f. pnpm-workspace.yaml. Every install a pnpm project will ever run
384
+ // — shadcn's in the next step, the one in index.ts, and the
385
+ // consumer's own later on — needs the scaffold's dependency build
386
+ // scripts approved, or pnpm 11 aborts the lot. npm, yarn and bun
387
+ // run install scripts without asking, so this file is pnpm's
388
+ // alone and would only be noise in their projects.
389
+ if (packageManager.name === 'pnpm') {
390
+ await writeIfAbsent(resolve(target, 'pnpm-workspace.yaml'), pnpmWorkspaceYaml());
391
+ }
392
+ // 4. Install the scaffold item. shadcn is the installer of record;
393
+ // when it fails, finish the job in-process rather than hand back a
394
+ // project with no src/ in it.
395
+ const itemPath = options.itemPath ?? resolveBundledItemPath();
396
+ const item = await loadItem(itemPath);
397
+ try {
398
+ await installScaffold({ target, itemPath, packageManager });
399
+ }
400
+ catch (error) {
401
+ const reason = error instanceof Error ? error.message : String(error);
402
+ console.warn(`\nInstalling the scaffold with shadcn failed: ${reason}\n` +
403
+ `Writing the bundled ${REGISTRY_NAMESPACE}/${item.name} item directly instead.\n`);
404
+ await installScaffoldDirectly(item, target, packagePath);
405
+ }
406
+ // 5. Grove's own packages, pinned to this CLI's version. Read-modify-
407
+ // write: step 4 rewrote package.json with the item's dependencies.
408
+ await updatePackageJson(packagePath, (pkg) => {
409
+ for (const dep of GROVE_PACKAGES)
410
+ pkg.dependencies[dep] = `^${version}`;
411
+ });
412
+ // 6. Record what was installed for `grove update`.
413
+ await writeLockfile(target, buildLockfile(item));
414
+ return { targetDir: target, projectName, installedScaffold: item, packageManager };
94
415
  }
95
416
  //# sourceMappingURL=init.js.map
package/dist/init.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;AAC5E,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC;IACrC,UAAU;IACV,eAAe;IACf,aAAa;IACb,YAAY;IACZ,cAAc;IACd,IAAI;CACL,CAAC,CAAC;AACH,MAAM,cAAc,GAAG,CAAC,kBAAkB,EAAE,gBAAgB,EAAE,iBAAiB,CAAU,CAAC;AAO1F,MAAM,UAAU,c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,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtE,OAAO,CAAC,IAAI,CACV,iDAAiD,MAAM,IAAI;YACzD,uBAAuB,kBAAkB,IAAI,IAAI,CAAC,IAAI,2BAA2B,CACpF,CAAC;QACF,MAAM,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IAC3D,CAAC;IAED,sEAAsE;IACtE,sEAAsE;IACtE,MAAM,iBAAiB,CAAC,WAAW,EAAE,CAAC,GAAG,EAAE,EAAE;QAC3C,KAAK,MAAM,GAAG,IAAI,cAAc;YAAE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,IAAI,OAAO,EAAE,CAAC;IAC1E,CAAC,CAAC,CAAC;IAEH,mDAAmD;IACnD,MAAM,aAAa,CAAC,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;IAEjD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,iBAAiB,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;AACrF,CAAC"}
@@ -0,0 +1,57 @@
1
+ export type PackageManagerName = 'pnpm' | 'npm' | 'yarn' | 'bun';
2
+ export interface PackageManager {
3
+ name: PackageManagerName;
4
+ /** Exact version, filled in by `requirePackageManager()`. */
5
+ version?: string;
6
+ }
7
+ /**
8
+ * `pnpm/10.12.1 npm/? node/v22.22.2 darwin arm64` → pnpm 10.12.1.
9
+ *
10
+ * Every package manager sets `npm_config_user_agent` for the processes
11
+ * it spawns, `npx`/`bunx`/`yarn dlx`/`pnpm dlx` included — so this is
12
+ * how the CLI knows what invoked it.
13
+ */
14
+ export declare function parseUserAgent(agent: string | undefined): PackageManager | null;
15
+ /**
16
+ * Which package manager to use in `cwd`, in order of how much the
17
+ * signal actually knows about the user's intent:
18
+ *
19
+ * 1. The project's own `packageManager` field — an explicit choice.
20
+ * 2. Its lockfile — the choice it has been living with.
21
+ * 3. `npm_config_user_agent` — how this very command was launched,
22
+ * which is all `grove init` into a fresh directory has to go on.
23
+ * 4. Whatever is installed, pnpm first, so a machine with no signal
24
+ * behaves the way Grove always did.
25
+ */
26
+ export declare function detectPackageManager(cwd?: string): PackageManager;
27
+ /**
28
+ * Confirm the package manager is really there before anything is
29
+ * written, and pin down its exact version while we are asking — the
30
+ * generated project records it so shadcn, corepack and the next
31
+ * contributor all agree on which one this project uses.
32
+ *
33
+ * `cwd` is the project being created, not the directory the command was
34
+ * typed in. pnpm and yarn re-exec the version a surrounding project
35
+ * pins, so probing anywhere else reports that neighbour's version and
36
+ * stamps it onto an unrelated new project.
37
+ */
38
+ export declare function requirePackageManager(pm: PackageManager, cwd: string): PackageManager;
39
+ /** `npm install`, `pnpm install`, `yarn install`, `bun install`. */
40
+ export declare function installCommand(pm: PackageManager): [command: string, args: string[]];
41
+ /** How the user runs a package.json script: always `<pm> run <script>`. */
42
+ export declare function runScriptCommand(pm: PackageManager, script: string): string;
43
+ /**
44
+ * Fetch and run a package straight from the registry, npx-style.
45
+ *
46
+ * Yarn is the awkward one: `dlx` arrived in Yarn 2, and on Yarn Classic
47
+ * `yarn dlx` is parsed as `yarn run dlx` and fails. Probe the major
48
+ * rather than guess, and fall back to `npx`, which ships with Node.
49
+ */
50
+ export declare function dlxCommand(pm: PackageManager, spec: string, args: string[]): [command: string, args: string[]];
51
+ /**
52
+ * A binary installed in the project itself. Grove runs `astro` this
53
+ * way rather than through `<pm> exec`: the file is right there, and
54
+ * asking a package manager to find it only adds a way to fail.
55
+ */
56
+ export declare function localBin(cwd: string, name: string): string;
57
+ //# sourceMappingURL=package-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-manager.d.ts","sourceRoot":"","sources":["../src/package-manager.ts"],"names":[],"mappings":"AAsBA,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,CAAC;AAEjE,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,kBAAkB,CAAC;IACzB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAkBD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,cAAc,GAAG,IAAI,CAM/E;AA+BD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,GAAE,MAAsB,GAAG,cAAc,CAQhF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,GAAG,cAAc,CAWrF;AAED,oEAAoE;AACpE,wBAAgB,cAAc,CAAC,EAAE,EAAE,cAAc,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAEpF;AAED,2EAA2E;AAC3E,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAE3E;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,EAAE,EAAE,cAAc,EAClB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EAAE,GACb,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAiBnC;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAG1D"}