vela 0.18.0 → 0.19.0
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 +147 -93
- package/dist/bin.js.map +3 -3
- package/package.json +2 -2
- package/templates/minimal/package.template.json +3 -8
package/dist/bin.js
CHANGED
|
@@ -20,7 +20,7 @@ import dotenv2 from "dotenv";
|
|
|
20
20
|
// package.json
|
|
21
21
|
var package_default = {
|
|
22
22
|
name: "vela",
|
|
23
|
-
version: "0.
|
|
23
|
+
version: "0.19.0",
|
|
24
24
|
type: "module",
|
|
25
25
|
description: "A CLI for creating and updating SvelteKit projects",
|
|
26
26
|
license: "MIT",
|
|
@@ -57,7 +57,7 @@ var package_default = {
|
|
|
57
57
|
dependencies: {
|
|
58
58
|
"@clack/prompts": "^1.7.0",
|
|
59
59
|
"@faker-js/faker": "^10.6.0",
|
|
60
|
-
"@velastack/patterns": "^0.
|
|
60
|
+
"@velastack/patterns": "^0.8.0",
|
|
61
61
|
"@velastack/pocketbase-codegen": "^0.1.0",
|
|
62
62
|
"@velastack/schema": "^0.3.0",
|
|
63
63
|
"@velastack/schema-ui": "^0.3.1",
|
|
@@ -372,6 +372,19 @@ function raiseFloor(pkg, name, range) {
|
|
|
372
372
|
}
|
|
373
373
|
return changed;
|
|
374
374
|
}
|
|
375
|
+
function dropFormsnapOverride(pkg) {
|
|
376
|
+
const overrides = pkg.overrides;
|
|
377
|
+
const entry = overrides?.formsnap;
|
|
378
|
+
if (typeof entry !== "object" || entry === null || !("sveltekit-superforms" in entry)) {
|
|
379
|
+
return false;
|
|
380
|
+
}
|
|
381
|
+
const { "sveltekit-superforms": _, ...rest } = entry;
|
|
382
|
+
const { formsnap: __, ...others } = overrides;
|
|
383
|
+
const next = Object.keys(rest).length > 0 ? { ...others, formsnap: rest } : others;
|
|
384
|
+
if (Object.keys(next).length > 0) pkg.overrides = next;
|
|
385
|
+
else delete pkg.overrides;
|
|
386
|
+
return true;
|
|
387
|
+
}
|
|
375
388
|
var VERSION_PART = /^v?(\d+|[xX*])(?:\.(\d+|[xX*]))?(?:\.(\d+|[xX*]))?(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
376
389
|
function minVersion(range) {
|
|
377
390
|
const alternatives = range.split("||").map((alt) => alt.trim());
|
|
@@ -406,9 +419,9 @@ function minOfComparatorSet(set) {
|
|
|
406
419
|
if (upperOnly) return { major: 0, minor: 0, patch: 0, prerelease: [] };
|
|
407
420
|
return floor;
|
|
408
421
|
}
|
|
409
|
-
function parseVersionPart(
|
|
410
|
-
if (
|
|
411
|
-
const match =
|
|
422
|
+
function parseVersionPart(text19) {
|
|
423
|
+
if (text19 === "" || text19 === "*" || text19 === "x" || text19 === "X") return null;
|
|
424
|
+
const match = text19.match(VERSION_PART);
|
|
412
425
|
if (!match) return null;
|
|
413
426
|
const nums = [match[1], match[2], match[3]];
|
|
414
427
|
const firstWild = nums.findIndex((n) => n === void 0 || /^[xX*]$/.test(n));
|
|
@@ -901,10 +914,10 @@ function writeCachedIndex(cached2) {
|
|
|
901
914
|
fs6.mkdirSync(cacheRoot(), { recursive: true });
|
|
902
915
|
fs6.writeFileSync(indexCachePath(), JSON.stringify(cached2, null, 2));
|
|
903
916
|
}
|
|
904
|
-
function parseTemplateIndex(
|
|
917
|
+
function parseTemplateIndex(text19, url) {
|
|
905
918
|
let parsed;
|
|
906
919
|
try {
|
|
907
|
-
parsed = JSON.parse(
|
|
920
|
+
parsed = JSON.parse(text19);
|
|
908
921
|
} catch (e) {
|
|
909
922
|
throw new Error(`Template index at ${url} is not valid JSON: ${e.message}`);
|
|
910
923
|
}
|
|
@@ -1854,8 +1867,8 @@ async function readSite(root) {
|
|
|
1854
1867
|
if (!property || !Node6.isPropertyAssignment(property)) continue;
|
|
1855
1868
|
const value = property.getInitializer();
|
|
1856
1869
|
if (Node6.isStringLiteral(value) || Node6.isNoSubstitutionTemplateLiteral(value)) {
|
|
1857
|
-
const
|
|
1858
|
-
if (
|
|
1870
|
+
const text19 = value.getLiteralValue().trim();
|
|
1871
|
+
if (text19) info[key] = text19;
|
|
1859
1872
|
}
|
|
1860
1873
|
}
|
|
1861
1874
|
return info;
|
|
@@ -2194,11 +2207,11 @@ function mergeOriginConfig(root, options = {}) {
|
|
|
2194
2207
|
if (target) setOriginComment(target);
|
|
2195
2208
|
}
|
|
2196
2209
|
if (orphaned.length > 0) {
|
|
2197
|
-
let
|
|
2210
|
+
let text19 = vite.sourceFile.getFullText();
|
|
2198
2211
|
for (const comment of orphaned) {
|
|
2199
|
-
|
|
2212
|
+
text19 = text19.replace(new RegExp(String.raw`\n[\t ]*${escapeRegExp2(comment)}[\t ]*(?=\n)`), "");
|
|
2200
2213
|
}
|
|
2201
|
-
vite.sourceFile.replaceWithText(
|
|
2214
|
+
vite.sourceFile.replaceWithText(text19);
|
|
2202
2215
|
}
|
|
2203
2216
|
vite.sourceFile.saveSync();
|
|
2204
2217
|
const moved = hasPathsOrigin ? "removed prerender.origin, which SvelteKit 3 no longer accepts; kept the existing paths.origin" : "moved prerender.origin to paths.origin";
|
|
@@ -2230,8 +2243,8 @@ var ORIGIN_COMMENT = [
|
|
|
2230
2243
|
"baked in at build time. It is left unset for a deploy that serves more",
|
|
2231
2244
|
"than one host, where each request's own origin is used instead."
|
|
2232
2245
|
];
|
|
2233
|
-
function escapeRegExp2(
|
|
2234
|
-
return
|
|
2246
|
+
function escapeRegExp2(text19) {
|
|
2247
|
+
return text19.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2235
2248
|
}
|
|
2236
2249
|
function mentionsPrerender(node) {
|
|
2237
2250
|
return node.getLeadingCommentRanges().some((c) => /prerender/i.test(c.getText()));
|
|
@@ -2528,7 +2541,7 @@ function detectJsonIndent(source) {
|
|
|
2528
2541
|
var PRINT_WIDTH = 100;
|
|
2529
2542
|
function stringifyJson(value, indent, level = 0, prefix = 0) {
|
|
2530
2543
|
const pad2 = (n) => indent.repeat(n);
|
|
2531
|
-
const width = (
|
|
2544
|
+
const width = (text19) => text19.replaceAll(" ", " ").length;
|
|
2532
2545
|
if (Array.isArray(value)) {
|
|
2533
2546
|
if (value.length === 0) return "[]";
|
|
2534
2547
|
const scalars = value.every((v14) => v14 === null || typeof v14 !== "object");
|
|
@@ -2888,8 +2901,10 @@ function mergeDependencies(projectPath, templateDir) {
|
|
|
2888
2901
|
if (ensureLibImports(merged)) p6.log.info("package.json: added the #lib imports.");
|
|
2889
2902
|
writePackageJson(userPkgPath, merged);
|
|
2890
2903
|
if (pinned.length > 0) {
|
|
2891
|
-
p6.log.info(
|
|
2892
|
-
|
|
2904
|
+
p6.log.info(
|
|
2905
|
+
`Set what SvelteKit 3's form libraries need:
|
|
2906
|
+
${pinned.map((l) => ` ${l}`).join("\n")}`
|
|
2907
|
+
);
|
|
2893
2908
|
}
|
|
2894
2909
|
if (added.length > 0) {
|
|
2895
2910
|
p6.log.info(
|
|
@@ -2926,16 +2941,15 @@ function applyTemplatePins(merged, template, conflicts) {
|
|
|
2926
2941
|
const index = conflicts.findIndex((c) => c.name === name);
|
|
2927
2942
|
if (index !== -1) conflicts.splice(index, 1);
|
|
2928
2943
|
}
|
|
2929
|
-
const
|
|
2930
|
-
const
|
|
2931
|
-
if (
|
|
2932
|
-
|
|
2933
|
-
const
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
}
|
|
2944
|
+
const formsnapRange = template.devDependencies?.formsnap ?? template.dependencies?.formsnap;
|
|
2945
|
+
const formsnapBefore = merged.devDependencies?.formsnap ?? merged.dependencies?.formsnap;
|
|
2946
|
+
if (formsnapRange && raiseFloor(merged, "formsnap", formsnapRange)) {
|
|
2947
|
+
lines.push(`formsnap: ${formsnapBefore} \u2192 ${formsnapRange}`);
|
|
2948
|
+
const index = conflicts.findIndex((c) => c.name === "formsnap");
|
|
2949
|
+
if (index !== -1) conflicts.splice(index, 1);
|
|
2950
|
+
}
|
|
2951
|
+
if (dropFormsnapOverride(merged)) {
|
|
2952
|
+
lines.push("overrides.formsnap: dropped the sveltekit-superforms entry formsnap 2.0 needed");
|
|
2939
2953
|
}
|
|
2940
2954
|
const engines = template.engines;
|
|
2941
2955
|
const userEngines = merged.engines ?? {};
|
|
@@ -3931,6 +3945,7 @@ import {
|
|
|
3931
3945
|
ADAPTER_STATIC as ADAPTER_STATIC2,
|
|
3932
3946
|
ensurePackageOverrides,
|
|
3933
3947
|
FLASH,
|
|
3948
|
+
FORMSNAP,
|
|
3934
3949
|
SUPERFORMS_VERSION,
|
|
3935
3950
|
VELASTACK_CMS,
|
|
3936
3951
|
VELASTACK_KIT,
|
|
@@ -4382,10 +4397,10 @@ var npmViewLookup = (name, range, cwd) => new Promise((resolve2, reject) => {
|
|
|
4382
4397
|
(error, stdout, stderr) => {
|
|
4383
4398
|
if (error && /\bE404\b/.test(`${stderr}${error.message}`)) return resolve2(null);
|
|
4384
4399
|
if (error) return reject(error);
|
|
4385
|
-
const
|
|
4386
|
-
if (!
|
|
4400
|
+
const text19 = stdout.trim();
|
|
4401
|
+
if (!text19) return resolve2(null);
|
|
4387
4402
|
try {
|
|
4388
|
-
resolve2(newest(JSON.parse(
|
|
4403
|
+
resolve2(newest(JSON.parse(text19)));
|
|
4389
4404
|
} catch (e) {
|
|
4390
4405
|
reject(e);
|
|
4391
4406
|
}
|
|
@@ -4842,14 +4857,14 @@ function skipString(source, start) {
|
|
|
4842
4857
|
}
|
|
4843
4858
|
return -1;
|
|
4844
4859
|
}
|
|
4845
|
-
function splitTopLevel(
|
|
4860
|
+
function splitTopLevel(text19) {
|
|
4846
4861
|
const parts = [];
|
|
4847
4862
|
let depth = 0;
|
|
4848
4863
|
let partStart = 0;
|
|
4849
|
-
for (let i = 0; i <
|
|
4850
|
-
const c =
|
|
4864
|
+
for (let i = 0; i < text19.length; i++) {
|
|
4865
|
+
const c = text19[i];
|
|
4851
4866
|
if (c === '"' || c === "'" || c === "`") {
|
|
4852
|
-
const end = skipString(
|
|
4867
|
+
const end = skipString(text19, i);
|
|
4853
4868
|
if (end === -1) break;
|
|
4854
4869
|
i = end;
|
|
4855
4870
|
continue;
|
|
@@ -4857,12 +4872,12 @@ function splitTopLevel(text18) {
|
|
|
4857
4872
|
if (c === "(" || c === "{" || c === "[") depth++;
|
|
4858
4873
|
else if (c === ")" || c === "}" || c === "]") depth--;
|
|
4859
4874
|
else if (c === "," && depth === 0) {
|
|
4860
|
-
parts.push({ start: partStart, end: i, text:
|
|
4875
|
+
parts.push({ start: partStart, end: i, text: text19.slice(partStart, i) });
|
|
4861
4876
|
partStart = i + 1;
|
|
4862
4877
|
}
|
|
4863
4878
|
}
|
|
4864
|
-
if (
|
|
4865
|
-
parts.push({ start: partStart, end:
|
|
4879
|
+
if (text19.slice(partStart).trim()) {
|
|
4880
|
+
parts.push({ start: partStart, end: text19.length, text: text19.slice(partStart) });
|
|
4866
4881
|
}
|
|
4867
4882
|
return parts;
|
|
4868
4883
|
}
|
|
@@ -4979,8 +4994,8 @@ function rewriteGotoOptions(inner) {
|
|
|
4979
4994
|
if (!joined.startsWith(lead)) joined = lead + joined.trimStart();
|
|
4980
4995
|
return { inner: joined + tail, summary: summary.join("; ") };
|
|
4981
4996
|
}
|
|
4982
|
-
function escapeRegExp3(
|
|
4983
|
-
return
|
|
4997
|
+
function escapeRegExp3(text19) {
|
|
4998
|
+
return text19.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4984
4999
|
}
|
|
4985
5000
|
function rewriteInvalidateAll(source) {
|
|
4986
5001
|
const outcome = { edits: [], changes: [], tasks: [] };
|
|
@@ -5065,9 +5080,9 @@ function addTaskComments(source, file, tasks) {
|
|
|
5065
5080
|
const lineStart2 = code2.lastIndexOf("\n", index - 1) + 1;
|
|
5066
5081
|
const lineEnd = code2.indexOf("\n", index);
|
|
5067
5082
|
const excerpt = code2.slice(lineStart2, lineEnd === -1 ? void 0 : lineEnd).trim().replace(/--/g, "- -").slice(0, 80);
|
|
5068
|
-
const
|
|
5069
|
-
if (code2.includes(
|
|
5070
|
-
code2 = `<!-- ${
|
|
5083
|
+
const text19 = `${MIGRATION_TASK_MARKER} \`${excerpt}\`: ${message}`;
|
|
5084
|
+
if (code2.includes(text19)) continue;
|
|
5085
|
+
code2 = `<!-- ${text19} -->
|
|
5071
5086
|
${code2}`;
|
|
5072
5087
|
added.push(`line ${line}: ${message}`);
|
|
5073
5088
|
continue;
|
|
@@ -5461,8 +5476,8 @@ function svArgs(root, tasks, exclude) {
|
|
|
5461
5476
|
}
|
|
5462
5477
|
var ANSI = /\u001b\[[0-9;?]*[A-Za-z]/g;
|
|
5463
5478
|
function parseSvFailure(output) {
|
|
5464
|
-
const
|
|
5465
|
-
const match =
|
|
5479
|
+
const text19 = output.replace(ANSI, "");
|
|
5480
|
+
const match = text19.match(/Task '([^']+)' failed: ([^\n]*)/);
|
|
5466
5481
|
if (!match) return null;
|
|
5467
5482
|
const message = match[2].trim();
|
|
5468
5483
|
const file = message.match(/Unable to process '([^']+)'/)?.[1];
|
|
@@ -5552,9 +5567,9 @@ function originFixup(root, capture, sv) {
|
|
|
5552
5567
|
${outcome.snippet}`);
|
|
5553
5568
|
}
|
|
5554
5569
|
const lost = Boolean(carry && !outcome.applied && outcome.snippet);
|
|
5555
|
-
for (const
|
|
5556
|
-
if (carry && !lost && carry.text.endsWith(
|
|
5557
|
-
sv.dropped.push({ file: capture.file, text:
|
|
5570
|
+
for (const text19 of capture?.spreads ?? []) {
|
|
5571
|
+
if (carry && !lost && carry.text.endsWith(text19)) continue;
|
|
5572
|
+
sv.dropped.push({ file: capture.file, text: text19 });
|
|
5558
5573
|
}
|
|
5559
5574
|
return f;
|
|
5560
5575
|
}
|
|
@@ -5670,6 +5685,8 @@ var FLOORS = [
|
|
|
5670
5685
|
["svelte-check", "^4.7.6"],
|
|
5671
5686
|
["typescript", "^6.0.0"],
|
|
5672
5687
|
["shadcn-svelte", "^1.7.0"],
|
|
5688
|
+
// 2.1 is the first formsnap whose superforms peer admits 3.x.
|
|
5689
|
+
splitSpec(FORMSNAP),
|
|
5673
5690
|
splitSpec(VELASTACK_KIT),
|
|
5674
5691
|
splitSpec(VELASTACK_POCKETBASE),
|
|
5675
5692
|
splitSpec(VELASTACK_CMS),
|
|
@@ -5706,23 +5723,10 @@ function packageFixup(root, cliVersion) {
|
|
|
5706
5723
|
changed.push(`engines.node ${engines.node ?? "(unset)"} \u2192 ${ENGINES_FLOOR}`);
|
|
5707
5724
|
data.engines = { ...engines, node: ENGINES_FLOOR };
|
|
5708
5725
|
}
|
|
5709
|
-
if (
|
|
5710
|
-
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
f.warnings.push(
|
|
5714
|
-
`overrides.formsnap is not an object; set "formsnap": { "sveltekit-superforms": "${SUPERFORMS_VERSION}" } by hand`
|
|
5715
|
-
);
|
|
5716
|
-
} else {
|
|
5717
|
-
const formsnap = current ?? {};
|
|
5718
|
-
if (formsnap["sveltekit-superforms"] !== SUPERFORMS_VERSION) {
|
|
5719
|
-
data.overrides = {
|
|
5720
|
-
...overrides,
|
|
5721
|
-
formsnap: { ...formsnap, "sveltekit-superforms": SUPERFORMS_VERSION }
|
|
5722
|
-
};
|
|
5723
|
-
changed.push(`overrides formsnap \u2192 sveltekit-superforms ${SUPERFORMS_VERSION}`);
|
|
5724
|
-
}
|
|
5725
|
-
}
|
|
5726
|
+
if (dropFormsnapOverride(data)) {
|
|
5727
|
+
changed.push(
|
|
5728
|
+
"overrides formsnap \u2192 sveltekit-superforms dropped (formsnap 2.1 peers superforms 3)"
|
|
5729
|
+
);
|
|
5726
5730
|
}
|
|
5727
5731
|
if (changed.length > 0) {
|
|
5728
5732
|
writeJson(pkgPath, data, indent);
|
|
@@ -5865,10 +5869,10 @@ function belowFloor(project, key, entry) {
|
|
|
5865
5869
|
return Boolean(floor && locked && compareVersions(locked, floor) < 0);
|
|
5866
5870
|
}
|
|
5867
5871
|
function readJson(file) {
|
|
5868
|
-
const
|
|
5872
|
+
const text19 = fs29.readFileSync(file, "utf8");
|
|
5869
5873
|
return {
|
|
5870
|
-
data: JSON.parse(
|
|
5871
|
-
indent:
|
|
5874
|
+
data: JSON.parse(text19),
|
|
5875
|
+
indent: text19.match(/^[{[]\s*\n([\t ]+)/)?.[1] ?? " "
|
|
5872
5876
|
};
|
|
5873
5877
|
}
|
|
5874
5878
|
function writeJson(file, data, indent) {
|
|
@@ -5975,13 +5979,13 @@ function previousFollowUps(root, pattern) {
|
|
|
5975
5979
|
const end = content.indexOf("\n## ", start + FOLLOW_UPS_HEADING.length);
|
|
5976
5980
|
return content.slice(start, end === -1 ? void 0 : end).split("\n").filter((line) => line.startsWith("- [") && pattern.test(line)).map((line) => line.replace(/^- \[[ x]\] /, ""));
|
|
5977
5981
|
}
|
|
5978
|
-
function code(
|
|
5979
|
-
const fence =
|
|
5980
|
-
const pad2 =
|
|
5981
|
-
return `${fence}${pad2}${
|
|
5982
|
+
function code(text19) {
|
|
5983
|
+
const fence = text19.includes("`") ? "``" : "`";
|
|
5984
|
+
const pad2 = text19.startsWith("`") || text19.endsWith("`") ? " " : "";
|
|
5985
|
+
return `${fence}${pad2}${text19}${pad2}${fence}`;
|
|
5982
5986
|
}
|
|
5983
|
-
function escape(
|
|
5984
|
-
return
|
|
5987
|
+
function escape(text19) {
|
|
5988
|
+
return text19.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5985
5989
|
}
|
|
5986
5990
|
function writeFollowUps(root, items, generic) {
|
|
5987
5991
|
const file = path28.join(root, MIGRATION_TASKS_FILE);
|
|
@@ -6123,8 +6127,8 @@ function findRepeaterImport(dir) {
|
|
|
6123
6127
|
for (const entry of entries) {
|
|
6124
6128
|
if (!entry.isFile() || !SOURCE_FILE.test(entry.name)) continue;
|
|
6125
6129
|
const file = path29.join(entry.parentPath, entry.name);
|
|
6126
|
-
const
|
|
6127
|
-
if (
|
|
6130
|
+
const text19 = fs30.readFileSync(file, "utf8");
|
|
6131
|
+
if (text19.includes("CmsRepeater") && REPEATER_IMPORT.test(text19)) {
|
|
6128
6132
|
return path29.relative(dir, file);
|
|
6129
6133
|
}
|
|
6130
6134
|
}
|
|
@@ -7720,14 +7724,20 @@ async function ensureOrderForm(root, deps = { readApiKey, createForms: createPro
|
|
|
7720
7724
|
// src/commands/enable/payments.ts
|
|
7721
7725
|
var payments = new Command20("payments").description("enable payments (Stripe, Shopify or WhatsApp)").option("--provider <provider>", "payment provider: stripe, shopify or whatsapp").option(
|
|
7722
7726
|
"--currency <code>",
|
|
7723
|
-
"
|
|
7727
|
+
"the currency the business prices in, an ISO 4217 code such as MXN (kept in src/lib/site.ts; WhatsApp needs it)"
|
|
7728
|
+
).option(
|
|
7729
|
+
"--country <code>",
|
|
7730
|
+
"the country the business is in, ISO 3166-1 such as MX; prices format for it"
|
|
7731
|
+
).option(
|
|
7732
|
+
"--currencies <codes>",
|
|
7733
|
+
"other currencies to show prices in, as estimates, comma-separated (USD,EUR); blank for none"
|
|
7724
7734
|
).allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
7725
7735
|
(opts, cmd) => runCommand(async () => {
|
|
7726
7736
|
const provider = await resolveProvider("enable-payments", opts.provider);
|
|
7727
7737
|
await assertPatternRequires("enable-payments", provider.id);
|
|
7728
7738
|
if (provider.id === "stripe") assertBackendReady("vela enable payments");
|
|
7729
7739
|
if (provider.id === "stripe") noteWebhookSecret();
|
|
7730
|
-
const
|
|
7740
|
+
const business = await askBusiness(opts, provider.id === "whatsapp");
|
|
7731
7741
|
const orderForm = provider.id === "whatsapp" ? await prepareOrderForm() : [];
|
|
7732
7742
|
const providerEnv = await collectProviderEnv(provider);
|
|
7733
7743
|
const demoId = provider.id === "whatsapp" ? "" : await askDemoId(provider);
|
|
@@ -7737,12 +7747,15 @@ var payments = new Command20("payments").description("enable payments (Stripe, S
|
|
|
7737
7747
|
await runPattern(
|
|
7738
7748
|
"enable-payments",
|
|
7739
7749
|
cmd.args,
|
|
7740
|
-
{ provider: provider.id, providerEnv, demoId,
|
|
7750
|
+
{ provider: provider.id, providerEnv, demoId, ...business },
|
|
7741
7751
|
{
|
|
7742
7752
|
summary: `Enabled ${provider.label} payments.`,
|
|
7743
7753
|
nextSteps: [
|
|
7744
7754
|
...blank.map((key) => `Set ${key} in .env.`),
|
|
7745
7755
|
...orderForm,
|
|
7756
|
+
...business.currencies ? [
|
|
7757
|
+
"Visitors can pick a currency in the navbar; the others are estimates at the day's rate from velastack.dev. Edit `currencies` in src/lib/site.ts to change the list."
|
|
7758
|
+
] : [],
|
|
7746
7759
|
...NEXT_STEPS2[provider.id],
|
|
7747
7760
|
"Set the same variables on each deploy target with `vela env set`."
|
|
7748
7761
|
],
|
|
@@ -7774,24 +7787,65 @@ var NEXT_STEPS2 = {
|
|
|
7774
7787
|
function isCurrency(code2) {
|
|
7775
7788
|
return Intl.supportedValuesOf("currency").includes(code2.trim().toUpperCase());
|
|
7776
7789
|
}
|
|
7777
|
-
|
|
7778
|
-
|
|
7790
|
+
function isCountry(code2) {
|
|
7791
|
+
const upper = code2.trim().toUpperCase();
|
|
7792
|
+
return /^[A-Z]{2}$/.test(upper) && new Intl.DisplayNames(["en"], { type: "region" }).of(upper) !== upper;
|
|
7793
|
+
}
|
|
7794
|
+
function declaredBusiness() {
|
|
7779
7795
|
const root = findWorkspaceRoot();
|
|
7780
7796
|
const site = root ? path35.join(root, "src", "lib", "site.ts") : null;
|
|
7781
|
-
if (site
|
|
7782
|
-
|
|
7797
|
+
if (!site || !fs35.existsSync(site)) return {};
|
|
7798
|
+
const source = fs35.readFileSync(site, "utf8");
|
|
7799
|
+
return {
|
|
7800
|
+
currency: /^\s*currency\s*:\s*['"]([A-Za-z]{3})['"]/m.exec(source)?.[1],
|
|
7801
|
+
country: /^\s*country\s*:\s*['"]([A-Za-z]{2})['"]/m.exec(source)?.[1],
|
|
7802
|
+
currencies: /^\s*currencies\s*:\s*\[([^\]]*)\]/m.exec(source)?.[1]
|
|
7803
|
+
};
|
|
7804
|
+
}
|
|
7805
|
+
async function askBusiness(flags, currencyRequired) {
|
|
7806
|
+
const declared = declaredBusiness();
|
|
7807
|
+
const business = {
|
|
7808
|
+
currency: flags.currency?.trim().toUpperCase(),
|
|
7809
|
+
country: flags.country?.trim().toUpperCase(),
|
|
7810
|
+
currencies: flags.currencies
|
|
7811
|
+
};
|
|
7812
|
+
const ask = isInteractive();
|
|
7813
|
+
if (!business.currency && !declared.currency) {
|
|
7814
|
+
if (!ask) return business;
|
|
7815
|
+
business.currency = await text7({
|
|
7816
|
+
message: "The currency the business prices in (ISO 4217)",
|
|
7817
|
+
placeholder: "MXN, EUR, USD...",
|
|
7818
|
+
validate: (value) => value && isCurrency(value) ? void 0 : currencyRequired || value ? "An ISO 4217 code, such as MXN or EUR" : void 0
|
|
7819
|
+
});
|
|
7783
7820
|
}
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
|
|
7789
|
-
|
|
7821
|
+
const home = (business.currency ?? declared.currency ?? "").toUpperCase();
|
|
7822
|
+
if (!business.country && !declared.country && ask) {
|
|
7823
|
+
business.country = await text7({
|
|
7824
|
+
message: "The country the business is in (ISO 3166-1, two letters), so prices format for it",
|
|
7825
|
+
placeholder: "MX, ES, US...",
|
|
7826
|
+
validate: (value) => !value || isCountry(value) ? void 0 : "A two-letter country code, such as MX"
|
|
7827
|
+
});
|
|
7828
|
+
}
|
|
7829
|
+
if (business.currencies === void 0 && declared.currencies === void 0 && ask && home) {
|
|
7830
|
+
business.currencies = await text7({
|
|
7831
|
+
message: `Other currencies to show prices in, as estimates (comma-separated, blank for ${home} only)`,
|
|
7832
|
+
placeholder: "USD, EUR",
|
|
7833
|
+
validate: (value) => value && value.split(/[,\s]+/).some((code2) => code2 && !isCurrency(code2)) ? "ISO 4217 codes, comma-separated" : void 0
|
|
7834
|
+
});
|
|
7835
|
+
}
|
|
7836
|
+
return {
|
|
7837
|
+
currency: business.currency?.toUpperCase() || void 0,
|
|
7838
|
+
country: business.country?.toUpperCase() || void 0,
|
|
7839
|
+
currencies: business.currencies ?? void 0
|
|
7840
|
+
};
|
|
7841
|
+
}
|
|
7842
|
+
async function text7(options) {
|
|
7843
|
+
const value = await p21.text(options);
|
|
7790
7844
|
if (p21.isCancel(value)) {
|
|
7791
7845
|
p21.cancel("Operation cancelled.");
|
|
7792
7846
|
process19.exit(0);
|
|
7793
7847
|
}
|
|
7794
|
-
return value.trim()
|
|
7848
|
+
return (value ?? "").trim() || void 0;
|
|
7795
7849
|
}
|
|
7796
7850
|
async function prepareOrderForm() {
|
|
7797
7851
|
if (process19.env.PUBLIC_WHATSAPP_ORDER_FORM) return [];
|
|
@@ -9485,8 +9539,8 @@ function describeTarget(target) {
|
|
|
9485
9539
|
return target.name;
|
|
9486
9540
|
}
|
|
9487
9541
|
}
|
|
9488
|
-
function bold(
|
|
9489
|
-
return `\`${
|
|
9542
|
+
function bold(text19) {
|
|
9543
|
+
return `\`${text19}\``;
|
|
9490
9544
|
}
|
|
9491
9545
|
|
|
9492
9546
|
// src/lib/server-command.ts
|
|
@@ -14463,8 +14517,8 @@ function matrixCell(key, columns, index, states) {
|
|
|
14463
14517
|
return pc23.dim("\u2014");
|
|
14464
14518
|
}
|
|
14465
14519
|
var ANSI3 = /\u001b\[[0-9;]*m/g;
|
|
14466
|
-
function plain(
|
|
14467
|
-
return
|
|
14520
|
+
function plain(text19) {
|
|
14521
|
+
return text19.replace(ANSI3, "");
|
|
14468
14522
|
}
|
|
14469
14523
|
|
|
14470
14524
|
// src/commands/env/set.ts
|