Skip to content

Commit

Permalink
fix: add deploy script to package.json when initializing (#463)
Browse files Browse the repository at this point in the history
* fix: add deploy script to package.json when initializing

* chore: add deploy command to generated README

* style: remove empty line indent
  • Loading branch information
amcgee committed Sep 23, 2020
1 parent d405673 commit 11b310e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cli/config/init.README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ A deployable `.zip` file can be found in `build/bundle`!

See the section about [building](https://platform.dhis2.nu/#/scripts/build) for more information.

### `yarn deploy`

Deploys the built app in the `build` folder to a running DHIS2 instance.<br />
This command will prompt you to enter a server URL as well as the username and password of a DHIS2 user with the App Management authority.<br/>
You must run `yarn build` before running `yarn deploy`.<br />

See the section about [deploying](https://platform.dhis2.nu/#/scripts/deploy) for more information.

## Learn More

You can learn more about the platform in the [DHIS2 Application Platform Documentation](https://platform.dhis2.nu/).
Expand Down
9 changes: 9 additions & 0 deletions cli/src/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ const handler = async ({ force, name, cwd, lib }) => {
pkg.scripts.test = 'd2-app-scripts test'
}

if (pkg.scripts && pkg.scripts.deploy && !force) {
reporter.warn(
'A script called "deploy" already exists, use --force to overwrite it'
)
} else {
pkg.scripts = pkg.scripts || {}
pkg.scripts.deploy = 'd2-app-scripts deploy'
}

fs.writeJSONSync(paths.package, pkg, {
spaces: 2,
})
Expand Down

0 comments on commit 11b310e

Please sign in to comment.