@untestutils/solidstart 0.5.2 → 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,24 @@
1
- import { type FrameworkBaseOptions, type Recipe } from "@untestutils/core";
1
+ import { type Driver, type FrameworkBaseOptions, type Recipe } from "@untestutils/core";
2
2
  export type SolidStartRun = "preview" | "server" | "dev";
3
+ export type SolidAppConfigOverride = Record<string, unknown>;
3
4
  export interface SolidStartOptions extends FrameworkBaseOptions {
4
5
  run?: SolidStartRun;
5
6
  /** Nitro-style output entry (default `.output/server/index.mjs`). */
6
7
  serverEntry?: string;
8
+ /**
9
+ * Merged onto `app.config.*` via backup/restore (`withMergedConfigOverride`).
10
+ * Same role as Nuxt `nuxtConfig`.
11
+ */
12
+ appConfig?: SolidAppConfigOverride;
7
13
  }
14
+ export type SolidStartMatrixVariant = Partial<Pick<SolidStartOptions, "env" | "hashInputs" | "run" | "serverEntry" | "readyPath" | "readyTimeoutMs" | "workspaceDeps" | "appConfig">>;
8
15
  /**
9
16
  * SolidStart (Vinxi) Recipe factory.
10
17
  * `run: 'preview'` (default) — `vinxi build` + `vinxi start` / preview
11
18
  * `run: 'server'` — build + `node .output/server/index.mjs`
12
19
  * `run: 'dev'` — `vinxi dev`
13
20
  */
14
- export declare function solidstart(opts: SolidStartOptions): Recipe;
21
+ export declare const solidstart: Driver<SolidStartOptions>;
22
+ /** Expand one SolidStart recipe base into many recipes with distinct ids. */
23
+ export declare function matrix(base: SolidStartOptions, variants: Record<string, SolidStartMatrixVariant>): Record<string, Recipe>;
15
24
  export default solidstart;
package/dist/index.d.ts CHANGED
@@ -1,16 +1,25 @@
1
- import { type FrameworkBaseOptions, type Recipe } from '@untestutils/core';
1
+ import { type Driver, type FrameworkBaseOptions, type Recipe } from '@untestutils/core';
2
2
  export type SolidStartRun = 'preview' | 'server' | 'dev';
3
+ export type SolidAppConfigOverride = Record<string, unknown>;
3
4
  export interface SolidStartOptions extends FrameworkBaseOptions {
4
5
  run?: SolidStartRun;
5
6
  /** Nitro-style output entry (default `.output/server/index.mjs`). */
6
7
  serverEntry?: string;
8
+ /**
9
+ * Merged onto `app.config.*` via backup/restore (`withMergedConfigOverride`).
10
+ * Same role as Nuxt `nuxtConfig`.
11
+ */
12
+ appConfig?: SolidAppConfigOverride;
7
13
  }
14
+ export type SolidStartMatrixVariant = Partial<Pick<SolidStartOptions, 'env' | 'hashInputs' | 'run' | 'serverEntry' | 'readyPath' | 'readyTimeoutMs' | 'workspaceDeps' | 'appConfig'>>;
8
15
  /**
9
16
  * SolidStart (Vinxi) Recipe factory.
10
17
  * `run: 'preview'` (default) — `vinxi build` + `vinxi start` / preview
11
18
  * `run: 'server'` — build + `node .output/server/index.mjs`
12
19
  * `run: 'dev'` — `vinxi dev`
13
20
  */
14
- export declare function solidstart(opts: SolidStartOptions): Recipe;
21
+ export declare const solidstart: Driver<SolidStartOptions>;
22
+ /** Expand one SolidStart recipe base into many recipes with distinct ids. */
23
+ export declare function matrix(base: SolidStartOptions, variants: Record<string, SolidStartMatrixVariant>): Record<string, Recipe>;
15
24
  export default solidstart;
16
25
  //# 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,EACZ,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEzD,MAAM,WAAW,iBAAkB,SAAQ,oBAAoB;IAC7D,GAAG,CAAC,EAAE,aAAa,CAAC;IACpB,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAYD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CA8E1D;AAED,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAYL,KAAK,MAAM,EACX,KAAK,oBAAoB,EACzB,KAAK,MAAM,EACZ,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEzD,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE7D,MAAM,WAAW,iBAAkB,SAAQ,oBAAoB;IAC7D,GAAG,CAAC,EAAE,aAAa,CAAC;IACpB,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,sBAAsB,CAAC;CACpC;AAED,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAC3C,IAAI,CACF,iBAAiB,EACf,KAAK,GACL,YAAY,GACZ,KAAK,GACL,aAAa,GACb,WAAW,GACX,gBAAgB,GAChB,eAAe,GACf,WAAW,CACd,CACF,CAAC;AAuCF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,iBAAiB,CAmIhD,CAAC;AAEF,6EAA6E;AAC7E,wBAAgB,MAAM,CACpB,IAAI,EAAE,iBAAiB,EACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,GAChD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkBxB;AAED,eAAe,UAAU,CAAC"}
package/dist/index.mjs CHANGED
@@ -1,6 +1,13 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { join, resolve } from "pathe";
3
- import { cliFrameworkRecipe, frameworkRoots, resolveBin } from "@untestutils/core";
3
+ import { cliFrameworkRecipe, configOverrideHashInput, deepMergePlain, defineDriver, findFirstExistingConfig, frameworkRoots, installMergedConfigOverride, matrixRecipe, resolveBin, runCommand, withMergedConfigOverride } from "@untestutils/core";
4
+ const APP_CONFIG_NAMES = [
5
+ "app.config.ts",
6
+ "app.config.mjs",
7
+ "app.config.js",
8
+ "app.config.mts",
9
+ "app.config.cjs"
10
+ ];
4
11
  function resolveVinxiBin(root) {
5
12
  return resolveBin({
6
13
  label: "solidstart",
@@ -10,34 +17,58 @@ function resolveVinxiBin(root) {
10
17
  binRelative: ["bin/cli.mjs", "bin/cli.js"]
11
18
  });
12
19
  }
20
+ function hashInputsFor(opts, root, extra) {
21
+ const inputs = [...opts.hashInputs ?? [root], ...extra];
22
+ if (opts.appConfig) inputs.push(configOverrideHashInput("appConfig", opts.appConfig));
23
+ return inputs;
24
+ }
25
+ function resolveAppConfigPath(root) {
26
+ return findFirstExistingConfig(root, APP_CONFIG_NAMES) ?? join(root, "app.config.ts");
27
+ }
28
+ async function withAppConfigOverride(root, overrides, fn) {
29
+ if (!overrides || !Object.keys(overrides).length) return fn();
30
+ return withMergedConfigOverride(resolveAppConfigPath(root), overrides, fn);
31
+ }
13
32
 
14
- export function solidstart(opts) {
33
+ export const solidstart = defineDriver((opts) => {
15
34
  const root = resolve(opts.root);
16
35
  const runMode = opts.run ?? "preview";
17
36
  const id = opts.id ?? `solidstart-${runMode}-${root.split("/").pop()}`;
18
37
  const bin = () => resolveVinxiBin(root);
19
38
  const serverEntry = opts.serverEntry ?? join(".output", "server", "index.mjs");
39
+ const hasOverrides = Boolean(opts.appConfig && Object.keys(opts.appConfig).length);
20
40
  if (runMode === "dev") {
41
+ let restore;
21
42
  return cliFrameworkRecipe({
22
43
  id,
23
44
  root,
24
45
  label: "solidstart",
25
46
  share: "never",
26
47
  env: opts.env,
27
- hashInputs: opts.hashInputs ?? [root, "run:dev"],
48
+ hashInputs: hashInputsFor(opts, root, ["run:dev"]),
28
49
  readyPath: opts.readyPath,
29
50
  readyTimeoutMs: opts.readyTimeoutMs,
30
- start: ({ port }) => ({
31
- command: process.execPath,
32
- args: [
33
- bin(),
34
- "dev",
35
- "--port",
36
- String(port)
37
- ],
38
- cwd: root,
39
- env: { PORT: String(port) }
40
- })
51
+ workspaceDeps: opts.workspaceDeps,
52
+ start: async ({ port }) => {
53
+ if (hasOverrides) {
54
+ restore = await installMergedConfigOverride(resolveAppConfigPath(root), opts.appConfig);
55
+ }
56
+ return {
57
+ command: process.execPath,
58
+ args: [
59
+ bin(),
60
+ "dev",
61
+ "--port",
62
+ String(port)
63
+ ],
64
+ cwd: root,
65
+ env: { PORT: String(port) }
66
+ };
67
+ },
68
+ afterStop: async () => {
69
+ await restore?.();
70
+ restore = undefined;
71
+ }
41
72
  });
42
73
  }
43
74
  if (runMode === "server") {
@@ -47,18 +78,33 @@ export function solidstart(opts) {
47
78
  label: "solidstart",
48
79
  share: "always",
49
80
  env: opts.env,
50
- hashInputs: opts.hashInputs ?? [
51
- root,
52
- "run:server",
53
- serverEntry
54
- ],
81
+ hashInputs: hashInputsFor(opts, root, ["run:server", serverEntry]),
55
82
  readyPath: opts.readyPath,
56
83
  readyTimeoutMs: opts.readyTimeoutMs,
57
- prepare: () => ({
58
- command: process.execPath,
59
- args: [bin(), "build"],
60
- cwd: root
61
- }),
84
+ workspaceDeps: opts.workspaceDeps,
85
+ prepare: async () => {
86
+ if (!hasOverrides) {
87
+ return {
88
+ command: process.execPath,
89
+ args: [bin(), "build"],
90
+ cwd: root
91
+ };
92
+ }
93
+ const vinxi = bin();
94
+ await withAppConfigOverride(root, opts.appConfig, async () => {
95
+ const result = await runCommand(process.execPath, [vinxi, "build"], {
96
+ cwd: root,
97
+ env: {
98
+ ...process.env,
99
+ ...opts.env
100
+ },
101
+ timeoutMs: opts.readyTimeoutMs ?? 3e5
102
+ });
103
+ if (result.exitCode !== 0) {
104
+ throw new Error(`[untestutils/solidstart] prepare failed (${result.exitCode}):\n${result.stderr.slice(-2e3)}\n${result.stdout.slice(-1e3)}`);
105
+ }
106
+ });
107
+ },
62
108
  verifyAfterPrepare: () => {
63
109
  const entry = join(root, serverEntry);
64
110
  if (!existsSync(entry)) {
@@ -83,14 +129,33 @@ export function solidstart(opts) {
83
129
  label: "solidstart",
84
130
  share: "always",
85
131
  env: opts.env,
86
- hashInputs: opts.hashInputs ?? [root, "run:preview"],
132
+ hashInputs: hashInputsFor(opts, root, ["run:preview"]),
87
133
  readyPath: opts.readyPath,
88
134
  readyTimeoutMs: opts.readyTimeoutMs,
89
- prepare: () => ({
90
- command: process.execPath,
91
- args: [bin(), "build"],
92
- cwd: root
93
- }),
135
+ workspaceDeps: opts.workspaceDeps,
136
+ prepare: async () => {
137
+ if (!hasOverrides) {
138
+ return {
139
+ command: process.execPath,
140
+ args: [bin(), "build"],
141
+ cwd: root
142
+ };
143
+ }
144
+ const vinxi = bin();
145
+ await withAppConfigOverride(root, opts.appConfig, async () => {
146
+ const result = await runCommand(process.execPath, [vinxi, "build"], {
147
+ cwd: root,
148
+ env: {
149
+ ...process.env,
150
+ ...opts.env
151
+ },
152
+ timeoutMs: opts.readyTimeoutMs ?? 3e5
153
+ });
154
+ if (result.exitCode !== 0) {
155
+ throw new Error(`[untestutils/solidstart] prepare failed (${result.exitCode}):\n${result.stderr.slice(-2e3)}\n${result.stdout.slice(-1e3)}`);
156
+ }
157
+ });
158
+ },
94
159
  start: ({ port }) => ({
95
160
  command: process.execPath,
96
161
  args: [
@@ -103,5 +168,26 @@ export function solidstart(opts) {
103
168
  env: { PORT: String(port) }
104
169
  })
105
170
  });
171
+ });
172
+
173
+ export function matrix(base, variants) {
174
+ return matrixRecipe(solidstart, base, variants, {
175
+ label: "solidstart",
176
+ merge: (b, patch, id, name) => ({
177
+ ...b,
178
+ ...patch,
179
+ id,
180
+ env: {
181
+ ...b.env ?? {},
182
+ ...patch.env ?? {}
183
+ },
184
+ appConfig: b.appConfig || patch.appConfig ? deepMergePlain(b.appConfig ?? {}, patch.appConfig ?? {}) : undefined,
185
+ hashInputs: [
186
+ ...b.hashInputs ?? [b.root],
187
+ ...patch.hashInputs ?? [],
188
+ `variant:${name}`
189
+ ]
190
+ })
191
+ });
106
192
  }
107
193
  export default solidstart;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@untestutils/solidstart",
3
- "version": "0.5.2",
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.2"
31
+ "@untestutils/core": "0.5.3"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/node": "^26.6.1",