@tinacms/cli 0.0.0-e623534-20250401065516 → 0.0.0-e88638d-20250922015536

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.10.3";
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"));
@@ -1807,7 +1814,6 @@ var createConfig = async ({
1807
1814
  noWatch,
1808
1815
  rollupOptions
1809
1816
  }) => {
1810
- var _a, _b, _c, _d, _e, _f, _g, _h;
1811
1817
  const publicEnv = {};
1812
1818
  Object.keys(process.env).forEach((key) => {
1813
1819
  if (key.startsWith("TINA_PUBLIC_") || key.startsWith("NEXT_PUBLIC_") || key === "NODE_ENV" || key === "HEAD") {
@@ -1829,9 +1835,9 @@ var createConfig = async ({
1829
1835
  configManager.generatedFolderPath,
1830
1836
  "static-media.json"
1831
1837
  );
1832
- if ((_b = (_a = configManager.config.media) == null ? void 0 : _a.tina) == null ? void 0 : _b.static) {
1838
+ if (configManager.config.media?.tina?.static) {
1833
1839
  const staticMedia = await listFilesRecursively({
1834
- directoryPath: ((_c = configManager.config.media.tina) == null ? void 0 : _c.mediaRoot) || "",
1840
+ directoryPath: configManager.config.media.tina?.mediaRoot || "",
1835
1841
  config: configManager.config.media.tina,
1836
1842
  roothPath: configManager.rootPath
1837
1843
  });
@@ -1892,7 +1898,7 @@ var createConfig = async ({
1892
1898
  // Used by picomatch https://github.com/micromatch/picomatch/blob/master/lib/utils.js#L4
1893
1899
  "process.platform": `"${process.platform}"`,
1894
1900
  __API_URL__: `"${apiURL}"`,
1895
- __BASE_PATH__: `"${((_e = (_d = configManager.config) == null ? void 0 : _d.build) == null ? void 0 : _e.basePath) || ""}"`,
1901
+ __BASE_PATH__: `"${configManager.config?.build?.basePath || ""}"`,
1896
1902
  __TINA_GRAPHQL_VERSION__: version2
1897
1903
  },
1898
1904
  logLevel: "error",
@@ -1904,7 +1910,7 @@ var createConfig = async ({
1904
1910
  include: ["react/jsx-runtime", "react/jsx-dev-runtime"]
1905
1911
  },
1906
1912
  server: {
1907
- host: (_h = (_g = (_f = configManager.config) == null ? void 0 : _f.build) == null ? void 0 : _g.host) != null ? _h : false,
1913
+ host: configManager.config?.build?.host ?? false,
1908
1914
  watch: noWatch ? {
1909
1915
  ignored: ["**/*"]
1910
1916
  } : {
@@ -1932,7 +1938,8 @@ var createConfig = async ({
1932
1938
  babel: {
1933
1939
  // Supresses the warning [NOTE] babel The code generator has deoptimised the styling of
1934
1940
  compact: true
1935
- }
1941
+ },
1942
+ fastRefresh: false
1936
1943
  }),
1937
1944
  (0, import_vite.splitVendorChunkPlugin)(),
1938
1945
  tinaTailwind(configManager.spaRootPath, configManager.prebuildFilePath),
@@ -1947,17 +1954,17 @@ var import_pluginutils = require("@rollup/pluginutils");
1947
1954
  var import_fs = __toESM(require("fs"));
1948
1955
  var import_vite2 = require("vite");
1949
1956
  var import_esbuild2 = require("esbuild");
1950
- var import_path4 = __toESM(require("path"));
1957
+ var import_path6 = __toESM(require("path"));
1951
1958
  var import_body_parser = __toESM(require("body-parser"));
1952
1959
  var import_cors = __toESM(require("cors"));
1953
1960
  var import_graphql9 = require("@tinacms/graphql");
1954
1961
 
1955
1962
  // src/next/commands/dev-command/server/media.ts
1956
1963
  var import_fs_extra5 = __toESM(require("fs-extra"));
1957
- var import_path3 = __toESM(require("path"));
1964
+ var import_path5 = __toESM(require("path"));
1958
1965
  var import_busboy = __toESM(require("busboy"));
1959
1966
  var createMediaRouter = (config2) => {
1960
- const mediaFolder = import_path3.default.join(
1967
+ const mediaFolder = import_path5.default.join(
1961
1968
  config2.rootPath,
1962
1969
  config2.publicFolder,
1963
1970
  config2.mediaRoot
@@ -1983,10 +1990,9 @@ var createMediaRouter = (config2) => {
1983
1990
  const handlePost = async function(req, res) {
1984
1991
  const bb = (0, import_busboy.default)({ headers: req.headers });
1985
1992
  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));
1993
+ const fullPath = decodeURI(req.url?.slice("/media/upload/".length));
1994
+ const saveTo = import_path5.default.join(mediaFolder, ...fullPath.split("/"));
1995
+ await import_fs_extra5.default.ensureDir(import_path5.default.dirname(saveTo));
1990
1996
  file.pipe(import_fs_extra5.default.createWriteStream(saveTo));
1991
1997
  });
1992
1998
  bb.on("error", (error) => {
@@ -2020,7 +2026,7 @@ var MediaModel = class {
2020
2026
  }
2021
2027
  async listMedia(args) {
2022
2028
  try {
2023
- const folderPath = (0, import_path3.join)(
2029
+ const folderPath = (0, import_path5.join)(
2024
2030
  this.rootPath,
2025
2031
  this.publicFolder,
2026
2032
  this.mediaRoot,
@@ -2035,7 +2041,7 @@ var MediaModel = class {
2035
2041
  }
2036
2042
  const filesStr = await import_fs_extra5.default.readdir(folderPath);
2037
2043
  const filesProm = filesStr.map(async (file) => {
2038
- const filePath = (0, import_path3.join)(folderPath, file);
2044
+ const filePath = (0, import_path5.join)(folderPath, file);
2039
2045
  const stat = await import_fs_extra5.default.stat(filePath);
2040
2046
  let src = `/${file}`;
2041
2047
  const isFile = stat.isFile();
@@ -2086,13 +2092,13 @@ var MediaModel = class {
2086
2092
  return {
2087
2093
  files: [],
2088
2094
  directories: [],
2089
- error: error == null ? void 0 : error.toString()
2095
+ error: error?.toString()
2090
2096
  };
2091
2097
  }
2092
2098
  }
2093
2099
  async deleteMedia(args) {
2094
2100
  try {
2095
- const file = (0, import_path3.join)(
2101
+ const file = (0, import_path5.join)(
2096
2102
  this.rootPath,
2097
2103
  this.publicFolder,
2098
2104
  this.mediaRoot,
@@ -2103,7 +2109,7 @@ var MediaModel = class {
2103
2109
  return { ok: true };
2104
2110
  } catch (error) {
2105
2111
  console.error(error);
2106
- return { ok: false, message: error == null ? void 0 : error.toString() };
2112
+ return { ok: false, message: error?.toString() };
2107
2113
  }
2108
2114
  }
2109
2115
  };
@@ -2157,7 +2163,7 @@ var transformTsxPlugin = ({
2157
2163
  const plug = {
2158
2164
  name: "transform-tsx",
2159
2165
  async transform(code, id) {
2160
- const extName = import_path4.default.extname(id);
2166
+ const extName = import_path6.default.extname(id);
2161
2167
  if (extName.startsWith(".tsx") || extName.startsWith(".ts")) {
2162
2168
  const result = await (0, import_esbuild2.transform)(code, { loader: "tsx" });
2163
2169
  return {
@@ -2181,13 +2187,12 @@ var devServerEndPointsPlugin = ({
2181
2187
  server.middlewares.use((0, import_cors.default)());
2182
2188
  server.middlewares.use(import_body_parser.default.json({ limit: "5mb" }));
2183
2189
  server.middlewares.use(async (req, res, next) => {
2184
- var _a;
2185
- const mediaPaths = (_a = configManager.config.media) == null ? void 0 : _a.tina;
2190
+ const mediaPaths = configManager.config.media?.tina;
2186
2191
  const mediaRouter = createMediaRouter({
2187
2192
  rootPath: configManager.rootPath,
2188
2193
  apiURL,
2189
- publicFolder: parseMediaFolder((mediaPaths == null ? void 0 : mediaPaths.publicFolder) || ""),
2190
- mediaRoot: parseMediaFolder((mediaPaths == null ? void 0 : mediaPaths.mediaRoot) || "")
2194
+ publicFolder: parseMediaFolder(mediaPaths?.publicFolder || ""),
2195
+ mediaRoot: parseMediaFolder(mediaPaths?.mediaRoot || "")
2191
2196
  });
2192
2197
  const searchIndexRouter = createSearchIndexRouter({
2193
2198
  config: { apiURL, searchPath: "searchIndex" },
@@ -2260,7 +2265,7 @@ function viteTransformExtension({
2260
2265
  name: "vite-plugin-svgr",
2261
2266
  async transform(code, id) {
2262
2267
  if (filter(id)) {
2263
- const { transform: transform2 } = await Promise.resolve().then(() => __toESM(require("@svgr/core")));
2268
+ const { transform: transform2 } = await import("@svgr/core");
2264
2269
  const svgCode = await import_fs.default.promises.readFile(
2265
2270
  id.replace(/\?.*$/, ""),
2266
2271
  "utf8"
@@ -2345,6 +2350,20 @@ var DevCommand = class extends BaseCommand {
2345
2350
  });
2346
2351
  this.indexingLock = new import_async_lock.default();
2347
2352
  }
2353
+ static {
2354
+ this.paths = [["dev"], ["server:start"]];
2355
+ }
2356
+ static {
2357
+ // Prevent indexes and reads occurring at once
2358
+ this.usage = import_clipanion2.Command.Usage({
2359
+ category: `Commands`,
2360
+ description: `Builds Tina and starts the dev server`,
2361
+ examples: [
2362
+ [`A basic example`, `$0 dev`],
2363
+ [`A second example`, `$0 dev --rootPath`]
2364
+ ]
2365
+ });
2366
+ }
2348
2367
  async catch(error) {
2349
2368
  logger.error("Error occured during tinacms dev");
2350
2369
  console.error(error);
@@ -2359,7 +2378,6 @@ var DevCommand = class extends BaseCommand {
2359
2378
  }
2360
2379
  }
2361
2380
  async execute() {
2362
- var _a, _b, _c, _d, _e, _f;
2363
2381
  const configManager = new ConfigManager({
2364
2382
  rootPath: this.rootPath,
2365
2383
  legacyNoSDK: this.noSDK
@@ -2409,14 +2427,14 @@ var DevCommand = class extends BaseCommand {
2409
2427
  graphql: graphqlSchemaObject
2410
2428
  });
2411
2429
  import_fs_extra6.default.writeFileSync(
2412
- import_path5.default.join(configManager.tinaFolderPath, tinaLockFilename),
2430
+ import_path7.default.join(configManager.tinaFolderPath, tinaLockFilename),
2413
2431
  tinaLockContent
2414
2432
  );
2415
2433
  if (configManager.hasSeparateContentRoot()) {
2416
2434
  const rootPath = await configManager.getTinaFolderPath(
2417
2435
  configManager.contentRootPath
2418
2436
  );
2419
- const filePath = import_path5.default.join(rootPath, tinaLockFilename);
2437
+ const filePath = import_path7.default.join(rootPath, tinaLockFilename);
2420
2438
  await import_fs_extra6.default.ensureFile(filePath);
2421
2439
  await import_fs_extra6.default.outputFile(filePath, tinaLockContent);
2422
2440
  }
@@ -2467,19 +2485,19 @@ ${dangerText(e.message)}
2467
2485
  "index.html\nassets/"
2468
2486
  );
2469
2487
  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
2488
+ stopwordLanguages: configManager.config.search?.tina?.stopwordLanguages,
2489
+ tokenSplitRegex: configManager.config.search?.tina?.tokenSplitRegex
2472
2490
  });
2473
2491
  await searchIndexClient.onStartIndexing();
2474
2492
  const searchIndexer = new import_search.SearchIndexer({
2475
- batchSize: ((_e = configManager.config.search) == null ? void 0 : _e.indexBatchSize) || 100,
2493
+ batchSize: configManager.config.search?.indexBatchSize || 100,
2476
2494
  bridge: new import_graphql10.FilesystemBridge(
2477
2495
  configManager.rootPath,
2478
2496
  configManager.contentRootPath
2479
2497
  ),
2480
2498
  schema: tinaSchema,
2481
2499
  client: searchIndexClient,
2482
- textIndexLength: ((_f = configManager.config.search) == null ? void 0 : _f.maxSearchIndexFieldLength) || 100
2500
+ textIndexLength: configManager.config.search?.maxSearchIndexFieldLength || 100
2483
2501
  });
2484
2502
  if (configManager.config.search) {
2485
2503
  await spin({
@@ -2576,11 +2594,11 @@ ${dangerText(e.message)}
2576
2594
  // subItems: [
2577
2595
  // {
2578
2596
  // key: 'Custom queries',
2579
- // value: 'https://tina.io/querying',
2597
+ // value: 'https://tina.io/docs/r/content-api-overview',
2580
2598
  // },
2581
2599
  // {
2582
2600
  // key: 'Visual editing',
2583
- // value: 'https://tina.io/visual-editing',
2601
+ // value: 'https://tina.io/docs/r/visual-editing-setup',
2584
2602
  // },
2585
2603
  // ],
2586
2604
  // },
@@ -2591,7 +2609,7 @@ ${dangerText(e.message)}
2591
2609
  watchContentFiles(configManager, database, databaseLock, searchIndexer) {
2592
2610
  const collectionContentFiles = [];
2593
2611
  configManager.config.schema.collections.forEach((collection) => {
2594
- const collectionGlob = `${import_path5.default.join(
2612
+ const collectionGlob = `${import_path7.default.join(
2595
2613
  configManager.contentRootPath,
2596
2614
  collection.path
2597
2615
  )}/**/*.${collection.format || "md"}`;
@@ -2638,20 +2656,10 @@ ${dangerText(e.message)}
2638
2656
  import_chokidar.default.watch(configManager.userQueriesAndFragmentsGlob).on("add", executeCallback).on("change", executeCallback).on("unlink", executeCallback);
2639
2657
  }
2640
2658
  };
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
2659
 
2652
2660
  // src/next/commands/build-command/index.ts
2653
2661
  var import_crypto = __toESM(require("crypto"));
2654
- var import_path6 = __toESM(require("path"));
2662
+ var import_path8 = __toESM(require("path"));
2655
2663
  var import_core3 = require("@graphql-inspector/core");
2656
2664
  var import_graphql11 = require("@tinacms/graphql");
2657
2665
  var import_schema_tools2 = require("@tinacms/schema-tools");
@@ -2666,7 +2674,7 @@ var import_core2 = require("@graphql-inspector/core");
2666
2674
  var getFaqLink = (type) => {
2667
2675
  switch (type) {
2668
2676
  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";
2677
+ return "https://tina.io/docs/r/FAQ/#2-how-do-i-resolve-the-local-graphql-schema-doesnt-match-the-remote-graphql-schema-error";
2670
2678
  }
2671
2679
  default:
2672
2680
  return null;
@@ -2845,12 +2853,20 @@ var BuildCommand = class extends BaseCommand {
2845
2853
  description: "Disables the client build cache"
2846
2854
  });
2847
2855
  }
2856
+ static {
2857
+ this.paths = [["build"]];
2858
+ }
2859
+ static {
2860
+ this.usage = import_clipanion3.Command.Usage({
2861
+ category: `Commands`,
2862
+ description: `Build the CMS and autogenerated modules for usage with TinaCloud`
2863
+ });
2864
+ }
2848
2865
  async catch(error) {
2849
2866
  console.error(error);
2850
2867
  process.exit(1);
2851
2868
  }
2852
2869
  async execute() {
2853
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
2854
2870
  logger.info("Starting Tina build");
2855
2871
  this.logDeprecationWarnings();
2856
2872
  const configManager = new ConfigManager({
@@ -2939,45 +2955,63 @@ ${dangerText(e.message)}
2939
2955
  }
2940
2956
  const skipCloudChecks = this.skipCloudChecks || configManager.hasSelfHostedConfig();
2941
2957
  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
- )}`
2958
+ try {
2959
+ const clientInfo = await this.checkClientInfo(
2960
+ configManager,
2961
+ codegen2.productionUrl,
2962
+ this.previewBaseBranch
2952
2963
  );
2964
+ if (clientInfo.detectedBotBranch) {
2965
+ logger.warn(
2966
+ `${warnText(
2967
+ `WARN: Detected bot branch. Using schema/content from default branch '${clientInfo.defaultBranch}' instead of '${configManager.config.branch}'.`
2968
+ )}`
2969
+ );
2970
+ }
2971
+ if (!clientInfo.hasUpstream && this.upstreamBranch) {
2972
+ logger.warn(
2973
+ `${dangerText(
2974
+ `WARN: Upstream branch '${this.upstreamBranch}' specified but no upstream project was found.`
2975
+ )}`
2976
+ );
2977
+ }
2978
+ if (clientInfo.hasUpstream || this.previewBaseBranch && this.previewName) {
2979
+ await this.syncProject(configManager, codegen2.productionUrl, {
2980
+ upstreamBranch: this.upstreamBranch,
2981
+ previewBaseBranch: this.previewBaseBranch,
2982
+ previewName: this.previewName
2983
+ });
2984
+ }
2985
+ await waitForDB(
2986
+ configManager.config,
2987
+ codegen2.productionUrl,
2988
+ this.previewName,
2989
+ false
2990
+ );
2991
+ await this.checkGraphqlSchema(
2992
+ configManager,
2993
+ database,
2994
+ codegen2.productionUrl,
2995
+ clientInfo.timestamp
2996
+ );
2997
+ await this.checkTinaSchema(
2998
+ configManager,
2999
+ database,
3000
+ codegen2.productionUrl,
3001
+ this.previewName,
3002
+ this.verbose,
3003
+ clientInfo.timestamp
3004
+ );
3005
+ } catch (e) {
3006
+ logger.error(`
3007
+
3008
+ ${dangerText(e.message)}
3009
+ `);
3010
+ if (this.verbose) {
3011
+ console.error(e);
3012
+ }
3013
+ process.exit(1);
2953
3014
  }
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
3015
  }
2982
3016
  await buildProductionSpa(configManager, database, codegen2.productionUrl);
2983
3017
  await import_fs_extra7.default.outputFile(
@@ -2986,9 +3020,9 @@ ${dangerText(e.message)}
2986
3020
  );
2987
3021
  if (configManager.config.search && !this.skipSearchIndex && !this.localOption) {
2988
3022
  let client;
2989
- const hasTinaSearch = Boolean((_b = (_a = configManager.config) == null ? void 0 : _a.search) == null ? void 0 : _b.tina);
3023
+ const hasTinaSearch = Boolean(configManager.config?.search?.tina);
2990
3024
  if (hasTinaSearch) {
2991
- if (!((_c = configManager.config) == null ? void 0 : _c.branch)) {
3025
+ if (!configManager.config?.branch) {
2992
3026
  logger.error(
2993
3027
  `${dangerText(
2994
3028
  `ERROR: Branch not configured in tina search configuration.`
@@ -2998,11 +3032,11 @@ ${dangerText(e.message)}
2998
3032
  "Branch not configured in tina search configuration."
2999
3033
  );
3000
3034
  }
3001
- if (!((_d = configManager.config) == null ? void 0 : _d.clientId)) {
3035
+ if (!configManager.config?.clientId) {
3002
3036
  logger.error(`${dangerText(`ERROR: clientId not configured.`)}`);
3003
3037
  throw new Error("clientId not configured.");
3004
3038
  }
3005
- if (!((_g = (_f = (_e = configManager.config) == null ? void 0 : _e.search) == null ? void 0 : _f.tina) == null ? void 0 : _g.indexerToken)) {
3039
+ if (!configManager.config?.search?.tina?.indexerToken) {
3006
3040
  logger.error(
3007
3041
  `${dangerText(
3008
3042
  `ERROR: indexerToken not configured in tina search configuration.`
@@ -3013,16 +3047,16 @@ ${dangerText(e.message)}
3013
3047
  );
3014
3048
  }
3015
3049
  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
3050
+ apiUrl: `${configManager.config.tinaioConfig?.contentApiUrlOverride || "https://content.tinajs.io"}/searchIndex/${configManager.config?.clientId}`,
3051
+ branch: configManager.config?.branch,
3052
+ indexerToken: configManager.config?.search?.tina?.indexerToken,
3053
+ stopwordLanguages: configManager.config?.search?.tina?.stopwordLanguages
3020
3054
  });
3021
3055
  } else {
3022
- client = (_r = (_q = configManager.config) == null ? void 0 : _q.search) == null ? void 0 : _r.searchClient;
3056
+ client = configManager.config?.search?.searchClient;
3023
3057
  }
3024
3058
  const searchIndexer = new import_search2.SearchIndexer({
3025
- batchSize: ((_s = configManager.config.search) == null ? void 0 : _s.indexBatchSize) || 100,
3059
+ batchSize: configManager.config.search?.indexBatchSize || 100,
3026
3060
  bridge: new import_graphql11.FilesystemBridge(
3027
3061
  configManager.rootPath,
3028
3062
  configManager.contentRootPath
@@ -3090,86 +3124,88 @@ ${dangerText(e.message)}
3090
3124
  }
3091
3125
  }
3092
3126
  async checkClientInfo(configManager, apiURL, previewBaseBranch) {
3127
+ const MAX_RETRIES = 5;
3093
3128
  const { config: config2 } = configManager;
3094
3129
  const token = config2.token;
3095
3130
  const { clientId, branch, host } = (0, import_schema_tools2.parseURL)(apiURL);
3096
- const url = `https://${host}/db/${clientId}/status/${previewBaseBranch || branch}`;
3097
3131
  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;
3132
+ const getBranchInfo = async () => {
3133
+ const url = `https://${host}/db/${clientId}/status/${previewBaseBranch || branch}`;
3134
+ const branchInfo2 = {
3135
+ status: "unknown",
3136
+ branchKnown: false,
3137
+ hasUpstream: false,
3138
+ timestamp: 0,
3139
+ detectedBotBranch: false,
3140
+ defaultBranch: void 0
3141
+ };
3142
+ try {
3143
+ const res = await request({
3144
+ token,
3145
+ url
3146
+ });
3147
+ branchInfo2.status = res.status;
3148
+ branchInfo2.branchKnown = res.status !== "unknown";
3149
+ branchInfo2.timestamp = res.timestamp || 0;
3150
+ branchInfo2.hasUpstream = res.hasUpstream;
3151
+ branchInfo2.detectedBotBranch = res.json.detectedBotBranch;
3152
+ branchInfo2.defaultBranch = res.json.defaultBranch;
3153
+ } catch (e) {
3154
+ summary({
3155
+ heading: "Error when checking client information",
3156
+ items: [
3157
+ {
3158
+ emoji: "\u274C",
3159
+ heading: "You provided",
3160
+ subItems: [
3161
+ {
3162
+ key: "clientId",
3163
+ value: config2.clientId
3164
+ },
3165
+ {
3166
+ key: "branch",
3167
+ value: config2.branch
3168
+ },
3169
+ {
3170
+ key: "token",
3171
+ value: config2.token
3172
+ }
3173
+ ]
3174
+ }
3175
+ ]
3176
+ });
3177
+ throw e;
3115
3178
  }
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) {
3179
+ return branchInfo2;
3180
+ };
3181
+ const branchInfo = await getBranchInfo();
3182
+ bar2.tick({
3183
+ prog: "\u2705"
3184
+ });
3185
+ const branchBar = new import_progress2.default(
3186
+ `Checking branch '${config2.branch}' is on TinaCloud. :prog`,
3187
+ 1
3188
+ );
3189
+ if (branchInfo.branchKnown) {
3144
3190
  branchBar.tick({
3145
3191
  prog: "\u2705"
3146
3192
  });
3147
- return {
3148
- hasUpstream,
3149
- timestamp
3150
- };
3193
+ return branchInfo;
3151
3194
  }
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
- });
3195
+ for (let i = 1; i <= MAX_RETRIES; i++) {
3196
+ await timeout(5e3);
3197
+ const branchInfo2 = await getBranchInfo();
3198
+ if (this.verbose) {
3199
+ logger.info(
3200
+ `Branch status: ${branchInfo2.status}. Attempt: ${i}. Trying again in 5 seconds.`
3201
+ );
3202
+ }
3203
+ if (branchInfo2.branchKnown) {
3204
+ branchBar.tick({
3205
+ prog: "\u2705"
3206
+ });
3207
+ return branchInfo2;
3208
+ }
3173
3209
  }
3174
3210
  branchBar.tick({
3175
3211
  prog: "\u274C"
@@ -3177,7 +3213,7 @@ ${dangerText(e.message)}
3177
3213
  logger.error(
3178
3214
  `${dangerText(
3179
3215
  `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(
3216
+ )} 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
3217
  `https://app.tina.io/projects/${clientId}/configuration`
3182
3218
  )}`
3183
3219
  );
@@ -3252,7 +3288,7 @@ ${dangerText(e.message)}
3252
3288
  prog: "\u274C"
3253
3289
  });
3254
3290
  let errorMessage = `The remote GraphQL schema does not exist. Check indexing for this branch.`;
3255
- if (config2 == null ? void 0 : config2.branch) {
3291
+ if (config2?.branch) {
3256
3292
  errorMessage += `
3257
3293
 
3258
3294
  Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
@@ -3284,7 +3320,7 @@ Check out '${faqLink}' for possible solutions.`}`;
3284
3320
  Additional info:
3285
3321
 
3286
3322
  `;
3287
- if (config2 == null ? void 0 : config2.branch) {
3323
+ if (config2?.branch) {
3288
3324
  errorMessage += ` Branch: ${config2.branch}, Client ID: ${config2.clientId}
3289
3325
  `;
3290
3326
  }
@@ -3333,7 +3369,7 @@ Additional info:
3333
3369
  prog: "\u274C"
3334
3370
  });
3335
3371
  let errorMessage = `The remote Tina schema does not exist. Check indexing for this branch.`;
3336
- if (config2 == null ? void 0 : config2.branch) {
3372
+ if (config2?.branch) {
3337
3373
  errorMessage += `
3338
3374
 
3339
3375
  Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
@@ -3345,7 +3381,7 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3345
3381
  }
3346
3382
  const localTinaSchema = JSON.parse(
3347
3383
  await database.bridge.get(
3348
- import_path6.default.join(database.tinaDirectory, "__generated__", "_schema.json")
3384
+ import_path8.default.join(database.tinaDirectory, "__generated__", "_schema.json")
3349
3385
  )
3350
3386
  );
3351
3387
  localTinaSchema.version = void 0;
@@ -3364,7 +3400,7 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3364
3400
  Additional info:
3365
3401
 
3366
3402
  `;
3367
- if (config2 == null ? void 0 : config2.branch) {
3403
+ if (config2?.branch) {
3368
3404
  errorMessage += ` Branch: ${config2.branch}, Client ID: ${config2.clientId}
3369
3405
  `;
3370
3406
  }
@@ -3376,18 +3412,13 @@ Additional info:
3376
3412
  }
3377
3413
  }
3378
3414
  };
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
3415
  async function request(args) {
3385
3416
  const headers = new Headers();
3386
3417
  if (args.token) {
3387
3418
  headers.append("X-API-KEY", args.token);
3388
3419
  }
3389
3420
  headers.append("Content-Type", "application/json");
3390
- const url = args == null ? void 0 : args.url;
3421
+ const url = args?.url;
3391
3422
  const res = await fetch(url, {
3392
3423
  method: args.method || "GET",
3393
3424
  headers,
@@ -3405,21 +3436,22 @@ async function request(args) {
3405
3436
  Message from server: ${json.message}`;
3406
3437
  }
3407
3438
  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/`
3439
+ `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
3440
  );
3410
3441
  }
3411
3442
  if (json.errors) {
3412
3443
  throw new Error(
3413
- `Unable to fetch, please see our FAQ for more information: https://tina.io/docs/errors/faq/
3444
+ `Unable to fetch, please see our FAQ for more information: https://tina.io/docs/r/FAQ/
3414
3445
 
3415
3446
  Errors:
3416
3447
  ${json.errors.map((error) => error.message).join("\n")}`
3417
3448
  );
3418
3449
  }
3419
3450
  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
3451
+ status: json?.status,
3452
+ timestamp: json?.timestamp,
3453
+ hasUpstream: json?.hasUpstream || false,
3454
+ json
3423
3455
  };
3424
3456
  }
3425
3457
  var fetchRemoteGraphqlSchema = async ({
@@ -3442,7 +3474,7 @@ var fetchRemoteGraphqlSchema = async ({
3442
3474
  });
3443
3475
  const data = await res.json();
3444
3476
  return {
3445
- remoteSchema: data == null ? void 0 : data.data,
3477
+ remoteSchema: data?.data,
3446
3478
  remoteRuntimeVersion: res.headers.get("tinacms-grapqhl-version"),
3447
3479
  remoteProjectVersion: res.headers.get("tinacms-graphql-project-version")
3448
3480
  };
@@ -3652,6 +3684,15 @@ var AuditCommand = class extends import_clipanion4.Command {
3652
3684
  description: "Specify a port to run the datalayer server on. (default 9000)"
3653
3685
  });
3654
3686
  }
3687
+ static {
3688
+ this.paths = [["audit"]];
3689
+ }
3690
+ static {
3691
+ this.usage = import_clipanion4.Command.Usage({
3692
+ category: `Commands`,
3693
+ description: `Audit config and content files`
3694
+ });
3695
+ }
3655
3696
  async catch(error) {
3656
3697
  logger.error("Error occured during tinacms audit");
3657
3698
  if (this.verbose) {
@@ -3705,36 +3746,31 @@ var AuditCommand = class extends import_clipanion4.Command {
3705
3746
  process.exit();
3706
3747
  }
3707
3748
  };
3708
- AuditCommand.paths = [["audit"]];
3709
- AuditCommand.usage = import_clipanion4.Command.Usage({
3710
- category: `Commands`,
3711
- description: `Audit config and content files`
3712
- });
3713
3749
 
3714
3750
  // src/next/commands/init-command/index.ts
3715
3751
  var import_clipanion6 = require("clipanion");
3716
3752
 
3717
3753
  // src/cmds/init/detectEnvironment.ts
3718
3754
  var import_fs_extra8 = __toESM(require("fs-extra"));
3719
- var import_path7 = __toESM(require("path"));
3755
+ var import_path9 = __toESM(require("path"));
3720
3756
  var checkGitignoreForItem = async ({
3721
3757
  baseDir,
3722
3758
  line
3723
3759
  }) => {
3724
- const gitignoreContent = import_fs_extra8.default.readFileSync(import_path7.default.join(baseDir, ".gitignore")).toString();
3760
+ const gitignoreContent = import_fs_extra8.default.readFileSync(import_path9.default.join(baseDir, ".gitignore")).toString();
3725
3761
  return gitignoreContent.split("\n").some((item) => item === line);
3726
3762
  };
3727
3763
  var makeGeneratedFile = async (name2, generatedFileType, parentPath, opts) => {
3728
3764
  const result = {
3729
- fullPathTS: import_path7.default.join(
3765
+ fullPathTS: import_path9.default.join(
3730
3766
  parentPath,
3731
- `${name2}.${(opts == null ? void 0 : opts.typescriptSuffix) || (opts == null ? void 0 : opts.extensionOverride) || "ts"}`
3767
+ `${name2}.${opts?.typescriptSuffix || opts?.extensionOverride || "ts"}`
3732
3768
  ),
3733
- fullPathJS: import_path7.default.join(
3769
+ fullPathJS: import_path9.default.join(
3734
3770
  parentPath,
3735
- `${name2}.${(opts == null ? void 0 : opts.extensionOverride) || "js"}`
3771
+ `${name2}.${opts?.extensionOverride || "js"}`
3736
3772
  ),
3737
- fullPathOverride: (opts == null ? void 0 : opts.extensionOverride) ? import_path7.default.join(parentPath, `${name2}.${opts == null ? void 0 : opts.extensionOverride}`) : "",
3773
+ fullPathOverride: opts?.extensionOverride ? import_path9.default.join(parentPath, `${name2}.${opts?.extensionOverride}`) : "",
3738
3774
  generatedFileType,
3739
3775
  name: name2,
3740
3776
  parentPath,
@@ -3762,18 +3798,17 @@ var detectEnvironment = async ({
3762
3798
  rootPath,
3763
3799
  debug = false
3764
3800
  }) => {
3765
- var _a;
3766
3801
  const hasForestryConfig = await import_fs_extra8.default.pathExists(
3767
- import_path7.default.join(pathToForestryConfig, ".forestry", "settings.yml")
3802
+ import_path9.default.join(pathToForestryConfig, ".forestry", "settings.yml")
3768
3803
  );
3769
- const sampleContentPath = import_path7.default.join(
3804
+ const sampleContentPath = import_path9.default.join(
3770
3805
  baseDir,
3771
3806
  "content",
3772
3807
  "posts",
3773
3808
  "hello-world.md"
3774
3809
  );
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");
3810
+ 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")));
3811
+ const tinaFolder = import_path9.default.join(baseDir, "tina");
3777
3812
  const tinaConfigExists = Boolean(
3778
3813
  // Does the tina folder exist?
3779
3814
  await import_fs_extra8.default.pathExists(tinaFolder) && // Does the tina folder contain a config file?
@@ -3789,12 +3824,12 @@ var detectEnvironment = async ({
3789
3824
  "next-api-handler": await makeGeneratedFile(
3790
3825
  "[...routes]",
3791
3826
  "next-api-handler",
3792
- import_path7.default.join(...pagesDir, "api", "tina")
3827
+ import_path9.default.join(...pagesDir, "api", "tina")
3793
3828
  ),
3794
3829
  "reactive-example": await makeGeneratedFile(
3795
3830
  "[filename]",
3796
3831
  "reactive-example",
3797
- import_path7.default.join(...pagesDir, "demo", "blog"),
3832
+ import_path9.default.join(...pagesDir, "demo", "blog"),
3798
3833
  {
3799
3834
  typescriptSuffix: "tsx"
3800
3835
  }
@@ -3802,13 +3837,13 @@ var detectEnvironment = async ({
3802
3837
  "users-json": await makeGeneratedFile(
3803
3838
  "index",
3804
3839
  "users-json",
3805
- import_path7.default.join(baseDir, "content", "users"),
3840
+ import_path9.default.join(baseDir, "content", "users"),
3806
3841
  { extensionOverride: "json" }
3807
3842
  ),
3808
3843
  "sample-content": await makeGeneratedFile(
3809
3844
  "hello-world",
3810
3845
  "sample-content",
3811
- import_path7.default.join(baseDir, "content", "posts"),
3846
+ import_path9.default.join(baseDir, "content", "posts"),
3812
3847
  { extensionOverride: "md" }
3813
3848
  )
3814
3849
  };
@@ -3819,10 +3854,10 @@ var detectEnvironment = async ({
3819
3854
  try {
3820
3855
  const packageJSON = await import_fs_extra8.default.readJSON("package.json");
3821
3856
  const deps = [];
3822
- if (packageJSON == null ? void 0 : packageJSON.dependencies) {
3857
+ if (packageJSON?.dependencies) {
3823
3858
  deps.push(...Object.keys(packageJSON.dependencies));
3824
3859
  }
3825
- if (packageJSON == null ? void 0 : packageJSON.devDependencies) {
3860
+ if (packageJSON?.devDependencies) {
3826
3861
  deps.push(...Object.keys(packageJSON.devDependencies));
3827
3862
  }
3828
3863
  if (deps.includes("@tinacms/cli") && deps.includes("tinacms")) {
@@ -3834,16 +3869,16 @@ var detectEnvironment = async ({
3834
3869
  );
3835
3870
  }
3836
3871
  }
3837
- const hasGitIgnore = await import_fs_extra8.default.pathExists(import_path7.default.join(".gitignore"));
3872
+ const hasGitIgnore = await import_fs_extra8.default.pathExists(import_path9.default.join(".gitignore"));
3838
3873
  const hasGitIgnoreNodeModules = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: "node_modules" });
3839
3874
  const hasEnvTina = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: ".env.tina" });
3840
3875
  const hasGitIgnoreEnv = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: ".env" });
3841
3876
  let frontMatterFormat;
3842
3877
  if (hasForestryConfig) {
3843
- const hugoConfigPath = import_path7.default.join(rootPath, "config.toml");
3878
+ const hugoConfigPath = import_path9.default.join(rootPath, "config.toml");
3844
3879
  if (await import_fs_extra8.default.pathExists(hugoConfigPath)) {
3845
3880
  const hugoConfig = await import_fs_extra8.default.readFile(hugoConfigPath, "utf8");
3846
- const metaDataFormat = (_a = hugoConfig.match(/metaDataFormat = "(.*)"/)) == null ? void 0 : _a[1];
3881
+ const metaDataFormat = hugoConfig.toString().match(/metaDataFormat = "(.*)"/)?.[1];
3847
3882
  if (metaDataFormat && (metaDataFormat === "yaml" || metaDataFormat === "toml" || metaDataFormat === "json")) {
3848
3883
  frontMatterFormat = metaDataFormat;
3849
3884
  }
@@ -3942,7 +3977,7 @@ var chooseGitProvider = async ({ config: config2 }) => {
3942
3977
  ${logText(
3943
3978
  "Learn more here: "
3944
3979
  )}${linkText(
3945
- "https://tina.io/docs/self-hosted/existing-site/#github-personal-access-token"
3980
+ "https://tina.io/docs/r/self-hosting-nextjs/#github-personal-access-token"
3946
3981
  )}`,
3947
3982
  initial: process.env.GITHUB_PERSONAL_ACCESS_TOKEN
3948
3983
  },
@@ -4203,7 +4238,8 @@ var askCommonSetUp = async () => {
4203
4238
  choices: [
4204
4239
  { title: "PNPM", value: "pnpm" },
4205
4240
  { title: "Yarn", value: "yarn" },
4206
- { title: "NPM", value: "npm" }
4241
+ { title: "NPM", value: "npm" },
4242
+ { title: "Bun", value: "bun" }
4207
4243
  ]
4208
4244
  }
4209
4245
  ]);
@@ -4264,7 +4300,7 @@ var askTinaSetupPrompts = async (params) => {
4264
4300
  message: `Where are public assets stored? (default: "public")
4265
4301
  ` + logText(
4266
4302
  `Not sure what value to use? Refer to our "Frameworks" doc: ${linkText(
4267
- "https://tina.io/docs/integration/frameworks/#configuring-tina-with-each-framework"
4303
+ "https://tina.io/docs/r/framework-guides-overview"
4268
4304
  )}`
4269
4305
  )
4270
4306
  });
@@ -4454,18 +4490,19 @@ var CLICommand = class {
4454
4490
  };
4455
4491
 
4456
4492
  // src/cmds/init/apply.ts
4457
- var import_path11 = __toESM(require("path"));
4493
+ var import_path13 = __toESM(require("path"));
4458
4494
 
4459
4495
  // src/cmds/forestry-migrate/index.ts
4460
4496
  var import_fs_extra10 = __toESM(require("fs-extra"));
4461
- var import_path9 = __toESM(require("path"));
4497
+ var import_path11 = __toESM(require("path"));
4462
4498
  var import_js_yaml2 = __toESM(require("js-yaml"));
4463
4499
  var import_minimatch = __toESM(require("minimatch"));
4464
4500
  var import_graphql16 = require("@tinacms/graphql");
4501
+ var import_schema_tools3 = require("@tinacms/schema-tools");
4465
4502
 
4466
4503
  // src/cmds/forestry-migrate/util/index.ts
4467
4504
  var import_fs_extra9 = __toESM(require("fs-extra"));
4468
- var import_path8 = __toESM(require("path"));
4505
+ var import_path10 = __toESM(require("path"));
4469
4506
  var import_js_yaml = __toESM(require("js-yaml"));
4470
4507
  var import_zod = __toESM(require("zod"));
4471
4508
 
@@ -4494,8 +4531,7 @@ var ErrorSingleton = class _ErrorSingleton {
4494
4531
  this.collectionNameErrors.push(error);
4495
4532
  }
4496
4533
  printCollectionNameErrors() {
4497
- var _a;
4498
- if ((_a = this.collectionNameErrors) == null ? void 0 : _a.length) {
4534
+ if (this.collectionNameErrors?.length) {
4499
4535
  logger.error(
4500
4536
  dangerText("ERROR: TinaCMS only supports alphanumeric template names")
4501
4537
  );
@@ -4677,8 +4713,7 @@ var transformForestryFieldsToTinaFields = ({
4677
4713
  skipBlocks = false
4678
4714
  }) => {
4679
4715
  const tinaFields = [];
4680
- fields == null ? void 0 : fields.forEach((forestryField2) => {
4681
- var _a, _b, _c, _d;
4716
+ fields?.forEach((forestryField2) => {
4682
4717
  if (forestryField2.name === "menu") {
4683
4718
  logger.info(
4684
4719
  warnText(
@@ -4754,12 +4789,12 @@ var transformForestryFieldsToTinaFields = ({
4754
4789
  };
4755
4790
  break;
4756
4791
  case "select":
4757
- if ((_a = forestryField2.config) == null ? void 0 : _a.options) {
4792
+ if (forestryField2.config?.options) {
4758
4793
  field = {
4759
4794
  type: "string",
4760
4795
  ...getTinaFieldsFromName(forestryField2.name),
4761
4796
  label: forestryField2.label,
4762
- options: ((_b = forestryField2.config) == null ? void 0 : _b.options) || []
4797
+ options: forestryField2.config?.options || []
4763
4798
  };
4764
4799
  } else {
4765
4800
  logger.info(
@@ -4777,7 +4812,7 @@ var transformForestryFieldsToTinaFields = ({
4777
4812
  label: forestryField2.label,
4778
4813
  list: true
4779
4814
  };
4780
- if ((_c = forestryField2.config) == null ? void 0 : _c.options) {
4815
+ if (forestryField2.config?.options) {
4781
4816
  field.options = forestryField2.config.options;
4782
4817
  }
4783
4818
  break;
@@ -4825,7 +4860,7 @@ var transformForestryFieldsToTinaFields = ({
4825
4860
  break;
4826
4861
  }
4827
4862
  const templates2 = [];
4828
- forestryField2 == null ? void 0 : forestryField2.template_types.forEach((tem) => {
4863
+ forestryField2?.template_types.forEach((tem) => {
4829
4864
  const { template: template2 } = getFieldsFromTemplates({
4830
4865
  tem,
4831
4866
  skipBlocks: true,
@@ -4883,7 +4918,7 @@ var transformForestryFieldsToTinaFields = ({
4883
4918
  );
4884
4919
  }
4885
4920
  if (field) {
4886
- if ((_d = forestryField2.config) == null ? void 0 : _d.required) {
4921
+ if (forestryField2.config?.required) {
4887
4922
  field = { ...field, required: true };
4888
4923
  }
4889
4924
  tinaFields.push(field);
@@ -4892,7 +4927,7 @@ var transformForestryFieldsToTinaFields = ({
4892
4927
  return tinaFields;
4893
4928
  };
4894
4929
  var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false }) => {
4895
- const templatePath = import_path8.default.join(
4930
+ const templatePath = import_path10.default.join(
4896
4931
  pathToForestryConfig,
4897
4932
  ".forestry",
4898
4933
  "front_matter",
@@ -4945,8 +4980,7 @@ var stringifyLabelWithField = (label) => {
4945
4980
  return `${labelString}Fields`;
4946
4981
  };
4947
4982
  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("{}", "");
4983
+ const newMatch = match.replace(" ", "").replace(/\.?(mdx|md|json|yaml|yml|toml)/g, "")?.replace(/\..*$/g, "")?.replace("{}", "");
4950
4984
  if (match !== newMatch) {
4951
4985
  logger.info(
4952
4986
  `Info: Match ${match} was transformed to ${newMatch}. See ${linkText(
@@ -4958,7 +4992,7 @@ var transformForestryMatchToTinaMatch = (match) => {
4958
4992
  };
4959
4993
  function checkExt(ext) {
4960
4994
  const extReal = ext.replace(".", "");
4961
- if (["mdx", "md", "json", "yaml", "yml", "toml"].includes(extReal)) {
4995
+ if (import_schema_tools3.CONTENT_FORMATS.includes(extReal)) {
4962
4996
  return extReal;
4963
4997
  } else {
4964
4998
  return false;
@@ -4968,8 +5002,8 @@ var generateAllTemplates = async ({
4968
5002
  pathToForestryConfig
4969
5003
  }) => {
4970
5004
  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"));
5005
+ import_path11.default.join(pathToForestryConfig, ".forestry", "front_matter", "templates")
5006
+ )).map((tem) => import_path11.default.basename(tem, ".yml"));
4973
5007
  const templateMap = /* @__PURE__ */ new Map();
4974
5008
  const proms = allTemplates.map(async (tem) => {
4975
5009
  try {
@@ -5011,18 +5045,18 @@ var generateCollectionFromForestrySection = (args) => {
5011
5045
  }
5012
5046
  if (section.match) {
5013
5047
  baseCollection.match = {
5014
- ...(baseCollection == null ? void 0 : baseCollection.match) || {},
5048
+ ...baseCollection?.match || {},
5015
5049
  include: transformForestryMatchToTinaMatch(section.match)
5016
5050
  };
5017
5051
  }
5018
5052
  if (section.exclude) {
5019
5053
  baseCollection.match = {
5020
- ...(baseCollection == null ? void 0 : baseCollection.match) || {},
5054
+ ...baseCollection?.match || {},
5021
5055
  exclude: transformForestryMatchToTinaMatch(section.exclude)
5022
5056
  };
5023
5057
  }
5024
5058
  if (section.type === "directory") {
5025
- if (!(section == null ? void 0 : section.path) || section.path === "/" || section.path === "./" || section.path === ".") {
5059
+ if (!section?.path || section.path === "/" || section.path === "./" || section.path === ".") {
5026
5060
  logger.log(
5027
5061
  warnText(
5028
5062
  `Warning: Section ${section.label} is using a Root Path. Currently, Tina Does not support Root paths see ${linkText(
@@ -5032,11 +5066,11 @@ var generateCollectionFromForestrySection = (args) => {
5032
5066
  );
5033
5067
  return;
5034
5068
  }
5035
- const forestryTemplates = (section == null ? void 0 : section.templates) || [];
5069
+ const forestryTemplates = section?.templates || [];
5036
5070
  if (forestryTemplates.length === 0 && section.create === "all") {
5037
5071
  for (const templateKey of templateMap.keys()) {
5038
5072
  const { templateObj } = templateMap.get(templateKey);
5039
- const pages = templateObj == null ? void 0 : templateObj.pages;
5073
+ const pages = templateObj?.pages;
5040
5074
  if (pages) {
5041
5075
  let glob = section.match;
5042
5076
  const skipPath = section.path === "" || section.path === "/" || !section.path;
@@ -5053,7 +5087,7 @@ var generateCollectionFromForestrySection = (args) => {
5053
5087
  }
5054
5088
  const hasBody = ["md", "mdx", "markdown"].includes(format3);
5055
5089
  let c;
5056
- if (((forestryTemplates == null ? void 0 : forestryTemplates.length) || 0) > 1) {
5090
+ if ((forestryTemplates?.length || 0) > 1) {
5057
5091
  c = {
5058
5092
  ...baseCollection,
5059
5093
  // @ts-expect-error
@@ -5075,7 +5109,7 @@ var generateCollectionFromForestrySection = (args) => {
5075
5109
  })
5076
5110
  };
5077
5111
  }
5078
- if ((forestryTemplates == null ? void 0 : forestryTemplates.length) === 1) {
5112
+ if (forestryTemplates?.length === 1) {
5079
5113
  const tem = forestryTemplates[0];
5080
5114
  const template = templateMap.get(tem);
5081
5115
  const fieldsString = stringifyLabelWithField(template.templateObj.label);
@@ -5090,7 +5124,7 @@ var generateCollectionFromForestrySection = (args) => {
5090
5124
  })
5091
5125
  };
5092
5126
  }
5093
- if ((forestryTemplates == null ? void 0 : forestryTemplates.length) === 0) {
5127
+ if (forestryTemplates?.length === 0) {
5094
5128
  logger.warn(
5095
5129
  warnText(
5096
5130
  `No templates found for section ${section.label}. Please see ${linkText(
@@ -5103,7 +5137,7 @@ var generateCollectionFromForestrySection = (args) => {
5103
5137
  fields: [BODY_FIELD]
5104
5138
  };
5105
5139
  }
5106
- if ((section == null ? void 0 : section.create) === "none") {
5140
+ if (section?.create === "none") {
5107
5141
  c.ui = {
5108
5142
  ...c.ui,
5109
5143
  allowedActions: {
@@ -5114,9 +5148,9 @@ var generateCollectionFromForestrySection = (args) => {
5114
5148
  return c;
5115
5149
  } else if (section.type === "document") {
5116
5150
  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);
5151
+ const extname = import_path11.default.extname(filePath);
5152
+ const fileName = import_path11.default.basename(filePath, extname);
5153
+ const dir = import_path11.default.dirname(filePath);
5120
5154
  const ext = checkExt(extname);
5121
5155
  if (ext) {
5122
5156
  const fields = [];
@@ -5125,7 +5159,7 @@ var generateCollectionFromForestrySection = (args) => {
5125
5159
  }
5126
5160
  for (const currentTemplateName of templateMap.keys()) {
5127
5161
  const { templateObj, fields: additionalFields } = templateMap.get(currentTemplateName);
5128
- const pages = (templateObj == null ? void 0 : templateObj.pages) || [];
5162
+ const pages = templateObj?.pages || [];
5129
5163
  if (pages.includes(section.path)) {
5130
5164
  fields.push(...additionalFields);
5131
5165
  break;
@@ -5136,7 +5170,7 @@ var generateCollectionFromForestrySection = (args) => {
5136
5170
  name: "dummy",
5137
5171
  label: "Dummy field",
5138
5172
  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"
5173
+ 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
5174
  });
5141
5175
  logger.warn(
5142
5176
  warnText(
@@ -5179,7 +5213,7 @@ var generateCollections = async ({
5179
5213
  usingTypescript
5180
5214
  });
5181
5215
  const forestryConfig = await import_fs_extra10.default.readFile(
5182
- import_path9.default.join(pathToForestryConfig, ".forestry", "settings.yml")
5216
+ import_path11.default.join(pathToForestryConfig, ".forestry", "settings.yml")
5183
5217
  );
5184
5218
  rewriteTemplateKeysInDocs({
5185
5219
  templateMap,
@@ -5204,17 +5238,16 @@ var generateCollections = async ({
5204
5238
  };
5205
5239
  };
5206
5240
  var rewriteTemplateKeysInDocs = (args) => {
5207
- var _a;
5208
5241
  const { templateMap, markdownParseConfig } = args;
5209
5242
  for (const templateKey of templateMap.keys()) {
5210
5243
  const { templateObj } = templateMap.get(templateKey);
5211
- (_a = templateObj == null ? void 0 : templateObj.pages) == null ? void 0 : _a.forEach((page) => {
5244
+ templateObj?.pages?.forEach((page) => {
5212
5245
  try {
5213
- const filePath = import_path9.default.join(page);
5246
+ const filePath = import_path11.default.join(page);
5214
5247
  if (import_fs_extra10.default.lstatSync(filePath).isDirectory()) {
5215
5248
  return;
5216
5249
  }
5217
- const extname = import_path9.default.extname(filePath);
5250
+ const extname = import_path11.default.extname(filePath);
5218
5251
  const fileContent = import_fs_extra10.default.readFileSync(filePath).toString();
5219
5252
  const content = (0, import_graphql16.parseFile)(
5220
5253
  fileContent,
@@ -5246,7 +5279,7 @@ var import_fs_extra13 = __toESM(require("fs-extra"));
5246
5279
  // src/next/commands/codemod-command/index.ts
5247
5280
  var import_clipanion5 = require("clipanion");
5248
5281
  var import_fs_extra11 = __toESM(require("fs-extra"));
5249
- var import_path10 = __toESM(require("path"));
5282
+ var import_path12 = __toESM(require("path"));
5250
5283
  var CodemodCommand = class extends import_clipanion5.Command {
5251
5284
  constructor() {
5252
5285
  super(...arguments);
@@ -5257,6 +5290,15 @@ var CodemodCommand = class extends import_clipanion5.Command {
5257
5290
  description: "increase verbosity of logged output"
5258
5291
  });
5259
5292
  }
5293
+ static {
5294
+ this.paths = [["codemod"], ["codemod", "move-tina-folder"]];
5295
+ }
5296
+ static {
5297
+ this.usage = import_clipanion5.Command.Usage({
5298
+ category: `Commands`,
5299
+ description: `Use codemods for various Tina tasks`
5300
+ });
5301
+ }
5260
5302
  async catch(error) {
5261
5303
  console.log(error);
5262
5304
  }
@@ -5277,11 +5319,6 @@ var CodemodCommand = class extends import_clipanion5.Command {
5277
5319
  await command2();
5278
5320
  }
5279
5321
  };
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
5322
  var moveTinaFolder = async (rootPath = process.cwd()) => {
5286
5323
  const configManager = new ConfigManager({ rootPath });
5287
5324
  try {
@@ -5290,7 +5327,7 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
5290
5327
  logger.error(e.message);
5291
5328
  process.exit(1);
5292
5329
  }
5293
- const tinaDestination = import_path10.default.join(configManager.rootPath, "tina");
5330
+ const tinaDestination = import_path12.default.join(configManager.rootPath, "tina");
5294
5331
  if (await import_fs_extra11.default.existsSync(tinaDestination)) {
5295
5332
  logger.info(
5296
5333
  `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 +5342,7 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
5305
5342
  };
5306
5343
  var writeGitignore = async (rootPath) => {
5307
5344
  await import_fs_extra11.default.outputFileSync(
5308
- import_path10.default.join(rootPath, "tina", ".gitignore"),
5345
+ import_path12.default.join(rootPath, "tina", ".gitignore"),
5309
5346
  "__generated__"
5310
5347
  );
5311
5348
  };
@@ -5358,7 +5395,7 @@ const BlogPage = (props) => {
5358
5395
  <div className='bg-green-100 text-center'>
5359
5396
  Lost and looking for a place to start?
5360
5397
  <a
5361
- href='https://tina.io/guides/tina-cloud/getting-started/overview/'
5398
+ href='https://tina.io/docs/r/beginner-series'
5362
5399
  className='text-blue-500 underline'
5363
5400
  >
5364
5401
  {' '}
@@ -5561,11 +5598,10 @@ var baseFields = `[
5561
5598
  },
5562
5599
  ]`;
5563
5600
  var generateCollectionString = (args) => {
5564
- var _a, _b, _c, _d;
5565
5601
  if (args.collections) {
5566
5602
  return args.collections;
5567
5603
  }
5568
- let extraTinaCollections = (_b = (_a = args.config.authProvider) == null ? void 0 : _a.extraTinaCollections) == null ? void 0 : _b.join(",\n");
5604
+ let extraTinaCollections = args.config.authProvider?.extraTinaCollections?.join(",\n");
5569
5605
  if (extraTinaCollections) {
5570
5606
  extraTinaCollections = extraTinaCollections + ",";
5571
5607
  }
@@ -5591,18 +5627,17 @@ var generateCollectionString = (args) => {
5591
5627
  },
5592
5628
  },
5593
5629
  ]`;
5594
- if (((_d = (_c = args.config) == null ? void 0 : _c.framework) == null ? void 0 : _d.name) === "next") {
5630
+ if (args.config?.framework?.name === "next") {
5595
5631
  return nextExampleCollection;
5596
5632
  }
5597
5633
  return baseCollections;
5598
5634
  };
5599
5635
  var generateConfig = (args) => {
5600
- var _a, _b, _c;
5601
- const isUsingTinaCloud = !args.selfHosted || ((_a = args.config.authProvider) == null ? void 0 : _a.name) === "tina-cloud";
5636
+ const isUsingTinaCloud = !args.selfHosted || args.config.authProvider?.name === "tina-cloud";
5602
5637
  let extraImports = "";
5603
5638
  if (args.selfHosted) {
5604
5639
  if (args.config.authProvider) {
5605
- extraImports = extraImports + makeImportString((_b = args.config.authProvider) == null ? void 0 : _b.configImports);
5640
+ extraImports = extraImports + makeImportString(args.config.authProvider?.configImports);
5606
5641
  }
5607
5642
  if (!isUsingTinaCloud) {
5608
5643
  extraImports = extraImports + `
@@ -5625,7 +5660,7 @@ import { LocalAuthProvider } from "tinacms";`;
5625
5660
  branch,
5626
5661
  ${args.selfHosted && !isUsingTinaCloud ? `authProvider: isLocal
5627
5662
  ? new LocalAuthProvider()
5628
- :${(_c = args.config) == null ? void 0 : _c.authProvider.configAuthProviderClass},` : ""}
5663
+ :${args.config?.authProvider.configAuthProviderClass},` : ""}
5629
5664
  ${isUsingTinaCloud ? `// Get this from tina.io
5630
5665
  clientId: process.env.NEXT_PUBLIC_TINA_CLIENT_ID,` : ""}
5631
5666
  ${isUsingTinaCloud ? `// Get this from tina.io
@@ -5642,7 +5677,7 @@ import { LocalAuthProvider } from "tinacms";`;
5642
5677
  publicFolder: "${args.publicFolder}",
5643
5678
  },
5644
5679
  },
5645
- // See docs on content modeling for more info on how to setup new content models: https://tina.io/docs/schema/
5680
+ // See docs on content modeling for more info on how to setup new content models: https://tina.io/docs/r/content-modelling-collections/
5646
5681
  schema: {
5647
5682
  collections: ${generateCollectionString(args)},
5648
5683
  },
@@ -5652,11 +5687,10 @@ import { LocalAuthProvider } from "tinacms";`;
5652
5687
 
5653
5688
  // src/cmds/init/templates/database.ts
5654
5689
  var databaseTemplate = ({ config: config2 }) => {
5655
- var _a, _b, _c, _d;
5656
5690
  return `
5657
5691
  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)}
5692
+ ${makeImportString(config2.gitProvider?.imports)}
5693
+ ${makeImportString(config2.databaseAdapter?.imports)}
5660
5694
 
5661
5695
  const branch = (process.env.GITHUB_BRANCH ||
5662
5696
  process.env.VERCEL_GIT_COMMIT_REF ||
@@ -5668,8 +5702,8 @@ const isLocal = process.env.${config2.isLocalEnvVarName} === 'true'
5668
5702
  export default isLocal
5669
5703
  ? createLocalDatabase()
5670
5704
  : createDatabase({
5671
- gitProvider: ${(_c = config2.gitProvider) == null ? void 0 : _c.gitProviderClassText},
5672
- databaseAdapter: ${(_d = config2.databaseAdapter) == null ? void 0 : _d.databaseAdapterClassText},
5705
+ gitProvider: ${config2.gitProvider?.gitProviderClassText},
5706
+ databaseAdapter: ${config2.databaseAdapter?.databaseAdapterClassText},
5673
5707
  namespace: branch,
5674
5708
  })
5675
5709
  `;
@@ -5680,10 +5714,9 @@ var nextApiRouteTemplate = ({
5680
5714
  config: config2,
5681
5715
  env
5682
5716
  }) => {
5683
- var _a, _b;
5684
5717
  const extraPath = env.usingSrc ? "../" : "";
5685
5718
  return `import { TinaNodeBackend, LocalBackendAuthProvider } from '@tinacms/datalayer'
5686
- ${makeImportString((_a = config2.authProvider) == null ? void 0 : _a.backendAuthProviderImports)}
5719
+ ${makeImportString(config2.authProvider?.backendAuthProviderImports)}
5687
5720
 
5688
5721
 
5689
5722
 
@@ -5694,7 +5727,7 @@ var nextApiRouteTemplate = ({
5694
5727
  const handler = TinaNodeBackend({
5695
5728
  authProvider: isLocal
5696
5729
  ? LocalBackendAuthProvider()
5697
- : ${((_b = config2.authProvider) == null ? void 0 : _b.backendAuthProvider) || ""},
5730
+ : ${config2.authProvider?.backendAuthProvider || ""},
5698
5731
  databaseClient,
5699
5732
  })
5700
5733
 
@@ -5722,19 +5755,18 @@ var import_prettier2 = require("prettier");
5722
5755
  // src/utils/script-helpers.ts
5723
5756
  function generateGqlScript(scriptValue, opts) {
5724
5757
  const cmd = `tinacms dev -c "${scriptValue}"`;
5725
- if (opts == null ? void 0 : opts.isLocalEnvVarName) {
5758
+ if (opts?.isLocalEnvVarName) {
5726
5759
  return `${opts.isLocalEnvVarName}=true ${cmd}`;
5727
5760
  }
5728
5761
  return cmd;
5729
5762
  }
5730
5763
  function extendNextScripts(scripts, opts) {
5731
- var _a, _b;
5732
5764
  const result = {
5733
5765
  ...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
5766
+ dev: !scripts?.dev || scripts?.dev?.indexOf("tinacms dev -c") === -1 ? generateGqlScript(scripts?.dev || "next dev", opts) : scripts?.dev,
5767
+ build: !scripts?.build || !scripts?.build?.startsWith("tinacms build &&") ? `tinacms build && ${scripts?.build || "next build"}` : scripts?.build
5736
5768
  };
5737
- if ((opts == null ? void 0 : opts.addSetupUsers) && !scripts["setup:users"]) {
5769
+ if (opts?.addSetupUsers && !scripts["setup:users"]) {
5738
5770
  result["setup:users"] = "tinacms-next-auth setup";
5739
5771
  }
5740
5772
  return result;
@@ -5816,7 +5848,6 @@ var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variable
5816
5848
  }
5817
5849
  };
5818
5850
  var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
5819
- var _a;
5820
5851
  if (import_typescript3.default.isSourceFile(node)) {
5821
5852
  const newStatements = [...node.statements];
5822
5853
  let changed = false;
@@ -5825,7 +5856,7 @@ var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
5825
5856
  for (const statement of newStatements) {
5826
5857
  if (import_typescript3.default.isImportDeclaration(statement) && import_typescript3.default.isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === moduleName) {
5827
5858
  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(
5859
+ const existingImports = statement.importClause?.namedBindings && import_typescript3.default.isNamedImports(statement.importClause.namedBindings) ? statement.importClause.namedBindings.elements.map(
5829
5860
  (e) => e.name.text
5830
5861
  ) : [];
5831
5862
  const newImports = [
@@ -6042,7 +6073,6 @@ async function apply({
6042
6073
  params,
6043
6074
  config: config2
6044
6075
  }) {
6045
- var _a;
6046
6076
  if (config2.framework.name === "other" && config2.hosting === "self-host") {
6047
6077
  logger.error(
6048
6078
  logText(
@@ -6148,8 +6178,8 @@ async function apply({
6148
6178
  await addConfigFile({
6149
6179
  configArgs: {
6150
6180
  config: config2,
6151
- publicFolder: import_path11.default.join(
6152
- import_path11.default.relative(process.cwd(), pathToForestryConfig),
6181
+ publicFolder: import_path13.default.join(
6182
+ import_path13.default.relative(process.cwd(), pathToForestryConfig),
6153
6183
  config2.publicFolder
6154
6184
  ),
6155
6185
  collections,
@@ -6168,7 +6198,7 @@ async function apply({
6168
6198
  env.tinaConfigExists && // Are we running tinacms init backend
6169
6199
  params.isBackendInit && // Do the user choose the 'self-host' option
6170
6200
  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"
6201
+ (config2.authProvider?.name || "") !== "tina-cloud"
6172
6202
  ) {
6173
6203
  await addSelfHostedTinaAuthToConfig(config2, env.generatedFiles["config"]);
6174
6204
  }
@@ -6222,21 +6252,20 @@ var createPackageJSON = async () => {
6222
6252
  };
6223
6253
  var createGitignore = async ({ baseDir }) => {
6224
6254
  logger.info(logText("No .gitignore found, creating one"));
6225
- import_fs_extra13.default.outputFileSync(import_path11.default.join(baseDir, ".gitignore"), "node_modules");
6255
+ import_fs_extra13.default.outputFileSync(import_path13.default.join(baseDir, ".gitignore"), "node_modules");
6226
6256
  };
6227
6257
  var updateGitIgnore = async ({
6228
6258
  baseDir,
6229
6259
  items
6230
6260
  }) => {
6231
6261
  logger.info(logText(`Adding ${items.join(",")} to .gitignore`));
6232
- const gitignoreContent = import_fs_extra13.default.readFileSync(import_path11.default.join(baseDir, ".gitignore")).toString();
6262
+ const gitignoreContent = import_fs_extra13.default.readFileSync(import_path13.default.join(baseDir, ".gitignore")).toString();
6233
6263
  const newGitignoreContent = [...gitignoreContent.split("\n"), ...items].join(
6234
6264
  "\n"
6235
6265
  );
6236
- await import_fs_extra13.default.writeFile(import_path11.default.join(baseDir, ".gitignore"), newGitignoreContent);
6266
+ await import_fs_extra13.default.writeFile(import_path13.default.join(baseDir, ".gitignore"), newGitignoreContent);
6237
6267
  };
6238
6268
  var addDependencies = async (config2, env, params) => {
6239
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
6240
6269
  const { packageManager } = config2;
6241
6270
  const tagVersion = params.tinaVersion ? `@${params.tinaVersion}` : "";
6242
6271
  let deps = [];
@@ -6252,18 +6281,18 @@ var addDependencies = async (config2, env, params) => {
6252
6281
  deps.push("@tinacms/datalayer");
6253
6282
  }
6254
6283
  deps.push(
6255
- ...((_b = (_a = config2.databaseAdapter) == null ? void 0 : _a.imports) == null ? void 0 : _b.map((x) => x.packageName)) || []
6284
+ ...config2.databaseAdapter?.imports?.map((x) => x.packageName) || []
6256
6285
  );
6257
- deps.push(...((_c = config2.authProvider) == null ? void 0 : _c.peerDependencies) || []);
6286
+ deps.push(...config2.authProvider?.peerDependencies || []);
6258
6287
  deps.push(
6259
- ...((_e = (_d = config2.authProvider) == null ? void 0 : _d.backendAuthProviderImports) == null ? void 0 : _e.map(
6288
+ ...config2.authProvider?.backendAuthProviderImports?.map(
6260
6289
  (x) => x.packageName
6261
- )) || []
6290
+ ) || []
6262
6291
  );
6263
6292
  deps.push(
6264
- ...((_g = (_f = config2.authProvider) == null ? void 0 : _f.configImports) == null ? void 0 : _g.map((x) => x.packageName)) || []
6293
+ ...config2.authProvider?.configImports?.map((x) => x.packageName) || []
6265
6294
  );
6266
- deps.push(...((_i = (_h = config2.gitProvider) == null ? void 0 : _h.imports) == null ? void 0 : _i.map((x) => x.packageName)) || []);
6295
+ deps.push(...config2.gitProvider?.imports?.map((x) => x.packageName) || []);
6267
6296
  if (tagVersion) {
6268
6297
  deps = deps.map(
6269
6298
  (dep) => dep.indexOf("tina") >= 0 ? `${dep}${tagVersion}` : dep
@@ -6275,7 +6304,8 @@ var addDependencies = async (config2, env, params) => {
6275
6304
  let packageManagers = {
6276
6305
  pnpm: process.env.USE_WORKSPACE ? `pnpm add ${deps.join(" ")} --workspace` : `pnpm add ${deps.join(" ")}`,
6277
6306
  npm: `npm install ${deps.join(" ")}`,
6278
- yarn: `yarn add ${deps.join(" ")}`
6307
+ yarn: `yarn add ${deps.join(" ")}`,
6308
+ bun: `bun add ${deps.join(" ")}`
6279
6309
  };
6280
6310
  if (packageManagers[packageManager] && deps.length > 0) {
6281
6311
  logger.info(logText("Adding dependencies, this might take a moment..."));
@@ -6286,7 +6316,8 @@ var addDependencies = async (config2, env, params) => {
6286
6316
  packageManagers = {
6287
6317
  pnpm: process.env.USE_WORKSPACE ? `pnpm add -D ${devDeps.join(" ")} --workspace` : `pnpm add -D ${devDeps.join(" ")}`,
6288
6318
  npm: `npm install -D ${devDeps.join(" ")}`,
6289
- yarn: `yarn add -D ${devDeps.join(" ")}`
6319
+ yarn: `yarn add -D ${devDeps.join(" ")}`,
6320
+ bun: `bun add -D ${devDeps.join(" ")}`
6290
6321
  };
6291
6322
  if (packageManagers[packageManager]) {
6292
6323
  logger.info(
@@ -6303,22 +6334,22 @@ var writeGeneratedFile = async ({
6303
6334
  content,
6304
6335
  typescript
6305
6336
  }) => {
6306
- const { exists, path: path14, parentPath } = generatedFile.resolve(typescript);
6337
+ const { exists, path: path15, parentPath } = generatedFile.resolve(typescript);
6307
6338
  if (exists) {
6308
6339
  if (overwrite) {
6309
- logger.info(`Overwriting file at ${path14}... \u2705`);
6310
- import_fs_extra13.default.outputFileSync(path14, content);
6340
+ logger.info(`Overwriting file at ${path15}... \u2705`);
6341
+ import_fs_extra13.default.outputFileSync(path15, content);
6311
6342
  } else {
6312
- logger.info(`Not overwriting file at ${path14}.`);
6343
+ logger.info(`Not overwriting file at ${path15}.`);
6313
6344
  logger.info(
6314
- logText(`Please add the following to ${path14}:
6345
+ logText(`Please add the following to ${path15}:
6315
6346
  ${indentText(content)}}`)
6316
6347
  );
6317
6348
  }
6318
6349
  } else {
6319
- logger.info(`Adding file at ${path14}... \u2705`);
6350
+ logger.info(`Adding file at ${path15}... \u2705`);
6320
6351
  await import_fs_extra13.default.ensureDir(parentPath);
6321
- import_fs_extra13.default.outputFileSync(path14, content);
6352
+ import_fs_extra13.default.outputFileSync(path15, content);
6322
6353
  }
6323
6354
  };
6324
6355
  var addConfigFile = async ({
@@ -6327,12 +6358,11 @@ var addConfigFile = async ({
6327
6358
  generatedFile,
6328
6359
  config: config2
6329
6360
  }) => {
6330
- var _a;
6331
6361
  const content = (0, import_prettier2.format)(generateConfig(configArgs), {
6332
6362
  parser: "babel"
6333
6363
  });
6334
6364
  await writeGeneratedFile({
6335
- overwrite: (_a = config2.overwriteList) == null ? void 0 : _a.includes("config"),
6365
+ overwrite: config2.overwriteList?.includes("config"),
6336
6366
  generatedFile,
6337
6367
  content,
6338
6368
  typescript: config2.typescript
@@ -6346,10 +6376,9 @@ var addDatabaseFile = async ({
6346
6376
  config: config2,
6347
6377
  generatedFile
6348
6378
  }) => {
6349
- var _a;
6350
6379
  await writeGeneratedFile({
6351
6380
  generatedFile,
6352
- overwrite: (_a = config2.overwriteList) == null ? void 0 : _a.includes("database"),
6381
+ overwrite: config2.overwriteList?.includes("database"),
6353
6382
  content: databaseTemplate({ config: config2 }),
6354
6383
  typescript: config2.typescript
6355
6384
  });
@@ -6359,13 +6388,12 @@ var addNextApiRoute = async ({
6359
6388
  generatedFile,
6360
6389
  env
6361
6390
  }) => {
6362
- var _a;
6363
6391
  const content = (0, import_prettier2.format)(nextApiRouteTemplate({ config: config2, env }), {
6364
6392
  parser: "babel"
6365
6393
  });
6366
6394
  await writeGeneratedFile({
6367
6395
  generatedFile,
6368
- overwrite: (_a = config2.overwriteList) == null ? void 0 : _a.includes("next-api-handler"),
6396
+ overwrite: config2.overwriteList?.includes("next-api-handler"),
6369
6397
  content,
6370
6398
  typescript: config2.typescript
6371
6399
  });
@@ -6375,10 +6403,9 @@ var addTemplateFile = async ({
6375
6403
  generatedFile,
6376
6404
  config: config2
6377
6405
  }) => {
6378
- var _a;
6379
6406
  await writeGeneratedFile({
6380
6407
  generatedFile,
6381
- overwrite: (_a = config2.overwriteList) == null ? void 0 : _a.includes(generatedFile.generatedFileType),
6408
+ overwrite: config2.overwriteList?.includes(generatedFile.generatedFileType),
6382
6409
  content,
6383
6410
  typescript: config2.typescript
6384
6411
  });
@@ -6387,7 +6414,6 @@ var addContentFile = async ({
6387
6414
  config: config2,
6388
6415
  env
6389
6416
  }) => {
6390
- var _a;
6391
6417
  await writeGeneratedFile({
6392
6418
  generatedFile: {
6393
6419
  javascriptExists: false,
@@ -6401,11 +6427,11 @@ var addContentFile = async ({
6401
6427
  return () => ({
6402
6428
  exists: env.sampleContentExists,
6403
6429
  path: env.sampleContentPath,
6404
- parentPath: import_path11.default.dirname(env.sampleContentPath)
6430
+ parentPath: import_path13.default.dirname(env.sampleContentPath)
6405
6431
  });
6406
6432
  }
6407
6433
  },
6408
- overwrite: (_a = config2.overwriteList) == null ? void 0 : _a.includes("sample-content"),
6434
+ overwrite: config2.overwriteList?.includes("sample-content"),
6409
6435
  content: helloWorldPost,
6410
6436
  typescript: false
6411
6437
  });
@@ -6424,7 +6450,7 @@ ${titleText(" TinaCMS ")} backend initialized!`));
6424
6450
  return `${x.key}=${x.value || "***"}`;
6425
6451
  }).join("\n") + `
6426
6452
  TINA_PUBLIC_IS_LOCAL=true`;
6427
- const envFile = import_path11.default.join(process.cwd(), ".env");
6453
+ const envFile = import_path13.default.join(process.cwd(), ".env");
6428
6454
  if (!import_fs_extra13.default.existsSync(envFile)) {
6429
6455
  logger.info(`Adding .env file to your project... \u2705`);
6430
6456
  import_fs_extra13.default.writeFileSync(envFile, envFileText);
@@ -6470,7 +6496,8 @@ var other = ({ packageManager }) => {
6470
6496
  pnpm: `pnpm`,
6471
6497
  npm: `npx`,
6472
6498
  // npx is the way to run executables that aren't in your "scripts"
6473
- yarn: `yarn`
6499
+ yarn: `yarn`,
6500
+ bun: `bun run`
6474
6501
  };
6475
6502
  return `${packageManagers[packageManager]} tinacms dev -c "<your dev command>"`;
6476
6503
  };
@@ -6483,7 +6510,8 @@ var frameworkDevCmds = {
6483
6510
  pnpm: `pnpm`,
6484
6511
  npm: `npm run`,
6485
6512
  // npx is the way to run executables that aren't in your "scripts"
6486
- yarn: `yarn`
6513
+ yarn: `yarn`,
6514
+ bun: `bun run`
6487
6515
  };
6488
6516
  return `${packageManagers[packageManager]} dev`;
6489
6517
  }
@@ -6496,12 +6524,11 @@ var addReactiveFile = {
6496
6524
  baseDir,
6497
6525
  dataLayer
6498
6526
  }) => {
6499
- var _a, _b;
6500
- const packageJsonPath = import_path11.default.join(baseDir, "package.json");
6527
+ const packageJsonPath = import_path13.default.join(baseDir, "package.json");
6501
6528
  await writeGeneratedFile({
6502
6529
  generatedFile,
6503
6530
  typescript: config2.typescript,
6504
- overwrite: (_a = config2.overwriteList) == null ? void 0 : _a.includes(
6531
+ overwrite: config2.overwriteList?.includes(
6505
6532
  generatedFile.generatedFileType
6506
6533
  ),
6507
6534
  content: templates["demo-post-page"]({
@@ -6517,7 +6544,7 @@ var addReactiveFile = {
6517
6544
  ...packageJson,
6518
6545
  scripts: extendNextScripts(scripts, {
6519
6546
  isLocalEnvVarName: config2.isLocalEnvVarName,
6520
- addSetupUsers: ((_b = config2.authProvider) == null ? void 0 : _b.name) === "next-auth"
6547
+ addSetupUsers: config2.authProvider?.name === "next-auth"
6521
6548
  })
6522
6549
  },
6523
6550
  null,
@@ -6592,6 +6619,15 @@ var InitCommand = class extends import_clipanion6.Command {
6592
6619
  description: "Specify a version for tina dependencies"
6593
6620
  });
6594
6621
  }
6622
+ static {
6623
+ this.paths = [["init"], ["init", "backend"]];
6624
+ }
6625
+ static {
6626
+ this.usage = import_clipanion6.Command.Usage({
6627
+ category: `Commands`,
6628
+ description: `Add Tina to an existing project`
6629
+ });
6630
+ }
6595
6631
  async catch(error) {
6596
6632
  logger.error("Error occured during tinacms init");
6597
6633
  console.error(error);
@@ -6611,11 +6647,6 @@ var InitCommand = class extends import_clipanion6.Command {
6611
6647
  process.exit();
6612
6648
  }
6613
6649
  };
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
6650
 
6620
6651
  // src/next/commands/searchindex-command/index.ts
6621
6652
  var import_clipanion7 = require("clipanion");
@@ -6631,13 +6662,21 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6631
6662
  description: "increase verbosity of logged output"
6632
6663
  });
6633
6664
  }
6665
+ static {
6666
+ this.paths = [["search-index"]];
6667
+ }
6668
+ static {
6669
+ this.usage = import_clipanion7.Command.Usage({
6670
+ category: `Commands`,
6671
+ description: `Index the site for search`
6672
+ });
6673
+ }
6634
6674
  async catch(error) {
6635
6675
  logger.error("Error occured during tinacms search-index");
6636
6676
  console.error(error);
6637
6677
  process.exit(1);
6638
6678
  }
6639
6679
  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
6680
  const rootPath = this.rootPath || process.cwd();
6642
6681
  const configManager = new ConfigManager({ rootPath });
6643
6682
  try {
@@ -6648,7 +6687,7 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6648
6687
  console.error(e);
6649
6688
  }
6650
6689
  }
6651
- if (!((_a = configManager.config) == null ? void 0 : _a.search)) {
6690
+ if (!configManager.config?.search) {
6652
6691
  logger.error("No search config found");
6653
6692
  process.exit(1);
6654
6693
  }
@@ -6657,9 +6696,9 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6657
6696
  schema: { ...schema, config: configManager.config }
6658
6697
  });
6659
6698
  let client;
6660
- const hasTinaSearch = Boolean((_c = (_b = configManager.config) == null ? void 0 : _b.search) == null ? void 0 : _c.tina);
6699
+ const hasTinaSearch = Boolean(configManager.config?.search?.tina);
6661
6700
  if (hasTinaSearch) {
6662
- if (!((_d = configManager.config) == null ? void 0 : _d.branch)) {
6701
+ if (!configManager.config?.branch) {
6663
6702
  logger.error(
6664
6703
  `${dangerText(
6665
6704
  `ERROR: Branch not configured in tina search configuration.`
@@ -6667,11 +6706,11 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6667
6706
  );
6668
6707
  throw new Error("Branch not configured in tina search configuration.");
6669
6708
  }
6670
- if (!((_e = configManager.config) == null ? void 0 : _e.clientId)) {
6709
+ if (!configManager.config?.clientId) {
6671
6710
  logger.error(`${dangerText(`ERROR: clientId not configured.`)}`);
6672
6711
  throw new Error("clientId not configured.");
6673
6712
  }
6674
- if (!((_h = (_g = (_f = configManager.config) == null ? void 0 : _f.search) == null ? void 0 : _g.tina) == null ? void 0 : _h.indexerToken)) {
6713
+ if (!configManager.config?.search?.tina?.indexerToken) {
6675
6714
  logger.error(
6676
6715
  `${dangerText(
6677
6716
  `ERROR: indexerToken not configured in tina search configuration.`
@@ -6682,22 +6721,22 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6682
6721
  );
6683
6722
  }
6684
6723
  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
6724
+ apiUrl: `${configManager.config.tinaioConfig?.contentApiUrlOverride || "https://content.tinajs.io"}/searchIndex/${configManager.config?.clientId}`,
6725
+ branch: configManager.config?.branch,
6726
+ indexerToken: configManager.config?.search?.tina?.indexerToken,
6727
+ stopwordLanguages: configManager.config?.search?.tina?.stopwordLanguages
6689
6728
  });
6690
6729
  } else {
6691
- client = (_s = (_r = configManager.config) == null ? void 0 : _r.search) == null ? void 0 : _s.searchClient;
6730
+ client = configManager.config?.search?.searchClient;
6692
6731
  }
6693
6732
  const searchIndexer = new import_search3.SearchIndexer({
6694
- batchSize: ((_t = configManager.config.search) == null ? void 0 : _t.indexBatchSize) || 100,
6733
+ batchSize: configManager.config.search?.indexBatchSize || 100,
6695
6734
  bridge: new import_graphql17.FilesystemBridge(
6696
6735
  configManager.rootPath,
6697
6736
  configManager.contentRootPath
6698
6737
  ),
6699
6738
  schema: tinaSchema,
6700
- textIndexLength: ((_u = configManager.config.search) == null ? void 0 : _u.maxSearchIndexFieldLength) || 100,
6739
+ textIndexLength: configManager.config.search?.maxSearchIndexFieldLength || 100,
6701
6740
  client
6702
6741
  });
6703
6742
  let err;
@@ -6718,11 +6757,6 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6718
6757
  process.exit(0);
6719
6758
  }
6720
6759
  };
6721
- SearchIndexCommand.paths = [["search-index"]];
6722
- SearchIndexCommand.usage = import_clipanion7.Command.Usage({
6723
- category: `Commands`,
6724
- description: `Index the site for search`
6725
- });
6726
6760
 
6727
6761
  // src/index.ts
6728
6762
  var cli = new import_clipanion8.Cli({