@adobe/helix-shared-config 2.0.7 → 2.1.2
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 +33 -0
- package/package.json +2 -2
- package/src/IndexConfig.js +28 -0
- package/src/SchemaDerivedConfig.js +3 -2
- package/src/SitemapConfig.js +68 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,39 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.1.2](https://github.com/adobe/helix-shared/compare/@adobe/helix-shared-config@2.1.1...@adobe/helix-shared-config@2.1.2) (2022-06-02)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* allow adding sitemap or languages ([#690](https://github.com/adobe/helix-shared/issues/690)) ([5f095ef](https://github.com/adobe/helix-shared/commit/5f095ef276e1a44a36d9f3168d25ecf1074fa4ad))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [2.1.1](https://github.com/adobe/helix-shared/compare/@adobe/helix-shared-config@2.1.0...@adobe/helix-shared-config@2.1.1) (2022-05-23)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* proxy clone to not change original configuration ([#686](https://github.com/adobe/helix-shared/issues/686)) ([96f9ce7](https://github.com/adobe/helix-shared/commit/96f9ce7dc90cd97efc44ecd7a06151451dee9d3e))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# [2.1.0](https://github.com/adobe/helix-shared/compare/@adobe/helix-shared-config@2.0.7...@adobe/helix-shared-config@2.1.0) (2022-05-20)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
* add index configuration ([#684](https://github.com/adobe/helix-shared/issues/684)) ([2cdec6f](https://github.com/adobe/helix-shared/commit/2cdec6f0c27b114d239ac524e3776e2d7e65fb18))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
6
39
|
## [2.0.7](https://github.com/adobe/helix-shared/compare/@adobe/helix-shared-config@2.0.6...@adobe/helix-shared-config@2.0.7) (2022-05-14)
|
|
7
40
|
|
|
8
41
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-shared-config",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "Shared modules of the Helix Project - config",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"mocha": "10.0.0",
|
|
50
50
|
"nock": "13.2.4"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "49e92ebcfa348d3cc01782c116d1ca2c42f20c6f"
|
|
53
53
|
}
|
package/src/IndexConfig.js
CHANGED
|
@@ -35,6 +35,34 @@ class IndexConfig extends SchemaDerivedConfig {
|
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Adds an index definition.
|
|
40
|
+
*
|
|
41
|
+
* @param {Object} index index configuration
|
|
42
|
+
* @param {string} index.name index name
|
|
43
|
+
* @param {Array} index.include paths to include
|
|
44
|
+
* @param {Array} index.exclude paths to exclude
|
|
45
|
+
* @param {string} index.target target
|
|
46
|
+
* @param {object} index.properties properties to add to the index
|
|
47
|
+
*/
|
|
48
|
+
addIndex({
|
|
49
|
+
name, include, exclude, target, properties,
|
|
50
|
+
}) {
|
|
51
|
+
const { indices } = this._cfg;
|
|
52
|
+
if (indices[name]) {
|
|
53
|
+
throw new Error(`Unable to add index definition with existing name: ${name}`);
|
|
54
|
+
}
|
|
55
|
+
indices[name] = {
|
|
56
|
+
include,
|
|
57
|
+
exclude,
|
|
58
|
+
target,
|
|
59
|
+
properties,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// let BaseConfig.toYAML() use the JSON output
|
|
63
|
+
this._document = null;
|
|
64
|
+
}
|
|
65
|
+
|
|
38
66
|
/**
|
|
39
67
|
* Evaluates a variable expression
|
|
40
68
|
* @param {string} expression the expression to encode
|
|
@@ -135,10 +135,11 @@ class SchemaDerivedConfig extends BaseConfig {
|
|
|
135
135
|
await this.loadConfig();
|
|
136
136
|
await this.validate();
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
const cfg = JSON.parse(JSON.stringify(this._cfg));
|
|
139
|
+
this._content = new Proxy(cfg, this.defaultHandler(''));
|
|
139
140
|
|
|
140
141
|
// redefine getters
|
|
141
|
-
Object.keys(
|
|
142
|
+
Object.keys(cfg).forEach((key) => {
|
|
142
143
|
if (!(key in this)) {
|
|
143
144
|
this[key] = this._content[key];
|
|
144
145
|
}
|
package/src/SitemapConfig.js
CHANGED
|
@@ -41,6 +41,74 @@ class SitemapConfig extends SchemaDerivedConfig {
|
|
|
41
41
|
this._version = this._cfg.version;
|
|
42
42
|
return this;
|
|
43
43
|
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Adds a sitemap definition.
|
|
47
|
+
*
|
|
48
|
+
* @param {Object} sitemap sitemap configuration
|
|
49
|
+
* @param {string} sitemap.name sitemap name
|
|
50
|
+
* @param {string} sitemap.origin sitemap origin
|
|
51
|
+
* @param {string} sitemap.source sitemap source
|
|
52
|
+
* @param {string} sitemap.destination sitemap destination
|
|
53
|
+
* @param {string} sitemap.lastmod lastmod format
|
|
54
|
+
* @return new sitemap
|
|
55
|
+
*/
|
|
56
|
+
addSitemap({
|
|
57
|
+
name, origin, source, destination, lastmod,
|
|
58
|
+
}) {
|
|
59
|
+
const { sitemaps } = this._cfg;
|
|
60
|
+
if (sitemaps[name]) {
|
|
61
|
+
throw new Error(`Unable to add sitemap definition with existing name: ${name}`);
|
|
62
|
+
}
|
|
63
|
+
sitemaps[name] = {
|
|
64
|
+
origin,
|
|
65
|
+
source,
|
|
66
|
+
destination,
|
|
67
|
+
lastmod,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// let BaseConfig.toYAML() use the JSON output
|
|
71
|
+
this._document = null;
|
|
72
|
+
return sitemaps[name];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Adds a language definition within a sitemap.
|
|
77
|
+
*
|
|
78
|
+
* @param {string} sitemapName sitemap name
|
|
79
|
+
* @param {Object} language language configuration
|
|
80
|
+
* @param {string} language.name language name
|
|
81
|
+
* @param {string} language.source language source
|
|
82
|
+
* @param {string} language.destination language destination
|
|
83
|
+
* @param {string} language.hreflang href language
|
|
84
|
+
* @param {string} language.alternate alternate location of this language
|
|
85
|
+
* @return new language
|
|
86
|
+
*/
|
|
87
|
+
addLanguage(sitemapName, {
|
|
88
|
+
name, source, destination, hreflang, alternate,
|
|
89
|
+
}) {
|
|
90
|
+
const { sitemaps } = this._cfg;
|
|
91
|
+
|
|
92
|
+
const sitemap = sitemaps[sitemapName];
|
|
93
|
+
if (!sitemap) {
|
|
94
|
+
throw new Error(`Unable to add language, sitemap not found: ${sitemapName}`);
|
|
95
|
+
}
|
|
96
|
+
// eslint-disable-next-line no-multi-assign
|
|
97
|
+
const languages = (sitemap.languages = sitemap.languages || {});
|
|
98
|
+
if (languages[name]) {
|
|
99
|
+
throw new Error(`Unable to add language definition with existing name: ${name}`);
|
|
100
|
+
}
|
|
101
|
+
languages[name] = {
|
|
102
|
+
source,
|
|
103
|
+
destination,
|
|
104
|
+
hreflang,
|
|
105
|
+
alternate,
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// let BaseConfig.toYAML() use the JSON output
|
|
109
|
+
this._document = null;
|
|
110
|
+
return languages[name];
|
|
111
|
+
}
|
|
44
112
|
}
|
|
45
113
|
|
|
46
114
|
module.exports = SitemapConfig;
|