@tinacms/cli 0.0.0-fd664d8-20250407054012 → 0.0.0-fd7d6a8-20251202025033

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
@@ -1,53 +1,27 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name2 in all)
9
- __defProp(target, name2, { get: all[name2], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
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.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
28
7
 
29
8
  // src/index.ts
30
- var index_exports = {};
31
- __export(index_exports, {
32
- default: () => index_default
33
- });
34
- module.exports = __toCommonJS(index_exports);
35
- var import_clipanion8 = require("clipanion");
9
+ import { Cli, Builtins } from "clipanion";
36
10
 
37
11
  // package.json
38
- var version = "1.9.4";
12
+ var version = "2.0.0";
39
13
 
40
14
  // src/next/commands/dev-command/index.ts
41
- var import_path5 = __toESM(require("path"));
42
- var import_graphql10 = require("@tinacms/graphql");
43
- var import_search = require("@tinacms/search");
44
- var import_async_lock = __toESM(require("async-lock"));
45
- var import_chokidar = __toESM(require("chokidar"));
46
- var import_clipanion2 = require("clipanion");
47
- var import_fs_extra6 = __toESM(require("fs-extra"));
15
+ import path8 from "path";
16
+ import { FilesystemBridge as FilesystemBridge2, buildSchema } from "@tinacms/graphql";
17
+ import { LocalSearchIndexClient, SearchIndexer } from "@tinacms/search";
18
+ import AsyncLock from "async-lock";
19
+ import chokidar from "chokidar";
20
+ import { Command as Command2, Option as Option2 } from "clipanion";
21
+ import fs7 from "fs-extra";
48
22
 
49
23
  // src/logger/index.ts
50
- var import_chalk = __toESM(require("chalk"));
24
+ import chalk from "chalk";
51
25
 
52
26
  // src/logger/is-unicode-supported.ts
53
27
  function isUnicodeSupported() {
@@ -61,9 +35,9 @@ function isUnicodeSupported() {
61
35
  }
62
36
 
63
37
  // src/logger/index.ts
64
- var import_log4js = __toESM(require("log4js"));
65
- var logger = import_log4js.default.getLogger();
66
- import_log4js.default.configure({
38
+ import log4js from "log4js";
39
+ var logger = log4js.getLogger();
40
+ log4js.configure({
67
41
  appenders: {
68
42
  out: { type: "stdout", layout: { type: "messagePassThrough" } }
69
43
  },
@@ -88,18 +62,18 @@ ${message}
88
62
  return ln.length > sum ? ln.length : sum;
89
63
  }, 0) + 2;
90
64
  const msg = lines.map(
91
- (ln) => `${import_chalk.default.gray(bar)} ${import_chalk.default.white(ln)}${" ".repeat(
65
+ (ln) => `${chalk.gray(bar)} ${chalk.white(ln)}${" ".repeat(
92
66
  len - strip(ln).length
93
- )}${import_chalk.default.gray(bar)}`
67
+ )}${chalk.gray(bar)}`
94
68
  ).join("\n");
95
69
  const underscoreLen = len - title.length - 1 > 0 ? len - title.length - 1 : 0;
96
70
  process.stdout.write(
97
- `${import_chalk.default.gray(bar)}
98
- ${import_chalk.default.green("\u25CB")} ${import_chalk.default.reset(
71
+ `${chalk.gray(bar)}
72
+ ${chalk.green("\u25CB")} ${chalk.reset(
99
73
  title
100
- )} ${import_chalk.default.gray("\u2500".repeat(underscoreLen) + "\u256E")}
74
+ )} ${chalk.gray("\u2500".repeat(underscoreLen) + "\u256E")}
101
75
  ${msg}
102
- ${import_chalk.default.gray(
76
+ ${chalk.gray(
103
77
  "\u251C" + "\u2500".repeat(len + 2) + "\u256F"
104
78
  )}
105
79
  `
@@ -116,11 +90,11 @@ var summary = (content) => {
116
90
  });
117
91
  });
118
92
  content.items.forEach((item) => {
119
- outString.push(`${item.emoji} ${import_chalk.default.cyan(item.heading)}`);
93
+ outString.push(`${item.emoji} ${chalk.cyan(item.heading)}`);
120
94
  item.subItems.forEach((subItem) => {
121
95
  const spaces = longestKey - subItem.key.length + 4;
122
96
  outString.push(
123
- ` ${subItem.key}:${[...Array(spaces)].join(" ")}${import_chalk.default.cyan(
97
+ ` ${subItem.key}:${[...Array(spaces)].join(" ")}${chalk.cyan(
124
98
  subItem.value
125
99
  )}`
126
100
  );
@@ -158,12 +132,12 @@ var S_WARN = s("\u25B2", "!");
158
132
  var S_ERROR = s("\u25A0", "x");
159
133
 
160
134
  // src/utils/spinner.ts
161
- var import_cli_spinner = require("cli-spinner");
135
+ import { Spinner } from "cli-spinner";
162
136
  async function localSpin({
163
137
  waitFor,
164
138
  text
165
139
  }) {
166
- const spinner = new import_cli_spinner.Spinner({
140
+ const spinner = new Spinner({
167
141
  text: `${text} %s`,
168
142
  stream: process.stderr,
169
143
  onTick: function(msg) {
@@ -194,32 +168,32 @@ function spin({
194
168
  }
195
169
 
196
170
  // src/utils/theme.ts
197
- var import_chalk2 = __toESM(require("chalk"));
198
- var successText = import_chalk2.default.bold.green;
199
- var focusText = import_chalk2.default.bold;
200
- var dangerText = import_chalk2.default.bold.red;
201
- var neutralText = import_chalk2.default.bold.cyan;
202
- var linkText = import_chalk2.default.bold.cyan;
203
- var labelText = import_chalk2.default.bold;
204
- var cmdText = import_chalk2.default.inverse;
171
+ import chalk2 from "chalk";
172
+ var successText = chalk2.bold.green;
173
+ var focusText = chalk2.bold;
174
+ var dangerText = chalk2.bold.red;
175
+ var neutralText = chalk2.bold.cyan;
176
+ var linkText = chalk2.bold.cyan;
177
+ var labelText = chalk2.bold;
178
+ var cmdText = chalk2.inverse;
205
179
  var indentedCmd = (str) => {
206
180
  return ` \u2503 ` + str;
207
181
  };
208
182
  var indentText = (str) => {
209
183
  return String(str).split("\n").map((line) => ` ${line}`).join("\n");
210
184
  };
211
- var logText = import_chalk2.default.italic.gray;
212
- var warnText = import_chalk2.default.yellowBright.bgBlack;
213
- var titleText = import_chalk2.default.bgHex("d2f1f8").hex("ec4816");
214
- var CONFIRMATION_TEXT = import_chalk2.default.dim("enter to confirm");
185
+ var logText = chalk2.italic.gray;
186
+ var warnText = chalk2.yellowBright.bgBlack;
187
+ var titleText = chalk2.bgHex("d2f1f8").hex("ec4816");
188
+ var CONFIRMATION_TEXT = chalk2.dim("enter to confirm");
215
189
 
216
190
  // src/next/codegen/index.ts
217
- var import_fs_extra = __toESM(require("fs-extra"));
218
- var import_path = __toESM(require("path"));
219
- var import_graphql5 = require("graphql");
191
+ import fs from "fs-extra";
192
+ import path from "path";
193
+ import { buildASTSchema, printSchema as printSchema2 } from "graphql";
220
194
 
221
195
  // src/next/codegen/codegen/index.ts
222
- var import_graphql4 = require("graphql");
196
+ import { parse, printSchema } from "graphql";
223
197
 
224
198
  // src/next/codegen/codegen/plugin.ts
225
199
  var AddGeneratedClientFunc = (apiURL) => {
@@ -288,37 +262,44 @@ var AddGeneratedClient = (apiURL) => ({
288
262
  });
289
263
 
290
264
  // src/next/codegen/codegen/index.ts
291
- var import_graphql_file_loader = require("@graphql-tools/graphql-file-loader");
292
- var import_core = require("@graphql-codegen/core");
293
- var import_load = require("@graphql-tools/load");
294
- var import_typescript_operations = require("@graphql-codegen/typescript-operations");
295
- var import_typescript = require("@graphql-codegen/typescript");
265
+ import { GraphQLFileLoader } from "@graphql-tools/graphql-file-loader";
266
+ import { codegen } from "@graphql-codegen/core";
267
+ import { loadDocuments } from "@graphql-tools/load";
268
+ import { plugin as typescriptOperationsPlugin } from "@graphql-codegen/typescript-operations";
269
+ import { plugin as typescriptPlugin } from "@graphql-codegen/typescript";
296
270
 
297
271
  // src/next/codegen/codegen/sdkPlugin/index.ts
298
- var import_graphql2 = require("graphql");
299
- var import_graphql3 = require("graphql");
272
+ import { visit } from "graphql";
273
+ import {
274
+ concatAST,
275
+ Kind as Kind2
276
+ } from "graphql";
300
277
 
301
278
  // src/next/codegen/codegen/sdkPlugin/visitor.ts
302
- var import_visitor_plugin_common = require("@graphql-codegen/visitor-plugin-common");
303
- var import_auto_bind = __toESM(require("auto-bind"));
304
- var import_graphql = require("graphql");
305
- var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBaseVisitor {
279
+ import {
280
+ ClientSideBaseVisitor,
281
+ DocumentMode,
282
+ indentMultiline
283
+ } from "@graphql-codegen/visitor-plugin-common";
284
+ import autoBind from "auto-bind";
285
+ import { Kind, print } from "graphql";
286
+ var GenericSdkVisitor = class extends ClientSideBaseVisitor {
287
+ _operationsToInclude = [];
306
288
  constructor(schema, fragments, rawConfig) {
307
289
  super(schema, fragments, rawConfig, {
308
290
  usingObservableFrom: rawConfig.usingObservableFrom
309
291
  });
310
- this._operationsToInclude = [];
311
- (0, import_auto_bind.default)(this);
292
+ autoBind(this);
312
293
  if (this.config.usingObservableFrom) {
313
294
  this._additionalImports.push(this.config.usingObservableFrom);
314
295
  }
315
- if (this.config.documentMode !== import_visitor_plugin_common.DocumentMode.string) {
296
+ if (this.config.documentMode !== DocumentMode.string) {
316
297
  }
317
298
  }
318
299
  buildOperation(node, documentVariableName, operationType, operationResultType, operationVariablesTypes) {
319
300
  if (node.name == null) {
320
301
  throw new Error(
321
- "Plugin 'generic-sdk' cannot generate SDK for unnamed operation.\n\n" + (0, import_graphql.print)(node)
302
+ "Plugin 'generic-sdk' cannot generate SDK for unnamed operation.\n\n" + print(node)
322
303
  );
323
304
  } else {
324
305
  this._operationsToInclude.push({
@@ -336,14 +317,14 @@ var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBas
336
317
  const usingObservable = !!this.config.usingObservableFrom;
337
318
  const allPossibleActions = this._operationsToInclude.map((o) => {
338
319
  const optionalVariables = !o.node.variableDefinitions || o.node.variableDefinitions.length === 0 || o.node.variableDefinitions.every(
339
- (v) => v.type.kind !== import_graphql.Kind.NON_NULL_TYPE || v.defaultValue
320
+ (v) => v.type.kind !== Kind.NON_NULL_TYPE || v.defaultValue
340
321
  );
341
322
  const returnType = usingObservable && o.operationType === "Subscription" ? "Observable" : "Promise";
342
323
  return `${o.node.name.value}(variables${optionalVariables ? "?" : ""}: ${o.operationVariablesTypes}, options?: C): ${returnType}<${o.operationResultType}> {
343
324
  return requester<${o.operationResultType}, ${o.operationVariablesTypes}>(${o.documentVariableName}, variables, options);
344
325
  }`;
345
- }).map((s2) => (0, import_visitor_plugin_common.indentMultiline)(s2, 2));
346
- return `export type Requester<C= {}> = <R, V>(doc: ${this.config.documentMode === import_visitor_plugin_common.DocumentMode.string ? "string" : "DocumentNode"}, vars?: V, options?: C) => ${usingObservable ? "Promise<R> & Observable<R>" : "Promise<R>"}
326
+ }).map((s2) => indentMultiline(s2, 2));
327
+ return `export type Requester<C= {}> = <R, V>(doc: ${this.config.documentMode === DocumentMode.string ? "string" : "DocumentNode"}, vars?: V, options?: C) => ${usingObservable ? "Promise<R> & Observable<R>" : "Promise<R>"}
347
328
  export function getSdk<C>(requester: Requester<C>) {
348
329
  return {
349
330
  ${allPossibleActions.join(",\n")}
@@ -355,14 +336,14 @@ var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBas
355
336
 
356
337
  // src/next/codegen/codegen/sdkPlugin/index.ts
357
338
  var plugin = (schema, documents, config2) => {
358
- const allAst = (0, import_graphql3.concatAST)(
339
+ const allAst = concatAST(
359
340
  documents.reduce((prev, v) => {
360
341
  return [...prev, v.document];
361
342
  }, [])
362
343
  );
363
344
  const allFragments = [
364
345
  ...allAst.definitions.filter(
365
- (d) => d.kind === import_graphql3.Kind.FRAGMENT_DEFINITION
346
+ (d) => d.kind === Kind2.FRAGMENT_DEFINITION
366
347
  ).map((fragmentDef) => ({
367
348
  node: fragmentDef,
368
349
  name: fragmentDef.name.value,
@@ -372,7 +353,7 @@ var plugin = (schema, documents, config2) => {
372
353
  ...config2.externalFragments || []
373
354
  ];
374
355
  const visitor = new GenericSdkVisitor(schema, allFragments, config2);
375
- const visitorResult = (0, import_graphql2.visit)(allAst, { leave: visitor });
356
+ const visitorResult = visit(allAst, { leave: visitor });
376
357
  return {
377
358
  // We will take care of imports
378
359
  // prepend: visitor.getImports(),
@@ -390,10 +371,10 @@ var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath =
390
371
  let fragDocs = [];
391
372
  docs = await loadGraphQLDocuments(queryPathGlob);
392
373
  fragDocs = await loadGraphQLDocuments(fragDocPath);
393
- const res = await (0, import_core.codegen)({
374
+ const res = await codegen({
394
375
  // Filename is not used. This is because the typescript plugin returns a string instead of writing to a file.
395
376
  filename: process.cwd(),
396
- schema: (0, import_graphql4.parse)((0, import_graphql4.printSchema)(schema)),
377
+ schema: parse(printSchema(schema)),
397
378
  documents: [...docs, ...fragDocs],
398
379
  config: {},
399
380
  plugins: [
@@ -406,10 +387,10 @@ var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath =
406
387
  ],
407
388
  pluginMap: {
408
389
  typescript: {
409
- plugin: import_typescript.plugin
390
+ plugin: typescriptPlugin
410
391
  },
411
392
  typescriptOperations: {
412
- plugin: import_typescript_operations.plugin
393
+ plugin: typescriptOperationsPlugin
413
394
  },
414
395
  typescriptSdk: {
415
396
  plugin
@@ -422,8 +403,8 @@ var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath =
422
403
  var loadGraphQLDocuments = async (globPath) => {
423
404
  let result = [];
424
405
  try {
425
- result = await (0, import_load.loadDocuments)(globPath, {
426
- loaders: [new import_graphql_file_loader.GraphQLFileLoader()]
406
+ result = await loadDocuments(globPath, {
407
+ loaders: [new GraphQLFileLoader()]
427
408
  });
428
409
  } catch (e) {
429
410
  if (
@@ -440,11 +421,27 @@ var loadGraphQLDocuments = async (globPath) => {
440
421
  };
441
422
 
442
423
  // src/next/codegen/index.ts
443
- var import_esbuild = require("esbuild");
444
- var import_graphql6 = require("@tinacms/graphql");
445
- var import_normalize_path = __toESM(require("normalize-path"));
424
+ import { transform } from "esbuild";
425
+ import { mapUserFields } from "@tinacms/graphql";
426
+ import normalizePath from "normalize-path";
446
427
  var TINA_HOST = "content.tinajs.io";
447
428
  var Codegen = class {
429
+ configManager;
430
+ port;
431
+ schema;
432
+ queryDoc;
433
+ fragDoc;
434
+ isLocal;
435
+ // The API url used in the client
436
+ apiURL;
437
+ // This is always the local URL.
438
+ localUrl;
439
+ // production url
440
+ productionUrl;
441
+ graphqlSchemaDoc;
442
+ tinaSchema;
443
+ lookup;
444
+ noClientBuildCache;
448
445
  constructor({
449
446
  configManager,
450
447
  port,
@@ -460,7 +457,7 @@ var Codegen = class {
460
457
  this.graphqlSchemaDoc = graphqlSchemaDoc;
461
458
  this.configManager = configManager;
462
459
  this.port = port;
463
- this.schema = (0, import_graphql5.buildASTSchema)(graphqlSchemaDoc);
460
+ this.schema = buildASTSchema(graphqlSchemaDoc);
464
461
  this.tinaSchema = tinaSchema;
465
462
  this.queryDoc = queryDoc;
466
463
  this.fragDoc = fragDoc;
@@ -468,19 +465,19 @@ var Codegen = class {
468
465
  this.noClientBuildCache = noClientBuildCache;
469
466
  }
470
467
  async writeConfigFile(fileName, data) {
471
- const filePath = import_path.default.join(
468
+ const filePath = path.join(
472
469
  this.configManager.generatedFolderPath,
473
470
  fileName
474
471
  );
475
- await import_fs_extra.default.ensureFile(filePath);
476
- await import_fs_extra.default.outputFile(filePath, data);
472
+ await fs.ensureFile(filePath);
473
+ await fs.outputFile(filePath, data);
477
474
  if (this.configManager.hasSeparateContentRoot()) {
478
- const filePath2 = import_path.default.join(
475
+ const filePath2 = path.join(
479
476
  this.configManager.generatedFolderPathContentRepo,
480
477
  fileName
481
478
  );
482
- await import_fs_extra.default.ensureFile(filePath2);
483
- await import_fs_extra.default.outputFile(filePath2, data);
479
+ await fs.ensureFile(filePath2);
480
+ await fs.outputFile(filePath2, data);
484
481
  }
485
482
  }
486
483
  async removeGeneratedFilesIfExists() {
@@ -512,11 +509,11 @@ var Codegen = class {
512
509
  await this.removeGeneratedFilesIfExists();
513
510
  return apiURL;
514
511
  }
515
- await import_fs_extra.default.outputFile(
512
+ await fs.outputFile(
516
513
  this.configManager.generatedQueriesFilePath,
517
514
  this.queryDoc
518
515
  );
519
- await import_fs_extra.default.outputFile(
516
+ await fs.outputFile(
520
517
  this.configManager.generatedFragmentsFilePath,
521
518
  this.fragDoc
522
519
  );
@@ -524,21 +521,21 @@ var Codegen = class {
524
521
  const { clientString } = await this.genClient();
525
522
  const databaseClientString = this.configManager.hasSelfHostedConfig() ? await this.genDatabaseClient() : "";
526
523
  const { codeString, schemaString } = await this.genTypes();
527
- await import_fs_extra.default.outputFile(
524
+ await fs.outputFile(
528
525
  this.configManager.generatedGraphQLGQLPath,
529
526
  schemaString
530
527
  );
531
528
  if (this.configManager.isUsingTs()) {
532
- await import_fs_extra.default.outputFile(
529
+ await fs.outputFile(
533
530
  this.configManager.generatedTypesTSFilePath,
534
531
  codeString
535
532
  );
536
- await import_fs_extra.default.outputFile(
533
+ await fs.outputFile(
537
534
  this.configManager.generatedClientTSFilePath,
538
535
  clientString
539
536
  );
540
537
  if (this.configManager.hasSelfHostedConfig()) {
541
- await import_fs_extra.default.outputFile(
538
+ await fs.outputFile(
542
539
  this.configManager.generatedDatabaseClientTSFilePath,
543
540
  databaseClientString
544
541
  );
@@ -547,35 +544,35 @@ var Codegen = class {
547
544
  await unlinkIfExists(this.configManager.generatedTypesDFilePath);
548
545
  await unlinkIfExists(this.configManager.generatedTypesJSFilePath);
549
546
  } else {
550
- await import_fs_extra.default.outputFile(
547
+ await fs.outputFile(
551
548
  this.configManager.generatedTypesDFilePath,
552
549
  codeString
553
550
  );
554
- const jsTypes = await (0, import_esbuild.transform)(codeString, { loader: "ts" });
555
- await import_fs_extra.default.outputFile(
551
+ const jsTypes = await transform(codeString, { loader: "ts" });
552
+ await fs.outputFile(
556
553
  this.configManager.generatedTypesJSFilePath,
557
554
  jsTypes.code
558
555
  );
559
- await import_fs_extra.default.outputFile(
556
+ await fs.outputFile(
560
557
  this.configManager.generatedClientDFilePath,
561
558
  clientString
562
559
  );
563
- const jsClient = await (0, import_esbuild.transform)(clientString, { loader: "ts" });
564
- await import_fs_extra.default.outputFile(
560
+ const jsClient = await transform(clientString, { loader: "ts" });
561
+ await fs.outputFile(
565
562
  this.configManager.generatedClientJSFilePath,
566
563
  jsClient.code
567
564
  );
568
565
  await unlinkIfExists(this.configManager.generatedTypesTSFilePath);
569
566
  await unlinkIfExists(this.configManager.generatedClientTSFilePath);
570
567
  if (this.configManager.hasSelfHostedConfig()) {
571
- const jsDatabaseClient = await (0, import_esbuild.transform)(databaseClientString, {
568
+ const jsDatabaseClient = await transform(databaseClientString, {
572
569
  loader: "ts"
573
570
  });
574
- await import_fs_extra.default.outputFile(
571
+ await fs.outputFile(
575
572
  this.configManager.generatedDatabaseClientJSFilePath,
576
573
  jsDatabaseClient.code
577
574
  );
578
- await import_fs_extra.default.outputFile(
575
+ await fs.outputFile(
579
576
  this.configManager.generatedDatabaseClientDFilePath,
580
577
  databaseClientString
581
578
  );
@@ -587,13 +584,12 @@ var Codegen = class {
587
584
  return apiURL;
588
585
  }
589
586
  _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;
587
+ const branch = this.configManager.config?.branch;
588
+ const clientId = this.configManager.config?.clientId;
589
+ const token = this.configManager.config?.token;
594
590
  const fullVersion = this.configManager.getTinaGraphQLVersion();
595
591
  const version2 = `${fullVersion.major}.${fullVersion.minor}`;
596
- const baseUrl = ((_d = this.configManager.config.tinaioConfig) == null ? void 0 : _d.contentApiUrlOverride) || `https://${TINA_HOST}`;
592
+ const baseUrl = this.configManager.config.tinaioConfig?.contentApiUrlOverride || `https://${TINA_HOST}`;
597
593
  if ((!branch || !clientId || !token) && !this.port && !this.configManager.config.contentApiUrlOverride) {
598
594
  const missing = [];
599
595
  if (!branch) missing.push("branch");
@@ -602,7 +598,7 @@ var Codegen = class {
602
598
  throw new Error(
603
599
  `Client not configured properly. Missing ${missing.join(
604
600
  ", "
605
- )}. Please visit https://tina.io/docs/tina-cloud/overview for more information`
601
+ )}. Please visit https://tina.io/docs/r/what-is-tinacloud for more information`
606
602
  );
607
603
  }
608
604
  let localUrl = `http://localhost:${this.port}/graphql`;
@@ -621,18 +617,17 @@ var Codegen = class {
621
617
  return this.apiURL;
622
618
  }
623
619
  async genDatabaseClient() {
624
- var _a, _b;
625
620
  const authCollection = this.tinaSchema.getCollections().find((c) => c.isAuthCollection);
626
621
  let authFields = [];
627
622
  if (authCollection) {
628
- const usersFields = (0, import_graphql6.mapUserFields)(authCollection, []);
623
+ const usersFields = mapUserFields(authCollection, []);
629
624
  if (usersFields.length === 0) {
630
625
  throw new Error("No user field found");
631
626
  }
632
627
  if (usersFields.length > 1) {
633
628
  throw new Error("Only one user field is allowed");
634
629
  }
635
- authFields = (_b = (_a = usersFields[0]) == null ? void 0 : _a.collectable) == null ? void 0 : _b.fields.map((f) => {
630
+ authFields = usersFields[0]?.collectable?.fields.map((f) => {
636
631
  if (f.type !== "password" && f.type !== "object") {
637
632
  if (f.uid) {
638
633
  return `id:${f.name}`;
@@ -710,13 +705,12 @@ export default databaseClient;
710
705
  `;
711
706
  }
712
707
  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;
708
+ const token = this.configManager.config?.token;
709
+ const errorPolicy = this.configManager.config?.client?.errorPolicy;
716
710
  const apiURL = this.getApiURL();
717
711
  const clientString = `import { createClient } from "tinacms/dist/client";
718
712
  import { queries } from "./types";
719
- export const client = createClient({ ${this.noClientBuildCache === false ? `cacheDir: '${(0, import_normalize_path.default)(
713
+ export const client = createClient({ ${this.noClientBuildCache === false ? `cacheDir: '${normalizePath(
720
714
  this.configManager.generatedCachePath
721
715
  )}', ` : ""}url: '${apiURL}', token: '${token}', queries, ${errorPolicy ? `errorPolicy: '${errorPolicy}'` : ""} });
722
716
  export default client;
@@ -742,7 +736,7 @@ export default client;
742
736
  ${typescriptTypes}
743
737
  `;
744
738
  const schemaString = `# DO NOT MODIFY THIS FILE. This file is automatically generated by Tina
745
- ${(0, import_graphql5.printSchema)(this.schema)}
739
+ ${printSchema2(this.schema)}
746
740
  schema {
747
741
  query: Query
748
742
  mutation: Mutation
@@ -754,7 +748,7 @@ schema {
754
748
  var maybeWarnFragmentSize = async (filepath) => {
755
749
  if (
756
750
  // is the file bigger than 100kb?
757
- (await import_fs_extra.default.stat(filepath)).size > // convert to 100 kb to bytes
751
+ (await fs.stat(filepath)).size > // convert to 100 kb to bytes
758
752
  100 * 1024
759
753
  ) {
760
754
  console.warn(
@@ -771,19 +765,34 @@ var maybeWarnFragmentSize = async (filepath) => {
771
765
  }
772
766
  };
773
767
  var unlinkIfExists = async (filepath) => {
774
- if (import_fs_extra.default.existsSync(filepath)) {
775
- import_fs_extra.default.unlinkSync(filepath);
768
+ if (fs.existsSync(filepath)) {
769
+ fs.unlinkSync(filepath);
776
770
  }
777
771
  };
778
772
 
779
773
  // src/next/config-manager.ts
780
- var import_fs_extra2 = __toESM(require("fs-extra"));
781
- var import_path2 = __toESM(require("path"));
782
- var import_os = __toESM(require("os"));
783
- var esbuild = __toESM(require("esbuild"));
784
- var dotenv = __toESM(require("dotenv"));
785
- var import_normalize_path2 = __toESM(require("normalize-path"));
786
- var import_chalk3 = __toESM(require("chalk"));
774
+ import fs2 from "fs-extra";
775
+ import path3 from "path";
776
+ import os from "os";
777
+ import { pathToFileURL } from "url";
778
+ import * as esbuild from "esbuild";
779
+ import * as dotenv from "dotenv";
780
+ import normalizePath2 from "normalize-path";
781
+ import chalk3 from "chalk";
782
+ import { createRequire } from "module";
783
+
784
+ // src/utils/path.ts
785
+ import path2 from "path";
786
+ function stripNativeTrailingSlash(p) {
787
+ const { root } = path2.parse(p);
788
+ let str = p;
789
+ while (str.length > root.length && str.endsWith(path2.sep)) {
790
+ str = str.slice(0, -1);
791
+ }
792
+ return str;
793
+ }
794
+
795
+ // src/next/config-manager.ts
787
796
  var TINA_FOLDER = "tina";
788
797
  var LEGACY_TINA_FOLDER = ".tina";
789
798
  var GENERATED_FOLDER = "__generated__";
@@ -792,17 +801,57 @@ var GRAPHQL_GQL_FILE = "schema.gql";
792
801
  var SCHEMA_JSON_FILE = "_schema.json";
793
802
  var LOOKUP_JSON_FILE = "_lookup.json";
794
803
  var ConfigManager = class {
804
+ config;
805
+ rootPath;
806
+ tinaFolderPath;
807
+ isUsingLegacyFolder;
808
+ tinaConfigFilePath;
809
+ tinaSpaPackagePath;
810
+ contentRootPath;
811
+ envFilePath;
812
+ generatedCachePath;
813
+ generatedFolderPath;
814
+ generatedFolderPathContentRepo;
815
+ generatedGraphQLGQLPath;
816
+ generatedGraphQLJSONPath;
817
+ generatedSchemaJSONPath;
818
+ generatedLookupJSONPath;
819
+ generatedTypesTSFilePath;
820
+ generatedTypesJSFilePath;
821
+ generatedTypesDFilePath;
822
+ generatedClientTSFilePath;
823
+ generatedClientJSFilePath;
824
+ generatedClientDFilePath;
825
+ generatedDatabaseClientJSFilePath;
826
+ generatedDatabaseClientTSFilePath;
827
+ generatedDatabaseClientDFilePath;
828
+ generatedQueriesFilePath;
829
+ generatedFragmentsFilePath;
830
+ generatedQueriesAndFragmentsGlob;
831
+ userQueriesAndFragmentsGlob;
832
+ publicFolderPath;
833
+ outputFolderPath;
834
+ outputHTMLFilePath;
835
+ outputGitignorePath;
836
+ selfHostedDatabaseFilePath;
837
+ prebuildFilePath;
838
+ spaRootPath;
839
+ spaMainPath;
840
+ spaHTMLPath;
841
+ tinaGraphQLVersionFromCLI;
842
+ legacyNoSDK;
843
+ watchList;
795
844
  constructor({
796
845
  rootPath = process.cwd(),
797
846
  tinaGraphQLVersion,
798
847
  legacyNoSDK
799
848
  }) {
800
- this.rootPath = (0, import_normalize_path2.default)(rootPath);
849
+ this.rootPath = normalizePath2(rootPath);
801
850
  this.tinaGraphQLVersionFromCLI = tinaGraphQLVersion;
802
851
  this.legacyNoSDK = legacyNoSDK;
803
852
  }
804
853
  isUsingTs() {
805
- return [".ts", ".tsx"].includes(import_path2.default.extname(this.tinaConfigFilePath));
854
+ return [".ts", ".tsx"].includes(path3.extname(this.tinaConfigFilePath));
806
855
  }
807
856
  hasSelfHostedConfig() {
808
857
  return !!this.selfHostedDatabaseFilePath;
@@ -811,20 +860,20 @@ var ConfigManager = class {
811
860
  return this.rootPath !== this.contentRootPath;
812
861
  }
813
862
  shouldSkipSDK() {
814
- var _a;
815
863
  if (this.legacyNoSDK) {
816
864
  return this.legacyNoSDK;
817
865
  }
818
- return ((_a = this.config.client) == null ? void 0 : _a.skip) || false;
866
+ return this.config.client?.skip || false;
819
867
  }
820
868
  async processConfig() {
869
+ const require2 = createRequire(import.meta.url);
821
870
  this.tinaFolderPath = await this.getTinaFolderPath(this.rootPath);
822
- this.envFilePath = import_path2.default.resolve(
823
- import_path2.default.join(this.tinaFolderPath, "..", ".env")
871
+ this.envFilePath = path3.resolve(
872
+ path3.join(this.tinaFolderPath, "..", ".env")
824
873
  );
825
874
  dotenv.config({ path: this.envFilePath });
826
875
  this.tinaConfigFilePath = await this.getPathWithExtension(
827
- import_path2.default.join(this.tinaFolderPath, "config")
876
+ path3.join(this.tinaFolderPath, "config")
828
877
  );
829
878
  if (!this.tinaConfigFilePath) {
830
879
  throw new Error(
@@ -832,89 +881,89 @@ var ConfigManager = class {
832
881
  );
833
882
  }
834
883
  this.selfHostedDatabaseFilePath = await this.getPathWithExtension(
835
- import_path2.default.join(this.tinaFolderPath, "database")
884
+ path3.join(this.tinaFolderPath, "database")
836
885
  );
837
- this.generatedFolderPath = import_path2.default.join(this.tinaFolderPath, GENERATED_FOLDER);
838
- this.generatedCachePath = import_path2.default.join(
886
+ this.generatedFolderPath = path3.join(this.tinaFolderPath, GENERATED_FOLDER);
887
+ this.generatedCachePath = path3.join(
839
888
  this.generatedFolderPath,
840
889
  ".cache",
841
890
  String((/* @__PURE__ */ new Date()).getTime())
842
891
  );
843
- this.generatedGraphQLGQLPath = import_path2.default.join(
892
+ this.generatedGraphQLGQLPath = path3.join(
844
893
  this.generatedFolderPath,
845
894
  GRAPHQL_GQL_FILE
846
895
  );
847
- this.generatedGraphQLJSONPath = import_path2.default.join(
896
+ this.generatedGraphQLJSONPath = path3.join(
848
897
  this.generatedFolderPath,
849
898
  GRAPHQL_JSON_FILE
850
899
  );
851
- this.generatedSchemaJSONPath = import_path2.default.join(
900
+ this.generatedSchemaJSONPath = path3.join(
852
901
  this.generatedFolderPath,
853
902
  SCHEMA_JSON_FILE
854
903
  );
855
- this.generatedLookupJSONPath = import_path2.default.join(
904
+ this.generatedLookupJSONPath = path3.join(
856
905
  this.generatedFolderPath,
857
906
  LOOKUP_JSON_FILE
858
907
  );
859
- this.generatedQueriesFilePath = import_path2.default.join(
908
+ this.generatedQueriesFilePath = path3.join(
860
909
  this.generatedFolderPath,
861
910
  "queries.gql"
862
911
  );
863
- this.generatedFragmentsFilePath = import_path2.default.join(
912
+ this.generatedFragmentsFilePath = path3.join(
864
913
  this.generatedFolderPath,
865
914
  "frags.gql"
866
915
  );
867
- this.generatedTypesTSFilePath = import_path2.default.join(
916
+ this.generatedTypesTSFilePath = path3.join(
868
917
  this.generatedFolderPath,
869
918
  "types.ts"
870
919
  );
871
- this.generatedTypesJSFilePath = import_path2.default.join(
920
+ this.generatedTypesJSFilePath = path3.join(
872
921
  this.generatedFolderPath,
873
922
  "types.js"
874
923
  );
875
- this.generatedTypesDFilePath = import_path2.default.join(
924
+ this.generatedTypesDFilePath = path3.join(
876
925
  this.generatedFolderPath,
877
926
  "types.d.ts"
878
927
  );
879
- this.userQueriesAndFragmentsGlob = import_path2.default.join(
928
+ this.userQueriesAndFragmentsGlob = path3.join(
880
929
  this.tinaFolderPath,
881
930
  "queries/**/*.{graphql,gql}"
882
931
  );
883
- this.generatedQueriesAndFragmentsGlob = import_path2.default.join(
932
+ this.generatedQueriesAndFragmentsGlob = path3.join(
884
933
  this.generatedFolderPath,
885
934
  "*.{graphql,gql}"
886
935
  );
887
- this.generatedClientTSFilePath = import_path2.default.join(
936
+ this.generatedClientTSFilePath = path3.join(
888
937
  this.generatedFolderPath,
889
938
  "client.ts"
890
939
  );
891
- this.generatedClientJSFilePath = import_path2.default.join(
940
+ this.generatedClientJSFilePath = path3.join(
892
941
  this.generatedFolderPath,
893
942
  "client.js"
894
943
  );
895
- this.generatedClientDFilePath = import_path2.default.join(
944
+ this.generatedClientDFilePath = path3.join(
896
945
  this.generatedFolderPath,
897
946
  "client.d.ts"
898
947
  );
899
- this.generatedDatabaseClientDFilePath = import_path2.default.join(
948
+ this.generatedDatabaseClientDFilePath = path3.join(
900
949
  this.generatedFolderPath,
901
950
  "databaseClient.d.ts"
902
951
  );
903
- this.generatedDatabaseClientTSFilePath = import_path2.default.join(
952
+ this.generatedDatabaseClientTSFilePath = path3.join(
904
953
  this.generatedFolderPath,
905
954
  "databaseClient.ts"
906
955
  );
907
- this.generatedDatabaseClientJSFilePath = import_path2.default.join(
956
+ this.generatedDatabaseClientJSFilePath = path3.join(
908
957
  this.generatedFolderPath,
909
958
  "databaseClient.js"
910
959
  );
911
- const clientExists = this.isUsingTs() ? await import_fs_extra2.default.pathExists(this.generatedClientTSFilePath) : await import_fs_extra2.default.pathExists(this.generatedClientJSFilePath);
960
+ const clientExists = this.isUsingTs() ? await fs2.pathExists(this.generatedClientTSFilePath) : await fs2.pathExists(this.generatedClientJSFilePath);
912
961
  if (!clientExists) {
913
962
  const file = "export default ()=>({})\nexport const client = ()=>({})";
914
963
  if (this.isUsingTs()) {
915
- await import_fs_extra2.default.outputFile(this.generatedClientTSFilePath, file);
964
+ await fs2.outputFile(this.generatedClientTSFilePath, file);
916
965
  } else {
917
- await import_fs_extra2.default.outputFile(this.generatedClientJSFilePath, file);
966
+ await fs2.outputFile(this.generatedClientJSFilePath, file);
918
967
  }
919
968
  }
920
969
  const { config: config2, prebuildPath, watchList } = await this.loadConfigFile(
@@ -924,30 +973,29 @@ var ConfigManager = class {
924
973
  this.watchList = watchList;
925
974
  this.config = config2;
926
975
  this.prebuildFilePath = prebuildPath;
927
- this.publicFolderPath = import_path2.default.join(
976
+ this.publicFolderPath = path3.join(
928
977
  this.rootPath,
929
978
  this.config.build.publicFolder
930
979
  );
931
- this.outputFolderPath = import_path2.default.join(
980
+ this.outputFolderPath = path3.join(
932
981
  this.publicFolderPath,
933
982
  this.config.build.outputFolder
934
983
  );
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 || ""
984
+ this.outputHTMLFilePath = path3.join(this.outputFolderPath, "index.html");
985
+ this.outputGitignorePath = path3.join(this.outputFolderPath, ".gitignore");
986
+ const fullLocalContentPath = stripNativeTrailingSlash(
987
+ path3.join(this.tinaFolderPath, this.config.localContentPath || "")
940
988
  );
941
989
  if (this.config.localContentPath) {
942
- const localContentPathExists = await import_fs_extra2.default.pathExists(fullLocalContentPath);
990
+ const localContentPathExists = await fs2.pathExists(fullLocalContentPath);
943
991
  if (localContentPathExists) {
944
992
  logger.info(`Using separate content repo at ${fullLocalContentPath}`);
945
993
  this.contentRootPath = fullLocalContentPath;
946
994
  } else {
947
995
  logger.warn(
948
- `${import_chalk3.default.yellow("Warning:")} The localContentPath ${import_chalk3.default.cyan(
996
+ `${chalk3.yellow("Warning:")} The localContentPath ${chalk3.cyan(
949
997
  fullLocalContentPath
950
- )} does not exist. Please create it or remove the localContentPath from your config file at ${import_chalk3.default.cyan(
998
+ )} does not exist. Please create it or remove the localContentPath from your config file at ${chalk3.cyan(
951
999
  this.tinaConfigFilePath
952
1000
  )}`
953
1001
  );
@@ -956,22 +1004,22 @@ var ConfigManager = class {
956
1004
  if (!this.contentRootPath) {
957
1005
  this.contentRootPath = this.rootPath;
958
1006
  }
959
- this.generatedFolderPathContentRepo = import_path2.default.join(
1007
+ this.generatedFolderPathContentRepo = path3.join(
960
1008
  await this.getTinaFolderPath(this.contentRootPath),
961
1009
  GENERATED_FOLDER
962
1010
  );
963
- this.spaMainPath = require.resolve("@tinacms/app");
964
- this.spaRootPath = import_path2.default.join(this.spaMainPath, "..", "..");
1011
+ this.spaMainPath = require2.resolve("@tinacms/app");
1012
+ this.spaRootPath = path3.join(this.spaMainPath, "..", "..");
965
1013
  }
966
1014
  async getTinaFolderPath(rootPath) {
967
- const tinaFolderPath = import_path2.default.join(rootPath, TINA_FOLDER);
968
- const tinaFolderExists = await import_fs_extra2.default.pathExists(tinaFolderPath);
1015
+ const tinaFolderPath = path3.join(rootPath, TINA_FOLDER);
1016
+ const tinaFolderExists = await fs2.pathExists(tinaFolderPath);
969
1017
  if (tinaFolderExists) {
970
1018
  this.isUsingLegacyFolder = false;
971
1019
  return tinaFolderPath;
972
1020
  }
973
- const legacyFolderPath = import_path2.default.join(rootPath, LEGACY_TINA_FOLDER);
974
- const legacyFolderExists = await import_fs_extra2.default.pathExists(legacyFolderPath);
1021
+ const legacyFolderPath = path3.join(rootPath, LEGACY_TINA_FOLDER);
1022
+ const legacyFolderExists = await fs2.pathExists(legacyFolderPath);
975
1023
  if (legacyFolderExists) {
976
1024
  this.isUsingLegacyFolder = true;
977
1025
  return legacyFolderPath;
@@ -990,8 +1038,8 @@ var ConfigManager = class {
990
1038
  patch: version2[2] || "x"
991
1039
  };
992
1040
  }
993
- const generatedSchema = import_fs_extra2.default.readJSONSync(this.generatedSchemaJSONPath);
994
- if (!generatedSchema || !(typeof (generatedSchema == null ? void 0 : generatedSchema.version) !== "undefined")) {
1041
+ const generatedSchema = fs2.readJSONSync(this.generatedSchemaJSONPath);
1042
+ if (!generatedSchema || !(typeof generatedSchema?.version !== "undefined")) {
995
1043
  throw new Error(
996
1044
  `Can not find Tina GraphQL version in ${this.generatedSchemaJSONPath}`
997
1045
  );
@@ -1037,7 +1085,7 @@ var ConfigManager = class {
1037
1085
  return;
1038
1086
  }
1039
1087
  const filepathWithExtension = `${filepath}.${ext}`;
1040
- const exists = import_fs_extra2.default.existsSync(filepathWithExtension);
1088
+ const exists = fs2.existsSync(filepathWithExtension);
1041
1089
  if (exists) {
1042
1090
  result = filepathWithExtension;
1043
1091
  }
@@ -1046,33 +1094,53 @@ var ConfigManager = class {
1046
1094
  return result;
1047
1095
  }
1048
1096
  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");
1097
+ const tmpdir = path3.join(os.tmpdir(), Date.now().toString());
1098
+ const outfile = path3.join(tmpdir, "database.build.mjs");
1051
1099
  await esbuild.build({
1052
1100
  entryPoints: [this.selfHostedDatabaseFilePath],
1053
1101
  bundle: true,
1054
1102
  platform: "node",
1103
+ format: "esm",
1055
1104
  outfile,
1056
- loader: loaders
1105
+ loader: loaders,
1106
+ // Provide a require() polyfill for ESM bundles containing CommonJS packages.
1107
+ // Some bundled packages (e.g., 'scmp' used by 'mongodb-level') use require('crypto').
1108
+ // When esbuild inlines these CommonJS packages, it keeps the require() calls,
1109
+ // but ESM doesn't have a global require. This banner creates one using Node.js's
1110
+ // official createRequire API, allowing the bundled CommonJS code to work in ESM.
1111
+ banner: {
1112
+ js: `import { createRequire } from 'module';const require = createRequire(import.meta.url);`
1113
+ }
1057
1114
  });
1058
- const result = require(outfile);
1059
- import_fs_extra2.default.removeSync(outfile);
1115
+ const result = await import(pathToFileURL(outfile).href);
1116
+ fs2.removeSync(outfile);
1060
1117
  return result.default;
1061
1118
  }
1062
1119
  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(
1120
+ const tmpdir = path3.join(os.tmpdir(), Date.now().toString());
1121
+ const preBuildConfigPath = path3.join(
1065
1122
  this.generatedFolderPath,
1066
1123
  "config.prebuild.jsx"
1067
1124
  );
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");
1071
- import_fs_extra2.default.outputFileSync(tempTSConfigFile, "{}");
1125
+ const nativeNodeModulesPlugin = {
1126
+ name: "native-node-modules",
1127
+ setup(build3) {
1128
+ build3.onResolve({ filter: /^node:.*/ }, (args) => {
1129
+ return {
1130
+ path: args.path,
1131
+ external: true
1132
+ };
1133
+ });
1134
+ }
1135
+ };
1136
+ const outfile = path3.join(tmpdir, "config.build.jsx");
1137
+ const outfile2 = path3.join(tmpdir, "config.build.mjs");
1138
+ const tempTSConfigFile = path3.join(tmpdir, "tsconfig.json");
1139
+ fs2.outputFileSync(tempTSConfigFile, "{}");
1072
1140
  const result2 = await esbuild.build({
1073
1141
  entryPoints: [configFilePath],
1074
1142
  bundle: true,
1075
- target: ["es2020"],
1143
+ target: ["esnext"],
1076
1144
  platform: "browser",
1077
1145
  format: "esm",
1078
1146
  logLevel: "silent",
@@ -1092,9 +1160,10 @@ var ConfigManager = class {
1092
1160
  await esbuild.build({
1093
1161
  entryPoints: [configFilePath],
1094
1162
  bundle: true,
1095
- target: ["es2020"],
1163
+ target: ["esnext"],
1096
1164
  logLevel: "silent",
1097
1165
  platform: "node",
1166
+ format: "esm",
1098
1167
  outfile,
1099
1168
  loader: loaders
1100
1169
  });
@@ -1104,19 +1173,21 @@ var ConfigManager = class {
1104
1173
  // Suppress warning about comparison with -0 from client module
1105
1174
  logLevel: "silent",
1106
1175
  platform: "node",
1176
+ target: ["esnext"],
1177
+ format: "esm",
1107
1178
  outfile: outfile2,
1108
1179
  loader: loaders
1109
1180
  });
1110
1181
  let result;
1111
1182
  try {
1112
- result = require(outfile2);
1183
+ result = await import(pathToFileURL(outfile2).href);
1113
1184
  } catch (e) {
1114
1185
  console.error("Unexpected error loading config");
1115
1186
  console.error(e);
1116
1187
  throw e;
1117
1188
  }
1118
- import_fs_extra2.default.removeSync(outfile);
1119
- import_fs_extra2.default.removeSync(outfile2);
1189
+ fs2.removeSync(outfile);
1190
+ fs2.removeSync(outfile2);
1120
1191
  return {
1121
1192
  config: result.default,
1122
1193
  prebuildPath: preBuildConfigPath,
@@ -1151,24 +1222,28 @@ var loaders = {
1151
1222
  };
1152
1223
 
1153
1224
  // src/next/database.ts
1154
- var import_graphql7 = require("@tinacms/graphql");
1155
- var import_readable_stream = require("readable-stream");
1156
- var import_net = require("net");
1157
- var import_many_level = require("many-level");
1158
- var import_memory_level = require("memory-level");
1225
+ import {
1226
+ createDatabaseInternal,
1227
+ FilesystemBridge,
1228
+ TinaLevelClient
1229
+ } from "@tinacms/graphql";
1230
+ import { pipeline } from "readable-stream";
1231
+ import { createServer } from "net";
1232
+ import { ManyLevelHost } from "many-level";
1233
+ import { MemoryLevel } from "memory-level";
1159
1234
  var createDBServer = (port) => {
1160
- const levelHost = new import_many_level.ManyLevelHost(
1235
+ const levelHost = new ManyLevelHost(
1161
1236
  // @ts-ignore
1162
- new import_memory_level.MemoryLevel({
1237
+ new MemoryLevel({
1163
1238
  valueEncoding: "json"
1164
1239
  })
1165
1240
  );
1166
- const dbServer = (0, import_net.createServer)(function(socket) {
1167
- return (0, import_readable_stream.pipeline)(socket, levelHost.createRpcStream(), socket, () => {
1241
+ const dbServer = createServer(function(socket) {
1242
+ return pipeline(socket, levelHost.createRpcStream(), socket, () => {
1168
1243
  });
1169
1244
  });
1170
1245
  dbServer.once("error", (err) => {
1171
- if ((err == null ? void 0 : err.code) === "EADDRINUSE") {
1246
+ if (err?.code === "EADDRINUSE") {
1172
1247
  throw new Error(
1173
1248
  `Tina Dev server is already in use. Datalayer server is busy on port ${port}`
1174
1249
  );
@@ -1178,7 +1253,7 @@ var createDBServer = (port) => {
1178
1253
  };
1179
1254
  async function createAndInitializeDatabase(configManager, datalayerPort, bridgeOverride) {
1180
1255
  let database;
1181
- const bridge = bridgeOverride || new import_graphql7.FilesystemBridge(configManager.rootPath, configManager.contentRootPath);
1256
+ const bridge = bridgeOverride || new FilesystemBridge(configManager.rootPath, configManager.contentRootPath);
1182
1257
  if (configManager.hasSelfHostedConfig() && configManager.config.contentApiUrlOverride) {
1183
1258
  database = await configManager.loadDatabaseFile();
1184
1259
  database.bridge = bridge;
@@ -1190,9 +1265,9 @@ async function createAndInitializeDatabase(configManager, datalayerPort, bridgeO
1190
1265
  )} but there was no "contentApiUrlOverride" set. Falling back to built-in datalayer`
1191
1266
  );
1192
1267
  }
1193
- const level = new import_graphql7.TinaLevelClient(datalayerPort);
1268
+ const level = new TinaLevelClient(datalayerPort);
1194
1269
  level.openConnection();
1195
- database = (0, import_graphql7.createDatabaseInternal)({
1270
+ database = createDatabaseInternal({
1196
1271
  bridge,
1197
1272
  level,
1198
1273
  tinaDirectory: configManager.isUsingLegacyFolder ? LEGACY_TINA_FOLDER : TINA_FOLDER
@@ -1202,17 +1277,17 @@ async function createAndInitializeDatabase(configManager, datalayerPort, bridgeO
1202
1277
  }
1203
1278
 
1204
1279
  // src/next/commands/baseCommands.ts
1205
- var import_clipanion = require("clipanion");
1206
- var import_chalk4 = __toESM(require("chalk"));
1280
+ import { Command, Option } from "clipanion";
1281
+ import chalk4 from "chalk";
1207
1282
 
1208
1283
  // src/utils/start-subprocess.ts
1209
- var import_child_process = __toESM(require("child_process"));
1284
+ import childProcess from "child_process";
1210
1285
  var startSubprocess2 = async ({ command: command2 }) => {
1211
1286
  if (typeof command2 === "string") {
1212
1287
  const commands = command2.split(" ");
1213
1288
  const firstCommand = commands[0];
1214
1289
  const args = commands.slice(1) || [];
1215
- const ps = import_child_process.default.spawn(firstCommand, args, {
1290
+ const ps = childProcess.spawn(firstCommand, args, {
1216
1291
  stdio: "inherit",
1217
1292
  shell: true
1218
1293
  });
@@ -1236,45 +1311,42 @@ stack: ${code.stack || "No stack was provided"}`);
1236
1311
  };
1237
1312
 
1238
1313
  // src/next/commands/baseCommands.ts
1239
- var import_graphql8 = require("@tinacms/graphql");
1240
- var import_fs_extra3 = __toESM(require("fs-extra"));
1241
- var BaseCommand = class extends import_clipanion.Command {
1242
- constructor() {
1243
- super(...arguments);
1244
- this.experimentalDataLayer = import_clipanion.Option.Boolean("--experimentalData", {
1245
- description: "DEPRECATED - Build the server with additional data querying capabilities"
1246
- });
1247
- this.isomorphicGitBridge = import_clipanion.Option.Boolean("--isomorphicGitBridge", {
1248
- description: "DEPRECATED - Enable Isomorphic Git Bridge Implementation"
1249
- });
1250
- this.port = import_clipanion.Option.String("-p,--port", "4001", {
1251
- description: "Specify a port to run the server on. (default 4001)"
1252
- });
1253
- this.datalayerPort = import_clipanion.Option.String("--datalayer-port", "9000", {
1254
- description: "Specify a port to run the datalayer server on. (default 9000)"
1255
- });
1256
- this.subCommand = import_clipanion.Option.String("-c,--command", {
1257
- description: "The sub-command to run"
1258
- });
1259
- this.rootPath = import_clipanion.Option.String("--rootPath", {
1260
- description: "Specify the root directory to run the CLI from (defaults to current working directory)"
1261
- });
1262
- this.verbose = import_clipanion.Option.Boolean("-v,--verbose", false, {
1263
- description: "increase verbosity of logged output"
1264
- });
1265
- this.noSDK = import_clipanion.Option.Boolean("--noSDK", false, {
1266
- description: "DEPRECATED - This should now be set in the config at client.skip = true'. Don't generate the generated client SDK"
1267
- });
1268
- this.noTelemetry = import_clipanion.Option.Boolean("--noTelemetry", false, {
1269
- description: "Disable anonymous telemetry that is collected"
1270
- });
1271
- }
1314
+ import { getChangedFiles, getSha, shaExists } from "@tinacms/graphql";
1315
+ import fs3 from "fs-extra";
1316
+ var BaseCommand = class extends Command {
1317
+ experimentalDataLayer = Option.Boolean("--experimentalData", {
1318
+ description: "DEPRECATED - Build the server with additional data querying capabilities"
1319
+ });
1320
+ isomorphicGitBridge = Option.Boolean("--isomorphicGitBridge", {
1321
+ description: "DEPRECATED - Enable Isomorphic Git Bridge Implementation"
1322
+ });
1323
+ port = Option.String("-p,--port", "4001", {
1324
+ description: "Specify a port to run the server on. (default 4001)"
1325
+ });
1326
+ datalayerPort = Option.String("--datalayer-port", "9000", {
1327
+ description: "Specify a port to run the datalayer server on. (default 9000)"
1328
+ });
1329
+ subCommand = Option.String("-c,--command", {
1330
+ description: "The sub-command to run"
1331
+ });
1332
+ rootPath = Option.String("--rootPath", {
1333
+ description: "Specify the root directory to run the CLI from (defaults to current working directory)"
1334
+ });
1335
+ verbose = Option.Boolean("-v,--verbose", false, {
1336
+ description: "increase verbosity of logged output"
1337
+ });
1338
+ noSDK = Option.Boolean("--noSDK", false, {
1339
+ description: "DEPRECATED - This should now be set in the config at client.skip = true'. Don't generate the generated client SDK"
1340
+ });
1341
+ noTelemetry = Option.Boolean("--noTelemetry", false, {
1342
+ description: "Disable anonymous telemetry that is collected"
1343
+ });
1272
1344
  async startSubCommand() {
1273
1345
  let subProc;
1274
1346
  if (this.subCommand) {
1275
1347
  subProc = await startSubprocess2({ command: this.subCommand });
1276
1348
  logger.info(
1277
- `Running web application with command: ${import_chalk4.default.cyan(this.subCommand)}`
1349
+ `Running web application with command: ${chalk4.cyan(this.subCommand)}`
1278
1350
  );
1279
1351
  }
1280
1352
  function exitHandler(options, exitCode) {
@@ -1319,11 +1391,10 @@ var BaseCommand = class extends import_clipanion.Command {
1319
1391
  const warnings = [];
1320
1392
  await spin({
1321
1393
  waitFor: async () => {
1322
- var _a, _b;
1323
1394
  const rootPath = configManager.rootPath;
1324
1395
  let sha;
1325
1396
  try {
1326
- sha = await (0, import_graphql8.getSha)({ fs: import_fs_extra3.default, dir: rootPath });
1397
+ sha = await getSha({ fs: fs3, dir: rootPath });
1327
1398
  } catch (e) {
1328
1399
  if (partialReindex) {
1329
1400
  console.error(
@@ -1333,7 +1404,7 @@ var BaseCommand = class extends import_clipanion.Command {
1333
1404
  }
1334
1405
  }
1335
1406
  const lastSha = await database.getMetadata("lastSha");
1336
- const exists = lastSha && await (0, import_graphql8.shaExists)({ fs: import_fs_extra3.default, dir: rootPath, sha: lastSha });
1407
+ const exists = lastSha && await shaExists({ fs: fs3, dir: rootPath, sha: lastSha });
1337
1408
  let res;
1338
1409
  if (partialReindex && lastSha && exists && sha) {
1339
1410
  const pathFilter = {};
@@ -1344,18 +1415,18 @@ var BaseCommand = class extends import_clipanion.Command {
1344
1415
  }
1345
1416
  for (const collection of tinaSchema.getCollections()) {
1346
1417
  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
1418
+ matches: collection.match?.exclude || collection.match?.include ? tinaSchema.getMatches({ collection }) : void 0
1348
1419
  };
1349
1420
  }
1350
- const { added, modified, deleted } = await (0, import_graphql8.getChangedFiles)({
1351
- fs: import_fs_extra3.default,
1421
+ const { added, modified, deleted } = await getChangedFiles({
1422
+ fs: fs3,
1352
1423
  dir: rootPath,
1353
1424
  from: lastSha,
1354
1425
  to: sha,
1355
1426
  pathFilter
1356
1427
  });
1357
1428
  const tinaPathUpdates = modified.filter(
1358
- (path14) => path14.startsWith(".tina/__generated__/_schema.json") || path14.startsWith("tina/tina-lock.json")
1429
+ (path15) => path15.startsWith(".tina/__generated__/_schema.json") || path15.startsWith("tina/tina-lock.json")
1359
1430
  );
1360
1431
  if (tinaPathUpdates.length > 0) {
1361
1432
  res = await database.indexContent({
@@ -1379,7 +1450,7 @@ var BaseCommand = class extends import_clipanion.Command {
1379
1450
  if (sha) {
1380
1451
  await database.setMetadata("lastSha", sha);
1381
1452
  }
1382
- if (res == null ? void 0 : res.warnings) {
1453
+ if (res?.warnings) {
1383
1454
  warnings.push(...res.warnings);
1384
1455
  }
1385
1456
  },
@@ -1433,7 +1504,7 @@ var errorHTML = `<style type="text/css">
1433
1504
  the assets for this page.
1434
1505
  </p>
1435
1506
  <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.
1507
+ 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
1508
  </p>
1438
1509
  </div>
1439
1510
  </div>`.trim().replace(/[\r\n\s]+/g, " ");
@@ -1471,34 +1542,38 @@ var devHTML = (port) => `<!DOCTYPE html>
1471
1542
  </html>`;
1472
1543
 
1473
1544
  // src/next/commands/dev-command/server/index.ts
1474
- var import_vite3 = require("vite");
1545
+ import { createServer as createViteServer } from "vite";
1475
1546
 
1476
1547
  // src/next/vite/index.ts
1477
- var import_node_path2 = __toESM(require("path"));
1478
- var import_plugin_react = __toESM(require("@vitejs/plugin-react"));
1479
- var import_fs_extra4 = __toESM(require("fs-extra"));
1480
- var import_normalize_path3 = __toESM(require("normalize-path"));
1481
- var import_vite = require("vite");
1548
+ import path5 from "node:path";
1549
+ import react from "@vitejs/plugin-react";
1550
+ import fs4 from "fs-extra";
1551
+ import normalizePath3 from "normalize-path";
1552
+ import {
1553
+ splitVendorChunkPlugin
1554
+ } from "vite";
1482
1555
 
1483
1556
  // src/next/vite/tailwind.ts
1484
- var import_node_path = __toESM(require("path"));
1485
- var import_aspect_ratio = __toESM(require("@tailwindcss/aspect-ratio"));
1486
- var import_container_queries = __toESM(require("@tailwindcss/container-queries"));
1487
- var import_typography = __toESM(require("@tailwindcss/typography"));
1488
- var import_tailwindcss = __toESM(require("tailwindcss"));
1489
- var import_defaultTheme = __toESM(require("tailwindcss/defaultTheme.js"));
1557
+ import path4 from "node:path";
1558
+ import aspectRatio from "@tailwindcss/aspect-ratio";
1559
+ import containerQueries from "@tailwindcss/container-queries";
1560
+ import twTypography from "@tailwindcss/typography";
1561
+ import tailwind from "tailwindcss";
1562
+ import defaultTheme from "tailwindcss/defaultTheme.js";
1563
+ import { createRequire as createRequire2 } from "module";
1490
1564
  var tinaTailwind = (spaPath, prebuildFilePath) => {
1491
1565
  return {
1492
1566
  name: "vite-plugin-tina",
1493
1567
  // @ts-ignore
1494
1568
  config: (viteConfig) => {
1569
+ const require2 = createRequire2(import.meta.url);
1495
1570
  const plugins = [];
1496
1571
  const content = [
1497
- import_node_path.default.join(spaPath, "src/**/*.{vue,js,ts,jsx,tsx,svelte}"),
1572
+ path4.join(spaPath, "src/**/*.{vue,js,ts,jsx,tsx,svelte}"),
1498
1573
  prebuildFilePath,
1499
- require.resolve("tinacms")
1574
+ require2.resolve("tinacms")
1500
1575
  ];
1501
- const tw = (0, import_tailwindcss.default)({
1576
+ const tw = tailwind({
1502
1577
  theme: {
1503
1578
  columns: {
1504
1579
  auto: "auto",
@@ -1686,6 +1761,9 @@ var tinaTailwind = (spaPath, prebuildFilePath) => {
1686
1761
  500: "#EC4815",
1687
1762
  600: "#DC4419"
1688
1763
  },
1764
+ "tina-orange": "#EC4815",
1765
+ "tina-orange-dark": "#C2410C",
1766
+ "tina-orange-light": "#FFF7ED",
1689
1767
  background: "#FFFFFF",
1690
1768
  foreground: "#0A0A0A",
1691
1769
  muted: "#F5F5F5",
@@ -1707,7 +1785,7 @@ var tinaTailwind = (spaPath, prebuildFilePath) => {
1707
1785
  ring: "#0A0A0A"
1708
1786
  },
1709
1787
  fontFamily: {
1710
- sans: ["Inter", ...import_defaultTheme.default.fontFamily.sans]
1788
+ sans: ["Inter", ...defaultTheme.fontFamily.sans]
1711
1789
  },
1712
1790
  lineHeight: {
1713
1791
  3: "12px",
@@ -1732,9 +1810,9 @@ var tinaTailwind = (spaPath, prebuildFilePath) => {
1732
1810
  },
1733
1811
  content,
1734
1812
  plugins: [
1735
- (0, import_typography.default)({ className: "tina-prose" }),
1736
- import_aspect_ratio.default,
1737
- import_container_queries.default
1813
+ twTypography({ className: "tina-prose" }),
1814
+ aspectRatio,
1815
+ containerQueries
1738
1816
  ]
1739
1817
  });
1740
1818
  plugins.push(tw);
@@ -1755,35 +1833,35 @@ async function listFilesRecursively({
1755
1833
  config: config2,
1756
1834
  roothPath
1757
1835
  }) {
1758
- const fullDirectoryPath = import_node_path2.default.join(
1836
+ const fullDirectoryPath = path5.join(
1759
1837
  roothPath,
1760
1838
  config2.publicFolder,
1761
1839
  directoryPath
1762
1840
  );
1763
- const exists = await import_fs_extra4.default.pathExists(fullDirectoryPath);
1841
+ const exists = await fs4.pathExists(fullDirectoryPath);
1764
1842
  if (!exists) {
1765
1843
  return { "0": [] };
1766
1844
  }
1767
- const items = await import_fs_extra4.default.readdir(fullDirectoryPath);
1845
+ const items = await fs4.readdir(fullDirectoryPath);
1768
1846
  const staticMediaItems = [];
1769
1847
  for (const item of items) {
1770
- const itemPath = import_node_path2.default.join(fullDirectoryPath, item);
1771
- const stats = await import_fs_extra4.default.promises.lstat(itemPath);
1848
+ const itemPath = path5.join(fullDirectoryPath, item);
1849
+ const stats = await fs4.promises.lstat(itemPath);
1772
1850
  const staticMediaItem = {
1773
1851
  id: item,
1774
1852
  filename: item,
1775
1853
  type: stats.isDirectory() ? "dir" : "file",
1776
1854
  directory: `${directoryPath.replace(config2.mediaRoot, "")}`,
1777
- src: `/${import_node_path2.default.join(directoryPath, item)}`,
1855
+ src: `/${path5.join(directoryPath, item)}`,
1778
1856
  thumbnails: {
1779
- "75x75": `/${import_node_path2.default.join(directoryPath, item)}`,
1780
- "400x400": `/${import_node_path2.default.join(directoryPath, item)}`,
1781
- "1000x1000": `/${import_node_path2.default.join(directoryPath, item)}`
1857
+ "75x75": `/${path5.join(directoryPath, item)}`,
1858
+ "400x400": `/${path5.join(directoryPath, item)}`,
1859
+ "1000x1000": `/${path5.join(directoryPath, item)}`
1782
1860
  }
1783
1861
  };
1784
1862
  if (stats.isDirectory()) {
1785
1863
  staticMediaItem.children = await listFilesRecursively({
1786
- directoryPath: import_node_path2.default.join(directoryPath, item),
1864
+ directoryPath: path5.join(directoryPath, item),
1787
1865
  config: config2,
1788
1866
  roothPath
1789
1867
  });
@@ -1807,7 +1885,6 @@ var createConfig = async ({
1807
1885
  noWatch,
1808
1886
  rollupOptions
1809
1887
  }) => {
1810
- var _a, _b, _c, _d, _e, _f, _g, _h;
1811
1888
  const publicEnv = {};
1812
1889
  Object.keys(process.env).forEach((key) => {
1813
1890
  if (key.startsWith("TINA_PUBLIC_") || key.startsWith("NEXT_PUBLIC_") || key === "NODE_ENV" || key === "HEAD") {
@@ -1825,31 +1902,31 @@ var createConfig = async ({
1825
1902
  }
1826
1903
  }
1827
1904
  });
1828
- const staticMediaPath = import_node_path2.default.join(
1905
+ const staticMediaPath = path5.join(
1829
1906
  configManager.generatedFolderPath,
1830
1907
  "static-media.json"
1831
1908
  );
1832
- if ((_b = (_a = configManager.config.media) == null ? void 0 : _a.tina) == null ? void 0 : _b.static) {
1909
+ if (configManager.config.media?.tina?.static) {
1833
1910
  const staticMedia = await listFilesRecursively({
1834
- directoryPath: ((_c = configManager.config.media.tina) == null ? void 0 : _c.mediaRoot) || "",
1911
+ directoryPath: configManager.config.media.tina?.mediaRoot || "",
1835
1912
  config: configManager.config.media.tina,
1836
1913
  roothPath: configManager.rootPath
1837
1914
  });
1838
- await import_fs_extra4.default.outputFile(staticMediaPath, JSON.stringify(staticMedia, null, 2));
1915
+ await fs4.outputFile(staticMediaPath, JSON.stringify(staticMedia, null, 2));
1839
1916
  } else {
1840
- await import_fs_extra4.default.outputFile(staticMediaPath, `[]`);
1917
+ await fs4.outputFile(staticMediaPath, `[]`);
1841
1918
  }
1842
1919
  const alias = {
1843
1920
  TINA_IMPORT: configManager.prebuildFilePath,
1844
1921
  SCHEMA_IMPORT: configManager.generatedGraphQLJSONPath,
1845
1922
  STATIC_MEDIA_IMPORT: staticMediaPath,
1846
- crypto: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
1847
- fs: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
1848
- os: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
1849
- path: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts")
1923
+ crypto: path5.join(configManager.spaRootPath, "src", "dummy-client.ts"),
1924
+ fs: path5.join(configManager.spaRootPath, "src", "dummy-client.ts"),
1925
+ os: path5.join(configManager.spaRootPath, "src", "dummy-client.ts"),
1926
+ path: path5.join(configManager.spaRootPath, "src", "dummy-client.ts")
1850
1927
  };
1851
1928
  if (configManager.shouldSkipSDK()) {
1852
- alias["CLIENT_IMPORT"] = import_node_path2.default.join(
1929
+ alias["CLIENT_IMPORT"] = path5.join(
1853
1930
  configManager.spaRootPath,
1854
1931
  "src",
1855
1932
  "dummy-client.ts"
@@ -1865,7 +1942,7 @@ var createConfig = async ({
1865
1942
  const version2 = `${fullVersion.major}.${fullVersion.minor}`;
1866
1943
  const config2 = {
1867
1944
  root: configManager.spaRootPath,
1868
- base: `/${basePath ? `${(0, import_normalize_path3.default)(basePath)}/` : ""}${(0, import_normalize_path3.default)(
1945
+ base: `/${basePath ? `${normalizePath3(basePath)}/` : ""}${normalizePath3(
1869
1946
  configManager.config.build.outputFolder
1870
1947
  )}/`,
1871
1948
  appType: "spa",
@@ -1892,7 +1969,7 @@ var createConfig = async ({
1892
1969
  // Used by picomatch https://github.com/micromatch/picomatch/blob/master/lib/utils.js#L4
1893
1970
  "process.platform": `"${process.platform}"`,
1894
1971
  __API_URL__: `"${apiURL}"`,
1895
- __BASE_PATH__: `"${((_e = (_d = configManager.config) == null ? void 0 : _d.build) == null ? void 0 : _e.basePath) || ""}"`,
1972
+ __BASE_PATH__: `"${configManager.config?.build?.basePath || ""}"`,
1896
1973
  __TINA_GRAPHQL_VERSION__: version2
1897
1974
  },
1898
1975
  logLevel: "error",
@@ -1904,7 +1981,7 @@ var createConfig = async ({
1904
1981
  include: ["react/jsx-runtime", "react/jsx-dev-runtime"]
1905
1982
  },
1906
1983
  server: {
1907
- host: (_h = (_g = (_f = configManager.config) == null ? void 0 : _f.build) == null ? void 0 : _g.host) != null ? _h : false,
1984
+ host: configManager.config?.build?.host ?? false,
1908
1985
  watch: noWatch ? {
1909
1986
  ignored: ["**/*"]
1910
1987
  } : {
@@ -1928,13 +2005,14 @@ var createConfig = async ({
1928
2005
  * `splitVendorChunkPlugin` is needed because `tinacms` is quite large,
1929
2006
  * Vite's chunking strategy chokes on memory issues for smaller machines (ie. on CI).
1930
2007
  */
1931
- (0, import_plugin_react.default)({
2008
+ react({
1932
2009
  babel: {
1933
2010
  // Supresses the warning [NOTE] babel The code generator has deoptimised the styling of
1934
2011
  compact: true
1935
- }
2012
+ },
2013
+ fastRefresh: false
1936
2014
  }),
1937
- (0, import_vite.splitVendorChunkPlugin)(),
2015
+ splitVendorChunkPlugin(),
1938
2016
  tinaTailwind(configManager.spaRootPath, configManager.prebuildFilePath),
1939
2017
  ...plugins
1940
2018
  ]
@@ -1943,21 +2021,21 @@ var createConfig = async ({
1943
2021
  };
1944
2022
 
1945
2023
  // src/next/vite/plugins.ts
1946
- var import_pluginutils = require("@rollup/pluginutils");
1947
- var import_fs = __toESM(require("fs"));
1948
- var import_vite2 = require("vite");
1949
- var import_esbuild2 = require("esbuild");
1950
- var import_path4 = __toESM(require("path"));
1951
- var import_body_parser = __toESM(require("body-parser"));
1952
- var import_cors = __toESM(require("cors"));
1953
- var import_graphql9 = require("@tinacms/graphql");
2024
+ import { createFilter } from "@rollup/pluginutils";
2025
+ import fs6 from "fs";
2026
+ import { transformWithEsbuild } from "vite";
2027
+ import { transform as esbuildTransform } from "esbuild";
2028
+ import path7 from "path";
2029
+ import bodyParser from "body-parser";
2030
+ import cors from "cors";
2031
+ import { resolve as gqlResolve } from "@tinacms/graphql";
1954
2032
 
1955
2033
  // src/next/commands/dev-command/server/media.ts
1956
- var import_fs_extra5 = __toESM(require("fs-extra"));
1957
- var import_path3 = __toESM(require("path"));
1958
- var import_busboy = __toESM(require("busboy"));
2034
+ import fs5 from "fs-extra";
2035
+ import path6, { join } from "path";
2036
+ import busboy from "busboy";
1959
2037
  var createMediaRouter = (config2) => {
1960
- const mediaFolder = import_path3.default.join(
2038
+ const mediaFolder = path6.join(
1961
2039
  config2.rootPath,
1962
2040
  config2.publicFolder,
1963
2041
  config2.mediaRoot
@@ -1981,13 +2059,12 @@ var createMediaRouter = (config2) => {
1981
2059
  res.end(JSON.stringify(didDelete));
1982
2060
  };
1983
2061
  const handlePost = async function(req, res) {
1984
- const bb = (0, import_busboy.default)({ headers: req.headers });
2062
+ const bb = busboy({ headers: req.headers });
1985
2063
  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));
1990
- file.pipe(import_fs_extra5.default.createWriteStream(saveTo));
2064
+ const fullPath = decodeURI(req.url?.slice("/media/upload/".length));
2065
+ const saveTo = path6.join(mediaFolder, ...fullPath.split("/"));
2066
+ await fs5.ensureDir(path6.dirname(saveTo));
2067
+ file.pipe(fs5.createWriteStream(saveTo));
1991
2068
  });
1992
2069
  bb.on("error", (error) => {
1993
2070
  res.statusCode = 500;
@@ -2013,6 +2090,9 @@ var parseMediaFolder = (str) => {
2013
2090
  return returnString;
2014
2091
  };
2015
2092
  var MediaModel = class {
2093
+ rootPath;
2094
+ publicFolder;
2095
+ mediaRoot;
2016
2096
  constructor({ rootPath, publicFolder, mediaRoot }) {
2017
2097
  this.rootPath = rootPath;
2018
2098
  this.mediaRoot = mediaRoot;
@@ -2020,23 +2100,23 @@ var MediaModel = class {
2020
2100
  }
2021
2101
  async listMedia(args) {
2022
2102
  try {
2023
- const folderPath = (0, import_path3.join)(
2103
+ const folderPath = join(
2024
2104
  this.rootPath,
2025
2105
  this.publicFolder,
2026
2106
  this.mediaRoot,
2027
2107
  decodeURIComponent(args.searchPath)
2028
2108
  );
2029
2109
  const searchPath = parseMediaFolder(args.searchPath);
2030
- if (!await import_fs_extra5.default.pathExists(folderPath)) {
2110
+ if (!await fs5.pathExists(folderPath)) {
2031
2111
  return {
2032
2112
  files: [],
2033
2113
  directories: []
2034
2114
  };
2035
2115
  }
2036
- const filesStr = await import_fs_extra5.default.readdir(folderPath);
2116
+ const filesStr = await fs5.readdir(folderPath);
2037
2117
  const filesProm = filesStr.map(async (file) => {
2038
- const filePath = (0, import_path3.join)(folderPath, file);
2039
- const stat = await import_fs_extra5.default.stat(filePath);
2118
+ const filePath = join(folderPath, file);
2119
+ const stat = await fs5.stat(filePath);
2040
2120
  let src = `/${file}`;
2041
2121
  const isFile = stat.isFile();
2042
2122
  if (!isFile) {
@@ -2086,24 +2166,24 @@ var MediaModel = class {
2086
2166
  return {
2087
2167
  files: [],
2088
2168
  directories: [],
2089
- error: error == null ? void 0 : error.toString()
2169
+ error: error?.toString()
2090
2170
  };
2091
2171
  }
2092
2172
  }
2093
2173
  async deleteMedia(args) {
2094
2174
  try {
2095
- const file = (0, import_path3.join)(
2175
+ const file = join(
2096
2176
  this.rootPath,
2097
2177
  this.publicFolder,
2098
2178
  this.mediaRoot,
2099
2179
  decodeURIComponent(args.searchPath)
2100
2180
  );
2101
- await import_fs_extra5.default.stat(file);
2102
- await import_fs_extra5.default.remove(file);
2181
+ await fs5.stat(file);
2182
+ await fs5.remove(file);
2103
2183
  return { ok: true };
2104
2184
  } catch (error) {
2105
2185
  console.error(error);
2106
- return { ok: false, message: error == null ? void 0 : error.toString() };
2186
+ return { ok: false, message: error?.toString() };
2107
2187
  }
2108
2188
  }
2109
2189
  };
@@ -2157,9 +2237,9 @@ var transformTsxPlugin = ({
2157
2237
  const plug = {
2158
2238
  name: "transform-tsx",
2159
2239
  async transform(code, id) {
2160
- const extName = import_path4.default.extname(id);
2240
+ const extName = path7.extname(id);
2161
2241
  if (extName.startsWith(".tsx") || extName.startsWith(".ts")) {
2162
- const result = await (0, import_esbuild2.transform)(code, { loader: "tsx" });
2242
+ const result = await esbuildTransform(code, { loader: "tsx" });
2163
2243
  return {
2164
2244
  code: result.code
2165
2245
  };
@@ -2178,16 +2258,15 @@ var devServerEndPointsPlugin = ({
2178
2258
  const plug = {
2179
2259
  name: "graphql-endpoints",
2180
2260
  configureServer(server) {
2181
- server.middlewares.use((0, import_cors.default)());
2182
- server.middlewares.use(import_body_parser.default.json({ limit: "5mb" }));
2261
+ server.middlewares.use(cors());
2262
+ server.middlewares.use(bodyParser.json({ limit: "5mb" }));
2183
2263
  server.middlewares.use(async (req, res, next) => {
2184
- var _a;
2185
- const mediaPaths = (_a = configManager.config.media) == null ? void 0 : _a.tina;
2264
+ const mediaPaths = configManager.config.media?.tina;
2186
2265
  const mediaRouter = createMediaRouter({
2187
2266
  rootPath: configManager.rootPath,
2188
2267
  apiURL,
2189
- publicFolder: parseMediaFolder((mediaPaths == null ? void 0 : mediaPaths.publicFolder) || ""),
2190
- mediaRoot: parseMediaFolder((mediaPaths == null ? void 0 : mediaPaths.mediaRoot) || "")
2268
+ publicFolder: parseMediaFolder(mediaPaths?.publicFolder || ""),
2269
+ mediaRoot: parseMediaFolder(mediaPaths?.mediaRoot || "")
2191
2270
  });
2192
2271
  const searchIndexRouter = createSearchIndexRouter({
2193
2272
  config: { apiURL, searchPath: "searchIndex" },
@@ -2219,7 +2298,7 @@ var devServerEndPointsPlugin = ({
2219
2298
  const { query, variables } = req.body;
2220
2299
  let result;
2221
2300
  await databaseLock(async () => {
2222
- result = await (0, import_graphql9.resolve)({
2301
+ result = await gqlResolve({
2223
2302
  config: {
2224
2303
  useRelativeMedia: true
2225
2304
  },
@@ -2255,13 +2334,13 @@ function viteTransformExtension({
2255
2334
  include = "**/*.svg",
2256
2335
  exclude
2257
2336
  } = {}) {
2258
- const filter = (0, import_pluginutils.createFilter)(include, exclude);
2337
+ const filter = createFilter(include, exclude);
2259
2338
  return {
2260
2339
  name: "vite-plugin-svgr",
2261
2340
  async transform(code, id) {
2262
2341
  if (filter(id)) {
2263
- const { transform: transform2 } = await Promise.resolve().then(() => __toESM(require("@svgr/core")));
2264
- const svgCode = await import_fs.default.promises.readFile(
2342
+ const { transform: transform2 } = await import("@svgr/core");
2343
+ const svgCode = await fs6.promises.readFile(
2265
2344
  id.replace(/\?.*$/, ""),
2266
2345
  "utf8"
2267
2346
  );
@@ -2271,7 +2350,7 @@ function viteTransformExtension({
2271
2350
  previousExport: exportAsDefault ? null : code
2272
2351
  }
2273
2352
  });
2274
- const res = await (0, import_vite2.transformWithEsbuild)(componentCode, id, {
2353
+ const res = await transformWithEsbuild(componentCode, id, {
2275
2354
  loader: "jsx",
2276
2355
  ...esbuildOptions
2277
2356
  });
@@ -2298,7 +2377,7 @@ var createDevServer = async (configManager, database, searchIndex, apiURL, noWat
2298
2377
  }),
2299
2378
  viteTransformExtension()
2300
2379
  ];
2301
- return (0, import_vite3.createServer)(
2380
+ return createViteServer(
2302
2381
  await createConfig({
2303
2382
  configManager,
2304
2383
  database,
@@ -2328,23 +2407,30 @@ var createDevServer = async (configManager, database, searchIndex, apiURL, noWat
2328
2407
 
2329
2408
  // src/next/commands/dev-command/index.ts
2330
2409
  var DevCommand = class extends BaseCommand {
2331
- constructor() {
2332
- super(...arguments);
2333
- // NOTE: camelCase commands for string options don't work if there's an `=` used https://github.com/arcanis/clipanion/issues/141
2334
- this.watchFolders = import_clipanion2.Option.String("-w,--watchFolders", {
2335
- description: "DEPRECATED - a list of folders (relative to where this is being run) that the cli will watch for changes"
2336
- });
2337
- this.noWatch = import_clipanion2.Option.Boolean("--noWatch", false, {
2338
- description: "Don't regenerate config on file changes"
2339
- });
2340
- this.outputSearchIndexPath = import_clipanion2.Option.String("--outputSearchIndexPath", {
2341
- description: "Path to write the search index to"
2342
- });
2343
- this.noServer = import_clipanion2.Option.Boolean("--no-server", false, {
2344
- description: "Do not start the dev server"
2345
- });
2346
- this.indexingLock = new import_async_lock.default();
2347
- }
2410
+ static paths = [["dev"], ["server:start"]];
2411
+ // NOTE: camelCase commands for string options don't work if there's an `=` used https://github.com/arcanis/clipanion/issues/141
2412
+ watchFolders = Option2.String("-w,--watchFolders", {
2413
+ description: "DEPRECATED - a list of folders (relative to where this is being run) that the cli will watch for changes"
2414
+ });
2415
+ noWatch = Option2.Boolean("--noWatch", false, {
2416
+ description: "Don't regenerate config on file changes"
2417
+ });
2418
+ outputSearchIndexPath = Option2.String("--outputSearchIndexPath", {
2419
+ description: "Path to write the search index to"
2420
+ });
2421
+ noServer = Option2.Boolean("--no-server", false, {
2422
+ description: "Do not start the dev server"
2423
+ });
2424
+ indexingLock = new AsyncLock();
2425
+ // Prevent indexes and reads occurring at once
2426
+ static usage = Command2.Usage({
2427
+ category: `Commands`,
2428
+ description: `Builds Tina and starts the dev server`,
2429
+ examples: [
2430
+ [`A basic example`, `$0 dev`],
2431
+ [`A second example`, `$0 dev --rootPath`]
2432
+ ]
2433
+ });
2348
2434
  async catch(error) {
2349
2435
  logger.error("Error occured during tinacms dev");
2350
2436
  console.error(error);
@@ -2359,7 +2445,6 @@ var DevCommand = class extends BaseCommand {
2359
2445
  }
2360
2446
  }
2361
2447
  async execute() {
2362
- var _a, _b, _c, _d, _e, _f;
2363
2448
  const configManager = new ConfigManager({
2364
2449
  rootPath: this.rootPath,
2365
2450
  legacyNoSDK: this.noSDK
@@ -2382,7 +2467,7 @@ var DevCommand = class extends BaseCommand {
2382
2467
  } else {
2383
2468
  database.clearCache();
2384
2469
  }
2385
- const { tinaSchema: tinaSchema2, graphQLSchema: graphQLSchema2, lookup, queryDoc, fragDoc } = await (0, import_graphql10.buildSchema)(configManager.config);
2470
+ const { tinaSchema: tinaSchema2, graphQLSchema: graphQLSchema2, lookup, queryDoc, fragDoc } = await buildSchema(configManager.config);
2386
2471
  const codegen2 = new Codegen({
2387
2472
  isLocal: true,
2388
2473
  configManager,
@@ -2396,29 +2481,32 @@ var DevCommand = class extends BaseCommand {
2396
2481
  });
2397
2482
  const apiURL2 = await codegen2.execute();
2398
2483
  if (!configManager.isUsingLegacyFolder) {
2399
- delete require.cache[configManager.generatedSchemaJSONPath];
2400
- delete require.cache[configManager.generatedLookupJSONPath];
2401
- delete require.cache[configManager.generatedGraphQLJSONPath];
2402
- const schemaObject = require(configManager.generatedSchemaJSONPath);
2403
- const lookupObject = require(configManager.generatedLookupJSONPath);
2404
- const graphqlSchemaObject = require(configManager.generatedGraphQLJSONPath);
2484
+ const schemaObject = await fs7.readJSON(
2485
+ configManager.generatedSchemaJSONPath
2486
+ );
2487
+ const lookupObject = await fs7.readJSON(
2488
+ configManager.generatedLookupJSONPath
2489
+ );
2490
+ const graphqlSchemaObject = await fs7.readJSON(
2491
+ configManager.generatedGraphQLJSONPath
2492
+ );
2405
2493
  const tinaLockFilename = "tina-lock.json";
2406
2494
  const tinaLockContent = JSON.stringify({
2407
2495
  schema: schemaObject,
2408
2496
  lookup: lookupObject,
2409
2497
  graphql: graphqlSchemaObject
2410
2498
  });
2411
- import_fs_extra6.default.writeFileSync(
2412
- import_path5.default.join(configManager.tinaFolderPath, tinaLockFilename),
2499
+ fs7.writeFileSync(
2500
+ path8.join(configManager.tinaFolderPath, tinaLockFilename),
2413
2501
  tinaLockContent
2414
2502
  );
2415
2503
  if (configManager.hasSeparateContentRoot()) {
2416
2504
  const rootPath = await configManager.getTinaFolderPath(
2417
2505
  configManager.contentRootPath
2418
2506
  );
2419
- const filePath = import_path5.default.join(rootPath, tinaLockFilename);
2420
- await import_fs_extra6.default.ensureFile(filePath);
2421
- await import_fs_extra6.default.outputFile(filePath, tinaLockContent);
2507
+ const filePath = path8.join(rootPath, tinaLockFilename);
2508
+ await fs7.ensureFile(filePath);
2509
+ await fs7.outputFile(filePath, tinaLockContent);
2422
2510
  }
2423
2511
  }
2424
2512
  await this.indexContentWithSpinner({
@@ -2461,25 +2549,25 @@ ${dangerText(e.message)}
2461
2549
  const { apiURL, graphQLSchema, tinaSchema } = await setup({
2462
2550
  firstTime: true
2463
2551
  });
2464
- await import_fs_extra6.default.outputFile(configManager.outputHTMLFilePath, devHTML(this.port));
2465
- await import_fs_extra6.default.outputFile(
2552
+ await fs7.outputFile(configManager.outputHTMLFilePath, devHTML(this.port));
2553
+ await fs7.outputFile(
2466
2554
  configManager.outputGitignorePath,
2467
2555
  "index.html\nassets/"
2468
2556
  );
2469
- 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
2557
+ const searchIndexClient = new LocalSearchIndexClient({
2558
+ stopwordLanguages: configManager.config.search?.tina?.stopwordLanguages,
2559
+ tokenSplitRegex: configManager.config.search?.tina?.tokenSplitRegex
2472
2560
  });
2473
2561
  await searchIndexClient.onStartIndexing();
2474
- const searchIndexer = new import_search.SearchIndexer({
2475
- batchSize: ((_e = configManager.config.search) == null ? void 0 : _e.indexBatchSize) || 100,
2476
- bridge: new import_graphql10.FilesystemBridge(
2562
+ const searchIndexer = new SearchIndexer({
2563
+ batchSize: configManager.config.search?.indexBatchSize || 100,
2564
+ bridge: new FilesystemBridge2(
2477
2565
  configManager.rootPath,
2478
2566
  configManager.contentRootPath
2479
2567
  ),
2480
2568
  schema: tinaSchema,
2481
2569
  client: searchIndexClient,
2482
- textIndexLength: ((_f = configManager.config.search) == null ? void 0 : _f.maxSearchIndexFieldLength) || 100
2570
+ textIndexLength: configManager.config.search?.maxSearchIndexFieldLength || 100
2483
2571
  });
2484
2572
  if (configManager.config.search) {
2485
2573
  await spin({
@@ -2514,7 +2602,7 @@ ${dangerText(e.message)}
2514
2602
  );
2515
2603
  await server.listen(Number(this.port));
2516
2604
  if (!this.noWatch) {
2517
- import_chokidar.default.watch(configManager.watchList).on("change", async () => {
2605
+ chokidar.watch(configManager.watchList).on("change", async () => {
2518
2606
  await dbLock(async () => {
2519
2607
  logger.info(`Tina config change detected, rebuilding`);
2520
2608
  await setup({ firstTime: false });
@@ -2576,11 +2664,11 @@ ${dangerText(e.message)}
2576
2664
  // subItems: [
2577
2665
  // {
2578
2666
  // key: 'Custom queries',
2579
- // value: 'https://tina.io/querying',
2667
+ // value: 'https://tina.io/docs/r/content-api-overview',
2580
2668
  // },
2581
2669
  // {
2582
2670
  // key: 'Visual editing',
2583
- // value: 'https://tina.io/visual-editing',
2671
+ // value: 'https://tina.io/docs/r/visual-editing-setup',
2584
2672
  // },
2585
2673
  // ],
2586
2674
  // },
@@ -2591,14 +2679,14 @@ ${dangerText(e.message)}
2591
2679
  watchContentFiles(configManager, database, databaseLock, searchIndexer) {
2592
2680
  const collectionContentFiles = [];
2593
2681
  configManager.config.schema.collections.forEach((collection) => {
2594
- const collectionGlob = `${import_path5.default.join(
2682
+ const collectionGlob = `${path8.join(
2595
2683
  configManager.contentRootPath,
2596
2684
  collection.path
2597
2685
  )}/**/*.${collection.format || "md"}`;
2598
2686
  collectionContentFiles.push(collectionGlob);
2599
2687
  });
2600
2688
  let ready = false;
2601
- import_chokidar.default.watch(collectionContentFiles).on("ready", () => {
2689
+ chokidar.watch(collectionContentFiles).on("ready", () => {
2602
2690
  ready = true;
2603
2691
  }).on("add", async (addedFile) => {
2604
2692
  if (!ready) {
@@ -2635,38 +2723,35 @@ ${dangerText(e.message)}
2635
2723
  await callback();
2636
2724
  });
2637
2725
  };
2638
- import_chokidar.default.watch(configManager.userQueriesAndFragmentsGlob).on("add", executeCallback).on("change", executeCallback).on("unlink", executeCallback);
2726
+ chokidar.watch(configManager.userQueriesAndFragmentsGlob).on("add", executeCallback).on("change", executeCallback).on("unlink", executeCallback);
2639
2727
  }
2640
2728
  };
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
2729
 
2652
2730
  // src/next/commands/build-command/index.ts
2653
- var import_crypto = __toESM(require("crypto"));
2654
- var import_path6 = __toESM(require("path"));
2655
- var import_core3 = require("@graphql-inspector/core");
2656
- var import_graphql11 = require("@tinacms/graphql");
2657
- var import_schema_tools2 = require("@tinacms/schema-tools");
2658
- var import_search2 = require("@tinacms/search");
2659
- var import_clipanion3 = require("clipanion");
2660
- var import_fs_extra7 = __toESM(require("fs-extra"));
2661
- var import_graphql12 = require("graphql");
2662
- var import_progress2 = __toESM(require("progress"));
2731
+ import crypto from "crypto";
2732
+ import path9 from "path";
2733
+ import { diff } from "@graphql-inspector/core";
2734
+ import { FilesystemBridge as FilesystemBridge3, buildSchema as buildSchema2 } from "@tinacms/graphql";
2735
+ import { parseURL as parseURL2 } from "@tinacms/schema-tools";
2736
+ import {
2737
+ SearchIndexer as SearchIndexer2,
2738
+ TinaCMSSearchIndexClient
2739
+ } from "@tinacms/search";
2740
+ import { Command as Command3, Option as Option3 } from "clipanion";
2741
+ import fs8 from "fs-extra";
2742
+ import {
2743
+ buildASTSchema as buildASTSchema2,
2744
+ buildClientSchema,
2745
+ getIntrospectionQuery
2746
+ } from "graphql";
2747
+ import Progress2 from "progress";
2663
2748
 
2664
2749
  // src/utils/index.ts
2665
- var import_core2 = require("@graphql-inspector/core");
2750
+ import { ChangeType } from "@graphql-inspector/core";
2666
2751
  var getFaqLink = (type) => {
2667
2752
  switch (type) {
2668
- 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";
2753
+ case ChangeType.FieldRemoved: {
2754
+ return "https://tina.io/docs/r/FAQ/#2-how-do-i-resolve-the-local-graphql-schema-doesnt-match-the-remote-graphql-schema-error";
2670
2755
  }
2671
2756
  default:
2672
2757
  return null;
@@ -2687,7 +2772,7 @@ async function sleepAndCallFunc({
2687
2772
  }
2688
2773
 
2689
2774
  // src/next/commands/build-command/server.ts
2690
- var import_vite5 = require("vite");
2775
+ import { build as build2 } from "vite";
2691
2776
  var buildProductionSpa = async (configManager, database, apiURL) => {
2692
2777
  const publicEnv = {};
2693
2778
  Object.keys(process.env).forEach((key) => {
@@ -2721,12 +2806,12 @@ var buildProductionSpa = async (configManager, database, apiURL) => {
2721
2806
  }
2722
2807
  }
2723
2808
  });
2724
- return (0, import_vite5.build)(config2);
2809
+ return build2(config2);
2725
2810
  };
2726
2811
 
2727
2812
  // src/next/commands/build-command/waitForDB.ts
2728
- var import_schema_tools = require("@tinacms/schema-tools");
2729
- var import_progress = __toESM(require("progress"));
2813
+ import { parseURL } from "@tinacms/schema-tools";
2814
+ import Progress from "progress";
2730
2815
  var POLLING_INTERVAL = 5e3;
2731
2816
  var STATUS_INPROGRESS = "inprogress";
2732
2817
  var STATUS_COMPLETE = "complete";
@@ -2739,14 +2824,14 @@ var IndexFailedError = class extends Error {
2739
2824
  };
2740
2825
  var waitForDB = async (config2, apiUrl, previewName, verbose) => {
2741
2826
  const token = config2.token;
2742
- const { clientId, branch, isLocalClient, host } = (0, import_schema_tools.parseURL)(apiUrl);
2827
+ const { clientId, branch, isLocalClient, host } = parseURL(apiUrl);
2743
2828
  if (isLocalClient || !host || !clientId || !branch) {
2744
2829
  if (verbose) {
2745
2830
  logger.info(logText("Not using TinaCloud, skipping DB check"));
2746
2831
  }
2747
2832
  return;
2748
2833
  }
2749
- const bar2 = new import_progress.default(
2834
+ const bar2 = new Progress(
2750
2835
  "Checking indexing process in TinaCloud... :prog",
2751
2836
  1
2752
2837
  );
@@ -2809,48 +2894,49 @@ var waitForDB = async (config2, apiUrl, previewName, verbose) => {
2809
2894
 
2810
2895
  // src/next/commands/build-command/index.ts
2811
2896
  var BuildCommand = class extends BaseCommand {
2812
- constructor() {
2813
- super(...arguments);
2814
- this.localOption = import_clipanion3.Option.Boolean("--local", {
2815
- description: "Starts local Graphql server and builds the local client instead of production client"
2816
- });
2817
- this.skipIndexing = import_clipanion3.Option.Boolean("--skip-indexing", false, {
2818
- description: "Skips indexing the content. This can be used for building the site without indexing the content (defaults to false)"
2819
- });
2820
- this.partialReindex = import_clipanion3.Option.Boolean("--partial-reindex", false, {
2821
- description: "Re-indexes only the content that has changed since the last build (defaults to false). Not currently supported for separate content repos."
2822
- });
2823
- this.tinaGraphQLVersion = import_clipanion3.Option.String("--tina-graphql-version", {
2824
- description: "Specify the version of @tinacms/graphql to use (defaults to latest)"
2825
- });
2826
- /**
2827
- * This option allows the user to skip the TinaCloud 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 TinaCloud
2828
- */
2829
- this.skipCloudChecks = import_clipanion3.Option.Boolean("--skip-cloud-checks", false, {
2830
- description: "Skips checking the provided cloud config."
2831
- });
2832
- this.skipSearchIndex = import_clipanion3.Option.Boolean("--skip-search-index", false, {
2833
- description: "Skip indexing the site for search"
2834
- });
2835
- this.upstreamBranch = import_clipanion3.Option.String("--upstream-branch", {
2836
- description: "Optional upstream branch with the schema. If not specified, default will be used."
2837
- });
2838
- this.previewBaseBranch = import_clipanion3.Option.String("--preview-base-branch", {
2839
- description: "The base branch for the preview"
2840
- });
2841
- this.previewName = import_clipanion3.Option.String("--preview-name", {
2842
- description: "The name of the preview branch"
2843
- });
2844
- this.noClientBuildCache = import_clipanion3.Option.Boolean("--no-client-build-cache", false, {
2845
- description: "Disables the client build cache"
2846
- });
2847
- }
2897
+ static paths = [["build"]];
2898
+ localOption = Option3.Boolean("--local", {
2899
+ description: "Starts local Graphql server and builds the local client instead of production client"
2900
+ });
2901
+ skipIndexing = Option3.Boolean("--skip-indexing", false, {
2902
+ description: "Skips indexing the content. This can be used for building the site without indexing the content (defaults to false)"
2903
+ });
2904
+ partialReindex = Option3.Boolean("--partial-reindex", false, {
2905
+ description: "Re-indexes only the content that has changed since the last build (defaults to false). Not currently supported for separate content repos."
2906
+ });
2907
+ tinaGraphQLVersion = Option3.String("--tina-graphql-version", {
2908
+ description: "Specify the version of @tinacms/graphql to use (defaults to latest)"
2909
+ });
2910
+ /**
2911
+ * This option allows the user to skip the TinaCloud 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 TinaCloud
2912
+ */
2913
+ skipCloudChecks = Option3.Boolean("--skip-cloud-checks", false, {
2914
+ description: "Skips checking the provided cloud config."
2915
+ });
2916
+ skipSearchIndex = Option3.Boolean("--skip-search-index", false, {
2917
+ description: "Skip indexing the site for search"
2918
+ });
2919
+ upstreamBranch = Option3.String("--upstream-branch", {
2920
+ description: "Optional upstream branch with the schema. If not specified, default will be used."
2921
+ });
2922
+ previewBaseBranch = Option3.String("--preview-base-branch", {
2923
+ description: "The base branch for the preview"
2924
+ });
2925
+ previewName = Option3.String("--preview-name", {
2926
+ description: "The name of the preview branch"
2927
+ });
2928
+ noClientBuildCache = Option3.Boolean("--no-client-build-cache", false, {
2929
+ description: "Disables the client build cache"
2930
+ });
2931
+ static usage = Command3.Usage({
2932
+ category: `Commands`,
2933
+ description: `Build the CMS and autogenerated modules for usage with TinaCloud`
2934
+ });
2848
2935
  async catch(error) {
2849
2936
  console.error(error);
2850
2937
  process.exit(1);
2851
2938
  }
2852
2939
  async execute() {
2853
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
2854
2940
  logger.info("Starting Tina build");
2855
2941
  this.logDeprecationWarnings();
2856
2942
  const configManager = new ConfigManager({
@@ -2890,7 +2976,7 @@ ${dangerText(e.message)}`);
2890
2976
  configManager,
2891
2977
  Number(this.datalayerPort)
2892
2978
  );
2893
- const { queryDoc, fragDoc, graphQLSchema, tinaSchema, lookup } = await (0, import_graphql11.buildSchema)(configManager.config);
2979
+ const { queryDoc, fragDoc, graphQLSchema, tinaSchema, lookup } = await buildSchema2(configManager.config);
2894
2980
  const codegen2 = new Codegen({
2895
2981
  configManager,
2896
2982
  port: this.localOption ? Number(this.port) : void 0,
@@ -2939,56 +3025,74 @@ ${dangerText(e.message)}
2939
3025
  }
2940
3026
  const skipCloudChecks = this.skipCloudChecks || configManager.hasSelfHostedConfig();
2941
3027
  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
- )}`
3028
+ try {
3029
+ const clientInfo = await this.checkClientInfo(
3030
+ configManager,
3031
+ codegen2.productionUrl,
3032
+ this.previewBaseBranch
2952
3033
  );
3034
+ if (clientInfo.detectedBotBranch) {
3035
+ logger.warn(
3036
+ `${warnText(
3037
+ `WARN: Detected bot branch. Using schema/content from default branch '${clientInfo.defaultBranch}' instead of '${configManager.config.branch}'.`
3038
+ )}`
3039
+ );
3040
+ }
3041
+ if (!clientInfo.hasUpstream && this.upstreamBranch) {
3042
+ logger.warn(
3043
+ `${dangerText(
3044
+ `WARN: Upstream branch '${this.upstreamBranch}' specified but no upstream project was found.`
3045
+ )}`
3046
+ );
3047
+ }
3048
+ if (clientInfo.hasUpstream || this.previewBaseBranch && this.previewName) {
3049
+ await this.syncProject(configManager, codegen2.productionUrl, {
3050
+ upstreamBranch: this.upstreamBranch,
3051
+ previewBaseBranch: this.previewBaseBranch,
3052
+ previewName: this.previewName
3053
+ });
3054
+ }
3055
+ await waitForDB(
3056
+ configManager.config,
3057
+ codegen2.productionUrl,
3058
+ this.previewName,
3059
+ false
3060
+ );
3061
+ await this.checkGraphqlSchema(
3062
+ configManager,
3063
+ database,
3064
+ codegen2.productionUrl,
3065
+ clientInfo.timestamp
3066
+ );
3067
+ await this.checkTinaSchema(
3068
+ configManager,
3069
+ database,
3070
+ codegen2.productionUrl,
3071
+ this.previewName,
3072
+ this.verbose,
3073
+ clientInfo.timestamp
3074
+ );
3075
+ } catch (e) {
3076
+ logger.error(`
3077
+
3078
+ ${dangerText(e.message)}
3079
+ `);
3080
+ if (this.verbose) {
3081
+ console.error(e);
3082
+ }
3083
+ process.exit(1);
2953
3084
  }
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
3085
  }
2982
3086
  await buildProductionSpa(configManager, database, codegen2.productionUrl);
2983
- await import_fs_extra7.default.outputFile(
3087
+ await fs8.outputFile(
2984
3088
  configManager.outputGitignorePath,
2985
3089
  "index.html\nassets/"
2986
3090
  );
2987
3091
  if (configManager.config.search && !this.skipSearchIndex && !this.localOption) {
2988
3092
  let client;
2989
- const hasTinaSearch = Boolean((_b = (_a = configManager.config) == null ? void 0 : _a.search) == null ? void 0 : _b.tina);
3093
+ const hasTinaSearch = Boolean(configManager.config?.search?.tina);
2990
3094
  if (hasTinaSearch) {
2991
- if (!((_c = configManager.config) == null ? void 0 : _c.branch)) {
3095
+ if (!configManager.config?.branch) {
2992
3096
  logger.error(
2993
3097
  `${dangerText(
2994
3098
  `ERROR: Branch not configured in tina search configuration.`
@@ -2998,11 +3102,11 @@ ${dangerText(e.message)}
2998
3102
  "Branch not configured in tina search configuration."
2999
3103
  );
3000
3104
  }
3001
- if (!((_d = configManager.config) == null ? void 0 : _d.clientId)) {
3105
+ if (!configManager.config?.clientId) {
3002
3106
  logger.error(`${dangerText(`ERROR: clientId not configured.`)}`);
3003
3107
  throw new Error("clientId not configured.");
3004
3108
  }
3005
- if (!((_g = (_f = (_e = configManager.config) == null ? void 0 : _e.search) == null ? void 0 : _f.tina) == null ? void 0 : _g.indexerToken)) {
3109
+ if (!configManager.config?.search?.tina?.indexerToken) {
3006
3110
  logger.error(
3007
3111
  `${dangerText(
3008
3112
  `ERROR: indexerToken not configured in tina search configuration.`
@@ -3012,18 +3116,18 @@ ${dangerText(e.message)}
3012
3116
  "indexerToken not configured in tina search configuration."
3013
3117
  );
3014
3118
  }
3015
- 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
3119
+ client = new TinaCMSSearchIndexClient({
3120
+ apiUrl: `${configManager.config.tinaioConfig?.contentApiUrlOverride || "https://content.tinajs.io"}/searchIndex/${configManager.config?.clientId}`,
3121
+ branch: configManager.config?.branch,
3122
+ indexerToken: configManager.config?.search?.tina?.indexerToken,
3123
+ stopwordLanguages: configManager.config?.search?.tina?.stopwordLanguages
3020
3124
  });
3021
3125
  } else {
3022
- client = (_r = (_q = configManager.config) == null ? void 0 : _q.search) == null ? void 0 : _r.searchClient;
3126
+ client = configManager.config?.search?.searchClient;
3023
3127
  }
3024
- const searchIndexer = new import_search2.SearchIndexer({
3025
- batchSize: ((_s = configManager.config.search) == null ? void 0 : _s.indexBatchSize) || 100,
3026
- bridge: new import_graphql11.FilesystemBridge(
3128
+ const searchIndexer = new SearchIndexer2({
3129
+ batchSize: configManager.config.search?.indexBatchSize || 100,
3130
+ bridge: new FilesystemBridge3(
3027
3131
  configManager.rootPath,
3028
3132
  configManager.contentRootPath
3029
3133
  ),
@@ -3090,86 +3194,88 @@ ${dangerText(e.message)}
3090
3194
  }
3091
3195
  }
3092
3196
  async checkClientInfo(configManager, apiURL, previewBaseBranch) {
3197
+ const MAX_RETRIES = 5;
3093
3198
  const { config: config2 } = configManager;
3094
3199
  const token = config2.token;
3095
- const { clientId, branch, host } = (0, import_schema_tools2.parseURL)(apiURL);
3096
- const url = `https://${host}/db/${clientId}/status/${previewBaseBranch || branch}`;
3097
- 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;
3200
+ const { clientId, branch, host } = parseURL2(apiURL);
3201
+ const bar2 = new Progress2("Checking clientId and token. :prog", 1);
3202
+ const getBranchInfo = async () => {
3203
+ const url = `https://${host}/db/${clientId}/status/${previewBaseBranch || branch}`;
3204
+ const branchInfo2 = {
3205
+ status: "unknown",
3206
+ branchKnown: false,
3207
+ hasUpstream: false,
3208
+ timestamp: 0,
3209
+ detectedBotBranch: false,
3210
+ defaultBranch: void 0
3211
+ };
3212
+ try {
3213
+ const res = await request({
3214
+ token,
3215
+ url
3216
+ });
3217
+ branchInfo2.status = res.status;
3218
+ branchInfo2.branchKnown = res.status !== "unknown";
3219
+ branchInfo2.timestamp = res.timestamp || 0;
3220
+ branchInfo2.hasUpstream = res.hasUpstream;
3221
+ branchInfo2.detectedBotBranch = res.json.detectedBotBranch;
3222
+ branchInfo2.defaultBranch = res.json.defaultBranch;
3223
+ } catch (e) {
3224
+ summary({
3225
+ heading: "Error when checking client information",
3226
+ items: [
3227
+ {
3228
+ emoji: "\u274C",
3229
+ heading: "You provided",
3230
+ subItems: [
3231
+ {
3232
+ key: "clientId",
3233
+ value: config2.clientId
3234
+ },
3235
+ {
3236
+ key: "branch",
3237
+ value: config2.branch
3238
+ },
3239
+ {
3240
+ key: "token",
3241
+ value: config2.token
3242
+ }
3243
+ ]
3244
+ }
3245
+ ]
3246
+ });
3247
+ throw e;
3115
3248
  }
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) {
3249
+ return branchInfo2;
3250
+ };
3251
+ const branchInfo = await getBranchInfo();
3252
+ bar2.tick({
3253
+ prog: "\u2705"
3254
+ });
3255
+ const branchBar = new Progress2(
3256
+ `Checking branch '${config2.branch}' is on TinaCloud. :prog`,
3257
+ 1
3258
+ );
3259
+ if (branchInfo.branchKnown) {
3144
3260
  branchBar.tick({
3145
3261
  prog: "\u2705"
3146
3262
  });
3147
- return {
3148
- hasUpstream,
3149
- timestamp
3150
- };
3263
+ return branchInfo;
3151
3264
  }
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
- });
3265
+ for (let i = 1; i <= MAX_RETRIES; i++) {
3266
+ await timeout(5e3);
3267
+ const branchInfo2 = await getBranchInfo();
3268
+ if (this.verbose) {
3269
+ logger.info(
3270
+ `Branch status: ${branchInfo2.status}. Attempt: ${i}. Trying again in 5 seconds.`
3271
+ );
3272
+ }
3273
+ if (branchInfo2.branchKnown) {
3274
+ branchBar.tick({
3275
+ prog: "\u2705"
3276
+ });
3277
+ return branchInfo2;
3278
+ }
3173
3279
  }
3174
3280
  branchBar.tick({
3175
3281
  prog: "\u274C"
@@ -3177,7 +3283,7 @@ ${dangerText(e.message)}
3177
3283
  logger.error(
3178
3284
  `${dangerText(
3179
3285
  `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(
3286
+ )} 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
3287
  `https://app.tina.io/projects/${clientId}/configuration`
3182
3288
  )}`
3183
3289
  );
@@ -3186,7 +3292,7 @@ ${dangerText(e.message)}
3186
3292
  async syncProject(configManager, apiURL, options) {
3187
3293
  const { config: config2 } = configManager;
3188
3294
  const token = config2.token;
3189
- const { clientId, branch, host } = (0, import_schema_tools2.parseURL)(apiURL);
3295
+ const { clientId, branch, host } = parseURL2(apiURL);
3190
3296
  const { previewName, previewBaseBranch, upstreamBranch } = options || {};
3191
3297
  let url = `https://${host}/db/${clientId}/reset/${branch}?refreshSchema=true&skipIfSchemaCurrent=true`;
3192
3298
  if (upstreamBranch && previewBaseBranch && previewName) {
@@ -3196,7 +3302,7 @@ ${dangerText(e.message)}
3196
3302
  } else if (upstreamBranch && !previewBaseBranch && !previewName) {
3197
3303
  url = `https://${host}/db/${clientId}/reset/${branch}?refreshSchema=true&skipIfSchemaCurrent=true&upstreamBranch=${upstreamBranch}`;
3198
3304
  }
3199
- const bar2 = new import_progress2.default("Syncing Project. :prog", 1);
3305
+ const bar2 = new Progress2("Syncing Project. :prog", 1);
3200
3306
  try {
3201
3307
  const res = await request({
3202
3308
  token,
@@ -3237,7 +3343,7 @@ ${dangerText(e.message)}
3237
3343
  }
3238
3344
  }
3239
3345
  async checkGraphqlSchema(configManager, database, apiURL, timestamp) {
3240
- const bar2 = new import_progress2.default(
3346
+ const bar2 = new Progress2(
3241
3347
  "Checking local GraphQL Schema matches server. :prog",
3242
3348
  1
3243
3349
  );
@@ -3252,18 +3358,18 @@ ${dangerText(e.message)}
3252
3358
  prog: "\u274C"
3253
3359
  });
3254
3360
  let errorMessage = `The remote GraphQL schema does not exist. Check indexing for this branch.`;
3255
- if (config2 == null ? void 0 : config2.branch) {
3361
+ if (config2?.branch) {
3256
3362
  errorMessage += `
3257
3363
 
3258
3364
  Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3259
3365
  }
3260
3366
  throw new Error(errorMessage);
3261
3367
  }
3262
- const remoteGqlSchema = (0, import_graphql12.buildClientSchema)(remoteSchema);
3368
+ const remoteGqlSchema = buildClientSchema(remoteSchema);
3263
3369
  const localSchemaDocument = await database.getGraphQLSchemaFromBridge();
3264
- const localGraphqlSchema = (0, import_graphql12.buildASTSchema)(localSchemaDocument);
3370
+ const localGraphqlSchema = buildASTSchema2(localSchemaDocument);
3265
3371
  try {
3266
- const diffResult = await (0, import_core3.diff)(remoteGqlSchema, localGraphqlSchema);
3372
+ const diffResult = await diff(remoteGqlSchema, localGraphqlSchema);
3267
3373
  if (diffResult.length === 0) {
3268
3374
  bar2.tick({
3269
3375
  prog: "\u2705"
@@ -3284,7 +3390,7 @@ Check out '${faqLink}' for possible solutions.`}`;
3284
3390
  Additional info:
3285
3391
 
3286
3392
  `;
3287
- if (config2 == null ? void 0 : config2.branch) {
3393
+ if (config2?.branch) {
3288
3394
  errorMessage += ` Branch: ${config2.branch}, Client ID: ${config2.clientId}
3289
3395
  `;
3290
3396
  }
@@ -3311,13 +3417,13 @@ Additional info:
3311
3417
  }
3312
3418
  }
3313
3419
  async checkTinaSchema(configManager, database, apiURL, previewName, verbose, timestamp) {
3314
- const bar2 = new import_progress2.default(
3420
+ const bar2 = new Progress2(
3315
3421
  "Checking local Tina Schema matches server. :prog",
3316
3422
  1
3317
3423
  );
3318
3424
  const { config: config2 } = configManager;
3319
3425
  const token = config2.token;
3320
- const { clientId, branch, isLocalClient, host } = (0, import_schema_tools2.parseURL)(apiURL);
3426
+ const { clientId, branch, isLocalClient, host } = parseURL2(apiURL);
3321
3427
  if (isLocalClient || !host || !clientId || !branch) {
3322
3428
  if (verbose) {
3323
3429
  logger.info(logText("Not using TinaCloud, skipping Tina Schema check"));
@@ -3333,7 +3439,7 @@ Additional info:
3333
3439
  prog: "\u274C"
3334
3440
  });
3335
3441
  let errorMessage = `The remote Tina schema does not exist. Check indexing for this branch.`;
3336
- if (config2 == null ? void 0 : config2.branch) {
3442
+ if (config2?.branch) {
3337
3443
  errorMessage += `
3338
3444
 
3339
3445
  Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
@@ -3345,11 +3451,11 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3345
3451
  }
3346
3452
  const localTinaSchema = JSON.parse(
3347
3453
  await database.bridge.get(
3348
- import_path6.default.join(database.tinaDirectory, "__generated__", "_schema.json")
3454
+ path9.join(database.tinaDirectory, "__generated__", "_schema.json")
3349
3455
  )
3350
3456
  );
3351
3457
  localTinaSchema.version = void 0;
3352
- const localTinaSchemaSha = import_crypto.default.createHash("sha256").update(JSON.stringify(localTinaSchema)).digest("hex");
3458
+ const localTinaSchemaSha = crypto.createHash("sha256").update(JSON.stringify(localTinaSchema)).digest("hex");
3353
3459
  if (localTinaSchemaSha === remoteTinaSchemaSha) {
3354
3460
  bar2.tick({
3355
3461
  prog: "\u2705"
@@ -3364,7 +3470,7 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3364
3470
  Additional info:
3365
3471
 
3366
3472
  `;
3367
- if (config2 == null ? void 0 : config2.branch) {
3473
+ if (config2?.branch) {
3368
3474
  errorMessage += ` Branch: ${config2.branch}, Client ID: ${config2.clientId}
3369
3475
  `;
3370
3476
  }
@@ -3376,18 +3482,13 @@ Additional info:
3376
3482
  }
3377
3483
  }
3378
3484
  };
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
3485
  async function request(args) {
3385
3486
  const headers = new Headers();
3386
3487
  if (args.token) {
3387
3488
  headers.append("X-API-KEY", args.token);
3388
3489
  }
3389
3490
  headers.append("Content-Type", "application/json");
3390
- const url = args == null ? void 0 : args.url;
3491
+ const url = args?.url;
3391
3492
  const res = await fetch(url, {
3392
3493
  method: args.method || "GET",
3393
3494
  headers,
@@ -3405,21 +3506,22 @@ async function request(args) {
3405
3506
  Message from server: ${json.message}`;
3406
3507
  }
3407
3508
  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/`
3509
+ `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
3510
  );
3410
3511
  }
3411
3512
  if (json.errors) {
3412
3513
  throw new Error(
3413
- `Unable to fetch, please see our FAQ for more information: https://tina.io/docs/errors/faq/
3514
+ `Unable to fetch, please see our FAQ for more information: https://tina.io/docs/r/FAQ/
3414
3515
 
3415
3516
  Errors:
3416
3517
  ${json.errors.map((error) => error.message).join("\n")}`
3417
3518
  );
3418
3519
  }
3419
3520
  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
3521
+ status: json?.status,
3522
+ timestamp: json?.timestamp,
3523
+ hasUpstream: json?.hasUpstream || false,
3524
+ json
3423
3525
  };
3424
3526
  }
3425
3527
  var fetchRemoteGraphqlSchema = async ({
@@ -3431,7 +3533,7 @@ var fetchRemoteGraphqlSchema = async ({
3431
3533
  headers.append("X-API-KEY", token);
3432
3534
  }
3433
3535
  const body = JSON.stringify({
3434
- query: (0, import_graphql12.getIntrospectionQuery)(),
3536
+ query: getIntrospectionQuery(),
3435
3537
  variables: {}
3436
3538
  });
3437
3539
  headers.append("Content-Type", "application/json");
@@ -3442,7 +3544,7 @@ var fetchRemoteGraphqlSchema = async ({
3442
3544
  });
3443
3545
  const data = await res.json();
3444
3546
  return {
3445
- remoteSchema: data == null ? void 0 : data.data,
3547
+ remoteSchema: data?.data,
3446
3548
  remoteRuntimeVersion: res.headers.get("tinacms-grapqhl-version"),
3447
3549
  remoteProjectVersion: res.headers.get("tinacms-graphql-project-version")
3448
3550
  };
@@ -3464,14 +3566,14 @@ var fetchSchemaSha = async ({
3464
3566
  };
3465
3567
 
3466
3568
  // src/next/commands/audit-command/index.ts
3467
- var import_clipanion4 = require("clipanion");
3468
- var import_graphql14 = require("@tinacms/graphql");
3569
+ import { Command as Command4, Option as Option4 } from "clipanion";
3570
+ import { buildSchema as buildSchema3 } from "@tinacms/graphql";
3469
3571
 
3470
3572
  // src/next/commands/audit-command/audit.ts
3471
- var import_prompts = __toESM(require("prompts"));
3472
- var import_metrics = require("@tinacms/metrics");
3473
- var import_graphql13 = require("@tinacms/graphql");
3474
- var import_chalk5 = __toESM(require("chalk"));
3573
+ import prompts from "prompts";
3574
+ import { Telemetry } from "@tinacms/metrics";
3575
+ import { resolve } from "@tinacms/graphql";
3576
+ import chalk5 from "chalk";
3475
3577
  var audit = async ({
3476
3578
  database,
3477
3579
  clean,
@@ -3479,7 +3581,7 @@ var audit = async ({
3479
3581
  noTelemetry,
3480
3582
  verbose
3481
3583
  }) => {
3482
- const telemetry = new import_metrics.Telemetry({ disabled: noTelemetry });
3584
+ const telemetry = new Telemetry({ disabled: noTelemetry });
3483
3585
  await telemetry.submitRecord({
3484
3586
  event: {
3485
3587
  name: "tinacms:cli:audit:invoke",
@@ -3489,25 +3591,25 @@ var audit = async ({
3489
3591
  });
3490
3592
  if (clean) {
3491
3593
  logger.info(
3492
- `You are using the \`--clean\` option. This will modify your content as if a user is submitting a form. Before running this you should have a ${import_chalk5.default.bold(
3594
+ `You are using the \`--clean\` option. This will modify your content as if a user is submitting a form. Before running this you should have a ${chalk5.bold(
3493
3595
  "clean git tree"
3494
3596
  )} so unwanted changes can be undone.
3495
3597
 
3496
3598
  `
3497
3599
  );
3498
- const res = await (0, import_prompts.default)({
3600
+ const res = await prompts({
3499
3601
  name: "useClean",
3500
3602
  type: "confirm",
3501
3603
  message: `Do you want to continue?`
3502
3604
  });
3503
3605
  if (!res.useClean) {
3504
- logger.warn(import_chalk5.default.yellowBright("\u26A0\uFE0F Audit not complete"));
3606
+ logger.warn(chalk5.yellowBright("\u26A0\uFE0F Audit not complete"));
3505
3607
  process.exit(0);
3506
3608
  }
3507
3609
  }
3508
3610
  if (useDefaultValues && !clean) {
3509
3611
  logger.warn(
3510
- import_chalk5.default.yellowBright(
3612
+ chalk5.yellowBright(
3511
3613
  "WARNING: using the `--useDefaultValues` without the `--clean` flag has no effect. Please re-run audit and add the `--clean` flag"
3512
3614
  )
3513
3615
  );
@@ -3535,10 +3637,10 @@ var audit = async ({
3535
3637
  }
3536
3638
  if (error) {
3537
3639
  logger.error(
3538
- import_chalk5.default.redBright(`\u203C\uFE0F Audit ${import_chalk5.default.bold("failed")} with errors`)
3640
+ chalk5.redBright(`\u203C\uFE0F Audit ${chalk5.bold("failed")} with errors`)
3539
3641
  );
3540
3642
  } else {
3541
- logger.info(import_chalk5.default.greenBright("\u2705 Audit passed"));
3643
+ logger.info(chalk5.greenBright("\u2705 Audit passed"));
3542
3644
  }
3543
3645
  };
3544
3646
  var auditDocuments = async (args) => {
@@ -3555,7 +3657,7 @@ var auditDocuments = async (args) => {
3555
3657
  }
3556
3658
  }
3557
3659
  }`;
3558
- const docResult = await (0, import_graphql13.resolve)({
3660
+ const docResult = await resolve({
3559
3661
  database,
3560
3662
  query: documentQuery,
3561
3663
  variables: {},
@@ -3566,11 +3668,11 @@ var auditDocuments = async (args) => {
3566
3668
  if (docResult.errors) {
3567
3669
  error = true;
3568
3670
  docResult.errors.forEach((err) => {
3569
- logger.error(import_chalk5.default.red(err.message));
3671
+ logger.error(chalk5.red(err.message));
3570
3672
  if (err.originalError.originalError) {
3571
3673
  logger.error(
3572
3674
  // @ts-ignore FIXME: this doesn't seem right
3573
- import_chalk5.default.red(` ${err.originalError.originalError.message}`)
3675
+ chalk5.red(` ${err.originalError.originalError.message}`)
3574
3676
  );
3575
3677
  }
3576
3678
  });
@@ -3597,7 +3699,7 @@ var auditDocuments = async (args) => {
3597
3699
  params: $params
3598
3700
  ){__typename}
3599
3701
  }`;
3600
- const mutationRes = await (0, import_graphql13.resolve)({
3702
+ const mutationRes = await resolve({
3601
3703
  database,
3602
3704
  query: mutation,
3603
3705
  variables: {
@@ -3612,7 +3714,7 @@ var auditDocuments = async (args) => {
3612
3714
  if (mutationRes.errors) {
3613
3715
  mutationRes.errors.forEach((err) => {
3614
3716
  error = true;
3615
- logger.error(import_chalk5.default.red(err.message));
3717
+ logger.error(chalk5.red(err.message));
3616
3718
  });
3617
3719
  }
3618
3720
  }
@@ -3629,29 +3731,31 @@ function filterObject(obj) {
3629
3731
  }
3630
3732
 
3631
3733
  // src/next/commands/audit-command/index.ts
3632
- var import_graphql15 = require("@tinacms/graphql");
3633
- var AuditCommand = class extends import_clipanion4.Command {
3634
- constructor() {
3635
- super(...arguments);
3636
- this.rootPath = import_clipanion4.Option.String("--rootPath", {
3637
- description: "Specify the root directory to run the CLI from"
3638
- });
3639
- this.verbose = import_clipanion4.Option.Boolean("-v,--verbose", false, {
3640
- description: "increase verbosity of logged output"
3641
- });
3642
- this.clean = import_clipanion4.Option.Boolean("--clean", false, {
3643
- description: "Clean the output"
3644
- });
3645
- this.useDefaultValues = import_clipanion4.Option.Boolean("--useDefaultValues", false, {
3646
- description: "When cleaning the output, use defaults on the config"
3647
- });
3648
- this.noTelemetry = import_clipanion4.Option.Boolean("--noTelemetry", false, {
3649
- description: "Disable anonymous telemetry that is collected"
3650
- });
3651
- this.datalayerPort = import_clipanion4.Option.String("--datalayer-port", "9000", {
3652
- description: "Specify a port to run the datalayer server on. (default 9000)"
3653
- });
3654
- }
3734
+ import { AuditFileSystemBridge } from "@tinacms/graphql";
3735
+ var AuditCommand = class extends Command4 {
3736
+ static paths = [["audit"]];
3737
+ rootPath = Option4.String("--rootPath", {
3738
+ description: "Specify the root directory to run the CLI from"
3739
+ });
3740
+ verbose = Option4.Boolean("-v,--verbose", false, {
3741
+ description: "increase verbosity of logged output"
3742
+ });
3743
+ clean = Option4.Boolean("--clean", false, {
3744
+ description: "Clean the output"
3745
+ });
3746
+ useDefaultValues = Option4.Boolean("--useDefaultValues", false, {
3747
+ description: "When cleaning the output, use defaults on the config"
3748
+ });
3749
+ noTelemetry = Option4.Boolean("--noTelemetry", false, {
3750
+ description: "Disable anonymous telemetry that is collected"
3751
+ });
3752
+ datalayerPort = Option4.String("--datalayer-port", "9000", {
3753
+ description: "Specify a port to run the datalayer server on. (default 9000)"
3754
+ });
3755
+ static usage = Command4.Usage({
3756
+ category: `Commands`,
3757
+ description: `Audit config and content files`
3758
+ });
3655
3759
  async catch(error) {
3656
3760
  logger.error("Error occured during tinacms audit");
3657
3761
  if (this.verbose) {
@@ -3672,9 +3776,9 @@ var AuditCommand = class extends import_clipanion4.Command {
3672
3776
  const database = await createAndInitializeDatabase(
3673
3777
  configManager,
3674
3778
  Number(this.datalayerPort),
3675
- this.clean ? void 0 : new import_graphql15.AuditFileSystemBridge(configManager.rootPath)
3779
+ this.clean ? void 0 : new AuditFileSystemBridge(configManager.rootPath)
3676
3780
  );
3677
- const { tinaSchema, graphQLSchema, lookup } = await (0, import_graphql14.buildSchema)(
3781
+ const { tinaSchema, graphQLSchema, lookup } = await buildSchema3(
3678
3782
  configManager.config
3679
3783
  );
3680
3784
  const warnings = [];
@@ -3705,36 +3809,31 @@ var AuditCommand = class extends import_clipanion4.Command {
3705
3809
  process.exit();
3706
3810
  }
3707
3811
  };
3708
- AuditCommand.paths = [["audit"]];
3709
- AuditCommand.usage = import_clipanion4.Command.Usage({
3710
- category: `Commands`,
3711
- description: `Audit config and content files`
3712
- });
3713
3812
 
3714
3813
  // src/next/commands/init-command/index.ts
3715
- var import_clipanion6 = require("clipanion");
3814
+ import { Command as Command6, Option as Option6 } from "clipanion";
3716
3815
 
3717
3816
  // src/cmds/init/detectEnvironment.ts
3718
- var import_fs_extra8 = __toESM(require("fs-extra"));
3719
- var import_path7 = __toESM(require("path"));
3817
+ import fs9 from "fs-extra";
3818
+ import path10 from "path";
3720
3819
  var checkGitignoreForItem = async ({
3721
3820
  baseDir,
3722
3821
  line
3723
3822
  }) => {
3724
- const gitignoreContent = import_fs_extra8.default.readFileSync(import_path7.default.join(baseDir, ".gitignore")).toString();
3823
+ const gitignoreContent = fs9.readFileSync(path10.join(baseDir, ".gitignore")).toString();
3725
3824
  return gitignoreContent.split("\n").some((item) => item === line);
3726
3825
  };
3727
3826
  var makeGeneratedFile = async (name2, generatedFileType, parentPath, opts) => {
3728
3827
  const result = {
3729
- fullPathTS: import_path7.default.join(
3828
+ fullPathTS: path10.join(
3730
3829
  parentPath,
3731
- `${name2}.${(opts == null ? void 0 : opts.typescriptSuffix) || (opts == null ? void 0 : opts.extensionOverride) || "ts"}`
3830
+ `${name2}.${opts?.typescriptSuffix || opts?.extensionOverride || "ts"}`
3732
3831
  ),
3733
- fullPathJS: import_path7.default.join(
3832
+ fullPathJS: path10.join(
3734
3833
  parentPath,
3735
- `${name2}.${(opts == null ? void 0 : opts.extensionOverride) || "js"}`
3834
+ `${name2}.${opts?.extensionOverride || "js"}`
3736
3835
  ),
3737
- fullPathOverride: (opts == null ? void 0 : opts.extensionOverride) ? import_path7.default.join(parentPath, `${name2}.${opts == null ? void 0 : opts.extensionOverride}`) : "",
3836
+ fullPathOverride: opts?.extensionOverride ? path10.join(parentPath, `${name2}.${opts?.extensionOverride}`) : "",
3738
3837
  generatedFileType,
3739
3838
  name: name2,
3740
3839
  parentPath,
@@ -3752,8 +3851,8 @@ var makeGeneratedFile = async (name2, generatedFileType, parentPath, opts) => {
3752
3851
  };
3753
3852
  }
3754
3853
  };
3755
- result.typescriptExists = await import_fs_extra8.default.pathExists(result.fullPathTS);
3756
- result.javascriptExists = await import_fs_extra8.default.pathExists(result.fullPathJS);
3854
+ result.typescriptExists = await fs9.pathExists(result.fullPathTS);
3855
+ result.javascriptExists = await fs9.pathExists(result.fullPathJS);
3757
3856
  return result;
3758
3857
  };
3759
3858
  var detectEnvironment = async ({
@@ -3762,22 +3861,21 @@ var detectEnvironment = async ({
3762
3861
  rootPath,
3763
3862
  debug = false
3764
3863
  }) => {
3765
- var _a;
3766
- const hasForestryConfig = await import_fs_extra8.default.pathExists(
3767
- import_path7.default.join(pathToForestryConfig, ".forestry", "settings.yml")
3864
+ const hasForestryConfig = await fs9.pathExists(
3865
+ path10.join(pathToForestryConfig, ".forestry", "settings.yml")
3768
3866
  );
3769
- const sampleContentPath = import_path7.default.join(
3867
+ const sampleContentPath = path10.join(
3770
3868
  baseDir,
3771
3869
  "content",
3772
3870
  "posts",
3773
3871
  "hello-world.md"
3774
3872
  );
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");
3873
+ const usingSrc = fs9.pathExistsSync(path10.join(baseDir, "src")) && (fs9.pathExistsSync(path10.join(baseDir, "src", "app")) || fs9.pathExistsSync(path10.join(baseDir, "src", "pages")));
3874
+ const tinaFolder = path10.join(baseDir, "tina");
3777
3875
  const tinaConfigExists = Boolean(
3778
3876
  // Does the tina folder exist?
3779
- await import_fs_extra8.default.pathExists(tinaFolder) && // Does the tina folder contain a config file?
3780
- (await import_fs_extra8.default.readdir(tinaFolder)).find((x) => x.includes("config"))
3877
+ await fs9.pathExists(tinaFolder) && // Does the tina folder contain a config file?
3878
+ (await fs9.readdir(tinaFolder)).find((x) => x.includes("config"))
3781
3879
  );
3782
3880
  const pagesDir = [baseDir, usingSrc ? "src" : false, "pages"].filter(
3783
3881
  Boolean
@@ -3789,12 +3887,12 @@ var detectEnvironment = async ({
3789
3887
  "next-api-handler": await makeGeneratedFile(
3790
3888
  "[...routes]",
3791
3889
  "next-api-handler",
3792
- import_path7.default.join(...pagesDir, "api", "tina")
3890
+ path10.join(...pagesDir, "api", "tina")
3793
3891
  ),
3794
3892
  "reactive-example": await makeGeneratedFile(
3795
3893
  "[filename]",
3796
3894
  "reactive-example",
3797
- import_path7.default.join(...pagesDir, "demo", "blog"),
3895
+ path10.join(...pagesDir, "demo", "blog"),
3798
3896
  {
3799
3897
  typescriptSuffix: "tsx"
3800
3898
  }
@@ -3802,27 +3900,27 @@ var detectEnvironment = async ({
3802
3900
  "users-json": await makeGeneratedFile(
3803
3901
  "index",
3804
3902
  "users-json",
3805
- import_path7.default.join(baseDir, "content", "users"),
3903
+ path10.join(baseDir, "content", "users"),
3806
3904
  { extensionOverride: "json" }
3807
3905
  ),
3808
3906
  "sample-content": await makeGeneratedFile(
3809
3907
  "hello-world",
3810
3908
  "sample-content",
3811
- import_path7.default.join(baseDir, "content", "posts"),
3909
+ path10.join(baseDir, "content", "posts"),
3812
3910
  { extensionOverride: "md" }
3813
3911
  )
3814
3912
  };
3815
- const hasSampleContent = await import_fs_extra8.default.pathExists(sampleContentPath);
3816
- const hasPackageJSON = await import_fs_extra8.default.pathExists("package.json");
3913
+ const hasSampleContent = await fs9.pathExists(sampleContentPath);
3914
+ const hasPackageJSON = await fs9.pathExists("package.json");
3817
3915
  let hasTinaDeps = false;
3818
3916
  if (hasPackageJSON) {
3819
3917
  try {
3820
- const packageJSON = await import_fs_extra8.default.readJSON("package.json");
3918
+ const packageJSON = await fs9.readJSON("package.json");
3821
3919
  const deps = [];
3822
- if (packageJSON == null ? void 0 : packageJSON.dependencies) {
3920
+ if (packageJSON?.dependencies) {
3823
3921
  deps.push(...Object.keys(packageJSON.dependencies));
3824
3922
  }
3825
- if (packageJSON == null ? void 0 : packageJSON.devDependencies) {
3923
+ if (packageJSON?.devDependencies) {
3826
3924
  deps.push(...Object.keys(packageJSON.devDependencies));
3827
3925
  }
3828
3926
  if (deps.includes("@tinacms/cli") && deps.includes("tinacms")) {
@@ -3834,16 +3932,16 @@ var detectEnvironment = async ({
3834
3932
  );
3835
3933
  }
3836
3934
  }
3837
- const hasGitIgnore = await import_fs_extra8.default.pathExists(import_path7.default.join(".gitignore"));
3935
+ const hasGitIgnore = await fs9.pathExists(path10.join(".gitignore"));
3838
3936
  const hasGitIgnoreNodeModules = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: "node_modules" });
3839
3937
  const hasEnvTina = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: ".env.tina" });
3840
3938
  const hasGitIgnoreEnv = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: ".env" });
3841
3939
  let frontMatterFormat;
3842
3940
  if (hasForestryConfig) {
3843
- const hugoConfigPath = import_path7.default.join(rootPath, "config.toml");
3844
- if (await import_fs_extra8.default.pathExists(hugoConfigPath)) {
3845
- const hugoConfig = await import_fs_extra8.default.readFile(hugoConfigPath, "utf8");
3846
- const metaDataFormat = (_a = hugoConfig.match(/metaDataFormat = "(.*)"/)) == null ? void 0 : _a[1];
3941
+ const hugoConfigPath = path10.join(rootPath, "config.toml");
3942
+ if (await fs9.pathExists(hugoConfigPath)) {
3943
+ const hugoConfig = await fs9.readFile(hugoConfigPath, "utf8");
3944
+ const metaDataFormat = hugoConfig.toString().match(/metaDataFormat = "(.*)"/)?.[1];
3847
3945
  if (metaDataFormat && (metaDataFormat === "yaml" || metaDataFormat === "toml" || metaDataFormat === "json")) {
3848
3946
  frontMatterFormat = metaDataFormat;
3849
3947
  }
@@ -3873,10 +3971,10 @@ var detectEnvironment = async ({
3873
3971
  var detectEnvironment_default = detectEnvironment;
3874
3972
 
3875
3973
  // src/cmds/init/prompts/index.ts
3876
- var import_prompts6 = __toESM(require("prompts"));
3974
+ import prompts6 from "prompts";
3877
3975
 
3878
3976
  // src/cmds/init/prompts/askTinaCloudSetup.ts
3879
- var import_prompts2 = __toESM(require("prompts"));
3977
+ import prompts2 from "prompts";
3880
3978
  var tinaCloudSetupQuestions = [
3881
3979
  {
3882
3980
  name: "clientId",
@@ -3898,7 +3996,7 @@ ${logText(
3898
3996
  }
3899
3997
  ];
3900
3998
  var askTinaCloudSetup = async ({ config: config2 }) => {
3901
- const { clientId, token } = await (0, import_prompts2.default)(tinaCloudSetupQuestions);
3999
+ const { clientId, token } = await prompts2(tinaCloudSetupQuestions);
3902
4000
  config2.envVars.push(
3903
4001
  {
3904
4002
  key: "NEXT_PUBLIC_TINA_CLIENT_ID",
@@ -3912,7 +4010,7 @@ var askTinaCloudSetup = async ({ config: config2 }) => {
3912
4010
  };
3913
4011
 
3914
4012
  // src/cmds/init/prompts/gitProvider.ts
3915
- var import_prompts3 = __toESM(require("prompts"));
4013
+ import prompts3 from "prompts";
3916
4014
  var supportedGitProviders = {
3917
4015
  github: {
3918
4016
  imports: [
@@ -3934,7 +4032,7 @@ var supportedGitProviders = {
3934
4032
  }
3935
4033
  };
3936
4034
  var chooseGitProvider = async ({ config: config2 }) => {
3937
- const result = await (0, import_prompts3.default)([
4035
+ const result = await prompts3([
3938
4036
  {
3939
4037
  name: "githubToken",
3940
4038
  type: "text",
@@ -3942,7 +4040,7 @@ var chooseGitProvider = async ({ config: config2 }) => {
3942
4040
  ${logText(
3943
4041
  "Learn more here: "
3944
4042
  )}${linkText(
3945
- "https://tina.io/docs/self-hosted/existing-site/#github-personal-access-token"
4043
+ "https://tina.io/docs/r/self-hosting-nextjs/#github-personal-access-token"
3946
4044
  )}`,
3947
4045
  initial: process.env.GITHUB_PERSONAL_ACCESS_TOKEN
3948
4046
  },
@@ -3979,7 +4077,7 @@ ${logText(
3979
4077
  };
3980
4078
 
3981
4079
  // src/cmds/init/prompts/databaseAdapter.ts
3982
- var import_prompts4 = __toESM(require("prompts"));
4080
+ import prompts4 from "prompts";
3983
4081
  var supportedDatabaseAdapters = {
3984
4082
  ["upstash-redis"]: {
3985
4083
  databaseAdapterClassText: `new RedisLevel({
@@ -4025,7 +4123,7 @@ var databaseAdapterUpdateConfig = {
4025
4123
  other: async (_args) => {
4026
4124
  },
4027
4125
  mongodb: async ({ config: config2 }) => {
4028
- const result = await (0, import_prompts4.default)([
4126
+ const result = await prompts4([
4029
4127
  {
4030
4128
  name: "mongoDBUri",
4031
4129
  type: "text",
@@ -4040,7 +4138,7 @@ var databaseAdapterUpdateConfig = {
4040
4138
  });
4041
4139
  },
4042
4140
  "upstash-redis": async ({ config: config2 }) => {
4043
- const result = await (0, import_prompts4.default)([
4141
+ const result = await prompts4([
4044
4142
  {
4045
4143
  name: "kvRestApiUrl",
4046
4144
  type: "text",
@@ -4071,7 +4169,7 @@ var chooseDatabaseAdapter = async ({
4071
4169
  framework,
4072
4170
  config: config2
4073
4171
  }) => {
4074
- const answers = await (0, import_prompts4.default)([
4172
+ const answers = await prompts4([
4075
4173
  {
4076
4174
  name: "dataLayerAdapter",
4077
4175
  message: "Select a self-hosted Database Adapter",
@@ -4101,8 +4199,8 @@ var chooseDatabaseAdapter = async ({
4101
4199
  };
4102
4200
 
4103
4201
  // src/cmds/init/prompts/authProvider.ts
4104
- var import_crypto_js = __toESM(require("crypto-js"));
4105
- var import_prompts5 = __toESM(require("prompts"));
4202
+ import crypto2 from "crypto-js";
4203
+ import prompts5 from "prompts";
4106
4204
  var supportedAuthProviders = {
4107
4205
  other: {
4108
4206
  name: "other"
@@ -4151,12 +4249,12 @@ var authProviderUpdateConfig = {
4151
4249
  },
4152
4250
  "tina-cloud": askTinaCloudSetup,
4153
4251
  "next-auth": async ({ config: config2 }) => {
4154
- const result = await (0, import_prompts5.default)([
4252
+ const result = await prompts5([
4155
4253
  {
4156
4254
  name: "nextAuthSecret",
4157
4255
  type: "text",
4158
4256
  message: `What is the NextAuth.js Secret? (Hit enter to use a randomly generated secret)`,
4159
- initial: process.env.NEXTAUTH_SECRET || import_crypto_js.default.lib.WordArray.random(16).toString()
4257
+ initial: process.env.NEXTAUTH_SECRET || crypto2.lib.WordArray.random(16).toString()
4160
4258
  }
4161
4259
  ]);
4162
4260
  config2.envVars.push({
@@ -4181,7 +4279,7 @@ var forestryDisclaimer = logText(
4181
4279
  `Note: This migration will update some of your content to match tina. Please save a backup of your content before doing this migration. (This can be done with git)`
4182
4280
  );
4183
4281
  var askCommonSetUp = async () => {
4184
- const answers = await (0, import_prompts6.default)([
4282
+ const answers = await prompts6([
4185
4283
  {
4186
4284
  name: "framework",
4187
4285
  type: "select",
@@ -4203,7 +4301,8 @@ var askCommonSetUp = async () => {
4203
4301
  choices: [
4204
4302
  { title: "PNPM", value: "pnpm" },
4205
4303
  { title: "Yarn", value: "yarn" },
4206
- { title: "NPM", value: "npm" }
4304
+ { title: "NPM", value: "npm" },
4305
+ { title: "Bun", value: "bun" }
4207
4306
  ]
4208
4307
  }
4209
4308
  ]);
@@ -4244,7 +4343,7 @@ ${forestryDisclaimer}`
4244
4343
  message: `What format are you using in your frontmatter?`
4245
4344
  });
4246
4345
  }
4247
- const answers = await (0, import_prompts6.default)(questions);
4346
+ const answers = await prompts6(questions);
4248
4347
  return answers;
4249
4348
  };
4250
4349
  var askTinaSetupPrompts = async (params) => {
@@ -4264,16 +4363,16 @@ var askTinaSetupPrompts = async (params) => {
4264
4363
  message: `Where are public assets stored? (default: "public")
4265
4364
  ` + logText(
4266
4365
  `Not sure what value to use? Refer to our "Frameworks" doc: ${linkText(
4267
- "https://tina.io/docs/integration/frameworks/#configuring-tina-with-each-framework"
4366
+ "https://tina.io/docs/r/framework-guides-overview"
4268
4367
  )}`
4269
4368
  )
4270
4369
  });
4271
4370
  }
4272
- const answers = await (0, import_prompts6.default)(questions);
4371
+ const answers = await prompts6(questions);
4273
4372
  return answers;
4274
4373
  };
4275
4374
  var askIfUsingSelfHosted = async () => {
4276
- const answers = await (0, import_prompts6.default)([
4375
+ const answers = await prompts6([
4277
4376
  {
4278
4377
  name: "hosting",
4279
4378
  type: "select",
@@ -4306,20 +4405,20 @@ var makeImportString = (imports) => {
4306
4405
  };
4307
4406
 
4308
4407
  // src/cmds/init/prompts/generatedFiles.ts
4309
- var import_prompts7 = __toESM(require("prompts"));
4408
+ import prompts7 from "prompts";
4310
4409
  var askIfOverride = async ({
4311
4410
  generatedFile,
4312
4411
  usingTypescript
4313
4412
  }) => {
4314
4413
  if (usingTypescript) {
4315
- const result = await (0, import_prompts7.default)({
4414
+ const result = await prompts7({
4316
4415
  name: `override`,
4317
4416
  type: "confirm",
4318
4417
  message: `Found existing file at ${generatedFile.fullPathTS}. Would you like to overwrite?`
4319
4418
  });
4320
4419
  return Boolean(result.override);
4321
4420
  } else {
4322
- const result = await (0, import_prompts7.default)({
4421
+ const result = await prompts7({
4323
4422
  name: `override`,
4324
4423
  type: "confirm",
4325
4424
  message: `Found existing file at ${generatedFile.fullPathJS}. Would you like to overwrite?`
@@ -4454,23 +4553,25 @@ var CLICommand = class {
4454
4553
  };
4455
4554
 
4456
4555
  // src/cmds/init/apply.ts
4457
- var import_path11 = __toESM(require("path"));
4556
+ import path14 from "path";
4458
4557
 
4459
4558
  // src/cmds/forestry-migrate/index.ts
4460
- var import_fs_extra10 = __toESM(require("fs-extra"));
4461
- var import_path9 = __toESM(require("path"));
4462
- var import_js_yaml2 = __toESM(require("js-yaml"));
4463
- var import_minimatch = __toESM(require("minimatch"));
4464
- var import_graphql16 = require("@tinacms/graphql");
4559
+ import fs11 from "fs-extra";
4560
+ import path12 from "path";
4561
+ import yaml2 from "js-yaml";
4562
+ import pkg from "minimatch";
4563
+ import { parseFile, stringifyFile } from "@tinacms/graphql";
4564
+ import { CONTENT_FORMATS } from "@tinacms/schema-tools";
4465
4565
 
4466
4566
  // src/cmds/forestry-migrate/util/index.ts
4467
- var import_fs_extra9 = __toESM(require("fs-extra"));
4468
- var import_path8 = __toESM(require("path"));
4469
- var import_js_yaml = __toESM(require("js-yaml"));
4470
- var import_zod = __toESM(require("zod"));
4567
+ import fs10 from "fs-extra";
4568
+ import path11 from "path";
4569
+ import yaml from "js-yaml";
4570
+ import z from "zod";
4471
4571
 
4472
4572
  // src/cmds/forestry-migrate/util/errorSingleton.ts
4473
4573
  var ErrorSingleton = class _ErrorSingleton {
4574
+ static instance;
4474
4575
  /**
4475
4576
  * The Singleton's constructor should always be private to prevent direct
4476
4577
  * construction calls with the `new` operator.
@@ -4490,12 +4591,12 @@ var ErrorSingleton = class _ErrorSingleton {
4490
4591
  }
4491
4592
  return _ErrorSingleton.instance;
4492
4593
  }
4594
+ collectionNameErrors;
4493
4595
  addErrorName(error) {
4494
4596
  this.collectionNameErrors.push(error);
4495
4597
  }
4496
4598
  printCollectionNameErrors() {
4497
- var _a;
4498
- if ((_a = this.collectionNameErrors) == null ? void 0 : _a.length) {
4599
+ if (this.collectionNameErrors?.length) {
4499
4600
  logger.error(
4500
4601
  dangerText("ERROR: TinaCMS only supports alphanumeric template names")
4501
4602
  );
@@ -4513,8 +4614,8 @@ var ErrorSingleton = class _ErrorSingleton {
4513
4614
  };
4514
4615
 
4515
4616
  // src/cmds/forestry-migrate/util/codeTransformer.ts
4516
- var import_prettier = require("prettier");
4517
- var import_parser_typescript = __toESM(require("prettier/parser-typescript"));
4617
+ import { format } from "prettier";
4618
+ import TsParser from "prettier/parser-typescript.js";
4518
4619
  var addVariablesToCode = (codeWithTinaPrefix) => {
4519
4620
  const code = codeWithTinaPrefix.replace(
4520
4621
  /"__TINA_INTERNAL__:::(.*?):::"/g,
@@ -4551,7 +4652,7 @@ var makeTemplateFile = async ({
4551
4652
  `export function ${stringifyLabelWithField(
4552
4653
  template.templateObj.label
4553
4654
  )} (){
4554
- return ${addVariablesToCode(JSON.stringify(template.fields, null, 2)).code} ${usingTypescript ? "as TinaField[]" : ""}
4655
+ return ${addVariablesToCode(JSON.stringify(template.fields, null, 2)).code} ${usingTypescript ? "as TinaField[]" : ""}
4555
4656
  } `
4556
4657
  );
4557
4658
  }
@@ -4559,9 +4660,9 @@ var makeTemplateFile = async ({
4559
4660
  ${usingTypescript ? "import type { TinaField } from 'tinacms'" : ""}
4560
4661
  ${templateCodeText.join("\n")}
4561
4662
  `;
4562
- const formattedCode = (0, import_prettier.format)(templateCode, {
4663
+ const formattedCode = format(templateCode, {
4563
4664
  parser: "typescript",
4564
- plugins: [import_parser_typescript.default]
4665
+ plugins: [TsParser]
4565
4666
  });
4566
4667
  return { importStatements, templateCodeText: formattedCode };
4567
4668
  };
@@ -4593,82 +4694,82 @@ var stringifyTemplateName = (name2, template) => {
4593
4694
  return newName;
4594
4695
  }
4595
4696
  };
4596
- var forestryConfigSchema = import_zod.default.object({
4597
- sections: import_zod.default.array(
4598
- import_zod.default.object({
4599
- type: import_zod.default.union([
4600
- import_zod.default.literal("directory"),
4601
- import_zod.default.literal("document"),
4602
- import_zod.default.literal("heading"),
4603
- import_zod.default.literal("jekyll-pages"),
4604
- import_zod.default.literal("jekyll-posts")
4697
+ var forestryConfigSchema = z.object({
4698
+ sections: z.array(
4699
+ z.object({
4700
+ type: z.union([
4701
+ z.literal("directory"),
4702
+ z.literal("document"),
4703
+ z.literal("heading"),
4704
+ z.literal("jekyll-pages"),
4705
+ z.literal("jekyll-posts")
4605
4706
  ]),
4606
- label: import_zod.default.string(),
4607
- path: import_zod.default.string().optional().nullable(),
4608
- match: import_zod.default.string().optional().nullable(),
4609
- exclude: import_zod.default.string().optional().nullable(),
4610
- create: import_zod.default.union([import_zod.default.literal("all"), import_zod.default.literal("documents"), import_zod.default.literal("none")]).optional(),
4611
- templates: import_zod.default.array(import_zod.default.string()).optional().nullable(),
4612
- new_doc_ext: import_zod.default.string().optional().nullable(),
4613
- read_only: import_zod.default.boolean().optional().nullable()
4707
+ label: z.string(),
4708
+ path: z.string().optional().nullable(),
4709
+ match: z.string().optional().nullable(),
4710
+ exclude: z.string().optional().nullable(),
4711
+ create: z.union([z.literal("all"), z.literal("documents"), z.literal("none")]).optional(),
4712
+ templates: z.array(z.string()).optional().nullable(),
4713
+ new_doc_ext: z.string().optional().nullable(),
4714
+ read_only: z.boolean().optional().nullable()
4614
4715
  })
4615
4716
  )
4616
4717
  });
4617
- var forestryFieldWithoutField = import_zod.default.object({
4718
+ var forestryFieldWithoutField = z.object({
4618
4719
  // TODO: maybe better type this?
4619
- type: import_zod.default.union([
4620
- import_zod.default.literal("text"),
4621
- import_zod.default.literal("datetime"),
4622
- import_zod.default.literal("list"),
4623
- import_zod.default.literal("file"),
4624
- import_zod.default.literal("image_gallery"),
4625
- import_zod.default.literal("textarea"),
4626
- import_zod.default.literal("tag_list"),
4627
- import_zod.default.literal("number"),
4628
- import_zod.default.literal("boolean"),
4629
- import_zod.default.literal("field_group"),
4630
- import_zod.default.literal("field_group_list"),
4631
- import_zod.default.literal("select"),
4632
- import_zod.default.literal("include"),
4633
- import_zod.default.literal("blocks"),
4634
- import_zod.default.literal("color")
4720
+ type: z.union([
4721
+ z.literal("text"),
4722
+ z.literal("datetime"),
4723
+ z.literal("list"),
4724
+ z.literal("file"),
4725
+ z.literal("image_gallery"),
4726
+ z.literal("textarea"),
4727
+ z.literal("tag_list"),
4728
+ z.literal("number"),
4729
+ z.literal("boolean"),
4730
+ z.literal("field_group"),
4731
+ z.literal("field_group_list"),
4732
+ z.literal("select"),
4733
+ z.literal("include"),
4734
+ z.literal("blocks"),
4735
+ z.literal("color")
4635
4736
  ]),
4636
- template_types: import_zod.default.array(import_zod.default.string()).optional().nullable(),
4637
- name: import_zod.default.string(),
4638
- label: import_zod.default.string(),
4639
- default: import_zod.default.any().optional(),
4640
- template: import_zod.default.string().optional(),
4641
- config: import_zod.default.object({
4737
+ template_types: z.array(z.string()).optional().nullable(),
4738
+ name: z.string(),
4739
+ label: z.string(),
4740
+ default: z.any().optional(),
4741
+ template: z.string().optional(),
4742
+ config: z.object({
4642
4743
  // min and max are used for lists
4643
- min: import_zod.default.number().optional().nullable(),
4644
- max: import_zod.default.number().optional().nullable(),
4645
- required: import_zod.default.boolean().optional().nullable(),
4646
- use_select: import_zod.default.boolean().optional().nullable(),
4647
- date_format: import_zod.default.string().optional().nullable(),
4648
- time_format: import_zod.default.string().optional().nullable(),
4649
- options: import_zod.default.array(import_zod.default.string()).optional().nullable(),
4650
- source: import_zod.default.object({
4651
- type: import_zod.default.union([
4652
- import_zod.default.literal("custom"),
4653
- import_zod.default.literal("pages"),
4654
- import_zod.default.literal("documents"),
4655
- import_zod.default.literal("simple"),
4744
+ min: z.number().optional().nullable(),
4745
+ max: z.number().optional().nullable(),
4746
+ required: z.boolean().optional().nullable(),
4747
+ use_select: z.boolean().optional().nullable(),
4748
+ date_format: z.string().optional().nullable(),
4749
+ time_format: z.string().optional().nullable(),
4750
+ options: z.array(z.string()).optional().nullable(),
4751
+ source: z.object({
4752
+ type: z.union([
4753
+ z.literal("custom"),
4754
+ z.literal("pages"),
4755
+ z.literal("documents"),
4756
+ z.literal("simple"),
4656
4757
  // TODO: I want to ignore this key if its invalid
4657
- import_zod.default.string()
4758
+ z.string()
4658
4759
  ]).optional().nullable(),
4659
- section: import_zod.default.string().optional().nullable()
4760
+ section: z.string().optional().nullable()
4660
4761
  }).optional()
4661
4762
  }).optional()
4662
4763
  });
4663
- var forestryField = import_zod.default.lazy(
4764
+ var forestryField = z.lazy(
4664
4765
  () => forestryFieldWithoutField.extend({
4665
- fields: import_zod.default.array(forestryField).optional()
4766
+ fields: z.array(forestryField).optional()
4666
4767
  })
4667
4768
  );
4668
- var FrontmatterTemplateSchema = import_zod.default.object({
4669
- label: import_zod.default.string(),
4670
- hide_body: import_zod.default.boolean().optional(),
4671
- fields: import_zod.default.array(forestryField).optional()
4769
+ var FrontmatterTemplateSchema = z.object({
4770
+ label: z.string(),
4771
+ hide_body: z.boolean().optional(),
4772
+ fields: z.array(forestryField).optional()
4672
4773
  });
4673
4774
  var transformForestryFieldsToTinaFields = ({
4674
4775
  fields,
@@ -4677,8 +4778,7 @@ var transformForestryFieldsToTinaFields = ({
4677
4778
  skipBlocks = false
4678
4779
  }) => {
4679
4780
  const tinaFields = [];
4680
- fields == null ? void 0 : fields.forEach((forestryField2) => {
4681
- var _a, _b, _c, _d;
4781
+ fields?.forEach((forestryField2) => {
4682
4782
  if (forestryField2.name === "menu") {
4683
4783
  logger.info(
4684
4784
  warnText(
@@ -4754,12 +4854,12 @@ var transformForestryFieldsToTinaFields = ({
4754
4854
  };
4755
4855
  break;
4756
4856
  case "select":
4757
- if ((_a = forestryField2.config) == null ? void 0 : _a.options) {
4857
+ if (forestryField2.config?.options) {
4758
4858
  field = {
4759
4859
  type: "string",
4760
4860
  ...getTinaFieldsFromName(forestryField2.name),
4761
4861
  label: forestryField2.label,
4762
- options: ((_b = forestryField2.config) == null ? void 0 : _b.options) || []
4862
+ options: forestryField2.config?.options || []
4763
4863
  };
4764
4864
  } else {
4765
4865
  logger.info(
@@ -4777,7 +4877,7 @@ var transformForestryFieldsToTinaFields = ({
4777
4877
  label: forestryField2.label,
4778
4878
  list: true
4779
4879
  };
4780
- if ((_c = forestryField2.config) == null ? void 0 : _c.options) {
4880
+ if (forestryField2.config?.options) {
4781
4881
  field.options = forestryField2.config.options;
4782
4882
  }
4783
4883
  break;
@@ -4825,7 +4925,7 @@ var transformForestryFieldsToTinaFields = ({
4825
4925
  break;
4826
4926
  }
4827
4927
  const templates2 = [];
4828
- forestryField2 == null ? void 0 : forestryField2.template_types.forEach((tem) => {
4928
+ forestryField2?.template_types.forEach((tem) => {
4829
4929
  const { template: template2 } = getFieldsFromTemplates({
4830
4930
  tem,
4831
4931
  skipBlocks: true,
@@ -4883,7 +4983,7 @@ var transformForestryFieldsToTinaFields = ({
4883
4983
  );
4884
4984
  }
4885
4985
  if (field) {
4886
- if ((_d = forestryField2.config) == null ? void 0 : _d.required) {
4986
+ if (forestryField2.config?.required) {
4887
4987
  field = { ...field, required: true };
4888
4988
  }
4889
4989
  tinaFields.push(field);
@@ -4892,7 +4992,7 @@ var transformForestryFieldsToTinaFields = ({
4892
4992
  return tinaFields;
4893
4993
  };
4894
4994
  var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false }) => {
4895
- const templatePath = import_path8.default.join(
4995
+ const templatePath = path11.join(
4896
4996
  pathToForestryConfig,
4897
4997
  ".forestry",
4898
4998
  "front_matter",
@@ -4901,7 +5001,7 @@ var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false })
4901
5001
  );
4902
5002
  let templateString = "";
4903
5003
  try {
4904
- templateString = import_fs_extra9.default.readFileSync(templatePath).toString();
5004
+ templateString = fs10.readFileSync(templatePath).toString();
4905
5005
  } catch {
4906
5006
  throw new Error(
4907
5007
  `Could not find template ${tem} at ${templatePath}
@@ -4909,7 +5009,7 @@ var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false })
4909
5009
  This will require manual migration.`
4910
5010
  );
4911
5011
  }
4912
- const templateObj = import_js_yaml.default.load(templateString);
5012
+ const templateObj = yaml.load(templateString);
4913
5013
  const template = parseTemplates({ val: templateObj });
4914
5014
  const fields = transformForestryFieldsToTinaFields({
4915
5015
  fields: template.fields,
@@ -4929,6 +5029,7 @@ var parseSections = ({ val }) => {
4929
5029
  };
4930
5030
 
4931
5031
  // src/cmds/forestry-migrate/index.ts
5032
+ var { minimatch } = pkg;
4932
5033
  var BODY_FIELD = {
4933
5034
  // This is the body field
4934
5035
  type: "rich-text",
@@ -4945,8 +5046,7 @@ var stringifyLabelWithField = (label) => {
4945
5046
  return `${labelString}Fields`;
4946
5047
  };
4947
5048
  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("{}", "");
5049
+ const newMatch = match.replace(" ", "").replace(/\.?(mdx|md|json|yaml|yml|toml)/g, "")?.replace(/\..*$/g, "")?.replace("{}", "");
4950
5050
  if (match !== newMatch) {
4951
5051
  logger.info(
4952
5052
  `Info: Match ${match} was transformed to ${newMatch}. See ${linkText(
@@ -4958,7 +5058,7 @@ var transformForestryMatchToTinaMatch = (match) => {
4958
5058
  };
4959
5059
  function checkExt(ext) {
4960
5060
  const extReal = ext.replace(".", "");
4961
- if (["mdx", "md", "json", "yaml", "yml", "toml"].includes(extReal)) {
5061
+ if (CONTENT_FORMATS.includes(extReal)) {
4962
5062
  return extReal;
4963
5063
  } else {
4964
5064
  return false;
@@ -4967,9 +5067,9 @@ function checkExt(ext) {
4967
5067
  var generateAllTemplates = async ({
4968
5068
  pathToForestryConfig
4969
5069
  }) => {
4970
- 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"));
5070
+ const allTemplates = (await fs11.readdir(
5071
+ path12.join(pathToForestryConfig, ".forestry", "front_matter", "templates")
5072
+ )).map((tem) => path12.basename(tem, ".yml"));
4973
5073
  const templateMap = /* @__PURE__ */ new Map();
4974
5074
  const proms = allTemplates.map(async (tem) => {
4975
5075
  try {
@@ -5011,18 +5111,18 @@ var generateCollectionFromForestrySection = (args) => {
5011
5111
  }
5012
5112
  if (section.match) {
5013
5113
  baseCollection.match = {
5014
- ...(baseCollection == null ? void 0 : baseCollection.match) || {},
5114
+ ...baseCollection?.match || {},
5015
5115
  include: transformForestryMatchToTinaMatch(section.match)
5016
5116
  };
5017
5117
  }
5018
5118
  if (section.exclude) {
5019
5119
  baseCollection.match = {
5020
- ...(baseCollection == null ? void 0 : baseCollection.match) || {},
5120
+ ...baseCollection?.match || {},
5021
5121
  exclude: transformForestryMatchToTinaMatch(section.exclude)
5022
5122
  };
5023
5123
  }
5024
5124
  if (section.type === "directory") {
5025
- if (!(section == null ? void 0 : section.path) || section.path === "/" || section.path === "./" || section.path === ".") {
5125
+ if (!section?.path || section.path === "/" || section.path === "./" || section.path === ".") {
5026
5126
  logger.log(
5027
5127
  warnText(
5028
5128
  `Warning: Section ${section.label} is using a Root Path. Currently, Tina Does not support Root paths see ${linkText(
@@ -5032,11 +5132,11 @@ var generateCollectionFromForestrySection = (args) => {
5032
5132
  );
5033
5133
  return;
5034
5134
  }
5035
- const forestryTemplates = (section == null ? void 0 : section.templates) || [];
5135
+ const forestryTemplates = section?.templates || [];
5036
5136
  if (forestryTemplates.length === 0 && section.create === "all") {
5037
5137
  for (const templateKey of templateMap.keys()) {
5038
5138
  const { templateObj } = templateMap.get(templateKey);
5039
- const pages = templateObj == null ? void 0 : templateObj.pages;
5139
+ const pages = templateObj?.pages;
5040
5140
  if (pages) {
5041
5141
  let glob = section.match;
5042
5142
  const skipPath = section.path === "" || section.path === "/" || !section.path;
@@ -5044,7 +5144,7 @@ var generateCollectionFromForestrySection = (args) => {
5044
5144
  glob = section.path + "/" + section.match;
5045
5145
  }
5046
5146
  if (pages.some((page) => {
5047
- return (0, import_minimatch.default)(page, glob);
5147
+ return minimatch(page, glob);
5048
5148
  })) {
5049
5149
  forestryTemplates.push(templateKey);
5050
5150
  }
@@ -5053,7 +5153,7 @@ var generateCollectionFromForestrySection = (args) => {
5053
5153
  }
5054
5154
  const hasBody = ["md", "mdx", "markdown"].includes(format3);
5055
5155
  let c;
5056
- if (((forestryTemplates == null ? void 0 : forestryTemplates.length) || 0) > 1) {
5156
+ if ((forestryTemplates?.length || 0) > 1) {
5057
5157
  c = {
5058
5158
  ...baseCollection,
5059
5159
  // @ts-expect-error
@@ -5075,7 +5175,7 @@ var generateCollectionFromForestrySection = (args) => {
5075
5175
  })
5076
5176
  };
5077
5177
  }
5078
- if ((forestryTemplates == null ? void 0 : forestryTemplates.length) === 1) {
5178
+ if (forestryTemplates?.length === 1) {
5079
5179
  const tem = forestryTemplates[0];
5080
5180
  const template = templateMap.get(tem);
5081
5181
  const fieldsString = stringifyLabelWithField(template.templateObj.label);
@@ -5090,7 +5190,7 @@ var generateCollectionFromForestrySection = (args) => {
5090
5190
  })
5091
5191
  };
5092
5192
  }
5093
- if ((forestryTemplates == null ? void 0 : forestryTemplates.length) === 0) {
5193
+ if (forestryTemplates?.length === 0) {
5094
5194
  logger.warn(
5095
5195
  warnText(
5096
5196
  `No templates found for section ${section.label}. Please see ${linkText(
@@ -5103,7 +5203,7 @@ var generateCollectionFromForestrySection = (args) => {
5103
5203
  fields: [BODY_FIELD]
5104
5204
  };
5105
5205
  }
5106
- if ((section == null ? void 0 : section.create) === "none") {
5206
+ if (section?.create === "none") {
5107
5207
  c.ui = {
5108
5208
  ...c.ui,
5109
5209
  allowedActions: {
@@ -5114,9 +5214,9 @@ var generateCollectionFromForestrySection = (args) => {
5114
5214
  return c;
5115
5215
  } else if (section.type === "document") {
5116
5216
  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);
5217
+ const extname = path12.extname(filePath);
5218
+ const fileName = path12.basename(filePath, extname);
5219
+ const dir = path12.dirname(filePath);
5120
5220
  const ext = checkExt(extname);
5121
5221
  if (ext) {
5122
5222
  const fields = [];
@@ -5125,7 +5225,7 @@ var generateCollectionFromForestrySection = (args) => {
5125
5225
  }
5126
5226
  for (const currentTemplateName of templateMap.keys()) {
5127
5227
  const { templateObj, fields: additionalFields } = templateMap.get(currentTemplateName);
5128
- const pages = (templateObj == null ? void 0 : templateObj.pages) || [];
5228
+ const pages = templateObj?.pages || [];
5129
5229
  if (pages.includes(section.path)) {
5130
5230
  fields.push(...additionalFields);
5131
5231
  break;
@@ -5136,7 +5236,7 @@ var generateCollectionFromForestrySection = (args) => {
5136
5236
  name: "dummy",
5137
5237
  label: "Dummy field",
5138
5238
  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"
5239
+ 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
5240
  });
5141
5241
  logger.warn(
5142
5242
  warnText(
@@ -5178,8 +5278,8 @@ var generateCollections = async ({
5178
5278
  templateMap,
5179
5279
  usingTypescript
5180
5280
  });
5181
- const forestryConfig = await import_fs_extra10.default.readFile(
5182
- import_path9.default.join(pathToForestryConfig, ".forestry", "settings.yml")
5281
+ const forestryConfig = await fs11.readFile(
5282
+ path12.join(pathToForestryConfig, ".forestry", "settings.yml")
5183
5283
  );
5184
5284
  rewriteTemplateKeysInDocs({
5185
5285
  templateMap,
@@ -5189,7 +5289,7 @@ var generateCollections = async ({
5189
5289
  }
5190
5290
  });
5191
5291
  const collections = parseSections({
5192
- val: import_js_yaml2.default.load(forestryConfig.toString())
5292
+ val: yaml2.load(forestryConfig.toString())
5193
5293
  }).sections.map(
5194
5294
  (section) => generateCollectionFromForestrySection({
5195
5295
  section,
@@ -5204,19 +5304,18 @@ var generateCollections = async ({
5204
5304
  };
5205
5305
  };
5206
5306
  var rewriteTemplateKeysInDocs = (args) => {
5207
- var _a;
5208
5307
  const { templateMap, markdownParseConfig } = args;
5209
5308
  for (const templateKey of templateMap.keys()) {
5210
5309
  const { templateObj } = templateMap.get(templateKey);
5211
- (_a = templateObj == null ? void 0 : templateObj.pages) == null ? void 0 : _a.forEach((page) => {
5310
+ templateObj?.pages?.forEach((page) => {
5212
5311
  try {
5213
- const filePath = import_path9.default.join(page);
5214
- if (import_fs_extra10.default.lstatSync(filePath).isDirectory()) {
5312
+ const filePath = path12.join(page);
5313
+ if (fs11.lstatSync(filePath).isDirectory()) {
5215
5314
  return;
5216
5315
  }
5217
- const extname = import_path9.default.extname(filePath);
5218
- const fileContent = import_fs_extra10.default.readFileSync(filePath).toString();
5219
- const content = (0, import_graphql16.parseFile)(
5316
+ const extname = path12.extname(filePath);
5317
+ const fileContent = fs11.readFileSync(filePath).toString();
5318
+ const content = parseFile(
5220
5319
  fileContent,
5221
5320
  extname,
5222
5321
  (yup) => yup.object({}),
@@ -5226,9 +5325,9 @@ var rewriteTemplateKeysInDocs = (args) => {
5226
5325
  _template: stringifyLabel(templateKey),
5227
5326
  ...content
5228
5327
  };
5229
- import_fs_extra10.default.writeFileSync(
5328
+ fs11.writeFileSync(
5230
5329
  filePath,
5231
- (0, import_graphql16.stringifyFile)(newContent, extname, true, markdownParseConfig)
5330
+ stringifyFile(newContent, extname, true, markdownParseConfig)
5232
5331
  );
5233
5332
  } catch (error) {
5234
5333
  console.log(
@@ -5240,23 +5339,25 @@ var rewriteTemplateKeysInDocs = (args) => {
5240
5339
  };
5241
5340
 
5242
5341
  // src/cmds/init/apply.ts
5243
- var import_metrics2 = require("@tinacms/metrics");
5244
- var import_fs_extra13 = __toESM(require("fs-extra"));
5342
+ import { Telemetry as Telemetry2 } from "@tinacms/metrics";
5343
+ import fs14 from "fs-extra";
5245
5344
 
5246
5345
  // src/next/commands/codemod-command/index.ts
5247
- var import_clipanion5 = require("clipanion");
5248
- var import_fs_extra11 = __toESM(require("fs-extra"));
5249
- var import_path10 = __toESM(require("path"));
5250
- var CodemodCommand = class extends import_clipanion5.Command {
5251
- constructor() {
5252
- super(...arguments);
5253
- this.rootPath = import_clipanion5.Option.String("--rootPath", {
5254
- description: "Specify the root directory to run the CLI from"
5255
- });
5256
- this.verbose = import_clipanion5.Option.Boolean("-v,--verbose", false, {
5257
- description: "increase verbosity of logged output"
5258
- });
5259
- }
5346
+ import { Command as Command5, Option as Option5 } from "clipanion";
5347
+ import fs12 from "fs-extra";
5348
+ import path13 from "path";
5349
+ var CodemodCommand = class extends Command5 {
5350
+ static paths = [["codemod"], ["codemod", "move-tina-folder"]];
5351
+ rootPath = Option5.String("--rootPath", {
5352
+ description: "Specify the root directory to run the CLI from"
5353
+ });
5354
+ verbose = Option5.Boolean("-v,--verbose", false, {
5355
+ description: "increase verbosity of logged output"
5356
+ });
5357
+ static usage = Command5.Usage({
5358
+ category: `Commands`,
5359
+ description: `Use codemods for various Tina tasks`
5360
+ });
5260
5361
  async catch(error) {
5261
5362
  console.log(error);
5262
5363
  }
@@ -5277,11 +5378,6 @@ var CodemodCommand = class extends import_clipanion5.Command {
5277
5378
  await command2();
5278
5379
  }
5279
5380
  };
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
5381
  var moveTinaFolder = async (rootPath = process.cwd()) => {
5286
5382
  const configManager = new ConfigManager({ rootPath });
5287
5383
  try {
@@ -5290,13 +5386,13 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
5290
5386
  logger.error(e.message);
5291
5387
  process.exit(1);
5292
5388
  }
5293
- const tinaDestination = import_path10.default.join(configManager.rootPath, "tina");
5294
- if (await import_fs_extra11.default.existsSync(tinaDestination)) {
5389
+ const tinaDestination = path13.join(configManager.rootPath, "tina");
5390
+ if (await fs12.existsSync(tinaDestination)) {
5295
5391
  logger.info(
5296
5392
  `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.`
5297
5393
  );
5298
5394
  } else {
5299
- await import_fs_extra11.default.moveSync(configManager.tinaFolderPath, tinaDestination);
5395
+ await fs12.moveSync(configManager.tinaFolderPath, tinaDestination);
5300
5396
  await writeGitignore(configManager.rootPath);
5301
5397
  logger.info(
5302
5398
  "Move to 'tina' folder complete. Be sure to update any imports of the autogenerated client!"
@@ -5304,8 +5400,8 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
5304
5400
  }
5305
5401
  };
5306
5402
  var writeGitignore = async (rootPath) => {
5307
- await import_fs_extra11.default.outputFileSync(
5308
- import_path10.default.join(rootPath, "tina", ".gitignore"),
5403
+ await fs12.outputFileSync(
5404
+ path13.join(rootPath, "tina", ".gitignore"),
5309
5405
  "__generated__"
5310
5406
  );
5311
5407
  };
@@ -5358,7 +5454,7 @@ const BlogPage = (props) => {
5358
5454
  <div className='bg-green-100 text-center'>
5359
5455
  Lost and looking for a place to start?
5360
5456
  <a
5361
- href='https://tina.io/guides/tina-cloud/getting-started/overview/'
5457
+ href='https://tina.io/docs/r/beginner-series'
5362
5458
  className='text-blue-500 underline'
5363
5459
  >
5364
5460
  {' '}
@@ -5561,11 +5657,10 @@ var baseFields = `[
5561
5657
  },
5562
5658
  ]`;
5563
5659
  var generateCollectionString = (args) => {
5564
- var _a, _b, _c, _d;
5565
5660
  if (args.collections) {
5566
5661
  return args.collections;
5567
5662
  }
5568
- let extraTinaCollections = (_b = (_a = args.config.authProvider) == null ? void 0 : _a.extraTinaCollections) == null ? void 0 : _b.join(",\n");
5663
+ let extraTinaCollections = args.config.authProvider?.extraTinaCollections?.join(",\n");
5569
5664
  if (extraTinaCollections) {
5570
5665
  extraTinaCollections = extraTinaCollections + ",";
5571
5666
  }
@@ -5591,18 +5686,17 @@ var generateCollectionString = (args) => {
5591
5686
  },
5592
5687
  },
5593
5688
  ]`;
5594
- if (((_d = (_c = args.config) == null ? void 0 : _c.framework) == null ? void 0 : _d.name) === "next") {
5689
+ if (args.config?.framework?.name === "next") {
5595
5690
  return nextExampleCollection;
5596
5691
  }
5597
5692
  return baseCollections;
5598
5693
  };
5599
5694
  var generateConfig = (args) => {
5600
- var _a, _b, _c;
5601
- const isUsingTinaCloud = !args.selfHosted || ((_a = args.config.authProvider) == null ? void 0 : _a.name) === "tina-cloud";
5695
+ const isUsingTinaCloud = !args.selfHosted || args.config.authProvider?.name === "tina-cloud";
5602
5696
  let extraImports = "";
5603
5697
  if (args.selfHosted) {
5604
5698
  if (args.config.authProvider) {
5605
- extraImports = extraImports + makeImportString((_b = args.config.authProvider) == null ? void 0 : _b.configImports);
5699
+ extraImports = extraImports + makeImportString(args.config.authProvider?.configImports);
5606
5700
  }
5607
5701
  if (!isUsingTinaCloud) {
5608
5702
  extraImports = extraImports + `
@@ -5625,7 +5719,7 @@ import { LocalAuthProvider } from "tinacms";`;
5625
5719
  branch,
5626
5720
  ${args.selfHosted && !isUsingTinaCloud ? `authProvider: isLocal
5627
5721
  ? new LocalAuthProvider()
5628
- :${(_c = args.config) == null ? void 0 : _c.authProvider.configAuthProviderClass},` : ""}
5722
+ :${args.config?.authProvider.configAuthProviderClass},` : ""}
5629
5723
  ${isUsingTinaCloud ? `// Get this from tina.io
5630
5724
  clientId: process.env.NEXT_PUBLIC_TINA_CLIENT_ID,` : ""}
5631
5725
  ${isUsingTinaCloud ? `// Get this from tina.io
@@ -5642,7 +5736,7 @@ import { LocalAuthProvider } from "tinacms";`;
5642
5736
  publicFolder: "${args.publicFolder}",
5643
5737
  },
5644
5738
  },
5645
- // See docs on content modeling for more info on how to setup new content models: https://tina.io/docs/schema/
5739
+ // See docs on content modeling for more info on how to setup new content models: https://tina.io/docs/r/content-modelling-collections/
5646
5740
  schema: {
5647
5741
  collections: ${generateCollectionString(args)},
5648
5742
  },
@@ -5652,11 +5746,10 @@ import { LocalAuthProvider } from "tinacms";`;
5652
5746
 
5653
5747
  // src/cmds/init/templates/database.ts
5654
5748
  var databaseTemplate = ({ config: config2 }) => {
5655
- var _a, _b, _c, _d;
5656
5749
  return `
5657
5750
  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)}
5751
+ ${makeImportString(config2.gitProvider?.imports)}
5752
+ ${makeImportString(config2.databaseAdapter?.imports)}
5660
5753
 
5661
5754
  const branch = (process.env.GITHUB_BRANCH ||
5662
5755
  process.env.VERCEL_GIT_COMMIT_REF ||
@@ -5668,8 +5761,8 @@ const isLocal = process.env.${config2.isLocalEnvVarName} === 'true'
5668
5761
  export default isLocal
5669
5762
  ? createLocalDatabase()
5670
5763
  : createDatabase({
5671
- gitProvider: ${(_c = config2.gitProvider) == null ? void 0 : _c.gitProviderClassText},
5672
- databaseAdapter: ${(_d = config2.databaseAdapter) == null ? void 0 : _d.databaseAdapterClassText},
5764
+ gitProvider: ${config2.gitProvider?.gitProviderClassText},
5765
+ databaseAdapter: ${config2.databaseAdapter?.databaseAdapterClassText},
5673
5766
  namespace: branch,
5674
5767
  })
5675
5768
  `;
@@ -5680,10 +5773,9 @@ var nextApiRouteTemplate = ({
5680
5773
  config: config2,
5681
5774
  env
5682
5775
  }) => {
5683
- var _a, _b;
5684
5776
  const extraPath = env.usingSrc ? "../" : "";
5685
5777
  return `import { TinaNodeBackend, LocalBackendAuthProvider } from '@tinacms/datalayer'
5686
- ${makeImportString((_a = config2.authProvider) == null ? void 0 : _a.backendAuthProviderImports)}
5778
+ ${makeImportString(config2.authProvider?.backendAuthProviderImports)}
5687
5779
 
5688
5780
 
5689
5781
 
@@ -5694,7 +5786,7 @@ var nextApiRouteTemplate = ({
5694
5786
  const handler = TinaNodeBackend({
5695
5787
  authProvider: isLocal
5696
5788
  ? LocalBackendAuthProvider()
5697
- : ${((_b = config2.authProvider) == null ? void 0 : _b.backendAuthProvider) || ""},
5789
+ : ${config2.authProvider?.backendAuthProvider || ""},
5698
5790
  databaseClient,
5699
5791
  })
5700
5792
 
@@ -5717,62 +5809,61 @@ Suspendisse facilisis, mi ac scelerisque interdum, ligula ex imperdiet felis, a
5717
5809
  `;
5718
5810
 
5719
5811
  // src/cmds/init/apply.ts
5720
- var import_prettier2 = require("prettier");
5812
+ import { format as format2 } from "prettier";
5721
5813
 
5722
5814
  // src/utils/script-helpers.ts
5723
5815
  function generateGqlScript(scriptValue, opts) {
5724
5816
  const cmd = `tinacms dev -c "${scriptValue}"`;
5725
- if (opts == null ? void 0 : opts.isLocalEnvVarName) {
5817
+ if (opts?.isLocalEnvVarName) {
5726
5818
  return `${opts.isLocalEnvVarName}=true ${cmd}`;
5727
5819
  }
5728
5820
  return cmd;
5729
5821
  }
5730
5822
  function extendNextScripts(scripts, opts) {
5731
- var _a, _b;
5732
5823
  const result = {
5733
5824
  ...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
5825
+ dev: !scripts?.dev || scripts?.dev?.indexOf("tinacms dev -c") === -1 ? generateGqlScript(scripts?.dev || "next dev", opts) : scripts?.dev,
5826
+ build: !scripts?.build || !scripts?.build?.startsWith("tinacms build &&") ? `tinacms build && ${scripts?.build || "next build"}` : scripts?.build
5736
5827
  };
5737
- if ((opts == null ? void 0 : opts.addSetupUsers) && !scripts["setup:users"]) {
5828
+ if (opts?.addSetupUsers && !scripts["setup:users"]) {
5738
5829
  result["setup:users"] = "tinacms-next-auth setup";
5739
5830
  }
5740
5831
  return result;
5741
5832
  }
5742
5833
 
5743
5834
  // src/cmds/init/codegen/index.ts
5744
- var import_typescript3 = __toESM(require("typescript"));
5745
- var import_fs_extra12 = __toESM(require("fs-extra"));
5835
+ import ts2 from "typescript";
5836
+ import fs13 from "fs-extra";
5746
5837
 
5747
5838
  // src/cmds/init/codegen/util.ts
5748
- var import_typescript2 = __toESM(require("typescript"));
5749
- var makeTransformer = (makeVisitor) => (ctx) => (node) => import_typescript2.default.visitNode(node, makeVisitor(ctx));
5839
+ import ts from "typescript";
5840
+ var makeTransformer = (makeVisitor) => (ctx) => (node) => ts.visitNode(node, makeVisitor(ctx));
5750
5841
  function parseExpression(expression) {
5751
- const sourceFile = import_typescript2.default.createSourceFile(
5842
+ const sourceFile = ts.createSourceFile(
5752
5843
  "temp.ts",
5753
5844
  expression,
5754
- import_typescript2.default.ScriptTarget.Latest
5845
+ ts.ScriptTarget.Latest
5755
5846
  );
5756
5847
  if (sourceFile.statements.length !== 1) {
5757
5848
  throw new Error("Expected one statement");
5758
5849
  }
5759
5850
  const statement = sourceFile.statements[0];
5760
- if (!import_typescript2.default.isExpressionStatement(statement)) {
5851
+ if (!ts.isExpressionStatement(statement)) {
5761
5852
  throw new Error("Expected an expression statement");
5762
5853
  }
5763
5854
  return [sourceFile, statement.expression];
5764
5855
  }
5765
5856
  function parseVariableStatement(stmt) {
5766
- const sourceFile = import_typescript2.default.createSourceFile(
5857
+ const sourceFile = ts.createSourceFile(
5767
5858
  "temp.ts",
5768
5859
  stmt,
5769
- import_typescript2.default.ScriptTarget.Latest
5860
+ ts.ScriptTarget.Latest
5770
5861
  );
5771
5862
  if (sourceFile.statements.length !== 1) {
5772
5863
  throw new Error("Expected one statement");
5773
5864
  }
5774
5865
  const statement = sourceFile.statements[0];
5775
- if (!import_typescript2.default.isVariableStatement(statement)) {
5866
+ if (!ts.isVariableStatement(statement)) {
5776
5867
  throw new Error("Expected a variable statement");
5777
5868
  }
5778
5869
  return [sourceFile, statement];
@@ -5780,7 +5871,7 @@ function parseVariableStatement(stmt) {
5780
5871
 
5781
5872
  // src/cmds/init/codegen/index.ts
5782
5873
  var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variableStmt) => (ctx) => (node) => {
5783
- if (import_typescript3.default.isSourceFile(node)) {
5874
+ if (ts2.isSourceFile(node)) {
5784
5875
  const newStatements = [...node.statements];
5785
5876
  let encounteredImports = false;
5786
5877
  let firstNonImportStatementIdx = -1;
@@ -5788,7 +5879,7 @@ var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variable
5788
5879
  const [newVarDec] = variableStmt.declarationList.declarations;
5789
5880
  const newVarDecName = newVarDec.name.getText(variableStmtSourceFile);
5790
5881
  for (let i = 0; i < newStatements.length; i++) {
5791
- const isImport = import_typescript3.default.isImportDeclaration(newStatements[i]);
5882
+ const isImport = ts2.isImportDeclaration(newStatements[i]);
5792
5883
  if (isImport && !encounteredImports) {
5793
5884
  encounteredImports = true;
5794
5885
  }
@@ -5796,9 +5887,9 @@ var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variable
5796
5887
  firstNonImportStatementIdx = i;
5797
5888
  }
5798
5889
  const stmt = newStatements[i];
5799
- if (import_typescript3.default.isVariableStatement(stmt)) {
5890
+ if (ts2.isVariableStatement(stmt)) {
5800
5891
  const [dec] = stmt.declarationList.declarations;
5801
- if (dec.name && import_typescript3.default.isIdentifier(dec.name) && dec.name.getText(sourceFile) === newVarDecName) {
5892
+ if (dec.name && ts2.isIdentifier(dec.name) && dec.name.getText(sourceFile) === newVarDecName) {
5802
5893
  existingStatementIdx = i;
5803
5894
  }
5804
5895
  }
@@ -5812,20 +5903,19 @@ var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variable
5812
5903
  if (existingStatementIdx === -1) {
5813
5904
  newStatements.splice(firstNonImportStatementIdx, 0, variableStmt);
5814
5905
  }
5815
- return import_typescript3.default.factory.updateSourceFile(node, newStatements);
5906
+ return ts2.factory.updateSourceFile(node, newStatements);
5816
5907
  }
5817
5908
  };
5818
5909
  var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
5819
- var _a;
5820
- if (import_typescript3.default.isSourceFile(node)) {
5910
+ if (ts2.isSourceFile(node)) {
5821
5911
  const newStatements = [...node.statements];
5822
5912
  let changed = false;
5823
5913
  for (const [moduleName, imports] of Object.entries(importMap)) {
5824
5914
  let foundImportStatement = false;
5825
5915
  for (const statement of newStatements) {
5826
- if (import_typescript3.default.isImportDeclaration(statement) && import_typescript3.default.isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === moduleName) {
5916
+ if (ts2.isImportDeclaration(statement) && ts2.isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === moduleName) {
5827
5917
  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(
5918
+ const existingImports = statement.importClause?.namedBindings && ts2.isNamedImports(statement.importClause.namedBindings) ? statement.importClause.namedBindings.elements.map(
5829
5919
  (e) => e.name.text
5830
5920
  ) : [];
5831
5921
  const newImports = [
@@ -5836,22 +5926,22 @@ var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
5836
5926
  ])
5837
5927
  ];
5838
5928
  const importSpecifiers = newImports.map(
5839
- (i) => import_typescript3.default.factory.createImportSpecifier(
5929
+ (i) => ts2.factory.createImportSpecifier(
5840
5930
  void 0,
5841
- import_typescript3.default.factory.createIdentifier(i),
5842
- import_typescript3.default.factory.createIdentifier(i)
5931
+ ts2.factory.createIdentifier(i),
5932
+ ts2.factory.createIdentifier(i)
5843
5933
  )
5844
5934
  );
5845
- const namedImports = import_typescript3.default.factory.createNamedImports(importSpecifiers);
5846
- const importClause = import_typescript3.default.factory.createImportClause(
5935
+ const namedImports = ts2.factory.createNamedImports(importSpecifiers);
5936
+ const importClause = ts2.factory.createImportClause(
5847
5937
  false,
5848
5938
  void 0,
5849
5939
  namedImports
5850
5940
  );
5851
- const importDec = import_typescript3.default.factory.createImportDeclaration(
5941
+ const importDec = ts2.factory.createImportDeclaration(
5852
5942
  void 0,
5853
5943
  importClause,
5854
- import_typescript3.default.factory.createStringLiteral(moduleName)
5944
+ ts2.factory.createStringLiteral(moduleName)
5855
5945
  );
5856
5946
  newStatements[newStatements.indexOf(statement)] = importDec;
5857
5947
  changed = true;
@@ -5859,45 +5949,45 @@ var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
5859
5949
  }
5860
5950
  if (!foundImportStatement) {
5861
5951
  const importSpecifiers = imports.map(
5862
- (i) => import_typescript3.default.factory.createImportSpecifier(
5952
+ (i) => ts2.factory.createImportSpecifier(
5863
5953
  void 0,
5864
- import_typescript3.default.factory.createIdentifier(i),
5865
- import_typescript3.default.factory.createIdentifier(i)
5954
+ ts2.factory.createIdentifier(i),
5955
+ ts2.factory.createIdentifier(i)
5866
5956
  )
5867
5957
  );
5868
- const namedImports = import_typescript3.default.factory.createNamedImports(importSpecifiers);
5869
- const importClause = import_typescript3.default.factory.createImportClause(
5958
+ const namedImports = ts2.factory.createNamedImports(importSpecifiers);
5959
+ const importClause = ts2.factory.createImportClause(
5870
5960
  false,
5871
5961
  void 0,
5872
5962
  namedImports
5873
5963
  );
5874
- const importDec = import_typescript3.default.factory.createImportDeclaration(
5964
+ const importDec = ts2.factory.createImportDeclaration(
5875
5965
  void 0,
5876
5966
  importClause,
5877
- import_typescript3.default.factory.createStringLiteral(moduleName)
5967
+ ts2.factory.createStringLiteral(moduleName)
5878
5968
  );
5879
5969
  newStatements.unshift(importDec);
5880
5970
  changed = true;
5881
5971
  }
5882
5972
  }
5883
5973
  if (changed) {
5884
- return import_typescript3.default.factory.updateSourceFile(node, newStatements);
5974
+ return ts2.factory.updateSourceFile(node, newStatements);
5885
5975
  }
5886
5976
  }
5887
5977
  };
5888
5978
  var makeAddExpressionToSchemaCollectionVisitor = (sourceFile, functionName, newExpressionSourceFile, newExpression) => (ctx) => {
5889
5979
  const visit2 = (node) => {
5890
- if (import_typescript3.default.isCallExpression(node) && import_typescript3.default.isIdentifier(node.expression) && node.expression.text === functionName && node.arguments.length > 0 && import_typescript3.default.isObjectLiteralExpression(node.arguments[0])) {
5980
+ if (ts2.isCallExpression(node) && ts2.isIdentifier(node.expression) && node.expression.text === functionName && node.arguments.length > 0 && ts2.isObjectLiteralExpression(node.arguments[0])) {
5891
5981
  const configObject = node.arguments[0];
5892
5982
  const updateProperties = configObject.properties.map((property) => {
5893
- if (import_typescript3.default.isPropertyAssignment(property)) {
5983
+ if (ts2.isPropertyAssignment(property)) {
5894
5984
  const thisPropertyName = property.name.getText(sourceFile);
5895
- if (thisPropertyName === "schema" && import_typescript3.default.isPropertyAssignment(property) && import_typescript3.default.isObjectLiteralExpression(property.initializer)) {
5985
+ if (thisPropertyName === "schema" && ts2.isPropertyAssignment(property) && ts2.isObjectLiteralExpression(property.initializer)) {
5896
5986
  const schemaObject = property.initializer;
5897
5987
  const collectionsProperty = schemaObject.properties.find(
5898
- (p) => import_typescript3.default.isPropertyAssignment(p) && p.name.getText(sourceFile) === "collections"
5988
+ (p) => ts2.isPropertyAssignment(p) && p.name.getText(sourceFile) === "collections"
5899
5989
  );
5900
- if (collectionsProperty && import_typescript3.default.isPropertyAssignment(collectionsProperty) && import_typescript3.default.isArrayLiteralExpression(collectionsProperty.initializer)) {
5990
+ if (collectionsProperty && ts2.isPropertyAssignment(collectionsProperty) && ts2.isArrayLiteralExpression(collectionsProperty.initializer)) {
5901
5991
  const collectionsArray = collectionsProperty.initializer;
5902
5992
  const collectionItems = collectionsArray.elements.map(
5903
5993
  (e) => e.getText(sourceFile)
@@ -5907,16 +5997,16 @@ var makeAddExpressionToSchemaCollectionVisitor = (sourceFile, functionName, newE
5907
5997
  )) {
5908
5998
  return property;
5909
5999
  }
5910
- return import_typescript3.default.factory.updatePropertyAssignment(
6000
+ return ts2.factory.updatePropertyAssignment(
5911
6001
  property,
5912
6002
  property.name,
5913
- import_typescript3.default.factory.createObjectLiteralExpression(
6003
+ ts2.factory.createObjectLiteralExpression(
5914
6004
  schemaObject.properties.map((subProp) => {
5915
- if (import_typescript3.default.isPropertyAssignment(subProp) && subProp.name.getText(sourceFile) === "collections" && import_typescript3.default.isArrayLiteralExpression(subProp.initializer)) {
5916
- return import_typescript3.default.factory.updatePropertyAssignment(
6005
+ if (ts2.isPropertyAssignment(subProp) && subProp.name.getText(sourceFile) === "collections" && ts2.isArrayLiteralExpression(subProp.initializer)) {
6006
+ return ts2.factory.updatePropertyAssignment(
5917
6007
  subProp,
5918
6008
  subProp.name,
5919
- import_typescript3.default.factory.createArrayLiteralExpression(
6009
+ ts2.factory.createArrayLiteralExpression(
5920
6010
  [newExpression, ...subProp.initializer.elements],
5921
6011
  true
5922
6012
  )
@@ -5932,56 +6022,56 @@ var makeAddExpressionToSchemaCollectionVisitor = (sourceFile, functionName, newE
5932
6022
  }
5933
6023
  return property;
5934
6024
  });
5935
- return import_typescript3.default.factory.createCallExpression(
6025
+ return ts2.factory.createCallExpression(
5936
6026
  node.expression,
5937
6027
  node.typeArguments,
5938
- [import_typescript3.default.factory.createObjectLiteralExpression(updateProperties, true)]
6028
+ [ts2.factory.createObjectLiteralExpression(updateProperties, true)]
5939
6029
  );
5940
6030
  }
5941
- return import_typescript3.default.visitEachChild(node, visit2, ctx);
6031
+ return ts2.visitEachChild(node, visit2, ctx);
5942
6032
  };
5943
6033
  return (sourceFile2) => {
5944
- return import_typescript3.default.visitEachChild(sourceFile2, visit2, ctx);
6034
+ return ts2.visitEachChild(sourceFile2, visit2, ctx);
5945
6035
  };
5946
6036
  };
5947
6037
  var makeUpdateObjectLiteralPropertyVisitor = (sourceFile, functionName, propertyName, propertyValueExpressionSourceFile, propertyValue) => (ctx) => {
5948
6038
  const visitor = (node) => {
5949
- if (import_typescript3.default.isCallExpression(node) && import_typescript3.default.isIdentifier(node.expression) && node.expression.text === functionName && node.arguments.length > 0 && import_typescript3.default.isObjectLiteralExpression(node.arguments[0])) {
6039
+ if (ts2.isCallExpression(node) && ts2.isIdentifier(node.expression) && node.expression.text === functionName && node.arguments.length > 0 && ts2.isObjectLiteralExpression(node.arguments[0])) {
5950
6040
  let foundProperty = false;
5951
6041
  const configObject = node.arguments[0];
5952
6042
  const updateProperties = configObject.properties.map((property) => {
5953
- if (import_typescript3.default.isPropertyAssignment(property) || import_typescript3.default.isShorthandPropertyAssignment(property)) {
6043
+ if (ts2.isPropertyAssignment(property) || ts2.isShorthandPropertyAssignment(property)) {
5954
6044
  const name2 = property.name.getText(sourceFile);
5955
6045
  if (name2 === propertyName) {
5956
6046
  foundProperty = true;
5957
- return import_typescript3.default.factory.createPropertyAssignment(name2, propertyValue);
6047
+ return ts2.factory.createPropertyAssignment(name2, propertyValue);
5958
6048
  }
5959
6049
  }
5960
6050
  return property;
5961
6051
  });
5962
6052
  if (!foundProperty) {
5963
6053
  updateProperties.unshift(
5964
- import_typescript3.default.factory.createPropertyAssignment(propertyName, propertyValue)
6054
+ ts2.factory.createPropertyAssignment(propertyName, propertyValue)
5965
6055
  );
5966
6056
  }
5967
- return import_typescript3.default.factory.createCallExpression(
6057
+ return ts2.factory.createCallExpression(
5968
6058
  node.expression,
5969
6059
  node.typeArguments,
5970
- [import_typescript3.default.factory.createObjectLiteralExpression(updateProperties, true)]
6060
+ [ts2.factory.createObjectLiteralExpression(updateProperties, true)]
5971
6061
  );
5972
6062
  }
5973
- return import_typescript3.default.visitEachChild(node, visitor, ctx);
6063
+ return ts2.visitEachChild(node, visitor, ctx);
5974
6064
  };
5975
6065
  return (sourceFile2) => {
5976
- return import_typescript3.default.visitNode(sourceFile2, visitor);
6066
+ return ts2.visitNode(sourceFile2, visitor);
5977
6067
  };
5978
6068
  };
5979
6069
  var addSelfHostedTinaAuthToConfig = async (config2, configFile) => {
5980
6070
  const pathToConfig = configFile.resolve(config2.typescript).path;
5981
- const sourceFile = import_typescript3.default.createSourceFile(
6071
+ const sourceFile = ts2.createSourceFile(
5982
6072
  pathToConfig,
5983
- import_fs_extra12.default.readFileSync(pathToConfig, "utf8"),
5984
- config2.typescript ? import_typescript3.default.ScriptTarget.Latest : import_typescript3.default.ScriptTarget.ESNext
6073
+ fs13.readFileSync(pathToConfig, "utf8"),
6074
+ config2.typescript ? ts2.ScriptTarget.Latest : ts2.ScriptTarget.ESNext
5985
6075
  );
5986
6076
  const { configImports, configAuthProviderClass, extraTinaCollections } = config2.authProvider;
5987
6077
  const importMap = {
@@ -5994,7 +6084,7 @@ var addSelfHostedTinaAuthToConfig = async (config2, configFile) => {
5994
6084
  {}
5995
6085
  )
5996
6086
  };
5997
- const transformedSourceFileResult = import_typescript3.default.transform(
6087
+ const transformedSourceFileResult = ts2.transform(
5998
6088
  sourceFile,
5999
6089
  [
6000
6090
  makeImportsVisitor(sourceFile, {
@@ -6030,9 +6120,9 @@ var addSelfHostedTinaAuthToConfig = async (config2, configFile) => {
6030
6120
  )
6031
6121
  ].map((visitor) => makeTransformer(visitor))
6032
6122
  );
6033
- return import_fs_extra12.default.writeFile(
6123
+ return fs13.writeFile(
6034
6124
  pathToConfig,
6035
- import_typescript3.default.createPrinter({ omitTrailingSemicolon: true }).printFile(transformedSourceFileResult.transformed[0])
6125
+ ts2.createPrinter({ omitTrailingSemicolon: true }).printFile(transformedSourceFileResult.transformed[0])
6036
6126
  );
6037
6127
  };
6038
6128
 
@@ -6042,7 +6132,6 @@ async function apply({
6042
6132
  params,
6043
6133
  config: config2
6044
6134
  }) {
6045
- var _a;
6046
6135
  if (config2.framework.name === "other" && config2.hosting === "self-host") {
6047
6136
  logger.error(
6048
6137
  logText(
@@ -6148,8 +6237,8 @@ async function apply({
6148
6237
  await addConfigFile({
6149
6238
  configArgs: {
6150
6239
  config: config2,
6151
- publicFolder: import_path11.default.join(
6152
- import_path11.default.relative(process.cwd(), pathToForestryConfig),
6240
+ publicFolder: path14.join(
6241
+ path14.relative(process.cwd(), pathToForestryConfig),
6153
6242
  config2.publicFolder
6154
6243
  ),
6155
6244
  collections,
@@ -6168,7 +6257,7 @@ async function apply({
6168
6257
  env.tinaConfigExists && // Are we running tinacms init backend
6169
6258
  params.isBackendInit && // Do the user choose the 'self-host' option
6170
6259
  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"
6260
+ (config2.authProvider?.name || "") !== "tina-cloud"
6172
6261
  ) {
6173
6262
  await addSelfHostedTinaAuthToConfig(config2, env.generatedFiles["config"]);
6174
6263
  }
@@ -6206,7 +6295,7 @@ var reportTelemetry = async ({
6206
6295
  if (noTelemetry) {
6207
6296
  logger.info(logText("Telemetry disabled"));
6208
6297
  }
6209
- const telemetry = new import_metrics2.Telemetry({ disabled: noTelemetry });
6298
+ const telemetry = new Telemetry2({ disabled: noTelemetry });
6210
6299
  const schemaFileType = usingTypescript ? "ts" : "js";
6211
6300
  await telemetry.submitRecord({
6212
6301
  event: {
@@ -6222,21 +6311,20 @@ var createPackageJSON = async () => {
6222
6311
  };
6223
6312
  var createGitignore = async ({ baseDir }) => {
6224
6313
  logger.info(logText("No .gitignore found, creating one"));
6225
- import_fs_extra13.default.outputFileSync(import_path11.default.join(baseDir, ".gitignore"), "node_modules");
6314
+ fs14.outputFileSync(path14.join(baseDir, ".gitignore"), "node_modules");
6226
6315
  };
6227
6316
  var updateGitIgnore = async ({
6228
6317
  baseDir,
6229
6318
  items
6230
6319
  }) => {
6231
6320
  logger.info(logText(`Adding ${items.join(",")} to .gitignore`));
6232
- const gitignoreContent = import_fs_extra13.default.readFileSync(import_path11.default.join(baseDir, ".gitignore")).toString();
6321
+ const gitignoreContent = fs14.readFileSync(path14.join(baseDir, ".gitignore")).toString();
6233
6322
  const newGitignoreContent = [...gitignoreContent.split("\n"), ...items].join(
6234
6323
  "\n"
6235
6324
  );
6236
- await import_fs_extra13.default.writeFile(import_path11.default.join(baseDir, ".gitignore"), newGitignoreContent);
6325
+ await fs14.writeFile(path14.join(baseDir, ".gitignore"), newGitignoreContent);
6237
6326
  };
6238
6327
  var addDependencies = async (config2, env, params) => {
6239
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
6240
6328
  const { packageManager } = config2;
6241
6329
  const tagVersion = params.tinaVersion ? `@${params.tinaVersion}` : "";
6242
6330
  let deps = [];
@@ -6252,18 +6340,18 @@ var addDependencies = async (config2, env, params) => {
6252
6340
  deps.push("@tinacms/datalayer");
6253
6341
  }
6254
6342
  deps.push(
6255
- ...((_b = (_a = config2.databaseAdapter) == null ? void 0 : _a.imports) == null ? void 0 : _b.map((x) => x.packageName)) || []
6343
+ ...config2.databaseAdapter?.imports?.map((x) => x.packageName) || []
6256
6344
  );
6257
- deps.push(...((_c = config2.authProvider) == null ? void 0 : _c.peerDependencies) || []);
6345
+ deps.push(...config2.authProvider?.peerDependencies || []);
6258
6346
  deps.push(
6259
- ...((_e = (_d = config2.authProvider) == null ? void 0 : _d.backendAuthProviderImports) == null ? void 0 : _e.map(
6347
+ ...config2.authProvider?.backendAuthProviderImports?.map(
6260
6348
  (x) => x.packageName
6261
- )) || []
6349
+ ) || []
6262
6350
  );
6263
6351
  deps.push(
6264
- ...((_g = (_f = config2.authProvider) == null ? void 0 : _f.configImports) == null ? void 0 : _g.map((x) => x.packageName)) || []
6352
+ ...config2.authProvider?.configImports?.map((x) => x.packageName) || []
6265
6353
  );
6266
- deps.push(...((_i = (_h = config2.gitProvider) == null ? void 0 : _h.imports) == null ? void 0 : _i.map((x) => x.packageName)) || []);
6354
+ deps.push(...config2.gitProvider?.imports?.map((x) => x.packageName) || []);
6267
6355
  if (tagVersion) {
6268
6356
  deps = deps.map(
6269
6357
  (dep) => dep.indexOf("tina") >= 0 ? `${dep}${tagVersion}` : dep
@@ -6275,7 +6363,8 @@ var addDependencies = async (config2, env, params) => {
6275
6363
  let packageManagers = {
6276
6364
  pnpm: process.env.USE_WORKSPACE ? `pnpm add ${deps.join(" ")} --workspace` : `pnpm add ${deps.join(" ")}`,
6277
6365
  npm: `npm install ${deps.join(" ")}`,
6278
- yarn: `yarn add ${deps.join(" ")}`
6366
+ yarn: `yarn add ${deps.join(" ")}`,
6367
+ bun: `bun add ${deps.join(" ")}`
6279
6368
  };
6280
6369
  if (packageManagers[packageManager] && deps.length > 0) {
6281
6370
  logger.info(logText("Adding dependencies, this might take a moment..."));
@@ -6286,7 +6375,8 @@ var addDependencies = async (config2, env, params) => {
6286
6375
  packageManagers = {
6287
6376
  pnpm: process.env.USE_WORKSPACE ? `pnpm add -D ${devDeps.join(" ")} --workspace` : `pnpm add -D ${devDeps.join(" ")}`,
6288
6377
  npm: `npm install -D ${devDeps.join(" ")}`,
6289
- yarn: `yarn add -D ${devDeps.join(" ")}`
6378
+ yarn: `yarn add -D ${devDeps.join(" ")}`,
6379
+ bun: `bun add -D ${devDeps.join(" ")}`
6290
6380
  };
6291
6381
  if (packageManagers[packageManager]) {
6292
6382
  logger.info(
@@ -6303,22 +6393,22 @@ var writeGeneratedFile = async ({
6303
6393
  content,
6304
6394
  typescript
6305
6395
  }) => {
6306
- const { exists, path: path14, parentPath } = generatedFile.resolve(typescript);
6396
+ const { exists, path: path15, parentPath } = generatedFile.resolve(typescript);
6307
6397
  if (exists) {
6308
6398
  if (overwrite) {
6309
- logger.info(`Overwriting file at ${path14}... \u2705`);
6310
- import_fs_extra13.default.outputFileSync(path14, content);
6399
+ logger.info(`Overwriting file at ${path15}... \u2705`);
6400
+ fs14.outputFileSync(path15, content);
6311
6401
  } else {
6312
- logger.info(`Not overwriting file at ${path14}.`);
6402
+ logger.info(`Not overwriting file at ${path15}.`);
6313
6403
  logger.info(
6314
- logText(`Please add the following to ${path14}:
6404
+ logText(`Please add the following to ${path15}:
6315
6405
  ${indentText(content)}}`)
6316
6406
  );
6317
6407
  }
6318
6408
  } else {
6319
- logger.info(`Adding file at ${path14}... \u2705`);
6320
- await import_fs_extra13.default.ensureDir(parentPath);
6321
- import_fs_extra13.default.outputFileSync(path14, content);
6409
+ logger.info(`Adding file at ${path15}... \u2705`);
6410
+ await fs14.ensureDir(parentPath);
6411
+ fs14.outputFileSync(path15, content);
6322
6412
  }
6323
6413
  };
6324
6414
  var addConfigFile = async ({
@@ -6327,12 +6417,11 @@ var addConfigFile = async ({
6327
6417
  generatedFile,
6328
6418
  config: config2
6329
6419
  }) => {
6330
- var _a;
6331
- const content = (0, import_prettier2.format)(generateConfig(configArgs), {
6420
+ const content = format2(generateConfig(configArgs), {
6332
6421
  parser: "babel"
6333
6422
  });
6334
6423
  await writeGeneratedFile({
6335
- overwrite: (_a = config2.overwriteList) == null ? void 0 : _a.includes("config"),
6424
+ overwrite: config2.overwriteList?.includes("config"),
6336
6425
  generatedFile,
6337
6426
  content,
6338
6427
  typescript: config2.typescript
@@ -6346,10 +6435,9 @@ var addDatabaseFile = async ({
6346
6435
  config: config2,
6347
6436
  generatedFile
6348
6437
  }) => {
6349
- var _a;
6350
6438
  await writeGeneratedFile({
6351
6439
  generatedFile,
6352
- overwrite: (_a = config2.overwriteList) == null ? void 0 : _a.includes("database"),
6440
+ overwrite: config2.overwriteList?.includes("database"),
6353
6441
  content: databaseTemplate({ config: config2 }),
6354
6442
  typescript: config2.typescript
6355
6443
  });
@@ -6359,13 +6447,12 @@ var addNextApiRoute = async ({
6359
6447
  generatedFile,
6360
6448
  env
6361
6449
  }) => {
6362
- var _a;
6363
- const content = (0, import_prettier2.format)(nextApiRouteTemplate({ config: config2, env }), {
6450
+ const content = format2(nextApiRouteTemplate({ config: config2, env }), {
6364
6451
  parser: "babel"
6365
6452
  });
6366
6453
  await writeGeneratedFile({
6367
6454
  generatedFile,
6368
- overwrite: (_a = config2.overwriteList) == null ? void 0 : _a.includes("next-api-handler"),
6455
+ overwrite: config2.overwriteList?.includes("next-api-handler"),
6369
6456
  content,
6370
6457
  typescript: config2.typescript
6371
6458
  });
@@ -6375,10 +6462,9 @@ var addTemplateFile = async ({
6375
6462
  generatedFile,
6376
6463
  config: config2
6377
6464
  }) => {
6378
- var _a;
6379
6465
  await writeGeneratedFile({
6380
6466
  generatedFile,
6381
- overwrite: (_a = config2.overwriteList) == null ? void 0 : _a.includes(generatedFile.generatedFileType),
6467
+ overwrite: config2.overwriteList?.includes(generatedFile.generatedFileType),
6382
6468
  content,
6383
6469
  typescript: config2.typescript
6384
6470
  });
@@ -6387,7 +6473,6 @@ var addContentFile = async ({
6387
6473
  config: config2,
6388
6474
  env
6389
6475
  }) => {
6390
- var _a;
6391
6476
  await writeGeneratedFile({
6392
6477
  generatedFile: {
6393
6478
  javascriptExists: false,
@@ -6401,11 +6486,11 @@ var addContentFile = async ({
6401
6486
  return () => ({
6402
6487
  exists: env.sampleContentExists,
6403
6488
  path: env.sampleContentPath,
6404
- parentPath: import_path11.default.dirname(env.sampleContentPath)
6489
+ parentPath: path14.dirname(env.sampleContentPath)
6405
6490
  });
6406
6491
  }
6407
6492
  },
6408
- overwrite: (_a = config2.overwriteList) == null ? void 0 : _a.includes("sample-content"),
6493
+ overwrite: config2.overwriteList?.includes("sample-content"),
6409
6494
  content: helloWorldPost,
6410
6495
  typescript: false
6411
6496
  });
@@ -6424,10 +6509,10 @@ ${titleText(" TinaCMS ")} backend initialized!`));
6424
6509
  return `${x.key}=${x.value || "***"}`;
6425
6510
  }).join("\n") + `
6426
6511
  TINA_PUBLIC_IS_LOCAL=true`;
6427
- const envFile = import_path11.default.join(process.cwd(), ".env");
6428
- if (!import_fs_extra13.default.existsSync(envFile)) {
6512
+ const envFile = path14.join(process.cwd(), ".env");
6513
+ if (!fs14.existsSync(envFile)) {
6429
6514
  logger.info(`Adding .env file to your project... \u2705`);
6430
- import_fs_extra13.default.writeFileSync(envFile, envFileText);
6515
+ fs14.writeFileSync(envFile, envFileText);
6431
6516
  } else {
6432
6517
  logger.info(
6433
6518
  "Please add the following environment variables to your .env file"
@@ -6470,7 +6555,8 @@ var other = ({ packageManager }) => {
6470
6555
  pnpm: `pnpm`,
6471
6556
  npm: `npx`,
6472
6557
  // npx is the way to run executables that aren't in your "scripts"
6473
- yarn: `yarn`
6558
+ yarn: `yarn`,
6559
+ bun: `bun run`
6474
6560
  };
6475
6561
  return `${packageManagers[packageManager]} tinacms dev -c "<your dev command>"`;
6476
6562
  };
@@ -6483,7 +6569,8 @@ var frameworkDevCmds = {
6483
6569
  pnpm: `pnpm`,
6484
6570
  npm: `npm run`,
6485
6571
  // npx is the way to run executables that aren't in your "scripts"
6486
- yarn: `yarn`
6572
+ yarn: `yarn`,
6573
+ bun: `bun run`
6487
6574
  };
6488
6575
  return `${packageManagers[packageManager]} dev`;
6489
6576
  }
@@ -6496,12 +6583,11 @@ var addReactiveFile = {
6496
6583
  baseDir,
6497
6584
  dataLayer
6498
6585
  }) => {
6499
- var _a, _b;
6500
- const packageJsonPath = import_path11.default.join(baseDir, "package.json");
6586
+ const packageJsonPath = path14.join(baseDir, "package.json");
6501
6587
  await writeGeneratedFile({
6502
6588
  generatedFile,
6503
6589
  typescript: config2.typescript,
6504
- overwrite: (_a = config2.overwriteList) == null ? void 0 : _a.includes(
6590
+ overwrite: config2.overwriteList?.includes(
6505
6591
  generatedFile.generatedFileType
6506
6592
  ),
6507
6593
  content: templates["demo-post-page"]({
@@ -6510,24 +6596,24 @@ var addReactiveFile = {
6510
6596
  })
6511
6597
  });
6512
6598
  logger.info("Adding a nextjs example... \u2705");
6513
- const packageJson = JSON.parse(import_fs_extra13.default.readFileSync(packageJsonPath).toString());
6599
+ const packageJson = JSON.parse(fs14.readFileSync(packageJsonPath).toString());
6514
6600
  const scripts = packageJson.scripts || {};
6515
6601
  const updatedPackageJson = JSON.stringify(
6516
6602
  {
6517
6603
  ...packageJson,
6518
6604
  scripts: extendNextScripts(scripts, {
6519
6605
  isLocalEnvVarName: config2.isLocalEnvVarName,
6520
- addSetupUsers: ((_b = config2.authProvider) == null ? void 0 : _b.name) === "next-auth"
6606
+ addSetupUsers: config2.authProvider?.name === "next-auth"
6521
6607
  })
6522
6608
  },
6523
6609
  null,
6524
6610
  2
6525
6611
  );
6526
- import_fs_extra13.default.writeFileSync(packageJsonPath, updatedPackageJson);
6612
+ fs14.writeFileSync(packageJsonPath, updatedPackageJson);
6527
6613
  }
6528
6614
  };
6529
6615
  function execShellCommand(cmd) {
6530
- const exec = require("child_process").exec;
6616
+ const exec = __require("child_process").exec;
6531
6617
  return new Promise((resolve2, reject) => {
6532
6618
  exec(cmd, (error, stdout, stderr) => {
6533
6619
  if (error) {
@@ -6573,25 +6659,27 @@ var command = new CLICommand({
6573
6659
  });
6574
6660
 
6575
6661
  // src/next/commands/init-command/index.ts
6576
- var InitCommand = class extends import_clipanion6.Command {
6577
- constructor() {
6578
- super(...arguments);
6579
- this.pathToForestryConfig = import_clipanion6.Option.String("--forestryPath", {
6580
- description: "Specify the relative path to the .forestry directory, if importing an existing forestry site."
6581
- });
6582
- this.rootPath = import_clipanion6.Option.String("--rootPath", {
6583
- description: "Specify the root directory to run the CLI from (defaults to current working directory)"
6584
- });
6585
- this.debug = import_clipanion6.Option.Boolean("--debug", false, {
6586
- description: "Enable debug logging"
6587
- });
6588
- this.noTelemetry = import_clipanion6.Option.Boolean("--noTelemetry", false, {
6589
- description: "Disable anonymous telemetry that is collected"
6590
- });
6591
- this.tinaVersion = import_clipanion6.Option.String("--tinaVersion", {
6592
- description: "Specify a version for tina dependencies"
6593
- });
6594
- }
6662
+ var InitCommand = class extends Command6 {
6663
+ static paths = [["init"], ["init", "backend"]];
6664
+ pathToForestryConfig = Option6.String("--forestryPath", {
6665
+ description: "Specify the relative path to the .forestry directory, if importing an existing forestry site."
6666
+ });
6667
+ rootPath = Option6.String("--rootPath", {
6668
+ description: "Specify the root directory to run the CLI from (defaults to current working directory)"
6669
+ });
6670
+ debug = Option6.Boolean("--debug", false, {
6671
+ description: "Enable debug logging"
6672
+ });
6673
+ noTelemetry = Option6.Boolean("--noTelemetry", false, {
6674
+ description: "Disable anonymous telemetry that is collected"
6675
+ });
6676
+ tinaVersion = Option6.String("--tinaVersion", {
6677
+ description: "Specify a version for tina dependencies"
6678
+ });
6679
+ static usage = Command6.Usage({
6680
+ category: `Commands`,
6681
+ description: `Add Tina to an existing project`
6682
+ });
6595
6683
  async catch(error) {
6596
6684
  logger.error("Error occured during tinacms init");
6597
6685
  console.error(error);
@@ -6611,33 +6699,32 @@ var InitCommand = class extends import_clipanion6.Command {
6611
6699
  process.exit();
6612
6700
  }
6613
6701
  };
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
6702
 
6620
6703
  // src/next/commands/searchindex-command/index.ts
6621
- var import_clipanion7 = require("clipanion");
6622
- var import_graphql17 = require("@tinacms/graphql");
6623
- var import_search3 = require("@tinacms/search");
6624
- var SearchIndexCommand = class extends import_clipanion7.Command {
6625
- constructor() {
6626
- super(...arguments);
6627
- this.rootPath = import_clipanion7.Option.String("--rootPath", {
6628
- description: "Specify the root directory to run the CLI from (defaults to current working directory)"
6629
- });
6630
- this.verbose = import_clipanion7.Option.Boolean("-v,--verbose", false, {
6631
- description: "increase verbosity of logged output"
6632
- });
6633
- }
6704
+ import { Command as Command7, Option as Option7 } from "clipanion";
6705
+ import { createSchema, FilesystemBridge as FilesystemBridge4 } from "@tinacms/graphql";
6706
+ import {
6707
+ SearchIndexer as SearchIndexer3,
6708
+ TinaCMSSearchIndexClient as TinaCMSSearchIndexClient2
6709
+ } from "@tinacms/search";
6710
+ var SearchIndexCommand = class extends Command7 {
6711
+ static paths = [["search-index"]];
6712
+ rootPath = Option7.String("--rootPath", {
6713
+ description: "Specify the root directory to run the CLI from (defaults to current working directory)"
6714
+ });
6715
+ verbose = Option7.Boolean("-v,--verbose", false, {
6716
+ description: "increase verbosity of logged output"
6717
+ });
6718
+ static usage = Command7.Usage({
6719
+ category: `Commands`,
6720
+ description: `Index the site for search`
6721
+ });
6634
6722
  async catch(error) {
6635
6723
  logger.error("Error occured during tinacms search-index");
6636
6724
  console.error(error);
6637
6725
  process.exit(1);
6638
6726
  }
6639
6727
  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
6728
  const rootPath = this.rootPath || process.cwd();
6642
6729
  const configManager = new ConfigManager({ rootPath });
6643
6730
  try {
@@ -6648,18 +6735,18 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6648
6735
  console.error(e);
6649
6736
  }
6650
6737
  }
6651
- if (!((_a = configManager.config) == null ? void 0 : _a.search)) {
6738
+ if (!configManager.config?.search) {
6652
6739
  logger.error("No search config found");
6653
6740
  process.exit(1);
6654
6741
  }
6655
6742
  const { schema } = configManager.config;
6656
- const tinaSchema = await (0, import_graphql17.createSchema)({
6743
+ const tinaSchema = await createSchema({
6657
6744
  schema: { ...schema, config: configManager.config }
6658
6745
  });
6659
6746
  let client;
6660
- const hasTinaSearch = Boolean((_c = (_b = configManager.config) == null ? void 0 : _b.search) == null ? void 0 : _c.tina);
6747
+ const hasTinaSearch = Boolean(configManager.config?.search?.tina);
6661
6748
  if (hasTinaSearch) {
6662
- if (!((_d = configManager.config) == null ? void 0 : _d.branch)) {
6749
+ if (!configManager.config?.branch) {
6663
6750
  logger.error(
6664
6751
  `${dangerText(
6665
6752
  `ERROR: Branch not configured in tina search configuration.`
@@ -6667,11 +6754,11 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6667
6754
  );
6668
6755
  throw new Error("Branch not configured in tina search configuration.");
6669
6756
  }
6670
- if (!((_e = configManager.config) == null ? void 0 : _e.clientId)) {
6757
+ if (!configManager.config?.clientId) {
6671
6758
  logger.error(`${dangerText(`ERROR: clientId not configured.`)}`);
6672
6759
  throw new Error("clientId not configured.");
6673
6760
  }
6674
- if (!((_h = (_g = (_f = configManager.config) == null ? void 0 : _f.search) == null ? void 0 : _g.tina) == null ? void 0 : _h.indexerToken)) {
6761
+ if (!configManager.config?.search?.tina?.indexerToken) {
6675
6762
  logger.error(
6676
6763
  `${dangerText(
6677
6764
  `ERROR: indexerToken not configured in tina search configuration.`
@@ -6681,23 +6768,23 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6681
6768
  "indexerToken not configured in tina search configuration."
6682
6769
  );
6683
6770
  }
6684
- 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
6771
+ client = new TinaCMSSearchIndexClient2({
6772
+ apiUrl: `${configManager.config.tinaioConfig?.contentApiUrlOverride || "https://content.tinajs.io"}/searchIndex/${configManager.config?.clientId}`,
6773
+ branch: configManager.config?.branch,
6774
+ indexerToken: configManager.config?.search?.tina?.indexerToken,
6775
+ stopwordLanguages: configManager.config?.search?.tina?.stopwordLanguages
6689
6776
  });
6690
6777
  } else {
6691
- client = (_s = (_r = configManager.config) == null ? void 0 : _r.search) == null ? void 0 : _s.searchClient;
6778
+ client = configManager.config?.search?.searchClient;
6692
6779
  }
6693
- const searchIndexer = new import_search3.SearchIndexer({
6694
- batchSize: ((_t = configManager.config.search) == null ? void 0 : _t.indexBatchSize) || 100,
6695
- bridge: new import_graphql17.FilesystemBridge(
6780
+ const searchIndexer = new SearchIndexer3({
6781
+ batchSize: configManager.config.search?.indexBatchSize || 100,
6782
+ bridge: new FilesystemBridge4(
6696
6783
  configManager.rootPath,
6697
6784
  configManager.contentRootPath
6698
6785
  ),
6699
6786
  schema: tinaSchema,
6700
- textIndexLength: ((_u = configManager.config.search) == null ? void 0 : _u.maxSearchIndexFieldLength) || 100,
6787
+ textIndexLength: configManager.config.search?.maxSearchIndexFieldLength || 100,
6701
6788
  client
6702
6789
  });
6703
6790
  let err;
@@ -6718,14 +6805,9 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6718
6805
  process.exit(0);
6719
6806
  }
6720
6807
  };
6721
- SearchIndexCommand.paths = [["search-index"]];
6722
- SearchIndexCommand.usage = import_clipanion7.Command.Usage({
6723
- category: `Commands`,
6724
- description: `Index the site for search`
6725
- });
6726
6808
 
6727
6809
  // src/index.ts
6728
- var cli = new import_clipanion8.Cli({
6810
+ var cli = new Cli({
6729
6811
  binaryName: `tinacms`,
6730
6812
  binaryLabel: `TinaCMS`,
6731
6813
  binaryVersion: version
@@ -6736,7 +6818,10 @@ cli.register(AuditCommand);
6736
6818
  cli.register(InitCommand);
6737
6819
  cli.register(CodemodCommand);
6738
6820
  cli.register(SearchIndexCommand);
6739
- cli.register(import_clipanion8.Builtins.DefinitionsCommand);
6740
- cli.register(import_clipanion8.Builtins.HelpCommand);
6741
- cli.register(import_clipanion8.Builtins.VersionCommand);
6821
+ cli.register(Builtins.DefinitionsCommand);
6822
+ cli.register(Builtins.HelpCommand);
6823
+ cli.register(Builtins.VersionCommand);
6742
6824
  var index_default = cli;
6825
+ export {
6826
+ index_default as default
6827
+ };