sv 0.16.5 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.mjs +1 -1
- package/dist/{engine-CtSoxta7.d.mts → engine-5Sg3lJiQ.d.mts} +19 -6
- package/dist/{engine-CCAozEpo.mjs → engine-B7chsCPG.mjs} +508 -239
- package/dist/shared.json +96 -0
- package/dist/src/index.d.mts +1 -1
- package/dist/src/index.mjs +1 -1
- package/dist/src/testing.d.mts +1 -1
- package/dist/src/testing.mjs +1 -1
- package/dist/templates/addon/package.json +3 -3
- package/package.json +2 -2
package/dist/bin.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { _ as name, a as detectPackageManager, d as Command, g as helpConfig, h as forwardExitCode, l as from, n as add, r as create, u as program, v as version } from "./engine-
|
|
2
|
+
import { _ as name, a as detectPackageManager, d as Command, g as helpConfig, h as forwardExitCode, l as from, n as add, r as create, u as program, v as version } from "./engine-B7chsCPG.mjs";
|
|
3
3
|
import { color, resolveCommandArray } from "@sveltejs/sv-utils";
|
|
4
4
|
import V from "node:process";
|
|
5
5
|
import { execSync } from "node:child_process";
|
|
@@ -13,7 +13,7 @@ type OfficialAddons = {
|
|
|
13
13
|
mdsvex: Addon<any>;
|
|
14
14
|
paraglide: Addon<any>;
|
|
15
15
|
storybook: Addon<any>;
|
|
16
|
-
|
|
16
|
+
aiTools: Addon<any>;
|
|
17
17
|
experimental: Addon<any>;
|
|
18
18
|
};
|
|
19
19
|
declare const officialAddons: OfficialAddons;
|
|
@@ -65,7 +65,7 @@ type BaseQuestion<Args extends OptionDefinition> = {
|
|
|
65
65
|
};
|
|
66
66
|
type Question<Args extends OptionDefinition = OptionDefinition> = BaseQuestion<Args> & (BooleanQuestion | StringQuestion | NumberQuestion | SelectQuestion<any> | MultiSelectQuestion<any>);
|
|
67
67
|
type OptionDefinition = Record<string, Question<any>>;
|
|
68
|
-
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`." };
|
|
68
|
+
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[] : Args[K] extends Question<any> ? unknown : "ERROR: The value for this type is invalid. Ensure that the `default` value exists in `options`." };
|
|
69
69
|
//#endregion
|
|
70
70
|
//#region src/core/workspace.d.ts
|
|
71
71
|
type WorkspaceOptions<Args extends OptionDefinition> = OptionValues<Args>;
|
|
@@ -134,7 +134,7 @@ type SvApi = {
|
|
|
134
134
|
*/
|
|
135
135
|
file: (path: string, edit: (content: string) => string | false) => void;
|
|
136
136
|
};
|
|
137
|
-
type Addon<Args extends OptionDefinition, Id extends string = string> = {
|
|
137
|
+
type Addon<Args extends OptionDefinition, Id extends string = string, Setup extends Record<string, unknown> = Record<string, unknown>> = {
|
|
138
138
|
id: Id;
|
|
139
139
|
alias?: string; /** one-liner shown in prompts */
|
|
140
140
|
shortDescription?: string; /** link to docs/repo */
|
|
@@ -149,10 +149,11 @@ type Addon<Args extends OptionDefinition, Id extends string = string> = {
|
|
|
149
149
|
* if (!isKit) unsupported('Requires SvelteKit');
|
|
150
150
|
*/
|
|
151
151
|
unsupported: (reason: string) => void; /** On what official addons does this addon run after? */
|
|
152
|
-
runsAfter: (name: keyof typeof officialAddons) => void;
|
|
152
|
+
runsAfter: (name: keyof typeof officialAddons) => void; /** Dynamically add an option to be prompted to the user */
|
|
153
|
+
addOption: <K extends Extract<keyof Setup, string>>(key: K, question: SetupOptions<Setup>[K]) => void;
|
|
153
154
|
}) => MaybePromise<void>; /** Run the addon. The actual execution of the addon... Add files, edit files, etc. */
|
|
154
155
|
run: (workspace: Workspace & {
|
|
155
|
-
/** Add-on options */options: WorkspaceOptions<Args>; /** Api to interact with the workspace. */
|
|
156
|
+
/** Add-on options (includes dynamically added options from setup) */options: WorkspaceOptions<Args> & Record<string, unknown>; /** Api to interact with the workspace. */
|
|
156
157
|
sv: SvApi;
|
|
157
158
|
/** Cancel the addon at any time!
|
|
158
159
|
* @example
|
|
@@ -161,13 +162,24 @@ type Addon<Args extends OptionDefinition, Id extends string = string> = {
|
|
|
161
162
|
cancel: (reason: string) => void;
|
|
162
163
|
}) => MaybePromise<void>; /** Next steps to display after the addon is run. */
|
|
163
164
|
nextSteps?: (workspace: Workspace & {
|
|
164
|
-
options: WorkspaceOptions<Args>;
|
|
165
|
+
options: WorkspaceOptions<Args> & Record<string, unknown>;
|
|
165
166
|
}) => string[];
|
|
166
167
|
};
|
|
168
|
+
/** Maps value types to question definitions for dynamic setup options */
|
|
169
|
+
type SetupOptions<T extends Record<string, unknown>> = { [K in keyof T]: BaseQuestion<any> & (T[K] extends boolean ? BooleanQuestion : T[K] extends string ? StringQuestion : T[K] extends number ? NumberQuestion : T[K] extends Array<infer V> ? MultiSelectQuestion<V> : Question<any>) };
|
|
167
170
|
/**
|
|
168
171
|
* The entry point for your addon, It will hold every thing! (options, setup, run, nextSteps, ...)
|
|
172
|
+
*
|
|
173
|
+
* For dynamic options added via `addOption` in setup, use the generic to get strong typing:
|
|
174
|
+
* ```ts
|
|
175
|
+
* const addon = defineAddon<{ extra: boolean }>()({ ... });
|
|
176
|
+
* addon.options.extra.default // boolean
|
|
177
|
+
* ```
|
|
169
178
|
*/
|
|
170
179
|
declare function defineAddon<const Id extends string, Args extends OptionDefinition>(config: Addon<Args, Id>): Addon<Args, Id>;
|
|
180
|
+
declare function defineAddon<SetupValues extends Record<string, unknown>>(): <const Id extends string, Args extends OptionDefinition>(config: Omit<Addon<Args & SetupOptions<SetupValues>, Id, SetupValues>, "options"> & {
|
|
181
|
+
options: Args;
|
|
182
|
+
}) => Addon<Args & SetupOptions<SetupValues>, Id, SetupValues>;
|
|
171
183
|
/**
|
|
172
184
|
* Stage 1: Raw CLI input - what the user typed
|
|
173
185
|
*/
|
|
@@ -229,6 +241,7 @@ type SetupResult = {
|
|
|
229
241
|
dependsOn: string[];
|
|
230
242
|
unsupported: string[];
|
|
231
243
|
runsAfter: string[];
|
|
244
|
+
additionalOptions: Record<string, Question>;
|
|
232
245
|
};
|
|
233
246
|
type AddonDefinition<Id extends string = string> = Addon<Record<string, Question<any>>, Id>;
|
|
234
247
|
type MaybePromise<T> = Promise<T> | T;
|