@architect/inventory 3.6.4 → 3.6.6-RC.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@architect/inventory",
3
- "version": "3.6.4",
3
+ "version": "3.6.6-RC.0",
4
4
  "description": "Architect project resource enumeration utility",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -21,20 +21,21 @@
21
21
  },
22
22
  "license": "Apache-2.0",
23
23
  "dependencies": {
24
- "@architect/asap": "~6.0.4",
24
+ "@architect/asap": "~6.1.0-RC.0",
25
25
  "@architect/parser": "~6.0.3",
26
- "@architect/utils": "~3.1.9",
27
- "lambda-runtimes": "~1.1.6"
26
+ "@architect/utils": "~4.0.0-RC.1",
27
+ "@aws-lite/client": "~0.12.2",
28
+ "@aws-lite/ssm": "~0.2.1",
29
+ "lambda-runtimes": "~1.1.7"
28
30
  },
29
31
  "devDependencies": {
30
32
  "@architect/eslint-config": "~2.1.2",
31
- "aws-sdk": "^2.1363.0",
32
- "aws-sdk-mock": "~5.8.0",
33
33
  "cross-env": "~7.0.3",
34
34
  "dotenv": "~16.3.1",
35
35
  "eslint": "~8.55.0",
36
- "mock-fs": "~5.2.0",
36
+ "mock-tmp": "~0.0.2",
37
37
  "nyc": "~15.1.0",
38
+ "proxyquire": "~2.1.3",
38
39
  "tap-arc": "^1.2.2",
39
40
  "tape": "^5.7.2"
40
41
  },
@@ -52,8 +52,8 @@ module.exports = function configureShared ({ arc, pragmas, inventory, errors })
52
52
  }
53
53
  else if (foundPluginSrc) {
54
54
  if (!required) {
55
- if (!is.exists(shared.src)) shared.src = src
56
- if (!is.exists(shared.src)) return null
55
+ if (!is.exists(shared.src) && !is.exists(join(cwd, shared.src))) shared.src = src
56
+ if (!is.exists(shared.src) && !is.exists(join(cwd, shared.src))) return null
57
57
  }
58
58
  validate.shared(shared.src, cwd, errors, required)
59
59
  }
@@ -56,8 +56,8 @@ module.exports = function configureViews ({ arc, pragmas, inventory, errors }) {
56
56
  }
57
57
  else if (foundPluginSrc) {
58
58
  if (!required) {
59
- if (!is.exists(views.src)) views.src = src
60
- if (!is.exists(views.src)) return null
59
+ if (!is.exists(views.src) && !is.exists(join(cwd, views.src))) views.src = src
60
+ if (!is.exists(views.src) && !is.exists(join(cwd, views.src))) return null
61
61
  }
62
62
  validate.shared(views.src, cwd, errors, required)
63
63
  }
@@ -4,11 +4,11 @@ let read = require('../../../read')
4
4
  let validate = require('../validate')
5
5
  let { is, validationPatterns: valid } = require('../../../lib')
6
6
  let { parse } = require('./dotenv')
7
- let { homedir } = require('os')
7
+ let os = require('os')
8
8
 
9
9
  module.exports = function getPrefs ({ scope, inventory, errors }) {
10
10
  let cwd = scope === 'global'
11
- ? homedir()
11
+ ? os.homedir()
12
12
  : inventory._project.cwd
13
13
 
14
14
  let envFilepath = join(cwd, '.env')
package/src/env/index.js CHANGED
@@ -8,68 +8,40 @@ module.exports = function env (params, inventory, callback) {
8
8
  return callback()
9
9
  }
10
10
 
11
- /* istanbul ignore next */
12
- try {
13
- // eslint-disable-next-line
14
- try { require('aws-sdk/lib/maintenance_mode_message').suppress = true }
15
- catch { /* Noop */ }
16
- // eslint-disable-next-line
17
- var aws = require('aws-sdk')
18
- }
19
- catch (err) {
20
- let msg = `'aws-sdk' not found, please install locally or globally (see also readme#aws-sdk-caveat)`
21
- return callback(Error(msg))
22
- }
11
+ let aws
23
12
  let name = inventory.app
24
13
  let { region } = inventory.aws
25
- let ssm = new aws.SSM({ region })
26
14
  let result = []
15
+ // eslint-disable-next-line
16
+ let awsLite = require('@aws-lite/client')
17
+ /* istanbul ignore next */
18
+ awsLite({ region }).then(_aws => {
19
+ aws = _aws
27
20
 
28
- function getSomeEnvVars (name, NextToken, callback) {
29
- // Base query to ssm
30
- let query = {
21
+ // Perform the query
22
+ let params = {
31
23
  Path: `/${name}`,
32
24
  Recursive: true,
33
25
  MaxResults: 10,
34
- WithDecryption: true
26
+ WithDecryption: true,
27
+ paginate: true
35
28
  }
36
-
37
- // Check if we're paginating
38
- /* istanbul ignore if */
39
- if (NextToken) query.NextToken = NextToken
40
-
41
- // Perform the query
42
- ssm.getParametersByPath(query, function _query (err, data) {
43
- if (err) callback(err)
44
- else {
45
- // Tidy up the response
46
- result = result.concat(data.Parameters.map(function (param) {
47
- let bits = param.Name.split('/')
48
- return {
49
- app: name, // jic
50
- env: bits[2],
51
- name: bits[3],
52
- value: param.Value,
53
- }
54
- }))
55
- // Check for more data and, if so, recurse
56
- /* istanbul ignore if: Sadly no way to easily mock this for testing */
57
- if (data.NextToken) {
58
- getSomeEnvVars(name, data.NextToken, callback)
29
+ aws.ssm.GetParametersByPath(params).then(data => {
30
+ // Tidy up the response
31
+ result = result.concat(data.Parameters.map(param => {
32
+ let bits = param.Name.split('/')
33
+ return {
34
+ app: name, // jic
35
+ env: bits[2],
36
+ name: bits[3],
37
+ value: param.Value,
59
38
  }
60
- else callback(null, result)
61
- }
62
- })
63
- }
39
+ }))
64
40
 
65
- getSomeEnvVars(name, false, function done (err, result) {
66
- if (err) callback(err)
67
- else {
68
41
  let testing = null
69
42
  let staging = null
70
43
  let production = null
71
44
  if (result.length) {
72
- // TODO refactor into a reducer?
73
45
  result.forEach(({ env, name: k, value: v }) => {
74
46
  if (env === 'testing') testing = Object.assign({}, testing, { [k]: v })
75
47
  if (env === 'staging') staging = Object.assign({}, staging, { [k]: v })
@@ -85,10 +57,9 @@ module.exports = function env (params, inventory, callback) {
85
57
  errors,
86
58
  })
87
59
  if (errors.length) {
88
- callback(Error(errors[0]))
89
- return
60
+ return callback(Error(errors[0]))
90
61
  }
91
62
  callback()
92
- }
93
- })
63
+ }).catch(err => callback(err))
64
+ }).catch(err => callback(err))
94
65
  }
@@ -1,23 +1,26 @@
1
1
  let { join } = require('path')
2
2
  let { existsSync } = require('fs')
3
3
 
4
- module.exports = function asapSrc () {
4
+ module.exports = function asapSrc (params = {}) {
5
+ let { _testing } = params
6
+ let dirname = _testing ? _testing : __dirname
5
7
  // Inventory running as an arc/arc dependency (most common use case)
6
8
  let src = join(process.cwd(), 'node_modules', '@architect', 'asap', 'src')
7
9
  if (existsSync(src)) return src
8
10
 
9
11
  // Inventory running in arc/arc as a global install
10
- let global = join(__dirname, '..', '..', '..', 'asap', 'src')
12
+ let global = join(dirname, '..', '..', '..', 'asap', 'src')
11
13
  if (existsSync(global)) return global
12
14
 
13
15
  // Inventory running from a local (symlink) context (usually testing/dev)
14
- let local = join(__dirname, '..', '..', 'node_modules', '@architect', 'asap', 'src')
16
+ let local = join(dirname, '..', '..', 'node_modules', '@architect', 'asap', 'src')
15
17
  if (existsSync(local)) return local
16
18
 
17
19
  try {
18
20
  return require.resolve('@architect/asap')
19
21
  }
20
- catch (err) {
22
+ catch {
23
+ /* istanbul ignore next */
21
24
  throw Error('Cannot find ASAP module!')
22
25
  }
23
26
  }
@@ -39,5 +39,4 @@ module.exports = function finalValidation (params, inventory) {
39
39
  if (errors.length) {
40
40
  return errorFmt({ type: 'file path', errors })
41
41
  }
42
-
43
42
  }