@valbuild/init 0.60.24 → 0.61.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.
@@ -504,7 +504,7 @@ function transformNextAppRouterValProvider(fileInfo, api, options) {
504
504
 
505
505
  var packageJson = {
506
506
  name: "@valbuild/init",
507
- version: "0.60.24",
507
+ version: "0.61.0",
508
508
  description: "Initialize a new val.build project",
509
509
  exports: {
510
510
  "./main": {
@@ -576,7 +576,7 @@ var VAL_APP_PAGE = function VAL_APP_PAGE(configImportPath) {
576
576
  return "import { ValApp } from \"@valbuild/next\";\nimport { config } from \"".concat(configImportPath, "\";\n\nexport default function Val() {\n return <ValApp config={config} />;\n}\n");
577
577
  };
578
578
  var BASIC_EXAMPLE = function BASIC_EXAMPLE(moduleId, configImportPath, isJavaScript) {
579
- 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 * Optional fields are marked with `.optional()`\n */\n optionals: s.string().optional(),\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().optional(),\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(moduleId, "\", 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");
579
+ 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(moduleId, "\", 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");
580
580
  };
581
581
 
582
582
  function error(message) {
@@ -664,7 +664,7 @@ function walk(dir) {
664
664
  }
665
665
  var analyze = /*#__PURE__*/function () {
666
666
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(root, files) {
667
- var analysis, packageJsonPath, packageJsonText, _packageJson, _semver$minVersion, minNextVersion, _semver$minVersion2, minValVersion, pagesRouterAppPath, appRouterLayoutPath, git, gitStatus, gitRemoteOrigin, parts, owner, repo, gitIgnorePath;
667
+ var analysis, packageJsonPath, packageJsonText, _packageJson, _semver$minVersion, minNextVersion, _semver$minVersion2, minValVersion, _semver$minVersion3, _minValVersion, pagesRouterAppPath, appRouterLayoutPath, git, gitStatus, gitRemoteOrigin, parts, owner, repo, gitIgnorePath;
668
668
  return _regeneratorRuntime().wrap(function _callee$(_context) {
669
669
  while (1) switch (_context.prev = _context.next) {
670
670
  case 0:
@@ -682,38 +682,46 @@ var analyze = /*#__PURE__*/function () {
682
682
  });
683
683
  analysis.packageJsonDir = packageJsonPath && path.dirname(packageJsonPath);
684
684
  if (!packageJsonPath) {
685
- _context.next = 20;
685
+ _context.next = 22;
686
686
  break;
687
687
  }
688
688
  packageJsonText = fs.readFileSync(packageJsonPath, "utf8");
689
689
  if (!packageJsonText) {
690
- _context.next = 20;
690
+ _context.next = 22;
691
691
  break;
692
692
  }
693
693
  _context.prev = 8;
694
694
  _packageJson = JSON.parse(packageJsonText);
695
- analysis.isValInstalled = !!_packageJson.dependencies["@valbuild/next"];
695
+ analysis.isValCoreInstalled = !!_packageJson.dependencies["@valbuild/core"];
696
+ analysis.isValNextInstalled = !!_packageJson.dependencies["@valbuild/next"];
696
697
  analysis.isNextInstalled = !!_packageJson.dependencies["next"];
697
698
  analysis.valEslintVersion = _packageJson.devDependencies["@valbuild/eslint-plugin"] || _packageJson.dependencies["@valbuild/eslint-plugin"];
698
699
  analysis.nextVersion = _packageJson.dependencies["next"];
699
- analysis.valVersion = _packageJson.dependencies["@valbuild/next"];
700
- _context.next = 20;
700
+ analysis.valCoreVersion = _packageJson.dependencies["@valbuild/core"];
701
+ analysis.valNextVersion = _packageJson.dependencies["@valbuild/next"];
702
+ _context.next = 22;
701
703
  break;
702
- case 17:
703
- _context.prev = 17;
704
+ case 19:
705
+ _context.prev = 19;
704
706
  _context.t0 = _context["catch"](8);
705
707
  throw new Error("Failed to parse package.json in file: ".concat(packageJsonPath));
706
- case 20:
708
+ case 22:
707
709
  if (analysis.nextVersion) {
708
710
  minNextVersion = (_semver$minVersion = semver.minVersion(analysis.nextVersion)) === null || _semver$minVersion === void 0 ? void 0 : _semver$minVersion.version;
709
711
  if (minNextVersion) {
710
712
  analysis.nextVersionIsSatisfied = semver.satisfies(minNextVersion, ">=" + MIN_NEXT_VERSION);
711
713
  }
712
714
  }
713
- if (analysis.valVersion) {
714
- minValVersion = (_semver$minVersion2 = semver.minVersion(analysis.valVersion)) === null || _semver$minVersion2 === void 0 ? void 0 : _semver$minVersion2.version;
715
+ if (analysis.valNextVersion) {
716
+ minValVersion = (_semver$minVersion2 = semver.minVersion(analysis.valNextVersion)) === null || _semver$minVersion2 === void 0 ? void 0 : _semver$minVersion2.version;
715
717
  if (minValVersion) {
716
- analysis.valVersionIsSatisfied = semver.satisfies(minValVersion, ">=" + MIN_VAL_VERSION);
718
+ analysis.valNextVersionIsSatisfied = semver.satisfies(minValVersion, ">=" + MIN_VAL_VERSION);
719
+ }
720
+ }
721
+ if (analysis.valCoreVersion) {
722
+ _minValVersion = (_semver$minVersion3 = semver.minVersion(analysis.valCoreVersion)) === null || _semver$minVersion3 === void 0 ? void 0 : _semver$minVersion3.version;
723
+ if (_minValVersion) {
724
+ analysis.valCoreVersionIsSatisfied = semver.satisfies(_minValVersion, ">=" + MIN_VAL_VERSION);
717
725
  }
718
726
  }
719
727
  analysis.eslintRcJsPath = files.find(function (file) {
@@ -763,15 +771,15 @@ var analyze = /*#__PURE__*/function () {
763
771
  analysis.appRouterPath = path.dirname(appRouterLayoutPath);
764
772
  analysis.srcDir = path.dirname(analysis.appRouterPath);
765
773
  }
766
- _context.prev = 31;
774
+ _context.prev = 34;
767
775
  git = simpleGit(root);
768
- _context.next = 35;
776
+ _context.next = 38;
769
777
  return git.status([]);
770
- case 35:
778
+ case 38:
771
779
  gitStatus = _context.sent;
772
- _context.next = 38;
780
+ _context.next = 41;
773
781
  return git.remote(["-v"]);
774
- case 38:
782
+ case 41:
775
783
  gitRemoteOrigin = _context.sent;
776
784
  analysis.hasGit = true;
777
785
  analysis.isGitHub = gitRemoteOrigin ? !!gitRemoteOrigin.includes("github.com") : false;
@@ -787,21 +795,21 @@ var analyze = /*#__PURE__*/function () {
787
795
  repo: repo
788
796
  };
789
797
  }
790
- _context.next = 47;
798
+ _context.next = 50;
791
799
  break;
792
- case 45:
793
- _context.prev = 45;
794
- _context.t1 = _context["catch"](31);
795
- case 47:
800
+ case 48:
801
+ _context.prev = 48;
802
+ _context.t1 = _context["catch"](34);
803
+ case 50:
796
804
  gitIgnorePath = path.join(root, ".gitignore");
797
805
  analysis.gitIgnorePath = gitIgnorePath;
798
806
  analysis.gitIgnoreFile = fs.readFileSync(gitIgnorePath, "utf-8");
799
807
  return _context.abrupt("return", analysis);
800
- case 51:
808
+ case 54:
801
809
  case "end":
802
810
  return _context.stop();
803
811
  }
804
- }, _callee, null, [[8, 17], [31, 45]]);
812
+ }, _callee, null, [[8, 19], [34, 48]]);
805
813
  }));
806
814
  return function analyze(_x, _x2) {
807
815
  return _ref2.apply(this, arguments);
@@ -815,10 +823,11 @@ function _plan() {
815
823
  var defaultAnswers,
816
824
  plan,
817
825
  answer,
826
+ _answer,
818
827
  tsconfigJsonPath,
819
828
  jsconfigJsonPath,
820
- _answer,
821
829
  _answer2,
830
+ _answer3,
822
831
  valConfigPath,
823
832
  valUtilsDir,
824
833
  valUtilsImportPath,
@@ -827,26 +836,26 @@ function _plan() {
827
836
  valPageImportPath,
828
837
  valRouterPath,
829
838
  valRouterImportPath,
830
- _answer3,
831
839
  _answer4,
840
+ _answer5,
832
841
  NO_PATCH_WARNING,
833
842
  res,
834
843
  diff,
835
844
  s,
836
- _answer5,
837
845
  _answer6,
838
846
  _answer7,
847
+ _answer8,
839
848
  currentEslintRc,
840
849
  parsedEslint,
841
- _answer8,
842
850
  _answer9,
851
+ _answer10,
843
852
  vscodeDir,
844
853
  settingsPath,
845
854
  currentSettings,
846
855
  currentSettingsFile,
847
856
  currentRecommendations,
848
857
  valBuildIntelliSense,
849
- _answer10,
858
+ _answer11,
850
859
  exampleDir,
851
860
  examplePath,
852
861
  exampleImport,
@@ -907,20 +916,20 @@ function _plan() {
907
916
  abort: true
908
917
  });
909
918
  case 20:
910
- if (analysis.isValInstalled) {
919
+ if (analysis.isValCoreInstalled) {
911
920
  _context3.next = 25;
912
921
  break;
913
922
  }
914
- error("Install @valbuild/next first");
923
+ error("Install @valbuild/core first");
915
924
  return _context3.abrupt("return", {
916
925
  abort: true
917
926
  });
918
927
  case 25:
919
- if (analysis.valVersionIsSatisfied) {
928
+ if (analysis.valCoreVersionIsSatisfied) {
920
929
  _context3.next = 40;
921
930
  break;
922
931
  }
923
- warn(" This init script expects @valbuild/next >= ".concat(MIN_VAL_VERSION, ". Found: ").concat(analysis.valVersion));
932
+ warn(" This init script expects @valbuild/core >= ".concat(MIN_VAL_VERSION, ". Found: ").concat(analysis.valCoreVersion));
924
933
  if (defaultAnswers) {
925
934
  _context3.next = 33;
926
935
  break;
@@ -942,7 +951,7 @@ function _plan() {
942
951
  _context3.next = 38;
943
952
  break;
944
953
  }
945
- error("Aborted: val version is not satisfied.\n\nInstall the @valbuild/next@".concat(MIN_VAL_VERSION, " package with your favorite package manager.\n\nExample:\n\n npm install -D @valbuild/next@").concat(MIN_VAL_VERSION, "\n"));
954
+ error("Aborted: @valbuild/core version is not satisfied.\n\nInstall the @valbuild/core@".concat(MIN_VAL_VERSION, " package with your favorite package manager.\n\nExample:\n\n npm install -D @valbuild/core@").concat(MIN_VAL_VERSION, "\n"));
946
955
  return _context3.abrupt("return", {
947
956
  abort: true
948
957
  });
@@ -950,23 +959,70 @@ function _plan() {
950
959
  _context3.next = 41;
951
960
  break;
952
961
  case 40:
953
- info(" Val version: found ".concat(analysis.valVersion, " >= ").concat(MIN_VAL_VERSION), {
962
+ info(" Val version: found ".concat(analysis.valCoreVersion, " >= ").concat(MIN_VAL_VERSION), {
954
963
  isGood: true
955
964
  });
956
965
  case 41:
957
- if (analysis.nextVersionIsSatisfied) {
966
+ if (analysis.isValNextInstalled) {
958
967
  _context3.next = 46;
959
968
  break;
960
969
  }
961
- error("Val requires Next.js >= ".concat(MIN_NEXT_VERSION, ". Found: ").concat(analysis.nextVersion));
970
+ error("Install @valbuild/next first");
962
971
  return _context3.abrupt("return", {
963
972
  abort: true
964
973
  });
965
974
  case 46:
975
+ if (analysis.valNextVersionIsSatisfied) {
976
+ _context3.next = 61;
977
+ break;
978
+ }
979
+ warn(" This init script expects @valbuild/next >= ".concat(MIN_VAL_VERSION, ". Found: ").concat(analysis.valNextVersion));
980
+ if (defaultAnswers) {
981
+ _context3.next = 54;
982
+ break;
983
+ }
984
+ _context3.next = 51;
985
+ return confirm({
986
+ message: "Continue?",
987
+ "default": false
988
+ });
989
+ case 51:
990
+ _context3.t1 = _context3.sent;
991
+ _context3.next = 55;
992
+ break;
993
+ case 54:
994
+ _context3.t1 = false;
995
+ case 55:
996
+ _answer = _context3.t1;
997
+ if (_answer) {
998
+ _context3.next = 59;
999
+ break;
1000
+ }
1001
+ error("Aborted: @valbuild/next version is not satisfied.\n\nInstall the @valbuild/next@".concat(MIN_VAL_VERSION, " package with your favorite package manager.\n\nExample:\n\n npm install -D @valbuild/next@").concat(MIN_VAL_VERSION, "\n"));
1002
+ return _context3.abrupt("return", {
1003
+ abort: true
1004
+ });
1005
+ case 59:
1006
+ _context3.next = 62;
1007
+ break;
1008
+ case 61:
1009
+ info(" Val version: found ".concat(analysis.valNextVersion, " >= ").concat(MIN_VAL_VERSION), {
1010
+ isGood: true
1011
+ });
1012
+ case 62:
1013
+ if (analysis.nextVersionIsSatisfied) {
1014
+ _context3.next = 67;
1015
+ break;
1016
+ }
1017
+ error("Val requires Next.js >= ".concat(MIN_NEXT_VERSION, ". Found: ").concat(analysis.nextVersion));
1018
+ return _context3.abrupt("return", {
1019
+ abort: true
1020
+ });
1021
+ case 67:
966
1022
  info(" Next.js version: found ".concat(analysis.nextVersion, " >= ").concat(MIN_NEXT_VERSION), {
967
1023
  isGood: true
968
1024
  });
969
- case 47:
1025
+ case 68:
970
1026
  if (analysis.isTypeScript) {
971
1027
  info(" Use: TypeScript", {
972
1028
  isGood: true
@@ -982,81 +1038,81 @@ function _plan() {
982
1038
  }
983
1039
  }
984
1040
  if (!analysis.isTypeScript) {
985
- _context3.next = 59;
1041
+ _context3.next = 80;
986
1042
  break;
987
1043
  }
988
1044
  tsconfigJsonPath = path.join(analysis.root, "tsconfig.json");
989
1045
  if (!fs.statSync(tsconfigJsonPath).isFile()) {
990
- _context3.next = 55;
1046
+ _context3.next = 76;
991
1047
  break;
992
1048
  }
993
1049
  info(" tsconfig.json: found", {
994
1050
  isGood: true
995
1051
  });
996
- _context3.next = 57;
1052
+ _context3.next = 78;
997
1053
  break;
998
- case 55:
1054
+ case 76:
999
1055
  error("tsconfig.json: Failed to find tsconfig.json");
1000
1056
  return _context3.abrupt("return", {
1001
1057
  abort: true
1002
1058
  });
1003
- case 57:
1004
- _context3.next = 66;
1059
+ case 78:
1060
+ _context3.next = 87;
1005
1061
  break;
1006
- case 59:
1062
+ case 80:
1007
1063
  jsconfigJsonPath = path.join(analysis.root, "jsconfig.json");
1008
1064
  if (!fs.statSync(jsconfigJsonPath).isFile()) {
1009
- _context3.next = 64;
1065
+ _context3.next = 85;
1010
1066
  break;
1011
1067
  }
1012
1068
  info(" jsconfig.json: found", {
1013
1069
  isGood: true
1014
1070
  });
1015
- _context3.next = 66;
1071
+ _context3.next = 87;
1016
1072
  break;
1017
- case 64:
1073
+ case 85:
1018
1074
  error(" jsconfig.json: failed to find jsconfig.json");
1019
1075
  return _context3.abrupt("return", {
1020
1076
  abort: true
1021
1077
  });
1022
- case 66:
1078
+ case 87:
1023
1079
  if (!(analysis.valEslintVersion === undefined)) {
1024
- _context3.next = 80;
1080
+ _context3.next = 101;
1025
1081
  break;
1026
1082
  }
1027
1083
  if (defaultAnswers) {
1028
- _context3.next = 73;
1084
+ _context3.next = 94;
1029
1085
  break;
1030
1086
  }
1031
- _context3.next = 70;
1087
+ _context3.next = 91;
1032
1088
  return confirm({
1033
1089
  message: "The recommended Val eslint plugin (@valbuild/eslint-plugin) is not installed. Continue?",
1034
1090
  "default": false
1035
1091
  });
1036
- case 70:
1037
- _context3.t1 = _context3.sent;
1038
- _context3.next = 74;
1092
+ case 91:
1093
+ _context3.t2 = _context3.sent;
1094
+ _context3.next = 95;
1039
1095
  break;
1040
- case 73:
1041
- _context3.t1 = false;
1042
- case 74:
1043
- _answer = _context3.t1;
1044
- if (_answer) {
1045
- _context3.next = 78;
1096
+ case 94:
1097
+ _context3.t2 = false;
1098
+ case 95:
1099
+ _answer2 = _context3.t2;
1100
+ if (_answer2) {
1101
+ _context3.next = 99;
1046
1102
  break;
1047
1103
  }
1048
1104
  error("Aborted: the Val eslint plugin is not installed.\n\nInstall the @valbuild/eslint-plugin package with your favorite package manager.\n\nExample:\n\n npm install -D @valbuild/eslint-plugin\n");
1049
1105
  return _context3.abrupt("return", {
1050
1106
  abort: true
1051
1107
  });
1052
- case 78:
1053
- _context3.next = 81;
1108
+ case 99:
1109
+ _context3.next = 102;
1054
1110
  break;
1055
- case 80:
1111
+ case 101:
1056
1112
  info(" @valbuild/eslint-plugin: installed", {
1057
1113
  isGood: true
1058
1114
  });
1059
- case 81:
1115
+ case 102:
1060
1116
  if (analysis.appRouter) {
1061
1117
  info(" Use: App Router", {
1062
1118
  isGood: true
@@ -1082,55 +1138,55 @@ function _plan() {
1082
1138
  warn(" Git state: dirty");
1083
1139
  }
1084
1140
  if (analysis.isGitClean) {
1085
- _context3.next = 101;
1141
+ _context3.next = 122;
1086
1142
  break;
1087
1143
  }
1088
- case 86:
1144
+ case 107:
1089
1145
  if (!(plan.ignoreGitDirty === undefined)) {
1090
- _context3.next = 101;
1146
+ _context3.next = 122;
1091
1147
  break;
1092
1148
  }
1093
1149
  if (defaultAnswers) {
1094
- _context3.next = 93;
1150
+ _context3.next = 114;
1095
1151
  break;
1096
1152
  }
1097
- _context3.next = 90;
1153
+ _context3.next = 111;
1098
1154
  return confirm({
1099
1155
  message: "You have uncommitted changes. Continue?",
1100
1156
  "default": false
1101
1157
  });
1102
- case 90:
1103
- _context3.t2 = _context3.sent;
1104
- _context3.next = 94;
1158
+ case 111:
1159
+ _context3.t3 = _context3.sent;
1160
+ _context3.next = 115;
1105
1161
  break;
1106
- case 93:
1107
- _context3.t2 = false;
1108
- case 94:
1109
- _answer2 = _context3.t2;
1110
- plan.ignoreGitDirty = _answer2;
1111
- if (_answer2) {
1112
- _context3.next = 99;
1162
+ case 114:
1163
+ _context3.t3 = false;
1164
+ case 115:
1165
+ _answer3 = _context3.t3;
1166
+ plan.ignoreGitDirty = _answer3;
1167
+ if (_answer3) {
1168
+ _context3.next = 120;
1113
1169
  break;
1114
1170
  }
1115
1171
  error("Aborted: git state dirty");
1116
1172
  return _context3.abrupt("return", {
1117
1173
  abort: true
1118
1174
  });
1119
- case 99:
1120
- _context3.next = 86;
1175
+ case 120:
1176
+ _context3.next = 107;
1121
1177
  break;
1122
- case 101:
1178
+ case 122:
1123
1179
  // New required files:
1124
1180
  valConfigPath = path.join(analysis.root, analysis.isTypeScript ? "val.config.ts" : "val.config.js");
1125
1181
  if (!fs.existsSync(valConfigPath)) {
1126
- _context3.next = 105;
1182
+ _context3.next = 126;
1127
1183
  break;
1128
1184
  }
1129
1185
  error("Aborted: a Val config file: ".concat(valConfigPath, " already exists."));
1130
1186
  return _context3.abrupt("return", {
1131
1187
  abort: true
1132
1188
  });
1133
- case 105:
1189
+ case 126:
1134
1190
  plan.createConfigFile = {
1135
1191
  path: valConfigPath,
1136
1192
  source: VAL_CONFIG(!!analysis.isTypeScript, {})
@@ -1159,29 +1215,29 @@ function _plan() {
1159
1215
  };
1160
1216
 
1161
1217
  // Util files:
1162
- case 117:
1218
+ case 138:
1163
1219
  if (!(plan.createValClient === undefined)) {
1164
- _context3.next = 129;
1220
+ _context3.next = 150;
1165
1221
  break;
1166
1222
  }
1167
1223
  if (defaultAnswers) {
1168
- _context3.next = 124;
1224
+ _context3.next = 145;
1169
1225
  break;
1170
1226
  }
1171
- _context3.next = 121;
1227
+ _context3.next = 142;
1172
1228
  return confirm({
1173
1229
  message: "Setup useVal for Client Components",
1174
1230
  "default": true
1175
1231
  });
1176
- case 121:
1177
- _context3.t3 = _context3.sent;
1178
- _context3.next = 125;
1232
+ case 142:
1233
+ _context3.t4 = _context3.sent;
1234
+ _context3.next = 146;
1179
1235
  break;
1180
- case 124:
1181
- _context3.t3 = true;
1182
- case 125:
1183
- _answer3 = _context3.t3;
1184
- if (_answer3) {
1236
+ case 145:
1237
+ _context3.t4 = true;
1238
+ case 146:
1239
+ _answer4 = _context3.t4;
1240
+ if (_answer4) {
1185
1241
  plan.createValClient = {
1186
1242
  path: path.join(valUtilsDir, analysis.isTypeScript ? "val.client.ts" : "val.client.js"),
1187
1243
  source: VAL_CLIENT(valUtilsImportPath)
@@ -1189,31 +1245,31 @@ function _plan() {
1189
1245
  } else {
1190
1246
  plan.createValClient = false;
1191
1247
  }
1192
- _context3.next = 117;
1248
+ _context3.next = 138;
1193
1249
  break;
1194
- case 129:
1250
+ case 150:
1195
1251
  if (!(plan.createValRsc === undefined)) {
1196
- _context3.next = 141;
1252
+ _context3.next = 162;
1197
1253
  break;
1198
1254
  }
1199
1255
  if (defaultAnswers) {
1200
- _context3.next = 136;
1256
+ _context3.next = 157;
1201
1257
  break;
1202
1258
  }
1203
- _context3.next = 133;
1259
+ _context3.next = 154;
1204
1260
  return confirm({
1205
1261
  message: "Setup fetchVal for React Server Components",
1206
1262
  "default": true
1207
1263
  });
1208
- case 133:
1209
- _context3.t4 = _context3.sent;
1210
- _context3.next = 137;
1264
+ case 154:
1265
+ _context3.t5 = _context3.sent;
1266
+ _context3.next = 158;
1211
1267
  break;
1212
- case 136:
1213
- _context3.t4 = true;
1214
- case 137:
1215
- _answer4 = _context3.t4;
1216
- if (_answer4) {
1268
+ case 157:
1269
+ _context3.t5 = true;
1270
+ case 158:
1271
+ _answer5 = _context3.t5;
1272
+ if (_answer5) {
1217
1273
  plan.createValRsc = {
1218
1274
  path: path.join(valUtilsDir, analysis.isTypeScript ? "val.rsc.ts" : "val.rsc.js"),
1219
1275
  source: VAL_RSC(valUtilsImportPath)
@@ -1221,24 +1277,24 @@ function _plan() {
1221
1277
  } else {
1222
1278
  plan.createValRsc = false;
1223
1279
  }
1224
- _context3.next = 129;
1280
+ _context3.next = 150;
1225
1281
  break;
1226
- case 141:
1282
+ case 162:
1227
1283
  // Patches:
1228
1284
  NO_PATCH_WARNING = "Remember to add the ValProvider in your root app/layout.tsx or pages/_app.tsx file.\n";
1229
1285
  if (!analysis.appRouterLayoutPath) {
1230
- _context3.next = 171;
1286
+ _context3.next = 192;
1231
1287
  break;
1232
1288
  }
1233
1289
  if (analysis.appRouterLayoutFile) {
1234
- _context3.next = 146;
1290
+ _context3.next = 167;
1235
1291
  break;
1236
1292
  }
1237
1293
  error("Failed to read app router layout file");
1238
1294
  return _context3.abrupt("return", {
1239
1295
  abort: true
1240
1296
  });
1241
- case 146:
1297
+ case 167:
1242
1298
  res = transformNextAppRouterValProvider({
1243
1299
  path: analysis.appRouterLayoutPath,
1244
1300
  source: analysis.appRouterLayoutFile
@@ -1262,44 +1318,44 @@ function _plan() {
1262
1318
  }
1263
1319
  });
1264
1320
  if (defaultAnswers) {
1265
- _context3.next = 156;
1321
+ _context3.next = 177;
1266
1322
  break;
1267
1323
  }
1268
- _context3.next = 153;
1324
+ _context3.next = 174;
1269
1325
  return confirm({
1270
1326
  message: "Automatically patch ".concat(analysis.appRouterLayoutPath, " file?"),
1271
1327
  "default": true
1272
1328
  });
1273
- case 153:
1274
- _context3.t5 = _context3.sent;
1275
- _context3.next = 157;
1329
+ case 174:
1330
+ _context3.t6 = _context3.sent;
1331
+ _context3.next = 178;
1276
1332
  break;
1277
- case 156:
1278
- _context3.t5 = true;
1279
- case 157:
1280
- _answer5 = _context3.t5;
1281
- if (!_answer5) {
1282
- _context3.next = 170;
1333
+ case 177:
1334
+ _context3.t6 = true;
1335
+ case 178:
1336
+ _answer6 = _context3.t6;
1337
+ if (!_answer6) {
1338
+ _context3.next = 191;
1283
1339
  break;
1284
1340
  }
1285
1341
  if (defaultAnswers) {
1286
- _context3.next = 165;
1342
+ _context3.next = 186;
1287
1343
  break;
1288
1344
  }
1289
- _context3.next = 162;
1345
+ _context3.next = 183;
1290
1346
  return confirm({
1291
1347
  message: "Do you accept the following patch:\n".concat(s, "\n"),
1292
1348
  "default": true
1293
1349
  });
1294
- case 162:
1295
- _context3.t6 = _context3.sent;
1296
- _context3.next = 166;
1350
+ case 183:
1351
+ _context3.t7 = _context3.sent;
1352
+ _context3.next = 187;
1297
1353
  break;
1298
- case 165:
1299
- _context3.t6 = true;
1300
- case 166:
1301
- _answer6 = _context3.t6;
1302
- if (!_answer6) {
1354
+ case 186:
1355
+ _context3.t7 = true;
1356
+ case 187:
1357
+ _answer7 = _context3.t7;
1358
+ if (!_answer7) {
1303
1359
  warn(NO_PATCH_WARNING);
1304
1360
  plan.updateAppLayout = false;
1305
1361
  } else {
@@ -1308,70 +1364,70 @@ function _plan() {
1308
1364
  source: res
1309
1365
  };
1310
1366
  }
1311
- _context3.next = 171;
1367
+ _context3.next = 192;
1312
1368
  break;
1313
- case 170:
1369
+ case 191:
1314
1370
  warn(NO_PATCH_WARNING);
1315
- case 171:
1371
+ case 192:
1316
1372
  if (analysis.pagesRouter) {
1317
1373
  warn(NO_PATCH_WARNING);
1318
1374
  }
1319
1375
  if (!analysis.valEslintVersion) {
1320
- _context3.next = 203;
1376
+ _context3.next = 224;
1321
1377
  break;
1322
1378
  }
1323
1379
  if (!analysis.isValEslintRulesConfigured) {
1324
- _context3.next = 177;
1380
+ _context3.next = 198;
1325
1381
  break;
1326
1382
  }
1327
1383
  warn(" @valbuild/eslint-plugin rules: already configured");
1328
- _context3.next = 203;
1384
+ _context3.next = 224;
1329
1385
  break;
1330
- case 177:
1386
+ case 198:
1331
1387
  if (!analysis.eslintRcJsPath) {
1332
- _context3.next = 181;
1388
+ _context3.next = 202;
1333
1389
  break;
1334
1390
  }
1335
1391
  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');
1336
- _context3.next = 203;
1392
+ _context3.next = 224;
1337
1393
  break;
1338
- case 181:
1394
+ case 202:
1339
1395
  if (!analysis.eslintRcJsonPath) {
1340
- _context3.next = 202;
1396
+ _context3.next = 223;
1341
1397
  break;
1342
1398
  }
1343
1399
  if (defaultAnswers) {
1344
- _context3.next = 188;
1400
+ _context3.next = 209;
1345
1401
  break;
1346
1402
  }
1347
- _context3.next = 185;
1403
+ _context3.next = 206;
1348
1404
  return confirm({
1349
1405
  message: "Patch eslintrc.json to use the recommended Val eslint rules?",
1350
1406
  "default": true
1351
1407
  });
1352
- case 185:
1353
- _context3.t7 = _context3.sent;
1354
- _context3.next = 189;
1408
+ case 206:
1409
+ _context3.t8 = _context3.sent;
1410
+ _context3.next = 210;
1355
1411
  break;
1356
- case 188:
1357
- _context3.t7 = true;
1358
- case 189:
1359
- _answer7 = _context3.t7;
1360
- if (!_answer7) {
1361
- _context3.next = 200;
1412
+ case 209:
1413
+ _context3.t8 = true;
1414
+ case 210:
1415
+ _answer8 = _context3.t8;
1416
+ if (!_answer8) {
1417
+ _context3.next = 221;
1362
1418
  break;
1363
1419
  }
1364
1420
  currentEslintRc = fs.readFileSync(analysis.eslintRcJsonPath, "utf-8");
1365
1421
  parsedEslint = JSON.parse(currentEslintRc);
1366
1422
  if (!(_typeof(parsedEslint) !== "object")) {
1367
- _context3.next = 196;
1423
+ _context3.next = 217;
1368
1424
  break;
1369
1425
  }
1370
1426
  error("Could not patch eslint: ".concat(analysis.eslintRcJsonPath, " was not an object"));
1371
1427
  return _context3.abrupt("return", {
1372
1428
  abort: true
1373
1429
  });
1374
- case 196:
1430
+ case 217:
1375
1431
  if (typeof parsedEslint["extends"] === "string") {
1376
1432
  parsedEslint["extends"] = [parsedEslint["extends"]];
1377
1433
  }
@@ -1381,24 +1437,24 @@ function _plan() {
1381
1437
  path: analysis.eslintRcJsonPath,
1382
1438
  source: JSON.stringify(parsedEslint, null, 2) + "\n"
1383
1439
  };
1384
- case 200:
1385
- _context3.next = 203;
1440
+ case 221:
1441
+ _context3.next = 224;
1386
1442
  break;
1387
- case 202:
1443
+ case 223:
1388
1444
  warn("Cannot patch eslint: failed to find eslint config file");
1389
- case 203:
1445
+ case 224:
1390
1446
  if (!analysis.gitIgnorePath) {
1391
- _context3.next = 210;
1447
+ _context3.next = 231;
1392
1448
  break;
1393
1449
  }
1394
- _context3.next = 206;
1450
+ _context3.next = 227;
1395
1451
  return confirm({
1396
1452
  message: "Append .gitignore entry for Val cache? (recommended)",
1397
1453
  "default": true
1398
1454
  });
1399
- case 206:
1400
- _answer8 = _context3.sent;
1401
- if (_answer8) {
1455
+ case 227:
1456
+ _answer9 = _context3.sent;
1457
+ if (_answer9) {
1402
1458
  plan.updateGitIgnore = {
1403
1459
  path: analysis.gitIgnorePath,
1404
1460
  source: (analysis.gitIgnoreFile ? "".concat(analysis.gitIgnoreFile, "\n\n") : "") + "# Val local cache\n.val\n"
@@ -1406,53 +1462,54 @@ function _plan() {
1406
1462
  } else {
1407
1463
  plan.updateGitIgnore = false;
1408
1464
  }
1409
- _context3.next = 211;
1465
+ _context3.next = 232;
1410
1466
  break;
1411
- case 210:
1467
+ case 231:
1412
1468
  plan.updateGitIgnore = false;
1413
- case 211:
1414
- _context3.next = 213;
1469
+ case 232:
1470
+ _context3.next = 234;
1415
1471
  return confirm({
1416
1472
  message: "Add the Val Build IntelliSense to .vscode/extensions.json?",
1417
1473
  "default": true
1418
1474
  });
1419
- case 213:
1420
- _answer9 = _context3.sent;
1421
- if (!_answer9) {
1422
- _context3.next = 239;
1475
+ case 234:
1476
+ _answer10 = _context3.sent;
1477
+ if (!_answer10) {
1478
+ _context3.next = 260;
1423
1479
  break;
1424
1480
  }
1425
1481
  vscodeDir = path.join(analysis.root, ".vscode");
1426
1482
  settingsPath = path.join(vscodeDir, "extensions.json");
1427
1483
  currentSettings = {};
1428
- _context3.prev = 218;
1484
+ _context3.prev = 239;
1429
1485
  currentSettingsFile = fs.readFileSync(settingsPath, "utf-8");
1430
1486
  if (!currentSettingsFile) {
1431
- _context3.next = 229;
1487
+ _context3.next = 250;
1432
1488
  break;
1433
1489
  }
1434
- _context3.prev = 221;
1490
+ _context3.prev = 242;
1435
1491
  currentSettings = JSON.parse(currentSettingsFile);
1436
- _context3.next = 229;
1492
+ _context3.next = 250;
1437
1493
  break;
1438
- case 225:
1439
- _context3.prev = 225;
1440
- _context3.t8 = _context3["catch"](221);
1441
- warn("Failed to parse VS Code extensions.json found here: ".concat(settingsPath, ".").concat(_context3.t8 instanceof Error ? "Parse error: ".concat(_context3.t8.message) : ""));
1494
+ case 246:
1495
+ _context3.prev = 246;
1496
+ _context3.t9 = _context3["catch"](242);
1497
+ warn("Failed to parse VS Code extensions.json found here: ".concat(settingsPath, ".").concat(_context3.t9 instanceof Error ? "Parse error: ".concat(_context3.t9.message) : ""));
1442
1498
  return _context3.abrupt("return", {
1443
1499
  abort: true
1444
1500
  });
1445
- case 229:
1446
- _context3.next = 233;
1501
+ case 250:
1502
+ _context3.next = 254;
1447
1503
  break;
1448
- case 231:
1449
- _context3.prev = 231;
1450
- _context3.t9 = _context3["catch"](218);
1451
- case 233:
1504
+ case 252:
1505
+ _context3.prev = 252;
1506
+ _context3.t10 = _context3["catch"](239);
1507
+ case 254:
1508
+ currentRecommendations =
1452
1509
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1453
- currentRecommendations = currentSettings.recommendations;
1510
+ currentSettings.recommendations;
1454
1511
  valBuildIntelliSense = "valbuild.vscode-val-build";
1455
- if (!currentRecommendations.includes(valBuildIntelliSense)) {
1512
+ if (!(currentRecommendations !== null && currentRecommendations !== void 0 && currentRecommendations.includes(valBuildIntelliSense))) {
1456
1513
  currentSettings = _objectSpread2(_objectSpread2({}, currentSettings), {}, {
1457
1514
  recommendations: (currentRecommendations || []).concat(valBuildIntelliSense)
1458
1515
  });
@@ -1461,43 +1518,43 @@ function _plan() {
1461
1518
  path: settingsPath,
1462
1519
  source: JSON.stringify(currentSettings, null, 2)
1463
1520
  };
1464
- _context3.next = 240;
1521
+ _context3.next = 261;
1465
1522
  break;
1466
- case 239:
1523
+ case 260:
1467
1524
  plan.updateVSCodeSettings = false;
1468
- case 240:
1469
- _context3.next = 242;
1525
+ case 261:
1526
+ _context3.next = 263;
1470
1527
  return confirm({
1471
1528
  message: "Include example Val files?",
1472
1529
  "default": true
1473
1530
  });
1474
- case 242:
1475
- _answer10 = _context3.sent;
1476
- if (!_answer10) {
1477
- _context3.next = 251;
1531
+ case 263:
1532
+ _answer11 = _context3.sent;
1533
+ if (!_answer11) {
1534
+ _context3.next = 272;
1478
1535
  break;
1479
1536
  }
1480
1537
  exampleDir = path.join(analysis.srcDir, "examples", "val");
1481
1538
  examplePath = path.join(exampleDir, "example.val." + (analysis.isJavaScript ? "js" : "ts"));
1482
1539
  exampleImport = path.relative(exampleDir, valConfigPath).replace(".js", "").replace(".ts", "");
1483
1540
  if (analysis.packageJsonDir) {
1484
- _context3.next = 249;
1541
+ _context3.next = 270;
1485
1542
  break;
1486
1543
  }
1487
1544
  throw Error("Could not detect package.json directory! This is a Val bug.");
1488
- case 249:
1545
+ case 270:
1489
1546
  exampleModuleId = "/".concat(path.relative(analysis.packageJsonDir, examplePath).replace(".val", "").replace(".js", "").replace(".ts", ""));
1490
1547
  plan.includeExample = {
1491
1548
  path: examplePath,
1492
1549
  source: BASIC_EXAMPLE(exampleModuleId, exampleImport, !!analysis.isJavaScript)
1493
1550
  };
1494
- case 251:
1551
+ case 272:
1495
1552
  return _context3.abrupt("return", plan);
1496
- case 252:
1553
+ case 273:
1497
1554
  case "end":
1498
1555
  return _context3.stop();
1499
1556
  }
1500
- }, _callee3, null, [[218, 231], [221, 225]]);
1557
+ }, _callee3, null, [[239, 252], [242, 246]]);
1501
1558
  }));
1502
1559
  return _plan.apply(this, arguments);
1503
1560
  }