feat: simplify development setup

Warns if .env is missing.  Combines the three docker installation
commands into one, updating the docs accordingly.

Also removes the libcimp patch as npm already has it.
This commit is contained in:
Oliver Eyton-Williams
2019-11-28 18:01:52 +01:00
committed by mrugesh
parent 647e25aa7c
commit e3b77a62cc
5 changed files with 8 additions and 22 deletions

View File

@ -1,7 +1,11 @@
const path = require('path');
const fs = require('fs');
if (process.env.FREECODECAMP_NODE_ENV !== 'production') {
const envPath = path.resolve(__dirname, '../.env');
if (!fs.existsSync(envPath)) {
throw Error('.env not found, please copy sample.env to .env.');
}
require('dotenv').config({ path: envPath });
}

View File

@ -191,12 +191,10 @@ This step will install the dependencies required for the application to run:
**Docker Build:**
```shell
npm run docker:init
npm run docker:install
npm run docker:seed
npm run docker:run-once
```
Each of the Docker commands above will take some time to complete. You should wait for each command to fully complete before running the next.
There is a lot to install, this step may take a few minutes.
You will also need to install a few npm packages outside of Docker. You can skip this step if you are only running the app locally and will not use git.

View File

@ -1,13 +0,0 @@
diff --git a/index.js b/index.js
index 61bf354..c00dc03 100644
--- a/index.js
+++ b/index.js
@@ -156,7 +156,7 @@ class Installer {
)
return BB.join(
this.checkLock(),
- stat && rimraf(path.join(this.prefix, 'node_modules'))
+ stat && rimraf(path.join(this.prefix, 'node_modules/*'))
)
}).then(() => {
// This needs to happen -after- we've done checkLock()

View File

@ -17,10 +17,11 @@
"develop": "npm-run-all ensure-env -p develop:*",
"develop:client": "cd ./client && npm run develop",
"develop:server": "cd ./api-server && npm run develop",
"docker:run-once": "npm run docker:init && npm run docker:install && npm run docker:seed",
"docker:clean": "docker-compose run -u root --rm freecodecamp bash -c \"rm -rf **/node_modules/* **/node_modules/..?* **/node_modules/.[!.]* node_modules/* node_modules/..?* node_modules/.[!.]*\"",
"docker:develop": "docker-compose up client api-server",
"docker:init": "docker-compose run -u root --rm freecodecamp bash change_volumes_owner.sh && docker-compose run -u root --rm client bash -c \"cd .. && bash change_volumes_owner.sh\" && docker-compose run -u root --rm api-server bash -c \"cd .. && bash change_volumes_owner.sh\"",
"docker:install": "docker-compose run -u root --rm freecodecamp bash patch_npm_and_install.sh",
"docker:install": "docker-compose run --rm freecodecamp npm ci",
"docker:seed": "docker-compose run --rm freecodecamp npm run seed",
"docker:test": "docker-compose -f docker-compose.tests.yml run --rm tests bash",
"docker:test:init": "docker-compose -f docker-compose.tests.yml run -u root --rm tests bash change_volumes_owner.sh",

View File

@ -1,4 +0,0 @@
#!/usr/bin/env bash
patch /usr/local/lib/node_modules/npm/node_modules/libcipm/index.js < libcimp_index_js.patch
su node -c "npm ci"