@adobe/helix-html-pipeline 6.17.0 → 6.17.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 CHANGED
@@ -1,3 +1,17 @@
1
+ ## [6.17.2](https://github.com/adobe/helix-html-pipeline/compare/v6.17.1...v6.17.2) (2024-12-14)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update external fixes ([#769](https://github.com/adobe/helix-html-pipeline/issues/769)) ([4a1952c](https://github.com/adobe/helix-html-pipeline/commit/4a1952c78e2d0b275bde7b7d9b73fd43f4d58c02))
7
+
8
+ ## [6.17.1](https://github.com/adobe/helix-html-pipeline/compare/v6.17.0...v6.17.1) (2024-12-04)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * apply folder-mapped metadata also for existing resources ([#765](https://github.com/adobe/helix-html-pipeline/issues/765)) ([e4feb9c](https://github.com/adobe/helix-html-pipeline/commit/e4feb9ce74801f428f4c50a393fce4824ede367d)), closes [#758](https://github.com/adobe/helix-html-pipeline/issues/758)
14
+
1
15
  # [6.17.0](https://github.com/adobe/helix-html-pipeline/compare/v6.16.0...v6.17.0) (2024-11-19)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-html-pipeline",
3
- "version": "6.17.0",
3
+ "version": "6.17.2",
4
4
  "description": "Helix HTML Pipeline",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -49,13 +49,13 @@
49
49
  "github-slugger": "2.0.0",
50
50
  "hast-util-raw": "9.1.0",
51
51
  "hast-util-select": "6.0.3",
52
- "hast-util-to-html": "9.0.3",
52
+ "hast-util-to-html": "9.0.4",
53
53
  "hast-util-to-string": "3.0.1",
54
54
  "hastscript": "9.0.0",
55
55
  "lodash.escape": "4.0.1",
56
56
  "mdast-util-to-hast": "13.2.0",
57
57
  "mdast-util-to-string": "4.0.0",
58
- "micromark-util-subtokenize": "2.0.1",
58
+ "micromark-util-subtokenize": "2.0.3",
59
59
  "mime": "4.0.4",
60
60
  "rehype-format": "5.0.1",
61
61
  "rehype-parse": "9.0.1",
@@ -75,18 +75,18 @@
75
75
  "@semantic-release/changelog": "6.0.3",
76
76
  "@semantic-release/git": "10.0.1",
77
77
  "@semantic-release/npm": "12.0.1",
78
- "c8": "10.1.2",
78
+ "c8": "10.1.3",
79
79
  "eslint": "8.57.1",
80
80
  "eslint-import-resolver-exports": "1.0.0-beta.5",
81
81
  "eslint-plugin-header": "3.1.1",
82
82
  "eslint-plugin-import": "2.31.0",
83
83
  "esmock": "2.6.9",
84
- "husky": "9.1.6",
84
+ "husky": "9.1.7",
85
85
  "js-yaml": "4.1.0",
86
86
  "jsdom": "25.0.1",
87
87
  "junit-report-builder": "5.1.1",
88
- "lint-staged": "15.2.10",
89
- "mocha": "10.8.2",
88
+ "lint-staged": "15.2.11",
89
+ "mocha": "11.0.1",
90
90
  "mocha-multi-reporters": "1.5.1",
91
91
  "mocha-suppress-logs": "0.5.1",
92
92
  "semantic-release": "24.2.0"
@@ -11,7 +11,7 @@
11
11
  */
12
12
  import {PathInfo, S3Loader, PipelineTimer } from "./index";
13
13
  import {PipelineContent} from "./PipelineContent";
14
- import {PipelineSiteConfig} from "./site-config";
14
+ import {ModifiersSheet, PipelineSiteConfig} from "./site-config";
15
15
 
16
16
  declare enum PipelineType {
17
17
  html = 'html',
@@ -117,5 +117,22 @@ declare class PipelineState {
117
117
  */
118
118
  liveHost: string;
119
119
 
120
+ /**
121
+ * specifies if the content as folder mapped (note that it remains false for content that
122
+ * exists below a folder mapped path. in this case, the `mappedPath` would still be different
123
+ * from the `info.path`
124
+ */
125
+ mapped: boolean;
126
+
127
+ /**
128
+ * the mapped path (target) of a folder mapping. this is set irrespective of the existence of the
129
+ * resource, when the path is below a folder mapped path
130
+ */
131
+ mappedPath: string;
132
+
133
+ /**
134
+ * metadata from folder mapping
135
+ */
136
+ mappedMetadata: Modifiers
120
137
  }
121
138
 
package/src/html-pipe.js CHANGED
@@ -18,7 +18,7 @@ import fetchContent from './steps/fetch-content.js';
18
18
  import fetch404 from './steps/fetch-404.js';
19
19
  import initConfig from './steps/init-config.js';
20
20
  import fixSections from './steps/fix-sections.js';
21
- import folderMapping from './steps/folder-mapping.js';
21
+ import { calculateFolderMapping, applyFolderMapping } from './steps/folder-mapping.js';
22
22
  import getMetadata from './steps/get-metadata.js';
23
23
  import html from './steps/make-html.js';
24
24
  import parseMarkdown from './steps/parse-markdown.js';
@@ -110,7 +110,7 @@ export async function htmlPipe(state, req) {
110
110
  state.content.sourceBus = 'code';
111
111
  }
112
112
 
113
- // ...and apply the folder mapping
113
+ calculateFolderMapping(state);
114
114
  state.timer?.update('content-fetch');
115
115
  let contentPromise = await fetchContent(state, req, res);
116
116
  if (res.status === 404) {
@@ -119,7 +119,7 @@ export async function htmlPipe(state, req) {
119
119
  contentPromise = fetchContentRedirectWith404Fallback(state, req, res);
120
120
  } else {
121
121
  // ...apply folder mapping if the current resource doesn't exist
122
- await folderMapping(state);
122
+ applyFolderMapping(state);
123
123
  if (state.info.unmappedPath) {
124
124
  contentPromise = fetchContentWith404Fallback(state, req, res);
125
125
  } else {
@@ -174,7 +174,7 @@ export default function extractMetaData(state, req) {
174
174
  // with local metadata from document
175
175
  const metaConfig = Object.assign(
176
176
  state.metadata.getModifiers(state.info.unmappedPath || state.info.path),
177
- state.mappedMetadata.getModifiers(state.info.unmappedPath),
177
+ state.mappedMetadata.getModifiers(state.info.unmappedPath || state.info.path),
178
178
  );
179
179
 
180
180
  // prune empty values and explicit "" strings from sheet based metadata
@@ -26,11 +26,12 @@ import { Modifiers } from '../utils/modifiers.js';
26
26
  // eslint-disable-next-line no-unused-vars
27
27
  export default async function fetchMappedMetadata(state, res) {
28
28
  state.mappedMetadata = Modifiers.EMPTY;
29
- if (!state.mapped) {
29
+ const { mappedPath } = state;
30
+ if (!mappedPath) {
30
31
  return;
31
32
  }
32
33
  const { contentBusId, partition } = state;
33
- const metadataPath = `${state.info.path}/metadata.json`;
34
+ const metadataPath = `${mappedPath}/metadata.json`;
34
35
  const key = `${contentBusId}/${partition}${metadataPath}`;
35
36
  const ret = await state.s3Loader.getObject('helix-content-bus', key);
36
37
  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.config;
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;