create-cloudflare 2.0.9 → 2.0.11

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.
Files changed (47) hide show
  1. package/README.md +7 -5
  2. package/dist/angular/templates/tools/bundle.mjs +5 -2
  3. package/dist/cli.js +48474 -51573
  4. package/dist/tsconfig.tsbuildinfo +1 -1
  5. package/package.json +8 -4
  6. package/templates/chatgptPlugin/ts/README.md +1 -1
  7. package/templates/chatgptPlugin/ts/package.json +1 -1
  8. package/templates/chatgptPlugin/ts/wrangler.toml +2 -2
  9. package/templates/common/js/package.json +1 -1
  10. package/templates/common/js/wrangler.toml +37 -25
  11. package/templates/common/ts/package.json +1 -1
  12. package/templates/common/ts/wrangler.toml +37 -25
  13. package/templates/{simple/ts → hello-world/js}/package.json +1 -1
  14. package/templates/hello-world/js/wrangler.toml +51 -0
  15. package/templates/{simple/js → hello-world/ts}/package.json +1 -1
  16. package/templates/hello-world/ts/wrangler.toml +51 -0
  17. package/templates/queues/js/.editorconfig +13 -0
  18. package/templates/queues/js/.prettierrc +6 -0
  19. package/templates/queues/js/package.json +14 -0
  20. package/templates/queues/js/src/worker.js +38 -0
  21. package/templates/queues/js/wrangler.toml +19 -0
  22. package/templates/queues/ts/.editorconfig +13 -0
  23. package/templates/queues/ts/.prettierrc +6 -0
  24. package/templates/queues/ts/package.json +14 -0
  25. package/templates/queues/ts/src/worker.ts +43 -0
  26. package/templates/queues/ts/tsconfig.json +101 -0
  27. package/templates/queues/ts/wrangler.toml +19 -0
  28. package/templates/scheduled/js/.editorconfig +13 -0
  29. package/templates/scheduled/js/.prettierrc +6 -0
  30. package/templates/scheduled/js/package.json +14 -0
  31. package/templates/scheduled/js/src/worker.js +30 -0
  32. package/templates/scheduled/js/wrangler.toml +9 -0
  33. package/templates/scheduled/ts/.editorconfig +13 -0
  34. package/templates/scheduled/ts/.prettierrc +6 -0
  35. package/templates/scheduled/ts/package.json +14 -0
  36. package/templates/scheduled/ts/src/worker.ts +50 -0
  37. package/templates/scheduled/ts/tsconfig.json +101 -0
  38. package/templates/scheduled/ts/wrangler.toml +9 -0
  39. package/templates/simple/js/wrangler.toml +0 -40
  40. package/templates/simple/ts/wrangler.toml +0 -40
  41. /package/templates/{simple → hello-world}/js/.editorconfig +0 -0
  42. /package/templates/{simple → hello-world}/js/.prettierrc +0 -0
  43. /package/templates/{simple → hello-world}/js/src/worker.js +0 -0
  44. /package/templates/{simple → hello-world}/ts/.editorconfig +0 -0
  45. /package/templates/{simple → hello-world}/ts/.prettierrc +0 -0
  46. /package/templates/{simple → hello-world}/ts/src/worker.ts +0 -0
  47. /package/templates/{simple → hello-world}/ts/tsconfig.json +0 -0
package/README.md CHANGED
@@ -37,21 +37,23 @@ Currently supported framework options: `angular`, `astro`, `docusaurus`, `gatsby
37
37
  To create a new Javascript "Hello World" worker, run:
38
38
 
39
39
  ```bash
40
- npm create cloudflare@latest hello-world -- --type simple --no-ts
40
+ npm create cloudflare@latest hello-world -- --type hello-world --no-ts
41
41
  ```
42
42
 
43
43
  To create a new Typescript "Hello World" worker, run:
44
44
 
45
45
  ```bash
46
- npm create cloudflare@latest hello-world -- --type simple --ts
46
+ npm create cloudflare@latest hello-world -- --type hello-world --ts
47
47
  ```
48
48
 
49
- Current template options are: `simple`, `common`, or `chatgptPlugin`.
49
+ Current template options are: `hello-world`, `common`, or `chatgptPlugin`.
50
50
 
51
51
  #### Additional arguments
52
52
 
53
- | `--deploy` | deploy your application automatically, bypassing the interactive prompt |
54
- | `--no-deploy` | create and scaffold a new application and bypass deployment prompt |
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 |
55
57
 
56
58
  ### Community
57
59
 
@@ -37,7 +37,8 @@ async function bundleMain() {
37
37
  ],
38
38
  });
39
39
 
40
- let main = result.outputFiles[0].text;
40
+ // Store the original promise (before Angular/Zone.js replaces it) on the global scope.
41
+ let main = "globalThis.OGPromise = Promise;\n" + result.outputFiles[0].text;
41
42
 
42
43
  // Patch any dynamic imports (converting `require()` calls to `import()` calls).
43
44
  main = main.replace(
@@ -45,7 +46,9 @@ async function bundleMain() {
45
46
  'promises.push(import("./" + __webpack_require__.u(chunkId)).then((mod) => installChunk(mod.default))'
46
47
  );
47
48
  // Export the fetch handler (grabbing it from the global).
48
- main += "\nexport default { fetch : globalThis.__workerFetchHandler };";
49
+ // Also Cloudflare expects `fetch()` to return an original Promise (not a ZoneAwarePromise).
50
+ main +=
51
+ "\nexport default { fetch: (request, env) => globalThis.OGPromise.resolve(globalThis.__workerFetchHandler(request, env)) };";
49
52
 
50
53
  await fs.writeFile(path.resolve(workerPath, "index.js"), main);
51
54
  }