Explorar o código

use dotenv-flow

Yuki Takei %!s(int64=4) %!d(string=hai) anos
pai
achega
5ed0647709

+ 27 - 26
packages/app/.env.development

@@ -1,26 +1,27 @@
-module.exports = {
-  NODE_ENV: 'development',
-  FILE_UPLOAD: 'mongodb',
-  // MONGO_GRIDFS_TOTAL_LIMIT: 10485760,   // 10MB
-  MATHJAX: 1,
-  // NO_CDN: true,
-  MONGO_URI: 'mongodb://mongo:27017/growi',
-  // REDIS_URI: 'http://redis:6379',
-  // NCHAN_URI: 'http://nchan',
-  ELASTICSEARCH_URI: 'http://elasticsearch:9200/growi',
-  HACKMD_URI: 'http://localhost:3010',
-  HACKMD_URI_FOR_SERVER: 'http://hackmd:3000',
-  // DRAWIO_URI: 'http://localhost:8080/?offline=1&https=0',
-  // S2SMSG_PUBSUB_SERVER_TYPE: 'nchan',
-  // PUBLISH_OPEN_API: true,
-  // USER_UPPER_LIMIT: 0,
-  // DEV_HTTPS: true,
-  // FORCE_WIKI_MODE: 'private', // 'public', 'private', undefined
-  // PROMSTER_ENABLED: true,
-  // SLACK_SIGNING_SECRET: '',
-  // SLACK_BOT_TOKEN: '',
-  SALT_FOR_GTOP_TOKEN: 'proxy',
-  SALT_FOR_PTOG_TOKEN: 'growi',
-  // GROWI_CLOUD_URI: 'http://growi.cloud',
-  // GROWI_APP_ID_FOR_GROWI_CLOUD: '012345',
-};
+##
+## Handled by Next.js with dotenv or dotenv-flow
+## https://nextjs.org/docs/basic-features/environment-variables
+##
+FILE_UPLOAD=mongodb
+# MONGO_GRIDFS_TOTAL_LIMIT=10485760 # 10MB
+MATHJAX=1
+# NO_CDN=true
+MONGO_URI="mongodb://mongo:27017/growi"
+# REDIS_URI="http://redis:6379"
+# NCHAN_URI="http://nchan"
+ELASTICSEARCH_URI="http://elasticsearch:9200/growi"
+HACKMD_URI="http://localhost:3010"
+HACKMD_URI_FOR_SERVER="http://hackmd:3000"
+# DRAWIO_URI="http://localhost:8080/?offline=1&https=0"
+# S2SMSG_PUBSUB_SERVER_TYPE=nchan
+# PUBLISH_OPEN_API=true
+# USER_UPPER_LIMIT=0
+# DEV_HTTPS=true
+# FORCE_WIKI_MODE=private # 'public', 'private', undefined
+# PROMSTER_ENABLED=true
+# SLACK_SIGNING_SECRET=''
+# SLACK_BOT_TOKEN=''
+SALT_FOR_GTOP_TOKEN="proxy"
+SALT_FOR_PTOG_TOKEN="growi"
+# GROWI_CLOUD_URI='http://growi.cloud'
+# GROWI_APP_ID_FOR_GROWI_CLOUD=012345

+ 5 - 4
packages/app/.env.production

@@ -1,4 +1,5 @@
-module.exports = {
-  NODE_ENV: 'production',
-  // FORMAT_NODE_LOG: false, // default: true
-};
+##
+## Handled by Next.js with dotenv or dotenv-flow
+## https://nextjs.org/docs/basic-features/environment-variables
+##
+FORMAT_NODE_LOG=false # default: true

+ 0 - 13
packages/app/config/index.js

@@ -1,13 +0,0 @@
-function envShortName() {
-  switch (process.env.NODE_ENV) {
-    case 'production':
-      return 'prod';
-    default:
-      return 'dev';
-  }
-}
-
-module.exports = {
-  env: require(`./env.${envShortName()}`),
-  logger: require(`./logger/config.${envShortName()}`),
-};

+ 9 - 9
packages/app/package.json

@@ -5,19 +5,19 @@
   "scripts": {
   "scripts": {
     "start": "yarn build && yarn server",
     "start": "yarn build && yarn server",
     "build": "run-p build:*",
     "build": "run-p build:*",
-    "build:client": "env-cmd -f config/env.prod.js webpack --config config/webpack.prod.js --profile --bail",
-    "build:server": "env-cmd -f config/env.prod.js tsc -p tsconfig.build.server.json && tsc-alias -p tsconfig.build.server.json",
+    "build:client": "cross-env NODE_ENV=production webpack --config config/webpack.prod.js --profile --bail",
+    "build:server": "cross-env NODE_ENV=production tsc -p tsconfig.build.server.json && tsc-alias -p tsconfig.build.server.json",
     "prebuild": "run-p resources:*",
     "prebuild": "run-p resources:*",
     "postbuild": "npx shx mv transpiled/src dist && npx shx rm -r transpiled",
     "postbuild": "npx shx mv transpiled/src dist && npx shx rm -r transpiled",
-    "server": "env-cmd -f config/env.prod.js node --expose_gc dist/server/app.js",
+    "server": "cross-env NODE_ENV=production node -r dotenv-flow/config --expose_gc dist/server/app.js",
     "server:ci": "yarn server --ci",
     "server:ci": "yarn server --ci",
     "dev": "run-p dev:client dev:server",
     "dev": "run-p dev:client dev:server",
-    "dev:client": "env-cmd -f config/env.dev.js webpack --config config/webpack.dev.js --progress --watch",
-    "dev:server": "env-cmd -f config/env.dev.js yarn ts-node-dev src/server/app.ts --expose_gc --inspect",
-    "dev:ci:client": "env-cmd -f config/env.dev.js webpack --config config/webpack.dev.js",
-    "dev:ci:server": "env-cmd -f config/env.dev.js yarn ts-node src/server/app.ts --ci",
+    "dev:client": "cross-env NODE_ENV=development webpack --config config/webpack.dev.js --progress --watch",
+    "dev:server": "cross-env NODE_ENV=development yarn ts-node-dev src/server/app.ts --expose_gc --inspect",
+    "dev:ci:client": "cross-env NODE_ENV=development webpack --config config/webpack.dev.js",
+    "dev:ci:server": "cross-env NODE_ENV=development yarn ts-node src/server/app.ts --ci",
     "predev:client": "run-p resources:*",
     "predev:client": "run-p resources:*",
-    "predev:ci": "run-p resources:*",
+    "predev:ci:client": "run-p resources:*",
     "resources:plugin": "yarn ts-node bin/generate-plugin-definitions-source.ts",
     "resources:plugin": "yarn ts-node bin/generate-plugin-definitions-source.ts",
     "resources:dl-resources": "yarn ts-node bin/download-cdn-resources.ts",
     "resources:dl-resources": "yarn ts-node bin/download-cdn-resources.ts",
     "test:lint:js": "eslint --quiet \"**/*.{js,jsx,ts,tsx}\"",
     "test:lint:js": "eslint --quiet \"**/*.{js,jsx,ts,tsx}\"",
@@ -73,9 +73,9 @@
     "date-fns": "^2.0.0",
     "date-fns": "^2.0.0",
     "detect-indent": "^6.0.0",
     "detect-indent": "^6.0.0",
     "diff": "^5.0.0",
     "diff": "^5.0.0",
+    "dotenv-flow": "^3.2.0",
     "elasticsearch": "^16.0.0",
     "elasticsearch": "^16.0.0",
     "entities": "^2.0.0",
     "entities": "^2.0.0",
-    "env-cmd": "^10.0.1",
     "esa-nodejs": "^0.0.7",
     "esa-nodejs": "^0.0.7",
     "escape-string-regexp": "=4.0.0",
     "escape-string-regexp": "=4.0.0",
     "express": "^4.16.1",
     "express": "^4.16.1",