@adobe/helix-html-pipeline 5.13.11 → 5.13.13

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
@@ -1,3 +1,17 @@
1
+ ## [5.13.13](https://github.com/adobe/helix-html-pipeline/compare/v5.13.12...v5.13.13) (2024-12-14)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update external fixes ([#770](https://github.com/adobe/helix-html-pipeline/issues/770)) ([987b21b](https://github.com/adobe/helix-html-pipeline/commit/987b21b8ff7fa0bc1afa3f6d7b03969d13431fd3))
7
+
8
+ ## [5.13.12](https://github.com/adobe/helix-html-pipeline/compare/v5.13.11...v5.13.12) (2024-12-04)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * apply folder-mapped metadata also for existing resources ([#766](https://github.com/adobe/helix-html-pipeline/issues/766)) ([9574186](https://github.com/adobe/helix-html-pipeline/commit/95741861927afe291cd63ca4502e9c52d2e215fa)), closes [#758](https://github.com/adobe/helix-html-pipeline/issues/758)
14
+
1
15
  ## [5.13.11](https://github.com/adobe/helix-html-pipeline/compare/v5.13.10...v5.13.11) (2024-11-23)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-html-pipeline",
3
- "version": "5.13.11",
3
+ "version": "5.13.13",
4
4
  "description": "Helix HTML Pipeline",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -51,7 +51,7 @@
51
51
  "github-slugger": "2.0.0",
52
52
  "hast-util-raw": "9.1.0",
53
53
  "hast-util-select": "6.0.3",
54
- "hast-util-to-html": "9.0.3",
54
+ "hast-util-to-html": "9.0.4",
55
55
  "hast-util-to-string": "3.0.1",
56
56
  "hastscript": "9.0.0",
57
57
  "jose": "5.9.6",
@@ -78,7 +78,7 @@
78
78
  "@semantic-release/changelog": "6.0.3",
79
79
  "@semantic-release/git": "10.0.1",
80
80
  "@semantic-release/npm": "12.0.1",
81
- "c8": "10.1.2",
81
+ "c8": "10.1.3",
82
82
  "eslint": "8.57.1",
83
83
  "eslint-import-resolver-exports": "1.0.0-beta.5",
84
84
  "eslint-plugin-header": "3.1.1",
@@ -88,8 +88,8 @@
88
88
  "js-yaml": "4.1.0",
89
89
  "jsdom": "25.0.1",
90
90
  "junit-report-builder": "5.1.1",
91
- "lint-staged": "15.2.10",
92
- "mocha": "10.8.2",
91
+ "lint-staged": "15.2.11",
92
+ "mocha": "11.0.1",
93
93
  "mocha-multi-reporters": "1.5.1",
94
94
  "mocha-suppress-logs": "0.5.1",
95
95
  "semantic-release": "24.2.0"
@@ -133,5 +133,23 @@ declare class PipelineState {
133
133
  * this is initialized after the config is loaded.
134
134
  */
135
135
  liveHost?: string;
136
+
137
+ /**
138
+ * specifies if the content as folder mapped (note that it remains false for content that
139
+ * exists below a folder mapped path. in this case, the `mappedPath` would still be different
140
+ * from the `info.path`
141
+ */
142
+ mapped: boolean;
143
+
144
+ /**
145
+ * the mapped path (target) of a folder mapping. this is set irrespective of the existence of the
146
+ * resource, when the path is below a folder mapped path
147
+ */
148
+ mappedPath: string;
149
+
150
+ /**
151
+ * metadata from folder mapping
152
+ */
153
+ mappedMetadata: Modifiers
136
154
  }
137
155
 
package/src/html-pipe.js CHANGED
@@ -20,7 +20,7 @@ import fetchContent from './steps/fetch-content.js';
20
20
  import fetch404 from './steps/fetch-404.js';
21
21
  import fetchConfigAll from './steps/fetch-config-all.js';
22
22
  import fixSections from './steps/fix-sections.js';
23
- import folderMapping from './steps/folder-mapping.js';
23
+ import { calculateFolderMapping, applyFolderMapping } from './steps/folder-mapping.js';
24
24
  import getMetadata from './steps/get-metadata.js';
25
25
  import html from './steps/make-html.js';
26
26
  import parseMarkdown from './steps/parse-markdown.js';
@@ -126,7 +126,7 @@ export async function htmlPipe(state, req) {
126
126
  state.content.sourceBus = 'code';
127
127
  }
128
128
 
129
- // ...and apply the folder mapping
129
+ calculateFolderMapping(state);
130
130
  state.timer?.update('content-fetch');
131
131
  let contentPromise = await fetchContent(state, req, res);
132
132
  if (res.status === 404) {
@@ -135,7 +135,7 @@ export async function htmlPipe(state, req) {
135
135
  contentPromise = fetchContentRedirectWith404Fallback(state, req, res);
136
136
  } else {
137
137
  // ...apply folder mapping if the current resource doesn't exist
138
- await folderMapping(state);
138
+ applyFolderMapping(state);
139
139
  if (state.info.unmappedPath) {
140
140
  contentPromise = fetchContentWith404Fallback(state, req, res);
141
141
  } else {
@@ -168,7 +168,7 @@ export default function extractMetaData(state, req) {
168
168
  // with local metadata from document
169
169
  const metaConfig = Object.assign(
170
170
  state.metadata.getModifiers(state.info.unmappedPath || state.info.path),
171
- state.mappedMetadata.getModifiers(state.info.unmappedPath),
171
+ state.mappedMetadata.getModifiers(state.info.unmappedPath || state.info.path),
172
172
  );
173
173
 
174
174
  // prune empty values and explicit "" strings from sheet based metadata
@@ -24,11 +24,12 @@ import { Modifiers } from '../utils/modifiers.js';
24
24
  */
25
25
  export default async function fetchMappedMetadata(state) {
26
26
  state.mappedMetadata = Modifiers.EMPTY;
27
- if (!state.mapped) {
27
+ const { mappedPath } = state;
28
+ if (!mappedPath) {
28
29
  return;
29
30
  }
30
31
  const { contentBusId, partition } = state;
31
- const metadataPath = `${state.info.path}/metadata.json`;
32
+ const metadataPath = `${mappedPath}/metadata.json`;
32
33
  const key = `${contentBusId}/${partition}${metadataPath}`;
33
34
  const ret = await state.s3Loader.getObject('helix-content-bus', key);
34
35
  if (ret.status === 200) {
@@ -33,26 +33,35 @@ export function mapPath(folders, path) {
33
33
  }
34
34
 
35
35
  /**
36
- * Checks the fstab for folder mapping entries and then re-adjusts the path infos if needed.
37
- * if the remapped resource is *not* extensionless, it will be declared as code-bus resource.
36
+ * Checks if the resource path is below a folder-mapped configuration and updates `state.mappedPath`
37
+ * accordingly.
38
38
  *
39
- * @type PipelineStep
40
- * @param {PipelineState} state
39
+ * @param state
41
40
  */
42
- export default function folderMapping(state) {
41
+ export function calculateFolderMapping(state) {
43
42
  const folders = state.helixConfig?.fstab?.data.folders;
44
43
  if (!folders) {
45
44
  return;
46
45
  }
47
46
  const { path } = state.info;
48
- const mapped = mapPath(folders, path);
49
- if (mapped) {
50
- state.info = getPathInfo(mapped);
47
+ state.mappedPath = mapPath(folders, path);
48
+ }
49
+
50
+ /**
51
+ * Applies folder mapping if the resource is mapped (i.e. if `state.mappedPath` is {@code true}.
52
+ *
53
+ * @type PipelineStep
54
+ * @param {PipelineState} state
55
+ */
56
+ export function applyFolderMapping(state) {
57
+ const { info: { path }, mappedPath } = state;
58
+ if (mappedPath) {
59
+ state.info = getPathInfo(mappedPath);
51
60
  state.info.unmappedPath = path;
52
- if (getExtension(mapped)) {
61
+ if (getExtension(mappedPath)) {
53
62
  // special case: use code-bus
54
63
  state.content.sourceBus = 'code';
55
- state.info.resourcePath = mapped;
64
+ state.info.resourcePath = mappedPath;
56
65
  state.log.info(`mapped ${path} to ${state.info.resourcePath} (code-bus)`);
57
66
  } else {
58
67
  state.mapped = true;