skymethod / denoflare

Develop, test, and deploy Cloudflare Workers with Deno.
https://denoflare.dev
MIT License
704 stars 34 forks source link

deno 2.0 #77

Open q351941406 opened 1 month ago

q351941406 commented 1 month ago
截屏2024-10-23 00 02 38

deno 2.0 denoflare 6

q351941406 commented 1 month ago

ganzhengwei@ganzhenweisMini ArtifexAIbot % denoflare serve main ✅ Granted all import access. Compiling https://raw.githubusercontent.com/skymethod/denoflare/v0.6.0/cli-webworker/worker.ts into worker contents... ✅ Granted all write access. TS0: error: unexpected argument '--config' found

Usage: deno bundle [OPTIONS]

at undefined: error: Uncaught (in promise) Error: bundle failed throw new Error('bundle failed'); ^ at bundle (https://raw.githubusercontent.com/skymethod/denoflare/v0.6.0/cli/bundle.ts:108:15) at eventLoopTick (ext:core/01_core.js:175:7) at async Function.start (https://raw.githubusercontent.com/skymethod/denoflare/v0.6.0/cli/worker_manager.ts:40:43) at async createLocalRequestServer (https://raw.githubusercontent.com/skymethod/denoflare/v0.6.0/cli/cli_serve.ts:161:35) at async Object.serve [as handler] (https://raw.githubusercontent.com/skymethod/denoflare/v0.6.0/cli/cli_serve.ts:194:32) at async CliCommand.routeSubcommand (https://raw.githubusercontent.com/skymethod/denoflare/v0.6.0/cli/cli_command.ts:104:13) at async https://raw.githubusercontent.com/skymethod/denoflare/v0.6.0/cli/cli.ts:41:5 ganzhengwei@ganzhenweisMini ArtifexAIbot %

soyantonio commented 4 weeks ago

You can use esbuild as the bundle backend. That was added recently, so for the moment there's no tag/release with those changes

A workaround is to use the commit hash for the installation, something like

deno install --global --allow-import=cdn.skypack.dev:443,raw.githubusercontent.com:443,deno.land:443 \
  --allow-write --unstable-worker-options --allow-read --allow-net --allow-env --allow-run \
  --name denoflare --force https://raw.githubusercontent.com/skymethod/denoflare/3a875145982d0b288dd864cb2ef1e00552b59cae/cli/cli.ts

Then you can use

denoflare serve main --bundle 'backend=esbuild'

I tested that using deno 2.0.2

q351941406 commented 4 weeks ago

@soyantonio Thank you, it is already usable. I hope Denoflare can fix this bug soon,Therefore, I will not close this issue until it is fixed.

ajsb85 commented 3 weeks ago

deno install fails for denoflare CLI with --unstable-worker-options and permission flags

When attempting to install the denoflare CLI using the command provided in the documentation:

deno install --unstable-worker-options --allow-read --allow-net --allow-env --allow-run --name denoflare --force \
https://raw.githubusercontent.com/skymethod/denoflare/v0.6.0/cli/cli.ts

I encounter the following error:

error: the following required arguments were not provided:
  --global

Note: Permission flags can only be used in a global setting

It seems that using --unstable-worker-options in conjunction with permission flags like --allow-read requires the --global flag, which is not mentioned in the installation instructions.

Steps to Reproduce:

  1. Run the deno install command as shown above.
  2. Observe the error message.

Expected Behavior:

The denoflare CLI should install successfully without requiring the --global flag when using --unstable-worker-options and permission flags.

Actual Behavior:

The installation fails with the error message indicated above.

Environment:

Additional Context:

This issue may be related to how Deno handles permissions in combination with --unstable-worker-options. Clarification in the documentation or a fix in the installation script would be appreciated.

https://github.com/skymethod/denoflare-docs/blob/HEAD/cli/index.md#installation