@things-factory/env 7.0.0-alpha.30 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -5,5 +5,6 @@ module.exports = {
5
5
  config: require('./lib/config'),
6
6
  logger: require('./lib/logger'),
7
7
  loader: require('./lib/module-loader'),
8
- appRootPath: require('./lib/app-root-path').appRootPath
8
+ appRootPath: require('./lib/app-root-path').appRootPath,
9
+ appPackage: require('./lib/app-package')
9
10
  }
@@ -0,0 +1,4 @@
1
+ const path = require('path')
2
+ const { appRootPath } = require('./app-root-path')
3
+
4
+ module.exports = require(path.resolve(appRootPath, 'package.json'))
package/lib/logger.js CHANGED
@@ -4,7 +4,7 @@ var config = require('./config')
4
4
  var { createLogger, format, transports } = require('winston')
5
5
  require('winston-daily-rotate-file')
6
6
 
7
- const { combine, timestamp, splat, simple, printf } = format
7
+ const { combine, errors, splat, printf } = format
8
8
 
9
9
  var { file: fileConfig, console: consoleConfig } = config.get('logger', {})
10
10
 
@@ -35,11 +35,11 @@ const systemTimestamp = format((info, opts) => {
35
35
  return info
36
36
  })
37
37
 
38
- const logFormat = printf(({ level, message, timestamp }) => {
39
- return `${timestamp} ${level}: ${message}`
38
+ const logFormat = printf(({ level, message, timestamp, stack }) => {
39
+ return `${timestamp} ${level}: ${stack || message}`
40
40
  })
41
41
 
42
42
  module.exports = createLogger({
43
- format: combine(systemTimestamp({ tz: SYSTEM_TZ }), splat(), logFormat),
43
+ format: combine(errors({ stack: true }), systemTimestamp({ tz: SYSTEM_TZ }), splat(), logFormat),
44
44
  transports: logTransports
45
45
  })
@@ -0,0 +1,36 @@
1
+ const path = require('path')
2
+ const { appRootPath } = require('./app-root-path')
3
+ const orderedModuleNames = require('./dependency-order')
4
+
5
+ const selfModulePackage = require(path.resolve(appRootPath, 'package.json'))
6
+ const selfModuleName = selfModulePackage.name
7
+
8
+ const operatoModues = orderedModuleNames.reduce((sum, name) => {
9
+ const dependencies =
10
+ name === selfModuleName ? selfModulePackage['dependencies'] : require(`${name}/package.json`)['dependencies'] || {}
11
+
12
+ Object.keys(dependencies)
13
+ .filter(dep => {
14
+ try {
15
+ const pkg = require(`${dep}/package.json`)
16
+ return pkg && pkg['operato']
17
+ } catch (err) {
18
+ return
19
+ }
20
+ })
21
+ .forEach(dep => {
22
+ sum[dep] = true
23
+ })
24
+
25
+ return sum
26
+ }, {})
27
+
28
+ const operatoModuleNames = Object.keys(operatoModues)
29
+
30
+ if (selfModulePackage['operato'] && !operatoModuleNames.includes(selfModuleName)) {
31
+ operatoModuleNames.push(selfModuleName)
32
+ }
33
+
34
+ console.log('operato module names', operatoModuleNames)
35
+
36
+ module.exports = operatoModuleNames
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/env",
3
- "version": "7.0.0-alpha.30",
3
+ "version": "7.0.0",
4
4
  "description": "Things Factory running environment helper library",
5
5
  "main": "index.js",
6
6
  "author": "heartyoh@hatiolab.com",
@@ -27,5 +27,5 @@
27
27
  "winston": "^3.2.1",
28
28
  "winston-daily-rotate-file": "^4.2.1"
29
29
  },
30
- "gitHead": "64f2ff6e284ecb26530d1a456a0627dced03fde7"
30
+ "gitHead": "00f3917ca132679e3571f3f4fd16f4caf84f488e"
31
31
  }