@astrojs/cloudflare 6.1.0 → 6.1.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/.turbo/turbo-build.log +5 -5
- package/CHANGELOG.md +9 -0
- package/dist/index.js +7 -4
- package/package.json +3 -3
- package/src/index.ts +8 -6
- package/test/directory.test.js +20 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
[
|
|
2
|
-
[
|
|
3
|
-
[
|
|
4
|
-
[
|
|
5
|
-
[
|
|
1
|
+
[35m@astrojs/cloudflare:build: [0mcache hit, replaying output [2maf3389b4b118897d[0m
|
|
2
|
+
[35m@astrojs/cloudflare:build: [0m
|
|
3
|
+
[35m@astrojs/cloudflare:build: [0m> @astrojs/cloudflare@6.1.1 build /home/runner/work/astro/astro/packages/integrations/cloudflare
|
|
4
|
+
[35m@astrojs/cloudflare:build: [0m> astro-scripts build "src/**/*.ts" && tsc
|
|
5
|
+
[35m@astrojs/cloudflare:build: [0m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @astrojs/cloudflare
|
|
2
2
|
|
|
3
|
+
## 6.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#6046](https://github.com/withastro/astro/pull/6046) [`df3201165`](https://github.com/withastro/astro/commit/df320116528e00ab082396531b4deffbb0707b78) Thanks [@matthewp](https://github.com/matthewp)! - Cloudflare fix for building to directory mode
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`41e97158b`](https://github.com/withastro/astro/commit/41e97158ba90d23d346b6e3ff6c7c14b5ecbe903), [`e779c6242`](https://github.com/withastro/astro/commit/e779c6242418d1d4102e683ca5b851b764c89688)]:
|
|
10
|
+
- astro@2.0.4
|
|
11
|
+
|
|
3
12
|
## 6.1.0
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import esbuild from "esbuild";
|
|
|
2
2
|
import * as fs from "fs";
|
|
3
3
|
import * as os from "os";
|
|
4
4
|
import glob from "tiny-glob";
|
|
5
|
-
import { fileURLToPath } from "url";
|
|
5
|
+
import { fileURLToPath, pathToFileURL } from "url";
|
|
6
6
|
function getAdapter(isModeDirectory) {
|
|
7
7
|
return isModeDirectory ? {
|
|
8
8
|
name: "@astrojs/cloudflare",
|
|
@@ -67,7 +67,10 @@ function createIntegration(args) {
|
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
69
|
"astro:build:done": async ({ pages }) => {
|
|
70
|
-
const entryPath = fileURLToPath(new URL(_buildConfig.serverEntry, _buildConfig.server))
|
|
70
|
+
const entryPath = fileURLToPath(new URL(_buildConfig.serverEntry, _buildConfig.server));
|
|
71
|
+
const entryUrl = new URL(_buildConfig.serverEntry, _config.outDir);
|
|
72
|
+
const buildPath = fileURLToPath(entryUrl);
|
|
73
|
+
const finalBuildUrl = pathToFileURL(buildPath.replace(/\.mjs$/, ".js"));
|
|
71
74
|
await esbuild.build({
|
|
72
75
|
target: "es2020",
|
|
73
76
|
platform: "browser",
|
|
@@ -81,7 +84,7 @@ function createIntegration(args) {
|
|
|
81
84
|
js: SHIM
|
|
82
85
|
}
|
|
83
86
|
});
|
|
84
|
-
await fs.promises.rename(buildPath,
|
|
87
|
+
await fs.promises.rename(buildPath, finalBuildUrl);
|
|
85
88
|
const serverUrl = new URL(_buildConfig.server);
|
|
86
89
|
await fs.promises.rm(serverUrl, { recursive: true, force: true });
|
|
87
90
|
const cloudflareSpecialFiles = ["_headers", "_redirects", "_routes.json"];
|
|
@@ -138,7 +141,7 @@ function createIntegration(args) {
|
|
|
138
141
|
const functionsUrl = new URL(`file://${process.cwd()}/functions/`);
|
|
139
142
|
await fs.promises.mkdir(functionsUrl, { recursive: true });
|
|
140
143
|
const directoryUrl = new URL("[[path]].js", functionsUrl);
|
|
141
|
-
await fs.promises.rename(
|
|
144
|
+
await fs.promises.rename(finalBuildUrl, directoryUrl);
|
|
142
145
|
}
|
|
143
146
|
}
|
|
144
147
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/cloudflare",
|
|
3
3
|
"description": "Deploy your site to cloudflare workers or cloudflare pages",
|
|
4
|
-
"version": "6.1.
|
|
4
|
+
"version": "6.1.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"author": "withastro",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"tiny-glob": "^0.2.9"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"astro": "^2.0.
|
|
35
|
+
"astro": "^2.0.4"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"astro": "2.0.
|
|
38
|
+
"astro": "2.0.4",
|
|
39
39
|
"astro-scripts": "0.0.10",
|
|
40
40
|
"chai": "^4.3.6",
|
|
41
41
|
"cheerio": "^1.0.0-rc.11",
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import esbuild from 'esbuild';
|
|
|
3
3
|
import * as fs from 'fs';
|
|
4
4
|
import * as os from 'os';
|
|
5
5
|
import glob from 'tiny-glob';
|
|
6
|
-
import { fileURLToPath } from 'url';
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
7
7
|
|
|
8
8
|
type Options = {
|
|
9
9
|
mode: 'directory' | 'advanced';
|
|
@@ -89,9 +89,11 @@ export default function createIntegration(args?: Options): AstroIntegration {
|
|
|
89
89
|
}
|
|
90
90
|
},
|
|
91
91
|
'astro:build:done': async ({ pages }) => {
|
|
92
|
-
const entryPath = fileURLToPath(new URL(_buildConfig.serverEntry, _buildConfig.server))
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
const entryPath = fileURLToPath(new URL(_buildConfig.serverEntry, _buildConfig.server));
|
|
93
|
+
const entryUrl = new URL(_buildConfig.serverEntry, _config.outDir);
|
|
94
|
+
const buildPath = fileURLToPath(entryUrl);
|
|
95
|
+
// A URL for the final build path after renaming
|
|
96
|
+
const finalBuildUrl = pathToFileURL(buildPath.replace(/\.mjs$/, '.js'));
|
|
95
97
|
|
|
96
98
|
await esbuild.build({
|
|
97
99
|
target: 'es2020',
|
|
@@ -108,7 +110,7 @@ export default function createIntegration(args?: Options): AstroIntegration {
|
|
|
108
110
|
});
|
|
109
111
|
|
|
110
112
|
// Rename to worker.js
|
|
111
|
-
await fs.promises.rename(buildPath,
|
|
113
|
+
await fs.promises.rename(buildPath, finalBuildUrl);
|
|
112
114
|
|
|
113
115
|
// throw the server folder in the bin
|
|
114
116
|
const serverUrl = new URL(_buildConfig.server);
|
|
@@ -204,7 +206,7 @@ export default function createIntegration(args?: Options): AstroIntegration {
|
|
|
204
206
|
const functionsUrl = new URL(`file://${process.cwd()}/functions/`);
|
|
205
207
|
await fs.promises.mkdir(functionsUrl, { recursive: true });
|
|
206
208
|
const directoryUrl = new URL('[[path]].js', functionsUrl);
|
|
207
|
-
await fs.promises.rename(
|
|
209
|
+
await fs.promises.rename(finalBuildUrl, directoryUrl);
|
|
208
210
|
}
|
|
209
211
|
},
|
|
210
212
|
},
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { loadFixture, runCLI } from './test-utils.js';
|
|
2
|
+
import { expect } from 'chai';
|
|
3
|
+
import * as cheerio from 'cheerio';
|
|
4
|
+
import cloudflare from '../dist/index.js';
|
|
5
|
+
|
|
6
|
+
describe('mode: "directory"', () => {
|
|
7
|
+
/** @type {import('./test-utils').Fixture} */
|
|
8
|
+
let fixture;
|
|
9
|
+
|
|
10
|
+
before(async () => {
|
|
11
|
+
fixture = await loadFixture({
|
|
12
|
+
root: './fixtures/basics/',
|
|
13
|
+
adapter: cloudflare({ mode: 'directory' }),
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('Builds', async () => {
|
|
18
|
+
await fixture.build();
|
|
19
|
+
});
|
|
20
|
+
});
|