@adobe/helix-html-pipeline 1.0.0 → 1.0.1
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 +7 -0
- package/package.json +1 -1
- package/src/html-pipe.js +10 -0
- package/src/steps/fetch-content.js +3 -3
- package/src/steps/folder-mapping.js +2 -2
- package/test/StaticS3Loader.js +45 -0
- package/.eslintrc.cjs +0 -33
- package/.husky/pre-commit +0 -4
- package/.mocha-multi.json +0 -6
- package/.nycrc.json +0 -10
- package/.releaserc.cjs +0 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.0.1](https://github.com/adobe/helix-html-pipeline/compare/v1.0.0...v1.0.1) (2022-03-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* include static s3 loader ([0a89e2f](https://github.com/adobe/helix-html-pipeline/commit/0a89e2fda5d6a8ab3e67724fd0b436c8b1aa6e58))
|
|
7
|
+
|
|
1
8
|
# 1.0.0 (2022-03-07)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/html-pipe.js
CHANGED
|
@@ -33,6 +33,7 @@ import splitSections from './steps/split-sections.js';
|
|
|
33
33
|
import tohtml from './steps/stringify-response.js';
|
|
34
34
|
import { PipelineStatusError } from './PipelineStatusError.js';
|
|
35
35
|
import { PipelineResponse } from './PipelineResponse.js';
|
|
36
|
+
import { validatePathInfo } from './utils/path.js';
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
39
|
* Runs the default pipeline and returns the response.
|
|
@@ -43,6 +44,15 @@ import { PipelineResponse } from './PipelineResponse.js';
|
|
|
43
44
|
export async function htmlPipe(state, req) {
|
|
44
45
|
const { log } = state;
|
|
45
46
|
|
|
47
|
+
if (!validatePathInfo(state.info)) {
|
|
48
|
+
return new PipelineResponse('', {
|
|
49
|
+
status: 404,
|
|
50
|
+
headers: {
|
|
51
|
+
'x-error': 'invalid path',
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
46
56
|
/** @type PipelineResponse */
|
|
47
57
|
const res = new PipelineResponse();
|
|
48
58
|
|
|
@@ -26,7 +26,7 @@ export default async function fetchContent(state, req, res) {
|
|
|
26
26
|
|
|
27
27
|
const isCode = state.content.sourceBus === 'code';
|
|
28
28
|
const key = isCode
|
|
29
|
-
? `${owner}/${repo}/${ref}
|
|
29
|
+
? `${owner}/${repo}/${ref}${info.resourcePath}`
|
|
30
30
|
: `${contentBusId}/${partition}${info.resourcePath}`;
|
|
31
31
|
const bucketId = isCode ? 'helix-code-bus' : 'helix-content-bus';
|
|
32
32
|
|
|
@@ -55,12 +55,12 @@ export default async function fetchContent(state, req, res) {
|
|
|
55
55
|
// (https://github.com/adobe/helix-pipeline-service/issues/290)
|
|
56
56
|
if (state.info.originalFilename === 'index') {
|
|
57
57
|
res.status = 404;
|
|
58
|
-
res.error = `request to ${info.
|
|
58
|
+
res.error = `request to ${info.resourcePath} not allowed (no-index).`;
|
|
59
59
|
}
|
|
60
60
|
} else {
|
|
61
61
|
// keep 404, but propagate others as 502
|
|
62
62
|
res.status = ret.status === 404 ? 404 : 502;
|
|
63
|
-
res.error = `failed to load ${info.
|
|
63
|
+
res.error = `failed to load ${info.resourcePath} from ${state.content.sourceBus}-bus: ${ret.status}`;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
if (res.status === 404) {
|
|
@@ -53,9 +53,9 @@ export default function folderMapping(state) {
|
|
|
53
53
|
// special case: use code-bus
|
|
54
54
|
state.content.sourceBus = 'code';
|
|
55
55
|
state.info.resourcePath = mapped;
|
|
56
|
-
state.log.info(`mapped ${path} to ${state.info.resourcePath} (
|
|
56
|
+
state.log.info(`mapped ${path} to ${state.info.resourcePath} (code-bus)`);
|
|
57
57
|
} else {
|
|
58
|
-
state.log.info(`mapped ${path} to ${state.info.path} (
|
|
58
|
+
state.log.info(`mapped ${path} to ${state.info.path} (content-bus)`);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* @implements S3Loader
|
|
14
|
+
*/
|
|
15
|
+
export class StaticS3Loader {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.buckets = {};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
reply(bucketId, key, response) {
|
|
21
|
+
let bucket = this.buckets[bucketId];
|
|
22
|
+
if (!bucket) {
|
|
23
|
+
bucket = {};
|
|
24
|
+
this.buckets[bucketId] = bucket;
|
|
25
|
+
}
|
|
26
|
+
bucket[key] = response;
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async getObject(bucketId, key) {
|
|
31
|
+
const bucket = this.buckets[bucketId];
|
|
32
|
+
const response = bucket?.[key] ?? {
|
|
33
|
+
status: 404,
|
|
34
|
+
body: '',
|
|
35
|
+
headers: new Map(),
|
|
36
|
+
};
|
|
37
|
+
// eslint-disable-next-line no-console
|
|
38
|
+
console.log(`StaticS3Loader: loading ${bucketId}/${key} -> ${response.status}`);
|
|
39
|
+
return response;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async headObject(bucketId, key) {
|
|
43
|
+
return this.getObject(bucketId, key);
|
|
44
|
+
}
|
|
45
|
+
}
|
package/.eslintrc.cjs
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2021 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
module.exports = {
|
|
14
|
-
root: true,
|
|
15
|
-
extends: '@adobe/helix',
|
|
16
|
-
env: {
|
|
17
|
-
node: true,
|
|
18
|
-
es6: true,
|
|
19
|
-
},
|
|
20
|
-
parserOptions: {
|
|
21
|
-
sourceType: 'module',
|
|
22
|
-
ecmaVersion: 2020,
|
|
23
|
-
},
|
|
24
|
-
rules: {
|
|
25
|
-
'import/extensions': [2, 'ignorePackages'],
|
|
26
|
-
'import/prefer-default-export': 0,
|
|
27
|
-
'no-param-reassign': ['error', { props: false }],
|
|
28
|
-
},
|
|
29
|
-
globals: {
|
|
30
|
-
__rootdir: true,
|
|
31
|
-
__testdir: true,
|
|
32
|
-
},
|
|
33
|
-
};
|
package/.husky/pre-commit
DELETED
package/.mocha-multi.json
DELETED
package/.nycrc.json
DELETED
package/.releaserc.cjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
plugins: [
|
|
3
|
-
"@semantic-release/commit-analyzer",
|
|
4
|
-
"@semantic-release/release-notes-generator",
|
|
5
|
-
["@semantic-release/changelog", {
|
|
6
|
-
"changelogFile": "CHANGELOG.md",
|
|
7
|
-
}],
|
|
8
|
-
"@semantic-release/npm",
|
|
9
|
-
["@semantic-release/git", {
|
|
10
|
-
"assets": ["package.json", "CHANGELOG.md"],
|
|
11
|
-
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
|
|
12
|
-
}],
|
|
13
|
-
["@semantic-release/github", {}]
|
|
14
|
-
],
|
|
15
|
-
branches: ['main'],
|
|
16
|
-
};
|