@adobe/helix-html-pipeline 3.11.24 → 3.12.0
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/PipelineState.d.ts +14 -8
- package/src/project-config.d.ts +157 -0
- package/src/steps/fetch-config-all.js +12 -0
- package/src/steps/utils.js +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [3.12.0](https://github.com/adobe/helix-html-pipeline/compare/v3.11.24...v3.12.0) (2023-07-25)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* also rewrite custom preview and live host links ([#367](https://github.com/adobe/helix-html-pipeline/issues/367)) ([#368](https://github.com/adobe/helix-html-pipeline/issues/368)) ([0127e72](https://github.com/adobe/helix-html-pipeline/commit/0127e720f67fcbd41bc862b26f0e5c42e3979e57)), closes [#359](https://github.com/adobe/helix-html-pipeline/issues/359)
|
|
7
|
+
|
|
1
8
|
## [3.11.24](https://github.com/adobe/helix-html-pipeline/compare/v3.11.23...v3.11.24) (2023-07-23)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/PipelineState.d.ts
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import {PathInfo, S3Loader, FormsMessageDispatcher, PipelineTimer} from "./index";
|
|
13
13
|
import {PipelineContent} from "./PipelineContent";
|
|
14
14
|
import {Modifiers} from './utils/modifiers';
|
|
15
|
+
import {ProjectConfig} from "./project-config";
|
|
15
16
|
|
|
16
17
|
declare enum PipelineType {
|
|
17
18
|
html = 'html',
|
|
@@ -29,13 +30,6 @@ declare interface AccessConfig {
|
|
|
29
30
|
};
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
declare interface HelixConfigAll {
|
|
33
|
-
host:string;
|
|
34
|
-
routes:RegExp[];
|
|
35
|
-
access?:AccessConfig;
|
|
36
|
-
[string]:any;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
33
|
declare interface PipelineOptions {
|
|
40
34
|
log: Console;
|
|
41
35
|
s3Loader: S3Loader;
|
|
@@ -97,7 +91,7 @@ declare class PipelineState {
|
|
|
97
91
|
/**
|
|
98
92
|
* the /.helix/config.json in object form
|
|
99
93
|
*/
|
|
100
|
-
config?:
|
|
94
|
+
config?: ProjectConfig;
|
|
101
95
|
|
|
102
96
|
/**
|
|
103
97
|
* the metadata.json in modifier form.
|
|
@@ -123,5 +117,17 @@ declare class PipelineState {
|
|
|
123
117
|
* Authentication information
|
|
124
118
|
*/
|
|
125
119
|
authInfo?: AuthInfo;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* the custom preview host if configured via config.cdn.preview.host
|
|
123
|
+
* this is initialized after the config is loaded.
|
|
124
|
+
*/
|
|
125
|
+
previewHost?: string;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* the custom live host if configured via config.cdn.live.host
|
|
129
|
+
* this is initialized after the config is loaded.
|
|
130
|
+
*/
|
|
131
|
+
liveHost?: string;
|
|
126
132
|
}
|
|
127
133
|
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 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
|
+
// NOTE: this file is autogenerated via 'npm run docs:types' in helix-admin-support
|
|
14
|
+
|
|
15
|
+
export interface ProjectConfig {
|
|
16
|
+
/**
|
|
17
|
+
* Name of the project used by the slack bot when reporting.
|
|
18
|
+
*/
|
|
19
|
+
name?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Name of the project used by the sidekick.
|
|
22
|
+
*/
|
|
23
|
+
project?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Timezone to be used by the slack bot when reporting times.
|
|
26
|
+
*/
|
|
27
|
+
timezone?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Production host use by the slack bot to display project information.
|
|
30
|
+
*/
|
|
31
|
+
host?: string;
|
|
32
|
+
/**
|
|
33
|
+
* configuration blueprint repository in the owner/repo format.
|
|
34
|
+
*/
|
|
35
|
+
blueprint?: string;
|
|
36
|
+
/**
|
|
37
|
+
* the slack teamId/channelID(s) where the slack bot is used.
|
|
38
|
+
*/
|
|
39
|
+
slack?: string | string[];
|
|
40
|
+
cdn?: ProjectCDNConfig;
|
|
41
|
+
access?: SiteAccessConfig;
|
|
42
|
+
admin?: AdminConfig;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The CDN config
|
|
46
|
+
*/
|
|
47
|
+
export interface ProjectCDNConfig {
|
|
48
|
+
prod: FastlyConfig | AkamaiConfig | CloudflareConfig | ManagedConfig;
|
|
49
|
+
live?: {
|
|
50
|
+
/**
|
|
51
|
+
* Sidekick config to override the default preview host. it supports parameters $owner and $repo
|
|
52
|
+
*/
|
|
53
|
+
host: string;
|
|
54
|
+
};
|
|
55
|
+
preview?: {
|
|
56
|
+
/**
|
|
57
|
+
* Sidekick config to override the default live host. it supports parameters $owner and $repo
|
|
58
|
+
*/
|
|
59
|
+
host: string;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Production CDN configuration for Fastly
|
|
64
|
+
*/
|
|
65
|
+
export interface FastlyConfig {
|
|
66
|
+
type: 'fastly';
|
|
67
|
+
/**
|
|
68
|
+
* production host
|
|
69
|
+
*/
|
|
70
|
+
host: string;
|
|
71
|
+
/**
|
|
72
|
+
* Route or routes on the CDN that are rendered with Franklin
|
|
73
|
+
*/
|
|
74
|
+
route: string | string[];
|
|
75
|
+
/**
|
|
76
|
+
* The Fastly Service ID
|
|
77
|
+
*/
|
|
78
|
+
serviceId: string;
|
|
79
|
+
/**
|
|
80
|
+
* A Fastly token for purging
|
|
81
|
+
*/
|
|
82
|
+
authToken: string;
|
|
83
|
+
}
|
|
84
|
+
export interface AkamaiConfig {
|
|
85
|
+
type: 'akamai';
|
|
86
|
+
/**
|
|
87
|
+
* production host
|
|
88
|
+
*/
|
|
89
|
+
host: string;
|
|
90
|
+
/**
|
|
91
|
+
* Route or routes on the CDN that are rendered with Franklin
|
|
92
|
+
*/
|
|
93
|
+
route: string | string[];
|
|
94
|
+
endpoint: string;
|
|
95
|
+
clientSecret: string;
|
|
96
|
+
clientToken: string;
|
|
97
|
+
accessToken: string;
|
|
98
|
+
}
|
|
99
|
+
export interface CloudflareConfig {
|
|
100
|
+
type: 'cloudflare';
|
|
101
|
+
/**
|
|
102
|
+
* production host
|
|
103
|
+
*/
|
|
104
|
+
host: string;
|
|
105
|
+
/**
|
|
106
|
+
* Route or routes on the CDN that are rendered with Franklin
|
|
107
|
+
*/
|
|
108
|
+
route: string | string[];
|
|
109
|
+
origin: string;
|
|
110
|
+
plan: string;
|
|
111
|
+
zoneId: string;
|
|
112
|
+
apiToken: string;
|
|
113
|
+
}
|
|
114
|
+
export interface ManagedConfig {
|
|
115
|
+
type: 'managed';
|
|
116
|
+
/**
|
|
117
|
+
* production host
|
|
118
|
+
*/
|
|
119
|
+
host: string;
|
|
120
|
+
/**
|
|
121
|
+
* Route or routes on the CDN that are rendered with Franklin
|
|
122
|
+
*/
|
|
123
|
+
route: string | string[];
|
|
124
|
+
}
|
|
125
|
+
export interface SiteAccessConfig {
|
|
126
|
+
/**
|
|
127
|
+
* The email glob of the users that are allowed.
|
|
128
|
+
*/
|
|
129
|
+
allow: string | string[];
|
|
130
|
+
/**
|
|
131
|
+
* the id of the API key(s). this is used to validate the API KEYS and allows to invalidate them.
|
|
132
|
+
*/
|
|
133
|
+
apiKeyId?: string | string[];
|
|
134
|
+
require?: {
|
|
135
|
+
/**
|
|
136
|
+
* The list of owner/repo pointers to projects that are allowed to use this content.
|
|
137
|
+
*/
|
|
138
|
+
repository: string | string[];
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
export interface AdminConfig {
|
|
142
|
+
role?: Role;
|
|
143
|
+
/**
|
|
144
|
+
* the id of the API key(s). this is used to validate the API KEYS and allows to invalidate them.
|
|
145
|
+
*/
|
|
146
|
+
apiKeyId?: string | string[];
|
|
147
|
+
}
|
|
148
|
+
export interface Role {
|
|
149
|
+
/**
|
|
150
|
+
* The email glob of the users with author role.
|
|
151
|
+
*/
|
|
152
|
+
author?: string | string[];
|
|
153
|
+
/**
|
|
154
|
+
* The email glob of the users with publish role.
|
|
155
|
+
*/
|
|
156
|
+
publish?: string | string[];
|
|
157
|
+
}
|
|
@@ -87,6 +87,15 @@ export function computeRoutes(value) {
|
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
function replaceParams(str, info) {
|
|
91
|
+
if (!str) {
|
|
92
|
+
return '';
|
|
93
|
+
}
|
|
94
|
+
return str
|
|
95
|
+
.replaceAll('$owner', info.owner)
|
|
96
|
+
.replaceAll('$repo', info.repo);
|
|
97
|
+
}
|
|
98
|
+
|
|
90
99
|
/**
|
|
91
100
|
* Loads the /.helix/config-all.json from the content-bus and stores it in the state. if no
|
|
92
101
|
* such config exists, it will load the metadata.json as fallback and separate out the
|
|
@@ -117,6 +126,9 @@ export default async function fetchConfigAll(state, req, res) {
|
|
|
117
126
|
// also update last-modified (only for extensionless html pipeline)
|
|
118
127
|
updateLastModified(state, res, extractLastModified(ret.headers));
|
|
119
128
|
}
|
|
129
|
+
// set custom preview and live hosts
|
|
130
|
+
state.previewHost = replaceParams(state.config.cdn?.preview?.host, state);
|
|
131
|
+
state.liveHost = replaceParams(state.config.cdn?.live?.host, state);
|
|
120
132
|
} else if (ret.status !== 404) {
|
|
121
133
|
throw new PipelineStatusError(502, `failed to load /.helix/config-all.json: ${ret.status}`);
|
|
122
134
|
} else {
|
package/src/steps/utils.js
CHANGED
|
@@ -186,7 +186,9 @@ export function rewriteUrl(state, url) {
|
|
|
186
186
|
return url;
|
|
187
187
|
}
|
|
188
188
|
try {
|
|
189
|
-
const {
|
|
189
|
+
const {
|
|
190
|
+
host, pathname, search, hash,
|
|
191
|
+
} = new URL(url);
|
|
190
192
|
|
|
191
193
|
if (AZURE_BLOB_REGEXP.test(url)) {
|
|
192
194
|
const filename = pathname.split('/').pop();
|
|
@@ -200,7 +202,9 @@ export function rewriteUrl(state, url) {
|
|
|
200
202
|
return `.${pathname}${hash}`;
|
|
201
203
|
}
|
|
202
204
|
|
|
203
|
-
if (HELIX_URL_REGEXP.test(url)
|
|
205
|
+
if (HELIX_URL_REGEXP.test(url)
|
|
206
|
+
|| host === state.previewHost
|
|
207
|
+
|| host === state.liveHost) {
|
|
204
208
|
if (hash && pathname === state.info?.path) {
|
|
205
209
|
return hash;
|
|
206
210
|
}
|