@untestutils/next 0.5.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 s00d
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,14 @@
1
+ import { type FrameworkBaseOptions } from "@untestutils/core";
2
+ import { type Recipe } from "@untestutils/core";
3
+ export type NextRun = "server" | "dev" | "static";
4
+ export interface NextOptions extends FrameworkBaseOptions {
5
+ run?: NextRun;
6
+ }
7
+ /**
8
+ * Next.js Recipe factory.
9
+ * `run: 'server'` (default) — `next build` + `next start`
10
+ * `run: 'dev'` — `next dev` (never shared)
11
+ * `run: 'static'` — `next build` with export + staticDir on `out/`
12
+ */
13
+ export declare function next(opts: NextOptions): Recipe;
14
+ export default next;
@@ -0,0 +1,15 @@
1
+ import { type FrameworkBaseOptions } from '@untestutils/core';
2
+ import { type Recipe } from '@untestutils/core';
3
+ export type NextRun = 'server' | 'dev' | 'static';
4
+ export interface NextOptions extends FrameworkBaseOptions {
5
+ run?: NextRun;
6
+ }
7
+ /**
8
+ * Next.js Recipe factory.
9
+ * `run: 'server'` (default) — `next build` + `next start`
10
+ * `run: 'dev'` — `next dev` (never shared)
11
+ * `run: 'static'` — `next build` with export + staticDir on `out/`
12
+ */
13
+ export declare function next(opts: NextOptions): Recipe;
14
+ export default next;
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,oBAAoB,EAC1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAA4B,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE1E,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,QAAQ,CAAC;AAElD,MAAM,WAAW,WAAY,SAAQ,oBAAoB;IACvD,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAYD;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAsF9C;AAED,eAAe,IAAI,CAAC"}
package/dist/index.mjs ADDED
@@ -0,0 +1,117 @@
1
+ import { existsSync } from "node:fs";
2
+ import { join, resolve } from "pathe";
3
+ import { assertAppRoot, cliFrameworkRecipe, frameworkRoots, resolveBin, staticDir } from "@untestutils/core";
4
+ import { defineRecipe, runCommand } from "@untestutils/core";
5
+ function resolveNextBin(root) {
6
+ return resolveBin({
7
+ label: "next",
8
+ roots: frameworkRoots(root),
9
+ directIds: ["next/dist/bin/next"],
10
+ packageJsonIds: ["next/package.json"],
11
+ binRelative: ["dist/bin/next"]
12
+ });
13
+ }
14
+
15
+ export function next(opts) {
16
+ const root = resolve(opts.root);
17
+ const runMode = opts.run ?? "server";
18
+ const id = opts.id ?? `next-${runMode}-${root.split("/").pop()}`;
19
+ const bin = () => resolveNextBin(root);
20
+ if (runMode === "dev") {
21
+ return cliFrameworkRecipe({
22
+ id,
23
+ root,
24
+ label: "next",
25
+ share: "never",
26
+ env: opts.env,
27
+ hashInputs: opts.hashInputs ?? [root, "run:dev"],
28
+ readyPath: opts.readyPath,
29
+ readyTimeoutMs: opts.readyTimeoutMs,
30
+ start: ({ port }) => ({
31
+ command: process.execPath,
32
+ args: [
33
+ bin(),
34
+ "dev",
35
+ "-H",
36
+ "127.0.0.1",
37
+ "-p",
38
+ String(port)
39
+ ],
40
+ cwd: root,
41
+ env: { PORT: String(port) }
42
+ })
43
+ });
44
+ }
45
+ if (runMode === "static") {
46
+ const ensureRoot = () => assertAppRoot(root, "next");
47
+ const recipe = defineRecipe({
48
+ id,
49
+ share: "always",
50
+ hashInputs: async () => [
51
+ ...opts.hashInputs ?? [root],
52
+ "run:static",
53
+ ...opts.env ? [`env:${JSON.stringify(opts.env)}`] : []
54
+ ],
55
+ ready: async () => {},
56
+ prepare: async () => {
57
+ ensureRoot();
58
+ const nextBin = bin();
59
+ const result = await runCommand(process.execPath, [nextBin, "build"], {
60
+ cwd: root,
61
+ env: {
62
+ ...process.env,
63
+ ...opts.env
64
+ },
65
+ timeoutMs: opts.readyTimeoutMs ?? 3e5
66
+ });
67
+ if (result.exitCode !== 0) {
68
+ throw new Error(`[untestutils/next] static build failed:\n${result.stderr.slice(-2e3)}`);
69
+ }
70
+ const out = join(root, "out");
71
+ if (!existsSync(out)) {
72
+ throw new Error(`[untestutils/next] expected ${out} after static export (set output: 'export' in next.config)`);
73
+ }
74
+ },
75
+ start: async (ctx) => {
76
+ ensureRoot();
77
+ const publicDir = join(root, "out");
78
+ const serving = staticDir({
79
+ id: `${id}-static-serve`,
80
+ root: publicDir
81
+ });
82
+ return serving.start(ctx);
83
+ }
84
+ });
85
+ recipe.root = root;
86
+ return recipe;
87
+ }
88
+ return cliFrameworkRecipe({
89
+ id,
90
+ root,
91
+ label: "next",
92
+ share: "always",
93
+ env: opts.env,
94
+ hashInputs: opts.hashInputs ?? [root, "run:server"],
95
+ readyPath: opts.readyPath,
96
+ readyTimeoutMs: opts.readyTimeoutMs,
97
+ prepare: () => ({
98
+ command: process.execPath,
99
+ args: [bin(), "build"],
100
+ cwd: root
101
+ }),
102
+ start: ({ port }) => ({
103
+ command: process.execPath,
104
+ args: [
105
+ bin(),
106
+ "start",
107
+ "-H",
108
+ "127.0.0.1",
109
+ "-p",
110
+ String(port)
111
+ ],
112
+ cwd: root,
113
+ env: { PORT: String(port) }
114
+ })
115
+ });
116
+ }
117
+ export default next;
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@untestutils/next",
3
+ "version": "0.5.0",
4
+ "files": [
5
+ "dist"
6
+ ],
7
+ "type": "module",
8
+ "sideEffects": false,
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.mjs",
13
+ "default": "./dist/index.mjs"
14
+ },
15
+ "./package.json": "./package.json"
16
+ },
17
+ "dependencies": {
18
+ "pathe": "^2.0.3",
19
+ "@untestutils/core": "0.5.0"
20
+ },
21
+ "devDependencies": {
22
+ "@types/node": "^26.6.1",
23
+ "publint": "^0.3.24",
24
+ "typescript": "^6.0.3",
25
+ "obuild": "^0.4.40"
26
+ },
27
+ "peerDependencies": {
28
+ "next": "*",
29
+ "react": "*",
30
+ "react-dom": "*"
31
+ },
32
+ "peerDependenciesMeta": {
33
+ "next": {
34
+ "optional": true
35
+ },
36
+ "react": {
37
+ "optional": true
38
+ },
39
+ "react-dom": {
40
+ "optional": true
41
+ }
42
+ },
43
+ "engines": {
44
+ "node": ">=20"
45
+ },
46
+ "license": "MIT",
47
+ "homepage": "https://s00d.github.io/untestutils/",
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "git+https://github.com/s00d/untestutils.git",
51
+ "directory": "packages/next"
52
+ },
53
+ "main": "./dist/index.mjs",
54
+ "types": "./dist/index.d.ts",
55
+ "publishConfig": {
56
+ "access": "public"
57
+ },
58
+ "scripts": {
59
+ "build": "obuild && tsc -p tsconfig.build.json",
60
+ "publint": "publint --strict"
61
+ }
62
+ }