@nuasite/cli 0.17.1 → 0.18.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
@@ -36,6 +36,29 @@ bunx nua build
36
36
  agent summary integration) and surfaces errors with inline source excerpts so
37
37
  you can diagnose failures quickly.
38
38
 
39
+ ### `nua init`
40
+
41
+ Converts a standard Astro project to use the Nua toolchain:
42
+
43
+ ```bash
44
+ nua init # interactive — previews changes, asks for confirmation
45
+ nua init --dry-run # show what would change without writing files
46
+ nua init --yes # skip confirmation prompt
47
+ ```
48
+
49
+ This rewrites your Astro config and `package.json` to adopt `@nuasite/nua`.
50
+ Specifically it:
51
+
52
+ - Replaces `astro/config` with `@nuasite/nua/config`
53
+ - Removes Nua-managed integration imports (`@astrojs/mdx`, `@astrojs/sitemap`,
54
+ `@tailwindcss/vite`) and their calls from the config
55
+ - Cleans up empty config structures left behind
56
+ - Removes Nua-provided dependencies and adds `@nuasite/nua`
57
+ - Updates scripts (`astro build` → `nua build`, etc.)
58
+
59
+ After running, follow the printed next-steps: `bun install`, review the
60
+ config, and run `nua dev`.
61
+
39
62
  ### `nua clean`
40
63
 
41
64
  Ejects your project from the Nua toolchain back to a standard Astro setup:
package/dist/index.js CHANGED
@@ -27,37 +27,6 @@ function findAstroConfig(cwd = process.cwd()) {
27
27
  }
28
28
  return null;
29
29
  }
30
- var CONFIG_NAMES;
31
- var init_utils = __esm(() => {
32
- CONFIG_NAMES = [
33
- "astro.config.ts",
34
- "astro.config.mts",
35
- "astro.config.mjs",
36
- "astro.config.js"
37
- ];
38
- });
39
-
40
- // src/clean.ts
41
- var exports_clean = {};
42
- __export(exports_clean, {
43
- transformPackageJson: () => transformPackageJson,
44
- transformConfig: () => transformConfig,
45
- removeProperty: () => removeProperty,
46
- extractConfigBody: () => extractConfigBody,
47
- detectDisabledFeatures: () => detectDisabledFeatures,
48
- clean: () => clean
49
- });
50
- import { existsSync as existsSync2, readdirSync, readFileSync, writeFileSync } from "fs";
51
- import { basename, join as join2 } from "path";
52
- function detectDisabledFeatures(content) {
53
- const disabled = new Set;
54
- for (const key of FEATURE_KEYS) {
55
- if (new RegExp(`\\b${key}\\s*:\\s*false\\b`).test(content)) {
56
- disabled.add(key);
57
- }
58
- }
59
- return disabled;
60
- }
61
30
  function findMatchingClose(text, start) {
62
31
  const open = text[start];
63
32
  const close = open === "{" ? "}" : open === "[" ? "]" : ")";
@@ -132,6 +101,283 @@ function removeProperty(body, propName) {
132
101
  end++;
133
102
  return body.slice(0, propLineStart) + body.slice(end);
134
103
  }
104
+ function assembleConfig(imports, body) {
105
+ const bodyLines = body.split(`
106
+ `).filter((line) => line.trim() !== "");
107
+ let result = imports.join(`
108
+ `) + `
109
+
110
+ `;
111
+ result += `export default defineConfig({
112
+ `;
113
+ if (bodyLines.length > 0) {
114
+ result += bodyLines.join(`
115
+ `) + `
116
+ `;
117
+ }
118
+ result += `})
119
+ `;
120
+ return result;
121
+ }
122
+ var CONFIG_NAMES;
123
+ var init_utils = __esm(() => {
124
+ CONFIG_NAMES = [
125
+ "astro.config.ts",
126
+ "astro.config.mts",
127
+ "astro.config.mjs",
128
+ "astro.config.js"
129
+ ];
130
+ });
131
+
132
+ // src/init.ts
133
+ var exports_init = {};
134
+ __export(exports_init, {
135
+ transformPackageJson: () => transformPackageJson,
136
+ transformConfig: () => transformConfig,
137
+ removeCallFromArray: () => removeCallFromArray,
138
+ init: () => init,
139
+ detectNuaManagedImports: () => detectNuaManagedImports,
140
+ cleanEmptyStructures: () => cleanEmptyStructures
141
+ });
142
+ import { existsSync as existsSync2, readFileSync, writeFileSync } from "fs";
143
+ import { basename, join as join2 } from "path";
144
+ function detectNuaManagedImports(content) {
145
+ const managed = new Map;
146
+ for (const pkg of NUA_MANAGED_PACKAGES) {
147
+ const regex = new RegExp(`import\\s+(\\w+)\\s+from\\s+['"]${pkg.replace("/", "\\/")}['"]`);
148
+ const match = regex.exec(content);
149
+ if (match) {
150
+ managed.set(pkg, match[1]);
151
+ }
152
+ }
153
+ return managed;
154
+ }
155
+ function removeCallFromArray(body, arrayProp, callName) {
156
+ const propRegex = new RegExp(`\\b${arrayProp}\\s*:\\s*\\[`);
157
+ const propMatch = propRegex.exec(body);
158
+ if (!propMatch || propMatch.index === undefined)
159
+ return body;
160
+ const arrayStart = body.indexOf("[", propMatch.index);
161
+ const arrayEnd = findMatchingClose(body, arrayStart);
162
+ if (arrayEnd === -1)
163
+ return body;
164
+ const arrayContent = body.slice(arrayStart + 1, arrayEnd);
165
+ const callRegex = new RegExp(`\\b${callName}\\s*\\(`);
166
+ const callMatch = callRegex.exec(arrayContent);
167
+ if (!callMatch || callMatch.index === undefined)
168
+ return body;
169
+ const parenStart = arrayContent.indexOf("(", callMatch.index);
170
+ const parenEnd = findMatchingClose(arrayContent, parenStart);
171
+ if (parenEnd === -1)
172
+ return body;
173
+ let removeStart = callMatch.index;
174
+ let removeEnd = parenEnd + 1;
175
+ let after = removeEnd;
176
+ while (after < arrayContent.length && (arrayContent[after] === " " || arrayContent[after] === "\t" || arrayContent[after] === `
177
+ `)) {
178
+ after++;
179
+ }
180
+ if (after < arrayContent.length && arrayContent[after] === ",") {
181
+ removeEnd = after + 1;
182
+ while (removeEnd < arrayContent.length && (arrayContent[removeEnd] === " " || arrayContent[removeEnd] === "\t" || arrayContent[removeEnd] === `
183
+ `))
184
+ removeEnd++;
185
+ }
186
+ if (removeEnd === parenEnd + 1) {
187
+ let before = removeStart - 1;
188
+ while (before >= 0 && (arrayContent[before] === " " || arrayContent[before] === "\t" || arrayContent[before] === `
189
+ `))
190
+ before--;
191
+ if (before >= 0 && arrayContent[before] === ",") {
192
+ removeStart = before;
193
+ }
194
+ }
195
+ const newArrayContent = arrayContent.slice(0, removeStart) + arrayContent.slice(removeEnd);
196
+ return body.slice(0, arrayStart + 1) + newArrayContent + body.slice(arrayEnd);
197
+ }
198
+ function cleanEmptyStructures(body) {
199
+ body = body.replace(/\n[ \t]*sourcemap\s*:\s*true\s*,?[ \t]*/g, `
200
+ `);
201
+ body = body.replace(/\n[ \t]*build\s*:\s*\{[\s,]*\}\s*,?[ \t]*/g, `
202
+ `);
203
+ body = body.replace(/\n[ \t]*plugins\s*:\s*\[[\s,]*\]\s*,?[ \t]*/g, `
204
+ `);
205
+ body = body.replace(/\n[ \t]*integrations\s*:\s*\[[\s,]*\]\s*,?[ \t]*/g, `
206
+ `);
207
+ body = body.replace(/\n[ \t]*vite\s*:\s*\{[\s,]*\}\s*,?[ \t]*/g, `
208
+ `);
209
+ return body;
210
+ }
211
+ function transformConfig(content, managedImports) {
212
+ const lines = content.split(`
213
+ `);
214
+ const newImports = [];
215
+ for (const line of lines) {
216
+ if (!/^\s*import\s/.test(line))
217
+ continue;
218
+ if (line.includes("astro/config") && line.includes("defineConfig")) {
219
+ newImports.push(`import { defineConfig } from '@nuasite/nua/config'`);
220
+ continue;
221
+ }
222
+ const isManagedImport = [...managedImports.keys()].some((pkg) => line.includes(pkg));
223
+ if (isManagedImport)
224
+ continue;
225
+ newImports.push(line);
226
+ }
227
+ let body = extractConfigBody(content);
228
+ for (const [pkg, localName] of managedImports) {
229
+ if (pkg === "@tailwindcss/vite") {
230
+ body = removeCallFromArray(body, "plugins", localName);
231
+ } else {
232
+ body = removeCallFromArray(body, "integrations", localName);
233
+ }
234
+ }
235
+ body = cleanEmptyStructures(body);
236
+ return assembleConfig(newImports, body);
237
+ }
238
+ function resolveNuaVersion() {
239
+ try {
240
+ const cliPkgPath = new URL("../../package.json", import.meta.url);
241
+ const cliPkg = JSON.parse(readFileSync(cliPkgPath, "utf-8"));
242
+ const version = cliPkg.version;
243
+ const [major, minor] = version.split(".");
244
+ return `^${major}.${minor}.0`;
245
+ } catch {
246
+ return "^0.17.0";
247
+ }
248
+ }
249
+ function transformPackageJson(pkg, nuaVersion) {
250
+ const result = structuredClone(pkg);
251
+ if (result.scripts) {
252
+ for (const [key, value] of Object.entries(result.scripts)) {
253
+ if (typeof value === "string") {
254
+ result.scripts[key] = value.replace(/\bastro build\b/g, "nua build").replace(/\bastro dev\b/g, "nua dev").replace(/\bastro preview\b/g, "nua preview");
255
+ }
256
+ }
257
+ }
258
+ for (const field of ["dependencies", "devDependencies"]) {
259
+ if (!result[field])
260
+ continue;
261
+ for (const name of NUA_PROVIDED_PACKAGES) {
262
+ delete result[field][name];
263
+ }
264
+ if (Object.keys(result[field]).length === 0) {
265
+ delete result[field];
266
+ }
267
+ }
268
+ if (!result.dependencies)
269
+ result.dependencies = {};
270
+ if (!result.dependencies["@nuasite/nua"]) {
271
+ result.dependencies["@nuasite/nua"] = nuaVersion;
272
+ }
273
+ result.dependencies = Object.fromEntries(Object.entries(result.dependencies).sort(([a], [b]) => a.localeCompare(b)));
274
+ return result;
275
+ }
276
+ async function init({ cwd = process.cwd(), dryRun = false, yes = false } = {}) {
277
+ const configPath = findAstroConfig(cwd);
278
+ if (!configPath) {
279
+ console.error("No Astro config file found.");
280
+ process.exit(1);
281
+ }
282
+ const configContent = readFileSync(configPath, "utf-8");
283
+ if (configContent.includes("@nuasite/nua")) {
284
+ console.log("This project already uses @nuasite/nua. Nothing to do.");
285
+ return;
286
+ }
287
+ if (!configContent.includes("defineConfig")) {
288
+ console.error("Could not find defineConfig in Astro config.");
289
+ process.exit(1);
290
+ }
291
+ const pkgPath = join2(cwd, "package.json");
292
+ if (!existsSync2(pkgPath)) {
293
+ console.error("No package.json found.");
294
+ process.exit(1);
295
+ }
296
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
297
+ const managedImports = detectNuaManagedImports(configContent);
298
+ const nuaVersion = resolveNuaVersion();
299
+ const configName = basename(configPath);
300
+ console.log("");
301
+ console.log("nua init \u2014 adopt the Nua toolchain");
302
+ console.log("");
303
+ console.log(` ${configName}`);
304
+ console.log(" - Replace astro/config with @nuasite/nua/config");
305
+ if (managedImports.size > 0) {
306
+ console.log(` - Remove Nua-managed imports: ${[...managedImports.keys()].join(", ")}`);
307
+ console.log(" - Remove managed integration/plugin calls");
308
+ }
309
+ console.log(" - Clean up empty config structures");
310
+ console.log("");
311
+ console.log(" package.json");
312
+ const removable = NUA_PROVIDED_PACKAGES.filter((name) => pkg.dependencies?.[name] || pkg.devDependencies?.[name]);
313
+ if (removable.length > 0) {
314
+ console.log(` - Remove Nua-provided deps: ${removable.join(", ")}`);
315
+ }
316
+ console.log(` - Add @nuasite/nua ${nuaVersion}`);
317
+ console.log(" - Update scripts: astro \u2192 nua");
318
+ if (dryRun) {
319
+ console.log("");
320
+ console.log(" (--dry-run: no changes made)");
321
+ console.log("");
322
+ return;
323
+ }
324
+ if (!yes) {
325
+ console.log("");
326
+ const answer = prompt("Proceed? [y/N] ");
327
+ if (answer?.toLowerCase() !== "y") {
328
+ console.log("Cancelled.");
329
+ return;
330
+ }
331
+ }
332
+ const newConfig = transformConfig(configContent, managedImports);
333
+ writeFileSync(configPath, newConfig);
334
+ console.log(` Updated ${configName}`);
335
+ const newPkg = transformPackageJson(pkg, nuaVersion);
336
+ writeFileSync(pkgPath, JSON.stringify(newPkg, null, "\t") + `
337
+ `);
338
+ console.log(" Updated package.json");
339
+ console.log("");
340
+ console.log("Next steps:");
341
+ console.log(" 1. bun install");
342
+ console.log(" 2. Review the updated config");
343
+ console.log(" 3. nua dev");
344
+ console.log("");
345
+ }
346
+ var NUA_PROVIDED_PACKAGES, NUA_MANAGED_PACKAGES;
347
+ var init_init = __esm(() => {
348
+ init_utils();
349
+ NUA_PROVIDED_PACKAGES = [
350
+ "@astrojs/mdx",
351
+ "@astrojs/sitemap",
352
+ "@tailwindcss/vite",
353
+ "tailwindcss"
354
+ ];
355
+ NUA_MANAGED_PACKAGES = [
356
+ "@astrojs/mdx",
357
+ "@astrojs/sitemap",
358
+ "@tailwindcss/vite"
359
+ ];
360
+ });
361
+
362
+ // src/clean.ts
363
+ var exports_clean = {};
364
+ __export(exports_clean, {
365
+ transformPackageJson: () => transformPackageJson2,
366
+ transformConfig: () => transformConfig2,
367
+ detectDisabledFeatures: () => detectDisabledFeatures,
368
+ clean: () => clean
369
+ });
370
+ import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
371
+ import { basename as basename2, join as join3 } from "path";
372
+ function detectDisabledFeatures(content) {
373
+ const disabled = new Set;
374
+ for (const key of FEATURE_KEYS) {
375
+ if (new RegExp(`\\b${key}\\s*:\\s*false\\b`).test(content)) {
376
+ disabled.add(key);
377
+ }
378
+ }
379
+ return disabled;
380
+ }
135
381
  function prependToArrayProperty(lines, property, items) {
136
382
  const pattern = new RegExp(`\\b${property}\\s*:\\s*\\[`);
137
383
  for (let i = 0;i < lines.length; i++) {
@@ -142,7 +388,7 @@ function prependToArrayProperty(lines, property, items) {
142
388
  }
143
389
  return false;
144
390
  }
145
- function transformConfig(content, disabled) {
391
+ function transformConfig2(content, disabled) {
146
392
  const userImports = content.split(`
147
393
  `).filter((line) => /^\s*import\s/.test(line)).filter((line) => !line.includes("@nuasite/")).filter((line) => !line.includes("defineConfig"));
148
394
  let body = extractConfigBody(content);
@@ -182,22 +428,10 @@ function transformConfig(content, disabled) {
182
428
  newPropLines.push(` integrations: [${integrationCalls.join(", ")}],`);
183
429
  }
184
430
  const allLines = [...bodyLines, ...newPropLines];
185
- let result = imports.join(`
186
- `) + `
187
-
188
- `;
189
- result += `export default defineConfig({
190
- `;
191
- if (allLines.length > 0) {
192
- result += allLines.join(`
193
- `) + `
194
- `;
195
- }
196
- result += `})
197
- `;
198
- return result;
431
+ return assembleConfig(imports, allLines.join(`
432
+ `));
199
433
  }
200
- function transformPackageJson(pkg, disabled, usedRuntimePackages = []) {
434
+ function transformPackageJson2(pkg, disabled, usedRuntimePackages = []) {
201
435
  const result = structuredClone(pkg);
202
436
  const nuaVersion = result.dependencies?.["@nuasite/nua"] ?? result.devDependencies?.["@nuasite/nua"];
203
437
  if (result.scripts) {
@@ -241,8 +475,8 @@ function transformPackageJson(pkg, disabled, usedRuntimePackages = []) {
241
475
  return result;
242
476
  }
243
477
  function scanForNuasiteUsage(cwd) {
244
- const srcDir = join2(cwd, "src");
245
- if (!existsSync2(srcDir))
478
+ const srcDir = join3(cwd, "src");
479
+ if (!existsSync3(srcDir))
246
480
  return [];
247
481
  const results = [];
248
482
  try {
@@ -252,11 +486,11 @@ function scanForNuasiteUsage(cwd) {
252
486
  if (!/\.(astro|ts|tsx|js|jsx)$/.test(fileName))
253
487
  continue;
254
488
  try {
255
- const content = readFileSync(join2(srcDir, fileName), "utf-8");
489
+ const content = readFileSync2(join3(srcDir, fileName), "utf-8");
256
490
  const matches = content.match(/@nuasite\/[\w-]+/g);
257
491
  if (matches) {
258
492
  results.push({
259
- file: join2("src", fileName),
493
+ file: join3("src", fileName),
260
494
  packages: [...new Set(matches)]
261
495
  });
262
496
  }
@@ -271,20 +505,20 @@ async function clean({ cwd = process.cwd(), dryRun = false, yes = false } = {})
271
505
  console.error("No Astro config file found.");
272
506
  process.exit(1);
273
507
  }
274
- const configContent = readFileSync(configPath, "utf-8");
508
+ const configContent = readFileSync2(configPath, "utf-8");
275
509
  if (!configContent.includes("@nuasite/nua")) {
276
510
  console.log("This project does not use @nuasite/nua. Nothing to clean.");
277
511
  return;
278
512
  }
279
- const pkgPath = join2(cwd, "package.json");
280
- if (!existsSync2(pkgPath)) {
513
+ const pkgPath = join3(cwd, "package.json");
514
+ if (!existsSync3(pkgPath)) {
281
515
  console.error("No package.json found.");
282
516
  process.exit(1);
283
517
  }
284
- const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
518
+ const pkg = JSON.parse(readFileSync2(pkgPath, "utf-8"));
285
519
  const disabled = detectDisabledFeatures(configContent);
286
520
  const nuasiteUsage = scanForNuasiteUsage(cwd);
287
- const configName = basename(configPath);
521
+ const configName = basename2(configPath);
288
522
  const usedRuntimePackages = new Set;
289
523
  const toolingUsage = [];
290
524
  for (const entry of nuasiteUsage) {
@@ -335,11 +569,11 @@ async function clean({ cwd = process.cwd(), dryRun = false, yes = false } = {})
335
569
  return;
336
570
  }
337
571
  }
338
- const newConfig = transformConfig(configContent, disabled);
339
- writeFileSync(configPath, newConfig);
572
+ const newConfig = transformConfig2(configContent, disabled);
573
+ writeFileSync2(configPath, newConfig);
340
574
  console.log(` Updated ${configName}`);
341
- const newPkg = transformPackageJson(pkg, disabled, [...usedRuntimePackages]);
342
- writeFileSync(pkgPath, JSON.stringify(newPkg, null, "\t") + `
575
+ const newPkg = transformPackageJson2(pkg, disabled, [...usedRuntimePackages]);
576
+ writeFileSync2(pkgPath, JSON.stringify(newPkg, null, "\t") + `
343
577
  `);
344
578
  console.log(" Updated package.json");
345
579
  console.log("");
@@ -585,11 +819,11 @@ var agentsSummary = () => {
585
819
  init_utils();
586
820
  import { build as astroBuild, dev, preview } from "astro";
587
821
  import { spawn } from "child_process";
588
- import { readFileSync as readFileSync2 } from "fs";
822
+ import { readFileSync as readFileSync3 } from "fs";
589
823
  var [, , command, ...args] = process.argv;
590
824
  function hasNuaIntegration(configPath) {
591
825
  try {
592
- const content = readFileSync2(configPath, "utf-8");
826
+ const content = readFileSync3(configPath, "utf-8");
593
827
  return content.includes("@nuasite/agent-summary") || content.includes("agentsSummary");
594
828
  } catch {
595
829
  return false;
@@ -615,6 +849,7 @@ Commands:`);
615
849
  console.log(" build Run astro build with the Nua defaults");
616
850
  console.log(" dev Run astro dev with the Nua defaults");
617
851
  console.log(" preview Run astro preview with the Nua defaults");
852
+ console.log(" init Convert a standard Astro project to use Nua");
618
853
  console.log(" clean Eject to a standard Astro project (remove @nuasite/* deps)");
619
854
  console.log(" help Show this message");
620
855
  console.log(`
@@ -660,6 +895,15 @@ if (canProxyDirectly && command && ["build", "dev", "preview"].includes(command)
660
895
  });
661
896
  break;
662
897
  }
898
+ case "init": {
899
+ const { init: init2 } = await Promise.resolve().then(() => (init_init(), exports_init));
900
+ await init2({
901
+ cwd: process.cwd(),
902
+ dryRun: args.includes("--dry-run"),
903
+ yes: args.includes("--yes") || args.includes("-y")
904
+ });
905
+ break;
906
+ }
663
907
  case "clean": {
664
908
  const { clean: clean2 } = await Promise.resolve().then(() => (init_clean(), exports_clean));
665
909
  await clean2({
@@ -1,18 +1,7 @@
1
- export interface CleanOptions {
2
- cwd?: string;
3
- dryRun?: boolean;
4
- yes?: boolean;
5
- }
1
+ import type { CommandOptions } from './utils';
2
+ export type CleanOptions = CommandOptions;
6
3
  export type FeatureKey = 'cms' | 'pageMarkdown' | 'mdx' | 'sitemap' | 'tailwindcss' | 'checks';
7
4
  export declare function detectDisabledFeatures(content: string): Set<FeatureKey>;
8
- /**
9
- * Extract the text between the outermost { } of defineConfig({ ... })
10
- */
11
- export declare function extractConfigBody(content: string): string;
12
- /**
13
- * Remove a top-level property from an object literal body text.
14
- */
15
- export declare function removeProperty(body: string, propName: string): string;
16
5
  export declare function transformConfig(content: string, disabled: Set<FeatureKey>): string;
17
6
  export declare function transformPackageJson(pkg: Record<string, any>, disabled: Set<FeatureKey>, usedRuntimePackages?: string[]): Record<string, any>;
18
7
  export declare function clean({ cwd, dryRun, yes }?: CleanOptions): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../src/clean.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,YAAY;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,GAAG,CAAC,EAAE,OAAO,CAAA;CACb;AAED,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,cAAc,GAAG,KAAK,GAAG,SAAS,GAAG,aAAa,GAAG,QAAQ,CAAA;AAyB9F,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,UAAU,CAAC,CAQvE;AAsCD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CASzD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAgCrE;AAoBD,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,CAAC,UAAU,CAAC,GAAG,MAAM,CAiElF;AAED,wBAAgB,oBAAoB,CACnC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACxB,QAAQ,EAAE,GAAG,CAAC,UAAU,CAAC,EACzB,mBAAmB,GAAE,MAAM,EAAO,GAChC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAkDrB;AAkCD,wBAAsB,KAAK,CAAC,EAAE,GAAmB,EAAE,MAAc,EAAE,GAAW,EAAE,GAAE,YAAiB,iBAgGlG"}
1
+ {"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../src/clean.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,MAAM,MAAM,YAAY,GAAG,cAAc,CAAA;AAEzC,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,cAAc,GAAG,KAAK,GAAG,SAAS,GAAG,aAAa,GAAG,QAAQ,CAAA;AAyB9F,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,UAAU,CAAC,CAQvE;AAoBD,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,CAAC,UAAU,CAAC,GAAG,MAAM,CA0DlF;AAED,wBAAgB,oBAAoB,CACnC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACxB,QAAQ,EAAE,GAAG,CAAC,UAAU,CAAC,EACzB,mBAAmB,GAAE,MAAM,EAAO,GAChC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAkDrB;AAkCD,wBAAsB,KAAK,CAAC,EAAE,GAAmB,EAAE,MAAc,EAAE,GAAW,EAAE,GAAE,YAAiB,iBAgGlG"}
@@ -0,0 +1,20 @@
1
+ import type { CommandOptions } from './utils';
2
+ export type InitOptions = CommandOptions;
3
+ /**
4
+ * Detect which Nua-managed packages are explicitly imported in the config.
5
+ * Returns a map of package specifier → local import name.
6
+ */
7
+ export declare function detectNuaManagedImports(content: string): Map<string, string>;
8
+ /**
9
+ * Remove a function call (e.g. `mdx()` or `sitemap({ ... })`) from an array property.
10
+ */
11
+ export declare function removeCallFromArray(body: string, arrayProp: string, callName: string): string;
12
+ /**
13
+ * Clean up empty structures left after removing managed integrations/plugins.
14
+ * Removes empty arrays/objects and the Nua-default `sourcemap: true`.
15
+ */
16
+ export declare function cleanEmptyStructures(body: string): string;
17
+ export declare function transformConfig(content: string, managedImports: Map<string, string>): string;
18
+ export declare function transformPackageJson(pkg: Record<string, any>, nuaVersion: string): Record<string, any>;
19
+ export declare function init({ cwd, dryRun, yes }?: InitOptions): Promise<void>;
20
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/init.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,MAAM,MAAM,WAAW,GAAG,cAAc,CAAA;AAexC;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAU5E;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CA4C7F;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQzD;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CA+B5F;AAcD,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAkCtG;AAED,wBAAsB,IAAI,CAAC,EAAE,GAAmB,EAAE,MAAc,EAAE,GAAW,EAAE,GAAE,WAAgB,iBA+EhG"}