@architect/inventory 3.6.5 → 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.
Files changed (2) hide show
  1. package/package.json +7 -7
  2. package/src/env/index.js +23 -52
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@architect/inventory",
3
- "version": "3.6.5",
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,21 +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",
37
36
  "mock-tmp": "~0.0.2",
38
37
  "nyc": "~15.1.0",
38
+ "proxyquire": "~2.1.3",
39
39
  "tap-arc": "^1.2.2",
40
40
  "tape": "^5.7.2"
41
41
  },
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
  }