Skip to content

Commit

Permalink
like this instead, and drive-by-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dummdidumm authored Dec 15, 2023
1 parent 85015b6 commit 0f52005
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .changeset/honest-badgers-itch.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
'svelte-migrate': patch
---

chore: inform @migration comments
fix: adjust cookie migration logic, note installation
2 changes: 1 addition & 1 deletion packages/migrate/migrations/sveltekit-2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ export async function migrate() {
const cyan = colors.bold().cyan;

const tasks = [
'Run npm install (or the corresponding installation command of your package manager)',
use_git && cyan('git commit -m "migration to SvelteKit 2"'),
'Review the migration guide at https://kit.svelte.dev/docs/migrating-to-sveltekit-2',
`Search codebase for ${cyan('"@migration"')} and manually complete migration tasks`,
'Read the updated docs at https://kit.svelte.dev/docs'
].filter(Boolean);

Expand Down
3 changes: 2 additions & 1 deletion packages/migrate/migrations/sveltekit-2/migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ function add_cookie_note(file_path, source) {

const logger = log_on_ts_modification(
source,
'Remember to add the `path` option to `cookies.set/delete/serialize` calls: https://kit.svelte.dev/docs/migrating-to-sveltekit-2#path-is-now-a-required-option-for-cookies'
'Search codebase for `@migration` and manually add the `path` option to `cookies.set/delete/serialize` calls: https://kit.svelte.dev/docs/migrating-to-sveltekit-2#path-is-now-a-required-option-for-cookies'
);

const calls = [];
Expand Down Expand Up @@ -240,6 +240,7 @@ function add_cookie_note(file_path, source) {
if (
expression_text !== 'cookies' &&
(!expression_text.includes('.') ||
expression_text.split('.').pop() !== 'cookies' ||
!parent_function.getParameter(expression_text.split('.')[0]))
) {
continue;
Expand Down
8 changes: 8 additions & 0 deletions packages/migrate/migrations/sveltekit-2/tsjs-samples.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ export function foo(event) {
x.cookies.set('foo', 'bar');
}

export function bar(event) {
event.x.set('foo', 'bar');
}

cookies.set('foo', 'bar');
```

Expand All @@ -113,6 +117,10 @@ export function foo(event) {
x.cookies.set('foo', 'bar');
}

export function bar(event) {
event.x.set('foo', 'bar');
}

cookies.set('foo', 'bar');
```

Expand Down

0 comments on commit 0f52005

Please sign in to comment.