@lazarv/create-react-server 0.0.0-experimental-c75b01a-20251226-122f8a22 → 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,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazarv/create-react-server",
3
- "version": "0.0.0-experimental-c75b01a-20251226-122f8a22",
3
+ "version": "0.0.0-experimental-953e1cd-20251226-5508ddf7",
4
4
  "keywords": [
5
5
  "create",
6
6
  "esm",
@@ -41,8 +41,8 @@
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
47
  "@lazarv/react-server": "0.0.0-experimental-c75b01a-20251226-122f8a22"
48
48
  },
@@ -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",
@@ -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
+ }
@@ -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
+ }
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
  }
@@ -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
  }