Skip to content

Commit e30f712

Browse files
authored
Support for the Svelte 5 env. (#701)
1 parent 8cdcac3 commit e30f712

File tree

8 files changed

+42
-22
lines changed

8 files changed

+42
-22
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
1717

1818
## Unreleased
1919

20+
## [0.21.8](https://github.com/o1-labs/zkapp-cli/compare/0.21.7...0.21.8) - 2024-10-23
21+
22+
### Changed
23+
24+
- Svelte project scaffold now uses latest `sv create` and sources migrated to `Svelte 5`. [#701](https://github.com/o1-labs/zkapp-cli/pull/701)
25+
2026
## [0.21.7](https://github.com/o1-labs/zkapp-cli/compare/0.21.6...0.21.7) - 2024-10-01
2127

2228
### Changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zkapp-cli",
3-
"version": "0.21.7",
3+
"version": "0.21.8",
44
"description": "CLI to create zkApps (zero-knowledge apps) for Mina Protocol",
55
"homepage": "https://github.com/o1-labs/zkapp-cli/",
66
"repository": {

src/lib/project.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import url from 'node:url';
77
import util from 'node:util';
88
import ora from 'ora';
99
import shell from 'shelljs';
10-
import customNextPage from '../lib/ui/next/customNextPage.js';
1110
import customNextLayout from '../lib/ui/next/customNextLayout.js';
11+
import customNextPage from '../lib/ui/next/customNextPage.js';
1212
import customNuxtIndex from '../lib/ui/nuxt/customNuxtIndex.js';
1313
import nuxtGradientBackground from '../lib/ui/nuxt/nuxtGradientBackground.js';
1414
import customLayoutSvelte from '../lib/ui/svelte/customLayoutSvelte.js';
@@ -175,8 +175,7 @@ async function project({ name, ui }) {
175175
}
176176

177177
function scaffoldSvelte() {
178-
// `-y` installs the latest version of create-svelte without prompting.
179-
spawnSync('npm', ['create', 'svelte@latest', '-y', 'ui'], {
178+
spawnSync('npx', ['sv', 'create', 'ui'], {
180179
stdio: 'inherit',
181180
shell: true,
182181
});

src/lib/project.test.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -381,11 +381,10 @@ describe('project.js', () => {
381381

382382
expect(shell.mkdir).toHaveBeenCalledWith('-p', 'test-project');
383383
expect(shell.cd).toHaveBeenCalledWith('test-project');
384-
expect(spawnSync).toHaveBeenCalledWith(
385-
'npm',
386-
['create', 'svelte@latest', '-y', 'ui'],
387-
{ stdio: 'inherit', shell: true }
388-
);
384+
expect(spawnSync).toHaveBeenCalledWith('npx', ['sv', 'create', 'ui'], {
385+
stdio: 'inherit',
386+
shell: true,
387+
});
389388
expect(shell.cd).toHaveBeenCalledWith('contracts');
390389
checkUiProjectSetup(shell.exec.mock.calls);
391390
checkIfProjectSetupSuccessful();
@@ -678,11 +677,10 @@ describe('project.js', () => {
678677

679678
scaffoldSvelte();
680679

681-
expect(spawnSync).toHaveBeenCalledWith(
682-
'npm',
683-
['create', 'svelte@latest', '-y', 'ui'],
684-
{ stdio: 'inherit', shell: true }
685-
);
680+
expect(spawnSync).toHaveBeenCalledWith('npx', ['sv', 'create', 'ui'], {
681+
stdio: 'inherit',
682+
shell: true,
683+
});
686684
expect(fs.writeFileSync).toHaveBeenCalled();
687685
});
688686
});
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
export default `
22
<script>
33
import '../styles/globals.css'
4+
/**
5+
* @typedef {Object} Props
6+
* @property {import('svelte').Snippet} [children]
7+
*/
8+
9+
/** @type {Props} */
10+
let { children } = $props();
411
</script>
5-
<slot/>
12+
{@render children?.()}
613
`;

src/lib/ui/svelte/gradientBackground.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
export default `
22
<script>
33
import { onMount } from 'svelte'
4+
/**
5+
* @typedef {Object} Props
6+
* @property {import('svelte').Snippet} [children]
7+
*/
8+
9+
/** @type {Props} */
10+
let { children } = $props();
411
let ctx
512
let pixels = []
613
let canvas
@@ -131,9 +138,9 @@ export default `
131138
</style>
132139
133140
<div class="background">
134-
<canvas class="background-gradients" width="6" height="6" />
141+
<canvas class="background-gradients" width="6" height="6"></canvas>
135142
</div>
136143
<div class="container">
137-
<slot />
144+
{@render children?.()}
138145
</div>
139146
`;

tests/utils/project-utils.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ export async function zkProject(
4747
case 'svelte': {
4848
interactiveDialog = {
4949
...interactiveDialog,
50-
'Which Svelte app template?': ['arrowDown', 'enter'],
51-
'Add type checking with TypeScript?': ['arrowDown', 'enter'],
52-
'Select additional options (use arrow keys/space bar)': [
50+
'Which template would you like?': ['enter'],
51+
'Add type checking with Typescript?': ['enter'],
52+
'What would you like to add to your project?': [
5353
'space',
5454
'arrowDown',
5555
'space',
@@ -59,6 +59,9 @@ export async function zkProject(
5959
'space',
6060
'enter',
6161
],
62+
'Which package manager do you want to install dependencies with?': [
63+
'enter',
64+
],
6265
};
6366
break;
6467
}

0 commit comments

Comments
 (0)