@lazarv/create-react-server 0.0.0-experimental-9900497-20251226-42112a97 → 0.0.0-experimental-953e1cd-20251226-5508ddf7
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/index.mjs +81 -71
- package/lib/formatter.mjs +12 -3
- package/package.json +14 -14
- package/steps/alias.mjs +1 -1
- package/steps/features.mjs +33 -1
- package/templates/.oxfmtrc.json +5 -0
- package/templates/.oxlintrc.json +4 -0
- package/templates/.prettierrc +1 -1
- package/templates/get-started/src/Confetti.jsx +2 -3
- package/templates/get-started-ts/src/Confetti.tsx +2 -3
- package/templates/nextjs/src/components/Confetti.tsx +2 -3
- package/templates/package.oxtools.json +10 -0
- package/templates/router/src/app/@content/about.tsx +1 -3
- package/templates/router/src/components/Confetti.tsx +2 -3
- package/wizard.mjs +5 -3
package/index.mjs
CHANGED
|
@@ -14,74 +14,84 @@ import { fileURLToPath } from "node:url";
|
|
|
14
14
|
import createLogger from "@lazarv/react-server/lib/dev/create-logger.mjs";
|
|
15
15
|
import cac from "cac";
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
cli
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
} = options;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
17
|
+
(async () => {
|
|
18
|
+
try {
|
|
19
|
+
const cli = cac();
|
|
20
|
+
|
|
21
|
+
const { default: packageJson } = await import("./package.json", {
|
|
22
|
+
with: { type: "json" },
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
cli.usage("[options]");
|
|
26
|
+
|
|
27
|
+
cli
|
|
28
|
+
.option("--name <name>", "The name of the project")
|
|
29
|
+
.option("--preset <preset>", "The preset to use")
|
|
30
|
+
.option("--features <features>", "The features to use")
|
|
31
|
+
.option("--alias <alias>", "The TypeScript path alias to use")
|
|
32
|
+
.option("--host <host>", "The host to use")
|
|
33
|
+
.option("--port <port>", "The port to use")
|
|
34
|
+
.option("--deploy <deploy>", "The deployment adapter to use")
|
|
35
|
+
.option("--git", "Initialize a git repository")
|
|
36
|
+
.option("--dev", "Run in development mode")
|
|
37
|
+
.option("--open", "Open the project in the browser")
|
|
38
|
+
.option("--clean", "Clean the project directory before bootstrapping")
|
|
39
|
+
.option("--no-install", "Do not install dependencies")
|
|
40
|
+
.option(
|
|
41
|
+
"--react-server <version>",
|
|
42
|
+
"The version of @lazarv/react-server to use"
|
|
43
|
+
)
|
|
44
|
+
.version(packageJson.version);
|
|
45
|
+
|
|
46
|
+
cli.name = packageJson.name.split("/").pop();
|
|
47
|
+
cli.help();
|
|
48
|
+
|
|
49
|
+
const { options } = cli.parse();
|
|
50
|
+
const {
|
|
51
|
+
help,
|
|
52
|
+
v: version,
|
|
53
|
+
reactServer,
|
|
54
|
+
install,
|
|
55
|
+
...createOptions
|
|
56
|
+
} = options;
|
|
57
|
+
delete createOptions["--"];
|
|
58
|
+
const hasOptions =
|
|
59
|
+
Object.keys(createOptions).length > 1 || install === false;
|
|
60
|
+
createOptions.install = install;
|
|
61
|
+
|
|
62
|
+
if (help || version) {
|
|
63
|
+
process.exit(0);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
await import("./logo.mjs");
|
|
67
|
+
|
|
68
|
+
const logger = createLogger();
|
|
69
|
+
|
|
70
|
+
const cwd = process.cwd();
|
|
71
|
+
const templateDir = join(
|
|
72
|
+
dirname(fileURLToPath(import.meta.url)),
|
|
73
|
+
"templates"
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const [{ wizard }, { generate }, { launch }] = await Promise.all([
|
|
77
|
+
import("./wizard.mjs"),
|
|
78
|
+
import("./generator.mjs"),
|
|
79
|
+
import("./launch.mjs"),
|
|
80
|
+
]);
|
|
81
|
+
|
|
82
|
+
const context = await wizard({
|
|
83
|
+
cwd,
|
|
84
|
+
logger,
|
|
85
|
+
templateDir,
|
|
86
|
+
hasOptions,
|
|
87
|
+
options: createOptions,
|
|
88
|
+
reactServer,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
await generate(context);
|
|
92
|
+
await launch(context);
|
|
93
|
+
} catch {
|
|
94
|
+
console.error("Wizard interrupted 🚫");
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
})();
|
package/lib/formatter.mjs
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { format as oxfmt } from "oxfmt";
|
|
2
|
+
|
|
3
|
+
const parserToExtension = {
|
|
4
|
+
babel: "js",
|
|
5
|
+
typescript: "ts",
|
|
6
|
+
json: "json",
|
|
7
|
+
js: "js",
|
|
8
|
+
ts: "ts",
|
|
9
|
+
};
|
|
2
10
|
|
|
3
11
|
export async function format(code, parser) {
|
|
4
|
-
|
|
5
|
-
|
|
12
|
+
const ext = parserToExtension[parser] || parser;
|
|
13
|
+
const { code: formatted } = await oxfmt(`file.${ext}`, code, {
|
|
6
14
|
printWidth: 80,
|
|
7
15
|
tabWidth: 2,
|
|
8
16
|
useTabs: false,
|
|
@@ -13,4 +21,5 @@ export async function format(code, parser) {
|
|
|
13
21
|
bracketSpacing: true,
|
|
14
22
|
bracketSameLine: false,
|
|
15
23
|
});
|
|
24
|
+
return formatted;
|
|
16
25
|
}
|
package/package.json
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lazarv/create-react-server",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
4
|
-
"bin": {
|
|
5
|
-
"create-react-server": "index.mjs"
|
|
6
|
-
},
|
|
7
|
-
"type": "module",
|
|
3
|
+
"version": "0.0.0-experimental-953e1cd-20251226-5508ddf7",
|
|
8
4
|
"keywords": [
|
|
5
|
+
"create",
|
|
6
|
+
"esm",
|
|
9
7
|
"react",
|
|
10
|
-
"server",
|
|
11
8
|
"rsc",
|
|
9
|
+
"server",
|
|
12
10
|
"ssr",
|
|
13
|
-
"
|
|
14
|
-
"vite",
|
|
15
|
-
"create"
|
|
11
|
+
"vite"
|
|
16
12
|
],
|
|
17
|
-
"
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/lazarv/react-server/issues"
|
|
15
|
+
},
|
|
18
16
|
"license": "MIT",
|
|
17
|
+
"author": "lazarv",
|
|
19
18
|
"repository": {
|
|
20
19
|
"type": "git",
|
|
21
20
|
"url": "git+https://github.com/lazarv/react-server.git"
|
|
22
21
|
},
|
|
23
|
-
"
|
|
24
|
-
"
|
|
22
|
+
"bin": {
|
|
23
|
+
"create-react-server": "index.mjs"
|
|
25
24
|
},
|
|
25
|
+
"type": "module",
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public",
|
|
28
28
|
"provenance": true,
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"cac": "^6.7.14",
|
|
42
42
|
"fast-glob": "^3.2.12",
|
|
43
43
|
"filesize": "^10.0.12",
|
|
44
|
+
"oxfmt": "^0.20.0",
|
|
44
45
|
"picocolors": "^1.1.1",
|
|
45
|
-
"prettier": "^3.0.0",
|
|
46
46
|
"ts-morph": "^24.0.0",
|
|
47
|
-
"@lazarv/react-server": "0.0.0-experimental-
|
|
47
|
+
"@lazarv/react-server": "0.0.0-experimental-c75b01a-20251226-122f8a22"
|
|
48
48
|
},
|
|
49
49
|
"engines": {
|
|
50
50
|
"node": ">=20.10.0"
|
package/steps/alias.mjs
CHANGED
package/steps/features.mjs
CHANGED
|
@@ -29,6 +29,12 @@ export default async (context) => {
|
|
|
29
29
|
description: "Add Prettier support",
|
|
30
30
|
checked: context.props.preset?.features.includes("prettier"),
|
|
31
31
|
},
|
|
32
|
+
{
|
|
33
|
+
name: "Oxlint and Oxfmt",
|
|
34
|
+
value: "oxtools",
|
|
35
|
+
description: "Add Oxlint and Oxfmt support",
|
|
36
|
+
checked: context.props.preset?.features.includes("oxtools"),
|
|
37
|
+
},
|
|
32
38
|
{
|
|
33
39
|
name: "Tailwind CSS v3",
|
|
34
40
|
value: "tailwind",
|
|
@@ -107,7 +113,7 @@ export default async (context) => {
|
|
|
107
113
|
...(context.props.preset?.features ?? []),
|
|
108
114
|
...(context.env.options.features?.split(",") ??
|
|
109
115
|
(!context.props.custom || context.env.hasOptions
|
|
110
|
-
? context.props.preset.features ?? []
|
|
116
|
+
? (context.props.preset.features ?? [])
|
|
111
117
|
: await checkbox(
|
|
112
118
|
{
|
|
113
119
|
message: "Enabled features",
|
|
@@ -240,6 +246,32 @@ import tsParser from "@typescript-eslint/parser";`,
|
|
|
240
246
|
};
|
|
241
247
|
}
|
|
242
248
|
|
|
249
|
+
if (answer.includes("oxtools")) {
|
|
250
|
+
if (answer.includes("eslint")) {
|
|
251
|
+
context.env.logger.warn(
|
|
252
|
+
"ESLint is already selected. Oxlint will not be installed as it serves the same purpose."
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
if (answer.includes("prettier")) {
|
|
256
|
+
context.env.logger.warn(
|
|
257
|
+
"Prettier is already selected. Oxfmt will not be installed as it serves the same purpose."
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
if (!answer.includes("eslint") && !answer.includes("prettier")) {
|
|
261
|
+
partials["package.json"] = {
|
|
262
|
+
...partials["package.json"],
|
|
263
|
+
merge: [
|
|
264
|
+
...partials["package.json"].merge,
|
|
265
|
+
await json(context.env.templateDir, "package.oxtools.json"),
|
|
266
|
+
],
|
|
267
|
+
};
|
|
268
|
+
files.push(
|
|
269
|
+
join(context.env.templateDir, ".oxlintrc.json"),
|
|
270
|
+
join(context.env.templateDir, ".oxfmtrc.json")
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
243
275
|
if (answer.includes("tailwind")) {
|
|
244
276
|
if (!answer.includes("tailwind-v4")) {
|
|
245
277
|
partials["package.json"] = {
|
package/templates/.prettierrc
CHANGED
|
@@ -7,9 +7,8 @@ export default function Confetti(props) {
|
|
|
7
7
|
<Button
|
|
8
8
|
{...props}
|
|
9
9
|
onClick={async () => {
|
|
10
|
-
const { default: confetti } =
|
|
11
|
-
"https://esm.sh/canvas-confetti"
|
|
12
|
-
);
|
|
10
|
+
const { default: confetti } =
|
|
11
|
+
await import("https://esm.sh/canvas-confetti");
|
|
13
12
|
confetti();
|
|
14
13
|
}}
|
|
15
14
|
>
|
|
@@ -7,9 +7,8 @@ export default function Confetti(props: ButtonProps) {
|
|
|
7
7
|
<Button
|
|
8
8
|
{...props}
|
|
9
9
|
onClick={async () => {
|
|
10
|
-
const { default: confetti } =
|
|
11
|
-
"https://esm.sh/canvas-confetti"
|
|
12
|
-
);
|
|
10
|
+
const { default: confetti } =
|
|
11
|
+
await import("https://esm.sh/canvas-confetti");
|
|
13
12
|
confetti();
|
|
14
13
|
}}
|
|
15
14
|
>
|
|
@@ -7,9 +7,8 @@ export default function Confetti(props: ButtonProps) {
|
|
|
7
7
|
<Button
|
|
8
8
|
{...props}
|
|
9
9
|
onClick={async () => {
|
|
10
|
-
const { default: confetti } =
|
|
11
|
-
"https://esm.sh/canvas-confetti"
|
|
12
|
-
);
|
|
10
|
+
const { default: confetti } =
|
|
11
|
+
await import("https://esm.sh/canvas-confetti");
|
|
13
12
|
confetti();
|
|
14
13
|
}}
|
|
15
14
|
>
|
|
@@ -39,9 +39,7 @@ export default function About() {
|
|
|
39
39
|
CLI tool, setting up a fully functional React Server Components (RSC)
|
|
40
40
|
app with file-system based routing and server functions out of the box.
|
|
41
41
|
</p>
|
|
42
|
-
<h2 className="text-xl font-semibold m-0">
|
|
43
|
-
🗂 File-system based routing
|
|
44
|
-
</h2>
|
|
42
|
+
<h2 className="text-xl font-semibold m-0">🗂 File-system based routing</h2>
|
|
45
43
|
<ul className="list-disc pl-6">
|
|
46
44
|
<li>
|
|
47
45
|
Add files to <b>/src/app</b> to{" "}
|
|
@@ -7,9 +7,8 @@ export default function Confetti(props: ButtonProps) {
|
|
|
7
7
|
<Button
|
|
8
8
|
{...props}
|
|
9
9
|
onClick={async () => {
|
|
10
|
-
const { default: confetti } =
|
|
11
|
-
"https://esm.sh/canvas-confetti"
|
|
12
|
-
);
|
|
10
|
+
const { default: confetti } =
|
|
11
|
+
await import("https://esm.sh/canvas-confetti");
|
|
13
12
|
confetti();
|
|
14
13
|
}}
|
|
15
14
|
>
|
package/wizard.mjs
CHANGED
|
@@ -78,7 +78,6 @@ export async function wizard(env) {
|
|
|
78
78
|
abortController = new AbortController();
|
|
79
79
|
context.signal = abortController.signal;
|
|
80
80
|
} catch (e) {
|
|
81
|
-
console.log(e);
|
|
82
81
|
if (e instanceof ExitPromptError) {
|
|
83
82
|
throw e;
|
|
84
83
|
}
|
|
@@ -101,7 +100,7 @@ export async function wizard(env) {
|
|
|
101
100
|
activeStep = prevStep;
|
|
102
101
|
}
|
|
103
102
|
} else {
|
|
104
|
-
throw new Error();
|
|
103
|
+
throw new Error("Invalid wizard step", { cause: e });
|
|
105
104
|
}
|
|
106
105
|
|
|
107
106
|
abortController = new AbortController();
|
|
@@ -115,8 +114,11 @@ export async function wizard(env) {
|
|
|
115
114
|
|
|
116
115
|
delete context.signal;
|
|
117
116
|
return context;
|
|
118
|
-
} catch {
|
|
117
|
+
} catch (e) {
|
|
119
118
|
logger.error("Wizard interrupted 🚫");
|
|
119
|
+
if (e instanceof ExitPromptError) {
|
|
120
|
+
process.exit(0);
|
|
121
|
+
}
|
|
120
122
|
process.exit(1);
|
|
121
123
|
}
|
|
122
124
|
}
|