@astrojs/cloudflare 8.1.0 → 9.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.
|
@@ -26,7 +26,7 @@ export function createExports(manifest) {
|
|
|
26
26
|
caches: caches,
|
|
27
27
|
},
|
|
28
28
|
};
|
|
29
|
-
const response = await app.render(request, routeData, locals);
|
|
29
|
+
const response = await app.render(request, { routeData, locals });
|
|
30
30
|
if (app.setCookieHeaders) {
|
|
31
31
|
for (const setCookieHeader of app.setCookieHeaders(response)) {
|
|
32
32
|
response.headers.append('Set-Cookie', setCookieHeader);
|
|
@@ -28,7 +28,7 @@ export function createExports(manifest) {
|
|
|
28
28
|
caches: caches,
|
|
29
29
|
},
|
|
30
30
|
};
|
|
31
|
-
const response = await app.render(request, routeData, locals);
|
|
31
|
+
const response = await app.render(request, { routeData, locals });
|
|
32
32
|
if (app.setCookieHeaders) {
|
|
33
33
|
for (const setCookieHeader of app.setCookieHeaders(response)) {
|
|
34
34
|
response.headers.append('Set-Cookie', setCookieHeader);
|
package/dist/index.js
CHANGED
|
@@ -417,21 +417,39 @@ export default function createIntegration(args) {
|
|
|
417
417
|
include: ['/*'],
|
|
418
418
|
exclude: deduplicatePatterns(staticPathList.concat(args?.routes?.exclude ?? [])),
|
|
419
419
|
};
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
420
|
+
switch (args?.routes?.strategy) {
|
|
421
|
+
case 'include':
|
|
422
|
+
await fs.promises.writeFile(new URL('./_routes.json', _config.outDir), JSON.stringify({
|
|
423
|
+
version: 1,
|
|
424
|
+
...includeStrategy,
|
|
425
|
+
}, null, 2));
|
|
426
|
+
break;
|
|
427
|
+
case 'exclude':
|
|
428
|
+
await fs.promises.writeFile(new URL('./_routes.json', _config.outDir), JSON.stringify({
|
|
429
|
+
version: 1,
|
|
430
|
+
...excludeStrategy,
|
|
431
|
+
}, null, 2));
|
|
432
|
+
break;
|
|
433
|
+
default:
|
|
434
|
+
{
|
|
435
|
+
const includeStrategyLength = includeStrategy
|
|
436
|
+
? includeStrategy.include.length + includeStrategy.exclude.length
|
|
437
|
+
: Infinity;
|
|
438
|
+
const excludeStrategyLength = excludeStrategy
|
|
439
|
+
? excludeStrategy.include.length + excludeStrategy.exclude.length
|
|
440
|
+
: Infinity;
|
|
441
|
+
const winningStrategy = notFoundIsSSR
|
|
442
|
+
? excludeStrategy
|
|
443
|
+
: includeStrategyLength <= excludeStrategyLength
|
|
444
|
+
? includeStrategy
|
|
445
|
+
: excludeStrategy;
|
|
446
|
+
await fs.promises.writeFile(new URL('./_routes.json', _config.outDir), JSON.stringify({
|
|
447
|
+
version: 1,
|
|
448
|
+
...winningStrategy,
|
|
449
|
+
}, null, 2));
|
|
450
|
+
}
|
|
451
|
+
break;
|
|
452
|
+
}
|
|
435
453
|
}
|
|
436
454
|
},
|
|
437
455
|
},
|
|
@@ -9,15 +9,17 @@ export function deduplicatePatterns(patterns) {
|
|
|
9
9
|
const openPatterns = [];
|
|
10
10
|
// A value in the set may only occur once; it is unique in the set's collection.
|
|
11
11
|
// ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
12
|
-
|
|
12
|
+
const uniquePatterns = [...new Set(patterns)];
|
|
13
|
+
for (const pattern of uniquePatterns) {
|
|
14
|
+
if (pattern.endsWith('*')) {
|
|
15
|
+
openPatterns.push(new RegExp(`^${pattern.replace(/(\*\/)*\*$/g, '[^*\n]*$')}`));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return uniquePatterns
|
|
13
19
|
.sort((a, b) => a.length - b.length)
|
|
14
20
|
.filter((pattern) => {
|
|
15
|
-
if (openPatterns.some((p) => p.test(pattern)))
|
|
21
|
+
if (openPatterns.some((p) => p.test(pattern)))
|
|
16
22
|
return false;
|
|
17
|
-
}
|
|
18
|
-
if (pattern.endsWith('*')) {
|
|
19
|
-
openPatterns.push(new RegExp(`^${pattern.replace(/(\*\/)*\*$/g, '.*')}`));
|
|
20
|
-
}
|
|
21
23
|
return true;
|
|
22
24
|
});
|
|
23
25
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mkdirSync, readFileSync, statSync, writeFileSync } from 'fs';
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'fs';
|
|
2
2
|
import assert from 'node:assert';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import TOML from '@iarna/toml';
|
|
@@ -111,7 +111,9 @@ class LocalRuntime {
|
|
|
111
111
|
const CF_ENDPOINT = 'https://workers.cloudflare.com/cf.json';
|
|
112
112
|
if (!this.cfObject) {
|
|
113
113
|
this.cfObject = await fetch(CF_ENDPOINT).then((res) => res.json());
|
|
114
|
-
|
|
114
|
+
if (!existsSync(this._astroConfig.cacheDir)) {
|
|
115
|
+
mkdirSync(this._astroConfig.cacheDir);
|
|
116
|
+
}
|
|
115
117
|
writeFileSync(fileURLToPath(new URL('cf.json', this._astroConfig.cacheDir)), JSON.stringify(this.cfObject), 'utf8');
|
|
116
118
|
}
|
|
117
119
|
return this.cfObject;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"//comment": "test changeset-bot",
|
|
3
3
|
"name": "@astrojs/cloudflare",
|
|
4
4
|
"description": "Deploy your site to Cloudflare Workers/Pages",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "9.0.1",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"author": "withastro",
|
|
@@ -40,26 +40,24 @@
|
|
|
40
40
|
"tiny-glob": "^0.2.9"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"astro": "^
|
|
43
|
+
"astro": "^4.2.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"execa": "^8.0.1",
|
|
47
47
|
"fast-glob": "^3.3.1",
|
|
48
48
|
"@types/iarna__toml": "^2.0.2",
|
|
49
49
|
"strip-ansi": "^7.1.0",
|
|
50
|
-
"astro": "^4.
|
|
51
|
-
"chai": "^4.3.10",
|
|
50
|
+
"astro": "^4.3.5",
|
|
52
51
|
"cheerio": "1.0.0-rc.12",
|
|
53
|
-
"mocha": "^10.2.0",
|
|
54
52
|
"wrangler": "^3.15.0",
|
|
55
|
-
"@astrojs/test-utils": "0.0.1"
|
|
53
|
+
"@astrojs/test-utils": "0.0.1",
|
|
54
|
+
"astro-scripts": "0.0.14"
|
|
56
55
|
},
|
|
57
56
|
"publishConfig": {
|
|
58
57
|
"provenance": true
|
|
59
58
|
},
|
|
60
59
|
"scripts": {
|
|
61
60
|
"build": "tsc",
|
|
62
|
-
"test": "
|
|
63
|
-
"test:match": "mocha --exit --timeout 30000 -g"
|
|
61
|
+
"test": "astro-scripts test \"test/**/*.test.js\""
|
|
64
62
|
}
|
|
65
63
|
}
|