Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: note @migration comments, fix cookie migration #11331

Merged
merged 2 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading