diff --git a/.gitignore b/.gitignore index 5e3cc9eb0..08b3410e5 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,6 @@ lib node_modules reports *.log -**/.env* .nyc_output **/coverage .yarn @@ -15,3 +14,10 @@ tsconfig.tsbuildinfo .next dist .now +# local env files +**/.envrc +**/.env +**/.env.local +**/.env.development.local +**/.env.test.local +**/.env.production.local diff --git a/examples/store/.env.example b/examples/store/.env.example new file mode 100644 index 000000000..91cb68369 --- /dev/null +++ b/examples/store/.env.example @@ -0,0 +1 @@ +DATABASE_URL=postgresql://USERNAME@localhost:5432/blitz-example-store diff --git a/examples/store/.gitignore b/examples/store/.gitignore index 98cbcedbf..d9eda379d 100644 --- a/examples/store/.gitignore +++ b/examples/store/.gitignore @@ -27,6 +27,8 @@ yarn-debug.log* yarn-error.log* # local env files +.envrc +.env .env.local .env.development.local .env.test.local diff --git a/packages/cli/README.md b/packages/cli/README.md index 931f918bb..35e5e0270 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -21,14 +21,16 @@ Run `yarn` from the monorepo root `yarn build` -* [blitz-cli](#blitz-cli) -* [Usage](#usage) -* [Commands](#commands) + +- [blitz-cli](#blitz-cli) +- [Usage](#usage) +- [Commands](#commands) # Usage + ```sh-session $ npm install -g @blitzjs/cli $ blitz COMMAND @@ -40,18 +42,20 @@ USAGE $ blitz COMMAND ... ``` + # Commands -* [`blitz build`](#blitz-build) -* [`blitz console`](#blitz-console) -* [`blitz db COMMAND`](#blitz-db-command) -* [`blitz help [COMMAND]`](#blitz-help-command) -* [`blitz new [PATH]`](#blitz-new-path) -* [`blitz start`](#blitz-start) -* [`blitz test [WATCH]`](#blitz-test-watch) + +- [`blitz build`](#blitz-build) +- [`blitz console`](#blitz-console) +- [`blitz db COMMAND`](#blitz-db-command) +- [`blitz help [COMMAND]`](#blitz-help-command) +- [`blitz new [PATH]`](#blitz-new-path) +- [`blitz start`](#blitz-start) +- [`blitz test [WATCH]`](#blitz-test-watch) ## `blitz build` @@ -157,4 +161,5 @@ ALIASES ``` _See code: [lib/commands/test.js](https://github.com/blitz-js/blitz/blob/v0.0.1-canary.1/lib/commands/test.js)_ + diff --git a/packages/cli/bin/run b/packages/cli/bin/run index e332faed1..ed7f3a862 100755 --- a/packages/cli/bin/run +++ b/packages/cli/bin/run @@ -1,3 +1,8 @@ #!/usr/bin/env node -require('@oclif/command').run().then(require('@oclif/command/flush')).catch(require('@oclif/errors/handle')) +require('dotenv').config() + +require('@oclif/command') + .run() + .then(require('@oclif/command/flush')) + .catch(require('@oclif/errors/handle')) diff --git a/packages/cli/package.json b/packages/cli/package.json index 45b1598dd..0b2524008 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -32,6 +32,7 @@ "chokidar": "^3.3.1", "cross-spawn": "^7.0.2", "diff": "^4.0.2", + "dotenv": "8.2.0", "enquirer": "^2.3.4", "fs-extra": "^9.0.0", "fs-readdir-recursive": "1.1.0", diff --git a/packages/cli/src/generator.ts b/packages/cli/src/generator.ts index a1deabff1..e937d5101 100644 --- a/packages/cli/src/generator.ts +++ b/packages/cli/src/generator.ts @@ -57,20 +57,20 @@ abstract class Generator extends const conflictChecker = new ConflictChecker({ dryRun: this.options.dryRun, }) - conflictChecker.on('error', err => { + conflictChecker.on('error', (err) => { reject(err) }) conflictChecker.on('fileStatus', (data: string) => { this.performedActions.push(data) }) - this.fs.commit([conflictChecker], err => { + this.fs.commit([conflictChecker], (err) => { if (err) reject(err) resolve() }) }) - this.performedActions.forEach(action => { + this.performedActions.forEach((action) => { console.log(action) }) diff --git a/packages/cli/templates/app/.gitignore b/packages/cli/templates/app/.gitignore index 13a17af4c..ebafc02b3 100644 --- a/packages/cli/templates/app/.gitignore +++ b/packages/cli/templates/app/.gitignore @@ -26,4 +26,9 @@ *.log # local env files -.env* +.env +.envrc +.env.local +.env.development.local +.env.test.local +.env.production.local diff --git a/yarn.lock b/yarn.lock index f7984f1c3..b41457465 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5088,6 +5088,11 @@ dot-prop@^4.2.0: dependencies: is-obj "^1.0.0" +dotenv@8.2.0: + version "8.2.0" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a" + integrity sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw== + duplexer@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1"