Skip to content

Conversation

@AdrianGonz97
Copy link
Member

@AdrianGonz97 AdrianGonz97 commented Dec 3, 2024

closes #248

sveltekit-adapter installs and replaces existing SvelteKit adapters.

usage:

sv add --sveltekit-adapter <node|static|vercel|cloudflare-pages|cloudflare-workers|netlify>

@changeset-bot
Copy link

changeset-bot bot commented Dec 3, 2024

🦋 Changeset detected

Latest commit: 6dfdaf0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
sv Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 3, 2024

Open in Stackblitz

npm i https://pkg.pr.new/sveltejs/cli/sv@346
npm i https://pkg.pr.new/sveltejs/cli/svelte-migrate@346

commit: 6dfdaf0

@Rich-Harris
Copy link
Member

preview: https://svelte-dev-git-preview-cli-346-svelte.vercel.app/

this is an automated message

Copy link
Member

@manuel3108 manuel3108 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running the command from the PR description fails npm sv add --sveltekit-adapter static:

Log

file:///D:/dev/web/svelte-cli/packages/cli/dist/bin.js:4317
    throw new ValiError(dataset.issues);
          ^

ValiError: Invalid type: Expected never but received Array
    at parse (file:///D:/dev/web/svelte-cli/packages/cli/dist/bin.js:4317:11)
    at Command.<anonymous> (file:///D:/dev/web/svelte-cli/packages/cli/dist/bin.js:11458:19)
    at Command.listener [as _actionHandler] (file:///D:/dev/web/svelte-cli/packages/cli/dist/bin.js:1798:17)
    at file:///D:/dev/web/svelte-cli/packages/cli/dist/bin.js:2758:14
    at Command._chainOrCall (file:///D:/dev/web/svelte-cli/packages/cli/dist/bin.js:2642:12)
    at Command._parseCommand (file:///D:/dev/web/svelte-cli/packages/cli/dist/bin.js:2757:27)
    at file:///D:/dev/web/svelte-cli/packages/cli/dist/bin.js:2521:27
    at Command._chainOrCall (file:///D:/dev/web/svelte-cli/packages/cli/dist/bin.js:2642:12)
    at Command._dispatchSubcommand (file:///D:/dev/web/svelte-cli/packages/cli/dist/bin.js:2517:25)
    at Command._parseCommand (file:///D:/dev/web/svelte-cli/packages/cli/dist/bin.js:2713:19) {
  issues: [
    {
      kind: 'schema',
      type: 'strict_object',
      input: [ 'static' ],
      expected: 'never',
      received: 'Array',
      message: 'Invalid type: Expected never but received Array',
      requirement: undefined,
      path: [
        {
          type: 'object',
          origin: 'value',
          input: {
            cwd: 'D:\\dev\\web\\svelte-cli',
            install: true,
            preconditions: true,
            sveltekitAdapter: [Array]
          },
          key: 'sveltekitAdapter',
          value: [ 'static' ]
        }
      ],
      issues: undefined,
      lang: undefined,
      abortEarly: undefined,
      abortPipeEarly: undefined
    }
  ]

I was thinking that we might need to add it here, but was unable to make it work (also unsure if this will work while using the alias, we might need to initialize valibot dynamically):

const AddonOptionFlagsSchema = v.object({
tailwindcss: v.optional(v.array(v.string())),
drizzle: v.optional(v.array(v.string())),
lucia: v.optional(v.array(v.string())),
paraglide: v.optional(v.array(v.string()))
});

Also some we have the single vs. double quotes problem again, I think we already solved this somewhere else, but I don't remember where and how.
image

@manuel3108
Copy link
Member

Also some we have the single vs. double quotes problem again, I think we already solved this somewhere else, but I don't remember where and how.

This still seems to be present, but looking at the code, no clue how this is happening and if this is fixable.

For whatever reason the following command is installing the node adapter, without asking any questions:

pnpm sv add --sveltekit-adapter --cwd ../svelte-cli-temp

Also, it looks like there is an inconsistency with the aliases:

pnpm sv add sveltekit-adapter --cwd ../svelte-cli-temp     # works
pnpm sv add adapter --cwd ../svelte-cli-temp               # works
pnpm sv add --sveltekit-adapter --cwd ../svelte-cli-temp   # works
pnpm sv add --adapter --cwd ../svelte-cli-temp             # error: unknown option '--adapter'

The last one could be solved in a separate PR as this is assumably a broader issue

@AdrianGonz97
Copy link
Member Author

AdrianGonz97 commented Dec 16, 2024

This still seems to be present, but looking at the code, no clue how this is happening and if this is fixable.

For whatever reason the following command is installing the node adapter, without asking any questions:

pnpm sv add --sveltekit-adapter --cwd ../svelte-cli-temp

That's the intended behavior. If you're specifying the adapter via the flag, then any unspecified add-on options will fallback to their defaults (which is node in this case).

Also, it looks like there is an inconsistency with the aliases:

I don't think we ever discussed if aliases should also get their own option flags. At the moment, they're only useful when specifying add-ons as args (i.e. sv add tailwind).

@manuel3108 manuel3108 merged commit 32deaf0 into main Dec 16, 2024
8 checks passed
@manuel3108 manuel3108 deleted the feat/sveltekit-adapters branch December 16, 2024 18:01
@github-actions github-actions bot mentioned this pull request Dec 16, 2024
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 this pull request may close these issues.

Adder for sveltekit adapter

5 participants