sv 0.6.21 → 0.6.23
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 +214 -154
- package/package.json +3 -3
package/dist/bin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { AtRule, Element, __commonJS, __require, __toESM, addPnpmBuildDependendencies, box, cancel, confirm, create, detectSync, esm_exports, from, getUserAgent, group, installDependencies, intro, isCancel, log, multiselect, note, outro, packageManagerPrompt, parseCss, parseHtml
|
|
2
|
+
import { AtRule, Element, __commonJS, __require, __toESM, addPnpmBuildDependendencies, box, cancel, confirm, create, detectSync, esm_exports, from, getUserAgent, group, installDependencies, intro, isCancel, log, multiselect, note, outro, packageManagerPrompt, parseCss, parseHtml, parseHtml$1, parseJson, parseScript, parseSvelte, resolveCommand, select, spinner, templates, text, up, walk_exports } from "./package-manager-f0ge7H2V.js";
|
|
3
3
|
import { __commonJS$1, __export, __toESM$1, addFromString, applyAddons, array_exports, common_exports, createWorkspace, dedent_default, exports_exports, formatFiles, function_exports, getHighlighter, imports_exports, kit_exports, object_exports, require_picocolors, setupAddons, variables_exports } from "./install-PTlNv0EA.js";
|
|
4
4
|
import fs, { existsSync } from "node:fs";
|
|
5
5
|
import path, { dirname, join } from "node:path";
|
|
@@ -12,7 +12,7 @@ import { promisify } from "node:util";
|
|
|
12
12
|
|
|
13
13
|
//#region packages/cli/package.json
|
|
14
14
|
var name = "sv";
|
|
15
|
-
var version = "0.6.
|
|
15
|
+
var version = "0.6.23";
|
|
16
16
|
var type = "module";
|
|
17
17
|
var description = "A CLI for creating and updating SvelteKit projects";
|
|
18
18
|
var license = "MIT";
|
|
@@ -913,11 +913,11 @@ var require_option = __commonJS({ "node_modules/.pnpm/commander@13.0.0/node_modu
|
|
|
913
913
|
/**
|
|
914
914
|
* @param {Option[]} options
|
|
915
915
|
*/
|
|
916
|
-
constructor(options$
|
|
916
|
+
constructor(options$6) {
|
|
917
917
|
this.positiveOptions = new Map();
|
|
918
918
|
this.negativeOptions = new Map();
|
|
919
919
|
this.dualOptions = new Set();
|
|
920
|
-
options$
|
|
920
|
+
options$6.forEach((option) => {
|
|
921
921
|
if (option.negate) this.negativeOptions.set(option.attributeName(), option);
|
|
922
922
|
else this.positiveOptions.set(option.attributeName(), option);
|
|
923
923
|
});
|
|
@@ -3201,14 +3201,14 @@ function optional(wrapped, ...args) {
|
|
|
3201
3201
|
if (0 in args) schema.default = args[0];
|
|
3202
3202
|
return schema;
|
|
3203
3203
|
}
|
|
3204
|
-
function picklist(options$
|
|
3204
|
+
function picklist(options$6, message) {
|
|
3205
3205
|
return {
|
|
3206
3206
|
kind: "schema",
|
|
3207
3207
|
type: "picklist",
|
|
3208
3208
|
reference: picklist,
|
|
3209
|
-
expects: _joinExpects(options$
|
|
3209
|
+
expects: _joinExpects(options$6.map(_stringify), "|"),
|
|
3210
3210
|
async: false,
|
|
3211
|
-
options: options$
|
|
3211
|
+
options: options$6,
|
|
3212
3212
|
message,
|
|
3213
3213
|
_run(dataset, config2) {
|
|
3214
3214
|
if (this.options.includes(dataset.value)) dataset.typed = true;
|
|
@@ -3302,14 +3302,14 @@ function _subIssues(datasets) {
|
|
|
3302
3302
|
else issues = dataset.issues;
|
|
3303
3303
|
return issues;
|
|
3304
3304
|
}
|
|
3305
|
-
function union(options$
|
|
3305
|
+
function union(options$6, message) {
|
|
3306
3306
|
return {
|
|
3307
3307
|
kind: "schema",
|
|
3308
3308
|
type: "union",
|
|
3309
3309
|
reference: union,
|
|
3310
|
-
expects: _joinExpects(options$
|
|
3310
|
+
expects: _joinExpects(options$6.map((option) => option.expects), "|"),
|
|
3311
3311
|
async: false,
|
|
3312
|
-
options: options$
|
|
3312
|
+
options: options$6,
|
|
3313
3313
|
message,
|
|
3314
3314
|
_run(dataset, config2) {
|
|
3315
3315
|
let validDataset;
|
|
@@ -3367,8 +3367,8 @@ function pipe$1(...pipe2) {
|
|
|
3367
3367
|
|
|
3368
3368
|
//#endregion
|
|
3369
3369
|
//#region node_modules/.pnpm/empathic@1.0.0/node_modules/empathic/package.mjs
|
|
3370
|
-
function up$1(options$
|
|
3371
|
-
return up("package.json", options$
|
|
3370
|
+
function up$1(options$6) {
|
|
3371
|
+
return up("package.json", options$6);
|
|
3372
3372
|
}
|
|
3373
3373
|
|
|
3374
3374
|
//#endregion
|
|
@@ -3376,8 +3376,8 @@ function up$1(options$5) {
|
|
|
3376
3376
|
function defineAddon(config) {
|
|
3377
3377
|
return config;
|
|
3378
3378
|
}
|
|
3379
|
-
function defineAddonOptions(options$
|
|
3380
|
-
return options$
|
|
3379
|
+
function defineAddonOptions(options$6) {
|
|
3380
|
+
return options$6;
|
|
3381
3381
|
}
|
|
3382
3382
|
var __create$1 = Object.create;
|
|
3383
3383
|
var __defProp$1 = Object.defineProperty;
|
|
@@ -4044,7 +4044,7 @@ const PORTS = {
|
|
|
4044
4044
|
postgresql: "5432",
|
|
4045
4045
|
sqlite: ""
|
|
4046
4046
|
};
|
|
4047
|
-
const options$
|
|
4047
|
+
const options$5 = defineAddonOptions({
|
|
4048
4048
|
database: {
|
|
4049
4049
|
question: "Which database would you like to use?",
|
|
4050
4050
|
type: "select",
|
|
@@ -4129,39 +4129,39 @@ var drizzle_default = defineAddon({
|
|
|
4129
4129
|
id: "drizzle",
|
|
4130
4130
|
shortDescription: "database orm",
|
|
4131
4131
|
homepage: "https://orm.drizzle.team",
|
|
4132
|
-
options: options$
|
|
4132
|
+
options: options$5,
|
|
4133
4133
|
setup: ({ kit, unsupported }) => {
|
|
4134
4134
|
if (!kit) unsupported("Requires SvelteKit");
|
|
4135
4135
|
},
|
|
4136
|
-
run: ({ sv, typescript, options: options$
|
|
4136
|
+
run: ({ sv, typescript, options: options$6, kit }) => {
|
|
4137
4137
|
const ext = typescript ? "ts" : "js";
|
|
4138
|
-
sv.dependency("drizzle-orm", "^0.
|
|
4138
|
+
sv.dependency("drizzle-orm", "^0.40.0");
|
|
4139
4139
|
sv.devDependency("drizzle-kit", "^0.30.2");
|
|
4140
|
-
if (options$
|
|
4141
|
-
if (options$
|
|
4142
|
-
if (options$
|
|
4143
|
-
if (options$
|
|
4144
|
-
if (options$
|
|
4140
|
+
if (options$6.mysql === "mysql2") sv.dependency("mysql2", "^3.12.0");
|
|
4141
|
+
if (options$6.mysql === "planetscale") sv.dependency("@planetscale/database", "^1.19.0");
|
|
4142
|
+
if (options$6.postgresql === "neon") sv.dependency("@neondatabase/serverless", "^0.10.4");
|
|
4143
|
+
if (options$6.postgresql === "postgres.js") sv.dependency("postgres", "^3.4.5");
|
|
4144
|
+
if (options$6.sqlite === "better-sqlite3") {
|
|
4145
4145
|
sv.dependency("better-sqlite3", "^11.8.0");
|
|
4146
4146
|
sv.devDependency("@types/better-sqlite3", "^7.6.12");
|
|
4147
4147
|
sv.pnpmBuildDependendency("better-sqlite3");
|
|
4148
4148
|
}
|
|
4149
|
-
if (options$
|
|
4150
|
-
sv.file(".env", (content) => generateEnvFileContent(content, options$
|
|
4151
|
-
sv.file(".env.example", (content) => generateEnvFileContent(content, options$
|
|
4152
|
-
if (options$
|
|
4149
|
+
if (options$6.sqlite === "libsql" || options$6.sqlite === "turso") sv.dependency("@libsql/client", "^0.14.0");
|
|
4150
|
+
sv.file(".env", (content) => generateEnvFileContent(content, options$6));
|
|
4151
|
+
sv.file(".env.example", (content) => generateEnvFileContent(content, options$6));
|
|
4152
|
+
if (options$6.docker && (options$6.mysql === "mysql2" || options$6.postgresql === "postgres.js")) sv.file("docker-compose.yml", (content) => {
|
|
4153
4153
|
if (content.length > 0) return content;
|
|
4154
|
-
const imageName = options$
|
|
4155
|
-
const port = PORTS[options$
|
|
4154
|
+
const imageName = options$6.database === "mysql" ? "mysql" : "postgres";
|
|
4155
|
+
const port = PORTS[options$6.database];
|
|
4156
4156
|
const USER = "root";
|
|
4157
4157
|
const PASSWORD = "mysecretpassword";
|
|
4158
4158
|
const DB_NAME = "local";
|
|
4159
4159
|
let dbSpecificContent = "";
|
|
4160
|
-
if (options$
|
|
4160
|
+
if (options$6.mysql === "mysql2") dbSpecificContent = `
|
|
4161
4161
|
MYSQL_ROOT_PASSWORD: ${PASSWORD}
|
|
4162
4162
|
MYSQL_DATABASE: ${DB_NAME}
|
|
4163
4163
|
`;
|
|
4164
|
-
if (options$
|
|
4164
|
+
if (options$6.postgresql === "postgres.js") dbSpecificContent = `
|
|
4165
4165
|
POSTGRES_USER: ${USER}
|
|
4166
4166
|
POSTGRES_PASSWORD: ${PASSWORD}
|
|
4167
4167
|
POSTGRES_DB: ${DB_NAME}
|
|
@@ -4181,13 +4181,13 @@ var drizzle_default = defineAddon({
|
|
|
4181
4181
|
const { data, generateCode } = parseJson(content);
|
|
4182
4182
|
data.scripts ??= {};
|
|
4183
4183
|
const scripts$1 = data.scripts;
|
|
4184
|
-
if (options$
|
|
4184
|
+
if (options$6.docker) scripts$1["db:start"] ??= "docker compose up";
|
|
4185
4185
|
scripts$1["db:push"] ??= "drizzle-kit push";
|
|
4186
4186
|
scripts$1["db:migrate"] ??= "drizzle-kit migrate";
|
|
4187
4187
|
scripts$1["db:studio"] ??= "drizzle-kit studio";
|
|
4188
4188
|
return generateCode();
|
|
4189
4189
|
});
|
|
4190
|
-
if (options$
|
|
4190
|
+
if (options$6.database === "sqlite") sv.file(".gitignore", (content) => {
|
|
4191
4191
|
if (content.length === 0) return content;
|
|
4192
4192
|
if (!content.includes("\n*.db")) content = content.trimEnd() + "\n\n# SQLite\n*.db";
|
|
4193
4193
|
return content;
|
|
@@ -4202,7 +4202,7 @@ var drizzle_default = defineAddon({
|
|
|
4202
4202
|
if (exportDefault.type !== "CallExpression") return content;
|
|
4203
4203
|
const objExpression = exportDefault.arguments?.[0];
|
|
4204
4204
|
if (!objExpression || objExpression.type !== "ObjectExpression") return content;
|
|
4205
|
-
const authToken = options$
|
|
4205
|
+
const authToken = options$6.sqlite === "turso" ? common_exports.expressionFromString("process.env.DATABASE_AUTH_TOKEN") : undefined;
|
|
4206
4206
|
object_exports.properties(objExpression, {
|
|
4207
4207
|
schema: common_exports.createLiteral(`./src/lib/server/db/schema.${typescript ? "ts" : "js"}`),
|
|
4208
4208
|
dbCredentials: object_exports.create({
|
|
@@ -4218,15 +4218,15 @@ var drizzle_default = defineAddon({
|
|
|
4218
4218
|
value: true
|
|
4219
4219
|
}
|
|
4220
4220
|
});
|
|
4221
|
-
const dialect = options$
|
|
4221
|
+
const dialect = options$6.sqlite === "turso" ? "turso" : options$6.database;
|
|
4222
4222
|
object_exports.overrideProperties(objExpression, { dialect: common_exports.createLiteral(dialect) });
|
|
4223
|
-
if (options$
|
|
4223
|
+
if (options$6.database !== "sqlite") object_exports.removeProperty(objExpression, "driver");
|
|
4224
4224
|
return generateCode();
|
|
4225
4225
|
});
|
|
4226
4226
|
sv.file(`${kit?.libDirectory}/server/db/schema.${ext}`, (content) => {
|
|
4227
4227
|
const { ast, generateCode } = parseScript(content);
|
|
4228
4228
|
let userSchemaExpression;
|
|
4229
|
-
if (options$
|
|
4229
|
+
if (options$6.database === "sqlite") {
|
|
4230
4230
|
imports_exports.addNamed(ast, "drizzle-orm/sqlite-core", {
|
|
4231
4231
|
sqliteTable: "sqliteTable",
|
|
4232
4232
|
text: "text",
|
|
@@ -4237,7 +4237,7 @@ var drizzle_default = defineAddon({
|
|
|
4237
4237
|
age: integer('age')
|
|
4238
4238
|
})`);
|
|
4239
4239
|
}
|
|
4240
|
-
if (options$
|
|
4240
|
+
if (options$6.database === "mysql") {
|
|
4241
4241
|
imports_exports.addNamed(ast, "drizzle-orm/mysql-core", {
|
|
4242
4242
|
mysqlTable: "mysqlTable",
|
|
4243
4243
|
serial: "serial",
|
|
@@ -4249,7 +4249,7 @@ var drizzle_default = defineAddon({
|
|
|
4249
4249
|
age: int('age'),
|
|
4250
4250
|
})`);
|
|
4251
4251
|
}
|
|
4252
|
-
if (options$
|
|
4252
|
+
if (options$6.database === "postgresql") {
|
|
4253
4253
|
imports_exports.addNamed(ast, "drizzle-orm/pg-core", {
|
|
4254
4254
|
pgTable: "pgTable",
|
|
4255
4255
|
serial: "serial",
|
|
@@ -4272,37 +4272,37 @@ var drizzle_default = defineAddon({
|
|
|
4272
4272
|
const dbURLCheck = common_exports.statementFromString("if (!env.DATABASE_URL) throw new Error('DATABASE_URL is not set');");
|
|
4273
4273
|
common_exports.addStatement(ast, dbURLCheck);
|
|
4274
4274
|
let clientExpression;
|
|
4275
|
-
if (options$
|
|
4275
|
+
if (options$6.sqlite === "better-sqlite3") {
|
|
4276
4276
|
imports_exports.addDefault(ast, "better-sqlite3", "Database");
|
|
4277
4277
|
imports_exports.addNamed(ast, "drizzle-orm/better-sqlite3", { drizzle: "drizzle" });
|
|
4278
4278
|
clientExpression = common_exports.expressionFromString("new Database(env.DATABASE_URL)");
|
|
4279
4279
|
}
|
|
4280
|
-
if (options$
|
|
4280
|
+
if (options$6.sqlite === "libsql" || options$6.sqlite === "turso") {
|
|
4281
4281
|
imports_exports.addNamed(ast, "@libsql/client", { createClient: "createClient" });
|
|
4282
4282
|
imports_exports.addNamed(ast, "drizzle-orm/libsql", { drizzle: "drizzle" });
|
|
4283
|
-
if (options$
|
|
4283
|
+
if (options$6.sqlite === "turso") {
|
|
4284
4284
|
imports_exports.addNamed(ast, "$app/environment", { dev: "dev" });
|
|
4285
4285
|
const authTokenCheck = common_exports.statementFromString("if (!dev && !env.DATABASE_AUTH_TOKEN) throw new Error('DATABASE_AUTH_TOKEN is not set');");
|
|
4286
4286
|
common_exports.addStatement(ast, authTokenCheck);
|
|
4287
4287
|
clientExpression = common_exports.expressionFromString("createClient({ url: env.DATABASE_URL, authToken: env.DATABASE_AUTH_TOKEN })");
|
|
4288
4288
|
} else clientExpression = common_exports.expressionFromString("createClient({ url: env.DATABASE_URL })");
|
|
4289
4289
|
}
|
|
4290
|
-
if (options$
|
|
4290
|
+
if (options$6.mysql === "mysql2") {
|
|
4291
4291
|
imports_exports.addDefault(ast, "mysql2/promise", "mysql");
|
|
4292
4292
|
imports_exports.addNamed(ast, "drizzle-orm/mysql2", { drizzle: "drizzle" });
|
|
4293
4293
|
clientExpression = common_exports.expressionFromString("await mysql.createConnection(env.DATABASE_URL)");
|
|
4294
4294
|
}
|
|
4295
|
-
if (options$
|
|
4295
|
+
if (options$6.mysql === "planetscale") {
|
|
4296
4296
|
imports_exports.addNamed(ast, "@planetscale/database", { Client: "Client" });
|
|
4297
4297
|
imports_exports.addNamed(ast, "drizzle-orm/planetscale-serverless", { drizzle: "drizzle" });
|
|
4298
4298
|
clientExpression = common_exports.expressionFromString("new Client({ url: env.DATABASE_URL })");
|
|
4299
4299
|
}
|
|
4300
|
-
if (options$
|
|
4300
|
+
if (options$6.postgresql === "neon") {
|
|
4301
4301
|
imports_exports.addNamed(ast, "@neondatabase/serverless", { neon: "neon" });
|
|
4302
4302
|
imports_exports.addNamed(ast, "drizzle-orm/neon-http", { drizzle: "drizzle" });
|
|
4303
4303
|
clientExpression = common_exports.expressionFromString("neon(env.DATABASE_URL)");
|
|
4304
4304
|
}
|
|
4305
|
-
if (options$
|
|
4305
|
+
if (options$6.postgresql === "postgres.js") {
|
|
4306
4306
|
imports_exports.addDefault(ast, "postgres", "postgres");
|
|
4307
4307
|
imports_exports.addNamed(ast, "drizzle-orm/postgres-js", { drizzle: "drizzle" });
|
|
4308
4308
|
clientExpression = common_exports.expressionFromString("postgres(env.DATABASE_URL)");
|
|
@@ -4316,9 +4316,10 @@ var drizzle_default = defineAddon({
|
|
|
4316
4316
|
return generateCode();
|
|
4317
4317
|
});
|
|
4318
4318
|
},
|
|
4319
|
-
nextSteps: ({ options: options$
|
|
4319
|
+
nextSteps: ({ options: options$6, highlighter, packageManager }) => {
|
|
4320
4320
|
const steps = [`You will need to set ${highlighter.env("DATABASE_URL")} in your production environment`];
|
|
4321
|
-
if (options$
|
|
4321
|
+
if (options$6.docker) steps.push(`Run ${highlighter.command(`${packageManager} run db:start`)} to start the docker container`);
|
|
4322
|
+
else steps.push(`Check ${highlighter.env("DATABASE_URL")} in ${highlighter.path(".env")} and adjust it to your needs`);
|
|
4322
4323
|
steps.push(`Run ${highlighter.command(`${packageManager} run db:push`)} to update your database schema`);
|
|
4323
4324
|
return steps;
|
|
4324
4325
|
}
|
|
@@ -4407,8 +4408,8 @@ var eslint_default = defineAddon({
|
|
|
4407
4408
|
const prettierInstalled = Boolean(dependencyVersion("prettier"));
|
|
4408
4409
|
sv.devDependency("eslint", "^9.18.0");
|
|
4409
4410
|
sv.devDependency("@eslint/compat", "^1.2.5");
|
|
4410
|
-
sv.devDependency("
|
|
4411
|
-
sv.devDependency("
|
|
4411
|
+
sv.devDependency("eslint-plugin-svelte", "^3.0.0");
|
|
4412
|
+
sv.devDependency("globals", "^16.0.0");
|
|
4412
4413
|
sv.devDependency("@eslint/js", "^9.18.0");
|
|
4413
4414
|
if (typescript) sv.devDependency("typescript-eslint", "^8.20.0");
|
|
4414
4415
|
if (prettierInstalled) sv.devDependency("eslint-config-prettier", "^10.0.1");
|
|
@@ -4431,6 +4432,7 @@ var eslint_default = defineAddon({
|
|
|
4431
4432
|
sv.file("eslint.config.js", (content) => {
|
|
4432
4433
|
const { ast, generateCode } = parseScript(content);
|
|
4433
4434
|
const eslintConfigs = [];
|
|
4435
|
+
imports_exports.addDefault(ast, "./svelte.config.js", "svelteConfig");
|
|
4434
4436
|
const gitIgnorePathStatement = common_exports.statementFromString("\nconst gitignorePath = fileURLToPath(new URL(\"./.gitignore\", import.meta.url));");
|
|
4435
4437
|
common_exports.addStatement(ast, gitIgnorePathStatement);
|
|
4436
4438
|
const ignoresConfig = common_exports.expressionFromString("includeIgnoreFile(gitignorePath)");
|
|
@@ -4441,7 +4443,7 @@ var eslint_default = defineAddon({
|
|
|
4441
4443
|
const tsConfig = common_exports.expressionFromString("ts.configs.recommended");
|
|
4442
4444
|
eslintConfigs.push(common_exports.createSpreadElement(tsConfig));
|
|
4443
4445
|
}
|
|
4444
|
-
const svelteConfig = common_exports.expressionFromString("svelte.configs
|
|
4446
|
+
const svelteConfig = common_exports.expressionFromString("svelte.configs.recommended");
|
|
4445
4447
|
eslintConfigs.push(common_exports.createSpreadElement(svelteConfig));
|
|
4446
4448
|
const globalsBrowser = common_exports.createSpreadElement(common_exports.expressionFromString("globals.browser"));
|
|
4447
4449
|
const globalsNode = common_exports.createSpreadElement(common_exports.expressionFromString("globals.node"));
|
|
@@ -4451,8 +4453,20 @@ var eslint_default = defineAddon({
|
|
|
4451
4453
|
eslintConfigs.push(globalsConfig);
|
|
4452
4454
|
if (typescript) {
|
|
4453
4455
|
const svelteTSParserConfig = object_exports.create({
|
|
4454
|
-
files: common_exports.expressionFromString("[\"**/*.svelte\"]"),
|
|
4455
|
-
|
|
4456
|
+
files: common_exports.expressionFromString("[\"**/*.svelte\", \"**/*.svelte.ts\", \"**/*.svelte.js\"]"),
|
|
4457
|
+
ignores: common_exports.expressionFromString("[\"eslint.config.js\", \"svelte.config.js\"]"),
|
|
4458
|
+
languageOptions: object_exports.create({ parserOptions: object_exports.create({
|
|
4459
|
+
projectService: common_exports.expressionFromString("true"),
|
|
4460
|
+
extraFileExtensions: common_exports.expressionFromString("['.svelte']"),
|
|
4461
|
+
parser: common_exports.expressionFromString("ts.parser"),
|
|
4462
|
+
svelteConfig: common_exports.expressionFromString("svelteConfig")
|
|
4463
|
+
}) })
|
|
4464
|
+
});
|
|
4465
|
+
eslintConfigs.push(svelteTSParserConfig);
|
|
4466
|
+
} else {
|
|
4467
|
+
const svelteTSParserConfig = object_exports.create({
|
|
4468
|
+
files: common_exports.expressionFromString("[\"**/*.svelte\", \"**/*.svelte.js\"]"),
|
|
4469
|
+
languageOptions: object_exports.create({ parserOptions: object_exports.create({ svelteConfig: common_exports.expressionFromString("svelteConfig") }) })
|
|
4456
4470
|
});
|
|
4457
4471
|
eslintConfigs.push(svelteTSParserConfig);
|
|
4458
4472
|
}
|
|
@@ -4487,6 +4501,11 @@ var eslint_default = defineAddon({
|
|
|
4487
4501
|
//#endregion
|
|
4488
4502
|
//#region packages/addons/sveltekit-adapter/index.ts
|
|
4489
4503
|
const adapters = [
|
|
4504
|
+
{
|
|
4505
|
+
id: "auto",
|
|
4506
|
+
package: "@sveltejs/adapter-auto",
|
|
4507
|
+
version: "^4.0.0"
|
|
4508
|
+
},
|
|
4490
4509
|
{
|
|
4491
4510
|
id: "node",
|
|
4492
4511
|
package: "@sveltejs/adapter-node",
|
|
@@ -4518,7 +4537,7 @@ const adapters = [
|
|
|
4518
4537
|
version: "^4.4.0"
|
|
4519
4538
|
}
|
|
4520
4539
|
];
|
|
4521
|
-
const options$
|
|
4540
|
+
const options$4 = defineAddonOptions({ adapter: {
|
|
4522
4541
|
type: "select",
|
|
4523
4542
|
question: "Which SvelteKit adapter would you like to use?",
|
|
4524
4543
|
options: adapters.map((p) => ({
|
|
@@ -4526,19 +4545,19 @@ const options$3 = defineAddonOptions({ adapter: {
|
|
|
4526
4545
|
label: p.id,
|
|
4527
4546
|
hint: p.package
|
|
4528
4547
|
})),
|
|
4529
|
-
default: "
|
|
4548
|
+
default: "auto"
|
|
4530
4549
|
} });
|
|
4531
4550
|
var sveltekit_adapter_default = defineAddon({
|
|
4532
4551
|
id: "sveltekit-adapter",
|
|
4533
4552
|
alias: "adapter",
|
|
4534
4553
|
shortDescription: "deployment",
|
|
4535
4554
|
homepage: "https://svelte.dev/docs/kit/adapters",
|
|
4536
|
-
options: options$
|
|
4555
|
+
options: options$4,
|
|
4537
4556
|
setup: ({ kit, unsupported }) => {
|
|
4538
4557
|
if (!kit) unsupported("Requires SvelteKit");
|
|
4539
4558
|
},
|
|
4540
|
-
run: ({ sv, options: options$
|
|
4541
|
-
const adapter = adapters.find((a) => a.id === options$
|
|
4559
|
+
run: ({ sv, options: options$6 }) => {
|
|
4560
|
+
const adapter = adapters.find((a) => a.id === options$6.adapter);
|
|
4542
4561
|
sv.file("package.json", (content) => {
|
|
4543
4562
|
const { data, generateCode } = parseJson(content);
|
|
4544
4563
|
const devDeps = data["devDependencies"];
|
|
@@ -4969,7 +4988,7 @@ const warned = {
|
|
|
4969
4988
|
storeName: false
|
|
4970
4989
|
};
|
|
4971
4990
|
var MagicString = class MagicString {
|
|
4972
|
-
constructor(string$1, options$
|
|
4991
|
+
constructor(string$1, options$6 = {}) {
|
|
4973
4992
|
const chunk = new Chunk(0, string$1.length, string$1);
|
|
4974
4993
|
Object.defineProperties(this, {
|
|
4975
4994
|
original: {
|
|
@@ -5006,11 +5025,11 @@ var MagicString = class MagicString {
|
|
|
5006
5025
|
},
|
|
5007
5026
|
filename: {
|
|
5008
5027
|
writable: true,
|
|
5009
|
-
value: options$
|
|
5028
|
+
value: options$6.filename
|
|
5010
5029
|
},
|
|
5011
5030
|
indentExclusionRanges: {
|
|
5012
5031
|
writable: true,
|
|
5013
|
-
value: options$
|
|
5032
|
+
value: options$6.indentExclusionRanges
|
|
5014
5033
|
},
|
|
5015
5034
|
sourcemapLocations: {
|
|
5016
5035
|
writable: true,
|
|
@@ -5026,11 +5045,11 @@ var MagicString = class MagicString {
|
|
|
5026
5045
|
},
|
|
5027
5046
|
ignoreList: {
|
|
5028
5047
|
writable: true,
|
|
5029
|
-
value: options$
|
|
5048
|
+
value: options$6.ignoreList
|
|
5030
5049
|
},
|
|
5031
5050
|
offset: {
|
|
5032
5051
|
writable: true,
|
|
5033
|
-
value: options$
|
|
5052
|
+
value: options$6.offset || 0
|
|
5034
5053
|
}
|
|
5035
5054
|
});
|
|
5036
5055
|
this.byStart[0] = chunk;
|
|
@@ -5088,11 +5107,11 @@ else this.outro += content;
|
|
|
5088
5107
|
cloned.outro = this.outro;
|
|
5089
5108
|
return cloned;
|
|
5090
5109
|
}
|
|
5091
|
-
generateDecodedMap(options$
|
|
5092
|
-
options$
|
|
5110
|
+
generateDecodedMap(options$6) {
|
|
5111
|
+
options$6 = options$6 || {};
|
|
5093
5112
|
const sourceIndex = 0;
|
|
5094
5113
|
const names = Object.keys(this.storedNames);
|
|
5095
|
-
const mappings = new Mappings(options$
|
|
5114
|
+
const mappings = new Mappings(options$6.hires);
|
|
5096
5115
|
const locate = getLocator(this.original);
|
|
5097
5116
|
if (this.intro) mappings.advance(this.intro);
|
|
5098
5117
|
this.firstChunk.eachNext((chunk) => {
|
|
@@ -5103,16 +5122,16 @@ else mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sour
|
|
|
5103
5122
|
if (chunk.outro.length) mappings.advance(chunk.outro);
|
|
5104
5123
|
});
|
|
5105
5124
|
return {
|
|
5106
|
-
file: options$
|
|
5107
|
-
sources: [options$
|
|
5108
|
-
sourcesContent: options$
|
|
5125
|
+
file: options$6.file ? options$6.file.split(/[/\\]/).pop() : undefined,
|
|
5126
|
+
sources: [options$6.source ? getRelativePath(options$6.file || "", options$6.source) : options$6.file || ""],
|
|
5127
|
+
sourcesContent: options$6.includeContent ? [this.original] : undefined,
|
|
5109
5128
|
names,
|
|
5110
5129
|
mappings: mappings.raw,
|
|
5111
5130
|
x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined
|
|
5112
5131
|
};
|
|
5113
5132
|
}
|
|
5114
|
-
generateMap(options$
|
|
5115
|
-
return new SourceMap(this.generateDecodedMap(options$
|
|
5133
|
+
generateMap(options$6) {
|
|
5134
|
+
return new SourceMap(this.generateDecodedMap(options$6));
|
|
5116
5135
|
}
|
|
5117
5136
|
_ensureindentStr() {
|
|
5118
5137
|
if (this.indentStr === undefined) this.indentStr = guessIndent(this.original);
|
|
@@ -5125,10 +5144,10 @@ else mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sour
|
|
|
5125
5144
|
this._ensureindentStr();
|
|
5126
5145
|
return this.indentStr === null ? " " : this.indentStr;
|
|
5127
5146
|
}
|
|
5128
|
-
indent(indentStr, options$
|
|
5147
|
+
indent(indentStr, options$6) {
|
|
5129
5148
|
const pattern = /^[^\r\n]/gm;
|
|
5130
5149
|
if (isObject(indentStr)) {
|
|
5131
|
-
options$
|
|
5150
|
+
options$6 = indentStr;
|
|
5132
5151
|
indentStr = undefined;
|
|
5133
5152
|
}
|
|
5134
5153
|
if (indentStr === undefined) {
|
|
@@ -5136,15 +5155,15 @@ else mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sour
|
|
|
5136
5155
|
indentStr = this.indentStr || " ";
|
|
5137
5156
|
}
|
|
5138
5157
|
if (indentStr === "") return this;
|
|
5139
|
-
options$
|
|
5158
|
+
options$6 = options$6 || {};
|
|
5140
5159
|
const isExcluded = {};
|
|
5141
|
-
if (options$
|
|
5142
|
-
const exclusions = typeof options$
|
|
5160
|
+
if (options$6.exclude) {
|
|
5161
|
+
const exclusions = typeof options$6.exclude[0] === "number" ? [options$6.exclude] : options$6.exclude;
|
|
5143
5162
|
exclusions.forEach((exclusion) => {
|
|
5144
5163
|
for (let i = exclusion[0]; i < exclusion[1]; i += 1) isExcluded[i] = true;
|
|
5145
5164
|
});
|
|
5146
5165
|
}
|
|
5147
|
-
let shouldIndentNextCharacter = options$
|
|
5166
|
+
let shouldIndentNextCharacter = options$6.indentStart !== false;
|
|
5148
5167
|
const replacer = (match) => {
|
|
5149
5168
|
if (shouldIndentNextCharacter) return `${indentStr}${match}`;
|
|
5150
5169
|
shouldIndentNextCharacter = true;
|
|
@@ -5232,14 +5251,14 @@ else {
|
|
|
5232
5251
|
if (!newRight) this.lastChunk = last;
|
|
5233
5252
|
return this;
|
|
5234
5253
|
}
|
|
5235
|
-
overwrite(start, end, content, options$
|
|
5236
|
-
options$
|
|
5254
|
+
overwrite(start, end, content, options$6) {
|
|
5255
|
+
options$6 = options$6 || {};
|
|
5237
5256
|
return this.update(start, end, content, {
|
|
5238
|
-
...options$
|
|
5239
|
-
overwrite: !options$
|
|
5257
|
+
...options$6,
|
|
5258
|
+
overwrite: !options$6.contentOnly
|
|
5240
5259
|
});
|
|
5241
5260
|
}
|
|
5242
|
-
update(start, end, content, options$
|
|
5261
|
+
update(start, end, content, options$6) {
|
|
5243
5262
|
start = start + this.offset;
|
|
5244
5263
|
end = end + this.offset;
|
|
5245
5264
|
if (typeof content !== "string") throw new TypeError("replacement content must be a string");
|
|
@@ -5251,15 +5270,15 @@ else {
|
|
|
5251
5270
|
if (start === end) throw new Error("Cannot overwrite a zero-length range – use appendLeft or prependRight instead");
|
|
5252
5271
|
this._split(start);
|
|
5253
5272
|
this._split(end);
|
|
5254
|
-
if (options$
|
|
5273
|
+
if (options$6 === true) {
|
|
5255
5274
|
if (!warned.storeName) {
|
|
5256
5275
|
console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string");
|
|
5257
5276
|
warned.storeName = true;
|
|
5258
5277
|
}
|
|
5259
|
-
options$
|
|
5278
|
+
options$6 = { storeName: true };
|
|
5260
5279
|
}
|
|
5261
|
-
const storeName = options$
|
|
5262
|
-
const overwrite = options$
|
|
5280
|
+
const storeName = options$6 !== undefined ? options$6.storeName : false;
|
|
5281
|
+
const overwrite = options$6 !== undefined ? options$6.overwrite : false;
|
|
5263
5282
|
if (storeName) {
|
|
5264
5283
|
const original = this.original.slice(start, end);
|
|
5265
5284
|
Object.defineProperty(this.storedNames, original, {
|
|
@@ -5590,7 +5609,7 @@ const TABLE_TYPE = {
|
|
|
5590
5609
|
};
|
|
5591
5610
|
let drizzleDialect;
|
|
5592
5611
|
let schemaPath;
|
|
5593
|
-
const options$
|
|
5612
|
+
const options$3 = defineAddonOptions({ demo: {
|
|
5594
5613
|
type: "boolean",
|
|
5595
5614
|
default: true,
|
|
5596
5615
|
question: `Do you want to include a demo? ${colors.dim("(includes a login/register page)")}`
|
|
@@ -5599,16 +5618,16 @@ var lucia_default = defineAddon({
|
|
|
5599
5618
|
id: "lucia",
|
|
5600
5619
|
shortDescription: "auth guide",
|
|
5601
5620
|
homepage: "https://lucia-auth.com",
|
|
5602
|
-
options: options$
|
|
5621
|
+
options: options$3,
|
|
5603
5622
|
setup: ({ kit, dependencyVersion, unsupported, dependsOn }) => {
|
|
5604
5623
|
if (!kit) unsupported("Requires SvelteKit");
|
|
5605
5624
|
if (!dependencyVersion("drizzle-orm")) dependsOn("drizzle");
|
|
5606
5625
|
},
|
|
5607
|
-
run: ({ sv, typescript, options: options$
|
|
5626
|
+
run: ({ sv, typescript, options: options$6, kit, dependencyVersion }) => {
|
|
5608
5627
|
const ext = typescript ? "ts" : "js";
|
|
5609
5628
|
sv.dependency("@oslojs/crypto", "^1.0.1");
|
|
5610
5629
|
sv.dependency("@oslojs/encoding", "^1.1.0");
|
|
5611
|
-
if (options$
|
|
5630
|
+
if (options$6.demo) sv.dependency("@node-rs/argon2", "^2.0.2");
|
|
5612
5631
|
sv.file(`drizzle.config.${ext}`, (content) => {
|
|
5613
5632
|
const { ast, generateCode } = parseScript(content);
|
|
5614
5633
|
const isProp = (name$1, node) => node.key.type === "Identifier" && node.key.name === name$1;
|
|
@@ -5642,7 +5661,7 @@ var lucia_default = defineAddon({
|
|
|
5642
5661
|
integer: "integer"
|
|
5643
5662
|
});
|
|
5644
5663
|
object_exports.overrideProperties(userAttributes, { id: common_exports.expressionFromString("text('id').primaryKey()") });
|
|
5645
|
-
if (options$
|
|
5664
|
+
if (options$6.demo) object_exports.overrideProperties(userAttributes, {
|
|
5646
5665
|
username: common_exports.expressionFromString("text('username').notNull().unique()"),
|
|
5647
5666
|
passwordHash: common_exports.expressionFromString("text('password_hash').notNull()")
|
|
5648
5667
|
});
|
|
@@ -5659,7 +5678,7 @@ var lucia_default = defineAddon({
|
|
|
5659
5678
|
datetime: "datetime"
|
|
5660
5679
|
});
|
|
5661
5680
|
object_exports.overrideProperties(userAttributes, { id: common_exports.expressionFromString("varchar('id', { length: 255 }).primaryKey()") });
|
|
5662
|
-
if (options$
|
|
5681
|
+
if (options$6.demo) object_exports.overrideProperties(userAttributes, {
|
|
5663
5682
|
username: common_exports.expressionFromString("varchar('username', { length: 32 }).notNull().unique()"),
|
|
5664
5683
|
passwordHash: common_exports.expressionFromString("varchar('password_hash', { length: 255 }).notNull()")
|
|
5665
5684
|
});
|
|
@@ -5676,7 +5695,7 @@ var lucia_default = defineAddon({
|
|
|
5676
5695
|
timestamp: "timestamp"
|
|
5677
5696
|
});
|
|
5678
5697
|
object_exports.overrideProperties(userAttributes, { id: common_exports.expressionFromString("text('id').primaryKey()") });
|
|
5679
|
-
if (options$
|
|
5698
|
+
if (options$6.demo) object_exports.overrideProperties(userAttributes, {
|
|
5680
5699
|
username: common_exports.expressionFromString("text('username').notNull().unique()"),
|
|
5681
5700
|
passwordHash: common_exports.expressionFromString("text('password_hash').notNull()")
|
|
5682
5701
|
});
|
|
@@ -5829,7 +5848,7 @@ var lucia_default = defineAddon({
|
|
|
5829
5848
|
kit_exports.addHooksHandle(ast, typescript, "handleAuth", getAuthHandleContent());
|
|
5830
5849
|
return generateCode();
|
|
5831
5850
|
});
|
|
5832
|
-
if (options$
|
|
5851
|
+
if (options$6.demo) {
|
|
5833
5852
|
sv.file(`${kit?.routesDirectory}/demo/+page.svelte`, (content) => {
|
|
5834
5853
|
return addToDemoPage(content, "lucia");
|
|
5835
5854
|
});
|
|
@@ -6040,9 +6059,9 @@ var lucia_default = defineAddon({
|
|
|
6040
6059
|
});
|
|
6041
6060
|
}
|
|
6042
6061
|
},
|
|
6043
|
-
nextSteps: ({ highlighter, options: options$
|
|
6062
|
+
nextSteps: ({ highlighter, options: options$6, packageManager }) => {
|
|
6044
6063
|
const steps = [`Run ${highlighter.command(`${packageManager} run db:push`)} to update your database schema`];
|
|
6045
|
-
if (options$
|
|
6064
|
+
if (options$6.demo) steps.push(`Visit ${highlighter.route("/demo/lucia")} route to view the demo`);
|
|
6046
6065
|
return steps;
|
|
6047
6066
|
}
|
|
6048
6067
|
});
|
|
@@ -6152,7 +6171,7 @@ function appendElement(childNodes, elementToAppend) {
|
|
|
6152
6171
|
childNodes.push(elementToAppend);
|
|
6153
6172
|
}
|
|
6154
6173
|
function addFromRawHtml(childNodes, html) {
|
|
6155
|
-
const document = parseHtml(html);
|
|
6174
|
+
const document = parseHtml$1(html);
|
|
6156
6175
|
for (const childNode of document.childNodes) childNodes.push(childNode);
|
|
6157
6176
|
}
|
|
6158
6177
|
function addSlot(jsAst, htmlAst, svelteVersion) {
|
|
@@ -6181,7 +6200,7 @@ const DEFAULT_INLANG_PROJECT = {
|
|
|
6181
6200
|
],
|
|
6182
6201
|
"plugin.inlang.messageFormat": { pathPattern: "./messages/{languageTag}.json" }
|
|
6183
6202
|
};
|
|
6184
|
-
const options$
|
|
6203
|
+
const options$2 = defineAddonOptions({
|
|
6185
6204
|
availableLanguageTags: {
|
|
6186
6205
|
question: `Which languages would you like to support? ${colors.gray("(e.g. en,de-ch)")}`,
|
|
6187
6206
|
type: "string",
|
|
@@ -6210,11 +6229,11 @@ var paraglide_default = defineAddon({
|
|
|
6210
6229
|
id: "paraglide",
|
|
6211
6230
|
shortDescription: "i18n",
|
|
6212
6231
|
homepage: "https://inlang.com",
|
|
6213
|
-
options: options$
|
|
6232
|
+
options: options$2,
|
|
6214
6233
|
setup: ({ kit, unsupported }) => {
|
|
6215
6234
|
if (!kit) unsupported("Requires SvelteKit");
|
|
6216
6235
|
},
|
|
6217
|
-
run: ({ sv, options: options$
|
|
6236
|
+
run: ({ sv, options: options$6, typescript, kit, dependencyVersion }) => {
|
|
6218
6237
|
const ext = typescript ? "ts" : "js";
|
|
6219
6238
|
if (!kit) throw new Error("SvelteKit is required");
|
|
6220
6239
|
const paraglideOutDir = "src/lib/paraglide";
|
|
@@ -6223,7 +6242,7 @@ var paraglide_default = defineAddon({
|
|
|
6223
6242
|
if (content) return content;
|
|
6224
6243
|
const { data, generateCode } = parseJson(content);
|
|
6225
6244
|
for (const key in DEFAULT_INLANG_PROJECT) data[key] = DEFAULT_INLANG_PROJECT[key];
|
|
6226
|
-
const { validLanguageTags: validLanguageTags$1 } = parseLanguageTagInput(options$
|
|
6245
|
+
const { validLanguageTags: validLanguageTags$1 } = parseLanguageTagInput(options$6.availableLanguageTags);
|
|
6227
6246
|
const sourceLanguageTag = validLanguageTags$1[0];
|
|
6228
6247
|
data.sourceLanguageTag = sourceLanguageTag;
|
|
6229
6248
|
data.languageTags = validLanguageTags$1;
|
|
@@ -6293,7 +6312,7 @@ var paraglide_default = defineAddon({
|
|
|
6293
6312
|
});
|
|
6294
6313
|
});
|
|
6295
6314
|
sv.file("src/app.html", (content) => {
|
|
6296
|
-
const { ast, generateCode } = parseHtml
|
|
6315
|
+
const { ast, generateCode } = parseHtml(content);
|
|
6297
6316
|
const htmlNode = ast.children.find((child) => child.type === esm_exports.Tag && child.name === "html");
|
|
6298
6317
|
if (!htmlNode) {
|
|
6299
6318
|
log$1.warn("Could not find <html> node in app.html. You'll need to add the language placeholder manually");
|
|
@@ -6311,7 +6330,7 @@ var paraglide_default = defineAddon({
|
|
|
6311
6330
|
if (!content.includes(`\n${paraglideOutDir}`)) content = content.trimEnd() + `\n\n# Paraglide\n${paraglideOutDir}`;
|
|
6312
6331
|
return content;
|
|
6313
6332
|
});
|
|
6314
|
-
if (options$
|
|
6333
|
+
if (options$6.demo) {
|
|
6315
6334
|
sv.file(`${kit.routesDirectory}/demo/+page.svelte`, (content) => {
|
|
6316
6335
|
return addToDemoPage(content, "paraglide");
|
|
6317
6336
|
});
|
|
@@ -6340,7 +6359,7 @@ var paraglide_default = defineAddon({
|
|
|
6340
6359
|
}
|
|
6341
6360
|
const templateCode = new MagicString(template.source);
|
|
6342
6361
|
templateCode.append("\n\n<h1>{m.hello_world({ name: 'SvelteKit User' })}</h1>\n");
|
|
6343
|
-
const { validLanguageTags: validLanguageTags$1 } = parseLanguageTagInput(options$
|
|
6362
|
+
const { validLanguageTags: validLanguageTags$1 } = parseLanguageTagInput(options$6.availableLanguageTags);
|
|
6344
6363
|
const links = validLanguageTags$1.map((x) => `${templateCode.getIndentString()}<button onclick={() => switchToLanguage('${x}')}>${x}</button>`).join("\n");
|
|
6345
6364
|
templateCode.append(`<div>\n${links}\n</div>`);
|
|
6346
6365
|
return generateCode({
|
|
@@ -6349,7 +6368,7 @@ var paraglide_default = defineAddon({
|
|
|
6349
6368
|
});
|
|
6350
6369
|
});
|
|
6351
6370
|
}
|
|
6352
|
-
const { validLanguageTags } = parseLanguageTagInput(options$
|
|
6371
|
+
const { validLanguageTags } = parseLanguageTagInput(options$6.availableLanguageTags);
|
|
6353
6372
|
for (const languageTag of validLanguageTags) sv.file(`messages/${languageTag}.json`, (content) => {
|
|
6354
6373
|
const { data, generateCode } = parseJson(content);
|
|
6355
6374
|
data["$schema"] = "https://inlang.com/schema/inlang-message-format";
|
|
@@ -6359,7 +6378,7 @@ var paraglide_default = defineAddon({
|
|
|
6359
6378
|
},
|
|
6360
6379
|
nextSteps: ({ highlighter }) => {
|
|
6361
6380
|
const steps = [`Edit your messages in ${highlighter.path("messages/en.json")}`, "Consider installing the Sherlock IDE Extension"];
|
|
6362
|
-
if (options$
|
|
6381
|
+
if (options$2.demo) steps.push(`Visit ${highlighter.route("/demo/paraglide")} route to view the demo`);
|
|
6363
6382
|
return steps;
|
|
6364
6383
|
}
|
|
6365
6384
|
});
|
|
@@ -6463,8 +6482,8 @@ var prettier_default = defineAddon({
|
|
|
6463
6482
|
}
|
|
6464
6483
|
data.plugins ??= [];
|
|
6465
6484
|
data.overrides ??= [];
|
|
6466
|
-
const plugins = data.plugins;
|
|
6467
|
-
if (!plugins.includes("prettier-plugin-svelte")) data.plugins.unshift("prettier-plugin-svelte");
|
|
6485
|
+
const plugins$1 = data.plugins;
|
|
6486
|
+
if (!plugins$1.includes("prettier-plugin-svelte")) data.plugins.unshift("prettier-plugin-svelte");
|
|
6468
6487
|
const overrides = data.overrides;
|
|
6469
6488
|
const override = overrides.find((o) => o?.options?.parser === "svelte");
|
|
6470
6489
|
if (!override) overrides.push({
|
|
@@ -6533,21 +6552,58 @@ else ast.prepend(rule);
|
|
|
6533
6552
|
});
|
|
6534
6553
|
return nodes;
|
|
6535
6554
|
}
|
|
6555
|
+
function addAtRule(ast, name$1, params, append = false) {
|
|
6556
|
+
const atRules = ast.nodes.filter((x) => x.type == "atrule");
|
|
6557
|
+
let atRule = atRules.find((x) => x.name == name$1 && x.params == params);
|
|
6558
|
+
if (atRule) return atRule;
|
|
6559
|
+
atRule = new AtRule({
|
|
6560
|
+
name: name$1,
|
|
6561
|
+
params
|
|
6562
|
+
});
|
|
6563
|
+
if (!append) ast.prepend(atRule);
|
|
6564
|
+
else ast.append(atRule);
|
|
6565
|
+
return atRule;
|
|
6566
|
+
}
|
|
6536
6567
|
|
|
6537
6568
|
//#endregion
|
|
6538
6569
|
//#region packages/addons/tailwindcss/index.ts
|
|
6570
|
+
const plugins = [{
|
|
6571
|
+
id: "typography",
|
|
6572
|
+
package: "@tailwindcss/typography",
|
|
6573
|
+
version: "^0.5.15",
|
|
6574
|
+
identifier: "typography"
|
|
6575
|
+
}, {
|
|
6576
|
+
id: "forms",
|
|
6577
|
+
package: "@tailwindcss/forms",
|
|
6578
|
+
version: "^0.5.9",
|
|
6579
|
+
identifier: "forms"
|
|
6580
|
+
}];
|
|
6581
|
+
const options$1 = defineAddonOptions({ plugins: {
|
|
6582
|
+
type: "multiselect",
|
|
6583
|
+
question: "Which plugins would you like to add?",
|
|
6584
|
+
options: plugins.map((p) => ({
|
|
6585
|
+
value: p.id,
|
|
6586
|
+
label: p.id,
|
|
6587
|
+
hint: p.package
|
|
6588
|
+
})),
|
|
6589
|
+
default: []
|
|
6590
|
+
} });
|
|
6539
6591
|
var tailwindcss_default = defineAddon({
|
|
6540
6592
|
id: "tailwindcss",
|
|
6541
6593
|
alias: "tailwind",
|
|
6542
6594
|
shortDescription: "css framework",
|
|
6543
6595
|
homepage: "https://tailwindcss.com",
|
|
6544
|
-
options:
|
|
6545
|
-
run: ({ sv, typescript, kit, dependencyVersion }) => {
|
|
6596
|
+
options: options$1,
|
|
6597
|
+
run: ({ sv, options: options$6, typescript, kit, dependencyVersion }) => {
|
|
6546
6598
|
const ext = typescript ? "ts" : "js";
|
|
6547
6599
|
const prettierInstalled = Boolean(dependencyVersion("prettier"));
|
|
6548
6600
|
sv.devDependency("tailwindcss", "^4.0.0");
|
|
6549
6601
|
sv.devDependency("@tailwindcss/vite", "^4.0.0");
|
|
6550
6602
|
if (prettierInstalled) sv.devDependency("prettier-plugin-tailwindcss", "^0.6.11");
|
|
6603
|
+
for (const plugin of plugins) {
|
|
6604
|
+
if (!options$6.plugins.includes(plugin.id)) continue;
|
|
6605
|
+
sv.devDependency(plugin.package, plugin.version);
|
|
6606
|
+
}
|
|
6551
6607
|
sv.file(`vite.config.${ext}`, (content) => {
|
|
6552
6608
|
const { ast, generateCode } = parseScript(content);
|
|
6553
6609
|
const vitePluginName = "tailwindcss";
|
|
@@ -6564,6 +6620,10 @@ var tailwindcss_default = defineAddon({
|
|
|
6564
6620
|
const { ast, generateCode } = parseCss(content);
|
|
6565
6621
|
const originalFirst = ast.first;
|
|
6566
6622
|
const nodes = addImports(ast, ["'tailwindcss'"]);
|
|
6623
|
+
for (const plugin of plugins) {
|
|
6624
|
+
if (!options$6.plugins.includes(plugin.id)) continue;
|
|
6625
|
+
addAtRule(ast, "plugin", `'${plugin.package}'`, true);
|
|
6626
|
+
}
|
|
6567
6627
|
if (originalFirst !== ast.first && originalFirst?.type === "atrule" && originalFirst.name === "import") originalFirst.raws.before = "\n";
|
|
6568
6628
|
nodes.shift();
|
|
6569
6629
|
nodes.forEach((n$1) => n$1.raws.before = "\n");
|
|
@@ -6591,8 +6651,8 @@ else sv.file(`${kit?.routesDirectory}/+layout.svelte`, (content) => {
|
|
|
6591
6651
|
const { data, generateCode } = parseJson(content);
|
|
6592
6652
|
const PLUGIN_NAME = "prettier-plugin-tailwindcss";
|
|
6593
6653
|
data.plugins ??= [];
|
|
6594
|
-
const plugins = data.plugins;
|
|
6595
|
-
if (!plugins.includes(PLUGIN_NAME)) plugins.push(PLUGIN_NAME);
|
|
6654
|
+
const plugins$1 = data.plugins;
|
|
6655
|
+
if (!plugins$1.includes(PLUGIN_NAME)) plugins$1.push(PLUGIN_NAME);
|
|
6596
6656
|
return generateCode();
|
|
6597
6657
|
});
|
|
6598
6658
|
}
|
|
@@ -6610,7 +6670,7 @@ var vitest_addon_default = defineAddon({
|
|
|
6610
6670
|
sv.devDependency("vitest", "^3.0.0");
|
|
6611
6671
|
sv.devDependency("@testing-library/svelte", "^5.2.4");
|
|
6612
6672
|
sv.devDependency("@testing-library/jest-dom", "^6.6.3");
|
|
6613
|
-
sv.devDependency("jsdom", "^
|
|
6673
|
+
sv.devDependency("jsdom", "^26.0.0");
|
|
6614
6674
|
sv.file("package.json", (content) => {
|
|
6615
6675
|
const { data, generateCode } = parseJson(content);
|
|
6616
6676
|
data.scripts ??= {};
|
|
@@ -9542,14 +9602,14 @@ function verifyPackage(pkg, specifier) {
|
|
|
9542
9602
|
throw new Error(`Invalid add-on package detected: '${specifier}'\nCommunity addons should not have any external 'dependencies' besides '@sveltejs/cli-core'. Consider bundling your dependencies if they are necessary`);
|
|
9543
9603
|
}
|
|
9544
9604
|
}
|
|
9545
|
-
async function downloadPackage(options$
|
|
9546
|
-
const { pkg } = options$
|
|
9547
|
-
if (options$
|
|
9605
|
+
async function downloadPackage(options$6) {
|
|
9606
|
+
const { pkg } = options$6;
|
|
9607
|
+
if (options$6.path) {
|
|
9548
9608
|
const dest = path.join(NODE_MODULES, pkg.name.split("/").join(path.sep));
|
|
9549
9609
|
if (fs.existsSync(dest)) fs.rmSync(dest);
|
|
9550
9610
|
const dir = path.dirname(dest);
|
|
9551
9611
|
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
9552
|
-
fs.symlinkSync(options$
|
|
9612
|
+
fs.symlinkSync(options$6.path, dest);
|
|
9553
9613
|
const { default: details$1 } = await import(pkg.name);
|
|
9554
9614
|
return details$1;
|
|
9555
9615
|
}
|
|
@@ -9672,7 +9732,7 @@ const add = new Command("add").description("applies specified add-ons into a pro
|
|
|
9672
9732
|
process$1.exit(1);
|
|
9673
9733
|
}
|
|
9674
9734
|
const specifiedAddons = parse(AddonsSchema, addonArgs);
|
|
9675
|
-
const options$
|
|
9735
|
+
const options$6 = parse(OptionsSchema$1, opts);
|
|
9676
9736
|
const addonIds = officialAddons.map((addon) => addon.id);
|
|
9677
9737
|
const invalidAddons = specifiedAddons.filter((a) => !addonIds.includes(a) && !aliases.includes(a));
|
|
9678
9738
|
if (invalidAddons.length > 0) {
|
|
@@ -9681,12 +9741,12 @@ const add = new Command("add").description("applies specified add-ons into a pro
|
|
|
9681
9741
|
}
|
|
9682
9742
|
const selectedAddons = transformAliases(specifiedAddons);
|
|
9683
9743
|
runCommand(async () => {
|
|
9684
|
-
const { nextSteps } = await runAddCommand(options$
|
|
9744
|
+
const { nextSteps } = await runAddCommand(options$6, selectedAddons);
|
|
9685
9745
|
if (nextSteps) box(nextSteps, "Next steps");
|
|
9686
9746
|
});
|
|
9687
9747
|
});
|
|
9688
9748
|
for (const option of addonsOptions) add.addOption(option);
|
|
9689
|
-
async function runAddCommand(options$
|
|
9749
|
+
async function runAddCommand(options$6, selectedAddonIds) {
|
|
9690
9750
|
const selectedAddons = selectedAddonIds.map((id) => ({
|
|
9691
9751
|
type: "official",
|
|
9692
9752
|
addon: getAddonDetails(id)
|
|
@@ -9696,7 +9756,7 @@ async function runAddCommand(options$5, selectedAddonIds) {
|
|
|
9696
9756
|
for (const addonOption of addonsOptions) {
|
|
9697
9757
|
const addonId = addonOption.name();
|
|
9698
9758
|
const aliased = addonOption.attributeName();
|
|
9699
|
-
const specifiedOptions = options$
|
|
9759
|
+
const specifiedOptions = options$6[addonId] || options$6[aliased];
|
|
9700
9760
|
if (!specifiedOptions) continue;
|
|
9701
9761
|
const details$1 = getAddonDetails(addonId);
|
|
9702
9762
|
if (!selectedAddons.find((d) => d.addon === details$1)) selectedAddons.push({
|
|
@@ -9726,7 +9786,7 @@ async function runAddCommand(options$5, selectedAddonIds) {
|
|
|
9726
9786
|
for (const [id, question] of Object.entries(details$1.options)) if (question.condition?.(official[addonId]) !== false) official[addonId][id] ??= question.default;
|
|
9727
9787
|
else if (official[addonId][id] !== undefined) throw new Error(`Incompatible '--${addonId}' option specified: '${official[addonId][id]}'`);
|
|
9728
9788
|
}
|
|
9729
|
-
if (options$
|
|
9789
|
+
if (options$6.community === true) {
|
|
9730
9790
|
const communityAddons = await Promise.all(communityAddonIds.map(async (id) => await getCommunityAddon(id)));
|
|
9731
9791
|
const promptOptions = communityAddons.map((addon) => ({
|
|
9732
9792
|
value: addon.id,
|
|
@@ -9745,10 +9805,10 @@ else if (official[addonId][id] !== undefined) throw new Error(`Incompatible '--$
|
|
|
9745
9805
|
cancel("No add-ons selected. Exiting.");
|
|
9746
9806
|
process$1.exit(1);
|
|
9747
9807
|
}
|
|
9748
|
-
options$
|
|
9808
|
+
options$6.community = selected;
|
|
9749
9809
|
}
|
|
9750
|
-
if (Array.isArray(options$
|
|
9751
|
-
const addons = options$
|
|
9810
|
+
if (Array.isArray(options$6.community) && options$6.community.length > 0) {
|
|
9811
|
+
const addons = options$6.community.map((id) => {
|
|
9752
9812
|
const hasDirective = Object.values(Directive).some((directive) => id.startsWith(directive));
|
|
9753
9813
|
if (hasDirective) return id;
|
|
9754
9814
|
const validAddon = communityAddonIds.includes(id);
|
|
@@ -9760,7 +9820,7 @@ else if (official[addonId][id] !== undefined) throw new Error(`Incompatible '--$
|
|
|
9760
9820
|
start("Resolving community add-on packages");
|
|
9761
9821
|
const pkgs = await Promise.all(addons.map(async (id) => {
|
|
9762
9822
|
return await getPackageJSON({
|
|
9763
|
-
cwd: options$
|
|
9823
|
+
cwd: options$6.cwd,
|
|
9764
9824
|
packageName: id
|
|
9765
9825
|
});
|
|
9766
9826
|
}));
|
|
@@ -9797,7 +9857,7 @@ else if (official[addonId][id] !== undefined) throw new Error(`Incompatible '--$
|
|
|
9797
9857
|
throw err;
|
|
9798
9858
|
}
|
|
9799
9859
|
}
|
|
9800
|
-
let workspace = createWorkspace({ cwd: options$
|
|
9860
|
+
let workspace = createWorkspace({ cwd: options$6.cwd });
|
|
9801
9861
|
const addonSetupResults = setupAddons(officialAddons, workspace);
|
|
9802
9862
|
if (selectedAddons.length === 0) {
|
|
9803
9863
|
const addonOptions = officialAddons.filter(({ id }) => addonSetupResults[id].unsupported.length === 0).map(({ id, homepage: homepage$1, shortDescription }) => ({
|
|
@@ -9840,9 +9900,9 @@ else if (official[addonId][id] !== undefined) throw new Error(`Incompatible '--$
|
|
|
9840
9900
|
});
|
|
9841
9901
|
}
|
|
9842
9902
|
}
|
|
9843
|
-
if (options$
|
|
9903
|
+
if (options$6.preconditions && selectedAddons.length > 0) {
|
|
9844
9904
|
const addons = selectedAddons.map(({ addon }) => addon);
|
|
9845
|
-
const { preconditions } = getGlobalPreconditions(options$
|
|
9905
|
+
const { preconditions } = getGlobalPreconditions(options$6.cwd, addons, addonSetupResults);
|
|
9846
9906
|
const fails = [];
|
|
9847
9907
|
for (const condition of preconditions) {
|
|
9848
9908
|
const { message, success } = await condition.run();
|
|
@@ -9925,12 +9985,12 @@ else if (official[addonId][id] !== undefined) throw new Error(`Incompatible '--$
|
|
|
9925
9985
|
});
|
|
9926
9986
|
log.success("Successfully setup add-ons");
|
|
9927
9987
|
let packageManager;
|
|
9928
|
-
if (options$
|
|
9929
|
-
packageManager = await packageManagerPrompt(options$
|
|
9988
|
+
if (options$6.install) {
|
|
9989
|
+
packageManager = await packageManagerPrompt(options$6.cwd);
|
|
9930
9990
|
if (packageManager) {
|
|
9931
9991
|
workspace.packageManager = packageManager;
|
|
9932
9992
|
addPnpmBuildDependendencies(workspace.cwd, packageManager, ["esbuild", ...addonPnpmBuildDependencies]);
|
|
9933
|
-
await installDependencies(packageManager, options$
|
|
9993
|
+
await installDependencies(packageManager, options$6.cwd);
|
|
9934
9994
|
}
|
|
9935
9995
|
}
|
|
9936
9996
|
workspace = createWorkspace(workspace);
|
|
@@ -9940,7 +10000,7 @@ else if (official[addonId][id] !== undefined) throw new Error(`Incompatible '--$
|
|
|
9940
10000
|
try {
|
|
9941
10001
|
await formatFiles({
|
|
9942
10002
|
packageManager,
|
|
9943
|
-
cwd: options$
|
|
10003
|
+
cwd: options$6.cwd,
|
|
9944
10004
|
paths: filesToFormat
|
|
9945
10005
|
});
|
|
9946
10006
|
stop("Successfully formatted modified files");
|
|
@@ -9978,7 +10038,7 @@ function transformAliases(ids) {
|
|
|
9978
10038
|
return Array.from(set);
|
|
9979
10039
|
}
|
|
9980
10040
|
function getAddonOptionFlags() {
|
|
9981
|
-
const options$
|
|
10041
|
+
const options$6 = [];
|
|
9982
10042
|
for (const addon of officialAddons) {
|
|
9983
10043
|
const id = addon.id;
|
|
9984
10044
|
const details = getAddonDetails(id);
|
|
@@ -9991,36 +10051,36 @@ function getAddonOptionFlags() {
|
|
|
9991
10051
|
prev = prev.concat(value.split(/\s|,/));
|
|
9992
10052
|
return prev;
|
|
9993
10053
|
});
|
|
9994
|
-
options$
|
|
10054
|
+
options$6.push(option);
|
|
9995
10055
|
}
|
|
9996
|
-
return options$
|
|
10056
|
+
return options$6;
|
|
9997
10057
|
}
|
|
9998
10058
|
function getOptionChoices(details) {
|
|
9999
10059
|
const choices = [];
|
|
10000
10060
|
const defaults = [];
|
|
10001
10061
|
const groups = {};
|
|
10002
|
-
const options$
|
|
10062
|
+
const options$6 = {};
|
|
10003
10063
|
for (const [id, question] of Object.entries(details.options)) {
|
|
10004
10064
|
let values = [];
|
|
10005
|
-
const applyDefault = question.condition?.(options$
|
|
10065
|
+
const applyDefault = question.condition?.(options$6) !== false;
|
|
10006
10066
|
if (question.type === "boolean") {
|
|
10007
10067
|
values = [id, `no-${id}`];
|
|
10008
10068
|
if (applyDefault) {
|
|
10009
|
-
options$
|
|
10069
|
+
options$6[id] = question.default;
|
|
10010
10070
|
defaults.push(question.default ? values[0] : values[1]);
|
|
10011
10071
|
}
|
|
10012
10072
|
}
|
|
10013
10073
|
if (question.type === "select") {
|
|
10014
10074
|
values = question.options.map((o) => o.value);
|
|
10015
10075
|
if (applyDefault) {
|
|
10016
|
-
options$
|
|
10076
|
+
options$6[id] = question.default;
|
|
10017
10077
|
defaults.push(question.default);
|
|
10018
10078
|
}
|
|
10019
10079
|
}
|
|
10020
10080
|
if (question.type === "multiselect") {
|
|
10021
10081
|
values = question.options.map((o) => o.value);
|
|
10022
10082
|
if (applyDefault) {
|
|
10023
|
-
options$
|
|
10083
|
+
options$6[id] = question.default;
|
|
10024
10084
|
defaults.push(...question.default);
|
|
10025
10085
|
}
|
|
10026
10086
|
}
|
|
@@ -10057,9 +10117,9 @@ const OptionsSchema = strictObject({
|
|
|
10057
10117
|
});
|
|
10058
10118
|
const create$1 = new Command("create").description("scaffolds a new SvelteKit project").argument("[path]", "where the project will be created").addOption(templateOption).addOption(langOption).option("--no-types").option("--no-add-ons", "skips interactive add-on installer").option("--no-install", "skip installing dependencies").configureHelp(helpConfig).action((projectPath, opts) => {
|
|
10059
10119
|
const cwd = parse(ProjectPathSchema, projectPath);
|
|
10060
|
-
const options$
|
|
10120
|
+
const options$6 = parse(OptionsSchema, opts);
|
|
10061
10121
|
runCommand(async () => {
|
|
10062
|
-
const { directory, addOnNextSteps, packageManager } = await createProject(cwd, options$
|
|
10122
|
+
const { directory, addOnNextSteps, packageManager } = await createProject(cwd, options$6);
|
|
10063
10123
|
const highlight = (str) => import_picocolors$1.default.bold(import_picocolors$1.default.cyan(str));
|
|
10064
10124
|
let i = 1;
|
|
10065
10125
|
const initialSteps = [];
|
|
@@ -10088,7 +10148,7 @@ const create$1 = new Command("create").description("scaffolds a new SvelteKit pr
|
|
|
10088
10148
|
if (addOnNextSteps) box(addOnNextSteps, "Add-on next steps");
|
|
10089
10149
|
});
|
|
10090
10150
|
});
|
|
10091
|
-
async function createProject(cwd, options$
|
|
10151
|
+
async function createProject(cwd, options$6) {
|
|
10092
10152
|
const { directory, template, language } = await group({
|
|
10093
10153
|
directory: () => {
|
|
10094
10154
|
if (cwd) return Promise.resolve(path.resolve(cwd));
|
|
@@ -10112,7 +10172,7 @@ async function createProject(cwd, options$5) {
|
|
|
10112
10172
|
}
|
|
10113
10173
|
},
|
|
10114
10174
|
template: () => {
|
|
10115
|
-
if (options$
|
|
10175
|
+
if (options$6.template) return Promise.resolve(options$6.template);
|
|
10116
10176
|
return select({
|
|
10117
10177
|
message: "Which template would you like?",
|
|
10118
10178
|
initialValue: "minimal",
|
|
@@ -10124,7 +10184,7 @@ async function createProject(cwd, options$5) {
|
|
|
10124
10184
|
});
|
|
10125
10185
|
},
|
|
10126
10186
|
language: () => {
|
|
10127
|
-
if (options$
|
|
10187
|
+
if (options$6.types) return Promise.resolve(options$6.types);
|
|
10128
10188
|
return select({
|
|
10129
10189
|
message: "Add type checking with Typescript?",
|
|
10130
10190
|
initialValue: "typescript",
|
|
@@ -10162,17 +10222,17 @@ async function createProject(cwd, options$5) {
|
|
|
10162
10222
|
addPnpmBuildDependendencies(projectPath, packageManager, ["esbuild"]);
|
|
10163
10223
|
if (packageManager) await installDependencies(packageManager, projectPath);
|
|
10164
10224
|
};
|
|
10165
|
-
if (options$
|
|
10225
|
+
if (options$6.addOns) {
|
|
10166
10226
|
const { nextSteps, packageManager: pm } = await runAddCommand({
|
|
10167
10227
|
cwd: projectPath,
|
|
10168
|
-
install: options$
|
|
10228
|
+
install: options$6.install,
|
|
10169
10229
|
preconditions: false,
|
|
10170
10230
|
community: []
|
|
10171
10231
|
}, []);
|
|
10172
10232
|
packageManager = pm;
|
|
10173
10233
|
addOnNextSteps = nextSteps;
|
|
10174
|
-
} else if (options$
|
|
10175
|
-
if (packageManager === null && options$
|
|
10234
|
+
} else if (options$6.install) await installDeps();
|
|
10235
|
+
if (packageManager === null && options$6.install) await installDeps();
|
|
10176
10236
|
return {
|
|
10177
10237
|
directory: projectPath,
|
|
10178
10238
|
addOnNextSteps,
|
|
@@ -10185,8 +10245,8 @@ async function createProject(cwd, options$5) {
|
|
|
10185
10245
|
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.cwd()).configureHelp({ formatHelp() {
|
|
10186
10246
|
runMigrate(process$1.cwd(), ["--help"]);
|
|
10187
10247
|
return "";
|
|
10188
|
-
} }).action((migration, options$
|
|
10189
|
-
runMigrate(options$
|
|
10248
|
+
} }).action((migration, options$6) => {
|
|
10249
|
+
runMigrate(options$6.cwd, [migration]);
|
|
10190
10250
|
});
|
|
10191
10251
|
function runMigrate(cwd, args) {
|
|
10192
10252
|
const pm = getUserAgent() ?? "npm";
|
|
@@ -10209,8 +10269,8 @@ var import_picocolors = __toESM(require_picocolors(), 1);
|
|
|
10209
10269
|
const check = new Command("check").description("a CLI for checking your Svelte code").allowUnknownOption(true).allowExcessArguments(true).option("-C, --cwd <path>", "path to working directory", process$1.cwd()).configureHelp({ formatHelp() {
|
|
10210
10270
|
runCheck(process$1.cwd(), ["--help"]);
|
|
10211
10271
|
return "";
|
|
10212
|
-
} }).action((options$
|
|
10213
|
-
const cwd = options$
|
|
10272
|
+
} }).action((options$6, check$1) => {
|
|
10273
|
+
const cwd = options$6.cwd;
|
|
10214
10274
|
const args = check$1.args;
|
|
10215
10275
|
runCheck(cwd, args);
|
|
10216
10276
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sv",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.23",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A CLI for creating and updating SvelteKit projects",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"valibot": "^0.41.0",
|
|
40
40
|
"@sveltejs/addons": "0.0.0",
|
|
41
41
|
"@sveltejs/clack-prompts": "0.9.1",
|
|
42
|
-
"@sveltejs/
|
|
43
|
-
"@sveltejs/
|
|
42
|
+
"@sveltejs/cli-core": "0.0.0",
|
|
43
|
+
"@sveltejs/create": "0.0.0"
|
|
44
44
|
},
|
|
45
45
|
"keywords": [
|
|
46
46
|
"create",
|