@hanzogui/recipes 8.1.0 → 8.2.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 +30 -30
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -44,7 +44,6 @@ async function readConfig(root) {
44
44
  function resolveInstallDir(root, config) {
45
45
  return path.join(root, config.installDir ?? DEFAULT_INSTALL_DIR);
46
46
  }
47
-
48
47
  // src/read.ts
49
48
  async function getJSON(url) {
50
49
  const res = await fetch(url, { headers: { Accept: "application/json" } });
@@ -98,6 +97,36 @@ async function resolveRecipe(slug, opts = {}) {
98
97
  return { recipe, transitiveRecipes, targetPaths };
99
98
  }
100
99
 
100
+ // src/write.ts
101
+ import { existsSync as existsSync2, promises as fs2 } from "node:fs";
102
+ import path2 from "node:path";
103
+ async function getInstallDir(opts) {
104
+ if (opts.installDir)
105
+ return opts.installDir;
106
+ const root = await findProjectRoot(opts.cwd);
107
+ return resolveInstallDir(root, await readConfig(root));
108
+ }
109
+ async function installRecipe(recipe, opts = {}) {
110
+ const installDir = await getInstallDir(opts);
111
+ const written = [];
112
+ for (const file of recipe.files) {
113
+ const dest = path2.join(installDir, file.path);
114
+ const dir = path2.dirname(dest);
115
+ if (!existsSync2(dir))
116
+ await fs2.mkdir(dir, { recursive: true });
117
+ await fs2.writeFile(dest, file.source);
118
+ written.push(dest);
119
+ }
120
+ return written;
121
+ }
122
+ async function installPlan(plan, opts = {}) {
123
+ const written = [];
124
+ for (const r of [plan.recipe, ...plan.transitiveRecipes]) {
125
+ written.push(...await installRecipe(r, opts));
126
+ }
127
+ return written;
128
+ }
129
+
101
130
  // src/admin.ts
102
131
  async function authAdmin({
103
132
  baseUrl,
@@ -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.2.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>",