sv 0.10.7 → 0.11.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.js → bin.mjs} +392 -200
- package/dist/chunk-BjMGrMj9.mjs +45 -0
- package/dist/core-D6dTS6c8.mjs +40208 -0
- package/dist/index-7xp7FWpU.d.mts +506 -0
- package/dist/index.d.mts +2 -0
- package/dist/index2.d.mts +65 -0
- package/dist/lib/core/index.mjs +4 -0
- package/dist/lib/index.mjs +5 -0
- package/dist/lib/{testing.js → testing.mjs} +84 -82
- package/dist/{install-BPIL0v3f.js → official-A2Qnog8q.mjs} +495 -1097
- package/dist/package-manager-BaBHlsHz.mjs +4620 -0
- package/dist/templates/demo/files.types=checkjs.json +1 -1
- package/dist/templates/demo/files.types=none.json +1 -1
- package/dist/templates/demo/files.types=typescript.json +1 -1
- package/dist/templates/demo/package.json +3 -3
- package/dist/templates/library/package.json +4 -4
- package/dist/templates/minimal/package.json +3 -3
- package/dist/{lib/testing.d.ts → testing.d.mts} +3 -4
- package/package.json +33 -16
- package/dist/create-DTIS6AzL.js +0 -32465
- package/dist/lib/index.d.ts +0 -296
- package/dist/lib/index.js +0 -4
- /package/dist/{bin.d.ts → bin.d.mts} +0 -0
package/dist/{bin.js → bin.mjs}
RENAMED
|
@@ -1,21 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
2
|
+
import { i as __toESM } from "./chunk-BjMGrMj9.mjs";
|
|
3
|
+
import { D as dist, E as templates, O as getSharedFiles, S as resolveCommand, T as create$1, a as installOption, b as from, c as Option, f as formatFiles, i as installDependencies, l as program, m as getPackageJson, n as addPnpmBuildDependencies, o as packageManagerPrompt, p as getHighlighter, r as getUserAgent, s as Command, t as AGENT_NAMES, u as commonFilePaths, x as detect, y as up$1 } from "./package-manager-BaBHlsHz.mjs";
|
|
4
|
+
import { $ as Fe, F as create$2, I as overrideProperties, O as addDefault, Q as De, X as walk, a as toFragment, at as We, ct as ke, dt as require_picocolors, et as Ge, g as parseSvelte, h as parseScript, it as Ue, lt as ze, m as parseJson, nt as Ke, o as isVersionUnsupportedBelow, r as ensureScript, rt as T, st as et, tt as J, ut as Vu, w as createDefault } from "./core-D6dTS6c8.mjs";
|
|
5
|
+
import { a as setupAddons, n as officialAddons, o as createWorkspace, r as applyAddons, t as getAddonDetails } from "./official-A2Qnog8q.mjs";
|
|
6
6
|
import fs, { existsSync } from "node:fs";
|
|
7
|
+
import path, { dirname, join } from "node:path";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
7
9
|
import process from "node:process";
|
|
8
10
|
import { promisify } from "node:util";
|
|
9
|
-
import {
|
|
11
|
+
import { exec, execSync } from "node:child_process";
|
|
10
12
|
import { createGunzip } from "node:zlib";
|
|
11
13
|
import { pipeline } from "node:stream/promises";
|
|
12
14
|
|
|
13
15
|
//#region package.json
|
|
14
16
|
var name = "sv";
|
|
15
|
-
var version = "0.
|
|
17
|
+
var version = "0.11.0";
|
|
16
18
|
|
|
17
19
|
//#endregion
|
|
18
|
-
//#region
|
|
20
|
+
//#region lib/addons/_config/community.ts
|
|
21
|
+
/** EVALUATED AT BUILD TIME */
|
|
22
|
+
const communityAddonIds = ["unocss", "unplugin-icons"];
|
|
23
|
+
async function getCommunityAddon(name$1) {
|
|
24
|
+
const { default: details } = await import(`../../../community-addons/${name$1}.ts`);
|
|
25
|
+
return details;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region ../../node_modules/.pnpm/empathic@2.0.0/node_modules/empathic/package.mjs
|
|
19
30
|
/**
|
|
20
31
|
* Find the closest "package.json" file while walking parent directories.
|
|
21
32
|
* @returns The absolute path to a "package.json", if found.
|
|
@@ -25,29 +36,72 @@ function up(options$1) {
|
|
|
25
36
|
}
|
|
26
37
|
|
|
27
38
|
//#endregion
|
|
28
|
-
//#region ../../node_modules/.pnpm/valibot@
|
|
39
|
+
//#region ../../node_modules/.pnpm/valibot@1.2.0_typescript@5.9.3/node_modules/valibot/dist/index.mjs
|
|
29
40
|
var import_picocolors$3 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
30
|
-
|
|
31
|
-
|
|
41
|
+
let store$4;
|
|
42
|
+
/**
|
|
43
|
+
* Returns the global configuration.
|
|
44
|
+
*
|
|
45
|
+
* @param config The config to merge.
|
|
46
|
+
*
|
|
47
|
+
* @returns The configuration.
|
|
48
|
+
*/
|
|
49
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
50
|
+
function getGlobalConfig(config$1) {
|
|
32
51
|
return {
|
|
33
|
-
lang:
|
|
34
|
-
message:
|
|
35
|
-
abortEarly:
|
|
36
|
-
abortPipeEarly:
|
|
52
|
+
lang: config$1?.lang ?? store$4?.lang,
|
|
53
|
+
message: config$1?.message,
|
|
54
|
+
abortEarly: config$1?.abortEarly ?? store$4?.abortEarly,
|
|
55
|
+
abortPipeEarly: config$1?.abortPipeEarly ?? store$4?.abortPipeEarly
|
|
37
56
|
};
|
|
38
57
|
}
|
|
39
|
-
|
|
58
|
+
let store$3;
|
|
59
|
+
/**
|
|
60
|
+
* Returns a global error message.
|
|
61
|
+
*
|
|
62
|
+
* @param lang The language of the message.
|
|
63
|
+
*
|
|
64
|
+
* @returns The error message.
|
|
65
|
+
*/
|
|
66
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
40
67
|
function getGlobalMessage(lang) {
|
|
41
|
-
return
|
|
68
|
+
return store$3?.get(lang);
|
|
42
69
|
}
|
|
43
|
-
|
|
70
|
+
let store$2;
|
|
71
|
+
/**
|
|
72
|
+
* Returns a schema error message.
|
|
73
|
+
*
|
|
74
|
+
* @param lang The language of the message.
|
|
75
|
+
*
|
|
76
|
+
* @returns The error message.
|
|
77
|
+
*/
|
|
78
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
44
79
|
function getSchemaMessage(lang) {
|
|
45
|
-
return
|
|
80
|
+
return store$2?.get(lang);
|
|
46
81
|
}
|
|
47
|
-
|
|
82
|
+
let store$1;
|
|
83
|
+
/**
|
|
84
|
+
* Returns a specific error message.
|
|
85
|
+
*
|
|
86
|
+
* @param reference The identifier reference.
|
|
87
|
+
* @param lang The language of the message.
|
|
88
|
+
*
|
|
89
|
+
* @returns The error message.
|
|
90
|
+
*/
|
|
91
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
48
92
|
function getSpecificMessage(reference, lang) {
|
|
49
|
-
return
|
|
93
|
+
return store$1?.get(reference)?.get(lang);
|
|
50
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Stringifies an unknown input to a literal or type string.
|
|
97
|
+
*
|
|
98
|
+
* @param input The unknown input.
|
|
99
|
+
*
|
|
100
|
+
* @returns A literal or type string.
|
|
101
|
+
*
|
|
102
|
+
* @internal
|
|
103
|
+
*/
|
|
104
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
51
105
|
function _stringify(input) {
|
|
52
106
|
const type = typeof input;
|
|
53
107
|
if (type === "string") return `"${input}"`;
|
|
@@ -55,10 +109,21 @@ function _stringify(input) {
|
|
|
55
109
|
if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
|
|
56
110
|
return type;
|
|
57
111
|
}
|
|
58
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Adds an issue to the dataset.
|
|
114
|
+
*
|
|
115
|
+
* @param context The issue context.
|
|
116
|
+
* @param label The issue label.
|
|
117
|
+
* @param dataset The input dataset.
|
|
118
|
+
* @param config The configuration.
|
|
119
|
+
* @param other The optional props.
|
|
120
|
+
*
|
|
121
|
+
* @internal
|
|
122
|
+
*/
|
|
123
|
+
function _addIssue(context, label, dataset, config$1, other) {
|
|
59
124
|
const input = other && "input" in other ? other.input : dataset.value;
|
|
60
125
|
const expected = other?.expected ?? context.expects ?? null;
|
|
61
|
-
const received = other?.received ?? _stringify(input);
|
|
126
|
+
const received = other?.received ?? /* @__PURE__ */ _stringify(input);
|
|
62
127
|
const issue = {
|
|
63
128
|
kind: context.kind,
|
|
64
129
|
type: context.type,
|
|
@@ -69,30 +134,69 @@ function _addIssue(context, label, dataset, config2, other) {
|
|
|
69
134
|
requirement: context.requirement,
|
|
70
135
|
path: other?.path,
|
|
71
136
|
issues: other?.issues,
|
|
72
|
-
lang:
|
|
73
|
-
abortEarly:
|
|
74
|
-
abortPipeEarly:
|
|
137
|
+
lang: config$1.lang,
|
|
138
|
+
abortEarly: config$1.abortEarly,
|
|
139
|
+
abortPipeEarly: config$1.abortPipeEarly
|
|
75
140
|
};
|
|
76
141
|
const isSchema = context.kind === "schema";
|
|
77
|
-
const message = other?.message ?? context.message ?? getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? getSchemaMessage(issue.lang) : null) ??
|
|
78
|
-
if (message) issue.message = typeof message === "function" ? message(issue) : message;
|
|
142
|
+
const message$1 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config$1.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
|
|
143
|
+
if (message$1 !== void 0) issue.message = typeof message$1 === "function" ? message$1(issue) : message$1;
|
|
79
144
|
if (isSchema) dataset.typed = false;
|
|
80
145
|
if (dataset.issues) dataset.issues.push(issue);
|
|
81
146
|
else dataset.issues = [issue];
|
|
82
147
|
}
|
|
83
|
-
|
|
84
|
-
|
|
148
|
+
/**
|
|
149
|
+
* Returns the Standard Schema properties.
|
|
150
|
+
*
|
|
151
|
+
* @param context The schema context.
|
|
152
|
+
*
|
|
153
|
+
* @returns The Standard Schema properties.
|
|
154
|
+
*/
|
|
155
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
156
|
+
function _getStandardProps(context) {
|
|
157
|
+
return {
|
|
158
|
+
version: 1,
|
|
159
|
+
vendor: "valibot",
|
|
160
|
+
validate(value$1) {
|
|
161
|
+
return context["~run"]({ value: value$1 }, /* @__PURE__ */ getGlobalConfig());
|
|
162
|
+
}
|
|
163
|
+
};
|
|
85
164
|
}
|
|
86
|
-
|
|
87
|
-
|
|
165
|
+
/**
|
|
166
|
+
* Disallows inherited object properties and prevents object prototype
|
|
167
|
+
* pollution by disallowing certain keys.
|
|
168
|
+
*
|
|
169
|
+
* @param object The object to check.
|
|
170
|
+
* @param key The key to check.
|
|
171
|
+
*
|
|
172
|
+
* @returns Whether the key is allowed.
|
|
173
|
+
*
|
|
174
|
+
* @internal
|
|
175
|
+
*/
|
|
176
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
177
|
+
function _isValidObjectKey(object$1, key) {
|
|
178
|
+
return Object.hasOwn(object$1, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Joins multiple `expects` values with the given separator.
|
|
182
|
+
*
|
|
183
|
+
* @param values The `expects` values.
|
|
184
|
+
* @param separator The separator.
|
|
185
|
+
*
|
|
186
|
+
* @returns The joined `expects` property.
|
|
187
|
+
*
|
|
188
|
+
* @internal
|
|
189
|
+
*/
|
|
190
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
191
|
+
function _joinExpects(values$1, separator) {
|
|
192
|
+
const list = [...new Set(values$1)];
|
|
88
193
|
if (list.length > 1) return `(${list.join(` ${separator} `)})`;
|
|
89
194
|
return list[0] ?? "never";
|
|
90
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* A Valibot error with useful information.
|
|
198
|
+
*/
|
|
91
199
|
var ValiError = class extends Error {
|
|
92
|
-
/**
|
|
93
|
-
* The error issues.
|
|
94
|
-
*/
|
|
95
|
-
issues;
|
|
96
200
|
/**
|
|
97
201
|
* Creates a Valibot error with useful information.
|
|
98
202
|
*
|
|
@@ -104,6 +208,14 @@ var ValiError = class extends Error {
|
|
|
104
208
|
this.issues = issues;
|
|
105
209
|
}
|
|
106
210
|
};
|
|
211
|
+
/**
|
|
212
|
+
* Creates a custom transformation action.
|
|
213
|
+
*
|
|
214
|
+
* @param operation The transformation operation.
|
|
215
|
+
*
|
|
216
|
+
* @returns A transform action.
|
|
217
|
+
*/
|
|
218
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
107
219
|
function transform(operation) {
|
|
108
220
|
return {
|
|
109
221
|
kind: "transformation",
|
|
@@ -111,16 +223,40 @@ function transform(operation) {
|
|
|
111
223
|
reference: transform,
|
|
112
224
|
async: false,
|
|
113
225
|
operation,
|
|
114
|
-
|
|
226
|
+
"~run"(dataset) {
|
|
115
227
|
dataset.value = this.operation(dataset.value);
|
|
116
228
|
return dataset;
|
|
117
229
|
}
|
|
118
230
|
};
|
|
119
231
|
}
|
|
120
|
-
|
|
121
|
-
|
|
232
|
+
/**
|
|
233
|
+
* Returns the fallback value of the schema.
|
|
234
|
+
*
|
|
235
|
+
* @param schema The schema to get it from.
|
|
236
|
+
* @param dataset The output dataset if available.
|
|
237
|
+
* @param config The config if available.
|
|
238
|
+
*
|
|
239
|
+
* @returns The fallback value.
|
|
240
|
+
*/
|
|
241
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
242
|
+
function getFallback(schema, dataset, config$1) {
|
|
243
|
+
return typeof schema.fallback === "function" ? schema.fallback(dataset, config$1) : schema.fallback;
|
|
122
244
|
}
|
|
123
|
-
|
|
245
|
+
/**
|
|
246
|
+
* Returns the default value of the schema.
|
|
247
|
+
*
|
|
248
|
+
* @param schema The schema to get it from.
|
|
249
|
+
* @param dataset The input dataset if available.
|
|
250
|
+
* @param config The config if available.
|
|
251
|
+
*
|
|
252
|
+
* @returns The default value.
|
|
253
|
+
*/
|
|
254
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
255
|
+
function getDefault(schema, dataset, config$1) {
|
|
256
|
+
return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
|
|
257
|
+
}
|
|
258
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
259
|
+
function array(item, message$1) {
|
|
124
260
|
return {
|
|
125
261
|
kind: "schema",
|
|
126
262
|
type: "array",
|
|
@@ -128,25 +264,25 @@ function array(item, message) {
|
|
|
128
264
|
expects: "Array",
|
|
129
265
|
async: false,
|
|
130
266
|
item,
|
|
131
|
-
message,
|
|
132
|
-
|
|
267
|
+
message: message$1,
|
|
268
|
+
get "~standard"() {
|
|
269
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
270
|
+
},
|
|
271
|
+
"~run"(dataset, config$1) {
|
|
133
272
|
const input = dataset.value;
|
|
134
273
|
if (Array.isArray(input)) {
|
|
135
274
|
dataset.typed = true;
|
|
136
275
|
dataset.value = [];
|
|
137
276
|
for (let key = 0; key < input.length; key++) {
|
|
138
|
-
const
|
|
139
|
-
const itemDataset = this.item
|
|
140
|
-
typed: false,
|
|
141
|
-
value: value2
|
|
142
|
-
}, config2);
|
|
277
|
+
const value$1 = input[key];
|
|
278
|
+
const itemDataset = this.item["~run"]({ value: value$1 }, config$1);
|
|
143
279
|
if (itemDataset.issues) {
|
|
144
280
|
const pathItem = {
|
|
145
281
|
type: "array",
|
|
146
282
|
origin: "value",
|
|
147
283
|
input,
|
|
148
284
|
key,
|
|
149
|
-
value:
|
|
285
|
+
value: value$1
|
|
150
286
|
};
|
|
151
287
|
for (const issue of itemDataset.issues) {
|
|
152
288
|
if (issue.path) issue.path.unshift(pathItem);
|
|
@@ -154,7 +290,7 @@ function array(item, message) {
|
|
|
154
290
|
dataset.issues?.push(issue);
|
|
155
291
|
}
|
|
156
292
|
if (!dataset.issues) dataset.issues = itemDataset.issues;
|
|
157
|
-
if (
|
|
293
|
+
if (config$1.abortEarly) {
|
|
158
294
|
dataset.typed = false;
|
|
159
295
|
break;
|
|
160
296
|
}
|
|
@@ -162,65 +298,77 @@ function array(item, message) {
|
|
|
162
298
|
if (!itemDataset.typed) dataset.typed = false;
|
|
163
299
|
dataset.value.push(itemDataset.value);
|
|
164
300
|
}
|
|
165
|
-
} else _addIssue(this, "type", dataset,
|
|
301
|
+
} else _addIssue(this, "type", dataset, config$1);
|
|
166
302
|
return dataset;
|
|
167
303
|
}
|
|
168
304
|
};
|
|
169
305
|
}
|
|
170
|
-
|
|
306
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
307
|
+
function boolean(message$1) {
|
|
171
308
|
return {
|
|
172
309
|
kind: "schema",
|
|
173
310
|
type: "boolean",
|
|
174
311
|
reference: boolean,
|
|
175
312
|
expects: "boolean",
|
|
176
313
|
async: false,
|
|
177
|
-
message,
|
|
178
|
-
|
|
314
|
+
message: message$1,
|
|
315
|
+
get "~standard"() {
|
|
316
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
317
|
+
},
|
|
318
|
+
"~run"(dataset, config$1) {
|
|
179
319
|
if (typeof dataset.value === "boolean") dataset.typed = true;
|
|
180
|
-
else _addIssue(this, "type", dataset,
|
|
320
|
+
else _addIssue(this, "type", dataset, config$1);
|
|
181
321
|
return dataset;
|
|
182
322
|
}
|
|
183
323
|
};
|
|
184
324
|
}
|
|
185
|
-
|
|
186
|
-
|
|
325
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
326
|
+
function optional(wrapped, default_) {
|
|
327
|
+
return {
|
|
187
328
|
kind: "schema",
|
|
188
329
|
type: "optional",
|
|
189
330
|
reference: optional,
|
|
190
331
|
expects: `(${wrapped.expects} | undefined)`,
|
|
191
332
|
async: false,
|
|
192
333
|
wrapped,
|
|
193
|
-
|
|
334
|
+
default: default_,
|
|
335
|
+
get "~standard"() {
|
|
336
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
337
|
+
},
|
|
338
|
+
"~run"(dataset, config$1) {
|
|
194
339
|
if (dataset.value === void 0) {
|
|
195
|
-
if (
|
|
340
|
+
if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
|
|
196
341
|
if (dataset.value === void 0) {
|
|
197
342
|
dataset.typed = true;
|
|
198
343
|
return dataset;
|
|
199
344
|
}
|
|
200
345
|
}
|
|
201
|
-
return this.wrapped
|
|
346
|
+
return this.wrapped["~run"](dataset, config$1);
|
|
202
347
|
}
|
|
203
348
|
};
|
|
204
|
-
if (0 in args) schema.default = args[0];
|
|
205
|
-
return schema;
|
|
206
349
|
}
|
|
207
|
-
|
|
350
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
351
|
+
function picklist(options$1, message$1) {
|
|
208
352
|
return {
|
|
209
353
|
kind: "schema",
|
|
210
354
|
type: "picklist",
|
|
211
355
|
reference: picklist,
|
|
212
|
-
expects: _joinExpects(options$1.map(_stringify), "|"),
|
|
356
|
+
expects: /* @__PURE__ */ _joinExpects(options$1.map(_stringify), "|"),
|
|
213
357
|
async: false,
|
|
214
358
|
options: options$1,
|
|
215
|
-
message,
|
|
216
|
-
|
|
359
|
+
message: message$1,
|
|
360
|
+
get "~standard"() {
|
|
361
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
362
|
+
},
|
|
363
|
+
"~run"(dataset, config$1) {
|
|
217
364
|
if (this.options.includes(dataset.value)) dataset.typed = true;
|
|
218
|
-
else _addIssue(this, "type", dataset,
|
|
365
|
+
else _addIssue(this, "type", dataset, config$1);
|
|
219
366
|
return dataset;
|
|
220
367
|
}
|
|
221
368
|
};
|
|
222
369
|
}
|
|
223
|
-
|
|
370
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
371
|
+
function record(key, value$1, message$1) {
|
|
224
372
|
return {
|
|
225
373
|
kind: "schema",
|
|
226
374
|
type: "record",
|
|
@@ -228,19 +376,19 @@ function record(key, value2, message) {
|
|
|
228
376
|
expects: "Object",
|
|
229
377
|
async: false,
|
|
230
378
|
key,
|
|
231
|
-
value:
|
|
232
|
-
message,
|
|
233
|
-
|
|
379
|
+
value: value$1,
|
|
380
|
+
message: message$1,
|
|
381
|
+
get "~standard"() {
|
|
382
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
383
|
+
},
|
|
384
|
+
"~run"(dataset, config$1) {
|
|
234
385
|
const input = dataset.value;
|
|
235
386
|
if (input && typeof input === "object") {
|
|
236
387
|
dataset.typed = true;
|
|
237
388
|
dataset.value = {};
|
|
238
|
-
for (const entryKey in input) if (_isValidObjectKey(input, entryKey)) {
|
|
389
|
+
for (const entryKey in input) if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
|
|
239
390
|
const entryValue = input[entryKey];
|
|
240
|
-
const keyDataset = this.key
|
|
241
|
-
typed: false,
|
|
242
|
-
value: entryKey
|
|
243
|
-
}, config2);
|
|
391
|
+
const keyDataset = this.key["~run"]({ value: entryKey }, config$1);
|
|
244
392
|
if (keyDataset.issues) {
|
|
245
393
|
const pathItem = {
|
|
246
394
|
type: "object",
|
|
@@ -254,15 +402,12 @@ function record(key, value2, message) {
|
|
|
254
402
|
dataset.issues?.push(issue);
|
|
255
403
|
}
|
|
256
404
|
if (!dataset.issues) dataset.issues = keyDataset.issues;
|
|
257
|
-
if (
|
|
405
|
+
if (config$1.abortEarly) {
|
|
258
406
|
dataset.typed = false;
|
|
259
407
|
break;
|
|
260
408
|
}
|
|
261
409
|
}
|
|
262
|
-
const valueDataset = this.value
|
|
263
|
-
typed: false,
|
|
264
|
-
value: entryValue
|
|
265
|
-
}, config2);
|
|
410
|
+
const valueDataset = this.value["~run"]({ value: entryValue }, config$1);
|
|
266
411
|
if (valueDataset.issues) {
|
|
267
412
|
const pathItem = {
|
|
268
413
|
type: "object",
|
|
@@ -277,7 +422,7 @@ function record(key, value2, message) {
|
|
|
277
422
|
dataset.issues?.push(issue);
|
|
278
423
|
}
|
|
279
424
|
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
280
|
-
if (
|
|
425
|
+
if (config$1.abortEarly) {
|
|
281
426
|
dataset.typed = false;
|
|
282
427
|
break;
|
|
283
428
|
}
|
|
@@ -285,114 +430,146 @@ function record(key, value2, message) {
|
|
|
285
430
|
if (!keyDataset.typed || !valueDataset.typed) dataset.typed = false;
|
|
286
431
|
if (keyDataset.typed) dataset.value[keyDataset.value] = valueDataset.value;
|
|
287
432
|
}
|
|
288
|
-
} else _addIssue(this, "type", dataset,
|
|
433
|
+
} else _addIssue(this, "type", dataset, config$1);
|
|
289
434
|
return dataset;
|
|
290
435
|
}
|
|
291
436
|
};
|
|
292
437
|
}
|
|
293
|
-
|
|
438
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
439
|
+
function strictObject(entries$1, message$1) {
|
|
294
440
|
return {
|
|
295
441
|
kind: "schema",
|
|
296
442
|
type: "strict_object",
|
|
297
443
|
reference: strictObject,
|
|
298
444
|
expects: "Object",
|
|
299
445
|
async: false,
|
|
300
|
-
entries,
|
|
301
|
-
message,
|
|
302
|
-
|
|
446
|
+
entries: entries$1,
|
|
447
|
+
message: message$1,
|
|
448
|
+
get "~standard"() {
|
|
449
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
450
|
+
},
|
|
451
|
+
"~run"(dataset, config$1) {
|
|
303
452
|
const input = dataset.value;
|
|
304
453
|
if (input && typeof input === "object") {
|
|
305
454
|
dataset.typed = true;
|
|
306
455
|
dataset.value = {};
|
|
307
456
|
for (const key in this.entries) {
|
|
308
|
-
const
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
value:
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
457
|
+
const valueSchema = this.entries[key];
|
|
458
|
+
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
|
|
459
|
+
const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
|
|
460
|
+
const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
|
|
461
|
+
if (valueDataset.issues) {
|
|
462
|
+
const pathItem = {
|
|
463
|
+
type: "object",
|
|
464
|
+
origin: "value",
|
|
465
|
+
input,
|
|
466
|
+
key,
|
|
467
|
+
value: value$1
|
|
468
|
+
};
|
|
469
|
+
for (const issue of valueDataset.issues) {
|
|
470
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
471
|
+
else issue.path = [pathItem];
|
|
472
|
+
dataset.issues?.push(issue);
|
|
473
|
+
}
|
|
474
|
+
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
475
|
+
if (config$1.abortEarly) {
|
|
476
|
+
dataset.typed = false;
|
|
477
|
+
break;
|
|
478
|
+
}
|
|
330
479
|
}
|
|
480
|
+
if (!valueDataset.typed) dataset.typed = false;
|
|
481
|
+
dataset.value[key] = valueDataset.value;
|
|
482
|
+
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
|
|
483
|
+
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
|
|
484
|
+
_addIssue(this, "key", dataset, config$1, {
|
|
485
|
+
input: void 0,
|
|
486
|
+
expected: `"${key}"`,
|
|
487
|
+
path: [{
|
|
488
|
+
type: "object",
|
|
489
|
+
origin: "key",
|
|
490
|
+
input,
|
|
491
|
+
key,
|
|
492
|
+
value: input[key]
|
|
493
|
+
}]
|
|
494
|
+
});
|
|
495
|
+
if (config$1.abortEarly) break;
|
|
331
496
|
}
|
|
332
|
-
if (!valueDataset.typed) dataset.typed = false;
|
|
333
|
-
if (valueDataset.value !== void 0 || key in input) dataset.value[key] = valueDataset.value;
|
|
334
497
|
}
|
|
335
|
-
if (!dataset.issues || !
|
|
498
|
+
if (!dataset.issues || !config$1.abortEarly) {
|
|
336
499
|
for (const key in input) if (!(key in this.entries)) {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
input: value2,
|
|
500
|
+
_addIssue(this, "key", dataset, config$1, {
|
|
501
|
+
input: key,
|
|
340
502
|
expected: "never",
|
|
341
503
|
path: [{
|
|
342
504
|
type: "object",
|
|
343
|
-
origin: "
|
|
505
|
+
origin: "key",
|
|
344
506
|
input,
|
|
345
507
|
key,
|
|
346
|
-
value:
|
|
508
|
+
value: input[key]
|
|
347
509
|
}]
|
|
348
510
|
});
|
|
349
511
|
break;
|
|
350
512
|
}
|
|
351
513
|
}
|
|
352
|
-
} else _addIssue(this, "type", dataset,
|
|
514
|
+
} else _addIssue(this, "type", dataset, config$1);
|
|
353
515
|
return dataset;
|
|
354
516
|
}
|
|
355
517
|
};
|
|
356
518
|
}
|
|
357
|
-
|
|
519
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
520
|
+
function string(message$1) {
|
|
358
521
|
return {
|
|
359
522
|
kind: "schema",
|
|
360
523
|
type: "string",
|
|
361
524
|
reference: string,
|
|
362
525
|
expects: "string",
|
|
363
526
|
async: false,
|
|
364
|
-
message,
|
|
365
|
-
|
|
527
|
+
message: message$1,
|
|
528
|
+
get "~standard"() {
|
|
529
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
530
|
+
},
|
|
531
|
+
"~run"(dataset, config$1) {
|
|
366
532
|
if (typeof dataset.value === "string") dataset.typed = true;
|
|
367
|
-
else _addIssue(this, "type", dataset,
|
|
533
|
+
else _addIssue(this, "type", dataset, config$1);
|
|
368
534
|
return dataset;
|
|
369
535
|
}
|
|
370
536
|
};
|
|
371
537
|
}
|
|
538
|
+
/**
|
|
539
|
+
* Returns the sub issues of the provided datasets for the union issue.
|
|
540
|
+
*
|
|
541
|
+
* @param datasets The datasets.
|
|
542
|
+
*
|
|
543
|
+
* @returns The sub issues.
|
|
544
|
+
*
|
|
545
|
+
* @internal
|
|
546
|
+
*/
|
|
547
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
372
548
|
function _subIssues(datasets) {
|
|
373
549
|
let issues;
|
|
374
550
|
if (datasets) for (const dataset of datasets) if (issues) issues.push(...dataset.issues);
|
|
375
551
|
else issues = dataset.issues;
|
|
376
552
|
return issues;
|
|
377
553
|
}
|
|
378
|
-
|
|
554
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
555
|
+
function union(options$1, message$1) {
|
|
379
556
|
return {
|
|
380
557
|
kind: "schema",
|
|
381
558
|
type: "union",
|
|
382
559
|
reference: union,
|
|
383
|
-
expects: _joinExpects(options$1.map((option) => option.expects), "|"),
|
|
560
|
+
expects: /* @__PURE__ */ _joinExpects(options$1.map((option) => option.expects), "|"),
|
|
384
561
|
async: false,
|
|
385
562
|
options: options$1,
|
|
386
|
-
message,
|
|
387
|
-
|
|
563
|
+
message: message$1,
|
|
564
|
+
get "~standard"() {
|
|
565
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
566
|
+
},
|
|
567
|
+
"~run"(dataset, config$1) {
|
|
388
568
|
let validDataset;
|
|
389
569
|
let typedDatasets;
|
|
390
570
|
let untypedDatasets;
|
|
391
571
|
for (const schema of this.options) {
|
|
392
|
-
const optionDataset = schema
|
|
393
|
-
typed: false,
|
|
394
|
-
value: dataset.value
|
|
395
|
-
}, config2);
|
|
572
|
+
const optionDataset = schema["~run"]({ value: dataset.value }, config$1);
|
|
396
573
|
if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
|
|
397
574
|
else typedDatasets = [optionDataset];
|
|
398
575
|
else {
|
|
@@ -405,33 +582,43 @@ function union(options$1, message) {
|
|
|
405
582
|
if (validDataset) return validDataset;
|
|
406
583
|
if (typedDatasets) {
|
|
407
584
|
if (typedDatasets.length === 1) return typedDatasets[0];
|
|
408
|
-
_addIssue(this, "type", dataset,
|
|
585
|
+
_addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
|
|
409
586
|
dataset.typed = true;
|
|
410
587
|
} else if (untypedDatasets?.length === 1) return untypedDatasets[0];
|
|
411
|
-
else _addIssue(this, "type", dataset,
|
|
588
|
+
else _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
|
|
412
589
|
return dataset;
|
|
413
590
|
}
|
|
414
591
|
};
|
|
415
592
|
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
593
|
+
/**
|
|
594
|
+
* Parses an unknown input based on a schema.
|
|
595
|
+
*
|
|
596
|
+
* @param schema The schema to be used.
|
|
597
|
+
* @param input The input to be parsed.
|
|
598
|
+
* @param config The parse configuration.
|
|
599
|
+
*
|
|
600
|
+
* @returns The parsed input.
|
|
601
|
+
*/
|
|
602
|
+
function parse(schema, input, config$1) {
|
|
603
|
+
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
|
|
421
604
|
if (dataset.issues) throw new ValiError(dataset.issues);
|
|
422
605
|
return dataset.value;
|
|
423
606
|
}
|
|
424
|
-
|
|
607
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
608
|
+
function pipe(...pipe$1) {
|
|
425
609
|
return {
|
|
426
|
-
...
|
|
427
|
-
pipe:
|
|
428
|
-
|
|
429
|
-
|
|
610
|
+
...pipe$1[0],
|
|
611
|
+
pipe: pipe$1,
|
|
612
|
+
get "~standard"() {
|
|
613
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
614
|
+
},
|
|
615
|
+
"~run"(dataset, config$1) {
|
|
616
|
+
for (const item of pipe$1) if (item.kind !== "metadata") {
|
|
430
617
|
if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
|
|
431
618
|
dataset.typed = false;
|
|
432
619
|
break;
|
|
433
620
|
}
|
|
434
|
-
if (!dataset.issues || !
|
|
621
|
+
if (!dataset.issues || !config$1.abortEarly && !config$1.abortPipeEarly) dataset = item["~run"](dataset, config$1);
|
|
435
622
|
}
|
|
436
623
|
return dataset;
|
|
437
624
|
}
|
|
@@ -439,7 +626,7 @@ function pipe(...pipe2) {
|
|
|
439
626
|
}
|
|
440
627
|
|
|
441
628
|
//#endregion
|
|
442
|
-
//#region utils/errors.ts
|
|
629
|
+
//#region lib/cli/utils/errors.ts
|
|
443
630
|
var UnsupportedError = class extends Error {
|
|
444
631
|
constructor(reasons) {
|
|
445
632
|
super();
|
|
@@ -450,7 +637,7 @@ var UnsupportedError = class extends Error {
|
|
|
450
637
|
};
|
|
451
638
|
|
|
452
639
|
//#endregion
|
|
453
|
-
//#region utils/common.ts
|
|
640
|
+
//#region lib/cli/utils/common.ts
|
|
454
641
|
const NO_PREFIX = "--no-";
|
|
455
642
|
let options = [];
|
|
456
643
|
function getLongFlag(flags) {
|
|
@@ -550,14 +737,14 @@ function errorAndExit(message) {
|
|
|
550
737
|
}
|
|
551
738
|
|
|
552
739
|
//#endregion
|
|
553
|
-
//#region
|
|
554
|
-
function verifyCleanWorkingDirectory(cwd, gitCheck) {
|
|
740
|
+
//#region lib/cli/add/verifiers.ts
|
|
741
|
+
function verifyCleanWorkingDirectory(cwd$1, gitCheck) {
|
|
555
742
|
const verifications = [];
|
|
556
743
|
if (gitCheck) verifications.push({
|
|
557
744
|
name: "clean working directory",
|
|
558
745
|
run: async () => {
|
|
559
746
|
try {
|
|
560
|
-
const { stdout: stdout$1 } = await promisify(exec)("git status --short", { cwd });
|
|
747
|
+
const { stdout: stdout$1 } = await promisify(exec)("git status --short", { cwd: cwd$1 });
|
|
561
748
|
if (stdout$1) return {
|
|
562
749
|
success: false,
|
|
563
750
|
message: "Found modified files"
|
|
@@ -596,7 +783,7 @@ function verifyUnsupportedAddons(addons, addonSetupResult) {
|
|
|
596
783
|
}
|
|
597
784
|
|
|
598
785
|
//#endregion
|
|
599
|
-
//#region
|
|
786
|
+
//#region lib/cli/add/fetch-packages.ts
|
|
600
787
|
const NODE_MODULES = fileURLToPath(new URL("../node_modules", import.meta.url));
|
|
601
788
|
const REGISTRY = "https://registry.npmjs.org";
|
|
602
789
|
const Directive = {
|
|
@@ -608,10 +795,10 @@ function verifyPackage(pkg, specifier) {
|
|
|
608
795
|
...pkg.dependencies,
|
|
609
796
|
...pkg.peerDependencies
|
|
610
797
|
};
|
|
611
|
-
if (!deps["
|
|
798
|
+
if (!deps["sv"]) throw new Error(`Invalid add-on package specified: '${specifier}' is missing a dependency on 'sv' in its 'package.json'`);
|
|
612
799
|
for (const dep of Object.keys(deps)) {
|
|
613
|
-
if (dep === "
|
|
614
|
-
throw new Error(`Invalid add-on package detected: '${specifier}'\nCommunity addons should not have any external 'dependencies' besides '
|
|
800
|
+
if (dep === "sv") continue;
|
|
801
|
+
throw new Error(`Invalid add-on package detected: '${specifier}'\nCommunity addons should not have any external 'dependencies' besides 'sv'. Consider bundling your dependencies if they are necessary`);
|
|
615
802
|
}
|
|
616
803
|
}
|
|
617
804
|
/**
|
|
@@ -636,10 +823,10 @@ async function downloadPackage(options$1) {
|
|
|
636
823
|
const { default: details } = await import(pkg.name);
|
|
637
824
|
return details;
|
|
638
825
|
}
|
|
639
|
-
async function getPackageJSON({ cwd, packageName }) {
|
|
826
|
+
async function getPackageJSON({ cwd: cwd$1, packageName }) {
|
|
640
827
|
let npm = packageName;
|
|
641
828
|
if (packageName.startsWith(Directive.file)) {
|
|
642
|
-
const pkgPath = path.resolve(cwd, packageName.slice(Directive.file.length));
|
|
829
|
+
const pkgPath = path.resolve(cwd$1, packageName.slice(Directive.file.length));
|
|
643
830
|
const pkgJSONPath = path.resolve(pkgPath, "package.json");
|
|
644
831
|
const json = fs.readFileSync(pkgJSONPath, "utf8");
|
|
645
832
|
const pkg$1 = JSON.parse(json);
|
|
@@ -675,7 +862,7 @@ async function fetchPackageJSON(packageName) {
|
|
|
675
862
|
}
|
|
676
863
|
|
|
677
864
|
//#endregion
|
|
678
|
-
//#region
|
|
865
|
+
//#region lib/cli/add/index.ts
|
|
679
866
|
var import_picocolors$2 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
680
867
|
const officialAddons$1 = Object.values(officialAddons);
|
|
681
868
|
const aliases = officialAddons$1.map((c) => c.alias).filter((v) => v !== void 0);
|
|
@@ -1172,7 +1359,7 @@ function getOptionChoices(details) {
|
|
|
1172
1359
|
groups
|
|
1173
1360
|
};
|
|
1174
1361
|
}
|
|
1175
|
-
async function resolveCommunityAddons(cwd, community) {
|
|
1362
|
+
async function resolveCommunityAddons(cwd$1, community) {
|
|
1176
1363
|
const selectedAddons = [];
|
|
1177
1364
|
const addons = community.map((id) => {
|
|
1178
1365
|
if (Object.values(Directive).some((directive) => id.startsWith(directive))) return id;
|
|
@@ -1184,7 +1371,7 @@ async function resolveCommunityAddons(cwd, community) {
|
|
|
1184
1371
|
start("Resolving community add-on packages");
|
|
1185
1372
|
const pkgs = await Promise.all(addons.map(async (id) => {
|
|
1186
1373
|
return await getPackageJSON({
|
|
1187
|
-
cwd,
|
|
1374
|
+
cwd: cwd$1,
|
|
1188
1375
|
packageName: id
|
|
1189
1376
|
});
|
|
1190
1377
|
}));
|
|
@@ -1215,7 +1402,7 @@ async function resolveCommunityAddons(cwd, community) {
|
|
|
1215
1402
|
}
|
|
1216
1403
|
|
|
1217
1404
|
//#endregion
|
|
1218
|
-
//#region
|
|
1405
|
+
//#region lib/create/playground.ts
|
|
1219
1406
|
function validatePlaygroundUrl(link) {
|
|
1220
1407
|
try {
|
|
1221
1408
|
const url = new URL(link);
|
|
@@ -1271,8 +1458,10 @@ function detectPlaygroundDependencies(files) {
|
|
|
1271
1458
|
];
|
|
1272
1459
|
for (const file of files) {
|
|
1273
1460
|
let ast;
|
|
1274
|
-
if (file.name.endsWith(".svelte"))
|
|
1275
|
-
|
|
1461
|
+
if (file.name.endsWith(".svelte")) {
|
|
1462
|
+
const { ast: svelteAst } = parseSvelte(file.content);
|
|
1463
|
+
ast = ensureScript(svelteAst);
|
|
1464
|
+
} else if (file.name.endsWith(".js") || file.name.endsWith(".ts")) ast = parseScript(file.content).ast;
|
|
1276
1465
|
if (!ast) continue;
|
|
1277
1466
|
ast.body.filter((node) => node.type === "ImportDeclaration").map((node) => node.source.value).filter((importPath) => !importPath.startsWith("./") && !importPath.startsWith("/")).filter((importPath) => !excludedPrefixes.some((prefix) => importPath.startsWith(prefix))).map(extractPackageInfo).forEach(({ pkgName, version: version$1 }) => packages.set(pkgName, version$1));
|
|
1278
1467
|
}
|
|
@@ -1303,13 +1492,13 @@ function extractPackageVersion(pkgName) {
|
|
|
1303
1492
|
if (pkgName.includes("@", 1)) [, version$1] = pkgName.split("@");
|
|
1304
1493
|
return version$1;
|
|
1305
1494
|
}
|
|
1306
|
-
function setupPlaygroundProject(url, playground, cwd, installDependencies$1
|
|
1495
|
+
function setupPlaygroundProject(url, playground, cwd$1, installDependencies$1) {
|
|
1307
1496
|
const mainFile = playground.files.find((file) => file.name === "App.svelte");
|
|
1308
1497
|
if (!mainFile) throw new Error("Failed to find `App.svelte` entrypoint.");
|
|
1309
1498
|
const dependencies = detectPlaygroundDependencies(playground.files);
|
|
1310
1499
|
for (const file of playground.files) {
|
|
1311
1500
|
for (const [pkg, version$1] of dependencies) if (version$1 !== "latest") file.content = file.content.replaceAll(`${pkg}@${version$1}`, pkg);
|
|
1312
|
-
const filePath$1 = path.join(cwd, "src", "lib", "playground", file.name);
|
|
1501
|
+
const filePath$1 = path.join(cwd$1, "src", "lib", "playground", file.name);
|
|
1313
1502
|
fs.mkdirSync(path.dirname(filePath$1), { recursive: true });
|
|
1314
1503
|
fs.writeFileSync(filePath$1, file.content, "utf8");
|
|
1315
1504
|
}
|
|
@@ -1318,35 +1507,38 @@ function setupPlaygroundProject(url, playground, cwd, installDependencies$1, typ
|
|
|
1318
1507
|
for (const file of playgroundFiles) {
|
|
1319
1508
|
let contentToWrite = file.contents;
|
|
1320
1509
|
if (file.name === "src/lib/PlaygroundLayout.svelte") {
|
|
1321
|
-
const {
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1510
|
+
const { ast: ast$1, generateCode: generateCode$1 } = parseSvelte(file.contents);
|
|
1511
|
+
walk(ensureScript(ast$1), null, { Literal(node) {
|
|
1512
|
+
if (node.value === "$sv-title-$sv") {
|
|
1513
|
+
node.value = playground.name;
|
|
1514
|
+
node.raw = void 0;
|
|
1515
|
+
} else if (node.value === "$sv-url-$sv") {
|
|
1516
|
+
node.value = url;
|
|
1517
|
+
node.raw = void 0;
|
|
1518
|
+
}
|
|
1519
|
+
} });
|
|
1520
|
+
contentToWrite = generateCode$1();
|
|
1328
1521
|
}
|
|
1329
|
-
fs.writeFileSync(path.join(cwd, file.name), contentToWrite, "utf-8");
|
|
1522
|
+
fs.writeFileSync(path.join(cwd$1, file.name), contentToWrite, "utf-8");
|
|
1330
1523
|
}
|
|
1331
1524
|
}
|
|
1332
|
-
const filePath = path.join(cwd, "src/routes/+page.svelte");
|
|
1333
|
-
const {
|
|
1334
|
-
|
|
1525
|
+
const filePath = path.join(cwd$1, "src/routes/+page.svelte");
|
|
1526
|
+
const { ast, generateCode } = parseSvelte(fs.readFileSync(filePath, "utf-8"));
|
|
1527
|
+
const scriptAst = ensureScript(ast);
|
|
1528
|
+
addDefault(scriptAst, {
|
|
1335
1529
|
as: "App",
|
|
1336
1530
|
from: `$lib/playground/${mainFile.name}`
|
|
1337
1531
|
});
|
|
1338
|
-
addDefault(
|
|
1532
|
+
addDefault(scriptAst, {
|
|
1339
1533
|
as: "PlaygroundLayout",
|
|
1340
1534
|
from: `$lib/PlaygroundLayout.svelte`
|
|
1341
1535
|
});
|
|
1342
|
-
|
|
1343
|
-
script: script.generateCode(),
|
|
1344
|
-
template: `<PlaygroundLayout>
|
|
1536
|
+
ast.fragment.nodes.push(...toFragment(`<PlaygroundLayout>
|
|
1345
1537
|
<App />
|
|
1346
|
-
</PlaygroundLayout>`
|
|
1347
|
-
|
|
1538
|
+
</PlaygroundLayout>`));
|
|
1539
|
+
const newContent = generateCode();
|
|
1348
1540
|
fs.writeFileSync(filePath, newContent, "utf-8");
|
|
1349
|
-
const pkgPath = path.join(cwd, "package.json");
|
|
1541
|
+
const pkgPath = path.join(cwd$1, "package.json");
|
|
1350
1542
|
const pkgJson = parseJson(fs.readFileSync(pkgPath, "utf-8"));
|
|
1351
1543
|
let updatePackageJson = false;
|
|
1352
1544
|
if (installDependencies$1 && dependencies.size >= 0) {
|
|
@@ -1356,9 +1548,9 @@ function setupPlaygroundProject(url, playground, cwd, installDependencies$1, typ
|
|
|
1356
1548
|
}
|
|
1357
1549
|
let experimentalAsyncNeeded = true;
|
|
1358
1550
|
const addExperimentalAsync = () => {
|
|
1359
|
-
const svelteConfigPath = path.join(cwd, "svelte.config.js");
|
|
1360
|
-
const { ast, generateCode: generateCode$1 } = parseScript(fs.readFileSync(svelteConfigPath, "utf-8"));
|
|
1361
|
-
const { value: config } = createDefault(ast, { fallback: create$2({}) });
|
|
1551
|
+
const svelteConfigPath = path.join(cwd$1, "svelte.config.js");
|
|
1552
|
+
const { ast: ast$1, generateCode: generateCode$1 } = parseScript(fs.readFileSync(svelteConfigPath, "utf-8"));
|
|
1553
|
+
const { value: config } = createDefault(ast$1, { fallback: create$2({}) });
|
|
1362
1554
|
overrideProperties(config, { compilerOptions: { experimental: { async: true } } });
|
|
1363
1555
|
fs.writeFileSync(svelteConfigPath, generateCode$1(), "utf-8");
|
|
1364
1556
|
};
|
|
@@ -1376,7 +1568,7 @@ function setupPlaygroundProject(url, playground, cwd, installDependencies$1, typ
|
|
|
1376
1568
|
}
|
|
1377
1569
|
|
|
1378
1570
|
//#endregion
|
|
1379
|
-
//#region
|
|
1571
|
+
//#region lib/cli/create.ts
|
|
1380
1572
|
var import_picocolors$1 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
1381
1573
|
const langs = ["ts", "jsdoc"];
|
|
1382
1574
|
const langMap = {
|
|
@@ -1400,14 +1592,14 @@ const OptionsSchema = strictObject({
|
|
|
1400
1592
|
dirCheck: boolean()
|
|
1401
1593
|
});
|
|
1402
1594
|
const create = new Command("create").description("scaffolds a new SvelteKit project").argument("[path]", "where the project will be created").addOption(templateOption).addOption(langOption).option("--no-types").addOption(noAddonsOption).addOption(addOption).option("--no-install", "skip installing dependencies").option("--from-playground <url>", "create a project from the svelte playground").option("--no-dir-check", "even if the folder is not empty, no prompt will be shown").addOption(installOption).configureHelp(helpConfig).action((projectPath, opts) => {
|
|
1403
|
-
const cwd = parse(ProjectPathSchema, projectPath);
|
|
1595
|
+
const cwd$1 = parse(ProjectPathSchema, projectPath);
|
|
1404
1596
|
const options$1 = parse(OptionsSchema, opts);
|
|
1405
1597
|
if (options$1.fromPlayground && !validatePlaygroundUrl(options$1.fromPlayground)) {
|
|
1406
1598
|
console.error(import_picocolors$1.default.red(`Error: Invalid playground URL: ${options$1.fromPlayground}`));
|
|
1407
1599
|
process.exit(1);
|
|
1408
1600
|
}
|
|
1409
1601
|
runCommand(async () => {
|
|
1410
|
-
const { directory, addOnNextSteps, packageManager } = await createProject(cwd, options$1);
|
|
1602
|
+
const { directory, addOnNextSteps, packageManager } = await createProject(cwd$1, options$1);
|
|
1411
1603
|
const highlight = (str) => import_picocolors$1.default.bold(import_picocolors$1.default.cyan(str));
|
|
1412
1604
|
let i = 1;
|
|
1413
1605
|
const initialSteps = ["📁 Project steps", ""];
|
|
@@ -1440,12 +1632,12 @@ const create = new Command("create").description("scaffolds a new SvelteKit proj
|
|
|
1440
1632
|
Ke(steps.join("\n"), "What's next?", { format: (line) => line });
|
|
1441
1633
|
});
|
|
1442
1634
|
}).showHelpAfterError(true);
|
|
1443
|
-
async function createProject(cwd, options$1) {
|
|
1635
|
+
async function createProject(cwd$1, options$1) {
|
|
1444
1636
|
if (options$1.fromPlayground) T.warn("The Svelte maintainers have not reviewed playgrounds for malicious code. Use at your discretion.");
|
|
1445
1637
|
const { directory, template, language } = await We({
|
|
1446
1638
|
directory: () => {
|
|
1447
1639
|
const defaultPath = "./";
|
|
1448
|
-
if (cwd) return Promise.resolve(cwd);
|
|
1640
|
+
if (cwd$1) return Promise.resolve(cwd$1);
|
|
1449
1641
|
return et({
|
|
1450
1642
|
message: "Where would you like your project to be created?",
|
|
1451
1643
|
placeholder: ` (hit Enter to use '${defaultPath}')`,
|
|
@@ -1539,7 +1731,7 @@ async function createProject(cwd, options$1) {
|
|
|
1539
1731
|
template,
|
|
1540
1732
|
types: language
|
|
1541
1733
|
});
|
|
1542
|
-
if (options$1.fromPlayground) await createProjectFromPlayground(options$1.fromPlayground, projectPath
|
|
1734
|
+
if (options$1.fromPlayground) await createProjectFromPlayground(options$1.fromPlayground, projectPath);
|
|
1543
1735
|
T.success("Project created");
|
|
1544
1736
|
let addOnNextSteps = [];
|
|
1545
1737
|
let argsFormattedAddons = [];
|
|
@@ -1587,10 +1779,10 @@ async function createProject(cwd, options$1) {
|
|
|
1587
1779
|
packageManager
|
|
1588
1780
|
};
|
|
1589
1781
|
}
|
|
1590
|
-
async function createProjectFromPlayground(url, cwd
|
|
1782
|
+
async function createProjectFromPlayground(url, cwd$1) {
|
|
1591
1783
|
const playground = await downloadPlaygroundData(parsePlaygroundUrl(url));
|
|
1592
1784
|
const dependencies = detectPlaygroundDependencies(playground.files);
|
|
1593
|
-
setupPlaygroundProject(url, playground, cwd, await confirmExternalDependencies(Array.from(dependencies.keys()))
|
|
1785
|
+
setupPlaygroundProject(url, playground, cwd$1, await confirmExternalDependencies(Array.from(dependencies.keys())));
|
|
1594
1786
|
}
|
|
1595
1787
|
async function confirmExternalDependencies(dependencies) {
|
|
1596
1788
|
if (dependencies.length === 0) return false;
|
|
@@ -1606,7 +1798,7 @@ async function confirmExternalDependencies(dependencies) {
|
|
|
1606
1798
|
}
|
|
1607
1799
|
return installDeps;
|
|
1608
1800
|
}
|
|
1609
|
-
async function createVirtualWorkspace({ cwd, template, type }) {
|
|
1801
|
+
async function createVirtualWorkspace({ cwd: cwd$1, template, type }) {
|
|
1610
1802
|
const override = { dependencies: {} };
|
|
1611
1803
|
if (template === "minimal" || template === "demo" || template === "library") override.kit = {
|
|
1612
1804
|
routesDirectory: "src/routes",
|
|
@@ -1619,7 +1811,7 @@ async function createVirtualWorkspace({ cwd, template, type }) {
|
|
|
1619
1811
|
...override.dependencies
|
|
1620
1812
|
};
|
|
1621
1813
|
const tentativeWorkspace = await createWorkspace({
|
|
1622
|
-
cwd,
|
|
1814
|
+
cwd: cwd$1,
|
|
1623
1815
|
override
|
|
1624
1816
|
});
|
|
1625
1817
|
return {
|
|
@@ -1634,11 +1826,11 @@ async function createVirtualWorkspace({ cwd, template, type }) {
|
|
|
1634
1826
|
}
|
|
1635
1827
|
|
|
1636
1828
|
//#endregion
|
|
1637
|
-
//#region
|
|
1829
|
+
//#region lib/cli/migrate.ts
|
|
1638
1830
|
const migrate = new Command("migrate").description("a CLI for migrating Svelte(Kit) codebases").argument("[migration]", "migration to run").option("-C, --cwd <path>", "path to working directory", process.cwd()).action((migration, options$1) => {
|
|
1639
1831
|
runMigrate(options$1.cwd, [migration]);
|
|
1640
1832
|
});
|
|
1641
|
-
function runMigrate(cwd, args) {
|
|
1833
|
+
function runMigrate(cwd$1, args) {
|
|
1642
1834
|
const pm = getUserAgent() ?? "npm";
|
|
1643
1835
|
try {
|
|
1644
1836
|
const cmdArgs = ["svelte-migrate@latest", ...args];
|
|
@@ -1646,7 +1838,7 @@ function runMigrate(cwd, args) {
|
|
|
1646
1838
|
const cmd = resolveCommand(pm, "execute", cmdArgs);
|
|
1647
1839
|
execSync(`${cmd.command} ${cmd.args.join(" ")}`, {
|
|
1648
1840
|
stdio: "inherit",
|
|
1649
|
-
cwd
|
|
1841
|
+
cwd: cwd$1
|
|
1650
1842
|
});
|
|
1651
1843
|
} catch (error) {
|
|
1652
1844
|
forwardExitCode(error);
|
|
@@ -1654,19 +1846,19 @@ function runMigrate(cwd, args) {
|
|
|
1654
1846
|
}
|
|
1655
1847
|
|
|
1656
1848
|
//#endregion
|
|
1657
|
-
//#region
|
|
1849
|
+
//#region lib/cli/check.ts
|
|
1658
1850
|
var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
1659
1851
|
const check = new Command("check").description("a CLI for checking your Svelte code").allowUnknownOption(true).allowExcessArguments(true).option("-C, --cwd <path>", "path to working directory", process.cwd()).configureHelp({ formatHelp() {
|
|
1660
1852
|
runCheck(process.cwd(), ["--help"]);
|
|
1661
1853
|
return "";
|
|
1662
1854
|
} }).action((options$1, check$1) => {
|
|
1663
|
-
const cwd = options$1.cwd;
|
|
1855
|
+
const cwd$1 = options$1.cwd;
|
|
1664
1856
|
const args = check$1.args;
|
|
1665
|
-
runCheck(cwd, args);
|
|
1857
|
+
runCheck(cwd$1, args);
|
|
1666
1858
|
});
|
|
1667
|
-
function runCheck(cwd, args) {
|
|
1859
|
+
function runCheck(cwd$1, args) {
|
|
1668
1860
|
const pm = getUserAgent() ?? "npm";
|
|
1669
|
-
if (!from(cwd, "svelte-check", true)) {
|
|
1861
|
+
if (!from(cwd$1, "svelte-check", true)) {
|
|
1670
1862
|
const cmd = resolveCommand(pm, "add", ["-D", "svelte-check"]);
|
|
1671
1863
|
console.error(`'svelte-check' is not installed locally. Install it with: ${import_picocolors.default.bold(`${cmd.command} ${cmd.args.join(" ")}`)}`);
|
|
1672
1864
|
process.exit(1);
|
|
@@ -1675,7 +1867,7 @@ function runCheck(cwd, args) {
|
|
|
1675
1867
|
const cmd = resolveCommand(pm, "execute-local", ["svelte-check", ...args]);
|
|
1676
1868
|
execSync(`${cmd.command} ${cmd.args.join(" ")}`, {
|
|
1677
1869
|
stdio: "inherit",
|
|
1678
|
-
cwd
|
|
1870
|
+
cwd: cwd$1
|
|
1679
1871
|
});
|
|
1680
1872
|
} catch (error) {
|
|
1681
1873
|
forwardExitCode(error);
|