@hanzogui/recipes 7.3.1 → 8.0.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 (2) hide show
  1. package/dist/index.js +31 -31
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -45,35 +45,6 @@ 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
- }
77
48
  // src/read.ts
78
49
  async function getJSON(url) {
79
50
  const res = await fetch(url, { headers: { Accept: "application/json" } });
@@ -122,8 +93,8 @@ async function resolveRecipe(slug, opts = {}) {
122
93
  })();
123
94
  const recipe = seen.get(slug);
124
95
  const transitiveRecipes = Array.from(seen.values()).filter((r) => r.slug !== slug);
125
- const path3 = await import("node:path");
126
- const targetPaths = [recipe, ...transitiveRecipes].flatMap((r) => r.files.map((f) => path3.join(installDir, f.path)));
96
+ const path2 = await import("node:path");
97
+ const targetPaths = [recipe, ...transitiveRecipes].flatMap((r) => r.files.map((f) => path2.join(installDir, f.path)));
127
98
  return { recipe, transitiveRecipes, targetPaths };
128
99
  }
129
100
 
@@ -205,6 +176,35 @@ async function upsertRecipe(auth, recipe) {
205
176
  throw new Error(`POST ${recipe.slug}: ${res.status} ${await res.text()}`);
206
177
  return "created";
207
178
  }
179
+ // src/write.ts
180
+ import { existsSync as existsSync2, promises as fs2 } from "node:fs";
181
+ import path2 from "node:path";
182
+ async function getInstallDir(opts) {
183
+ if (opts.installDir)
184
+ return opts.installDir;
185
+ const root = await findProjectRoot(opts.cwd);
186
+ return resolveInstallDir(root, await readConfig(root));
187
+ }
188
+ async function installRecipe(recipe, opts = {}) {
189
+ const installDir = await getInstallDir(opts);
190
+ const written = [];
191
+ for (const file of recipe.files) {
192
+ const dest = path2.join(installDir, file.path);
193
+ const dir = path2.dirname(dest);
194
+ if (!existsSync2(dir))
195
+ await fs2.mkdir(dir, { recursive: true });
196
+ await fs2.writeFile(dest, file.source);
197
+ written.push(dest);
198
+ }
199
+ return written;
200
+ }
201
+ async function installPlan(plan, opts = {}) {
202
+ const written = [];
203
+ for (const r of [plan.recipe, ...plan.transitiveRecipes]) {
204
+ written.push(...await installRecipe(r, opts));
205
+ }
206
+ return written;
207
+ }
208
208
  export {
209
209
  upsertRecipe,
210
210
  resolveRecipe,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzogui/recipes",
3
- "version": "7.3.1",
3
+ "version": "8.0.0",
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>",