Forráskód Böngészése

fix: config env vars parser + heroku config file

NGPixel 8 éve
szülő
commit
8b89c2bba7
5 módosított fájl, 25 hozzáadás és 38 törlés
  1. 12 12
      npm/configs/config.heroku.yml
  2. 8 8
      npm/install.js
  3. 2 2
      server/configure.js
  4. 1 1
      server/helpers/config.js
  5. 2 15
      server/init.js

+ 12 - 12
npm/configs/config.heroku.yml

@@ -8,13 +8,13 @@
 # Title of this site
 # Title of this site
 # ---------------------------------------------------------------------
 # ---------------------------------------------------------------------
 
 
-title: Wiki
+title: $(WIKI_TITLE)
 
 
 # ---------------------------------------------------------------------
 # ---------------------------------------------------------------------
 # Full public path to the site, without the trailing slash
 # Full public path to the site, without the trailing slash
 # ---------------------------------------------------------------------
 # ---------------------------------------------------------------------
 
 
-host: https://YOURAPP.herokuapp.com/
+host: $(WIKI_HOST)
 
 
 # ---------------------------------------------------------------------
 # ---------------------------------------------------------------------
 # Port the main server should listen to (80 by default)
 # Port the main server should listen to (80 by default)
@@ -44,13 +44,13 @@ uploads:
 # ---------------------------------------------------------------------
 # ---------------------------------------------------------------------
 # Possible values: en, de, es, fr, ko, pt or ru
 # Possible values: en, de, es, fr, ko, pt or ru
 
 
-lang: en
+lang: $(WIKI_LANG)
 
 
 # ---------------------------------------------------------------------
 # ---------------------------------------------------------------------
 # Site Authentication
 # Site Authentication
 # ---------------------------------------------------------------------
 # ---------------------------------------------------------------------
 
 
-public: false
+public: $(WIKI_PUBLIC)
 
 
 auth:
 auth:
   defaultReadAccess: false
   defaultReadAccess: false
@@ -97,7 +97,7 @@ auth:
 # ---------------------------------------------------------------------
 # ---------------------------------------------------------------------
 # Use a long and unique random string (256-bit keys are perfect!)
 # Use a long and unique random string (256-bit keys are perfect!)
 
 
-sessionSecret: 1234567890abcdefghijklmnopqrstuvxyz
+sessionSecret: $(WIKI_SESSION_KEY)
 
 
 # ---------------------------------------------------------------------
 # ---------------------------------------------------------------------
 # Database Connection String
 # Database Connection String
@@ -110,16 +110,16 @@ db: $(MONGODB_URI)
 # ---------------------------------------------------------------------
 # ---------------------------------------------------------------------
 
 
 git:
 git:
-  url: https://github.com/Organization/Repo
-  branch: master
+  url: $(WIKI_GIT_URL)
+  branch: $(WIKI_GIT_BRANCH)
   auth:
   auth:
 
 
     # Type: basic or ssh
     # Type: basic or ssh
-    type: ssh
+    type: basic
 
 
     # Only for Basic authentication:
     # Only for Basic authentication:
-    username: marty
-    password: MartyMcFly88
+    username: $(WIKI_GIT_USERNAME)
+    password: $(WIKI_GIT_PASSWORD)
 
 
     # Only for SSH authentication:
     # Only for SSH authentication:
     privateKey: /etc/wiki/keys/git.pem
     privateKey: /etc/wiki/keys/git.pem
@@ -127,10 +127,10 @@ git:
     sslVerify: true
     sslVerify: true
 
 
   # Default email to use as commit author
   # Default email to use as commit author
-  serverEmail: marty@example.com
+  serverEmail: $(WIKI_SERVER_EMAIL)
 
 
   # Whether to use user email as author in commits
   # Whether to use user email as author in commits
-  showUserEmail: true
+  showUserEmail: $(WIKI_SHOW_USER_EMAIL)
 
 
 # ---------------------------------------------------------------------
 # ---------------------------------------------------------------------
 # Features
 # Features

+ 8 - 8
npm/install.js

@@ -137,7 +137,7 @@ const tasks = {
       if (err.code === 'ENOENT') {
       if (err.code === 'ENOENT') {
         ora.text = 'First-time install, creating a new config.yml...'
         ora.text = 'First-time install, creating a new config.yml...'
         let sourceConfigFile = path.join(installDir, 'config.sample.yml')
         let sourceConfigFile = path.join(installDir, 'config.sample.yml')
-        if (process.env.IS_HEROKU) {
+        if (process.env.WIKI_JS_HEROKU) {
           sourceConfigFile = path.join(__dirname, 'configs/config.heroku.yml')
           sourceConfigFile = path.join(__dirname, 'configs/config.heroku.yml')
         } else if (process.env.WIKI_JS_DOCKER) {
         } else if (process.env.WIKI_JS_DOCKER) {
           sourceConfigFile = path.join(__dirname, 'configs/config.docker.yml')
           sourceConfigFile = path.join(__dirname, 'configs/config.docker.yml')
@@ -152,7 +152,11 @@ const tasks = {
     })
     })
   },
   },
   startConfigurationWizard () {
   startConfigurationWizard () {
-    if (process.stdout.isTTY && !process.env.WIKI_JS_DOCKER) {
+    if (process.env.WIKI_JS_HEROKU) {
+      console.info('Wiki.js has been installed and is configured to use Heroku configuration.')
+    } else if (process.env.WIKI_JS_DOCKER) {
+      console.info('Docker environment detected. Skipping setup wizard auto-start.')
+    } else if (process.stdout.isTTY) {
       inquirer.prompt([{
       inquirer.prompt([{
         type: 'list',
         type: 'list',
         name: 'action',
         name: 'action',
@@ -202,11 +206,7 @@ const tasks = {
         })
         })
       })
       })
     } else {
     } else {
-      if (!process.env.IS_HEROKU && !process.env.WIKI_JS_DOCKER) {
-        console.info(colors.cyan('[WARNING] Non-interactive terminal detected. You must manually start the configuration wizard using the command: node wiki configure'))
-      } else {
-        console.info('Container environment detected. Skipping setup wizard auto-start. OK.')
-      }
+      console.info(colors.cyan('[WARNING] Non-interactive terminal detected. You must manually start the configuration wizard using the command: node wiki configure'))
     }
     }
   }
   }
 }
 }
@@ -224,7 +224,7 @@ if (!process.env.IS_HEROKU && !process.env.WIKI_JS_DOCKER) {
     '  \\/  \\/ |_|_|\\_\\_(_)/ |___/ \n' +
     '  \\/  \\/ |_|_|\\_\\_(_)/ |___/ \n' +
     '                   |__/\n'))
     '                   |__/\n'))
 } else {
 } else {
-  console.info('=-=-= WIKI.JS =-=-=')
+  console.info('> WIKI.JS [Installing...]')
 }
 }
 
 
 let ora = require('ora')({ text: 'Initializing...', spinner: 'dots12' }).start()
 let ora = require('ora')({ text: 'Initializing...', spinner: 'dots12' }).start()

+ 2 - 2
server/configure.js

@@ -67,8 +67,8 @@ module.exports = (port, spinner) => {
       langs,
       langs,
       conf,
       conf,
       runmode: {
       runmode: {
-        staticPort: (process.env.IS_HEROKU || process.env.WIKI_JS_DOCKER),
-        staticMongo: (!_.isNil(process.env.IS_HEROKU))
+        staticPort: (process.env.WIKI_JS_HEROKU || process.env.WIKI_JS_DOCKER),
+        staticMongo: (!_.isNil(process.env.WIKI_JS_HEROKU))
       }
       }
     })
     })
   })
   })

+ 1 - 1
server/helpers/config.js

@@ -13,7 +13,7 @@ module.exports = {
     return _.replace(
     return _.replace(
       cfg,
       cfg,
       (/\$\(([A-Z0-9_]+)\)/g,
       (/\$\(([A-Z0-9_]+)\)/g,
-      (m) => { return process.env[m] })
+      (fm, m) => { return process.env[m] })
     )
     )
   }
   }
 }
 }

+ 2 - 15
server/init.js

@@ -13,7 +13,7 @@ module.exports = {
    * Detect the most appropriate start mode
    * Detect the most appropriate start mode
    */
    */
   startDetect: function () {
   startDetect: function () {
-    if (process.env.IS_HEROKU) {
+    if (process.env.WIKI_JS_HEROKU) {
       return this.startInHerokuMode()
       return this.startInHerokuMode()
     } else {
     } else {
       return this.startInBackgroundMode()
       return this.startInBackgroundMode()
@@ -49,21 +49,8 @@ module.exports = {
    * Start in Heroku mode
    * Start in Heroku mode
    */
    */
   startInHerokuMode: function () {
   startInHerokuMode: function () {
-    let self = this
-
     console.info('Initializing Wiki.js for Heroku...')
     console.info('Initializing Wiki.js for Heroku...')
-    let herokuStatePath = path.join(__dirname, './app/heroku.json')
-    return fs.accessAsync(herokuStatePath).then(() => {
-      require('./server.js')
-    }).catch(err => {
-      if (err.code === 'ENOENT') {
-        console.info('Wiki.js is not configured yet. Launching configuration wizard...')
-        self.configure(process.env.PORT)
-      } else {
-        console.error(err)
-        process.exit(1)
-      }
-    })
+    require('./server.js')
   },
   },
   /**
   /**
    * Stop Wiki.js process(es)
    * Stop Wiki.js process(es)