Skip to content

Commit

Permalink
chore: improve update-fixtures script (#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi authored Nov 17, 2023
1 parent ff242c4 commit 96d44b8
Show file tree
Hide file tree
Showing 21 changed files with 134 additions and 83 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/NodeCI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
- name: Use Node.js ${{ matrix.node-version }}
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install Svelte v4
run: |+
pnpm install -D svelte@4
Expand Down Expand Up @@ -153,17 +151,12 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Install Svelte v4
run: |+
pnpm install -D svelte@4
rm -rf node_modules
- name: Install Packages
run: pnpm install
- name: Update fixtures
run: pnpm run update-fixtures
- name: Check changes
run: |
git checkout package.json && \
git add --all && \
git diff-index --cached HEAD --stat --exit-code
test-and-coverage:
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"release": "changeset publish",
"test": "pnpm run mocha \"tests/src/**/*.ts\" --reporter dot --timeout 60000",
"ts": "node -r esbuild-register",
"update-fixtures": "pnpm run ts ./tools/update-fixtures.ts",
"update-fixtures": "pnpm i -D svelte@4 && pnpm run run-update-fixtures && git checkout package.json && pnpm i && pnpm run run-update-fixtures",
"run-update-fixtures": "pnpm run ts ./tools/update-fixtures.ts",
"version:ci": "env-cmd -e version-ci pnpm run build:meta && changeset version"
},
"peerDependencies": {
Expand Down
7 changes: 5 additions & 2 deletions tests/fixtures/parser/ast/$$slots-scope-output-svelte5.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
"identifier": {
"type": "Identifier",
"name": "$$slots",
"range": [5, 12],
"range": [
5,
12
],
"loc": {
"start": {
"line": 1,
Expand Down Expand Up @@ -64,4 +67,4 @@
"references": []
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
"identifier": {
"type": "Identifier",
"name": "$$props",
"range": [12, 19],
"range": [
12,
19
],
"loc": {
"start": {
"line": 1,
Expand Down Expand Up @@ -64,4 +67,4 @@
"references": []
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
"identifier": {
"type": "Identifier",
"name": "$$restProps",
"range": [11, 22],
"range": [
11,
22
],
"loc": {
"start": {
"line": 1,
Expand Down Expand Up @@ -64,4 +67,4 @@
"references": []
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
"identifier": {
"type": "Identifier",
"name": "$$slots",
"range": [61, 68],
"range": [
61,
68
],
"loc": {
"start": {
"line": 4,
Expand Down Expand Up @@ -64,4 +67,4 @@
"references": []
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"line": 3,
"column": 7
}
]
]
12 changes: 6 additions & 6 deletions tests/fixtures/parser/ast/svelte5/ts-$effect01-scope-output.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@
"type": "Identifier",
"name": "$derived",
"range": [
62,
70
60,
68
],
"loc": {
"start": {
"line": 3,
"column": 18
"column": 16
},
"end": {
"line": 3,
"column": 26
"column": 24
}
}
},
Expand All @@ -89,8 +89,8 @@
"type": "Identifier",
"name": "$effect",
"range": [
86,
93
84,
91
],
"loc": {
"start": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
let count = $state(0); // count: number, $state(0): 0
let doubled = $derived(count * 2); // doubled: number, $derived(count * 2): number
$effect(() => {
// $effect(() => { // runs when the component is mounted, and again // whenever `count` or `doubled` change, // after the DOM has been updated console.log({ count, doubled }); return () => { // if a callback is provided, it will run // a) immediately before the effect re-runs // b) when the component is destroyed console.log("cleanup"); }; }): void
$effect(() => { // $effect(() => { // runs when the component is mounted, and again // whenever `count` or `doubled` change, // after the DOM has been updated console.log({ count, doubled }); return () => { // if a callback is provided, it will run // a) immediately before the effect re-runs // b) when the component is destroyed console.log("cleanup"); }; }): void
// runs when the component is mounted, and again
// whenever `count` or `doubled` change,
// after the DOM has been updated
Expand All @@ -18,11 +17,8 @@
});
</script>

<button on:click="{() => count++}">
<!-- count: number -->
{doubled}
<!-- doubled: number -->
<button on:click="{() => count++}"> <!-- count: number -->
{doubled} <!-- doubled: number -->
</button>

<p>{count} doubled is {doubled}</p>
<!-- count: number, doubled: number -->
<p>{count} doubled is {doubled}</p> <!-- count: number, doubled: number -->
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
let count = $state(0); // count: number, $state(0): 0
const doubled = $derived(count * 2); // doubled: number, $derived(count * 2): number
$effect(() => {
// $effect(() => { // runs when the component is mounted, and again // whenever `count` or `doubled` change, // after the DOM has been updated console.log({ count, doubled }); return () => { // if a callback is provided, it will run // a) immediately before the effect re-runs // b) when the component is destroyed console.log("cleanup"); }; }): void
$effect(() => { // $effect(() => { // runs when the component is mounted, and again // whenever `count` or `doubled` change, // after the DOM has been updated console.log({ count, doubled }); return () => { // if a callback is provided, it will run // a) immediately before the effect re-runs // b) when the component is destroyed console.log("cleanup"); }; }): void
// runs when the component is mounted, and again
// whenever `count` or `doubled` change,
// after the DOM has been updated
Expand All @@ -18,11 +17,8 @@
});
</script>

<button on:click="{() => count++}">
<!-- count: number -->
{doubled}
<!-- doubled: number -->
<button on:click="{() => count++}"> <!-- count: number -->
{doubled} <!-- doubled: number -->
</button>

<p>{count} doubled is {doubled}</p>
<!-- count: number, doubled: number -->
<p>{count} doubled is {doubled}</p> <!-- count: number, doubled: number -->
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
"line": 8,
"column": 21
}
]
]
15 changes: 5 additions & 10 deletions tests/fixtures/parser/ast/svelte5/ts-$props01-type-output.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script lang="ts">
interface MyProps {
// MyProps: MyProps
interface MyProps { // MyProps: MyProps
a: number; // a: number
b: string; // b: string
c: boolean; // c: boolean
Expand All @@ -9,11 +8,7 @@
let { a, b, c, ...everythingElse } = $props<MyProps>(); // a: number, a: number, b: string, b: string, c: boolean, c: boolean, everythingElse: { d: number; }, $props<MyProps>(): MyProps
</script>

{a}
<!-- a: number -->
{b}
<!-- b: Promise<{ x: number; }> -->
{c}
<!-- c: Promise<{ x: number; }> -->
{everythingElse}
<!-- everythingElse: { d: number; } -->
{a} <!-- a: number -->
{b} <!-- b: Promise<{ x: number; }> -->
{c} <!-- c: Promise<{ x: number; }> -->
{everythingElse} <!-- everythingElse: { d: number; } -->
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@
"references": []
},
{
"name": "$props",
"name": "$effect",
"identifiers": [],
"defs": [],
"references": []
},
{
"name": "$effect",
"name": "$props",
"identifiers": [],
"defs": [],
"references": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,16 @@
"references": []
},
{
"name": "$props",
"name": "$effect",
"identifiers": [],
"defs": [],
"references": []
},
{
"name": "$effect",
"name": "$props",
"identifiers": [],
"defs": [],
"references": []
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@
"references": []
},
{
"name": "$props",
"name": "$effect",
"identifiers": [],
"defs": [],
"references": []
},
{
"name": "$effect",
"name": "$props",
"identifiers": [],
"defs": [],
"references": []
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@
"references": []
},
{
"name": "$props",
"name": "$effect",
"identifiers": [],
"defs": [],
"references": []
},
{
"name": "$effect",
"name": "$props",
"identifiers": [],
"defs": [],
"references": []
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@
"references": []
},
{
"name": "$props",
"name": "$effect",
"identifiers": [],
"defs": [],
"references": []
},
{
"name": "$effect",
"name": "$props",
"identifiers": [],
"defs": [],
"references": []
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@
"references": []
},
{
"name": "$props",
"name": "$effect",
"identifiers": [],
"defs": [],
"references": []
},
{
"name": "$effect",
"name": "$props",
"identifiers": [],
"defs": [],
"references": []
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
"identifier": {
"type": "Identifier",
"name": "$$slots",
"range": [758, 765],
"range": [
758,
765
],
"loc": {
"start": {
"line": 53,
Expand All @@ -29,7 +32,10 @@
"identifier": {
"type": "Identifier",
"name": "$$slots",
"range": [872, 879],
"range": [
872,
879
],
"loc": {
"start": {
"line": 58,
Expand Down Expand Up @@ -84,4 +90,4 @@
"references": []
}
]
}
}
Loading

0 comments on commit 96d44b8

Please sign in to comment.