@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 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
- const cli = cac();
18
-
19
- const { default: packageJson } = await import("./package.json", {
20
- with: { type: "json" },
21
- });
22
-
23
- cli.usage("[options]");
24
-
25
- cli
26
- .option("--name <name>", "The name of the project")
27
- .option("--preset <preset>", "The preset to use")
28
- .option("--features <features>", "The features to use")
29
- .option("--alias <alias>", "The TypeScript path alias to use")
30
- .option("--host <host>", "The host to use")
31
- .option("--port <port>", "The port to use")
32
- .option("--deploy <deploy>", "The deployment adapter to use")
33
- .option("--git", "Initialize a git repository")
34
- .option("--dev", "Run in development mode")
35
- .option("--open", "Open the project in the browser")
36
- .option("--clean", "Clean the project directory before bootstrapping")
37
- .option("--no-install", "Do not install dependencies")
38
- .option(
39
- "--react-server <version>",
40
- "The version of @lazarv/react-server to use"
41
- )
42
- .version(packageJson.version);
43
-
44
- cli.name = packageJson.name.split("/").pop();
45
- cli.help();
46
-
47
- const { options } = cli.parse();
48
- const {
49
- help,
50
- v: version,
51
- reactServer,
52
- install,
53
- // eslint-disable-next-line no-unused-vars
54
- "--": _,
55
- ...createOptions
56
- } = options;
57
- const hasOptions = Object.keys(createOptions).length > 1 || install === false;
58
- createOptions.install = install;
59
-
60
- if (help || version) {
61
- process.exit(0);
62
- }
63
-
64
- await import("./logo.mjs");
65
-
66
- const logger = createLogger();
67
-
68
- const cwd = process.cwd();
69
- const templateDir = join(dirname(fileURLToPath(import.meta.url)), "templates");
70
-
71
- const [{ wizard }, { generate }, { launch }] = await Promise.all([
72
- import("./wizard.mjs"),
73
- import("./generator.mjs"),
74
- import("./launch.mjs"),
75
- ]);
76
-
77
- const context = await wizard({
78
- cwd,
79
- logger,
80
- templateDir,
81
- hasOptions,
82
- options: createOptions,
83
- reactServer,
84
- });
85
-
86
- await generate(context);
87
- await launch(context);
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 prettier from "prettier";
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
- return prettier.format(code, {
5
- parser,
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-9900497-20251226-42112a97",
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
- "esm",
14
- "vite",
15
- "create"
11
+ "vite"
16
12
  ],
17
- "author": "lazarv",
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
- "bugs": {
24
- "url": "https://github.com/lazarv/react-server/issues"
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-9900497-20251226-42112a97"
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
@@ -10,7 +10,7 @@ export default [
10
10
  (!context.props.custom ||
11
11
  context.env.hasOptions ||
12
12
  context.props.preset?.alias
13
- ? context.props.preset?.alias ?? "~/*"
13
+ ? (context.props.preset?.alias ?? "~/*")
14
14
  : await input(
15
15
  {
16
16
  message: "TypeScript path alias",
@@ -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"] = {
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/user/oxfmt/main/npm/oxfmt/configuration_schema.json",
3
+ "indentWidth": 2,
4
+ "lineWidth": 80
5
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/oxc-project/oxc/main/npm/oxlint/configuration_schema.json",
3
+ "rules": {}
4
+ }
@@ -7,5 +7,5 @@
7
7
  "quoteProps": "as-needed",
8
8
  "trailingComma": "es5",
9
9
  "bracketSpacing": true,
10
- "bracketSameLine": false
10
+ "bracketSameLine": false,
11
11
  }
@@ -7,9 +7,8 @@ export default function Confetti(props) {
7
7
  <Button
8
8
  {...props}
9
9
  onClick={async () => {
10
- const { default: confetti } = await import(
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 } = await import(
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 } = await import(
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
  >
@@ -0,0 +1,10 @@
1
+ {
2
+ "scripts": {
3
+ "lint": "oxlint",
4
+ "format": "oxfmt ."
5
+ },
6
+ "devDependencies": {
7
+ "oxlint": "^1.34.0",
8
+ "oxfmt": "^0.19.0"
9
+ }
10
+ }
@@ -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 } = await import(
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
  }