-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
166 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// DO NOT EDIT THIS FILE, WAS GENERATED BY src/scripts/generate.ts | ||
type TInstaller = "Prisma" | "TailwindCSS" | "UnoCSS" | "Upstash Ratelimit" | "tRPC" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import fs from "fs-extra"; | ||
import path from "path"; | ||
import { ICtx, IUtil } from "~types"; | ||
|
||
export const getViteConfig: IUtil = (ctx) => { | ||
const useUno = ctx.installers.includes("UnoCSS"); | ||
const plugins = | ||
useUno && ctx.vercel | ||
? `[ | ||
solid({ ssr: false, adapter: vercel({ edge: false }) }), | ||
UnoCSS(unoConfig), | ||
]` | ||
: useUno | ||
? "[solid({ ssr: false }), UnoCSS(unoConfig)]" | ||
: `[solid({ ssr: false, adapter: vercel({ edge: false }) })]`; | ||
return `import solid from "solid-start/vite"; | ||
import dotenv from "dotenv";${ | ||
useUno | ||
? `\nimport UnoCSS from "unocss/vite"; | ||
import unoConfig from "./unocss.config";` | ||
: "" | ||
} | ||
import { defineConfig } from "vite";${ | ||
ctx.vercel | ||
? `\n// @ts-expect-error no typing | ||
import vercel from "solid-start-vercel";` | ||
: "" | ||
} | ||
export default defineConfig(() => { | ||
dotenv.config(); | ||
return { | ||
plugins: ${plugins}, | ||
}; | ||
}); | ||
`; | ||
}; | ||
|
||
export const modifyConfigIfNeeded = async (ctx: ICtx) => { | ||
if (ctx.vercel || ctx.installers.includes("UnoCSS")) { | ||
await fs.writeFile( | ||
path.join(ctx.userDir, "vite.config.ts"), | ||
getViteConfig(ctx) | ||
); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { defineConfig } from "unocss"; | ||
import transformerVariantGroup from "@unocss/transformer-variant-group"; | ||
|
||
export default defineConfig({ | ||
transformers: [transformerVariantGroup()], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// @refresh reload | ||
import "./root.css"; | ||
import "uno.css"; | ||
import { Suspense } from "solid-js"; | ||
import { | ||
Body, | ||
ErrorBoundary, | ||
FileRoutes, | ||
Head, | ||
Html, | ||
Meta, | ||
Routes, | ||
Scripts, | ||
Title, | ||
} from "solid-start"; | ||
|
||
export default function Root() { | ||
return ( | ||
<Html lang="en"> | ||
<Head> | ||
<Title>Create JD App</Title> | ||
<Meta charset="utf-8" /> | ||
<Meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
</Head> | ||
<Body> | ||
<Suspense> | ||
<ErrorBoundary> | ||
<Routes> | ||
<FileRoutes /> | ||
</Routes> | ||
</ErrorBoundary> | ||
</Suspense> | ||
<Scripts /> | ||
</Body> | ||
</Html> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { IInstaller } from "~types"; | ||
|
||
const config: IInstaller = (ctx) => ({ | ||
pkgs: { | ||
unocss: { | ||
devMode: true, | ||
}, | ||
}, | ||
name: "UnoCSS", | ||
files: [ | ||
{ | ||
path: `${__dirname}/files/root.txt`, | ||
to: `${ctx.userDir}/src/root.tsx`, | ||
}, | ||
{ | ||
to: `${ctx.userDir}/src/root.css`, | ||
content: "/* feel free to modify uno in here */", | ||
type: "write", | ||
}, | ||
{ | ||
path: `${__dirname}/files/config.txt`, | ||
to: `${ctx.userDir}/unocss.config.ts`, | ||
}, | ||
], | ||
}); | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { formatError } from "~utils/helpers"; | ||
import fs from "fs-extra"; | ||
import path from "path"; | ||
|
||
async function main() { | ||
const installers = await fs.readdir(path.join(__dirname, "../installers")); | ||
const type = `type TInstaller = ${installers | ||
.map((i) => `"${i}"`) | ||
.join(" | ")}`; | ||
const G_PATH = path.join(__dirname, "../generated.ts"); | ||
await fs.writeFile( | ||
G_PATH, | ||
`// DO NOT EDIT THIS FILE, WAS GENERATED BY src/scripts/generate.ts | ||
${type} | ||
` | ||
); | ||
} | ||
|
||
main().catch((e) => { | ||
console.log(formatError(e)); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters