sv 0.5.4 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/dist/bin.js +50 -32
- package/dist/bin.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
# sv - the Svelte CLI
|
|
2
2
|
|
|
3
|
-
A command line interface (CLI) for creating and maintaining [Svelte](https://svelte.dev) applications. Just run
|
|
3
|
+
A command line interface (CLI) for creating and maintaining [Svelte](https://svelte.dev) applications. Just run:
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
6
|
npx sv
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
...and follow the prompts.
|
|
10
|
-
|
|
11
9
|
## Acknowledgements
|
|
12
10
|
|
|
13
11
|
Thank you to [Christopher Brown](https://github.com/chbrown) who originally owned the `sv` name on npm for graciously allowing it to be used for this package. You can find the original `sv` package at [`@chbrown/sv`](https://www.npmjs.com/package/@chbrown/sv).
|
|
14
12
|
|
|
15
13
|
This project was formed by merging the `create-svelte` and `svelte-add` CLIs. Thank you to [J](https://github.com/babichjacob) for starting the community-led `svelte-add` project and to the [`svelte-add` contributors](https://github.com/svelte-add/svelte-add/graphs/contributors).
|
|
16
14
|
|
|
15
|
+
## Changelog
|
|
16
|
+
|
|
17
|
+
[Changelog](./CHANGELOG.md)
|
|
18
|
+
|
|
17
19
|
## License
|
|
18
20
|
|
|
19
21
|
[MIT](../../LICENSE)
|
package/dist/bin.js
CHANGED
|
@@ -25,7 +25,7 @@ import require$$0$3 from 'events';
|
|
|
25
25
|
import { t as templates, c as create$2 } from './index-A89HFWzv.js';
|
|
26
26
|
|
|
27
27
|
var name = "sv";
|
|
28
|
-
var version = "0.5.
|
|
28
|
+
var version = "0.5.5";
|
|
29
29
|
var type = "module";
|
|
30
30
|
var description = "A CLI for creating and updating SvelteKit projects";
|
|
31
31
|
var license = "MIT";
|
|
@@ -48693,6 +48693,17 @@ function addEslintConfigPrettier({ content }) {
|
|
|
48693
48693
|
}
|
|
48694
48694
|
return generateCode();
|
|
48695
48695
|
}
|
|
48696
|
+
function addToDemoPage({ content }, path) {
|
|
48697
|
+
const { template, generateCode } = parseSvelte(content);
|
|
48698
|
+
for (const node of template.ast.childNodes) {
|
|
48699
|
+
if (node.type === "tag" && node.attribs["href"] === `/demo/${path}`) {
|
|
48700
|
+
return content;
|
|
48701
|
+
}
|
|
48702
|
+
}
|
|
48703
|
+
const newLine = template.source ? "\n" : "";
|
|
48704
|
+
const src = template.source + `${newLine}<a href="/demo/${path}">${path}</a>`;
|
|
48705
|
+
return generateCode({ template: src });
|
|
48706
|
+
}
|
|
48696
48707
|
|
|
48697
48708
|
var eslint = defineAdder({
|
|
48698
48709
|
id: "eslint",
|
|
@@ -50480,6 +50491,11 @@ ${sessionType}`);
|
|
|
50480
50491
|
},
|
|
50481
50492
|
// DEMO
|
|
50482
50493
|
// login/register
|
|
50494
|
+
{
|
|
50495
|
+
name: ({ kit: kit2 }) => `${kit2?.routesDirectory}/demo/+page.svelte`,
|
|
50496
|
+
condition: ({ options: options2 }) => options2.demo,
|
|
50497
|
+
content: (editor) => addToDemoPage(editor, "lucia")
|
|
50498
|
+
},
|
|
50483
50499
|
{
|
|
50484
50500
|
name: ({ kit: kit2, typescript }) => `${kit2.routesDirectory}/demo/lucia/login/+page.server.${typescript ? "ts" : "js"}`,
|
|
50485
50501
|
condition: ({ options: options2 }) => options2.demo,
|
|
@@ -51008,6 +51024,11 @@ var paraglide = defineAdder({
|
|
|
51008
51024
|
return generateCode();
|
|
51009
51025
|
}
|
|
51010
51026
|
},
|
|
51027
|
+
{
|
|
51028
|
+
name: ({ kit: kit2 }) => `${kit2?.routesDirectory}/demo/+page.svelte`,
|
|
51029
|
+
condition: ({ options: options2 }) => options2.demo,
|
|
51030
|
+
content: (editor) => addToDemoPage(editor, "paraglide")
|
|
51031
|
+
},
|
|
51011
51032
|
{
|
|
51012
51033
|
// add usage example
|
|
51013
51034
|
name: ({ kit: kit2 }) => `${kit2?.routesDirectory}/demo/paraglide/+page.svelte`,
|
|
@@ -51662,7 +51683,7 @@ async function runCommand(action) {
|
|
|
51662
51683
|
} catch (e) {
|
|
51663
51684
|
cancel("Operation failed.");
|
|
51664
51685
|
if (e instanceof Error) {
|
|
51665
|
-
console.error(e.
|
|
51686
|
+
console.error(e.stack ?? e);
|
|
51666
51687
|
}
|
|
51667
51688
|
}
|
|
51668
51689
|
}
|
|
@@ -51675,27 +51696,24 @@ async function formatFiles(cwd, paths) {
|
|
|
51675
51696
|
});
|
|
51676
51697
|
}
|
|
51677
51698
|
async function suggestInstallingDependencies(cwd) {
|
|
51678
|
-
const
|
|
51679
|
-
|
|
51680
|
-
const agents = AGENTS.filter((
|
|
51681
|
-
const options = agents.map((
|
|
51699
|
+
const detected = detectSync({ cwd });
|
|
51700
|
+
const agent = detected?.agent ?? getUserAgent() ?? null;
|
|
51701
|
+
const agents = AGENTS.filter((agent2) => !agent2.includes("@"));
|
|
51702
|
+
const options = agents.map((pm2) => ({ value: pm2, label: pm2 }));
|
|
51682
51703
|
options.unshift({ label: "None", value: null });
|
|
51683
|
-
|
|
51684
|
-
|
|
51685
|
-
|
|
51686
|
-
|
|
51687
|
-
|
|
51688
|
-
|
|
51689
|
-
|
|
51690
|
-
|
|
51691
|
-
process$1$1.exit(1);
|
|
51692
|
-
}
|
|
51693
|
-
selectedPm = pm;
|
|
51704
|
+
const pm = await select({
|
|
51705
|
+
message: "Which package manager do you want to install dependencies with?",
|
|
51706
|
+
options,
|
|
51707
|
+
initialValue: agent
|
|
51708
|
+
});
|
|
51709
|
+
if (isCancel(pm)) {
|
|
51710
|
+
cancel("Operation cancelled.");
|
|
51711
|
+
process$1$1.exit(1);
|
|
51694
51712
|
}
|
|
51695
|
-
if (!
|
|
51713
|
+
if (!pm) {
|
|
51696
51714
|
return "skipped";
|
|
51697
51715
|
}
|
|
51698
|
-
const { command, args } = constructCommand(COMMANDS[
|
|
51716
|
+
const { command, args } = constructCommand(COMMANDS[pm].install, []);
|
|
51699
51717
|
const loadingSpinner = spinner();
|
|
51700
51718
|
loadingSpinner.start("Installing dependencies...");
|
|
51701
51719
|
await installDependencies(command, args, cwd);
|
|
@@ -55248,7 +55266,8 @@ const add = new Command("add").description("applies specified integrations into
|
|
|
55248
55266
|
}
|
|
55249
55267
|
const selectedAdders = transformAliases(specifiedAdders);
|
|
55250
55268
|
runCommand(async () => {
|
|
55251
|
-
await runAddCommand(options, selectedAdders);
|
|
55269
|
+
const { nextSteps } = await runAddCommand(options, selectedAdders);
|
|
55270
|
+
if (nextSteps) box(nextSteps, "Next steps");
|
|
55252
55271
|
});
|
|
55253
55272
|
});
|
|
55254
55273
|
for (const option of addersOptions) {
|
|
@@ -55532,7 +55551,7 @@ Available options: ${communityAdderIds.join(", ")}`
|
|
|
55532
55551
|
}
|
|
55533
55552
|
}
|
|
55534
55553
|
const highlighter = getHighlighter();
|
|
55535
|
-
const
|
|
55554
|
+
const nextSteps = selectedAdders.filter(({ adder }) => adder.nextSteps).map(({ adder }) => {
|
|
55536
55555
|
let adderMessage = "";
|
|
55537
55556
|
if (selectedAdders.length > 1) {
|
|
55538
55557
|
adderMessage = `${pc.green(adder.id)}:
|
|
@@ -55545,8 +55564,8 @@ Available options: ${communityAdderIds.join(", ")}`
|
|
|
55545
55564
|
});
|
|
55546
55565
|
adderMessage += `- ${adderNextSteps.join("\n- ")}`;
|
|
55547
55566
|
return adderMessage;
|
|
55548
|
-
}).join("\n\n");
|
|
55549
|
-
|
|
55567
|
+
}).join("\n\n") || void 0;
|
|
55568
|
+
return { nextSteps };
|
|
55550
55569
|
}
|
|
55551
55570
|
async function runAdders({
|
|
55552
55571
|
cwd,
|
|
@@ -55688,7 +55707,7 @@ const create = new Command("create").description("scaffolds a new SvelteKit proj
|
|
|
55688
55707
|
const cwd = parse$8(ProjectPathSchema, projectPath);
|
|
55689
55708
|
const options = parse$8(OptionsSchema, opts);
|
|
55690
55709
|
runCommand(async () => {
|
|
55691
|
-
const { directory } = await createProject(cwd, options);
|
|
55710
|
+
const { directory, integrationNextSteps } = await createProject(cwd, options);
|
|
55692
55711
|
const highlight = (str) => pc.bold(pc.cyan(str));
|
|
55693
55712
|
let i = 1;
|
|
55694
55713
|
const initialSteps = [];
|
|
@@ -55710,6 +55729,7 @@ const create = new Command("create").description("scaffolds a new SvelteKit proj
|
|
|
55710
55729
|
`Stuck? Visit us at ${pc.cyan("https://svelte.dev/chat")}`
|
|
55711
55730
|
];
|
|
55712
55731
|
box(steps.join("\n"), "Project next steps");
|
|
55732
|
+
if (integrationNextSteps) box(integrationNextSteps, "Integration next steps");
|
|
55713
55733
|
});
|
|
55714
55734
|
});
|
|
55715
55735
|
async function createProject(cwd, options) {
|
|
@@ -55765,27 +55785,25 @@ async function createProject(cwd, options) {
|
|
|
55765
55785
|
}
|
|
55766
55786
|
}
|
|
55767
55787
|
);
|
|
55768
|
-
const initSpinner = spinner();
|
|
55769
|
-
initSpinner.start("Initializing template");
|
|
55770
55788
|
const projectPath = path$3.resolve(directory);
|
|
55771
55789
|
create$2(projectPath, {
|
|
55772
55790
|
name: path$3.basename(projectPath),
|
|
55773
55791
|
template,
|
|
55774
55792
|
types: language
|
|
55775
55793
|
});
|
|
55776
|
-
|
|
55794
|
+
log$1.success("Project created");
|
|
55795
|
+
let integrationNextSteps;
|
|
55777
55796
|
if (options.integrations) {
|
|
55778
|
-
await runAddCommand(
|
|
55797
|
+
const { nextSteps } = await runAddCommand(
|
|
55779
55798
|
{ cwd: projectPath, install: false, preconditions: true, community: [] },
|
|
55780
55799
|
[]
|
|
55781
55800
|
);
|
|
55801
|
+
integrationNextSteps = nextSteps;
|
|
55782
55802
|
}
|
|
55783
55803
|
if (options.install) {
|
|
55784
55804
|
await suggestInstallingDependencies(projectPath);
|
|
55785
55805
|
}
|
|
55786
|
-
return {
|
|
55787
|
-
directory: projectPath
|
|
55788
|
-
};
|
|
55806
|
+
return { directory: projectPath, integrationNextSteps };
|
|
55789
55807
|
}
|
|
55790
55808
|
|
|
55791
55809
|
const migrate = new Command("migrate").description("a CLI for migrating Svelte(Kit) codebases").argument("<migration>", "migration to run").option("-C, --cwd <path>", "path to working directory", process$1$1.cwd()).configureHelp({
|
|
@@ -55834,7 +55852,7 @@ function runCheck(cwd, args) {
|
|
|
55834
55852
|
}
|
|
55835
55853
|
}
|
|
55836
55854
|
|
|
55837
|
-
program.name(pkg.name).version(pkg.version, "-v").configureHelp(helpConfig);
|
|
55855
|
+
program.name(pkg.name).version(pkg.version, "-v, --version").configureHelp(helpConfig);
|
|
55838
55856
|
program.addCommand(create).addCommand(add).addCommand(migrate).addCommand(check);
|
|
55839
55857
|
program.parse();
|
|
55840
55858
|
//# sourceMappingURL=bin.js.map
|