From e8ac078b3251fdc4490de08d9d813d8fbbbee5f5 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Fri, 23 Apr 2021 19:10:55 -0400 Subject: [PATCH 1/5] update welcome message --- .changeset/flat-parrots-juggle.md | 5 +++++ packages/create-svelte/bin.js | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 .changeset/flat-parrots-juggle.md diff --git a/.changeset/flat-parrots-juggle.md b/.changeset/flat-parrots-juggle.md new file mode 100644 index 000000000000..eccb72fc0d73 --- /dev/null +++ b/.changeset/flat-parrots-juggle.md @@ -0,0 +1,5 @@ +--- +'create-svelte': patch +--- + +Update welcome message diff --git a/packages/create-svelte/bin.js b/packages/create-svelte/bin.js index a5dc3928dccc..8d8de6ab9266 100755 --- a/packages/create-svelte/bin.js +++ b/packages/create-svelte/bin.js @@ -6,18 +6,20 @@ import { bold, cyan, gray, green, red } from 'kleur/colors'; import prompts from 'prompts'; import { mkdirp, copy } from './utils.js'; +// prettier-ignore const disclaimer = ` -Welcome to the SvelteKit setup wizard! +${bold(cyan('Welcome to SvelteKit!'))} -SvelteKit is in public beta now. There are definitely bugs and some feature might not work yet. -If you encounter an issue, have a look at https://github.com/sveltejs/kit/issues and open a new one, if it is not already tracked. +${bold(red('This is beta software; expect bugs and missing features.'))} + +If you encounter a problem, open an issue on ${cyan('https://github.com/sveltejs/kit/issues')} if none exists already. `; const { version } = JSON.parse(fs.readFileSync(new URL('package.json', import.meta.url), 'utf-8')); async function main() { console.log(gray(`\ncreate-svelte version ${version}`)); - console.log(red(disclaimer)); + console.log(disclaimer); const cwd = process.argv[2] || '.'; From 5aa3801d124a9cea2b7c6f87486d065fc24f272b Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Fri, 23 Apr 2021 19:14:32 -0400 Subject: [PATCH 2/5] make our next steps consistent with our FAQ --- packages/create-svelte/bin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-svelte/bin.js b/packages/create-svelte/bin.js index 8d8de6ab9266..bff1d5178ebf 100755 --- a/packages/create-svelte/bin.js +++ b/packages/create-svelte/bin.js @@ -132,7 +132,7 @@ async function main() { // prettier-ignore console.log(` ${i++}: ${bold(cyan('git init && git add -A && git commit -m "Initial commit"'))} (optional step)`); - console.log(` ${i++}: ${bold(cyan('npm install'))} (or pnpm install, or yarn)`); + console.log(` ${i++}: ${bold(cyan('npm install'))} (or pnpm install, etc)`); console.log(` ${i++}: ${bold(cyan('npm run dev -- --open'))}`); console.log(`\nTo close the dev server, hit ${bold(cyan('Ctrl-C'))}`); From 2afcb5e4c19fc3cb72602ce58e6fd00b1bbad00a Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Fri, 23 Apr 2021 19:30:20 -0400 Subject: [PATCH 3/5] no adapter by default --- .changeset/late-glasses-sin.md | 5 +++++ .../shared/+typescript/svelte.config.cjs | 11 ++--------- .../shared/-typescript/svelte.config.cjs | 8 -------- .../templates/default/package.template.json | 1 - .../templates/skeleton/package.template.json | 1 - 5 files changed, 7 insertions(+), 19 deletions(-) create mode 100644 .changeset/late-glasses-sin.md diff --git a/.changeset/late-glasses-sin.md b/.changeset/late-glasses-sin.md new file mode 100644 index 000000000000..c48c73987131 --- /dev/null +++ b/.changeset/late-glasses-sin.md @@ -0,0 +1,5 @@ +--- +'create-svelte': patch +--- + +No adapter by default diff --git a/packages/create-svelte/shared/+typescript/svelte.config.cjs b/packages/create-svelte/shared/+typescript/svelte.config.cjs index 46d50cea5f57..9133017977fe 100644 --- a/packages/create-svelte/shared/+typescript/svelte.config.cjs +++ b/packages/create-svelte/shared/+typescript/svelte.config.cjs @@ -1,19 +1,12 @@ -const sveltePreprocess = require('svelte-preprocess'); -const node = require('@sveltejs/adapter-node'); -const pkg = require('./package.json'); +const preprocess = require('svelte-preprocess'); /** @type {import('@sveltejs/kit').Config} */ module.exports = { // Consult https://github.com/sveltejs/svelte-preprocess // for more information about preprocessors - preprocess: sveltePreprocess(), + preprocess: preprocess(), kit: { - // By default, `npm run build` will create a standard Node app. - // You can create optimized builds for different platforms by - // specifying a different adapter - adapter: node(), - // hydrate the
element in src/app.html target: '#svelte' } diff --git a/packages/create-svelte/shared/-typescript/svelte.config.cjs b/packages/create-svelte/shared/-typescript/svelte.config.cjs index e04420ed3c28..edb9c69ab38b 100644 --- a/packages/create-svelte/shared/-typescript/svelte.config.cjs +++ b/packages/create-svelte/shared/-typescript/svelte.config.cjs @@ -1,14 +1,6 @@ -const node = require('@sveltejs/adapter-node'); -const pkg = require('./package.json'); - /** @type {import('@sveltejs/kit').Config} */ module.exports = { kit: { - // By default, `npm run build` will create a standard Node app. - // You can create optimized builds for different platforms by - // specifying a different adapter - adapter: node(), - // hydrate the
element in src/app.html target: '#svelte' } diff --git a/packages/create-svelte/templates/default/package.template.json b/packages/create-svelte/templates/default/package.template.json index b00adcfafa69..4a943cd6a7d4 100644 --- a/packages/create-svelte/templates/default/package.template.json +++ b/packages/create-svelte/templates/default/package.template.json @@ -7,7 +7,6 @@ "preview": "svelte-kit preview" }, "devDependencies": { - "@sveltejs/adapter-node": "workspace:*", "@sveltejs/kit": "workspace:*", "svelte": "^3.29.0", "vite": "^2.1.0" diff --git a/packages/create-svelte/templates/skeleton/package.template.json b/packages/create-svelte/templates/skeleton/package.template.json index 6ce32c4b9b5c..aa7a58aa48db 100644 --- a/packages/create-svelte/templates/skeleton/package.template.json +++ b/packages/create-svelte/templates/skeleton/package.template.json @@ -7,7 +7,6 @@ "preview": "svelte-kit preview" }, "devDependencies": { - "@sveltejs/adapter-node": "workspace:*", "@sveltejs/kit": "workspace:*", "svelte": "^3.29.0", "vite": "^2.1.0" From e5a61f17a112fea196147fd0d29bd9eb18cded30 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Fri, 23 Apr 2021 19:31:11 -0400 Subject: [PATCH 4/5] replace references to npm start with npm run preview --- .changeset/tame-lobsters-beam.md | 6 ++++++ packages/adapter-static/test/apps/spa/README.md | 2 +- packages/kit/src/cli.js | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 .changeset/tame-lobsters-beam.md diff --git a/.changeset/tame-lobsters-beam.md b/.changeset/tame-lobsters-beam.md new file mode 100644 index 000000000000..c0a7783e26ca --- /dev/null +++ b/.changeset/tame-lobsters-beam.md @@ -0,0 +1,6 @@ +--- +'@sveltejs/adapter-static': patch +'@sveltejs/kit': patch +--- + +Remove references to npm start diff --git a/packages/adapter-static/test/apps/spa/README.md b/packages/adapter-static/test/apps/spa/README.md index eefd796f3175..82510ca06f50 100644 --- a/packages/adapter-static/test/apps/spa/README.md +++ b/packages/adapter-static/test/apps/spa/README.md @@ -35,4 +35,4 @@ Before creating a production version of your app, install an [adapter](https://k npm run build ``` -> You can preview the built app with `npm start`, regardless of whether you installed an adapter. This should _not_ be used to serve your app in production. +> You can preview the built app with `npm run preview`, regardless of whether you installed an adapter. This should _not_ be used to serve your app in production. diff --git a/packages/kit/src/cli.js b/packages/kit/src/cli.js index 096206645ebc..073c06eca888 100644 --- a/packages/kit/src/cli.js +++ b/packages/kit/src/cli.js @@ -116,7 +116,9 @@ prog const { build } = await import('./core/build/index.js'); const build_data = await build(config); - console.log(`\nRun ${colors.bold().cyan('npm start')} to try your app locally.`); + console.log( + `\nRun ${colors.bold().cyan('npm run preview')} to preview your production build locally.` + ); if (config.kit.adapter) { const { adapt } = await import('./core/adapt/index.js'); From 25736fdd22e4f2f84c4e87bbb0d9d370698cc391 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Fri, 23 Apr 2021 21:22:38 -0400 Subject: [PATCH 5/5] couple more simplifications --- .../templates/default/src/routes/todos/index.json.ts | 12 +++--------- .../templates/default/src/routes/todos/index.svelte | 9 ++------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/packages/create-svelte/templates/default/src/routes/todos/index.json.ts b/packages/create-svelte/templates/default/src/routes/todos/index.json.ts index f719477059ec..35b62f382c92 100644 --- a/packages/create-svelte/templates/default/src/routes/todos/index.json.ts +++ b/packages/create-svelte/templates/default/src/routes/todos/index.json.ts @@ -3,18 +3,12 @@ import type { RequestHandler } from '@sveltejs/kit'; // GET /todos.json export const get: RequestHandler = async (request) => { - if (!request.context.userid) { - // the user has never visited the site before - // and so doesn't yet have a userid, which is - // set in `handle`, in src/hooks.js - return { body: [] }; - } - + // request.context.userid comes from src/hooks.js const response = await api(request, `todos/${request.context.userid}`); if (response.status === 404) { - // the user has visited before, but hasn't yet - // created a todo list. start with an empty array + // user hasn't created a todo list. + // start with an empty array return { body: [] }; } diff --git a/packages/create-svelte/templates/default/src/routes/todos/index.svelte b/packages/create-svelte/templates/default/src/routes/todos/index.svelte index 020612557705..c460af0c8402 100644 --- a/packages/create-svelte/templates/default/src/routes/todos/index.svelte +++ b/packages/create-svelte/templates/default/src/routes/todos/index.svelte @@ -67,12 +67,7 @@
{ - const done = !!data.get('done'); - - todos = todos.map(t => { - if (t === todo) return { ...t, done }; - return t; - }); + todo.done = !!data.get('done'); }, result: patch }}> @@ -205,4 +200,4 @@ transition: opacity 0.2s; opacity: 1; } - \ No newline at end of file +