@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 +81 -71
- package/lib/formatter.mjs +12 -3
- package/package.json +2 -2
- package/steps/features.mjs +32 -0
- package/templates/.oxfmtrc.json +5 -0
- package/templates/.oxlintrc.json +4 -0
- package/templates/package.oxtools.json +10 -0
- package/wizard.mjs +4 -2
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lazarv/create-react-server",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
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
|
},
|
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",
|
|
@@ -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/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
|
}
|