@tinacms/cli 0.0.0-ab43169-20250401070153 → 0.0.0-ab51af8-20251124045003

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/index.js CHANGED
@@ -35,10 +35,10 @@ module.exports = __toCommonJS(index_exports);
35
35
  var import_clipanion8 = require("clipanion");
36
36
 
37
37
  // package.json
38
- var version = "1.9.4";
38
+ var version = "1.12.4";
39
39
 
40
40
  // src/next/commands/dev-command/index.ts
41
- var import_path5 = __toESM(require("path"));
41
+ var import_path7 = __toESM(require("path"));
42
42
  var import_graphql10 = require("@tinacms/graphql");
43
43
  var import_search = require("@tinacms/search");
44
44
  var import_async_lock = __toESM(require("async-lock"));
@@ -587,13 +587,12 @@ var Codegen = class {
587
587
  return apiURL;
588
588
  }
589
589
  _createApiUrl() {
590
- var _a, _b, _c, _d;
591
- const branch = (_a = this.configManager.config) == null ? void 0 : _a.branch;
592
- const clientId = (_b = this.configManager.config) == null ? void 0 : _b.clientId;
593
- const token = (_c = this.configManager.config) == null ? void 0 : _c.token;
590
+ const branch = this.configManager.config?.branch;
591
+ const clientId = this.configManager.config?.clientId;
592
+ const token = this.configManager.config?.token;
594
593
  const fullVersion = this.configManager.getTinaGraphQLVersion();
595
594
  const version2 = `${fullVersion.major}.${fullVersion.minor}`;
596
- const baseUrl = ((_d = this.configManager.config.tinaioConfig) == null ? void 0 : _d.contentApiUrlOverride) || `https://${TINA_HOST}`;
595
+ const baseUrl = this.configManager.config.tinaioConfig?.contentApiUrlOverride || `https://${TINA_HOST}`;
597
596
  if ((!branch || !clientId || !token) && !this.port && !this.configManager.config.contentApiUrlOverride) {
598
597
  const missing = [];
599
598
  if (!branch) missing.push("branch");
@@ -602,7 +601,7 @@ var Codegen = class {
602
601
  throw new Error(
603
602
  `Client not configured properly. Missing ${missing.join(
604
603
  ", "
605
- )}. Please visit https://tina.io/docs/tina-cloud/overview for more information`
604
+ )}. Please visit https://tina.io/docs/r/what-is-tinacloud for more information`
606
605
  );
607
606
  }
608
607
  let localUrl = `http://localhost:${this.port}/graphql`;
@@ -621,7 +620,6 @@ var Codegen = class {
621
620
  return this.apiURL;
622
621
  }
623
622
  async genDatabaseClient() {
624
- var _a, _b;
625
623
  const authCollection = this.tinaSchema.getCollections().find((c) => c.isAuthCollection);
626
624
  let authFields = [];
627
625
  if (authCollection) {
@@ -632,7 +630,7 @@ var Codegen = class {
632
630
  if (usersFields.length > 1) {
633
631
  throw new Error("Only one user field is allowed");
634
632
  }
635
- authFields = (_b = (_a = usersFields[0]) == null ? void 0 : _a.collectable) == null ? void 0 : _b.fields.map((f) => {
633
+ authFields = usersFields[0]?.collectable?.fields.map((f) => {
636
634
  if (f.type !== "password" && f.type !== "object") {
637
635
  if (f.uid) {
638
636
  return `id:${f.name}`;
@@ -710,9 +708,8 @@ export default databaseClient;
710
708
  `;
711
709
  }
712
710
  async genClient() {
713
- var _a, _b, _c;
714
- const token = (_a = this.configManager.config) == null ? void 0 : _a.token;
715
- const errorPolicy = (_c = (_b = this.configManager.config) == null ? void 0 : _b.client) == null ? void 0 : _c.errorPolicy;
711
+ const token = this.configManager.config?.token;
712
+ const errorPolicy = this.configManager.config?.client?.errorPolicy;
716
713
  const apiURL = this.getApiURL();
717
714
  const clientString = `import { createClient } from "tinacms/dist/client";
718
715
  import { queries } from "./types";
@@ -778,12 +775,25 @@ var unlinkIfExists = async (filepath) => {
778
775
 
779
776
  // src/next/config-manager.ts
780
777
  var import_fs_extra2 = __toESM(require("fs-extra"));
781
- var import_path2 = __toESM(require("path"));
778
+ var import_path3 = __toESM(require("path"));
782
779
  var import_os = __toESM(require("os"));
783
780
  var esbuild = __toESM(require("esbuild"));
784
781
  var dotenv = __toESM(require("dotenv"));
785
782
  var import_normalize_path2 = __toESM(require("normalize-path"));
786
783
  var import_chalk3 = __toESM(require("chalk"));
784
+
785
+ // src/utils/path.ts
786
+ var import_path2 = __toESM(require("path"));
787
+ function stripNativeTrailingSlash(p) {
788
+ const { root } = import_path2.default.parse(p);
789
+ let str = p;
790
+ while (str.length > root.length && str.endsWith(import_path2.default.sep)) {
791
+ str = str.slice(0, -1);
792
+ }
793
+ return str;
794
+ }
795
+
796
+ // src/next/config-manager.ts
787
797
  var TINA_FOLDER = "tina";
788
798
  var LEGACY_TINA_FOLDER = ".tina";
789
799
  var GENERATED_FOLDER = "__generated__";
@@ -802,7 +812,7 @@ var ConfigManager = class {
802
812
  this.legacyNoSDK = legacyNoSDK;
803
813
  }
804
814
  isUsingTs() {
805
- return [".ts", ".tsx"].includes(import_path2.default.extname(this.tinaConfigFilePath));
815
+ return [".ts", ".tsx"].includes(import_path3.default.extname(this.tinaConfigFilePath));
806
816
  }
807
817
  hasSelfHostedConfig() {
808
818
  return !!this.selfHostedDatabaseFilePath;
@@ -811,20 +821,19 @@ var ConfigManager = class {
811
821
  return this.rootPath !== this.contentRootPath;
812
822
  }
813
823
  shouldSkipSDK() {
814
- var _a;
815
824
  if (this.legacyNoSDK) {
816
825
  return this.legacyNoSDK;
817
826
  }
818
- return ((_a = this.config.client) == null ? void 0 : _a.skip) || false;
827
+ return this.config.client?.skip || false;
819
828
  }
820
829
  async processConfig() {
821
830
  this.tinaFolderPath = await this.getTinaFolderPath(this.rootPath);
822
- this.envFilePath = import_path2.default.resolve(
823
- import_path2.default.join(this.tinaFolderPath, "..", ".env")
831
+ this.envFilePath = import_path3.default.resolve(
832
+ import_path3.default.join(this.tinaFolderPath, "..", ".env")
824
833
  );
825
834
  dotenv.config({ path: this.envFilePath });
826
835
  this.tinaConfigFilePath = await this.getPathWithExtension(
827
- import_path2.default.join(this.tinaFolderPath, "config")
836
+ import_path3.default.join(this.tinaFolderPath, "config")
828
837
  );
829
838
  if (!this.tinaConfigFilePath) {
830
839
  throw new Error(
@@ -832,79 +841,79 @@ var ConfigManager = class {
832
841
  );
833
842
  }
834
843
  this.selfHostedDatabaseFilePath = await this.getPathWithExtension(
835
- import_path2.default.join(this.tinaFolderPath, "database")
844
+ import_path3.default.join(this.tinaFolderPath, "database")
836
845
  );
837
- this.generatedFolderPath = import_path2.default.join(this.tinaFolderPath, GENERATED_FOLDER);
838
- this.generatedCachePath = import_path2.default.join(
846
+ this.generatedFolderPath = import_path3.default.join(this.tinaFolderPath, GENERATED_FOLDER);
847
+ this.generatedCachePath = import_path3.default.join(
839
848
  this.generatedFolderPath,
840
849
  ".cache",
841
850
  String((/* @__PURE__ */ new Date()).getTime())
842
851
  );
843
- this.generatedGraphQLGQLPath = import_path2.default.join(
852
+ this.generatedGraphQLGQLPath = import_path3.default.join(
844
853
  this.generatedFolderPath,
845
854
  GRAPHQL_GQL_FILE
846
855
  );
847
- this.generatedGraphQLJSONPath = import_path2.default.join(
856
+ this.generatedGraphQLJSONPath = import_path3.default.join(
848
857
  this.generatedFolderPath,
849
858
  GRAPHQL_JSON_FILE
850
859
  );
851
- this.generatedSchemaJSONPath = import_path2.default.join(
860
+ this.generatedSchemaJSONPath = import_path3.default.join(
852
861
  this.generatedFolderPath,
853
862
  SCHEMA_JSON_FILE
854
863
  );
855
- this.generatedLookupJSONPath = import_path2.default.join(
864
+ this.generatedLookupJSONPath = import_path3.default.join(
856
865
  this.generatedFolderPath,
857
866
  LOOKUP_JSON_FILE
858
867
  );
859
- this.generatedQueriesFilePath = import_path2.default.join(
868
+ this.generatedQueriesFilePath = import_path3.default.join(
860
869
  this.generatedFolderPath,
861
870
  "queries.gql"
862
871
  );
863
- this.generatedFragmentsFilePath = import_path2.default.join(
872
+ this.generatedFragmentsFilePath = import_path3.default.join(
864
873
  this.generatedFolderPath,
865
874
  "frags.gql"
866
875
  );
867
- this.generatedTypesTSFilePath = import_path2.default.join(
876
+ this.generatedTypesTSFilePath = import_path3.default.join(
868
877
  this.generatedFolderPath,
869
878
  "types.ts"
870
879
  );
871
- this.generatedTypesJSFilePath = import_path2.default.join(
880
+ this.generatedTypesJSFilePath = import_path3.default.join(
872
881
  this.generatedFolderPath,
873
882
  "types.js"
874
883
  );
875
- this.generatedTypesDFilePath = import_path2.default.join(
884
+ this.generatedTypesDFilePath = import_path3.default.join(
876
885
  this.generatedFolderPath,
877
886
  "types.d.ts"
878
887
  );
879
- this.userQueriesAndFragmentsGlob = import_path2.default.join(
888
+ this.userQueriesAndFragmentsGlob = import_path3.default.join(
880
889
  this.tinaFolderPath,
881
890
  "queries/**/*.{graphql,gql}"
882
891
  );
883
- this.generatedQueriesAndFragmentsGlob = import_path2.default.join(
892
+ this.generatedQueriesAndFragmentsGlob = import_path3.default.join(
884
893
  this.generatedFolderPath,
885
894
  "*.{graphql,gql}"
886
895
  );
887
- this.generatedClientTSFilePath = import_path2.default.join(
896
+ this.generatedClientTSFilePath = import_path3.default.join(
888
897
  this.generatedFolderPath,
889
898
  "client.ts"
890
899
  );
891
- this.generatedClientJSFilePath = import_path2.default.join(
900
+ this.generatedClientJSFilePath = import_path3.default.join(
892
901
  this.generatedFolderPath,
893
902
  "client.js"
894
903
  );
895
- this.generatedClientDFilePath = import_path2.default.join(
904
+ this.generatedClientDFilePath = import_path3.default.join(
896
905
  this.generatedFolderPath,
897
906
  "client.d.ts"
898
907
  );
899
- this.generatedDatabaseClientDFilePath = import_path2.default.join(
908
+ this.generatedDatabaseClientDFilePath = import_path3.default.join(
900
909
  this.generatedFolderPath,
901
910
  "databaseClient.d.ts"
902
911
  );
903
- this.generatedDatabaseClientTSFilePath = import_path2.default.join(
912
+ this.generatedDatabaseClientTSFilePath = import_path3.default.join(
904
913
  this.generatedFolderPath,
905
914
  "databaseClient.ts"
906
915
  );
907
- this.generatedDatabaseClientJSFilePath = import_path2.default.join(
916
+ this.generatedDatabaseClientJSFilePath = import_path3.default.join(
908
917
  this.generatedFolderPath,
909
918
  "databaseClient.js"
910
919
  );
@@ -924,19 +933,18 @@ var ConfigManager = class {
924
933
  this.watchList = watchList;
925
934
  this.config = config2;
926
935
  this.prebuildFilePath = prebuildPath;
927
- this.publicFolderPath = import_path2.default.join(
936
+ this.publicFolderPath = import_path3.default.join(
928
937
  this.rootPath,
929
938
  this.config.build.publicFolder
930
939
  );
931
- this.outputFolderPath = import_path2.default.join(
940
+ this.outputFolderPath = import_path3.default.join(
932
941
  this.publicFolderPath,
933
942
  this.config.build.outputFolder
934
943
  );
935
- this.outputHTMLFilePath = import_path2.default.join(this.outputFolderPath, "index.html");
936
- this.outputGitignorePath = import_path2.default.join(this.outputFolderPath, ".gitignore");
937
- const fullLocalContentPath = import_path2.default.join(
938
- this.tinaFolderPath,
939
- this.config.localContentPath || ""
944
+ this.outputHTMLFilePath = import_path3.default.join(this.outputFolderPath, "index.html");
945
+ this.outputGitignorePath = import_path3.default.join(this.outputFolderPath, ".gitignore");
946
+ const fullLocalContentPath = stripNativeTrailingSlash(
947
+ import_path3.default.join(this.tinaFolderPath, this.config.localContentPath || "")
940
948
  );
941
949
  if (this.config.localContentPath) {
942
950
  const localContentPathExists = await import_fs_extra2.default.pathExists(fullLocalContentPath);
@@ -956,21 +964,21 @@ var ConfigManager = class {
956
964
  if (!this.contentRootPath) {
957
965
  this.contentRootPath = this.rootPath;
958
966
  }
959
- this.generatedFolderPathContentRepo = import_path2.default.join(
967
+ this.generatedFolderPathContentRepo = import_path3.default.join(
960
968
  await this.getTinaFolderPath(this.contentRootPath),
961
969
  GENERATED_FOLDER
962
970
  );
963
971
  this.spaMainPath = require.resolve("@tinacms/app");
964
- this.spaRootPath = import_path2.default.join(this.spaMainPath, "..", "..");
972
+ this.spaRootPath = import_path3.default.join(this.spaMainPath, "..", "..");
965
973
  }
966
974
  async getTinaFolderPath(rootPath) {
967
- const tinaFolderPath = import_path2.default.join(rootPath, TINA_FOLDER);
975
+ const tinaFolderPath = import_path3.default.join(rootPath, TINA_FOLDER);
968
976
  const tinaFolderExists = await import_fs_extra2.default.pathExists(tinaFolderPath);
969
977
  if (tinaFolderExists) {
970
978
  this.isUsingLegacyFolder = false;
971
979
  return tinaFolderPath;
972
980
  }
973
- const legacyFolderPath = import_path2.default.join(rootPath, LEGACY_TINA_FOLDER);
981
+ const legacyFolderPath = import_path3.default.join(rootPath, LEGACY_TINA_FOLDER);
974
982
  const legacyFolderExists = await import_fs_extra2.default.pathExists(legacyFolderPath);
975
983
  if (legacyFolderExists) {
976
984
  this.isUsingLegacyFolder = true;
@@ -991,7 +999,7 @@ var ConfigManager = class {
991
999
  };
992
1000
  }
993
1001
  const generatedSchema = import_fs_extra2.default.readJSONSync(this.generatedSchemaJSONPath);
994
- if (!generatedSchema || !(typeof (generatedSchema == null ? void 0 : generatedSchema.version) !== "undefined")) {
1002
+ if (!generatedSchema || !(typeof generatedSchema?.version !== "undefined")) {
995
1003
  throw new Error(
996
1004
  `Can not find Tina GraphQL version in ${this.generatedSchemaJSONPath}`
997
1005
  );
@@ -1046,8 +1054,8 @@ var ConfigManager = class {
1046
1054
  return result;
1047
1055
  }
1048
1056
  async loadDatabaseFile() {
1049
- const tmpdir = import_path2.default.join(import_os.default.tmpdir(), Date.now().toString());
1050
- const outfile = import_path2.default.join(tmpdir, "database.build.js");
1057
+ const tmpdir = import_path3.default.join(import_os.default.tmpdir(), Date.now().toString());
1058
+ const outfile = import_path3.default.join(tmpdir, "database.build.js");
1051
1059
  await esbuild.build({
1052
1060
  entryPoints: [this.selfHostedDatabaseFilePath],
1053
1061
  bundle: true,
@@ -1060,14 +1068,14 @@ var ConfigManager = class {
1060
1068
  return result.default;
1061
1069
  }
1062
1070
  async loadConfigFile(generatedFolderPath, configFilePath) {
1063
- const tmpdir = import_path2.default.join(import_os.default.tmpdir(), Date.now().toString());
1064
- const preBuildConfigPath = import_path2.default.join(
1071
+ const tmpdir = import_path3.default.join(import_os.default.tmpdir(), Date.now().toString());
1072
+ const preBuildConfigPath = import_path3.default.join(
1065
1073
  this.generatedFolderPath,
1066
1074
  "config.prebuild.jsx"
1067
1075
  );
1068
- const outfile = import_path2.default.join(tmpdir, "config.build.jsx");
1069
- const outfile2 = import_path2.default.join(tmpdir, "config.build.js");
1070
- const tempTSConfigFile = import_path2.default.join(tmpdir, "tsconfig.json");
1076
+ const outfile = import_path3.default.join(tmpdir, "config.build.jsx");
1077
+ const outfile2 = import_path3.default.join(tmpdir, "config.build.js");
1078
+ const tempTSConfigFile = import_path3.default.join(tmpdir, "tsconfig.json");
1071
1079
  import_fs_extra2.default.outputFileSync(tempTSConfigFile, "{}");
1072
1080
  const result2 = await esbuild.build({
1073
1081
  entryPoints: [configFilePath],
@@ -1168,7 +1176,7 @@ var createDBServer = (port) => {
1168
1176
  });
1169
1177
  });
1170
1178
  dbServer.once("error", (err) => {
1171
- if ((err == null ? void 0 : err.code) === "EADDRINUSE") {
1179
+ if (err?.code === "EADDRINUSE") {
1172
1180
  throw new Error(
1173
1181
  `Tina Dev server is already in use. Datalayer server is busy on port ${port}`
1174
1182
  );
@@ -1319,7 +1327,6 @@ var BaseCommand = class extends import_clipanion.Command {
1319
1327
  const warnings = [];
1320
1328
  await spin({
1321
1329
  waitFor: async () => {
1322
- var _a, _b;
1323
1330
  const rootPath = configManager.rootPath;
1324
1331
  let sha;
1325
1332
  try {
@@ -1344,7 +1351,7 @@ var BaseCommand = class extends import_clipanion.Command {
1344
1351
  }
1345
1352
  for (const collection of tinaSchema.getCollections()) {
1346
1353
  pathFilter[collection.path] = {
1347
- matches: ((_a = collection.match) == null ? void 0 : _a.exclude) || ((_b = collection.match) == null ? void 0 : _b.include) ? tinaSchema.getMatches({ collection }) : void 0
1354
+ matches: collection.match?.exclude || collection.match?.include ? tinaSchema.getMatches({ collection }) : void 0
1348
1355
  };
1349
1356
  }
1350
1357
  const { added, modified, deleted } = await (0, import_graphql8.getChangedFiles)({
@@ -1355,7 +1362,7 @@ var BaseCommand = class extends import_clipanion.Command {
1355
1362
  pathFilter
1356
1363
  });
1357
1364
  const tinaPathUpdates = modified.filter(
1358
- (path14) => path14.startsWith(".tina/__generated__/_schema.json") || path14.startsWith("tina/tina-lock.json")
1365
+ (path15) => path15.startsWith(".tina/__generated__/_schema.json") || path15.startsWith("tina/tina-lock.json")
1359
1366
  );
1360
1367
  if (tinaPathUpdates.length > 0) {
1361
1368
  res = await database.indexContent({
@@ -1379,7 +1386,7 @@ var BaseCommand = class extends import_clipanion.Command {
1379
1386
  if (sha) {
1380
1387
  await database.setMetadata("lastSha", sha);
1381
1388
  }
1382
- if (res == null ? void 0 : res.warnings) {
1389
+ if (res?.warnings) {
1383
1390
  warnings.push(...res.warnings);
1384
1391
  }
1385
1392
  },
@@ -1433,7 +1440,7 @@ var errorHTML = `<style type="text/css">
1433
1440
  the assets for this page.
1434
1441
  </p>
1435
1442
  <p>
1436
- Please visit <a href="https://tina.io/docs/tina-cloud/faq/#how-do-i-resolve-failed-loading-tinacms-assets-error">this doc</a> for help.
1443
+ Please visit <a href="https://tina.io/docs/r/FAQ/#13-how-do-i-resolve-failed-loading-tinacms-assets-error">this doc</a> for help.
1437
1444
  </p>
1438
1445
  </div>
1439
1446
  </div>`.trim().replace(/[\r\n\s]+/g, " ");
@@ -1474,14 +1481,14 @@ var devHTML = (port) => `<!DOCTYPE html>
1474
1481
  var import_vite3 = require("vite");
1475
1482
 
1476
1483
  // src/next/vite/index.ts
1477
- var import_node_path2 = __toESM(require("path"));
1484
+ var import_node_path2 = __toESM(require("node:path"));
1478
1485
  var import_plugin_react = __toESM(require("@vitejs/plugin-react"));
1479
1486
  var import_fs_extra4 = __toESM(require("fs-extra"));
1480
1487
  var import_normalize_path3 = __toESM(require("normalize-path"));
1481
1488
  var import_vite = require("vite");
1482
1489
 
1483
1490
  // src/next/vite/tailwind.ts
1484
- var import_node_path = __toESM(require("path"));
1491
+ var import_node_path = __toESM(require("node:path"));
1485
1492
  var import_aspect_ratio = __toESM(require("@tailwindcss/aspect-ratio"));
1486
1493
  var import_container_queries = __toESM(require("@tailwindcss/container-queries"));
1487
1494
  var import_typography = __toESM(require("@tailwindcss/typography"));
@@ -1686,6 +1693,9 @@ var tinaTailwind = (spaPath, prebuildFilePath) => {
1686
1693
  500: "#EC4815",
1687
1694
  600: "#DC4419"
1688
1695
  },
1696
+ "tina-orange": "#EC4815",
1697
+ "tina-orange-dark": "#C2410C",
1698
+ "tina-orange-light": "#FFF7ED",
1689
1699
  background: "#FFFFFF",
1690
1700
  foreground: "#0A0A0A",
1691
1701
  muted: "#F5F5F5",
@@ -1807,7 +1817,6 @@ var createConfig = async ({
1807
1817
  noWatch,
1808
1818
  rollupOptions
1809
1819
  }) => {
1810
- var _a, _b, _c, _d, _e, _f, _g, _h;
1811
1820
  const publicEnv = {};
1812
1821
  Object.keys(process.env).forEach((key) => {
1813
1822
  if (key.startsWith("TINA_PUBLIC_") || key.startsWith("NEXT_PUBLIC_") || key === "NODE_ENV" || key === "HEAD") {
@@ -1829,9 +1838,9 @@ var createConfig = async ({
1829
1838
  configManager.generatedFolderPath,
1830
1839
  "static-media.json"
1831
1840
  );
1832
- if ((_b = (_a = configManager.config.media) == null ? void 0 : _a.tina) == null ? void 0 : _b.static) {
1841
+ if (configManager.config.media?.tina?.static) {
1833
1842
  const staticMedia = await listFilesRecursively({
1834
- directoryPath: ((_c = configManager.config.media.tina) == null ? void 0 : _c.mediaRoot) || "",
1843
+ directoryPath: configManager.config.media.tina?.mediaRoot || "",
1835
1844
  config: configManager.config.media.tina,
1836
1845
  roothPath: configManager.rootPath
1837
1846
  });
@@ -1892,7 +1901,7 @@ var createConfig = async ({
1892
1901
  // Used by picomatch https://github.com/micromatch/picomatch/blob/master/lib/utils.js#L4
1893
1902
  "process.platform": `"${process.platform}"`,
1894
1903
  __API_URL__: `"${apiURL}"`,
1895
- __BASE_PATH__: `"${((_e = (_d = configManager.config) == null ? void 0 : _d.build) == null ? void 0 : _e.basePath) || ""}"`,
1904
+ __BASE_PATH__: `"${configManager.config?.build?.basePath || ""}"`,
1896
1905
  __TINA_GRAPHQL_VERSION__: version2
1897
1906
  },
1898
1907
  logLevel: "error",
@@ -1904,7 +1913,7 @@ var createConfig = async ({
1904
1913
  include: ["react/jsx-runtime", "react/jsx-dev-runtime"]
1905
1914
  },
1906
1915
  server: {
1907
- host: (_h = (_g = (_f = configManager.config) == null ? void 0 : _f.build) == null ? void 0 : _g.host) != null ? _h : false,
1916
+ host: configManager.config?.build?.host ?? false,
1908
1917
  watch: noWatch ? {
1909
1918
  ignored: ["**/*"]
1910
1919
  } : {
@@ -1932,7 +1941,8 @@ var createConfig = async ({
1932
1941
  babel: {
1933
1942
  // Supresses the warning [NOTE] babel The code generator has deoptimised the styling of
1934
1943
  compact: true
1935
- }
1944
+ },
1945
+ fastRefresh: false
1936
1946
  }),
1937
1947
  (0, import_vite.splitVendorChunkPlugin)(),
1938
1948
  tinaTailwind(configManager.spaRootPath, configManager.prebuildFilePath),
@@ -1947,17 +1957,17 @@ var import_pluginutils = require("@rollup/pluginutils");
1947
1957
  var import_fs = __toESM(require("fs"));
1948
1958
  var import_vite2 = require("vite");
1949
1959
  var import_esbuild2 = require("esbuild");
1950
- var import_path4 = __toESM(require("path"));
1960
+ var import_path6 = __toESM(require("path"));
1951
1961
  var import_body_parser = __toESM(require("body-parser"));
1952
1962
  var import_cors = __toESM(require("cors"));
1953
1963
  var import_graphql9 = require("@tinacms/graphql");
1954
1964
 
1955
1965
  // src/next/commands/dev-command/server/media.ts
1956
1966
  var import_fs_extra5 = __toESM(require("fs-extra"));
1957
- var import_path3 = __toESM(require("path"));
1967
+ var import_path5 = __toESM(require("path"));
1958
1968
  var import_busboy = __toESM(require("busboy"));
1959
1969
  var createMediaRouter = (config2) => {
1960
- const mediaFolder = import_path3.default.join(
1970
+ const mediaFolder = import_path5.default.join(
1961
1971
  config2.rootPath,
1962
1972
  config2.publicFolder,
1963
1973
  config2.mediaRoot
@@ -1983,10 +1993,9 @@ var createMediaRouter = (config2) => {
1983
1993
  const handlePost = async function(req, res) {
1984
1994
  const bb = (0, import_busboy.default)({ headers: req.headers });
1985
1995
  bb.on("file", async (_name, file, _info) => {
1986
- var _a;
1987
- const fullPath = decodeURI((_a = req.url) == null ? void 0 : _a.slice("/media/upload/".length));
1988
- const saveTo = import_path3.default.join(mediaFolder, ...fullPath.split("/"));
1989
- await import_fs_extra5.default.ensureDir(import_path3.default.dirname(saveTo));
1996
+ const fullPath = decodeURI(req.url?.slice("/media/upload/".length));
1997
+ const saveTo = import_path5.default.join(mediaFolder, ...fullPath.split("/"));
1998
+ await import_fs_extra5.default.ensureDir(import_path5.default.dirname(saveTo));
1990
1999
  file.pipe(import_fs_extra5.default.createWriteStream(saveTo));
1991
2000
  });
1992
2001
  bb.on("error", (error) => {
@@ -2020,7 +2029,7 @@ var MediaModel = class {
2020
2029
  }
2021
2030
  async listMedia(args) {
2022
2031
  try {
2023
- const folderPath = (0, import_path3.join)(
2032
+ const folderPath = (0, import_path5.join)(
2024
2033
  this.rootPath,
2025
2034
  this.publicFolder,
2026
2035
  this.mediaRoot,
@@ -2035,7 +2044,7 @@ var MediaModel = class {
2035
2044
  }
2036
2045
  const filesStr = await import_fs_extra5.default.readdir(folderPath);
2037
2046
  const filesProm = filesStr.map(async (file) => {
2038
- const filePath = (0, import_path3.join)(folderPath, file);
2047
+ const filePath = (0, import_path5.join)(folderPath, file);
2039
2048
  const stat = await import_fs_extra5.default.stat(filePath);
2040
2049
  let src = `/${file}`;
2041
2050
  const isFile = stat.isFile();
@@ -2086,13 +2095,13 @@ var MediaModel = class {
2086
2095
  return {
2087
2096
  files: [],
2088
2097
  directories: [],
2089
- error: error == null ? void 0 : error.toString()
2098
+ error: error?.toString()
2090
2099
  };
2091
2100
  }
2092
2101
  }
2093
2102
  async deleteMedia(args) {
2094
2103
  try {
2095
- const file = (0, import_path3.join)(
2104
+ const file = (0, import_path5.join)(
2096
2105
  this.rootPath,
2097
2106
  this.publicFolder,
2098
2107
  this.mediaRoot,
@@ -2103,7 +2112,7 @@ var MediaModel = class {
2103
2112
  return { ok: true };
2104
2113
  } catch (error) {
2105
2114
  console.error(error);
2106
- return { ok: false, message: error == null ? void 0 : error.toString() };
2115
+ return { ok: false, message: error?.toString() };
2107
2116
  }
2108
2117
  }
2109
2118
  };
@@ -2157,7 +2166,7 @@ var transformTsxPlugin = ({
2157
2166
  const plug = {
2158
2167
  name: "transform-tsx",
2159
2168
  async transform(code, id) {
2160
- const extName = import_path4.default.extname(id);
2169
+ const extName = import_path6.default.extname(id);
2161
2170
  if (extName.startsWith(".tsx") || extName.startsWith(".ts")) {
2162
2171
  const result = await (0, import_esbuild2.transform)(code, { loader: "tsx" });
2163
2172
  return {
@@ -2181,13 +2190,12 @@ var devServerEndPointsPlugin = ({
2181
2190
  server.middlewares.use((0, import_cors.default)());
2182
2191
  server.middlewares.use(import_body_parser.default.json({ limit: "5mb" }));
2183
2192
  server.middlewares.use(async (req, res, next) => {
2184
- var _a;
2185
- const mediaPaths = (_a = configManager.config.media) == null ? void 0 : _a.tina;
2193
+ const mediaPaths = configManager.config.media?.tina;
2186
2194
  const mediaRouter = createMediaRouter({
2187
2195
  rootPath: configManager.rootPath,
2188
2196
  apiURL,
2189
- publicFolder: parseMediaFolder((mediaPaths == null ? void 0 : mediaPaths.publicFolder) || ""),
2190
- mediaRoot: parseMediaFolder((mediaPaths == null ? void 0 : mediaPaths.mediaRoot) || "")
2197
+ publicFolder: parseMediaFolder(mediaPaths?.publicFolder || ""),
2198
+ mediaRoot: parseMediaFolder(mediaPaths?.mediaRoot || "")
2191
2199
  });
2192
2200
  const searchIndexRouter = createSearchIndexRouter({
2193
2201
  config: { apiURL, searchPath: "searchIndex" },
@@ -2260,7 +2268,7 @@ function viteTransformExtension({
2260
2268
  name: "vite-plugin-svgr",
2261
2269
  async transform(code, id) {
2262
2270
  if (filter(id)) {
2263
- const { transform: transform2 } = await Promise.resolve().then(() => __toESM(require("@svgr/core")));
2271
+ const { transform: transform2 } = await import("@svgr/core");
2264
2272
  const svgCode = await import_fs.default.promises.readFile(
2265
2273
  id.replace(/\?.*$/, ""),
2266
2274
  "utf8"
@@ -2345,6 +2353,20 @@ var DevCommand = class extends BaseCommand {
2345
2353
  });
2346
2354
  this.indexingLock = new import_async_lock.default();
2347
2355
  }
2356
+ static {
2357
+ this.paths = [["dev"], ["server:start"]];
2358
+ }
2359
+ static {
2360
+ // Prevent indexes and reads occurring at once
2361
+ this.usage = import_clipanion2.Command.Usage({
2362
+ category: `Commands`,
2363
+ description: `Builds Tina and starts the dev server`,
2364
+ examples: [
2365
+ [`A basic example`, `$0 dev`],
2366
+ [`A second example`, `$0 dev --rootPath`]
2367
+ ]
2368
+ });
2369
+ }
2348
2370
  async catch(error) {
2349
2371
  logger.error("Error occured during tinacms dev");
2350
2372
  console.error(error);
@@ -2359,7 +2381,6 @@ var DevCommand = class extends BaseCommand {
2359
2381
  }
2360
2382
  }
2361
2383
  async execute() {
2362
- var _a, _b, _c, _d, _e, _f;
2363
2384
  const configManager = new ConfigManager({
2364
2385
  rootPath: this.rootPath,
2365
2386
  legacyNoSDK: this.noSDK
@@ -2409,14 +2430,14 @@ var DevCommand = class extends BaseCommand {
2409
2430
  graphql: graphqlSchemaObject
2410
2431
  });
2411
2432
  import_fs_extra6.default.writeFileSync(
2412
- import_path5.default.join(configManager.tinaFolderPath, tinaLockFilename),
2433
+ import_path7.default.join(configManager.tinaFolderPath, tinaLockFilename),
2413
2434
  tinaLockContent
2414
2435
  );
2415
2436
  if (configManager.hasSeparateContentRoot()) {
2416
2437
  const rootPath = await configManager.getTinaFolderPath(
2417
2438
  configManager.contentRootPath
2418
2439
  );
2419
- const filePath = import_path5.default.join(rootPath, tinaLockFilename);
2440
+ const filePath = import_path7.default.join(rootPath, tinaLockFilename);
2420
2441
  await import_fs_extra6.default.ensureFile(filePath);
2421
2442
  await import_fs_extra6.default.outputFile(filePath, tinaLockContent);
2422
2443
  }
@@ -2467,19 +2488,19 @@ ${dangerText(e.message)}
2467
2488
  "index.html\nassets/"
2468
2489
  );
2469
2490
  const searchIndexClient = new import_search.LocalSearchIndexClient({
2470
- stopwordLanguages: (_b = (_a = configManager.config.search) == null ? void 0 : _a.tina) == null ? void 0 : _b.stopwordLanguages,
2471
- tokenSplitRegex: (_d = (_c = configManager.config.search) == null ? void 0 : _c.tina) == null ? void 0 : _d.tokenSplitRegex
2491
+ stopwordLanguages: configManager.config.search?.tina?.stopwordLanguages,
2492
+ tokenSplitRegex: configManager.config.search?.tina?.tokenSplitRegex
2472
2493
  });
2473
2494
  await searchIndexClient.onStartIndexing();
2474
2495
  const searchIndexer = new import_search.SearchIndexer({
2475
- batchSize: ((_e = configManager.config.search) == null ? void 0 : _e.indexBatchSize) || 100,
2496
+ batchSize: configManager.config.search?.indexBatchSize || 100,
2476
2497
  bridge: new import_graphql10.FilesystemBridge(
2477
2498
  configManager.rootPath,
2478
2499
  configManager.contentRootPath
2479
2500
  ),
2480
2501
  schema: tinaSchema,
2481
2502
  client: searchIndexClient,
2482
- textIndexLength: ((_f = configManager.config.search) == null ? void 0 : _f.maxSearchIndexFieldLength) || 100
2503
+ textIndexLength: configManager.config.search?.maxSearchIndexFieldLength || 100
2483
2504
  });
2484
2505
  if (configManager.config.search) {
2485
2506
  await spin({
@@ -2576,11 +2597,11 @@ ${dangerText(e.message)}
2576
2597
  // subItems: [
2577
2598
  // {
2578
2599
  // key: 'Custom queries',
2579
- // value: 'https://tina.io/querying',
2600
+ // value: 'https://tina.io/docs/r/content-api-overview',
2580
2601
  // },
2581
2602
  // {
2582
2603
  // key: 'Visual editing',
2583
- // value: 'https://tina.io/visual-editing',
2604
+ // value: 'https://tina.io/docs/r/visual-editing-setup',
2584
2605
  // },
2585
2606
  // ],
2586
2607
  // },
@@ -2591,7 +2612,7 @@ ${dangerText(e.message)}
2591
2612
  watchContentFiles(configManager, database, databaseLock, searchIndexer) {
2592
2613
  const collectionContentFiles = [];
2593
2614
  configManager.config.schema.collections.forEach((collection) => {
2594
- const collectionGlob = `${import_path5.default.join(
2615
+ const collectionGlob = `${import_path7.default.join(
2595
2616
  configManager.contentRootPath,
2596
2617
  collection.path
2597
2618
  )}/**/*.${collection.format || "md"}`;
@@ -2638,20 +2659,10 @@ ${dangerText(e.message)}
2638
2659
  import_chokidar.default.watch(configManager.userQueriesAndFragmentsGlob).on("add", executeCallback).on("change", executeCallback).on("unlink", executeCallback);
2639
2660
  }
2640
2661
  };
2641
- DevCommand.paths = [["dev"], ["server:start"]];
2642
- // Prevent indexes and reads occurring at once
2643
- DevCommand.usage = import_clipanion2.Command.Usage({
2644
- category: `Commands`,
2645
- description: `Builds Tina and starts the dev server`,
2646
- examples: [
2647
- [`A basic example`, `$0 dev`],
2648
- [`A second example`, `$0 dev --rootPath`]
2649
- ]
2650
- });
2651
2662
 
2652
2663
  // src/next/commands/build-command/index.ts
2653
2664
  var import_crypto = __toESM(require("crypto"));
2654
- var import_path6 = __toESM(require("path"));
2665
+ var import_path8 = __toESM(require("path"));
2655
2666
  var import_core3 = require("@graphql-inspector/core");
2656
2667
  var import_graphql11 = require("@tinacms/graphql");
2657
2668
  var import_schema_tools2 = require("@tinacms/schema-tools");
@@ -2666,7 +2677,7 @@ var import_core2 = require("@graphql-inspector/core");
2666
2677
  var getFaqLink = (type) => {
2667
2678
  switch (type) {
2668
2679
  case import_core2.ChangeType.FieldRemoved: {
2669
- return "https://tina.io/docs/introduction/faq#how-do-i-resolve-the-local-graphql-schema-doesnt-match-the-remote-graphql-schema-errors";
2680
+ return "https://tina.io/docs/r/FAQ/#2-how-do-i-resolve-the-local-graphql-schema-doesnt-match-the-remote-graphql-schema-error";
2670
2681
  }
2671
2682
  default:
2672
2683
  return null;
@@ -2845,12 +2856,20 @@ var BuildCommand = class extends BaseCommand {
2845
2856
  description: "Disables the client build cache"
2846
2857
  });
2847
2858
  }
2859
+ static {
2860
+ this.paths = [["build"]];
2861
+ }
2862
+ static {
2863
+ this.usage = import_clipanion3.Command.Usage({
2864
+ category: `Commands`,
2865
+ description: `Build the CMS and autogenerated modules for usage with TinaCloud`
2866
+ });
2867
+ }
2848
2868
  async catch(error) {
2849
2869
  console.error(error);
2850
2870
  process.exit(1);
2851
2871
  }
2852
2872
  async execute() {
2853
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
2854
2873
  logger.info("Starting Tina build");
2855
2874
  this.logDeprecationWarnings();
2856
2875
  const configManager = new ConfigManager({
@@ -2939,45 +2958,63 @@ ${dangerText(e.message)}
2939
2958
  }
2940
2959
  const skipCloudChecks = this.skipCloudChecks || configManager.hasSelfHostedConfig();
2941
2960
  if (!skipCloudChecks) {
2942
- const { hasUpstream, timestamp } = await this.checkClientInfo(
2943
- configManager,
2944
- codegen2.productionUrl,
2945
- this.previewBaseBranch
2946
- );
2947
- if (!hasUpstream && this.upstreamBranch) {
2948
- logger.warn(
2949
- `${dangerText(
2950
- `WARN: Upstream branch '${this.upstreamBranch}' specified but no upstream project was found.`
2951
- )}`
2961
+ try {
2962
+ const clientInfo = await this.checkClientInfo(
2963
+ configManager,
2964
+ codegen2.productionUrl,
2965
+ this.previewBaseBranch
2952
2966
  );
2967
+ if (clientInfo.detectedBotBranch) {
2968
+ logger.warn(
2969
+ `${warnText(
2970
+ `WARN: Detected bot branch. Using schema/content from default branch '${clientInfo.defaultBranch}' instead of '${configManager.config.branch}'.`
2971
+ )}`
2972
+ );
2973
+ }
2974
+ if (!clientInfo.hasUpstream && this.upstreamBranch) {
2975
+ logger.warn(
2976
+ `${dangerText(
2977
+ `WARN: Upstream branch '${this.upstreamBranch}' specified but no upstream project was found.`
2978
+ )}`
2979
+ );
2980
+ }
2981
+ if (clientInfo.hasUpstream || this.previewBaseBranch && this.previewName) {
2982
+ await this.syncProject(configManager, codegen2.productionUrl, {
2983
+ upstreamBranch: this.upstreamBranch,
2984
+ previewBaseBranch: this.previewBaseBranch,
2985
+ previewName: this.previewName
2986
+ });
2987
+ }
2988
+ await waitForDB(
2989
+ configManager.config,
2990
+ codegen2.productionUrl,
2991
+ this.previewName,
2992
+ false
2993
+ );
2994
+ await this.checkGraphqlSchema(
2995
+ configManager,
2996
+ database,
2997
+ codegen2.productionUrl,
2998
+ clientInfo.timestamp
2999
+ );
3000
+ await this.checkTinaSchema(
3001
+ configManager,
3002
+ database,
3003
+ codegen2.productionUrl,
3004
+ this.previewName,
3005
+ this.verbose,
3006
+ clientInfo.timestamp
3007
+ );
3008
+ } catch (e) {
3009
+ logger.error(`
3010
+
3011
+ ${dangerText(e.message)}
3012
+ `);
3013
+ if (this.verbose) {
3014
+ console.error(e);
3015
+ }
3016
+ process.exit(1);
2953
3017
  }
2954
- if (hasUpstream || this.previewBaseBranch && this.previewName) {
2955
- await this.syncProject(configManager, codegen2.productionUrl, {
2956
- upstreamBranch: this.upstreamBranch,
2957
- previewBaseBranch: this.previewBaseBranch,
2958
- previewName: this.previewName
2959
- });
2960
- }
2961
- await waitForDB(
2962
- configManager.config,
2963
- codegen2.productionUrl,
2964
- this.previewName,
2965
- false
2966
- );
2967
- await this.checkGraphqlSchema(
2968
- configManager,
2969
- database,
2970
- codegen2.productionUrl,
2971
- timestamp
2972
- );
2973
- await this.checkTinaSchema(
2974
- configManager,
2975
- database,
2976
- codegen2.productionUrl,
2977
- this.previewName,
2978
- this.verbose,
2979
- timestamp
2980
- );
2981
3018
  }
2982
3019
  await buildProductionSpa(configManager, database, codegen2.productionUrl);
2983
3020
  await import_fs_extra7.default.outputFile(
@@ -2986,9 +3023,9 @@ ${dangerText(e.message)}
2986
3023
  );
2987
3024
  if (configManager.config.search && !this.skipSearchIndex && !this.localOption) {
2988
3025
  let client;
2989
- const hasTinaSearch = Boolean((_b = (_a = configManager.config) == null ? void 0 : _a.search) == null ? void 0 : _b.tina);
3026
+ const hasTinaSearch = Boolean(configManager.config?.search?.tina);
2990
3027
  if (hasTinaSearch) {
2991
- if (!((_c = configManager.config) == null ? void 0 : _c.branch)) {
3028
+ if (!configManager.config?.branch) {
2992
3029
  logger.error(
2993
3030
  `${dangerText(
2994
3031
  `ERROR: Branch not configured in tina search configuration.`
@@ -2998,11 +3035,11 @@ ${dangerText(e.message)}
2998
3035
  "Branch not configured in tina search configuration."
2999
3036
  );
3000
3037
  }
3001
- if (!((_d = configManager.config) == null ? void 0 : _d.clientId)) {
3038
+ if (!configManager.config?.clientId) {
3002
3039
  logger.error(`${dangerText(`ERROR: clientId not configured.`)}`);
3003
3040
  throw new Error("clientId not configured.");
3004
3041
  }
3005
- if (!((_g = (_f = (_e = configManager.config) == null ? void 0 : _e.search) == null ? void 0 : _f.tina) == null ? void 0 : _g.indexerToken)) {
3042
+ if (!configManager.config?.search?.tina?.indexerToken) {
3006
3043
  logger.error(
3007
3044
  `${dangerText(
3008
3045
  `ERROR: indexerToken not configured in tina search configuration.`
@@ -3013,16 +3050,16 @@ ${dangerText(e.message)}
3013
3050
  );
3014
3051
  }
3015
3052
  client = new import_search2.TinaCMSSearchIndexClient({
3016
- apiUrl: `${((_h = configManager.config.tinaioConfig) == null ? void 0 : _h.contentApiUrlOverride) || "https://content.tinajs.io"}/searchIndex/${(_i = configManager.config) == null ? void 0 : _i.clientId}`,
3017
- branch: (_j = configManager.config) == null ? void 0 : _j.branch,
3018
- indexerToken: (_m = (_l = (_k = configManager.config) == null ? void 0 : _k.search) == null ? void 0 : _l.tina) == null ? void 0 : _m.indexerToken,
3019
- stopwordLanguages: (_p = (_o = (_n = configManager.config) == null ? void 0 : _n.search) == null ? void 0 : _o.tina) == null ? void 0 : _p.stopwordLanguages
3053
+ apiUrl: `${configManager.config.tinaioConfig?.contentApiUrlOverride || "https://content.tinajs.io"}/searchIndex/${configManager.config?.clientId}`,
3054
+ branch: configManager.config?.branch,
3055
+ indexerToken: configManager.config?.search?.tina?.indexerToken,
3056
+ stopwordLanguages: configManager.config?.search?.tina?.stopwordLanguages
3020
3057
  });
3021
3058
  } else {
3022
- client = (_r = (_q = configManager.config) == null ? void 0 : _q.search) == null ? void 0 : _r.searchClient;
3059
+ client = configManager.config?.search?.searchClient;
3023
3060
  }
3024
3061
  const searchIndexer = new import_search2.SearchIndexer({
3025
- batchSize: ((_s = configManager.config.search) == null ? void 0 : _s.indexBatchSize) || 100,
3062
+ batchSize: configManager.config.search?.indexBatchSize || 100,
3026
3063
  bridge: new import_graphql11.FilesystemBridge(
3027
3064
  configManager.rootPath,
3028
3065
  configManager.contentRootPath
@@ -3090,86 +3127,88 @@ ${dangerText(e.message)}
3090
3127
  }
3091
3128
  }
3092
3129
  async checkClientInfo(configManager, apiURL, previewBaseBranch) {
3130
+ const MAX_RETRIES = 5;
3093
3131
  const { config: config2 } = configManager;
3094
3132
  const token = config2.token;
3095
3133
  const { clientId, branch, host } = (0, import_schema_tools2.parseURL)(apiURL);
3096
- const url = `https://${host}/db/${clientId}/status/${previewBaseBranch || branch}`;
3097
3134
  const bar2 = new import_progress2.default("Checking clientId and token. :prog", 1);
3098
- let branchKnown = false;
3099
- let hasUpstream = false;
3100
- let timestamp;
3101
- try {
3102
- const res = await request({
3103
- token,
3104
- url
3105
- });
3106
- timestamp = res.timestamp || 0;
3107
- bar2.tick({
3108
- prog: "\u2705"
3109
- });
3110
- if (!(res.status === "unknown")) {
3111
- branchKnown = true;
3112
- }
3113
- if (res.hasUpstream) {
3114
- hasUpstream = true;
3135
+ const getBranchInfo = async () => {
3136
+ const url = `https://${host}/db/${clientId}/status/${previewBaseBranch || branch}`;
3137
+ const branchInfo2 = {
3138
+ status: "unknown",
3139
+ branchKnown: false,
3140
+ hasUpstream: false,
3141
+ timestamp: 0,
3142
+ detectedBotBranch: false,
3143
+ defaultBranch: void 0
3144
+ };
3145
+ try {
3146
+ const res = await request({
3147
+ token,
3148
+ url
3149
+ });
3150
+ branchInfo2.status = res.status;
3151
+ branchInfo2.branchKnown = res.status !== "unknown";
3152
+ branchInfo2.timestamp = res.timestamp || 0;
3153
+ branchInfo2.hasUpstream = res.hasUpstream;
3154
+ branchInfo2.detectedBotBranch = res.json.detectedBotBranch;
3155
+ branchInfo2.defaultBranch = res.json.defaultBranch;
3156
+ } catch (e) {
3157
+ summary({
3158
+ heading: "Error when checking client information",
3159
+ items: [
3160
+ {
3161
+ emoji: "\u274C",
3162
+ heading: "You provided",
3163
+ subItems: [
3164
+ {
3165
+ key: "clientId",
3166
+ value: config2.clientId
3167
+ },
3168
+ {
3169
+ key: "branch",
3170
+ value: config2.branch
3171
+ },
3172
+ {
3173
+ key: "token",
3174
+ value: config2.token
3175
+ }
3176
+ ]
3177
+ }
3178
+ ]
3179
+ });
3180
+ throw e;
3115
3181
  }
3116
- } catch (e) {
3117
- summary({
3118
- heading: "Error when checking client information",
3119
- items: [
3120
- {
3121
- emoji: "\u274C",
3122
- heading: "You provided",
3123
- subItems: [
3124
- {
3125
- key: "clientId",
3126
- value: config2.clientId
3127
- },
3128
- {
3129
- key: "branch",
3130
- value: config2.branch
3131
- },
3132
- {
3133
- key: "token",
3134
- value: config2.token
3135
- }
3136
- ]
3137
- }
3138
- ]
3139
- });
3140
- throw e;
3141
- }
3142
- const branchBar = new import_progress2.default("Checking branch is on TinaCloud. :prog", 1);
3143
- if (branchKnown) {
3182
+ return branchInfo2;
3183
+ };
3184
+ const branchInfo = await getBranchInfo();
3185
+ bar2.tick({
3186
+ prog: "\u2705"
3187
+ });
3188
+ const branchBar = new import_progress2.default(
3189
+ `Checking branch '${config2.branch}' is on TinaCloud. :prog`,
3190
+ 1
3191
+ );
3192
+ if (branchInfo.branchKnown) {
3144
3193
  branchBar.tick({
3145
3194
  prog: "\u2705"
3146
3195
  });
3147
- return {
3148
- hasUpstream,
3149
- timestamp
3150
- };
3196
+ return branchInfo;
3151
3197
  }
3152
- for (let i = 0; i <= 5; i++) {
3153
- await sleepAndCallFunc({
3154
- fn: async () => {
3155
- const res = await request({
3156
- token,
3157
- url
3158
- });
3159
- if (this.verbose) {
3160
- logger.info(
3161
- `Branch status: ${res.status}. Attempt: ${i + 1}. Trying again in 5 seconds.`
3162
- );
3163
- }
3164
- if (!(res.status === "unknown")) {
3165
- branchBar.tick({
3166
- prog: "\u2705"
3167
- });
3168
- return;
3169
- }
3170
- },
3171
- ms: 5e3
3172
- });
3198
+ for (let i = 1; i <= MAX_RETRIES; i++) {
3199
+ await timeout(5e3);
3200
+ const branchInfo2 = await getBranchInfo();
3201
+ if (this.verbose) {
3202
+ logger.info(
3203
+ `Branch status: ${branchInfo2.status}. Attempt: ${i}. Trying again in 5 seconds.`
3204
+ );
3205
+ }
3206
+ if (branchInfo2.branchKnown) {
3207
+ branchBar.tick({
3208
+ prog: "\u2705"
3209
+ });
3210
+ return branchInfo2;
3211
+ }
3173
3212
  }
3174
3213
  branchBar.tick({
3175
3214
  prog: "\u274C"
@@ -3177,7 +3216,7 @@ ${dangerText(e.message)}
3177
3216
  logger.error(
3178
3217
  `${dangerText(
3179
3218
  `ERROR: Branch '${branch}' is not on TinaCloud.`
3180
- )} Please make sure that branch '${branch}' exists in your repository and that you have pushed your all changes to the remote. View all all branches and there current status here: ${linkText(
3219
+ )} Please make sure that branch '${branch}' exists in your repository and that you have pushed your all changes to the remote. View all branches and their current status here: ${linkText(
3181
3220
  `https://app.tina.io/projects/${clientId}/configuration`
3182
3221
  )}`
3183
3222
  );
@@ -3252,7 +3291,7 @@ ${dangerText(e.message)}
3252
3291
  prog: "\u274C"
3253
3292
  });
3254
3293
  let errorMessage = `The remote GraphQL schema does not exist. Check indexing for this branch.`;
3255
- if (config2 == null ? void 0 : config2.branch) {
3294
+ if (config2?.branch) {
3256
3295
  errorMessage += `
3257
3296
 
3258
3297
  Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
@@ -3284,7 +3323,7 @@ Check out '${faqLink}' for possible solutions.`}`;
3284
3323
  Additional info:
3285
3324
 
3286
3325
  `;
3287
- if (config2 == null ? void 0 : config2.branch) {
3326
+ if (config2?.branch) {
3288
3327
  errorMessage += ` Branch: ${config2.branch}, Client ID: ${config2.clientId}
3289
3328
  `;
3290
3329
  }
@@ -3333,7 +3372,7 @@ Additional info:
3333
3372
  prog: "\u274C"
3334
3373
  });
3335
3374
  let errorMessage = `The remote Tina schema does not exist. Check indexing for this branch.`;
3336
- if (config2 == null ? void 0 : config2.branch) {
3375
+ if (config2?.branch) {
3337
3376
  errorMessage += `
3338
3377
 
3339
3378
  Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
@@ -3345,7 +3384,7 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3345
3384
  }
3346
3385
  const localTinaSchema = JSON.parse(
3347
3386
  await database.bridge.get(
3348
- import_path6.default.join(database.tinaDirectory, "__generated__", "_schema.json")
3387
+ import_path8.default.join(database.tinaDirectory, "__generated__", "_schema.json")
3349
3388
  )
3350
3389
  );
3351
3390
  localTinaSchema.version = void 0;
@@ -3364,7 +3403,7 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3364
3403
  Additional info:
3365
3404
 
3366
3405
  `;
3367
- if (config2 == null ? void 0 : config2.branch) {
3406
+ if (config2?.branch) {
3368
3407
  errorMessage += ` Branch: ${config2.branch}, Client ID: ${config2.clientId}
3369
3408
  `;
3370
3409
  }
@@ -3376,18 +3415,13 @@ Additional info:
3376
3415
  }
3377
3416
  }
3378
3417
  };
3379
- BuildCommand.paths = [["build"]];
3380
- BuildCommand.usage = import_clipanion3.Command.Usage({
3381
- category: `Commands`,
3382
- description: `Build the CMS and autogenerated modules for usage with TinaCloud`
3383
- });
3384
3418
  async function request(args) {
3385
3419
  const headers = new Headers();
3386
3420
  if (args.token) {
3387
3421
  headers.append("X-API-KEY", args.token);
3388
3422
  }
3389
3423
  headers.append("Content-Type", "application/json");
3390
- const url = args == null ? void 0 : args.url;
3424
+ const url = args?.url;
3391
3425
  const res = await fetch(url, {
3392
3426
  method: args.method || "GET",
3393
3427
  headers,
@@ -3405,21 +3439,22 @@ async function request(args) {
3405
3439
  Message from server: ${json.message}`;
3406
3440
  }
3407
3441
  throw new Error(
3408
- `Server responded with status code ${res.status}, ${res.statusText}. ${additionalInfo ? additionalInfo : ""} Please see our FAQ for more information: https://tina.io/docs/errors/faq/`
3442
+ `Server responded with status code ${res.status}, ${res.statusText}. ${additionalInfo ? additionalInfo : ""} Please see our FAQ for more information: https://tina.io/docs/r/FAQ/`
3409
3443
  );
3410
3444
  }
3411
3445
  if (json.errors) {
3412
3446
  throw new Error(
3413
- `Unable to fetch, please see our FAQ for more information: https://tina.io/docs/errors/faq/
3447
+ `Unable to fetch, please see our FAQ for more information: https://tina.io/docs/r/FAQ/
3414
3448
 
3415
3449
  Errors:
3416
3450
  ${json.errors.map((error) => error.message).join("\n")}`
3417
3451
  );
3418
3452
  }
3419
3453
  return {
3420
- status: json == null ? void 0 : json.status,
3421
- timestamp: json == null ? void 0 : json.timestamp,
3422
- hasUpstream: (json == null ? void 0 : json.hasUpstream) || false
3454
+ status: json?.status,
3455
+ timestamp: json?.timestamp,
3456
+ hasUpstream: json?.hasUpstream || false,
3457
+ json
3423
3458
  };
3424
3459
  }
3425
3460
  var fetchRemoteGraphqlSchema = async ({
@@ -3442,7 +3477,7 @@ var fetchRemoteGraphqlSchema = async ({
3442
3477
  });
3443
3478
  const data = await res.json();
3444
3479
  return {
3445
- remoteSchema: data == null ? void 0 : data.data,
3480
+ remoteSchema: data?.data,
3446
3481
  remoteRuntimeVersion: res.headers.get("tinacms-grapqhl-version"),
3447
3482
  remoteProjectVersion: res.headers.get("tinacms-graphql-project-version")
3448
3483
  };
@@ -3652,6 +3687,15 @@ var AuditCommand = class extends import_clipanion4.Command {
3652
3687
  description: "Specify a port to run the datalayer server on. (default 9000)"
3653
3688
  });
3654
3689
  }
3690
+ static {
3691
+ this.paths = [["audit"]];
3692
+ }
3693
+ static {
3694
+ this.usage = import_clipanion4.Command.Usage({
3695
+ category: `Commands`,
3696
+ description: `Audit config and content files`
3697
+ });
3698
+ }
3655
3699
  async catch(error) {
3656
3700
  logger.error("Error occured during tinacms audit");
3657
3701
  if (this.verbose) {
@@ -3705,36 +3749,31 @@ var AuditCommand = class extends import_clipanion4.Command {
3705
3749
  process.exit();
3706
3750
  }
3707
3751
  };
3708
- AuditCommand.paths = [["audit"]];
3709
- AuditCommand.usage = import_clipanion4.Command.Usage({
3710
- category: `Commands`,
3711
- description: `Audit config and content files`
3712
- });
3713
3752
 
3714
3753
  // src/next/commands/init-command/index.ts
3715
3754
  var import_clipanion6 = require("clipanion");
3716
3755
 
3717
3756
  // src/cmds/init/detectEnvironment.ts
3718
3757
  var import_fs_extra8 = __toESM(require("fs-extra"));
3719
- var import_path7 = __toESM(require("path"));
3758
+ var import_path9 = __toESM(require("path"));
3720
3759
  var checkGitignoreForItem = async ({
3721
3760
  baseDir,
3722
3761
  line
3723
3762
  }) => {
3724
- const gitignoreContent = import_fs_extra8.default.readFileSync(import_path7.default.join(baseDir, ".gitignore")).toString();
3763
+ const gitignoreContent = import_fs_extra8.default.readFileSync(import_path9.default.join(baseDir, ".gitignore")).toString();
3725
3764
  return gitignoreContent.split("\n").some((item) => item === line);
3726
3765
  };
3727
3766
  var makeGeneratedFile = async (name2, generatedFileType, parentPath, opts) => {
3728
3767
  const result = {
3729
- fullPathTS: import_path7.default.join(
3768
+ fullPathTS: import_path9.default.join(
3730
3769
  parentPath,
3731
- `${name2}.${(opts == null ? void 0 : opts.typescriptSuffix) || (opts == null ? void 0 : opts.extensionOverride) || "ts"}`
3770
+ `${name2}.${opts?.typescriptSuffix || opts?.extensionOverride || "ts"}`
3732
3771
  ),
3733
- fullPathJS: import_path7.default.join(
3772
+ fullPathJS: import_path9.default.join(
3734
3773
  parentPath,
3735
- `${name2}.${(opts == null ? void 0 : opts.extensionOverride) || "js"}`
3774
+ `${name2}.${opts?.extensionOverride || "js"}`
3736
3775
  ),
3737
- fullPathOverride: (opts == null ? void 0 : opts.extensionOverride) ? import_path7.default.join(parentPath, `${name2}.${opts == null ? void 0 : opts.extensionOverride}`) : "",
3776
+ fullPathOverride: opts?.extensionOverride ? import_path9.default.join(parentPath, `${name2}.${opts?.extensionOverride}`) : "",
3738
3777
  generatedFileType,
3739
3778
  name: name2,
3740
3779
  parentPath,
@@ -3762,18 +3801,17 @@ var detectEnvironment = async ({
3762
3801
  rootPath,
3763
3802
  debug = false
3764
3803
  }) => {
3765
- var _a;
3766
3804
  const hasForestryConfig = await import_fs_extra8.default.pathExists(
3767
- import_path7.default.join(pathToForestryConfig, ".forestry", "settings.yml")
3805
+ import_path9.default.join(pathToForestryConfig, ".forestry", "settings.yml")
3768
3806
  );
3769
- const sampleContentPath = import_path7.default.join(
3807
+ const sampleContentPath = import_path9.default.join(
3770
3808
  baseDir,
3771
3809
  "content",
3772
3810
  "posts",
3773
3811
  "hello-world.md"
3774
3812
  );
3775
- const usingSrc = import_fs_extra8.default.pathExistsSync(import_path7.default.join(baseDir, "src")) && (import_fs_extra8.default.pathExistsSync(import_path7.default.join(baseDir, "src", "app")) || import_fs_extra8.default.pathExistsSync(import_path7.default.join(baseDir, "src", "pages")));
3776
- const tinaFolder = import_path7.default.join(baseDir, "tina");
3813
+ const usingSrc = import_fs_extra8.default.pathExistsSync(import_path9.default.join(baseDir, "src")) && (import_fs_extra8.default.pathExistsSync(import_path9.default.join(baseDir, "src", "app")) || import_fs_extra8.default.pathExistsSync(import_path9.default.join(baseDir, "src", "pages")));
3814
+ const tinaFolder = import_path9.default.join(baseDir, "tina");
3777
3815
  const tinaConfigExists = Boolean(
3778
3816
  // Does the tina folder exist?
3779
3817
  await import_fs_extra8.default.pathExists(tinaFolder) && // Does the tina folder contain a config file?
@@ -3789,12 +3827,12 @@ var detectEnvironment = async ({
3789
3827
  "next-api-handler": await makeGeneratedFile(
3790
3828
  "[...routes]",
3791
3829
  "next-api-handler",
3792
- import_path7.default.join(...pagesDir, "api", "tina")
3830
+ import_path9.default.join(...pagesDir, "api", "tina")
3793
3831
  ),
3794
3832
  "reactive-example": await makeGeneratedFile(
3795
3833
  "[filename]",
3796
3834
  "reactive-example",
3797
- import_path7.default.join(...pagesDir, "demo", "blog"),
3835
+ import_path9.default.join(...pagesDir, "demo", "blog"),
3798
3836
  {
3799
3837
  typescriptSuffix: "tsx"
3800
3838
  }
@@ -3802,13 +3840,13 @@ var detectEnvironment = async ({
3802
3840
  "users-json": await makeGeneratedFile(
3803
3841
  "index",
3804
3842
  "users-json",
3805
- import_path7.default.join(baseDir, "content", "users"),
3843
+ import_path9.default.join(baseDir, "content", "users"),
3806
3844
  { extensionOverride: "json" }
3807
3845
  ),
3808
3846
  "sample-content": await makeGeneratedFile(
3809
3847
  "hello-world",
3810
3848
  "sample-content",
3811
- import_path7.default.join(baseDir, "content", "posts"),
3849
+ import_path9.default.join(baseDir, "content", "posts"),
3812
3850
  { extensionOverride: "md" }
3813
3851
  )
3814
3852
  };
@@ -3819,10 +3857,10 @@ var detectEnvironment = async ({
3819
3857
  try {
3820
3858
  const packageJSON = await import_fs_extra8.default.readJSON("package.json");
3821
3859
  const deps = [];
3822
- if (packageJSON == null ? void 0 : packageJSON.dependencies) {
3860
+ if (packageJSON?.dependencies) {
3823
3861
  deps.push(...Object.keys(packageJSON.dependencies));
3824
3862
  }
3825
- if (packageJSON == null ? void 0 : packageJSON.devDependencies) {
3863
+ if (packageJSON?.devDependencies) {
3826
3864
  deps.push(...Object.keys(packageJSON.devDependencies));
3827
3865
  }
3828
3866
  if (deps.includes("@tinacms/cli") && deps.includes("tinacms")) {
@@ -3834,16 +3872,16 @@ var detectEnvironment = async ({
3834
3872
  );
3835
3873
  }
3836
3874
  }
3837
- const hasGitIgnore = await import_fs_extra8.default.pathExists(import_path7.default.join(".gitignore"));
3875
+ const hasGitIgnore = await import_fs_extra8.default.pathExists(import_path9.default.join(".gitignore"));
3838
3876
  const hasGitIgnoreNodeModules = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: "node_modules" });
3839
3877
  const hasEnvTina = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: ".env.tina" });
3840
3878
  const hasGitIgnoreEnv = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: ".env" });
3841
3879
  let frontMatterFormat;
3842
3880
  if (hasForestryConfig) {
3843
- const hugoConfigPath = import_path7.default.join(rootPath, "config.toml");
3881
+ const hugoConfigPath = import_path9.default.join(rootPath, "config.toml");
3844
3882
  if (await import_fs_extra8.default.pathExists(hugoConfigPath)) {
3845
3883
  const hugoConfig = await import_fs_extra8.default.readFile(hugoConfigPath, "utf8");
3846
- const metaDataFormat = (_a = hugoConfig.match(/metaDataFormat = "(.*)"/)) == null ? void 0 : _a[1];
3884
+ const metaDataFormat = hugoConfig.toString().match(/metaDataFormat = "(.*)"/)?.[1];
3847
3885
  if (metaDataFormat && (metaDataFormat === "yaml" || metaDataFormat === "toml" || metaDataFormat === "json")) {
3848
3886
  frontMatterFormat = metaDataFormat;
3849
3887
  }
@@ -3942,7 +3980,7 @@ var chooseGitProvider = async ({ config: config2 }) => {
3942
3980
  ${logText(
3943
3981
  "Learn more here: "
3944
3982
  )}${linkText(
3945
- "https://tina.io/docs/self-hosted/existing-site/#github-personal-access-token"
3983
+ "https://tina.io/docs/r/self-hosting-nextjs/#github-personal-access-token"
3946
3984
  )}`,
3947
3985
  initial: process.env.GITHUB_PERSONAL_ACCESS_TOKEN
3948
3986
  },
@@ -4203,7 +4241,8 @@ var askCommonSetUp = async () => {
4203
4241
  choices: [
4204
4242
  { title: "PNPM", value: "pnpm" },
4205
4243
  { title: "Yarn", value: "yarn" },
4206
- { title: "NPM", value: "npm" }
4244
+ { title: "NPM", value: "npm" },
4245
+ { title: "Bun", value: "bun" }
4207
4246
  ]
4208
4247
  }
4209
4248
  ]);
@@ -4264,7 +4303,7 @@ var askTinaSetupPrompts = async (params) => {
4264
4303
  message: `Where are public assets stored? (default: "public")
4265
4304
  ` + logText(
4266
4305
  `Not sure what value to use? Refer to our "Frameworks" doc: ${linkText(
4267
- "https://tina.io/docs/integration/frameworks/#configuring-tina-with-each-framework"
4306
+ "https://tina.io/docs/r/framework-guides-overview"
4268
4307
  )}`
4269
4308
  )
4270
4309
  });
@@ -4454,18 +4493,19 @@ var CLICommand = class {
4454
4493
  };
4455
4494
 
4456
4495
  // src/cmds/init/apply.ts
4457
- var import_path11 = __toESM(require("path"));
4496
+ var import_path13 = __toESM(require("path"));
4458
4497
 
4459
4498
  // src/cmds/forestry-migrate/index.ts
4460
4499
  var import_fs_extra10 = __toESM(require("fs-extra"));
4461
- var import_path9 = __toESM(require("path"));
4500
+ var import_path11 = __toESM(require("path"));
4462
4501
  var import_js_yaml2 = __toESM(require("js-yaml"));
4463
- var import_minimatch = __toESM(require("minimatch"));
4502
+ var import_minimatch = require("minimatch");
4464
4503
  var import_graphql16 = require("@tinacms/graphql");
4504
+ var import_schema_tools3 = require("@tinacms/schema-tools");
4465
4505
 
4466
4506
  // src/cmds/forestry-migrate/util/index.ts
4467
4507
  var import_fs_extra9 = __toESM(require("fs-extra"));
4468
- var import_path8 = __toESM(require("path"));
4508
+ var import_path10 = __toESM(require("path"));
4469
4509
  var import_js_yaml = __toESM(require("js-yaml"));
4470
4510
  var import_zod = __toESM(require("zod"));
4471
4511
 
@@ -4494,8 +4534,7 @@ var ErrorSingleton = class _ErrorSingleton {
4494
4534
  this.collectionNameErrors.push(error);
4495
4535
  }
4496
4536
  printCollectionNameErrors() {
4497
- var _a;
4498
- if ((_a = this.collectionNameErrors) == null ? void 0 : _a.length) {
4537
+ if (this.collectionNameErrors?.length) {
4499
4538
  logger.error(
4500
4539
  dangerText("ERROR: TinaCMS only supports alphanumeric template names")
4501
4540
  );
@@ -4677,8 +4716,7 @@ var transformForestryFieldsToTinaFields = ({
4677
4716
  skipBlocks = false
4678
4717
  }) => {
4679
4718
  const tinaFields = [];
4680
- fields == null ? void 0 : fields.forEach((forestryField2) => {
4681
- var _a, _b, _c, _d;
4719
+ fields?.forEach((forestryField2) => {
4682
4720
  if (forestryField2.name === "menu") {
4683
4721
  logger.info(
4684
4722
  warnText(
@@ -4754,12 +4792,12 @@ var transformForestryFieldsToTinaFields = ({
4754
4792
  };
4755
4793
  break;
4756
4794
  case "select":
4757
- if ((_a = forestryField2.config) == null ? void 0 : _a.options) {
4795
+ if (forestryField2.config?.options) {
4758
4796
  field = {
4759
4797
  type: "string",
4760
4798
  ...getTinaFieldsFromName(forestryField2.name),
4761
4799
  label: forestryField2.label,
4762
- options: ((_b = forestryField2.config) == null ? void 0 : _b.options) || []
4800
+ options: forestryField2.config?.options || []
4763
4801
  };
4764
4802
  } else {
4765
4803
  logger.info(
@@ -4777,7 +4815,7 @@ var transformForestryFieldsToTinaFields = ({
4777
4815
  label: forestryField2.label,
4778
4816
  list: true
4779
4817
  };
4780
- if ((_c = forestryField2.config) == null ? void 0 : _c.options) {
4818
+ if (forestryField2.config?.options) {
4781
4819
  field.options = forestryField2.config.options;
4782
4820
  }
4783
4821
  break;
@@ -4825,7 +4863,7 @@ var transformForestryFieldsToTinaFields = ({
4825
4863
  break;
4826
4864
  }
4827
4865
  const templates2 = [];
4828
- forestryField2 == null ? void 0 : forestryField2.template_types.forEach((tem) => {
4866
+ forestryField2?.template_types.forEach((tem) => {
4829
4867
  const { template: template2 } = getFieldsFromTemplates({
4830
4868
  tem,
4831
4869
  skipBlocks: true,
@@ -4883,7 +4921,7 @@ var transformForestryFieldsToTinaFields = ({
4883
4921
  );
4884
4922
  }
4885
4923
  if (field) {
4886
- if ((_d = forestryField2.config) == null ? void 0 : _d.required) {
4924
+ if (forestryField2.config?.required) {
4887
4925
  field = { ...field, required: true };
4888
4926
  }
4889
4927
  tinaFields.push(field);
@@ -4892,7 +4930,7 @@ var transformForestryFieldsToTinaFields = ({
4892
4930
  return tinaFields;
4893
4931
  };
4894
4932
  var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false }) => {
4895
- const templatePath = import_path8.default.join(
4933
+ const templatePath = import_path10.default.join(
4896
4934
  pathToForestryConfig,
4897
4935
  ".forestry",
4898
4936
  "front_matter",
@@ -4945,8 +4983,7 @@ var stringifyLabelWithField = (label) => {
4945
4983
  return `${labelString}Fields`;
4946
4984
  };
4947
4985
  var transformForestryMatchToTinaMatch = (match) => {
4948
- var _a, _b;
4949
- const newMatch = (_b = (_a = match.replace(" ", "").replace(/\.?(mdx|md|json|yaml|yml|toml)/g, "")) == null ? void 0 : _a.replace(/\..*$/g, "")) == null ? void 0 : _b.replace("{}", "");
4986
+ const newMatch = match.replace(" ", "").replace(/\.?(mdx|md|json|yaml|yml|toml)/g, "")?.replace(/\..*$/g, "")?.replace("{}", "");
4950
4987
  if (match !== newMatch) {
4951
4988
  logger.info(
4952
4989
  `Info: Match ${match} was transformed to ${newMatch}. See ${linkText(
@@ -4958,7 +4995,7 @@ var transformForestryMatchToTinaMatch = (match) => {
4958
4995
  };
4959
4996
  function checkExt(ext) {
4960
4997
  const extReal = ext.replace(".", "");
4961
- if (["mdx", "md", "json", "yaml", "yml", "toml"].includes(extReal)) {
4998
+ if (import_schema_tools3.CONTENT_FORMATS.includes(extReal)) {
4962
4999
  return extReal;
4963
5000
  } else {
4964
5001
  return false;
@@ -4968,8 +5005,8 @@ var generateAllTemplates = async ({
4968
5005
  pathToForestryConfig
4969
5006
  }) => {
4970
5007
  const allTemplates = (await import_fs_extra10.default.readdir(
4971
- import_path9.default.join(pathToForestryConfig, ".forestry", "front_matter", "templates")
4972
- )).map((tem) => import_path9.default.basename(tem, ".yml"));
5008
+ import_path11.default.join(pathToForestryConfig, ".forestry", "front_matter", "templates")
5009
+ )).map((tem) => import_path11.default.basename(tem, ".yml"));
4973
5010
  const templateMap = /* @__PURE__ */ new Map();
4974
5011
  const proms = allTemplates.map(async (tem) => {
4975
5012
  try {
@@ -5011,18 +5048,18 @@ var generateCollectionFromForestrySection = (args) => {
5011
5048
  }
5012
5049
  if (section.match) {
5013
5050
  baseCollection.match = {
5014
- ...(baseCollection == null ? void 0 : baseCollection.match) || {},
5051
+ ...baseCollection?.match || {},
5015
5052
  include: transformForestryMatchToTinaMatch(section.match)
5016
5053
  };
5017
5054
  }
5018
5055
  if (section.exclude) {
5019
5056
  baseCollection.match = {
5020
- ...(baseCollection == null ? void 0 : baseCollection.match) || {},
5057
+ ...baseCollection?.match || {},
5021
5058
  exclude: transformForestryMatchToTinaMatch(section.exclude)
5022
5059
  };
5023
5060
  }
5024
5061
  if (section.type === "directory") {
5025
- if (!(section == null ? void 0 : section.path) || section.path === "/" || section.path === "./" || section.path === ".") {
5062
+ if (!section?.path || section.path === "/" || section.path === "./" || section.path === ".") {
5026
5063
  logger.log(
5027
5064
  warnText(
5028
5065
  `Warning: Section ${section.label} is using a Root Path. Currently, Tina Does not support Root paths see ${linkText(
@@ -5032,11 +5069,11 @@ var generateCollectionFromForestrySection = (args) => {
5032
5069
  );
5033
5070
  return;
5034
5071
  }
5035
- const forestryTemplates = (section == null ? void 0 : section.templates) || [];
5072
+ const forestryTemplates = section?.templates || [];
5036
5073
  if (forestryTemplates.length === 0 && section.create === "all") {
5037
5074
  for (const templateKey of templateMap.keys()) {
5038
5075
  const { templateObj } = templateMap.get(templateKey);
5039
- const pages = templateObj == null ? void 0 : templateObj.pages;
5076
+ const pages = templateObj?.pages;
5040
5077
  if (pages) {
5041
5078
  let glob = section.match;
5042
5079
  const skipPath = section.path === "" || section.path === "/" || !section.path;
@@ -5044,7 +5081,7 @@ var generateCollectionFromForestrySection = (args) => {
5044
5081
  glob = section.path + "/" + section.match;
5045
5082
  }
5046
5083
  if (pages.some((page) => {
5047
- return (0, import_minimatch.default)(page, glob);
5084
+ return (0, import_minimatch.minimatch)(page, glob);
5048
5085
  })) {
5049
5086
  forestryTemplates.push(templateKey);
5050
5087
  }
@@ -5053,7 +5090,7 @@ var generateCollectionFromForestrySection = (args) => {
5053
5090
  }
5054
5091
  const hasBody = ["md", "mdx", "markdown"].includes(format3);
5055
5092
  let c;
5056
- if (((forestryTemplates == null ? void 0 : forestryTemplates.length) || 0) > 1) {
5093
+ if ((forestryTemplates?.length || 0) > 1) {
5057
5094
  c = {
5058
5095
  ...baseCollection,
5059
5096
  // @ts-expect-error
@@ -5075,7 +5112,7 @@ var generateCollectionFromForestrySection = (args) => {
5075
5112
  })
5076
5113
  };
5077
5114
  }
5078
- if ((forestryTemplates == null ? void 0 : forestryTemplates.length) === 1) {
5115
+ if (forestryTemplates?.length === 1) {
5079
5116
  const tem = forestryTemplates[0];
5080
5117
  const template = templateMap.get(tem);
5081
5118
  const fieldsString = stringifyLabelWithField(template.templateObj.label);
@@ -5090,7 +5127,7 @@ var generateCollectionFromForestrySection = (args) => {
5090
5127
  })
5091
5128
  };
5092
5129
  }
5093
- if ((forestryTemplates == null ? void 0 : forestryTemplates.length) === 0) {
5130
+ if (forestryTemplates?.length === 0) {
5094
5131
  logger.warn(
5095
5132
  warnText(
5096
5133
  `No templates found for section ${section.label}. Please see ${linkText(
@@ -5103,7 +5140,7 @@ var generateCollectionFromForestrySection = (args) => {
5103
5140
  fields: [BODY_FIELD]
5104
5141
  };
5105
5142
  }
5106
- if ((section == null ? void 0 : section.create) === "none") {
5143
+ if (section?.create === "none") {
5107
5144
  c.ui = {
5108
5145
  ...c.ui,
5109
5146
  allowedActions: {
@@ -5114,9 +5151,9 @@ var generateCollectionFromForestrySection = (args) => {
5114
5151
  return c;
5115
5152
  } else if (section.type === "document") {
5116
5153
  const filePath = section.path;
5117
- const extname = import_path9.default.extname(filePath);
5118
- const fileName = import_path9.default.basename(filePath, extname);
5119
- const dir = import_path9.default.dirname(filePath);
5154
+ const extname = import_path11.default.extname(filePath);
5155
+ const fileName = import_path11.default.basename(filePath, extname);
5156
+ const dir = import_path11.default.dirname(filePath);
5120
5157
  const ext = checkExt(extname);
5121
5158
  if (ext) {
5122
5159
  const fields = [];
@@ -5125,7 +5162,7 @@ var generateCollectionFromForestrySection = (args) => {
5125
5162
  }
5126
5163
  for (const currentTemplateName of templateMap.keys()) {
5127
5164
  const { templateObj, fields: additionalFields } = templateMap.get(currentTemplateName);
5128
- const pages = (templateObj == null ? void 0 : templateObj.pages) || [];
5165
+ const pages = templateObj?.pages || [];
5129
5166
  if (pages.includes(section.path)) {
5130
5167
  fields.push(...additionalFields);
5131
5168
  break;
@@ -5136,7 +5173,7 @@ var generateCollectionFromForestrySection = (args) => {
5136
5173
  name: "dummy",
5137
5174
  label: "Dummy field",
5138
5175
  type: "string",
5139
- description: "This is a dummy field, please replace it with the fields you want to edit. See https://tina.io/docs/schema/ for more info"
5176
+ description: "This is a dummy field, please replace it with the fields you want to edit. See https://tina.io/docs/r/content-modelling-collections/ for more info"
5140
5177
  });
5141
5178
  logger.warn(
5142
5179
  warnText(
@@ -5179,7 +5216,7 @@ var generateCollections = async ({
5179
5216
  usingTypescript
5180
5217
  });
5181
5218
  const forestryConfig = await import_fs_extra10.default.readFile(
5182
- import_path9.default.join(pathToForestryConfig, ".forestry", "settings.yml")
5219
+ import_path11.default.join(pathToForestryConfig, ".forestry", "settings.yml")
5183
5220
  );
5184
5221
  rewriteTemplateKeysInDocs({
5185
5222
  templateMap,
@@ -5204,17 +5241,16 @@ var generateCollections = async ({
5204
5241
  };
5205
5242
  };
5206
5243
  var rewriteTemplateKeysInDocs = (args) => {
5207
- var _a;
5208
5244
  const { templateMap, markdownParseConfig } = args;
5209
5245
  for (const templateKey of templateMap.keys()) {
5210
5246
  const { templateObj } = templateMap.get(templateKey);
5211
- (_a = templateObj == null ? void 0 : templateObj.pages) == null ? void 0 : _a.forEach((page) => {
5247
+ templateObj?.pages?.forEach((page) => {
5212
5248
  try {
5213
- const filePath = import_path9.default.join(page);
5249
+ const filePath = import_path11.default.join(page);
5214
5250
  if (import_fs_extra10.default.lstatSync(filePath).isDirectory()) {
5215
5251
  return;
5216
5252
  }
5217
- const extname = import_path9.default.extname(filePath);
5253
+ const extname = import_path11.default.extname(filePath);
5218
5254
  const fileContent = import_fs_extra10.default.readFileSync(filePath).toString();
5219
5255
  const content = (0, import_graphql16.parseFile)(
5220
5256
  fileContent,
@@ -5246,7 +5282,7 @@ var import_fs_extra13 = __toESM(require("fs-extra"));
5246
5282
  // src/next/commands/codemod-command/index.ts
5247
5283
  var import_clipanion5 = require("clipanion");
5248
5284
  var import_fs_extra11 = __toESM(require("fs-extra"));
5249
- var import_path10 = __toESM(require("path"));
5285
+ var import_path12 = __toESM(require("path"));
5250
5286
  var CodemodCommand = class extends import_clipanion5.Command {
5251
5287
  constructor() {
5252
5288
  super(...arguments);
@@ -5257,6 +5293,15 @@ var CodemodCommand = class extends import_clipanion5.Command {
5257
5293
  description: "increase verbosity of logged output"
5258
5294
  });
5259
5295
  }
5296
+ static {
5297
+ this.paths = [["codemod"], ["codemod", "move-tina-folder"]];
5298
+ }
5299
+ static {
5300
+ this.usage = import_clipanion5.Command.Usage({
5301
+ category: `Commands`,
5302
+ description: `Use codemods for various Tina tasks`
5303
+ });
5304
+ }
5260
5305
  async catch(error) {
5261
5306
  console.log(error);
5262
5307
  }
@@ -5277,11 +5322,6 @@ var CodemodCommand = class extends import_clipanion5.Command {
5277
5322
  await command2();
5278
5323
  }
5279
5324
  };
5280
- CodemodCommand.paths = [["codemod"], ["codemod", "move-tina-folder"]];
5281
- CodemodCommand.usage = import_clipanion5.Command.Usage({
5282
- category: `Commands`,
5283
- description: `Use codemods for various Tina tasks`
5284
- });
5285
5325
  var moveTinaFolder = async (rootPath = process.cwd()) => {
5286
5326
  const configManager = new ConfigManager({ rootPath });
5287
5327
  try {
@@ -5290,7 +5330,7 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
5290
5330
  logger.error(e.message);
5291
5331
  process.exit(1);
5292
5332
  }
5293
- const tinaDestination = import_path10.default.join(configManager.rootPath, "tina");
5333
+ const tinaDestination = import_path12.default.join(configManager.rootPath, "tina");
5294
5334
  if (await import_fs_extra11.default.existsSync(tinaDestination)) {
5295
5335
  logger.info(
5296
5336
  `Folder already exists at ${tinaDestination}. Either delete this folder to complete the codemod, or ensure you have properly copied your config from the ".tina" folder.`
@@ -5305,7 +5345,7 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
5305
5345
  };
5306
5346
  var writeGitignore = async (rootPath) => {
5307
5347
  await import_fs_extra11.default.outputFileSync(
5308
- import_path10.default.join(rootPath, "tina", ".gitignore"),
5348
+ import_path12.default.join(rootPath, "tina", ".gitignore"),
5309
5349
  "__generated__"
5310
5350
  );
5311
5351
  };
@@ -5358,7 +5398,7 @@ const BlogPage = (props) => {
5358
5398
  <div className='bg-green-100 text-center'>
5359
5399
  Lost and looking for a place to start?
5360
5400
  <a
5361
- href='https://tina.io/guides/tina-cloud/getting-started/overview/'
5401
+ href='https://tina.io/docs/r/beginner-series'
5362
5402
  className='text-blue-500 underline'
5363
5403
  >
5364
5404
  {' '}
@@ -5561,11 +5601,10 @@ var baseFields = `[
5561
5601
  },
5562
5602
  ]`;
5563
5603
  var generateCollectionString = (args) => {
5564
- var _a, _b, _c, _d;
5565
5604
  if (args.collections) {
5566
5605
  return args.collections;
5567
5606
  }
5568
- let extraTinaCollections = (_b = (_a = args.config.authProvider) == null ? void 0 : _a.extraTinaCollections) == null ? void 0 : _b.join(",\n");
5607
+ let extraTinaCollections = args.config.authProvider?.extraTinaCollections?.join(",\n");
5569
5608
  if (extraTinaCollections) {
5570
5609
  extraTinaCollections = extraTinaCollections + ",";
5571
5610
  }
@@ -5591,18 +5630,17 @@ var generateCollectionString = (args) => {
5591
5630
  },
5592
5631
  },
5593
5632
  ]`;
5594
- if (((_d = (_c = args.config) == null ? void 0 : _c.framework) == null ? void 0 : _d.name) === "next") {
5633
+ if (args.config?.framework?.name === "next") {
5595
5634
  return nextExampleCollection;
5596
5635
  }
5597
5636
  return baseCollections;
5598
5637
  };
5599
5638
  var generateConfig = (args) => {
5600
- var _a, _b, _c;
5601
- const isUsingTinaCloud = !args.selfHosted || ((_a = args.config.authProvider) == null ? void 0 : _a.name) === "tina-cloud";
5639
+ const isUsingTinaCloud = !args.selfHosted || args.config.authProvider?.name === "tina-cloud";
5602
5640
  let extraImports = "";
5603
5641
  if (args.selfHosted) {
5604
5642
  if (args.config.authProvider) {
5605
- extraImports = extraImports + makeImportString((_b = args.config.authProvider) == null ? void 0 : _b.configImports);
5643
+ extraImports = extraImports + makeImportString(args.config.authProvider?.configImports);
5606
5644
  }
5607
5645
  if (!isUsingTinaCloud) {
5608
5646
  extraImports = extraImports + `
@@ -5625,7 +5663,7 @@ import { LocalAuthProvider } from "tinacms";`;
5625
5663
  branch,
5626
5664
  ${args.selfHosted && !isUsingTinaCloud ? `authProvider: isLocal
5627
5665
  ? new LocalAuthProvider()
5628
- :${(_c = args.config) == null ? void 0 : _c.authProvider.configAuthProviderClass},` : ""}
5666
+ :${args.config?.authProvider.configAuthProviderClass},` : ""}
5629
5667
  ${isUsingTinaCloud ? `// Get this from tina.io
5630
5668
  clientId: process.env.NEXT_PUBLIC_TINA_CLIENT_ID,` : ""}
5631
5669
  ${isUsingTinaCloud ? `// Get this from tina.io
@@ -5642,7 +5680,7 @@ import { LocalAuthProvider } from "tinacms";`;
5642
5680
  publicFolder: "${args.publicFolder}",
5643
5681
  },
5644
5682
  },
5645
- // See docs on content modeling for more info on how to setup new content models: https://tina.io/docs/schema/
5683
+ // See docs on content modeling for more info on how to setup new content models: https://tina.io/docs/r/content-modelling-collections/
5646
5684
  schema: {
5647
5685
  collections: ${generateCollectionString(args)},
5648
5686
  },
@@ -5652,11 +5690,10 @@ import { LocalAuthProvider } from "tinacms";`;
5652
5690
 
5653
5691
  // src/cmds/init/templates/database.ts
5654
5692
  var databaseTemplate = ({ config: config2 }) => {
5655
- var _a, _b, _c, _d;
5656
5693
  return `
5657
5694
  import { createDatabase, createLocalDatabase } from '@tinacms/datalayer'
5658
- ${makeImportString((_a = config2.gitProvider) == null ? void 0 : _a.imports)}
5659
- ${makeImportString((_b = config2.databaseAdapter) == null ? void 0 : _b.imports)}
5695
+ ${makeImportString(config2.gitProvider?.imports)}
5696
+ ${makeImportString(config2.databaseAdapter?.imports)}
5660
5697
 
5661
5698
  const branch = (process.env.GITHUB_BRANCH ||
5662
5699
  process.env.VERCEL_GIT_COMMIT_REF ||
@@ -5668,8 +5705,8 @@ const isLocal = process.env.${config2.isLocalEnvVarName} === 'true'
5668
5705
  export default isLocal
5669
5706
  ? createLocalDatabase()
5670
5707
  : createDatabase({
5671
- gitProvider: ${(_c = config2.gitProvider) == null ? void 0 : _c.gitProviderClassText},
5672
- databaseAdapter: ${(_d = config2.databaseAdapter) == null ? void 0 : _d.databaseAdapterClassText},
5708
+ gitProvider: ${config2.gitProvider?.gitProviderClassText},
5709
+ databaseAdapter: ${config2.databaseAdapter?.databaseAdapterClassText},
5673
5710
  namespace: branch,
5674
5711
  })
5675
5712
  `;
@@ -5680,10 +5717,9 @@ var nextApiRouteTemplate = ({
5680
5717
  config: config2,
5681
5718
  env
5682
5719
  }) => {
5683
- var _a, _b;
5684
5720
  const extraPath = env.usingSrc ? "../" : "";
5685
5721
  return `import { TinaNodeBackend, LocalBackendAuthProvider } from '@tinacms/datalayer'
5686
- ${makeImportString((_a = config2.authProvider) == null ? void 0 : _a.backendAuthProviderImports)}
5722
+ ${makeImportString(config2.authProvider?.backendAuthProviderImports)}
5687
5723
 
5688
5724
 
5689
5725
 
@@ -5694,7 +5730,7 @@ var nextApiRouteTemplate = ({
5694
5730
  const handler = TinaNodeBackend({
5695
5731
  authProvider: isLocal
5696
5732
  ? LocalBackendAuthProvider()
5697
- : ${((_b = config2.authProvider) == null ? void 0 : _b.backendAuthProvider) || ""},
5733
+ : ${config2.authProvider?.backendAuthProvider || ""},
5698
5734
  databaseClient,
5699
5735
  })
5700
5736
 
@@ -5722,19 +5758,18 @@ var import_prettier2 = require("prettier");
5722
5758
  // src/utils/script-helpers.ts
5723
5759
  function generateGqlScript(scriptValue, opts) {
5724
5760
  const cmd = `tinacms dev -c "${scriptValue}"`;
5725
- if (opts == null ? void 0 : opts.isLocalEnvVarName) {
5761
+ if (opts?.isLocalEnvVarName) {
5726
5762
  return `${opts.isLocalEnvVarName}=true ${cmd}`;
5727
5763
  }
5728
5764
  return cmd;
5729
5765
  }
5730
5766
  function extendNextScripts(scripts, opts) {
5731
- var _a, _b;
5732
5767
  const result = {
5733
5768
  ...scripts,
5734
- dev: !(scripts == null ? void 0 : scripts.dev) || ((_a = scripts == null ? void 0 : scripts.dev) == null ? void 0 : _a.indexOf("tinacms dev -c")) === -1 ? generateGqlScript((scripts == null ? void 0 : scripts.dev) || "next dev", opts) : scripts == null ? void 0 : scripts.dev,
5735
- build: !(scripts == null ? void 0 : scripts.build) || !((_b = scripts == null ? void 0 : scripts.build) == null ? void 0 : _b.startsWith("tinacms build &&")) ? `tinacms build && ${(scripts == null ? void 0 : scripts.build) || "next build"}` : scripts == null ? void 0 : scripts.build
5769
+ dev: !scripts?.dev || scripts?.dev?.indexOf("tinacms dev -c") === -1 ? generateGqlScript(scripts?.dev || "next dev", opts) : scripts?.dev,
5770
+ build: !scripts?.build || !scripts?.build?.startsWith("tinacms build &&") ? `tinacms build && ${scripts?.build || "next build"}` : scripts?.build
5736
5771
  };
5737
- if ((opts == null ? void 0 : opts.addSetupUsers) && !scripts["setup:users"]) {
5772
+ if (opts?.addSetupUsers && !scripts["setup:users"]) {
5738
5773
  result["setup:users"] = "tinacms-next-auth setup";
5739
5774
  }
5740
5775
  return result;
@@ -5816,7 +5851,6 @@ var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variable
5816
5851
  }
5817
5852
  };
5818
5853
  var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
5819
- var _a;
5820
5854
  if (import_typescript3.default.isSourceFile(node)) {
5821
5855
  const newStatements = [...node.statements];
5822
5856
  let changed = false;
@@ -5825,7 +5859,7 @@ var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
5825
5859
  for (const statement of newStatements) {
5826
5860
  if (import_typescript3.default.isImportDeclaration(statement) && import_typescript3.default.isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === moduleName) {
5827
5861
  foundImportStatement = true;
5828
- const existingImports = ((_a = statement.importClause) == null ? void 0 : _a.namedBindings) && import_typescript3.default.isNamedImports(statement.importClause.namedBindings) ? statement.importClause.namedBindings.elements.map(
5862
+ const existingImports = statement.importClause?.namedBindings && import_typescript3.default.isNamedImports(statement.importClause.namedBindings) ? statement.importClause.namedBindings.elements.map(
5829
5863
  (e) => e.name.text
5830
5864
  ) : [];
5831
5865
  const newImports = [
@@ -6042,7 +6076,6 @@ async function apply({
6042
6076
  params,
6043
6077
  config: config2
6044
6078
  }) {
6045
- var _a;
6046
6079
  if (config2.framework.name === "other" && config2.hosting === "self-host") {
6047
6080
  logger.error(
6048
6081
  logText(
@@ -6148,8 +6181,8 @@ async function apply({
6148
6181
  await addConfigFile({
6149
6182
  configArgs: {
6150
6183
  config: config2,
6151
- publicFolder: import_path11.default.join(
6152
- import_path11.default.relative(process.cwd(), pathToForestryConfig),
6184
+ publicFolder: import_path13.default.join(
6185
+ import_path13.default.relative(process.cwd(), pathToForestryConfig),
6153
6186
  config2.publicFolder
6154
6187
  ),
6155
6188
  collections,
@@ -6168,7 +6201,7 @@ async function apply({
6168
6201
  env.tinaConfigExists && // Are we running tinacms init backend
6169
6202
  params.isBackendInit && // Do the user choose the 'self-host' option
6170
6203
  config2.hosting === "self-host" && // the user did not choose the 'tina-cloud' auth provider
6171
- (((_a = config2.authProvider) == null ? void 0 : _a.name) || "") !== "tina-cloud"
6204
+ (config2.authProvider?.name || "") !== "tina-cloud"
6172
6205
  ) {
6173
6206
  await addSelfHostedTinaAuthToConfig(config2, env.generatedFiles["config"]);
6174
6207
  }
@@ -6222,21 +6255,20 @@ var createPackageJSON = async () => {
6222
6255
  };
6223
6256
  var createGitignore = async ({ baseDir }) => {
6224
6257
  logger.info(logText("No .gitignore found, creating one"));
6225
- import_fs_extra13.default.outputFileSync(import_path11.default.join(baseDir, ".gitignore"), "node_modules");
6258
+ import_fs_extra13.default.outputFileSync(import_path13.default.join(baseDir, ".gitignore"), "node_modules");
6226
6259
  };
6227
6260
  var updateGitIgnore = async ({
6228
6261
  baseDir,
6229
6262
  items
6230
6263
  }) => {
6231
6264
  logger.info(logText(`Adding ${items.join(",")} to .gitignore`));
6232
- const gitignoreContent = import_fs_extra13.default.readFileSync(import_path11.default.join(baseDir, ".gitignore")).toString();
6265
+ const gitignoreContent = import_fs_extra13.default.readFileSync(import_path13.default.join(baseDir, ".gitignore")).toString();
6233
6266
  const newGitignoreContent = [...gitignoreContent.split("\n"), ...items].join(
6234
6267
  "\n"
6235
6268
  );
6236
- await import_fs_extra13.default.writeFile(import_path11.default.join(baseDir, ".gitignore"), newGitignoreContent);
6269
+ await import_fs_extra13.default.writeFile(import_path13.default.join(baseDir, ".gitignore"), newGitignoreContent);
6237
6270
  };
6238
6271
  var addDependencies = async (config2, env, params) => {
6239
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
6240
6272
  const { packageManager } = config2;
6241
6273
  const tagVersion = params.tinaVersion ? `@${params.tinaVersion}` : "";
6242
6274
  let deps = [];
@@ -6252,18 +6284,18 @@ var addDependencies = async (config2, env, params) => {
6252
6284
  deps.push("@tinacms/datalayer");
6253
6285
  }
6254
6286
  deps.push(
6255
- ...((_b = (_a = config2.databaseAdapter) == null ? void 0 : _a.imports) == null ? void 0 : _b.map((x) => x.packageName)) || []
6287
+ ...config2.databaseAdapter?.imports?.map((x) => x.packageName) || []
6256
6288
  );
6257
- deps.push(...((_c = config2.authProvider) == null ? void 0 : _c.peerDependencies) || []);
6289
+ deps.push(...config2.authProvider?.peerDependencies || []);
6258
6290
  deps.push(
6259
- ...((_e = (_d = config2.authProvider) == null ? void 0 : _d.backendAuthProviderImports) == null ? void 0 : _e.map(
6291
+ ...config2.authProvider?.backendAuthProviderImports?.map(
6260
6292
  (x) => x.packageName
6261
- )) || []
6293
+ ) || []
6262
6294
  );
6263
6295
  deps.push(
6264
- ...((_g = (_f = config2.authProvider) == null ? void 0 : _f.configImports) == null ? void 0 : _g.map((x) => x.packageName)) || []
6296
+ ...config2.authProvider?.configImports?.map((x) => x.packageName) || []
6265
6297
  );
6266
- deps.push(...((_i = (_h = config2.gitProvider) == null ? void 0 : _h.imports) == null ? void 0 : _i.map((x) => x.packageName)) || []);
6298
+ deps.push(...config2.gitProvider?.imports?.map((x) => x.packageName) || []);
6267
6299
  if (tagVersion) {
6268
6300
  deps = deps.map(
6269
6301
  (dep) => dep.indexOf("tina") >= 0 ? `${dep}${tagVersion}` : dep
@@ -6275,7 +6307,8 @@ var addDependencies = async (config2, env, params) => {
6275
6307
  let packageManagers = {
6276
6308
  pnpm: process.env.USE_WORKSPACE ? `pnpm add ${deps.join(" ")} --workspace` : `pnpm add ${deps.join(" ")}`,
6277
6309
  npm: `npm install ${deps.join(" ")}`,
6278
- yarn: `yarn add ${deps.join(" ")}`
6310
+ yarn: `yarn add ${deps.join(" ")}`,
6311
+ bun: `bun add ${deps.join(" ")}`
6279
6312
  };
6280
6313
  if (packageManagers[packageManager] && deps.length > 0) {
6281
6314
  logger.info(logText("Adding dependencies, this might take a moment..."));
@@ -6286,7 +6319,8 @@ var addDependencies = async (config2, env, params) => {
6286
6319
  packageManagers = {
6287
6320
  pnpm: process.env.USE_WORKSPACE ? `pnpm add -D ${devDeps.join(" ")} --workspace` : `pnpm add -D ${devDeps.join(" ")}`,
6288
6321
  npm: `npm install -D ${devDeps.join(" ")}`,
6289
- yarn: `yarn add -D ${devDeps.join(" ")}`
6322
+ yarn: `yarn add -D ${devDeps.join(" ")}`,
6323
+ bun: `bun add -D ${devDeps.join(" ")}`
6290
6324
  };
6291
6325
  if (packageManagers[packageManager]) {
6292
6326
  logger.info(
@@ -6303,22 +6337,22 @@ var writeGeneratedFile = async ({
6303
6337
  content,
6304
6338
  typescript
6305
6339
  }) => {
6306
- const { exists, path: path14, parentPath } = generatedFile.resolve(typescript);
6340
+ const { exists, path: path15, parentPath } = generatedFile.resolve(typescript);
6307
6341
  if (exists) {
6308
6342
  if (overwrite) {
6309
- logger.info(`Overwriting file at ${path14}... \u2705`);
6310
- import_fs_extra13.default.outputFileSync(path14, content);
6343
+ logger.info(`Overwriting file at ${path15}... \u2705`);
6344
+ import_fs_extra13.default.outputFileSync(path15, content);
6311
6345
  } else {
6312
- logger.info(`Not overwriting file at ${path14}.`);
6346
+ logger.info(`Not overwriting file at ${path15}.`);
6313
6347
  logger.info(
6314
- logText(`Please add the following to ${path14}:
6348
+ logText(`Please add the following to ${path15}:
6315
6349
  ${indentText(content)}}`)
6316
6350
  );
6317
6351
  }
6318
6352
  } else {
6319
- logger.info(`Adding file at ${path14}... \u2705`);
6353
+ logger.info(`Adding file at ${path15}... \u2705`);
6320
6354
  await import_fs_extra13.default.ensureDir(parentPath);
6321
- import_fs_extra13.default.outputFileSync(path14, content);
6355
+ import_fs_extra13.default.outputFileSync(path15, content);
6322
6356
  }
6323
6357
  };
6324
6358
  var addConfigFile = async ({
@@ -6327,12 +6361,11 @@ var addConfigFile = async ({
6327
6361
  generatedFile,
6328
6362
  config: config2
6329
6363
  }) => {
6330
- var _a;
6331
6364
  const content = (0, import_prettier2.format)(generateConfig(configArgs), {
6332
6365
  parser: "babel"
6333
6366
  });
6334
6367
  await writeGeneratedFile({
6335
- overwrite: (_a = config2.overwriteList) == null ? void 0 : _a.includes("config"),
6368
+ overwrite: config2.overwriteList?.includes("config"),
6336
6369
  generatedFile,
6337
6370
  content,
6338
6371
  typescript: config2.typescript
@@ -6346,10 +6379,9 @@ var addDatabaseFile = async ({
6346
6379
  config: config2,
6347
6380
  generatedFile
6348
6381
  }) => {
6349
- var _a;
6350
6382
  await writeGeneratedFile({
6351
6383
  generatedFile,
6352
- overwrite: (_a = config2.overwriteList) == null ? void 0 : _a.includes("database"),
6384
+ overwrite: config2.overwriteList?.includes("database"),
6353
6385
  content: databaseTemplate({ config: config2 }),
6354
6386
  typescript: config2.typescript
6355
6387
  });
@@ -6359,13 +6391,12 @@ var addNextApiRoute = async ({
6359
6391
  generatedFile,
6360
6392
  env
6361
6393
  }) => {
6362
- var _a;
6363
6394
  const content = (0, import_prettier2.format)(nextApiRouteTemplate({ config: config2, env }), {
6364
6395
  parser: "babel"
6365
6396
  });
6366
6397
  await writeGeneratedFile({
6367
6398
  generatedFile,
6368
- overwrite: (_a = config2.overwriteList) == null ? void 0 : _a.includes("next-api-handler"),
6399
+ overwrite: config2.overwriteList?.includes("next-api-handler"),
6369
6400
  content,
6370
6401
  typescript: config2.typescript
6371
6402
  });
@@ -6375,10 +6406,9 @@ var addTemplateFile = async ({
6375
6406
  generatedFile,
6376
6407
  config: config2
6377
6408
  }) => {
6378
- var _a;
6379
6409
  await writeGeneratedFile({
6380
6410
  generatedFile,
6381
- overwrite: (_a = config2.overwriteList) == null ? void 0 : _a.includes(generatedFile.generatedFileType),
6411
+ overwrite: config2.overwriteList?.includes(generatedFile.generatedFileType),
6382
6412
  content,
6383
6413
  typescript: config2.typescript
6384
6414
  });
@@ -6387,7 +6417,6 @@ var addContentFile = async ({
6387
6417
  config: config2,
6388
6418
  env
6389
6419
  }) => {
6390
- var _a;
6391
6420
  await writeGeneratedFile({
6392
6421
  generatedFile: {
6393
6422
  javascriptExists: false,
@@ -6401,11 +6430,11 @@ var addContentFile = async ({
6401
6430
  return () => ({
6402
6431
  exists: env.sampleContentExists,
6403
6432
  path: env.sampleContentPath,
6404
- parentPath: import_path11.default.dirname(env.sampleContentPath)
6433
+ parentPath: import_path13.default.dirname(env.sampleContentPath)
6405
6434
  });
6406
6435
  }
6407
6436
  },
6408
- overwrite: (_a = config2.overwriteList) == null ? void 0 : _a.includes("sample-content"),
6437
+ overwrite: config2.overwriteList?.includes("sample-content"),
6409
6438
  content: helloWorldPost,
6410
6439
  typescript: false
6411
6440
  });
@@ -6424,7 +6453,7 @@ ${titleText(" TinaCMS ")} backend initialized!`));
6424
6453
  return `${x.key}=${x.value || "***"}`;
6425
6454
  }).join("\n") + `
6426
6455
  TINA_PUBLIC_IS_LOCAL=true`;
6427
- const envFile = import_path11.default.join(process.cwd(), ".env");
6456
+ const envFile = import_path13.default.join(process.cwd(), ".env");
6428
6457
  if (!import_fs_extra13.default.existsSync(envFile)) {
6429
6458
  logger.info(`Adding .env file to your project... \u2705`);
6430
6459
  import_fs_extra13.default.writeFileSync(envFile, envFileText);
@@ -6470,7 +6499,8 @@ var other = ({ packageManager }) => {
6470
6499
  pnpm: `pnpm`,
6471
6500
  npm: `npx`,
6472
6501
  // npx is the way to run executables that aren't in your "scripts"
6473
- yarn: `yarn`
6502
+ yarn: `yarn`,
6503
+ bun: `bun run`
6474
6504
  };
6475
6505
  return `${packageManagers[packageManager]} tinacms dev -c "<your dev command>"`;
6476
6506
  };
@@ -6483,7 +6513,8 @@ var frameworkDevCmds = {
6483
6513
  pnpm: `pnpm`,
6484
6514
  npm: `npm run`,
6485
6515
  // npx is the way to run executables that aren't in your "scripts"
6486
- yarn: `yarn`
6516
+ yarn: `yarn`,
6517
+ bun: `bun run`
6487
6518
  };
6488
6519
  return `${packageManagers[packageManager]} dev`;
6489
6520
  }
@@ -6496,12 +6527,11 @@ var addReactiveFile = {
6496
6527
  baseDir,
6497
6528
  dataLayer
6498
6529
  }) => {
6499
- var _a, _b;
6500
- const packageJsonPath = import_path11.default.join(baseDir, "package.json");
6530
+ const packageJsonPath = import_path13.default.join(baseDir, "package.json");
6501
6531
  await writeGeneratedFile({
6502
6532
  generatedFile,
6503
6533
  typescript: config2.typescript,
6504
- overwrite: (_a = config2.overwriteList) == null ? void 0 : _a.includes(
6534
+ overwrite: config2.overwriteList?.includes(
6505
6535
  generatedFile.generatedFileType
6506
6536
  ),
6507
6537
  content: templates["demo-post-page"]({
@@ -6517,7 +6547,7 @@ var addReactiveFile = {
6517
6547
  ...packageJson,
6518
6548
  scripts: extendNextScripts(scripts, {
6519
6549
  isLocalEnvVarName: config2.isLocalEnvVarName,
6520
- addSetupUsers: ((_b = config2.authProvider) == null ? void 0 : _b.name) === "next-auth"
6550
+ addSetupUsers: config2.authProvider?.name === "next-auth"
6521
6551
  })
6522
6552
  },
6523
6553
  null,
@@ -6592,6 +6622,15 @@ var InitCommand = class extends import_clipanion6.Command {
6592
6622
  description: "Specify a version for tina dependencies"
6593
6623
  });
6594
6624
  }
6625
+ static {
6626
+ this.paths = [["init"], ["init", "backend"]];
6627
+ }
6628
+ static {
6629
+ this.usage = import_clipanion6.Command.Usage({
6630
+ category: `Commands`,
6631
+ description: `Add Tina to an existing project`
6632
+ });
6633
+ }
6595
6634
  async catch(error) {
6596
6635
  logger.error("Error occured during tinacms init");
6597
6636
  console.error(error);
@@ -6611,11 +6650,6 @@ var InitCommand = class extends import_clipanion6.Command {
6611
6650
  process.exit();
6612
6651
  }
6613
6652
  };
6614
- InitCommand.paths = [["init"], ["init", "backend"]];
6615
- InitCommand.usage = import_clipanion6.Command.Usage({
6616
- category: `Commands`,
6617
- description: `Add Tina to an existing project`
6618
- });
6619
6653
 
6620
6654
  // src/next/commands/searchindex-command/index.ts
6621
6655
  var import_clipanion7 = require("clipanion");
@@ -6631,13 +6665,21 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6631
6665
  description: "increase verbosity of logged output"
6632
6666
  });
6633
6667
  }
6668
+ static {
6669
+ this.paths = [["search-index"]];
6670
+ }
6671
+ static {
6672
+ this.usage = import_clipanion7.Command.Usage({
6673
+ category: `Commands`,
6674
+ description: `Index the site for search`
6675
+ });
6676
+ }
6634
6677
  async catch(error) {
6635
6678
  logger.error("Error occured during tinacms search-index");
6636
6679
  console.error(error);
6637
6680
  process.exit(1);
6638
6681
  }
6639
6682
  async execute() {
6640
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
6641
6683
  const rootPath = this.rootPath || process.cwd();
6642
6684
  const configManager = new ConfigManager({ rootPath });
6643
6685
  try {
@@ -6648,7 +6690,7 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6648
6690
  console.error(e);
6649
6691
  }
6650
6692
  }
6651
- if (!((_a = configManager.config) == null ? void 0 : _a.search)) {
6693
+ if (!configManager.config?.search) {
6652
6694
  logger.error("No search config found");
6653
6695
  process.exit(1);
6654
6696
  }
@@ -6657,9 +6699,9 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6657
6699
  schema: { ...schema, config: configManager.config }
6658
6700
  });
6659
6701
  let client;
6660
- const hasTinaSearch = Boolean((_c = (_b = configManager.config) == null ? void 0 : _b.search) == null ? void 0 : _c.tina);
6702
+ const hasTinaSearch = Boolean(configManager.config?.search?.tina);
6661
6703
  if (hasTinaSearch) {
6662
- if (!((_d = configManager.config) == null ? void 0 : _d.branch)) {
6704
+ if (!configManager.config?.branch) {
6663
6705
  logger.error(
6664
6706
  `${dangerText(
6665
6707
  `ERROR: Branch not configured in tina search configuration.`
@@ -6667,11 +6709,11 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6667
6709
  );
6668
6710
  throw new Error("Branch not configured in tina search configuration.");
6669
6711
  }
6670
- if (!((_e = configManager.config) == null ? void 0 : _e.clientId)) {
6712
+ if (!configManager.config?.clientId) {
6671
6713
  logger.error(`${dangerText(`ERROR: clientId not configured.`)}`);
6672
6714
  throw new Error("clientId not configured.");
6673
6715
  }
6674
- if (!((_h = (_g = (_f = configManager.config) == null ? void 0 : _f.search) == null ? void 0 : _g.tina) == null ? void 0 : _h.indexerToken)) {
6716
+ if (!configManager.config?.search?.tina?.indexerToken) {
6675
6717
  logger.error(
6676
6718
  `${dangerText(
6677
6719
  `ERROR: indexerToken not configured in tina search configuration.`
@@ -6682,22 +6724,22 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6682
6724
  );
6683
6725
  }
6684
6726
  client = new import_search3.TinaCMSSearchIndexClient({
6685
- apiUrl: `${((_i = configManager.config.tinaioConfig) == null ? void 0 : _i.contentApiUrlOverride) || "https://content.tinajs.io"}/searchIndex/${(_j = configManager.config) == null ? void 0 : _j.clientId}`,
6686
- branch: (_k = configManager.config) == null ? void 0 : _k.branch,
6687
- indexerToken: (_n = (_m = (_l = configManager.config) == null ? void 0 : _l.search) == null ? void 0 : _m.tina) == null ? void 0 : _n.indexerToken,
6688
- stopwordLanguages: (_q = (_p = (_o = configManager.config) == null ? void 0 : _o.search) == null ? void 0 : _p.tina) == null ? void 0 : _q.stopwordLanguages
6727
+ apiUrl: `${configManager.config.tinaioConfig?.contentApiUrlOverride || "https://content.tinajs.io"}/searchIndex/${configManager.config?.clientId}`,
6728
+ branch: configManager.config?.branch,
6729
+ indexerToken: configManager.config?.search?.tina?.indexerToken,
6730
+ stopwordLanguages: configManager.config?.search?.tina?.stopwordLanguages
6689
6731
  });
6690
6732
  } else {
6691
- client = (_s = (_r = configManager.config) == null ? void 0 : _r.search) == null ? void 0 : _s.searchClient;
6733
+ client = configManager.config?.search?.searchClient;
6692
6734
  }
6693
6735
  const searchIndexer = new import_search3.SearchIndexer({
6694
- batchSize: ((_t = configManager.config.search) == null ? void 0 : _t.indexBatchSize) || 100,
6736
+ batchSize: configManager.config.search?.indexBatchSize || 100,
6695
6737
  bridge: new import_graphql17.FilesystemBridge(
6696
6738
  configManager.rootPath,
6697
6739
  configManager.contentRootPath
6698
6740
  ),
6699
6741
  schema: tinaSchema,
6700
- textIndexLength: ((_u = configManager.config.search) == null ? void 0 : _u.maxSearchIndexFieldLength) || 100,
6742
+ textIndexLength: configManager.config.search?.maxSearchIndexFieldLength || 100,
6701
6743
  client
6702
6744
  });
6703
6745
  let err;
@@ -6718,11 +6760,6 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6718
6760
  process.exit(0);
6719
6761
  }
6720
6762
  };
6721
- SearchIndexCommand.paths = [["search-index"]];
6722
- SearchIndexCommand.usage = import_clipanion7.Command.Usage({
6723
- category: `Commands`,
6724
- description: `Index the site for search`
6725
- });
6726
6763
 
6727
6764
  // src/index.ts
6728
6765
  var cli = new import_clipanion8.Cli({