@architect/inventory 3.2.0 → 3.2.1
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
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
## [3.2.1] 2022-08-10
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- By default, when a `set.shared|views` plugin sets a `src` path, if it is not present on the filesystem, Inventory falls back to default paths (e.g. `src/shared|views`)
|
|
10
|
+
- `set.shared|views` plugins now accept a `required` flag to enforce a validation error should a `src` path conflict with the project manifest (or not be found on the filesystem)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- Fixed an obscure internal reference passing bug in `set.proxy|shared|static|views` plugins
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
5
19
|
## [3.2.0] 2022-07-24
|
|
6
20
|
|
|
7
21
|
### Added
|
package/package.json
CHANGED
|
@@ -75,9 +75,9 @@ function validate (item, valid, type) {
|
|
|
75
75
|
*/
|
|
76
76
|
function settings (params) {
|
|
77
77
|
let { errors, settings, plugins, inventory, type, valid } = params
|
|
78
|
+
let newSettings = is.defined(settings) ? JSON.parse(JSON.stringify(settings)) : settings
|
|
78
79
|
if (plugins) {
|
|
79
80
|
let invCopy = deepFrozenCopy(inventory)
|
|
80
|
-
let pluginSettings = settings
|
|
81
81
|
let foundError = false
|
|
82
82
|
plugins.forEach(fn => {
|
|
83
83
|
try {
|
|
@@ -95,7 +95,7 @@ function settings (params) {
|
|
|
95
95
|
else {
|
|
96
96
|
Object.entries(result).forEach(([ setting, value ]) => {
|
|
97
97
|
if (is.defined(settings[setting]) && is.defined(value)) {
|
|
98
|
-
|
|
98
|
+
newSettings[setting] = value
|
|
99
99
|
}
|
|
100
100
|
})
|
|
101
101
|
}
|
|
@@ -103,15 +103,15 @@ function settings (params) {
|
|
|
103
103
|
if (foundError) return null
|
|
104
104
|
|
|
105
105
|
// Validation pass
|
|
106
|
-
let validationErrors = validate(
|
|
106
|
+
let validationErrors = validate(newSettings, valid, type)
|
|
107
107
|
if (validationErrors.length) {
|
|
108
108
|
errors = errors.push(...validationErrors)
|
|
109
109
|
return null
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
return
|
|
112
|
+
return newSettings
|
|
113
113
|
}
|
|
114
|
-
return
|
|
114
|
+
return newSettings
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
module.exports = { resources, settings }
|
|
@@ -14,10 +14,10 @@ module.exports = function configureShared ({ arc, pragmas, inventory, errors })
|
|
|
14
14
|
shared: []
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
let
|
|
17
|
+
let foundPluginSrc, foundArcSrc, required = false
|
|
18
18
|
let pluginSrc = populate.settings({
|
|
19
19
|
errors,
|
|
20
|
-
settings: shared,
|
|
20
|
+
settings: { ...shared, required: null },
|
|
21
21
|
plugins: inventory.plugins?._methods?.set?.shared,
|
|
22
22
|
inventory,
|
|
23
23
|
type: 'shared',
|
|
@@ -27,33 +27,45 @@ module.exports = function configureShared ({ arc, pragmas, inventory, errors })
|
|
|
27
27
|
// Lambda paths have not yet been reified in Inventory
|
|
28
28
|
if (is.string(pluginSrc?.src)) {
|
|
29
29
|
shared.src = pluginSrc.src
|
|
30
|
-
|
|
30
|
+
required = pluginSrc.required
|
|
31
|
+
foundPluginSrc = true
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
// First pass to get + check shared folder (if any)
|
|
34
35
|
if (arc?.shared?.length) {
|
|
35
36
|
for (let share of arc.shared) {
|
|
36
|
-
if (is.array(share)) {
|
|
37
|
-
|
|
38
|
-
if (key === 'src' && is.string(share[1])) {
|
|
37
|
+
if (is.array(share) && share[0]?.toLowerCase() === 'src') {
|
|
38
|
+
if (is.string(share[1])) {
|
|
39
39
|
shared.src = share[1]
|
|
40
|
-
|
|
40
|
+
foundArcSrc = true
|
|
41
|
+
if (required) errors.push(`@shared src setting conflicts with plugin`)
|
|
41
42
|
continue
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
-
errors.push(`@shared invalid setting: ${key}`)
|
|
45
|
-
}
|
|
44
|
+
else errors.push(`@shared invalid setting: src`)
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
|
|
50
|
-
if
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
// Source path selection + validation: manifest always wins; validate plugins differently if required; if not, fall back to `src/shared` (or null)
|
|
50
|
+
if (foundArcSrc) {
|
|
51
|
+
validate.shared(shared.src, cwd, errors, true)
|
|
52
|
+
}
|
|
53
|
+
else if (foundPluginSrc) {
|
|
54
|
+
if (!required) {
|
|
55
|
+
if (!is.exists(shared.src)) shared.src = src
|
|
56
|
+
if (!is.exists(shared.src)) return null
|
|
57
|
+
}
|
|
58
|
+
validate.shared(shared.src, cwd, errors, required)
|
|
59
|
+
}
|
|
60
|
+
else if (is.exists(src)) {
|
|
61
|
+
shared.src = src
|
|
62
|
+
validate.shared(shared.src, cwd, errors, false)
|
|
63
|
+
}
|
|
53
64
|
// Exit if configured shared folder doesn't exist
|
|
54
|
-
|
|
65
|
+
else return null
|
|
55
66
|
|
|
56
67
|
// Proceeding from here resets all shared config, so make sure it's only if specific shared are specified
|
|
68
|
+
let foundSrcSetting = foundArcSrc || foundPluginSrc
|
|
57
69
|
let some = arc.shared?.length && !(arc?.shared?.length === 1 && foundSrcSetting)
|
|
58
70
|
if (some) {
|
|
59
71
|
// Reset shared settings
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
let { join, resolve, sep } = require('path')
|
|
2
2
|
let { is } = require('../../../lib')
|
|
3
3
|
|
|
4
|
-
module.exports = function validateShared (src, cwd, errors) {
|
|
5
|
-
let path = src
|
|
4
|
+
module.exports = function validateShared (src, cwd, errors, required) {
|
|
5
|
+
let path = src?.startsWith(cwd) ? src : resolve(join(cwd, src))
|
|
6
6
|
|
|
7
|
-
if (
|
|
8
|
-
else if (!is.
|
|
7
|
+
if (is.exists(path) && !is.folder(path)) errors.push(`Must be a directory: ${src}`)
|
|
8
|
+
else if (!is.exists(path) && required) errors.push(`Directory not found: ${src}`)
|
|
9
9
|
|
|
10
|
-
let valid = path && path.
|
|
11
|
-
(cwd.split(sep) < path.split(sep))
|
|
10
|
+
let valid = path?.startsWith(cwd) && (cwd.split(sep) < path.split(sep))
|
|
12
11
|
if (!valid) errors.push(`Directory must be a subfolder of this project: ${src}`)
|
|
13
12
|
}
|
|
@@ -18,10 +18,10 @@ module.exports = function configureViews ({ arc, pragmas, inventory, errors }) {
|
|
|
18
18
|
views: []
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
let
|
|
21
|
+
let foundPluginSrc, foundArcSrc, required = false
|
|
22
22
|
let pluginSrc = populate.settings({
|
|
23
23
|
errors,
|
|
24
|
-
settings: views,
|
|
24
|
+
settings: { ...views, required: null },
|
|
25
25
|
plugins: inventory.plugins?._methods?.set?.views,
|
|
26
26
|
inventory,
|
|
27
27
|
type: 'views',
|
|
@@ -31,33 +31,45 @@ module.exports = function configureViews ({ arc, pragmas, inventory, errors }) {
|
|
|
31
31
|
// Lambda paths have not yet been reified in Inventory
|
|
32
32
|
if (is.string(pluginSrc?.src)) {
|
|
33
33
|
views.src = pluginSrc.src
|
|
34
|
-
|
|
34
|
+
required = pluginSrc.required
|
|
35
|
+
foundPluginSrc = true
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
// First pass to get + check views folder (if any)
|
|
38
39
|
if (arc?.views?.length) {
|
|
39
40
|
for (let view of arc.views) {
|
|
40
|
-
if (is.array(view)) {
|
|
41
|
-
|
|
42
|
-
if (key === 'src' && is.string(view[1])) {
|
|
41
|
+
if (is.array(view) && view[0]?.toLowerCase() === 'src') {
|
|
42
|
+
if (is.string(view[1])) {
|
|
43
43
|
views.src = view[1]
|
|
44
|
-
|
|
44
|
+
foundArcSrc = true
|
|
45
|
+
if (required) errors.push(`@views src setting conflicts with plugin`)
|
|
45
46
|
continue
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
-
errors.push(`@shared invalid setting: ${key}`)
|
|
49
|
-
}
|
|
48
|
+
else errors.push(`@views invalid setting: src`)
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
if
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (
|
|
53
|
+
// Source path selection + validation: manifest always wins; validate plugins differently if required; if not, fall back to `src/shared` (or null)
|
|
54
|
+
if (foundArcSrc) {
|
|
55
|
+
validate.shared(views.src, cwd, errors, true)
|
|
56
|
+
}
|
|
57
|
+
else if (foundPluginSrc) {
|
|
58
|
+
if (!required) {
|
|
59
|
+
if (!is.exists(views.src)) views.src = src
|
|
60
|
+
if (!is.exists(views.src)) return null
|
|
61
|
+
}
|
|
62
|
+
validate.shared(views.src, cwd, errors, required)
|
|
63
|
+
}
|
|
64
|
+
else if (is.exists(src)) {
|
|
65
|
+
views.src = src
|
|
66
|
+
validate.shared(views.src, cwd, errors, false)
|
|
67
|
+
}
|
|
68
|
+
// Exit if configured shared folder doesn't exist
|
|
69
|
+
else return null
|
|
59
70
|
|
|
60
71
|
// Proceeding from here resets all views config, so make sure it's only if specific views are specified
|
|
72
|
+
let foundSrcSetting = foundArcSrc || foundPluginSrc
|
|
61
73
|
let some = arc.views?.length && !(arc?.views?.length === 1 && foundSrcSetting)
|
|
62
74
|
if (some) {
|
|
63
75
|
// Reset views settings
|