diff --git a/packages/create-bison-app/CONTRIBUTING.md b/packages/create-bison-app/CONTRIBUTING.md index a8523613..8395df8a 100644 --- a/packages/create-bison-app/CONTRIBUTING.md +++ b/packages/create-bison-app/CONTRIBUTING.md @@ -5,16 +5,25 @@ Run the following commands in the `packages/create-bison-app` directory to start the development server: 1. Run `yarn install` to install dependencies -1. Run `yarn dev` to create a Bison app and start the server. Optionally, you may pass the following arguments: +1. Run `yarn dev` to create a Bison app and start the server. Optionally, you may pass the following arguments and options: + - `[script]` Any script in the template's [package.json](/packages/create-bison-app/template/package.json.ejs). By default, the `dev` script is run. - `--acceptDefaults` Skip interactive prompts and use default options to create a new Bison app - `--clean` When running `yarn dev` subsequent times, use this to reconfigure and create a new Bison app - - `--port` Specify the port to listen on. Defaults to 3001. -Example: +### Example Usages + +Start the development server: + +``` +yarn dev --acceptDefaults --clean +``` + +Run the `test` script in the template's [package.json](/packages/create-bison-app/template/package.json.ejs): + ``` -yarn dev --acceptDefaults --clean --port=5000 +yarn dev test ``` ## Making Changes to the Bison Template -After you have the development server running, you can make your changes in the `packages/create-bison-app/template/` directory which will trigger the server to recompile. \ No newline at end of file +After you have the development server running, you can make your changes in the `packages/create-bison-app/template/` directory which will trigger the server to recompile. diff --git a/packages/create-bison-app/scripts/createDevAppAndStartServer.js b/packages/create-bison-app/scripts/createDevAppAndStartServer.js index eaf9d463..80a54315 100644 --- a/packages/create-bison-app/scripts/createDevAppAndStartServer.js +++ b/packages/create-bison-app/scripts/createDevAppAndStartServer.js @@ -4,7 +4,6 @@ const fs = require("fs"); const path = require("path"); const yargs = require("yargs/yargs"); const { createApp } = require("../scripts/createApp"); -const { startServer } = require("../scripts/startServer"); const { templateFolder } = require("../tasks/copyFiles"); const { cleanTemplateDestPath } = require("../utils/copyDirectoryWithTemplate"); const { copyWithTemplate } = require("../utils/copyWithTemplate"); @@ -16,7 +15,10 @@ async function init() { const distPath = path.join(__dirname, "..", "dist"); const devAppPath = path.join(distPath, BISON_DEV_APP_NAME); const args = process.argv.slice(2); - const { clean, port } = yargs(args).argv; + const { _, clean } = yargs(args).argv; + + // Script in the template's package.json to run + const templateCommand = _.length ? _[0] : 'dev'; if (clean) { await removeTemplateSymlinks(); @@ -56,15 +58,21 @@ async function init() { } }; - // Watch template files and copy to dev app - chokidar - .watch(templateFolder, { - ignored: (path) => path.includes("node_modules"), - }) - .on("add", copyFile) - .on("change", copyFile); + if (templateCommand === 'dev') { + // Watch template files and copy to dev app + chokidar + .watch(templateFolder, { + ignored: (path) => path.includes("node_modules"), + }) + .on("add", copyFile) + .on("change", copyFile); + } - return startServer(devAppPath, port); + return await execa(`yarn ${templateCommand}`, { + cwd: devAppPath, + shell: true, + stdio: "inherit", + }); } /**