From 49b85ecec086da9d6cbe6274fa3a62eb8f3474b1 Mon Sep 17 00:00:00 2001 From: Wahed Mangal Date: Thu, 26 Mar 2020 16:12:27 +0100 Subject: [PATCH] fix(init): add a default README.md file (#335) --- cli/config/init.README.md | 37 +++++++++++++++++++++++++++++++++++++ cli/src/commands/init.js | 7 +++++++ cli/src/lib/paths.js | 2 ++ 3 files changed, 46 insertions(+) create mode 100644 cli/config/init.README.md diff --git a/cli/config/init.README.md b/cli/config/init.README.md new file mode 100644 index 000000000..c8496cd26 --- /dev/null +++ b/cli/config/init.README.md @@ -0,0 +1,37 @@ +This project was bootstrapped with [DHIS2 Application Platform](https://github.com/dhis2/app-platform). + +## Available Scripts + +In the project directory, you can run: + +### `yarn start` + +Runs the app in the development mode.
+Open [http://localhost:3000](http://localhost:3000) to view it in the browser. + +The page will reload if you make edits.
+You will also see any lint errors in the console. + +### `yarn test` + +Launches the test runner and runs all available tests found in `/src`.
+ +See the section about [running tests](https://platform.dhis2.nu/#/scripts/test) for more information. + +### `yarn build` + +Builds the app for production to the `build` folder.
+It correctly bundles React in production mode and optimizes the build for the best performance. + +The build is minified and the filenames include the hashes.
+A deployable `.zip` file can be found in `build/bundle`! + +See the section about [building](https://platform.dhis2.nu/#/scripts/build) for more information. + +## Learn More + +You can learn more about the platform in the [DHIS2 Application Platform Documentation](https://platform.dhis2.nu/). + +You can learn more about the runtime in the [DHIS2 Application Runtime Documentation](https://runtime.dhis2.nu/). + +To learn React, check out the [React documentation](https://reactjs.org/). diff --git a/cli/src/commands/init.js b/cli/src/commands/init.js index 28c48939b..84e67c4a1 100644 --- a/cli/src/commands/init.js +++ b/cli/src/commands/init.js @@ -205,6 +205,13 @@ const handler = async ({ force, name, cwd, lib }) => { const sections = parseGitignore(gitignoreFile) writeGitignore(gitignoreFile, sections) + if (fs.existsSync(paths.readme) && !force) { + reporter.warn('A README already exists, use --force to overwrite it') + } else { + reporter.info('Writing README...') + fs.copyFileSync(paths.readmeDefault, paths.readme) + } + reporter.print('') reporter.info('SUCCESS!') const cdCmd = name != '.' ? `cd ${name} && ` : '' diff --git a/cli/src/lib/paths.js b/cli/src/lib/paths.js index 1b75461f5..e87ac9230 100644 --- a/cli/src/lib/paths.js +++ b/cli/src/lib/paths.js @@ -19,6 +19,7 @@ module.exports = (cwd = process.cwd()) => { '../../config/d2.config.lib.js' ), jestConfigDefaults: path.join(__dirname, '../../config/jest.config.js'), + readmeDefault: path.join(__dirname, '../../config/init.README.md'), shellSource, shellSourceEntrypoint: path.join(shellSource, 'src/App.js'), @@ -28,6 +29,7 @@ module.exports = (cwd = process.cwd()) => { package: path.join(base, './package.json'), dotenv: path.join(base, './.env'), config: path.join(base, './d2.config.js'), + readme: path.join(base, './README.md'), src: path.join(base, './src'), public: path.join(base, './public'), jestConfig: path.join(base, 'jest.config.js'),