@adobe/helix-shared-config 2.1.0 → 2.1.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/CHANGELOG.md CHANGED
@@ -3,6 +3,36 @@
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.3](https://github.com/adobe/helix-shared/compare/@adobe/helix-shared-config@2.1.2...@adobe/helix-shared-config@2.1.3) (2022-06-04)
7
+
8
+ **Note:** Version bump only for package @adobe/helix-shared-config
9
+
10
+
11
+
12
+
13
+
14
+ ## [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)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * allow adding sitemap or languages ([#690](https://github.com/adobe/helix-shared/issues/690)) ([5f095ef](https://github.com/adobe/helix-shared/commit/5f095ef276e1a44a36d9f3168d25ecf1074fa4ad))
20
+
21
+
22
+
23
+
24
+
25
+ ## [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)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * 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))
31
+
32
+
33
+
34
+
35
+
6
36
  # [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)
7
37
 
8
38
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-shared-config",
3
- "version": "2.1.0",
3
+ "version": "2.1.3",
4
4
  "description": "Shared modules of the Helix Project - config",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -27,9 +27,9 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@adobe/helix-fetch": "^3.0.3",
30
- "@adobe/helix-shared-git": "^2.0.3",
30
+ "@adobe/helix-shared-git": "^2.0.4",
31
31
  "@adobe/helix-shared-prune": "^1.0.5",
32
- "@adobe/helix-shared-utils": "^2.0.10",
32
+ "@adobe/helix-shared-utils": "^2.0.11",
33
33
  "ajv": "8.11.0",
34
34
  "ajv-formats": "2.1.1",
35
35
  "cookie": "0.5.0",
@@ -38,7 +38,7 @@
38
38
  "lru-cache": "7.10.1",
39
39
  "object-hash": "3.0.0",
40
40
  "uri-js": "4.4.1",
41
- "yaml": "2.1.0"
41
+ "yaml": "2.1.1"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@adobe/helix-shared-wrap": "^1.0.5",
@@ -47,7 +47,7 @@
47
47
  "@pollyjs/core": "6.0.5",
48
48
  "@pollyjs/persister-fs": "6.0.5",
49
49
  "mocha": "10.0.0",
50
- "nock": "13.2.4"
50
+ "nock": "13.2.6"
51
51
  },
52
- "gitHead": "e77cc809f42f4b6b13e4274ddf106a6c84f8abfa"
52
+ "gitHead": "82417e6b7d3232568187a9ae8249fc0c1234d473"
53
53
  }
@@ -53,7 +53,6 @@ class IndexConfig extends SchemaDerivedConfig {
53
53
  throw new Error(`Unable to add index definition with existing name: ${name}`);
54
54
  }
55
55
  indices[name] = {
56
- name,
57
56
  include,
58
57
  exclude,
59
58
  target,
@@ -135,10 +135,11 @@ class SchemaDerivedConfig extends BaseConfig {
135
135
  await this.loadConfig();
136
136
  await this.validate();
137
137
 
138
- this._content = new Proxy(this._cfg, this.defaultHandler(''));
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(this._cfg).forEach((key) => {
142
+ Object.keys(cfg).forEach((key) => {
142
143
  if (!(key in this)) {
143
144
  this[key] = this._content[key];
144
145
  }
@@ -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;