sv 0.14.1 → 0.15.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/bin.mjs +1 -1
- package/dist/{engine-BdGJvT03.d.mts → engine-3mrtB4nw.d.mts} +12 -57
- package/dist/{engine-CK31LRlH.mjs → engine-CzIdz0uO.mjs} +530 -513
- package/dist/shared.json +3 -3
- package/dist/src/index.d.mts +8 -3
- package/dist/src/index.mjs +12 -1
- package/dist/src/testing.d.mts +7 -44
- package/dist/src/testing.mjs +12 -8
- package/dist/templates/addon/assets/src/index.js +1 -1
- package/dist/templates/addon/assets/src/sv-utils.js +3 -0
- package/dist/templates/addon/assets/tsdown.config.js +1 -1
- package/dist/templates/addon/package.json +4 -4
- package/dist/templates/demo/package.json +5 -5
- package/dist/templates/library/package.json +7 -7
- package/dist/templates/minimal/package.json +5 -5
- package/package.json +2 -2
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
import { AGENTS, COMMANDS, Walker, color,
|
|
2
|
+
import { AGENTS, COMMANDS, Walker, color, constructCommand, createPrinter, dedent, detect, downloadJson, fileExists, isVersionUnsupportedBelow, js, loadFile, loadPackageJson, parse, pnpm, resolveCommand, resolveCommandArray, sanitizeName, saveFile, splitVersion, svelte, text, transforms } from "@sveltejs/sv-utils";
|
|
3
3
|
import fs, { existsSync } from "node:fs";
|
|
4
4
|
import path, { delimiter, dirname, isAbsolute, join, normalize, resolve } from "node:path";
|
|
5
|
-
import { fileURLToPath } from "node:url";
|
|
6
5
|
import process$1, { cwd, stdin, stdout } from "node:process";
|
|
7
6
|
import * as k$1 from "node:readline";
|
|
8
7
|
import c from "node:readline";
|
|
9
8
|
import { ReadStream } from "node:tty";
|
|
10
9
|
import { promisify, stripVTControlCharacters } from "node:util";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
11
|
import { exec, spawn } from "node:child_process";
|
|
12
12
|
import { PassThrough } from "node:stream";
|
|
13
13
|
import crypto from "node:crypto";
|
|
@@ -38,156 +38,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
38
38
|
}) : target, mod));
|
|
39
39
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
40
40
|
//#endregion
|
|
41
|
-
//#region src/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
throw e;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function identity(x) {
|
|
52
|
-
return x;
|
|
53
|
-
}
|
|
54
|
-
function replace(contents, kv) {
|
|
55
|
-
for (const [key, value] of Object.entries(kv)) contents = contents.replaceAll(key, value);
|
|
56
|
-
return contents;
|
|
57
|
-
}
|
|
58
|
-
function kv(name) {
|
|
59
|
-
const protocolName = name.startsWith("@") ? name.split("/")[0] : name;
|
|
60
|
-
return {
|
|
61
|
-
"~SV-PROTOCOL-NAME-TODO~": protocolName,
|
|
62
|
-
"~SV-NAME-TODO~": name
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
const withReplaceExtensions = [
|
|
66
|
-
".md",
|
|
67
|
-
".js",
|
|
68
|
-
".ts",
|
|
69
|
-
".json"
|
|
70
|
-
];
|
|
71
|
-
function copy(from, to, rename = identity, kv = {}) {
|
|
72
|
-
if (!fs.existsSync(from)) return;
|
|
73
|
-
if (fs.statSync(from).isDirectory()) fs.readdirSync(from).forEach((file) => {
|
|
74
|
-
copy(path.join(from, file), path.join(to, rename(file)), rename, kv);
|
|
75
|
-
});
|
|
76
|
-
else {
|
|
77
|
-
mkdirp(path.dirname(to));
|
|
78
|
-
if (withReplaceExtensions.some((ext) => from.endsWith(ext))) fs.writeFileSync(to, replace(fs.readFileSync(from, "utf-8"), kv));
|
|
79
|
-
else fs.copyFileSync(from, to);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
function dist(path) {
|
|
83
|
-
const insideDistFolder = import.meta.url.includes("dist");
|
|
84
|
-
return fileURLToPath(new URL(`./${!insideDistFolder ? "dist/" : ""}${path}`, import.meta.url).href);
|
|
85
|
-
}
|
|
86
|
-
function getSharedFiles() {
|
|
87
|
-
const shared = dist("shared.json");
|
|
88
|
-
const { files } = JSON.parse(fs.readFileSync(shared, "utf-8"));
|
|
89
|
-
return files;
|
|
90
|
-
}
|
|
91
|
-
//#endregion
|
|
92
|
-
//#region src/create/index.ts
|
|
93
|
-
const publicTemplateTypes = [
|
|
94
|
-
"minimal",
|
|
95
|
-
"demo",
|
|
96
|
-
"library",
|
|
97
|
-
"addon"
|
|
98
|
-
];
|
|
99
|
-
const templateTypes = [
|
|
100
|
-
"minimal",
|
|
101
|
-
"demo",
|
|
102
|
-
"library",
|
|
103
|
-
"addon",
|
|
104
|
-
"svelte"
|
|
105
|
-
];
|
|
106
|
-
const languageTypes = [
|
|
107
|
-
"typescript",
|
|
108
|
-
"checkjs",
|
|
109
|
-
"none"
|
|
110
|
-
];
|
|
111
|
-
function create$1(cwd, options) {
|
|
112
|
-
mkdirp(cwd);
|
|
113
|
-
write_template_files(options.template, options.types, options.name, cwd);
|
|
114
|
-
if (options.template !== "svelte") write_common_files(cwd, options, options.name);
|
|
115
|
-
if (options.template === "addon") {
|
|
116
|
-
fs.rmSync(path.join(cwd, "svelte.config.js"));
|
|
117
|
-
fs.rmSync(path.join(cwd, "vite.config.js"));
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
const templates = publicTemplateTypes.map((dir) => {
|
|
121
|
-
const meta_file = dist(`templates/${dir}/meta.json`);
|
|
122
|
-
const { title, description } = JSON.parse(fs.readFileSync(meta_file, "utf8"));
|
|
123
|
-
return {
|
|
124
|
-
name: dir,
|
|
125
|
-
title,
|
|
126
|
-
description
|
|
127
|
-
};
|
|
128
|
-
});
|
|
129
|
-
function write_template_files(template, types, name, cwd) {
|
|
130
|
-
const dir = dist(`templates/${template}`);
|
|
131
|
-
copy(`${dir}/assets`, cwd, (name) => name.replace("DOT-", "."), kv(name));
|
|
132
|
-
copy(`${dir}/package.json`, `${cwd}/package.json`, void 0, kv(name));
|
|
133
|
-
const manifest = `${dir}/files.types=${types}.json`;
|
|
134
|
-
JSON.parse(fs.readFileSync(manifest, "utf-8")).forEach((file) => {
|
|
135
|
-
const dest = path.join(cwd, file.name);
|
|
136
|
-
mkdirp(path.dirname(dest));
|
|
137
|
-
fs.writeFileSync(dest, replace(file.contents, kv(name)));
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
function write_common_files(cwd, options, name) {
|
|
141
|
-
const files = getSharedFiles();
|
|
142
|
-
const pkg_file = path.join(cwd, commonFilePaths.packageJson);
|
|
143
|
-
const pkg = JSON.parse(fs.readFileSync(pkg_file, "utf-8"));
|
|
144
|
-
sort_files(files).forEach((file) => {
|
|
145
|
-
const include = file.include.every((condition) => matches_condition(condition, options));
|
|
146
|
-
if (file.exclude.some((condition) => matches_condition(condition, options)) || !include) return;
|
|
147
|
-
if (file.name === commonFilePaths.packageJson) merge(pkg, JSON.parse(file.contents));
|
|
148
|
-
else {
|
|
149
|
-
const dest = path.join(cwd, file.name);
|
|
150
|
-
mkdirp(path.dirname(dest));
|
|
151
|
-
fs.writeFileSync(dest, replace(file.contents, kv(name)));
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
pkg.dependencies = sort_keys(pkg.dependencies);
|
|
155
|
-
pkg.devDependencies = sort_keys(pkg.devDependencies);
|
|
156
|
-
pkg.name = sanitizeName(name, "package");
|
|
157
|
-
fs.writeFileSync(pkg_file, JSON.stringify(pkg, null, " ") + "\n");
|
|
158
|
-
}
|
|
159
|
-
function matches_condition(condition, options) {
|
|
160
|
-
if (templateTypes.includes(condition)) return options.template === condition;
|
|
161
|
-
if (languageTypes.includes(condition)) return options.types === condition;
|
|
162
|
-
return Boolean(options[condition]);
|
|
163
|
-
}
|
|
164
|
-
function merge(target, source) {
|
|
165
|
-
for (const key in source) if (key in target) {
|
|
166
|
-
const target_value = target[key];
|
|
167
|
-
const source_value = source[key];
|
|
168
|
-
if (typeof source_value !== typeof target_value || Array.isArray(source_value) !== Array.isArray(target_value)) throw new Error("Mismatched values");
|
|
169
|
-
if (typeof source_value === "object") merge(target_value, source_value);
|
|
170
|
-
else target[key] = source_value;
|
|
171
|
-
} else target[key] = source[key];
|
|
172
|
-
}
|
|
173
|
-
function sort_keys(obj) {
|
|
174
|
-
if (!obj) return;
|
|
175
|
-
const sorted = {};
|
|
176
|
-
Object.keys(obj).sort().forEach((key) => {
|
|
177
|
-
sorted[key] = obj[key];
|
|
178
|
-
});
|
|
179
|
-
return sorted;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Sort files so that those which apply more generically come first so they
|
|
183
|
-
* can be overwritten by files for more precise cases later.
|
|
184
|
-
*/
|
|
185
|
-
function sort_files(files) {
|
|
186
|
-
return files.sort((f1, f2) => {
|
|
187
|
-
const f1_more_generic = f1.include.every((include) => f2.include.includes(include)) && f1.exclude.every((exclude) => f2.exclude.includes(exclude));
|
|
188
|
-
const f2_more_generic = f2.include.every((include) => f1.include.includes(include)) && f2.exclude.every((exclude) => f1.exclude.includes(exclude));
|
|
189
|
-
return f1_more_generic && f2_more_generic || !f1_more_generic && !f2_more_generic ? 0 : f1_more_generic ? -1 : 1;
|
|
190
|
-
});
|
|
41
|
+
//#region src/core/deprecated.ts
|
|
42
|
+
const warned = /* @__PURE__ */ new Set();
|
|
43
|
+
/** Emit a one-time deprecation warning. */
|
|
44
|
+
function svDeprecated(message) {
|
|
45
|
+
if (warned.has(message)) return;
|
|
46
|
+
warned.add(message);
|
|
47
|
+
console.warn(`[sv] Deprecated: ${message}`);
|
|
191
48
|
}
|
|
192
49
|
//#endregion
|
|
193
50
|
//#region ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
|
|
@@ -1532,6 +1389,376 @@ ${r ? import_picocolors.default.cyan(x$1) : ""}
|
|
|
1532
1389
|
}
|
|
1533
1390
|
}).prompt();
|
|
1534
1391
|
//#endregion
|
|
1392
|
+
//#region package.json
|
|
1393
|
+
var name = "sv";
|
|
1394
|
+
var version = "0.15.0";
|
|
1395
|
+
//#endregion
|
|
1396
|
+
//#region src/core/errors.ts
|
|
1397
|
+
var UnsupportedError = class extends Error {
|
|
1398
|
+
constructor(reasons) {
|
|
1399
|
+
super();
|
|
1400
|
+
this.name = "Unsupported Environment";
|
|
1401
|
+
this.reasons = [];
|
|
1402
|
+
this.reasons = reasons;
|
|
1403
|
+
}
|
|
1404
|
+
};
|
|
1405
|
+
//#endregion
|
|
1406
|
+
//#region src/core/common.ts
|
|
1407
|
+
const NO_PREFIX = "--no-";
|
|
1408
|
+
let options$7 = [];
|
|
1409
|
+
function getLongFlag(flags) {
|
|
1410
|
+
return flags.split(",").map((f) => f.trim()).find((f) => f.startsWith("--"));
|
|
1411
|
+
}
|
|
1412
|
+
const helpConfig = {
|
|
1413
|
+
argumentDescription: formatDescription,
|
|
1414
|
+
optionDescription: formatDescription,
|
|
1415
|
+
visibleOptions(cmd) {
|
|
1416
|
+
options$7 = cmd.options;
|
|
1417
|
+
const visible = cmd.options.filter((o) => !o.hidden);
|
|
1418
|
+
const show = [];
|
|
1419
|
+
for (const option of visible) {
|
|
1420
|
+
const flag = getLongFlag(option.flags);
|
|
1421
|
+
if (flag?.startsWith(NO_PREFIX)) {
|
|
1422
|
+
const stripped = flag.slice(5);
|
|
1423
|
+
if (visible.some((o) => getLongFlag(o.flags)?.startsWith(`--${stripped}`))) continue;
|
|
1424
|
+
}
|
|
1425
|
+
show.push(option);
|
|
1426
|
+
}
|
|
1427
|
+
return show;
|
|
1428
|
+
},
|
|
1429
|
+
optionTerm(option) {
|
|
1430
|
+
const longFlag = getLongFlag(option.flags);
|
|
1431
|
+
const flag = longFlag?.split(" ").at(0);
|
|
1432
|
+
if (!flag || !longFlag) return option.flags;
|
|
1433
|
+
const noVariant = `--no-${flag.slice(2)}`;
|
|
1434
|
+
if (options$7.some((o) => getLongFlag(o.flags) === noVariant)) return `--[no-]${longFlag.slice(2)}`;
|
|
1435
|
+
return option.flags;
|
|
1436
|
+
},
|
|
1437
|
+
styleCommandText: (str) => color.success(str),
|
|
1438
|
+
styleDescriptionText: (str) => color.optional(str)
|
|
1439
|
+
};
|
|
1440
|
+
function formatDescription(arg) {
|
|
1441
|
+
let output = arg.description;
|
|
1442
|
+
if (arg.defaultValue !== void 0 && String(arg.defaultValue)) output += color.dim(` (default: ${JSON.stringify(arg.defaultValue)})`);
|
|
1443
|
+
if (arg.argChoices !== void 0 && String(arg.argChoices)) output += color.dim(` (choices: ${arg.argChoices.join(", ")})`);
|
|
1444
|
+
return output;
|
|
1445
|
+
}
|
|
1446
|
+
/**
|
|
1447
|
+
* Returns standard help sections and a formatItem helper.
|
|
1448
|
+
* Used by `add` and `create` custom `formatHelp` to avoid duplicating boilerplate.
|
|
1449
|
+
*/
|
|
1450
|
+
function getHelpSections(cmd, helper) {
|
|
1451
|
+
const termWidth = helper.padWidth(cmd, helper);
|
|
1452
|
+
const helpWidth = helper.helpWidth ?? 80;
|
|
1453
|
+
function formatItem(term, description) {
|
|
1454
|
+
return helper.formatItem(term, termWidth, description, helper);
|
|
1455
|
+
}
|
|
1456
|
+
const usage = [`${helper.styleTitle("Usage:")} ${helper.styleUsage(helper.commandUsage(cmd))}`, ""];
|
|
1457
|
+
const descText = helper.commandDescription(cmd);
|
|
1458
|
+
const description = descText.length > 0 ? [helper.boxWrap(helper.styleCommandDescription(descText), helpWidth), ""] : [];
|
|
1459
|
+
const argItems = helper.visibleArguments(cmd).map((argument) => formatItem(helper.styleArgumentTerm(helper.argumentTerm(argument)), helper.styleArgumentDescription(helper.argumentDescription(argument))));
|
|
1460
|
+
const arguments_ = argItems.length > 0 ? [
|
|
1461
|
+
helper.styleTitle("Arguments:"),
|
|
1462
|
+
...argItems,
|
|
1463
|
+
""
|
|
1464
|
+
] : [];
|
|
1465
|
+
const optItems = helper.visibleOptions(cmd).map((option) => formatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option))));
|
|
1466
|
+
const options = optItems.length > 0 ? [
|
|
1467
|
+
helper.styleTitle("Options:"),
|
|
1468
|
+
...optItems,
|
|
1469
|
+
""
|
|
1470
|
+
] : [];
|
|
1471
|
+
const globalOptItems = helper.showGlobalOptions ? helper.visibleGlobalOptions(cmd).map((option) => formatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)))) : [];
|
|
1472
|
+
const globalOptions = globalOptItems.length > 0 ? [
|
|
1473
|
+
helper.styleTitle("Global Options:"),
|
|
1474
|
+
...globalOptItems,
|
|
1475
|
+
""
|
|
1476
|
+
] : [];
|
|
1477
|
+
const cmdItems = helper.visibleCommands(cmd).map((sub) => formatItem(helper.styleSubcommandTerm(helper.subcommandTerm(sub)), helper.styleSubcommandDescription(helper.subcommandDescription(sub))));
|
|
1478
|
+
const commands = cmdItems.length > 0 ? [
|
|
1479
|
+
helper.styleTitle("Commands:"),
|
|
1480
|
+
...cmdItems,
|
|
1481
|
+
""
|
|
1482
|
+
] : [];
|
|
1483
|
+
return {
|
|
1484
|
+
formatItem,
|
|
1485
|
+
styleTitle: helper.styleTitle.bind(helper),
|
|
1486
|
+
usage,
|
|
1487
|
+
description,
|
|
1488
|
+
arguments: arguments_,
|
|
1489
|
+
options,
|
|
1490
|
+
globalOptions,
|
|
1491
|
+
commands
|
|
1492
|
+
};
|
|
1493
|
+
}
|
|
1494
|
+
async function runCommand(action) {
|
|
1495
|
+
try {
|
|
1496
|
+
console.log(color.hidden("HINT: Run \"sv --help\" to get the full list of commands, add-ons, and examples to one-shot and skip interactive prompts."));
|
|
1497
|
+
Nt(`Welcome to the Svelte CLI! ${color.optional(`(v${version})`)}`);
|
|
1498
|
+
const minimumVersion = "18.3.0";
|
|
1499
|
+
if (isVersionUnsupportedBelow(process$1.versions.node, minimumVersion)) R$1.warn(`You are using Node.js ${color.error(process$1.versions.node)}, please upgrade to Node.js ${color.success(minimumVersion)} or higher.`);
|
|
1500
|
+
await action();
|
|
1501
|
+
Wt("You're all set!");
|
|
1502
|
+
} catch (e) {
|
|
1503
|
+
if (e instanceof UnsupportedError) {
|
|
1504
|
+
const padding = getPadding(e.reasons.map((r) => r.id));
|
|
1505
|
+
const message = e.reasons.map((r) => ` ${r.id.padEnd(padding)} ${color.error(r.reason)}`).join("\n");
|
|
1506
|
+
R$1.error(`${e.name}\n\n${message}`);
|
|
1507
|
+
R$1.message();
|
|
1508
|
+
} else if (e instanceof Error) {
|
|
1509
|
+
R$1.error(e.stack ?? String(e));
|
|
1510
|
+
R$1.message();
|
|
1511
|
+
}
|
|
1512
|
+
Pt("Operation failed.");
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
function getPadding(lines) {
|
|
1516
|
+
const lengths = lines.map((s) => s.length);
|
|
1517
|
+
return Math.max(...lengths);
|
|
1518
|
+
}
|
|
1519
|
+
function forwardExitCode(error) {
|
|
1520
|
+
if (error && typeof error === "object" && "status" in error && typeof error.status === "number") process$1.exit(error.status);
|
|
1521
|
+
else process$1.exit(1);
|
|
1522
|
+
}
|
|
1523
|
+
function parseAddonOptions(optionFlags) {
|
|
1524
|
+
if (optionFlags === void 0 || optionFlags === "") return;
|
|
1525
|
+
const options = optionFlags.split("+");
|
|
1526
|
+
const malformed = options.filter((option) => !/.+:.*/.test(option));
|
|
1527
|
+
if (malformed.length > 0) {
|
|
1528
|
+
const message = `Malformed arguments: The following add-on options: ${malformed.map((o) => `'${o}'`).join(", ")} are missing their option name or value (e.g. 'addon=option1:value1+option2:value2').`;
|
|
1529
|
+
throw new Error(message);
|
|
1530
|
+
}
|
|
1531
|
+
return options;
|
|
1532
|
+
}
|
|
1533
|
+
function buildAndLogArgs(agent, command, args, lastArgs = []) {
|
|
1534
|
+
const allArgs = [
|
|
1535
|
+
`sv@${version}`,
|
|
1536
|
+
command,
|
|
1537
|
+
...args
|
|
1538
|
+
];
|
|
1539
|
+
if (agent === null || agent === void 0) allArgs.push("--no-install");
|
|
1540
|
+
else allArgs.push("--install", agent);
|
|
1541
|
+
const message = resolveCommandArray(agent ?? "npm", "execute", [...allArgs, ...lastArgs]).join(" ");
|
|
1542
|
+
R$1.message(color.optional(color.dim(`To skip prompts next time, run:`)));
|
|
1543
|
+
R$1.info(color.optional(message), { spacing: -1 });
|
|
1544
|
+
return message;
|
|
1545
|
+
}
|
|
1546
|
+
function updateReadme(projectPath, command) {
|
|
1547
|
+
const readmePath = path.join(projectPath, "README.md");
|
|
1548
|
+
if (!fs.existsSync(readmePath)) return;
|
|
1549
|
+
let content = fs.readFileSync(readmePath, "utf-8");
|
|
1550
|
+
const creatingSectionPattern = /## Creating a project[\s\S]*?(?=## |$)/;
|
|
1551
|
+
const creatingSectionMatch = content.match(creatingSectionPattern);
|
|
1552
|
+
if (!creatingSectionMatch) return;
|
|
1553
|
+
const updatedSection = `${creatingSectionMatch[0].trim()}\n\nTo recreate this project with the same configuration:
|
|
1554
|
+
|
|
1555
|
+
\`\`\`sh
|
|
1556
|
+
# recreate this project
|
|
1557
|
+
${command}\n\`\`\`
|
|
1558
|
+
|
|
1559
|
+
`;
|
|
1560
|
+
content = content.replace(creatingSectionPattern, updatedSection);
|
|
1561
|
+
fs.writeFileSync(readmePath, content);
|
|
1562
|
+
}
|
|
1563
|
+
function errorAndExit(message) {
|
|
1564
|
+
R$1.error(message);
|
|
1565
|
+
R$1.message();
|
|
1566
|
+
Pt("Operation failed.");
|
|
1567
|
+
process$1.exit(1);
|
|
1568
|
+
}
|
|
1569
|
+
const normalizePosix = (dir) => {
|
|
1570
|
+
return path.posix.normalize(dir.replace(/\\/g, "/"));
|
|
1571
|
+
};
|
|
1572
|
+
function updateAgent(projectPath, language, packageManager, loadedAddons) {
|
|
1573
|
+
const agentFiles = [
|
|
1574
|
+
"AGENTS.md",
|
|
1575
|
+
"GEMINI.md",
|
|
1576
|
+
"CLAUDE.md"
|
|
1577
|
+
];
|
|
1578
|
+
const languageLabel = language === "typescript" ? "TypeScript" : language === "checkjs" ? "JavaScript (JSDoc)" : "None";
|
|
1579
|
+
const packageManagerLabel = packageManager ?? "npm";
|
|
1580
|
+
const addonNames = loadedAddons.map((addon) => addon.addon.id);
|
|
1581
|
+
const configSection = `## Project Configuration
|
|
1582
|
+
|
|
1583
|
+
- **Language**: ${languageLabel}
|
|
1584
|
+
- **Package Manager**: ${packageManagerLabel}
|
|
1585
|
+
- **Add-ons**: ${addonNames.length > 0 ? addonNames.join(", ") : "none"}
|
|
1586
|
+
|
|
1587
|
+
---
|
|
1588
|
+
|
|
1589
|
+
`;
|
|
1590
|
+
const existingSectionPattern = /^## Project Configuration[\s\S]*?---\n\n/;
|
|
1591
|
+
for (const fileName of agentFiles) {
|
|
1592
|
+
const agentPath = path.join(projectPath, fileName);
|
|
1593
|
+
if (!fs.existsSync(agentPath)) continue;
|
|
1594
|
+
let content = fs.readFileSync(agentPath, "utf-8");
|
|
1595
|
+
content = content.replace(existingSectionPattern, "");
|
|
1596
|
+
content = configSection + content;
|
|
1597
|
+
fs.writeFileSync(agentPath, content);
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
const filePaths = {
|
|
1601
|
+
packageJson: "package.json",
|
|
1602
|
+
svelteConfig: "svelte.config.js",
|
|
1603
|
+
svelteConfigTS: "svelte.config.ts",
|
|
1604
|
+
jsconfig: "jsconfig.json",
|
|
1605
|
+
tsconfig: "tsconfig.json",
|
|
1606
|
+
viteConfig: "vite.config.js",
|
|
1607
|
+
viteConfigTS: "vite.config.ts"
|
|
1608
|
+
};
|
|
1609
|
+
//#endregion
|
|
1610
|
+
//#region src/create/utils.ts
|
|
1611
|
+
function mkdirp(dir) {
|
|
1612
|
+
try {
|
|
1613
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
1614
|
+
} catch (err) {
|
|
1615
|
+
const e = err;
|
|
1616
|
+
if (e.code === "EEXIST") return;
|
|
1617
|
+
throw e;
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
function identity(x) {
|
|
1621
|
+
return x;
|
|
1622
|
+
}
|
|
1623
|
+
function replace(contents, kv) {
|
|
1624
|
+
for (const [key, value] of Object.entries(kv)) contents = contents.replaceAll(key, value);
|
|
1625
|
+
return contents;
|
|
1626
|
+
}
|
|
1627
|
+
function kv(name) {
|
|
1628
|
+
const protocolName = name.startsWith("@") ? name.split("/")[0] : name;
|
|
1629
|
+
return {
|
|
1630
|
+
"~SV-PROTOCOL-NAME-TODO~": protocolName,
|
|
1631
|
+
"~SV-NAME-TODO~": name
|
|
1632
|
+
};
|
|
1633
|
+
}
|
|
1634
|
+
const withReplaceExtensions = [
|
|
1635
|
+
".md",
|
|
1636
|
+
".js",
|
|
1637
|
+
".ts",
|
|
1638
|
+
".json"
|
|
1639
|
+
];
|
|
1640
|
+
function copy(from, to, rename = identity, kv = {}) {
|
|
1641
|
+
if (!fs.existsSync(from)) return;
|
|
1642
|
+
if (fs.statSync(from).isDirectory()) fs.readdirSync(from).forEach((file) => {
|
|
1643
|
+
copy(path.join(from, file), path.join(to, rename(file)), rename, kv);
|
|
1644
|
+
});
|
|
1645
|
+
else {
|
|
1646
|
+
mkdirp(path.dirname(to));
|
|
1647
|
+
if (withReplaceExtensions.some((ext) => from.endsWith(ext))) fs.writeFileSync(to, replace(fs.readFileSync(from, "utf-8"), kv));
|
|
1648
|
+
else fs.copyFileSync(from, to);
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
function dist(path) {
|
|
1652
|
+
const insideDistFolder = import.meta.url.includes("dist");
|
|
1653
|
+
return fileURLToPath(new URL(`./${!insideDistFolder ? "dist/" : ""}${path}`, import.meta.url).href);
|
|
1654
|
+
}
|
|
1655
|
+
function getSharedFiles() {
|
|
1656
|
+
const shared = dist("shared.json");
|
|
1657
|
+
const { files } = JSON.parse(fs.readFileSync(shared, "utf-8"));
|
|
1658
|
+
return files;
|
|
1659
|
+
}
|
|
1660
|
+
//#endregion
|
|
1661
|
+
//#region src/create/index.ts
|
|
1662
|
+
const publicTemplateTypes = [
|
|
1663
|
+
"minimal",
|
|
1664
|
+
"demo",
|
|
1665
|
+
"library",
|
|
1666
|
+
"addon"
|
|
1667
|
+
];
|
|
1668
|
+
const templateTypes = [
|
|
1669
|
+
"minimal",
|
|
1670
|
+
"demo",
|
|
1671
|
+
"library",
|
|
1672
|
+
"addon",
|
|
1673
|
+
"svelte"
|
|
1674
|
+
];
|
|
1675
|
+
const languageTypes = [
|
|
1676
|
+
"typescript",
|
|
1677
|
+
"checkjs",
|
|
1678
|
+
"none"
|
|
1679
|
+
];
|
|
1680
|
+
function create$1({ cwd, ...options }) {
|
|
1681
|
+
mkdirp(cwd);
|
|
1682
|
+
write_template_files(options.template, options.types, options.name, cwd);
|
|
1683
|
+
if (options.template !== "svelte") write_common_files(cwd, options, options.name);
|
|
1684
|
+
if (options.template === "addon") {
|
|
1685
|
+
fs.rmSync(path.join(cwd, "svelte.config.js"));
|
|
1686
|
+
fs.rmSync(path.join(cwd, "vite.config.js"));
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
const templates = publicTemplateTypes.map((dir) => {
|
|
1690
|
+
const meta_file = dist(`templates/${dir}/meta.json`);
|
|
1691
|
+
const { title, description } = JSON.parse(fs.readFileSync(meta_file, "utf8"));
|
|
1692
|
+
return {
|
|
1693
|
+
name: dir,
|
|
1694
|
+
title,
|
|
1695
|
+
description
|
|
1696
|
+
};
|
|
1697
|
+
});
|
|
1698
|
+
function write_template_files(template, types, name, cwd) {
|
|
1699
|
+
const dir = dist(`templates/${template}`);
|
|
1700
|
+
copy(`${dir}/assets`, cwd, (name) => name.replace("DOT-", "."), kv(name));
|
|
1701
|
+
copy(`${dir}/package.json`, `${cwd}/package.json`, void 0, kv(name));
|
|
1702
|
+
const manifest = `${dir}/files.types=${types}.json`;
|
|
1703
|
+
JSON.parse(fs.readFileSync(manifest, "utf-8")).forEach((file) => {
|
|
1704
|
+
const dest = path.join(cwd, file.name);
|
|
1705
|
+
mkdirp(path.dirname(dest));
|
|
1706
|
+
fs.writeFileSync(dest, replace(file.contents, kv(name)));
|
|
1707
|
+
});
|
|
1708
|
+
}
|
|
1709
|
+
function write_common_files(cwd, options, name) {
|
|
1710
|
+
const files = getSharedFiles();
|
|
1711
|
+
const pkg_file = path.join(cwd, filePaths.packageJson);
|
|
1712
|
+
const pkg = JSON.parse(fs.readFileSync(pkg_file, "utf-8"));
|
|
1713
|
+
sort_files(files).forEach((file) => {
|
|
1714
|
+
const include = file.include.every((condition) => matches_condition(condition, options));
|
|
1715
|
+
if (file.exclude.some((condition) => matches_condition(condition, options)) || !include) return;
|
|
1716
|
+
if (file.name === filePaths.packageJson) merge(pkg, JSON.parse(file.contents));
|
|
1717
|
+
else {
|
|
1718
|
+
const dest = path.join(cwd, file.name);
|
|
1719
|
+
mkdirp(path.dirname(dest));
|
|
1720
|
+
fs.writeFileSync(dest, replace(file.contents, kv(name)));
|
|
1721
|
+
}
|
|
1722
|
+
});
|
|
1723
|
+
pkg.dependencies = sort_keys(pkg.dependencies);
|
|
1724
|
+
pkg.devDependencies = sort_keys(pkg.devDependencies);
|
|
1725
|
+
pkg.name = sanitizeName(name, "package");
|
|
1726
|
+
fs.writeFileSync(pkg_file, JSON.stringify(pkg, null, " ") + "\n");
|
|
1727
|
+
}
|
|
1728
|
+
function matches_condition(condition, options) {
|
|
1729
|
+
if (templateTypes.includes(condition)) return options.template === condition;
|
|
1730
|
+
if (languageTypes.includes(condition)) return options.types === condition;
|
|
1731
|
+
return Boolean(options[condition]);
|
|
1732
|
+
}
|
|
1733
|
+
function merge(target, source) {
|
|
1734
|
+
for (const key in source) if (key in target) {
|
|
1735
|
+
const target_value = target[key];
|
|
1736
|
+
const source_value = source[key];
|
|
1737
|
+
if (typeof source_value !== typeof target_value || Array.isArray(source_value) !== Array.isArray(target_value)) throw new Error("Mismatched values");
|
|
1738
|
+
if (typeof source_value === "object") merge(target_value, source_value);
|
|
1739
|
+
else target[key] = source_value;
|
|
1740
|
+
} else target[key] = source[key];
|
|
1741
|
+
}
|
|
1742
|
+
function sort_keys(obj) {
|
|
1743
|
+
if (!obj) return;
|
|
1744
|
+
const sorted = {};
|
|
1745
|
+
Object.keys(obj).sort().forEach((key) => {
|
|
1746
|
+
sorted[key] = obj[key];
|
|
1747
|
+
});
|
|
1748
|
+
return sorted;
|
|
1749
|
+
}
|
|
1750
|
+
/**
|
|
1751
|
+
* Sort files so that those which apply more generically come first so they
|
|
1752
|
+
* can be overwritten by files for more precise cases later.
|
|
1753
|
+
*/
|
|
1754
|
+
function sort_files(files) {
|
|
1755
|
+
return files.sort((f1, f2) => {
|
|
1756
|
+
const f1_more_generic = f1.include.every((include) => f2.include.includes(include)) && f1.exclude.every((exclude) => f2.exclude.includes(exclude));
|
|
1757
|
+
const f2_more_generic = f2.include.every((include) => f1.include.includes(include)) && f2.exclude.every((exclude) => f1.exclude.includes(exclude));
|
|
1758
|
+
return f1_more_generic && f2_more_generic || !f1_more_generic && !f2_more_generic ? 0 : f1_more_generic ? -1 : 1;
|
|
1759
|
+
});
|
|
1760
|
+
}
|
|
1761
|
+
//#endregion
|
|
1535
1762
|
//#region ../../node_modules/.pnpm/tinyexec@1.0.4/node_modules/tinyexec/dist/main.mjs
|
|
1536
1763
|
var l = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports);
|
|
1537
1764
|
var u = /* @__PURE__ */ createRequire(import.meta.url);
|
|
@@ -5224,7 +5451,7 @@ function up(options) {
|
|
|
5224
5451
|
return up$1("package.json", options);
|
|
5225
5452
|
}
|
|
5226
5453
|
//#endregion
|
|
5227
|
-
//#region ../../node_modules/.pnpm/valibot@1.3.1_typescript@
|
|
5454
|
+
//#region ../../node_modules/.pnpm/valibot@1.3.1_typescript@6.0.2/node_modules/valibot/dist/index.mjs
|
|
5228
5455
|
let store$4;
|
|
5229
5456
|
/**
|
|
5230
5457
|
* Returns the global configuration.
|
|
@@ -5929,7 +6156,7 @@ function getNodeTypesVersion() {
|
|
|
5929
6156
|
return `^${isEvenMajor ? majorNum - 2 : majorNum - 1}`;
|
|
5930
6157
|
}
|
|
5931
6158
|
//#endregion
|
|
5932
|
-
//#region \0@oxc-project+runtime@0.
|
|
6159
|
+
//#region \0@oxc-project+runtime@0.122.0/helpers/taggedTemplateLiteral.js
|
|
5933
6160
|
function _taggedTemplateLiteral(e, t) {
|
|
5934
6161
|
return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } }));
|
|
5935
6162
|
}
|
|
@@ -6353,25 +6580,6 @@ const generateEnv$1 = (demoGithub, isExample) => transforms.text(({ content, tex
|
|
|
6353
6580
|
return content;
|
|
6354
6581
|
});
|
|
6355
6582
|
//#endregion
|
|
6356
|
-
//#region src/addons/devtools-json.ts
|
|
6357
|
-
var devtools_json_default = defineAddon({
|
|
6358
|
-
id: "devtools-json",
|
|
6359
|
-
shortDescription: "devtools json",
|
|
6360
|
-
homepage: "https://github.com/ChromeDevTools/vite-plugin-devtools-json",
|
|
6361
|
-
options: {},
|
|
6362
|
-
run: ({ sv, file }) => {
|
|
6363
|
-
sv.devDependency("vite-plugin-devtools-json", "^1.0.0");
|
|
6364
|
-
sv.file(file.viteConfig, transforms.script(({ ast, js }) => {
|
|
6365
|
-
const vitePluginName = "devtoolsJson";
|
|
6366
|
-
js.imports.addDefault(ast, {
|
|
6367
|
-
as: vitePluginName,
|
|
6368
|
-
from: "vite-plugin-devtools-json"
|
|
6369
|
-
});
|
|
6370
|
-
js.vite.addPlugin(ast, { code: `${vitePluginName}()` });
|
|
6371
|
-
}));
|
|
6372
|
-
}
|
|
6373
|
-
});
|
|
6374
|
-
//#endregion
|
|
6375
6583
|
//#region src/addons/drizzle.ts
|
|
6376
6584
|
const PORTS = {
|
|
6377
6585
|
mysql: "3306",
|
|
@@ -6467,7 +6675,7 @@ var drizzle_default = defineAddon({
|
|
|
6467
6675
|
runsAfter("sveltekitAdapter");
|
|
6468
6676
|
if (!isKit) return unsupported("Requires SvelteKit");
|
|
6469
6677
|
},
|
|
6470
|
-
run: ({ sv, language, options, directory, dependencyVersion, cwd, cancel, file }) => {
|
|
6678
|
+
run: ({ sv, language, options, directory, dependencyVersion, cwd, cancel, file, packageManager }) => {
|
|
6471
6679
|
if (options.database === "d1" && !dependencyVersion("@sveltejs/adapter-cloudflare")) return cancel("Cloudflare D1 requires @sveltejs/adapter-cloudflare - add the adapter first");
|
|
6472
6680
|
const [ts] = createPrinter(language === "ts");
|
|
6473
6681
|
const baseDBPath = path.resolve(cwd, directory.lib, "server", "db");
|
|
@@ -6477,19 +6685,19 @@ var drizzle_default = defineAddon({
|
|
|
6477
6685
|
database: path.resolve(baseDBPath, `index.${language}`)
|
|
6478
6686
|
};
|
|
6479
6687
|
for (const [fileType, filePath] of Object.entries(paths)) if (fs.existsSync(filePath)) return cancel(`Preexisting ${fileType} file at '${filePath}'`);
|
|
6480
|
-
sv.devDependency("drizzle-orm", "^0.45.
|
|
6481
|
-
sv.devDependency("drizzle-kit", "^0.31.
|
|
6688
|
+
sv.devDependency("drizzle-orm", "^0.45.2");
|
|
6689
|
+
sv.devDependency("drizzle-kit", "^0.31.10");
|
|
6482
6690
|
sv.devDependency("@types/node", getNodeTypesVersion());
|
|
6483
|
-
if (options.mysql === "mysql2") sv.devDependency("mysql2", "^3.
|
|
6484
|
-
if (options.mysql === "planetscale") sv.devDependency("@planetscale/database", "^1.
|
|
6691
|
+
if (options.mysql === "mysql2") sv.devDependency("mysql2", "^3.20.0");
|
|
6692
|
+
if (options.mysql === "planetscale") sv.devDependency("@planetscale/database", "^1.20.1");
|
|
6485
6693
|
if (options.postgresql === "neon") sv.devDependency("@neondatabase/serverless", "^1.0.2");
|
|
6486
|
-
if (options.postgresql === "postgres.js") sv.devDependency("postgres", "^3.4.
|
|
6694
|
+
if (options.postgresql === "postgres.js") sv.devDependency("postgres", "^3.4.9");
|
|
6487
6695
|
if (options.sqlite === "better-sqlite3") {
|
|
6488
|
-
sv.dependency("better-sqlite3", "^12.
|
|
6696
|
+
sv.dependency("better-sqlite3", "^12.8.0");
|
|
6489
6697
|
sv.devDependency("@types/better-sqlite3", "^7.6.13");
|
|
6490
|
-
sv.
|
|
6698
|
+
if (packageManager === "pnpm") sv.file(file.findUp("pnpm-workspace.yaml"), pnpm.onlyBuiltDependencies("better-sqlite3"));
|
|
6491
6699
|
}
|
|
6492
|
-
if (options.sqlite === "libsql" || options.sqlite === "turso") sv.devDependency("@libsql/client", "^0.17.
|
|
6700
|
+
if (options.sqlite === "libsql" || options.sqlite === "turso") sv.devDependency("@libsql/client", "^0.17.2");
|
|
6493
6701
|
sv.file(".env", generateEnv(options, false));
|
|
6494
6702
|
sv.file(".env.example", generateEnv(options, true));
|
|
6495
6703
|
if (options.docker && (options.mysql === "mysql2" || options.postgresql === "postgres.js")) {
|
|
@@ -6542,7 +6750,7 @@ var drizzle_default = defineAddon({
|
|
|
6542
6750
|
json.packageScriptsUpsert(data, "db:migrate", "drizzle-kit migrate");
|
|
6543
6751
|
json.packageScriptsUpsert(data, "db:studio", "drizzle-kit studio");
|
|
6544
6752
|
}));
|
|
6545
|
-
if (Boolean(dependencyVersion("prettier"))) sv.file(
|
|
6753
|
+
if (Boolean(dependencyVersion("prettier"))) sv.file(".prettierignore", transforms.text(({ content, text }) => text.upsert(content, "/drizzle/")));
|
|
6546
6754
|
if (options.database === "sqlite") sv.file(file.gitignore, transforms.text(({ content, text }) => {
|
|
6547
6755
|
if (content.length === 0) return false;
|
|
6548
6756
|
return text.upsert(content, "*.db", { comment: "SQLite" });
|
|
@@ -6585,6 +6793,10 @@ var drizzle_default = defineAddon({
|
|
|
6585
6793
|
})
|
|
6586
6794
|
`) });
|
|
6587
6795
|
}));
|
|
6796
|
+
sv.file(file.svelteConfig, transforms.script(({ ast, js }) => {
|
|
6797
|
+
const { value: config } = js.exports.createDefault(ast, { fallback: js.object.create({}) });
|
|
6798
|
+
js.object.overrideProperties(config, { kit: { typescript: { config: js.common.parseExpression(`(config) => ({ ...config, include: [...config.include, '../drizzle.config.${language}'] })`) } } });
|
|
6799
|
+
}));
|
|
6588
6800
|
sv.file(paths["database schema"], transforms.script(({ ast, js }) => {
|
|
6589
6801
|
let taskSchemaExpression;
|
|
6590
6802
|
if (options.database === "sqlite" || options.database === "d1") {
|
|
@@ -6831,18 +7043,18 @@ var eslint_default = defineAddon({
|
|
|
6831
7043
|
run: ({ sv, language, dependencyVersion, file }) => {
|
|
6832
7044
|
const typescript = language === "ts";
|
|
6833
7045
|
const prettierInstalled = Boolean(dependencyVersion("prettier"));
|
|
6834
|
-
sv.devDependency("eslint", "^10.0
|
|
6835
|
-
sv.devDependency("@eslint/compat", "^2.0.
|
|
6836
|
-
sv.devDependency("eslint-plugin-svelte", "^3.
|
|
7046
|
+
sv.devDependency("eslint", "^10.2.0");
|
|
7047
|
+
sv.devDependency("@eslint/compat", "^2.0.4");
|
|
7048
|
+
sv.devDependency("eslint-plugin-svelte", "^3.17.0");
|
|
6837
7049
|
sv.devDependency("globals", "^17.4.0");
|
|
6838
7050
|
sv.devDependency("@eslint/js", "^10.0.1");
|
|
6839
7051
|
sv.devDependency("@types/node", getNodeTypesVersion());
|
|
6840
|
-
if (typescript) sv.devDependency("typescript-eslint", "^8.
|
|
7052
|
+
if (typescript) sv.devDependency("typescript-eslint", "^8.58.1");
|
|
6841
7053
|
if (prettierInstalled) sv.devDependency("eslint-config-prettier", "^10.1.8");
|
|
6842
7054
|
sv.file(file.package, transforms.json(({ data, json }) => {
|
|
6843
7055
|
json.packageScriptsUpsert(data, "lint", "eslint .");
|
|
6844
7056
|
}));
|
|
6845
|
-
sv.file(
|
|
7057
|
+
sv.file("eslint.config.js", transforms.script(({ ast, comments, js }) => {
|
|
6846
7058
|
const eslintConfigs = [];
|
|
6847
7059
|
js.imports.addDefault(ast, {
|
|
6848
7060
|
from: "./svelte.config.js",
|
|
@@ -6956,10 +7168,10 @@ var eslint_default = defineAddon({
|
|
|
6956
7168
|
as: "path"
|
|
6957
7169
|
});
|
|
6958
7170
|
}));
|
|
6959
|
-
sv.file(
|
|
7171
|
+
sv.file(".vscode/extensions.json", transforms.json(({ data, json }) => {
|
|
6960
7172
|
json.arrayUpsert(data, "recommendations", "dbaeumer.vscode-eslint");
|
|
6961
7173
|
}));
|
|
6962
|
-
if (prettierInstalled) sv.file(
|
|
7174
|
+
if (prettierInstalled) sv.file("eslint.config.js", addEslintConfigPrettier);
|
|
6963
7175
|
}
|
|
6964
7176
|
});
|
|
6965
7177
|
var mcp_default = defineAddon({
|
|
@@ -7111,7 +7323,7 @@ var mdsvex_default = defineAddon({
|
|
|
7111
7323
|
homepage: "https://mdsvex.pngwn.io",
|
|
7112
7324
|
options: {},
|
|
7113
7325
|
run: ({ sv, file }) => {
|
|
7114
|
-
sv.devDependency("mdsvex", "^0.12.
|
|
7326
|
+
sv.devDependency("mdsvex", "^0.12.7");
|
|
7115
7327
|
sv.file(file.svelteConfig, transforms.script(({ ast, js }) => {
|
|
7116
7328
|
js.imports.addNamed(ast, {
|
|
7117
7329
|
from: "mdsvex",
|
|
@@ -7151,7 +7363,7 @@ const DEFAULT_INLANG_PROJECT = {
|
|
|
7151
7363
|
modules: ["https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@4/dist/index.js", "https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@2/dist/index.js"],
|
|
7152
7364
|
"plugin.inlang.messageFormat": { pathPattern: "./messages/{locale}.json" }
|
|
7153
7365
|
};
|
|
7154
|
-
const options$
|
|
7366
|
+
const options$3 = defineAddonOptions().add("languageTags", {
|
|
7155
7367
|
question: `Which languages would you like to support? ${color.optional("(e.g. en,de-ch)")}`,
|
|
7156
7368
|
type: "string",
|
|
7157
7369
|
default: "en, es",
|
|
@@ -7174,13 +7386,14 @@ var paraglide_default = defineAddon({
|
|
|
7174
7386
|
id: "paraglide",
|
|
7175
7387
|
shortDescription: "i18n",
|
|
7176
7388
|
homepage: "https://inlang.com/m/gerre34r/library-inlang-paraglideJs",
|
|
7177
|
-
options: options$
|
|
7389
|
+
options: options$3,
|
|
7178
7390
|
setup: ({ isKit, unsupported }) => {
|
|
7179
7391
|
if (!isKit) unsupported("Requires SvelteKit");
|
|
7180
7392
|
},
|
|
7181
7393
|
run: ({ sv, options, file, language, directory }) => {
|
|
7394
|
+
const [ts] = createPrinter(language === "ts");
|
|
7182
7395
|
const paraglideOutDir = `${directory.lib}/paraglide`;
|
|
7183
|
-
sv.devDependency("@inlang/paraglide-js", "^2.
|
|
7396
|
+
sv.devDependency("@inlang/paraglide-js", "^2.15.2");
|
|
7184
7397
|
sv.file(file.viteConfig, transforms.script(({ ast, js }) => {
|
|
7185
7398
|
const vitePluginName = "paraglideVitePlugin";
|
|
7186
7399
|
js.imports.addNamed(ast, {
|
|
@@ -7267,11 +7480,21 @@ var paraglide_default = defineAddon({
|
|
|
7267
7480
|
imports: ["page"],
|
|
7268
7481
|
from: "$app/state"
|
|
7269
7482
|
});
|
|
7270
|
-
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7483
|
+
js.imports.addNamed(ast.instance.content, {
|
|
7484
|
+
imports: ["resolve"],
|
|
7485
|
+
from: "$app/paths"
|
|
7486
|
+
});
|
|
7487
|
+
if (language === "ts") js.imports.addNamed(ast.instance.content, {
|
|
7488
|
+
imports: ["Pathname"],
|
|
7489
|
+
from: "$app/types",
|
|
7490
|
+
isType: true
|
|
7491
|
+
});
|
|
7492
|
+
svelte.addFragment(ast, dedent`
|
|
7493
|
+
<div style="display:none">
|
|
7494
|
+
{#each locales as locale (locale)}
|
|
7495
|
+
<a href={resolve(localizeHref(page.url.pathname, { locale })${ts(" as Pathname")})}>{locale}</a>
|
|
7496
|
+
{/each}
|
|
7497
|
+
</div>`, { language });
|
|
7275
7498
|
}));
|
|
7276
7499
|
if (options.demo) {
|
|
7277
7500
|
sv.file(`${directory.kitRoutes}/demo/+page.svelte`, addToDemoPage("paraglide", language));
|
|
@@ -7300,7 +7523,7 @@ var paraglide_default = defineAddon({
|
|
|
7300
7523
|
},
|
|
7301
7524
|
nextSteps: () => {
|
|
7302
7525
|
const steps = [`Edit your messages in ${color.path("messages/en.json")}`];
|
|
7303
|
-
if (options$
|
|
7526
|
+
if (options$3.demo) steps.push(`Visit ${color.route("/demo/paraglide")} route to view the demo`);
|
|
7304
7527
|
return steps;
|
|
7305
7528
|
}
|
|
7306
7529
|
});
|
|
@@ -7324,7 +7547,7 @@ var playwright_default = defineAddon({
|
|
|
7324
7547
|
homepage: "https://playwright.dev",
|
|
7325
7548
|
options: {},
|
|
7326
7549
|
run: ({ sv, language, file, isKit, directory }) => {
|
|
7327
|
-
sv.devDependency("@playwright/test", "^1.
|
|
7550
|
+
sv.devDependency("@playwright/test", "^1.59.1");
|
|
7328
7551
|
sv.file(file.package, transforms.json(({ data, json }) => {
|
|
7329
7552
|
json.packageScriptsUpsert(data, "prepare", "playwright install", { mode: "prepend" });
|
|
7330
7553
|
json.packageScriptsUpsert(data, "test:e2e", "playwright test");
|
|
@@ -7395,8 +7618,8 @@ var prettier_default = defineAddon({
|
|
|
7395
7618
|
const tailwindcssInstalled = Boolean(dependencyVersion("tailwindcss"));
|
|
7396
7619
|
if (tailwindcssInstalled) sv.devDependency("prettier-plugin-tailwindcss", "^0.7.2");
|
|
7397
7620
|
sv.devDependency("prettier", "^3.8.1");
|
|
7398
|
-
sv.devDependency("prettier-plugin-svelte", "^3.
|
|
7399
|
-
sv.file(
|
|
7621
|
+
sv.devDependency("prettier-plugin-svelte", "^3.5.1");
|
|
7622
|
+
sv.file(".prettierignore", transforms.text(({ content }) => {
|
|
7400
7623
|
if (content) return false;
|
|
7401
7624
|
return dedent`
|
|
7402
7625
|
# Package Managers
|
|
@@ -7410,7 +7633,7 @@ var prettier_default = defineAddon({
|
|
|
7410
7633
|
/static/
|
|
7411
7634
|
`;
|
|
7412
7635
|
}));
|
|
7413
|
-
sv.file(
|
|
7636
|
+
sv.file(".prettierrc", transforms.json(({ data, json }) => {
|
|
7414
7637
|
if (Object.keys(data).length === 0) {
|
|
7415
7638
|
data.useTabs = true;
|
|
7416
7639
|
data.singleQuote = true;
|
|
@@ -7437,13 +7660,13 @@ var prettier_default = defineAddon({
|
|
|
7437
7660
|
json.packageScriptsUpsert(data, "lint", "prettier --check .", { mode: "prepend" });
|
|
7438
7661
|
json.packageScriptsUpsert(data, "format", "prettier --write .");
|
|
7439
7662
|
}));
|
|
7440
|
-
sv.file(
|
|
7663
|
+
sv.file(".vscode/extensions.json", transforms.json(({ data, json }) => {
|
|
7441
7664
|
json.arrayUpsert(data, "recommendations", "esbenp.prettier-vscode");
|
|
7442
7665
|
}));
|
|
7443
7666
|
if (eslintVersion?.startsWith(SUPPORTED_ESLINT_VERSION) === false) R$1.warn(`An older major version of ${color.warning("eslint")} was detected. Skipping ${color.warning("eslint-config-prettier")} installation.`);
|
|
7444
7667
|
if (eslintInstalled) {
|
|
7445
7668
|
sv.devDependency("eslint-config-prettier", "^10.1.8");
|
|
7446
|
-
sv.file(
|
|
7669
|
+
sv.file("eslint.config.js", addEslintConfigPrettier);
|
|
7447
7670
|
}
|
|
7448
7671
|
}
|
|
7449
7672
|
});
|
|
@@ -7479,12 +7702,12 @@ const adapters = [
|
|
|
7479
7702
|
{
|
|
7480
7703
|
id: "auto",
|
|
7481
7704
|
package: "@sveltejs/adapter-auto",
|
|
7482
|
-
version: "^7.0.
|
|
7705
|
+
version: "^7.0.1"
|
|
7483
7706
|
},
|
|
7484
7707
|
{
|
|
7485
7708
|
id: "node",
|
|
7486
7709
|
package: "@sveltejs/adapter-node",
|
|
7487
|
-
version: "^5.5.
|
|
7710
|
+
version: "^5.5.4"
|
|
7488
7711
|
},
|
|
7489
7712
|
{
|
|
7490
7713
|
id: "static",
|
|
@@ -7494,17 +7717,17 @@ const adapters = [
|
|
|
7494
7717
|
{
|
|
7495
7718
|
id: "vercel",
|
|
7496
7719
|
package: "@sveltejs/adapter-vercel",
|
|
7497
|
-
version: "^6.3.
|
|
7720
|
+
version: "^6.3.3"
|
|
7498
7721
|
},
|
|
7499
7722
|
{
|
|
7500
7723
|
id: "cloudflare",
|
|
7501
7724
|
package: "@sveltejs/adapter-cloudflare",
|
|
7502
|
-
version: "^7.2.
|
|
7725
|
+
version: "^7.2.8"
|
|
7503
7726
|
},
|
|
7504
7727
|
{
|
|
7505
7728
|
id: "netlify",
|
|
7506
7729
|
package: "@sveltejs/adapter-netlify",
|
|
7507
|
-
version: "^
|
|
7730
|
+
version: "^6.0.4"
|
|
7508
7731
|
}
|
|
7509
7732
|
];
|
|
7510
7733
|
var sveltekit_adapter_default = defineAddon({
|
|
@@ -7576,11 +7799,11 @@ var sveltekit_adapter_default = defineAddon({
|
|
|
7576
7799
|
}
|
|
7577
7800
|
}));
|
|
7578
7801
|
if (adapter.package === "@sveltejs/adapter-cloudflare") {
|
|
7579
|
-
sv.devDependency("wrangler", "^4.
|
|
7802
|
+
sv.devDependency("wrangler", "^4.81.0");
|
|
7580
7803
|
const ext = fileExists(cwd, "wrangler.toml") ? "toml" : "jsonc";
|
|
7581
7804
|
const applyWranglerConfig = (data) => {
|
|
7582
7805
|
if (ext === "jsonc") data.$schema ??= "./node_modules/wrangler/config-schema.json";
|
|
7583
|
-
if (!data.name) data.name = sanitizeName(
|
|
7806
|
+
if (!data.name) data.name = sanitizeName(loadPackageJson(cwd).data.name, "wrangler");
|
|
7584
7807
|
data.compatibility_date ??= (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
7585
7808
|
data.compatibility_flags ??= [];
|
|
7586
7809
|
if (!data.compatibility_flags.includes("nodejs_compat") && !data.compatibility_flags.includes("nodejs_als")) data.compatibility_flags.push("nodejs_als");
|
|
@@ -7654,11 +7877,11 @@ var tailwindcss_default = defineAddon({
|
|
|
7654
7877
|
default: [],
|
|
7655
7878
|
required: false
|
|
7656
7879
|
}).build(),
|
|
7657
|
-
run: ({ sv, options, file, isKit, directory, dependencyVersion, language }) => {
|
|
7880
|
+
run: ({ sv, options, file, isKit, directory, dependencyVersion, language, packageManager }) => {
|
|
7658
7881
|
const prettierInstalled = Boolean(dependencyVersion("prettier"));
|
|
7659
|
-
sv.devDependency("tailwindcss", "^4.
|
|
7660
|
-
sv.devDependency("@tailwindcss/vite", "^4.
|
|
7661
|
-
sv.
|
|
7882
|
+
sv.devDependency("tailwindcss", "^4.2.2");
|
|
7883
|
+
sv.devDependency("@tailwindcss/vite", "^4.2.2");
|
|
7884
|
+
if (packageManager === "pnpm") sv.file(file.findUp("pnpm-workspace.yaml"), pnpm.onlyBuiltDependencies("@tailwindcss/oxide"));
|
|
7662
7885
|
if (prettierInstalled) sv.devDependency("prettier-plugin-tailwindcss", "^0.7.2");
|
|
7663
7886
|
for (const plugin of plugins) {
|
|
7664
7887
|
if (!options.plugins.includes(plugin.id)) continue;
|
|
@@ -7714,14 +7937,14 @@ var tailwindcss_default = defineAddon({
|
|
|
7714
7937
|
js.imports.addEmpty(ast.instance.content, { from: stylesheetRelative });
|
|
7715
7938
|
}));
|
|
7716
7939
|
}
|
|
7717
|
-
sv.file(
|
|
7940
|
+
sv.file(".vscode/settings.json", transforms.json(({ data }) => {
|
|
7718
7941
|
data["files.associations"] ??= {};
|
|
7719
7942
|
data["files.associations"]["*.css"] = "tailwindcss";
|
|
7720
7943
|
}));
|
|
7721
|
-
sv.file(
|
|
7944
|
+
sv.file(".vscode/extensions.json", transforms.json(({ data, json }) => {
|
|
7722
7945
|
json.arrayUpsert(data, "recommendations", "bradlc.vscode-tailwindcss");
|
|
7723
7946
|
}));
|
|
7724
|
-
if (prettierInstalled) sv.file(
|
|
7947
|
+
if (prettierInstalled) sv.file(".prettierrc", transforms.json(({ data, json }) => {
|
|
7725
7948
|
json.arrayUpsert(data, "plugins", "prettier-plugin-tailwindcss");
|
|
7726
7949
|
data.tailwindStylesheet ??= file.getRelative({ to: file.stylesheet });
|
|
7727
7950
|
}));
|
|
@@ -7730,7 +7953,7 @@ var tailwindcss_default = defineAddon({
|
|
|
7730
7953
|
//#endregion
|
|
7731
7954
|
//#region src/addons/vitest-addon.ts
|
|
7732
7955
|
var _templateObject;
|
|
7733
|
-
const options
|
|
7956
|
+
const options = defineAddonOptions().add("usages", {
|
|
7734
7957
|
question: "What do you want to use vitest for?",
|
|
7735
7958
|
type: "multiselect",
|
|
7736
7959
|
default: ["unit", "component"],
|
|
@@ -7753,16 +7976,16 @@ const officialAddons$1 = {
|
|
|
7753
7976
|
id: "vitest",
|
|
7754
7977
|
shortDescription: "unit testing",
|
|
7755
7978
|
homepage: "https://vitest.dev",
|
|
7756
|
-
options
|
|
7979
|
+
options,
|
|
7757
7980
|
run: ({ sv, file, language, directory, options, dependencyVersion }) => {
|
|
7758
7981
|
const unitTesting = options.usages.includes("unit");
|
|
7759
7982
|
const componentTesting = options.usages.includes("component");
|
|
7760
7983
|
vitestV3Installed = (dependencyVersion("vitest") ?? "").replaceAll("^", "").replaceAll("~", "")?.startsWith("3.");
|
|
7761
|
-
sv.devDependency("vitest", "^4.1.
|
|
7984
|
+
sv.devDependency("vitest", "^4.1.3");
|
|
7762
7985
|
if (componentTesting) {
|
|
7763
|
-
sv.devDependency("@vitest/browser-playwright", "^4.1.
|
|
7764
|
-
sv.devDependency("vitest-browser-svelte", "^2.0
|
|
7765
|
-
sv.devDependency("playwright", "^1.
|
|
7986
|
+
sv.devDependency("@vitest/browser-playwright", "^4.1.3");
|
|
7987
|
+
sv.devDependency("vitest-browser-svelte", "^2.1.0");
|
|
7988
|
+
sv.devDependency("playwright", "^1.59.1");
|
|
7766
7989
|
}
|
|
7767
7990
|
sv.file(file.package, transforms.json(({ data, json }) => {
|
|
7768
7991
|
json.packageScriptsUpsert(data, "test:unit", "vitest");
|
|
@@ -7893,7 +8116,6 @@ const officialAddons$1 = {
|
|
|
7893
8116
|
playwright: playwright_default,
|
|
7894
8117
|
tailwindcss: tailwindcss_default,
|
|
7895
8118
|
sveltekitAdapter: sveltekit_adapter_default,
|
|
7896
|
-
devtoolsJson: devtools_json_default,
|
|
7897
8119
|
drizzle: drizzle_default,
|
|
7898
8120
|
betterAuth: better_auth_default,
|
|
7899
8121
|
mdsvex: mdsvex_default,
|
|
@@ -7907,215 +8129,6 @@ function getAddonDetails(id) {
|
|
|
7907
8129
|
return details;
|
|
7908
8130
|
}
|
|
7909
8131
|
//#endregion
|
|
7910
|
-
//#region package.json
|
|
7911
|
-
var name = "sv";
|
|
7912
|
-
var version = "0.14.1";
|
|
7913
|
-
//#endregion
|
|
7914
|
-
//#region src/core/errors.ts
|
|
7915
|
-
var UnsupportedError = class extends Error {
|
|
7916
|
-
constructor(reasons) {
|
|
7917
|
-
super();
|
|
7918
|
-
this.name = "Unsupported Environment";
|
|
7919
|
-
this.reasons = [];
|
|
7920
|
-
this.reasons = reasons;
|
|
7921
|
-
}
|
|
7922
|
-
};
|
|
7923
|
-
//#endregion
|
|
7924
|
-
//#region src/core/common.ts
|
|
7925
|
-
const NO_PREFIX = "--no-";
|
|
7926
|
-
let options = [];
|
|
7927
|
-
function getLongFlag(flags) {
|
|
7928
|
-
return flags.split(",").map((f) => f.trim()).find((f) => f.startsWith("--"));
|
|
7929
|
-
}
|
|
7930
|
-
const helpConfig = {
|
|
7931
|
-
argumentDescription: formatDescription,
|
|
7932
|
-
optionDescription: formatDescription,
|
|
7933
|
-
visibleOptions(cmd) {
|
|
7934
|
-
options = cmd.options;
|
|
7935
|
-
const visible = cmd.options.filter((o) => !o.hidden);
|
|
7936
|
-
const show = [];
|
|
7937
|
-
for (const option of visible) {
|
|
7938
|
-
const flag = getLongFlag(option.flags);
|
|
7939
|
-
if (flag?.startsWith(NO_PREFIX)) {
|
|
7940
|
-
const stripped = flag.slice(5);
|
|
7941
|
-
if (visible.some((o) => getLongFlag(o.flags)?.startsWith(`--${stripped}`))) continue;
|
|
7942
|
-
}
|
|
7943
|
-
show.push(option);
|
|
7944
|
-
}
|
|
7945
|
-
return show;
|
|
7946
|
-
},
|
|
7947
|
-
optionTerm(option) {
|
|
7948
|
-
const longFlag = getLongFlag(option.flags);
|
|
7949
|
-
const flag = longFlag?.split(" ").at(0);
|
|
7950
|
-
if (!flag || !longFlag) return option.flags;
|
|
7951
|
-
const noVariant = `--no-${flag.slice(2)}`;
|
|
7952
|
-
if (options.some((o) => getLongFlag(o.flags) === noVariant)) return `--[no-]${longFlag.slice(2)}`;
|
|
7953
|
-
return option.flags;
|
|
7954
|
-
},
|
|
7955
|
-
styleCommandText: (str) => color.success(str),
|
|
7956
|
-
styleDescriptionText: (str) => color.optional(str)
|
|
7957
|
-
};
|
|
7958
|
-
function formatDescription(arg) {
|
|
7959
|
-
let output = arg.description;
|
|
7960
|
-
if (arg.defaultValue !== void 0 && String(arg.defaultValue)) output += color.dim(` (default: ${JSON.stringify(arg.defaultValue)})`);
|
|
7961
|
-
if (arg.argChoices !== void 0 && String(arg.argChoices)) output += color.dim(` (choices: ${arg.argChoices.join(", ")})`);
|
|
7962
|
-
return output;
|
|
7963
|
-
}
|
|
7964
|
-
/**
|
|
7965
|
-
* Returns standard help sections and a formatItem helper.
|
|
7966
|
-
* Used by `add` and `create` custom `formatHelp` to avoid duplicating boilerplate.
|
|
7967
|
-
*/
|
|
7968
|
-
function getHelpSections(cmd, helper) {
|
|
7969
|
-
const termWidth = helper.padWidth(cmd, helper);
|
|
7970
|
-
const helpWidth = helper.helpWidth ?? 80;
|
|
7971
|
-
function formatItem(term, description) {
|
|
7972
|
-
return helper.formatItem(term, termWidth, description, helper);
|
|
7973
|
-
}
|
|
7974
|
-
const usage = [`${helper.styleTitle("Usage:")} ${helper.styleUsage(helper.commandUsage(cmd))}`, ""];
|
|
7975
|
-
const descText = helper.commandDescription(cmd);
|
|
7976
|
-
const description = descText.length > 0 ? [helper.boxWrap(helper.styleCommandDescription(descText), helpWidth), ""] : [];
|
|
7977
|
-
const argItems = helper.visibleArguments(cmd).map((argument) => formatItem(helper.styleArgumentTerm(helper.argumentTerm(argument)), helper.styleArgumentDescription(helper.argumentDescription(argument))));
|
|
7978
|
-
const arguments_ = argItems.length > 0 ? [
|
|
7979
|
-
helper.styleTitle("Arguments:"),
|
|
7980
|
-
...argItems,
|
|
7981
|
-
""
|
|
7982
|
-
] : [];
|
|
7983
|
-
const optItems = helper.visibleOptions(cmd).map((option) => formatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option))));
|
|
7984
|
-
const options = optItems.length > 0 ? [
|
|
7985
|
-
helper.styleTitle("Options:"),
|
|
7986
|
-
...optItems,
|
|
7987
|
-
""
|
|
7988
|
-
] : [];
|
|
7989
|
-
const globalOptItems = helper.showGlobalOptions ? helper.visibleGlobalOptions(cmd).map((option) => formatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)))) : [];
|
|
7990
|
-
const globalOptions = globalOptItems.length > 0 ? [
|
|
7991
|
-
helper.styleTitle("Global Options:"),
|
|
7992
|
-
...globalOptItems,
|
|
7993
|
-
""
|
|
7994
|
-
] : [];
|
|
7995
|
-
const cmdItems = helper.visibleCommands(cmd).map((sub) => formatItem(helper.styleSubcommandTerm(helper.subcommandTerm(sub)), helper.styleSubcommandDescription(helper.subcommandDescription(sub))));
|
|
7996
|
-
const commands = cmdItems.length > 0 ? [
|
|
7997
|
-
helper.styleTitle("Commands:"),
|
|
7998
|
-
...cmdItems,
|
|
7999
|
-
""
|
|
8000
|
-
] : [];
|
|
8001
|
-
return {
|
|
8002
|
-
formatItem,
|
|
8003
|
-
styleTitle: helper.styleTitle.bind(helper),
|
|
8004
|
-
usage,
|
|
8005
|
-
description,
|
|
8006
|
-
arguments: arguments_,
|
|
8007
|
-
options,
|
|
8008
|
-
globalOptions,
|
|
8009
|
-
commands
|
|
8010
|
-
};
|
|
8011
|
-
}
|
|
8012
|
-
async function runCommand(action) {
|
|
8013
|
-
try {
|
|
8014
|
-
console.log(color.hidden("HINT: Run \"sv --help\" to get the full list of commands, add-ons, and examples to one-shot and skip interactive prompts."));
|
|
8015
|
-
Nt(`Welcome to the Svelte CLI! ${color.optional(`(v${version})`)}`);
|
|
8016
|
-
const minimumVersion = "18.3.0";
|
|
8017
|
-
if (isVersionUnsupportedBelow(process$1.versions.node, minimumVersion)) R$1.warn(`You are using Node.js ${color.error(process$1.versions.node)}, please upgrade to Node.js ${color.success(minimumVersion)} or higher.`);
|
|
8018
|
-
await action();
|
|
8019
|
-
Wt("You're all set!");
|
|
8020
|
-
} catch (e) {
|
|
8021
|
-
if (e instanceof UnsupportedError) {
|
|
8022
|
-
const padding = getPadding(e.reasons.map((r) => r.id));
|
|
8023
|
-
const message = e.reasons.map((r) => ` ${r.id.padEnd(padding)} ${color.error(r.reason)}`).join("\n");
|
|
8024
|
-
R$1.error(`${e.name}\n\n${message}`);
|
|
8025
|
-
R$1.message();
|
|
8026
|
-
} else if (e instanceof Error) {
|
|
8027
|
-
R$1.error(e.stack ?? String(e));
|
|
8028
|
-
R$1.message();
|
|
8029
|
-
}
|
|
8030
|
-
Pt("Operation failed.");
|
|
8031
|
-
}
|
|
8032
|
-
}
|
|
8033
|
-
function getPadding(lines) {
|
|
8034
|
-
const lengths = lines.map((s) => s.length);
|
|
8035
|
-
return Math.max(...lengths);
|
|
8036
|
-
}
|
|
8037
|
-
function forwardExitCode(error) {
|
|
8038
|
-
if (error && typeof error === "object" && "status" in error && typeof error.status === "number") process$1.exit(error.status);
|
|
8039
|
-
else process$1.exit(1);
|
|
8040
|
-
}
|
|
8041
|
-
function parseAddonOptions(optionFlags) {
|
|
8042
|
-
if (optionFlags === void 0 || optionFlags === "") return;
|
|
8043
|
-
const options = optionFlags.split("+");
|
|
8044
|
-
const malformed = options.filter((option) => !/.+:.*/.test(option));
|
|
8045
|
-
if (malformed.length > 0) {
|
|
8046
|
-
const message = `Malformed arguments: The following add-on options: ${malformed.map((o) => `'${o}'`).join(", ")} are missing their option name or value (e.g. 'addon=option1:value1+option2:value2').`;
|
|
8047
|
-
throw new Error(message);
|
|
8048
|
-
}
|
|
8049
|
-
return options;
|
|
8050
|
-
}
|
|
8051
|
-
function buildAndLogArgs(agent, command, args, lastArgs = []) {
|
|
8052
|
-
const allArgs = [
|
|
8053
|
-
`sv@${version}`,
|
|
8054
|
-
command,
|
|
8055
|
-
...args
|
|
8056
|
-
];
|
|
8057
|
-
if (agent === null || agent === void 0) allArgs.push("--no-install");
|
|
8058
|
-
else allArgs.push("--install", agent);
|
|
8059
|
-
const message = resolveCommandArray(agent ?? "npm", "execute", [...allArgs, ...lastArgs]).join(" ");
|
|
8060
|
-
R$1.message(color.optional(color.dim(`To skip prompts next time, run:`)));
|
|
8061
|
-
R$1.info(color.optional(message), { spacing: -1 });
|
|
8062
|
-
return message;
|
|
8063
|
-
}
|
|
8064
|
-
function updateReadme(projectPath, command) {
|
|
8065
|
-
const readmePath = path.join(projectPath, "README.md");
|
|
8066
|
-
if (!fs.existsSync(readmePath)) return;
|
|
8067
|
-
let content = fs.readFileSync(readmePath, "utf-8");
|
|
8068
|
-
const creatingSectionPattern = /## Creating a project[\s\S]*?(?=## |$)/;
|
|
8069
|
-
const creatingSectionMatch = content.match(creatingSectionPattern);
|
|
8070
|
-
if (!creatingSectionMatch) return;
|
|
8071
|
-
const updatedSection = `${creatingSectionMatch[0].trim()}\n\nTo recreate this project with the same configuration:
|
|
8072
|
-
|
|
8073
|
-
\`\`\`sh
|
|
8074
|
-
# recreate this project
|
|
8075
|
-
${command}\n\`\`\`
|
|
8076
|
-
|
|
8077
|
-
`;
|
|
8078
|
-
content = content.replace(creatingSectionPattern, updatedSection);
|
|
8079
|
-
fs.writeFileSync(readmePath, content);
|
|
8080
|
-
}
|
|
8081
|
-
function errorAndExit(message) {
|
|
8082
|
-
R$1.error(message);
|
|
8083
|
-
R$1.message();
|
|
8084
|
-
Pt("Operation failed.");
|
|
8085
|
-
process$1.exit(1);
|
|
8086
|
-
}
|
|
8087
|
-
const normalizePosix = (dir) => {
|
|
8088
|
-
return path.posix.normalize(dir.replace(/\\/g, "/"));
|
|
8089
|
-
};
|
|
8090
|
-
function updateAgent(projectPath, language, packageManager, loadedAddons) {
|
|
8091
|
-
const agentFiles = [
|
|
8092
|
-
"AGENTS.md",
|
|
8093
|
-
"GEMINI.md",
|
|
8094
|
-
"CLAUDE.md"
|
|
8095
|
-
];
|
|
8096
|
-
const languageLabel = language === "typescript" ? "TypeScript" : language === "checkjs" ? "JavaScript (JSDoc)" : "None";
|
|
8097
|
-
const packageManagerLabel = packageManager ?? "npm";
|
|
8098
|
-
const addonNames = loadedAddons.map((addon) => addon.addon.id);
|
|
8099
|
-
const configSection = `## Project Configuration
|
|
8100
|
-
|
|
8101
|
-
- **Language**: ${languageLabel}
|
|
8102
|
-
- **Package Manager**: ${packageManagerLabel}
|
|
8103
|
-
- **Add-ons**: ${addonNames.length > 0 ? addonNames.join(", ") : "none"}
|
|
8104
|
-
|
|
8105
|
-
---
|
|
8106
|
-
|
|
8107
|
-
`;
|
|
8108
|
-
const existingSectionPattern = /^## Project Configuration[\s\S]*?---\n\n/;
|
|
8109
|
-
for (const fileName of agentFiles) {
|
|
8110
|
-
const agentPath = path.join(projectPath, fileName);
|
|
8111
|
-
if (!fs.existsSync(agentPath)) continue;
|
|
8112
|
-
let content = fs.readFileSync(agentPath, "utf-8");
|
|
8113
|
-
content = content.replace(existingSectionPattern, "");
|
|
8114
|
-
content = configSection + content;
|
|
8115
|
-
fs.writeFileSync(agentPath, content);
|
|
8116
|
-
}
|
|
8117
|
-
}
|
|
8118
|
-
//#endregion
|
|
8119
8132
|
//#region ../../node_modules/.pnpm/events-universal@1.0.1/node_modules/events-universal/default.js
|
|
8120
8133
|
var require_default = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
8121
8134
|
module.exports = __require("events");
|
|
@@ -10964,46 +10977,13 @@ function getUserAgent() {
|
|
|
10964
10977
|
const name = pmSpec.substring(0, separatorPos);
|
|
10965
10978
|
return AGENTS.includes(name) ? name : void 0;
|
|
10966
10979
|
}
|
|
10967
|
-
|
|
10968
|
-
if (
|
|
10969
|
-
let confIn = "package.json";
|
|
10970
|
-
const pnpmVersion = await getPnpmVersion();
|
|
10971
|
-
if (pnpmVersion) confIn = isVersionUnsupportedBelow(pnpmVersion, "10.5") ? "package.json" : "pnpm-workspace.yaml";
|
|
10980
|
+
function addPnpmOnlyBuiltDependencies(cwd, packageManager, ...packages) {
|
|
10981
|
+
if (packageManager !== "pnpm" || packages.length === 0) return;
|
|
10972
10982
|
const found = up$1("pnpm-workspace.yaml", { cwd });
|
|
10973
|
-
|
|
10974
|
-
|
|
10975
|
-
|
|
10976
|
-
|
|
10977
|
-
for (const item of allowedPackages) {
|
|
10978
|
-
if (items.includes(item)) continue;
|
|
10979
|
-
if (items.some((y) => typeof y === "object" && y.value === item)) continue;
|
|
10980
|
-
items.push(item);
|
|
10981
|
-
}
|
|
10982
|
-
data.set("onlyBuiltDependencies", items);
|
|
10983
|
-
const newContent = generateCode();
|
|
10984
|
-
const pnpmWorkspacePath = found ?? path.join(cwd, "pnpm-workspace.yaml");
|
|
10985
|
-
if (newContent !== content) fs.writeFileSync(pnpmWorkspacePath, newContent, "utf-8");
|
|
10986
|
-
} else {
|
|
10987
|
-
const rootDir = found ? path.dirname(found) : cwd;
|
|
10988
|
-
const pkgPath = path.join(rootDir, "package.json");
|
|
10989
|
-
const content = fs.readFileSync(pkgPath, "utf-8");
|
|
10990
|
-
const { data, generateCode } = parse.json(content);
|
|
10991
|
-
data.pnpm ??= {};
|
|
10992
|
-
data.pnpm.onlyBuiltDependencies ??= [];
|
|
10993
|
-
for (const allowedPackage of allowedPackages) {
|
|
10994
|
-
if (data.pnpm.onlyBuiltDependencies.includes(allowedPackage)) continue;
|
|
10995
|
-
data.pnpm.onlyBuiltDependencies.push(allowedPackage);
|
|
10996
|
-
}
|
|
10997
|
-
const newContent = generateCode();
|
|
10998
|
-
if (newContent !== content) fs.writeFileSync(pkgPath, newContent, "utf-8");
|
|
10999
|
-
}
|
|
11000
|
-
}
|
|
11001
|
-
async function getPnpmVersion() {
|
|
11002
|
-
let v = void 0;
|
|
11003
|
-
try {
|
|
11004
|
-
v = (await z("pnpm", ["--version"], { throwOnError: true })).stdout.trim();
|
|
11005
|
-
} catch {}
|
|
11006
|
-
return v;
|
|
10983
|
+
const filePath = found ?? path.join(cwd, "pnpm-workspace.yaml");
|
|
10984
|
+
const content = found ? fs.readFileSync(found, "utf-8") : "";
|
|
10985
|
+
const newContent = pnpm.onlyBuiltDependencies(...packages)(content);
|
|
10986
|
+
if (newContent !== content) fs.writeFileSync(filePath, newContent, "utf-8");
|
|
11007
10987
|
}
|
|
11008
10988
|
//#endregion
|
|
11009
10989
|
//#region src/core/verifiers.ts
|
|
@@ -11054,12 +11034,12 @@ function verifyUnsupportedAddons(addons, setupResults) {
|
|
|
11054
11034
|
//#region src/core/workspace.ts
|
|
11055
11035
|
async function createWorkspace({ cwd, packageManager, override }) {
|
|
11056
11036
|
const resolvedCwd = path.resolve(cwd);
|
|
11057
|
-
const typeConfig = any([
|
|
11058
|
-
const typescript = typeConfig?.endsWith(
|
|
11059
|
-
const viteConfigPath = path.join(resolvedCwd,
|
|
11060
|
-
const viteConfig = fs.existsSync(viteConfigPath) ?
|
|
11061
|
-
const svelteConfigPath = path.join(resolvedCwd,
|
|
11062
|
-
const svelteConfig = fs.existsSync(svelteConfigPath) ?
|
|
11037
|
+
const typeConfig = any([filePaths.jsconfig, filePaths.tsconfig], { cwd });
|
|
11038
|
+
const typescript = typeConfig?.endsWith(filePaths.tsconfig) ?? false;
|
|
11039
|
+
const viteConfigPath = path.join(resolvedCwd, filePaths.viteConfigTS);
|
|
11040
|
+
const viteConfig = fs.existsSync(viteConfigPath) ? filePaths.viteConfigTS : filePaths.viteConfig;
|
|
11041
|
+
const svelteConfigPath = path.join(resolvedCwd, filePaths.svelteConfigTS);
|
|
11042
|
+
const svelteConfig = fs.existsSync(svelteConfigPath) ? filePaths.svelteConfigTS : filePaths.svelteConfig;
|
|
11063
11043
|
let dependencies = {};
|
|
11064
11044
|
if (override?.dependencies) dependencies = override.dependencies;
|
|
11065
11045
|
else {
|
|
@@ -11067,8 +11047,8 @@ async function createWorkspace({ cwd, packageManager, override }) {
|
|
|
11067
11047
|
const workspaceRoot = findWorkspaceRoot(directory);
|
|
11068
11048
|
const { root } = path.parse(directory);
|
|
11069
11049
|
while (directory && directory.length >= workspaceRoot.length) {
|
|
11070
|
-
if (fs.existsSync(path.join(directory,
|
|
11071
|
-
const { data: packageJson } =
|
|
11050
|
+
if (fs.existsSync(path.join(directory, filePaths.packageJson))) {
|
|
11051
|
+
const { data: packageJson } = loadPackageJson(directory);
|
|
11072
11052
|
dependencies = {
|
|
11073
11053
|
...packageJson.devDependencies,
|
|
11074
11054
|
...packageJson.dependencies,
|
|
@@ -11101,16 +11081,37 @@ async function createWorkspace({ cwd, packageManager, override }) {
|
|
|
11101
11081
|
stylesheet,
|
|
11102
11082
|
package: "package.json",
|
|
11103
11083
|
gitignore: ".gitignore",
|
|
11104
|
-
prettierignore
|
|
11105
|
-
|
|
11106
|
-
|
|
11107
|
-
|
|
11108
|
-
|
|
11084
|
+
get prettierignore() {
|
|
11085
|
+
svDeprecated("`workspace.file.prettierignore` is deprecated, use the string `.prettierignore` isntead.");
|
|
11086
|
+
return ".prettierignore";
|
|
11087
|
+
},
|
|
11088
|
+
get prettierrc() {
|
|
11089
|
+
svDeprecated("`workspace.file.prettierrc` is deprecated, use the string `.prettierrc` isntead.");
|
|
11090
|
+
return ".prettierrc";
|
|
11091
|
+
},
|
|
11092
|
+
get eslintConfig() {
|
|
11093
|
+
svDeprecated("`workspace.file.eslintConfig` is deprecated, use the string `eslint.config.js` isntead.");
|
|
11094
|
+
return "eslint.config.js";
|
|
11095
|
+
},
|
|
11096
|
+
get vscodeSettings() {
|
|
11097
|
+
svDeprecated("`workspace.file.vscodeSettings` is deprecated, use the string `.vscode/settings.json` isntead.");
|
|
11098
|
+
return ".vscode/settings.json";
|
|
11099
|
+
},
|
|
11100
|
+
get vscodeExtensions() {
|
|
11101
|
+
svDeprecated("`workspace.file.vscodeExtensions` is deprecated, use the string `.vscode/extensions.json` isntead.");
|
|
11102
|
+
return ".vscode/extensions.json";
|
|
11103
|
+
},
|
|
11109
11104
|
getRelative({ from, to }) {
|
|
11110
11105
|
from = from ?? "";
|
|
11111
11106
|
let relativePath = path.posix.relative(path.posix.dirname(from), to);
|
|
11112
11107
|
if (!relativePath.startsWith(".") && !relativePath.startsWith("/")) relativePath = `./${relativePath}`;
|
|
11113
11108
|
return relativePath;
|
|
11109
|
+
},
|
|
11110
|
+
findUp(filename) {
|
|
11111
|
+
const found = up$1(filename, { cwd: resolvedCwd });
|
|
11112
|
+
if (!found) return filename;
|
|
11113
|
+
if (resolvedCwd.includes(".test-output") && !found.includes(".test-output")) return filename;
|
|
11114
|
+
return path.relative(resolvedCwd, found);
|
|
11114
11115
|
}
|
|
11115
11116
|
},
|
|
11116
11117
|
isKit,
|
|
@@ -11122,9 +11123,9 @@ function findWorkspaceRoot(cwd) {
|
|
|
11122
11123
|
const { root } = path.parse(cwd);
|
|
11123
11124
|
let directory = cwd;
|
|
11124
11125
|
while (directory && directory !== root) {
|
|
11125
|
-
if (fs.existsSync(path.join(directory,
|
|
11126
|
+
if (fs.existsSync(path.join(directory, filePaths.packageJson))) {
|
|
11126
11127
|
if (fs.existsSync(path.join(directory, "pnpm-workspace.yaml"))) return directory;
|
|
11127
|
-
const { data } =
|
|
11128
|
+
const { data } = loadPackageJson(directory);
|
|
11128
11129
|
if (data.workspaces) return directory;
|
|
11129
11130
|
}
|
|
11130
11131
|
const parent = path.dirname(directory);
|
|
@@ -11134,7 +11135,7 @@ function findWorkspaceRoot(cwd) {
|
|
|
11134
11135
|
return cwd;
|
|
11135
11136
|
}
|
|
11136
11137
|
function parseKitOptions(cwd, svelteConfigPath) {
|
|
11137
|
-
const configSource =
|
|
11138
|
+
const configSource = loadFile(cwd, svelteConfigPath);
|
|
11138
11139
|
const { ast } = parse.script(configSource);
|
|
11139
11140
|
const defaultExport = ast.body.find((s) => s.type === "ExportDefaultDeclaration");
|
|
11140
11141
|
if (!defaultExport) throw Error(`Missing default export in \`${svelteConfigPath}\``);
|
|
@@ -11310,7 +11311,7 @@ function setupPlaygroundProject(url, playground, cwd, installDependencies) {
|
|
|
11310
11311
|
</PlaygroundLayout>`);
|
|
11311
11312
|
const newContent = generateCode();
|
|
11312
11313
|
fs.writeFileSync(filePath, newContent, "utf-8");
|
|
11313
|
-
const pkgPath = path.join(cwd,
|
|
11314
|
+
const pkgPath = path.join(cwd, filePaths.packageJson);
|
|
11314
11315
|
const pkgSource = fs.readFileSync(pkgPath, "utf-8");
|
|
11315
11316
|
const pkgJson = parse.json(pkgSource);
|
|
11316
11317
|
let updatePackageJson = false;
|
|
@@ -11321,7 +11322,7 @@ function setupPlaygroundProject(url, playground, cwd, installDependencies) {
|
|
|
11321
11322
|
}
|
|
11322
11323
|
let experimentalAsyncNeeded = true;
|
|
11323
11324
|
const addExperimentalAsync = () => {
|
|
11324
|
-
const svelteConfigPath = path.join(cwd,
|
|
11325
|
+
const svelteConfigPath = path.join(cwd, filePaths.svelteConfig);
|
|
11325
11326
|
const svelteConfig = fs.readFileSync(svelteConfigPath, "utf-8");
|
|
11326
11327
|
const { ast, generateCode } = parse.script(svelteConfig);
|
|
11327
11328
|
const { value: config } = js.exports.createDefault(ast, { fallback: js.object.create({}) });
|
|
@@ -11539,7 +11540,8 @@ async function createProject(cwd, options) {
|
|
|
11539
11540
|
loadedAddons = result.loadedAddons;
|
|
11540
11541
|
answers = result.answers;
|
|
11541
11542
|
}
|
|
11542
|
-
create$1(
|
|
11543
|
+
create$1({
|
|
11544
|
+
cwd: projectPath,
|
|
11543
11545
|
name: projectName,
|
|
11544
11546
|
template,
|
|
11545
11547
|
types: language
|
|
@@ -11581,7 +11583,7 @@ async function createProject(cwd, options) {
|
|
|
11581
11583
|
updateAgent(directory, language, packageManager ?? "npm", loadedAddons);
|
|
11582
11584
|
if (packageManager) workspace.packageManager = packageManager;
|
|
11583
11585
|
const addOnNextSteps = getNextSteps(addOnSuccessfulAddons, workspace, answers, addonSetupResults);
|
|
11584
|
-
|
|
11586
|
+
addPnpmOnlyBuiltDependencies(projectPath, packageManager, "esbuild");
|
|
11585
11587
|
if (packageManager) {
|
|
11586
11588
|
await installDependencies(packageManager, projectPath);
|
|
11587
11589
|
await formatFiles({
|
|
@@ -11625,7 +11627,7 @@ async function createVirtualWorkspace({ cwd, template, type }) {
|
|
|
11625
11627
|
kitRoutes: "src/routes"
|
|
11626
11628
|
};
|
|
11627
11629
|
}
|
|
11628
|
-
const { data: packageJson } =
|
|
11630
|
+
const { data: packageJson } = loadPackageJson(dist(`templates/${template}`));
|
|
11629
11631
|
override.dependencies = {
|
|
11630
11632
|
...packageJson.devDependencies,
|
|
11631
11633
|
...packageJson.dependencies,
|
|
@@ -11640,8 +11642,8 @@ async function createVirtualWorkspace({ cwd, template, type }) {
|
|
|
11640
11642
|
language: type === "typescript" ? "ts" : "js",
|
|
11641
11643
|
file: {
|
|
11642
11644
|
...tentativeWorkspace.file,
|
|
11643
|
-
viteConfig: type === "typescript" ?
|
|
11644
|
-
svelteConfig:
|
|
11645
|
+
viteConfig: type === "typescript" ? filePaths.viteConfigTS : filePaths.viteConfig,
|
|
11646
|
+
svelteConfig: filePaths.svelteConfig
|
|
11645
11647
|
}
|
|
11646
11648
|
};
|
|
11647
11649
|
}
|
|
@@ -12031,7 +12033,7 @@ async function runAddonsApply({ answers, options, loadedAddons, setupResults, wo
|
|
|
12031
12033
|
successfulAddons: [],
|
|
12032
12034
|
setupResults: {}
|
|
12033
12035
|
};
|
|
12034
|
-
const { filesToFormat,
|
|
12036
|
+
const { filesToFormat, status } = await applyAddons({
|
|
12035
12037
|
loadedAddons,
|
|
12036
12038
|
workspace,
|
|
12037
12039
|
setupResults,
|
|
@@ -12050,7 +12052,7 @@ async function runAddonsApply({ answers, options, loadedAddons, setupResults, wo
|
|
|
12050
12052
|
process$1.exit(1);
|
|
12051
12053
|
} else R$1.success(`Successfully setup add-ons: ${addonSuccess.map((c) => color.addon(c)).join(", ")}`);
|
|
12052
12054
|
const packageManager = options.install === false ? null : options.install === true ? await packageManagerPrompt(options.cwd) : options.install;
|
|
12053
|
-
|
|
12055
|
+
addPnpmOnlyBuiltDependencies(workspace.cwd, packageManager, "esbuild");
|
|
12054
12056
|
const argsFormattedAddons = [];
|
|
12055
12057
|
for (const loaded of successfulAddons) {
|
|
12056
12058
|
const addonId = loaded.addon.id;
|
|
@@ -12273,6 +12275,26 @@ async function resolveNonOfficialAddons(refs, downloadCheck) {
|
|
|
12273
12275
|
const TESTING = process$1.env.NODE_ENV?.toLowerCase() === "test";
|
|
12274
12276
|
//#endregion
|
|
12275
12277
|
//#region src/core/engine.ts
|
|
12278
|
+
function alphabetizeRecord(obj) {
|
|
12279
|
+
const ordered = {};
|
|
12280
|
+
for (const [key, value] of Object.entries(obj).sort(([a], [b]) => a.localeCompare(b))) ordered[key] = value;
|
|
12281
|
+
return ordered;
|
|
12282
|
+
}
|
|
12283
|
+
function updatePackages(dependencies, cwd) {
|
|
12284
|
+
const { source } = loadPackageJson(cwd);
|
|
12285
|
+
const { data, generateCode } = parse.json(source);
|
|
12286
|
+
for (const dependency of dependencies) if (dependency.dev) {
|
|
12287
|
+
data.devDependencies ??= {};
|
|
12288
|
+
data.devDependencies[dependency.pkg] = dependency.version;
|
|
12289
|
+
} else {
|
|
12290
|
+
data.dependencies ??= {};
|
|
12291
|
+
data.dependencies[dependency.pkg] = dependency.version;
|
|
12292
|
+
}
|
|
12293
|
+
if (data.dependencies) data.dependencies = alphabetizeRecord(data.dependencies);
|
|
12294
|
+
if (data.devDependencies) data.devDependencies = alphabetizeRecord(data.devDependencies);
|
|
12295
|
+
saveFile(cwd, filePaths.packageJson, generateCode());
|
|
12296
|
+
return filePaths.packageJson;
|
|
12297
|
+
}
|
|
12276
12298
|
async function add({ addons, cwd, options, packageManager = "npm" }) {
|
|
12277
12299
|
const workspace = await createWorkspace({
|
|
12278
12300
|
cwd,
|
|
@@ -12288,7 +12310,6 @@ async function add({ addons, cwd, options, packageManager = "npm" }) {
|
|
|
12288
12310
|
}
|
|
12289
12311
|
async function applyAddons({ loadedAddons, workspace, setupResults, options }) {
|
|
12290
12312
|
const filesToFormat = /* @__PURE__ */ new Set();
|
|
12291
|
-
const allPnpmBuildDependencies = [];
|
|
12292
12313
|
const status = {};
|
|
12293
12314
|
const ordered = orderAddons(loadedAddons.map((l) => l.addon), setupResults);
|
|
12294
12315
|
let hasFormatter = false;
|
|
@@ -12300,7 +12321,7 @@ async function applyAddons({ loadedAddons, workspace, setupResults, options }) {
|
|
|
12300
12321
|
packageManager: workspace.packageManager
|
|
12301
12322
|
});
|
|
12302
12323
|
if (!hasFormatter) hasFormatter = !!addonWorkspace.dependencyVersion("prettier");
|
|
12303
|
-
const { files,
|
|
12324
|
+
const { files, cancels } = await runAddon({
|
|
12304
12325
|
workspace: addonWorkspace,
|
|
12305
12326
|
workspaceOptions,
|
|
12306
12327
|
addon,
|
|
@@ -12308,13 +12329,11 @@ async function applyAddons({ loadedAddons, workspace, setupResults, options }) {
|
|
|
12308
12329
|
multiple: ordered.length > 1
|
|
12309
12330
|
});
|
|
12310
12331
|
files.forEach((f) => filesToFormat.add(f));
|
|
12311
|
-
pnpmBuildDependencies.forEach((s) => allPnpmBuildDependencies.push(s));
|
|
12312
12332
|
if (cancels.length === 0) status[addon.id] = "success";
|
|
12313
12333
|
else status[addon.id] = cancels;
|
|
12314
12334
|
}
|
|
12315
12335
|
return {
|
|
12316
12336
|
filesToFormat: hasFormatter ? Array.from(filesToFormat) : [],
|
|
12317
|
-
pnpmBuildDependencies: allPnpmBuildDependencies,
|
|
12318
12337
|
status
|
|
12319
12338
|
};
|
|
12320
12339
|
}
|
|
@@ -12351,14 +12370,13 @@ async function runAddon({ addon, loaded, multiple, workspace, workspaceOptions }
|
|
|
12351
12370
|
const options = { ...workspaceOptions };
|
|
12352
12371
|
for (const [id, question] of Object.entries(addon.options)) if (question.condition?.(options) !== false) options[id] ??= question.default;
|
|
12353
12372
|
const dependencies = [];
|
|
12354
|
-
const pnpmBuildDependencies = [];
|
|
12355
12373
|
const sv = {
|
|
12356
12374
|
file: (path, edit) => {
|
|
12357
12375
|
try {
|
|
12358
|
-
const content = fileExists(workspace.cwd, path) ?
|
|
12376
|
+
const content = fileExists(workspace.cwd, path) ? loadFile(workspace.cwd, path) : "";
|
|
12359
12377
|
const editedContent = edit(content);
|
|
12360
12378
|
if (editedContent === "" || editedContent === false) return content;
|
|
12361
|
-
|
|
12379
|
+
saveFile(workspace.cwd, path, editedContent);
|
|
12362
12380
|
files.add(path);
|
|
12363
12381
|
} catch (e) {
|
|
12364
12382
|
if (e instanceof Error) {
|
|
@@ -12383,8 +12401,7 @@ async function runAddon({ addon, loaded, multiple, workspace, workspaceOptions }
|
|
|
12383
12401
|
throwOnError: true
|
|
12384
12402
|
});
|
|
12385
12403
|
} catch (error) {
|
|
12386
|
-
|
|
12387
|
-
throw new Error(`Failed to execute scripts '${executedCommand}': ${typedError.message}`, { cause: error });
|
|
12404
|
+
throw new Error(`Failed to execute scripts '${executedCommand}': ${error.message}`, { cause: error });
|
|
12388
12405
|
}
|
|
12389
12406
|
},
|
|
12390
12407
|
dependency: (pkg, version) => {
|
|
@@ -12402,7 +12419,8 @@ async function runAddon({ addon, loaded, multiple, workspace, workspaceOptions }
|
|
|
12402
12419
|
});
|
|
12403
12420
|
},
|
|
12404
12421
|
pnpmBuildDependency: (pkg) => {
|
|
12405
|
-
|
|
12422
|
+
svDeprecated("use `pnpm.onlyBuiltDependencies` from `@sveltejs/sv-utils` instead of `sv.pnpmBuildDependency`");
|
|
12423
|
+
addPnpmOnlyBuiltDependencies(workspace.cwd, workspace.packageManager, pkg);
|
|
12406
12424
|
}
|
|
12407
12425
|
};
|
|
12408
12426
|
const cancels = [];
|
|
@@ -12420,12 +12438,11 @@ async function runAddon({ addon, loaded, multiple, workspace, workspaceOptions }
|
|
|
12420
12438
|
throw new Error(`Add-on '${addon.id}' failed during run: ${msg}\n\n${getErrorHint(loaded.reference.source)}`, { cause: err });
|
|
12421
12439
|
}
|
|
12422
12440
|
if (cancels.length === 0) {
|
|
12423
|
-
const pkgPath =
|
|
12441
|
+
const pkgPath = updatePackages(dependencies, workspace.cwd);
|
|
12424
12442
|
files.add(pkgPath);
|
|
12425
12443
|
}
|
|
12426
12444
|
return {
|
|
12427
12445
|
files: Array.from(files),
|
|
12428
|
-
pnpmBuildDependencies,
|
|
12429
12446
|
cancels
|
|
12430
12447
|
};
|
|
12431
12448
|
}
|
|
@@ -12435,4 +12452,4 @@ function orderAddons(addons, setupResults) {
|
|
|
12435
12452
|
});
|
|
12436
12453
|
}
|
|
12437
12454
|
//#endregion
|
|
12438
|
-
export {
|
|
12455
|
+
export { __toESM as S, name as _, detectPackageManager as a, __commonJSMin as b, defineAddonOptions as c, program as d, R as f, helpConfig as g, forwardExitCode as h, addPnpmOnlyBuiltDependencies as i, from as l, create$1 as m, add$1 as n, officialAddons$1 as o, z as p, create as r, defineAddon as s, add as t, Command as u, version as v, __require as x, svDeprecated as y };
|