@nuasite/cli 0.16.1 → 0.17.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/dist/index.js +393 -22
- package/dist/types/clean.d.ts +19 -0
- package/dist/types/clean.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/utils.d.ts +2 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/clean.ts +402 -0
- package/src/index.ts +16 -23
- package/src/utils.ts +17 -0
package/dist/index.js
CHANGED
|
@@ -1,5 +1,381 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __returnValue = (v) => v;
|
|
5
|
+
function __exportSetter(name, newValue) {
|
|
6
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
7
|
+
}
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: true,
|
|
14
|
+
set: __exportSetter.bind(all, name)
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
18
|
+
|
|
19
|
+
// src/utils.ts
|
|
20
|
+
import { existsSync } from "fs";
|
|
21
|
+
import { join } from "path";
|
|
22
|
+
function findAstroConfig(cwd = process.cwd()) {
|
|
23
|
+
for (const name of CONFIG_NAMES) {
|
|
24
|
+
const p = join(cwd, name);
|
|
25
|
+
if (existsSync(p))
|
|
26
|
+
return p;
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
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
|
+
function findMatchingClose(text, start) {
|
|
62
|
+
const open = text[start];
|
|
63
|
+
const close = open === "{" ? "}" : open === "[" ? "]" : ")";
|
|
64
|
+
let depth = 0;
|
|
65
|
+
let inString = false;
|
|
66
|
+
for (let i = start;i < text.length; i++) {
|
|
67
|
+
const ch = text[i];
|
|
68
|
+
if (inString) {
|
|
69
|
+
if (ch === "\\") {
|
|
70
|
+
i++;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (ch === inString)
|
|
74
|
+
inString = false;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (ch === "'" || ch === '"' || ch === "`") {
|
|
78
|
+
inString = ch;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (ch === open)
|
|
82
|
+
depth++;
|
|
83
|
+
if (ch === close) {
|
|
84
|
+
depth--;
|
|
85
|
+
if (depth === 0)
|
|
86
|
+
return i;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return -1;
|
|
90
|
+
}
|
|
91
|
+
function extractConfigBody(content) {
|
|
92
|
+
const match = content.match(/defineConfig\s*\(\s*\{/);
|
|
93
|
+
if (!match || match.index === undefined)
|
|
94
|
+
return "";
|
|
95
|
+
const openBrace = content.indexOf("{", match.index + "defineConfig".length);
|
|
96
|
+
const closeBrace = findMatchingClose(content, openBrace);
|
|
97
|
+
if (closeBrace === -1)
|
|
98
|
+
return "";
|
|
99
|
+
return content.slice(openBrace + 1, closeBrace);
|
|
100
|
+
}
|
|
101
|
+
function removeProperty(body, propName) {
|
|
102
|
+
const regex = new RegExp(`(\\n[ \\t]*)${propName}\\s*:\\s*`);
|
|
103
|
+
const match = regex.exec(body);
|
|
104
|
+
if (!match || match.index === undefined)
|
|
105
|
+
return body;
|
|
106
|
+
const propLineStart = match.index + 1;
|
|
107
|
+
const afterMatch = match.index + match[0].length;
|
|
108
|
+
let i = afterMatch;
|
|
109
|
+
while (i < body.length && (body[i] === " " || body[i] === "\t"))
|
|
110
|
+
i++;
|
|
111
|
+
let valueEnd;
|
|
112
|
+
if (body[i] === "{" || body[i] === "[") {
|
|
113
|
+
valueEnd = findMatchingClose(body, i);
|
|
114
|
+
if (valueEnd === -1)
|
|
115
|
+
return body;
|
|
116
|
+
valueEnd++;
|
|
117
|
+
} else {
|
|
118
|
+
while (i < body.length && body[i] !== "," && body[i] !== `
|
|
119
|
+
`)
|
|
120
|
+
i++;
|
|
121
|
+
valueEnd = i;
|
|
122
|
+
}
|
|
123
|
+
let end = valueEnd;
|
|
124
|
+
while (end < body.length && (body[end] === " " || body[end] === "\t"))
|
|
125
|
+
end++;
|
|
126
|
+
if (end < body.length && body[end] === ",")
|
|
127
|
+
end++;
|
|
128
|
+
while (end < body.length && (body[end] === " " || body[end] === "\t"))
|
|
129
|
+
end++;
|
|
130
|
+
if (end < body.length && body[end] === `
|
|
131
|
+
`)
|
|
132
|
+
end++;
|
|
133
|
+
return body.slice(0, propLineStart) + body.slice(end);
|
|
134
|
+
}
|
|
135
|
+
function prependToArrayProperty(lines, property, items) {
|
|
136
|
+
const pattern = new RegExp(`\\b${property}\\s*:\\s*\\[`);
|
|
137
|
+
for (let i = 0;i < lines.length; i++) {
|
|
138
|
+
if (pattern.test(lines[i])) {
|
|
139
|
+
lines[i] = lines[i].replace(new RegExp(`(\\b${property}\\s*:\\s*\\[)`), `$1${items}, `);
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
function transformConfig(content, disabled) {
|
|
146
|
+
const userImports = content.split(`
|
|
147
|
+
`).filter((line) => /^\s*import\s/.test(line)).filter((line) => !line.includes("@nuasite/")).filter((line) => !line.includes("defineConfig"));
|
|
148
|
+
let body = extractConfigBody(content);
|
|
149
|
+
body = removeProperty(body, "nua");
|
|
150
|
+
if (content.includes("@nuasite/nua/integration")) {
|
|
151
|
+
body = body.replace(/\bnua\s*\([^)]*\)\s*,?\s*/g, "");
|
|
152
|
+
body = body.replace(/\bintegrations\s*:\s*\[\s*,?\s*\]\s*,?/g, "");
|
|
153
|
+
}
|
|
154
|
+
const imports = [`import { defineConfig } from 'astro/config'`];
|
|
155
|
+
if (!disabled.has("tailwindcss"))
|
|
156
|
+
imports.push(`import tailwindcss from '@tailwindcss/vite'`);
|
|
157
|
+
if (!disabled.has("mdx"))
|
|
158
|
+
imports.push(`import mdx from '@astrojs/mdx'`);
|
|
159
|
+
if (!disabled.has("sitemap"))
|
|
160
|
+
imports.push(`import sitemap from '@astrojs/sitemap'`);
|
|
161
|
+
imports.push(...userImports);
|
|
162
|
+
const integrationCalls = [];
|
|
163
|
+
if (!disabled.has("mdx"))
|
|
164
|
+
integrationCalls.push("mdx()");
|
|
165
|
+
if (!disabled.has("sitemap"))
|
|
166
|
+
integrationCalls.push("sitemap()");
|
|
167
|
+
const bodyLines = body.split(`
|
|
168
|
+
`).filter((line) => line.trim() !== "");
|
|
169
|
+
const hasIntegrations = bodyLines.some((line) => /^\s*integrations\s*:/.test(line));
|
|
170
|
+
const hasVite = bodyLines.some((line) => /^\s*vite\s*:/.test(line));
|
|
171
|
+
if (hasIntegrations && integrationCalls.length > 0) {
|
|
172
|
+
prependToArrayProperty(bodyLines, "integrations", integrationCalls.join(", "));
|
|
173
|
+
}
|
|
174
|
+
if (!disabled.has("tailwindcss") && hasVite) {
|
|
175
|
+
prependToArrayProperty(bodyLines, "plugins", "tailwindcss()");
|
|
176
|
+
}
|
|
177
|
+
const newPropLines = [];
|
|
178
|
+
if (!disabled.has("tailwindcss") && !hasVite) {
|
|
179
|
+
newPropLines.push("\tvite: {", "\t\tbuild: {", "\t\t\tsourcemap: true,", "\t\t},", "\t\tplugins: [tailwindcss()],", "\t},");
|
|
180
|
+
}
|
|
181
|
+
if (!hasIntegrations && integrationCalls.length > 0) {
|
|
182
|
+
newPropLines.push(` integrations: [${integrationCalls.join(", ")}],`);
|
|
183
|
+
}
|
|
184
|
+
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;
|
|
199
|
+
}
|
|
200
|
+
function transformPackageJson(pkg, disabled, usedRuntimePackages = []) {
|
|
201
|
+
const result = structuredClone(pkg);
|
|
202
|
+
const nuaVersion = result.dependencies?.["@nuasite/nua"] ?? result.devDependencies?.["@nuasite/nua"];
|
|
203
|
+
if (result.scripts) {
|
|
204
|
+
for (const [key, value] of Object.entries(result.scripts)) {
|
|
205
|
+
if (typeof value === "string") {
|
|
206
|
+
result.scripts[key] = value.replace(/\bnua build\b/g, "astro build").replace(/\bnua dev\b/g, "astro dev").replace(/\bnua preview\b/g, "astro preview");
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
for (const field of ["dependencies", "devDependencies", "peerDependencies"]) {
|
|
211
|
+
if (!result[field])
|
|
212
|
+
continue;
|
|
213
|
+
for (const name of NUASITE_TOOLING) {
|
|
214
|
+
delete result[field][name];
|
|
215
|
+
}
|
|
216
|
+
if (Object.keys(result[field]).length === 0) {
|
|
217
|
+
delete result[field];
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (!result.dependencies)
|
|
221
|
+
result.dependencies = {};
|
|
222
|
+
for (const [name, version] of Object.entries(PACKAGES_TO_ADD)) {
|
|
223
|
+
if (result.dependencies[name])
|
|
224
|
+
continue;
|
|
225
|
+
if (name === "@astrojs/mdx" && disabled.has("mdx"))
|
|
226
|
+
continue;
|
|
227
|
+
if (name === "@astrojs/sitemap" && disabled.has("sitemap"))
|
|
228
|
+
continue;
|
|
229
|
+
if (name === "@tailwindcss/vite" && disabled.has("tailwindcss"))
|
|
230
|
+
continue;
|
|
231
|
+
if (name === "tailwindcss" && disabled.has("tailwindcss"))
|
|
232
|
+
continue;
|
|
233
|
+
result.dependencies[name] = version;
|
|
234
|
+
}
|
|
235
|
+
for (const name of usedRuntimePackages) {
|
|
236
|
+
if (!result.dependencies[name]) {
|
|
237
|
+
result.dependencies[name] = nuaVersion ?? "^0.16.0";
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
result.dependencies = Object.fromEntries(Object.entries(result.dependencies).sort(([a], [b]) => a.localeCompare(b)));
|
|
241
|
+
return result;
|
|
242
|
+
}
|
|
243
|
+
function scanForNuasiteUsage(cwd) {
|
|
244
|
+
const srcDir = join2(cwd, "src");
|
|
245
|
+
if (!existsSync2(srcDir))
|
|
246
|
+
return [];
|
|
247
|
+
const results = [];
|
|
248
|
+
try {
|
|
249
|
+
const files = readdirSync(srcDir, { recursive: true });
|
|
250
|
+
for (const entry of files) {
|
|
251
|
+
const fileName = String(entry);
|
|
252
|
+
if (!/\.(astro|ts|tsx|js|jsx)$/.test(fileName))
|
|
253
|
+
continue;
|
|
254
|
+
try {
|
|
255
|
+
const content = readFileSync(join2(srcDir, fileName), "utf-8");
|
|
256
|
+
const matches = content.match(/@nuasite\/[\w-]+/g);
|
|
257
|
+
if (matches) {
|
|
258
|
+
results.push({
|
|
259
|
+
file: join2("src", fileName),
|
|
260
|
+
packages: [...new Set(matches)]
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
} catch {}
|
|
264
|
+
}
|
|
265
|
+
} catch {}
|
|
266
|
+
return results;
|
|
267
|
+
}
|
|
268
|
+
async function clean({ cwd = process.cwd(), dryRun = false, yes = false } = {}) {
|
|
269
|
+
const configPath = findAstroConfig(cwd);
|
|
270
|
+
if (!configPath) {
|
|
271
|
+
console.error("No Astro config file found.");
|
|
272
|
+
process.exit(1);
|
|
273
|
+
}
|
|
274
|
+
const configContent = readFileSync(configPath, "utf-8");
|
|
275
|
+
if (!configContent.includes("@nuasite/nua")) {
|
|
276
|
+
console.log("This project does not use @nuasite/nua. Nothing to clean.");
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
const pkgPath = join2(cwd, "package.json");
|
|
280
|
+
if (!existsSync2(pkgPath)) {
|
|
281
|
+
console.error("No package.json found.");
|
|
282
|
+
process.exit(1);
|
|
283
|
+
}
|
|
284
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
285
|
+
const disabled = detectDisabledFeatures(configContent);
|
|
286
|
+
const nuasiteUsage = scanForNuasiteUsage(cwd);
|
|
287
|
+
const configName = basename(configPath);
|
|
288
|
+
const usedRuntimePackages = new Set;
|
|
289
|
+
const toolingUsage = [];
|
|
290
|
+
for (const entry of nuasiteUsage) {
|
|
291
|
+
const runtime = entry.packages.filter((p) => !NUASITE_TOOLING.includes(p));
|
|
292
|
+
const tooling = entry.packages.filter((p) => NUASITE_TOOLING.includes(p));
|
|
293
|
+
for (const p of runtime)
|
|
294
|
+
usedRuntimePackages.add(p);
|
|
295
|
+
if (tooling.length > 0) {
|
|
296
|
+
toolingUsage.push({ file: entry.file, packages: tooling });
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
console.log("");
|
|
300
|
+
console.log("nua clean \u2014 eject to standard Astro project");
|
|
301
|
+
console.log("");
|
|
302
|
+
console.log(` ${configName}`);
|
|
303
|
+
console.log(" - Replace @nuasite/nua with explicit Astro integrations");
|
|
304
|
+
console.log(" - Add mdx, sitemap, tailwindcss imports");
|
|
305
|
+
if (disabled.size > 0) {
|
|
306
|
+
console.log(` - Skipping disabled: ${[...disabled].join(", ")}`);
|
|
307
|
+
}
|
|
308
|
+
console.log("");
|
|
309
|
+
console.log(" package.json");
|
|
310
|
+
console.log(" - Remove @nuasite/* tooling dependencies");
|
|
311
|
+
if (usedRuntimePackages.size > 0) {
|
|
312
|
+
console.log(` - Keep as explicit deps: ${[...usedRuntimePackages].join(", ")}`);
|
|
313
|
+
}
|
|
314
|
+
console.log(" - Add standard Astro packages");
|
|
315
|
+
console.log(" - Update scripts: nua \u2192 astro");
|
|
316
|
+
if (toolingUsage.length > 0) {
|
|
317
|
+
console.log("");
|
|
318
|
+
console.log(" Warning: @nuasite tooling imports found in source files:");
|
|
319
|
+
for (const { file, packages } of toolingUsage) {
|
|
320
|
+
console.log(` ${file} (${packages.join(", ")})`);
|
|
321
|
+
}
|
|
322
|
+
console.log(" These will need manual removal.");
|
|
323
|
+
}
|
|
324
|
+
if (dryRun) {
|
|
325
|
+
console.log("");
|
|
326
|
+
console.log(" (--dry-run: no changes made)");
|
|
327
|
+
console.log("");
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
if (!yes) {
|
|
331
|
+
console.log("");
|
|
332
|
+
const answer = prompt("Proceed? [y/N] ");
|
|
333
|
+
if (answer?.toLowerCase() !== "y") {
|
|
334
|
+
console.log("Cancelled.");
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
const newConfig = transformConfig(configContent, disabled);
|
|
339
|
+
writeFileSync(configPath, newConfig);
|
|
340
|
+
console.log(` Updated ${configName}`);
|
|
341
|
+
const newPkg = transformPackageJson(pkg, disabled, [...usedRuntimePackages]);
|
|
342
|
+
writeFileSync(pkgPath, JSON.stringify(newPkg, null, "\t") + `
|
|
343
|
+
`);
|
|
344
|
+
console.log(" Updated package.json");
|
|
345
|
+
console.log("");
|
|
346
|
+
console.log("Next steps:");
|
|
347
|
+
console.log(" 1. bun install");
|
|
348
|
+
console.log(" 2. Review the updated config");
|
|
349
|
+
console.log(" 3. astro dev");
|
|
350
|
+
if (toolingUsage.length > 0) {
|
|
351
|
+
console.log(" 4. Remove @nuasite tooling imports from source files");
|
|
352
|
+
}
|
|
353
|
+
console.log("");
|
|
354
|
+
}
|
|
355
|
+
var FEATURE_KEYS, NUASITE_TOOLING, PACKAGES_TO_ADD;
|
|
356
|
+
var init_clean = __esm(() => {
|
|
357
|
+
init_utils();
|
|
358
|
+
FEATURE_KEYS = ["cms", "pageMarkdown", "mdx", "sitemap", "tailwindcss", "checks"];
|
|
359
|
+
NUASITE_TOOLING = [
|
|
360
|
+
"@nuasite/nua",
|
|
361
|
+
"@nuasite/core",
|
|
362
|
+
"@nuasite/cli",
|
|
363
|
+
"@nuasite/cms",
|
|
364
|
+
"@nuasite/llm-enhancements",
|
|
365
|
+
"@nuasite/checks",
|
|
366
|
+
"@nuasite/agent-summary"
|
|
367
|
+
];
|
|
368
|
+
PACKAGES_TO_ADD = {
|
|
369
|
+
astro: "^6.0.2",
|
|
370
|
+
"@astrojs/check": "^0.9.7",
|
|
371
|
+
"@astrojs/mdx": "^5.0.0",
|
|
372
|
+
"@astrojs/rss": "^4.0.17",
|
|
373
|
+
"@astrojs/sitemap": "^3.7.1",
|
|
374
|
+
"@tailwindcss/vite": "^4.2.1",
|
|
375
|
+
tailwindcss: "^4.2.1",
|
|
376
|
+
typescript: "^5"
|
|
377
|
+
};
|
|
378
|
+
});
|
|
3
379
|
|
|
4
380
|
// ../agent-summary/src/agent-summary-integration.ts
|
|
5
381
|
import fs2 from "fs/promises";
|
|
@@ -206,34 +582,19 @@ var agentsSummary = () => {
|
|
|
206
582
|
};
|
|
207
583
|
};
|
|
208
584
|
// src/index.ts
|
|
585
|
+
init_utils();
|
|
209
586
|
import { build as astroBuild, dev, preview } from "astro";
|
|
210
587
|
import { spawn } from "child_process";
|
|
211
|
-
import {
|
|
212
|
-
import { join } from "path";
|
|
588
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
213
589
|
var [, , command, ...args] = process.argv;
|
|
214
590
|
function hasNuaIntegration(configPath) {
|
|
215
591
|
try {
|
|
216
|
-
const content =
|
|
592
|
+
const content = readFileSync2(configPath, "utf-8");
|
|
217
593
|
return content.includes("@nuasite/agent-summary") || content.includes("agentsSummary");
|
|
218
594
|
} catch {
|
|
219
595
|
return false;
|
|
220
596
|
}
|
|
221
597
|
}
|
|
222
|
-
function findAstroConfig() {
|
|
223
|
-
const possibleConfigs = [
|
|
224
|
-
"astro.config.mjs",
|
|
225
|
-
"astro.config.js",
|
|
226
|
-
"astro.config.ts",
|
|
227
|
-
"astro.config.mts"
|
|
228
|
-
];
|
|
229
|
-
for (const config of possibleConfigs) {
|
|
230
|
-
const configPath = join(process.cwd(), config);
|
|
231
|
-
if (existsSync(configPath)) {
|
|
232
|
-
return configPath;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
return null;
|
|
236
|
-
}
|
|
237
598
|
function proxyToAstroCLI(command2, args2) {
|
|
238
599
|
const astro = spawn("npx", ["astro", command2, ...args2], {
|
|
239
600
|
stdio: "inherit",
|
|
@@ -251,10 +612,11 @@ function printUsage() {
|
|
|
251
612
|
console.log("Usage: nua <command> [options]");
|
|
252
613
|
console.log(`
|
|
253
614
|
Commands:`);
|
|
254
|
-
console.log(" build
|
|
255
|
-
console.log("
|
|
256
|
-
console.log("
|
|
257
|
-
console.log("
|
|
615
|
+
console.log(" build Run astro build with the Nua defaults");
|
|
616
|
+
console.log(" dev Run astro dev with the Nua defaults");
|
|
617
|
+
console.log(" preview Run astro preview with the Nua defaults");
|
|
618
|
+
console.log(" clean Eject to a standard Astro project (remove @nuasite/* deps)");
|
|
619
|
+
console.log(" help Show this message");
|
|
258
620
|
console.log(`
|
|
259
621
|
All Astro CLI options are supported.
|
|
260
622
|
`);
|
|
@@ -298,6 +660,15 @@ if (canProxyDirectly && command && ["build", "dev", "preview"].includes(command)
|
|
|
298
660
|
});
|
|
299
661
|
break;
|
|
300
662
|
}
|
|
663
|
+
case "clean": {
|
|
664
|
+
const { clean: clean2 } = await Promise.resolve().then(() => (init_clean(), exports_clean));
|
|
665
|
+
await clean2({
|
|
666
|
+
cwd: process.cwd(),
|
|
667
|
+
dryRun: args.includes("--dry-run"),
|
|
668
|
+
yes: args.includes("--yes") || args.includes("-y")
|
|
669
|
+
});
|
|
670
|
+
break;
|
|
671
|
+
}
|
|
301
672
|
case "help":
|
|
302
673
|
case "--help":
|
|
303
674
|
case "-h":
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface CleanOptions {
|
|
2
|
+
cwd?: string;
|
|
3
|
+
dryRun?: boolean;
|
|
4
|
+
yes?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export type FeatureKey = 'cms' | 'pageMarkdown' | 'mdx' | 'sitemap' | 'tailwindcss' | 'checks';
|
|
7
|
+
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
|
+
export declare function transformConfig(content: string, disabled: Set<FeatureKey>): string;
|
|
17
|
+
export declare function transformPackageJson(pkg: Record<string, any>, disabled: Set<FeatureKey>, usedRuntimePackages?: string[]): Record<string, any>;
|
|
18
|
+
export declare function clean({ cwd, dryRun, yes }?: CleanOptions): Promise<void>;
|
|
19
|
+
//# sourceMappingURL=clean.d.ts.map
|
|
@@ -0,0 +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"}
|