sv 0.5.2 → 0.5.4
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
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.4";
|
|
29
29
|
var type = "module";
|
|
30
30
|
var description = "A CLI for creating and updating SvelteKit projects";
|
|
31
31
|
var license = "MIT";
|
|
@@ -45201,56 +45201,59 @@ function __extends(d, b) {
|
|
|
45201
45201
|
}
|
|
45202
45202
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
45203
45203
|
}
|
|
45204
|
+
typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
45205
|
+
var e = new Error(message);
|
|
45206
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
45207
|
+
};
|
|
45208
|
+
var whitespace = /\s/;
|
|
45209
|
+
var number = /-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/;
|
|
45210
|
+
function spaces(n) {
|
|
45211
|
+
var result2 = "";
|
|
45212
|
+
while (n--)
|
|
45213
|
+
result2 += " ";
|
|
45214
|
+
return result2;
|
|
45215
|
+
}
|
|
45216
|
+
function rangeContains(range, index2) {
|
|
45217
|
+
return range.start <= index2 && index2 < range.end;
|
|
45218
|
+
}
|
|
45204
45219
|
function getLocator$2(source, options2) {
|
|
45205
45220
|
if (options2 === void 0) {
|
|
45206
45221
|
options2 = {};
|
|
45207
45222
|
}
|
|
45208
|
-
var
|
|
45209
|
-
var offsetColumn = options2.offsetColumn || 0;
|
|
45210
|
-
var originalLines = source.split("\n");
|
|
45223
|
+
var _a2 = options2.offsetLine, offsetLine = _a2 === void 0 ? 0 : _a2, _b = options2.offsetColumn, offsetColumn = _b === void 0 ? 0 : _b;
|
|
45211
45224
|
var start = 0;
|
|
45212
|
-
var
|
|
45225
|
+
var ranges = source.split("\n").map(function(line, i2) {
|
|
45213
45226
|
var end = start + line.length + 1;
|
|
45214
45227
|
var range = { start, end, line: i2 };
|
|
45215
45228
|
start = end;
|
|
45216
45229
|
return range;
|
|
45217
45230
|
});
|
|
45218
45231
|
var i = 0;
|
|
45219
|
-
function
|
|
45220
|
-
return range.start <= index2 && index2 < range.end;
|
|
45221
|
-
}
|
|
45222
|
-
function getLocation(range, index2) {
|
|
45223
|
-
return { line: offsetLine + range.line, column: offsetColumn + index2 - range.start, character: index2 };
|
|
45224
|
-
}
|
|
45225
|
-
function locate2(search, startIndex) {
|
|
45232
|
+
function locator(search, index2) {
|
|
45226
45233
|
if (typeof search === "string") {
|
|
45227
|
-
search = source.indexOf(search,
|
|
45234
|
+
search = source.indexOf(search, index2 !== null && index2 !== void 0 ? index2 : 0);
|
|
45228
45235
|
}
|
|
45229
|
-
|
|
45236
|
+
if (search === -1)
|
|
45237
|
+
return void 0;
|
|
45238
|
+
var range = ranges[i];
|
|
45230
45239
|
var d = search >= range.end ? 1 : -1;
|
|
45231
45240
|
while (range) {
|
|
45232
|
-
if (rangeContains(range, search))
|
|
45233
|
-
return
|
|
45241
|
+
if (rangeContains(range, search)) {
|
|
45242
|
+
return {
|
|
45243
|
+
line: offsetLine + range.line,
|
|
45244
|
+
column: offsetColumn + search - range.start,
|
|
45245
|
+
character: search
|
|
45246
|
+
};
|
|
45247
|
+
}
|
|
45234
45248
|
i += d;
|
|
45235
|
-
range =
|
|
45249
|
+
range = ranges[i];
|
|
45236
45250
|
}
|
|
45237
45251
|
}
|
|
45238
|
-
return
|
|
45252
|
+
return locator;
|
|
45239
45253
|
}
|
|
45240
45254
|
function locate(source, search, options2) {
|
|
45241
|
-
if (typeof options2 === "number") {
|
|
45242
|
-
throw new Error("locate takes a { startIndex, offsetLine, offsetColumn } object as the third argument");
|
|
45243
|
-
}
|
|
45244
45255
|
return getLocator$2(source, options2)(search, options2 && options2.startIndex);
|
|
45245
45256
|
}
|
|
45246
|
-
var whitespace = /\s/;
|
|
45247
|
-
var number = /-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/;
|
|
45248
|
-
function spaces(n) {
|
|
45249
|
-
var result2 = "";
|
|
45250
|
-
while (n--)
|
|
45251
|
-
result2 += " ";
|
|
45252
|
-
return result2;
|
|
45253
|
-
}
|
|
45254
45257
|
function parse(str, opts) {
|
|
45255
45258
|
var parser2 = new Parser3(str, opts);
|
|
45256
45259
|
return parser2.value;
|
|
@@ -45535,7 +45538,7 @@ function stringifyValue(value, indentation, indentString, newlines) {
|
|
|
45535
45538
|
return stringifyValue(element, indentation + indentString, indentString);
|
|
45536
45539
|
});
|
|
45537
45540
|
{
|
|
45538
|
-
return "[
|
|
45541
|
+
return "[".concat(indentation + indentString) + elements.join(",".concat(indentation + indentString)) + "".concat(indentation, "]");
|
|
45539
45542
|
}
|
|
45540
45543
|
} else if (type === "object") {
|
|
45541
45544
|
var keys = Object.keys(value);
|
|
@@ -46406,7 +46409,7 @@ function addGlobalAppInterface(ast, name) {
|
|
|
46406
46409
|
}
|
|
46407
46410
|
return interfaceNode;
|
|
46408
46411
|
}
|
|
46409
|
-
function addHooksHandle(ast, typescript, newHandleName, handleContent
|
|
46412
|
+
function addHooksHandle(ast, typescript, newHandleName, handleContent) {
|
|
46410
46413
|
if (typescript) {
|
|
46411
46414
|
addNamed(ast, "@sveltejs/kit", { Handle: "Handle" }, true);
|
|
46412
46415
|
}
|
|
@@ -46439,31 +46442,23 @@ function addHooksHandle(ast, typescript, newHandleName, handleContent, forceSepa
|
|
|
46439
46442
|
const newHandle = expressionFromString(handleContent);
|
|
46440
46443
|
if (hasNode(ast, newHandle)) return;
|
|
46441
46444
|
if (!originalHandleDecl || !exportDecl) {
|
|
46442
|
-
const newDecl2 = declaration(ast, "const",
|
|
46445
|
+
const newDecl2 = declaration(ast, "const", newHandleName, newHandle);
|
|
46443
46446
|
if (typescript) {
|
|
46444
46447
|
const declarator = newDecl2.declarations[0];
|
|
46445
46448
|
typeAnnotateDeclarator(declarator, "Handle");
|
|
46446
46449
|
}
|
|
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);
|
|
46450
|
+
ast.body.push(newDecl2);
|
|
46451
|
+
const handleDecl = declaration(
|
|
46452
|
+
ast,
|
|
46453
|
+
"const",
|
|
46454
|
+
handleName,
|
|
46455
|
+
expressionFromString(newHandleName)
|
|
46456
|
+
);
|
|
46457
|
+
if (typescript) {
|
|
46458
|
+
const declarator = handleDecl.declarations[0];
|
|
46459
|
+
typeAnnotateDeclarator(declarator, "Handle");
|
|
46466
46460
|
}
|
|
46461
|
+
namedExport(ast, handleName, handleDecl);
|
|
46467
46462
|
return;
|
|
46468
46463
|
}
|
|
46469
46464
|
const newDecl = declaration(ast, "const", newHandleName, newHandle);
|
|
@@ -50479,18 +50474,18 @@ ${sessionType}`);
|
|
|
50479
50474
|
const { ast, generateCode } = parseScript(content);
|
|
50480
50475
|
imports.addNamespace(ast, "$lib/server/auth.js", "auth");
|
|
50481
50476
|
imports.addNamed(ast, "$app/environment", { dev: "dev" });
|
|
50482
|
-
kit.addHooksHandle(ast, typescript, "
|
|
50477
|
+
kit.addHooksHandle(ast, typescript, "handleAuth", getAuthHandleContent());
|
|
50483
50478
|
return generateCode();
|
|
50484
50479
|
}
|
|
50485
50480
|
},
|
|
50486
50481
|
// DEMO
|
|
50487
50482
|
// login/register
|
|
50488
50483
|
{
|
|
50489
|
-
name: ({ kit: kit2, typescript }) => `${kit2.routesDirectory}/demo/login/+page.server.${typescript ? "ts" : "js"}`,
|
|
50484
|
+
name: ({ kit: kit2, typescript }) => `${kit2.routesDirectory}/demo/lucia/login/+page.server.${typescript ? "ts" : "js"}`,
|
|
50490
50485
|
condition: ({ options: options2 }) => options2.demo,
|
|
50491
50486
|
content({ content, typescript, kit: kit2 }) {
|
|
50492
50487
|
if (content) {
|
|
50493
|
-
const filePath = `${kit2.routesDirectory}/demo/login/+page.server.${typescript ? "ts" : "js"}`;
|
|
50488
|
+
const filePath = `${kit2.routesDirectory}/demo/lucia/login/+page.server.${typescript ? "ts" : "js"}`;
|
|
50494
50489
|
log.warn(`Existing ${picocolors.yellow(filePath)} file. Could not update.`);
|
|
50495
50490
|
return content;
|
|
50496
50491
|
}
|
|
@@ -50508,7 +50503,7 @@ ${sessionType}`);
|
|
|
50508
50503
|
`)}
|
|
50509
50504
|
export const load${ts(": PageServerLoad")} = async (event) => {
|
|
50510
50505
|
if (event.locals.user) {
|
|
50511
|
-
return redirect(302, '/demo');
|
|
50506
|
+
return redirect(302, '/demo/lucia');
|
|
50512
50507
|
}
|
|
50513
50508
|
return {};
|
|
50514
50509
|
};
|
|
@@ -50555,7 +50550,7 @@ ${sessionType}`);
|
|
|
50555
50550
|
secure: !dev
|
|
50556
50551
|
});
|
|
50557
50552
|
|
|
50558
|
-
return redirect(302, '/demo');
|
|
50553
|
+
return redirect(302, '/demo/lucia');
|
|
50559
50554
|
},
|
|
50560
50555
|
register: async (event) => {
|
|
50561
50556
|
const formData = await event.request.formData();
|
|
@@ -50592,7 +50587,7 @@ ${sessionType}`);
|
|
|
50592
50587
|
} catch (e) {
|
|
50593
50588
|
return fail(500, { message: 'An error has occurred' });
|
|
50594
50589
|
}
|
|
50595
|
-
return redirect(302, '/demo');
|
|
50590
|
+
return redirect(302, '/demo/lucia');
|
|
50596
50591
|
},
|
|
50597
50592
|
};
|
|
50598
50593
|
|
|
@@ -50622,26 +50617,27 @@ ${sessionType}`);
|
|
|
50622
50617
|
}
|
|
50623
50618
|
},
|
|
50624
50619
|
{
|
|
50625
|
-
name: ({ kit: kit2 }) => `${kit2.routesDirectory}/demo/login/+page.svelte`,
|
|
50620
|
+
name: ({ kit: kit2 }) => `${kit2.routesDirectory}/demo/lucia/login/+page.svelte`,
|
|
50626
50621
|
condition: ({ options: options2 }) => options2.demo,
|
|
50627
|
-
content({ content, typescript, kit: kit2 }) {
|
|
50622
|
+
content({ content, dependencyVersion, typescript, kit: kit2 }) {
|
|
50628
50623
|
if (content) {
|
|
50629
|
-
const filePath = `${kit2.routesDirectory}/demo/login/+page.svelte`;
|
|
50624
|
+
const filePath = `${kit2.routesDirectory}/demo/lucia/login/+page.svelte`;
|
|
50630
50625
|
log.warn(`Existing ${picocolors.yellow(filePath)} file. Could not update.`);
|
|
50631
50626
|
return content;
|
|
50632
50627
|
}
|
|
50633
|
-
const
|
|
50634
|
-
|
|
50635
|
-
`), ts(
|
|
50628
|
+
const svelte5 = !!dependencyVersion("svelte")?.startsWith("5");
|
|
50629
|
+
const [ts, s5] = utils.createPrinter(typescript, svelte5);
|
|
50630
|
+
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';
|
|
50631
|
+
`), s5(`let { form }${ts(": { form: ActionData }")} = $props();`, `export let form${ts(": ActionData")};`));
|
|
50636
50632
|
}
|
|
50637
50633
|
},
|
|
50638
50634
|
// logout
|
|
50639
50635
|
{
|
|
50640
|
-
name: ({ kit: kit2, typescript }) => `${kit2.routesDirectory}/demo/+page.server.${typescript ? "ts" : "js"}`,
|
|
50636
|
+
name: ({ kit: kit2, typescript }) => `${kit2.routesDirectory}/demo/lucia/+page.server.${typescript ? "ts" : "js"}`,
|
|
50641
50637
|
condition: ({ options: options2 }) => options2.demo,
|
|
50642
50638
|
content({ content, typescript, kit: kit2 }) {
|
|
50643
50639
|
if (content) {
|
|
50644
|
-
const filePath = `${kit2.routesDirectory}/demo/+page.server.${typescript ? "ts" : "js"}`;
|
|
50640
|
+
const filePath = `${kit2.routesDirectory}/demo/lucia/+page.server.${typescript ? "ts" : "js"}`;
|
|
50645
50641
|
log.warn(`Existing ${picocolors.yellow(filePath)} file. Could not update.`);
|
|
50646
50642
|
return content;
|
|
50647
50643
|
}
|
|
@@ -50653,7 +50649,7 @@ ${sessionType}`);
|
|
|
50653
50649
|
`)}
|
|
50654
50650
|
export const load${ts(": PageServerLoad")} = async (event) => {
|
|
50655
50651
|
if (!event.locals.user) {
|
|
50656
|
-
return redirect(302, '/demo/login');
|
|
50652
|
+
return redirect(302, '/demo/lucia/login');
|
|
50657
50653
|
}
|
|
50658
50654
|
return { user: event.locals.user };
|
|
50659
50655
|
};
|
|
@@ -50666,31 +50662,32 @@ ${sessionType}`);
|
|
|
50666
50662
|
await auth.invalidateSession(event.locals.session.id);
|
|
50667
50663
|
event.cookies.delete(auth.sessionCookieName, { path: '/' });
|
|
50668
50664
|
|
|
50669
|
-
return redirect(302, '/demo/login');
|
|
50665
|
+
return redirect(302, '/demo/lucia/login');
|
|
50670
50666
|
},
|
|
50671
50667
|
};
|
|
50672
50668
|
`;
|
|
50673
50669
|
}
|
|
50674
50670
|
},
|
|
50675
50671
|
{
|
|
50676
|
-
name: ({ kit: kit2 }) => `${kit2.routesDirectory}/demo/+page.svelte`,
|
|
50672
|
+
name: ({ kit: kit2 }) => `${kit2.routesDirectory}/demo/lucia/+page.svelte`,
|
|
50677
50673
|
condition: ({ options: options2 }) => options2.demo,
|
|
50678
|
-
content({ content, typescript, kit: kit2 }) {
|
|
50674
|
+
content({ content, dependencyVersion, typescript, kit: kit2 }) {
|
|
50679
50675
|
if (content) {
|
|
50680
|
-
const filePath = `${kit2.routesDirectory}/demo/+page.svelte`;
|
|
50676
|
+
const filePath = `${kit2.routesDirectory}/demo/lucia/+page.svelte`;
|
|
50681
50677
|
log.warn(`Existing ${picocolors.yellow(filePath)} file. Could not update.`);
|
|
50682
50678
|
return content;
|
|
50683
50679
|
}
|
|
50684
|
-
const
|
|
50685
|
-
|
|
50686
|
-
`), ts(
|
|
50680
|
+
const svelte5 = !!dependencyVersion("svelte")?.startsWith("5");
|
|
50681
|
+
const [ts, s5] = utils.createPrinter(typescript, svelte5);
|
|
50682
|
+
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';
|
|
50683
|
+
`), s5(`let { data }${ts(": { data: PageServerData }")} = $props();`, `export let data${ts(": PageServerData")};`));
|
|
50687
50684
|
}
|
|
50688
50685
|
}
|
|
50689
50686
|
],
|
|
50690
50687
|
nextSteps: ({ highlighter, options: options2 }) => {
|
|
50691
50688
|
const steps = [`Run ${highlighter.command("npm run db:push")} to update your database schema`];
|
|
50692
50689
|
if (options2.demo) {
|
|
50693
|
-
steps.push(`Visit ${highlighter.route("/demo")} route to view the demo`);
|
|
50690
|
+
steps.push(`Visit ${highlighter.route("/demo/lucia")} route to view the demo`);
|
|
50694
50691
|
}
|
|
50695
50692
|
return steps;
|
|
50696
50693
|
}
|
|
@@ -50841,15 +50838,14 @@ const DEFAULT_INLANG_PROJECT = {
|
|
|
50841
50838
|
};
|
|
50842
50839
|
const options$1 = defineAdderOptions({
|
|
50843
50840
|
availableLanguageTags: {
|
|
50844
|
-
question:
|
|
50841
|
+
question: `Which languages would you like to support? ${picocolors.gray("(e.g. en,de-ch)")}`,
|
|
50845
50842
|
type: "string",
|
|
50846
|
-
default: "",
|
|
50847
|
-
placeholder: "en,de-ch",
|
|
50843
|
+
default: "en",
|
|
50848
50844
|
validate(input) {
|
|
50849
50845
|
const { invalidLanguageTags, validLanguageTags } = parseLanguageTagInput(input);
|
|
50850
50846
|
if (invalidLanguageTags.length > 0) {
|
|
50851
50847
|
if (invalidLanguageTags.length === 1) {
|
|
50852
|
-
return `The input "${invalidLanguageTags[0]}" is not a valid
|
|
50848
|
+
return `The input "${invalidLanguageTags[0]}" is not a valid IETF BCP 47 language tag`;
|
|
50853
50849
|
} else {
|
|
50854
50850
|
const listFormat = new Intl.ListFormat("en", { style: "long", type: "conjunction" });
|
|
50855
50851
|
return `The inputs ${listFormat.format(invalidLanguageTags.map((x) => `"${x}"`))} are not valid BCP47 language tags`;
|
|
@@ -50862,7 +50858,7 @@ const options$1 = defineAdderOptions({
|
|
|
50862
50858
|
},
|
|
50863
50859
|
demo: {
|
|
50864
50860
|
type: "boolean",
|
|
50865
|
-
default:
|
|
50861
|
+
default: true,
|
|
50866
50862
|
question: "Do you want to include a demo?"
|
|
50867
50863
|
}
|
|
50868
50864
|
});
|
|
@@ -50901,9 +50897,7 @@ var paraglide = defineAdder({
|
|
|
50901
50897
|
content: ({ content }) => {
|
|
50902
50898
|
const { ast, generateCode } = parseScript(content);
|
|
50903
50899
|
const vitePluginName = "paraglide";
|
|
50904
|
-
imports.addNamed(ast, "@inlang/paraglide-sveltekit/vite", {
|
|
50905
|
-
paraglide: vitePluginName
|
|
50906
|
-
});
|
|
50900
|
+
imports.addNamed(ast, "@inlang/paraglide-sveltekit/vite", { paraglide: vitePluginName });
|
|
50907
50901
|
const { value: rootObject } = exports.defaultExport(
|
|
50908
50902
|
ast,
|
|
50909
50903
|
_function.call("defineConfig", [])
|
|
@@ -50962,7 +50956,7 @@ var paraglide = defineAdder({
|
|
|
50962
50956
|
i18n: "i18n"
|
|
50963
50957
|
});
|
|
50964
50958
|
const hookHandleContent = "i18n.handle()";
|
|
50965
|
-
kit.addHooksHandle(ast, typescript, "
|
|
50959
|
+
kit.addHooksHandle(ast, typescript, "handleParaglide", hookHandleContent);
|
|
50966
50960
|
return generateCode();
|
|
50967
50961
|
}
|
|
50968
50962
|
},
|
|
@@ -51016,10 +51010,10 @@ var paraglide = defineAdder({
|
|
|
51016
51010
|
},
|
|
51017
51011
|
{
|
|
51018
51012
|
// add usage example
|
|
51019
|
-
name: ({ kit: kit2 }) => `${kit2?.routesDirectory}/+page.svelte`,
|
|
51013
|
+
name: ({ kit: kit2 }) => `${kit2?.routesDirectory}/demo/paraglide/+page.svelte`,
|
|
51020
51014
|
condition: ({ options: options2 }) => options2.demo,
|
|
51021
51015
|
content({ content, options: options2, typescript }) {
|
|
51022
|
-
const { script, template, generateCode } = parseSvelte(content);
|
|
51016
|
+
const { script, template, generateCode } = parseSvelte(content, { typescript });
|
|
51023
51017
|
imports.addDefault(script.ast, "$lib/paraglide/messages.js", "* as m");
|
|
51024
51018
|
imports.addNamed(script.ast, "$app/navigation", { goto: "goto" });
|
|
51025
51019
|
imports.addNamed(script.ast, "$app/stores", { page: "page" });
|
|
@@ -51075,10 +51069,16 @@ ${links}
|
|
|
51075
51069
|
fs$3.writeFileSync(fullFilePath, JSON.stringify(jsonData, null, 2) + "\n");
|
|
51076
51070
|
}
|
|
51077
51071
|
},
|
|
51078
|
-
nextSteps: ({ highlighter }) =>
|
|
51079
|
-
|
|
51080
|
-
|
|
51081
|
-
|
|
51072
|
+
nextSteps: ({ highlighter }) => {
|
|
51073
|
+
const steps = [
|
|
51074
|
+
`Edit your messages in ${highlighter.path("messages/en.json")}`,
|
|
51075
|
+
"Consider installing the Sherlock IDE Extension"
|
|
51076
|
+
];
|
|
51077
|
+
if (options$1.demo) {
|
|
51078
|
+
steps.push(`Visit ${highlighter.route("/demo/paraglide")} route to view the demo`);
|
|
51079
|
+
}
|
|
51080
|
+
return steps;
|
|
51081
|
+
}
|
|
51082
51082
|
});
|
|
51083
51083
|
const isValidLanguageTag = (languageTag) => (
|
|
51084
51084
|
// Regex vendored in from https://github.com/opral/monorepo/blob/94c2298cc1da5378b908e4c160b0fa71a45caadb/inlang/source-code/versioned-interfaces/language-tag/src/interface.ts#L16
|
|
@@ -51367,11 +51367,43 @@ function addImports(ast, imports) {
|
|
|
51367
51367
|
return nodes;
|
|
51368
51368
|
}
|
|
51369
51369
|
|
|
51370
|
+
const plugins = [
|
|
51371
|
+
{
|
|
51372
|
+
id: "typography",
|
|
51373
|
+
package: "@tailwindcss/typography",
|
|
51374
|
+
version: "^0.5.15",
|
|
51375
|
+
identifier: "typography"
|
|
51376
|
+
},
|
|
51377
|
+
{
|
|
51378
|
+
id: "forms",
|
|
51379
|
+
package: "@tailwindcss/forms",
|
|
51380
|
+
version: "^0.5.9",
|
|
51381
|
+
identifier: "forms"
|
|
51382
|
+
},
|
|
51383
|
+
{
|
|
51384
|
+
id: "container-queries",
|
|
51385
|
+
package: "@tailwindcss/container-queries",
|
|
51386
|
+
version: "^0.1.1",
|
|
51387
|
+
identifier: "containerQueries"
|
|
51388
|
+
},
|
|
51389
|
+
{
|
|
51390
|
+
id: "aspect-ratio",
|
|
51391
|
+
package: "@tailwindcss/aspect-ratio",
|
|
51392
|
+
version: "^0.4.2",
|
|
51393
|
+
identifier: "aspectRatio"
|
|
51394
|
+
}
|
|
51395
|
+
];
|
|
51396
|
+
const pluginPackages = plugins.map((x) => ({
|
|
51397
|
+
name: x.package,
|
|
51398
|
+
version: x.version,
|
|
51399
|
+
dev: true,
|
|
51400
|
+
condition: ({ options: options2 }) => options2.plugins.includes(x.id)
|
|
51401
|
+
}));
|
|
51370
51402
|
const options = defineAdderOptions({
|
|
51371
51403
|
plugins: {
|
|
51372
51404
|
type: "multiselect",
|
|
51373
51405
|
question: "Which plugins would you like to add?",
|
|
51374
|
-
options:
|
|
51406
|
+
options: plugins.map((p) => ({ value: p.id, label: p.id, hint: p.package })),
|
|
51375
51407
|
default: []
|
|
51376
51408
|
}
|
|
51377
51409
|
});
|
|
@@ -51384,18 +51416,13 @@ var tailwindcss = defineAdder({
|
|
|
51384
51416
|
packages: [
|
|
51385
51417
|
{ name: "tailwindcss", version: "^3.4.9", dev: true },
|
|
51386
51418
|
{ name: "autoprefixer", version: "^10.4.20", dev: true },
|
|
51387
|
-
{
|
|
51388
|
-
name: "@tailwindcss/typography",
|
|
51389
|
-
version: "^0.5.14",
|
|
51390
|
-
dev: true,
|
|
51391
|
-
condition: ({ options: options2 }) => options2.plugins.includes("typography")
|
|
51392
|
-
},
|
|
51393
51419
|
{
|
|
51394
51420
|
name: "prettier-plugin-tailwindcss",
|
|
51395
51421
|
version: "^0.6.5",
|
|
51396
51422
|
dev: true,
|
|
51397
51423
|
condition: ({ dependencyVersion }) => Boolean(dependencyVersion("prettier"))
|
|
51398
|
-
}
|
|
51424
|
+
},
|
|
51425
|
+
...pluginPackages
|
|
51399
51426
|
],
|
|
51400
51427
|
files: [
|
|
51401
51428
|
{
|
|
@@ -51408,17 +51435,23 @@ var tailwindcss = defineAdder({
|
|
|
51408
51435
|
imports.addNamed(ast, "tailwindcss", { Config: "Config" }, true);
|
|
51409
51436
|
root = common.typeAnnotateExpression(rootExport, "Config");
|
|
51410
51437
|
}
|
|
51411
|
-
const { astNode: exportDeclaration } = exports.defaultExport(
|
|
51412
|
-
|
|
51438
|
+
const { astNode: exportDeclaration, value: node } = exports.defaultExport(
|
|
51439
|
+
ast,
|
|
51440
|
+
root ?? rootExport
|
|
51441
|
+
);
|
|
51442
|
+
const config = node.type === "TSAsExpression" ? node.expression : node;
|
|
51443
|
+
if (!typescript) {
|
|
51413
51444
|
common.addJsDocTypeComment(exportDeclaration, "import('tailwindcss').Config");
|
|
51414
|
-
|
|
51445
|
+
}
|
|
51446
|
+
const contentArray = object.property(config, "content", array.createEmpty());
|
|
51415
51447
|
array.push(contentArray, "./src/**/*.{html,js,svelte,ts}");
|
|
51416
|
-
const themeObject = object.property(
|
|
51448
|
+
const themeObject = object.property(config, "theme", object.createEmpty());
|
|
51417
51449
|
object.property(themeObject, "extend", object.createEmpty());
|
|
51418
|
-
const pluginsArray = object.property(
|
|
51419
|
-
|
|
51420
|
-
|
|
51421
|
-
|
|
51450
|
+
const pluginsArray = object.property(config, "plugins", array.createEmpty());
|
|
51451
|
+
for (const plugin of plugins) {
|
|
51452
|
+
if (!options2.plugins.includes(plugin.id)) continue;
|
|
51453
|
+
imports.addDefault(ast, plugin.package, plugin.identifier);
|
|
51454
|
+
array.push(pluginsArray, { type: "Identifier", name: plugin.identifier });
|
|
51422
51455
|
}
|
|
51423
51456
|
return generateCode();
|
|
51424
51457
|
}
|
|
@@ -51483,8 +51516,8 @@ var tailwindcss = defineAdder({
|
|
|
51483
51516
|
const { data, generateCode } = parseJson(content);
|
|
51484
51517
|
const PLUGIN_NAME = "prettier-plugin-tailwindcss";
|
|
51485
51518
|
data.plugins ?? (data.plugins = []);
|
|
51486
|
-
const
|
|
51487
|
-
if (!
|
|
51519
|
+
const plugins2 = data.plugins;
|
|
51520
|
+
if (!plugins2.includes(PLUGIN_NAME)) plugins2.push(PLUGIN_NAME);
|
|
51488
51521
|
return generateCode();
|
|
51489
51522
|
},
|
|
51490
51523
|
condition: ({ dependencyVersion }) => Boolean(dependencyVersion("prettier"))
|
|
@@ -51720,13 +51753,17 @@ function getGlobalPreconditions(cwd, projectType, adders) {
|
|
|
51720
51753
|
if (projectType === "svelte" && !supportedEnvironments.svelte) return true;
|
|
51721
51754
|
return false;
|
|
51722
51755
|
});
|
|
51723
|
-
if (addersForInvalidEnvironment.length
|
|
51756
|
+
if (addersForInvalidEnvironment.length === 0) {
|
|
51724
51757
|
return { success: true, message: void 0 };
|
|
51725
51758
|
}
|
|
51726
|
-
const messages = addersForInvalidEnvironment.map(
|
|
51727
|
-
(
|
|
51728
|
-
|
|
51729
|
-
|
|
51759
|
+
const messages = addersForInvalidEnvironment.map((a) => {
|
|
51760
|
+
if (projectType === "kit") {
|
|
51761
|
+
return `'${a.id}' does not support SvelteKit`;
|
|
51762
|
+
} else {
|
|
51763
|
+
return `'${a.id}' requires SvelteKit`;
|
|
51764
|
+
}
|
|
51765
|
+
});
|
|
51766
|
+
throw new Error(messages.join("\n"));
|
|
51730
51767
|
}
|
|
51731
51768
|
}
|
|
51732
51769
|
]
|
|
@@ -55187,7 +55224,7 @@ const addersOptions = getAdderOptionFlags();
|
|
|
55187
55224
|
const communityDetails = [];
|
|
55188
55225
|
const defaultPkgPath = up();
|
|
55189
55226
|
const defaultCwd = defaultPkgPath ? path$3.dirname(defaultPkgPath) : void 0;
|
|
55190
|
-
const add = new Command("add").description("applies specified
|
|
55227
|
+
const add = new Command("add").description("applies specified integrations into a project").argument("[integration...]", "integrations to install").option("-C, --cwd <path>", "path to working directory", defaultCwd).option("--no-install", "skips installing dependencies").option("--no-preconditions", "skips validating preconditions").configureHelp(helpConfig).action((adderArgs, opts) => {
|
|
55191
55228
|
if (opts.cwd === void 0) {
|
|
55192
55229
|
console.error(
|
|
55193
55230
|
"Invalid workspace: Please verify that you are inside of a Svelte project. You can also specify the working directory with `--cwd <path>`"
|
|
@@ -55388,7 +55425,7 @@ Available options: ${communityAdderIds.join(", ")}`
|
|
|
55388
55425
|
);
|
|
55389
55426
|
if (installed) continue;
|
|
55390
55427
|
const install = await confirm({
|
|
55391
|
-
message: `The ${pc.bold(pc.cyan(adder.id))}
|
|
55428
|
+
message: `The ${pc.bold(pc.cyan(adder.id))} integration requires ${pc.bold(pc.cyan(depId))} to also be setup. ${pc.green("Include it?")}`
|
|
55392
55429
|
});
|
|
55393
55430
|
if (install !== true) {
|
|
55394
55431
|
cancel("Operation cancelled.");
|
|
@@ -55538,10 +55575,13 @@ async function runAdders({
|
|
|
55538
55575
|
changedFiles.forEach((file) => filesToFormat.add(file));
|
|
55539
55576
|
await config.postInstall?.(workspace);
|
|
55540
55577
|
if (config.scripts && config.scripts.length > 0) {
|
|
55541
|
-
log$1.step(`Running external command ${pc.gray(`(${config.id})`)}`);
|
|
55542
55578
|
for (const script of config.scripts) {
|
|
55543
55579
|
if (script.condition?.(workspace) === false) continue;
|
|
55544
55580
|
const { command, args } = resolveCommand(workspace.packageManager, "execute", script.args);
|
|
55581
|
+
const adderPrefix = details.length > 1 ? `${config.id}: ` : "";
|
|
55582
|
+
log$1.step(
|
|
55583
|
+
`${adderPrefix}Running external command ${pc.gray(`(${command} ${args.join(" ")})`)}`
|
|
55584
|
+
);
|
|
55545
55585
|
if (workspace.packageManager === "npm") args.unshift("--yes");
|
|
55546
55586
|
try {
|
|
55547
55587
|
await be(command, args, { nodeOptions: { cwd: workspace.cwd, stdio: script.stdio } });
|
|
@@ -55552,7 +55592,6 @@ async function runAdders({
|
|
|
55552
55592
|
);
|
|
55553
55593
|
}
|
|
55554
55594
|
}
|
|
55555
|
-
log$1.success(`Finished running ${config.id}`);
|
|
55556
55595
|
}
|
|
55557
55596
|
}
|
|
55558
55597
|
return Array.from(filesToFormat);
|
|
@@ -55580,7 +55619,7 @@ function getAdderOptionFlags() {
|
|
|
55580
55619
|
const preset = defaults.join(", ") || "none";
|
|
55581
55620
|
const option = new Option(
|
|
55582
55621
|
`--${id} [options...]`,
|
|
55583
|
-
`${id}
|
|
55622
|
+
`${id} integration options ${pc.dim(`(preset: ${preset})`)}
|
|
55584
55623
|
${choices}`
|
|
55585
55624
|
).preset(preset).argParser((value, prev) => {
|
|
55586
55625
|
prev ?? (prev = []);
|
|
@@ -55641,11 +55680,11 @@ const templateOption = new Option("--template <type>", "template to scaffold").c
|
|
|
55641
55680
|
const ProjectPathSchema = string();
|
|
55642
55681
|
const OptionsSchema = strictObject({
|
|
55643
55682
|
checkTypes: optional(picklist(langs)),
|
|
55644
|
-
|
|
55683
|
+
integrations: boolean(),
|
|
55645
55684
|
install: boolean(),
|
|
55646
55685
|
template: optional(picklist(templateChoices))
|
|
55647
55686
|
});
|
|
55648
|
-
const create = new Command("create").description("scaffolds a new SvelteKit project").argument("[path]", "where the project will be created", process$1$1.cwd()).addOption(langOption).addOption(templateOption).option("--no-
|
|
55687
|
+
const create = new Command("create").description("scaffolds a new SvelteKit project").argument("[path]", "where the project will be created", process$1$1.cwd()).addOption(langOption).addOption(templateOption).option("--no-integrations", "skips interactive integration installer").option("--no-install", "skips installing dependencies").configureHelp(helpConfig).action((projectPath, opts) => {
|
|
55649
55688
|
const cwd = parse$8(ProjectPathSchema, projectPath);
|
|
55650
55689
|
const options = parse$8(OptionsSchema, opts);
|
|
55651
55690
|
runCommand(async () => {
|
|
@@ -55735,7 +55774,7 @@ async function createProject(cwd, options) {
|
|
|
55735
55774
|
types: language
|
|
55736
55775
|
});
|
|
55737
55776
|
initSpinner.stop("Project created");
|
|
55738
|
-
if (options.
|
|
55777
|
+
if (options.integrations) {
|
|
55739
55778
|
await runAddCommand(
|
|
55740
55779
|
{ cwd: projectPath, install: false, preconditions: true, community: [] },
|
|
55741
55780
|
[]
|