@lazarv/create-react-server 0.0.0-experimental-d003259-20250211-2495688e

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.
Files changed (95) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +31 -0
  3. package/generator.mjs +195 -0
  4. package/globals.d.ts +59 -0
  5. package/index.mjs +87 -0
  6. package/launch.mjs +136 -0
  7. package/lib/code-merge.mjs +246 -0
  8. package/lib/dynamic-checkbox.mjs +259 -0
  9. package/lib/files.mjs +6 -0
  10. package/lib/formatter.mjs +16 -0
  11. package/lib/generate-name.mjs +220 -0
  12. package/lib/theme.mjs +56 -0
  13. package/logo.mjs +3 -0
  14. package/package.json +26 -0
  15. package/steps/alias.mjs +50 -0
  16. package/steps/authentication.mjs +62 -0
  17. package/steps/database.mjs +56 -0
  18. package/steps/deploy.mjs +151 -0
  19. package/steps/features.mjs +415 -0
  20. package/steps/host.mjs +40 -0
  21. package/steps/index.mjs +33 -0
  22. package/steps/integrations.mjs +104 -0
  23. package/steps/name.mjs +69 -0
  24. package/steps/package.mjs +104 -0
  25. package/steps/port.mjs +42 -0
  26. package/steps/preset.mjs +188 -0
  27. package/steps/state-management.mjs +68 -0
  28. package/steps/third-party.mjs +19 -0
  29. package/steps/ui.mjs +87 -0
  30. package/templates/.dockerignore +5 -0
  31. package/templates/.gitignore.template +19 -0
  32. package/templates/.prettierignore +3 -0
  33. package/templates/.prettierrc +11 -0
  34. package/templates/Dockerfile.npm +49 -0
  35. package/templates/Dockerfile.pnpm +71 -0
  36. package/templates/Dockerfile.yarn +71 -0
  37. package/templates/README.docker.md +15 -0
  38. package/templates/README.md +35 -0
  39. package/templates/blank/package.json +6 -0
  40. package/templates/blank/src/App.jsx +5 -0
  41. package/templates/blank-ts/package.json +6 -0
  42. package/templates/blank-ts/src/App.tsx +5 -0
  43. package/templates/eslint.config.template.mjs +98 -0
  44. package/templates/get-started/package.json +6 -0
  45. package/templates/get-started/src/App.jsx +60 -0
  46. package/templates/get-started/src/Button.jsx +14 -0
  47. package/templates/get-started/src/Confetti.jsx +19 -0
  48. package/templates/get-started/src/global.css +3 -0
  49. package/templates/get-started-ts/globals.d.ts +3 -0
  50. package/templates/get-started-ts/package.json +6 -0
  51. package/templates/get-started-ts/src/App.tsx +66 -0
  52. package/templates/get-started-ts/src/Button.tsx +18 -0
  53. package/templates/get-started-ts/src/Confetti.tsx +19 -0
  54. package/templates/get-started-ts/src/global.css +3 -0
  55. package/templates/nextjs/globals.d.ts +3 -0
  56. package/templates/nextjs/react-server.config.json +9 -0
  57. package/templates/nextjs/src/app/layout.tsx +38 -0
  58. package/templates/nextjs/src/app/page.tsx +33 -0
  59. package/templates/nextjs/src/components/Button.tsx +18 -0
  60. package/templates/nextjs/src/components/Confetti.tsx +19 -0
  61. package/templates/nextjs/src/global.css +3 -0
  62. package/templates/package.css.json +5 -0
  63. package/templates/package.eslint.json +19 -0
  64. package/templates/package.eslint.ts.json +7 -0
  65. package/templates/package.json +12 -0
  66. package/templates/package.lightningcss.json +6 -0
  67. package/templates/package.prettier.json +8 -0
  68. package/templates/package.react-compiler.json +7 -0
  69. package/templates/package.swc.json +5 -0
  70. package/templates/package.tailwind.json +7 -0
  71. package/templates/package.ts.json +11 -0
  72. package/templates/postcss.config.mjs +6 -0
  73. package/templates/router/globals.d.ts +3 -0
  74. package/templates/router/react-server.config.json +19 -0
  75. package/templates/router/src/app/@content/about.tsx +98 -0
  76. package/templates/router/src/app/@content/index.tsx +33 -0
  77. package/templates/router/src/app/layout.tsx +44 -0
  78. package/templates/router/src/app/page.tsx +17 -0
  79. package/templates/router/src/components/Button.tsx +18 -0
  80. package/templates/router/src/components/Confetti.tsx +19 -0
  81. package/templates/router/src/components/Navigation.tsx +31 -0
  82. package/templates/router/src/global.css +3 -0
  83. package/templates/shared/public/github.svg +4 -0
  84. package/templates/shared/public/react-server.svg +51 -0
  85. package/templates/tailwind.config.mjs +6 -0
  86. package/templates/tsconfig.css.json +9 -0
  87. package/templates/tsconfig.template.json +15 -0
  88. package/templates/vite.config.lightningcss.mjs +15 -0
  89. package/templates/vite.config.lightningcss.ts +15 -0
  90. package/templates/vite.config.react-compiler.mjs +19 -0
  91. package/templates/vite.config.react-compiler.ts +19 -0
  92. package/templates/vite.config.swc.mjs +6 -0
  93. package/templates/vite.config.swc.ts +6 -0
  94. package/templates/vite.config.ts +3 -0
  95. package/wizard.mjs +122 -0
package/wizard.mjs ADDED
@@ -0,0 +1,122 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+
4
+ import { ExitPromptError } from "@inquirer/core";
5
+ import { confirm } from "@inquirer/prompts";
6
+ import { version } from "@lazarv/react-server";
7
+ import banner from "@lazarv/react-server/lib/utils/banner.mjs";
8
+ import colors from "picocolors";
9
+
10
+ import { warning } from "./lib/theme.mjs";
11
+ import steps from "./steps/index.mjs";
12
+
13
+ export async function wizard(env) {
14
+ const { logger, templateDir } = env;
15
+
16
+ if (!env.options.name) {
17
+ banner("running wizard");
18
+ }
19
+
20
+ if (!process.stdin.isTTY) {
21
+ logger.error("Wizard can only be run in an interactive terminal");
22
+ process.exit(1);
23
+ }
24
+
25
+ logger.info(
26
+ `Press ${colors.cyan("[Escape]")} to revert to the previous step or exit`
27
+ );
28
+
29
+ try {
30
+ let activeStep = 0;
31
+ const history = [];
32
+ let abortController = new AbortController();
33
+ let context = {
34
+ env,
35
+ features: [],
36
+ template: null,
37
+ files: [],
38
+ partials: {
39
+ "package.json": {
40
+ type: "json",
41
+ merge: [
42
+ JSON.parse(
43
+ await readFile(join(templateDir, "package.json"), "utf8")
44
+ ),
45
+ {
46
+ dependencies: {
47
+ "@lazarv/react-server": `${env.reactServer ?? `${version.split("/")[1]}`}`,
48
+ },
49
+ },
50
+ ],
51
+ },
52
+ "README.md": {
53
+ type: "text",
54
+ template: await readFile(join(templateDir, "README.md"), "utf8"),
55
+ },
56
+ },
57
+ signal: abortController.signal,
58
+ };
59
+ process.stdin.on("keypress", async (_, key) => {
60
+ if (key.name === "escape") {
61
+ abortController.abort();
62
+ }
63
+ });
64
+ while (activeStep < steps.length) {
65
+ try {
66
+ const [condition, step] = Array.isArray(steps[activeStep])
67
+ ? steps[activeStep]
68
+ : [() => true, steps[activeStep]];
69
+ if (await condition(context)) {
70
+ context = await step(context);
71
+ if (context.interactive) {
72
+ history.push({ context, step, activeStep });
73
+ delete context.interactive;
74
+ }
75
+ }
76
+ activeStep++;
77
+
78
+ abortController = new AbortController();
79
+ context.signal = abortController.signal;
80
+ } catch (e) {
81
+ console.log(e);
82
+ if (e instanceof ExitPromptError) {
83
+ throw e;
84
+ }
85
+
86
+ if (history.length > 0) {
87
+ abortController = new AbortController();
88
+ const answer = await confirm(
89
+ {
90
+ message: "Revert to previous step?",
91
+ theme: warning,
92
+ },
93
+ {
94
+ signal: abortController.signal,
95
+ }
96
+ );
97
+ if (answer) {
98
+ const { context: prevContext, activeStep: prevStep } =
99
+ history.pop();
100
+ context = prevContext;
101
+ activeStep = prevStep;
102
+ }
103
+ } else {
104
+ throw new Error();
105
+ }
106
+
107
+ abortController = new AbortController();
108
+ context.signal = abortController.signal;
109
+ }
110
+ }
111
+
112
+ if (!env.options.name) {
113
+ logger.info("Wizard completed! 🎉");
114
+ }
115
+
116
+ delete context.signal;
117
+ return context;
118
+ } catch {
119
+ logger.error("Wizard interrupted 🚫");
120
+ process.exit(1);
121
+ }
122
+ }