Wrangler: Generate worker metadata.json at build time

Created on 7 Nov 2019  路  22Comments  路  Source: cloudflare/wrangler

馃挕 Feature request

Overview and problem statement

We use wrangler to build our project but not publish it. Since the metadata file is only generated at publish time, we are force to write it on our own.

Metadata generation was moved to the publish phase because of KV bindings.

Basic example

I suggest introducing a flag --write-metadata for the wrangler build command which will generate and write the metadata.json file.
This should throw if KV binbings are detected.

category - feature status - PR welcome user report

Most helpful comment

If there's no issue moving back the metadata generation in the build command, that would be a permanent improvement that fixes this issue.

FPW support in wrangler, is another issue but we are slowly getting there. Maybe we could start a doc internally about current issues.

All 22 comments

This should throw if KV bindings are detected.

Why? because of

Metadata generation was moved to the publish phase because of KV bindings.

? it was moved to the publish phase when we added kv bindings, but that was simply because the bindings were not used (by wrangler) at the build stage.

I don't exactly remember the issue with KV to be honest, but if you are sure there's isn't I'm fine.

I'm not quite sure why we would move this to the build stage - is this for debug purposes? We could add a log::debug that includes the constructed file content if that is the goal?

@EverlastingBugstopper

We use wrangler to build our project but not publish it

Is there a reason for building with wrangler and not publishing with it? Is there something that wrangler publish is not doing that it should be?

Is there a reason for building with wrangler and not publishing with it? Is there something that wrangler publish is not doing that it should be?

FPW

oh duh.. makes sense.

Is there a reason for building with wrangler and not publishing with it? Is there something that wrangler publish is not doing that it should be?

Even without FPW use case publishing with regular curl is much more flexible than wrangler publish a at the moment:

  • using API Tokens is not supported with wrangler
  • publishing script without specifying route
  • configure account ID, script name, API token through environment variables. It's much more flexible with TeamCity setup than dealing with multiple environments in .toml file.

Hi @sejoker! We are actively working on those for wrangler

1) API Token support will be available in the next release
2) I'm not quite sure what you mean by publishing a script without specifying a route, could you elaborate?
3) Wrangler will respect CF_ACCOUNT_ID, CF_NAME in the current release, and will respect CF_API_TOKEN in the next release (this is not documented, but should be added to the documentation by the end of November)

This feedback is really helpful! As we continue developing Wrangler we want to make sure that it's the obvious choice and that it is just as flexible as using the API.

@EverlastingBugstopper re: 2 because upload and add route are different endpoints, you can actually upload a script to the workers config api without sending it to the edge by simply not calling the POST /route endpoint. wrangler just doesn't allow this. idk how much we want to push that, as generally we aren't in the business of just arbitrarily storing inactive scripts, but it's not as expensive so perhaps like a --draft flag would be helpful, idk.

That makes sense, I'm wondering what the use case for that is?

@EverlastingBugstopper one word: "migration". I have already deployed script (through UI) which runs on all requests: "example.com/*". API returns an error when I deploy new script against existing route. Maybe a flag --overrideExisting could address the need, but currently it's a blocker for me to use wrangler for deployments.

I believe we already had some discussion about a --force flag which could overide this kind of things.

@xtuc @sejoker if we implemented wrangler publish --draft (this seems semantically more appropriate than --force, which is rather general), is that preferred to this? This seems like a stop-gap proposal to get around the absence of the above features, but all are supported in the next release except the idea of a draft publish.

If so, I propose closing this issue and opening a new one for the draft feature.

@sejoker that makes sense! For now, if you name the script the same as what's named in the dash, you won't get that pesky API error.

This issue is about generating the metadata at build time. Is this fixed in the next release?

@xtuc sorry this discussion got a bit derailed.

As for getting this in for this release, the team has not triaged this specific issue and likely won't before the end of this week. That being said we would more than welcome a community PR that addresses this!

@xtuc no. what i was asking was whether this issue is actually a thing you want, or if it is a counter-measure against other missing wrangler features. putting it behind a flag seems chill, but if the only reason it is happening is because wrangler isn't meeting your needs in ways that it could, i'd personally prefer to improve wrangler.

maybe we do both. idk. just wondering if you are asking for a lemon when you actually want a lime but don't think we have it to give 馃檭

Regarding permanent improvements - I don't think that wrangler will support FPW until their deploy process changes, so this flag seems like a good stopgap.

If there's no issue moving back the metadata generation in the build command, that would be a permanent improvement that fixes this issue.

FPW support in wrangler, is another issue but we are slowly getting there. Maybe we could start a doc internally about current issues.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PierBover picture PierBover  路  5Comments

TownLake picture TownLake  路  3Comments

GregBrimble picture GregBrimble  路  6Comments

simplenotezy picture simplenotezy  路  5Comments

EverlastingBugstopper picture EverlastingBugstopper  路  3Comments