Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nx-cloudflare] Publish command not working for a fresh project #38

Closed
2 of 4 tasks
mnlbox opened this issue Apr 10, 2024 · 7 comments · Fixed by #40
Closed
2 of 4 tasks

[nx-cloudflare] Publish command not working for a fresh project #38

mnlbox opened this issue Apr 10, 2024 · 7 comments · Fixed by #40

Comments

@mnlbox
Copy link

mnlbox commented Apr 10, 2024

Current Behavior

When I run my project through the publish command I'm getting this error in my terminal:

 NX   Cannot find configuration for task api-test:publish

Pass --verbose to see the stacktrace.

Expected Behavior

It's just a helloworld application based on Hono. Do I missed anything in my wrangler.toml file? What should I do to fix this and deploy and publish my worker? Maybe a more clear error message can be helpful here.

GitHub Repo

No response

Steps to Reproduce

  1. Create my project with this command:
pnpm nx generate @naxodev/nx-cloudflare:application --name api-test--template hono --directory apis/test --port 4001 --projectNameAndRootFormat=as-provided
  1. Then run my project with this command:
pnpm nx publish api-test

I can run my project sucessfully but I'm getting this error on publish:

NX   Cannot find configuration for task api-test:publish

Pass --verbose to see the stacktrace.

Nx Report

NX   Report complete - copy this into the issue template

Node   : 20.11.0
OS     : linux-arm64
pnpm   : 8.15.5

nx                 : 18.2.4
@nx/js             : 18.2.4
@nx/jest           : 18.2.4
@nx/linter         : 18.2.4
@nx/eslint         : 18.2.4
@nx/workspace      : 18.2.4
@nx/devkit         : 18.2.4
@nx/esbuild        : 18.2.4
@nx/eslint-plugin  : 18.2.4
@nx/nest           : 18.2.4
@nx/node           : 18.2.4
@nx/playwright     : 18.2.4
@nx/react          : 18.2.4
@nrwl/tao          : 18.2.4
@nx/vite           : 18.2.4
@nx/web            : 18.2.4
@nx/webpack        : 18.2.4
typescript         : 5.4.4
---------------------------------------
Registered Plugins:
@nx/webpack/plugin
@nx/eslint/plugin
@nx/vite/plugin
@nx/playwright/plugin
---------------------------------------
Community plugins:
@naxodev/nx-cloudflare : 2.0.1

Failure Logs

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

I'm using vscode devContainer with a Debian based linux in a MacOs host machine.

@mnlbox mnlbox changed the title Publish command not working for a fresh project [nx-cloudflare] Publish command not working for a fresh project Apr 10, 2024
@NachoVazquez
Copy link
Contributor

Thank you! I'll check this one in the evening.

@NachoVazquez
Copy link
Contributor

Yes, it is one of the supported arguments.

export interface DeployExecutorSchema {
  name: string;
  noBundle: boolean;
  env: string;
  outdir: string;
  compatibilityDate: string;
  compatibilityFlags: string[];
  latest: boolean;
  assets: string;
  site: string;
  siteInclude: string[];
  siteExclude: string[];
  var: string[];
  define: string[];
  triggers: string[];
  routes: string[];
  tsconfig: string;
  minify: boolean;
  nodeCompat: boolean;
  dryRun: boolean;
  keepVars: boolean;
}

@NachoVazquez
Copy link
Contributor

I understand the problem.

publish and deploy are aliases, but only for the executor. For example:

      "executor": "@naxodev/nx-cloudflare:deploy"

is the same as

      "executor": "@naxodev/nx-cloudflare:publish"

however, we are generating the applications with deploy as the command name, which is causing the confussion

    "deploy": {
      "executor": "@naxodev/nx-cloudflare:deploy"
    }

so the options here are either change the docs to use deploy or change the generator to use publish

@NachoVazquez
Copy link
Contributor

Since wrangler publish has been deprecated, I will move everything to deploy. But you can use it right now.

@mnlbox
Copy link
Author

mnlbox commented Apr 11, 2024

@NachoVazquez Thanks for the update, I tried this command: pnpm nx deploy api-test. And this is the output:

> nx run api-test:deploy

 ⛅️ wrangler 3.49.0
-------------------
▲ [WARNING] Using the latest version of the Workers runtime. To silence this warning, please choose a specific version of the runtime with --compatibility-date, or add a compatibility_date to your wrangler.toml.

  



✘ [ERROR] In a non-interactive environment, it's necessary to set a CLOUDFLARE_API_TOKEN environment variable for wrangler to work. Please go to https://developers.cloudflare.com/fundamentals/api/get-started/create-token/ for instructions on how to create an api token, and assign its value to CLOUDFLARE_API_TOKEN.


🪵  Logs were written to "/home/node/.config/.wrangler/logs/wrangler-2024-04-11_13-43-49_985.log"

————————————————————————————————————————————————————————————————————————————————————————————————————————————

 NX   Ran target deploy for project api-test (3s)

   ✖  1/1 failed
   ✔  0/1 succeeded [0 read from cache]

So I think it will work after setting the CLOUDFLARE_API_KEY. I'll check with API_KEY and will inform you here.

@mnlbox
Copy link
Author

mnlbox commented Apr 17, 2024

@NachoVazquez the deploy command also seems working but it return the below warning:

pnpm nx run service-test:deploy

> nx run service-test:deploy

 ⛅️ wrangler 3.50.0 (update available 3.51.0)
-------------------------------------------------------
▲ [WARNING] Using the latest version of the Workers runtime. To silence this warning, please choose a specific version of the runtime with --compatibility-date, or add a compatibility_date to your wrangler.toml.

  



✘ [ERROR] In a non-interactive environment, it's necessary to set a CLOUDFLARE_API_TOKEN environment variable for wrangler to work. Please go to https://developers.cloudflare.com/fundamentals/api/get-started/create-token/ for instructions on how to create an api token, and assign its value to CLOUDFLARE_API_TOKEN.


🪵  Logs were written to "/home/node/.config/.wrangler/logs/wrangler-2024-04-17_07-14-51_645.log"

———————————————————————————————————————————————————————————————————————————————————————————————————————————————

 NX   Ran target deploy for project service-test (3s)

   ✖  1/1 failed
   ✔  0/1 succeeded [0 read from cache]

I think maybe a bit more information and guide or a "how to deploy" section in README is also useful. But I'm new in CloudFlare so I guess by some research I can do it.

@NachoVazquez
Copy link
Contributor

You need to set the Cloudflare API key in your env variables. I might make a note on the docs. However, this is needed for any Cloudflare project beyond this plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants