diff options
-rw-r--r-- | .changeset/five-maps-bake.md | 5 | ||||
-rw-r--r-- | packages/astro/src/cli/add/index.ts | 7 |
2 files changed, 11 insertions, 1 deletions
diff --git a/.changeset/five-maps-bake.md b/.changeset/five-maps-bake.md new file mode 100644 index 000000000..13bacbcdc --- /dev/null +++ b/.changeset/five-maps-bake.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes code generated by `astro add` command when adding a version of an integration other than the default `latest`. diff --git a/packages/astro/src/cli/add/index.ts b/packages/astro/src/cli/add/index.ts index 08c57dc04..2b4faa266 100644 --- a/packages/astro/src/cli/add/index.ts +++ b/packages/astro/src/cli/add/index.ts @@ -390,13 +390,16 @@ function isAdapter( // Some examples: // - @astrojs/image => image // - @astrojs/markdown-component => markdownComponent +// - @astrojs/image@beta => image // - astro-cast => cast +// - astro-cast@next => cast // - markdown-astro => markdown // - some-package => somePackage // - example.com => exampleCom // - under_score => underScore // - 123numeric => numeric // - @npm/thingy => npmThingy +// - @npm/thingy@1.2.3 => npmThingy // - @jane/foo.js => janeFoo // - @tokencss/astro => tokencss const toIdent = (name: string) => { @@ -409,7 +412,9 @@ const toIdent = (name: string) => { // convert to camel case .replace(/[.\-_/]+([a-zA-Z])/g, (_, w) => w.toUpperCase()) // drop invalid first characters - .replace(/^[^a-zA-Z$_]+/, ''); + .replace(/^[^a-zA-Z$_]+/, '') + // drop version or tag + .replace(/@.*$/, ''); return `${ident[0].toLowerCase()}${ident.slice(1)}`; }; |