@untestutils/sveltekit 0.5.1 → 0.5.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/index.d.mts CHANGED
@@ -1,15 +1,21 @@
1
- import { type FrameworkBaseOptions, type Recipe } from "@untestutils/core";
1
+ import { type Driver, type FrameworkBaseOptions, type Recipe } from "@untestutils/core";
2
2
  export type SvelteKitRun = "preview" | "server" | "dev";
3
+ export type ViteConfigOverride = Record<string, unknown>;
3
4
  export interface SvelteKitOptions extends FrameworkBaseOptions {
4
5
  run?: SvelteKitRun;
5
6
  /** adapter-node output entry relative to root (default `build/index.js`). */
6
7
  serverEntry?: string;
8
+ /** Merged onto the app vite.config (SvelteKit is a Vite plugin). */
9
+ viteConfig?: ViteConfigOverride;
7
10
  }
11
+ export type SvelteKitMatrixVariant = Partial<Pick<SvelteKitOptions, "env" | "hashInputs" | "run" | "serverEntry" | "readyPath" | "readyTimeoutMs" | "workspaceDeps" | "viteConfig">>;
8
12
  /**
9
13
  * SvelteKit Recipe factory.
10
14
  * `run: 'preview'` (default) — `vite build` + `vite preview`
11
15
  * `run: 'server'` — build + `node build` (adapter-node)
12
16
  * `run: 'dev'` — `vite dev`
13
17
  */
14
- export declare function sveltekit(opts: SvelteKitOptions): Recipe;
18
+ export declare const sveltekit: Driver<SvelteKitOptions>;
19
+ /** Expand one SvelteKit recipe base into many recipes with distinct ids. */
20
+ export declare function matrix(base: SvelteKitOptions, variants: Record<string, SvelteKitMatrixVariant>): Record<string, Recipe>;
15
21
  export default sveltekit;
package/dist/index.d.ts CHANGED
@@ -1,16 +1,22 @@
1
- import { type FrameworkBaseOptions, type Recipe } from '@untestutils/core';
1
+ import { type Driver, type FrameworkBaseOptions, type Recipe } from '@untestutils/core';
2
2
  export type SvelteKitRun = 'preview' | 'server' | 'dev';
3
+ export type ViteConfigOverride = Record<string, unknown>;
3
4
  export interface SvelteKitOptions extends FrameworkBaseOptions {
4
5
  run?: SvelteKitRun;
5
6
  /** adapter-node output entry relative to root (default `build/index.js`). */
6
7
  serverEntry?: string;
8
+ /** Merged onto the app vite.config (SvelteKit is a Vite plugin). */
9
+ viteConfig?: ViteConfigOverride;
7
10
  }
11
+ export type SvelteKitMatrixVariant = Partial<Pick<SvelteKitOptions, 'env' | 'hashInputs' | 'run' | 'serverEntry' | 'readyPath' | 'readyTimeoutMs' | 'workspaceDeps' | 'viteConfig'>>;
8
12
  /**
9
13
  * SvelteKit Recipe factory.
10
14
  * `run: 'preview'` (default) — `vite build` + `vite preview`
11
15
  * `run: 'server'` — build + `node build` (adapter-node)
12
16
  * `run: 'dev'` — `vite dev`
13
17
  */
14
- export declare function sveltekit(opts: SvelteKitOptions): Recipe;
18
+ export declare const sveltekit: Driver<SvelteKitOptions>;
19
+ /** Expand one SvelteKit recipe base into many recipes with distinct ids. */
20
+ export declare function matrix(base: SvelteKitOptions, variants: Record<string, SvelteKitMatrixVariant>): Record<string, Recipe>;
15
21
  export default sveltekit;
16
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,oBAAoB,EACzB,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEzC,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,QAAQ,GAAG,KAAK,CAAC;AAExD,MAAM,WAAW,gBAAiB,SAAQ,oBAAoB;IAC5D,GAAG,CAAC,EAAE,YAAY,CAAC;IACnB,6EAA6E;IAC7E,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAYD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAkFxD;AAED,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAWL,KAAK,MAAM,EACX,KAAK,oBAAoB,EACzB,KAAK,MAAM,EACZ,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,QAAQ,GAAG,KAAK,CAAC;AAExD,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEzD,MAAM,WAAW,gBAAiB,SAAQ,oBAAoB;IAC5D,GAAG,CAAC,EAAE,YAAY,CAAC;IACnB,6EAA6E;IAC7E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oEAAoE;IACpE,UAAU,CAAC,EAAE,kBAAkB,CAAC;CACjC;AAED,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAC1C,IAAI,CACF,gBAAgB,EACd,KAAK,GACL,YAAY,GACZ,KAAK,GACL,aAAa,GACb,WAAW,GACX,gBAAgB,GAChB,eAAe,GACf,YAAY,CACf,CACF,CAAC;AAgCF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,gBAAgB,CAqH9C,CAAC;AAEF,4EAA4E;AAC5E,wBAAgB,MAAM,CACpB,IAAI,EAAE,gBAAgB,EACtB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,GAC/C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkBxB;AAED,eAAe,SAAS,CAAC"}
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { join, resolve } from "pathe";
3
- import { loopbackUrl, cliFrameworkRecipe, frameworkRoots, resolveBin } from "@untestutils/core";
3
+ import { cliFrameworkRecipe, configOverrideHashInput, deepMergePlain, defineDriver, frameworkRoots, loopbackUrl, matrixRecipe, resolveBin, serializeViteMergeConfigModule, writeEphemeralConfig } from "@untestutils/core";
4
4
  function resolveViteBin(root) {
5
5
  return resolveBin({
6
6
  label: "sveltekit",
@@ -10,8 +10,22 @@ function resolveViteBin(root) {
10
10
  binRelative: ["bin/vite.js", "bin/vite.mjs"]
11
11
  });
12
12
  }
13
+ function hashInputsFor(opts, root, extra) {
14
+ const inputs = [...opts.hashInputs ?? [root], ...extra];
15
+ if (opts.viteConfig) inputs.push(configOverrideHashInput("viteConfig", opts.viteConfig));
16
+ return inputs;
17
+ }
18
+ async function viteConfigArgs(root, outDir, viteConfig) {
19
+ if (!viteConfig || !Object.keys(viteConfig).length) return [];
20
+ const configPath = join(outDir, "vite.untestutils.mjs");
21
+ await writeEphemeralConfig(configPath, serializeViteMergeConfigModule({
22
+ appRoot: root,
23
+ overrides: viteConfig
24
+ }));
25
+ return ["--config", configPath];
26
+ }
13
27
 
14
- export function sveltekit(opts) {
28
+ export const sveltekit = defineDriver((opts) => {
15
29
  const root = resolve(opts.root);
16
30
  const runMode = opts.run ?? "preview";
17
31
  const id = opts.id ?? `sveltekit-${runMode}-${root.split("/").pop()}`;
@@ -23,22 +37,27 @@ export function sveltekit(opts) {
23
37
  label: "sveltekit",
24
38
  share: "never",
25
39
  env: opts.env,
26
- hashInputs: opts.hashInputs ?? [root, "run:dev"],
40
+ hashInputs: hashInputsFor(opts, root, ["run:dev"]),
27
41
  readyPath: opts.readyPath,
28
42
  readyTimeoutMs: opts.readyTimeoutMs,
29
- start: ({ port }) => ({
30
- command: process.execPath,
31
- args: [
32
- bin(),
33
- "dev",
34
- "--host",
35
- "127.0.0.1",
36
- "--port",
37
- String(port),
38
- "--strictPort"
39
- ],
40
- cwd: root
41
- })
43
+ workspaceDeps: opts.workspaceDeps,
44
+ start: async ({ port, outDir }) => {
45
+ const configArgs = await viteConfigArgs(root, outDir, opts.viteConfig);
46
+ return {
47
+ command: process.execPath,
48
+ args: [
49
+ bin(),
50
+ "dev",
51
+ ...configArgs,
52
+ "--host",
53
+ "127.0.0.1",
54
+ "--port",
55
+ String(port),
56
+ "--strictPort"
57
+ ],
58
+ cwd: root
59
+ };
60
+ }
42
61
  });
43
62
  }
44
63
  if (runMode === "server") {
@@ -49,18 +68,22 @@ export function sveltekit(opts) {
49
68
  label: "sveltekit",
50
69
  share: "always",
51
70
  env: opts.env,
52
- hashInputs: opts.hashInputs ?? [
53
- root,
54
- "run:server",
55
- entryRel
56
- ],
71
+ hashInputs: hashInputsFor(opts, root, ["run:server", entryRel]),
57
72
  readyPath: opts.readyPath,
58
73
  readyTimeoutMs: opts.readyTimeoutMs,
59
- prepare: () => ({
60
- command: process.execPath,
61
- args: [bin(), "build"],
62
- cwd: root
63
- }),
74
+ workspaceDeps: opts.workspaceDeps,
75
+ prepare: async ({ outDir }) => {
76
+ const configArgs = await viteConfigArgs(root, outDir, opts.viteConfig);
77
+ return {
78
+ command: process.execPath,
79
+ args: [
80
+ bin(),
81
+ "build",
82
+ ...configArgs
83
+ ],
84
+ cwd: root
85
+ };
86
+ },
64
87
  verifyAfterPrepare: () => {
65
88
  const entry = join(root, entryRel);
66
89
  if (!existsSync(entry)) {
@@ -86,26 +109,59 @@ export function sveltekit(opts) {
86
109
  label: "sveltekit",
87
110
  share: "always",
88
111
  env: opts.env,
89
- hashInputs: opts.hashInputs ?? [root, "run:preview"],
112
+ hashInputs: hashInputsFor(opts, root, ["run:preview"]),
90
113
  readyPath: opts.readyPath,
91
114
  readyTimeoutMs: opts.readyTimeoutMs,
92
- prepare: () => ({
93
- command: process.execPath,
94
- args: [bin(), "build"],
95
- cwd: root
96
- }),
97
- start: ({ port, host }) => ({
98
- command: process.execPath,
99
- args: [
100
- bin(),
101
- "preview",
102
- "--host",
103
- host,
104
- "--port",
105
- String(port),
106
- "--strictPort"
107
- ],
108
- cwd: root
115
+ workspaceDeps: opts.workspaceDeps,
116
+ prepare: async ({ outDir }) => {
117
+ const configArgs = await viteConfigArgs(root, outDir, opts.viteConfig);
118
+ return {
119
+ command: process.execPath,
120
+ args: [
121
+ bin(),
122
+ "build",
123
+ ...configArgs
124
+ ],
125
+ cwd: root
126
+ };
127
+ },
128
+ start: async ({ port, host, outDir }) => {
129
+ const configArgs = await viteConfigArgs(root, outDir, opts.viteConfig);
130
+ return {
131
+ command: process.execPath,
132
+ args: [
133
+ bin(),
134
+ "preview",
135
+ ...configArgs,
136
+ "--host",
137
+ host,
138
+ "--port",
139
+ String(port),
140
+ "--strictPort"
141
+ ],
142
+ cwd: root
143
+ };
144
+ }
145
+ });
146
+ });
147
+
148
+ export function matrix(base, variants) {
149
+ return matrixRecipe(sveltekit, base, variants, {
150
+ label: "sveltekit",
151
+ merge: (b, patch, id, name) => ({
152
+ ...b,
153
+ ...patch,
154
+ id,
155
+ env: {
156
+ ...b.env ?? {},
157
+ ...patch.env ?? {}
158
+ },
159
+ viteConfig: b.viteConfig || patch.viteConfig ? deepMergePlain(b.viteConfig ?? {}, patch.viteConfig ?? {}) : undefined,
160
+ hashInputs: [
161
+ ...b.hashInputs ?? [b.root],
162
+ ...patch.hashInputs ?? [],
163
+ `variant:${name}`
164
+ ]
109
165
  })
110
166
  });
111
167
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@untestutils/sveltekit",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "homepage": "https://s00d.github.io/untestutils/",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "pathe": "^2.0.3",
31
- "@untestutils/core": "0.5.1"
31
+ "@untestutils/core": "0.5.3"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/node": "^26.6.1",