sv 0.5.2 → 0.5.3
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 +35 -42
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
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.3";
|
|
29
29
|
var type = "module";
|
|
30
30
|
var description = "A CLI for creating and updating SvelteKit projects";
|
|
31
31
|
var license = "MIT";
|
|
@@ -46406,7 +46406,7 @@ function addGlobalAppInterface(ast, name) {
|
|
|
46406
46406
|
}
|
|
46407
46407
|
return interfaceNode;
|
|
46408
46408
|
}
|
|
46409
|
-
function addHooksHandle(ast, typescript, newHandleName, handleContent
|
|
46409
|
+
function addHooksHandle(ast, typescript, newHandleName, handleContent) {
|
|
46410
46410
|
if (typescript) {
|
|
46411
46411
|
addNamed(ast, "@sveltejs/kit", { Handle: "Handle" }, true);
|
|
46412
46412
|
}
|
|
@@ -46439,31 +46439,23 @@ function addHooksHandle(ast, typescript, newHandleName, handleContent, forceSepa
|
|
|
46439
46439
|
const newHandle = expressionFromString(handleContent);
|
|
46440
46440
|
if (hasNode(ast, newHandle)) return;
|
|
46441
46441
|
if (!originalHandleDecl || !exportDecl) {
|
|
46442
|
-
const newDecl2 = declaration(ast, "const",
|
|
46442
|
+
const newDecl2 = declaration(ast, "const", newHandleName, newHandle);
|
|
46443
46443
|
if (typescript) {
|
|
46444
46444
|
const declarator = newDecl2.declarations[0];
|
|
46445
46445
|
typeAnnotateDeclarator(declarator, "Handle");
|
|
46446
46446
|
}
|
|
46447
|
-
|
|
46448
|
-
|
|
46449
|
-
|
|
46450
|
-
|
|
46451
|
-
|
|
46452
|
-
|
|
46453
|
-
|
|
46454
|
-
|
|
46455
|
-
const
|
|
46456
|
-
|
|
46457
|
-
"const",
|
|
46458
|
-
handleName,
|
|
46459
|
-
expressionFromString(newHandleName)
|
|
46460
|
-
);
|
|
46461
|
-
if (typescript) {
|
|
46462
|
-
const declarator = handleDecl.declarations[0];
|
|
46463
|
-
typeAnnotateDeclarator(declarator, "Handle");
|
|
46464
|
-
}
|
|
46465
|
-
namedExport(ast, handleName, handleDecl);
|
|
46447
|
+
ast.body.push(newDecl2);
|
|
46448
|
+
const handleDecl = declaration(
|
|
46449
|
+
ast,
|
|
46450
|
+
"const",
|
|
46451
|
+
handleName,
|
|
46452
|
+
expressionFromString(newHandleName)
|
|
46453
|
+
);
|
|
46454
|
+
if (typescript) {
|
|
46455
|
+
const declarator = handleDecl.declarations[0];
|
|
46456
|
+
typeAnnotateDeclarator(declarator, "Handle");
|
|
46466
46457
|
}
|
|
46458
|
+
namedExport(ast, handleName, handleDecl);
|
|
46467
46459
|
return;
|
|
46468
46460
|
}
|
|
46469
46461
|
const newDecl = declaration(ast, "const", newHandleName, newHandle);
|
|
@@ -50479,7 +50471,7 @@ ${sessionType}`);
|
|
|
50479
50471
|
const { ast, generateCode } = parseScript(content);
|
|
50480
50472
|
imports.addNamespace(ast, "$lib/server/auth.js", "auth");
|
|
50481
50473
|
imports.addNamed(ast, "$app/environment", { dev: "dev" });
|
|
50482
|
-
kit.addHooksHandle(ast, typescript, "
|
|
50474
|
+
kit.addHooksHandle(ast, typescript, "handleAuth", getAuthHandleContent());
|
|
50483
50475
|
return generateCode();
|
|
50484
50476
|
}
|
|
50485
50477
|
},
|
|
@@ -50624,15 +50616,16 @@ ${sessionType}`);
|
|
|
50624
50616
|
{
|
|
50625
50617
|
name: ({ kit: kit2 }) => `${kit2.routesDirectory}/demo/login/+page.svelte`,
|
|
50626
50618
|
condition: ({ options: options2 }) => options2.demo,
|
|
50627
|
-
content({ content, typescript, kit: kit2 }) {
|
|
50619
|
+
content({ content, dependencyVersion, typescript, kit: kit2 }) {
|
|
50628
50620
|
if (content) {
|
|
50629
50621
|
const filePath = `${kit2.routesDirectory}/demo/login/+page.svelte`;
|
|
50630
50622
|
log.warn(`Existing ${picocolors.yellow(filePath)} file. Could not update.`);
|
|
50631
50623
|
return content;
|
|
50632
50624
|
}
|
|
50633
|
-
const
|
|
50634
|
-
|
|
50635
|
-
`), ts(
|
|
50625
|
+
const svelte5 = !!dependencyVersion("svelte")?.startsWith("5");
|
|
50626
|
+
const [ts, s5] = utils.createPrinter(typescript, svelte5);
|
|
50627
|
+
return dedent(_a || (_a = __template(["\n <script ", ">\n import { enhance } from '$app/forms';\n ", "\n ", "\n <\/script>\n\n <h1>Login/Register</h1>\n <form method='post' action='?/login' use:enhance>\n <label>\n Username\n <input name='username' />\n </label>\n <label>\n Password\n <input type='password' name='password' />\n </label>\n <button>Login</button>\n <button formaction='?/register'>Register</button>\n </form>\n <p style='color: red'>{form?.message ?? ''}</p>\n "])), ts(`lang='ts'`), ts(`import type { ActionData } from './$types';
|
|
50628
|
+
`), s5(`let { form }${ts(": { form: ActionData }")} = $props();`, `export let form${ts(": ActionData")};`));
|
|
50636
50629
|
}
|
|
50637
50630
|
},
|
|
50638
50631
|
// logout
|
|
@@ -50675,15 +50668,16 @@ ${sessionType}`);
|
|
|
50675
50668
|
{
|
|
50676
50669
|
name: ({ kit: kit2 }) => `${kit2.routesDirectory}/demo/+page.svelte`,
|
|
50677
50670
|
condition: ({ options: options2 }) => options2.demo,
|
|
50678
|
-
content({ content, typescript, kit: kit2 }) {
|
|
50671
|
+
content({ content, dependencyVersion, typescript, kit: kit2 }) {
|
|
50679
50672
|
if (content) {
|
|
50680
50673
|
const filePath = `${kit2.routesDirectory}/demo/+page.svelte`;
|
|
50681
50674
|
log.warn(`Existing ${picocolors.yellow(filePath)} file. Could not update.`);
|
|
50682
50675
|
return content;
|
|
50683
50676
|
}
|
|
50684
|
-
const
|
|
50685
|
-
|
|
50686
|
-
`), ts(
|
|
50677
|
+
const svelte5 = !!dependencyVersion("svelte")?.startsWith("5");
|
|
50678
|
+
const [ts, s5] = utils.createPrinter(typescript, svelte5);
|
|
50679
|
+
return dedent(_b || (_b = __template(["\n <script ", ">\n import { enhance } from '$app/forms';\n ", "\n ", "\n <\/script>\n\n <h1>Hi, {data.user.username}!</h1>\n <p>Your user ID is {data.user.id}.</p>\n <form method='post' action='?/logout' use:enhance>\n <button>Sign out</button>\n </form>\n "])), ts(`lang='ts'`), ts(`import type { PageServerData } from './$types';
|
|
50680
|
+
`), s5(`let { data }${ts(": { data: PageServerData }")} = $props();`, `export let data${ts(": PageServerData")};`));
|
|
50687
50681
|
}
|
|
50688
50682
|
}
|
|
50689
50683
|
],
|
|
@@ -50841,15 +50835,14 @@ const DEFAULT_INLANG_PROJECT = {
|
|
|
50841
50835
|
};
|
|
50842
50836
|
const options$1 = defineAdderOptions({
|
|
50843
50837
|
availableLanguageTags: {
|
|
50844
|
-
question:
|
|
50838
|
+
question: `Which language tags would you like to support? ${picocolors.gray("(e.g. en,de-ch)")}`,
|
|
50845
50839
|
type: "string",
|
|
50846
|
-
default: "",
|
|
50847
|
-
placeholder: "en,de-ch",
|
|
50840
|
+
default: "en",
|
|
50848
50841
|
validate(input) {
|
|
50849
50842
|
const { invalidLanguageTags, validLanguageTags } = parseLanguageTagInput(input);
|
|
50850
50843
|
if (invalidLanguageTags.length > 0) {
|
|
50851
50844
|
if (invalidLanguageTags.length === 1) {
|
|
50852
|
-
return `The input "${invalidLanguageTags[0]}" is not a valid
|
|
50845
|
+
return `The input "${invalidLanguageTags[0]}" is not a valid IETF BCP 47 language tag`;
|
|
50853
50846
|
} else {
|
|
50854
50847
|
const listFormat = new Intl.ListFormat("en", { style: "long", type: "conjunction" });
|
|
50855
50848
|
return `The inputs ${listFormat.format(invalidLanguageTags.map((x) => `"${x}"`))} are not valid BCP47 language tags`;
|
|
@@ -50901,9 +50894,7 @@ var paraglide = defineAdder({
|
|
|
50901
50894
|
content: ({ content }) => {
|
|
50902
50895
|
const { ast, generateCode } = parseScript(content);
|
|
50903
50896
|
const vitePluginName = "paraglide";
|
|
50904
|
-
imports.addNamed(ast, "@inlang/paraglide-sveltekit/vite", {
|
|
50905
|
-
paraglide: vitePluginName
|
|
50906
|
-
});
|
|
50897
|
+
imports.addNamed(ast, "@inlang/paraglide-sveltekit/vite", { paraglide: vitePluginName });
|
|
50907
50898
|
const { value: rootObject } = exports.defaultExport(
|
|
50908
50899
|
ast,
|
|
50909
50900
|
_function.call("defineConfig", [])
|
|
@@ -50962,7 +50953,7 @@ var paraglide = defineAdder({
|
|
|
50962
50953
|
i18n: "i18n"
|
|
50963
50954
|
});
|
|
50964
50955
|
const hookHandleContent = "i18n.handle()";
|
|
50965
|
-
kit.addHooksHandle(ast, typescript, "
|
|
50956
|
+
kit.addHooksHandle(ast, typescript, "handleParaglide", hookHandleContent);
|
|
50966
50957
|
return generateCode();
|
|
50967
50958
|
}
|
|
50968
50959
|
},
|
|
@@ -51019,7 +51010,7 @@ var paraglide = defineAdder({
|
|
|
51019
51010
|
name: ({ kit: kit2 }) => `${kit2?.routesDirectory}/+page.svelte`,
|
|
51020
51011
|
condition: ({ options: options2 }) => options2.demo,
|
|
51021
51012
|
content({ content, options: options2, typescript }) {
|
|
51022
|
-
const { script, template, generateCode } = parseSvelte(content);
|
|
51013
|
+
const { script, template, generateCode } = parseSvelte(content, { typescript });
|
|
51023
51014
|
imports.addDefault(script.ast, "$lib/paraglide/messages.js", "* as m");
|
|
51024
51015
|
imports.addNamed(script.ast, "$app/navigation", { goto: "goto" });
|
|
51025
51016
|
imports.addNamed(script.ast, "$app/stores", { page: "page" });
|
|
@@ -55538,10 +55529,13 @@ async function runAdders({
|
|
|
55538
55529
|
changedFiles.forEach((file) => filesToFormat.add(file));
|
|
55539
55530
|
await config.postInstall?.(workspace);
|
|
55540
55531
|
if (config.scripts && config.scripts.length > 0) {
|
|
55541
|
-
log$1.step(`Running external command ${pc.gray(`(${config.id})`)}`);
|
|
55542
55532
|
for (const script of config.scripts) {
|
|
55543
55533
|
if (script.condition?.(workspace) === false) continue;
|
|
55544
55534
|
const { command, args } = resolveCommand(workspace.packageManager, "execute", script.args);
|
|
55535
|
+
const adderPrefix = details.length > 1 ? `${config.id}: ` : "";
|
|
55536
|
+
log$1.step(
|
|
55537
|
+
`${adderPrefix}Running external command ${pc.gray(`(${command} ${args.join(" ")})`)}`
|
|
55538
|
+
);
|
|
55545
55539
|
if (workspace.packageManager === "npm") args.unshift("--yes");
|
|
55546
55540
|
try {
|
|
55547
55541
|
await be(command, args, { nodeOptions: { cwd: workspace.cwd, stdio: script.stdio } });
|
|
@@ -55552,7 +55546,6 @@ async function runAdders({
|
|
|
55552
55546
|
);
|
|
55553
55547
|
}
|
|
55554
55548
|
}
|
|
55555
|
-
log$1.success(`Finished running ${config.id}`);
|
|
55556
55549
|
}
|
|
55557
55550
|
}
|
|
55558
55551
|
return Array.from(filesToFormat);
|