oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.54k stars 2.71k forks source link

bunx --bun and astro add #6843

Open arjunindia opened 11 months ago

arjunindia commented 11 months ago

What version of Bun is running?

1.0.7+b0393fba6200d8573f3433fb0af258a0e33ac157

What platform is your computer?

Linux 5.15.90.1-microsoft-standard-WSL2 x86_64 x86_64

What steps can reproduce the bug?

run bunx --bun astro add react on a new astro project created with bun create astro

What is the expected behavior?

❯ bunx astro add react

✔ Resolving packages...

  Astro will run the following command:
  If you skip this step, you can always run it yourself later

 ╭────────────────────────────────────────────────────────────────────────────────────────────────────────╮
 │ bun add @astrojs/react @types/react-dom@^18.0.6 @types/react@^18.0.21 react-dom@^18.0.0 react@^18.0.0  │
 ╰────────────────────────────────────────────────────────────────────────────────────────────────────────╯

✔ Continue? … yes
✔ Installing dependencies...

  Astro will make the following changes to your config file:

 ╭ astro.config.mjs ─────────────────────────────╮
 │ import { defineConfig } from 'astro/config';  │
 │                                               │
 │ import react from "@astrojs/react";           │
 │                                               │
 │ // https://astro.build/config                 │
 │ export default defineConfig({                 │
 │   integrations: [react()]                     │
 │ });                                           │
 ╰───────────────────────────────────────────────╯

✔ Continue? … yes

   success  Added the following integration to your project:
  - @astrojs/react

  Astro will make the following changes to your tsconfig.json:

 ╭ tsconfig.json ──────────────────────────╮
 │ {                                       │
 │   "extends": "astro/tsconfigs/strict",  │
 │   "compilerOptions": {                  │
 │     "jsx": "react-jsx",                 │
 │     "jsxImportSource": "react"          │
 │   }                                     │
 │ }                                       │
 ╰─────────────────────────────────────────╯

✔ Continue? … yes

   success  Successfully updated TypeScript settings

What do you see instead?

❯ bunx --bun astro add react

✔ Resolving packages...

  Astro will run the following command:
  If you skip this step, you can always run it yourself later

 ╭────────────────────────────────────────────────────────────────────────────────────────────────────────╮
 │ bun add @astrojs/react @types/react-dom@^18.0.6 @types/react@^18.0.21 react-dom@^18.0.0 react@^18.0.0  │
 ╰────────────────────────────────────────────────────────────────────────────────────────────────────────╯

✔ Continue? … yes
✔ Installing dependencies...
 error   Astro could not update your astro.config.js file safely.
  Reason: undefined is not a function (near '...visit...')

  You will need to add these integration(s) manually.
  Documentation: https://docs.astro.build/en/guides/integrations-guide/
  File:
    /home/arjun/devfolder/dynamyx/node_modules/astro/dist/cli/add/imports.js:4:4
  Code:
    3 |   let specifiersToFind = [...importDeclaration.specifiers];
    > 4 |   visit(root, {
        |    ^
      5 |     ImportDeclaration(path) {
      6 |       if (path.node.source.value === importDeclaration.source.value) {
      7 |         path.node.specifiers.forEach(
  Stacktrace:
TypeError: Astro could not update your astro.config.js file safely.
Reason: undefined is not a function (near '...visit...')

You will need to add these integration(s) manually.
Documentation: https://docs.astro.build/en/guides/integrations-guide/
    at ensureImport (/home/arjun/devfolder/dynamyx/node_modules/astro/dist/cli/add/imports.js:4:4)
    at <anonymous> (/home/arjun/devfolder/dynamyx/node_modules/astro/dist/cli/add/index.js:204:15)
    at processTicksAndRejections (:61:39)

Additional information

astro v3.4.2

bun running on WSL Ubuntu linux bun upgrade was run after scaffolding the project with bun create I believe it was working before

arjunindia commented 11 months ago

Something interesting also happens when running add tailwind

❯ bunx --bun astro add tailwind
✔ Resolving packages...

  Astro will run the following command:
  If you skip this step, you can always run it yourself later

 ╭────────────────────────────────────────────────╮
 │ bun add @astrojs/tailwind tailwindcss@^3.0.24  │
 ╰────────────────────────────────────────────────╯

✔ Continue? … yes
✔ Installing dependencies...

  Astro will generate a minimal ./tailwind.config.mjs file.

? Continue? › (Y/n)%                                                                                                                                                   
❯ bunx --bun astro add tailwind
✔ Resolving packages...

  Astro will run the following command:
  If you skip this step, you can always run it yourself later

 ╭────────────────────────────────────────────────╮
 │ bun add @astrojs/tailwind tailwindcss@^3.0.24  │
 ╰────────────────────────────────────────────────╯

✔ Continue? … yes
✔ Installing dependencies...

  Astro will generate a minimal ./tailwind.config.mjs file.

? Continue? › (Y/n)%                                            

The prompt exits here and does not let you choose y/n