@madgex/fert 4.2.4 → 4.2.5
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/bin/commands/configs.js +1 -7
- package/bin/commands/publish.js +4 -9
- package/bin/utils/configs.js +22 -0
- package/package.json +1 -1
package/bin/commands/configs.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
const { resolveConfig } = require('../utils/index.js');
|
|
2
|
-
const {
|
|
3
|
-
getConfigAPI,
|
|
4
|
-
validateLocalConfigs,
|
|
5
|
-
updateProjectConfigs,
|
|
6
|
-
} = require('../utils/configs.js');
|
|
2
|
+
const { getConfigAPI, updateProjectConfigs } = require('../utils/configs.js');
|
|
7
3
|
const chalk = require('chalk');
|
|
8
4
|
const { log } = require('../utils/logging.js');
|
|
9
5
|
const { getSchemaMeta } = require('../utils/getSchemaMeta.js');
|
|
@@ -97,9 +93,7 @@ const handlePublish = async (fertConfig, api, options) => {
|
|
|
97
93
|
}
|
|
98
94
|
|
|
99
95
|
try {
|
|
100
|
-
await validateLocalConfigs(fertConfig, { catch: false });
|
|
101
96
|
await updateProjectConfigs(fertConfig, { environment: options.publish });
|
|
102
|
-
console.log('upload');
|
|
103
97
|
} catch (err) {
|
|
104
98
|
log.debug(err);
|
|
105
99
|
process.exit(1);
|
package/bin/commands/publish.js
CHANGED
|
@@ -5,10 +5,7 @@ const { resolveConfig } = require('../utils');
|
|
|
5
5
|
const { log } = require('../utils/logging');
|
|
6
6
|
const getAwsParam = require('./publish-tasks/get-aws-parameter');
|
|
7
7
|
const AssetStoreUploader = require('./publish-tasks/asset-store-uploader');
|
|
8
|
-
const {
|
|
9
|
-
validateLocalConfigs,
|
|
10
|
-
updateProjectConfigs,
|
|
11
|
-
} = require('../utils/configs.js');
|
|
8
|
+
const { updateProjectConfigs } = require('../utils/configs.js');
|
|
12
9
|
const {
|
|
13
10
|
getCloudFrontDistributionsForDomain,
|
|
14
11
|
} = require('../utils/lookup-cf-distribution-ids');
|
|
@@ -77,11 +74,9 @@ module.exports = async (root, options) => {
|
|
|
77
74
|
const uploadResult = await assetStore.uploadDir(localDir);
|
|
78
75
|
|
|
79
76
|
// validate & upload local configs to configuration API
|
|
80
|
-
await
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
environment: fertConfig.currBranch === 'master' ? 'production' : 'dev',
|
|
84
|
-
};
|
|
77
|
+
await updateProjectConfigs(fertConfig, {
|
|
78
|
+
environment: fertConfig.currBranch === 'master' ? 'production' : 'dev',
|
|
79
|
+
});
|
|
85
80
|
|
|
86
81
|
log.success(
|
|
87
82
|
`Publish complete in ${(uploadResult.duration / 1000).toFixed(0)}s\n`
|
package/bin/utils/configs.js
CHANGED
|
@@ -35,6 +35,15 @@ const validateLocalConfigs = async (fertConfig, options = { catch: true }) => {
|
|
|
35
35
|
async (configName) => {
|
|
36
36
|
try {
|
|
37
37
|
const schema = api.getSchema(configName);
|
|
38
|
+
const isSchemaReadOnly = api._isSchemaReadOnly(schema);
|
|
39
|
+
|
|
40
|
+
if (isSchemaReadOnly) {
|
|
41
|
+
throw Error(
|
|
42
|
+
`You're trying to set values on a read-only (usually V5) config schema: ${configName}`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// check the entire config against the config validation
|
|
38
47
|
const { error } = schema.validate(localConfigs[configName].data);
|
|
39
48
|
if (error) {
|
|
40
49
|
throw new Error(
|
|
@@ -42,6 +51,17 @@ const validateLocalConfigs = async (fertConfig, options = { catch: true }) => {
|
|
|
42
51
|
);
|
|
43
52
|
}
|
|
44
53
|
|
|
54
|
+
// validate all keys individually against the schema keys to ensure we're not trying to set any read-only keys
|
|
55
|
+
const config = localConfigs[configName].data;
|
|
56
|
+
for (const key in config) {
|
|
57
|
+
const keySchema = schema.extract(key);
|
|
58
|
+
if (api._isSchemaReadOnly(keySchema)) {
|
|
59
|
+
throw new Error(
|
|
60
|
+
`You're trying to set a read-only key on a config schema: ${configName}/${key}`
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
45
65
|
log.success(`Config validated:`, chalk.bold(configName));
|
|
46
66
|
} catch (err) {
|
|
47
67
|
log.error(err.message);
|
|
@@ -125,6 +145,8 @@ const updateProjectConfigs = async (
|
|
|
125
145
|
}
|
|
126
146
|
|
|
127
147
|
try {
|
|
148
|
+
await validateLocalConfigs(fertConfig, { catch: false });
|
|
149
|
+
|
|
128
150
|
const api = await getConfigAPI({
|
|
129
151
|
clientPropertyId: fertConfig.clientPropertyId,
|
|
130
152
|
environment,
|