Skip to content
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

[WIP] Implement plop base #1249

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions code/react/handlebar-templates/App.tsx.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Suspense } from "react";
{{#if router}}
import { Router } from './routes';
import { Router } from './routes';
{{else}}
import Home from './ui/pages';
import Home from './ui/pages';
{{/if}}
import { AppProviders } from "./context";

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"eslint-config-custom": "workspace:*",
"husky": "8.0.3",
"lint-staged": "13.1.1",
"prettier": "2.8.4",
"prettier": "3.2.5",
"turbo": "1.7.4"
},
"lint-staged": {
Expand Down
13 changes: 7 additions & 6 deletions packages/start-frontend/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env node
// @ts-ignore
import { format } from "prettier";
import prettier from "prettier";
import fse from "fs-extra";
import meow from "meow";
import os from "node:os";
Expand Down Expand Up @@ -237,7 +236,7 @@ async function copyTests(
/**
* Copy common files into the target app directory
*/
function copyCommon(appDir: string, sharedConfigDir: string) {
async function copyCommon(appDir: string, sharedConfigDir: string) {
fse.copySync(`${sharedConfigDir}/gitignore`, `${appDir}/gitignore`);

// Rename dot files
Expand Down Expand Up @@ -269,7 +268,9 @@ function copyCommon(appDir: string, sharedConfigDir: string) {
// Rewrite tsconfig.json
fse.writeFileSync(
path.join(appDir, "tsconfig.json"),
format(JSON.stringify(tsconfigObjs, null, 2), { parser: "json" })
await prettier.format(JSON.stringify(tsconfigObjs, null, 2), {
parser: "json",
})
);
}

Expand Down Expand Up @@ -335,10 +336,10 @@ async function run() {
});

const baseGenerator = plop.getGenerator("constructBase");
baseGenerator.runActions({});
await baseGenerator.runActions({});

// Copy commons
copyCommon(appDir, sharedConfigDir);
await copyCommon(appDir, sharedConfigDir);

console.log();
console.log(`Success! Created a new app at "${path.basename(appDir)}".`);
Expand Down
4 changes: 4 additions & 0 deletions packages/start-frontend/src/plopfile.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { NodePlopAPI } from "node-plop";
import path from "node:path";
import prettier from "prettier";

const TEMP_DIR = path.resolve(__dirname, "temp");

Expand All @@ -19,6 +20,9 @@ module.exports = function (plop: NodePlopAPI) {
"handlebar-templates",
"app.tsx.hbs"
),
transform: async (template) => {
return await prettier.format(template, { parser: "typescript" });
},
},
],
});
Expand Down
1 change: 1 addition & 0 deletions packages/start-frontend/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ export default defineConfig((options: Options) => ({
define: {
"process.env.BRANCH_NAME": `"${process.env.BRANCH_NAME}"`,
},
shims: true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://tsup.egoist.dev/#inject-cjs-and-esm-shims
I believe it's enabled to support both ESM and CJS.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, without it, the build produces errors since the generated build includes import.meta.url

...options,
}));
56 changes: 34 additions & 22 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading