sv 0.5.6 → 0.5.8
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/dist/bin.js +85 -89
- package/dist/bin.js.map +1 -1
- package/dist/shared.json +3 -3
- package/dist/templates/demo/files.types=checkjs.json +1 -1
- package/dist/templates/demo/files.types=typescript.json +1 -1
- package/dist/templates/library/files.types=checkjs.json +1 -1
- package/dist/templates/library/files.types=typescript.json +1 -1
- package/dist/templates/minimal/files.types=checkjs.json +1 -1
- package/dist/templates/minimal/files.types=typescript.json +1 -1
- package/package.json +2 -2
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.8";
|
|
29
29
|
var type = "module";
|
|
30
30
|
var description = "A CLI for creating and updating SvelteKit projects";
|
|
31
31
|
var license = "MIT";
|
|
@@ -48593,14 +48593,18 @@ var drizzle = defineAdder({
|
|
|
48593
48593
|
}
|
|
48594
48594
|
}
|
|
48595
48595
|
],
|
|
48596
|
-
nextSteps: ({ options: options2, highlighter }) => {
|
|
48596
|
+
nextSteps: ({ options: options2, highlighter, packageManager }) => {
|
|
48597
48597
|
const steps = [
|
|
48598
48598
|
`You will need to set ${highlighter.env("DATABASE_URL")} in your production environment`
|
|
48599
48599
|
];
|
|
48600
48600
|
if (options2.docker) {
|
|
48601
|
-
steps.push(
|
|
48601
|
+
steps.push(
|
|
48602
|
+
`Run ${highlighter.command(`${packageManager} run db:start`)} to start the docker container`
|
|
48603
|
+
);
|
|
48602
48604
|
}
|
|
48603
|
-
steps.push(
|
|
48605
|
+
steps.push(
|
|
48606
|
+
`Run ${highlighter.command(`${packageManager} run db:push`)} to update your database schema`
|
|
48607
|
+
);
|
|
48604
48608
|
return steps;
|
|
48605
48609
|
}
|
|
48606
48610
|
});
|
|
@@ -50194,7 +50198,7 @@ const options$2 = defineAdderOptions({
|
|
|
50194
50198
|
var lucia = defineAdder({
|
|
50195
50199
|
id: "lucia",
|
|
50196
50200
|
environments: { svelte: false, kit: true },
|
|
50197
|
-
homepage: "https://lucia-
|
|
50201
|
+
homepage: "https://lucia-auth.com",
|
|
50198
50202
|
options: options$2,
|
|
50199
50203
|
packages: [
|
|
50200
50204
|
{ name: "@oslojs/crypto", version: "^1.0.1", dev: false },
|
|
@@ -50700,8 +50704,10 @@ ${sessionType}`);
|
|
|
50700
50704
|
}
|
|
50701
50705
|
}
|
|
50702
50706
|
],
|
|
50703
|
-
nextSteps: ({ highlighter, options: options2 }) => {
|
|
50704
|
-
const steps = [
|
|
50707
|
+
nextSteps: ({ highlighter, options: options2, packageManager }) => {
|
|
50708
|
+
const steps = [
|
|
50709
|
+
`Run ${highlighter.command(`${packageManager} run db:push`)} to update your database schema`
|
|
50710
|
+
];
|
|
50705
50711
|
if (options2.demo) {
|
|
50706
50712
|
steps.push(`Visit ${highlighter.route("/demo/lucia")} route to view the demo`);
|
|
50707
50713
|
}
|
|
@@ -51687,55 +51693,40 @@ async function runCommand(action) {
|
|
|
51687
51693
|
}
|
|
51688
51694
|
}
|
|
51689
51695
|
}
|
|
51690
|
-
async function formatFiles(
|
|
51691
|
-
const
|
|
51692
|
-
const
|
|
51693
|
-
|
|
51694
|
-
await be(cmd.command, cmd.args, {
|
|
51695
|
-
nodeOptions: { cwd, stdio: "pipe" }
|
|
51696
|
-
});
|
|
51696
|
+
async function formatFiles(options) {
|
|
51697
|
+
const args = ["prettier", "--write", "--ignore-unknown", ...options.paths];
|
|
51698
|
+
const cmd = resolveCommand(options.packageManager, "execute-local", args);
|
|
51699
|
+
await be(cmd.command, cmd.args, { nodeOptions: { cwd: options.cwd, stdio: "pipe" } });
|
|
51697
51700
|
}
|
|
51698
|
-
|
|
51701
|
+
const agents = AGENTS.filter((agent) => !agent.includes("@"));
|
|
51702
|
+
const agentOptions = agents.map((pm) => ({ value: pm, label: pm }));
|
|
51703
|
+
agentOptions.unshift({ label: "None", value: void 0 });
|
|
51704
|
+
async function packageManagerPrompt(cwd) {
|
|
51699
51705
|
const detected = detectSync({ cwd });
|
|
51700
|
-
const agent = detected?.
|
|
51701
|
-
const agents = AGENTS.filter((agent2) => !agent2.includes("@"));
|
|
51702
|
-
const options = agents.map((pm2) => ({ value: pm2, label: pm2 }));
|
|
51703
|
-
options.unshift({ label: "None", value: null });
|
|
51706
|
+
const agent = detected?.name ?? getUserAgent();
|
|
51704
51707
|
const pm = await select({
|
|
51705
51708
|
message: "Which package manager do you want to install dependencies with?",
|
|
51706
|
-
options,
|
|
51709
|
+
options: agentOptions,
|
|
51707
51710
|
initialValue: agent
|
|
51708
51711
|
});
|
|
51709
51712
|
if (isCancel(pm)) {
|
|
51710
51713
|
cancel("Operation cancelled.");
|
|
51711
51714
|
process$1$1.exit(1);
|
|
51712
51715
|
}
|
|
51713
|
-
|
|
51714
|
-
return "skipped";
|
|
51715
|
-
}
|
|
51716
|
-
const { command, args } = constructCommand(COMMANDS[pm].install, []);
|
|
51717
|
-
const loadingSpinner = spinner();
|
|
51718
|
-
loadingSpinner.start("Installing dependencies...");
|
|
51719
|
-
await installDependencies(command, args, cwd);
|
|
51720
|
-
packageManager = command;
|
|
51721
|
-
loadingSpinner.stop("Successfully installed dependencies");
|
|
51722
|
-
return "installed";
|
|
51716
|
+
return pm;
|
|
51723
51717
|
}
|
|
51724
|
-
async function installDependencies(
|
|
51718
|
+
async function installDependencies(agent, cwd) {
|
|
51719
|
+
const spinner$1 = spinner();
|
|
51720
|
+
spinner$1.start("Installing dependencies...");
|
|
51725
51721
|
try {
|
|
51722
|
+
const { command, args } = constructCommand(COMMANDS[agent].install, []);
|
|
51726
51723
|
await be(command, args, { nodeOptions: { cwd } });
|
|
51724
|
+
spinner$1.stop("Successfully installed dependencies");
|
|
51727
51725
|
} catch (error) {
|
|
51728
|
-
|
|
51729
|
-
throw
|
|
51726
|
+
spinner$1.stop("Failed to install dependencies", 2);
|
|
51727
|
+
throw error;
|
|
51730
51728
|
}
|
|
51731
51729
|
}
|
|
51732
|
-
let packageManager;
|
|
51733
|
-
function detectPackageManager(cwd) {
|
|
51734
|
-
if (packageManager) return packageManager;
|
|
51735
|
-
const pm = detectSync({ cwd });
|
|
51736
|
-
if (pm?.name) packageManager = pm.name;
|
|
51737
|
-
return pm?.name ?? getUserAgent() ?? "npm";
|
|
51738
|
-
}
|
|
51739
51730
|
function getUserAgent() {
|
|
51740
51731
|
const userAgent = process$1$1.env.npm_config_user_agent;
|
|
51741
51732
|
if (!userAgent) return void 0;
|
|
@@ -55111,27 +55102,18 @@ function getHighlighter() {
|
|
|
55111
55102
|
};
|
|
55112
55103
|
}
|
|
55113
55104
|
|
|
55114
|
-
function
|
|
55115
|
-
|
|
55116
|
-
|
|
55117
|
-
|
|
55118
|
-
dependencyVersion: (_pkg) => void 0,
|
|
55119
|
-
typescript: false,
|
|
55120
|
-
kit: void 0
|
|
55121
|
-
};
|
|
55122
|
-
}
|
|
55123
|
-
function createWorkspace(cwd) {
|
|
55124
|
-
const workspace = createEmptyWorkspace();
|
|
55125
|
-
workspace.cwd = path$3.resolve(cwd);
|
|
55126
|
-
let usesTypescript = fs$3.existsSync(path$3.join(cwd, commonFilePaths.viteConfigTS));
|
|
55105
|
+
function createWorkspace({ cwd, packageManager }) {
|
|
55106
|
+
const resolvedCwd = path$3.resolve(cwd);
|
|
55107
|
+
const viteConfigPath = path$3.join(resolvedCwd, commonFilePaths.viteConfigTS);
|
|
55108
|
+
let usesTypescript = fs$3.existsSync(viteConfigPath);
|
|
55127
55109
|
if (TESTING) {
|
|
55128
|
-
usesTypescript || (usesTypescript = fs$3.existsSync(path$3.join(
|
|
55110
|
+
usesTypescript || (usesTypescript = fs$3.existsSync(path$3.join(resolvedCwd, commonFilePaths.tsconfig)));
|
|
55129
55111
|
} else {
|
|
55130
55112
|
usesTypescript || (usesTypescript = up$1(commonFilePaths.tsconfig, { cwd }) !== void 0);
|
|
55131
55113
|
}
|
|
55132
55114
|
let dependencies = {};
|
|
55133
|
-
let directory =
|
|
55134
|
-
const root = findRoot(
|
|
55115
|
+
let directory = resolvedCwd;
|
|
55116
|
+
const root = findRoot(resolvedCwd);
|
|
55135
55117
|
while (directory && directory !== root) {
|
|
55136
55118
|
if (fs$3.existsSync(path$3.join(directory, commonFilePaths.packageJson))) {
|
|
55137
55119
|
const { data: packageJson } = getPackageJson(directory);
|
|
@@ -55146,13 +55128,14 @@ function createWorkspace(cwd) {
|
|
|
55146
55128
|
for (const [key, value] of Object.entries(dependencies)) {
|
|
55147
55129
|
dependencies[key] = value.replaceAll(/[^\d|.]/g, "");
|
|
55148
55130
|
}
|
|
55149
|
-
|
|
55150
|
-
|
|
55131
|
+
return {
|
|
55132
|
+
kit: dependencies["@sveltejs/kit"] ? parseKitOptions(resolvedCwd) : void 0,
|
|
55133
|
+
packageManager: packageManager ?? getUserAgent() ?? "npm",
|
|
55134
|
+
cwd: resolvedCwd,
|
|
55135
|
+
dependencyVersion: (pkg) => dependencies[pkg],
|
|
55136
|
+
typescript: usesTypescript,
|
|
55137
|
+
options: {}
|
|
55151
55138
|
};
|
|
55152
|
-
workspace.typescript = usesTypescript;
|
|
55153
|
-
workspace.packageManager = detectPackageManager(cwd);
|
|
55154
|
-
if (workspace.dependencyVersion("@sveltejs/kit")) workspace.kit = parseKitOptions(workspace);
|
|
55155
|
-
return workspace;
|
|
55156
55139
|
}
|
|
55157
55140
|
function findRoot(cwd) {
|
|
55158
55141
|
const { root } = path$3.parse(cwd);
|
|
@@ -55171,8 +55154,8 @@ function findRoot(cwd) {
|
|
|
55171
55154
|
}
|
|
55172
55155
|
return root;
|
|
55173
55156
|
}
|
|
55174
|
-
function parseKitOptions(
|
|
55175
|
-
const configSource = readFile(
|
|
55157
|
+
function parseKitOptions(cwd) {
|
|
55158
|
+
const configSource = readFile(cwd, commonFilePaths.svelteConfig);
|
|
55176
55159
|
const { ast } = parseScript(configSource);
|
|
55177
55160
|
const defaultExport = ast.body.find((s) => s.type === "ExportDefaultDeclaration");
|
|
55178
55161
|
if (!defaultExport) throw Error("Missing default export in `svelte.config.js`");
|
|
@@ -55409,7 +55392,7 @@ Available options: ${communityAdderIds.join(", ")}`
|
|
|
55409
55392
|
}
|
|
55410
55393
|
}
|
|
55411
55394
|
if (selectedAdders.length === 0) {
|
|
55412
|
-
const workspace2 = createWorkspace(options.cwd);
|
|
55395
|
+
const workspace2 = createWorkspace({ cwd: options.cwd });
|
|
55413
55396
|
const projectType = workspace2.kit ? "kit" : "svelte";
|
|
55414
55397
|
const adderOptions = officialAdders.map((adder) => {
|
|
55415
55398
|
if (projectType === "kit" && !adder.environments.kit) return;
|
|
@@ -55421,7 +55404,7 @@ Available options: ${communityAdderIds.join(", ")}`
|
|
|
55421
55404
|
};
|
|
55422
55405
|
}).filter((a) => !!a);
|
|
55423
55406
|
const selected = await multiselect({
|
|
55424
|
-
message:
|
|
55407
|
+
message: `What would you like to add to your project? ${pc.dim("(use arrow keys / space bar)")}`,
|
|
55425
55408
|
options: adderOptions,
|
|
55426
55409
|
required: false
|
|
55427
55410
|
});
|
|
@@ -55433,7 +55416,7 @@ Available options: ${communityAdderIds.join(", ")}`
|
|
|
55433
55416
|
}
|
|
55434
55417
|
for (const { adder } of selectedAdders) {
|
|
55435
55418
|
const dependents = adder.dependsOn?.filter((dep) => !selectedAdders.some((a) => a.adder.id === dep)) ?? [];
|
|
55436
|
-
const workspace2 = createWorkspace(options.cwd);
|
|
55419
|
+
const workspace2 = createWorkspace({ cwd: options.cwd });
|
|
55437
55420
|
for (const depId of dependents) {
|
|
55438
55421
|
const dependent = officialAdders.find((a) => a.id === depId);
|
|
55439
55422
|
if (!dependent) throw new Error(`Adder '${adder.id}' depends on an invalid '${depId}'`);
|
|
@@ -55454,7 +55437,7 @@ Available options: ${communityAdderIds.join(", ")}`
|
|
|
55454
55437
|
}
|
|
55455
55438
|
}
|
|
55456
55439
|
if (options.preconditions && selectedAdders.length > 0) {
|
|
55457
|
-
const { kit } = createWorkspace(options.cwd);
|
|
55440
|
+
const { kit } = createWorkspace({ cwd: options.cwd });
|
|
55458
55441
|
const projectType = kit ? "kit" : "svelte";
|
|
55459
55442
|
const adders = selectedAdders.map(({ adder }) => adder);
|
|
55460
55443
|
const { preconditions } = getGlobalPreconditions(options.cwd, projectType, adders);
|
|
@@ -55529,21 +55512,22 @@ Available options: ${communityAdderIds.join(", ")}`
|
|
|
55529
55512
|
values[questionId] = answer;
|
|
55530
55513
|
}
|
|
55531
55514
|
}
|
|
55532
|
-
|
|
55533
|
-
|
|
55534
|
-
|
|
55535
|
-
|
|
55515
|
+
if (selectedAdders.length === 0) return { packageManager: null };
|
|
55516
|
+
let packageManager;
|
|
55517
|
+
if (options.install) {
|
|
55518
|
+
packageManager = await packageManagerPrompt(options.cwd);
|
|
55536
55519
|
}
|
|
55537
|
-
|
|
55538
|
-
|
|
55539
|
-
|
|
55520
|
+
const filesToFormat = await runAdders({ cwd: options.cwd, packageManager, official, community });
|
|
55521
|
+
log$1.success("Successfully setup integrations");
|
|
55522
|
+
if (packageManager && options.install) {
|
|
55523
|
+
await installDependencies(packageManager, options.cwd);
|
|
55540
55524
|
}
|
|
55541
|
-
const workspace = createWorkspace(options.cwd);
|
|
55542
|
-
if (filesToFormat.length > 0 &&
|
|
55525
|
+
const workspace = createWorkspace({ cwd: options.cwd, packageManager });
|
|
55526
|
+
if (filesToFormat.length > 0 && packageManager && !!workspace.dependencyVersion("prettier")) {
|
|
55543
55527
|
const { start, stop } = spinner();
|
|
55544
55528
|
start("Formatting modified files");
|
|
55545
55529
|
try {
|
|
55546
|
-
await formatFiles(options.cwd, filesToFormat);
|
|
55530
|
+
await formatFiles({ packageManager, cwd: options.cwd, paths: filesToFormat });
|
|
55547
55531
|
stop("Successfully formatted modified files");
|
|
55548
55532
|
} catch (e) {
|
|
55549
55533
|
stop("Failed to format files");
|
|
@@ -55565,12 +55549,13 @@ Available options: ${communityAdderIds.join(", ")}`
|
|
|
55565
55549
|
adderMessage += `- ${adderNextSteps.join("\n- ")}`;
|
|
55566
55550
|
return adderMessage;
|
|
55567
55551
|
}).join("\n\n") || void 0;
|
|
55568
|
-
return { nextSteps };
|
|
55552
|
+
return { nextSteps, packageManager };
|
|
55569
55553
|
}
|
|
55570
55554
|
async function runAdders({
|
|
55571
55555
|
cwd,
|
|
55572
55556
|
official = {},
|
|
55573
|
-
community = {}
|
|
55557
|
+
community = {},
|
|
55558
|
+
packageManager
|
|
55574
55559
|
}) {
|
|
55575
55560
|
const adderDetails = Object.keys(official).map((id) => getAdderDetails(id));
|
|
55576
55561
|
const commDetails = Object.keys(community).map(
|
|
@@ -55585,7 +55570,7 @@ async function runAdders({
|
|
|
55585
55570
|
const filesToFormat = /* @__PURE__ */ new Set();
|
|
55586
55571
|
for (const config of details) {
|
|
55587
55572
|
const adderId = config.id;
|
|
55588
|
-
const workspace = createWorkspace(cwd);
|
|
55573
|
+
const workspace = createWorkspace({ cwd, packageManager });
|
|
55589
55574
|
workspace.options = official[adderId] ?? community[adderId];
|
|
55590
55575
|
await config.preInstall?.(workspace);
|
|
55591
55576
|
const pkgPath = installPackages(config, workspace);
|
|
@@ -55707,14 +55692,17 @@ const create = new Command("create").description("scaffolds a new SvelteKit proj
|
|
|
55707
55692
|
const cwd = parse$8(ProjectPathSchema, projectPath);
|
|
55708
55693
|
const options = parse$8(OptionsSchema, opts);
|
|
55709
55694
|
runCommand(async () => {
|
|
55710
|
-
const { directory, integrationNextSteps } = await createProject(cwd, options);
|
|
55695
|
+
const { directory, integrationNextSteps, packageManager } = await createProject(cwd, options);
|
|
55711
55696
|
const highlight = (str) => pc.bold(pc.cyan(str));
|
|
55712
55697
|
let i = 1;
|
|
55713
55698
|
const initialSteps = [];
|
|
55714
55699
|
const relative = path$3.relative(process$1$1.cwd(), directory);
|
|
55715
|
-
const pm =
|
|
55700
|
+
const pm = packageManager ?? detectSync({ cwd })?.name ?? getUserAgent() ?? "npm";
|
|
55716
55701
|
if (relative !== "") {
|
|
55717
|
-
|
|
55702
|
+
const pathHasSpaces = relative.includes(" ");
|
|
55703
|
+
initialSteps.push(
|
|
55704
|
+
`${i++}: ${highlight(`cd ${pathHasSpaces ? `"${relative}"` : relative}`)}`
|
|
55705
|
+
);
|
|
55718
55706
|
}
|
|
55719
55707
|
if (!packageManager) {
|
|
55720
55708
|
initialSteps.push(`${i++}: ${highlight(`${pm} install`)}`);
|
|
@@ -55792,18 +55780,26 @@ async function createProject(cwd, options) {
|
|
|
55792
55780
|
types: language
|
|
55793
55781
|
});
|
|
55794
55782
|
log$1.success("Project created");
|
|
55783
|
+
let packageManager;
|
|
55795
55784
|
let integrationNextSteps;
|
|
55785
|
+
const installDeps = async () => {
|
|
55786
|
+
packageManager = await packageManagerPrompt(projectPath);
|
|
55787
|
+
if (packageManager) await installDependencies(packageManager, projectPath);
|
|
55788
|
+
};
|
|
55796
55789
|
if (options.integrations) {
|
|
55797
|
-
const { nextSteps } = await runAddCommand(
|
|
55798
|
-
{ cwd: projectPath, install:
|
|
55790
|
+
const { nextSteps, packageManager: pm } = await runAddCommand(
|
|
55791
|
+
{ cwd: projectPath, install: options.install, preconditions: true, community: [] },
|
|
55799
55792
|
[]
|
|
55800
55793
|
);
|
|
55794
|
+
packageManager = pm;
|
|
55801
55795
|
integrationNextSteps = nextSteps;
|
|
55796
|
+
} else if (options.install) {
|
|
55797
|
+
await installDeps();
|
|
55802
55798
|
}
|
|
55803
|
-
if (options.install) {
|
|
55804
|
-
await
|
|
55799
|
+
if (packageManager === null && options.install) {
|
|
55800
|
+
await installDeps();
|
|
55805
55801
|
}
|
|
55806
|
-
return { directory: projectPath, integrationNextSteps };
|
|
55802
|
+
return { directory: projectPath, integrationNextSteps, packageManager };
|
|
55807
55803
|
}
|
|
55808
55804
|
|
|
55809
55805
|
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({
|