sv 0.12.2 → 0.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.mjs +5 -5
- package/dist/engine-BZ0rj9tz.d.mts +359 -0
- package/dist/{add-RNKqR0_d.mjs → engine-BmcQ5Tk6.mjs} +2252 -2101
- package/dist/{package-manager-B3sMOeTk.mjs → package-manager-BYzDyeam.mjs} +2650 -231
- package/dist/shared.json +3 -3
- package/dist/src/index.d.mts +25 -0
- package/dist/src/index.mjs +4 -0
- package/dist/{lib → src}/testing.d.mts +4 -5
- package/dist/{lib → src}/testing.mjs +2 -4
- package/dist/templates/addon/assets/src/index.js +2 -1
- package/dist/templates/addon/package.json +2 -1
- package/dist/templates/demo/assets/DOT-vscode/extensions.json +3 -0
- package/dist/templates/library/assets/DOT-vscode/extensions.json +3 -0
- package/dist/templates/minimal/assets/DOT-vscode/extensions.json +3 -0
- package/package.json +11 -22
- package/dist/add-BP-WJ6Sw.d.mts +0 -38
- package/dist/chunk-BcJDCUAU.mjs +0 -45
- package/dist/core-VSHdSalh.d.mts +0 -788
- package/dist/lib/core.d.mts +0 -2
- package/dist/lib/core.mjs +0 -3
- package/dist/lib/index.d.mts +0 -16
- package/dist/lib/index.mjs +0 -5
- package/dist/utils-D-OWcBXG.mjs +0 -41170
package/dist/core-VSHdSalh.d.mts
DELETED
|
@@ -1,788 +0,0 @@
|
|
|
1
|
-
import { TomlTable } from "smol-toml";
|
|
2
|
-
import * as estree from "estree";
|
|
3
|
-
import { BaseNode as BaseNode$1 } from "estree";
|
|
4
|
-
import { AST as SvelteAst } from "svelte/compiler";
|
|
5
|
-
import * as yaml from "yaml";
|
|
6
|
-
import { log } from "@clack/prompts";
|
|
7
|
-
import dedent from "dedent";
|
|
8
|
-
import * as Walker from "zimmerframe";
|
|
9
|
-
import { AgentName } from "package-manager-detector";
|
|
10
|
-
import { resolveCommand } from "package-manager-detector/commands";
|
|
11
|
-
|
|
12
|
-
//#region lib/core/tooling/js/ts-estree.d.ts
|
|
13
|
-
declare module "estree" {
|
|
14
|
-
interface TSTypeAnnotation {
|
|
15
|
-
type: "TSTypeAnnotation";
|
|
16
|
-
typeAnnotation: TSStringKeyword | TSTypeReference | TSUnionType | TSIndexedAccessType;
|
|
17
|
-
}
|
|
18
|
-
interface TSStringKeyword {
|
|
19
|
-
type: "TSStringKeyword";
|
|
20
|
-
}
|
|
21
|
-
interface TSNullKeyword {
|
|
22
|
-
type: "TSNullKeyword";
|
|
23
|
-
}
|
|
24
|
-
interface TSTypeReference {
|
|
25
|
-
type: "TSTypeReference";
|
|
26
|
-
typeName: Identifier;
|
|
27
|
-
}
|
|
28
|
-
interface TSAsExpression extends BaseNode {
|
|
29
|
-
type: "TSAsExpression";
|
|
30
|
-
expression: Expression;
|
|
31
|
-
typeAnnotation: TSTypeAnnotation["typeAnnotation"];
|
|
32
|
-
}
|
|
33
|
-
interface TSModuleDeclaration extends BaseNode {
|
|
34
|
-
type: "TSModuleDeclaration";
|
|
35
|
-
global: boolean;
|
|
36
|
-
declare: boolean;
|
|
37
|
-
id: Identifier;
|
|
38
|
-
body: TSModuleBlock;
|
|
39
|
-
}
|
|
40
|
-
interface TSModuleBlock extends BaseNode {
|
|
41
|
-
type: "TSModuleBlock";
|
|
42
|
-
body: Array<TSModuleDeclaration | TSInterfaceDeclaration>;
|
|
43
|
-
}
|
|
44
|
-
interface TSInterfaceDeclaration extends BaseNode {
|
|
45
|
-
type: "TSInterfaceDeclaration";
|
|
46
|
-
id: Identifier;
|
|
47
|
-
body: TSInterfaceBody;
|
|
48
|
-
}
|
|
49
|
-
interface TSInterfaceBody extends BaseNode {
|
|
50
|
-
type: "TSInterfaceBody";
|
|
51
|
-
body: TSPropertySignature[];
|
|
52
|
-
}
|
|
53
|
-
interface TSPropertySignature extends BaseNode {
|
|
54
|
-
type: "TSPropertySignature";
|
|
55
|
-
computed: boolean;
|
|
56
|
-
key: Identifier;
|
|
57
|
-
optional?: boolean;
|
|
58
|
-
typeAnnotation: TSTypeAnnotation;
|
|
59
|
-
}
|
|
60
|
-
interface TSProgram extends Omit<Program, "body"> {
|
|
61
|
-
body: Array<Directive | Statement | ModuleDeclaration | TSModuleDeclaration>;
|
|
62
|
-
}
|
|
63
|
-
interface TSUnionType {
|
|
64
|
-
type: "TSUnionType";
|
|
65
|
-
types: Array<TSNullKeyword | TSTypeReference | TSImportType>;
|
|
66
|
-
}
|
|
67
|
-
interface TSImportType {
|
|
68
|
-
type: "TSImportType";
|
|
69
|
-
argument: Literal;
|
|
70
|
-
qualifier: Identifier;
|
|
71
|
-
}
|
|
72
|
-
interface TSIndexedAccessType {
|
|
73
|
-
type: "TSIndexedAccessType";
|
|
74
|
-
objectType: TSImportType;
|
|
75
|
-
indexType: TSLiteralType;
|
|
76
|
-
}
|
|
77
|
-
interface TSLiteralType {
|
|
78
|
-
type: "TSLiteralType";
|
|
79
|
-
literal: Literal;
|
|
80
|
-
}
|
|
81
|
-
interface TSSatisfiesExpression extends BaseNode {
|
|
82
|
-
type: "TSSatisfiesExpression";
|
|
83
|
-
expression: Expression;
|
|
84
|
-
typeAnnotation: TSTypeAnnotation["typeAnnotation"];
|
|
85
|
-
}
|
|
86
|
-
interface BaseNodeWithoutComments {
|
|
87
|
-
type: string;
|
|
88
|
-
loc?: SourceLocation | null | undefined;
|
|
89
|
-
range?: [number, number] | undefined;
|
|
90
|
-
start?: number;
|
|
91
|
-
end?: number;
|
|
92
|
-
}
|
|
93
|
-
interface Identifier {
|
|
94
|
-
typeAnnotation?: TSTypeAnnotation;
|
|
95
|
-
}
|
|
96
|
-
interface ExpressionMap {
|
|
97
|
-
TSAsExpression: TSAsExpression;
|
|
98
|
-
TSSatisfiesExpression: TSSatisfiesExpression;
|
|
99
|
-
}
|
|
100
|
-
interface NodeMap {
|
|
101
|
-
TSModuleDeclaration: TSModuleDeclaration;
|
|
102
|
-
TSInterfaceDeclaration: TSInterfaceDeclaration;
|
|
103
|
-
}
|
|
104
|
-
interface ImportDeclaration {
|
|
105
|
-
importKind: "type" | "value";
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
//#endregion
|
|
109
|
-
//#region lib/core/tooling/index.d.ts
|
|
110
|
-
declare function parseYaml$1(content: string): ReturnType<typeof yaml.parseDocument>;
|
|
111
|
-
type CommentType = {
|
|
112
|
-
type: "Line" | "Block";
|
|
113
|
-
value: string;
|
|
114
|
-
};
|
|
115
|
-
declare class Comments {
|
|
116
|
-
private original;
|
|
117
|
-
private leading;
|
|
118
|
-
private trailing;
|
|
119
|
-
constructor();
|
|
120
|
-
add(node: BaseNode$1, comment: CommentType, options?: {
|
|
121
|
-
position?: "leading" | "trailing";
|
|
122
|
-
}): void;
|
|
123
|
-
remove(predicate: (comment: estree.Comment) => boolean | undefined | null): void;
|
|
124
|
-
}
|
|
125
|
-
//#endregion
|
|
126
|
-
//#region lib/core/tooling/parsers.d.ts
|
|
127
|
-
type ParseBase = {
|
|
128
|
-
source: string;
|
|
129
|
-
/**
|
|
130
|
-
* Generate the code after manipulating the `ast`.
|
|
131
|
-
*
|
|
132
|
-
* ```ts
|
|
133
|
-
* import { svelte } from 'sv/core';
|
|
134
|
-
* const { ast, generateCode } = parse.svelte(content);
|
|
135
|
-
*
|
|
136
|
-
* svelte.addFragment(ast, '<p>Hello World</p>');
|
|
137
|
-
*
|
|
138
|
-
* const code = generateCode();
|
|
139
|
-
* ```
|
|
140
|
-
*/
|
|
141
|
-
generateCode(): string;
|
|
142
|
-
};
|
|
143
|
-
declare function parseScript(source: string): {
|
|
144
|
-
ast: estree.Program;
|
|
145
|
-
comments: Comments;
|
|
146
|
-
} & ParseBase;
|
|
147
|
-
declare function parseCss(source: string): {
|
|
148
|
-
ast: Omit<SvelteAst.CSS.StyleSheetBase, "attributes" | "content">;
|
|
149
|
-
} & ParseBase;
|
|
150
|
-
declare function parseHtml(source: string): {
|
|
151
|
-
ast: SvelteAst.Fragment;
|
|
152
|
-
} & ParseBase;
|
|
153
|
-
declare function parseJson(source: string): {
|
|
154
|
-
data: any;
|
|
155
|
-
} & ParseBase;
|
|
156
|
-
declare function parseYaml(source: string): {
|
|
157
|
-
data: ReturnType<typeof parseYaml$1>;
|
|
158
|
-
} & ParseBase;
|
|
159
|
-
declare function parseSvelte(source: string): {
|
|
160
|
-
ast: SvelteAst.Root;
|
|
161
|
-
} & ParseBase;
|
|
162
|
-
declare function parseToml(source: string): {
|
|
163
|
-
data: TomlTable;
|
|
164
|
-
} & ParseBase;
|
|
165
|
-
//#endregion
|
|
166
|
-
//#region lib/addons/_engine/official.d.ts
|
|
167
|
-
type OfficialAddons = {
|
|
168
|
-
prettier: Addon<any>;
|
|
169
|
-
eslint: Addon<any>;
|
|
170
|
-
vitest: Addon<any>;
|
|
171
|
-
playwright: Addon<any>;
|
|
172
|
-
tailwindcss: Addon<any>;
|
|
173
|
-
sveltekitAdapter: Addon<any>;
|
|
174
|
-
devtoolsJson: Addon<any>;
|
|
175
|
-
drizzle: Addon<any>;
|
|
176
|
-
betterAuth: Addon<any>;
|
|
177
|
-
mdsvex: Addon<any>;
|
|
178
|
-
paraglide: Addon<any>;
|
|
179
|
-
storybook: Addon<any>;
|
|
180
|
-
mcp: Addon<any>;
|
|
181
|
-
};
|
|
182
|
-
declare const officialAddons: OfficialAddons;
|
|
183
|
-
//#endregion
|
|
184
|
-
//#region lib/core/addon/options.d.ts
|
|
185
|
-
type BooleanQuestion = {
|
|
186
|
-
type: "boolean";
|
|
187
|
-
default: boolean;
|
|
188
|
-
};
|
|
189
|
-
type StringQuestion = {
|
|
190
|
-
type: "string";
|
|
191
|
-
default: string;
|
|
192
|
-
validate?: (value: string | undefined) => string | Error | undefined;
|
|
193
|
-
placeholder?: string;
|
|
194
|
-
};
|
|
195
|
-
type NumberQuestion = {
|
|
196
|
-
type: "number";
|
|
197
|
-
default: number;
|
|
198
|
-
validate?: (value: string | undefined) => string | Error | undefined;
|
|
199
|
-
placeholder?: string;
|
|
200
|
-
};
|
|
201
|
-
type SelectQuestion<Value$1> = {
|
|
202
|
-
type: "select";
|
|
203
|
-
default: NoInfer<Value$1>;
|
|
204
|
-
options: Array<{
|
|
205
|
-
value: Value$1;
|
|
206
|
-
label?: string;
|
|
207
|
-
hint?: string;
|
|
208
|
-
}>;
|
|
209
|
-
};
|
|
210
|
-
type MultiSelectQuestion<Value$1> = {
|
|
211
|
-
type: "multiselect";
|
|
212
|
-
default: NoInfer<Value$1[]>;
|
|
213
|
-
options: Array<{
|
|
214
|
-
value: Value$1;
|
|
215
|
-
label?: string;
|
|
216
|
-
hint?: string;
|
|
217
|
-
}>;
|
|
218
|
-
required: boolean;
|
|
219
|
-
};
|
|
220
|
-
type BaseQuestion<Args extends OptionDefinition> = {
|
|
221
|
-
question: string;
|
|
222
|
-
group?: string;
|
|
223
|
-
/**
|
|
224
|
-
* When this condition explicitly returns `false`, the question's value will
|
|
225
|
-
* always be `undefined` and will not fallback to the specified `default` value.
|
|
226
|
-
*/
|
|
227
|
-
condition?: (options: OptionValues<Args>) => boolean;
|
|
228
|
-
};
|
|
229
|
-
type Question<Args extends OptionDefinition = OptionDefinition> = BaseQuestion<Args> & (BooleanQuestion | StringQuestion | NumberQuestion | SelectQuestion<any> | MultiSelectQuestion<any>);
|
|
230
|
-
type OptionDefinition = Record<string, Question<any>>;
|
|
231
|
-
type OptionValues<Args extends OptionDefinition> = { [K in keyof Args]: Args[K] extends StringQuestion ? string : Args[K] extends BooleanQuestion ? boolean : Args[K] extends NumberQuestion ? number : Args[K] extends SelectQuestion<infer Value> ? Value : Args[K] extends MultiSelectQuestion<infer Value> ? Value[] : "ERROR: The value for this type is invalid. Ensure that the `default` value exists in `options`." };
|
|
232
|
-
//#endregion
|
|
233
|
-
//#region lib/core/addon/workspace.d.ts
|
|
234
|
-
type WorkspaceOptions<Args extends OptionDefinition> = OptionValues<Args>;
|
|
235
|
-
type Workspace = {
|
|
236
|
-
cwd: string;
|
|
237
|
-
/**
|
|
238
|
-
* Returns the dependency version declared in the package.json.
|
|
239
|
-
* This may differ from the installed version.
|
|
240
|
-
* Includes both dependencies and devDependencies.
|
|
241
|
-
* Also checks parent package.json files if called in a monorepo.
|
|
242
|
-
* @param pkg the package to check for
|
|
243
|
-
* @returns the dependency version with any leading characters such as ^ or ~ removed
|
|
244
|
-
*/
|
|
245
|
-
dependencyVersion: (pkg: string) => string | undefined;
|
|
246
|
-
/** to know if the workspace is using typescript or javascript */
|
|
247
|
-
language: "ts" | "js";
|
|
248
|
-
files: {
|
|
249
|
-
viteConfig: "vite.config.js" | "vite.config.ts";
|
|
250
|
-
svelteConfig: "svelte.config.js" | "svelte.config.ts";
|
|
251
|
-
/** `${kit.routesDirectory}/layout.css` or `src/app.css` */
|
|
252
|
-
stylesheet: `${string}/layout.css` | "src/app.css";
|
|
253
|
-
package: "package.json";
|
|
254
|
-
gitignore: ".gitignore";
|
|
255
|
-
prettierignore: ".prettierignore";
|
|
256
|
-
prettierrc: ".prettierrc";
|
|
257
|
-
eslintConfig: "eslint.config.js";
|
|
258
|
-
vscodeSettings: ".vscode/settings.json";
|
|
259
|
-
/** Get the relative path between two files */
|
|
260
|
-
getRelative: ({
|
|
261
|
-
from,
|
|
262
|
-
to
|
|
263
|
-
}: {
|
|
264
|
-
from?: string;
|
|
265
|
-
to: string;
|
|
266
|
-
}) => string;
|
|
267
|
-
};
|
|
268
|
-
/** If we are in a kit project, this object will contain the lib and routes directories */
|
|
269
|
-
kit: {
|
|
270
|
-
libDirectory: string;
|
|
271
|
-
routesDirectory: string;
|
|
272
|
-
} | undefined;
|
|
273
|
-
/** The package manager used to install dependencies */
|
|
274
|
-
packageManager: PackageManager;
|
|
275
|
-
};
|
|
276
|
-
type PackageManager = "npm" | "yarn" | "pnpm" | "bun" | "deno";
|
|
277
|
-
//#endregion
|
|
278
|
-
//#region lib/core/addon/config.d.ts
|
|
279
|
-
type ConditionDefinition = (Workspace: Workspace) => boolean;
|
|
280
|
-
type PackageDefinition = {
|
|
281
|
-
name: string;
|
|
282
|
-
version: string;
|
|
283
|
-
dev: boolean;
|
|
284
|
-
condition?: ConditionDefinition;
|
|
285
|
-
};
|
|
286
|
-
type Scripts = {
|
|
287
|
-
description: string;
|
|
288
|
-
args: string[];
|
|
289
|
-
stdio: "inherit" | "pipe";
|
|
290
|
-
condition?: ConditionDefinition;
|
|
291
|
-
};
|
|
292
|
-
type SvApi = {
|
|
293
|
-
/** Add a package to the pnpm build dependencies. */
|
|
294
|
-
pnpmBuildDependency: (pkg: string) => void;
|
|
295
|
-
/** Add a package to the dependencies. */
|
|
296
|
-
dependency: (pkg: string, version: string) => void;
|
|
297
|
-
/** Add a package to the dev dependencies. */
|
|
298
|
-
devDependency: (pkg: string, version: string) => void;
|
|
299
|
-
/** Execute a command in the workspace. */
|
|
300
|
-
execute: (args: string[], stdio: "inherit" | "pipe") => Promise<void>;
|
|
301
|
-
/** Edit a file in the workspace. (will create it if it doesn't exist) */
|
|
302
|
-
file: (path: string, edit: (content: string) => string) => void;
|
|
303
|
-
};
|
|
304
|
-
type Addon<Args extends OptionDefinition, Id extends string = string> = {
|
|
305
|
-
id: Id;
|
|
306
|
-
alias?: string;
|
|
307
|
-
shortDescription?: string;
|
|
308
|
-
homepage?: string;
|
|
309
|
-
/** If true, this addon won't appear in the interactive prompt but can still be used via CLI */
|
|
310
|
-
hidden?: boolean;
|
|
311
|
-
options: Args;
|
|
312
|
-
/** Setup the addon. Will be called before the addon is run. */
|
|
313
|
-
setup?: (workspace: Workspace & {
|
|
314
|
-
/** On what official addons does this addon depend on? */
|
|
315
|
-
dependsOn: (name: keyof typeof officialAddons) => void;
|
|
316
|
-
/** Why is this addon not supported?
|
|
317
|
-
*
|
|
318
|
-
* @example
|
|
319
|
-
* if (!kit) unsupported('Requires SvelteKit');
|
|
320
|
-
*/
|
|
321
|
-
unsupported: (reason: string) => void;
|
|
322
|
-
/** On what official addons does this addon run after? */
|
|
323
|
-
runsAfter: (name: keyof typeof officialAddons) => void;
|
|
324
|
-
}) => MaybePromise<void>;
|
|
325
|
-
/** Run the addon. The actual execution of the addon... Add files, edit files, etc. */
|
|
326
|
-
run: (workspace: Workspace & {
|
|
327
|
-
/** Add-on options */
|
|
328
|
-
options: WorkspaceOptions<Args>;
|
|
329
|
-
/** Api to interact with the workspace. */
|
|
330
|
-
sv: SvApi;
|
|
331
|
-
/** Cancel the addon at any time!
|
|
332
|
-
* @example
|
|
333
|
-
* return cancel('There is a problem with...');
|
|
334
|
-
*/
|
|
335
|
-
cancel: (reason: string) => void;
|
|
336
|
-
}) => MaybePromise<void>;
|
|
337
|
-
/** Next steps to display after the addon is run. */
|
|
338
|
-
nextSteps?: (data: Workspace & {
|
|
339
|
-
options: WorkspaceOptions<Args>;
|
|
340
|
-
}) => string[];
|
|
341
|
-
};
|
|
342
|
-
/**
|
|
343
|
-
* The entry point for your addon, It will hold every thing! (options, setup, run, nextSteps, ...)
|
|
344
|
-
*/
|
|
345
|
-
declare function defineAddon<const Id extends string, Args extends OptionDefinition>(config: Addon<Args, Id>): Addon<Args, Id>;
|
|
346
|
-
/**
|
|
347
|
-
* Stage 1: Raw CLI input - what the user typed
|
|
348
|
-
*/
|
|
349
|
-
type AddonInput = {
|
|
350
|
-
readonly specifier: string;
|
|
351
|
-
readonly options: string[];
|
|
352
|
-
};
|
|
353
|
-
/**
|
|
354
|
-
* Stage 2: Classified source - knows where addon comes from
|
|
355
|
-
*/
|
|
356
|
-
type AddonSource = {
|
|
357
|
-
readonly kind: "official";
|
|
358
|
-
readonly id: string;
|
|
359
|
-
} | {
|
|
360
|
-
readonly kind: "file";
|
|
361
|
-
readonly path: string;
|
|
362
|
-
} | {
|
|
363
|
-
readonly kind: "npm";
|
|
364
|
-
readonly packageName: string;
|
|
365
|
-
readonly npmUrl: string;
|
|
366
|
-
readonly registryUrl: string;
|
|
367
|
-
readonly tag: string;
|
|
368
|
-
};
|
|
369
|
-
type AddonReference = {
|
|
370
|
-
readonly specifier: string;
|
|
371
|
-
readonly options: string[];
|
|
372
|
-
readonly source: AddonSource;
|
|
373
|
-
};
|
|
374
|
-
/**
|
|
375
|
-
* Stage 3: Code loaded - addon definition is always present
|
|
376
|
-
*/
|
|
377
|
-
type LoadedAddon = {
|
|
378
|
-
readonly reference: AddonReference;
|
|
379
|
-
readonly addon: AddonDefinition;
|
|
380
|
-
};
|
|
381
|
-
/**
|
|
382
|
-
* Stage 4: Setup done - has dependency info
|
|
383
|
-
*/
|
|
384
|
-
type PreparedAddon = LoadedAddon & {
|
|
385
|
-
readonly setupResult: SetupResult;
|
|
386
|
-
};
|
|
387
|
-
/**
|
|
388
|
-
* Stage 5: User configured - has answers to questions
|
|
389
|
-
*/
|
|
390
|
-
type ConfiguredAddon = PreparedAddon & {
|
|
391
|
-
readonly answers: OptionValues<any>;
|
|
392
|
-
};
|
|
393
|
-
/**
|
|
394
|
-
* Stage 6: Execution result
|
|
395
|
-
*/
|
|
396
|
-
type AddonResult = {
|
|
397
|
-
readonly id: string;
|
|
398
|
-
readonly status: "success" | {
|
|
399
|
-
canceled: string[];
|
|
400
|
-
};
|
|
401
|
-
readonly files: string[];
|
|
402
|
-
};
|
|
403
|
-
/**
|
|
404
|
-
* Generates an inline error hint based on the addon source
|
|
405
|
-
*/
|
|
406
|
-
declare function getErrorHint(source: AddonSource): string;
|
|
407
|
-
type SetupResult = {
|
|
408
|
-
dependsOn: string[];
|
|
409
|
-
unsupported: string[];
|
|
410
|
-
runsAfter: string[];
|
|
411
|
-
};
|
|
412
|
-
type AddonDefinition<Id extends string = string> = Addon<Record<string, Question<any>>, Id>;
|
|
413
|
-
type Tests = {
|
|
414
|
-
expectProperty: (selector: string, property: string, expectedValue: string) => Promise<void>;
|
|
415
|
-
elementExists: (selector: string) => Promise<void>;
|
|
416
|
-
click: (selector: string, path?: string) => Promise<void>;
|
|
417
|
-
expectUrlPath: (path: string) => void;
|
|
418
|
-
};
|
|
419
|
-
type TestDefinition<Args extends OptionDefinition> = {
|
|
420
|
-
name: string;
|
|
421
|
-
run: (tests: Tests) => Promise<void>;
|
|
422
|
-
condition?: (options: OptionValues<Args>) => boolean;
|
|
423
|
-
};
|
|
424
|
-
type MaybePromise<T> = Promise<T> | T;
|
|
425
|
-
type Verification = {
|
|
426
|
-
name: string;
|
|
427
|
-
run: () => MaybePromise<{
|
|
428
|
-
success: boolean;
|
|
429
|
-
message: string | undefined;
|
|
430
|
-
}>;
|
|
431
|
-
};
|
|
432
|
-
type Prettify<T> = { [K in keyof T]: T[K] } & unknown;
|
|
433
|
-
type OptionBuilder<T extends OptionDefinition> = {
|
|
434
|
-
/**
|
|
435
|
-
* This type is a bit complex, but in usage, it's quite simple!
|
|
436
|
-
*
|
|
437
|
-
* The idea is to `add()` options one by one, with the key and the question.
|
|
438
|
-
*
|
|
439
|
-
* ```ts
|
|
440
|
-
* .add('demo', {
|
|
441
|
-
* question: 'Do you want to add a demo?',
|
|
442
|
-
* type: 'boolean', // string, number, select, multiselect
|
|
443
|
-
* default: true,
|
|
444
|
-
* // condition: (o) => o.previousOption === 'ok',
|
|
445
|
-
* })
|
|
446
|
-
* ```
|
|
447
|
-
*/
|
|
448
|
-
add<K$1 extends string, const Q extends Question<T & Record<K$1, Q>>>(key: K$1, question: Q): OptionBuilder<T & Record<K$1, Q>>;
|
|
449
|
-
/** Finalize all options of your `add-on`. */
|
|
450
|
-
build(): Prettify<T>;
|
|
451
|
-
};
|
|
452
|
-
/**
|
|
453
|
-
* Options for an addon.
|
|
454
|
-
*
|
|
455
|
-
* Will be prompted to the user if there are not answered by args when calling the cli.
|
|
456
|
-
*
|
|
457
|
-
* ```ts
|
|
458
|
-
* const options = defineAddonOptions()
|
|
459
|
-
* .add('demo', {
|
|
460
|
-
* question: `demo? ${color.optional('(a cool one!)')}`
|
|
461
|
-
* type: string | boolean | number | select | multiselect,
|
|
462
|
-
* default: true,
|
|
463
|
-
* })
|
|
464
|
-
* .build();
|
|
465
|
-
* ```
|
|
466
|
-
*
|
|
467
|
-
* To define by args, you can do
|
|
468
|
-
* ```sh
|
|
469
|
-
* npx sv add <addon>=<option1>:<value1>+<option2>:<value2>
|
|
470
|
-
* ```
|
|
471
|
-
*/
|
|
472
|
-
declare function defineAddonOptions(): OptionBuilder<{}>;
|
|
473
|
-
//#endregion
|
|
474
|
-
//#region lib/cli/add/utils.d.ts
|
|
475
|
-
declare function fileExists(cwd: string, filePath: string): boolean;
|
|
476
|
-
declare const color: {
|
|
477
|
-
addon: (str: string) => string;
|
|
478
|
-
command: (str: string) => string;
|
|
479
|
-
env: (str: string) => string;
|
|
480
|
-
path: (str: string) => string;
|
|
481
|
-
route: (str: string) => string;
|
|
482
|
-
website: (str: string) => string;
|
|
483
|
-
optional: (str: string) => string;
|
|
484
|
-
dim: (str: string) => string;
|
|
485
|
-
success: (str: string) => string;
|
|
486
|
-
warning: (str: string) => string;
|
|
487
|
-
error: (str: string) => string;
|
|
488
|
-
};
|
|
489
|
-
//#endregion
|
|
490
|
-
//#region lib/core/common.d.ts
|
|
491
|
-
declare function isVersionUnsupportedBelow(versionStr: string, belowStr: string): boolean | undefined;
|
|
492
|
-
//#endregion
|
|
493
|
-
//#region lib/addons/_engine/common.d.ts
|
|
494
|
-
declare function addToDemoPage(existingContent: string, path: string, language: "ts" | "js"): string;
|
|
495
|
-
/**
|
|
496
|
-
* Returns the corresponding `@types/node` version for the version of Node.js running in the current process.
|
|
497
|
-
*
|
|
498
|
-
* If the installed version of Node.js is from a `Current` release, then the major is decremented to
|
|
499
|
-
* the nearest `LTS` release version.
|
|
500
|
-
*/
|
|
501
|
-
declare function getNodeTypesVersion(): string;
|
|
502
|
-
//#endregion
|
|
503
|
-
//#region lib/core/utils.d.ts
|
|
504
|
-
type Printer = (content: string, alt?: string) => string;
|
|
505
|
-
declare function createPrinter(...conditions: boolean[]): Printer[];
|
|
506
|
-
declare namespace index_d_exports$3 {
|
|
507
|
-
export { addAtRule, addDeclaration, addImports, addRule };
|
|
508
|
-
}
|
|
509
|
-
declare function addRule(node: SvelteAst.CSS.StyleSheetBase, options: {
|
|
510
|
-
selector: string;
|
|
511
|
-
}): SvelteAst.CSS.Rule;
|
|
512
|
-
declare function addDeclaration(node: SvelteAst.CSS.Rule, options: {
|
|
513
|
-
property: string;
|
|
514
|
-
value: string;
|
|
515
|
-
}): void;
|
|
516
|
-
declare function addImports(node: SvelteAst.CSS.StyleSheetBase, options: {
|
|
517
|
-
imports: string[];
|
|
518
|
-
}): void;
|
|
519
|
-
declare function addAtRule(node: SvelteAst.CSS.StyleSheetBase, options: {
|
|
520
|
-
name: string;
|
|
521
|
-
params: string;
|
|
522
|
-
append: boolean;
|
|
523
|
-
}): SvelteAst.CSS.Atrule;
|
|
524
|
-
declare namespace array_d_exports {
|
|
525
|
-
export { append, create$1 as create, prepend };
|
|
526
|
-
}
|
|
527
|
-
declare function create$1(): estree.ArrayExpression;
|
|
528
|
-
declare function append(node: estree.ArrayExpression, element: string | estree.Expression | estree.SpreadElement): void;
|
|
529
|
-
declare function prepend(node: estree.ArrayExpression, element: string | estree.Expression | estree.SpreadElement): void;
|
|
530
|
-
declare namespace object_d_exports {
|
|
531
|
-
export { create, overrideProperties, property, propertyNode };
|
|
532
|
-
}
|
|
533
|
-
type ObjectPrimitiveValues = string | number | boolean | undefined | null;
|
|
534
|
-
type ObjectValues = ObjectPrimitiveValues | Record<string, any> | ObjectValues[];
|
|
535
|
-
type ObjectMap = Record<string, ObjectValues | estree.Expression>;
|
|
536
|
-
declare function property<T extends estree.Expression | estree.Identifier>(node: estree.ObjectExpression, options: {
|
|
537
|
-
name: string;
|
|
538
|
-
fallback: T;
|
|
539
|
-
}): T;
|
|
540
|
-
declare function propertyNode<T extends estree.Expression | estree.Identifier>(node: estree.ObjectExpression, options: {
|
|
541
|
-
name: string;
|
|
542
|
-
fallback: T;
|
|
543
|
-
}): estree.Property;
|
|
544
|
-
declare function create(properties: ObjectMap): estree.ObjectExpression;
|
|
545
|
-
declare function overrideProperties(objectExpression: estree.ObjectExpression, properties: ObjectMap): void;
|
|
546
|
-
declare namespace common_d_exports {
|
|
547
|
-
export { addJsDocComment, addJsDocTypeComment, appendFromString, appendStatement, areNodesEqual, contains, createBlockStatement, createExpressionStatement, createLiteral, createSatisfies, createSpread, createTypeProperty, hasTypeProperty, parseExpression, parseFromString, parseStatement, typeAnnotate };
|
|
548
|
-
}
|
|
549
|
-
declare function addJsDocTypeComment(node: estree.Node, comments: Comments, options: {
|
|
550
|
-
type: string;
|
|
551
|
-
}): void;
|
|
552
|
-
declare function addJsDocComment(node: estree.Node, comments: Comments, options: {
|
|
553
|
-
params: Record<string, string>;
|
|
554
|
-
}): void;
|
|
555
|
-
declare function typeAnnotate(node: estree.Expression, options: {
|
|
556
|
-
type: string;
|
|
557
|
-
}): estree.TSAsExpression;
|
|
558
|
-
declare function createSatisfies(node: estree.Expression, options: {
|
|
559
|
-
type: string;
|
|
560
|
-
}): estree.TSSatisfiesExpression;
|
|
561
|
-
declare function createSpread(argument: estree.Expression): estree.SpreadElement;
|
|
562
|
-
declare function createLiteral(value: string | number | boolean | null): estree.Literal;
|
|
563
|
-
declare function areNodesEqual(node: estree.Node, otherNode: estree.Node): boolean;
|
|
564
|
-
declare function createBlockStatement(): estree.BlockStatement;
|
|
565
|
-
declare function createExpressionStatement(options: {
|
|
566
|
-
expression: estree.Expression;
|
|
567
|
-
}): estree.ExpressionStatement;
|
|
568
|
-
declare function appendFromString(node: estree.BlockStatement | estree.Program, options: {
|
|
569
|
-
code: string;
|
|
570
|
-
comments?: Comments;
|
|
571
|
-
}): void;
|
|
572
|
-
declare function parseExpression(code: string): estree.Expression;
|
|
573
|
-
declare function parseStatement(code: string): estree.Statement;
|
|
574
|
-
declare function parseFromString<T extends estree.Node>(code: string): T;
|
|
575
|
-
/** Appends the statement to body of the block if it doesn't already exist */
|
|
576
|
-
declare function appendStatement(node: estree.BlockStatement | estree.Program, options: {
|
|
577
|
-
statement: estree.Statement;
|
|
578
|
-
}): void;
|
|
579
|
-
/** Returns `true` if the provided node exists in the AST */
|
|
580
|
-
declare function contains(node: estree.Node, targetNode: estree.Node): boolean;
|
|
581
|
-
declare function hasTypeProperty(node: estree.TSInterfaceDeclaration["body"]["body"][number], options: {
|
|
582
|
-
name: string;
|
|
583
|
-
}): boolean;
|
|
584
|
-
declare function createTypeProperty(name: string, value: string, optional?: boolean): estree.TSInterfaceBody["body"][number];
|
|
585
|
-
declare namespace function_d_exports {
|
|
586
|
-
export { createArrow, createCall, getArgument };
|
|
587
|
-
}
|
|
588
|
-
declare function createCall(options: {
|
|
589
|
-
name: string;
|
|
590
|
-
args: string[];
|
|
591
|
-
useIdentifiers?: boolean;
|
|
592
|
-
}): estree.CallExpression;
|
|
593
|
-
declare function createArrow(options: {
|
|
594
|
-
body: estree.Expression | estree.BlockStatement;
|
|
595
|
-
async: boolean;
|
|
596
|
-
}): estree.ArrowFunctionExpression;
|
|
597
|
-
declare function getArgument<T extends estree.Expression>(node: estree.CallExpression, options: {
|
|
598
|
-
index: number;
|
|
599
|
-
fallback: T;
|
|
600
|
-
}): T;
|
|
601
|
-
declare namespace imports_d_exports {
|
|
602
|
-
export { addDefault, addEmpty, addNamed, addNamespace$1 as addNamespace, find, remove };
|
|
603
|
-
}
|
|
604
|
-
declare function addEmpty(node: estree.Program, options: {
|
|
605
|
-
from: string;
|
|
606
|
-
}): void;
|
|
607
|
-
declare function addNamespace$1(node: estree.Program, options: {
|
|
608
|
-
from: string;
|
|
609
|
-
as: string;
|
|
610
|
-
}): void;
|
|
611
|
-
declare function addDefault(node: estree.Program, options: {
|
|
612
|
-
from: string;
|
|
613
|
-
as: string;
|
|
614
|
-
}): void;
|
|
615
|
-
declare function addNamed(node: estree.Program, options: {
|
|
616
|
-
/**
|
|
617
|
-
* ```ts
|
|
618
|
-
* imports: { 'name': 'alias' } | ['name']
|
|
619
|
-
* ```
|
|
620
|
-
*/
|
|
621
|
-
imports: Record<string, string> | string[];
|
|
622
|
-
from: string;
|
|
623
|
-
isType?: boolean;
|
|
624
|
-
}): void;
|
|
625
|
-
declare function find(ast: estree.Program, options: {
|
|
626
|
-
name: string;
|
|
627
|
-
from: string;
|
|
628
|
-
}): {
|
|
629
|
-
statement: estree.ImportDeclaration;
|
|
630
|
-
alias: string;
|
|
631
|
-
} | {
|
|
632
|
-
statement: undefined;
|
|
633
|
-
alias: undefined;
|
|
634
|
-
};
|
|
635
|
-
declare function remove(ast: estree.Program, options: {
|
|
636
|
-
name: string;
|
|
637
|
-
from: string;
|
|
638
|
-
statement?: estree.ImportDeclaration;
|
|
639
|
-
}): void;
|
|
640
|
-
declare namespace variables_d_exports {
|
|
641
|
-
export { createIdentifier, declaration, typeAnnotateDeclarator };
|
|
642
|
-
}
|
|
643
|
-
declare function declaration(node: estree.Program | estree.Declaration, options: {
|
|
644
|
-
kind: "const" | "let" | "var";
|
|
645
|
-
name: string;
|
|
646
|
-
value: estree.Expression;
|
|
647
|
-
}): estree.VariableDeclaration;
|
|
648
|
-
declare function createIdentifier(name: string): estree.Identifier;
|
|
649
|
-
declare function typeAnnotateDeclarator(node: estree.VariableDeclarator, options: {
|
|
650
|
-
typeName: string;
|
|
651
|
-
}): estree.VariableDeclarator;
|
|
652
|
-
declare namespace exports_d_exports {
|
|
653
|
-
export { ExportDefaultResult, addNamespace, createDefault, createNamed };
|
|
654
|
-
}
|
|
655
|
-
type ExportDefaultResult<T> = {
|
|
656
|
-
astNode: estree.ExportDefaultDeclaration;
|
|
657
|
-
value: T;
|
|
658
|
-
isFallback: boolean;
|
|
659
|
-
};
|
|
660
|
-
declare function createDefault<T extends estree.Expression>(node: estree.Program, options: {
|
|
661
|
-
fallback: T;
|
|
662
|
-
}): ExportDefaultResult<T>;
|
|
663
|
-
declare function createNamed(node: estree.Program, options: {
|
|
664
|
-
name: string;
|
|
665
|
-
fallback: estree.VariableDeclaration;
|
|
666
|
-
}): estree.ExportNamedDeclaration;
|
|
667
|
-
declare function addNamespace(node: estree.Program, options: {
|
|
668
|
-
from: string;
|
|
669
|
-
as?: string;
|
|
670
|
-
}): void;
|
|
671
|
-
declare namespace kit_d_exports {
|
|
672
|
-
export { addGlobalAppInterface, addHooksHandle };
|
|
673
|
-
}
|
|
674
|
-
declare function addGlobalAppInterface(node: estree.TSProgram, options: {
|
|
675
|
-
name: "Error" | "Locals" | "PageData" | "PageState" | "Platform";
|
|
676
|
-
}): estree.TSInterfaceDeclaration;
|
|
677
|
-
declare function addHooksHandle(node: estree.Program, options: {
|
|
678
|
-
language: "ts" | "js";
|
|
679
|
-
newHandleName: string;
|
|
680
|
-
handleContent: string;
|
|
681
|
-
comments: Comments;
|
|
682
|
-
}): void;
|
|
683
|
-
declare namespace vite_d_exports {
|
|
684
|
-
export { addPlugin, getConfig };
|
|
685
|
-
}
|
|
686
|
-
declare const addPlugin: (ast: estree.Program, options: {
|
|
687
|
-
code: string;
|
|
688
|
-
/** default: `append` */
|
|
689
|
-
mode?: "append" | "prepend";
|
|
690
|
-
}) => void;
|
|
691
|
-
declare const getConfig: (ast: estree.Program) => estree.ObjectExpression;
|
|
692
|
-
declare namespace index_d_exports$2 {
|
|
693
|
-
export { estree as AstTypes, Comments, array_d_exports as array, common_d_exports as common, exports_d_exports as exports, function_d_exports as functions, imports_d_exports as imports, kit_d_exports as kit, object_d_exports as object, variables_d_exports as variables, vite_d_exports as vite };
|
|
694
|
-
}
|
|
695
|
-
declare namespace index_d_exports$1 {
|
|
696
|
-
export { addAttribute, addFromRawHtml, appendElement, createElement, insertElement };
|
|
697
|
-
}
|
|
698
|
-
declare function createElement(tagName: string, attributes?: Record<string, string>): SvelteAst.RegularElement;
|
|
699
|
-
declare function addAttribute(element: SvelteAst.RegularElement, name: string, value: string): void;
|
|
700
|
-
declare function insertElement(fragment: SvelteAst.Fragment, elementToInsert: SvelteAst.Fragment["nodes"][0]): void;
|
|
701
|
-
declare function appendElement(fragment: SvelteAst.Fragment, elementToAppend: SvelteAst.Fragment["nodes"][0]): void;
|
|
702
|
-
declare function addFromRawHtml(fragment: SvelteAst.Fragment, html: string): void;
|
|
703
|
-
declare namespace text_d_exports {
|
|
704
|
-
export { upsert };
|
|
705
|
-
}
|
|
706
|
-
type CommentEntry = {
|
|
707
|
-
text: string;
|
|
708
|
-
mode: "append" | "prepend";
|
|
709
|
-
};
|
|
710
|
-
type CommentOption = string | Array<string | CommentEntry>;
|
|
711
|
-
/**
|
|
712
|
-
* Upsert a line into flat file content (.env, .gitignore, etc.)
|
|
713
|
-
* - key + value → "KEY=value" (skips if KEY= already present)
|
|
714
|
-
* - key only → "key" line (skips if already present, e.g. gitignore entry)
|
|
715
|
-
* - comment → string, string[], or { text, mode }[] for prepend/append comments
|
|
716
|
-
* - separator → adds a blank line before this entry (for visual grouping)
|
|
717
|
-
*/
|
|
718
|
-
declare function upsert(content: string, key: string, options?: {
|
|
719
|
-
value?: string;
|
|
720
|
-
comment?: CommentOption;
|
|
721
|
-
separator?: boolean;
|
|
722
|
-
}): string;
|
|
723
|
-
declare namespace json_d_exports {
|
|
724
|
-
export { arrayUpsert, packageScriptsUpsert };
|
|
725
|
-
}
|
|
726
|
-
declare function arrayUpsert(data: any, key: string, value: any, options?: {
|
|
727
|
-
/** default: `append` */
|
|
728
|
-
mode?: "append" | "prepend";
|
|
729
|
-
}): void;
|
|
730
|
-
declare function packageScriptsUpsert(data: any, key: string, value: string, options?: {
|
|
731
|
-
mode?: "append" | "prepend";
|
|
732
|
-
}): void;
|
|
733
|
-
declare namespace index_d_exports {
|
|
734
|
-
export { addFragment, addSlot, ensureScript };
|
|
735
|
-
}
|
|
736
|
-
type RootWithInstance = SvelteAst.Root & {
|
|
737
|
-
instance: SvelteAst.Script;
|
|
738
|
-
};
|
|
739
|
-
declare function ensureScript(ast: SvelteAst.Root, options?: {
|
|
740
|
-
language?: "ts" | "js";
|
|
741
|
-
}): asserts ast is RootWithInstance;
|
|
742
|
-
declare function addSlot(ast: SvelteAst.Root, options: {
|
|
743
|
-
svelteVersion: string;
|
|
744
|
-
language?: "ts" | "js";
|
|
745
|
-
}): void;
|
|
746
|
-
declare function addFragment(ast: SvelteAst.Root, content: string, options?: {
|
|
747
|
-
mode?: "append" | "prepend";
|
|
748
|
-
}): void;
|
|
749
|
-
//#endregion
|
|
750
|
-
//#region lib/core/addon/processors.d.ts
|
|
751
|
-
type FileEditor = Workspace & {
|
|
752
|
-
content: string;
|
|
753
|
-
};
|
|
754
|
-
type FileType = {
|
|
755
|
-
name: (options: Workspace) => string;
|
|
756
|
-
condition?: ConditionDefinition;
|
|
757
|
-
content: (editor: FileEditor) => string;
|
|
758
|
-
};
|
|
759
|
-
//#endregion
|
|
760
|
-
//#region lib/core.d.ts
|
|
761
|
-
/**
|
|
762
|
-
* Will help you `parse` code into an `ast` from all supported languages.
|
|
763
|
-
* Then manipulate the `ast` as you want,
|
|
764
|
-
* and finally `generateCode()` to write it back to the file.
|
|
765
|
-
*
|
|
766
|
-
* ```ts
|
|
767
|
-
* import { parse } from 'sv/core';
|
|
768
|
-
*
|
|
769
|
-
* const { ast, generateCode } = parse.css('body { color: red; }');
|
|
770
|
-
* const { ast, generateCode } = parse.html('<div>Hello, world!</div>');
|
|
771
|
-
* const { ast, generateCode } = parse.json('{ "name": "John", "age": 30 }');
|
|
772
|
-
* const { ast, generateCode } = parse.script('function add(a, b) { return a + b; }');
|
|
773
|
-
* const { ast, generateCode } = parse.svelte('<div>Hello, world!</div>');
|
|
774
|
-
* const { ast, generateCode } = parse.toml('name = "John"');
|
|
775
|
-
* const { ast, generateCode } = parse.yaml('name: John');
|
|
776
|
-
* ```
|
|
777
|
-
*/
|
|
778
|
-
declare const parse: {
|
|
779
|
-
css: typeof parseCss;
|
|
780
|
-
html: typeof parseHtml;
|
|
781
|
-
json: typeof parseJson;
|
|
782
|
-
script: typeof parseScript;
|
|
783
|
-
svelte: typeof parseSvelte;
|
|
784
|
-
toml: typeof parseToml;
|
|
785
|
-
yaml: typeof parseYaml;
|
|
786
|
-
};
|
|
787
|
-
//#endregion
|
|
788
|
-
export { officialAddons as $, PackageDefinition as A, getErrorHint as B, AddonReference as C, ConfiguredAddon as D, ConditionDefinition as E, TestDefinition as F, BooleanQuestion as G, Workspace as H, Tests as I, OptionDefinition as J, MultiSelectQuestion as K, Verification as L, Scripts as M, SetupResult as N, LoadedAddon as O, SvApi as P, StringQuestion as Q, defineAddon as R, AddonInput as S, AddonSource as T, WorkspaceOptions as U, PackageManager as V, BaseQuestion as W, Question as X, OptionValues as Y, SelectQuestion as Z, isVersionUnsupportedBelow as _, resolveCommand as a, Addon as b, index_d_exports as c, index_d_exports$1 as d, Comments as et, index_d_exports$2 as f, getNodeTypesVersion as g, addToDemoPage as h, parse as i, PreparedAddon as j, OptionBuilder as k, json_d_exports as l, createPrinter as m, dedent as n, estree as nt, FileEditor as o, index_d_exports$3 as p, NumberQuestion as q, log as r, FileType as s, Walker as t, SvelteAst as tt, text_d_exports as u, color as v, AddonResult as w, AddonDefinition as x, fileExists as y, defineAddonOptions as z };
|