@adobe/helix-deploy 11.1.15 → 12.0.0-pre.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/index.js +2 -1
- package/package.json +2 -12
- package/params.json +3 -0
- package/src/ActionBuilder.js +20 -19
- package/src/BaseConfig.js +9 -3
- package/src/bundler/BaseBundler.js +6 -16
- package/src/bundler/WebpackBundler.js +12 -1
- package/src/cli.js +59 -13
- package/src/bundler/EdgeBundler.js +0 -132
- package/src/deploy/CloudflareConfig.js +0 -74
- package/src/deploy/CloudflareDeployer.js +0 -178
- package/src/deploy/ComputeAtEdgeConfig.js +0 -91
- package/src/deploy/ComputeAtEdgeDeployer.js +0 -185
- package/src/gateway/FastlyConfig.js +0 -96
- package/src/gateway/FastlyGateway.js +0 -525
- package/src/template/adapter-utils.js +0 -17
- package/src/template/cloudflare-adapter.js +0 -65
- package/src/template/fastly-adapter.js +0 -128
- package/src/template/polyfills/fetch.js +0 -20
- package/src/template/serviceworker-index.js +0 -26
|
@@ -1,128 +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
|
-
/* eslint-env serviceworker */
|
|
13
|
-
/* global Dictionary */
|
|
14
|
-
|
|
15
|
-
import { extractPathFromURL } from './adapter-utils.js';
|
|
16
|
-
|
|
17
|
-
export function getEnvInfo(req, env) {
|
|
18
|
-
const serviceVersion = env('FASTLY_SERVICE_VERSION');
|
|
19
|
-
const requestId = env('FASTLY_TRACE_ID');
|
|
20
|
-
const region = env('FASTLY_POP');
|
|
21
|
-
const functionName = env('FASTLY_SERVICE_ID');
|
|
22
|
-
const functionFQN = `${env('FASTLY_CUSTOMER_ID')}-${functionName}-${serviceVersion}`;
|
|
23
|
-
const txId = req.headers.get('x-transaction-id') ?? env('FASTLY_TRACE_ID');
|
|
24
|
-
|
|
25
|
-
console.debug('Env info sv: ', serviceVersion, ' reqId: ', requestId, ' region: ', region, ' functionName: ', functionName, ' functionFQN: ', functionFQN, ' txId: ', txId);
|
|
26
|
-
|
|
27
|
-
return {
|
|
28
|
-
functionFQN,
|
|
29
|
-
functionName,
|
|
30
|
-
region,
|
|
31
|
-
requestId,
|
|
32
|
-
serviceVersion,
|
|
33
|
-
txId,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async function getEnvironmentInfo(req) {
|
|
38
|
-
// The fastly:env import will be available in the fastly c@e environment
|
|
39
|
-
/* eslint-disable-next-line import/no-unresolved */
|
|
40
|
-
const mod = await import('fastly:env');
|
|
41
|
-
return getEnvInfo(req, mod.env);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async function handler(event) {
|
|
45
|
-
try {
|
|
46
|
-
const { request } = event;
|
|
47
|
-
const env = await getEnvironmentInfo(request);
|
|
48
|
-
|
|
49
|
-
console.log('Fastly Adapter is here');
|
|
50
|
-
let packageParams;
|
|
51
|
-
// eslint-disable-next-line import/no-unresolved,global-require
|
|
52
|
-
const { main } = require('./main.js');
|
|
53
|
-
const context = {
|
|
54
|
-
resolver: null,
|
|
55
|
-
pathInfo: {
|
|
56
|
-
suffix: extractPathFromURL(request),
|
|
57
|
-
},
|
|
58
|
-
runtime: {
|
|
59
|
-
name: 'compute-at-edge',
|
|
60
|
-
region: env.region,
|
|
61
|
-
},
|
|
62
|
-
func: {
|
|
63
|
-
name: env.functionName,
|
|
64
|
-
package: null,
|
|
65
|
-
version: env.serviceVersion,
|
|
66
|
-
fqn: env.functionFQN,
|
|
67
|
-
app: null,
|
|
68
|
-
},
|
|
69
|
-
invocation: {
|
|
70
|
-
id: null,
|
|
71
|
-
deadline: null,
|
|
72
|
-
transactionId: env.txId,
|
|
73
|
-
requestId: env.requestId,
|
|
74
|
-
},
|
|
75
|
-
env: new Proxy(new Dictionary('secrets'), {
|
|
76
|
-
get: (target, prop) => {
|
|
77
|
-
try {
|
|
78
|
-
return target.get(prop);
|
|
79
|
-
} catch {
|
|
80
|
-
if (packageParams) {
|
|
81
|
-
console.log('Using cached params');
|
|
82
|
-
return packageParams[prop];
|
|
83
|
-
}
|
|
84
|
-
const url = target.get('_package');
|
|
85
|
-
const token = target.get('_token');
|
|
86
|
-
// console.log(`Getting secrets from ${url} with ${token}`);
|
|
87
|
-
return fetch(url, {
|
|
88
|
-
backend: 'gateway',
|
|
89
|
-
headers: {
|
|
90
|
-
authorization: `Bearer ${token}`,
|
|
91
|
-
},
|
|
92
|
-
}).then((response) => {
|
|
93
|
-
if (response.ok) {
|
|
94
|
-
// console.log('response is ok...');
|
|
95
|
-
return response.text().then((json) => {
|
|
96
|
-
// console.log('json received: ' + json);
|
|
97
|
-
packageParams = JSON.parse(json);
|
|
98
|
-
return packageParams[prop];
|
|
99
|
-
}).catch((error) => {
|
|
100
|
-
console.error(`Unable to parse JSON: ${error.message}`);
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
console.error(`HTTP status is not ok: ${response.status}`);
|
|
104
|
-
return undefined;
|
|
105
|
-
}).catch((err) => {
|
|
106
|
-
console.error(`Unable to fetch parames: ${err.message}`);
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
}),
|
|
111
|
-
storage: null,
|
|
112
|
-
};
|
|
113
|
-
const response = await main(request, context);
|
|
114
|
-
return response;
|
|
115
|
-
} catch (e) {
|
|
116
|
-
console.log(e.message);
|
|
117
|
-
return new Response(`Error: ${e.message}`, { status: 500 });
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export default function fastly() {
|
|
122
|
-
console.log('checking for fastly environment');
|
|
123
|
-
/* eslint-disable-next-line no-undef */
|
|
124
|
-
if (CacheOverride) {
|
|
125
|
-
return handler;
|
|
126
|
-
}
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
@@ -1,20 +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
|
-
/* eslint-env serviceworker */
|
|
13
|
-
|
|
14
|
-
module.exports = {
|
|
15
|
-
// replacing @adobe/fetch with the built-in APIs
|
|
16
|
-
fetch,
|
|
17
|
-
Request,
|
|
18
|
-
Response,
|
|
19
|
-
Headers,
|
|
20
|
-
};
|
|
@@ -1,26 +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
|
-
/* eslint-env serviceworker */
|
|
13
|
-
|
|
14
|
-
import fastly from './fastly-adapter.js';
|
|
15
|
-
|
|
16
|
-
const cloudflare = require('./cloudflare-adapter.js');
|
|
17
|
-
|
|
18
|
-
/* eslint-disable no-restricted-globals */
|
|
19
|
-
if (typeof addEventListener === 'function') {
|
|
20
|
-
addEventListener('fetch', (event) => {
|
|
21
|
-
const handler = cloudflare() || fastly();
|
|
22
|
-
if (typeof handler === 'function') {
|
|
23
|
-
event.respondWith(handler(event));
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}
|