Skip to content

Commit

Permalink
fix: note @migration comments, fix cookie migration (#11331)
Browse files Browse the repository at this point in the history
fixes #11327

---------

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
  • Loading branch information
hyunbinseo and dummdidumm authored Dec 15, 2023
1 parent f0dcc76 commit 88ce6b0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/honest-badgers-itch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte-migrate': patch
---

fix: adjust cookie migration logic, note installation
3 changes: 2 additions & 1 deletion packages/migrate/migrations/sveltekit-2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import {
update_svelte_file,
update_tsconfig
} from '../../utils.js';
import { migrate as migrate_svelte_4 } from '../svelte-4/index.js';
import {
transform_code,
update_pkg_json,
update_svelte_config,
update_tsconfig_content
} from './migrate.js';
import { migrate as migrate_svelte_4 } from '../svelte-4/index.js';

export async function migrate() {
if (!fs.existsSync('package.json')) {
Expand Down Expand Up @@ -148,6 +148,7 @@ 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',
'Read the updated docs at https://kit.svelte.dev/docs'
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 88ce6b0

Please sign in to comment.