@tinacms/cli 0.0.0-f696c7d-20241104134240 → 0.0.0-f6ffae4-20250213230656

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
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -31,9 +35,10 @@ module.exports = __toCommonJS(src_exports);
31
35
  var import_clipanion8 = require("clipanion");
32
36
 
33
37
  // package.json
34
- var version = "1.6.11";
38
+ var version = "1.8.4";
35
39
 
36
40
  // src/next/commands/dev-command/index.ts
41
+ var import_async_lock = __toESM(require("async-lock"));
37
42
  var import_clipanion2 = require("clipanion");
38
43
  var import_fs_extra6 = __toESM(require("fs-extra"));
39
44
  var import_path5 = __toESM(require("path"));
@@ -57,7 +62,10 @@ function isUnicodeSupported() {
57
62
  if (process.platform !== "win32") {
58
63
  return process.env.TERM !== "linux";
59
64
  }
60
- return Boolean(process.env.CI) || Boolean(process.env.WT_SESSION) || Boolean(process.env.TERMINUS_SUBLIME) || process.env.ConEmuTask === "{cmd::Cmder}" || process.env.TERM_PROGRAM === "Terminus-Sublime" || process.env.TERM_PROGRAM === "vscode" || process.env.TERM === "xterm-256color" || process.env.TERM === "alacritty" || process.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
65
+ return Boolean(process.env.CI) || Boolean(process.env.WT_SESSION) || // Windows Terminal
66
+ Boolean(process.env.TERMINUS_SUBLIME) || // Terminus (<0.2.27)
67
+ process.env.ConEmuTask === "{cmd::Cmder}" || // ConEmu and cmder
68
+ process.env.TERM_PROGRAM === "Terminus-Sublime" || process.env.TERM_PROGRAM === "vscode" || process.env.TERM === "xterm-256color" || process.env.TERM === "alacritty" || process.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
61
69
  }
62
70
 
63
71
  // src/logger/index.ts
@@ -212,7 +220,7 @@ var ConfigManager = class {
212
220
  this.generatedCachePath = import_path.default.join(
213
221
  this.generatedFolderPath,
214
222
  ".cache",
215
- String(new Date().getTime())
223
+ String((/* @__PURE__ */ new Date()).getTime())
216
224
  );
217
225
  this.generatedGraphQLGQLPath = import_path.default.join(
218
226
  this.generatedFolderPath,
@@ -355,17 +363,22 @@ var ConfigManager = class {
355
363
  );
356
364
  }
357
365
  getTinaGraphQLVersion() {
358
- var _a, _b;
359
366
  if (this.tinaGraphQLVersionFromCLI) {
360
- return this.tinaGraphQLVersionFromCLI;
367
+ const version2 = this.tinaGraphQLVersionFromCLI.split(".");
368
+ return {
369
+ fullVersion: this.tinaGraphQLVersionFromCLI,
370
+ major: version2[0] || "x",
371
+ minor: version2[1] || "x",
372
+ patch: version2[2] || "x"
373
+ };
361
374
  }
362
375
  const generatedSchema = import_fs_extra.default.readJSONSync(this.generatedSchemaJSONPath);
363
- if (!generatedSchema || !(typeof (generatedSchema == null ? void 0 : generatedSchema.version) !== "undefined") || !(typeof ((_a = generatedSchema == null ? void 0 : generatedSchema.version) == null ? void 0 : _a.major) === "string") || !(typeof ((_b = generatedSchema == null ? void 0 : generatedSchema.version) == null ? void 0 : _b.minor) === "string")) {
376
+ if (!generatedSchema || !(typeof (generatedSchema == null ? void 0 : generatedSchema.version) !== "undefined")) {
364
377
  throw new Error(
365
378
  `Can not find Tina GraphQL version in ${this.generatedSchemaJSONPath}`
366
379
  );
367
380
  }
368
- return `${generatedSchema.version.major}.${generatedSchema.version.minor}`;
381
+ return generatedSchema.version;
369
382
  }
370
383
  printGeneratedClientFilePath() {
371
384
  if (this.isUsingTs()) {
@@ -394,6 +407,9 @@ var ConfigManager = class {
394
407
  }
395
408
  throw `No path provided to print`;
396
409
  }
410
+ /**
411
+ * Given a filepath without an extension, find the first match (eg. tsx, ts, jsx, js)
412
+ */
397
413
  async getPathWithExtension(filepath) {
398
414
  const extensions = ["tsx", "ts", "jsx", "js"];
399
415
  let result;
@@ -427,7 +443,10 @@ var ConfigManager = class {
427
443
  }
428
444
  async loadConfigFile(generatedFolderPath, configFilePath) {
429
445
  const tmpdir = import_path.default.join(import_os.default.tmpdir(), Date.now().toString());
430
- const prebuild = import_path.default.join(this.generatedFolderPath, "config.prebuild.jsx");
446
+ const preBuildConfigPath = import_path.default.join(
447
+ this.generatedFolderPath,
448
+ "config.prebuild.jsx"
449
+ );
431
450
  const outfile = import_path.default.join(tmpdir, "config.build.jsx");
432
451
  const outfile2 = import_path.default.join(tmpdir, "config.build.js");
433
452
  const tempTSConfigFile = import_path.default.join(tmpdir, "tsconfig.json");
@@ -441,7 +460,7 @@ var ConfigManager = class {
441
460
  logLevel: "silent",
442
461
  packages: "external",
443
462
  ignoreAnnotations: true,
444
- outfile: prebuild,
463
+ outfile: preBuildConfigPath,
445
464
  loader: loaders,
446
465
  metafile: true
447
466
  });
@@ -464,6 +483,7 @@ var ConfigManager = class {
464
483
  await esbuild.build({
465
484
  entryPoints: [outfile],
466
485
  bundle: true,
486
+ // Suppress warning about comparison with -0 from client module
467
487
  logLevel: "silent",
468
488
  platform: "node",
469
489
  outfile: outfile2,
@@ -481,7 +501,7 @@ var ConfigManager = class {
481
501
  import_fs_extra.default.removeSync(outfile2);
482
502
  return {
483
503
  config: result.default,
484
- prebuildPath: prebuild,
504
+ prebuildPath: preBuildConfigPath,
485
505
  watchList: flattenedList
486
506
  };
487
507
  }
@@ -570,19 +590,19 @@ var devHTML = (port) => `<!DOCTYPE html>
570
590
  window.$RefreshReg$ = () => {}
571
591
  window.$RefreshSig$ = () => (type) => type
572
592
  window.__vite_plugin_react_preamble_installed__ = true
573
- <\/script>
574
- <script type="module" src="http://localhost:${port}/@vite/client"><\/script>
593
+ </script>
594
+ <script type="module" src="http://localhost:${port}/@vite/client"></script>
575
595
  <script>
576
596
  function handleLoadError() {
577
597
  // Assets have failed to load
578
598
  document.getElementById('root').innerHTML = '${errorHTML}';
579
599
  }
580
- <\/script>
600
+ </script>
581
601
  <script
582
602
  type="module"
583
603
  src="http://localhost:${port}/src/main.tsx"
584
604
  onerror="handleLoadError()"
585
- ><\/script>
605
+ ></script>
586
606
  <body class="tina-tailwind">
587
607
  <div id="root"></div>
588
608
  </body>
@@ -628,6 +648,7 @@ var import_defaultTheme = __toESM(require("tailwindcss/defaultTheme.js"));
628
648
  var tinaTailwind = (spaPath, prebuildFilePath) => {
629
649
  return {
630
650
  name: "vite-plugin-tina",
651
+ // @ts-ignore
631
652
  config: (viteConfig) => {
632
653
  const plugins = [];
633
654
  const content = [
@@ -939,7 +960,6 @@ async function listFilesRecursively({
939
960
  }
940
961
  var createConfig = async ({
941
962
  configManager,
942
- database,
943
963
  apiURL,
944
964
  plugins = [],
945
965
  noWatch,
@@ -999,6 +1019,8 @@ var createConfig = async ({
999
1019
  if (configManager.config.build.basePath) {
1000
1020
  basePath = configManager.config.build.basePath;
1001
1021
  }
1022
+ const fullVersion = configManager.getTinaGraphQLVersion();
1023
+ const version2 = `${fullVersion.major}.${fullVersion.minor}`;
1002
1024
  const config2 = {
1003
1025
  root: configManager.spaRootPath,
1004
1026
  base: `/${basePath ? `${(0, import_normalize_path2.default)(basePath)}/` : ""}${(0, import_normalize_path2.default)(
@@ -1010,15 +1032,33 @@ var createConfig = async ({
1010
1032
  dedupe: ["graphql", "tinacms", "react", "react-dom", "react-router-dom"]
1011
1033
  },
1012
1034
  define: {
1035
+ /**
1036
+ * Since we prebuild the config.ts, it's possible for modules to be loaded which make
1037
+ * use of `process`. The main scenario where this is an issue is when co-locating schema
1038
+ * definitions with source files, and specifically source files which impor from NextJS.
1039
+ *
1040
+ * Some examples of what NextJS uses for `process.env` are:
1041
+ * - `process.env.__NEXT_TRAILING_SLASH`
1042
+ * - `process.env.__NEXT_CROSS_ORIGIN`
1043
+ * - `process.env.__NEXT_I18N_SUPPORT`
1044
+ *
1045
+ * Also, interestingly some of the advice for handling this doesn't work, references to replacing
1046
+ * `process.env` with `{}` are problematic, because browsers don't understand the `{}.` syntax,
1047
+ * but node does. This was a surprise, but using `new Object()` seems to do the trick.
1048
+ */
1013
1049
  "process.env": `new Object(${JSON.stringify(publicEnv)})`,
1050
+ // Used by picomatch https://github.com/micromatch/picomatch/blob/master/lib/utils.js#L4
1014
1051
  "process.platform": `"${process.platform}"`,
1015
1052
  __API_URL__: `"${apiURL}"`,
1016
1053
  __BASE_PATH__: `"${((_e = (_d = configManager.config) == null ? void 0 : _d.build) == null ? void 0 : _e.basePath) || ""}"`,
1017
- __TINA_GRAPHQL_VERSION__: `"${configManager.getTinaGraphQLVersion()}"`
1054
+ __TINA_GRAPHQL_VERSION__: version2
1018
1055
  },
1019
1056
  logLevel: "error",
1057
+ // Vite import warnings are noisy
1020
1058
  optimizeDeps: {
1021
1059
  force: true,
1060
+ // Not 100% sure why this isn't being picked up automatically, this works from within the monorepo
1061
+ // but breaks externally
1022
1062
  include: ["react/jsx-runtime", "react/jsx-dev-runtime"]
1023
1063
  },
1024
1064
  server: {
@@ -1026,6 +1066,7 @@ var createConfig = async ({
1026
1066
  watch: noWatch ? {
1027
1067
  ignored: ["**/*"]
1028
1068
  } : {
1069
+ // Ignore everything except for the alias fields we specified above
1029
1070
  ignored: [
1030
1071
  `${configManager.tinaFolderPath}/**/!(config.prebuild.jsx|_graphql.json)`
1031
1072
  ]
@@ -1041,8 +1082,13 @@ var createConfig = async ({
1041
1082
  rollupOptions
1042
1083
  },
1043
1084
  plugins: [
1085
+ /**
1086
+ * `splitVendorChunkPlugin` is needed because `tinacms` is quite large,
1087
+ * Vite's chunking strategy chokes on memory issues for smaller machines (ie. on CI).
1088
+ */
1044
1089
  (0, import_plugin_react.default)({
1045
1090
  babel: {
1091
+ // Supresses the warning [NOTE] babel The code generator has deoptimised the styling of
1046
1092
  compact: true
1047
1093
  }
1048
1094
  }),
@@ -1119,8 +1165,7 @@ var createMediaRouter = (config2) => {
1119
1165
  };
1120
1166
  var parseMediaFolder = (str) => {
1121
1167
  let returnString = str;
1122
- if (returnString.startsWith("/"))
1123
- returnString = returnString.substr(1);
1168
+ if (returnString.startsWith("/")) returnString = returnString.substr(1);
1124
1169
  if (returnString.endsWith("/"))
1125
1170
  returnString = returnString.substr(0, returnString.length - 1);
1126
1171
  return returnString;
@@ -1285,7 +1330,8 @@ var devServerEndPointsPlugin = ({
1285
1330
  configManager,
1286
1331
  apiURL,
1287
1332
  database,
1288
- searchIndex
1333
+ searchIndex,
1334
+ databaseLock
1289
1335
  }) => {
1290
1336
  const plug = {
1291
1337
  name: "graphql-endpoints",
@@ -1329,14 +1375,17 @@ var devServerEndPointsPlugin = ({
1329
1375
  }
1330
1376
  if (req.url === "/graphql") {
1331
1377
  const { query, variables } = req.body;
1332
- const result = await (0, import_graphql.resolve)({
1333
- config: {
1334
- useRelativeMedia: true
1335
- },
1336
- database,
1337
- query,
1338
- variables,
1339
- verbose: false
1378
+ let result;
1379
+ await databaseLock(async () => {
1380
+ result = await (0, import_graphql.resolve)({
1381
+ config: {
1382
+ useRelativeMedia: true
1383
+ },
1384
+ database,
1385
+ query,
1386
+ variables,
1387
+ verbose: false
1388
+ });
1340
1389
  });
1341
1390
  res.end(JSON.stringify(result));
1342
1391
  return;
@@ -1387,6 +1436,7 @@ function viteTransformExtension({
1387
1436
  return {
1388
1437
  code: res.code,
1389
1438
  map: null
1439
+ // TODO:
1390
1440
  };
1391
1441
  }
1392
1442
  }
@@ -1394,10 +1444,16 @@ function viteTransformExtension({
1394
1444
  }
1395
1445
 
1396
1446
  // src/next/commands/dev-command/server/index.ts
1397
- var createDevServer = async (configManager, database, searchIndex, apiURL, noWatch) => {
1447
+ var createDevServer = async (configManager, database, searchIndex, apiURL, noWatch, databaseLock) => {
1398
1448
  const plugins = [
1399
1449
  transformTsxPlugin({ configManager }),
1400
- devServerEndPointsPlugin({ apiURL, configManager, database, searchIndex }),
1450
+ devServerEndPointsPlugin({
1451
+ apiURL,
1452
+ configManager,
1453
+ database,
1454
+ searchIndex,
1455
+ databaseLock
1456
+ }),
1401
1457
  viteTransformExtension()
1402
1458
  ];
1403
1459
  return (0, import_vite3.createServer)(
@@ -1407,6 +1463,14 @@ var createDevServer = async (configManager, database, searchIndex, apiURL, noWat
1407
1463
  apiURL,
1408
1464
  plugins,
1409
1465
  noWatch,
1466
+ /**
1467
+ * Ensure Vite's import scan uses the spaMainPath as the input
1468
+ * so it properly finds everything. This is for dev only, and when
1469
+ * running the server outside of this monorepo vite fails to find
1470
+ * and optimize the imports, so you get errors about it not being
1471
+ * able to find an export from a module, and it's always a CJS
1472
+ * module that Vite would usually transform to an ES module.
1473
+ */
1410
1474
  rollupOptions: {
1411
1475
  input: configManager.spaMainPath,
1412
1476
  onwarn(warning, warn) {
@@ -1532,6 +1596,7 @@ var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBas
1532
1596
  node,
1533
1597
  documentVariableName,
1534
1598
  operationType,
1599
+ // This is the only line that is different
1535
1600
  operationResultType: `{data: ${operationResultType}, errors?: { message: string, locations: { line: number, column: number }[], path: string[] }[], variables: ${operationVariablesTypes}, query: string}`,
1536
1601
  operationVariablesTypes
1537
1602
  });
@@ -1580,6 +1645,8 @@ var plugin = (schema, documents, config2) => {
1580
1645
  const visitor = new GenericSdkVisitor(schema, allFragments, config2);
1581
1646
  const visitorResult = (0, import_graphql3.visit)(allAst, { leave: visitor });
1582
1647
  return {
1648
+ // We will take care of imports
1649
+ // prepend: visitor.getImports(),
1583
1650
  content: [
1584
1651
  visitor.fragments,
1585
1652
  ...visitorResult.definitions.filter((t) => typeof t === "string"),
@@ -1595,6 +1662,7 @@ var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath =
1595
1662
  docs = await loadGraphQLDocuments(queryPathGlob);
1596
1663
  fragDocs = await loadGraphQLDocuments(fragDocPath);
1597
1664
  const res = await (0, import_core.codegen)({
1665
+ // Filename is not used. This is because the typescript plugin returns a string instead of writing to a file.
1598
1666
  filename: process.cwd(),
1599
1667
  schema: (0, import_graphql5.parse)((0, import_graphql5.printSchema)(schema)),
1600
1668
  documents: [...docs, ...fragDocs],
@@ -1629,9 +1697,12 @@ var loadGraphQLDocuments = async (globPath) => {
1629
1697
  loaders: [new import_graphql_file_loader.GraphQLFileLoader()]
1630
1698
  });
1631
1699
  } catch (e) {
1632
- if ((e.message || "").includes(
1633
- "Unable to find any GraphQL type definitions for the following pointers:"
1634
- )) {
1700
+ if (
1701
+ // https://www.graphql-tools.com/docs/documents-loading#no-files-found
1702
+ (e.message || "").includes(
1703
+ "Unable to find any GraphQL type definitions for the following pointers:"
1704
+ )
1705
+ ) {
1635
1706
  } else {
1636
1707
  throw e;
1637
1708
  }
@@ -1788,16 +1859,14 @@ var Codegen = class {
1788
1859
  const branch = (_a = this.configManager.config) == null ? void 0 : _a.branch;
1789
1860
  const clientId = (_b = this.configManager.config) == null ? void 0 : _b.clientId;
1790
1861
  const token = (_c = this.configManager.config) == null ? void 0 : _c.token;
1791
- const version2 = this.configManager.getTinaGraphQLVersion();
1862
+ const fullVersion = this.configManager.getTinaGraphQLVersion();
1863
+ const version2 = `${fullVersion.major}.${fullVersion.minor}`;
1792
1864
  const baseUrl = ((_d = this.configManager.config.tinaioConfig) == null ? void 0 : _d.contentApiUrlOverride) || `https://${TINA_HOST}`;
1793
1865
  if ((!branch || !clientId || !token) && !this.port && !this.configManager.config.contentApiUrlOverride) {
1794
1866
  const missing = [];
1795
- if (!branch)
1796
- missing.push("branch");
1797
- if (!clientId)
1798
- missing.push("clientId");
1799
- if (!token)
1800
- missing.push("token");
1867
+ if (!branch) missing.push("branch");
1868
+ if (!clientId) missing.push("clientId");
1869
+ if (!token) missing.push("token");
1801
1870
  throw new Error(
1802
1871
  `Client not configured properly. Missing ${missing.join(
1803
1872
  ", "
@@ -1951,7 +2020,11 @@ schema {
1951
2020
  }
1952
2021
  };
1953
2022
  var maybeWarnFragmentSize = async (filepath) => {
1954
- if ((await import_fs_extra4.default.stat(filepath)).size > 100 * 1024) {
2023
+ if (
2024
+ // is the file bigger than 100kb?
2025
+ (await import_fs_extra4.default.stat(filepath)).size > // convert to 100 kb to bytes
2026
+ 100 * 1024
2027
+ ) {
1955
2028
  console.warn(
1956
2029
  "Warning: frags.gql is very large (>100kb). Consider setting the reference depth to 1 or 0. See code snippet below."
1957
2030
  );
@@ -1979,6 +2052,7 @@ var import_many_level = require("many-level");
1979
2052
  var import_memory_level = require("memory-level");
1980
2053
  var createDBServer = (port) => {
1981
2054
  const levelHost = new import_many_level.ManyLevelHost(
2055
+ // @ts-ignore
1982
2056
  new import_memory_level.MemoryLevel({
1983
2057
  valueEncoding: "json"
1984
2058
  })
@@ -2253,6 +2327,7 @@ var import_search = require("@tinacms/search");
2253
2327
  var DevCommand = class extends BaseCommand {
2254
2328
  constructor() {
2255
2329
  super(...arguments);
2330
+ // NOTE: camelCase commands for string options don't work if there's an `=` used https://github.com/arcanis/clipanion/issues/141
2256
2331
  this.watchFolders = import_clipanion2.Option.String("-w,--watchFolders", {
2257
2332
  description: "DEPRECATED - a list of folders (relative to where this is being run) that the cli will watch for changes"
2258
2333
  });
@@ -2262,6 +2337,7 @@ var DevCommand = class extends BaseCommand {
2262
2337
  this.outputSearchIndexPath = import_clipanion2.Option.String("--outputSearchIndexPath", {
2263
2338
  description: "Path to write the search index to"
2264
2339
  });
2340
+ this.indexingLock = new import_async_lock.default();
2265
2341
  }
2266
2342
  async catch(error) {
2267
2343
  logger.error("Error occured during tinacms dev");
@@ -2286,6 +2362,9 @@ var DevCommand = class extends BaseCommand {
2286
2362
  this.logDeprecationWarnings();
2287
2363
  createDBServer(Number(this.datalayerPort));
2288
2364
  let database = null;
2365
+ const dbLock = async (fn) => {
2366
+ return this.indexingLock.acquire("Key", fn);
2367
+ };
2289
2368
  const setup = async ({ firstTime }) => {
2290
2369
  try {
2291
2370
  await configManager.processConfig();
@@ -2336,9 +2415,6 @@ var DevCommand = class extends BaseCommand {
2336
2415
  await import_fs_extra6.default.outputFile(filePath, tinaLockContent);
2337
2416
  }
2338
2417
  }
2339
- if (!this.noWatch) {
2340
- this.watchQueries(configManager, async () => await codegen2.execute());
2341
- }
2342
2418
  await this.indexContentWithSpinner({
2343
2419
  database,
2344
2420
  graphQLSchema: graphQLSchema2,
@@ -2348,6 +2424,13 @@ var DevCommand = class extends BaseCommand {
2348
2424
  if (!firstTime) {
2349
2425
  logger.error("Re-index complete");
2350
2426
  }
2427
+ if (!this.noWatch) {
2428
+ this.watchQueries(
2429
+ configManager,
2430
+ dbLock,
2431
+ async () => await codegen2.execute()
2432
+ );
2433
+ }
2351
2434
  return { apiURL: apiURL2, database, graphQLSchema: graphQLSchema2, tinaSchema: tinaSchema2 };
2352
2435
  } catch (e) {
2353
2436
  logger.error(`
@@ -2382,14 +2465,6 @@ ${dangerText(e.message)}
2382
2465
  tokenSplitRegex: (_d = (_c = configManager.config.search) == null ? void 0 : _c.tina) == null ? void 0 : _d.tokenSplitRegex
2383
2466
  });
2384
2467
  await searchIndexClient.onStartIndexing();
2385
- const server = await createDevServer(
2386
- configManager,
2387
- database,
2388
- searchIndexClient.searchIndex,
2389
- apiURL,
2390
- this.noWatch
2391
- );
2392
- await server.listen(Number(this.port));
2393
2468
  const searchIndexer = new import_search.SearchIndexer({
2394
2469
  batchSize: ((_e = configManager.config.search) == null ? void 0 : _e.indexBatchSize) || 100,
2395
2470
  bridge: new import_graphql10.FilesystemBridge(
@@ -2415,12 +2490,26 @@ ${dangerText(e.message)}
2415
2490
  this.watchContentFiles(
2416
2491
  configManager,
2417
2492
  database,
2493
+ dbLock,
2418
2494
  configManager.config.search && searchIndexer
2419
2495
  );
2496
+ }
2497
+ const server = await createDevServer(
2498
+ configManager,
2499
+ database,
2500
+ searchIndexClient.searchIndex,
2501
+ apiURL,
2502
+ this.noWatch,
2503
+ dbLock
2504
+ );
2505
+ await server.listen(Number(this.port));
2506
+ if (!this.noWatch) {
2420
2507
  import_chokidar.default.watch(configManager.watchList).on("change", async () => {
2421
- logger.info(`Tina config change detected, rebuilding`);
2422
- await setup({ firstTime: false });
2423
- server.ws.send({ type: "full-reload", path: "*" });
2508
+ await dbLock(async () => {
2509
+ logger.info(`Tina config change detected, rebuilding`);
2510
+ await setup({ firstTime: false });
2511
+ server.ws.send({ type: "full-reload", path: "*" });
2512
+ });
2424
2513
  });
2425
2514
  }
2426
2515
  const subItems = [];
@@ -2471,11 +2560,25 @@ ${dangerText(e.message)}
2471
2560
  heading: "Tina Dev Server is running...",
2472
2561
  items: [
2473
2562
  ...summaryItems
2563
+ // {
2564
+ // emoji: '📚',
2565
+ // heading: 'Useful links',
2566
+ // subItems: [
2567
+ // {
2568
+ // key: 'Custom queries',
2569
+ // value: 'https://tina.io/querying',
2570
+ // },
2571
+ // {
2572
+ // key: 'Visual editing',
2573
+ // value: 'https://tina.io/visual-editing',
2574
+ // },
2575
+ // ],
2576
+ // },
2474
2577
  ]
2475
2578
  });
2476
2579
  await this.startSubCommand();
2477
2580
  }
2478
- watchContentFiles(configManager, database, searchIndexer) {
2581
+ watchContentFiles(configManager, database, databaseLock, searchIndexer) {
2479
2582
  const collectionContentFiles = [];
2480
2583
  configManager.config.schema.collections.forEach((collection) => {
2481
2584
  const collectionGlob = `${import_path5.default.join(
@@ -2491,39 +2594,42 @@ ${dangerText(e.message)}
2491
2594
  if (!ready) {
2492
2595
  return;
2493
2596
  }
2494
- const pathFromRoot = configManager.printContentRelativePath(addedFile);
2495
- await database.indexContentByPaths([pathFromRoot]).catch(console.error);
2496
- if (searchIndexer) {
2497
- await searchIndexer.indexContentByPaths([pathFromRoot]).catch(console.error);
2498
- }
2597
+ await databaseLock(async () => {
2598
+ const pathFromRoot = configManager.printContentRelativePath(addedFile);
2599
+ await database.indexContentByPaths([pathFromRoot]).catch(console.error);
2600
+ if (searchIndexer) {
2601
+ await searchIndexer.indexContentByPaths([pathFromRoot]).catch(console.error);
2602
+ }
2603
+ });
2499
2604
  }).on("change", async (changedFile) => {
2500
2605
  const pathFromRoot = configManager.printContentRelativePath(changedFile);
2501
- await database.indexContentByPaths([pathFromRoot]).catch(console.error);
2502
- if (searchIndexer) {
2503
- await searchIndexer.indexContentByPaths([pathFromRoot]).catch(console.error);
2504
- }
2606
+ await databaseLock(async () => {
2607
+ await database.indexContentByPaths([pathFromRoot]).catch(console.error);
2608
+ if (searchIndexer) {
2609
+ await searchIndexer.indexContentByPaths([pathFromRoot]).catch(console.error);
2610
+ }
2611
+ });
2505
2612
  }).on("unlink", async (removedFile) => {
2506
2613
  const pathFromRoot = configManager.printContentRelativePath(removedFile);
2507
- await database.deleteContentByPaths([pathFromRoot]).catch(console.error);
2508
- if (searchIndexer) {
2509
- await searchIndexer.deleteIndexContent([pathFromRoot]).catch(console.error);
2510
- }
2614
+ await databaseLock(async () => {
2615
+ await database.deleteContentByPaths([pathFromRoot]).catch(console.error);
2616
+ if (searchIndexer) {
2617
+ await searchIndexer.deleteIndexContent([pathFromRoot]).catch(console.error);
2618
+ }
2619
+ });
2511
2620
  });
2512
2621
  }
2513
- watchQueries(configManager, callback) {
2514
- let ready = false;
2515
- import_chokidar.default.watch(configManager.userQueriesAndFragmentsGlob).on("ready", () => {
2516
- ready = true;
2517
- }).on("add", async (addedFile) => {
2518
- await callback();
2519
- }).on("change", async (changedFile) => {
2520
- await callback();
2521
- }).on("unlink", async (removedFile) => {
2522
- await callback();
2523
- });
2622
+ watchQueries(configManager, databaseLock, callback) {
2623
+ const executeCallback = async (_) => {
2624
+ await databaseLock(async () => {
2625
+ await callback();
2626
+ });
2627
+ };
2628
+ import_chokidar.default.watch(configManager.userQueriesAndFragmentsGlob).on("add", executeCallback).on("change", executeCallback).on("unlink", executeCallback);
2524
2629
  }
2525
2630
  };
2526
2631
  DevCommand.paths = [["dev"], ["server:start"]];
2632
+ // Prevent indexes and reads occurring at once
2527
2633
  DevCommand.usage = import_clipanion2.Command.Usage({
2528
2634
  category: `Commands`,
2529
2635
  description: `Builds Tina and starts the dev server`,
@@ -2582,7 +2688,7 @@ var buildProductionSpa = async (configManager, database, apiURL) => {
2582
2688
  // src/next/commands/build-command/index.ts
2583
2689
  var import_schema_tools2 = require("@tinacms/schema-tools");
2584
2690
  var import_graphql12 = require("graphql");
2585
- var import_core2 = require("@graphql-inspector/core");
2691
+ var import_core3 = require("@graphql-inspector/core");
2586
2692
 
2587
2693
  // src/next/commands/build-command/waitForDB.ts
2588
2694
  var import_progress = __toESM(require("progress"));
@@ -2684,6 +2790,20 @@ var waitForDB = async (config2, apiUrl, previewName, verbose) => {
2684
2790
 
2685
2791
  // src/next/commands/build-command/index.ts
2686
2792
  var import_search2 = require("@tinacms/search");
2793
+
2794
+ // src/utils/index.ts
2795
+ var import_core2 = require("@graphql-inspector/core");
2796
+ var getFaqLink = (type) => {
2797
+ switch (type) {
2798
+ case import_core2.ChangeType.FieldRemoved: {
2799
+ return "https://tina.io/docs/introduction/faq#how-do-i-resolve-the-local-graphql-schema-doesnt-match-the-remote-graphql-schema-errors";
2800
+ }
2801
+ default:
2802
+ return null;
2803
+ }
2804
+ };
2805
+
2806
+ // src/next/commands/build-command/index.ts
2687
2807
  var BuildCommand = class extends BaseCommand {
2688
2808
  constructor() {
2689
2809
  super(...arguments);
@@ -2699,6 +2819,9 @@ var BuildCommand = class extends BaseCommand {
2699
2819
  this.tinaGraphQLVersion = import_clipanion3.Option.String("--tina-graphql-version", {
2700
2820
  description: "Specify the version of @tinacms/graphql to use (defaults to latest)"
2701
2821
  });
2822
+ /**
2823
+ * This option allows the user to skip the tina cloud checks if they want to. This could be useful for mismatched GraphQL versions or if they want to build only using the local client and never connect to Tina Cloud
2824
+ */
2702
2825
  this.skipCloudChecks = import_clipanion3.Option.Boolean("--skip-cloud-checks", false, {
2703
2826
  description: "Skips checking the provided cloud config."
2704
2827
  });
@@ -2804,14 +2927,15 @@ ${dangerText(e.message)}
2804
2927
  database,
2805
2928
  null,
2806
2929
  apiURL,
2807
- true
2930
+ true,
2931
+ (lockedFn) => lockedFn()
2808
2932
  );
2809
2933
  await server.listen(Number(this.port));
2810
2934
  console.log("server listening on port", this.port);
2811
2935
  }
2812
2936
  const skipCloudChecks = this.skipCloudChecks || configManager.hasSelfHostedConfig();
2813
2937
  if (!skipCloudChecks) {
2814
- const { hasUpstream } = await this.checkClientInfo(
2938
+ const { hasUpstream, timestamp } = await this.checkClientInfo(
2815
2939
  configManager,
2816
2940
  codegen2.productionUrl,
2817
2941
  this.previewBaseBranch
@@ -2839,14 +2963,16 @@ ${dangerText(e.message)}
2839
2963
  await this.checkGraphqlSchema(
2840
2964
  configManager,
2841
2965
  database,
2842
- codegen2.productionUrl
2966
+ codegen2.productionUrl,
2967
+ timestamp
2843
2968
  );
2844
2969
  await this.checkTinaSchema(
2845
2970
  configManager,
2846
2971
  database,
2847
2972
  codegen2.productionUrl,
2848
2973
  this.previewName,
2849
- this.verbose
2974
+ this.verbose,
2975
+ timestamp
2850
2976
  );
2851
2977
  }
2852
2978
  await buildProductionSpa(configManager, database, codegen2.productionUrl);
@@ -2965,11 +3091,13 @@ ${dangerText(e.message)}
2965
3091
  const bar2 = new import_progress2.default("Checking clientId and token. :prog", 1);
2966
3092
  let branchKnown = false;
2967
3093
  let hasUpstream = false;
3094
+ let timestamp;
2968
3095
  try {
2969
3096
  const res = await request({
2970
3097
  token,
2971
3098
  url
2972
3099
  });
3100
+ timestamp = res.timestamp || 0;
2973
3101
  bar2.tick({
2974
3102
  prog: "\u2705"
2975
3103
  });
@@ -3011,7 +3139,8 @@ ${dangerText(e.message)}
3011
3139
  prog: "\u2705"
3012
3140
  });
3013
3141
  return {
3014
- hasUpstream
3142
+ hasUpstream,
3143
+ timestamp
3015
3144
  };
3016
3145
  }
3017
3146
  for (let i = 0; i <= 5; i++) {
@@ -3101,14 +3230,14 @@ ${dangerText(e.message)}
3101
3230
  throw e;
3102
3231
  }
3103
3232
  }
3104
- async checkGraphqlSchema(configManager, database, apiURL) {
3233
+ async checkGraphqlSchema(configManager, database, apiURL, timestamp) {
3105
3234
  const bar2 = new import_progress2.default(
3106
3235
  "Checking local GraphQL Schema matches server. :prog",
3107
3236
  1
3108
3237
  );
3109
3238
  const { config: config2 } = configManager;
3110
3239
  const token = config2.token;
3111
- const remoteSchema = await fetchRemoteGraphqlSchema({
3240
+ const { remoteSchema, remoteProjectVersion } = await fetchRemoteGraphqlSchema({
3112
3241
  url: apiURL,
3113
3242
  token
3114
3243
  });
@@ -3128,7 +3257,7 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3128
3257
  const localSchemaDocument = await database.getGraphQLSchemaFromBridge();
3129
3258
  const localGraphqlSchema = (0, import_graphql12.buildASTSchema)(localSchemaDocument);
3130
3259
  try {
3131
- const diffResult = await (0, import_core2.diff)(localGraphqlSchema, remoteGqlSchema);
3260
+ const diffResult = await (0, import_core3.diff)(localGraphqlSchema, remoteGqlSchema);
3132
3261
  if (diffResult.length === 0) {
3133
3262
  bar2.tick({
3134
3263
  prog: "\u2705"
@@ -3137,12 +3266,30 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3137
3266
  bar2.tick({
3138
3267
  prog: "\u274C"
3139
3268
  });
3140
- let errorMessage = `The local GraphQL schema doesn't match the remote GraphQL schema. Please push up your changes to GitHub to update your remote GraphQL schema.`;
3141
- if (config2 == null ? void 0 : config2.branch) {
3142
- errorMessage += `
3269
+ const type = diffResult[0].type;
3270
+ const reason = diffResult[0].message;
3271
+ const errorLevel = diffResult[0].criticality.level;
3272
+ const faqLink = getFaqLink(type);
3273
+ const tinaGraphQLVersion = configManager.getTinaGraphQLVersion();
3274
+ let errorMessage = `The local GraphQL schema doesn't match the remote GraphQL schema. Please push up your changes to GitHub to update your remote GraphQL schema. ${faqLink && `
3275
+ Check out '${faqLink}' for possible solutions.`}`;
3276
+ errorMessage += `
3143
3277
 
3144
- Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3278
+ Additional info:
3279
+
3280
+ `;
3281
+ if (config2 == null ? void 0 : config2.branch) {
3282
+ errorMessage += ` Branch: ${config2.branch}, Client ID: ${config2.clientId}
3283
+ `;
3145
3284
  }
3285
+ errorMessage += ` Local GraphQL version: ${tinaGraphQLVersion.fullVersion} / Remote GraphQL version: ${remoteProjectVersion}
3286
+ `;
3287
+ errorMessage += ` Last indexed at: ${new Date(
3288
+ timestamp
3289
+ ).toUTCString()}
3290
+ `;
3291
+ errorMessage += ` Reason: [${errorLevel} - ${type}] ${reason}
3292
+ `;
3146
3293
  throw new Error(errorMessage);
3147
3294
  }
3148
3295
  } catch (e) {
@@ -3157,7 +3304,7 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3157
3304
  }
3158
3305
  }
3159
3306
  }
3160
- async checkTinaSchema(configManager, database, apiURL, previewName, verbose) {
3307
+ async checkTinaSchema(configManager, database, apiURL, previewName, verbose, timestamp) {
3161
3308
  const bar2 = new import_progress2.default(
3162
3309
  "Checking local Tina Schema matches server. :prog",
3163
3310
  1
@@ -3206,11 +3353,19 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3206
3353
  prog: "\u274C"
3207
3354
  });
3208
3355
  let errorMessage = `The local Tina schema doesn't match the remote Tina schema. Please push up your changes to GitHub to update your remote tina schema.`;
3209
- if (config2 == null ? void 0 : config2.branch) {
3210
- errorMessage += `
3356
+ errorMessage += `
3211
3357
 
3212
- Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3358
+ Additional info:
3359
+
3360
+ `;
3361
+ if (config2 == null ? void 0 : config2.branch) {
3362
+ errorMessage += ` Branch: ${config2.branch}, Client ID: ${config2.clientId}
3363
+ `;
3213
3364
  }
3365
+ errorMessage += ` Last indexed at: ${new Date(
3366
+ timestamp
3367
+ ).toUTCString()}
3368
+ `;
3214
3369
  throw new Error(errorMessage);
3215
3370
  }
3216
3371
  }
@@ -3280,7 +3435,11 @@ var fetchRemoteGraphqlSchema = async ({
3280
3435
  body
3281
3436
  });
3282
3437
  const data = await res.json();
3283
- return data == null ? void 0 : data.data;
3438
+ return {
3439
+ remoteSchema: data == null ? void 0 : data.data,
3440
+ remoteRuntimeVersion: res.headers.get("tinacms-grapqhl-version"),
3441
+ remoteProjectVersion: res.headers.get("tinacms-graphql-project-version")
3442
+ };
3284
3443
  };
3285
3444
  var fetchSchemaSha = async ({
3286
3445
  url,
@@ -3404,6 +3563,7 @@ var auditDocuments = async (args) => {
3404
3563
  logger.error(import_chalk5.default.red(err.message));
3405
3564
  if (err.originalError.originalError) {
3406
3565
  logger.error(
3566
+ // @ts-ignore FIXME: this doesn't seem right
3407
3567
  import_chalk5.default.red(` ${err.originalError.originalError.message}`)
3408
3568
  );
3409
3569
  }
@@ -3609,7 +3769,9 @@ var detectEnvironment = async ({
3609
3769
  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")));
3610
3770
  const tinaFolder = import_path7.default.join(baseDir, "tina");
3611
3771
  const tinaConfigExists = Boolean(
3612
- await import_fs_extra8.default.pathExists(tinaFolder) && (await import_fs_extra8.default.readdir(tinaFolder)).find((x) => x.includes("config"))
3772
+ // Does the tina folder exist?
3773
+ await import_fs_extra8.default.pathExists(tinaFolder) && // Does the tina folder contain a config file?
3774
+ (await import_fs_extra8.default.readdir(tinaFolder)).find((x) => x.includes("config"))
3613
3775
  );
3614
3776
  const pagesDir = [baseDir, usingSrc ? "src" : false, "pages"].filter(
3615
3777
  Boolean
@@ -3844,6 +4006,7 @@ var supportedDatabaseAdapters = {
3844
4006
  {
3845
4007
  from: "mongodb",
3846
4008
  imported: [],
4009
+ // not explicitly imported
3847
4010
  packageName: "mongodb"
3848
4011
  }
3849
4012
  ]
@@ -3916,6 +4079,10 @@ var chooseDatabaseAdapter = async ({
3916
4079
  title: "MongoDB",
3917
4080
  value: "mongodb"
3918
4081
  }
4082
+ // {
4083
+ // title: "I'll create my own database adapter",
4084
+ // value: 'other',
4085
+ // },
3919
4086
  ]
3920
4087
  }
3921
4088
  ]);
@@ -4193,6 +4360,7 @@ async function configure(env, opts) {
4193
4360
  packageManager,
4194
4361
  forestryMigrate: false,
4195
4362
  isLocalEnvVarName: "TINA_PUBLIC_IS_LOCAL",
4363
+ // TODO: give this a better default
4196
4364
  typescript: false
4197
4365
  };
4198
4366
  if (config2.framework.name === "next") {
@@ -4296,15 +4464,25 @@ var import_js_yaml = __toESM(require("js-yaml"));
4296
4464
  var import_zod = __toESM(require("zod"));
4297
4465
 
4298
4466
  // src/cmds/forestry-migrate/util/errorSingleton.ts
4299
- var ErrorSingleton = class {
4467
+ var ErrorSingleton = class _ErrorSingleton {
4468
+ /**
4469
+ * The Singleton's constructor should always be private to prevent direct
4470
+ * construction calls with the `new` operator.
4471
+ */
4300
4472
  constructor() {
4301
4473
  }
4474
+ /**
4475
+ * The static method that controls the access to the singleton instance.
4476
+ *
4477
+ * This implementation let you subclass the Singleton class while keeping
4478
+ * just one instance of each subclass around.
4479
+ */
4302
4480
  static getInstance() {
4303
- if (!ErrorSingleton.instance) {
4304
- ErrorSingleton.instance = new ErrorSingleton();
4305
- ErrorSingleton.instance.collectionNameErrors = [];
4481
+ if (!_ErrorSingleton.instance) {
4482
+ _ErrorSingleton.instance = new _ErrorSingleton();
4483
+ _ErrorSingleton.instance.collectionNameErrors = [];
4306
4484
  }
4307
- return ErrorSingleton.instance;
4485
+ return _ErrorSingleton.instance;
4308
4486
  }
4309
4487
  addErrorName(error) {
4310
4488
  this.collectionNameErrors.push(error);
@@ -4347,8 +4525,7 @@ var makeFieldsWithInternalCode = ({
4347
4525
  if (hasBody) {
4348
4526
  return [bodyField, `__TINA_INTERNAL__:::...${field}():::`];
4349
4527
  } else {
4350
- if (spread)
4351
- return `__TINA_INTERNAL__:::...${field}():::`;
4528
+ if (spread) return `__TINA_INTERNAL__:::...${field}():::`;
4352
4529
  return `__TINA_INTERNAL__:::${field}():::`;
4353
4530
  }
4354
4531
  };
@@ -4432,6 +4609,7 @@ var forestryConfigSchema = import_zod.default.object({
4432
4609
  )
4433
4610
  });
4434
4611
  var forestryFieldWithoutField = import_zod.default.object({
4612
+ // TODO: maybe better type this?
4435
4613
  type: import_zod.default.union([
4436
4614
  import_zod.default.literal("text"),
4437
4615
  import_zod.default.literal("datetime"),
@@ -4455,6 +4633,7 @@ var forestryFieldWithoutField = import_zod.default.object({
4455
4633
  default: import_zod.default.any().optional(),
4456
4634
  template: import_zod.default.string().optional(),
4457
4635
  config: import_zod.default.object({
4636
+ // min and max are used for lists
4458
4637
  min: import_zod.default.number().optional().nullable(),
4459
4638
  max: import_zod.default.number().optional().nullable(),
4460
4639
  required: import_zod.default.boolean().optional().nullable(),
@@ -4468,6 +4647,7 @@ var forestryFieldWithoutField = import_zod.default.object({
4468
4647
  import_zod.default.literal("pages"),
4469
4648
  import_zod.default.literal("documents"),
4470
4649
  import_zod.default.literal("simple"),
4650
+ // TODO: I want to ignore this key if its invalid
4471
4651
  import_zod.default.string()
4472
4652
  ]).optional().nullable(),
4473
4653
  section: import_zod.default.string().optional().nullable()
@@ -4503,6 +4683,7 @@ var transformForestryFieldsToTinaFields = ({
4503
4683
  }
4504
4684
  let field;
4505
4685
  switch (forestryField2.type) {
4686
+ // Single filed types
4506
4687
  case "text":
4507
4688
  field = {
4508
4689
  type: "string",
@@ -4582,6 +4763,7 @@ var transformForestryFieldsToTinaFields = ({
4582
4763
  );
4583
4764
  }
4584
4765
  break;
4766
+ // List Types
4585
4767
  case "list":
4586
4768
  field = {
4587
4769
  type: "string",
@@ -4604,6 +4786,7 @@ var transformForestryFieldsToTinaFields = ({
4604
4786
  }
4605
4787
  };
4606
4788
  break;
4789
+ // Object (Group) types
4607
4790
  case "field_group":
4608
4791
  field = {
4609
4792
  type: "object",
@@ -4644,6 +4827,7 @@ var transformForestryFieldsToTinaFields = ({
4644
4827
  });
4645
4828
  const fieldsString = stringifyLabelWithField(template2.label);
4646
4829
  const t = {
4830
+ // @ts-ignore
4647
4831
  fields: makeFieldsWithInternalCode({
4648
4832
  hasBody: false,
4649
4833
  field: fieldsString
@@ -4681,6 +4865,7 @@ var transformForestryFieldsToTinaFields = ({
4681
4865
  spread: true
4682
4866
  });
4683
4867
  tinaFields.push(
4868
+ // @ts-ignore
4684
4869
  field2
4685
4870
  );
4686
4871
  break;
@@ -4740,6 +4925,7 @@ var parseSections = ({ val }) => {
4740
4925
 
4741
4926
  // src/cmds/forestry-migrate/index.ts
4742
4927
  var BODY_FIELD = {
4928
+ // This is the body field
4743
4929
  type: "rich-text",
4744
4930
  name: "body",
4745
4931
  label: "Body of Document",
@@ -4798,8 +4984,7 @@ var generateAllTemplates = async ({
4798
4984
  };
4799
4985
  var generateCollectionFromForestrySection = (args) => {
4800
4986
  const { section, templateMap } = args;
4801
- if (section.read_only)
4802
- return;
4987
+ if (section.read_only) return;
4803
4988
  let format3 = "md";
4804
4989
  if (section.new_doc_ext) {
4805
4990
  const ext = checkExt(section.new_doc_ext);
@@ -4866,12 +5051,14 @@ var generateCollectionFromForestrySection = (args) => {
4866
5051
  if (((forestryTemplates == null ? void 0 : forestryTemplates.length) || 0) > 1) {
4867
5052
  c = {
4868
5053
  ...baseCollection,
5054
+ // @ts-expect-error
4869
5055
  templates: forestryTemplates.map((tem) => {
4870
5056
  const currentTemplate = templateMap.get(tem);
4871
5057
  const fieldsString = stringifyLabelWithField(
4872
5058
  currentTemplate.templateObj.label
4873
5059
  );
4874
5060
  return {
5061
+ // fields: [BODY_FIELD],
4875
5062
  fields: makeFieldsWithInternalCode({
4876
5063
  hasBody,
4877
5064
  field: fieldsString,
@@ -4889,6 +5076,8 @@ var generateCollectionFromForestrySection = (args) => {
4889
5076
  const fieldsString = stringifyLabelWithField(template.templateObj.label);
4890
5077
  c = {
4891
5078
  ...baseCollection,
5079
+ // fields: [BODY_FIELD],
5080
+ // @ts-expect-error
4892
5081
  fields: makeFieldsWithInternalCode({
4893
5082
  field: fieldsString,
4894
5083
  hasBody,
@@ -5636,6 +5825,7 @@ var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
5636
5825
  ) : [];
5637
5826
  const newImports = [
5638
5827
  .../* @__PURE__ */ new Set([
5828
+ // we use Set to remove duplicates
5639
5829
  ...existingImports,
5640
5830
  ...imports
5641
5831
  ])
@@ -5790,6 +5980,7 @@ var addSelfHostedTinaAuthToConfig = async (config2, configFile) => {
5790
5980
  );
5791
5981
  const { configImports, configAuthProviderClass, extraTinaCollections } = config2.authProvider;
5792
5982
  const importMap = {
5983
+ // iterate over configImports and add them to the import map
5793
5984
  ...configImports.reduce((acc, { from, imported }) => {
5794
5985
  acc[from] = imported;
5795
5986
  return acc;
@@ -5964,7 +6155,13 @@ async function apply({
5964
6155
  config: config2
5965
6156
  });
5966
6157
  }
5967
- if (env.tinaConfigExists && params.isBackendInit && config2.hosting === "self-host" && (((_a = config2.authProvider) == null ? void 0 : _a.name) || "") !== "tina-cloud") {
6158
+ if (
6159
+ // if the config was just generated we do not need to update the config file because it will be generated correctly
6160
+ env.tinaConfigExists && // Are we running tinacms init backend
6161
+ params.isBackendInit && // Do the user choose the 'self-host' option
6162
+ config2.hosting === "self-host" && // the user did not choose the 'tina-cloud' auth provider
6163
+ (((_a = config2.authProvider) == null ? void 0 : _a.name) || "") !== "tina-cloud"
6164
+ ) {
5968
6165
  await addSelfHostedTinaAuthToConfig(config2, env.generatedFiles["config"]);
5969
6166
  }
5970
6167
  logNextSteps({
@@ -6257,6 +6454,7 @@ var other = ({ packageManager }) => {
6257
6454
  const packageManagers = {
6258
6455
  pnpm: `pnpm`,
6259
6456
  npm: `npx`,
6457
+ // npx is the way to run executables that aren't in your "scripts"
6260
6458
  yarn: `yarn`
6261
6459
  };
6262
6460
  return `${packageManagers[packageManager]} tinacms dev -c "<your dev command>"`;
@@ -6269,6 +6467,7 @@ var frameworkDevCmds = {
6269
6467
  const packageManagers = {
6270
6468
  pnpm: `pnpm`,
6271
6469
  npm: `npm run`,
6470
+ // npx is the way to run executables that aren't in your "scripts"
6272
6471
  yarn: `yarn`
6273
6472
  };
6274
6473
  return `${packageManagers[packageManager]} dev`;
@@ -6526,5 +6725,3 @@ cli.register(import_clipanion8.Builtins.DefinitionsCommand);
6526
6725
  cli.register(import_clipanion8.Builtins.HelpCommand);
6527
6726
  cli.register(import_clipanion8.Builtins.VersionCommand);
6528
6727
  var src_default = cli;
6529
- // Annotate the CommonJS export names for ESM import in node:
6530
- 0 && (module.exports = {});
@@ -21,19 +21,24 @@ export declare class BuildCommand extends BaseCommand {
21
21
  execute(): Promise<number | void>;
22
22
  checkClientInfo(configManager: ConfigManager, apiURL: string, previewBaseBranch?: string): Promise<{
23
23
  hasUpstream: boolean;
24
+ timestamp: number;
24
25
  }>;
25
26
  syncProject(configManager: ConfigManager, apiURL: string, options?: {
26
27
  upstreamBranch?: string;
27
28
  previewBaseBranch?: string;
28
29
  previewName?: string;
29
30
  }): Promise<void>;
30
- checkGraphqlSchema(configManager: ConfigManager, database: Database, apiURL: string): Promise<void>;
31
- checkTinaSchema(configManager: ConfigManager, database: Database, apiURL: string, previewName: string, verbose: boolean): Promise<void>;
31
+ checkGraphqlSchema(configManager: ConfigManager, database: Database, apiURL: string, timestamp: number): Promise<void>;
32
+ checkTinaSchema(configManager: ConfigManager, database: Database, apiURL: string, previewName: string, verbose: boolean, timestamp: number): Promise<void>;
32
33
  }
33
34
  export declare const fetchRemoteGraphqlSchema: ({ url, token, }: {
34
35
  url: string;
35
36
  token?: string;
36
- }) => Promise<any>;
37
+ }) => Promise<{
38
+ remoteSchema: any;
39
+ remoteRuntimeVersion: string;
40
+ remoteProjectVersion: string;
41
+ }>;
37
42
  export declare const fetchSchemaSha: ({ url, token, }: {
38
43
  url: string;
39
44
  token?: string;
@@ -1,3 +1,4 @@
1
+ import AsyncLock from 'async-lock';
1
2
  import { Database } from '@tinacms/graphql';
2
3
  import { ConfigManager } from '../../config-manager';
3
4
  import { BaseCommand } from '../baseCommands';
@@ -7,10 +8,11 @@ export declare class DevCommand extends BaseCommand {
7
8
  watchFolders: string;
8
9
  noWatch: boolean;
9
10
  outputSearchIndexPath: string;
11
+ indexingLock: AsyncLock;
10
12
  static usage: import("clipanion").Usage;
11
13
  catch(error: any): Promise<void>;
12
14
  logDeprecationWarnings(): void;
13
15
  execute(): Promise<number | void>;
14
- watchContentFiles(configManager: ConfigManager, database: Database, searchIndexer?: SearchIndexer): void;
15
- watchQueries(configManager: ConfigManager, callback: () => Promise<string>): void;
16
+ watchContentFiles(configManager: ConfigManager, database: Database, databaseLock: (fn: () => Promise<void>) => Promise<void>, searchIndexer?: SearchIndexer): void;
17
+ watchQueries(configManager: ConfigManager, databaseLock: (fn: () => Promise<void>) => Promise<void>, callback: () => Promise<string>): void;
16
18
  }
@@ -1,3 +1,3 @@
1
1
  import type { Database } from '@tinacms/graphql';
2
2
  import { ConfigManager } from '../../../config-manager';
3
- export declare const createDevServer: (configManager: ConfigManager, database: Database, searchIndex: any, apiURL: string, noWatch: boolean) => Promise<import("vite").ViteDevServer>;
3
+ export declare const createDevServer: (configManager: ConfigManager, database: Database, searchIndex: any, apiURL: string, noWatch: boolean, databaseLock: (fn: () => Promise<void>) => Promise<void>) => Promise<import("vite").ViteDevServer>;
@@ -55,7 +55,12 @@ export declare class ConfigManager {
55
55
  shouldSkipSDK(): boolean;
56
56
  processConfig(): Promise<void>;
57
57
  getTinaFolderPath(rootPath: any): Promise<string>;
58
- getTinaGraphQLVersion(): string;
58
+ getTinaGraphQLVersion(): {
59
+ fullVersion: string;
60
+ major: string;
61
+ minor: string;
62
+ patch: string;
63
+ };
59
64
  printGeneratedClientFilePath(): string;
60
65
  printGeneratedTypesFilePath(): string;
61
66
  printoutputHTMLFilePath(): string;
@@ -22,7 +22,7 @@ interface StaticMediaItem {
22
22
  export interface StaticMedia {
23
23
  [offset: string]: StaticMediaItem[];
24
24
  }
25
- export declare const createConfig: ({ configManager, database, apiURL, plugins, noWatch, rollupOptions, }: {
25
+ export declare const createConfig: ({ configManager, apiURL, plugins, noWatch, rollupOptions, }: {
26
26
  configManager: ConfigManager;
27
27
  database: Database;
28
28
  apiURL: string;
@@ -7,11 +7,12 @@ import type { ConfigManager } from '../config-manager';
7
7
  export declare const transformTsxPlugin: ({ configManager: _configManager, }: {
8
8
  configManager: ConfigManager;
9
9
  }) => Plugin;
10
- export declare const devServerEndPointsPlugin: ({ configManager, apiURL, database, searchIndex, }: {
10
+ export declare const devServerEndPointsPlugin: ({ configManager, apiURL, database, searchIndex, databaseLock, }: {
11
11
  apiURL: string;
12
12
  database: Database;
13
13
  configManager: ConfigManager;
14
14
  searchIndex: any;
15
+ databaseLock: (fn: () => Promise<void>) => Promise<void>;
15
16
  }) => Plugin;
16
17
  export interface ViteSvgrOptions {
17
18
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
2
 
3
3
  */
4
- import http from 'http';
4
+ import http from 'node:http';
5
5
  export declare const gqlServer: (database: any, verbose: boolean) => Promise<http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>>;
@@ -1,4 +1,6 @@
1
1
  /**
2
2
 
3
3
  */
4
+ import { ChangeType } from '@graphql-inspector/core';
4
5
  export declare const parseMediaFolder: (str: string) => string;
6
+ export declare const getFaqLink: (type: ChangeType) => string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/cli",
3
- "version": "0.0.0-f696c7d-20241104134240",
3
+ "version": "0.0.0-f6ffae4-20250213230656",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [
@@ -26,7 +26,6 @@
26
26
  "@types/cors": "2.8.5",
27
27
  "@types/crypto-js": "^4.2.2",
28
28
  "@types/express": "^4.17.21",
29
- "@types/express-graphql": "^0.9.0",
30
29
  "@types/figlet": "1.2.0",
31
30
  "@types/fs-extra": "^11.0.4",
32
31
  "@types/jest": "26.0.4",
@@ -38,24 +37,25 @@
38
37
  "@types/prompts": "^2.4.9",
39
38
  "@types/yup": "^0.32.0",
40
39
  "jest": "^29.7.0",
41
- "@tinacms/scripts": "1.3.0"
40
+ "@tinacms/scripts": "1.3.1"
42
41
  },
43
42
  "dependencies": {
44
43
  "@graphql-codegen/core": "^2.6.8",
45
44
  "@graphql-codegen/plugin-helpers": "latest",
46
- "@graphql-codegen/typescript": "^4.0.9",
47
- "@graphql-codegen/typescript-operations": "^4.2.3",
45
+ "@graphql-codegen/typescript": "^4.1.1",
46
+ "@graphql-codegen/typescript-operations": "^4.3.1",
48
47
  "@graphql-codegen/visitor-plugin-common": "^4.1.2",
49
48
  "@graphql-inspector/core": "^4.2.2",
50
49
  "@graphql-tools/graphql-file-loader": "^7.5.17",
51
50
  "@graphql-tools/load": "^7.8.14",
52
- "@rollup/pluginutils": "^5.1.2",
51
+ "@rollup/pluginutils": "^5.1.3",
53
52
  "@svgr/core": "8.1.0",
54
53
  "@tailwindcss/aspect-ratio": "^0.4.2",
55
54
  "@tailwindcss/container-queries": "^0.1.1",
56
55
  "@tailwindcss/typography": "^0.5.15",
57
56
  "@vitejs/plugin-react": "3.1.0",
58
57
  "altair-express-middleware": "^7.3.6",
58
+ "async-lock": "^1.4.1",
59
59
  "auto-bind": "^4.0.0",
60
60
  "body-parser": "^1.20.3",
61
61
  "busboy": "^1.6.0",
@@ -66,7 +66,7 @@
66
66
  "cors": "^2.8.5",
67
67
  "crypto-js": "^4.2.0",
68
68
  "dotenv": "^16.4.5",
69
- "esbuild": "^0.18.20",
69
+ "esbuild": "^0.24.0",
70
70
  "fs-extra": "^11.2.0",
71
71
  "graphql": "15.8.0",
72
72
  "js-yaml": "^4.1.0",
@@ -79,18 +79,18 @@
79
79
  "progress": "^2.0.3",
80
80
  "prompts": "^2.4.2",
81
81
  "readable-stream": "^4.5.2",
82
- "tailwindcss": "^3.4.13",
82
+ "tailwindcss": "^3.4.15",
83
83
  "typanion": "3.13.0",
84
- "typescript": "^5.6.2",
84
+ "typescript": "^5.6.3",
85
85
  "vite": "^4.5.5",
86
86
  "yup": "^1.4.0",
87
87
  "zod": "^3.23.8",
88
- "@tinacms/graphql": "0.0.0-f696c7d-20241104134240",
89
- "@tinacms/app": "0.0.0-f696c7d-20241104134240",
90
- "@tinacms/metrics": "1.0.7",
91
- "@tinacms/schema-tools": "0.0.0-f696c7d-20241104134240",
92
- "@tinacms/search": "0.0.0-f696c7d-20241104134240",
93
- "tinacms": "0.0.0-f696c7d-20241104134240"
88
+ "@tinacms/app": "2.1.19",
89
+ "@tinacms/metrics": "1.0.8",
90
+ "@tinacms/schema-tools": "1.7.0",
91
+ "@tinacms/graphql": "1.5.12",
92
+ "@tinacms/search": "1.0.39",
93
+ "tinacms": "2.6.4"
94
94
  },
95
95
  "publishConfig": {
96
96
  "registry": "https://registry.npmjs.org"