sv 0.9.7 → 0.9.9
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.js +53 -18
- package/dist/{create-CyyvJXoi.js → create-CdiXN6U7.js} +7446 -597
- package/dist/{install-DE_JOizJ.js → install-CD-dlXd7.js} +354 -355
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/index.js +2 -2
- package/dist/lib/testing.d.ts +1 -1
- package/dist/lib/testing.js +1 -1
- package/dist/shared.json +8 -0
- package/package.json +3 -3
|
@@ -1,156 +1,8 @@
|
|
|
1
|
-
import { Element, MagicString, T, Tag, __toESM, any, be, detect, getUserAgent, parseCss, parseHtml, parseHtml$1, parseJson, parseScript, parseScript$1, parseSvelte, require_picocolors, resolveCommand, serializeScript, stripAst, walk } from "./create-
|
|
1
|
+
import { Element, MagicString, T, Tag, __toESM, any, be, createPrinter, dedent_default, defineAddon, defineAddonOptions, detect, getUserAgent, import_picocolors as import_picocolors$2, parseCss, parseHtml, parseHtml$1, parseJson, parseScript, parseScript$1, parseSvelte, require_picocolors, resolveCommand, serializeScript, stripAst, walk } from "./create-CdiXN6U7.js";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import process from "node:process";
|
|
5
5
|
|
|
6
|
-
//#region ../core/addon/config.ts
|
|
7
|
-
function defineAddon(config) {
|
|
8
|
-
return config;
|
|
9
|
-
}
|
|
10
|
-
function defineAddonOptions() {
|
|
11
|
-
return createOptionBuilder({});
|
|
12
|
-
}
|
|
13
|
-
function createOptionBuilder(options$6) {
|
|
14
|
-
return {
|
|
15
|
-
add(key, question) {
|
|
16
|
-
const newOptions = {
|
|
17
|
-
...options$6,
|
|
18
|
-
[key]: question
|
|
19
|
-
};
|
|
20
|
-
return createOptionBuilder(newOptions);
|
|
21
|
-
},
|
|
22
|
-
build() {
|
|
23
|
-
return options$6;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region ../../node_modules/.pnpm/dedent@1.6.0/node_modules/dedent/dist/dedent.mjs
|
|
30
|
-
function ownKeys(object, enumerableOnly) {
|
|
31
|
-
var keys = Object.keys(object);
|
|
32
|
-
if (Object.getOwnPropertySymbols) {
|
|
33
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
34
|
-
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
35
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
36
|
-
})), keys.push.apply(keys, symbols);
|
|
37
|
-
}
|
|
38
|
-
return keys;
|
|
39
|
-
}
|
|
40
|
-
function _objectSpread(target) {
|
|
41
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
42
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
43
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function(key) {
|
|
44
|
-
_defineProperty(target, key, source[key]);
|
|
45
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
46
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
return target;
|
|
50
|
-
}
|
|
51
|
-
function _defineProperty(obj, key, value) {
|
|
52
|
-
key = _toPropertyKey(key);
|
|
53
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
54
|
-
value,
|
|
55
|
-
enumerable: true,
|
|
56
|
-
configurable: true,
|
|
57
|
-
writable: true
|
|
58
|
-
});
|
|
59
|
-
else obj[key] = value;
|
|
60
|
-
return obj;
|
|
61
|
-
}
|
|
62
|
-
function _toPropertyKey(arg) {
|
|
63
|
-
var key = _toPrimitive(arg, "string");
|
|
64
|
-
return typeof key === "symbol" ? key : String(key);
|
|
65
|
-
}
|
|
66
|
-
function _toPrimitive(input, hint) {
|
|
67
|
-
if (typeof input !== "object" || input === null) return input;
|
|
68
|
-
var prim = input[Symbol.toPrimitive];
|
|
69
|
-
if (prim !== void 0) {
|
|
70
|
-
var res = prim.call(input, hint || "default");
|
|
71
|
-
if (typeof res !== "object") return res;
|
|
72
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
73
|
-
}
|
|
74
|
-
return (hint === "string" ? String : Number)(input);
|
|
75
|
-
}
|
|
76
|
-
const dedent = createDedent({});
|
|
77
|
-
var dedent_default = dedent;
|
|
78
|
-
function createDedent(options$6) {
|
|
79
|
-
dedent$1.withOptions = (newOptions) => createDedent(_objectSpread(_objectSpread({}, options$6), newOptions));
|
|
80
|
-
return dedent$1;
|
|
81
|
-
function dedent$1(strings, ...values) {
|
|
82
|
-
const raw = typeof strings === "string" ? [strings] : strings.raw;
|
|
83
|
-
const { escapeSpecialCharacters = Array.isArray(strings), trimWhitespace = true } = options$6;
|
|
84
|
-
let result = "";
|
|
85
|
-
for (let i = 0; i < raw.length; i++) {
|
|
86
|
-
let next = raw[i];
|
|
87
|
-
if (escapeSpecialCharacters) next = next.replace(/\\\n[ \t]*/g, "").replace(/\\`/g, "`").replace(/\\\$/g, "$").replace(/\\\{/g, "{");
|
|
88
|
-
result += next;
|
|
89
|
-
if (i < values.length) result += values[i];
|
|
90
|
-
}
|
|
91
|
-
const lines = result.split("\n");
|
|
92
|
-
let mindent = null;
|
|
93
|
-
for (const l of lines) {
|
|
94
|
-
const m = l.match(/^(\s+)\S+/);
|
|
95
|
-
if (m) {
|
|
96
|
-
const indent = m[1].length;
|
|
97
|
-
if (!mindent) mindent = indent;
|
|
98
|
-
else mindent = Math.min(mindent, indent);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
if (mindent !== null) {
|
|
102
|
-
const m = mindent;
|
|
103
|
-
result = lines.map((l) => l[0] === " " || l[0] === " " ? l.slice(m) : l).join("\n");
|
|
104
|
-
}
|
|
105
|
-
if (trimWhitespace) result = result.trim();
|
|
106
|
-
if (escapeSpecialCharacters) result = result.replace(/\\n/g, "\n");
|
|
107
|
-
return result;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
//#endregion
|
|
112
|
-
//#region ../core/utils.ts
|
|
113
|
-
function createPrinter(...conditions) {
|
|
114
|
-
return conditions.map((condition) => {
|
|
115
|
-
return (content, alt = "") => condition ? content : alt;
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
//#endregion
|
|
120
|
-
//#region ../core/common.ts
|
|
121
|
-
function splitVersion(str) {
|
|
122
|
-
const [major, minor, patch] = str?.split(".") ?? [];
|
|
123
|
-
function toVersionNumber(val) {
|
|
124
|
-
return val !== void 0 && val !== "" && !isNaN(Number(val)) ? Number(val) : void 0;
|
|
125
|
-
}
|
|
126
|
-
return {
|
|
127
|
-
major: toVersionNumber(major),
|
|
128
|
-
minor: toVersionNumber(minor),
|
|
129
|
-
patch: toVersionNumber(patch)
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
function isVersionUnsupportedBelow(versionStr, belowStr) {
|
|
133
|
-
const version = splitVersion(versionStr);
|
|
134
|
-
const below = splitVersion(belowStr);
|
|
135
|
-
if (version.major === void 0 || below.major === void 0) return void 0;
|
|
136
|
-
if (version.major < below.major) return true;
|
|
137
|
-
if (version.major > below.major) return false;
|
|
138
|
-
if (version.minor === void 0 || below.minor === void 0) if (version.major === below.major) return false;
|
|
139
|
-
else return true;
|
|
140
|
-
if (version.minor < below.minor) return true;
|
|
141
|
-
if (version.minor > below.minor) return false;
|
|
142
|
-
if (version.patch === void 0 || below.patch === void 0) if (version.minor === below.minor) return false;
|
|
143
|
-
else return true;
|
|
144
|
-
if (version.patch < below.patch) return true;
|
|
145
|
-
if (version.patch > below.patch) return false;
|
|
146
|
-
if (version.patch === below.patch) return false;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
//#endregion
|
|
150
|
-
//#region ../core/index.ts
|
|
151
|
-
var import_picocolors$2 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
152
|
-
|
|
153
|
-
//#endregion
|
|
154
6
|
//#region ../../node_modules/.pnpm/decircular@1.0.0/node_modules/decircular/index.js
|
|
155
7
|
function decircular(object) {
|
|
156
8
|
const seenObjects = /* @__PURE__ */ new WeakMap();
|
|
@@ -169,10 +21,10 @@ function decircular(object) {
|
|
|
169
21
|
|
|
170
22
|
//#endregion
|
|
171
23
|
//#region ../core/tooling/js/common.ts
|
|
172
|
-
function addJsDocTypeComment(node, options$
|
|
24
|
+
function addJsDocTypeComment(node, options$7) {
|
|
173
25
|
const comment = {
|
|
174
26
|
type: "Block",
|
|
175
|
-
value: `* @type {${options$
|
|
27
|
+
value: `* @type {${options$7.type}} `
|
|
176
28
|
};
|
|
177
29
|
addComment(node, comment);
|
|
178
30
|
}
|
|
@@ -197,8 +49,8 @@ function areNodesEqual(node, otherNode) {
|
|
|
197
49
|
const otherNodeClone = stripAst(decircular(otherNode), ["loc", "raw"]);
|
|
198
50
|
return serializeScript(nodeClone) === serializeScript(otherNodeClone);
|
|
199
51
|
}
|
|
200
|
-
function appendFromString(node, options$
|
|
201
|
-
const program = parseScript$1(dedent_default(options$
|
|
52
|
+
function appendFromString(node, options$7) {
|
|
53
|
+
const program = parseScript$1(dedent_default(options$7.code));
|
|
202
54
|
for (const childNode of program.body) node.body.push(childNode);
|
|
203
55
|
}
|
|
204
56
|
function parseExpression(code) {
|
|
@@ -215,8 +67,8 @@ function parseFromString(code) {
|
|
|
215
67
|
return parseScript$1(dedent_default(code)).body[0];
|
|
216
68
|
}
|
|
217
69
|
/** Appends the statement to body of the block if it doesn't already exist */
|
|
218
|
-
function appendStatement(node, options$
|
|
219
|
-
if (!contains(node, options$
|
|
70
|
+
function appendStatement(node, options$7) {
|
|
71
|
+
if (!contains(node, options$7.statement)) node.body.push(options$7.statement);
|
|
220
72
|
}
|
|
221
73
|
/** Returns `true` if the provided node exists in the AST */
|
|
222
74
|
function contains(node, targetNode) {
|
|
@@ -230,8 +82,8 @@ function contains(node, targetNode) {
|
|
|
230
82
|
} });
|
|
231
83
|
return found;
|
|
232
84
|
}
|
|
233
|
-
function hasTypeProperty(node, options$
|
|
234
|
-
return node.type === "TSPropertySignature" && node.key.type === "Identifier" && node.key.name === options$
|
|
85
|
+
function hasTypeProperty(node, options$7) {
|
|
86
|
+
return node.type === "TSPropertySignature" && node.key.type === "Identifier" && node.key.name === options$7.name;
|
|
235
87
|
}
|
|
236
88
|
|
|
237
89
|
//#endregion
|
|
@@ -248,7 +100,7 @@ function append(node, element) {
|
|
|
248
100
|
function prepend(node, element) {
|
|
249
101
|
insertElement(node, element, { insertEnd: false });
|
|
250
102
|
}
|
|
251
|
-
function insertElement(node, element, options$
|
|
103
|
+
function insertElement(node, element, options$7) {
|
|
252
104
|
if (typeof element === "string") {
|
|
253
105
|
let literal = node.elements.filter((item) => item !== null && item.type === "Literal").find((item) => item.value === element);
|
|
254
106
|
if (!literal) {
|
|
@@ -256,31 +108,31 @@ function insertElement(node, element, options$6) {
|
|
|
256
108
|
type: "Literal",
|
|
257
109
|
value: element
|
|
258
110
|
};
|
|
259
|
-
if (options$
|
|
111
|
+
if (options$7.insertEnd) node.elements.push(literal);
|
|
260
112
|
else node.elements.unshift(literal);
|
|
261
113
|
}
|
|
262
|
-
} else if (!node.elements.some((item) => item && areNodesEqual(element, item))) if (options$
|
|
114
|
+
} else if (!node.elements.some((item) => item && areNodesEqual(element, item))) if (options$7.insertEnd) node.elements.push(element);
|
|
263
115
|
else node.elements.unshift(element);
|
|
264
116
|
}
|
|
265
117
|
|
|
266
118
|
//#endregion
|
|
267
119
|
//#region ../core/tooling/js/object.ts
|
|
268
|
-
function property(node, options$
|
|
269
|
-
return propertyNode(node, options$
|
|
120
|
+
function property(node, options$7) {
|
|
121
|
+
return propertyNode(node, options$7).value;
|
|
270
122
|
}
|
|
271
|
-
function propertyNode(node, options$
|
|
272
|
-
let prop = node.properties.filter((x$1) => x$1.type === "Property").find((x$1) => x$1.key.name === options$
|
|
123
|
+
function propertyNode(node, options$7) {
|
|
124
|
+
let prop = node.properties.filter((x$1) => x$1.type === "Property").find((x$1) => x$1.key.name === options$7.name);
|
|
273
125
|
if (!prop) {
|
|
274
126
|
let isShorthand = false;
|
|
275
|
-
if (options$
|
|
127
|
+
if (options$7.fallback.type === "Identifier") isShorthand = options$7.fallback.name === options$7.name;
|
|
276
128
|
prop = {
|
|
277
129
|
type: "Property",
|
|
278
130
|
shorthand: isShorthand,
|
|
279
131
|
key: {
|
|
280
132
|
type: "Identifier",
|
|
281
|
-
name: options$
|
|
133
|
+
name: options$7.name
|
|
282
134
|
},
|
|
283
|
-
value: options$
|
|
135
|
+
value: options$7.fallback,
|
|
284
136
|
kind: "init",
|
|
285
137
|
computed: false,
|
|
286
138
|
method: false
|
|
@@ -306,67 +158,67 @@ function overrideProperties(objectExpression, properties) {
|
|
|
306
158
|
override: true
|
|
307
159
|
});
|
|
308
160
|
}
|
|
309
|
-
function overrideProperty(node, options$
|
|
310
|
-
const prop = node.properties.filter((x$1) => x$1.type === "Property").find((x$1) => x$1.key.name === options$
|
|
161
|
+
function overrideProperty(node, options$7) {
|
|
162
|
+
const prop = node.properties.filter((x$1) => x$1.type === "Property").find((x$1) => x$1.key.name === options$7.name);
|
|
311
163
|
if (!prop) return property(node, {
|
|
312
|
-
name: options$
|
|
313
|
-
fallback: options$
|
|
164
|
+
name: options$7.name,
|
|
165
|
+
fallback: options$7.value
|
|
314
166
|
});
|
|
315
|
-
prop.value = options$
|
|
316
|
-
return options$
|
|
167
|
+
prop.value = options$7.value;
|
|
168
|
+
return options$7.value;
|
|
317
169
|
}
|
|
318
|
-
function populateObjectExpression(options$
|
|
170
|
+
function populateObjectExpression(options$7) {
|
|
319
171
|
const getExpression = (value, existingExpression) => {
|
|
320
172
|
let expression;
|
|
321
173
|
if (Array.isArray(value)) {
|
|
322
174
|
expression = create$1();
|
|
323
175
|
for (const v of value) append(expression, getExpression(v));
|
|
324
176
|
} else if (typeof value === "object" && value !== null) if (value.type !== void 0) expression = value;
|
|
325
|
-
else if (options$
|
|
177
|
+
else if (options$7.override && existingExpression && existingExpression.type === "ObjectExpression") expression = populateObjectExpression({
|
|
326
178
|
objectExpression: existingExpression,
|
|
327
179
|
properties: value,
|
|
328
|
-
override: options$
|
|
180
|
+
override: options$7.override
|
|
329
181
|
});
|
|
330
182
|
else expression = populateObjectExpression({
|
|
331
183
|
objectExpression: create({}),
|
|
332
184
|
properties: value,
|
|
333
|
-
override: options$
|
|
185
|
+
override: options$7.override
|
|
334
186
|
});
|
|
335
187
|
else expression = createLiteral(value);
|
|
336
188
|
return expression;
|
|
337
189
|
};
|
|
338
|
-
for (const [prop, value] of Object.entries(options$
|
|
190
|
+
for (const [prop, value] of Object.entries(options$7.properties)) {
|
|
339
191
|
if (value === void 0) continue;
|
|
340
|
-
if (options$
|
|
341
|
-
const existingProperty = options$
|
|
192
|
+
if (options$7.override) {
|
|
193
|
+
const existingProperty = options$7.objectExpression.properties.filter((x$1) => x$1.type === "Property").find((x$1) => x$1.key.name === prop);
|
|
342
194
|
const existingExpression = existingProperty?.value.type === "ObjectExpression" ? existingProperty.value : void 0;
|
|
343
|
-
overrideProperty(options$
|
|
195
|
+
overrideProperty(options$7.objectExpression, {
|
|
344
196
|
name: prop,
|
|
345
197
|
value: getExpression(value, existingExpression)
|
|
346
198
|
});
|
|
347
|
-
} else property(options$
|
|
199
|
+
} else property(options$7.objectExpression, {
|
|
348
200
|
name: prop,
|
|
349
201
|
fallback: getExpression(value)
|
|
350
202
|
});
|
|
351
203
|
}
|
|
352
|
-
return options$
|
|
204
|
+
return options$7.objectExpression;
|
|
353
205
|
}
|
|
354
206
|
|
|
355
207
|
//#endregion
|
|
356
208
|
//#region ../core/tooling/js/function.ts
|
|
357
|
-
function createCall(options$
|
|
209
|
+
function createCall(options$7) {
|
|
358
210
|
const callExpression = {
|
|
359
211
|
type: "CallExpression",
|
|
360
212
|
callee: {
|
|
361
213
|
type: "Identifier",
|
|
362
|
-
name: options$
|
|
214
|
+
name: options$7.name
|
|
363
215
|
},
|
|
364
216
|
arguments: [],
|
|
365
217
|
optional: false
|
|
366
218
|
};
|
|
367
|
-
for (const arg of options$
|
|
219
|
+
for (const arg of options$7.args) {
|
|
368
220
|
let argNode;
|
|
369
|
-
if (options$
|
|
221
|
+
if (options$7.useIdentifiers) argNode = {
|
|
370
222
|
type: "Identifier",
|
|
371
223
|
name: arg
|
|
372
224
|
};
|
|
@@ -378,20 +230,20 @@ function createCall(options$6) {
|
|
|
378
230
|
}
|
|
379
231
|
return callExpression;
|
|
380
232
|
}
|
|
381
|
-
function getArgument(node, options$
|
|
382
|
-
if (options$
|
|
383
|
-
node.arguments.push(options$
|
|
384
|
-
return options$
|
|
233
|
+
function getArgument(node, options$7) {
|
|
234
|
+
if (options$7.index < node.arguments.length) return node.arguments[options$7.index];
|
|
235
|
+
node.arguments.push(options$7.fallback);
|
|
236
|
+
return options$7.fallback;
|
|
385
237
|
}
|
|
386
238
|
|
|
387
239
|
//#endregion
|
|
388
240
|
//#region ../core/tooling/js/imports.ts
|
|
389
|
-
function addEmpty(node, options$
|
|
241
|
+
function addEmpty(node, options$7) {
|
|
390
242
|
const expectedImportDeclaration = {
|
|
391
243
|
type: "ImportDeclaration",
|
|
392
244
|
source: {
|
|
393
245
|
type: "Literal",
|
|
394
|
-
value: options$
|
|
246
|
+
value: options$7.from
|
|
395
247
|
},
|
|
396
248
|
specifiers: [],
|
|
397
249
|
attributes: [],
|
|
@@ -399,37 +251,37 @@ function addEmpty(node, options$6) {
|
|
|
399
251
|
};
|
|
400
252
|
addImportIfNecessary(node, expectedImportDeclaration);
|
|
401
253
|
}
|
|
402
|
-
function addNamespace(node, options$
|
|
254
|
+
function addNamespace(node, options$7) {
|
|
403
255
|
const expectedImportDeclaration = {
|
|
404
256
|
type: "ImportDeclaration",
|
|
405
257
|
importKind: "value",
|
|
406
258
|
source: {
|
|
407
259
|
type: "Literal",
|
|
408
|
-
value: options$
|
|
260
|
+
value: options$7.from
|
|
409
261
|
},
|
|
410
262
|
specifiers: [{
|
|
411
263
|
type: "ImportNamespaceSpecifier",
|
|
412
264
|
local: {
|
|
413
265
|
type: "Identifier",
|
|
414
|
-
name: options$
|
|
266
|
+
name: options$7.as
|
|
415
267
|
}
|
|
416
268
|
}],
|
|
417
269
|
attributes: []
|
|
418
270
|
};
|
|
419
271
|
addImportIfNecessary(node, expectedImportDeclaration);
|
|
420
272
|
}
|
|
421
|
-
function addDefault(node, options$
|
|
273
|
+
function addDefault(node, options$7) {
|
|
422
274
|
const expectedImportDeclaration = {
|
|
423
275
|
type: "ImportDeclaration",
|
|
424
276
|
source: {
|
|
425
277
|
type: "Literal",
|
|
426
|
-
value: options$
|
|
278
|
+
value: options$7.from
|
|
427
279
|
},
|
|
428
280
|
specifiers: [{
|
|
429
281
|
type: "ImportDefaultSpecifier",
|
|
430
282
|
local: {
|
|
431
283
|
type: "Identifier",
|
|
432
|
-
name: options$
|
|
284
|
+
name: options$7.as
|
|
433
285
|
}
|
|
434
286
|
}],
|
|
435
287
|
attributes: [],
|
|
@@ -437,8 +289,8 @@ function addDefault(node, options$6) {
|
|
|
437
289
|
};
|
|
438
290
|
addImportIfNecessary(node, expectedImportDeclaration);
|
|
439
291
|
}
|
|
440
|
-
function addNamed(node, options$
|
|
441
|
-
const o_imports = Array.isArray(options$
|
|
292
|
+
function addNamed(node, options$7) {
|
|
293
|
+
const o_imports = Array.isArray(options$7.imports) ? Object.fromEntries(options$7.imports.map((n) => [n, n])) : options$7.imports;
|
|
442
294
|
const specifiers = Object.entries(o_imports).map(([key, value]) => {
|
|
443
295
|
return {
|
|
444
296
|
type: "ImportSpecifier",
|
|
@@ -454,7 +306,7 @@ function addNamed(node, options$6) {
|
|
|
454
306
|
});
|
|
455
307
|
let importDecl;
|
|
456
308
|
walk(node, null, { ImportDeclaration(declaration$1) {
|
|
457
|
-
if (declaration$1.source.value === options$
|
|
309
|
+
if (declaration$1.source.value === options$7.from && declaration$1.specifiers) importDecl = declaration$1;
|
|
458
310
|
} });
|
|
459
311
|
if (importDecl) {
|
|
460
312
|
specifiers.forEach((specifierToAdd) => {
|
|
@@ -466,23 +318,23 @@ function addNamed(node, options$6) {
|
|
|
466
318
|
type: "ImportDeclaration",
|
|
467
319
|
source: {
|
|
468
320
|
type: "Literal",
|
|
469
|
-
value: options$
|
|
321
|
+
value: options$7.from
|
|
470
322
|
},
|
|
471
323
|
specifiers,
|
|
472
324
|
attributes: [],
|
|
473
|
-
importKind: options$
|
|
325
|
+
importKind: options$7.isType ? "type" : "value"
|
|
474
326
|
};
|
|
475
327
|
node.body.unshift(expectedImportDeclaration);
|
|
476
328
|
}
|
|
477
329
|
function addImportIfNecessary(node, expectedImportDeclaration) {
|
|
478
330
|
if (!node.body.filter((item) => item.type === "ImportDeclaration").find((item) => areNodesEqual(item, expectedImportDeclaration))) node.body.unshift(expectedImportDeclaration);
|
|
479
331
|
}
|
|
480
|
-
function find(ast, options$
|
|
481
|
-
let alias = options$
|
|
332
|
+
function find(ast, options$7) {
|
|
333
|
+
let alias = options$7.name;
|
|
482
334
|
let statement;
|
|
483
335
|
walk(ast, null, { ImportDeclaration(node) {
|
|
484
|
-
if (node.specifiers && node.source.value === options$
|
|
485
|
-
const specifier = node.specifiers.find((sp) => sp.type === "ImportSpecifier" && sp.imported.type === "Identifier" && sp.imported.name === options$
|
|
336
|
+
if (node.specifiers && node.source.value === options$7.from) {
|
|
337
|
+
const specifier = node.specifiers.find((sp) => sp.type === "ImportSpecifier" && sp.imported.type === "Identifier" && sp.imported.name === options$7.name);
|
|
486
338
|
if (specifier) {
|
|
487
339
|
statement = node;
|
|
488
340
|
alias = specifier.local?.name ?? alias;
|
|
@@ -499,38 +351,38 @@ function find(ast, options$6) {
|
|
|
499
351
|
alias: void 0
|
|
500
352
|
};
|
|
501
353
|
}
|
|
502
|
-
function remove(ast, options$
|
|
503
|
-
const statement = options$
|
|
504
|
-
name: options$
|
|
505
|
-
from: options$
|
|
354
|
+
function remove(ast, options$7) {
|
|
355
|
+
const statement = options$7.statement ?? find(ast, {
|
|
356
|
+
name: options$7.name,
|
|
357
|
+
from: options$7.from
|
|
506
358
|
}).statement;
|
|
507
359
|
if (!statement) return;
|
|
508
360
|
if (statement.specifiers?.length === 1) {
|
|
509
361
|
const idxToRemove = ast.body.indexOf(statement);
|
|
510
362
|
ast.body.splice(idxToRemove, 1);
|
|
511
363
|
} else {
|
|
512
|
-
const idxToRemove = statement.specifiers?.findIndex((s) => s.type === "ImportSpecifier" && s.imported.type === "Identifier" && s.imported.name === options$
|
|
364
|
+
const idxToRemove = statement.specifiers?.findIndex((s) => s.type === "ImportSpecifier" && s.imported.type === "Identifier" && s.imported.name === options$7.name);
|
|
513
365
|
if (idxToRemove !== void 0 && idxToRemove !== -1) statement.specifiers?.splice(idxToRemove, 1);
|
|
514
366
|
}
|
|
515
367
|
}
|
|
516
368
|
|
|
517
369
|
//#endregion
|
|
518
370
|
//#region ../core/tooling/js/variables.ts
|
|
519
|
-
function declaration(node, options$
|
|
371
|
+
function declaration(node, options$7) {
|
|
520
372
|
let declaration$1 = (node.type === "Program" ? node.body.filter((x$1) => x$1.type === "VariableDeclaration") : [node]).find((x$1) => {
|
|
521
|
-
return x$1.declarations[0].id.name === options$
|
|
373
|
+
return x$1.declarations[0].id.name === options$7.name;
|
|
522
374
|
});
|
|
523
375
|
if (declaration$1) return declaration$1;
|
|
524
376
|
declaration$1 = {
|
|
525
377
|
type: "VariableDeclaration",
|
|
526
|
-
kind: options$
|
|
378
|
+
kind: options$7.kind,
|
|
527
379
|
declarations: [{
|
|
528
380
|
type: "VariableDeclarator",
|
|
529
381
|
id: {
|
|
530
382
|
type: "Identifier",
|
|
531
|
-
name: options$
|
|
383
|
+
name: options$7.name
|
|
532
384
|
},
|
|
533
|
-
init: options$
|
|
385
|
+
init: options$7.value
|
|
534
386
|
}]
|
|
535
387
|
};
|
|
536
388
|
return declaration$1;
|
|
@@ -541,14 +393,14 @@ function createIdentifier(name) {
|
|
|
541
393
|
name
|
|
542
394
|
};
|
|
543
395
|
}
|
|
544
|
-
function typeAnnotateDeclarator(node, options$
|
|
396
|
+
function typeAnnotateDeclarator(node, options$7) {
|
|
545
397
|
if (node.id.type === "Identifier") node.id.typeAnnotation = {
|
|
546
398
|
type: "TSTypeAnnotation",
|
|
547
399
|
typeAnnotation: {
|
|
548
400
|
type: "TSTypeReference",
|
|
549
401
|
typeName: {
|
|
550
402
|
type: "Identifier",
|
|
551
|
-
name: options$
|
|
403
|
+
name: options$7.typeName
|
|
552
404
|
}
|
|
553
405
|
}
|
|
554
406
|
};
|
|
@@ -557,17 +409,17 @@ function typeAnnotateDeclarator(node, options$6) {
|
|
|
557
409
|
|
|
558
410
|
//#endregion
|
|
559
411
|
//#region ../core/tooling/js/exports.ts
|
|
560
|
-
function createDefault(node, options$
|
|
412
|
+
function createDefault(node, options$7) {
|
|
561
413
|
const existingNode = node.body.find((item) => item.type === "ExportDefaultDeclaration");
|
|
562
414
|
if (!existingNode) {
|
|
563
415
|
const exportNode = {
|
|
564
416
|
type: "ExportDefaultDeclaration",
|
|
565
|
-
declaration: options$
|
|
417
|
+
declaration: options$7.fallback
|
|
566
418
|
};
|
|
567
419
|
node.body.push(exportNode);
|
|
568
420
|
return {
|
|
569
421
|
astNode: exportNode,
|
|
570
|
-
value: options$
|
|
422
|
+
value: options$7.fallback,
|
|
571
423
|
isFallback: true
|
|
572
424
|
};
|
|
573
425
|
}
|
|
@@ -596,14 +448,14 @@ function createDefault(node, options$6) {
|
|
|
596
448
|
isFallback: false
|
|
597
449
|
};
|
|
598
450
|
}
|
|
599
|
-
function createNamed(node, options$
|
|
451
|
+
function createNamed(node, options$7) {
|
|
600
452
|
let namedExport = node.body.filter((item) => item.type === "ExportNamedDeclaration").find((exportNode) => {
|
|
601
|
-
return exportNode.declaration.declarations[0].id.name === options$
|
|
453
|
+
return exportNode.declaration.declarations[0].id.name === options$7.name;
|
|
602
454
|
});
|
|
603
455
|
if (namedExport) return namedExport;
|
|
604
456
|
namedExport = {
|
|
605
457
|
type: "ExportNamedDeclaration",
|
|
606
|
-
declaration: options$
|
|
458
|
+
declaration: options$7.fallback,
|
|
607
459
|
specifiers: [],
|
|
608
460
|
attributes: []
|
|
609
461
|
};
|
|
@@ -613,7 +465,7 @@ function createNamed(node, options$6) {
|
|
|
613
465
|
|
|
614
466
|
//#endregion
|
|
615
467
|
//#region ../core/tooling/js/kit.ts
|
|
616
|
-
function addGlobalAppInterface(node, options$
|
|
468
|
+
function addGlobalAppInterface(node, options$7) {
|
|
617
469
|
let globalDecl = node.body.filter((n) => n.type === "TSModuleDeclaration").find((m) => m.global && m.declare);
|
|
618
470
|
if (!globalDecl) {
|
|
619
471
|
globalDecl = parseFromString("declare global {}");
|
|
@@ -628,7 +480,7 @@ function addGlobalAppInterface(node, options$6) {
|
|
|
628
480
|
next();
|
|
629
481
|
},
|
|
630
482
|
TSInterfaceDeclaration(node$1) {
|
|
631
|
-
if (node$1.id.type === "Identifier" && node$1.id.name === options$
|
|
483
|
+
if (node$1.id.type === "Identifier" && node$1.id.name === options$7.name) interfaceNode = node$1;
|
|
632
484
|
}
|
|
633
485
|
});
|
|
634
486
|
if (!app) {
|
|
@@ -637,13 +489,13 @@ function addGlobalAppInterface(node, options$6) {
|
|
|
637
489
|
}
|
|
638
490
|
if (app.body?.type !== "TSModuleBlock") throw new Error("Unexpected body type of `namespace App` in `src/app.d.ts`");
|
|
639
491
|
if (!interfaceNode) {
|
|
640
|
-
interfaceNode = parseFromString(`interface ${options$
|
|
492
|
+
interfaceNode = parseFromString(`interface ${options$7.name} {}`);
|
|
641
493
|
app.body.body.push(interfaceNode);
|
|
642
494
|
}
|
|
643
495
|
return interfaceNode;
|
|
644
496
|
}
|
|
645
|
-
function addHooksHandle(node, options$
|
|
646
|
-
if (options$
|
|
497
|
+
function addHooksHandle(node, options$7) {
|
|
498
|
+
if (options$7.typescript) addNamed(node, {
|
|
647
499
|
from: "@sveltejs/kit",
|
|
648
500
|
imports: { Handle: "Handle" },
|
|
649
501
|
isType: true
|
|
@@ -672,15 +524,15 @@ function addHooksHandle(node, options$6) {
|
|
|
672
524
|
originalHandleDecl = maybeHandleDecl;
|
|
673
525
|
}
|
|
674
526
|
} });
|
|
675
|
-
const newHandle = parseExpression(options$
|
|
527
|
+
const newHandle = parseExpression(options$7.handleContent);
|
|
676
528
|
if (contains(node, newHandle)) return;
|
|
677
529
|
if (!originalHandleDecl || !exportDecl) {
|
|
678
530
|
const newHandleDecl$1 = declaration(node, {
|
|
679
531
|
kind: "const",
|
|
680
|
-
name: options$
|
|
532
|
+
name: options$7.newHandleName,
|
|
681
533
|
value: newHandle
|
|
682
534
|
});
|
|
683
|
-
if (options$
|
|
535
|
+
if (options$7.typescript) {
|
|
684
536
|
const declarator = newHandleDecl$1.declarations[0];
|
|
685
537
|
typeAnnotateDeclarator(declarator, { typeName: "Handle" });
|
|
686
538
|
}
|
|
@@ -688,9 +540,9 @@ function addHooksHandle(node, options$6) {
|
|
|
688
540
|
const handleDecl = declaration(node, {
|
|
689
541
|
kind: "const",
|
|
690
542
|
name: handleName,
|
|
691
|
-
value: createIdentifier(options$
|
|
543
|
+
value: createIdentifier(options$7.newHandleName)
|
|
692
544
|
});
|
|
693
|
-
if (options$
|
|
545
|
+
if (options$7.typescript) {
|
|
694
546
|
const declarator = handleDecl.declarations[0];
|
|
695
547
|
typeAnnotateDeclarator(declarator, { typeName: "Handle" });
|
|
696
548
|
}
|
|
@@ -702,17 +554,17 @@ function addHooksHandle(node, options$6) {
|
|
|
702
554
|
}
|
|
703
555
|
const newHandleDecl = declaration(node, {
|
|
704
556
|
kind: "const",
|
|
705
|
-
name: options$
|
|
557
|
+
name: options$7.newHandleName,
|
|
706
558
|
value: newHandle
|
|
707
559
|
});
|
|
708
|
-
if (options$
|
|
560
|
+
if (options$7.typescript) {
|
|
709
561
|
const declarator = newHandleDecl.declarations[0];
|
|
710
562
|
typeAnnotateDeclarator(declarator, { typeName: "Handle" });
|
|
711
563
|
}
|
|
712
564
|
let sequence;
|
|
713
565
|
if (originalHandleDecl.type === "VariableDeclaration") sequence = originalHandleDecl.declarations.find((declarator) => declarator.type === "VariableDeclarator" && usingSequence(declarator, handleName))?.init;
|
|
714
566
|
if (sequence) {
|
|
715
|
-
if (!sequence.arguments.some((arg) => arg.type === "Identifier" && arg.name === options$
|
|
567
|
+
if (!sequence.arguments.some((arg) => arg.type === "Identifier" && arg.name === options$7.newHandleName)) sequence.arguments.push(createIdentifier(options$7.newHandleName));
|
|
716
568
|
node.body = node.body.filter((item) => item !== originalHandleDecl && item !== exportDecl && item !== newHandleDecl);
|
|
717
569
|
if (isSpecifier) node.body.push(newHandleDecl, originalHandleDecl, exportDecl);
|
|
718
570
|
else node.body.push(newHandleDecl, exportDecl);
|
|
@@ -720,7 +572,7 @@ function addHooksHandle(node, options$6) {
|
|
|
720
572
|
const NEW_HANDLE_NAME = "originalHandle";
|
|
721
573
|
const sequenceCall = createCall({
|
|
722
574
|
name: "sequence",
|
|
723
|
-
args: [NEW_HANDLE_NAME, options$
|
|
575
|
+
args: [NEW_HANDLE_NAME, options$7.newHandleName],
|
|
724
576
|
useIdentifiers: true
|
|
725
577
|
});
|
|
726
578
|
const finalHandleDecl = declaration(node, {
|
|
@@ -756,7 +608,7 @@ function addHooksHandle(node, options$6) {
|
|
|
756
608
|
const variableDeclarator = getVariableDeclarator(originalHandleDecl, handleName);
|
|
757
609
|
const sequenceCall$1 = createCall({
|
|
758
610
|
name: "sequence",
|
|
759
|
-
args: [(variableDeclarator?.init).name, options$
|
|
611
|
+
args: [(variableDeclarator?.init).name, options$7.newHandleName],
|
|
760
612
|
useIdentifiers: true
|
|
761
613
|
});
|
|
762
614
|
const finalHandleDecl$1 = declaration(node, {
|
|
@@ -764,7 +616,7 @@ function addHooksHandle(node, options$6) {
|
|
|
764
616
|
name: handleName,
|
|
765
617
|
value: sequenceCall$1
|
|
766
618
|
});
|
|
767
|
-
if (options$
|
|
619
|
+
if (options$7.typescript) {
|
|
768
620
|
const declarator = finalHandleDecl$1.declarations[0];
|
|
769
621
|
typeAnnotateDeclarator(declarator, { typeName: "Handle" });
|
|
770
622
|
}
|
|
@@ -797,13 +649,13 @@ function isConfigWrapper(callExpression, knownWrappers) {
|
|
|
797
649
|
const isObjectCall = callExpression.arguments.length === 1 && callExpression.arguments[0]?.type === "ObjectExpression";
|
|
798
650
|
return knownWrappers.includes(calleeName) || isObjectCall;
|
|
799
651
|
}
|
|
800
|
-
function exportDefaultConfig(ast, options$
|
|
801
|
-
const { fallback, ignoreWrapper } = options$
|
|
652
|
+
function exportDefaultConfig(ast, options$7) {
|
|
653
|
+
const { fallback, ignoreWrapper } = options$7;
|
|
802
654
|
let fallbackExpression;
|
|
803
655
|
if (fallback) fallbackExpression = typeof fallback.code === "string" ? parseExpression(fallback.code) : fallback.code;
|
|
804
656
|
else fallbackExpression = create({});
|
|
805
657
|
const { value, isFallback } = createDefault(ast, { fallback: fallbackExpression });
|
|
806
|
-
if (isFallback) options$
|
|
658
|
+
if (isFallback) options$7.fallback?.additional?.(ast);
|
|
807
659
|
const rootObject = value.type === "TSSatisfiesExpression" ? value.expression : value;
|
|
808
660
|
let configObject;
|
|
809
661
|
if (!("arguments" in rootObject) || !Array.isArray(rootObject.arguments)) {
|
|
@@ -845,8 +697,8 @@ function exportDefaultConfig(ast, options$6) {
|
|
|
845
697
|
else configObject = create({});
|
|
846
698
|
return configObject;
|
|
847
699
|
}
|
|
848
|
-
function addInArrayOfObject(ast, options$
|
|
849
|
-
const { code, arrayProperty, mode = "append" } = options$
|
|
700
|
+
function addInArrayOfObject(ast, options$7) {
|
|
701
|
+
const { code, arrayProperty, mode = "append" } = options$7;
|
|
850
702
|
const targetArray = property(ast, {
|
|
851
703
|
name: arrayProperty,
|
|
852
704
|
fallback: create$1()
|
|
@@ -855,11 +707,11 @@ function addInArrayOfObject(ast, options$6) {
|
|
|
855
707
|
if (mode === "prepend") prepend(targetArray, expression);
|
|
856
708
|
else append(targetArray, expression);
|
|
857
709
|
}
|
|
858
|
-
const addPlugin = (ast, options$
|
|
710
|
+
const addPlugin = (ast, options$7) => {
|
|
859
711
|
const configObject = getConfig(ast);
|
|
860
712
|
addInArrayOfObject(configObject, {
|
|
861
713
|
arrayProperty: "plugins",
|
|
862
|
-
...options$
|
|
714
|
+
...options$7
|
|
863
715
|
});
|
|
864
716
|
};
|
|
865
717
|
const getConfig = (ast) => {
|
|
@@ -958,7 +810,7 @@ const PORTS = {
|
|
|
958
810
|
postgresql: "5432",
|
|
959
811
|
sqlite: ""
|
|
960
812
|
};
|
|
961
|
-
const options$
|
|
813
|
+
const options$6 = defineAddonOptions().add("database", {
|
|
962
814
|
question: "Which database would you like to use?",
|
|
963
815
|
type: "select",
|
|
964
816
|
default: "sqlite",
|
|
@@ -1037,45 +889,58 @@ var drizzle_default = defineAddon({
|
|
|
1037
889
|
id: "drizzle",
|
|
1038
890
|
shortDescription: "database orm",
|
|
1039
891
|
homepage: "https://orm.drizzle.team",
|
|
1040
|
-
options: options$
|
|
1041
|
-
setup: ({ kit, unsupported, runsAfter
|
|
892
|
+
options: options$6,
|
|
893
|
+
setup: ({ kit, unsupported, runsAfter }) => {
|
|
1042
894
|
runsAfter("prettier");
|
|
1043
|
-
const ext = typescript ? "ts" : "js";
|
|
1044
895
|
if (!kit) return unsupported("Requires SvelteKit");
|
|
1045
|
-
const baseDBPath = path.resolve(kit.libDirectory, "server", "db");
|
|
1046
|
-
const paths = {
|
|
1047
|
-
"drizzle config": path.relative(cwd, path.resolve(cwd, `drizzle.config.${ext}`)),
|
|
1048
|
-
"database schema": path.relative(cwd, path.resolve(baseDBPath, `schema.${ext}`)),
|
|
1049
|
-
database: path.relative(cwd, path.resolve(baseDBPath, `index.${ext}`))
|
|
1050
|
-
};
|
|
1051
|
-
for (const [fileType, filePath] of Object.entries(paths)) if (fs.existsSync(filePath)) unsupported(`Preexisting ${fileType} file at '${filePath}'`);
|
|
1052
896
|
},
|
|
1053
|
-
run: ({ sv, typescript, options: options$
|
|
897
|
+
run: ({ sv, typescript, options: options$7, kit, dependencyVersion, cwd, cancel }) => {
|
|
898
|
+
if (!kit) throw new Error("SvelteKit is required");
|
|
1054
899
|
const ext = typescript ? "ts" : "js";
|
|
900
|
+
const baseDBPath = path.resolve(cwd, kit.libDirectory, "server", "db");
|
|
901
|
+
const paths = {
|
|
902
|
+
"drizzle config": path.resolve(cwd, `drizzle.config.${ext}`),
|
|
903
|
+
"database schema": path.resolve(baseDBPath, `schema.${ext}`),
|
|
904
|
+
database: path.resolve(baseDBPath, `index.${ext}`)
|
|
905
|
+
};
|
|
906
|
+
for (const [fileType, filePath] of Object.entries(paths)) if (fs.existsSync(filePath)) return cancel(`Preexisting ${fileType} file at '${filePath}'`);
|
|
907
|
+
console.log(`no preexisting files`);
|
|
1055
908
|
sv.devDependency("drizzle-orm", "^0.44.5");
|
|
1056
909
|
sv.devDependency("drizzle-kit", "^0.31.4");
|
|
1057
910
|
sv.devDependency("@types/node", getNodeTypesVersion());
|
|
1058
|
-
if (options$
|
|
1059
|
-
if (options$
|
|
1060
|
-
if (options$
|
|
1061
|
-
if (options$
|
|
1062
|
-
if (options$
|
|
911
|
+
if (options$7.mysql === "mysql2") sv.dependency("mysql2", "^3.15.0");
|
|
912
|
+
if (options$7.mysql === "planetscale") sv.dependency("@planetscale/database", "^1.19.0");
|
|
913
|
+
if (options$7.postgresql === "neon") sv.dependency("@neondatabase/serverless", "^1.0.1");
|
|
914
|
+
if (options$7.postgresql === "postgres.js") sv.dependency("postgres", "^3.4.7");
|
|
915
|
+
if (options$7.sqlite === "better-sqlite3") {
|
|
1063
916
|
sv.dependency("better-sqlite3", "^12.4.1");
|
|
1064
917
|
sv.devDependency("@types/better-sqlite3", "^7.6.13");
|
|
1065
918
|
sv.pnpmBuildDependency("better-sqlite3");
|
|
1066
919
|
}
|
|
1067
|
-
if (options$
|
|
1068
|
-
sv.file(".env", (content) => generateEnvFileContent(content, options$
|
|
1069
|
-
sv.file(".env.example", (content) => generateEnvFileContent(content, options$
|
|
1070
|
-
if (options$
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
920
|
+
if (options$7.sqlite === "libsql" || options$7.sqlite === "turso") sv.devDependency("@libsql/client", "^0.15.15");
|
|
921
|
+
sv.file(".env", (content) => generateEnvFileContent(content, options$7));
|
|
922
|
+
sv.file(".env.example", (content) => generateEnvFileContent(content, options$7));
|
|
923
|
+
if (options$7.docker && (options$7.mysql === "mysql2" || options$7.postgresql === "postgres.js")) {
|
|
924
|
+
const composeFileOptions = [
|
|
925
|
+
"docker-compose.yml",
|
|
926
|
+
"docker-compose.yaml",
|
|
927
|
+
"compose.yaml"
|
|
928
|
+
];
|
|
929
|
+
let composeFile = "";
|
|
930
|
+
for (const option of composeFileOptions) {
|
|
931
|
+
composeFile = option;
|
|
932
|
+
if (fs.existsSync(path.resolve(cwd, option))) break;
|
|
933
|
+
}
|
|
934
|
+
if (composeFile === "") throw new Error("unreachable state...");
|
|
935
|
+
sv.file(composeFile, (content) => {
|
|
936
|
+
if (content.length > 0) return content;
|
|
937
|
+
const imageName = options$7.database === "mysql" ? "mysql" : "postgres";
|
|
938
|
+
const port = PORTS[options$7.database];
|
|
939
|
+
const USER = "root";
|
|
940
|
+
const PASSWORD = "mysecretpassword";
|
|
941
|
+
const DB_NAME = "local";
|
|
942
|
+
let dbSpecificContent = "";
|
|
943
|
+
if (options$7.mysql === "mysql2") dbSpecificContent = `
|
|
1079
944
|
MYSQL_ROOT_PASSWORD: ${PASSWORD}
|
|
1080
945
|
MYSQL_DATABASE: ${DB_NAME}
|
|
1081
946
|
volumes:
|
|
@@ -1083,7 +948,7 @@ var drizzle_default = defineAddon({
|
|
|
1083
948
|
volumes:
|
|
1084
949
|
mysqldata:
|
|
1085
950
|
`;
|
|
1086
|
-
|
|
951
|
+
if (options$7.postgresql === "postgres.js") dbSpecificContent = `
|
|
1087
952
|
POSTGRES_USER: ${USER}
|
|
1088
953
|
POSTGRES_PASSWORD: ${PASSWORD}
|
|
1089
954
|
POSTGRES_DB: ${DB_NAME}
|
|
@@ -1092,7 +957,7 @@ var drizzle_default = defineAddon({
|
|
|
1092
957
|
volumes:
|
|
1093
958
|
pgdata:
|
|
1094
959
|
`;
|
|
1095
|
-
|
|
960
|
+
content = dedent_default`
|
|
1096
961
|
services:
|
|
1097
962
|
db:
|
|
1098
963
|
image: ${imageName}
|
|
@@ -1101,13 +966,14 @@ var drizzle_default = defineAddon({
|
|
|
1101
966
|
- ${port}:${port}
|
|
1102
967
|
environment: ${dbSpecificContent}
|
|
1103
968
|
`;
|
|
1104
|
-
|
|
1105
|
-
|
|
969
|
+
return content;
|
|
970
|
+
});
|
|
971
|
+
}
|
|
1106
972
|
sv.file("package.json", (content) => {
|
|
1107
973
|
const { data, generateCode } = parseJson(content);
|
|
1108
974
|
data.scripts ??= {};
|
|
1109
975
|
const scripts = data.scripts;
|
|
1110
|
-
if (options$
|
|
976
|
+
if (options$7.docker) scripts["db:start"] ??= "docker compose up";
|
|
1111
977
|
scripts["db:push"] ??= "drizzle-kit push";
|
|
1112
978
|
scripts["db:generate"] ??= "drizzle-kit generate";
|
|
1113
979
|
scripts["db:migrate"] ??= "drizzle-kit migrate";
|
|
@@ -1118,12 +984,12 @@ var drizzle_default = defineAddon({
|
|
|
1118
984
|
if (!content.includes(`/drizzle/`)) return content.trimEnd() + "\n/drizzle/";
|
|
1119
985
|
return content;
|
|
1120
986
|
});
|
|
1121
|
-
if (options$
|
|
987
|
+
if (options$7.database === "sqlite") sv.file(".gitignore", (content) => {
|
|
1122
988
|
if (content.length === 0) return content;
|
|
1123
989
|
if (!content.includes("\n*.db")) content = content.trimEnd() + "\n\n# SQLite\n*.db";
|
|
1124
990
|
return content;
|
|
1125
991
|
});
|
|
1126
|
-
sv.file(
|
|
992
|
+
sv.file(paths["drizzle config"], (content) => {
|
|
1127
993
|
const { ast, generateCode } = parseScript(content);
|
|
1128
994
|
addNamed(ast, {
|
|
1129
995
|
from: "drizzle-kit",
|
|
@@ -1133,9 +999,9 @@ var drizzle_default = defineAddon({
|
|
|
1133
999
|
createDefault(ast, { fallback: parseExpression(`
|
|
1134
1000
|
defineConfig({
|
|
1135
1001
|
schema: "./src/lib/server/db/schema.${typescript ? "ts" : "js"}",
|
|
1136
|
-
dialect: "${options$
|
|
1002
|
+
dialect: "${options$7.sqlite === "turso" ? "turso" : options$7.database}",
|
|
1137
1003
|
dbCredentials: {
|
|
1138
|
-
${options$
|
|
1004
|
+
${options$7.sqlite === "turso" ? "authToken: process.env.DATABASE_AUTH_TOKEN," : ""}
|
|
1139
1005
|
url: process.env.DATABASE_URL
|
|
1140
1006
|
},
|
|
1141
1007
|
verbose: true,
|
|
@@ -1143,20 +1009,24 @@ var drizzle_default = defineAddon({
|
|
|
1143
1009
|
})`) });
|
|
1144
1010
|
return generateCode();
|
|
1145
1011
|
});
|
|
1146
|
-
sv.file(
|
|
1012
|
+
sv.file(paths["database schema"], (content) => {
|
|
1147
1013
|
const { ast, generateCode } = parseScript(content);
|
|
1148
1014
|
let userSchemaExpression;
|
|
1149
|
-
if (options$
|
|
1015
|
+
if (options$7.database === "sqlite") {
|
|
1150
1016
|
addNamed(ast, {
|
|
1151
1017
|
from: "drizzle-orm/sqlite-core",
|
|
1152
|
-
imports: [
|
|
1018
|
+
imports: [
|
|
1019
|
+
"integer",
|
|
1020
|
+
"sqliteTable",
|
|
1021
|
+
"text"
|
|
1022
|
+
]
|
|
1153
1023
|
});
|
|
1154
1024
|
userSchemaExpression = parseExpression(`sqliteTable('user', {
|
|
1155
|
-
id:
|
|
1025
|
+
id: text('id').primaryKey().$defaultFn(() => crypto.randomUUID()),
|
|
1156
1026
|
age: integer('age')
|
|
1157
1027
|
})`);
|
|
1158
1028
|
}
|
|
1159
|
-
if (options$
|
|
1029
|
+
if (options$7.database === "mysql") {
|
|
1160
1030
|
addNamed(ast, {
|
|
1161
1031
|
from: "drizzle-orm/mysql-core",
|
|
1162
1032
|
imports: [
|
|
@@ -1170,7 +1040,7 @@ var drizzle_default = defineAddon({
|
|
|
1170
1040
|
age: int('age'),
|
|
1171
1041
|
})`);
|
|
1172
1042
|
}
|
|
1173
|
-
if (options$
|
|
1043
|
+
if (options$7.database === "postgresql") {
|
|
1174
1044
|
addNamed(ast, {
|
|
1175
1045
|
from: "drizzle-orm/pg-core",
|
|
1176
1046
|
imports: [
|
|
@@ -1196,7 +1066,7 @@ var drizzle_default = defineAddon({
|
|
|
1196
1066
|
});
|
|
1197
1067
|
return generateCode();
|
|
1198
1068
|
});
|
|
1199
|
-
sv.file(
|
|
1069
|
+
sv.file(paths["database"], (content) => {
|
|
1200
1070
|
const { ast, generateCode } = parseScript(content);
|
|
1201
1071
|
addNamed(ast, {
|
|
1202
1072
|
from: "$env/dynamic/private",
|
|
@@ -1209,7 +1079,7 @@ var drizzle_default = defineAddon({
|
|
|
1209
1079
|
const dbURLCheck = parseStatement("if (!env.DATABASE_URL) throw new Error('DATABASE_URL is not set');");
|
|
1210
1080
|
ast.body.push(dbURLCheck);
|
|
1211
1081
|
let clientExpression;
|
|
1212
|
-
if (options$
|
|
1082
|
+
if (options$7.sqlite === "better-sqlite3") {
|
|
1213
1083
|
addDefault(ast, {
|
|
1214
1084
|
from: "better-sqlite3",
|
|
1215
1085
|
as: "Database"
|
|
@@ -1220,7 +1090,7 @@ var drizzle_default = defineAddon({
|
|
|
1220
1090
|
});
|
|
1221
1091
|
clientExpression = parseExpression("new Database(env.DATABASE_URL)");
|
|
1222
1092
|
}
|
|
1223
|
-
if (options$
|
|
1093
|
+
if (options$7.sqlite === "libsql" || options$7.sqlite === "turso") {
|
|
1224
1094
|
addNamed(ast, {
|
|
1225
1095
|
from: "@libsql/client",
|
|
1226
1096
|
imports: ["createClient"]
|
|
@@ -1229,7 +1099,7 @@ var drizzle_default = defineAddon({
|
|
|
1229
1099
|
from: "drizzle-orm/libsql",
|
|
1230
1100
|
imports: ["drizzle"]
|
|
1231
1101
|
});
|
|
1232
|
-
if (options$
|
|
1102
|
+
if (options$7.sqlite === "turso") {
|
|
1233
1103
|
addNamed(ast, {
|
|
1234
1104
|
from: "$app/environment",
|
|
1235
1105
|
imports: ["dev"]
|
|
@@ -1239,7 +1109,7 @@ var drizzle_default = defineAddon({
|
|
|
1239
1109
|
clientExpression = parseExpression("createClient({ url: env.DATABASE_URL, authToken: env.DATABASE_AUTH_TOKEN })");
|
|
1240
1110
|
} else clientExpression = parseExpression("createClient({ url: env.DATABASE_URL })");
|
|
1241
1111
|
}
|
|
1242
|
-
if (options$
|
|
1112
|
+
if (options$7.mysql === "mysql2" || options$7.mysql === "planetscale") {
|
|
1243
1113
|
addDefault(ast, {
|
|
1244
1114
|
from: "mysql2/promise",
|
|
1245
1115
|
as: "mysql"
|
|
@@ -1250,7 +1120,7 @@ var drizzle_default = defineAddon({
|
|
|
1250
1120
|
});
|
|
1251
1121
|
clientExpression = parseExpression("mysql.createPool(env.DATABASE_URL)");
|
|
1252
1122
|
}
|
|
1253
|
-
if (options$
|
|
1123
|
+
if (options$7.postgresql === "neon") {
|
|
1254
1124
|
addNamed(ast, {
|
|
1255
1125
|
from: "@neondatabase/serverless",
|
|
1256
1126
|
imports: ["neon"]
|
|
@@ -1261,7 +1131,7 @@ var drizzle_default = defineAddon({
|
|
|
1261
1131
|
});
|
|
1262
1132
|
clientExpression = parseExpression("neon(env.DATABASE_URL)");
|
|
1263
1133
|
}
|
|
1264
|
-
if (options$
|
|
1134
|
+
if (options$7.postgresql === "postgres.js") {
|
|
1265
1135
|
addDefault(ast, {
|
|
1266
1136
|
from: "postgres",
|
|
1267
1137
|
as: "postgres"
|
|
@@ -1284,8 +1154,8 @@ var drizzle_default = defineAddon({
|
|
|
1284
1154
|
useIdentifiers: true
|
|
1285
1155
|
});
|
|
1286
1156
|
const paramObject = create({ schema: createIdentifier("schema") });
|
|
1287
|
-
if (options$
|
|
1288
|
-
const mode = options$
|
|
1157
|
+
if (options$7.database === "mysql") {
|
|
1158
|
+
const mode = options$7.mysql === "planetscale" ? "planetscale" : "default";
|
|
1289
1159
|
property(paramObject, {
|
|
1290
1160
|
name: "mode",
|
|
1291
1161
|
fallback: createLiteral(mode)
|
|
@@ -1304,9 +1174,9 @@ var drizzle_default = defineAddon({
|
|
|
1304
1174
|
return generateCode();
|
|
1305
1175
|
});
|
|
1306
1176
|
},
|
|
1307
|
-
nextSteps: ({ options: options$
|
|
1177
|
+
nextSteps: ({ options: options$7, highlighter, packageManager }) => {
|
|
1308
1178
|
const steps = [`You will need to set ${highlighter.env("DATABASE_URL")} in your production environment`];
|
|
1309
|
-
if (options$
|
|
1179
|
+
if (options$7.docker) {
|
|
1310
1180
|
const { command: command$1, args: args$1 } = resolveCommand(packageManager, "run", ["db:start"]);
|
|
1311
1181
|
steps.push(`Run ${highlighter.command(`${command$1} ${args$1.join(" ")}`)} to start the docker container`);
|
|
1312
1182
|
} else steps.push(`Check ${highlighter.env("DATABASE_URL")} in ${highlighter.path(".env")} and adjust it to your needs`);
|
|
@@ -1507,7 +1377,7 @@ const TABLE_TYPE = {
|
|
|
1507
1377
|
};
|
|
1508
1378
|
let drizzleDialect;
|
|
1509
1379
|
let schemaPath;
|
|
1510
|
-
const options$
|
|
1380
|
+
const options$5 = defineAddonOptions().add("demo", {
|
|
1511
1381
|
type: "boolean",
|
|
1512
1382
|
default: true,
|
|
1513
1383
|
question: `Do you want to include a demo? ${import_picocolors$2.default.dim("(includes a login/register page)")}`
|
|
@@ -1516,17 +1386,17 @@ var lucia_default = defineAddon({
|
|
|
1516
1386
|
id: "lucia",
|
|
1517
1387
|
shortDescription: "auth guide",
|
|
1518
1388
|
homepage: "https://lucia-auth.com",
|
|
1519
|
-
options: options$
|
|
1389
|
+
options: options$5,
|
|
1520
1390
|
setup: ({ kit, dependencyVersion, unsupported, dependsOn, runsAfter }) => {
|
|
1521
1391
|
if (!kit) unsupported("Requires SvelteKit");
|
|
1522
1392
|
if (!dependencyVersion("drizzle-orm")) dependsOn("drizzle");
|
|
1523
1393
|
runsAfter("tailwindcss");
|
|
1524
1394
|
},
|
|
1525
|
-
run: ({ sv, typescript, options: options$
|
|
1395
|
+
run: ({ sv, typescript, options: options$7, kit, dependencyVersion }) => {
|
|
1526
1396
|
const ext = typescript ? "ts" : "js";
|
|
1527
1397
|
sv.devDependency("@oslojs/crypto", "^1.0.1");
|
|
1528
1398
|
sv.devDependency("@oslojs/encoding", "^1.1.0");
|
|
1529
|
-
if (options$
|
|
1399
|
+
if (options$7.demo) sv.dependency("@node-rs/argon2", "^2.0.2");
|
|
1530
1400
|
sv.file(`drizzle.config.${ext}`, (content) => {
|
|
1531
1401
|
const { ast, generateCode } = parseScript(content);
|
|
1532
1402
|
const isProp = (name, node) => node.key.type === "Identifier" && node.key.name === name;
|
|
@@ -1580,7 +1450,7 @@ var lucia_default = defineAddon({
|
|
|
1580
1450
|
]
|
|
1581
1451
|
});
|
|
1582
1452
|
overrideProperties(userAttributes, { id: parseExpression("text('id').primaryKey()") });
|
|
1583
|
-
if (options$
|
|
1453
|
+
if (options$7.demo) overrideProperties(userAttributes, {
|
|
1584
1454
|
username: parseExpression("text('username').notNull().unique()"),
|
|
1585
1455
|
passwordHash: parseExpression("text('password_hash').notNull()")
|
|
1586
1456
|
});
|
|
@@ -1600,7 +1470,7 @@ var lucia_default = defineAddon({
|
|
|
1600
1470
|
]
|
|
1601
1471
|
});
|
|
1602
1472
|
overrideProperties(userAttributes, { id: parseExpression("varchar('id', { length: 255 }).primaryKey()") });
|
|
1603
|
-
if (options$
|
|
1473
|
+
if (options$7.demo) overrideProperties(userAttributes, {
|
|
1604
1474
|
username: parseExpression("varchar('username', { length: 32 }).notNull().unique()"),
|
|
1605
1475
|
passwordHash: parseExpression("varchar('password_hash', { length: 255 }).notNull()")
|
|
1606
1476
|
});
|
|
@@ -1620,7 +1490,7 @@ var lucia_default = defineAddon({
|
|
|
1620
1490
|
]
|
|
1621
1491
|
});
|
|
1622
1492
|
overrideProperties(userAttributes, { id: parseExpression("text('id').primaryKey()") });
|
|
1623
|
-
if (options$
|
|
1493
|
+
if (options$7.demo) overrideProperties(userAttributes, {
|
|
1624
1494
|
username: parseExpression("text('username').notNull().unique()"),
|
|
1625
1495
|
passwordHash: parseExpression("text('password_hash').notNull()")
|
|
1626
1496
|
});
|
|
@@ -1793,7 +1663,7 @@ var lucia_default = defineAddon({
|
|
|
1793
1663
|
});
|
|
1794
1664
|
return generateCode();
|
|
1795
1665
|
});
|
|
1796
|
-
if (options$
|
|
1666
|
+
if (options$7.demo) {
|
|
1797
1667
|
sv.file(`${kit?.routesDirectory}/demo/+page.svelte`, (content) => {
|
|
1798
1668
|
return addToDemoPage(content, "lucia");
|
|
1799
1669
|
});
|
|
@@ -2027,10 +1897,10 @@ var lucia_default = defineAddon({
|
|
|
2027
1897
|
});
|
|
2028
1898
|
}
|
|
2029
1899
|
},
|
|
2030
|
-
nextSteps: ({ highlighter, options: options$
|
|
1900
|
+
nextSteps: ({ highlighter, options: options$7, packageManager }) => {
|
|
2031
1901
|
const { command, args } = resolveCommand(packageManager, "run", ["db:push"]);
|
|
2032
1902
|
const steps = [`Run ${highlighter.command(`${command} ${args.join(" ")}`)} to update your database schema`];
|
|
2033
|
-
if (options$
|
|
1903
|
+
if (options$7.demo) steps.push(`Visit ${highlighter.route("/demo/lucia")} route to view the demo`);
|
|
2034
1904
|
return steps;
|
|
2035
1905
|
}
|
|
2036
1906
|
});
|
|
@@ -2155,14 +2025,14 @@ function addFromRawHtml(childNodes, html) {
|
|
|
2155
2025
|
const document = parseHtml$1(html);
|
|
2156
2026
|
for (const childNode of document.childNodes) childNodes.push(childNode);
|
|
2157
2027
|
}
|
|
2158
|
-
function addSlot(jsAst, options$
|
|
2159
|
-
if (options$
|
|
2028
|
+
function addSlot(jsAst, options$7) {
|
|
2029
|
+
if (options$7.svelteVersion && (options$7.svelteVersion.startsWith("4") || options$7.svelteVersion.startsWith("3"))) {
|
|
2160
2030
|
const slot = createElement("slot");
|
|
2161
|
-
appendElement(options$
|
|
2031
|
+
appendElement(options$7.htmlAst.childNodes, slot);
|
|
2162
2032
|
return;
|
|
2163
2033
|
}
|
|
2164
2034
|
appendFromString(jsAst, { code: "let { children } = $props();" });
|
|
2165
|
-
addFromRawHtml(options$
|
|
2035
|
+
addFromRawHtml(options$7.htmlAst.childNodes, "{@render children()}");
|
|
2166
2036
|
}
|
|
2167
2037
|
|
|
2168
2038
|
//#endregion
|
|
@@ -2172,7 +2042,7 @@ const DEFAULT_INLANG_PROJECT = {
|
|
|
2172
2042
|
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"],
|
|
2173
2043
|
"plugin.inlang.messageFormat": { pathPattern: "./messages/{locale}.json" }
|
|
2174
2044
|
};
|
|
2175
|
-
const options$
|
|
2045
|
+
const options$4 = defineAddonOptions().add("languageTags", {
|
|
2176
2046
|
question: `Which languages would you like to support? ${import_picocolors$2.default.gray("(e.g. en,de-ch)")}`,
|
|
2177
2047
|
type: "string",
|
|
2178
2048
|
default: "en, es",
|
|
@@ -2195,11 +2065,11 @@ var paraglide_default = defineAddon({
|
|
|
2195
2065
|
id: "paraglide",
|
|
2196
2066
|
shortDescription: "i18n",
|
|
2197
2067
|
homepage: "https://inlang.com/m/gerre34r/library-inlang-paraglideJs",
|
|
2198
|
-
options: options$
|
|
2068
|
+
options: options$4,
|
|
2199
2069
|
setup: ({ kit, unsupported }) => {
|
|
2200
2070
|
if (!kit) unsupported("Requires SvelteKit");
|
|
2201
2071
|
},
|
|
2202
|
-
run: ({ sv, options: options$
|
|
2072
|
+
run: ({ sv, options: options$7, viteConfigFile, typescript, kit }) => {
|
|
2203
2073
|
const ext = typescript ? "ts" : "js";
|
|
2204
2074
|
if (!kit) throw new Error("SvelteKit is required");
|
|
2205
2075
|
const paraglideOutDir = "src/lib/paraglide";
|
|
@@ -2208,7 +2078,7 @@ var paraglide_default = defineAddon({
|
|
|
2208
2078
|
if (content) return content;
|
|
2209
2079
|
const { data, generateCode } = parseJson(content);
|
|
2210
2080
|
for (const key in DEFAULT_INLANG_PROJECT) data[key] = DEFAULT_INLANG_PROJECT[key];
|
|
2211
|
-
const { validLanguageTags: validLanguageTags$1 } = parseLanguageTagInput(options$
|
|
2081
|
+
const { validLanguageTags: validLanguageTags$1 } = parseLanguageTagInput(options$7.languageTags);
|
|
2212
2082
|
data.baseLocale = validLanguageTags$1[0];
|
|
2213
2083
|
data.locales = validLanguageTags$1;
|
|
2214
2084
|
return generateCode();
|
|
@@ -2280,7 +2150,7 @@ var paraglide_default = defineAddon({
|
|
|
2280
2150
|
if (!content.includes(`\n${paraglideOutDir}`)) content = content.trimEnd() + `\n\n# Paraglide\n${paraglideOutDir}`;
|
|
2281
2151
|
return content;
|
|
2282
2152
|
});
|
|
2283
|
-
if (options$
|
|
2153
|
+
if (options$7.demo) {
|
|
2284
2154
|
sv.file(`${kit.routesDirectory}/demo/+page.svelte`, (content) => {
|
|
2285
2155
|
return addToDemoPage(content, "paraglide");
|
|
2286
2156
|
});
|
|
@@ -2305,7 +2175,7 @@ var paraglide_default = defineAddon({
|
|
|
2305
2175
|
const scriptCode = new MagicString(script.generateCode());
|
|
2306
2176
|
const templateCode = new MagicString(template.source);
|
|
2307
2177
|
templateCode.append("\n\n<h1>{m.hello_world({ name: 'SvelteKit User' })}</h1>\n");
|
|
2308
|
-
const { validLanguageTags: validLanguageTags$1 } = parseLanguageTagInput(options$
|
|
2178
|
+
const { validLanguageTags: validLanguageTags$1 } = parseLanguageTagInput(options$7.languageTags);
|
|
2309
2179
|
const links = validLanguageTags$1.map((x$1) => `${templateCode.getIndentString()}<button onclick={() => setLocale('${x$1}')}>${x$1}</button>`).join("\n");
|
|
2310
2180
|
templateCode.append(`<div>\n${links}\n</div>`);
|
|
2311
2181
|
templateCode.append("<p>\nIf you use VSCode, install the <a href=\"https://marketplace.visualstudio.com/items?itemName=inlang.vs-code-extension\" target=\"_blank\">Sherlock i18n extension</a> for a better i18n experience.\n</p>");
|
|
@@ -2315,7 +2185,7 @@ var paraglide_default = defineAddon({
|
|
|
2315
2185
|
});
|
|
2316
2186
|
});
|
|
2317
2187
|
}
|
|
2318
|
-
const { validLanguageTags } = parseLanguageTagInput(options$
|
|
2188
|
+
const { validLanguageTags } = parseLanguageTagInput(options$7.languageTags);
|
|
2319
2189
|
for (const languageTag of validLanguageTags) sv.file(`messages/${languageTag}.json`, (content) => {
|
|
2320
2190
|
const { data, generateCode } = parseJson(content);
|
|
2321
2191
|
data["$schema"] = "https://inlang.com/schema/inlang-message-format";
|
|
@@ -2325,7 +2195,7 @@ var paraglide_default = defineAddon({
|
|
|
2325
2195
|
},
|
|
2326
2196
|
nextSteps: ({ highlighter }) => {
|
|
2327
2197
|
const steps = [`Edit your messages in ${highlighter.path("messages/en.json")}`];
|
|
2328
|
-
if (options$
|
|
2198
|
+
if (options$4.demo) steps.push(`Visit ${highlighter.route("/demo/paraglide")} route to view the demo`);
|
|
2329
2199
|
return steps;
|
|
2330
2200
|
}
|
|
2331
2201
|
});
|
|
@@ -2342,6 +2212,120 @@ function parseLanguageTagInput(input) {
|
|
|
2342
2212
|
};
|
|
2343
2213
|
}
|
|
2344
2214
|
|
|
2215
|
+
//#endregion
|
|
2216
|
+
//#region ../addons/mcp/index.ts
|
|
2217
|
+
const options$3 = defineAddonOptions().add("ide", {
|
|
2218
|
+
question: "Which client would you like to use?",
|
|
2219
|
+
type: "multiselect",
|
|
2220
|
+
default: [],
|
|
2221
|
+
options: [
|
|
2222
|
+
{
|
|
2223
|
+
value: "claude-code",
|
|
2224
|
+
label: "claude code"
|
|
2225
|
+
},
|
|
2226
|
+
{
|
|
2227
|
+
value: "cursor",
|
|
2228
|
+
label: "Cursor"
|
|
2229
|
+
},
|
|
2230
|
+
{
|
|
2231
|
+
value: "gemini",
|
|
2232
|
+
label: "Gemini"
|
|
2233
|
+
},
|
|
2234
|
+
{
|
|
2235
|
+
value: "opencode",
|
|
2236
|
+
label: "opencode"
|
|
2237
|
+
},
|
|
2238
|
+
{
|
|
2239
|
+
value: "vscode",
|
|
2240
|
+
label: "VSCode"
|
|
2241
|
+
},
|
|
2242
|
+
{
|
|
2243
|
+
value: "other",
|
|
2244
|
+
label: "Other"
|
|
2245
|
+
}
|
|
2246
|
+
],
|
|
2247
|
+
required: true
|
|
2248
|
+
}).add("setup", {
|
|
2249
|
+
question: "What setup you want to use?",
|
|
2250
|
+
type: "select",
|
|
2251
|
+
default: "remote",
|
|
2252
|
+
options: [{
|
|
2253
|
+
value: "local",
|
|
2254
|
+
label: "Local",
|
|
2255
|
+
hint: "will use stdio"
|
|
2256
|
+
}, {
|
|
2257
|
+
value: "remote",
|
|
2258
|
+
label: "Remote",
|
|
2259
|
+
hint: "will use a remote endpoint"
|
|
2260
|
+
}],
|
|
2261
|
+
required: true
|
|
2262
|
+
}).build();
|
|
2263
|
+
var mcp_default = defineAddon({
|
|
2264
|
+
id: "mcp",
|
|
2265
|
+
shortDescription: "Svelte MCP",
|
|
2266
|
+
homepage: "https://svelte.dev/docs/mcp",
|
|
2267
|
+
options: options$3,
|
|
2268
|
+
run: ({ sv, options: options$7 }) => {
|
|
2269
|
+
const getLocalConfig = (o) => {
|
|
2270
|
+
return {
|
|
2271
|
+
...o?.type ? { type: o.type } : {},
|
|
2272
|
+
command: "npx",
|
|
2273
|
+
args: ["-y", "@sveltejs/mcp"],
|
|
2274
|
+
...o?.env ? { env: {} } : {}
|
|
2275
|
+
};
|
|
2276
|
+
};
|
|
2277
|
+
const getRemoteConfig = (o) => {
|
|
2278
|
+
return {
|
|
2279
|
+
...o?.type ? { type: o.type } : {},
|
|
2280
|
+
url: "https://mcp.svelte.dev/mcp"
|
|
2281
|
+
};
|
|
2282
|
+
};
|
|
2283
|
+
const configurator = {
|
|
2284
|
+
"claude-code": {
|
|
2285
|
+
filePath: ".mcp.json",
|
|
2286
|
+
typeLocal: "stdio",
|
|
2287
|
+
typeRemote: "http",
|
|
2288
|
+
env: true
|
|
2289
|
+
},
|
|
2290
|
+
cursor: { filePath: ".cursor/mcp.json" },
|
|
2291
|
+
gemini: { filePath: ".gemini/settings.json" },
|
|
2292
|
+
opencode: {
|
|
2293
|
+
schema: "https://opencode.ai/config.json",
|
|
2294
|
+
mcpServersKey: "mcp",
|
|
2295
|
+
filePath: "opencode.json",
|
|
2296
|
+
typeLocal: "local",
|
|
2297
|
+
typeRemote: "remote"
|
|
2298
|
+
},
|
|
2299
|
+
vscode: {
|
|
2300
|
+
mcpServersKey: "servers",
|
|
2301
|
+
filePath: ".vscode/mcp.json"
|
|
2302
|
+
},
|
|
2303
|
+
other: { other: true }
|
|
2304
|
+
};
|
|
2305
|
+
for (const ide of options$7.ide) {
|
|
2306
|
+
const value = configurator[ide];
|
|
2307
|
+
if ("other" in value) continue;
|
|
2308
|
+
const { mcpServersKey, filePath, typeLocal, typeRemote, env, schema } = value;
|
|
2309
|
+
sv.file(filePath, (content) => {
|
|
2310
|
+
const { data, generateCode } = parseJson(content);
|
|
2311
|
+
if (schema) data["$schema"] = schema;
|
|
2312
|
+
const key = mcpServersKey || "mcpServers";
|
|
2313
|
+
data[key] ??= {};
|
|
2314
|
+
data[key].svelte = options$7.setup === "local" ? getLocalConfig({
|
|
2315
|
+
type: typeLocal,
|
|
2316
|
+
env
|
|
2317
|
+
}) : getRemoteConfig({ type: typeRemote });
|
|
2318
|
+
return generateCode();
|
|
2319
|
+
});
|
|
2320
|
+
}
|
|
2321
|
+
},
|
|
2322
|
+
nextSteps({ highlighter, options: options$7 }) {
|
|
2323
|
+
const steps = [];
|
|
2324
|
+
if (options$7.ide.includes("other")) steps.push(`For other clients: ${highlighter.website(`https://svelte.dev/docs/mcp/${options$7.setup}-setup#Other-clients`)}`);
|
|
2325
|
+
return steps;
|
|
2326
|
+
}
|
|
2327
|
+
});
|
|
2328
|
+
|
|
2345
2329
|
//#endregion
|
|
2346
2330
|
//#region ../addons/playwright/index.ts
|
|
2347
2331
|
var playwright_default = defineAddon({
|
|
@@ -2553,8 +2537,8 @@ var sveltekit_adapter_default = defineAddon({
|
|
|
2553
2537
|
setup: ({ kit, unsupported }) => {
|
|
2554
2538
|
if (!kit) unsupported("Requires SvelteKit");
|
|
2555
2539
|
},
|
|
2556
|
-
run: ({ sv, options: options$
|
|
2557
|
-
const adapter = adapters.find((a) => a.id === options$
|
|
2540
|
+
run: ({ sv, options: options$7 }) => {
|
|
2541
|
+
const adapter = adapters.find((a) => a.id === options$7.adapter);
|
|
2558
2542
|
sv.file("package.json", (content) => {
|
|
2559
2543
|
const { data, generateCode } = parseJson(content);
|
|
2560
2544
|
const devDeps = data["devDependencies"];
|
|
@@ -2625,13 +2609,14 @@ var tailwindcss_default = defineAddon({
|
|
|
2625
2609
|
shortDescription: "css framework",
|
|
2626
2610
|
homepage: "https://tailwindcss.com",
|
|
2627
2611
|
options: options$1,
|
|
2628
|
-
run: ({ sv, options: options$
|
|
2612
|
+
run: ({ sv, options: options$7, viteConfigFile, typescript, kit, dependencyVersion }) => {
|
|
2629
2613
|
const prettierInstalled = Boolean(dependencyVersion("prettier"));
|
|
2630
2614
|
sv.devDependency("tailwindcss", "^4.1.13");
|
|
2631
2615
|
sv.devDependency("@tailwindcss/vite", "^4.1.13");
|
|
2616
|
+
sv.pnpmBuildDependency("@tailwindcss/oxide");
|
|
2632
2617
|
if (prettierInstalled) sv.devDependency("prettier-plugin-tailwindcss", "^0.6.14");
|
|
2633
2618
|
for (const plugin of plugins) {
|
|
2634
|
-
if (!options$
|
|
2619
|
+
if (!options$7.plugins.includes(plugin.id)) continue;
|
|
2635
2620
|
sv.devDependency(plugin.package, plugin.version);
|
|
2636
2621
|
}
|
|
2637
2622
|
sv.file(viteConfigFile, (content) => {
|
|
@@ -2657,7 +2642,7 @@ var tailwindcss_default = defineAddon({
|
|
|
2657
2642
|
}
|
|
2658
2643
|
const pluginPos = atRules.findLast((rule) => ["plugin", "import"].includes(rule.name)).source.end.offset;
|
|
2659
2644
|
for (const plugin of plugins) {
|
|
2660
|
-
if (!options$
|
|
2645
|
+
if (!options$7.plugins.includes(plugin.id)) continue;
|
|
2661
2646
|
if (!findAtRule("plugin", plugin.package)) {
|
|
2662
2647
|
const pluginImport = `\n@plugin '${plugin.package}';`;
|
|
2663
2648
|
code = code.substring(0, pluginPos) + pluginImport + code.substring(pluginPos);
|
|
@@ -2718,10 +2703,10 @@ var vitest_addon_default = defineAddon({
|
|
|
2718
2703
|
shortDescription: "unit testing",
|
|
2719
2704
|
homepage: "https://vitest.dev",
|
|
2720
2705
|
options,
|
|
2721
|
-
run: ({ sv, viteConfigFile, typescript, kit, options: options$
|
|
2706
|
+
run: ({ sv, viteConfigFile, typescript, kit, options: options$7 }) => {
|
|
2722
2707
|
const ext = typescript ? "ts" : "js";
|
|
2723
|
-
const unitTesting = options$
|
|
2724
|
-
const componentTesting = options$
|
|
2708
|
+
const unitTesting = options$7.usages.includes("unit");
|
|
2709
|
+
const componentTesting = options$7.usages.includes("component");
|
|
2725
2710
|
sv.devDependency("vitest", "^3.2.4");
|
|
2726
2711
|
if (componentTesting) {
|
|
2727
2712
|
sv.devDependency("@vitest/browser", "^3.2.4");
|
|
@@ -2851,7 +2836,8 @@ const officialAddons = {
|
|
|
2851
2836
|
lucia: lucia_default,
|
|
2852
2837
|
mdsvex: mdsvex_default,
|
|
2853
2838
|
paraglide: paraglide_default,
|
|
2854
|
-
storybook: storybook_default
|
|
2839
|
+
storybook: storybook_default,
|
|
2840
|
+
mcp: mcp_default
|
|
2855
2841
|
};
|
|
2856
2842
|
function getAddonDetails(id) {
|
|
2857
2843
|
const details = Object.values(officialAddons).find((a) => a.id === id);
|
|
@@ -2884,17 +2870,17 @@ function getPackageJson(cwd) {
|
|
|
2884
2870
|
generateCode
|
|
2885
2871
|
};
|
|
2886
2872
|
}
|
|
2887
|
-
async function formatFiles(options$
|
|
2873
|
+
async function formatFiles(options$7) {
|
|
2888
2874
|
const args = [
|
|
2889
2875
|
"prettier",
|
|
2890
2876
|
"--write",
|
|
2891
2877
|
"--ignore-unknown",
|
|
2892
|
-
...options$
|
|
2878
|
+
...options$7.paths
|
|
2893
2879
|
];
|
|
2894
|
-
const cmd = resolveCommand(options$
|
|
2880
|
+
const cmd = resolveCommand(options$7.packageManager, "execute-local", args);
|
|
2895
2881
|
await be(cmd.command, cmd.args, {
|
|
2896
2882
|
nodeOptions: {
|
|
2897
|
-
cwd: options$
|
|
2883
|
+
cwd: options$7.cwd,
|
|
2898
2884
|
stdio: "pipe"
|
|
2899
2885
|
},
|
|
2900
2886
|
throwOnError: true
|
|
@@ -2956,15 +2942,16 @@ function getHighlighter() {
|
|
|
2956
2942
|
|
|
2957
2943
|
//#endregion
|
|
2958
2944
|
//#region commands/add/workspace.ts
|
|
2959
|
-
async function createWorkspace({ cwd, options: options$
|
|
2945
|
+
async function createWorkspace({ cwd, options: options$7 = {}, packageManager }) {
|
|
2960
2946
|
const resolvedCwd = path.resolve(cwd);
|
|
2961
2947
|
const usesTypescript = !any([commonFilePaths.jsconfig, commonFilePaths.tsconfig], { cwd })?.endsWith(commonFilePaths.jsconfig);
|
|
2962
2948
|
const viteConfigPath = path.join(resolvedCwd, commonFilePaths.viteConfigTS);
|
|
2963
2949
|
const viteConfigFile = fs.existsSync(viteConfigPath) ? commonFilePaths.viteConfigTS : commonFilePaths.viteConfig;
|
|
2964
2950
|
let dependencies = {};
|
|
2965
2951
|
let directory = resolvedCwd;
|
|
2966
|
-
const
|
|
2967
|
-
|
|
2952
|
+
const workspaceRoot = findWorkspaceRoot(directory);
|
|
2953
|
+
const { root } = path.parse(directory);
|
|
2954
|
+
while (directory && directory.length >= workspaceRoot.length) {
|
|
2968
2955
|
if (fs.existsSync(path.join(directory, commonFilePaths.packageJson))) {
|
|
2969
2956
|
const { data: packageJson } = getPackageJson(directory);
|
|
2970
2957
|
dependencies = {
|
|
@@ -2973,12 +2960,13 @@ async function createWorkspace({ cwd, options: options$6 = {}, packageManager })
|
|
|
2973
2960
|
...dependencies
|
|
2974
2961
|
};
|
|
2975
2962
|
}
|
|
2963
|
+
if (root === directory) break;
|
|
2976
2964
|
directory = path.dirname(directory);
|
|
2977
2965
|
}
|
|
2978
2966
|
for (const [key, value] of Object.entries(dependencies)) dependencies[key] = value.replaceAll(/[^\d|.]/g, "");
|
|
2979
2967
|
return {
|
|
2980
2968
|
cwd: resolvedCwd,
|
|
2981
|
-
options: options$
|
|
2969
|
+
options: options$7,
|
|
2982
2970
|
packageManager: packageManager ?? (await detect({ cwd }))?.name ?? getUserAgent() ?? "npm",
|
|
2983
2971
|
typescript: usesTypescript,
|
|
2984
2972
|
viteConfigFile,
|
|
@@ -2986,7 +2974,7 @@ async function createWorkspace({ cwd, options: options$6 = {}, packageManager })
|
|
|
2986
2974
|
dependencyVersion: (pkg) => dependencies[pkg]
|
|
2987
2975
|
};
|
|
2988
2976
|
}
|
|
2989
|
-
function
|
|
2977
|
+
function findWorkspaceRoot(cwd) {
|
|
2990
2978
|
const { root } = path.parse(cwd);
|
|
2991
2979
|
let directory = cwd;
|
|
2992
2980
|
while (directory && directory !== root) {
|
|
@@ -2997,7 +2985,7 @@ function findRoot(cwd) {
|
|
|
2997
2985
|
}
|
|
2998
2986
|
directory = path.dirname(directory);
|
|
2999
2987
|
}
|
|
3000
|
-
return
|
|
2988
|
+
return cwd;
|
|
3001
2989
|
}
|
|
3002
2990
|
function parseKitOptions(cwd) {
|
|
3003
2991
|
const configSource = readFile(cwd, commonFilePaths.svelteConfig);
|
|
@@ -3047,7 +3035,7 @@ const TESTING = process.env.NODE_ENV?.toLowerCase() === "test";
|
|
|
3047
3035
|
//#endregion
|
|
3048
3036
|
//#region lib/install.ts
|
|
3049
3037
|
var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
3050
|
-
async function installAddon({ addons, cwd, options: options$
|
|
3038
|
+
async function installAddon({ addons, cwd, options: options$7, packageManager = "npm" }) {
|
|
3051
3039
|
const workspace = await createWorkspace({
|
|
3052
3040
|
cwd,
|
|
3053
3041
|
packageManager
|
|
@@ -3056,31 +3044,35 @@ async function installAddon({ addons, cwd, options: options$6, packageManager =
|
|
|
3056
3044
|
return await applyAddons({
|
|
3057
3045
|
addons,
|
|
3058
3046
|
workspace,
|
|
3059
|
-
options: options$
|
|
3047
|
+
options: options$7,
|
|
3060
3048
|
addonSetupResults
|
|
3061
3049
|
});
|
|
3062
3050
|
}
|
|
3063
|
-
async function applyAddons({ addons, workspace, addonSetupResults, options: options$
|
|
3051
|
+
async function applyAddons({ addons, workspace, addonSetupResults, options: options$7 }) {
|
|
3064
3052
|
const filesToFormat = /* @__PURE__ */ new Set();
|
|
3065
3053
|
const allPnpmBuildDependencies = [];
|
|
3054
|
+
const status = {};
|
|
3066
3055
|
const mapped = Object.entries(addons).map(([, addon]) => addon);
|
|
3067
3056
|
const ordered = orderAddons(mapped, addonSetupResults);
|
|
3068
3057
|
for (const addon of ordered) {
|
|
3069
3058
|
workspace = await createWorkspace({
|
|
3070
3059
|
...workspace,
|
|
3071
|
-
options: options$
|
|
3060
|
+
options: options$7[addon.id]
|
|
3072
3061
|
});
|
|
3073
|
-
const { files, pnpmBuildDependencies } = await runAddon({
|
|
3062
|
+
const { files, pnpmBuildDependencies, cancels } = await runAddon({
|
|
3074
3063
|
workspace,
|
|
3075
3064
|
addon,
|
|
3076
3065
|
multiple: ordered.length > 1
|
|
3077
3066
|
});
|
|
3078
3067
|
files.forEach((f) => filesToFormat.add(f));
|
|
3079
3068
|
pnpmBuildDependencies.forEach((s) => allPnpmBuildDependencies.push(s));
|
|
3069
|
+
if (cancels.length === 0) status[addon.id] = "success";
|
|
3070
|
+
else status[addon.id] = cancels;
|
|
3080
3071
|
}
|
|
3081
3072
|
return {
|
|
3082
3073
|
filesToFormat: Array.from(filesToFormat),
|
|
3083
|
-
pnpmBuildDependencies: allPnpmBuildDependencies
|
|
3074
|
+
pnpmBuildDependencies: allPnpmBuildDependencies,
|
|
3075
|
+
status
|
|
3084
3076
|
};
|
|
3085
3077
|
}
|
|
3086
3078
|
function setupAddons(addons, workspace) {
|
|
@@ -3159,15 +3151,22 @@ async function runAddon({ addon, multiple, workspace }) {
|
|
|
3159
3151
|
pnpmBuildDependencies.push(pkg);
|
|
3160
3152
|
}
|
|
3161
3153
|
};
|
|
3154
|
+
const cancels = [];
|
|
3162
3155
|
await addon.run({
|
|
3156
|
+
cancel: (reason) => {
|
|
3157
|
+
cancels.push(reason);
|
|
3158
|
+
},
|
|
3163
3159
|
...workspace,
|
|
3164
3160
|
sv
|
|
3165
3161
|
});
|
|
3166
|
-
|
|
3167
|
-
|
|
3162
|
+
if (cancels.length === 0) {
|
|
3163
|
+
const pkgPath = installPackages(dependencies, workspace);
|
|
3164
|
+
files.add(pkgPath);
|
|
3165
|
+
}
|
|
3168
3166
|
return {
|
|
3169
3167
|
files: Array.from(files),
|
|
3170
|
-
pnpmBuildDependencies
|
|
3168
|
+
pnpmBuildDependencies,
|
|
3169
|
+
cancels
|
|
3171
3170
|
};
|
|
3172
3171
|
}
|
|
3173
3172
|
function orderAddons(addons, setupResults) {
|
|
@@ -3177,4 +3176,4 @@ function orderAddons(addons, setupResults) {
|
|
|
3177
3176
|
}
|
|
3178
3177
|
|
|
3179
3178
|
//#endregion
|
|
3180
|
-
export { addDefault, applyAddons, communityAddonIds, create, createDefault, createWorkspace, formatFiles, getAddonDetails, getCommunityAddon, getHighlighter, installAddon,
|
|
3179
|
+
export { addDefault, applyAddons, communityAddonIds, create, createDefault, createWorkspace, formatFiles, getAddonDetails, getCommunityAddon, getHighlighter, installAddon, officialAddons, overrideProperties, setupAddons };
|