create-cloudflare 2.6.2 → 2.7.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/README.md +1 -52
- package/dist/angular/templates/{src/main.server.ts → server.ts} +14 -15
- package/dist/angular/templates/tools/alter-polyfills.mjs +27 -0
- package/dist/angular/templates/tools/copy-files.mjs +9 -0
- package/dist/cli.js +214 -145
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -9
- package/templates/scheduled/ts/wrangler.toml +1 -1
- package/dist/angular/templates/tools/bundle.mjs +0 -77
- package/dist/angular/templates/tools/copy-client-files.mjs +0 -4
- package/dist/angular/templates/tools/copy-worker-files.mjs +0 -10
- package/dist/angular/templates/tsconfig.server.json +0 -5
package/README.md
CHANGED
|
@@ -2,58 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A CLI for creating and deploying new applications to [Cloudflare](https://developers.cloudflare.com/).
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
### Setup via Interactive CLI
|
|
8
|
-
|
|
9
|
-
To create new applications via interactive CLI, run:
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npm create cloudflare@latest
|
|
13
|
-
# or
|
|
14
|
-
pnpm create cloudflare@latest
|
|
15
|
-
# or
|
|
16
|
-
yarn create cloudflare
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
### Setup via CLI Arguments
|
|
20
|
-
|
|
21
|
-
#### New Websites or Web applications via Frameworks
|
|
22
|
-
|
|
23
|
-
To create a new website or web framework without interaction, run:
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
npm create cloudflare@latest -- --type webFramework --framework <frameworkName>
|
|
27
|
-
# or
|
|
28
|
-
pnpm create cloudflare@latest ...
|
|
29
|
-
# or
|
|
30
|
-
yarn create cloudflare ...
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
Currently supported framework options: `angular`, `astro`, `docusaurus`, `gatsby`, `hono`, `next`, `nuxt`, `qwik`, `react`, `remix`, `solid`, `svelte`, `vue`.
|
|
34
|
-
|
|
35
|
-
#### New Workers via Templates
|
|
36
|
-
|
|
37
|
-
To create a new Javascript "Hello World" worker, run:
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
npm create cloudflare@latest hello-world -- --type hello-world --no-ts
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
To create a new Typescript "Hello World" worker, run:
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
npm create cloudflare@latest hello-world -- --type hello-world --ts
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
Current template options are: `hello-world`, `common`, `chatgptPlugin`, or `openapi`.
|
|
50
|
-
|
|
51
|
-
#### Additional arguments
|
|
52
|
-
|
|
53
|
-
| | |
|
|
54
|
-
| ------------- | :---------------------------------------------------------------------: |
|
|
55
|
-
| `--deploy` | deploy your application automatically, bypassing the interactive prompt |
|
|
56
|
-
| `--no-deploy` | create and scaffold a new application and bypass deployment prompt |
|
|
5
|
+
For more details on how to use the create-cloudflare CLI (C3) please visit the [official C3 documentation](https://developers.cloudflare.com/pages/get-started/c3).
|
|
57
6
|
|
|
58
7
|
### Community
|
|
59
8
|
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import "zone.js/dist/zone-node";
|
|
2
|
-
import "@angular/platform-server/init";
|
|
3
|
-
|
|
4
|
-
import { bootstrapApplication } from "@angular/platform-browser";
|
|
5
1
|
import { renderApplication } from "@angular/platform-server";
|
|
6
|
-
|
|
7
|
-
import { AppComponent } from "./app/app.component";
|
|
8
|
-
import { config } from "./app/app.config.server";
|
|
2
|
+
import bootstrap from "./src/main.server";
|
|
9
3
|
|
|
10
4
|
interface Env {
|
|
11
5
|
ASSETS: { fetch: typeof fetch };
|
|
@@ -14,10 +8,7 @@ interface Env {
|
|
|
14
8
|
// We attach the Cloudflare `fetch()` handler to the global scope
|
|
15
9
|
// so that we can export it when we process the Angular output.
|
|
16
10
|
// See tools/bundle.mjs
|
|
17
|
-
|
|
18
|
-
request: Request,
|
|
19
|
-
env: Env
|
|
20
|
-
) {
|
|
11
|
+
async function workerFetchHandler(request: Request, env: Env) {
|
|
21
12
|
const url = new URL(request.url);
|
|
22
13
|
console.log("render SSR", url.href);
|
|
23
14
|
|
|
@@ -26,10 +17,18 @@ interface Env {
|
|
|
26
17
|
const indexResponse = await env.ASSETS.fetch(new Request(indexUrl));
|
|
27
18
|
const document = await indexResponse.text();
|
|
28
19
|
|
|
29
|
-
const content = await renderApplication(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
);
|
|
20
|
+
const content = await renderApplication(bootstrap, {
|
|
21
|
+
document,
|
|
22
|
+
url: url.pathname,
|
|
23
|
+
});
|
|
24
|
+
|
|
33
25
|
// console.log("rendered SSR", content);
|
|
34
26
|
return new Response(content, indexResponse);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default {
|
|
30
|
+
fetch: (request: Request, env: Env) =>
|
|
31
|
+
(globalThis as any)["__zone_symbol__Promise"].resolve(
|
|
32
|
+
workerFetchHandler(request, env)
|
|
33
|
+
),
|
|
35
34
|
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { EOL } from "node:os";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { worker } from "./paths.mjs";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Split by lines and comment the banner
|
|
8
|
+
* ```
|
|
9
|
+
* import { createRequire } from 'node:module';
|
|
10
|
+
* globalThis['require'] ??= createRequire(import.meta.url);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
const serverPolyfillsFile = join(worker, "polyfills.server.mjs");
|
|
14
|
+
const serverPolyfillsData = fs
|
|
15
|
+
.readFileSync(serverPolyfillsFile, "utf8")
|
|
16
|
+
.split(EOL);
|
|
17
|
+
|
|
18
|
+
for (let index = 0; index < 2; index++) {
|
|
19
|
+
if (serverPolyfillsData[index].includes("createRequire")) {
|
|
20
|
+
serverPolyfillsData[index] = "// " + serverPolyfillsData[index];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Add needed polyfills
|
|
25
|
+
serverPolyfillsData.unshift(`globalThis['process'] = {};`);
|
|
26
|
+
|
|
27
|
+
fs.writeFileSync(serverPolyfillsFile, serverPolyfillsData.join(EOL));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copy the files over so that they can be uploaded by the pages publish command.
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { client, cloudflare, worker, ssr } from "./paths.mjs";
|
|
5
|
+
|
|
6
|
+
fs.cpSync(client, cloudflare, { recursive: true });
|
|
7
|
+
fs.cpSync(ssr, worker, { recursive: true });
|
|
8
|
+
|
|
9
|
+
fs.renameSync(join(worker, "server.mjs"), join(worker, "index.js"));
|