@valbuild/init 0.63.1 → 0.63.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/main/dist/valbuild-init-main.cjs.dev.js +143 -113
- package/main/dist/valbuild-init-main.cjs.prod.js +143 -113
- package/main/dist/valbuild-init-main.esm.js +143 -113
- package/package.json +1 -1
- package/src/init.ts +18 -12
- package/src/templates.ts +39 -16
|
@@ -504,7 +504,7 @@ function transformNextAppRouterValProvider(fileInfo, api, options) {
|
|
|
504
504
|
|
|
505
505
|
var packageJson = {
|
|
506
506
|
name: "@valbuild/init",
|
|
507
|
-
version: "0.63.
|
|
507
|
+
version: "0.63.4",
|
|
508
508
|
description: "Initialize a new val.build project",
|
|
509
509
|
exports: {
|
|
510
510
|
"./main": {
|
|
@@ -579,7 +579,7 @@ var VAL_MODULES = function VAL_MODULES(configImportPath, exampleModuleImport) {
|
|
|
579
579
|
return "import { modules } from \"@valbuild/next\";\nimport { config } from \"./".concat(configImportPath, "\";\n\nexport default modules(config, [\n // Add your modules here").concat(exampleModuleImport ? "\n { def: () => import(\"./".concat(exampleModuleImport, "\") },") : "", "\n]);\n\n");
|
|
580
580
|
};
|
|
581
581
|
var BASIC_EXAMPLE = function BASIC_EXAMPLE(moduleFilePath, configImportPath, isJavaScript) {
|
|
582
|
-
return "".concat(isJavaScript ? "// @ts-check\n" : "", "/**\n * Val example file - generated by @valbuild/init\n **/\n\nimport {\n s /* s = schema */,\n c /* c = content */,").concat(isJavaScript ? "" : "\n type t /* t = type */,", "\n} from \"").concat(configImportPath, "\";\n\n/**\n * This is the schema for the content. It defines the structure of the content and the types of each field.\n *\n * @docs https://val.build/docs/api-reference\n */\nexport const testSchema = s.object({\n /**\n * Basic text field\n */\n text: s.string(),\n\n /**\n * Nullable are optional fields in the UI that can be null or not\n */\n optionals: s.string().nullable(),\n\n arrays: s.array(s.string()),\n /**\n * Records are objects where entries can be added. Useful for array-like structures where you would use a key to uniquely identify each entry.\n */\n records: s.record(s.string()),\n\n /**\n * Rich text can be used for multiline text, but also for more complex text editing capabilities like links, images, lists, etc.\n *\n * @docs https://val.build/docs/api-reference/schema-types/richtext\n *\n * @see ValRichText will render rich text\n */\n richText: s.richtext({\n //
|
|
582
|
+
return "".concat(isJavaScript ? "// @ts-check\n" : "", "/**\n * Val example file - generated by @valbuild/init\n **/\n\nimport {\n s /* s = schema */,\n c /* c = content */,").concat(isJavaScript ? "" : "\n type t /* t = type */,", "\n} from \"").concat(configImportPath, "\";\n\n/**\n * This is the schema for the content. It defines the structure of the content and the types of each field.\n *\n * @docs https://val.build/docs/api-reference\n */\nexport const testSchema = s.object({\n /**\n * Basic text field\n */\n text: s.string(),\n\n /**\n * Nullable are optional fields in the UI that can be null or not\n */\n optionals: s.string().nullable(),\n\n arrays: s.array(s.string()),\n /**\n * Records are objects where entries can be added. Useful for array-like structures where you would use a key to uniquely identify each entry.\n */\n records: s.record(s.string()),\n\n /**\n * Rich text can be used for multiline text, but also for more complex text editing capabilities like links, images, lists, etc.\n *\n * @docs https://val.build/docs/api-reference/schema-types/richtext\n *\n * @see ValRichText will render rich text\n */\n richText: s.richtext({\n // styling:\n style: {\n bold: true, // enables bold\n italic: true, // enables italic text\n lineThrough: true, // enables line/strike-through\n },\n // block-level elements:\n block: {\n // tags:\n h1: true, // enables h1\n h2: true,\n h3: true,\n h4: true,\n h5: true,\n h6: true,\n ul: true, // enables unordered lists\n ol: true, // enables ordered lists\n },\n // inline elements:\n inline: {\n a: true,\n img: true,\n },\n }),\n\n /**\n * Images in Val are stored as files in the public folder.\n *\n * @docs https://val.build/docs/api-reference/schema-types/image\n *\n * When defining content use the following syntax:\n * @example c.file('/public/myimage.png') // path to the image file, use the VS Code plugin or the `@valbuild/cli validate --fix` command to add metadata\n *\n * @see ValImage component to see how to render this in your app\n */\n image: s.image().nullable(),\n\n /**\n * String enums: presents as a dropdown in the UI\n */\n stringEnum: s.union(s.literal(\"lit-0\"), s.literal(\"lit-1\")),\n\n /**\n * Raw strings disables the stega (steganography) feature that automatically tags content when using the overlay.\n * It is useful for slugs and other data that might be processed in code (parsed or matching for equality...)\n */\n slug: s.string().raw(),\n\n /**\n * Object unions: presents as a dropdown in the UI and the different fields\n *\n * @docs https://val.build/docs/api-reference/schema-types/union\n */\n objectUnions: s.union(\n \"type\",\n s.object({\n type: s.literal(\"page-type-1\"),\n value: s.number(),\n }),\n s.object({\n type: s.literal(\"page-type-2\"),\n text: s.string(),\n })\n ),\n});\n").concat(isJavaScript ? "" : "\n/**\n * t.inferSchema returns the type of the content.\n * This pattern is useful to type props of components that use this content (partially or whole)\n */\nexport type TestContent = t.inferSchema<typeof testSchema>;\n", "\n\n/**\n * This is the content definition. Add your content below.\n *\n * NOTE: the first argument, module id, must match the path of the file.\n */\nexport default c.define(\"").concat(moduleFilePath, "\", testSchema, {\n text: \"Basic text content\",\n optionals: null,\n arrays: [\"A string\"],\n records: {\n \"unique-key-1\": \"A string\",\n },\n richText: [\n { tag: \"h1\", children: [\"Title 1\"] },\n {\n tag: \"p\",\n children: [\n { tag: \"a\", href: \"https://val.build/docs\", children: [\"Val docs\"] },\n ],\n },\n {\n tag: \"ul\",\n children: [\n { tag: \"li\", children: [{ tag: \"p\", children: [\"List item 1\"] }] },\n { tag: \"li\", children: [{ tag: \"p\", children: [\"List item 2\"] }] },\n ],\n },\n ],\n image: null,\n slug: \"test\",\n objectUnions: {\n type: \"page-type-2\",\n text: \"String value\",\n },\n stringEnum: \"lit-1\",\n});\n");
|
|
583
583
|
};
|
|
584
584
|
|
|
585
585
|
function error(message) {
|
|
@@ -1199,32 +1199,42 @@ function _plan() {
|
|
|
1199
1199
|
path: valConfigPath,
|
|
1200
1200
|
source: VAL_CONFIG(!!analysis.isTypeScript, {})
|
|
1201
1201
|
};
|
|
1202
|
-
|
|
1202
|
+
if (defaultAnswers) {
|
|
1203
|
+
_context3.next = 133;
|
|
1204
|
+
break;
|
|
1205
|
+
}
|
|
1206
|
+
_context3.next = 130;
|
|
1203
1207
|
return confirm({
|
|
1204
1208
|
message: "Include example Val files?",
|
|
1205
1209
|
"default": true
|
|
1206
1210
|
});
|
|
1207
|
-
case
|
|
1208
|
-
|
|
1211
|
+
case 130:
|
|
1212
|
+
_context3.t4 = _context3.sent;
|
|
1213
|
+
_context3.next = 134;
|
|
1214
|
+
break;
|
|
1215
|
+
case 133:
|
|
1216
|
+
_context3.t4 = true;
|
|
1217
|
+
case 134:
|
|
1218
|
+
_answer4 = _context3.t4;
|
|
1209
1219
|
if (!_answer4) {
|
|
1210
|
-
_context3.next =
|
|
1220
|
+
_context3.next = 143;
|
|
1211
1221
|
break;
|
|
1212
1222
|
}
|
|
1213
1223
|
exampleDir = path.join(analysis.srcDir, "examples", "val");
|
|
1214
1224
|
examplePath = path.join(exampleDir, "example.val." + (analysis.isJavaScript ? "js" : "ts"));
|
|
1215
1225
|
exampleImport = path.relative(exampleDir, valConfigPath).replace(".js", "").replace(".ts", "");
|
|
1216
1226
|
if (analysis.packageJsonDir) {
|
|
1217
|
-
_context3.next =
|
|
1227
|
+
_context3.next = 141;
|
|
1218
1228
|
break;
|
|
1219
1229
|
}
|
|
1220
1230
|
throw Error("Could not detect package.json directory! This is a Val bug.");
|
|
1221
|
-
case
|
|
1231
|
+
case 141:
|
|
1222
1232
|
_exampleModuleFilePath = "/".concat(path.relative(analysis.packageJsonDir, examplePath));
|
|
1223
1233
|
plan.includeExample = {
|
|
1224
1234
|
path: examplePath,
|
|
1225
1235
|
source: BASIC_EXAMPLE(_exampleModuleFilePath, exampleImport, !!analysis.isJavaScript)
|
|
1226
1236
|
};
|
|
1227
|
-
case
|
|
1237
|
+
case 143:
|
|
1228
1238
|
valModulesDir = analysis.root;
|
|
1229
1239
|
valModulesImport = path.relative(valModulesDir, valConfigPath).replace(".js", "").replace(".ts", "");
|
|
1230
1240
|
exampleModuleFilePath = plan.includeExample ? plan.includeExample.path : undefined;
|
|
@@ -1258,28 +1268,28 @@ function _plan() {
|
|
|
1258
1268
|
};
|
|
1259
1269
|
|
|
1260
1270
|
// Util files:
|
|
1261
|
-
case
|
|
1271
|
+
case 160:
|
|
1262
1272
|
if (!(plan.createValClient === undefined)) {
|
|
1263
|
-
_context3.next =
|
|
1273
|
+
_context3.next = 172;
|
|
1264
1274
|
break;
|
|
1265
1275
|
}
|
|
1266
1276
|
if (defaultAnswers) {
|
|
1267
|
-
_context3.next =
|
|
1277
|
+
_context3.next = 167;
|
|
1268
1278
|
break;
|
|
1269
1279
|
}
|
|
1270
|
-
_context3.next =
|
|
1280
|
+
_context3.next = 164;
|
|
1271
1281
|
return confirm({
|
|
1272
1282
|
message: "Setup useVal for Client Components",
|
|
1273
1283
|
"default": true
|
|
1274
1284
|
});
|
|
1275
|
-
case
|
|
1276
|
-
_context3.
|
|
1277
|
-
_context3.next =
|
|
1285
|
+
case 164:
|
|
1286
|
+
_context3.t5 = _context3.sent;
|
|
1287
|
+
_context3.next = 168;
|
|
1278
1288
|
break;
|
|
1279
|
-
case
|
|
1280
|
-
_context3.
|
|
1281
|
-
case
|
|
1282
|
-
_answer5 = _context3.
|
|
1289
|
+
case 167:
|
|
1290
|
+
_context3.t5 = true;
|
|
1291
|
+
case 168:
|
|
1292
|
+
_answer5 = _context3.t5;
|
|
1283
1293
|
if (_answer5) {
|
|
1284
1294
|
plan.createValClient = {
|
|
1285
1295
|
path: path.join(valUtilsDir, analysis.isTypeScript ? "val.client.ts" : "val.client.js"),
|
|
@@ -1288,30 +1298,30 @@ function _plan() {
|
|
|
1288
1298
|
} else {
|
|
1289
1299
|
plan.createValClient = false;
|
|
1290
1300
|
}
|
|
1291
|
-
_context3.next =
|
|
1301
|
+
_context3.next = 160;
|
|
1292
1302
|
break;
|
|
1293
|
-
case
|
|
1303
|
+
case 172:
|
|
1294
1304
|
if (!(plan.createValRsc === undefined)) {
|
|
1295
|
-
_context3.next =
|
|
1305
|
+
_context3.next = 184;
|
|
1296
1306
|
break;
|
|
1297
1307
|
}
|
|
1298
1308
|
if (defaultAnswers) {
|
|
1299
|
-
_context3.next =
|
|
1309
|
+
_context3.next = 179;
|
|
1300
1310
|
break;
|
|
1301
1311
|
}
|
|
1302
|
-
_context3.next =
|
|
1312
|
+
_context3.next = 176;
|
|
1303
1313
|
return confirm({
|
|
1304
1314
|
message: "Setup fetchVal for React Server Components",
|
|
1305
1315
|
"default": true
|
|
1306
1316
|
});
|
|
1307
|
-
case
|
|
1308
|
-
_context3.
|
|
1309
|
-
_context3.next =
|
|
1317
|
+
case 176:
|
|
1318
|
+
_context3.t6 = _context3.sent;
|
|
1319
|
+
_context3.next = 180;
|
|
1310
1320
|
break;
|
|
1311
|
-
case
|
|
1312
|
-
_context3.
|
|
1313
|
-
case
|
|
1314
|
-
_answer6 = _context3.
|
|
1321
|
+
case 179:
|
|
1322
|
+
_context3.t6 = true;
|
|
1323
|
+
case 180:
|
|
1324
|
+
_answer6 = _context3.t6;
|
|
1315
1325
|
if (_answer6) {
|
|
1316
1326
|
plan.createValRsc = {
|
|
1317
1327
|
path: path.join(valUtilsDir, analysis.isTypeScript ? "val.rsc.ts" : "val.rsc.js"),
|
|
@@ -1320,24 +1330,24 @@ function _plan() {
|
|
|
1320
1330
|
} else {
|
|
1321
1331
|
plan.createValRsc = false;
|
|
1322
1332
|
}
|
|
1323
|
-
_context3.next =
|
|
1333
|
+
_context3.next = 172;
|
|
1324
1334
|
break;
|
|
1325
|
-
case
|
|
1335
|
+
case 184:
|
|
1326
1336
|
// Patches:
|
|
1327
1337
|
NO_PATCH_WARNING = "Remember to add the ValProvider in your root app/layout.tsx or pages/_app.tsx file.\n";
|
|
1328
1338
|
if (!analysis.appRouterLayoutPath) {
|
|
1329
|
-
_context3.next =
|
|
1339
|
+
_context3.next = 214;
|
|
1330
1340
|
break;
|
|
1331
1341
|
}
|
|
1332
1342
|
if (analysis.appRouterLayoutFile) {
|
|
1333
|
-
_context3.next =
|
|
1343
|
+
_context3.next = 189;
|
|
1334
1344
|
break;
|
|
1335
1345
|
}
|
|
1336
1346
|
error("Failed to read app router layout file");
|
|
1337
1347
|
return _context3.abrupt("return", {
|
|
1338
1348
|
abort: true
|
|
1339
1349
|
});
|
|
1340
|
-
case
|
|
1350
|
+
case 189:
|
|
1341
1351
|
res = transformNextAppRouterValProvider({
|
|
1342
1352
|
path: analysis.appRouterLayoutPath,
|
|
1343
1353
|
source: analysis.appRouterLayoutFile
|
|
@@ -1361,43 +1371,43 @@ function _plan() {
|
|
|
1361
1371
|
}
|
|
1362
1372
|
});
|
|
1363
1373
|
if (defaultAnswers) {
|
|
1364
|
-
_context3.next =
|
|
1374
|
+
_context3.next = 199;
|
|
1365
1375
|
break;
|
|
1366
1376
|
}
|
|
1367
|
-
_context3.next =
|
|
1377
|
+
_context3.next = 196;
|
|
1368
1378
|
return confirm({
|
|
1369
1379
|
message: "Automatically patch ".concat(analysis.appRouterLayoutPath, " file?"),
|
|
1370
1380
|
"default": true
|
|
1371
1381
|
});
|
|
1372
|
-
case
|
|
1373
|
-
_context3.
|
|
1374
|
-
_context3.next =
|
|
1382
|
+
case 196:
|
|
1383
|
+
_context3.t7 = _context3.sent;
|
|
1384
|
+
_context3.next = 200;
|
|
1375
1385
|
break;
|
|
1376
|
-
case
|
|
1377
|
-
_context3.
|
|
1378
|
-
case
|
|
1379
|
-
_answer7 = _context3.
|
|
1386
|
+
case 199:
|
|
1387
|
+
_context3.t7 = true;
|
|
1388
|
+
case 200:
|
|
1389
|
+
_answer7 = _context3.t7;
|
|
1380
1390
|
if (!_answer7) {
|
|
1381
|
-
_context3.next =
|
|
1391
|
+
_context3.next = 213;
|
|
1382
1392
|
break;
|
|
1383
1393
|
}
|
|
1384
1394
|
if (defaultAnswers) {
|
|
1385
|
-
_context3.next =
|
|
1395
|
+
_context3.next = 208;
|
|
1386
1396
|
break;
|
|
1387
1397
|
}
|
|
1388
|
-
_context3.next =
|
|
1398
|
+
_context3.next = 205;
|
|
1389
1399
|
return confirm({
|
|
1390
1400
|
message: "Do you accept the following patch:\n".concat(s, "\n"),
|
|
1391
1401
|
"default": true
|
|
1392
1402
|
});
|
|
1393
|
-
case
|
|
1394
|
-
_context3.
|
|
1395
|
-
_context3.next =
|
|
1403
|
+
case 205:
|
|
1404
|
+
_context3.t8 = _context3.sent;
|
|
1405
|
+
_context3.next = 209;
|
|
1396
1406
|
break;
|
|
1397
|
-
case
|
|
1398
|
-
_context3.
|
|
1399
|
-
case
|
|
1400
|
-
_answer8 = _context3.
|
|
1407
|
+
case 208:
|
|
1408
|
+
_context3.t8 = true;
|
|
1409
|
+
case 209:
|
|
1410
|
+
_answer8 = _context3.t8;
|
|
1401
1411
|
if (!_answer8) {
|
|
1402
1412
|
warn(NO_PATCH_WARNING);
|
|
1403
1413
|
plan.updateAppLayout = false;
|
|
@@ -1407,70 +1417,70 @@ function _plan() {
|
|
|
1407
1417
|
source: res
|
|
1408
1418
|
};
|
|
1409
1419
|
}
|
|
1410
|
-
_context3.next =
|
|
1420
|
+
_context3.next = 214;
|
|
1411
1421
|
break;
|
|
1412
|
-
case
|
|
1422
|
+
case 213:
|
|
1413
1423
|
warn(NO_PATCH_WARNING);
|
|
1414
|
-
case
|
|
1424
|
+
case 214:
|
|
1415
1425
|
if (analysis.pagesRouter) {
|
|
1416
1426
|
warn(NO_PATCH_WARNING);
|
|
1417
1427
|
}
|
|
1418
1428
|
if (!analysis.valEslintVersion) {
|
|
1419
|
-
_context3.next =
|
|
1429
|
+
_context3.next = 246;
|
|
1420
1430
|
break;
|
|
1421
1431
|
}
|
|
1422
1432
|
if (!analysis.isValEslintRulesConfigured) {
|
|
1423
|
-
_context3.next =
|
|
1433
|
+
_context3.next = 220;
|
|
1424
1434
|
break;
|
|
1425
1435
|
}
|
|
1426
1436
|
warn(" @valbuild/eslint-plugin rules: already configured");
|
|
1427
|
-
_context3.next =
|
|
1437
|
+
_context3.next = 246;
|
|
1428
1438
|
break;
|
|
1429
|
-
case
|
|
1439
|
+
case 220:
|
|
1430
1440
|
if (!analysis.eslintRcJsPath) {
|
|
1431
|
-
_context3.next =
|
|
1441
|
+
_context3.next = 224;
|
|
1432
1442
|
break;
|
|
1433
1443
|
}
|
|
1434
1444
|
warn('Cannot patch eslint: found .eslintrc.js but can only patch JSON files (at the moment).\nAdd the following to your eslint config:\n\n "extends": ["plugin:@valbuild/recommended"]\n');
|
|
1435
|
-
_context3.next =
|
|
1445
|
+
_context3.next = 246;
|
|
1436
1446
|
break;
|
|
1437
|
-
case
|
|
1447
|
+
case 224:
|
|
1438
1448
|
if (!analysis.eslintRcJsonPath) {
|
|
1439
|
-
_context3.next =
|
|
1449
|
+
_context3.next = 245;
|
|
1440
1450
|
break;
|
|
1441
1451
|
}
|
|
1442
1452
|
if (defaultAnswers) {
|
|
1443
|
-
_context3.next =
|
|
1453
|
+
_context3.next = 231;
|
|
1444
1454
|
break;
|
|
1445
1455
|
}
|
|
1446
|
-
_context3.next =
|
|
1456
|
+
_context3.next = 228;
|
|
1447
1457
|
return confirm({
|
|
1448
1458
|
message: "Patch eslintrc.json to use the recommended Val eslint rules?",
|
|
1449
1459
|
"default": true
|
|
1450
1460
|
});
|
|
1451
|
-
case
|
|
1452
|
-
_context3.
|
|
1453
|
-
_context3.next =
|
|
1461
|
+
case 228:
|
|
1462
|
+
_context3.t9 = _context3.sent;
|
|
1463
|
+
_context3.next = 232;
|
|
1454
1464
|
break;
|
|
1455
|
-
case
|
|
1456
|
-
_context3.
|
|
1457
|
-
case
|
|
1458
|
-
_answer9 = _context3.
|
|
1465
|
+
case 231:
|
|
1466
|
+
_context3.t9 = true;
|
|
1467
|
+
case 232:
|
|
1468
|
+
_answer9 = _context3.t9;
|
|
1459
1469
|
if (!_answer9) {
|
|
1460
|
-
_context3.next =
|
|
1470
|
+
_context3.next = 243;
|
|
1461
1471
|
break;
|
|
1462
1472
|
}
|
|
1463
1473
|
currentEslintRc = fs.readFileSync(analysis.eslintRcJsonPath, "utf-8");
|
|
1464
1474
|
parsedEslint = JSON.parse(currentEslintRc);
|
|
1465
1475
|
if (!(_typeof(parsedEslint) !== "object")) {
|
|
1466
|
-
_context3.next =
|
|
1476
|
+
_context3.next = 239;
|
|
1467
1477
|
break;
|
|
1468
1478
|
}
|
|
1469
1479
|
error("Could not patch eslint: ".concat(analysis.eslintRcJsonPath, " was not an object"));
|
|
1470
1480
|
return _context3.abrupt("return", {
|
|
1471
1481
|
abort: true
|
|
1472
1482
|
});
|
|
1473
|
-
case
|
|
1483
|
+
case 239:
|
|
1474
1484
|
if (typeof parsedEslint["extends"] === "string") {
|
|
1475
1485
|
parsedEslint["extends"] = [parsedEslint["extends"]];
|
|
1476
1486
|
}
|
|
@@ -1480,23 +1490,33 @@ function _plan() {
|
|
|
1480
1490
|
path: analysis.eslintRcJsonPath,
|
|
1481
1491
|
source: JSON.stringify(parsedEslint, null, 2) + "\n"
|
|
1482
1492
|
};
|
|
1483
|
-
case
|
|
1484
|
-
_context3.next =
|
|
1493
|
+
case 243:
|
|
1494
|
+
_context3.next = 246;
|
|
1485
1495
|
break;
|
|
1486
|
-
case
|
|
1496
|
+
case 245:
|
|
1487
1497
|
warn("Cannot patch eslint: failed to find eslint config file");
|
|
1488
|
-
case
|
|
1498
|
+
case 246:
|
|
1489
1499
|
if (!analysis.gitIgnorePath) {
|
|
1490
|
-
_context3.next =
|
|
1500
|
+
_context3.next = 258;
|
|
1501
|
+
break;
|
|
1502
|
+
}
|
|
1503
|
+
if (defaultAnswers) {
|
|
1504
|
+
_context3.next = 253;
|
|
1491
1505
|
break;
|
|
1492
1506
|
}
|
|
1493
|
-
_context3.next =
|
|
1507
|
+
_context3.next = 250;
|
|
1494
1508
|
return confirm({
|
|
1495
1509
|
message: "Append .gitignore entry for Val cache? (recommended)",
|
|
1496
1510
|
"default": true
|
|
1497
1511
|
});
|
|
1498
|
-
case
|
|
1499
|
-
|
|
1512
|
+
case 250:
|
|
1513
|
+
_context3.t10 = _context3.sent;
|
|
1514
|
+
_context3.next = 254;
|
|
1515
|
+
break;
|
|
1516
|
+
case 253:
|
|
1517
|
+
_context3.t10 = true;
|
|
1518
|
+
case 254:
|
|
1519
|
+
_answer10 = _context3.t10;
|
|
1500
1520
|
if (_answer10) {
|
|
1501
1521
|
plan.updateGitIgnore = {
|
|
1502
1522
|
path: analysis.gitIgnorePath,
|
|
@@ -1505,49 +1525,59 @@ function _plan() {
|
|
|
1505
1525
|
} else {
|
|
1506
1526
|
plan.updateGitIgnore = false;
|
|
1507
1527
|
}
|
|
1508
|
-
_context3.next =
|
|
1528
|
+
_context3.next = 259;
|
|
1509
1529
|
break;
|
|
1510
|
-
case
|
|
1530
|
+
case 258:
|
|
1511
1531
|
plan.updateGitIgnore = false;
|
|
1512
|
-
case
|
|
1513
|
-
|
|
1532
|
+
case 259:
|
|
1533
|
+
if (defaultAnswers) {
|
|
1534
|
+
_context3.next = 265;
|
|
1535
|
+
break;
|
|
1536
|
+
}
|
|
1537
|
+
_context3.next = 262;
|
|
1514
1538
|
return confirm({
|
|
1515
1539
|
message: "Add the Val Build IntelliSense to .vscode/extensions.json?",
|
|
1516
1540
|
"default": true
|
|
1517
1541
|
});
|
|
1518
|
-
case
|
|
1519
|
-
|
|
1542
|
+
case 262:
|
|
1543
|
+
_context3.t11 = _context3.sent;
|
|
1544
|
+
_context3.next = 266;
|
|
1545
|
+
break;
|
|
1546
|
+
case 265:
|
|
1547
|
+
_context3.t11 = true;
|
|
1548
|
+
case 266:
|
|
1549
|
+
_answer11 = _context3.t11;
|
|
1520
1550
|
if (!_answer11) {
|
|
1521
|
-
_context3.next =
|
|
1551
|
+
_context3.next = 292;
|
|
1522
1552
|
break;
|
|
1523
1553
|
}
|
|
1524
1554
|
vscodeDir = path.join(analysis.root, ".vscode");
|
|
1525
1555
|
settingsPath = path.join(vscodeDir, "extensions.json");
|
|
1526
1556
|
currentSettings = {};
|
|
1527
|
-
_context3.prev =
|
|
1557
|
+
_context3.prev = 271;
|
|
1528
1558
|
currentSettingsFile = fs.readFileSync(settingsPath, "utf-8");
|
|
1529
1559
|
if (!currentSettingsFile) {
|
|
1530
|
-
_context3.next =
|
|
1560
|
+
_context3.next = 282;
|
|
1531
1561
|
break;
|
|
1532
1562
|
}
|
|
1533
|
-
_context3.prev =
|
|
1563
|
+
_context3.prev = 274;
|
|
1534
1564
|
currentSettings = JSON.parse(currentSettingsFile);
|
|
1535
|
-
_context3.next =
|
|
1565
|
+
_context3.next = 282;
|
|
1536
1566
|
break;
|
|
1537
|
-
case
|
|
1538
|
-
_context3.prev =
|
|
1539
|
-
_context3.
|
|
1540
|
-
warn("Failed to parse VS Code extensions.json found here: ".concat(settingsPath, ".").concat(_context3.
|
|
1567
|
+
case 278:
|
|
1568
|
+
_context3.prev = 278;
|
|
1569
|
+
_context3.t12 = _context3["catch"](274);
|
|
1570
|
+
warn("Failed to parse VS Code extensions.json found here: ".concat(settingsPath, ".").concat(_context3.t12 instanceof Error ? "Parse error: ".concat(_context3.t12.message) : ""));
|
|
1541
1571
|
return _context3.abrupt("return", {
|
|
1542
1572
|
abort: true
|
|
1543
1573
|
});
|
|
1544
|
-
case
|
|
1545
|
-
_context3.next =
|
|
1574
|
+
case 282:
|
|
1575
|
+
_context3.next = 286;
|
|
1546
1576
|
break;
|
|
1547
|
-
case
|
|
1548
|
-
_context3.prev =
|
|
1549
|
-
_context3.
|
|
1550
|
-
case
|
|
1577
|
+
case 284:
|
|
1578
|
+
_context3.prev = 284;
|
|
1579
|
+
_context3.t13 = _context3["catch"](271);
|
|
1580
|
+
case 286:
|
|
1551
1581
|
currentRecommendations =
|
|
1552
1582
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1553
1583
|
currentSettings.recommendations;
|
|
@@ -1561,17 +1591,17 @@ function _plan() {
|
|
|
1561
1591
|
path: settingsPath,
|
|
1562
1592
|
source: JSON.stringify(currentSettings, null, 2)
|
|
1563
1593
|
};
|
|
1564
|
-
_context3.next =
|
|
1594
|
+
_context3.next = 293;
|
|
1565
1595
|
break;
|
|
1566
|
-
case
|
|
1596
|
+
case 292:
|
|
1567
1597
|
plan.updateVSCodeSettings = false;
|
|
1568
|
-
case
|
|
1598
|
+
case 293:
|
|
1569
1599
|
return _context3.abrupt("return", plan);
|
|
1570
|
-
case
|
|
1600
|
+
case 294:
|
|
1571
1601
|
case "end":
|
|
1572
1602
|
return _context3.stop();
|
|
1573
1603
|
}
|
|
1574
|
-
}, _callee3, null, [[
|
|
1604
|
+
}, _callee3, null, [[271, 284], [274, 278]]);
|
|
1575
1605
|
}));
|
|
1576
1606
|
return _plan.apply(this, arguments);
|
|
1577
1607
|
}
|
package/package.json
CHANGED
package/src/init.ts
CHANGED
|
@@ -489,10 +489,12 @@ async function plan(
|
|
|
489
489
|
};
|
|
490
490
|
|
|
491
491
|
{
|
|
492
|
-
const answer =
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
492
|
+
const answer = !defaultAnswers
|
|
493
|
+
? await confirm({
|
|
494
|
+
message: "Include example Val files?",
|
|
495
|
+
default: true,
|
|
496
|
+
})
|
|
497
|
+
: true;
|
|
496
498
|
if (answer) {
|
|
497
499
|
const exampleDir = path.join(analysis.srcDir, "examples", "val");
|
|
498
500
|
const examplePath = path.join(
|
|
@@ -755,10 +757,12 @@ async function plan(
|
|
|
755
757
|
|
|
756
758
|
{
|
|
757
759
|
if (analysis.gitIgnorePath) {
|
|
758
|
-
const answer =
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
760
|
+
const answer = !defaultAnswers
|
|
761
|
+
? await confirm({
|
|
762
|
+
message: "Append .gitignore entry for Val cache? (recommended)",
|
|
763
|
+
default: true,
|
|
764
|
+
})
|
|
765
|
+
: true;
|
|
762
766
|
if (answer) {
|
|
763
767
|
plan.updateGitIgnore = {
|
|
764
768
|
path: analysis.gitIgnorePath,
|
|
@@ -774,10 +778,12 @@ async function plan(
|
|
|
774
778
|
}
|
|
775
779
|
}
|
|
776
780
|
{
|
|
777
|
-
const answer =
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
+
const answer = !defaultAnswers
|
|
782
|
+
? await confirm({
|
|
783
|
+
message: "Add the Val Build IntelliSense to .vscode/extensions.json?",
|
|
784
|
+
default: true,
|
|
785
|
+
})
|
|
786
|
+
: true;
|
|
781
787
|
if (answer) {
|
|
782
788
|
const vscodeDir = path.join(analysis.root, ".vscode");
|
|
783
789
|
const settingsPath = path.join(vscodeDir, "extensions.json");
|
package/src/templates.ts
CHANGED
|
@@ -141,15 +141,29 @@ export const testSchema = s.object({
|
|
|
141
141
|
* @see ValRichText will render rich text
|
|
142
142
|
*/
|
|
143
143
|
richText: s.richtext({
|
|
144
|
-
//
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
144
|
+
// styling:
|
|
145
|
+
style: {
|
|
146
|
+
bold: true, // enables bold
|
|
147
|
+
italic: true, // enables italic text
|
|
148
|
+
lineThrough: true, // enables line/strike-through
|
|
149
|
+
},
|
|
150
|
+
// block-level elements:
|
|
151
|
+
block: {
|
|
152
|
+
// tags:
|
|
153
|
+
h1: true, // enables h1
|
|
154
|
+
h2: true,
|
|
155
|
+
h3: true,
|
|
156
|
+
h4: true,
|
|
157
|
+
h5: true,
|
|
158
|
+
h6: true,
|
|
159
|
+
ul: true, // enables unordered lists
|
|
160
|
+
ol: true, // enables ordered lists
|
|
161
|
+
},
|
|
162
|
+
// inline elements:
|
|
163
|
+
inline: {
|
|
164
|
+
a: true,
|
|
165
|
+
img: true,
|
|
166
|
+
},
|
|
153
167
|
}),
|
|
154
168
|
|
|
155
169
|
/**
|
|
@@ -216,13 +230,22 @@ export default c.define("${moduleFilePath}", testSchema, {
|
|
|
216
230
|
records: {
|
|
217
231
|
"unique-key-1": "A string",
|
|
218
232
|
},
|
|
219
|
-
richText:
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
233
|
+
richText: [
|
|
234
|
+
{ tag: "h1", children: ["Title 1"] },
|
|
235
|
+
{
|
|
236
|
+
tag: "p",
|
|
237
|
+
children: [
|
|
238
|
+
{ tag: "a", href: "https://val.build/docs", children: ["Val docs"] },
|
|
239
|
+
],
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
tag: "ul",
|
|
243
|
+
children: [
|
|
244
|
+
{ tag: "li", children: [{ tag: "p", children: ["List item 1"] }] },
|
|
245
|
+
{ tag: "li", children: [{ tag: "p", children: ["List item 2"] }] },
|
|
246
|
+
],
|
|
247
|
+
},
|
|
248
|
+
],
|
|
226
249
|
image: null,
|
|
227
250
|
slug: "test",
|
|
228
251
|
objectUnions: {
|