@valbuild/init 0.62.3 → 0.62.5
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 +157 -140
- package/main/dist/valbuild-init-main.cjs.prod.js +157 -140
- package/main/dist/valbuild-init-main.esm.js +157 -140
- package/package.json +1 -1
- package/src/init.ts +61 -39
- package/src/templates.ts +25 -3
|
@@ -516,7 +516,7 @@ function transformNextAppRouterValProvider(fileInfo, api, options) {
|
|
|
516
516
|
|
|
517
517
|
var packageJson = {
|
|
518
518
|
name: "@valbuild/init",
|
|
519
|
-
version: "0.62.
|
|
519
|
+
version: "0.62.5",
|
|
520
520
|
description: "Initialize a new val.build project",
|
|
521
521
|
exports: {
|
|
522
522
|
"./main": {
|
|
@@ -572,8 +572,8 @@ var VAL_CLIENT = function VAL_CLIENT(configImportPath) {
|
|
|
572
572
|
var VAL_RSC = function VAL_RSC(configImportPath) {
|
|
573
573
|
return "import \"server-only\";\nimport { initValRsc } from \"@valbuild/next/rsc\";\nimport { config } from \"".concat(configImportPath, "\";\nimport { cookies, draftMode, headers } from \"next/headers\";\n\nconst { fetchValStega: fetchVal } = initValRsc(config, {\n draftMode,\n headers,\n cookies,\n});\n\nexport { fetchVal };\n");
|
|
574
574
|
};
|
|
575
|
-
var VAL_SERVER = function VAL_SERVER(configImportPath) {
|
|
576
|
-
return "import \"server-only\";\nimport { initValServer } from \"@valbuild/next/server\";\nimport { config } from \"".concat(configImportPath, "\";\nimport { draftMode } from \"next/headers\";\n\nconst { valNextAppRouter } = initValServer(\n { ...config },\n {\n draftMode,\n }\n);\n\nexport { valNextAppRouter };\n");
|
|
575
|
+
var VAL_SERVER = function VAL_SERVER(configImportPath, valModulesImportPath) {
|
|
576
|
+
return "import \"server-only\";\nimport { initValServer } from \"@valbuild/next/server\";\nimport { config } from \"".concat(configImportPath, "\";\nimport { draftMode } from \"next/headers\";\nimport valModules from \"").concat(valModulesImportPath, "\";\n\nconst { valNextAppRouter } = initValServer(\n valModules,\n { ...config },\n {\n draftMode,\n }\n);\n\nexport { valNextAppRouter };\n");
|
|
577
577
|
};
|
|
578
578
|
|
|
579
579
|
// TODO: use Val config
|
|
@@ -587,8 +587,11 @@ var VAL_API_ROUTER = function VAL_API_ROUTER(valServerPath) {
|
|
|
587
587
|
var VAL_APP_PAGE = function VAL_APP_PAGE(configImportPath) {
|
|
588
588
|
return "import { ValApp } from \"@valbuild/next\";\nimport { config } from \"".concat(configImportPath, "\";\n\nexport default function Val() {\n return <ValApp config={config} />;\n}\n");
|
|
589
589
|
};
|
|
590
|
-
var
|
|
591
|
-
return "
|
|
590
|
+
var VAL_MODULES = function VAL_MODULES(configImportPath, exampleModuleImport) {
|
|
591
|
+
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");
|
|
592
|
+
};
|
|
593
|
+
var BASIC_EXAMPLE = function BASIC_EXAMPLE(moduleFilePath, configImportPath, isJavaScript) {
|
|
594
|
+
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 // All features enabled:\n bold: true,\n italic: true,\n lineThrough: true,\n headings: [\"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\"],\n a: true,\n img: true,\n ul: true,\n ol: true,\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: c.richtext`# Title 1\n\n${c.rt.link(\"Val docs\", { href: \"https://val.build/docs\" })}\n\n- List item 1\n- List item 2\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");
|
|
592
595
|
};
|
|
593
596
|
|
|
594
597
|
function error(message) {
|
|
@@ -841,37 +844,42 @@ function _plan() {
|
|
|
841
844
|
_answer2,
|
|
842
845
|
_answer3,
|
|
843
846
|
valConfigPath,
|
|
847
|
+
_answer4,
|
|
848
|
+
exampleDir,
|
|
849
|
+
examplePath,
|
|
850
|
+
exampleImport,
|
|
851
|
+
_exampleModuleFilePath,
|
|
852
|
+
valModulesDir,
|
|
853
|
+
valModulesImport,
|
|
854
|
+
exampleModuleFilePath,
|
|
855
|
+
exampleModuleImport,
|
|
844
856
|
valUtilsDir,
|
|
857
|
+
valModulesServerImport,
|
|
845
858
|
valUtilsImportPath,
|
|
846
859
|
valServerPath,
|
|
847
860
|
valAppPagePath,
|
|
848
861
|
valPageImportPath,
|
|
849
862
|
valRouterPath,
|
|
850
863
|
valRouterImportPath,
|
|
851
|
-
_answer4,
|
|
852
864
|
_answer5,
|
|
865
|
+
_answer6,
|
|
853
866
|
NO_PATCH_WARNING,
|
|
854
867
|
res,
|
|
855
868
|
diff$1,
|
|
856
869
|
s,
|
|
857
|
-
_answer6,
|
|
858
870
|
_answer7,
|
|
859
871
|
_answer8,
|
|
872
|
+
_answer9,
|
|
860
873
|
currentEslintRc,
|
|
861
874
|
parsedEslint,
|
|
862
|
-
_answer9,
|
|
863
875
|
_answer10,
|
|
876
|
+
_answer11,
|
|
864
877
|
vscodeDir,
|
|
865
878
|
settingsPath,
|
|
866
879
|
currentSettings,
|
|
867
880
|
currentSettingsFile,
|
|
868
881
|
currentRecommendations,
|
|
869
882
|
valBuildIntelliSense,
|
|
870
|
-
_answer11,
|
|
871
|
-
exampleDir,
|
|
872
|
-
examplePath,
|
|
873
|
-
exampleImport,
|
|
874
|
-
exampleModuleId,
|
|
875
883
|
_args3 = arguments;
|
|
876
884
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
877
885
|
while (1) switch (_context3.prev = _context3.next) {
|
|
@@ -1203,12 +1211,47 @@ function _plan() {
|
|
|
1203
1211
|
path: valConfigPath,
|
|
1204
1212
|
source: VAL_CONFIG(!!analysis.isTypeScript, {})
|
|
1205
1213
|
};
|
|
1214
|
+
_context3.next = 129;
|
|
1215
|
+
return prompts.confirm({
|
|
1216
|
+
message: "Include example Val files?",
|
|
1217
|
+
"default": true
|
|
1218
|
+
});
|
|
1219
|
+
case 129:
|
|
1220
|
+
_answer4 = _context3.sent;
|
|
1221
|
+
if (!_answer4) {
|
|
1222
|
+
_context3.next = 138;
|
|
1223
|
+
break;
|
|
1224
|
+
}
|
|
1225
|
+
exampleDir = path__default["default"].join(analysis.srcDir, "examples", "val");
|
|
1226
|
+
examplePath = path__default["default"].join(exampleDir, "example.val." + (analysis.isJavaScript ? "js" : "ts"));
|
|
1227
|
+
exampleImport = path__default["default"].relative(exampleDir, valConfigPath).replace(".js", "").replace(".ts", "");
|
|
1228
|
+
if (analysis.packageJsonDir) {
|
|
1229
|
+
_context3.next = 136;
|
|
1230
|
+
break;
|
|
1231
|
+
}
|
|
1232
|
+
throw Error("Could not detect package.json directory! This is a Val bug.");
|
|
1233
|
+
case 136:
|
|
1234
|
+
_exampleModuleFilePath = "/".concat(path__default["default"].relative(analysis.packageJsonDir, examplePath));
|
|
1235
|
+
plan.includeExample = {
|
|
1236
|
+
path: examplePath,
|
|
1237
|
+
source: BASIC_EXAMPLE(_exampleModuleFilePath, exampleImport, !!analysis.isJavaScript)
|
|
1238
|
+
};
|
|
1239
|
+
case 138:
|
|
1240
|
+
valModulesDir = analysis.root;
|
|
1241
|
+
valModulesImport = path__default["default"].relative(valModulesDir, valConfigPath).replace(".js", "").replace(".ts", "");
|
|
1242
|
+
exampleModuleFilePath = plan.includeExample ? plan.includeExample.path : undefined;
|
|
1243
|
+
exampleModuleImport = exampleModuleFilePath && path__default["default"].relative(valModulesDir, exampleModuleFilePath).replace(".js", "").replace(".ts", "");
|
|
1244
|
+
plan.includeModules = {
|
|
1245
|
+
path: path__default["default"].join(valModulesDir, "val.modules.ts"),
|
|
1246
|
+
source: VAL_MODULES(valModulesImport, exampleModuleImport)
|
|
1247
|
+
};
|
|
1206
1248
|
valUtilsDir = path__default["default"].join(analysis.srcDir, "val");
|
|
1249
|
+
valModulesServerImport = path__default["default"].relative(valUtilsDir, plan.includeModules.path).replace(".js", "").replace(".ts", "");
|
|
1207
1250
|
valUtilsImportPath = path__default["default"].relative(valUtilsDir, valConfigPath).replace(".js", "").replace(".ts", "");
|
|
1208
1251
|
valServerPath = path__default["default"].join(valUtilsDir, analysis.isTypeScript ? "val.server.ts" : "val.server.js");
|
|
1209
1252
|
plan.createValServer = {
|
|
1210
1253
|
path: valServerPath,
|
|
1211
|
-
source: VAL_SERVER(valUtilsImportPath)
|
|
1254
|
+
source: VAL_SERVER(valUtilsImportPath, valModulesServerImport)
|
|
1212
1255
|
};
|
|
1213
1256
|
if (!analysis.appRouterPath) {
|
|
1214
1257
|
warn('Creating a new "app" router');
|
|
@@ -1227,29 +1270,29 @@ function _plan() {
|
|
|
1227
1270
|
};
|
|
1228
1271
|
|
|
1229
1272
|
// Util files:
|
|
1230
|
-
case
|
|
1273
|
+
case 155:
|
|
1231
1274
|
if (!(plan.createValClient === undefined)) {
|
|
1232
|
-
_context3.next =
|
|
1275
|
+
_context3.next = 167;
|
|
1233
1276
|
break;
|
|
1234
1277
|
}
|
|
1235
1278
|
if (defaultAnswers) {
|
|
1236
|
-
_context3.next =
|
|
1279
|
+
_context3.next = 162;
|
|
1237
1280
|
break;
|
|
1238
1281
|
}
|
|
1239
|
-
_context3.next =
|
|
1282
|
+
_context3.next = 159;
|
|
1240
1283
|
return prompts.confirm({
|
|
1241
1284
|
message: "Setup useVal for Client Components",
|
|
1242
1285
|
"default": true
|
|
1243
1286
|
});
|
|
1244
|
-
case
|
|
1287
|
+
case 159:
|
|
1245
1288
|
_context3.t4 = _context3.sent;
|
|
1246
|
-
_context3.next =
|
|
1289
|
+
_context3.next = 163;
|
|
1247
1290
|
break;
|
|
1248
|
-
case
|
|
1291
|
+
case 162:
|
|
1249
1292
|
_context3.t4 = true;
|
|
1250
|
-
case
|
|
1251
|
-
|
|
1252
|
-
if (
|
|
1293
|
+
case 163:
|
|
1294
|
+
_answer5 = _context3.t4;
|
|
1295
|
+
if (_answer5) {
|
|
1253
1296
|
plan.createValClient = {
|
|
1254
1297
|
path: path__default["default"].join(valUtilsDir, analysis.isTypeScript ? "val.client.ts" : "val.client.js"),
|
|
1255
1298
|
source: VAL_CLIENT(valUtilsImportPath)
|
|
@@ -1257,31 +1300,31 @@ function _plan() {
|
|
|
1257
1300
|
} else {
|
|
1258
1301
|
plan.createValClient = false;
|
|
1259
1302
|
}
|
|
1260
|
-
_context3.next =
|
|
1303
|
+
_context3.next = 155;
|
|
1261
1304
|
break;
|
|
1262
|
-
case
|
|
1305
|
+
case 167:
|
|
1263
1306
|
if (!(plan.createValRsc === undefined)) {
|
|
1264
|
-
_context3.next =
|
|
1307
|
+
_context3.next = 179;
|
|
1265
1308
|
break;
|
|
1266
1309
|
}
|
|
1267
1310
|
if (defaultAnswers) {
|
|
1268
|
-
_context3.next =
|
|
1311
|
+
_context3.next = 174;
|
|
1269
1312
|
break;
|
|
1270
1313
|
}
|
|
1271
|
-
_context3.next =
|
|
1314
|
+
_context3.next = 171;
|
|
1272
1315
|
return prompts.confirm({
|
|
1273
1316
|
message: "Setup fetchVal for React Server Components",
|
|
1274
1317
|
"default": true
|
|
1275
1318
|
});
|
|
1276
|
-
case
|
|
1319
|
+
case 171:
|
|
1277
1320
|
_context3.t5 = _context3.sent;
|
|
1278
|
-
_context3.next =
|
|
1321
|
+
_context3.next = 175;
|
|
1279
1322
|
break;
|
|
1280
|
-
case
|
|
1323
|
+
case 174:
|
|
1281
1324
|
_context3.t5 = true;
|
|
1282
|
-
case
|
|
1283
|
-
|
|
1284
|
-
if (
|
|
1325
|
+
case 175:
|
|
1326
|
+
_answer6 = _context3.t5;
|
|
1327
|
+
if (_answer6) {
|
|
1285
1328
|
plan.createValRsc = {
|
|
1286
1329
|
path: path__default["default"].join(valUtilsDir, analysis.isTypeScript ? "val.rsc.ts" : "val.rsc.js"),
|
|
1287
1330
|
source: VAL_RSC(valUtilsImportPath)
|
|
@@ -1289,24 +1332,24 @@ function _plan() {
|
|
|
1289
1332
|
} else {
|
|
1290
1333
|
plan.createValRsc = false;
|
|
1291
1334
|
}
|
|
1292
|
-
_context3.next =
|
|
1335
|
+
_context3.next = 167;
|
|
1293
1336
|
break;
|
|
1294
|
-
case
|
|
1337
|
+
case 179:
|
|
1295
1338
|
// Patches:
|
|
1296
1339
|
NO_PATCH_WARNING = "Remember to add the ValProvider in your root app/layout.tsx or pages/_app.tsx file.\n";
|
|
1297
1340
|
if (!analysis.appRouterLayoutPath) {
|
|
1298
|
-
_context3.next =
|
|
1341
|
+
_context3.next = 209;
|
|
1299
1342
|
break;
|
|
1300
1343
|
}
|
|
1301
1344
|
if (analysis.appRouterLayoutFile) {
|
|
1302
|
-
_context3.next =
|
|
1345
|
+
_context3.next = 184;
|
|
1303
1346
|
break;
|
|
1304
1347
|
}
|
|
1305
1348
|
error("Failed to read app router layout file");
|
|
1306
1349
|
return _context3.abrupt("return", {
|
|
1307
1350
|
abort: true
|
|
1308
1351
|
});
|
|
1309
|
-
case
|
|
1352
|
+
case 184:
|
|
1310
1353
|
res = transformNextAppRouterValProvider({
|
|
1311
1354
|
path: analysis.appRouterLayoutPath,
|
|
1312
1355
|
source: analysis.appRouterLayoutFile
|
|
@@ -1330,44 +1373,44 @@ function _plan() {
|
|
|
1330
1373
|
}
|
|
1331
1374
|
});
|
|
1332
1375
|
if (defaultAnswers) {
|
|
1333
|
-
_context3.next =
|
|
1376
|
+
_context3.next = 194;
|
|
1334
1377
|
break;
|
|
1335
1378
|
}
|
|
1336
|
-
_context3.next =
|
|
1379
|
+
_context3.next = 191;
|
|
1337
1380
|
return prompts.confirm({
|
|
1338
1381
|
message: "Automatically patch ".concat(analysis.appRouterLayoutPath, " file?"),
|
|
1339
1382
|
"default": true
|
|
1340
1383
|
});
|
|
1341
|
-
case
|
|
1384
|
+
case 191:
|
|
1342
1385
|
_context3.t6 = _context3.sent;
|
|
1343
|
-
_context3.next =
|
|
1386
|
+
_context3.next = 195;
|
|
1344
1387
|
break;
|
|
1345
|
-
case
|
|
1388
|
+
case 194:
|
|
1346
1389
|
_context3.t6 = true;
|
|
1347
|
-
case
|
|
1348
|
-
|
|
1349
|
-
if (!
|
|
1350
|
-
_context3.next =
|
|
1390
|
+
case 195:
|
|
1391
|
+
_answer7 = _context3.t6;
|
|
1392
|
+
if (!_answer7) {
|
|
1393
|
+
_context3.next = 208;
|
|
1351
1394
|
break;
|
|
1352
1395
|
}
|
|
1353
1396
|
if (defaultAnswers) {
|
|
1354
|
-
_context3.next =
|
|
1397
|
+
_context3.next = 203;
|
|
1355
1398
|
break;
|
|
1356
1399
|
}
|
|
1357
|
-
_context3.next =
|
|
1400
|
+
_context3.next = 200;
|
|
1358
1401
|
return prompts.confirm({
|
|
1359
1402
|
message: "Do you accept the following patch:\n".concat(s, "\n"),
|
|
1360
1403
|
"default": true
|
|
1361
1404
|
});
|
|
1362
|
-
case
|
|
1405
|
+
case 200:
|
|
1363
1406
|
_context3.t7 = _context3.sent;
|
|
1364
|
-
_context3.next =
|
|
1407
|
+
_context3.next = 204;
|
|
1365
1408
|
break;
|
|
1366
|
-
case
|
|
1409
|
+
case 203:
|
|
1367
1410
|
_context3.t7 = true;
|
|
1368
|
-
case
|
|
1369
|
-
|
|
1370
|
-
if (!
|
|
1411
|
+
case 204:
|
|
1412
|
+
_answer8 = _context3.t7;
|
|
1413
|
+
if (!_answer8) {
|
|
1371
1414
|
warn(NO_PATCH_WARNING);
|
|
1372
1415
|
plan.updateAppLayout = false;
|
|
1373
1416
|
} else {
|
|
@@ -1376,70 +1419,70 @@ function _plan() {
|
|
|
1376
1419
|
source: res
|
|
1377
1420
|
};
|
|
1378
1421
|
}
|
|
1379
|
-
_context3.next =
|
|
1422
|
+
_context3.next = 209;
|
|
1380
1423
|
break;
|
|
1381
|
-
case
|
|
1424
|
+
case 208:
|
|
1382
1425
|
warn(NO_PATCH_WARNING);
|
|
1383
|
-
case
|
|
1426
|
+
case 209:
|
|
1384
1427
|
if (analysis.pagesRouter) {
|
|
1385
1428
|
warn(NO_PATCH_WARNING);
|
|
1386
1429
|
}
|
|
1387
1430
|
if (!analysis.valEslintVersion) {
|
|
1388
|
-
_context3.next =
|
|
1431
|
+
_context3.next = 241;
|
|
1389
1432
|
break;
|
|
1390
1433
|
}
|
|
1391
1434
|
if (!analysis.isValEslintRulesConfigured) {
|
|
1392
|
-
_context3.next =
|
|
1435
|
+
_context3.next = 215;
|
|
1393
1436
|
break;
|
|
1394
1437
|
}
|
|
1395
1438
|
warn(" @valbuild/eslint-plugin rules: already configured");
|
|
1396
|
-
_context3.next =
|
|
1439
|
+
_context3.next = 241;
|
|
1397
1440
|
break;
|
|
1398
|
-
case
|
|
1441
|
+
case 215:
|
|
1399
1442
|
if (!analysis.eslintRcJsPath) {
|
|
1400
|
-
_context3.next =
|
|
1443
|
+
_context3.next = 219;
|
|
1401
1444
|
break;
|
|
1402
1445
|
}
|
|
1403
1446
|
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');
|
|
1404
|
-
_context3.next =
|
|
1447
|
+
_context3.next = 241;
|
|
1405
1448
|
break;
|
|
1406
|
-
case
|
|
1449
|
+
case 219:
|
|
1407
1450
|
if (!analysis.eslintRcJsonPath) {
|
|
1408
|
-
_context3.next =
|
|
1451
|
+
_context3.next = 240;
|
|
1409
1452
|
break;
|
|
1410
1453
|
}
|
|
1411
1454
|
if (defaultAnswers) {
|
|
1412
|
-
_context3.next =
|
|
1455
|
+
_context3.next = 226;
|
|
1413
1456
|
break;
|
|
1414
1457
|
}
|
|
1415
|
-
_context3.next =
|
|
1458
|
+
_context3.next = 223;
|
|
1416
1459
|
return prompts.confirm({
|
|
1417
1460
|
message: "Patch eslintrc.json to use the recommended Val eslint rules?",
|
|
1418
1461
|
"default": true
|
|
1419
1462
|
});
|
|
1420
|
-
case
|
|
1463
|
+
case 223:
|
|
1421
1464
|
_context3.t8 = _context3.sent;
|
|
1422
|
-
_context3.next =
|
|
1465
|
+
_context3.next = 227;
|
|
1423
1466
|
break;
|
|
1424
|
-
case
|
|
1467
|
+
case 226:
|
|
1425
1468
|
_context3.t8 = true;
|
|
1426
|
-
case
|
|
1427
|
-
|
|
1428
|
-
if (!
|
|
1429
|
-
_context3.next =
|
|
1469
|
+
case 227:
|
|
1470
|
+
_answer9 = _context3.t8;
|
|
1471
|
+
if (!_answer9) {
|
|
1472
|
+
_context3.next = 238;
|
|
1430
1473
|
break;
|
|
1431
1474
|
}
|
|
1432
1475
|
currentEslintRc = fs__default["default"].readFileSync(analysis.eslintRcJsonPath, "utf-8");
|
|
1433
1476
|
parsedEslint = JSON.parse(currentEslintRc);
|
|
1434
1477
|
if (!(_typeof(parsedEslint) !== "object")) {
|
|
1435
|
-
_context3.next =
|
|
1478
|
+
_context3.next = 234;
|
|
1436
1479
|
break;
|
|
1437
1480
|
}
|
|
1438
1481
|
error("Could not patch eslint: ".concat(analysis.eslintRcJsonPath, " was not an object"));
|
|
1439
1482
|
return _context3.abrupt("return", {
|
|
1440
1483
|
abort: true
|
|
1441
1484
|
});
|
|
1442
|
-
case
|
|
1485
|
+
case 234:
|
|
1443
1486
|
if (typeof parsedEslint["extends"] === "string") {
|
|
1444
1487
|
parsedEslint["extends"] = [parsedEslint["extends"]];
|
|
1445
1488
|
}
|
|
@@ -1449,24 +1492,24 @@ function _plan() {
|
|
|
1449
1492
|
path: analysis.eslintRcJsonPath,
|
|
1450
1493
|
source: JSON.stringify(parsedEslint, null, 2) + "\n"
|
|
1451
1494
|
};
|
|
1452
|
-
case
|
|
1453
|
-
_context3.next =
|
|
1495
|
+
case 238:
|
|
1496
|
+
_context3.next = 241;
|
|
1454
1497
|
break;
|
|
1455
|
-
case
|
|
1498
|
+
case 240:
|
|
1456
1499
|
warn("Cannot patch eslint: failed to find eslint config file");
|
|
1457
|
-
case
|
|
1500
|
+
case 241:
|
|
1458
1501
|
if (!analysis.gitIgnorePath) {
|
|
1459
|
-
_context3.next =
|
|
1502
|
+
_context3.next = 248;
|
|
1460
1503
|
break;
|
|
1461
1504
|
}
|
|
1462
|
-
_context3.next =
|
|
1505
|
+
_context3.next = 244;
|
|
1463
1506
|
return prompts.confirm({
|
|
1464
1507
|
message: "Append .gitignore entry for Val cache? (recommended)",
|
|
1465
1508
|
"default": true
|
|
1466
1509
|
});
|
|
1467
|
-
case
|
|
1468
|
-
|
|
1469
|
-
if (
|
|
1510
|
+
case 244:
|
|
1511
|
+
_answer10 = _context3.sent;
|
|
1512
|
+
if (_answer10) {
|
|
1470
1513
|
plan.updateGitIgnore = {
|
|
1471
1514
|
path: analysis.gitIgnorePath,
|
|
1472
1515
|
source: (analysis.gitIgnoreFile ? "".concat(analysis.gitIgnoreFile, "\n\n") : "") + "# Val local cache\n.val\n"
|
|
@@ -1474,49 +1517,49 @@ function _plan() {
|
|
|
1474
1517
|
} else {
|
|
1475
1518
|
plan.updateGitIgnore = false;
|
|
1476
1519
|
}
|
|
1477
|
-
_context3.next =
|
|
1520
|
+
_context3.next = 249;
|
|
1478
1521
|
break;
|
|
1479
|
-
case
|
|
1522
|
+
case 248:
|
|
1480
1523
|
plan.updateGitIgnore = false;
|
|
1481
|
-
case
|
|
1482
|
-
_context3.next =
|
|
1524
|
+
case 249:
|
|
1525
|
+
_context3.next = 251;
|
|
1483
1526
|
return prompts.confirm({
|
|
1484
1527
|
message: "Add the Val Build IntelliSense to .vscode/extensions.json?",
|
|
1485
1528
|
"default": true
|
|
1486
1529
|
});
|
|
1487
|
-
case
|
|
1488
|
-
|
|
1489
|
-
if (!
|
|
1490
|
-
_context3.next =
|
|
1530
|
+
case 251:
|
|
1531
|
+
_answer11 = _context3.sent;
|
|
1532
|
+
if (!_answer11) {
|
|
1533
|
+
_context3.next = 277;
|
|
1491
1534
|
break;
|
|
1492
1535
|
}
|
|
1493
1536
|
vscodeDir = path__default["default"].join(analysis.root, ".vscode");
|
|
1494
1537
|
settingsPath = path__default["default"].join(vscodeDir, "extensions.json");
|
|
1495
1538
|
currentSettings = {};
|
|
1496
|
-
_context3.prev =
|
|
1539
|
+
_context3.prev = 256;
|
|
1497
1540
|
currentSettingsFile = fs__default["default"].readFileSync(settingsPath, "utf-8");
|
|
1498
1541
|
if (!currentSettingsFile) {
|
|
1499
|
-
_context3.next =
|
|
1542
|
+
_context3.next = 267;
|
|
1500
1543
|
break;
|
|
1501
1544
|
}
|
|
1502
|
-
_context3.prev =
|
|
1545
|
+
_context3.prev = 259;
|
|
1503
1546
|
currentSettings = JSON.parse(currentSettingsFile);
|
|
1504
|
-
_context3.next =
|
|
1547
|
+
_context3.next = 267;
|
|
1505
1548
|
break;
|
|
1506
|
-
case
|
|
1507
|
-
_context3.prev =
|
|
1508
|
-
_context3.t9 = _context3["catch"](
|
|
1549
|
+
case 263:
|
|
1550
|
+
_context3.prev = 263;
|
|
1551
|
+
_context3.t9 = _context3["catch"](259);
|
|
1509
1552
|
warn("Failed to parse VS Code extensions.json found here: ".concat(settingsPath, ".").concat(_context3.t9 instanceof Error ? "Parse error: ".concat(_context3.t9.message) : ""));
|
|
1510
1553
|
return _context3.abrupt("return", {
|
|
1511
1554
|
abort: true
|
|
1512
1555
|
});
|
|
1513
|
-
case
|
|
1514
|
-
_context3.next =
|
|
1556
|
+
case 267:
|
|
1557
|
+
_context3.next = 271;
|
|
1515
1558
|
break;
|
|
1516
|
-
case
|
|
1517
|
-
_context3.prev =
|
|
1518
|
-
_context3.t10 = _context3["catch"](
|
|
1519
|
-
case
|
|
1559
|
+
case 269:
|
|
1560
|
+
_context3.prev = 269;
|
|
1561
|
+
_context3.t10 = _context3["catch"](256);
|
|
1562
|
+
case 271:
|
|
1520
1563
|
currentRecommendations =
|
|
1521
1564
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1522
1565
|
currentSettings.recommendations;
|
|
@@ -1530,43 +1573,17 @@ function _plan() {
|
|
|
1530
1573
|
path: settingsPath,
|
|
1531
1574
|
source: JSON.stringify(currentSettings, null, 2)
|
|
1532
1575
|
};
|
|
1533
|
-
_context3.next =
|
|
1576
|
+
_context3.next = 278;
|
|
1534
1577
|
break;
|
|
1535
|
-
case
|
|
1578
|
+
case 277:
|
|
1536
1579
|
plan.updateVSCodeSettings = false;
|
|
1537
|
-
case
|
|
1538
|
-
_context3.next = 263;
|
|
1539
|
-
return prompts.confirm({
|
|
1540
|
-
message: "Include example Val files?",
|
|
1541
|
-
"default": true
|
|
1542
|
-
});
|
|
1543
|
-
case 263:
|
|
1544
|
-
_answer11 = _context3.sent;
|
|
1545
|
-
if (!_answer11) {
|
|
1546
|
-
_context3.next = 272;
|
|
1547
|
-
break;
|
|
1548
|
-
}
|
|
1549
|
-
exampleDir = path__default["default"].join(analysis.srcDir, "examples", "val");
|
|
1550
|
-
examplePath = path__default["default"].join(exampleDir, "example.val." + (analysis.isJavaScript ? "js" : "ts"));
|
|
1551
|
-
exampleImport = path__default["default"].relative(exampleDir, valConfigPath).replace(".js", "").replace(".ts", "");
|
|
1552
|
-
if (analysis.packageJsonDir) {
|
|
1553
|
-
_context3.next = 270;
|
|
1554
|
-
break;
|
|
1555
|
-
}
|
|
1556
|
-
throw Error("Could not detect package.json directory! This is a Val bug.");
|
|
1557
|
-
case 270:
|
|
1558
|
-
exampleModuleId = "/".concat(path__default["default"].relative(analysis.packageJsonDir, examplePath).replace(".val", "").replace(".js", "").replace(".ts", ""));
|
|
1559
|
-
plan.includeExample = {
|
|
1560
|
-
path: examplePath,
|
|
1561
|
-
source: BASIC_EXAMPLE(exampleModuleId, exampleImport, !!analysis.isJavaScript)
|
|
1562
|
-
};
|
|
1563
|
-
case 272:
|
|
1580
|
+
case 278:
|
|
1564
1581
|
return _context3.abrupt("return", plan);
|
|
1565
|
-
case
|
|
1582
|
+
case 279:
|
|
1566
1583
|
case "end":
|
|
1567
1584
|
return _context3.stop();
|
|
1568
1585
|
}
|
|
1569
|
-
}, _callee3, null, [[
|
|
1586
|
+
}, _callee3, null, [[256, 269], [259, 263]]);
|
|
1570
1587
|
}));
|
|
1571
1588
|
return _plan.apply(this, arguments);
|
|
1572
1589
|
}
|