@hanzogui/recipes 8.1.0 → 8.1.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.
Files changed (2) hide show
  1. package/dist/index.js +31 -31
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -45,6 +45,35 @@ function resolveInstallDir(root, config) {
45
45
  return path.join(root, config.installDir ?? DEFAULT_INSTALL_DIR);
46
46
  }
47
47
 
48
+ // src/write.ts
49
+ import { existsSync as existsSync2, promises as fs2 } from "node:fs";
50
+ import path2 from "node:path";
51
+ async function getInstallDir(opts) {
52
+ if (opts.installDir)
53
+ return opts.installDir;
54
+ const root = await findProjectRoot(opts.cwd);
55
+ return resolveInstallDir(root, await readConfig(root));
56
+ }
57
+ async function installRecipe(recipe, opts = {}) {
58
+ const installDir = await getInstallDir(opts);
59
+ const written = [];
60
+ for (const file of recipe.files) {
61
+ const dest = path2.join(installDir, file.path);
62
+ const dir = path2.dirname(dest);
63
+ if (!existsSync2(dir))
64
+ await fs2.mkdir(dir, { recursive: true });
65
+ await fs2.writeFile(dest, file.source);
66
+ written.push(dest);
67
+ }
68
+ return written;
69
+ }
70
+ async function installPlan(plan, opts = {}) {
71
+ const written = [];
72
+ for (const r of [plan.recipe, ...plan.transitiveRecipes]) {
73
+ written.push(...await installRecipe(r, opts));
74
+ }
75
+ return written;
76
+ }
48
77
  // src/read.ts
49
78
  async function getJSON(url) {
50
79
  const res = await fetch(url, { headers: { Accept: "application/json" } });
@@ -93,8 +122,8 @@ async function resolveRecipe(slug, opts = {}) {
93
122
  })();
94
123
  const recipe = seen.get(slug);
95
124
  const transitiveRecipes = Array.from(seen.values()).filter((r) => r.slug !== slug);
96
- const path2 = await import("node:path");
97
- const targetPaths = [recipe, ...transitiveRecipes].flatMap((r) => r.files.map((f) => path2.join(installDir, f.path)));
125
+ const path3 = await import("node:path");
126
+ const targetPaths = [recipe, ...transitiveRecipes].flatMap((r) => r.files.map((f) => path3.join(installDir, f.path)));
98
127
  return { recipe, transitiveRecipes, targetPaths };
99
128
  }
100
129
 
@@ -184,35 +213,6 @@ async function upsertRecipe(auth, recipe) {
184
213
  throw new Error(`POST ${recipe.slug}: ${res.status} ${await res.text()}`);
185
214
  return "created";
186
215
  }
187
- // src/write.ts
188
- import { existsSync as existsSync2, promises as fs2 } from "node:fs";
189
- import path2 from "node:path";
190
- async function getInstallDir(opts) {
191
- if (opts.installDir)
192
- return opts.installDir;
193
- const root = await findProjectRoot(opts.cwd);
194
- return resolveInstallDir(root, await readConfig(root));
195
- }
196
- async function installRecipe(recipe, opts = {}) {
197
- const installDir = await getInstallDir(opts);
198
- const written = [];
199
- for (const file of recipe.files) {
200
- const dest = path2.join(installDir, file.path);
201
- const dir = path2.dirname(dest);
202
- if (!existsSync2(dir))
203
- await fs2.mkdir(dir, { recursive: true });
204
- await fs2.writeFile(dest, file.source);
205
- written.push(dest);
206
- }
207
- return written;
208
- }
209
- async function installPlan(plan, opts = {}) {
210
- const written = [];
211
- for (const r of [plan.recipe, ...plan.transitiveRecipes]) {
212
- written.push(...await installRecipe(r, opts));
213
- }
214
- return written;
215
- }
216
216
  export {
217
217
  upsertRecipe,
218
218
  resolveRecipe,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzogui/recipes",
3
- "version": "8.1.0",
3
+ "version": "8.1.1",
4
4
  "description": "Hanzo GUI recipe library: read from Base, resolve transitive deps, install into a project.",
5
5
  "license": "BSD-3-Clause",
6
6
  "author": "Hanzo AI <dev@hanzo.ai>",