-
Notifications
You must be signed in to change notification settings - Fork 1
[WIP] Implement plop base #1249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
b60692d
ca5313c
72a787b
3573958
e27a9fb
df94520
1322a0d
f5011b9
f929da7
0b9fb8f
d1c7589
221cf6a
7f34e50
ef4f7e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { Suspense } from "react"; | ||
| {{#if router}} | ||
| import { Router } from './routes'; | ||
| {{else}} | ||
| import Home from './ui/pages'; | ||
| {{/if}} | ||
| import { AppProviders } from "./context"; | ||
|
|
||
| function App() { | ||
| return ( | ||
| <AppProviders> | ||
| <Suspense> | ||
| {{#if router}} | ||
| <Router /> | ||
| {{else}} | ||
| <Home /> | ||
| {{/if}} | ||
| </Suspense> | ||
| </AppProviders> | ||
| ) | ||
| } | ||
|
|
||
| export default App; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| #!/usr/bin/env node | ||
| // @ts-ignore | ||
ptrkdan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| import { format } from "prettier"; | ||
| import fse from "fs-extra"; | ||
| import meow from "meow"; | ||
|
|
@@ -326,6 +327,16 @@ async function run() { | |
| removeEslintConfig(); | ||
| } | ||
|
|
||
| const { default: nodePlop } = await import("node-plop"); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Normally importing In order to successfully build with |
||
| const plopFilePath = path.resolve(__dirname, "plopfile.js"); | ||
| const plop = await nodePlop(plopFilePath, { | ||
| destBasePath: appDir, | ||
| force: true, | ||
| }); | ||
|
|
||
| const baseGenerator = plop.getGenerator("constructBase"); | ||
| baseGenerator.runActions({}); | ||
|
|
||
| // Copy commons | ||
| copyCommon(appDir, sharedConfigDir); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import type { NodePlopAPI } from "node-plop"; | ||
| import path from "node:path"; | ||
|
|
||
| const TEMP_DIR = path.resolve(__dirname, "temp"); | ||
|
|
||
| module.exports = function (plop: NodePlopAPI) { | ||
| plop.setHelper("reverseEach", (ctx, { fn }) => | ||
| ctx.reverse().map(fn).join("") | ||
| ); | ||
|
|
||
| plop.setGenerator("constructBase", { | ||
| actions: [ | ||
| { | ||
| type: "add", | ||
| force: true, | ||
| path: "src/app.tsx", | ||
| templateFile: path.resolve( | ||
| TEMP_DIR, | ||
| "handlebar-templates", | ||
| "app.tsx.hbs" | ||
| ), | ||
| }, | ||
| ], | ||
| }); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| { | ||
| "extends": "tsconfig/library.json", | ||
| "compilerOptions": { | ||
| "rootDir": "." | ||
| "rootDir": ".", | ||
| "module": "ESNext" | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To allow the (dynamic) import of |
||
| }, | ||
| "include": ["src", "tsup.config.ts"], | ||
| "exclude": ["templates"] | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.