Skip to content

Commit db79f99

Browse files
committed
initial commit
0 parents  commit db79f99

File tree

122 files changed

+16368
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+16368
-0
lines changed

Diff for: .gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
node_modules
3+
dist
4+
package-lock.json
5+
yarn.lock
6+
vite.config.js.timestamp-*
7+
/packages/create-svelte/template/CHANGELOG.md

Diff for: .prettierrc

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"useTabs": true,
3+
"singleQuote": true,
4+
"trailingComma": "none",
5+
"printWidth": 100,
6+
"plugins": ["prettier-plugin-svelte"],
7+
"overrides": [
8+
{
9+
"files": ["*.svelte"],
10+
"options": {
11+
"bracketSameLine": false
12+
}
13+
},
14+
{
15+
"files": ["packages/*/README.md"],
16+
"options": {
17+
"useTabs": false,
18+
"tabWidth": 2
19+
}
20+
},
21+
{
22+
"files": [
23+
"**/CHANGELOG.md"
24+
],
25+
"options": {
26+
"requirePragma": true
27+
}
28+
}
29+
]
30+
}

Diff for: LICENSE

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright (c) 2024 [these people](https://github.com/sveltejs/cli/graphs/contributors)
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Diff for: README.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[![Chat](https://img.shields.io/discord/457912077277855764?label=chat&logo=discord)](https://svelte.dev/chat)
2+
3+
# sv - the Svelte CLI
4+
5+
Web development, streamlined. Read the [documentation](https://kit.svelte.dev/docs) to get started.
6+
7+
### Packages
8+
9+
| Package | Changelog |
10+
| --------------------------------------------------------------------------- | ------------------------------------------------------------- |
11+
| [sv](packages/cli) | [Changelog](packages/cli/CHANGELOG.md) |
12+
13+
[Additional adders](https://www.sveltesociety.dev/templates?category=svelte-add) are maintained by the community.
14+
15+
## Supporting Svelte
16+
17+
Svelte is an MIT-licensed open source project with its ongoing development made possible entirely by fantastic volunteers. If you'd like to support their efforts, please consider:
18+
19+
- [Becoming a backer on Open Collective](https://opencollective.com/svelte).
20+
21+
## License
22+
23+
[MIT](https://github.com/sveltejs/kit/blob/main/LICENSE)

Diff for: eslint.config.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import svelte_config from '@sveltejs/eslint-config';
2+
3+
/** @type {import('eslint').Linter.Config[]} */
4+
export default [
5+
...svelte_config,
6+
{
7+
rules: {
8+
'no-undef': 'off'
9+
}
10+
},
11+
{
12+
languageOptions: {
13+
parserOptions: {
14+
project: true
15+
}
16+
},
17+
rules: {
18+
'@typescript-eslint/await-thenable': 'error',
19+
'@typescript-eslint/no-unused-expressions': 'off',
20+
'@typescript-eslint/require-await': 'error',
21+
},
22+
ignores: [
23+
'packages/create-svelte/shared/**/*',
24+
'packages/create-svelte/templates/**/*',
25+
]
26+
}
27+
];

Diff for: package.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "sv-monorepo",
3+
"version": "0.0.1",
4+
"description": "monorepo for sv and friends",
5+
"private": true,
6+
"type": "module",
7+
"scripts": {
8+
"check": "pnpm -r check",
9+
"lint": "pnpm -r lint && eslint --cache --cache-location node_modules/.eslintcache 'packages/**/*.js'",
10+
"format": "pnpm -r format",
11+
"changeset:version": "changeset version && pnpm -r generate:version && git add --all",
12+
"changeset:release": "changeset publish",
13+
"build": "pnpm -r build"
14+
},
15+
"devDependencies": {
16+
"@changesets/cli": "^2.27.6",
17+
"@sveltejs/eslint-config": "^8.0.1",
18+
"@svitejs/changesets-changelog-github-compact": "^1.1.0",
19+
"eslint": "^9.6.0",
20+
"typescript-eslint": "^8.0.0"
21+
},
22+
"packageManager": "[email protected]",
23+
"engines": {
24+
"pnpm": "^9.0.0"
25+
}
26+
}

Diff for: packages/cli/.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/dist
2+
/.test-tmp
3+
4+
# re-enable this once we're out of prerelease
5+
/cli/versions.js
6+
7+
/templates/*/.svelte
8+
/templates/*/.svelte-kit
9+
/templates/*/build
10+
/templates/*/.cloudflare
11+
/templates/*/.vercel_build_output
12+
/templates/*/.netlify
13+
/templates/*/dist
14+
/templates/*/package

Diff for: packages/cli/README.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# sv - the Svelte CLI
2+
3+
A CLI for creating new [SvelteKit](https://kit.svelte.dev) projects and adding functionality to existing ones. Just run...
4+
5+
```bash
6+
npx sv
7+
```
8+
9+
...and follow the prompts.
10+
11+
## API
12+
13+
You can also use `sv` programmatically:
14+
15+
```js
16+
import { create } from 'sv';
17+
18+
await create('my-new-app', {
19+
name: 'my-new-app',
20+
template: 'default', // or 'skeleton' or 'skeletonlib'
21+
types: 'checkjs', // or 'typescript' or null;
22+
prettier: false,
23+
eslint: false,
24+
playwright: false,
25+
vitest: false
26+
});
27+
```
28+
29+
`checkjs` means your project will use TypeScript to typecheck JavaScript via [JSDoc comments](https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html).
30+
31+
## License
32+
33+
[MIT](../../LICENSE).

Diff for: packages/cli/bin.js

+149
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
#!/usr/bin/env node
2+
import fs from 'node:fs';
3+
import path from 'node:path';
4+
import * as p from '@clack/prompts';
5+
import { bold, cyan, grey, yellow } from 'kleur/colors';
6+
import { create } from './index.js';
7+
import { dist, package_manager } from './utils.js';
8+
9+
const { version } = JSON.parse(fs.readFileSync(new URL('package.json', import.meta.url), 'utf-8'));
10+
let cwd = process.argv[2] || '.';
11+
12+
console.log(`
13+
${grey(`create-svelte version ${version}`)}
14+
`);
15+
16+
p.intro('Welcome to SvelteKit!');
17+
18+
if (cwd === '.') {
19+
const dir = await p.text({
20+
message: 'Where should we create your project?',
21+
placeholder: ' (hit Enter to use current directory)'
22+
});
23+
24+
if (p.isCancel(dir)) process.exit(1);
25+
26+
if (dir) {
27+
cwd = /** @type {string} */ (dir);
28+
}
29+
}
30+
31+
if (fs.existsSync(cwd)) {
32+
if (fs.readdirSync(cwd).length > 0) {
33+
const force = await p.confirm({
34+
message: 'Directory not empty. Continue?',
35+
initialValue: false
36+
});
37+
38+
// bail if `force` is `false` or the user cancelled with Ctrl-C
39+
if (force !== true) {
40+
process.exit(1);
41+
}
42+
}
43+
}
44+
45+
const options = await p.group(
46+
{
47+
template: (_) =>
48+
p.select({
49+
message: 'Which Svelte app template?',
50+
options: fs.readdirSync(dist('templates')).map((dir) => {
51+
const meta_file = dist(`templates/${dir}/meta.json`);
52+
const { title, description } = JSON.parse(fs.readFileSync(meta_file, 'utf8'));
53+
54+
return {
55+
label: title,
56+
hint: description,
57+
value: dir
58+
};
59+
})
60+
}),
61+
62+
types: ({ results }) =>
63+
p.select({
64+
message: 'Add type checking with TypeScript?',
65+
initialValue: /** @type {'checkjs' | 'typescript' | null} */ (
66+
results.template === 'skeletonlib' ? 'checkjs' : 'typescript'
67+
),
68+
options: [
69+
{
70+
label: 'Yes, using TypeScript syntax',
71+
value: 'typescript'
72+
},
73+
{
74+
label: 'Yes, using JavaScript with JSDoc comments',
75+
value: 'checkjs'
76+
},
77+
{ label: 'No', value: null }
78+
]
79+
}),
80+
81+
features: () =>
82+
p.multiselect({
83+
message: 'Select additional options (use arrow keys/space bar)',
84+
required: false,
85+
options: [
86+
{
87+
value: 'eslint',
88+
label: 'Add ESLint for code linting'
89+
},
90+
{
91+
value: 'prettier',
92+
label: 'Add Prettier for code formatting'
93+
},
94+
{
95+
value: 'playwright',
96+
label: 'Add Playwright for browser testing'
97+
},
98+
{
99+
value: 'vitest',
100+
label: 'Add Vitest for unit testing'
101+
},
102+
{
103+
value: 'svelte5',
104+
label: 'Try the Svelte 5 preview (unstable!)'
105+
}
106+
]
107+
})
108+
},
109+
{ onCancel: () => process.exit(1) }
110+
);
111+
112+
await create(cwd, {
113+
name: path.basename(path.resolve(cwd)),
114+
template: /** @type {'default' | 'skeleton' | 'skeletonlib'} */ (options.template),
115+
types: /** @type {'checkjs' | 'typescript' | null} */ (options.types),
116+
prettier: options.features.includes('prettier'),
117+
eslint: options.features.includes('eslint'),
118+
playwright: options.features.includes('playwright'),
119+
vitest: options.features.includes('vitest'),
120+
svelte5: options.features.includes('svelte5')
121+
});
122+
123+
p.outro('Your project is ready!');
124+
125+
if (!options.types && options.template === 'skeletonlib') {
126+
const warning = yellow('▲');
127+
console.log(
128+
`${warning} You chose to not add type checking, but TypeScript will still be installed in order to generate type definitions when building the library\n`
129+
);
130+
}
131+
132+
console.log('Install more integrations with:');
133+
console.log(bold(cyan(' npx svelte-add')));
134+
135+
console.log('\nNext steps:');
136+
let i = 1;
137+
138+
const relative = path.relative(process.cwd(), cwd);
139+
if (relative !== '') {
140+
console.log(` ${i++}: ${bold(cyan(`cd ${relative}`))}`);
141+
}
142+
143+
console.log(` ${i++}: ${bold(cyan(`${package_manager} install`))}`);
144+
// prettier-ignore
145+
console.log(` ${i++}: ${bold(cyan('git init && git add -A && git commit -m "Initial commit"'))} (optional)`);
146+
console.log(` ${i++}: ${bold(cyan(`${package_manager} run dev -- --open`))}`);
147+
148+
console.log(`\nTo close the dev server, hit ${bold(cyan('Ctrl-C'))}`);
149+
console.log(`\nStuck? Visit us at ${cyan('https://svelte.dev/chat')}`);

0 commit comments

Comments
 (0)