create-tsrouter-app 0.0.4
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/.gitattributes +2 -0
- package/.github/FUNDING.yml +1 -0
- package/.github/ISSUE_TEMPLATE/bug_report.yml +94 -0
- package/.github/ISSUE_TEMPLATE/config.yml +11 -0
- package/.github/workflows/ci.yml +43 -0
- package/.nvmrc +1 -0
- package/.prettierignore +3 -0
- package/CONTRIBUTING.md +32 -0
- package/LICENSE +21 -0
- package/README.md +47 -0
- package/dist/index.js +140 -0
- package/dist/utils/getPackageManager.js +15 -0
- package/eslint.config.js +35 -0
- package/package.json +41 -0
- package/prettier.config.js +10 -0
- package/project-template/.vscode/settings.json +11 -0
- package/project-template/README.md.ejs +498 -0
- package/project-template/gitignore +5 -0
- package/project-template/index.html.ejs +20 -0
- package/project-template/package.json +28 -0
- package/project-template/package.ts.json +7 -0
- package/project-template/package.tw.json +6 -0
- package/project-template/public/favicon.ico +0 -0
- package/project-template/public/logo192.png +0 -0
- package/project-template/public/logo512.png +0 -0
- package/project-template/public/manifest.json +25 -0
- package/project-template/public/robots.txt +3 -0
- package/project-template/src/App.css +38 -0
- package/project-template/src/App.test.tsx.ejs +10 -0
- package/project-template/src/App.tsx.ejs +64 -0
- package/project-template/src/logo.svg +44 -0
- package/project-template/src/main.tsx.ejs +61 -0
- package/project-template/src/reportWebVitals.ts.ejs +28 -0
- package/project-template/src/styles.css.ejs +15 -0
- package/project-template/tsconfig.dev.json +10 -0
- package/project-template/tsconfig.json +10 -0
- package/project-template/vite.config.js.ejs +14 -0
- package/scripts/publish.js +33 -0
- package/src/index.ts +248 -0
- package/src/utils/getPackageManager.ts +22 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import logo from "./logo.svg";
|
|
2
|
+
<% if (!tailwind) { %>
|
|
3
|
+
import "./App.css";
|
|
4
|
+
<% } %>
|
|
5
|
+
|
|
6
|
+
function App() {
|
|
7
|
+
return (<% if (tailwind) { %>
|
|
8
|
+
<div className="text-center">
|
|
9
|
+
<header className="min-h-screen flex flex-col items-center justify-center bg-[#282c34] text-white text-[calc(10px+2vmin)]">
|
|
10
|
+
<img
|
|
11
|
+
src={logo}
|
|
12
|
+
className="h-[40vmin] pointer-events-none animate-[spin_20s_linear_infinite]"
|
|
13
|
+
alt="logo"
|
|
14
|
+
/>
|
|
15
|
+
<p>
|
|
16
|
+
Edit <code>src/App.<%= jsx %></code> and save to reload.
|
|
17
|
+
</p>
|
|
18
|
+
<a
|
|
19
|
+
className="text-[#61dafb] hover:underline"
|
|
20
|
+
href="https://reactjs.org"
|
|
21
|
+
target="_blank"
|
|
22
|
+
rel="noopener noreferrer"
|
|
23
|
+
>
|
|
24
|
+
Learn React
|
|
25
|
+
</a>
|
|
26
|
+
<a
|
|
27
|
+
className="text-[#61dafb] hover:underline"
|
|
28
|
+
href="https://tanstack.com"
|
|
29
|
+
target="_blank"
|
|
30
|
+
rel="noopener noreferrer"
|
|
31
|
+
>
|
|
32
|
+
Learn TanStack
|
|
33
|
+
</a>
|
|
34
|
+
</header>
|
|
35
|
+
</div>
|
|
36
|
+
<% } else { %>
|
|
37
|
+
<div className="App">
|
|
38
|
+
<header className="App-header">
|
|
39
|
+
<img src={logo} className="App-logo" alt="logo" />
|
|
40
|
+
<p>
|
|
41
|
+
Edit <code>src/App.<%= jsx %></code> and save to reload.
|
|
42
|
+
</p>
|
|
43
|
+
<a
|
|
44
|
+
className="App-link"
|
|
45
|
+
href="https://reactjs.org"
|
|
46
|
+
target="_blank"
|
|
47
|
+
rel="noopener noreferrer"
|
|
48
|
+
>
|
|
49
|
+
Learn React
|
|
50
|
+
</a>
|
|
51
|
+
<a
|
|
52
|
+
className="App-link"
|
|
53
|
+
href="https://tanstack.com"
|
|
54
|
+
target="_blank"
|
|
55
|
+
rel="noopener noreferrer"
|
|
56
|
+
>
|
|
57
|
+
Learn TanStack
|
|
58
|
+
</a>
|
|
59
|
+
</header>
|
|
60
|
+
</div>
|
|
61
|
+
<% } %> );
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default App;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 841.9 595.3">
|
|
3
|
+
<!-- Generator: Adobe Illustrator 29.3.0, SVG Export Plug-In . SVG Version: 2.1.0 Build 146) -->
|
|
4
|
+
<defs>
|
|
5
|
+
<style>
|
|
6
|
+
.st0 {
|
|
7
|
+
fill: #9ae7fc;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.st1 {
|
|
11
|
+
fill: #61dafb;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.st2 {
|
|
15
|
+
fill: #61dafb;
|
|
16
|
+
}
|
|
17
|
+
</style>
|
|
18
|
+
</defs>
|
|
19
|
+
<circle class="st0" cx="420.7" cy="297.3" r="51"/>
|
|
20
|
+
<path class="st2" d="M474.4,297.3c0,29.6-24,53.6-53.6,53.6s-53.6-24-53.6-53.6,24-53.6,53.6-53.6,53.6,24,53.6,53.6ZM379.5,296.1v-7.5c0-1.3,1.4-6.1,2.1-7.4,1.2-2.3,3.4-4.1,5.4-5.6l-4-4c4.7-4.3,11.1-4.4,16.2-.8,2.3-5.6,7.8-8.4,13.8-8l-1,5c7,.2,15.5,4.9,15.5,12.8s0,.6-.8.8c-2,.3-4-.5-5.9-.7s-1.4-.5-1.4.4,3,4.9,3.5,6.5,1.2,4.1,1,6.3c-6.6-1-12.4-3.8-17.5-8,.3,3.1,4.9,25.7,6.3,26s1-.7,1.2-1.3,1.5-7.5,1.5-8c0-1.2-2-2.1-2.6-3.3-1.4-3.2,1.5-5.6,4.4-3.9s6.2,7.4,8.9,8.6,15.4,1.7,17.6,3.9-3.4,5.4-1.8,9c8-3.1,16-3.9,24.4-3,3.7-11.5,3.7-24.1-1.1-35.3-8.6,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|
+
<path class="st0" d="M409.5,273.8c.1-1,2.5-.5,3.1-.4,2.8.5,4.7,2,7.4,2.4-1.4-3.7-6.7-3.8-10-4.5-.1-.9,1.1-.5,1.7-.5,3.3,0,6.6.8,9.2,2.8s4.8,4.7,1.4,4.6c-5.1-.1-8.4-2.8-12.9-4.4Z"/>
|
|
26
|
+
<path class="st0" d="M390.5,277.3c-1.3,1.9-3.5,3.6-4.7,5.5s-2.3,3.3-.5,3,3.3-4.8,5-5.5-1.1,4.3-1.3,4.7c-.5.8-5.6,6.2-6.4,5.3-.2-5.5,2.1-11.7,8-13Z"/>
|
|
27
|
+
<path class="st0" d="M440,312.8l-1.2,3c-4.3-2.7-9.5-3.3-14.3-4.7.6-.8,1.3-.8,2.2-.8,4,.1,9.2,2.1,13.3,2.5Z"/>
|
|
28
|
+
<path class="st0" d="M416.5,311.3c0-1.2.1-6.9,1.7-6.5,4.7,4.2,7.2,7.3-1.7,6.5Z"/>
|
|
29
|
+
<path class="st0" d="M396.5,273.3c-2.1-.3-4.1.8-6.2.5s-2.7-1-2.3-1.7c1-1.9,8.2-1.7,8.5,1.2Z"/>
|
|
30
|
+
<path class="st0" d="M409,265.8c.5,3.5-4.3,3.9-6.5,5.5-.7-2.1,5.9-6.1,6.5-5.5Z"/>
|
|
31
|
+
<path class="st0" d="M428,308.3c-3-.2-4.9-1.5-6.5-4,2-.5,2.4,1,3.5,1.7s3.1.3,3,2.3Z"/>
|
|
32
|
+
<path class="st2" d="M434.5,266.8l.2-2c1.3,0,6.1-2.6,6.7-.7s-6.5,3.4-6.9,2.7Z"/>
|
|
33
|
+
<path class="st2" d="M433.5,259.8l.2-1.5c10-2.5,9.1,4-.2,1.5Z"/>
|
|
34
|
+
<path class="st2" d="M437,272.8c-1.3-1.8,6-5.5,6.5-3.2s-5.5,4.7-6.5,3.2Z"/>
|
|
35
|
+
<path class="st2" d="M447,273.3c1.3,1.3-4.7,7.6-5.5,4.7s4.4-5.8,5.5-4.7Z"/>
|
|
36
|
+
<path class="st2" d="M449.6,277.4c.8-.5,2.5,0,2.4,1.1s-2.8,5.2-4.2,4.8,1.5-5.7,1.8-5.9Z"/>
|
|
37
|
+
<path class="st2" d="M454,286.3c-.4-.4.5-7.2,2.7-6.5,1.7.5-.2,7.4-2.7,6.5Z"/>
|
|
38
|
+
<path class="st2" d="M464,287.8l-1.5-.2-.4-.6c0-1.1-.5-5.4.7-5.7,2.5.9,1.8,4.5,1.2,6.5Z"/>
|
|
39
|
+
<path class="st0" d="M420.4,316.4c10.5-.1,21.2,5.6,27.8,13.4s4.5,4.1-.1,7.4c-12.7,9.1-30.9,10.7-45.3,5-2.2-.9-12.4-6-12.4-8.1s4.7-6.3,5.7-7.3c6.3-5.9,15.5-10.2,24.2-10.4Z"/>
|
|
40
|
+
<path class="st0" d="M394.5,321.3l-16.5-1.7c2-1.2,5.9-.9,8.2-.7s6.6.8,8.3,2.5Z"/>
|
|
41
|
+
<path class="st0" d="M463.5,318.8c.8.6,0,.9-.7,1-1.9.2-4.1-.2-6,0-2.9.3-6.2,1.4-9,1.5s-1.3-.1-.1-.6,6-1.9,7.1-1.9h8.8Z"/>
|
|
42
|
+
<path class="st2" d="M666.3,296.5c0-32.5-40.7-63.3-103.1-82.4,14.4-63.6,8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6,0,8.3.9,11.4,2.6,13.6,7.8,19.5,37.5,14.9,75.7-1.1,9.4-2.9,19.3-5.1,29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50,32.6-30.3,63.2-46.9,84-46.9v-22.3c-27.5,0-63.5,19.6-99.9,53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7,0,51.4,16.5,84,46.6-14,14.7-28,31.4-41.3,49.9-22.6,2.4-44,6.1-63.6,11-2.3-10-4-19.7-5.2-29-4.7-38.2,1.1-67.9,14.6-75.8,3-1.8,6.9-2.6,11.5-2.6v-22.3c-8.4,0-16,1.8-22.6,5.6-28.1,16.2-34.4,66.7-19.9,130.1-62.2,19.2-102.7,49.9-102.7,82.3s40.7,63.3,103.1,82.4c-14.4,63.6-8,114.2,20.2,130.4,6.5,3.8,14.1,5.6,22.5,5.6,27.5,0,63.5-19.6,99.9-53.6,36.4,33.8,72.4,53.2,99.9,53.2s16-1.8,22.6-5.6c28.1-16.2,34.4-66.7,19.9-130.1,62-19.1,102.5-49.9,102.5-82.3h0ZM536.1,229.8c-3.7,12.9-8.3,26.2-13.5,39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4,14.2,2.1,27.9,4.7,41,7.9h0ZM490.3,336.3c-7.8,13.5-15.8,26.3-24.1,38.2-14.9,1.3-30,2-45.2,2s-30.2-.7-45-1.9c-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8,6.2-13.4,13.2-26.8,20.7-39.9,7.8-13.5,15.8-26.3,24.1-38.2,14.9-1.3,30-2,45.2-2s30.2.7,45,1.9c8.3,11.9,16.4,24.6,24.2,38,7.6,13.1,14.5,26.4,20.8,39.8-6.3,13.4-13.2,26.8-20.7,39.9h0ZM522.6,323.3c5.4,13.4,10,26.8,13.8,39.8-13.1,3.2-26.9,5.9-41.2,8,4.9-7.7,9.8-15.6,14.4-23.7,4.6-8,8.9-16.1,13-24.1h0ZM421.2,430c-9.3-9.6-18.6-20.3-27.8-32,9,.4,18.2.7,27.5.7s18.7-.2,27.8-.7c-9,11.7-18.3,22.4-27.5,32ZM346.8,371.1c-14.2-2.1-27.9-4.7-41-7.9,3.7-12.9,8.3-26.2,13.5-39.5,4.1,8,8.4,16,13.1,24s9.5,15.8,14.4,23.4ZM420.7,163c9.3,9.6,18.6,20.3,27.8,32-9-.4-18.2-.7-27.5-.7s-18.7.2-27.8.7c9-11.7,18.3-22.4,27.5-32ZM346.7,221.9c-4.9,7.7-9.8,15.6-14.4,23.7-4.6,8-8.9,16-13,24-5.4-13.4-10-26.8-13.8-39.8,13.1-3.1,26.9-5.8,41.2-7.9h0ZM256.2,347.1c-35.4-15.1-58.3-34.9-58.3-50.6s22.9-35.6,58.3-50.6c8.6-3.7,18-7,27.7-10.1,5.7,19.6,13.2,40,22.5,60.9-9.2,20.8-16.6,41.1-22.2,60.6-9.9-3.1-19.3-6.5-28-10.2h0ZM310,490c-13.6-7.8-19.5-37.5-14.9-75.7,1.1-9.4,2.9-19.3,5.1-29.4,19.6,4.8,41,8.5,63.5,10.9,13.5,18.5,27.5,35.3,41.6,50-32.6,30.3-63.2,46.9-84,46.9-4.5-.1-8.3-1-11.3-2.7h0ZM547.2,413.8c4.7,38.2-1.1,67.9-14.6,75.8-3,1.8-6.9,2.6-11.5,2.6-20.7,0-51.4-16.5-84-46.6,14-14.7,28-31.4,41.3-49.9,22.6-2.4,44-6.1,63.6-11,2.3,10.1,4.1,19.8,5.2,29.1ZM585.7,347.1c-8.6,3.7-18,7-27.7,10.1-5.7-19.6-13.2-40-22.5-60.9,9.2-20.8,16.6-41.1,22.2-60.6,9.9,3.1,19.3,6.5,28.1,10.2,35.4,15.1,58.3,34.9,58.3,50.6,0,15.7-23,35.6-58.4,50.6h0Z"/>
|
|
43
|
+
<path class="st1" d="M520.5,78.1"/>
|
|
44
|
+
</svg>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { StrictMode } from "react";
|
|
2
|
+
import ReactDOM from "react-dom/client";
|
|
3
|
+
import {
|
|
4
|
+
Outlet,
|
|
5
|
+
RouterProvider,
|
|
6
|
+
createRootRoute,
|
|
7
|
+
createRoute,
|
|
8
|
+
createRouter,
|
|
9
|
+
} from "@tanstack/react-router";
|
|
10
|
+
import { TanStackRouterDevtools } from "@tanstack/router-devtools";
|
|
11
|
+
|
|
12
|
+
import "./styles.css";
|
|
13
|
+
import reportWebVitals from "./reportWebVitals";
|
|
14
|
+
|
|
15
|
+
import App from "./App";
|
|
16
|
+
|
|
17
|
+
const rootRoute = createRootRoute({
|
|
18
|
+
component: () => (
|
|
19
|
+
<>
|
|
20
|
+
<Outlet />
|
|
21
|
+
<TanStackRouterDevtools />
|
|
22
|
+
</>
|
|
23
|
+
),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const indexRoute = createRoute({
|
|
27
|
+
getParentRoute: () => rootRoute,
|
|
28
|
+
path: "/",
|
|
29
|
+
component: App,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const routeTree = rootRoute.addChildren([indexRoute]);
|
|
33
|
+
|
|
34
|
+
const router = createRouter({
|
|
35
|
+
routeTree,
|
|
36
|
+
defaultPreload: "intent",
|
|
37
|
+
scrollRestoration: true,
|
|
38
|
+
});
|
|
39
|
+
<% if (typescript) { %>
|
|
40
|
+
declare module "@tanstack/react-router" {
|
|
41
|
+
interface Register {
|
|
42
|
+
router: typeof router;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const rootElement = document.getElementById("app")!;
|
|
47
|
+
<% } else { %>
|
|
48
|
+
const rootElement = document.getElementById("app");
|
|
49
|
+
<% } %>if (!rootElement.innerHTML) {
|
|
50
|
+
const root = ReactDOM.createRoot(rootElement);
|
|
51
|
+
root.render(
|
|
52
|
+
<StrictMode>
|
|
53
|
+
<RouterProvider router={router} />
|
|
54
|
+
</StrictMode>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// If you want to start measuring performance in your app, pass a function
|
|
59
|
+
// to log results (for example: reportWebVitals(console.log))
|
|
60
|
+
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
|
61
|
+
reportWebVitals();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<% if (typescript) { %>
|
|
2
|
+
const reportWebVitals = (onPerfEntry?: () => void) => {
|
|
3
|
+
if (onPerfEntry && onPerfEntry instanceof Function) {
|
|
4
|
+
import("web-vitals").then(
|
|
5
|
+
({ getCLS, getFID, getFCP, getLCP, getTTFB }: any) => {
|
|
6
|
+
getCLS(onPerfEntry);
|
|
7
|
+
getFID(onPerfEntry);
|
|
8
|
+
getFCP(onPerfEntry);
|
|
9
|
+
getLCP(onPerfEntry);
|
|
10
|
+
getTTFB(onPerfEntry);
|
|
11
|
+
}
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
<% } else { %>
|
|
16
|
+
const reportWebVitals = onPerfEntry => {
|
|
17
|
+
if (onPerfEntry && onPerfEntry instanceof Function) {
|
|
18
|
+
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
|
19
|
+
getCLS(onPerfEntry);
|
|
20
|
+
getFID(onPerfEntry);
|
|
21
|
+
getFCP(onPerfEntry);
|
|
22
|
+
getLCP(onPerfEntry);
|
|
23
|
+
getTTFB(onPerfEntry);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
<% } %>
|
|
28
|
+
export default reportWebVitals;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<% if (tailwind) { %>@import "tailwindcss";
|
|
2
|
+
<% } %>
|
|
3
|
+
body {
|
|
4
|
+
<% if (tailwind) { %>@apply m-0;<% } else { %>margin: 0;<% } %>
|
|
5
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
|
|
6
|
+
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
|
|
7
|
+
sans-serif;
|
|
8
|
+
-webkit-font-smoothing: antialiased;
|
|
9
|
+
-moz-osx-font-smoothing: grayscale;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
code {
|
|
13
|
+
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
|
|
14
|
+
monospace;
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineConfig } from "vite";
|
|
2
|
+
import viteReact from "@vitejs/plugin-react";
|
|
3
|
+
<% if (tailwind) { %>
|
|
4
|
+
import tailwindcss from "@tailwindcss/vite";
|
|
5
|
+
<% } %>
|
|
6
|
+
|
|
7
|
+
// https://vitejs.dev/config/
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
plugins: [viteReact()<% if (tailwind) { %>, tailwindcss()<% } %>],
|
|
10
|
+
test: {
|
|
11
|
+
globals: true,
|
|
12
|
+
environment: "jsdom",
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import { resolve } from 'node:path'
|
|
4
|
+
import { fileURLToPath } from 'node:url'
|
|
5
|
+
import { publish } from '@tanstack/config/publish'
|
|
6
|
+
|
|
7
|
+
const __dirname = fileURLToPath(new URL('.', import.meta.url))
|
|
8
|
+
|
|
9
|
+
await publish({
|
|
10
|
+
packages: [
|
|
11
|
+
{
|
|
12
|
+
name: 'create-tsrouter-app',
|
|
13
|
+
packageDir: '.',
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
branchConfigs: {
|
|
17
|
+
main: {
|
|
18
|
+
prerelease: false,
|
|
19
|
+
},
|
|
20
|
+
alpha: {
|
|
21
|
+
prerelease: true,
|
|
22
|
+
},
|
|
23
|
+
beta: {
|
|
24
|
+
prerelease: true,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
rootDir: resolve(__dirname, '..'),
|
|
28
|
+
branch: process.env.BRANCH,
|
|
29
|
+
tag: process.env.TAG,
|
|
30
|
+
ghToken: process.env.GH_TOKEN,
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
process.exit(0)
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { copyFile, mkdir, readFile, writeFile } from 'node:fs/promises'
|
|
4
|
+
import { resolve } from 'node:path'
|
|
5
|
+
import { fileURLToPath } from 'node:url'
|
|
6
|
+
import { Command, InvalidArgumentError } from 'commander'
|
|
7
|
+
import { intro, outro, spinner } from '@clack/prompts'
|
|
8
|
+
import { execa } from 'execa'
|
|
9
|
+
import { render } from 'ejs'
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
SUPPORTED_PACKAGE_MANAGERS,
|
|
13
|
+
getPackageManager,
|
|
14
|
+
} from './utils/getPackageManager.js'
|
|
15
|
+
|
|
16
|
+
import type { PackageManager } from './utils/getPackageManager.js'
|
|
17
|
+
|
|
18
|
+
const program = new Command()
|
|
19
|
+
|
|
20
|
+
interface Options {
|
|
21
|
+
typescript: boolean
|
|
22
|
+
tailwind: boolean
|
|
23
|
+
packageManager: PackageManager
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const createCopyFile = (templateDir: string, targetDir: string) =>
|
|
27
|
+
async function copyFiles(files: Array<string>) {
|
|
28
|
+
for (const file of files) {
|
|
29
|
+
const targetFileName = file.replace('.tw', '')
|
|
30
|
+
await copyFile(
|
|
31
|
+
resolve(templateDir, file),
|
|
32
|
+
resolve(targetDir, targetFileName),
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const createTemplateFile = (
|
|
38
|
+
projectName: string,
|
|
39
|
+
options: Required<Options>,
|
|
40
|
+
templateDir: string,
|
|
41
|
+
targetDir: string,
|
|
42
|
+
) =>
|
|
43
|
+
async function templateFile(file: string, targetFileName?: string) {
|
|
44
|
+
const templateValues = {
|
|
45
|
+
packageManager: options.packageManager,
|
|
46
|
+
projectName: projectName,
|
|
47
|
+
typescript: options.typescript,
|
|
48
|
+
tailwind: options.tailwind,
|
|
49
|
+
js: options.typescript ? 'ts' : 'js',
|
|
50
|
+
jsx: options.typescript ? 'tsx' : 'jsx',
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const template = await readFile(resolve(templateDir, file), 'utf-8')
|
|
54
|
+
const content = render(template, templateValues)
|
|
55
|
+
const target = targetFileName ?? file.replace('.ejs', '')
|
|
56
|
+
await writeFile(resolve(targetDir, target), content)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function createPackageJSON(
|
|
60
|
+
projectName: string,
|
|
61
|
+
options: Required<Options>,
|
|
62
|
+
templateDir: string,
|
|
63
|
+
targetDir: string,
|
|
64
|
+
) {
|
|
65
|
+
let packageJSON = JSON.parse(
|
|
66
|
+
await readFile(resolve(templateDir, 'package.json'), 'utf8'),
|
|
67
|
+
)
|
|
68
|
+
packageJSON.name = projectName
|
|
69
|
+
if (options.typescript) {
|
|
70
|
+
const tsPackageJSON = JSON.parse(
|
|
71
|
+
await readFile(resolve(templateDir, 'package.ts.json'), 'utf8'),
|
|
72
|
+
)
|
|
73
|
+
packageJSON = {
|
|
74
|
+
...packageJSON,
|
|
75
|
+
devDependencies: {
|
|
76
|
+
...packageJSON.devDependencies,
|
|
77
|
+
...tsPackageJSON.devDependencies,
|
|
78
|
+
},
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (options.tailwind) {
|
|
82
|
+
const twPackageJSON = JSON.parse(
|
|
83
|
+
await readFile(resolve(templateDir, 'package.tw.json'), 'utf8'),
|
|
84
|
+
)
|
|
85
|
+
packageJSON = {
|
|
86
|
+
...packageJSON,
|
|
87
|
+
dependencies: {
|
|
88
|
+
...packageJSON.dependencies,
|
|
89
|
+
...twPackageJSON.dependencies,
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
await writeFile(
|
|
94
|
+
resolve(targetDir, 'package.json'),
|
|
95
|
+
JSON.stringify(packageJSON, null, 2),
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async function createApp(projectName: string, options: Required<Options>) {
|
|
100
|
+
const templateDir = fileURLToPath(
|
|
101
|
+
new URL('../project-template', import.meta.url),
|
|
102
|
+
)
|
|
103
|
+
const targetDir = resolve(process.cwd(), projectName)
|
|
104
|
+
|
|
105
|
+
const copyFiles = createCopyFile(templateDir, targetDir)
|
|
106
|
+
const templateFile = createTemplateFile(
|
|
107
|
+
projectName,
|
|
108
|
+
options,
|
|
109
|
+
templateDir,
|
|
110
|
+
targetDir,
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
intro(`Creating a new TanStack app in ${targetDir}...`)
|
|
114
|
+
|
|
115
|
+
// Make the root directory
|
|
116
|
+
await mkdir(targetDir, { recursive: true })
|
|
117
|
+
|
|
118
|
+
// Setup the .vscode directory
|
|
119
|
+
await mkdir(resolve(targetDir, '.vscode'), { recursive: true })
|
|
120
|
+
await copyFile(
|
|
121
|
+
resolve(templateDir, '.vscode/settings.json'),
|
|
122
|
+
resolve(targetDir, '.vscode/settings.json'),
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
// Fill the public directory
|
|
126
|
+
await mkdir(resolve(targetDir, 'public'), { recursive: true })
|
|
127
|
+
copyFiles([
|
|
128
|
+
'./public/robots.txt',
|
|
129
|
+
'./public/favicon.ico',
|
|
130
|
+
'./public/manifest.json',
|
|
131
|
+
'./public/logo192.png',
|
|
132
|
+
'./public/logo512.png',
|
|
133
|
+
])
|
|
134
|
+
|
|
135
|
+
// Make the src directory
|
|
136
|
+
await mkdir(resolve(targetDir, 'src'), { recursive: true })
|
|
137
|
+
|
|
138
|
+
// Copy in Vite and Tailwind config and CSS
|
|
139
|
+
if (!options.tailwind) {
|
|
140
|
+
await copyFiles(['./src/App.css'])
|
|
141
|
+
}
|
|
142
|
+
await templateFile('./vite.config.js.ejs')
|
|
143
|
+
await templateFile('./src/styles.css.ejs')
|
|
144
|
+
|
|
145
|
+
copyFiles(['./src/logo.svg'])
|
|
146
|
+
|
|
147
|
+
// Setup the app component. There are four variations, typescript/javascript and tailwind/non-tailwind.
|
|
148
|
+
await templateFile(
|
|
149
|
+
'./src/App.tsx.ejs',
|
|
150
|
+
options.typescript ? undefined : './src/App.jsx',
|
|
151
|
+
)
|
|
152
|
+
await templateFile(
|
|
153
|
+
'./src/App.test.tsx.ejs',
|
|
154
|
+
options.typescript ? undefined : './src/App.test.jsx',
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
// Setup the main, reportWebVitals and index.html files
|
|
158
|
+
if (options.typescript) {
|
|
159
|
+
await templateFile('./src/main.tsx.ejs')
|
|
160
|
+
await templateFile('./src/reportWebVitals.ts.ejs')
|
|
161
|
+
} else {
|
|
162
|
+
await templateFile('./src/main.tsx.ejs', './src/main.jsx')
|
|
163
|
+
await templateFile(
|
|
164
|
+
'./src/reportWebVitals.ts.ejs',
|
|
165
|
+
'./src/reportWebVitals.js',
|
|
166
|
+
)
|
|
167
|
+
}
|
|
168
|
+
await templateFile('./index.html.ejs')
|
|
169
|
+
|
|
170
|
+
// Setup tsconfig
|
|
171
|
+
if (options.typescript) {
|
|
172
|
+
await copyFiles(['./tsconfig.json', './tsconfig.dev.json'])
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Setup the package.json file, optionally with typescript and tailwind
|
|
176
|
+
await createPackageJSON(projectName, options, templateDir, targetDir)
|
|
177
|
+
|
|
178
|
+
// Add .gitignore
|
|
179
|
+
await copyFile(
|
|
180
|
+
resolve(templateDir, 'gitignore'),
|
|
181
|
+
resolve(targetDir, '.gitignore'),
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
// Create the README.md
|
|
185
|
+
await templateFile('README.md.ejs')
|
|
186
|
+
|
|
187
|
+
// Install dependencies
|
|
188
|
+
const s = spinner()
|
|
189
|
+
s.start(`Installing dependencies via ${options.packageManager}...`)
|
|
190
|
+
await execa(options.packageManager, ['install'], { cwd: targetDir })
|
|
191
|
+
s.stop(`Installed dependencies`)
|
|
192
|
+
|
|
193
|
+
outro(`Created your new TanStack app in ${targetDir}.`)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
program
|
|
197
|
+
.name('create-tsrouter-app')
|
|
198
|
+
.description('CLI to create a new TanStack application')
|
|
199
|
+
.argument('<project-name>', 'name of the project')
|
|
200
|
+
.option<'typescript' | 'javascript'>(
|
|
201
|
+
'--template <type>',
|
|
202
|
+
'project template (typescript/javascript)',
|
|
203
|
+
(value) => {
|
|
204
|
+
if (value !== 'typescript' && value !== 'javascript') {
|
|
205
|
+
throw new InvalidArgumentError(
|
|
206
|
+
`Invalid template: ${value}. Only the following are allowed: typescript, javascript`,
|
|
207
|
+
)
|
|
208
|
+
}
|
|
209
|
+
return value
|
|
210
|
+
},
|
|
211
|
+
'javascript',
|
|
212
|
+
)
|
|
213
|
+
.option<PackageManager>(
|
|
214
|
+
`--package-manager <${SUPPORTED_PACKAGE_MANAGERS.join('|')}>`,
|
|
215
|
+
`Explicitly tell the CLI to use this package manager`,
|
|
216
|
+
(value) => {
|
|
217
|
+
if (!SUPPORTED_PACKAGE_MANAGERS.includes(value as PackageManager)) {
|
|
218
|
+
throw new InvalidArgumentError(
|
|
219
|
+
`Invalid package manager: ${value}. Only the following are allowed: ${SUPPORTED_PACKAGE_MANAGERS.join(
|
|
220
|
+
', ',
|
|
221
|
+
)}`,
|
|
222
|
+
)
|
|
223
|
+
}
|
|
224
|
+
return value as PackageManager
|
|
225
|
+
},
|
|
226
|
+
getPackageManager(),
|
|
227
|
+
)
|
|
228
|
+
.option('--tailwind', 'add Tailwind CSS', false)
|
|
229
|
+
.action(
|
|
230
|
+
(
|
|
231
|
+
projectName: string,
|
|
232
|
+
options: {
|
|
233
|
+
template: string
|
|
234
|
+
tailwind: boolean
|
|
235
|
+
packageManager: PackageManager
|
|
236
|
+
},
|
|
237
|
+
) => {
|
|
238
|
+
const typescript = options.template === 'typescript'
|
|
239
|
+
|
|
240
|
+
createApp(projectName, {
|
|
241
|
+
typescript,
|
|
242
|
+
tailwind: options.tailwind,
|
|
243
|
+
packageManager: options.packageManager,
|
|
244
|
+
})
|
|
245
|
+
},
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
program.parse()
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const SUPPORTED_PACKAGE_MANAGERS = [
|
|
2
|
+
'npm',
|
|
3
|
+
'yarn',
|
|
4
|
+
'pnpm',
|
|
5
|
+
'bun',
|
|
6
|
+
] as const
|
|
7
|
+
export type PackageManager = (typeof SUPPORTED_PACKAGE_MANAGERS)[number]
|
|
8
|
+
export const DEFAULT_PACKAGE_MANAGER: PackageManager = 'npm'
|
|
9
|
+
|
|
10
|
+
export function getPackageManager(): PackageManager | undefined {
|
|
11
|
+
const userAgent = process.env.npm_config_user_agent
|
|
12
|
+
|
|
13
|
+
if (userAgent === undefined) {
|
|
14
|
+
return DEFAULT_PACKAGE_MANAGER
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const packageManager = SUPPORTED_PACKAGE_MANAGERS.find((manager) =>
|
|
18
|
+
userAgent.startsWith(manager),
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
return packageManager || DEFAULT_PACKAGE_MANAGER
|
|
22
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "ES2020",
|
|
5
|
+
"outDir": "./dist",
|
|
6
|
+
"rootDir": "./src",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"moduleResolution": "node"
|
|
12
|
+
},
|
|
13
|
+
"include": ["./src/**/*.ts"],
|
|
14
|
+
"exclude": ["node_modules", "dist"]
|
|
15
|
+
}
|