init/react-app
Scaffolds a new React app with Vite.
Usage
npx @lukasbach/scripts init/react-app
You can call the script directly if you have installed it globally:
npm i -g @lukasbach/scripts
ldo init/react-app
Arguments
[0]: Repository name[1]: What is the name of the project?
Options
--push: Do you want to push local changes as initial commit?--git: Do you want to initialize a github repository?-v,--verbose: Verbose logging
You can also omit options, and will be asked for them interactively.
Add --yes to skip all confirmations.
Referenced scripts
node/yarn-nodemodulesnode/voltagithub/setup-node-verify-actionnode/normalize-package-jsongithub/create-from-local
Script source
/** Scaffolds a new React app with Vite. */
const projectName = await ask.text("_", "What is the name of the project?", "my-app");
await $`yarn create vite ${projectName} --template react-ts`;
await utils.cd(projectName);
if (fs.existsSync("package-lock.json")) {
await fs.remove("package-lock.json");
}
await utils.runScript("node/yarn-nodemodules");
await utils.runScript("node/volta");
if (await ask.confirm("Do you want to use eslint with my default config?")) {
await utils.node.removeDependencies(
"@typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-plugin-react-hooks eslint-plugin-react-refresh"
);
await fs.unlink(".eslintrc.cjs");
await utils.runScript("node/setup-eslint", { rule: "@lukasbach/base/react" });
}
await utils.node.amendPackageJson({
scripts: { start: "vite" },
});
await utils.runScript("github/setup-node-verify-action");
await utils.runScript("node/normalize-package-json");
if (await ask.bool("git", "Do you want to initialize a github repository?")) {
await utils.runScript("github/create-from-local");
}