revine 0.4.1 → 0.6.0
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/dist/commands/createProject.js +3 -1
- package/dist/prompts/index.js +2 -0
- package/dist/prompts/project.js +27 -0
- package/dist/prompts/tailwind.js +1 -1
- package/dist/setup/tailwind.js +21 -0
- package/package.json +1 -1
- package/src/commands/createProject.ts +4 -1
- package/src/prompts/index.ts +2 -0
- package/src/prompts/project.ts +31 -0
- package/src/prompts/tailwind.ts +1 -1
- package/src/setup/tailwind.ts +22 -0
- package/template/.revine/routing/fileBased.tsx +7 -1
- package/template/package.json +1 -2
- package/template/src/NotFound.tsx +13 -0
- package/template/src/styles/global.css +41 -0
|
@@ -3,7 +3,7 @@ import { fileURLToPath } from "url";
|
|
|
3
3
|
import { updatePackageJson } from "../config/package.js";
|
|
4
4
|
import { updateReadme } from "../config/readme.js";
|
|
5
5
|
import { installDependencies } from "../setup/dependencies.js";
|
|
6
|
-
import { askForTailwindSetup } from "../prompts/
|
|
6
|
+
import { askForTailwindSetup, initiateProject } from "../prompts/index.js";
|
|
7
7
|
import { setupTailwind } from "../setup/tailwind.js";
|
|
8
8
|
import { copyTemplate } from "../utils/file.js";
|
|
9
9
|
import { logError, logInfo } from "../utils/logger.js";
|
|
@@ -41,6 +41,8 @@ export async function createProject(projectName, options) {
|
|
|
41
41
|
if (!isCurrentDir)
|
|
42
42
|
console.log(` cd ${projectName}`);
|
|
43
43
|
console.log(" npm run dev\n");
|
|
44
|
+
// Prompt to initiate project
|
|
45
|
+
await initiateProject(projectDir);
|
|
44
46
|
}
|
|
45
47
|
catch (error) {
|
|
46
48
|
logError("Error during project creation:", error);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import inquirer from "inquirer";
|
|
2
|
+
import { execSync } from "child_process";
|
|
3
|
+
import { logInfo } from "../utils/logger.js";
|
|
4
|
+
/**
|
|
5
|
+
* Ask the user if they want to run the project after setup is complete.
|
|
6
|
+
* If the user confirms, it will run `npm run dev` or the equivalent command.
|
|
7
|
+
* @param projectDir - The directory where the project was set up.
|
|
8
|
+
*/
|
|
9
|
+
export default async function initiateProject(projectDir) {
|
|
10
|
+
const { runProject } = await inquirer.prompt([
|
|
11
|
+
{
|
|
12
|
+
type: "confirm",
|
|
13
|
+
name: "runProject",
|
|
14
|
+
message: "Do you want to run the project now?",
|
|
15
|
+
default: true,
|
|
16
|
+
},
|
|
17
|
+
]);
|
|
18
|
+
if (runProject) {
|
|
19
|
+
logInfo("Running your Revine project on dev server...");
|
|
20
|
+
try {
|
|
21
|
+
execSync("npm run dev", { cwd: projectDir, stdio: "inherit" });
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
logInfo("Failed to start the project. You can manually run `npm run dev`.");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
package/dist/prompts/tailwind.js
CHANGED
package/dist/setup/tailwind.js
CHANGED
|
@@ -127,4 +127,25 @@ export default function HomePage() {
|
|
|
127
127
|
}
|
|
128
128
|
`;
|
|
129
129
|
await fs.writeFile(starterFile, starterFileContent);
|
|
130
|
+
// Replace the NotFound.tsx content
|
|
131
|
+
const notFoundFile = path.join(projectDir, "src", "NotFound.tsx");
|
|
132
|
+
const notFoundContent = `
|
|
133
|
+
export default function NotFound() {
|
|
134
|
+
return (
|
|
135
|
+
<div className="min-h-screen flex items-center justify-center bg-gray-100">
|
|
136
|
+
<div className="text-center space-y-4">
|
|
137
|
+
<h1 className="text-6xl font-bold text-gray-900">404</h1>
|
|
138
|
+
<p className="text-xl text-gray-600">Page Not Found</p>
|
|
139
|
+
<a
|
|
140
|
+
href="/"
|
|
141
|
+
className="mt-6 inline-block bg-indigo-600 text-white font-semibold px-6 py-3 rounded-md shadow hover:bg-indigo-700"
|
|
142
|
+
>
|
|
143
|
+
Go Back Home
|
|
144
|
+
</a>
|
|
145
|
+
</div>
|
|
146
|
+
</div>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
`;
|
|
150
|
+
await fs.writeFile(notFoundFile, notFoundContent);
|
|
130
151
|
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import { fileURLToPath } from "url";
|
|
|
3
3
|
import { updatePackageJson } from "../config/package.js";
|
|
4
4
|
import { updateReadme } from "../config/readme.js";
|
|
5
5
|
import { installDependencies } from "../setup/dependencies.js";
|
|
6
|
-
import { askForTailwindSetup } from "../prompts/
|
|
6
|
+
import { askForTailwindSetup, initiateProject } from "../prompts/index.js";
|
|
7
7
|
import { setupTailwind } from "../setup/tailwind.js";
|
|
8
8
|
import { copyTemplate } from "../utils/file.js";
|
|
9
9
|
import { logError, logInfo } from "../utils/logger.js";
|
|
@@ -52,6 +52,9 @@ export async function createProject(
|
|
|
52
52
|
logInfo("\nStart developing with:");
|
|
53
53
|
if (!isCurrentDir) console.log(` cd ${projectName}`);
|
|
54
54
|
console.log(" npm run dev\n");
|
|
55
|
+
|
|
56
|
+
// Prompt to initiate project
|
|
57
|
+
await initiateProject(projectDir);
|
|
55
58
|
} catch (error) {
|
|
56
59
|
logError("Error during project creation:", error);
|
|
57
60
|
process.exit(1);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import inquirer from "inquirer";
|
|
2
|
+
import { execSync } from "child_process";
|
|
3
|
+
import { logInfo } from "../utils/logger.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Ask the user if they want to run the project after setup is complete.
|
|
7
|
+
* If the user confirms, it will run `npm run dev` or the equivalent command.
|
|
8
|
+
* @param projectDir - The directory where the project was set up.
|
|
9
|
+
*/
|
|
10
|
+
export default async function initiateProject(projectDir: string) {
|
|
11
|
+
const { runProject } = await inquirer.prompt([
|
|
12
|
+
{
|
|
13
|
+
type: "confirm",
|
|
14
|
+
name: "runProject",
|
|
15
|
+
message: "Do you want to run the project now?",
|
|
16
|
+
default: true,
|
|
17
|
+
},
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
if (runProject) {
|
|
21
|
+
logInfo("Running your Revine project on dev server...");
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
execSync("npm run dev", { cwd: projectDir, stdio: "inherit" });
|
|
25
|
+
} catch (error) {
|
|
26
|
+
logInfo(
|
|
27
|
+
"Failed to start the project. You can manually run `npm run dev`."
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
package/src/prompts/tailwind.ts
CHANGED
package/src/setup/tailwind.ts
CHANGED
|
@@ -138,4 +138,26 @@ export default function HomePage() {
|
|
|
138
138
|
}
|
|
139
139
|
`;
|
|
140
140
|
await fs.writeFile(starterFile, starterFileContent);
|
|
141
|
+
|
|
142
|
+
// Replace the NotFound.tsx content
|
|
143
|
+
const notFoundFile = path.join(projectDir, "src", "NotFound.tsx");
|
|
144
|
+
const notFoundContent = `
|
|
145
|
+
export default function NotFound() {
|
|
146
|
+
return (
|
|
147
|
+
<div className="min-h-screen flex items-center justify-center bg-gray-100">
|
|
148
|
+
<div className="text-center space-y-4">
|
|
149
|
+
<h1 className="text-6xl font-bold text-gray-900">404</h1>
|
|
150
|
+
<p className="text-xl text-gray-600">Page Not Found</p>
|
|
151
|
+
<a
|
|
152
|
+
href="/"
|
|
153
|
+
className="mt-6 inline-block bg-indigo-600 text-white font-semibold px-6 py-3 rounded-md shadow hover:bg-indigo-700"
|
|
154
|
+
>
|
|
155
|
+
Go Back Home
|
|
156
|
+
</a>
|
|
157
|
+
</div>
|
|
158
|
+
</div>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
`;
|
|
162
|
+
await fs.writeFile(notFoundFile, notFoundContent);
|
|
141
163
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createBrowserRouter } from "react-router-dom";
|
|
2
2
|
import { lazy, Suspense, ComponentType } from "react";
|
|
3
|
+
import NotFound from "../../src/NotFound";
|
|
3
4
|
|
|
4
5
|
const pages = import.meta.glob("../../src/pages/**/*.tsx");
|
|
5
6
|
|
|
@@ -18,7 +19,6 @@ const routes = Object.entries(pages).map(([filePath, component]) => {
|
|
|
18
19
|
cleaned = "";
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
// 6. Route path is empty for index => "/"
|
|
22
22
|
const routePath = cleaned === "" ? "/" : `/${cleaned}`;
|
|
23
23
|
|
|
24
24
|
const Component = lazy(
|
|
@@ -35,4 +35,10 @@ const routes = Object.entries(pages).map(([filePath, component]) => {
|
|
|
35
35
|
};
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
+
// fallback route for 404s
|
|
39
|
+
routes.push({
|
|
40
|
+
path: "*",
|
|
41
|
+
element: <NotFound />,
|
|
42
|
+
});
|
|
43
|
+
|
|
38
44
|
export const router = createBrowserRouter(routes);
|
package/template/package.json
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default function NotFound() {
|
|
2
|
+
return (
|
|
3
|
+
<div className="notfound-container">
|
|
4
|
+
<div className="notfound-content">
|
|
5
|
+
<h1 className="notfound-title">404</h1>
|
|
6
|
+
<p className="notfound-text">Page Not Found</p>
|
|
7
|
+
<a href="/" className="notfound-link">
|
|
8
|
+
Go Back Home
|
|
9
|
+
</a>
|
|
10
|
+
</div>
|
|
11
|
+
</div>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
@@ -148,3 +148,44 @@ p {
|
|
|
148
148
|
font-size: 0.875rem;
|
|
149
149
|
color: var(--text-secondary);
|
|
150
150
|
}
|
|
151
|
+
|
|
152
|
+
/* notfound.css */
|
|
153
|
+
.notfound-container {
|
|
154
|
+
min-height: 100vh;
|
|
155
|
+
display: flex;
|
|
156
|
+
align-items: center;
|
|
157
|
+
justify-content: center;
|
|
158
|
+
background-color: #f5f5f5; /* Light gray */
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.notfound-content {
|
|
162
|
+
text-align: center;
|
|
163
|
+
margin: auto;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.notfound-title {
|
|
167
|
+
font-size: 4rem; /* 64px */
|
|
168
|
+
font-weight: bold;
|
|
169
|
+
color: #1a202c; /* Gray-900 */
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.notfound-text {
|
|
173
|
+
font-size: 1.25rem; /* 20px */
|
|
174
|
+
color: #4a5568; /* Gray-600 */
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.notfound-link {
|
|
178
|
+
margin-top: 1.5rem;
|
|
179
|
+
display: inline-block;
|
|
180
|
+
padding: 0.75rem 1.5rem;
|
|
181
|
+
font-weight: 600;
|
|
182
|
+
background-color: #5a67d8; /* Indigo-600 */
|
|
183
|
+
color: #ffffff;
|
|
184
|
+
text-decoration: none;
|
|
185
|
+
border-radius: 0.375rem;
|
|
186
|
+
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.notfound-link:hover {
|
|
190
|
+
background-color: #4c51bf; /* Indigo-700 */
|
|
191
|
+
}
|