Skip to content

Commit 4f7b8f4

Browse files
committed
feat: add ability to run any bison dev app script
1 parent eb8a8cb commit 4f7b8f4

File tree

2 files changed

+32
-15
lines changed

2 files changed

+32
-15
lines changed

packages/create-bison-app/CONTRIBUTING.md

+14-5
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,25 @@
55
Run the following commands in the `packages/create-bison-app` directory to start the development server:
66

77
1. Run `yarn install` to install dependencies
8-
1. Run `yarn dev` to create a Bison app and start the server. Optionally, you may pass the following arguments:
8+
1. Run `yarn dev` to create a Bison app and start the server. Optionally, you may pass the following arguments and options:
9+
- `[script]` Any script in the template's [package.json](/packages/create-bison-app/template/package.json.ejs). By default, the `dev` script is run.
910
- `--acceptDefaults` Skip interactive prompts and use default options to create a new Bison app
1011
- `--clean` When running `yarn dev` subsequent times, use this to reconfigure and create a new Bison app
11-
- `--port` Specify the port to listen on. Defaults to 3001.
1212

13-
Example:
13+
### Example Usages
14+
15+
Start the development server:
16+
17+
```
18+
yarn dev --acceptDefaults --clean
19+
```
20+
21+
Run the `test` script in Bison's [package.json](/packages/create-bison-app/template/package.json.ejs):
22+
1423
```
15-
yarn dev --acceptDefaults --clean --port=5000
24+
yarn dev test
1625
```
1726

1827
## Making Changes to the Bison Template
1928

20-
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.
29+
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.

packages/create-bison-app/scripts/createDevAppAndStartServer.js

+18-10
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const fs = require("fs");
44
const path = require("path");
55
const yargs = require("yargs/yargs");
66
const { createApp } = require("../scripts/createApp");
7-
const { startServer } = require("../scripts/startServer");
87
const { templateFolder } = require("../tasks/copyFiles");
98
const { cleanTemplateDestPath } = require("../utils/copyDirectoryWithTemplate");
109
const { copyWithTemplate } = require("../utils/copyWithTemplate");
@@ -16,7 +15,10 @@ async function init() {
1615
const distPath = path.join(__dirname, "..", "dist");
1716
const devAppPath = path.join(distPath, BISON_DEV_APP_NAME);
1817
const args = process.argv.slice(2);
19-
const { clean, port } = yargs(args).argv;
18+
const { _, clean } = yargs(args).argv;
19+
20+
// Script in the template's package.json to run
21+
const templateCommand = _.length ? _[0] : 'dev';
2022

2123
if (clean) {
2224
await removeTemplateSymlinks();
@@ -56,15 +58,21 @@ async function init() {
5658
}
5759
};
5860

59-
// Watch template files and copy to dev app
60-
chokidar
61-
.watch(templateFolder, {
62-
ignored: (path) => path.includes("node_modules"),
63-
})
64-
.on("add", copyFile)
65-
.on("change", copyFile);
61+
if (templateCommand === 'dev') {
62+
// Watch template files and copy to dev app
63+
chokidar
64+
.watch(templateFolder, {
65+
ignored: (path) => path.includes("node_modules"),
66+
})
67+
.on("add", copyFile)
68+
.on("change", copyFile);
69+
}
6670

67-
return startServer(devAppPath, port);
71+
return await execa(`yarn ${templateCommand}`, {
72+
cwd: devAppPath,
73+
shell: true,
74+
stdio: "inherit",
75+
});
6876
}
6977

7078
/**

0 commit comments

Comments
 (0)