@adobe/helix-deploy 4.13.0 → 4.15.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 +56 -0
- package/README.md +1 -1
- package/index.js +1 -1
- package/package.json +20 -15
- package/src/ActionBuilder.js +70 -28
- package/src/BaseConfig.js +30 -1
- package/src/DevelopmentServer.js +10 -4
- package/src/{BaseBundler.js → bundler/BaseBundler.js} +13 -4
- package/src/bundler/EdgeBundler.js +118 -0
- package/src/{RollupBundler.js → bundler/RollupBundler.js} +2 -2
- package/src/{Bundler.js → bundler/WebpackBundler.js} +13 -8
- package/src/cli.js +4 -0
- package/src/deploy/BaseDeployer.js +5 -0
- package/src/deploy/CloudflareConfig.js +71 -0
- package/src/deploy/CloudflareDeployer.js +145 -0
- package/src/deploy/ComputeAtEdgeConfig.js +93 -0
- package/src/deploy/ComputeAtEdgeDeployer.js +190 -0
- package/src/deploy/GoogleDeployer.js +15 -19
- package/src/gateway/FastlyGateway.js +245 -166
- package/src/template/cloudflare-adapter.js +62 -0
- package/src/template/fastly-adapter.js +99 -0
- package/src/template/{index.js → node-index.js} +0 -1
- package/src/template/{index.mjs → node-index.mjs} +0 -0
- package/src/template/polyfills/helix-fetch.js +19 -0
- package/src/template/serviceworker-index.js +24 -0
|
@@ -0,0 +1,99 @@
|
|
|
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
|
+
/* eslint-env serviceworker */
|
|
13
|
+
/* global Dictionary */
|
|
14
|
+
|
|
15
|
+
async function handler(event) {
|
|
16
|
+
try {
|
|
17
|
+
const { request } = event;
|
|
18
|
+
console.log('Fastly Adapter is here');
|
|
19
|
+
let packageParams;
|
|
20
|
+
// eslint-disable-next-line import/no-unresolved,global-require
|
|
21
|
+
const { main } = require('./main.js');
|
|
22
|
+
const context = {
|
|
23
|
+
resolver: null,
|
|
24
|
+
pathInfo: {
|
|
25
|
+
suffix: request.url.replace(/\?.*/, ''),
|
|
26
|
+
},
|
|
27
|
+
runtime: {
|
|
28
|
+
name: 'compute-at-edge',
|
|
29
|
+
// region: request.cf.colo,
|
|
30
|
+
},
|
|
31
|
+
func: {
|
|
32
|
+
name: null,
|
|
33
|
+
package: null,
|
|
34
|
+
version: null,
|
|
35
|
+
fqn: null,
|
|
36
|
+
app: null,
|
|
37
|
+
},
|
|
38
|
+
invocation: {
|
|
39
|
+
id: null,
|
|
40
|
+
deadline: null,
|
|
41
|
+
transactionId: null,
|
|
42
|
+
requestId: null,
|
|
43
|
+
},
|
|
44
|
+
env: new Proxy(new Dictionary('secrets'), {
|
|
45
|
+
get: (target, prop) => {
|
|
46
|
+
try {
|
|
47
|
+
return target.get(prop);
|
|
48
|
+
} catch {
|
|
49
|
+
if (packageParams) {
|
|
50
|
+
console.log('Using cached params');
|
|
51
|
+
return packageParams[prop];
|
|
52
|
+
}
|
|
53
|
+
const url = target.get('_package');
|
|
54
|
+
const token = target.get('_token');
|
|
55
|
+
// console.log(`Getting secrets from ${url} with ${token}`);
|
|
56
|
+
return fetch(url, {
|
|
57
|
+
backend: 'gateway',
|
|
58
|
+
headers: {
|
|
59
|
+
authorization: `Bearer ${token}`,
|
|
60
|
+
},
|
|
61
|
+
}).then((response) => {
|
|
62
|
+
if (response.ok) {
|
|
63
|
+
// console.log('response is ok...');
|
|
64
|
+
return response.text().then((json) => {
|
|
65
|
+
// console.log('json received: ' + json);
|
|
66
|
+
packageParams = JSON.parse(json);
|
|
67
|
+
return packageParams[prop];
|
|
68
|
+
}).catch((error) => {
|
|
69
|
+
console.error(`Unable to parse JSON: ${error.message}`);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
console.error(`HTTP status is not ok: ${response.status}`);
|
|
73
|
+
return undefined;
|
|
74
|
+
}).catch((err) => {
|
|
75
|
+
console.error(`Unable to fetch parames: ${err.message}`);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
}),
|
|
80
|
+
storage: null,
|
|
81
|
+
};
|
|
82
|
+
const response = await main(request, context);
|
|
83
|
+
return response;
|
|
84
|
+
} catch (e) {
|
|
85
|
+
console.log(e.message);
|
|
86
|
+
return new Response(`Error: ${e.message}`, { status: 500 });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function fastly() {
|
|
91
|
+
console.log('checking for fastly environment');
|
|
92
|
+
/* eslint-disable-next-line no-undef */
|
|
93
|
+
if (CacheOverride) {
|
|
94
|
+
return handler;
|
|
95
|
+
}
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
module.exports = fastly;
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
/* eslint-env serviceworker */
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
// replacing helix-fetch with the built-in APIs
|
|
16
|
+
fetch,
|
|
17
|
+
Request,
|
|
18
|
+
Response,
|
|
19
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
/* eslint-env serviceworker */
|
|
13
|
+
const fastly = require('./fastly-adapter');
|
|
14
|
+
const cloudflare = require('./cloudflare-adapter');
|
|
15
|
+
|
|
16
|
+
/* eslint-disable no-restricted-globals */
|
|
17
|
+
if (typeof addEventListener === 'function') {
|
|
18
|
+
addEventListener('fetch', (event) => {
|
|
19
|
+
const handler = cloudflare() || fastly();
|
|
20
|
+
if (typeof handler === 'function') {
|
|
21
|
+
event.respondWith(handler(event));
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|