@madgex/fert 2.0.2 → 2.0.3
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/build-tasks/build-external-assets.js +2 -2
- package/bin/commands/build-tasks/build-tokens-v5.js +2 -2
- package/bin/commands/build-tasks/build-tokens.js +2 -2
- package/bin/commands/build-tasks/bundle-entry.js +1 -1
- package/bin/commands/build.js +1 -1
- package/bin/commands/dev-server.js +1 -1
- package/bin/commands/init.js +2 -2
- package/bin/commands/publish-tasks/asset-store-uploader.js +2 -2
- package/bin/commands/publish.js +6 -2
- package/bin/utils/cpid-lookup.js +18 -13
- package/bin/utils/disk-cache-with-ttl.js +29 -0
- package/bin/utils/index.js +6 -6
- package/bin/utils/slug.js +6 -0
- package/constants.js +3 -3
- package/package.json +2 -2
- package/server/index.js +1 -1
- package/server/view-manager.js +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
const Path = require('node:path');
|
|
2
|
+
const fs = require('node:fs/promises');
|
|
1
3
|
const StyleDictionaryPackage = require('style-dictionary');
|
|
2
|
-
const Path = require('path');
|
|
3
|
-
const fs = require('fs/promises');
|
|
4
4
|
const {
|
|
5
5
|
registerTransforms,
|
|
6
6
|
} = require('@madgex/design-system-v5/tasks/registerTransforms');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
const Path = require('node:path');
|
|
2
|
+
const fs = require('node:fs/promises');
|
|
1
3
|
const StyleDictionaryPackage = require('style-dictionary');
|
|
2
|
-
const Path = require('path');
|
|
3
|
-
const fs = require('fs/promises');
|
|
4
4
|
const {
|
|
5
5
|
registerTransforms,
|
|
6
6
|
} = require('@madgex/design-system/tasks/registerTransforms');
|
package/bin/commands/build.js
CHANGED
package/bin/commands/init.js
CHANGED
package/bin/commands/publish.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const path = require('path');
|
|
1
|
+
const path = require('node:path');
|
|
2
2
|
const Hoek = require('@hapi/hoek');
|
|
3
3
|
const chalk = require('chalk');
|
|
4
4
|
const { resolveConfig } = require('../utils');
|
|
@@ -38,7 +38,11 @@ module.exports = async (root, options) => {
|
|
|
38
38
|
const apiKey = await getAwsParam(apiKeyParamPath);
|
|
39
39
|
|
|
40
40
|
log.info(
|
|
41
|
-
|
|
41
|
+
`\nPublishing ${chalk.cyan(localDir)} to ${chalk.green.bold(
|
|
42
|
+
options.target
|
|
43
|
+
)} for ${chalk.green(fertConfig.client.brandName)} ${chalk.dim(
|
|
44
|
+
`(${fertConfig.clientPropertyId})`
|
|
45
|
+
)}\n`
|
|
42
46
|
);
|
|
43
47
|
|
|
44
48
|
// send to S3 using the Asset Store API
|
package/bin/utils/cpid-lookup.js
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
const path = require('node:path');
|
|
2
2
|
const axios = require('axios');
|
|
3
3
|
const { log } = require('../utils/logging');
|
|
4
|
-
const
|
|
4
|
+
const { slug } = require('../utils/slug');
|
|
5
5
|
const dayjs = require('dayjs');
|
|
6
6
|
const duration = require('dayjs/plugin/duration');
|
|
7
|
-
const { PROPERTY_ID_API, TMP_DIR } = require('../../constants');
|
|
7
|
+
const { PROPERTY_ID_API, TMP_DIR, VERSION } = require('../../constants');
|
|
8
8
|
const chalk = require('chalk');
|
|
9
|
+
const flatCache = require('flat-cache');
|
|
10
|
+
const { diskCacheWithTtl } = require('./disk-cache-with-ttl');
|
|
9
11
|
|
|
10
12
|
dayjs.extend(duration);
|
|
11
13
|
|
|
14
|
+
const flatCacheDoc = flatCache.load(
|
|
15
|
+
'fert-cpid-cache',
|
|
16
|
+
path.resolve(`${TMP_DIR}/fert-cpid-cache-${slug(VERSION)}`)
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const cache = new diskCacheWithTtl(flatCacheDoc, {
|
|
20
|
+
ttl: dayjs.duration(1, 'week').asMilliseconds(),
|
|
21
|
+
});
|
|
22
|
+
|
|
12
23
|
exports.doCpidLookup = async (clientPropertyId) => {
|
|
13
24
|
const API_URL = new URL(clientPropertyId, PROPERTY_ID_API).toString();
|
|
14
25
|
|
|
@@ -27,7 +38,6 @@ exports.doCpidLookup = async (clientPropertyId) => {
|
|
|
27
38
|
throw Error(error.message);
|
|
28
39
|
});
|
|
29
40
|
|
|
30
|
-
// const { data: results } = await res.json();
|
|
31
41
|
const { brandName, parentId: parentCpid } = results;
|
|
32
42
|
|
|
33
43
|
return {
|
|
@@ -39,20 +49,15 @@ exports.doCpidLookup = async (clientPropertyId) => {
|
|
|
39
49
|
};
|
|
40
50
|
|
|
41
51
|
exports.cpidLookup = async (clientPropertyId) => {
|
|
42
|
-
|
|
43
|
-
dir: `${TMP_DIR}/fert-cpid-cache`,
|
|
44
|
-
ttl: dayjs.duration(1, 'week').asMilliseconds(),
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const cache = await storage.getItem(clientPropertyId);
|
|
52
|
+
const value = cache.get(clientPropertyId);
|
|
48
53
|
|
|
49
|
-
if (
|
|
50
|
-
return
|
|
54
|
+
if (value) {
|
|
55
|
+
return value;
|
|
51
56
|
}
|
|
52
57
|
|
|
53
58
|
const result = await this.doCpidLookup(clientPropertyId);
|
|
54
59
|
|
|
55
|
-
|
|
60
|
+
cache.set(clientPropertyId, result);
|
|
56
61
|
|
|
57
62
|
return result;
|
|
58
63
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
class diskCacheWithTtl {
|
|
2
|
+
constructor(cache, options = { ttl: 0 }) {
|
|
3
|
+
this.cache = cache;
|
|
4
|
+
this.options = options;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
set(key, value) {
|
|
8
|
+
this.cache.setKey(key, {
|
|
9
|
+
value,
|
|
10
|
+
expire: new Date().getTime() + this.options.ttl,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
this.cache.save(true);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get(key) {
|
|
17
|
+
let cachedBlob = this.cache.getKey(key);
|
|
18
|
+
|
|
19
|
+
if (cachedBlob && new Date().getTime() > cachedBlob.expire) {
|
|
20
|
+
this.cache.removeKey(key);
|
|
21
|
+
cachedBlob = null;
|
|
22
|
+
|
|
23
|
+
this.cache.save(true);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return cachedBlob && cachedBlob.value;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.diskCacheWithTtl = diskCacheWithTtl;
|
package/bin/utils/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const fsp = require('fs/promises');
|
|
1
|
+
const path = require('node:path');
|
|
2
|
+
const fs = require('node:fs');
|
|
4
3
|
const { VERSION, SITE } = require('../../constants');
|
|
5
4
|
const chalk = require('chalk');
|
|
6
5
|
const uuidValidator = require('uuid-validate');
|
|
7
6
|
const Hoek = require('@hapi/hoek');
|
|
8
7
|
const { cpidLookup } = require('./cpid-lookup');
|
|
9
8
|
const resolveExternalAssets = require('./resolve-external-assets');
|
|
9
|
+
const { log } = require('./logging');
|
|
10
10
|
|
|
11
11
|
exports.printBanner = () => {
|
|
12
|
-
console.log(
|
|
12
|
+
console.log(`\n${chalk.green.bold('Fert')} v${VERSION}`);
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
exports.resolveConfig = async (root, options = {}) => {
|
|
@@ -62,7 +62,7 @@ exports.loadConfigFromFile = (workingDir) => {
|
|
|
62
62
|
|
|
63
63
|
return fertConfig;
|
|
64
64
|
} catch (err) {
|
|
65
|
-
|
|
65
|
+
log.error(
|
|
66
66
|
`Failed to load fert.config.js - ensure you're running fert on a branding repo & config exists.\n`
|
|
67
67
|
);
|
|
68
68
|
|
|
@@ -78,7 +78,7 @@ exports.ensureTrailingSlash = (str) => {
|
|
|
78
78
|
|
|
79
79
|
exports.exists = async (path) => {
|
|
80
80
|
try {
|
|
81
|
-
|
|
81
|
+
fs.access(path);
|
|
82
82
|
return true;
|
|
83
83
|
} catch {
|
|
84
84
|
return false;
|
package/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const os = require('os');
|
|
1
|
+
const fs = require('node:fs');
|
|
2
|
+
const path = require('node:path');
|
|
3
|
+
const os = require('node:os');
|
|
4
4
|
|
|
5
5
|
const { version: VERSION } = JSON.parse(
|
|
6
6
|
fs.readFileSync(path.resolve(__dirname, './package.json')).toString()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@madgex/fert",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "Tool to help build the V6 branding",
|
|
5
5
|
"bin": {
|
|
6
6
|
"fert": "./bin/cli.js"
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"chokidar": "^3.5.3",
|
|
40
40
|
"dayjs": "^1.11.10",
|
|
41
41
|
"debug": "^4.3.4",
|
|
42
|
+
"flat-cache": "^4.0.0",
|
|
42
43
|
"form-data": "^4.0.0",
|
|
43
44
|
"lodash": "^4.17.21",
|
|
44
|
-
"node-persist": "^3.1.3",
|
|
45
45
|
"nunjucks": "^3.2.4",
|
|
46
46
|
"open": "8.4.2",
|
|
47
47
|
"ora": "5.4.1",
|
package/server/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const Hapi = require('@hapi/hapi');
|
|
2
2
|
const Toys = require('@hapipal/toys');
|
|
3
|
-
const path = require('path');
|
|
3
|
+
const path = require('node:path');
|
|
4
4
|
const { log } = require('../bin/utils/logging');
|
|
5
5
|
const podletServer = require('@private/header-footer-podlet-server');
|
|
6
6
|
const {
|
package/server/view-manager.js
CHANGED