@architect/inventory 3.0.0-RC.8 → 3.1.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/changelog.md +8 -0
- package/package.json +7 -7
- package/src/config/pragmas/plugins.js +2 -2
- package/src/config/project/plugins/env.js +2 -2
- package/src/config/project/prefs/dotenv.js +2 -2
- package/src/defaults/function-config.js +1 -0
- package/src/lib/get-lambda-dirs.js +3 -3
- package/src/lib/index.js +4 -0
- package/src/validate/config.js +17 -2
package/changelog.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@architect/inventory",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Architect project resource enumeration utility",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
},
|
|
22
22
|
"license": "Apache-2.0",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@architect/asap": "~5.0.0
|
|
25
|
-
"@architect/parser": "~6.0.0
|
|
26
|
-
"@architect/utils": "~3.1.0
|
|
24
|
+
"@architect/asap": "~5.0.0",
|
|
25
|
+
"@architect/parser": "~6.0.0",
|
|
26
|
+
"@architect/utils": "~3.1.0",
|
|
27
27
|
"lambda-runtimes": "~1.1.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"aws-sdk": "2.1001.0",
|
|
32
32
|
"aws-sdk-mock": "~5.6.2",
|
|
33
33
|
"cross-env": "~7.0.3",
|
|
34
|
-
"dotenv": "~
|
|
35
|
-
"eslint": "~8.
|
|
34
|
+
"dotenv": "~16.0.0",
|
|
35
|
+
"eslint": "~8.9.0",
|
|
36
36
|
"mock-fs": "~5.1.2",
|
|
37
37
|
"mock-require": "~3.0.3",
|
|
38
38
|
"nyc": "~15.1.0",
|
|
39
39
|
"tap-spec": "^5.0.0",
|
|
40
|
-
"tape": "^5.5.
|
|
40
|
+
"tape": "^5.5.2"
|
|
41
41
|
},
|
|
42
42
|
"eslintConfig": {
|
|
43
43
|
"extends": "@architect/eslint-config"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
let { join } = require('path')
|
|
2
2
|
let { existsSync } = require('fs')
|
|
3
|
-
let { is, normalizeSrc, pragmas, validationPatterns } = require('../../lib')
|
|
3
|
+
let { is, normalizeSrc, pragmas, tidyError, validationPatterns } = require('../../lib')
|
|
4
4
|
let { lambdas } = pragmas
|
|
5
5
|
let nonLambdaSetters = [ 'customLambdas', 'env', 'runtimes' ]
|
|
6
6
|
let setters = [ ...lambdas, ...nonLambdaSetters ]
|
|
@@ -91,7 +91,7 @@ module.exports = function getPluginModules ({ arc, inventory, errors }) {
|
|
|
91
91
|
})
|
|
92
92
|
}
|
|
93
93
|
catch (err) {
|
|
94
|
-
errors.push(`Unable to load plugin '${name}': ${err
|
|
94
|
+
errors.push(`Unable to load plugin '${name}': ${tidyError(err)}`)
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
else errors.push(`Cannot find plugin '${name || plugin}'! Are you sure you have installed or created it correctly?`)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
let { deepFrozenCopy } = require('@architect/utils')
|
|
2
|
-
let { is, validationPatterns: valid } = require('../../../lib')
|
|
2
|
+
let { is, tidyError, validationPatterns: valid } = require('../../../lib')
|
|
3
3
|
let envs = [ 'testing', 'staging', 'production' ]
|
|
4
4
|
let str = value => {
|
|
5
5
|
if (is.object(value) || is.array(value)) return JSON.stringify(value)
|
|
@@ -62,7 +62,7 @@ module.exports = function setEnvPlugins (params, project) {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
catch (err) {
|
|
65
|
-
errors.push(`Runtime plugin '${fn.plugin}' failed: ${err
|
|
65
|
+
errors.push(`Runtime plugin '${fn.plugin}' failed: ${tidyError(err)}`)
|
|
66
66
|
}
|
|
67
67
|
})
|
|
68
68
|
return env
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
var fs = require("fs");
|
|
8
8
|
var path = require("path");
|
|
9
9
|
var os = require("os");
|
|
10
|
-
var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"
|
|
10
|
+
var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
11
11
|
function parse(src) {
|
|
12
12
|
const obj = {};
|
|
13
13
|
let lines = src.toString();
|
|
@@ -18,7 +18,7 @@ function parse(src) {
|
|
|
18
18
|
let value = match[2] || "";
|
|
19
19
|
value = value.trim();
|
|
20
20
|
const maybeQuote = value[0];
|
|
21
|
-
value = value.replace(/^(['"])([\s\S]
|
|
21
|
+
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
|
|
22
22
|
if (maybeQuote === '"') {
|
|
23
23
|
value = value.replace(/\\n/g, "\n");
|
|
24
24
|
value = value.replace(/\\r/g, "\r");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
let { join } = require('path')
|
|
1
|
+
let { isAbsolute, join } = require('path')
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Get the src (and build) dirs for a Lambda
|
|
@@ -29,8 +29,8 @@ function getLambdaDirs (params, options) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
function normalizeSrc (cwd, dir) {
|
|
32
|
-
if (
|
|
33
|
-
return dir
|
|
32
|
+
if (isAbsolute(dir)) return dir
|
|
33
|
+
return join(cwd, dir)
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
getLambdaDirs.normalizeSrc = normalizeSrc
|
package/src/lib/index.js
CHANGED
|
@@ -24,6 +24,9 @@ let validationPatterns = {
|
|
|
24
24
|
envVar: /^[a-zA-Z0-9_]+$/,
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
// Error tidier: remove the error name, just print the message + stack data
|
|
28
|
+
let tidyError = err => err.message + `\n` + err.stack.split('\n').slice(1).join('\n')
|
|
29
|
+
|
|
27
30
|
module.exports = {
|
|
28
31
|
asapSrc,
|
|
29
32
|
compiledRuntimes,
|
|
@@ -34,5 +37,6 @@ module.exports = {
|
|
|
34
37
|
mergeEnvVars,
|
|
35
38
|
normalizeSrc: getLambdaDirs.normalizeSrc,
|
|
36
39
|
pragmas,
|
|
40
|
+
tidyError,
|
|
37
41
|
validationPatterns,
|
|
38
42
|
}
|
package/src/validate/config.js
CHANGED
|
@@ -9,7 +9,8 @@ module.exports = function configValidator (params, inventory, errors) {
|
|
|
9
9
|
let {
|
|
10
10
|
runtime: globalRuntime,
|
|
11
11
|
memory: globalMemory,
|
|
12
|
-
|
|
12
|
+
storage: globalStorage,
|
|
13
|
+
timeout: globalTimeout,
|
|
13
14
|
} = inventory.aws
|
|
14
15
|
|
|
15
16
|
let customRuntimes = inventory._project?.customRuntimes?.runtimes || []
|
|
@@ -28,6 +29,10 @@ module.exports = function configValidator (params, inventory, errors) {
|
|
|
28
29
|
!aliases[globalRuntime] && !aliases[globalRuntime.toLowerCase()])) {
|
|
29
30
|
errors.push(`Invalid project-level runtime: ${globalRuntime}`)
|
|
30
31
|
}
|
|
32
|
+
// Storage
|
|
33
|
+
if (!is.nullish(globalStorage) && invalidStorage(globalStorage)) {
|
|
34
|
+
errors.push(invalidStorageMsg(`${globalStorage} MB (@aws)`))
|
|
35
|
+
}
|
|
31
36
|
// Timeout
|
|
32
37
|
if (!is.nullish(globalTimeout) && invalidTimeout(globalTimeout)) {
|
|
33
38
|
errors.push(invalidTimeoutMsg(`${globalTimeout} seconds (@aws)`))
|
|
@@ -39,7 +44,7 @@ module.exports = function configValidator (params, inventory, errors) {
|
|
|
39
44
|
lambdas.forEach(p => {
|
|
40
45
|
let pragma = inventory[p]
|
|
41
46
|
if (pragma) pragma.forEach(({ name, config }) => {
|
|
42
|
-
let { memory, runtime, timeout } = config
|
|
47
|
+
let { memory, runtime, storage, timeout } = config
|
|
43
48
|
|
|
44
49
|
// Memory
|
|
45
50
|
if (invalidMemory(memory) && memory !== globalMemory) {
|
|
@@ -49,6 +54,10 @@ module.exports = function configValidator (params, inventory, errors) {
|
|
|
49
54
|
if (!allRuntimes.includes(runtime) && runtime !== globalRuntime) {
|
|
50
55
|
errors.push(`Invalid runtime: ${runtime} (@${p} ${name})`)
|
|
51
56
|
}
|
|
57
|
+
// Storage
|
|
58
|
+
if (invalidStorage(storage) && storage !== globalStorage) {
|
|
59
|
+
errors.push(invalidStorageMsg(`${storage} MB (@${p} ${name})`))
|
|
60
|
+
}
|
|
52
61
|
// Timeout
|
|
53
62
|
if (invalidTimeout(timeout) && timeout !== globalTimeout) {
|
|
54
63
|
errors.push(invalidTimeoutMsg(`${timeout} seconds (@${p} ${name})`))
|
|
@@ -68,3 +77,9 @@ let minTimeout = 1
|
|
|
68
77
|
let maxTimeout = 1 * 60 * 15 // 15 mins
|
|
69
78
|
let invalidTimeout = timeout => !is.number(timeout) || (timeout < minTimeout) || (timeout > maxTimeout)
|
|
70
79
|
let invalidTimeoutMsg = info => `Invalid Lambda timeout setting: ${info}, timeout must be between ${minTimeout} - ${maxTimeout} seconds`
|
|
80
|
+
|
|
81
|
+
// Memory
|
|
82
|
+
let minStorage = 512
|
|
83
|
+
let maxStorage = 10240
|
|
84
|
+
let invalidStorage = storage => !is.number(storage) || (storage < minStorage) || (storage > maxStorage)
|
|
85
|
+
let invalidStorageMsg = info => `Invalid Lambda storage setting: ${info}, storage must be between ${minStorage} - ${maxStorage} MB`
|