@tinacms/cli 0.0.0-af4eb2c-20250514032536 → 0.0.0-b1a78a1-20251210055020

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,20 @@
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);
28
-
29
1
  // 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");
2
+ import { Cli, Builtins } from "clipanion";
36
3
 
37
4
  // package.json
38
- var version = "1.9.7";
5
+ var version = "2.0.2";
39
6
 
40
7
  // 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"));
8
+ import path8 from "path";
9
+ import { FilesystemBridge as FilesystemBridge2, buildSchema } from "@tinacms/graphql";
10
+ import { LocalSearchIndexClient, SearchIndexer } from "@tinacms/search";
11
+ import AsyncLock from "async-lock";
12
+ import chokidar from "chokidar";
13
+ import { Command as Command2, Option as Option2 } from "clipanion";
14
+ import fs7 from "fs-extra";
48
15
 
49
16
  // src/logger/index.ts
50
- var import_chalk = __toESM(require("chalk"));
17
+ import chalk from "chalk";
51
18
 
52
19
  // src/logger/is-unicode-supported.ts
53
20
  function isUnicodeSupported() {
@@ -61,15 +28,15 @@ function isUnicodeSupported() {
61
28
  }
62
29
 
63
30
  // src/logger/index.ts
64
- var import_log4js = __toESM(require("log4js"));
65
- var logger = import_log4js.default.getLogger();
66
- import_log4js.default.configure({
67
- appenders: {
68
- out: { type: "stdout", layout: { type: "messagePassThrough" } }
69
- },
70
- categories: { default: { appenders: ["out"], level: "info" } }
71
- });
72
- logger.level = "info";
31
+ var logger = {
32
+ level: "info",
33
+ info: (msg) => process.stdout.write(msg + "\n"),
34
+ warn: (msg) => process.stdout.write(msg + "\n"),
35
+ error: (msg) => process.stderr.write(msg + "\n"),
36
+ debug: (msg) => {
37
+ if (logger.level === "debug") process.stdout.write(msg + "\n");
38
+ }
39
+ };
73
40
  function ansiRegex() {
74
41
  const pattern = [
75
42
  "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
@@ -88,18 +55,18 @@ ${message}
88
55
  return ln.length > sum ? ln.length : sum;
89
56
  }, 0) + 2;
90
57
  const msg = lines.map(
91
- (ln) => `${import_chalk.default.gray(bar)} ${import_chalk.default.white(ln)}${" ".repeat(
58
+ (ln) => `${chalk.gray(bar)} ${chalk.white(ln)}${" ".repeat(
92
59
  len - strip(ln).length
93
- )}${import_chalk.default.gray(bar)}`
60
+ )}${chalk.gray(bar)}`
94
61
  ).join("\n");
95
62
  const underscoreLen = len - title.length - 1 > 0 ? len - title.length - 1 : 0;
96
63
  process.stdout.write(
97
- `${import_chalk.default.gray(bar)}
98
- ${import_chalk.default.green("\u25CB")} ${import_chalk.default.reset(
64
+ `${chalk.gray(bar)}
65
+ ${chalk.green("\u25CB")} ${chalk.reset(
99
66
  title
100
- )} ${import_chalk.default.gray("\u2500".repeat(underscoreLen) + "\u256E")}
67
+ )} ${chalk.gray("\u2500".repeat(underscoreLen) + "\u256E")}
101
68
  ${msg}
102
- ${import_chalk.default.gray(
69
+ ${chalk.gray(
103
70
  "\u251C" + "\u2500".repeat(len + 2) + "\u256F"
104
71
  )}
105
72
  `
@@ -116,11 +83,11 @@ var summary = (content) => {
116
83
  });
117
84
  });
118
85
  content.items.forEach((item) => {
119
- outString.push(`${item.emoji} ${import_chalk.default.cyan(item.heading)}`);
86
+ outString.push(`${item.emoji} ${chalk.cyan(item.heading)}`);
120
87
  item.subItems.forEach((subItem) => {
121
88
  const spaces = longestKey - subItem.key.length + 4;
122
89
  outString.push(
123
- ` ${subItem.key}:${[...Array(spaces)].join(" ")}${import_chalk.default.cyan(
90
+ ` ${subItem.key}:${[...Array(spaces)].join(" ")}${chalk.cyan(
124
91
  subItem.value
125
92
  )}`
126
93
  );
@@ -158,12 +125,12 @@ var S_WARN = s("\u25B2", "!");
158
125
  var S_ERROR = s("\u25A0", "x");
159
126
 
160
127
  // src/utils/spinner.ts
161
- var import_cli_spinner = require("cli-spinner");
128
+ import { Spinner } from "cli-spinner";
162
129
  async function localSpin({
163
130
  waitFor,
164
131
  text
165
132
  }) {
166
- const spinner = new import_cli_spinner.Spinner({
133
+ const spinner = new Spinner({
167
134
  text: `${text} %s`,
168
135
  stream: process.stderr,
169
136
  onTick: function(msg) {
@@ -194,32 +161,32 @@ function spin({
194
161
  }
195
162
 
196
163
  // 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;
164
+ import chalk2 from "chalk";
165
+ var successText = chalk2.bold.green;
166
+ var focusText = chalk2.bold;
167
+ var dangerText = chalk2.bold.red;
168
+ var neutralText = chalk2.bold.cyan;
169
+ var linkText = chalk2.bold.cyan;
170
+ var labelText = chalk2.bold;
171
+ var cmdText = chalk2.inverse;
205
172
  var indentedCmd = (str) => {
206
173
  return ` \u2503 ` + str;
207
174
  };
208
175
  var indentText = (str) => {
209
176
  return String(str).split("\n").map((line) => ` ${line}`).join("\n");
210
177
  };
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");
178
+ var logText = chalk2.italic.gray;
179
+ var warnText = chalk2.yellowBright.bgBlack;
180
+ var titleText = chalk2.bgHex("d2f1f8").hex("ec4816");
181
+ var CONFIRMATION_TEXT = chalk2.dim("enter to confirm");
215
182
 
216
183
  // 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");
184
+ import fs from "fs-extra";
185
+ import path from "path";
186
+ import { buildASTSchema, printSchema as printSchema2 } from "graphql";
220
187
 
221
188
  // src/next/codegen/codegen/index.ts
222
- var import_graphql4 = require("graphql");
189
+ import { parse, printSchema } from "graphql";
223
190
 
224
191
  // src/next/codegen/codegen/plugin.ts
225
192
  var AddGeneratedClientFunc = (apiURL) => {
@@ -288,37 +255,44 @@ var AddGeneratedClient = (apiURL) => ({
288
255
  });
289
256
 
290
257
  // 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");
258
+ import { GraphQLFileLoader } from "@graphql-tools/graphql-file-loader";
259
+ import { codegen } from "@graphql-codegen/core";
260
+ import { loadDocuments } from "@graphql-tools/load";
261
+ import { plugin as typescriptOperationsPlugin } from "@graphql-codegen/typescript-operations";
262
+ import { plugin as typescriptPlugin } from "@graphql-codegen/typescript";
296
263
 
297
264
  // src/next/codegen/codegen/sdkPlugin/index.ts
298
- var import_graphql2 = require("graphql");
299
- var import_graphql3 = require("graphql");
265
+ import { visit } from "graphql";
266
+ import {
267
+ concatAST,
268
+ Kind as Kind2
269
+ } from "graphql";
300
270
 
301
271
  // 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 {
272
+ import {
273
+ ClientSideBaseVisitor,
274
+ DocumentMode,
275
+ indentMultiline
276
+ } from "@graphql-codegen/visitor-plugin-common";
277
+ import autoBind from "auto-bind";
278
+ import { Kind, print } from "graphql";
279
+ var GenericSdkVisitor = class extends ClientSideBaseVisitor {
280
+ _operationsToInclude = [];
306
281
  constructor(schema, fragments, rawConfig) {
307
282
  super(schema, fragments, rawConfig, {
308
283
  usingObservableFrom: rawConfig.usingObservableFrom
309
284
  });
310
- this._operationsToInclude = [];
311
- (0, import_auto_bind.default)(this);
285
+ autoBind(this);
312
286
  if (this.config.usingObservableFrom) {
313
287
  this._additionalImports.push(this.config.usingObservableFrom);
314
288
  }
315
- if (this.config.documentMode !== import_visitor_plugin_common.DocumentMode.string) {
289
+ if (this.config.documentMode !== DocumentMode.string) {
316
290
  }
317
291
  }
318
292
  buildOperation(node, documentVariableName, operationType, operationResultType, operationVariablesTypes) {
319
293
  if (node.name == null) {
320
294
  throw new Error(
321
- "Plugin 'generic-sdk' cannot generate SDK for unnamed operation.\n\n" + (0, import_graphql.print)(node)
295
+ "Plugin 'generic-sdk' cannot generate SDK for unnamed operation.\n\n" + print(node)
322
296
  );
323
297
  } else {
324
298
  this._operationsToInclude.push({
@@ -336,14 +310,14 @@ var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBas
336
310
  const usingObservable = !!this.config.usingObservableFrom;
337
311
  const allPossibleActions = this._operationsToInclude.map((o) => {
338
312
  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
313
+ (v) => v.type.kind !== Kind.NON_NULL_TYPE || v.defaultValue
340
314
  );
341
315
  const returnType = usingObservable && o.operationType === "Subscription" ? "Observable" : "Promise";
342
316
  return `${o.node.name.value}(variables${optionalVariables ? "?" : ""}: ${o.operationVariablesTypes}, options?: C): ${returnType}<${o.operationResultType}> {
343
317
  return requester<${o.operationResultType}, ${o.operationVariablesTypes}>(${o.documentVariableName}, variables, options);
344
318
  }`;
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>"}
319
+ }).map((s2) => indentMultiline(s2, 2));
320
+ 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
321
  export function getSdk<C>(requester: Requester<C>) {
348
322
  return {
349
323
  ${allPossibleActions.join(",\n")}
@@ -355,14 +329,14 @@ var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBas
355
329
 
356
330
  // src/next/codegen/codegen/sdkPlugin/index.ts
357
331
  var plugin = (schema, documents, config2) => {
358
- const allAst = (0, import_graphql3.concatAST)(
332
+ const allAst = concatAST(
359
333
  documents.reduce((prev, v) => {
360
334
  return [...prev, v.document];
361
335
  }, [])
362
336
  );
363
337
  const allFragments = [
364
338
  ...allAst.definitions.filter(
365
- (d) => d.kind === import_graphql3.Kind.FRAGMENT_DEFINITION
339
+ (d) => d.kind === Kind2.FRAGMENT_DEFINITION
366
340
  ).map((fragmentDef) => ({
367
341
  node: fragmentDef,
368
342
  name: fragmentDef.name.value,
@@ -372,7 +346,7 @@ var plugin = (schema, documents, config2) => {
372
346
  ...config2.externalFragments || []
373
347
  ];
374
348
  const visitor = new GenericSdkVisitor(schema, allFragments, config2);
375
- const visitorResult = (0, import_graphql2.visit)(allAst, { leave: visitor });
349
+ const visitorResult = visit(allAst, { leave: visitor });
376
350
  return {
377
351
  // We will take care of imports
378
352
  // prepend: visitor.getImports(),
@@ -390,10 +364,10 @@ var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath =
390
364
  let fragDocs = [];
391
365
  docs = await loadGraphQLDocuments(queryPathGlob);
392
366
  fragDocs = await loadGraphQLDocuments(fragDocPath);
393
- const res = await (0, import_core.codegen)({
367
+ const res = await codegen({
394
368
  // Filename is not used. This is because the typescript plugin returns a string instead of writing to a file.
395
369
  filename: process.cwd(),
396
- schema: (0, import_graphql4.parse)((0, import_graphql4.printSchema)(schema)),
370
+ schema: parse(printSchema(schema)),
397
371
  documents: [...docs, ...fragDocs],
398
372
  config: {},
399
373
  plugins: [
@@ -406,10 +380,10 @@ var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath =
406
380
  ],
407
381
  pluginMap: {
408
382
  typescript: {
409
- plugin: import_typescript.plugin
383
+ plugin: typescriptPlugin
410
384
  },
411
385
  typescriptOperations: {
412
- plugin: import_typescript_operations.plugin
386
+ plugin: typescriptOperationsPlugin
413
387
  },
414
388
  typescriptSdk: {
415
389
  plugin
@@ -422,8 +396,8 @@ var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath =
422
396
  var loadGraphQLDocuments = async (globPath) => {
423
397
  let result = [];
424
398
  try {
425
- result = await (0, import_load.loadDocuments)(globPath, {
426
- loaders: [new import_graphql_file_loader.GraphQLFileLoader()]
399
+ result = await loadDocuments(globPath, {
400
+ loaders: [new GraphQLFileLoader()]
427
401
  });
428
402
  } catch (e) {
429
403
  if (
@@ -440,11 +414,27 @@ var loadGraphQLDocuments = async (globPath) => {
440
414
  };
441
415
 
442
416
  // 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"));
417
+ import { transform } from "esbuild";
418
+ import { mapUserFields } from "@tinacms/graphql";
419
+ import normalizePath from "normalize-path";
446
420
  var TINA_HOST = "content.tinajs.io";
447
421
  var Codegen = class {
422
+ configManager;
423
+ port;
424
+ schema;
425
+ queryDoc;
426
+ fragDoc;
427
+ isLocal;
428
+ // The API url used in the client
429
+ apiURL;
430
+ // This is always the local URL.
431
+ localUrl;
432
+ // production url
433
+ productionUrl;
434
+ graphqlSchemaDoc;
435
+ tinaSchema;
436
+ lookup;
437
+ noClientBuildCache;
448
438
  constructor({
449
439
  configManager,
450
440
  port,
@@ -460,7 +450,7 @@ var Codegen = class {
460
450
  this.graphqlSchemaDoc = graphqlSchemaDoc;
461
451
  this.configManager = configManager;
462
452
  this.port = port;
463
- this.schema = (0, import_graphql5.buildASTSchema)(graphqlSchemaDoc);
453
+ this.schema = buildASTSchema(graphqlSchemaDoc);
464
454
  this.tinaSchema = tinaSchema;
465
455
  this.queryDoc = queryDoc;
466
456
  this.fragDoc = fragDoc;
@@ -468,19 +458,19 @@ var Codegen = class {
468
458
  this.noClientBuildCache = noClientBuildCache;
469
459
  }
470
460
  async writeConfigFile(fileName, data) {
471
- const filePath = import_path.default.join(
461
+ const filePath = path.join(
472
462
  this.configManager.generatedFolderPath,
473
463
  fileName
474
464
  );
475
- await import_fs_extra.default.ensureFile(filePath);
476
- await import_fs_extra.default.outputFile(filePath, data);
465
+ await fs.ensureFile(filePath);
466
+ await fs.outputFile(filePath, data);
477
467
  if (this.configManager.hasSeparateContentRoot()) {
478
- const filePath2 = import_path.default.join(
468
+ const filePath2 = path.join(
479
469
  this.configManager.generatedFolderPathContentRepo,
480
470
  fileName
481
471
  );
482
- await import_fs_extra.default.ensureFile(filePath2);
483
- await import_fs_extra.default.outputFile(filePath2, data);
472
+ await fs.ensureFile(filePath2);
473
+ await fs.outputFile(filePath2, data);
484
474
  }
485
475
  }
486
476
  async removeGeneratedFilesIfExists() {
@@ -512,11 +502,11 @@ var Codegen = class {
512
502
  await this.removeGeneratedFilesIfExists();
513
503
  return apiURL;
514
504
  }
515
- await import_fs_extra.default.outputFile(
505
+ await fs.outputFile(
516
506
  this.configManager.generatedQueriesFilePath,
517
507
  this.queryDoc
518
508
  );
519
- await import_fs_extra.default.outputFile(
509
+ await fs.outputFile(
520
510
  this.configManager.generatedFragmentsFilePath,
521
511
  this.fragDoc
522
512
  );
@@ -524,21 +514,21 @@ var Codegen = class {
524
514
  const { clientString } = await this.genClient();
525
515
  const databaseClientString = this.configManager.hasSelfHostedConfig() ? await this.genDatabaseClient() : "";
526
516
  const { codeString, schemaString } = await this.genTypes();
527
- await import_fs_extra.default.outputFile(
517
+ await fs.outputFile(
528
518
  this.configManager.generatedGraphQLGQLPath,
529
519
  schemaString
530
520
  );
531
521
  if (this.configManager.isUsingTs()) {
532
- await import_fs_extra.default.outputFile(
522
+ await fs.outputFile(
533
523
  this.configManager.generatedTypesTSFilePath,
534
524
  codeString
535
525
  );
536
- await import_fs_extra.default.outputFile(
526
+ await fs.outputFile(
537
527
  this.configManager.generatedClientTSFilePath,
538
528
  clientString
539
529
  );
540
530
  if (this.configManager.hasSelfHostedConfig()) {
541
- await import_fs_extra.default.outputFile(
531
+ await fs.outputFile(
542
532
  this.configManager.generatedDatabaseClientTSFilePath,
543
533
  databaseClientString
544
534
  );
@@ -547,35 +537,35 @@ var Codegen = class {
547
537
  await unlinkIfExists(this.configManager.generatedTypesDFilePath);
548
538
  await unlinkIfExists(this.configManager.generatedTypesJSFilePath);
549
539
  } else {
550
- await import_fs_extra.default.outputFile(
540
+ await fs.outputFile(
551
541
  this.configManager.generatedTypesDFilePath,
552
542
  codeString
553
543
  );
554
- const jsTypes = await (0, import_esbuild.transform)(codeString, { loader: "ts" });
555
- await import_fs_extra.default.outputFile(
544
+ const jsTypes = await transform(codeString, { loader: "ts" });
545
+ await fs.outputFile(
556
546
  this.configManager.generatedTypesJSFilePath,
557
547
  jsTypes.code
558
548
  );
559
- await import_fs_extra.default.outputFile(
549
+ await fs.outputFile(
560
550
  this.configManager.generatedClientDFilePath,
561
551
  clientString
562
552
  );
563
- const jsClient = await (0, import_esbuild.transform)(clientString, { loader: "ts" });
564
- await import_fs_extra.default.outputFile(
553
+ const jsClient = await transform(clientString, { loader: "ts" });
554
+ await fs.outputFile(
565
555
  this.configManager.generatedClientJSFilePath,
566
556
  jsClient.code
567
557
  );
568
558
  await unlinkIfExists(this.configManager.generatedTypesTSFilePath);
569
559
  await unlinkIfExists(this.configManager.generatedClientTSFilePath);
570
560
  if (this.configManager.hasSelfHostedConfig()) {
571
- const jsDatabaseClient = await (0, import_esbuild.transform)(databaseClientString, {
561
+ const jsDatabaseClient = await transform(databaseClientString, {
572
562
  loader: "ts"
573
563
  });
574
- await import_fs_extra.default.outputFile(
564
+ await fs.outputFile(
575
565
  this.configManager.generatedDatabaseClientJSFilePath,
576
566
  jsDatabaseClient.code
577
567
  );
578
- await import_fs_extra.default.outputFile(
568
+ await fs.outputFile(
579
569
  this.configManager.generatedDatabaseClientDFilePath,
580
570
  databaseClientString
581
571
  );
@@ -601,7 +591,7 @@ var Codegen = class {
601
591
  throw new Error(
602
592
  `Client not configured properly. Missing ${missing.join(
603
593
  ", "
604
- )}. Please visit https://tina.io/docs/tina-cloud/overview for more information`
594
+ )}. Please visit https://tina.io/docs/r/what-is-tinacloud for more information`
605
595
  );
606
596
  }
607
597
  let localUrl = `http://localhost:${this.port}/graphql`;
@@ -623,7 +613,7 @@ var Codegen = class {
623
613
  const authCollection = this.tinaSchema.getCollections().find((c) => c.isAuthCollection);
624
614
  let authFields = [];
625
615
  if (authCollection) {
626
- const usersFields = (0, import_graphql6.mapUserFields)(authCollection, []);
616
+ const usersFields = mapUserFields(authCollection, []);
627
617
  if (usersFields.length === 0) {
628
618
  throw new Error("No user field found");
629
619
  }
@@ -713,7 +703,7 @@ export default databaseClient;
713
703
  const apiURL = this.getApiURL();
714
704
  const clientString = `import { createClient } from "tinacms/dist/client";
715
705
  import { queries } from "./types";
716
- export const client = createClient({ ${this.noClientBuildCache === false ? `cacheDir: '${(0, import_normalize_path.default)(
706
+ export const client = createClient({ ${this.noClientBuildCache === false ? `cacheDir: '${normalizePath(
717
707
  this.configManager.generatedCachePath
718
708
  )}', ` : ""}url: '${apiURL}', token: '${token}', queries, ${errorPolicy ? `errorPolicy: '${errorPolicy}'` : ""} });
719
709
  export default client;
@@ -739,7 +729,7 @@ export default client;
739
729
  ${typescriptTypes}
740
730
  `;
741
731
  const schemaString = `# DO NOT MODIFY THIS FILE. This file is automatically generated by Tina
742
- ${(0, import_graphql5.printSchema)(this.schema)}
732
+ ${printSchema2(this.schema)}
743
733
  schema {
744
734
  query: Query
745
735
  mutation: Mutation
@@ -751,7 +741,7 @@ schema {
751
741
  var maybeWarnFragmentSize = async (filepath) => {
752
742
  if (
753
743
  // is the file bigger than 100kb?
754
- (await import_fs_extra.default.stat(filepath)).size > // convert to 100 kb to bytes
744
+ (await fs.stat(filepath)).size > // convert to 100 kb to bytes
755
745
  100 * 1024
756
746
  ) {
757
747
  console.warn(
@@ -768,19 +758,34 @@ var maybeWarnFragmentSize = async (filepath) => {
768
758
  }
769
759
  };
770
760
  var unlinkIfExists = async (filepath) => {
771
- if (import_fs_extra.default.existsSync(filepath)) {
772
- import_fs_extra.default.unlinkSync(filepath);
761
+ if (fs.existsSync(filepath)) {
762
+ fs.unlinkSync(filepath);
773
763
  }
774
764
  };
775
765
 
776
766
  // src/next/config-manager.ts
777
- var import_fs_extra2 = __toESM(require("fs-extra"));
778
- var import_path2 = __toESM(require("path"));
779
- var import_os = __toESM(require("os"));
780
- var esbuild = __toESM(require("esbuild"));
781
- var dotenv = __toESM(require("dotenv"));
782
- var import_normalize_path2 = __toESM(require("normalize-path"));
783
- var import_chalk3 = __toESM(require("chalk"));
767
+ import fs2 from "fs-extra";
768
+ import path3 from "path";
769
+ import os from "os";
770
+ import { pathToFileURL } from "url";
771
+ import * as esbuild from "esbuild";
772
+ import * as dotenv from "dotenv";
773
+ import normalizePath2 from "normalize-path";
774
+ import chalk3 from "chalk";
775
+ import { createRequire } from "module";
776
+
777
+ // src/utils/path.ts
778
+ import path2 from "path";
779
+ function stripNativeTrailingSlash(p) {
780
+ const { root } = path2.parse(p);
781
+ let str = p;
782
+ while (str.length > root.length && str.endsWith(path2.sep)) {
783
+ str = str.slice(0, -1);
784
+ }
785
+ return str;
786
+ }
787
+
788
+ // src/next/config-manager.ts
784
789
  var TINA_FOLDER = "tina";
785
790
  var LEGACY_TINA_FOLDER = ".tina";
786
791
  var GENERATED_FOLDER = "__generated__";
@@ -789,17 +794,57 @@ var GRAPHQL_GQL_FILE = "schema.gql";
789
794
  var SCHEMA_JSON_FILE = "_schema.json";
790
795
  var LOOKUP_JSON_FILE = "_lookup.json";
791
796
  var ConfigManager = class {
797
+ config;
798
+ rootPath;
799
+ tinaFolderPath;
800
+ isUsingLegacyFolder;
801
+ tinaConfigFilePath;
802
+ tinaSpaPackagePath;
803
+ contentRootPath;
804
+ envFilePath;
805
+ generatedCachePath;
806
+ generatedFolderPath;
807
+ generatedFolderPathContentRepo;
808
+ generatedGraphQLGQLPath;
809
+ generatedGraphQLJSONPath;
810
+ generatedSchemaJSONPath;
811
+ generatedLookupJSONPath;
812
+ generatedTypesTSFilePath;
813
+ generatedTypesJSFilePath;
814
+ generatedTypesDFilePath;
815
+ generatedClientTSFilePath;
816
+ generatedClientJSFilePath;
817
+ generatedClientDFilePath;
818
+ generatedDatabaseClientJSFilePath;
819
+ generatedDatabaseClientTSFilePath;
820
+ generatedDatabaseClientDFilePath;
821
+ generatedQueriesFilePath;
822
+ generatedFragmentsFilePath;
823
+ generatedQueriesAndFragmentsGlob;
824
+ userQueriesAndFragmentsGlob;
825
+ publicFolderPath;
826
+ outputFolderPath;
827
+ outputHTMLFilePath;
828
+ outputGitignorePath;
829
+ selfHostedDatabaseFilePath;
830
+ prebuildFilePath;
831
+ spaRootPath;
832
+ spaMainPath;
833
+ spaHTMLPath;
834
+ tinaGraphQLVersionFromCLI;
835
+ legacyNoSDK;
836
+ watchList;
792
837
  constructor({
793
838
  rootPath = process.cwd(),
794
839
  tinaGraphQLVersion,
795
840
  legacyNoSDK
796
841
  }) {
797
- this.rootPath = (0, import_normalize_path2.default)(rootPath);
842
+ this.rootPath = normalizePath2(rootPath);
798
843
  this.tinaGraphQLVersionFromCLI = tinaGraphQLVersion;
799
844
  this.legacyNoSDK = legacyNoSDK;
800
845
  }
801
846
  isUsingTs() {
802
- return [".ts", ".tsx"].includes(import_path2.default.extname(this.tinaConfigFilePath));
847
+ return [".ts", ".tsx"].includes(path3.extname(this.tinaConfigFilePath));
803
848
  }
804
849
  hasSelfHostedConfig() {
805
850
  return !!this.selfHostedDatabaseFilePath;
@@ -814,13 +859,14 @@ var ConfigManager = class {
814
859
  return this.config.client?.skip || false;
815
860
  }
816
861
  async processConfig() {
862
+ const require2 = createRequire(import.meta.url);
817
863
  this.tinaFolderPath = await this.getTinaFolderPath(this.rootPath);
818
- this.envFilePath = import_path2.default.resolve(
819
- import_path2.default.join(this.tinaFolderPath, "..", ".env")
864
+ this.envFilePath = path3.resolve(
865
+ path3.join(this.tinaFolderPath, "..", ".env")
820
866
  );
821
867
  dotenv.config({ path: this.envFilePath });
822
868
  this.tinaConfigFilePath = await this.getPathWithExtension(
823
- import_path2.default.join(this.tinaFolderPath, "config")
869
+ path3.join(this.tinaFolderPath, "config")
824
870
  );
825
871
  if (!this.tinaConfigFilePath) {
826
872
  throw new Error(
@@ -828,89 +874,89 @@ var ConfigManager = class {
828
874
  );
829
875
  }
830
876
  this.selfHostedDatabaseFilePath = await this.getPathWithExtension(
831
- import_path2.default.join(this.tinaFolderPath, "database")
877
+ path3.join(this.tinaFolderPath, "database")
832
878
  );
833
- this.generatedFolderPath = import_path2.default.join(this.tinaFolderPath, GENERATED_FOLDER);
834
- this.generatedCachePath = import_path2.default.join(
879
+ this.generatedFolderPath = path3.join(this.tinaFolderPath, GENERATED_FOLDER);
880
+ this.generatedCachePath = path3.join(
835
881
  this.generatedFolderPath,
836
882
  ".cache",
837
883
  String((/* @__PURE__ */ new Date()).getTime())
838
884
  );
839
- this.generatedGraphQLGQLPath = import_path2.default.join(
885
+ this.generatedGraphQLGQLPath = path3.join(
840
886
  this.generatedFolderPath,
841
887
  GRAPHQL_GQL_FILE
842
888
  );
843
- this.generatedGraphQLJSONPath = import_path2.default.join(
889
+ this.generatedGraphQLJSONPath = path3.join(
844
890
  this.generatedFolderPath,
845
891
  GRAPHQL_JSON_FILE
846
892
  );
847
- this.generatedSchemaJSONPath = import_path2.default.join(
893
+ this.generatedSchemaJSONPath = path3.join(
848
894
  this.generatedFolderPath,
849
895
  SCHEMA_JSON_FILE
850
896
  );
851
- this.generatedLookupJSONPath = import_path2.default.join(
897
+ this.generatedLookupJSONPath = path3.join(
852
898
  this.generatedFolderPath,
853
899
  LOOKUP_JSON_FILE
854
900
  );
855
- this.generatedQueriesFilePath = import_path2.default.join(
901
+ this.generatedQueriesFilePath = path3.join(
856
902
  this.generatedFolderPath,
857
903
  "queries.gql"
858
904
  );
859
- this.generatedFragmentsFilePath = import_path2.default.join(
905
+ this.generatedFragmentsFilePath = path3.join(
860
906
  this.generatedFolderPath,
861
907
  "frags.gql"
862
908
  );
863
- this.generatedTypesTSFilePath = import_path2.default.join(
909
+ this.generatedTypesTSFilePath = path3.join(
864
910
  this.generatedFolderPath,
865
911
  "types.ts"
866
912
  );
867
- this.generatedTypesJSFilePath = import_path2.default.join(
913
+ this.generatedTypesJSFilePath = path3.join(
868
914
  this.generatedFolderPath,
869
915
  "types.js"
870
916
  );
871
- this.generatedTypesDFilePath = import_path2.default.join(
917
+ this.generatedTypesDFilePath = path3.join(
872
918
  this.generatedFolderPath,
873
919
  "types.d.ts"
874
920
  );
875
- this.userQueriesAndFragmentsGlob = import_path2.default.join(
921
+ this.userQueriesAndFragmentsGlob = path3.join(
876
922
  this.tinaFolderPath,
877
923
  "queries/**/*.{graphql,gql}"
878
924
  );
879
- this.generatedQueriesAndFragmentsGlob = import_path2.default.join(
925
+ this.generatedQueriesAndFragmentsGlob = path3.join(
880
926
  this.generatedFolderPath,
881
927
  "*.{graphql,gql}"
882
928
  );
883
- this.generatedClientTSFilePath = import_path2.default.join(
929
+ this.generatedClientTSFilePath = path3.join(
884
930
  this.generatedFolderPath,
885
931
  "client.ts"
886
932
  );
887
- this.generatedClientJSFilePath = import_path2.default.join(
933
+ this.generatedClientJSFilePath = path3.join(
888
934
  this.generatedFolderPath,
889
935
  "client.js"
890
936
  );
891
- this.generatedClientDFilePath = import_path2.default.join(
937
+ this.generatedClientDFilePath = path3.join(
892
938
  this.generatedFolderPath,
893
939
  "client.d.ts"
894
940
  );
895
- this.generatedDatabaseClientDFilePath = import_path2.default.join(
941
+ this.generatedDatabaseClientDFilePath = path3.join(
896
942
  this.generatedFolderPath,
897
943
  "databaseClient.d.ts"
898
944
  );
899
- this.generatedDatabaseClientTSFilePath = import_path2.default.join(
945
+ this.generatedDatabaseClientTSFilePath = path3.join(
900
946
  this.generatedFolderPath,
901
947
  "databaseClient.ts"
902
948
  );
903
- this.generatedDatabaseClientJSFilePath = import_path2.default.join(
949
+ this.generatedDatabaseClientJSFilePath = path3.join(
904
950
  this.generatedFolderPath,
905
951
  "databaseClient.js"
906
952
  );
907
- const clientExists = this.isUsingTs() ? await import_fs_extra2.default.pathExists(this.generatedClientTSFilePath) : await import_fs_extra2.default.pathExists(this.generatedClientJSFilePath);
953
+ const clientExists = this.isUsingTs() ? await fs2.pathExists(this.generatedClientTSFilePath) : await fs2.pathExists(this.generatedClientJSFilePath);
908
954
  if (!clientExists) {
909
955
  const file = "export default ()=>({})\nexport const client = ()=>({})";
910
956
  if (this.isUsingTs()) {
911
- await import_fs_extra2.default.outputFile(this.generatedClientTSFilePath, file);
957
+ await fs2.outputFile(this.generatedClientTSFilePath, file);
912
958
  } else {
913
- await import_fs_extra2.default.outputFile(this.generatedClientJSFilePath, file);
959
+ await fs2.outputFile(this.generatedClientJSFilePath, file);
914
960
  }
915
961
  }
916
962
  const { config: config2, prebuildPath, watchList } = await this.loadConfigFile(
@@ -920,30 +966,29 @@ var ConfigManager = class {
920
966
  this.watchList = watchList;
921
967
  this.config = config2;
922
968
  this.prebuildFilePath = prebuildPath;
923
- this.publicFolderPath = import_path2.default.join(
969
+ this.publicFolderPath = path3.join(
924
970
  this.rootPath,
925
971
  this.config.build.publicFolder
926
972
  );
927
- this.outputFolderPath = import_path2.default.join(
973
+ this.outputFolderPath = path3.join(
928
974
  this.publicFolderPath,
929
975
  this.config.build.outputFolder
930
976
  );
931
- this.outputHTMLFilePath = import_path2.default.join(this.outputFolderPath, "index.html");
932
- this.outputGitignorePath = import_path2.default.join(this.outputFolderPath, ".gitignore");
933
- const fullLocalContentPath = import_path2.default.join(
934
- this.tinaFolderPath,
935
- this.config.localContentPath || ""
977
+ this.outputHTMLFilePath = path3.join(this.outputFolderPath, "index.html");
978
+ this.outputGitignorePath = path3.join(this.outputFolderPath, ".gitignore");
979
+ const fullLocalContentPath = stripNativeTrailingSlash(
980
+ path3.join(this.tinaFolderPath, this.config.localContentPath || "")
936
981
  );
937
982
  if (this.config.localContentPath) {
938
- const localContentPathExists = await import_fs_extra2.default.pathExists(fullLocalContentPath);
983
+ const localContentPathExists = await fs2.pathExists(fullLocalContentPath);
939
984
  if (localContentPathExists) {
940
985
  logger.info(`Using separate content repo at ${fullLocalContentPath}`);
941
986
  this.contentRootPath = fullLocalContentPath;
942
987
  } else {
943
988
  logger.warn(
944
- `${import_chalk3.default.yellow("Warning:")} The localContentPath ${import_chalk3.default.cyan(
989
+ `${chalk3.yellow("Warning:")} The localContentPath ${chalk3.cyan(
945
990
  fullLocalContentPath
946
- )} does not exist. Please create it or remove the localContentPath from your config file at ${import_chalk3.default.cyan(
991
+ )} does not exist. Please create it or remove the localContentPath from your config file at ${chalk3.cyan(
947
992
  this.tinaConfigFilePath
948
993
  )}`
949
994
  );
@@ -952,22 +997,22 @@ var ConfigManager = class {
952
997
  if (!this.contentRootPath) {
953
998
  this.contentRootPath = this.rootPath;
954
999
  }
955
- this.generatedFolderPathContentRepo = import_path2.default.join(
1000
+ this.generatedFolderPathContentRepo = path3.join(
956
1001
  await this.getTinaFolderPath(this.contentRootPath),
957
1002
  GENERATED_FOLDER
958
1003
  );
959
- this.spaMainPath = require.resolve("@tinacms/app");
960
- this.spaRootPath = import_path2.default.join(this.spaMainPath, "..", "..");
1004
+ this.spaMainPath = require2.resolve("@tinacms/app");
1005
+ this.spaRootPath = path3.join(this.spaMainPath, "..", "..");
961
1006
  }
962
1007
  async getTinaFolderPath(rootPath) {
963
- const tinaFolderPath = import_path2.default.join(rootPath, TINA_FOLDER);
964
- const tinaFolderExists = await import_fs_extra2.default.pathExists(tinaFolderPath);
1008
+ const tinaFolderPath = path3.join(rootPath, TINA_FOLDER);
1009
+ const tinaFolderExists = await fs2.pathExists(tinaFolderPath);
965
1010
  if (tinaFolderExists) {
966
1011
  this.isUsingLegacyFolder = false;
967
1012
  return tinaFolderPath;
968
1013
  }
969
- const legacyFolderPath = import_path2.default.join(rootPath, LEGACY_TINA_FOLDER);
970
- const legacyFolderExists = await import_fs_extra2.default.pathExists(legacyFolderPath);
1014
+ const legacyFolderPath = path3.join(rootPath, LEGACY_TINA_FOLDER);
1015
+ const legacyFolderExists = await fs2.pathExists(legacyFolderPath);
971
1016
  if (legacyFolderExists) {
972
1017
  this.isUsingLegacyFolder = true;
973
1018
  return legacyFolderPath;
@@ -986,7 +1031,7 @@ var ConfigManager = class {
986
1031
  patch: version2[2] || "x"
987
1032
  };
988
1033
  }
989
- const generatedSchema = import_fs_extra2.default.readJSONSync(this.generatedSchemaJSONPath);
1034
+ const generatedSchema = fs2.readJSONSync(this.generatedSchemaJSONPath);
990
1035
  if (!generatedSchema || !(typeof generatedSchema?.version !== "undefined")) {
991
1036
  throw new Error(
992
1037
  `Can not find Tina GraphQL version in ${this.generatedSchemaJSONPath}`
@@ -1033,7 +1078,7 @@ var ConfigManager = class {
1033
1078
  return;
1034
1079
  }
1035
1080
  const filepathWithExtension = `${filepath}.${ext}`;
1036
- const exists = import_fs_extra2.default.existsSync(filepathWithExtension);
1081
+ const exists = fs2.existsSync(filepathWithExtension);
1037
1082
  if (exists) {
1038
1083
  result = filepathWithExtension;
1039
1084
  }
@@ -1042,33 +1087,45 @@ var ConfigManager = class {
1042
1087
  return result;
1043
1088
  }
1044
1089
  async loadDatabaseFile() {
1045
- const tmpdir = import_path2.default.join(import_os.default.tmpdir(), Date.now().toString());
1046
- const outfile = import_path2.default.join(tmpdir, "database.build.js");
1090
+ const tmpdir = path3.join(os.tmpdir(), Date.now().toString());
1091
+ const outfile = path3.join(tmpdir, "database.build.mjs");
1047
1092
  await esbuild.build({
1048
1093
  entryPoints: [this.selfHostedDatabaseFilePath],
1049
1094
  bundle: true,
1050
1095
  platform: "node",
1096
+ format: "esm",
1051
1097
  outfile,
1052
- loader: loaders
1098
+ loader: loaders,
1099
+ // Provide a require() polyfill for ESM bundles containing CommonJS packages.
1100
+ // Some bundled packages (e.g., 'scmp' used by 'mongodb-level') use require('crypto').
1101
+ // When esbuild inlines these CommonJS packages, it keeps the require() calls,
1102
+ // but ESM doesn't have a global require. This banner creates one using Node.js's
1103
+ // official createRequire API, allowing the bundled CommonJS code to work in ESM.
1104
+ banner: {
1105
+ js: `import { createRequire } from 'module';const require = createRequire(import.meta.url);`
1106
+ }
1053
1107
  });
1054
- const result = require(outfile);
1055
- import_fs_extra2.default.removeSync(outfile);
1108
+ const result = await import(pathToFileURL(outfile).href);
1109
+ fs2.removeSync(outfile);
1056
1110
  return result.default;
1057
1111
  }
1058
1112
  async loadConfigFile(generatedFolderPath, configFilePath) {
1059
- const tmpdir = import_path2.default.join(import_os.default.tmpdir(), Date.now().toString());
1060
- const preBuildConfigPath = import_path2.default.join(
1113
+ const tmpdir = path3.join(os.tmpdir(), Date.now().toString());
1114
+ const preBuildConfigPath = path3.join(
1061
1115
  this.generatedFolderPath,
1062
1116
  "config.prebuild.jsx"
1063
1117
  );
1064
- const outfile = import_path2.default.join(tmpdir, "config.build.jsx");
1065
- const outfile2 = import_path2.default.join(tmpdir, "config.build.js");
1066
- const tempTSConfigFile = import_path2.default.join(tmpdir, "tsconfig.json");
1067
- import_fs_extra2.default.outputFileSync(tempTSConfigFile, "{}");
1118
+ const outfile = path3.join(tmpdir, "config.build.jsx");
1119
+ const outfile2 = path3.join(tmpdir, "config.build.mjs");
1120
+ const tempTSConfigFile = path3.join(tmpdir, "tsconfig.json");
1121
+ const esmRequireBanner = {
1122
+ js: `import { createRequire } from 'module';const require = createRequire(import.meta.url);`
1123
+ };
1124
+ fs2.outputFileSync(tempTSConfigFile, "{}");
1068
1125
  const result2 = await esbuild.build({
1069
1126
  entryPoints: [configFilePath],
1070
1127
  bundle: true,
1071
- target: ["es2020"],
1128
+ target: ["esnext"],
1072
1129
  platform: "browser",
1073
1130
  format: "esm",
1074
1131
  logLevel: "silent",
@@ -1088,31 +1145,34 @@ var ConfigManager = class {
1088
1145
  await esbuild.build({
1089
1146
  entryPoints: [configFilePath],
1090
1147
  bundle: true,
1091
- target: ["es2020"],
1148
+ target: ["esnext"],
1092
1149
  logLevel: "silent",
1093
1150
  platform: "node",
1151
+ format: "esm",
1094
1152
  outfile,
1095
- loader: loaders
1153
+ loader: loaders,
1154
+ banner: esmRequireBanner
1096
1155
  });
1097
1156
  await esbuild.build({
1098
1157
  entryPoints: [outfile],
1099
1158
  bundle: true,
1100
- // Suppress warning about comparison with -0 from client module
1101
1159
  logLevel: "silent",
1102
1160
  platform: "node",
1161
+ target: ["esnext"],
1162
+ format: "esm",
1103
1163
  outfile: outfile2,
1104
1164
  loader: loaders
1105
1165
  });
1106
1166
  let result;
1107
1167
  try {
1108
- result = require(outfile2);
1168
+ result = await import(pathToFileURL(outfile2).href);
1109
1169
  } catch (e) {
1110
1170
  console.error("Unexpected error loading config");
1111
1171
  console.error(e);
1112
1172
  throw e;
1113
1173
  }
1114
- import_fs_extra2.default.removeSync(outfile);
1115
- import_fs_extra2.default.removeSync(outfile2);
1174
+ fs2.removeSync(outfile);
1175
+ fs2.removeSync(outfile2);
1116
1176
  return {
1117
1177
  config: result.default,
1118
1178
  prebuildPath: preBuildConfigPath,
@@ -1147,20 +1207,24 @@ var loaders = {
1147
1207
  };
1148
1208
 
1149
1209
  // src/next/database.ts
1150
- var import_graphql7 = require("@tinacms/graphql");
1151
- var import_readable_stream = require("readable-stream");
1152
- var import_net = require("net");
1153
- var import_many_level = require("many-level");
1154
- var import_memory_level = require("memory-level");
1210
+ import {
1211
+ createDatabaseInternal,
1212
+ FilesystemBridge,
1213
+ TinaLevelClient
1214
+ } from "@tinacms/graphql";
1215
+ import { pipeline } from "readable-stream";
1216
+ import { createServer } from "net";
1217
+ import { ManyLevelHost } from "many-level";
1218
+ import { MemoryLevel } from "memory-level";
1155
1219
  var createDBServer = (port) => {
1156
- const levelHost = new import_many_level.ManyLevelHost(
1220
+ const levelHost = new ManyLevelHost(
1157
1221
  // @ts-ignore
1158
- new import_memory_level.MemoryLevel({
1222
+ new MemoryLevel({
1159
1223
  valueEncoding: "json"
1160
1224
  })
1161
1225
  );
1162
- const dbServer = (0, import_net.createServer)(function(socket) {
1163
- return (0, import_readable_stream.pipeline)(socket, levelHost.createRpcStream(), socket, () => {
1226
+ const dbServer = createServer(function(socket) {
1227
+ return pipeline(socket, levelHost.createRpcStream(), socket, () => {
1164
1228
  });
1165
1229
  });
1166
1230
  dbServer.once("error", (err) => {
@@ -1174,7 +1238,7 @@ var createDBServer = (port) => {
1174
1238
  };
1175
1239
  async function createAndInitializeDatabase(configManager, datalayerPort, bridgeOverride) {
1176
1240
  let database;
1177
- const bridge = bridgeOverride || new import_graphql7.FilesystemBridge(configManager.rootPath, configManager.contentRootPath);
1241
+ const bridge = bridgeOverride || new FilesystemBridge(configManager.rootPath, configManager.contentRootPath);
1178
1242
  if (configManager.hasSelfHostedConfig() && configManager.config.contentApiUrlOverride) {
1179
1243
  database = await configManager.loadDatabaseFile();
1180
1244
  database.bridge = bridge;
@@ -1186,9 +1250,9 @@ async function createAndInitializeDatabase(configManager, datalayerPort, bridgeO
1186
1250
  )} but there was no "contentApiUrlOverride" set. Falling back to built-in datalayer`
1187
1251
  );
1188
1252
  }
1189
- const level = new import_graphql7.TinaLevelClient(datalayerPort);
1253
+ const level = new TinaLevelClient(datalayerPort);
1190
1254
  level.openConnection();
1191
- database = (0, import_graphql7.createDatabaseInternal)({
1255
+ database = createDatabaseInternal({
1192
1256
  bridge,
1193
1257
  level,
1194
1258
  tinaDirectory: configManager.isUsingLegacyFolder ? LEGACY_TINA_FOLDER : TINA_FOLDER
@@ -1198,17 +1262,17 @@ async function createAndInitializeDatabase(configManager, datalayerPort, bridgeO
1198
1262
  }
1199
1263
 
1200
1264
  // src/next/commands/baseCommands.ts
1201
- var import_clipanion = require("clipanion");
1202
- var import_chalk4 = __toESM(require("chalk"));
1265
+ import { Command, Option } from "clipanion";
1266
+ import chalk4 from "chalk";
1203
1267
 
1204
1268
  // src/utils/start-subprocess.ts
1205
- var import_child_process = __toESM(require("child_process"));
1269
+ import childProcess from "child_process";
1206
1270
  var startSubprocess2 = async ({ command: command2 }) => {
1207
1271
  if (typeof command2 === "string") {
1208
1272
  const commands = command2.split(" ");
1209
1273
  const firstCommand = commands[0];
1210
1274
  const args = commands.slice(1) || [];
1211
- const ps = import_child_process.default.spawn(firstCommand, args, {
1275
+ const ps = childProcess.spawn(firstCommand, args, {
1212
1276
  stdio: "inherit",
1213
1277
  shell: true
1214
1278
  });
@@ -1232,45 +1296,42 @@ stack: ${code.stack || "No stack was provided"}`);
1232
1296
  };
1233
1297
 
1234
1298
  // src/next/commands/baseCommands.ts
1235
- var import_graphql8 = require("@tinacms/graphql");
1236
- var import_fs_extra3 = __toESM(require("fs-extra"));
1237
- var BaseCommand = class extends import_clipanion.Command {
1238
- constructor() {
1239
- super(...arguments);
1240
- this.experimentalDataLayer = import_clipanion.Option.Boolean("--experimentalData", {
1241
- description: "DEPRECATED - Build the server with additional data querying capabilities"
1242
- });
1243
- this.isomorphicGitBridge = import_clipanion.Option.Boolean("--isomorphicGitBridge", {
1244
- description: "DEPRECATED - Enable Isomorphic Git Bridge Implementation"
1245
- });
1246
- this.port = import_clipanion.Option.String("-p,--port", "4001", {
1247
- description: "Specify a port to run the server on. (default 4001)"
1248
- });
1249
- this.datalayerPort = import_clipanion.Option.String("--datalayer-port", "9000", {
1250
- description: "Specify a port to run the datalayer server on. (default 9000)"
1251
- });
1252
- this.subCommand = import_clipanion.Option.String("-c,--command", {
1253
- description: "The sub-command to run"
1254
- });
1255
- this.rootPath = import_clipanion.Option.String("--rootPath", {
1256
- description: "Specify the root directory to run the CLI from (defaults to current working directory)"
1257
- });
1258
- this.verbose = import_clipanion.Option.Boolean("-v,--verbose", false, {
1259
- description: "increase verbosity of logged output"
1260
- });
1261
- this.noSDK = import_clipanion.Option.Boolean("--noSDK", false, {
1262
- description: "DEPRECATED - This should now be set in the config at client.skip = true'. Don't generate the generated client SDK"
1263
- });
1264
- this.noTelemetry = import_clipanion.Option.Boolean("--noTelemetry", false, {
1265
- description: "Disable anonymous telemetry that is collected"
1266
- });
1267
- }
1299
+ import { getChangedFiles, getSha, shaExists } from "@tinacms/graphql";
1300
+ import fs3 from "fs-extra";
1301
+ var BaseCommand = class extends Command {
1302
+ experimentalDataLayer = Option.Boolean("--experimentalData", {
1303
+ description: "DEPRECATED - Build the server with additional data querying capabilities"
1304
+ });
1305
+ isomorphicGitBridge = Option.Boolean("--isomorphicGitBridge", {
1306
+ description: "DEPRECATED - Enable Isomorphic Git Bridge Implementation"
1307
+ });
1308
+ port = Option.String("-p,--port", "4001", {
1309
+ description: "Specify a port to run the server on. (default 4001)"
1310
+ });
1311
+ datalayerPort = Option.String("--datalayer-port", "9000", {
1312
+ description: "Specify a port to run the datalayer server on. (default 9000)"
1313
+ });
1314
+ subCommand = Option.String("-c,--command", {
1315
+ description: "The sub-command to run"
1316
+ });
1317
+ rootPath = Option.String("--rootPath", {
1318
+ description: "Specify the root directory to run the CLI from (defaults to current working directory)"
1319
+ });
1320
+ verbose = Option.Boolean("-v,--verbose", false, {
1321
+ description: "increase verbosity of logged output"
1322
+ });
1323
+ noSDK = Option.Boolean("--noSDK", false, {
1324
+ description: "DEPRECATED - This should now be set in the config at client.skip = true'. Don't generate the generated client SDK"
1325
+ });
1326
+ noTelemetry = Option.Boolean("--noTelemetry", false, {
1327
+ description: "Disable anonymous telemetry that is collected"
1328
+ });
1268
1329
  async startSubCommand() {
1269
1330
  let subProc;
1270
1331
  if (this.subCommand) {
1271
1332
  subProc = await startSubprocess2({ command: this.subCommand });
1272
1333
  logger.info(
1273
- `Running web application with command: ${import_chalk4.default.cyan(this.subCommand)}`
1334
+ `Running web application with command: ${chalk4.cyan(this.subCommand)}`
1274
1335
  );
1275
1336
  }
1276
1337
  function exitHandler(options, exitCode) {
@@ -1318,7 +1379,7 @@ var BaseCommand = class extends import_clipanion.Command {
1318
1379
  const rootPath = configManager.rootPath;
1319
1380
  let sha;
1320
1381
  try {
1321
- sha = await (0, import_graphql8.getSha)({ fs: import_fs_extra3.default, dir: rootPath });
1382
+ sha = await getSha({ fs: fs3, dir: rootPath });
1322
1383
  } catch (e) {
1323
1384
  if (partialReindex) {
1324
1385
  console.error(
@@ -1328,7 +1389,7 @@ var BaseCommand = class extends import_clipanion.Command {
1328
1389
  }
1329
1390
  }
1330
1391
  const lastSha = await database.getMetadata("lastSha");
1331
- const exists = lastSha && await (0, import_graphql8.shaExists)({ fs: import_fs_extra3.default, dir: rootPath, sha: lastSha });
1392
+ const exists = lastSha && await shaExists({ fs: fs3, dir: rootPath, sha: lastSha });
1332
1393
  let res;
1333
1394
  if (partialReindex && lastSha && exists && sha) {
1334
1395
  const pathFilter = {};
@@ -1342,15 +1403,15 @@ var BaseCommand = class extends import_clipanion.Command {
1342
1403
  matches: collection.match?.exclude || collection.match?.include ? tinaSchema.getMatches({ collection }) : void 0
1343
1404
  };
1344
1405
  }
1345
- const { added, modified, deleted } = await (0, import_graphql8.getChangedFiles)({
1346
- fs: import_fs_extra3.default,
1406
+ const { added, modified, deleted } = await getChangedFiles({
1407
+ fs: fs3,
1347
1408
  dir: rootPath,
1348
1409
  from: lastSha,
1349
1410
  to: sha,
1350
1411
  pathFilter
1351
1412
  });
1352
1413
  const tinaPathUpdates = modified.filter(
1353
- (path14) => path14.startsWith(".tina/__generated__/_schema.json") || path14.startsWith("tina/tina-lock.json")
1414
+ (path15) => path15.startsWith(".tina/__generated__/_schema.json") || path15.startsWith("tina/tina-lock.json")
1354
1415
  );
1355
1416
  if (tinaPathUpdates.length > 0) {
1356
1417
  res = await database.indexContent({
@@ -1428,7 +1489,7 @@ var errorHTML = `<style type="text/css">
1428
1489
  the assets for this page.
1429
1490
  </p>
1430
1491
  <p>
1431
- 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.
1492
+ 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.
1432
1493
  </p>
1433
1494
  </div>
1434
1495
  </div>`.trim().replace(/[\r\n\s]+/g, " ");
@@ -1466,34 +1527,38 @@ var devHTML = (port) => `<!DOCTYPE html>
1466
1527
  </html>`;
1467
1528
 
1468
1529
  // src/next/commands/dev-command/server/index.ts
1469
- var import_vite3 = require("vite");
1530
+ import { createServer as createViteServer } from "vite";
1470
1531
 
1471
1532
  // src/next/vite/index.ts
1472
- var import_node_path2 = __toESM(require("node:path"));
1473
- var import_plugin_react = __toESM(require("@vitejs/plugin-react"));
1474
- var import_fs_extra4 = __toESM(require("fs-extra"));
1475
- var import_normalize_path3 = __toESM(require("normalize-path"));
1476
- var import_vite = require("vite");
1533
+ import path5 from "node:path";
1534
+ import react from "@vitejs/plugin-react";
1535
+ import fs4 from "fs-extra";
1536
+ import normalizePath3 from "normalize-path";
1537
+ import {
1538
+ splitVendorChunkPlugin
1539
+ } from "vite";
1477
1540
 
1478
1541
  // src/next/vite/tailwind.ts
1479
- var import_node_path = __toESM(require("node:path"));
1480
- var import_aspect_ratio = __toESM(require("@tailwindcss/aspect-ratio"));
1481
- var import_container_queries = __toESM(require("@tailwindcss/container-queries"));
1482
- var import_typography = __toESM(require("@tailwindcss/typography"));
1483
- var import_tailwindcss = __toESM(require("tailwindcss"));
1484
- var import_defaultTheme = __toESM(require("tailwindcss/defaultTheme.js"));
1542
+ import path4 from "node:path";
1543
+ import aspectRatio from "@tailwindcss/aspect-ratio";
1544
+ import containerQueries from "@tailwindcss/container-queries";
1545
+ import twTypography from "@tailwindcss/typography";
1546
+ import tailwind from "tailwindcss";
1547
+ import defaultTheme from "tailwindcss/defaultTheme.js";
1548
+ import { createRequire as createRequire2 } from "module";
1485
1549
  var tinaTailwind = (spaPath, prebuildFilePath) => {
1486
1550
  return {
1487
1551
  name: "vite-plugin-tina",
1488
1552
  // @ts-ignore
1489
1553
  config: (viteConfig) => {
1554
+ const require2 = createRequire2(import.meta.url);
1490
1555
  const plugins = [];
1491
1556
  const content = [
1492
- import_node_path.default.join(spaPath, "src/**/*.{vue,js,ts,jsx,tsx,svelte}"),
1557
+ path4.join(spaPath, "src/**/*.{vue,js,ts,jsx,tsx,svelte}"),
1493
1558
  prebuildFilePath,
1494
- require.resolve("tinacms")
1559
+ require2.resolve("tinacms")
1495
1560
  ];
1496
- const tw = (0, import_tailwindcss.default)({
1561
+ const tw = tailwind({
1497
1562
  theme: {
1498
1563
  columns: {
1499
1564
  auto: "auto",
@@ -1681,6 +1746,9 @@ var tinaTailwind = (spaPath, prebuildFilePath) => {
1681
1746
  500: "#EC4815",
1682
1747
  600: "#DC4419"
1683
1748
  },
1749
+ "tina-orange": "#EC4815",
1750
+ "tina-orange-dark": "#C2410C",
1751
+ "tina-orange-light": "#FFF7ED",
1684
1752
  background: "#FFFFFF",
1685
1753
  foreground: "#0A0A0A",
1686
1754
  muted: "#F5F5F5",
@@ -1702,7 +1770,7 @@ var tinaTailwind = (spaPath, prebuildFilePath) => {
1702
1770
  ring: "#0A0A0A"
1703
1771
  },
1704
1772
  fontFamily: {
1705
- sans: ["Inter", ...import_defaultTheme.default.fontFamily.sans]
1773
+ sans: ["Inter", ...defaultTheme.fontFamily.sans]
1706
1774
  },
1707
1775
  lineHeight: {
1708
1776
  3: "12px",
@@ -1727,9 +1795,9 @@ var tinaTailwind = (spaPath, prebuildFilePath) => {
1727
1795
  },
1728
1796
  content,
1729
1797
  plugins: [
1730
- (0, import_typography.default)({ className: "tina-prose" }),
1731
- import_aspect_ratio.default,
1732
- import_container_queries.default
1798
+ twTypography({ className: "tina-prose" }),
1799
+ aspectRatio,
1800
+ containerQueries
1733
1801
  ]
1734
1802
  });
1735
1803
  plugins.push(tw);
@@ -1750,35 +1818,35 @@ async function listFilesRecursively({
1750
1818
  config: config2,
1751
1819
  roothPath
1752
1820
  }) {
1753
- const fullDirectoryPath = import_node_path2.default.join(
1821
+ const fullDirectoryPath = path5.join(
1754
1822
  roothPath,
1755
1823
  config2.publicFolder,
1756
1824
  directoryPath
1757
1825
  );
1758
- const exists = await import_fs_extra4.default.pathExists(fullDirectoryPath);
1826
+ const exists = await fs4.pathExists(fullDirectoryPath);
1759
1827
  if (!exists) {
1760
1828
  return { "0": [] };
1761
1829
  }
1762
- const items = await import_fs_extra4.default.readdir(fullDirectoryPath);
1830
+ const items = await fs4.readdir(fullDirectoryPath);
1763
1831
  const staticMediaItems = [];
1764
1832
  for (const item of items) {
1765
- const itemPath = import_node_path2.default.join(fullDirectoryPath, item);
1766
- const stats = await import_fs_extra4.default.promises.lstat(itemPath);
1833
+ const itemPath = path5.join(fullDirectoryPath, item);
1834
+ const stats = await fs4.promises.lstat(itemPath);
1767
1835
  const staticMediaItem = {
1768
1836
  id: item,
1769
1837
  filename: item,
1770
1838
  type: stats.isDirectory() ? "dir" : "file",
1771
1839
  directory: `${directoryPath.replace(config2.mediaRoot, "")}`,
1772
- src: `/${import_node_path2.default.join(directoryPath, item)}`,
1840
+ src: `/${path5.join(directoryPath, item)}`,
1773
1841
  thumbnails: {
1774
- "75x75": `/${import_node_path2.default.join(directoryPath, item)}`,
1775
- "400x400": `/${import_node_path2.default.join(directoryPath, item)}`,
1776
- "1000x1000": `/${import_node_path2.default.join(directoryPath, item)}`
1842
+ "75x75": `/${path5.join(directoryPath, item)}`,
1843
+ "400x400": `/${path5.join(directoryPath, item)}`,
1844
+ "1000x1000": `/${path5.join(directoryPath, item)}`
1777
1845
  }
1778
1846
  };
1779
1847
  if (stats.isDirectory()) {
1780
1848
  staticMediaItem.children = await listFilesRecursively({
1781
- directoryPath: import_node_path2.default.join(directoryPath, item),
1849
+ directoryPath: path5.join(directoryPath, item),
1782
1850
  config: config2,
1783
1851
  roothPath
1784
1852
  });
@@ -1819,7 +1887,7 @@ var createConfig = async ({
1819
1887
  }
1820
1888
  }
1821
1889
  });
1822
- const staticMediaPath = import_node_path2.default.join(
1890
+ const staticMediaPath = path5.join(
1823
1891
  configManager.generatedFolderPath,
1824
1892
  "static-media.json"
1825
1893
  );
@@ -1829,21 +1897,21 @@ var createConfig = async ({
1829
1897
  config: configManager.config.media.tina,
1830
1898
  roothPath: configManager.rootPath
1831
1899
  });
1832
- await import_fs_extra4.default.outputFile(staticMediaPath, JSON.stringify(staticMedia, null, 2));
1900
+ await fs4.outputFile(staticMediaPath, JSON.stringify(staticMedia, null, 2));
1833
1901
  } else {
1834
- await import_fs_extra4.default.outputFile(staticMediaPath, `[]`);
1902
+ await fs4.outputFile(staticMediaPath, `[]`);
1835
1903
  }
1836
1904
  const alias = {
1837
1905
  TINA_IMPORT: configManager.prebuildFilePath,
1838
1906
  SCHEMA_IMPORT: configManager.generatedGraphQLJSONPath,
1839
1907
  STATIC_MEDIA_IMPORT: staticMediaPath,
1840
- crypto: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
1841
- fs: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
1842
- os: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
1843
- path: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts")
1908
+ crypto: path5.join(configManager.spaRootPath, "src", "dummy-client.ts"),
1909
+ fs: path5.join(configManager.spaRootPath, "src", "dummy-client.ts"),
1910
+ os: path5.join(configManager.spaRootPath, "src", "dummy-client.ts"),
1911
+ path: path5.join(configManager.spaRootPath, "src", "dummy-client.ts")
1844
1912
  };
1845
1913
  if (configManager.shouldSkipSDK()) {
1846
- alias["CLIENT_IMPORT"] = import_node_path2.default.join(
1914
+ alias["CLIENT_IMPORT"] = path5.join(
1847
1915
  configManager.spaRootPath,
1848
1916
  "src",
1849
1917
  "dummy-client.ts"
@@ -1859,7 +1927,7 @@ var createConfig = async ({
1859
1927
  const version2 = `${fullVersion.major}.${fullVersion.minor}`;
1860
1928
  const config2 = {
1861
1929
  root: configManager.spaRootPath,
1862
- base: `/${basePath ? `${(0, import_normalize_path3.default)(basePath)}/` : ""}${(0, import_normalize_path3.default)(
1930
+ base: `/${basePath ? `${normalizePath3(basePath)}/` : ""}${normalizePath3(
1863
1931
  configManager.config.build.outputFolder
1864
1932
  )}/`,
1865
1933
  appType: "spa",
@@ -1912,7 +1980,7 @@ var createConfig = async ({
1912
1980
  }
1913
1981
  },
1914
1982
  build: {
1915
- sourcemap: true,
1983
+ sourcemap: false,
1916
1984
  outDir: configManager.outputFolderPath,
1917
1985
  emptyOutDir: true,
1918
1986
  rollupOptions
@@ -1922,13 +1990,14 @@ var createConfig = async ({
1922
1990
  * `splitVendorChunkPlugin` is needed because `tinacms` is quite large,
1923
1991
  * Vite's chunking strategy chokes on memory issues for smaller machines (ie. on CI).
1924
1992
  */
1925
- (0, import_plugin_react.default)({
1993
+ react({
1926
1994
  babel: {
1927
1995
  // Supresses the warning [NOTE] babel The code generator has deoptimised the styling of
1928
1996
  compact: true
1929
- }
1997
+ },
1998
+ fastRefresh: false
1930
1999
  }),
1931
- (0, import_vite.splitVendorChunkPlugin)(),
2000
+ splitVendorChunkPlugin(),
1932
2001
  tinaTailwind(configManager.spaRootPath, configManager.prebuildFilePath),
1933
2002
  ...plugins
1934
2003
  ]
@@ -1937,21 +2006,21 @@ var createConfig = async ({
1937
2006
  };
1938
2007
 
1939
2008
  // src/next/vite/plugins.ts
1940
- var import_pluginutils = require("@rollup/pluginutils");
1941
- var import_fs = __toESM(require("fs"));
1942
- var import_vite2 = require("vite");
1943
- var import_esbuild2 = require("esbuild");
1944
- var import_path4 = __toESM(require("path"));
1945
- var import_body_parser = __toESM(require("body-parser"));
1946
- var import_cors = __toESM(require("cors"));
1947
- var import_graphql9 = require("@tinacms/graphql");
2009
+ import { createFilter } from "@rollup/pluginutils";
2010
+ import fs6 from "fs";
2011
+ import { transformWithEsbuild } from "vite";
2012
+ import { transform as esbuildTransform } from "esbuild";
2013
+ import path7 from "path";
2014
+ import bodyParser from "body-parser";
2015
+ import cors from "cors";
2016
+ import { resolve as gqlResolve } from "@tinacms/graphql";
1948
2017
 
1949
2018
  // src/next/commands/dev-command/server/media.ts
1950
- var import_fs_extra5 = __toESM(require("fs-extra"));
1951
- var import_path3 = __toESM(require("path"));
1952
- var import_busboy = __toESM(require("busboy"));
2019
+ import fs5 from "fs-extra";
2020
+ import path6, { join } from "path";
2021
+ import busboy from "busboy";
1953
2022
  var createMediaRouter = (config2) => {
1954
- const mediaFolder = import_path3.default.join(
2023
+ const mediaFolder = path6.join(
1955
2024
  config2.rootPath,
1956
2025
  config2.publicFolder,
1957
2026
  config2.mediaRoot
@@ -1975,12 +2044,12 @@ var createMediaRouter = (config2) => {
1975
2044
  res.end(JSON.stringify(didDelete));
1976
2045
  };
1977
2046
  const handlePost = async function(req, res) {
1978
- const bb = (0, import_busboy.default)({ headers: req.headers });
2047
+ const bb = busboy({ headers: req.headers });
1979
2048
  bb.on("file", async (_name, file, _info) => {
1980
2049
  const fullPath = decodeURI(req.url?.slice("/media/upload/".length));
1981
- const saveTo = import_path3.default.join(mediaFolder, ...fullPath.split("/"));
1982
- await import_fs_extra5.default.ensureDir(import_path3.default.dirname(saveTo));
1983
- file.pipe(import_fs_extra5.default.createWriteStream(saveTo));
2050
+ const saveTo = path6.join(mediaFolder, ...fullPath.split("/"));
2051
+ await fs5.ensureDir(path6.dirname(saveTo));
2052
+ file.pipe(fs5.createWriteStream(saveTo));
1984
2053
  });
1985
2054
  bb.on("error", (error) => {
1986
2055
  res.statusCode = 500;
@@ -2006,6 +2075,9 @@ var parseMediaFolder = (str) => {
2006
2075
  return returnString;
2007
2076
  };
2008
2077
  var MediaModel = class {
2078
+ rootPath;
2079
+ publicFolder;
2080
+ mediaRoot;
2009
2081
  constructor({ rootPath, publicFolder, mediaRoot }) {
2010
2082
  this.rootPath = rootPath;
2011
2083
  this.mediaRoot = mediaRoot;
@@ -2013,23 +2085,23 @@ var MediaModel = class {
2013
2085
  }
2014
2086
  async listMedia(args) {
2015
2087
  try {
2016
- const folderPath = (0, import_path3.join)(
2088
+ const folderPath = join(
2017
2089
  this.rootPath,
2018
2090
  this.publicFolder,
2019
2091
  this.mediaRoot,
2020
2092
  decodeURIComponent(args.searchPath)
2021
2093
  );
2022
2094
  const searchPath = parseMediaFolder(args.searchPath);
2023
- if (!await import_fs_extra5.default.pathExists(folderPath)) {
2095
+ if (!await fs5.pathExists(folderPath)) {
2024
2096
  return {
2025
2097
  files: [],
2026
2098
  directories: []
2027
2099
  };
2028
2100
  }
2029
- const filesStr = await import_fs_extra5.default.readdir(folderPath);
2101
+ const filesStr = await fs5.readdir(folderPath);
2030
2102
  const filesProm = filesStr.map(async (file) => {
2031
- const filePath = (0, import_path3.join)(folderPath, file);
2032
- const stat = await import_fs_extra5.default.stat(filePath);
2103
+ const filePath = join(folderPath, file);
2104
+ const stat = await fs5.stat(filePath);
2033
2105
  let src = `/${file}`;
2034
2106
  const isFile = stat.isFile();
2035
2107
  if (!isFile) {
@@ -2085,14 +2157,14 @@ var MediaModel = class {
2085
2157
  }
2086
2158
  async deleteMedia(args) {
2087
2159
  try {
2088
- const file = (0, import_path3.join)(
2160
+ const file = join(
2089
2161
  this.rootPath,
2090
2162
  this.publicFolder,
2091
2163
  this.mediaRoot,
2092
2164
  decodeURIComponent(args.searchPath)
2093
2165
  );
2094
- await import_fs_extra5.default.stat(file);
2095
- await import_fs_extra5.default.remove(file);
2166
+ await fs5.stat(file);
2167
+ await fs5.remove(file);
2096
2168
  return { ok: true };
2097
2169
  } catch (error) {
2098
2170
  console.error(error);
@@ -2150,9 +2222,9 @@ var transformTsxPlugin = ({
2150
2222
  const plug = {
2151
2223
  name: "transform-tsx",
2152
2224
  async transform(code, id) {
2153
- const extName = import_path4.default.extname(id);
2225
+ const extName = path7.extname(id);
2154
2226
  if (extName.startsWith(".tsx") || extName.startsWith(".ts")) {
2155
- const result = await (0, import_esbuild2.transform)(code, { loader: "tsx" });
2227
+ const result = await esbuildTransform(code, { loader: "tsx" });
2156
2228
  return {
2157
2229
  code: result.code
2158
2230
  };
@@ -2171,8 +2243,8 @@ var devServerEndPointsPlugin = ({
2171
2243
  const plug = {
2172
2244
  name: "graphql-endpoints",
2173
2245
  configureServer(server) {
2174
- server.middlewares.use((0, import_cors.default)());
2175
- server.middlewares.use(import_body_parser.default.json({ limit: "5mb" }));
2246
+ server.middlewares.use(cors());
2247
+ server.middlewares.use(bodyParser.json({ limit: "5mb" }));
2176
2248
  server.middlewares.use(async (req, res, next) => {
2177
2249
  const mediaPaths = configManager.config.media?.tina;
2178
2250
  const mediaRouter = createMediaRouter({
@@ -2211,7 +2283,7 @@ var devServerEndPointsPlugin = ({
2211
2283
  const { query, variables } = req.body;
2212
2284
  let result;
2213
2285
  await databaseLock(async () => {
2214
- result = await (0, import_graphql9.resolve)({
2286
+ result = await gqlResolve({
2215
2287
  config: {
2216
2288
  useRelativeMedia: true
2217
2289
  },
@@ -2247,13 +2319,13 @@ function viteTransformExtension({
2247
2319
  include = "**/*.svg",
2248
2320
  exclude
2249
2321
  } = {}) {
2250
- const filter = (0, import_pluginutils.createFilter)(include, exclude);
2322
+ const filter = createFilter(include, exclude);
2251
2323
  return {
2252
2324
  name: "vite-plugin-svgr",
2253
2325
  async transform(code, id) {
2254
2326
  if (filter(id)) {
2255
2327
  const { transform: transform2 } = await import("@svgr/core");
2256
- const svgCode = await import_fs.default.promises.readFile(
2328
+ const svgCode = await fs6.promises.readFile(
2257
2329
  id.replace(/\?.*$/, ""),
2258
2330
  "utf8"
2259
2331
  );
@@ -2263,7 +2335,7 @@ function viteTransformExtension({
2263
2335
  previousExport: exportAsDefault ? null : code
2264
2336
  }
2265
2337
  });
2266
- const res = await (0, import_vite2.transformWithEsbuild)(componentCode, id, {
2338
+ const res = await transformWithEsbuild(componentCode, id, {
2267
2339
  loader: "jsx",
2268
2340
  ...esbuildOptions
2269
2341
  });
@@ -2290,7 +2362,7 @@ var createDevServer = async (configManager, database, searchIndex, apiURL, noWat
2290
2362
  }),
2291
2363
  viteTransformExtension()
2292
2364
  ];
2293
- return (0, import_vite3.createServer)(
2365
+ return createViteServer(
2294
2366
  await createConfig({
2295
2367
  configManager,
2296
2368
  database,
@@ -2320,37 +2392,30 @@ var createDevServer = async (configManager, database, searchIndex, apiURL, noWat
2320
2392
 
2321
2393
  // src/next/commands/dev-command/index.ts
2322
2394
  var DevCommand = class extends BaseCommand {
2323
- constructor() {
2324
- super(...arguments);
2325
- // NOTE: camelCase commands for string options don't work if there's an `=` used https://github.com/arcanis/clipanion/issues/141
2326
- this.watchFolders = import_clipanion2.Option.String("-w,--watchFolders", {
2327
- description: "DEPRECATED - a list of folders (relative to where this is being run) that the cli will watch for changes"
2328
- });
2329
- this.noWatch = import_clipanion2.Option.Boolean("--noWatch", false, {
2330
- description: "Don't regenerate config on file changes"
2331
- });
2332
- this.outputSearchIndexPath = import_clipanion2.Option.String("--outputSearchIndexPath", {
2333
- description: "Path to write the search index to"
2334
- });
2335
- this.noServer = import_clipanion2.Option.Boolean("--no-server", false, {
2336
- description: "Do not start the dev server"
2337
- });
2338
- this.indexingLock = new import_async_lock.default();
2339
- }
2340
- static {
2341
- this.paths = [["dev"], ["server:start"]];
2342
- }
2343
- static {
2344
- // Prevent indexes and reads occurring at once
2345
- this.usage = import_clipanion2.Command.Usage({
2346
- category: `Commands`,
2347
- description: `Builds Tina and starts the dev server`,
2348
- examples: [
2349
- [`A basic example`, `$0 dev`],
2350
- [`A second example`, `$0 dev --rootPath`]
2351
- ]
2352
- });
2353
- }
2395
+ static paths = [["dev"], ["server:start"]];
2396
+ // NOTE: camelCase commands for string options don't work if there's an `=` used https://github.com/arcanis/clipanion/issues/141
2397
+ watchFolders = Option2.String("-w,--watchFolders", {
2398
+ description: "DEPRECATED - a list of folders (relative to where this is being run) that the cli will watch for changes"
2399
+ });
2400
+ noWatch = Option2.Boolean("--noWatch", false, {
2401
+ description: "Don't regenerate config on file changes"
2402
+ });
2403
+ outputSearchIndexPath = Option2.String("--outputSearchIndexPath", {
2404
+ description: "Path to write the search index to"
2405
+ });
2406
+ noServer = Option2.Boolean("--no-server", false, {
2407
+ description: "Do not start the dev server"
2408
+ });
2409
+ indexingLock = new AsyncLock();
2410
+ // Prevent indexes and reads occurring at once
2411
+ static usage = Command2.Usage({
2412
+ category: `Commands`,
2413
+ description: `Builds Tina and starts the dev server`,
2414
+ examples: [
2415
+ [`A basic example`, `$0 dev`],
2416
+ [`A second example`, `$0 dev --rootPath`]
2417
+ ]
2418
+ });
2354
2419
  async catch(error) {
2355
2420
  logger.error("Error occured during tinacms dev");
2356
2421
  console.error(error);
@@ -2387,7 +2452,7 @@ var DevCommand = class extends BaseCommand {
2387
2452
  } else {
2388
2453
  database.clearCache();
2389
2454
  }
2390
- const { tinaSchema: tinaSchema2, graphQLSchema: graphQLSchema2, lookup, queryDoc, fragDoc } = await (0, import_graphql10.buildSchema)(configManager.config);
2455
+ const { tinaSchema: tinaSchema2, graphQLSchema: graphQLSchema2, lookup, queryDoc, fragDoc } = await buildSchema(configManager.config);
2391
2456
  const codegen2 = new Codegen({
2392
2457
  isLocal: true,
2393
2458
  configManager,
@@ -2401,29 +2466,32 @@ var DevCommand = class extends BaseCommand {
2401
2466
  });
2402
2467
  const apiURL2 = await codegen2.execute();
2403
2468
  if (!configManager.isUsingLegacyFolder) {
2404
- delete require.cache[configManager.generatedSchemaJSONPath];
2405
- delete require.cache[configManager.generatedLookupJSONPath];
2406
- delete require.cache[configManager.generatedGraphQLJSONPath];
2407
- const schemaObject = require(configManager.generatedSchemaJSONPath);
2408
- const lookupObject = require(configManager.generatedLookupJSONPath);
2409
- const graphqlSchemaObject = require(configManager.generatedGraphQLJSONPath);
2469
+ const schemaObject = await fs7.readJSON(
2470
+ configManager.generatedSchemaJSONPath
2471
+ );
2472
+ const lookupObject = await fs7.readJSON(
2473
+ configManager.generatedLookupJSONPath
2474
+ );
2475
+ const graphqlSchemaObject = await fs7.readJSON(
2476
+ configManager.generatedGraphQLJSONPath
2477
+ );
2410
2478
  const tinaLockFilename = "tina-lock.json";
2411
2479
  const tinaLockContent = JSON.stringify({
2412
2480
  schema: schemaObject,
2413
2481
  lookup: lookupObject,
2414
2482
  graphql: graphqlSchemaObject
2415
2483
  });
2416
- import_fs_extra6.default.writeFileSync(
2417
- import_path5.default.join(configManager.tinaFolderPath, tinaLockFilename),
2484
+ fs7.writeFileSync(
2485
+ path8.join(configManager.tinaFolderPath, tinaLockFilename),
2418
2486
  tinaLockContent
2419
2487
  );
2420
2488
  if (configManager.hasSeparateContentRoot()) {
2421
2489
  const rootPath = await configManager.getTinaFolderPath(
2422
2490
  configManager.contentRootPath
2423
2491
  );
2424
- const filePath = import_path5.default.join(rootPath, tinaLockFilename);
2425
- await import_fs_extra6.default.ensureFile(filePath);
2426
- await import_fs_extra6.default.outputFile(filePath, tinaLockContent);
2492
+ const filePath = path8.join(rootPath, tinaLockFilename);
2493
+ await fs7.ensureFile(filePath);
2494
+ await fs7.outputFile(filePath, tinaLockContent);
2427
2495
  }
2428
2496
  }
2429
2497
  await this.indexContentWithSpinner({
@@ -2466,19 +2534,19 @@ ${dangerText(e.message)}
2466
2534
  const { apiURL, graphQLSchema, tinaSchema } = await setup({
2467
2535
  firstTime: true
2468
2536
  });
2469
- await import_fs_extra6.default.outputFile(configManager.outputHTMLFilePath, devHTML(this.port));
2470
- await import_fs_extra6.default.outputFile(
2537
+ await fs7.outputFile(configManager.outputHTMLFilePath, devHTML(this.port));
2538
+ await fs7.outputFile(
2471
2539
  configManager.outputGitignorePath,
2472
2540
  "index.html\nassets/"
2473
2541
  );
2474
- const searchIndexClient = new import_search.LocalSearchIndexClient({
2542
+ const searchIndexClient = new LocalSearchIndexClient({
2475
2543
  stopwordLanguages: configManager.config.search?.tina?.stopwordLanguages,
2476
2544
  tokenSplitRegex: configManager.config.search?.tina?.tokenSplitRegex
2477
2545
  });
2478
2546
  await searchIndexClient.onStartIndexing();
2479
- const searchIndexer = new import_search.SearchIndexer({
2547
+ const searchIndexer = new SearchIndexer({
2480
2548
  batchSize: configManager.config.search?.indexBatchSize || 100,
2481
- bridge: new import_graphql10.FilesystemBridge(
2549
+ bridge: new FilesystemBridge2(
2482
2550
  configManager.rootPath,
2483
2551
  configManager.contentRootPath
2484
2552
  ),
@@ -2519,7 +2587,7 @@ ${dangerText(e.message)}
2519
2587
  );
2520
2588
  await server.listen(Number(this.port));
2521
2589
  if (!this.noWatch) {
2522
- import_chokidar.default.watch(configManager.watchList).on("change", async () => {
2590
+ chokidar.watch(configManager.watchList).on("change", async () => {
2523
2591
  await dbLock(async () => {
2524
2592
  logger.info(`Tina config change detected, rebuilding`);
2525
2593
  await setup({ firstTime: false });
@@ -2581,11 +2649,11 @@ ${dangerText(e.message)}
2581
2649
  // subItems: [
2582
2650
  // {
2583
2651
  // key: 'Custom queries',
2584
- // value: 'https://tina.io/querying',
2652
+ // value: 'https://tina.io/docs/r/content-api-overview',
2585
2653
  // },
2586
2654
  // {
2587
2655
  // key: 'Visual editing',
2588
- // value: 'https://tina.io/visual-editing',
2656
+ // value: 'https://tina.io/docs/r/visual-editing-setup',
2589
2657
  // },
2590
2658
  // ],
2591
2659
  // },
@@ -2596,14 +2664,14 @@ ${dangerText(e.message)}
2596
2664
  watchContentFiles(configManager, database, databaseLock, searchIndexer) {
2597
2665
  const collectionContentFiles = [];
2598
2666
  configManager.config.schema.collections.forEach((collection) => {
2599
- const collectionGlob = `${import_path5.default.join(
2667
+ const collectionGlob = `${path8.join(
2600
2668
  configManager.contentRootPath,
2601
2669
  collection.path
2602
2670
  )}/**/*.${collection.format || "md"}`;
2603
2671
  collectionContentFiles.push(collectionGlob);
2604
2672
  });
2605
2673
  let ready = false;
2606
- import_chokidar.default.watch(collectionContentFiles).on("ready", () => {
2674
+ chokidar.watch(collectionContentFiles).on("ready", () => {
2607
2675
  ready = true;
2608
2676
  }).on("add", async (addedFile) => {
2609
2677
  if (!ready) {
@@ -2640,28 +2708,35 @@ ${dangerText(e.message)}
2640
2708
  await callback();
2641
2709
  });
2642
2710
  };
2643
- import_chokidar.default.watch(configManager.userQueriesAndFragmentsGlob).on("add", executeCallback).on("change", executeCallback).on("unlink", executeCallback);
2711
+ chokidar.watch(configManager.userQueriesAndFragmentsGlob).on("add", executeCallback).on("change", executeCallback).on("unlink", executeCallback);
2644
2712
  }
2645
2713
  };
2646
2714
 
2647
2715
  // src/next/commands/build-command/index.ts
2648
- var import_crypto = __toESM(require("crypto"));
2649
- var import_path6 = __toESM(require("path"));
2650
- var import_core3 = require("@graphql-inspector/core");
2651
- var import_graphql11 = require("@tinacms/graphql");
2652
- var import_schema_tools2 = require("@tinacms/schema-tools");
2653
- var import_search2 = require("@tinacms/search");
2654
- var import_clipanion3 = require("clipanion");
2655
- var import_fs_extra7 = __toESM(require("fs-extra"));
2656
- var import_graphql12 = require("graphql");
2657
- var import_progress2 = __toESM(require("progress"));
2716
+ import crypto from "crypto";
2717
+ import path9 from "path";
2718
+ import { diff } from "@graphql-inspector/core";
2719
+ import { FilesystemBridge as FilesystemBridge3, buildSchema as buildSchema2 } from "@tinacms/graphql";
2720
+ import { parseURL as parseURL2 } from "@tinacms/schema-tools";
2721
+ import {
2722
+ SearchIndexer as SearchIndexer2,
2723
+ TinaCMSSearchIndexClient
2724
+ } from "@tinacms/search";
2725
+ import { Command as Command3, Option as Option3 } from "clipanion";
2726
+ import fs8 from "fs-extra";
2727
+ import {
2728
+ buildASTSchema as buildASTSchema2,
2729
+ buildClientSchema,
2730
+ getIntrospectionQuery
2731
+ } from "graphql";
2732
+ import Progress2 from "progress";
2658
2733
 
2659
2734
  // src/utils/index.ts
2660
- var import_core2 = require("@graphql-inspector/core");
2735
+ import { ChangeType } from "@graphql-inspector/core";
2661
2736
  var getFaqLink = (type) => {
2662
2737
  switch (type) {
2663
- case import_core2.ChangeType.FieldRemoved: {
2664
- return "https://tina.io/docs/introduction/faq#how-do-i-resolve-the-local-graphql-schema-doesnt-match-the-remote-graphql-schema-errors";
2738
+ case ChangeType.FieldRemoved: {
2739
+ return "https://tina.io/docs/r/FAQ/#2-how-do-i-resolve-the-local-graphql-schema-doesnt-match-the-remote-graphql-schema-error";
2665
2740
  }
2666
2741
  default:
2667
2742
  return null;
@@ -2682,7 +2757,7 @@ async function sleepAndCallFunc({
2682
2757
  }
2683
2758
 
2684
2759
  // src/next/commands/build-command/server.ts
2685
- var import_vite5 = require("vite");
2760
+ import { build as build2 } from "vite";
2686
2761
  var buildProductionSpa = async (configManager, database, apiURL) => {
2687
2762
  const publicEnv = {};
2688
2763
  Object.keys(process.env).forEach((key) => {
@@ -2716,12 +2791,12 @@ var buildProductionSpa = async (configManager, database, apiURL) => {
2716
2791
  }
2717
2792
  }
2718
2793
  });
2719
- return (0, import_vite5.build)(config2);
2794
+ return build2(config2);
2720
2795
  };
2721
2796
 
2722
2797
  // src/next/commands/build-command/waitForDB.ts
2723
- var import_schema_tools = require("@tinacms/schema-tools");
2724
- var import_progress = __toESM(require("progress"));
2798
+ import { parseURL } from "@tinacms/schema-tools";
2799
+ import Progress from "progress";
2725
2800
  var POLLING_INTERVAL = 5e3;
2726
2801
  var STATUS_INPROGRESS = "inprogress";
2727
2802
  var STATUS_COMPLETE = "complete";
@@ -2734,14 +2809,14 @@ var IndexFailedError = class extends Error {
2734
2809
  };
2735
2810
  var waitForDB = async (config2, apiUrl, previewName, verbose) => {
2736
2811
  const token = config2.token;
2737
- const { clientId, branch, isLocalClient, host } = (0, import_schema_tools.parseURL)(apiUrl);
2812
+ const { clientId, branch, isLocalClient, host } = parseURL(apiUrl);
2738
2813
  if (isLocalClient || !host || !clientId || !branch) {
2739
2814
  if (verbose) {
2740
2815
  logger.info(logText("Not using TinaCloud, skipping DB check"));
2741
2816
  }
2742
2817
  return;
2743
2818
  }
2744
- const bar2 = new import_progress.default(
2819
+ const bar2 = new Progress(
2745
2820
  "Checking indexing process in TinaCloud... :prog",
2746
2821
  1
2747
2822
  );
@@ -2804,51 +2879,44 @@ var waitForDB = async (config2, apiUrl, previewName, verbose) => {
2804
2879
 
2805
2880
  // src/next/commands/build-command/index.ts
2806
2881
  var BuildCommand = class extends BaseCommand {
2807
- constructor() {
2808
- super(...arguments);
2809
- this.localOption = import_clipanion3.Option.Boolean("--local", {
2810
- description: "Starts local Graphql server and builds the local client instead of production client"
2811
- });
2812
- this.skipIndexing = import_clipanion3.Option.Boolean("--skip-indexing", false, {
2813
- description: "Skips indexing the content. This can be used for building the site without indexing the content (defaults to false)"
2814
- });
2815
- this.partialReindex = import_clipanion3.Option.Boolean("--partial-reindex", false, {
2816
- description: "Re-indexes only the content that has changed since the last build (defaults to false). Not currently supported for separate content repos."
2817
- });
2818
- this.tinaGraphQLVersion = import_clipanion3.Option.String("--tina-graphql-version", {
2819
- description: "Specify the version of @tinacms/graphql to use (defaults to latest)"
2820
- });
2821
- /**
2822
- * 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
2823
- */
2824
- this.skipCloudChecks = import_clipanion3.Option.Boolean("--skip-cloud-checks", false, {
2825
- description: "Skips checking the provided cloud config."
2826
- });
2827
- this.skipSearchIndex = import_clipanion3.Option.Boolean("--skip-search-index", false, {
2828
- description: "Skip indexing the site for search"
2829
- });
2830
- this.upstreamBranch = import_clipanion3.Option.String("--upstream-branch", {
2831
- description: "Optional upstream branch with the schema. If not specified, default will be used."
2832
- });
2833
- this.previewBaseBranch = import_clipanion3.Option.String("--preview-base-branch", {
2834
- description: "The base branch for the preview"
2835
- });
2836
- this.previewName = import_clipanion3.Option.String("--preview-name", {
2837
- description: "The name of the preview branch"
2838
- });
2839
- this.noClientBuildCache = import_clipanion3.Option.Boolean("--no-client-build-cache", false, {
2840
- description: "Disables the client build cache"
2841
- });
2842
- }
2843
- static {
2844
- this.paths = [["build"]];
2845
- }
2846
- static {
2847
- this.usage = import_clipanion3.Command.Usage({
2848
- category: `Commands`,
2849
- description: `Build the CMS and autogenerated modules for usage with TinaCloud`
2850
- });
2851
- }
2882
+ static paths = [["build"]];
2883
+ localOption = Option3.Boolean("--local", {
2884
+ description: "Starts local Graphql server and builds the local client instead of production client"
2885
+ });
2886
+ skipIndexing = Option3.Boolean("--skip-indexing", false, {
2887
+ description: "Skips indexing the content. This can be used for building the site without indexing the content (defaults to false)"
2888
+ });
2889
+ partialReindex = Option3.Boolean("--partial-reindex", false, {
2890
+ description: "Re-indexes only the content that has changed since the last build (defaults to false). Not currently supported for separate content repos."
2891
+ });
2892
+ tinaGraphQLVersion = Option3.String("--tina-graphql-version", {
2893
+ description: "Specify the version of @tinacms/graphql to use (defaults to latest)"
2894
+ });
2895
+ /**
2896
+ * 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
2897
+ */
2898
+ skipCloudChecks = Option3.Boolean("--skip-cloud-checks", false, {
2899
+ description: "Skips checking the provided cloud config."
2900
+ });
2901
+ skipSearchIndex = Option3.Boolean("--skip-search-index", false, {
2902
+ description: "Skip indexing the site for search"
2903
+ });
2904
+ upstreamBranch = Option3.String("--upstream-branch", {
2905
+ description: "Optional upstream branch with the schema. If not specified, default will be used."
2906
+ });
2907
+ previewBaseBranch = Option3.String("--preview-base-branch", {
2908
+ description: "The base branch for the preview"
2909
+ });
2910
+ previewName = Option3.String("--preview-name", {
2911
+ description: "The name of the preview branch"
2912
+ });
2913
+ noClientBuildCache = Option3.Boolean("--no-client-build-cache", false, {
2914
+ description: "Disables the client build cache"
2915
+ });
2916
+ static usage = Command3.Usage({
2917
+ category: `Commands`,
2918
+ description: `Build the CMS and autogenerated modules for usage with TinaCloud`
2919
+ });
2852
2920
  async catch(error) {
2853
2921
  console.error(error);
2854
2922
  process.exit(1);
@@ -2893,7 +2961,7 @@ ${dangerText(e.message)}`);
2893
2961
  configManager,
2894
2962
  Number(this.datalayerPort)
2895
2963
  );
2896
- const { queryDoc, fragDoc, graphQLSchema, tinaSchema, lookup } = await (0, import_graphql11.buildSchema)(configManager.config);
2964
+ const { queryDoc, fragDoc, graphQLSchema, tinaSchema, lookup } = await buildSchema2(configManager.config);
2897
2965
  const codegen2 = new Codegen({
2898
2966
  configManager,
2899
2967
  port: this.localOption ? Number(this.port) : void 0,
@@ -2942,48 +3010,66 @@ ${dangerText(e.message)}
2942
3010
  }
2943
3011
  const skipCloudChecks = this.skipCloudChecks || configManager.hasSelfHostedConfig();
2944
3012
  if (!skipCloudChecks) {
2945
- const { hasUpstream, timestamp } = await this.checkClientInfo(
2946
- configManager,
2947
- codegen2.productionUrl,
2948
- this.previewBaseBranch
2949
- );
2950
- if (!hasUpstream && this.upstreamBranch) {
2951
- logger.warn(
2952
- `${dangerText(
2953
- `WARN: Upstream branch '${this.upstreamBranch}' specified but no upstream project was found.`
2954
- )}`
3013
+ try {
3014
+ const clientInfo = await this.checkClientInfo(
3015
+ configManager,
3016
+ codegen2.productionUrl,
3017
+ this.previewBaseBranch
2955
3018
  );
3019
+ if (clientInfo.detectedBotBranch) {
3020
+ logger.warn(
3021
+ `${warnText(
3022
+ `WARN: Detected bot branch. Using schema/content from default branch '${clientInfo.defaultBranch}' instead of '${configManager.config.branch}'.`
3023
+ )}`
3024
+ );
3025
+ }
3026
+ if (!clientInfo.hasUpstream && this.upstreamBranch) {
3027
+ logger.warn(
3028
+ `${dangerText(
3029
+ `WARN: Upstream branch '${this.upstreamBranch}' specified but no upstream project was found.`
3030
+ )}`
3031
+ );
3032
+ }
3033
+ if (clientInfo.hasUpstream || this.previewBaseBranch && this.previewName) {
3034
+ await this.syncProject(configManager, codegen2.productionUrl, {
3035
+ upstreamBranch: this.upstreamBranch,
3036
+ previewBaseBranch: this.previewBaseBranch,
3037
+ previewName: this.previewName
3038
+ });
3039
+ }
3040
+ await waitForDB(
3041
+ configManager.config,
3042
+ codegen2.productionUrl,
3043
+ this.previewName,
3044
+ false
3045
+ );
3046
+ await this.checkGraphqlSchema(
3047
+ configManager,
3048
+ database,
3049
+ codegen2.productionUrl,
3050
+ clientInfo.timestamp
3051
+ );
3052
+ await this.checkTinaSchema(
3053
+ configManager,
3054
+ database,
3055
+ codegen2.productionUrl,
3056
+ this.previewName,
3057
+ this.verbose,
3058
+ clientInfo.timestamp
3059
+ );
3060
+ } catch (e) {
3061
+ logger.error(`
3062
+
3063
+ ${dangerText(e.message)}
3064
+ `);
3065
+ if (this.verbose) {
3066
+ console.error(e);
3067
+ }
3068
+ process.exit(1);
2956
3069
  }
2957
- if (hasUpstream || this.previewBaseBranch && this.previewName) {
2958
- await this.syncProject(configManager, codegen2.productionUrl, {
2959
- upstreamBranch: this.upstreamBranch,
2960
- previewBaseBranch: this.previewBaseBranch,
2961
- previewName: this.previewName
2962
- });
2963
- }
2964
- await waitForDB(
2965
- configManager.config,
2966
- codegen2.productionUrl,
2967
- this.previewName,
2968
- false
2969
- );
2970
- await this.checkGraphqlSchema(
2971
- configManager,
2972
- database,
2973
- codegen2.productionUrl,
2974
- timestamp
2975
- );
2976
- await this.checkTinaSchema(
2977
- configManager,
2978
- database,
2979
- codegen2.productionUrl,
2980
- this.previewName,
2981
- this.verbose,
2982
- timestamp
2983
- );
2984
3070
  }
2985
3071
  await buildProductionSpa(configManager, database, codegen2.productionUrl);
2986
- await import_fs_extra7.default.outputFile(
3072
+ await fs8.outputFile(
2987
3073
  configManager.outputGitignorePath,
2988
3074
  "index.html\nassets/"
2989
3075
  );
@@ -3015,7 +3101,7 @@ ${dangerText(e.message)}
3015
3101
  "indexerToken not configured in tina search configuration."
3016
3102
  );
3017
3103
  }
3018
- client = new import_search2.TinaCMSSearchIndexClient({
3104
+ client = new TinaCMSSearchIndexClient({
3019
3105
  apiUrl: `${configManager.config.tinaioConfig?.contentApiUrlOverride || "https://content.tinajs.io"}/searchIndex/${configManager.config?.clientId}`,
3020
3106
  branch: configManager.config?.branch,
3021
3107
  indexerToken: configManager.config?.search?.tina?.indexerToken,
@@ -3024,9 +3110,9 @@ ${dangerText(e.message)}
3024
3110
  } else {
3025
3111
  client = configManager.config?.search?.searchClient;
3026
3112
  }
3027
- const searchIndexer = new import_search2.SearchIndexer({
3113
+ const searchIndexer = new SearchIndexer2({
3028
3114
  batchSize: configManager.config.search?.indexBatchSize || 100,
3029
- bridge: new import_graphql11.FilesystemBridge(
3115
+ bridge: new FilesystemBridge3(
3030
3116
  configManager.rootPath,
3031
3117
  configManager.contentRootPath
3032
3118
  ),
@@ -3093,86 +3179,88 @@ ${dangerText(e.message)}
3093
3179
  }
3094
3180
  }
3095
3181
  async checkClientInfo(configManager, apiURL, previewBaseBranch) {
3182
+ const MAX_RETRIES = 5;
3096
3183
  const { config: config2 } = configManager;
3097
3184
  const token = config2.token;
3098
- const { clientId, branch, host } = (0, import_schema_tools2.parseURL)(apiURL);
3099
- const url = `https://${host}/db/${clientId}/status/${previewBaseBranch || branch}`;
3100
- const bar2 = new import_progress2.default("Checking clientId and token. :prog", 1);
3101
- let branchKnown = false;
3102
- let hasUpstream = false;
3103
- let timestamp;
3104
- try {
3105
- const res = await request({
3106
- token,
3107
- url
3108
- });
3109
- timestamp = res.timestamp || 0;
3110
- bar2.tick({
3111
- prog: "\u2705"
3112
- });
3113
- if (!(res.status === "unknown")) {
3114
- branchKnown = true;
3115
- }
3116
- if (res.hasUpstream) {
3117
- hasUpstream = true;
3185
+ const { clientId, branch, host } = parseURL2(apiURL);
3186
+ const bar2 = new Progress2("Checking clientId and token. :prog", 1);
3187
+ const getBranchInfo = async () => {
3188
+ const url = `https://${host}/db/${clientId}/status/${previewBaseBranch || branch}`;
3189
+ const branchInfo2 = {
3190
+ status: "unknown",
3191
+ branchKnown: false,
3192
+ hasUpstream: false,
3193
+ timestamp: 0,
3194
+ detectedBotBranch: false,
3195
+ defaultBranch: void 0
3196
+ };
3197
+ try {
3198
+ const res = await request({
3199
+ token,
3200
+ url
3201
+ });
3202
+ branchInfo2.status = res.status;
3203
+ branchInfo2.branchKnown = res.status !== "unknown";
3204
+ branchInfo2.timestamp = res.timestamp || 0;
3205
+ branchInfo2.hasUpstream = res.hasUpstream;
3206
+ branchInfo2.detectedBotBranch = res.json.detectedBotBranch;
3207
+ branchInfo2.defaultBranch = res.json.defaultBranch;
3208
+ } catch (e) {
3209
+ summary({
3210
+ heading: "Error when checking client information",
3211
+ items: [
3212
+ {
3213
+ emoji: "\u274C",
3214
+ heading: "You provided",
3215
+ subItems: [
3216
+ {
3217
+ key: "clientId",
3218
+ value: config2.clientId
3219
+ },
3220
+ {
3221
+ key: "branch",
3222
+ value: config2.branch
3223
+ },
3224
+ {
3225
+ key: "token",
3226
+ value: config2.token
3227
+ }
3228
+ ]
3229
+ }
3230
+ ]
3231
+ });
3232
+ throw e;
3118
3233
  }
3119
- } catch (e) {
3120
- summary({
3121
- heading: "Error when checking client information",
3122
- items: [
3123
- {
3124
- emoji: "\u274C",
3125
- heading: "You provided",
3126
- subItems: [
3127
- {
3128
- key: "clientId",
3129
- value: config2.clientId
3130
- },
3131
- {
3132
- key: "branch",
3133
- value: config2.branch
3134
- },
3135
- {
3136
- key: "token",
3137
- value: config2.token
3138
- }
3139
- ]
3140
- }
3141
- ]
3142
- });
3143
- throw e;
3144
- }
3145
- const branchBar = new import_progress2.default("Checking branch is on TinaCloud. :prog", 1);
3146
- if (branchKnown) {
3234
+ return branchInfo2;
3235
+ };
3236
+ const branchInfo = await getBranchInfo();
3237
+ bar2.tick({
3238
+ prog: "\u2705"
3239
+ });
3240
+ const branchBar = new Progress2(
3241
+ `Checking branch '${config2.branch}' is on TinaCloud. :prog`,
3242
+ 1
3243
+ );
3244
+ if (branchInfo.branchKnown) {
3147
3245
  branchBar.tick({
3148
3246
  prog: "\u2705"
3149
3247
  });
3150
- return {
3151
- hasUpstream,
3152
- timestamp
3153
- };
3248
+ return branchInfo;
3154
3249
  }
3155
- for (let i = 0; i <= 5; i++) {
3156
- await sleepAndCallFunc({
3157
- fn: async () => {
3158
- const res = await request({
3159
- token,
3160
- url
3161
- });
3162
- if (this.verbose) {
3163
- logger.info(
3164
- `Branch status: ${res.status}. Attempt: ${i + 1}. Trying again in 5 seconds.`
3165
- );
3166
- }
3167
- if (!(res.status === "unknown")) {
3168
- branchBar.tick({
3169
- prog: "\u2705"
3170
- });
3171
- return;
3172
- }
3173
- },
3174
- ms: 5e3
3175
- });
3250
+ for (let i = 1; i <= MAX_RETRIES; i++) {
3251
+ await timeout(5e3);
3252
+ const branchInfo2 = await getBranchInfo();
3253
+ if (this.verbose) {
3254
+ logger.info(
3255
+ `Branch status: ${branchInfo2.status}. Attempt: ${i}. Trying again in 5 seconds.`
3256
+ );
3257
+ }
3258
+ if (branchInfo2.branchKnown) {
3259
+ branchBar.tick({
3260
+ prog: "\u2705"
3261
+ });
3262
+ return branchInfo2;
3263
+ }
3176
3264
  }
3177
3265
  branchBar.tick({
3178
3266
  prog: "\u274C"
@@ -3180,7 +3268,7 @@ ${dangerText(e.message)}
3180
3268
  logger.error(
3181
3269
  `${dangerText(
3182
3270
  `ERROR: Branch '${branch}' is not on TinaCloud.`
3183
- )} 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(
3271
+ )} 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(
3184
3272
  `https://app.tina.io/projects/${clientId}/configuration`
3185
3273
  )}`
3186
3274
  );
@@ -3189,7 +3277,7 @@ ${dangerText(e.message)}
3189
3277
  async syncProject(configManager, apiURL, options) {
3190
3278
  const { config: config2 } = configManager;
3191
3279
  const token = config2.token;
3192
- const { clientId, branch, host } = (0, import_schema_tools2.parseURL)(apiURL);
3280
+ const { clientId, branch, host } = parseURL2(apiURL);
3193
3281
  const { previewName, previewBaseBranch, upstreamBranch } = options || {};
3194
3282
  let url = `https://${host}/db/${clientId}/reset/${branch}?refreshSchema=true&skipIfSchemaCurrent=true`;
3195
3283
  if (upstreamBranch && previewBaseBranch && previewName) {
@@ -3199,7 +3287,7 @@ ${dangerText(e.message)}
3199
3287
  } else if (upstreamBranch && !previewBaseBranch && !previewName) {
3200
3288
  url = `https://${host}/db/${clientId}/reset/${branch}?refreshSchema=true&skipIfSchemaCurrent=true&upstreamBranch=${upstreamBranch}`;
3201
3289
  }
3202
- const bar2 = new import_progress2.default("Syncing Project. :prog", 1);
3290
+ const bar2 = new Progress2("Syncing Project. :prog", 1);
3203
3291
  try {
3204
3292
  const res = await request({
3205
3293
  token,
@@ -3240,7 +3328,7 @@ ${dangerText(e.message)}
3240
3328
  }
3241
3329
  }
3242
3330
  async checkGraphqlSchema(configManager, database, apiURL, timestamp) {
3243
- const bar2 = new import_progress2.default(
3331
+ const bar2 = new Progress2(
3244
3332
  "Checking local GraphQL Schema matches server. :prog",
3245
3333
  1
3246
3334
  );
@@ -3262,11 +3350,11 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3262
3350
  }
3263
3351
  throw new Error(errorMessage);
3264
3352
  }
3265
- const remoteGqlSchema = (0, import_graphql12.buildClientSchema)(remoteSchema);
3353
+ const remoteGqlSchema = buildClientSchema(remoteSchema);
3266
3354
  const localSchemaDocument = await database.getGraphQLSchemaFromBridge();
3267
- const localGraphqlSchema = (0, import_graphql12.buildASTSchema)(localSchemaDocument);
3355
+ const localGraphqlSchema = buildASTSchema2(localSchemaDocument);
3268
3356
  try {
3269
- const diffResult = await (0, import_core3.diff)(remoteGqlSchema, localGraphqlSchema);
3357
+ const diffResult = await diff(remoteGqlSchema, localGraphqlSchema);
3270
3358
  if (diffResult.length === 0) {
3271
3359
  bar2.tick({
3272
3360
  prog: "\u2705"
@@ -3314,13 +3402,13 @@ Additional info:
3314
3402
  }
3315
3403
  }
3316
3404
  async checkTinaSchema(configManager, database, apiURL, previewName, verbose, timestamp) {
3317
- const bar2 = new import_progress2.default(
3405
+ const bar2 = new Progress2(
3318
3406
  "Checking local Tina Schema matches server. :prog",
3319
3407
  1
3320
3408
  );
3321
3409
  const { config: config2 } = configManager;
3322
3410
  const token = config2.token;
3323
- const { clientId, branch, isLocalClient, host } = (0, import_schema_tools2.parseURL)(apiURL);
3411
+ const { clientId, branch, isLocalClient, host } = parseURL2(apiURL);
3324
3412
  if (isLocalClient || !host || !clientId || !branch) {
3325
3413
  if (verbose) {
3326
3414
  logger.info(logText("Not using TinaCloud, skipping Tina Schema check"));
@@ -3348,11 +3436,11 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3348
3436
  }
3349
3437
  const localTinaSchema = JSON.parse(
3350
3438
  await database.bridge.get(
3351
- import_path6.default.join(database.tinaDirectory, "__generated__", "_schema.json")
3439
+ path9.join(database.tinaDirectory, "__generated__", "_schema.json")
3352
3440
  )
3353
3441
  );
3354
3442
  localTinaSchema.version = void 0;
3355
- const localTinaSchemaSha = import_crypto.default.createHash("sha256").update(JSON.stringify(localTinaSchema)).digest("hex");
3443
+ const localTinaSchemaSha = crypto.createHash("sha256").update(JSON.stringify(localTinaSchema)).digest("hex");
3356
3444
  if (localTinaSchemaSha === remoteTinaSchemaSha) {
3357
3445
  bar2.tick({
3358
3446
  prog: "\u2705"
@@ -3403,12 +3491,12 @@ async function request(args) {
3403
3491
  Message from server: ${json.message}`;
3404
3492
  }
3405
3493
  throw new Error(
3406
- `Server responded with status code ${res.status}, ${res.statusText}. ${additionalInfo ? additionalInfo : ""} Please see our FAQ for more information: https://tina.io/docs/errors/faq/`
3494
+ `Server responded with status code ${res.status}, ${res.statusText}. ${additionalInfo ? additionalInfo : ""} Please see our FAQ for more information: https://tina.io/docs/r/FAQ/`
3407
3495
  );
3408
3496
  }
3409
3497
  if (json.errors) {
3410
3498
  throw new Error(
3411
- `Unable to fetch, please see our FAQ for more information: https://tina.io/docs/errors/faq/
3499
+ `Unable to fetch, please see our FAQ for more information: https://tina.io/docs/r/FAQ/
3412
3500
 
3413
3501
  Errors:
3414
3502
  ${json.errors.map((error) => error.message).join("\n")}`
@@ -3417,7 +3505,8 @@ Message from server: ${json.message}`;
3417
3505
  return {
3418
3506
  status: json?.status,
3419
3507
  timestamp: json?.timestamp,
3420
- hasUpstream: json?.hasUpstream || false
3508
+ hasUpstream: json?.hasUpstream || false,
3509
+ json
3421
3510
  };
3422
3511
  }
3423
3512
  var fetchRemoteGraphqlSchema = async ({
@@ -3429,7 +3518,7 @@ var fetchRemoteGraphqlSchema = async ({
3429
3518
  headers.append("X-API-KEY", token);
3430
3519
  }
3431
3520
  const body = JSON.stringify({
3432
- query: (0, import_graphql12.getIntrospectionQuery)(),
3521
+ query: getIntrospectionQuery(),
3433
3522
  variables: {}
3434
3523
  });
3435
3524
  headers.append("Content-Type", "application/json");
@@ -3462,14 +3551,14 @@ var fetchSchemaSha = async ({
3462
3551
  };
3463
3552
 
3464
3553
  // src/next/commands/audit-command/index.ts
3465
- var import_clipanion4 = require("clipanion");
3466
- var import_graphql14 = require("@tinacms/graphql");
3554
+ import { Command as Command4, Option as Option4 } from "clipanion";
3555
+ import { buildSchema as buildSchema3 } from "@tinacms/graphql";
3467
3556
 
3468
3557
  // src/next/commands/audit-command/audit.ts
3469
- var import_prompts = __toESM(require("prompts"));
3470
- var import_metrics = require("@tinacms/metrics");
3471
- var import_graphql13 = require("@tinacms/graphql");
3472
- var import_chalk5 = __toESM(require("chalk"));
3558
+ import prompts from "prompts";
3559
+ import { Telemetry } from "@tinacms/metrics";
3560
+ import { resolve } from "@tinacms/graphql";
3561
+ import chalk5 from "chalk";
3473
3562
  var audit = async ({
3474
3563
  database,
3475
3564
  clean,
@@ -3477,7 +3566,7 @@ var audit = async ({
3477
3566
  noTelemetry,
3478
3567
  verbose
3479
3568
  }) => {
3480
- const telemetry = new import_metrics.Telemetry({ disabled: noTelemetry });
3569
+ const telemetry = new Telemetry({ disabled: noTelemetry });
3481
3570
  await telemetry.submitRecord({
3482
3571
  event: {
3483
3572
  name: "tinacms:cli:audit:invoke",
@@ -3487,25 +3576,25 @@ var audit = async ({
3487
3576
  });
3488
3577
  if (clean) {
3489
3578
  logger.info(
3490
- `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(
3579
+ `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(
3491
3580
  "clean git tree"
3492
3581
  )} so unwanted changes can be undone.
3493
3582
 
3494
3583
  `
3495
3584
  );
3496
- const res = await (0, import_prompts.default)({
3585
+ const res = await prompts({
3497
3586
  name: "useClean",
3498
3587
  type: "confirm",
3499
3588
  message: `Do you want to continue?`
3500
3589
  });
3501
3590
  if (!res.useClean) {
3502
- logger.warn(import_chalk5.default.yellowBright("\u26A0\uFE0F Audit not complete"));
3591
+ logger.warn(chalk5.yellowBright("\u26A0\uFE0F Audit not complete"));
3503
3592
  process.exit(0);
3504
3593
  }
3505
3594
  }
3506
3595
  if (useDefaultValues && !clean) {
3507
3596
  logger.warn(
3508
- import_chalk5.default.yellowBright(
3597
+ chalk5.yellowBright(
3509
3598
  "WARNING: using the `--useDefaultValues` without the `--clean` flag has no effect. Please re-run audit and add the `--clean` flag"
3510
3599
  )
3511
3600
  );
@@ -3533,10 +3622,10 @@ var audit = async ({
3533
3622
  }
3534
3623
  if (error) {
3535
3624
  logger.error(
3536
- import_chalk5.default.redBright(`\u203C\uFE0F Audit ${import_chalk5.default.bold("failed")} with errors`)
3625
+ chalk5.redBright(`\u203C\uFE0F Audit ${chalk5.bold("failed")} with errors`)
3537
3626
  );
3538
3627
  } else {
3539
- logger.info(import_chalk5.default.greenBright("\u2705 Audit passed"));
3628
+ logger.info(chalk5.greenBright("\u2705 Audit passed"));
3540
3629
  }
3541
3630
  };
3542
3631
  var auditDocuments = async (args) => {
@@ -3553,7 +3642,7 @@ var auditDocuments = async (args) => {
3553
3642
  }
3554
3643
  }
3555
3644
  }`;
3556
- const docResult = await (0, import_graphql13.resolve)({
3645
+ const docResult = await resolve({
3557
3646
  database,
3558
3647
  query: documentQuery,
3559
3648
  variables: {},
@@ -3564,11 +3653,11 @@ var auditDocuments = async (args) => {
3564
3653
  if (docResult.errors) {
3565
3654
  error = true;
3566
3655
  docResult.errors.forEach((err) => {
3567
- logger.error(import_chalk5.default.red(err.message));
3656
+ logger.error(chalk5.red(err.message));
3568
3657
  if (err.originalError.originalError) {
3569
3658
  logger.error(
3570
3659
  // @ts-ignore FIXME: this doesn't seem right
3571
- import_chalk5.default.red(` ${err.originalError.originalError.message}`)
3660
+ chalk5.red(` ${err.originalError.originalError.message}`)
3572
3661
  );
3573
3662
  }
3574
3663
  });
@@ -3595,7 +3684,7 @@ var auditDocuments = async (args) => {
3595
3684
  params: $params
3596
3685
  ){__typename}
3597
3686
  }`;
3598
- const mutationRes = await (0, import_graphql13.resolve)({
3687
+ const mutationRes = await resolve({
3599
3688
  database,
3600
3689
  query: mutation,
3601
3690
  variables: {
@@ -3610,7 +3699,7 @@ var auditDocuments = async (args) => {
3610
3699
  if (mutationRes.errors) {
3611
3700
  mutationRes.errors.forEach((err) => {
3612
3701
  error = true;
3613
- logger.error(import_chalk5.default.red(err.message));
3702
+ logger.error(chalk5.red(err.message));
3614
3703
  });
3615
3704
  }
3616
3705
  }
@@ -3627,38 +3716,31 @@ function filterObject(obj) {
3627
3716
  }
3628
3717
 
3629
3718
  // src/next/commands/audit-command/index.ts
3630
- var import_graphql15 = require("@tinacms/graphql");
3631
- var AuditCommand = class extends import_clipanion4.Command {
3632
- constructor() {
3633
- super(...arguments);
3634
- this.rootPath = import_clipanion4.Option.String("--rootPath", {
3635
- description: "Specify the root directory to run the CLI from"
3636
- });
3637
- this.verbose = import_clipanion4.Option.Boolean("-v,--verbose", false, {
3638
- description: "increase verbosity of logged output"
3639
- });
3640
- this.clean = import_clipanion4.Option.Boolean("--clean", false, {
3641
- description: "Clean the output"
3642
- });
3643
- this.useDefaultValues = import_clipanion4.Option.Boolean("--useDefaultValues", false, {
3644
- description: "When cleaning the output, use defaults on the config"
3645
- });
3646
- this.noTelemetry = import_clipanion4.Option.Boolean("--noTelemetry", false, {
3647
- description: "Disable anonymous telemetry that is collected"
3648
- });
3649
- this.datalayerPort = import_clipanion4.Option.String("--datalayer-port", "9000", {
3650
- description: "Specify a port to run the datalayer server on. (default 9000)"
3651
- });
3652
- }
3653
- static {
3654
- this.paths = [["audit"]];
3655
- }
3656
- static {
3657
- this.usage = import_clipanion4.Command.Usage({
3658
- category: `Commands`,
3659
- description: `Audit config and content files`
3660
- });
3661
- }
3719
+ import { AuditFileSystemBridge } from "@tinacms/graphql";
3720
+ var AuditCommand = class extends Command4 {
3721
+ static paths = [["audit"]];
3722
+ rootPath = Option4.String("--rootPath", {
3723
+ description: "Specify the root directory to run the CLI from"
3724
+ });
3725
+ verbose = Option4.Boolean("-v,--verbose", false, {
3726
+ description: "increase verbosity of logged output"
3727
+ });
3728
+ clean = Option4.Boolean("--clean", false, {
3729
+ description: "Clean the output"
3730
+ });
3731
+ useDefaultValues = Option4.Boolean("--useDefaultValues", false, {
3732
+ description: "When cleaning the output, use defaults on the config"
3733
+ });
3734
+ noTelemetry = Option4.Boolean("--noTelemetry", false, {
3735
+ description: "Disable anonymous telemetry that is collected"
3736
+ });
3737
+ datalayerPort = Option4.String("--datalayer-port", "9000", {
3738
+ description: "Specify a port to run the datalayer server on. (default 9000)"
3739
+ });
3740
+ static usage = Command4.Usage({
3741
+ category: `Commands`,
3742
+ description: `Audit config and content files`
3743
+ });
3662
3744
  async catch(error) {
3663
3745
  logger.error("Error occured during tinacms audit");
3664
3746
  if (this.verbose) {
@@ -3679,9 +3761,9 @@ var AuditCommand = class extends import_clipanion4.Command {
3679
3761
  const database = await createAndInitializeDatabase(
3680
3762
  configManager,
3681
3763
  Number(this.datalayerPort),
3682
- this.clean ? void 0 : new import_graphql15.AuditFileSystemBridge(configManager.rootPath)
3764
+ this.clean ? void 0 : new AuditFileSystemBridge(configManager.rootPath)
3683
3765
  );
3684
- const { tinaSchema, graphQLSchema, lookup } = await (0, import_graphql14.buildSchema)(
3766
+ const { tinaSchema, graphQLSchema, lookup } = await buildSchema3(
3685
3767
  configManager.config
3686
3768
  );
3687
3769
  const warnings = [];
@@ -3714,29 +3796,29 @@ var AuditCommand = class extends import_clipanion4.Command {
3714
3796
  };
3715
3797
 
3716
3798
  // src/next/commands/init-command/index.ts
3717
- var import_clipanion6 = require("clipanion");
3799
+ import { Command as Command6, Option as Option6 } from "clipanion";
3718
3800
 
3719
3801
  // src/cmds/init/detectEnvironment.ts
3720
- var import_fs_extra8 = __toESM(require("fs-extra"));
3721
- var import_path7 = __toESM(require("path"));
3802
+ import fs9 from "fs-extra";
3803
+ import path10 from "path";
3722
3804
  var checkGitignoreForItem = async ({
3723
3805
  baseDir,
3724
3806
  line
3725
3807
  }) => {
3726
- const gitignoreContent = import_fs_extra8.default.readFileSync(import_path7.default.join(baseDir, ".gitignore")).toString();
3808
+ const gitignoreContent = fs9.readFileSync(path10.join(baseDir, ".gitignore")).toString();
3727
3809
  return gitignoreContent.split("\n").some((item) => item === line);
3728
3810
  };
3729
3811
  var makeGeneratedFile = async (name2, generatedFileType, parentPath, opts) => {
3730
3812
  const result = {
3731
- fullPathTS: import_path7.default.join(
3813
+ fullPathTS: path10.join(
3732
3814
  parentPath,
3733
3815
  `${name2}.${opts?.typescriptSuffix || opts?.extensionOverride || "ts"}`
3734
3816
  ),
3735
- fullPathJS: import_path7.default.join(
3817
+ fullPathJS: path10.join(
3736
3818
  parentPath,
3737
3819
  `${name2}.${opts?.extensionOverride || "js"}`
3738
3820
  ),
3739
- fullPathOverride: opts?.extensionOverride ? import_path7.default.join(parentPath, `${name2}.${opts?.extensionOverride}`) : "",
3821
+ fullPathOverride: opts?.extensionOverride ? path10.join(parentPath, `${name2}.${opts?.extensionOverride}`) : "",
3740
3822
  generatedFileType,
3741
3823
  name: name2,
3742
3824
  parentPath,
@@ -3754,8 +3836,8 @@ var makeGeneratedFile = async (name2, generatedFileType, parentPath, opts) => {
3754
3836
  };
3755
3837
  }
3756
3838
  };
3757
- result.typescriptExists = await import_fs_extra8.default.pathExists(result.fullPathTS);
3758
- result.javascriptExists = await import_fs_extra8.default.pathExists(result.fullPathJS);
3839
+ result.typescriptExists = await fs9.pathExists(result.fullPathTS);
3840
+ result.javascriptExists = await fs9.pathExists(result.fullPathJS);
3759
3841
  return result;
3760
3842
  };
3761
3843
  var detectEnvironment = async ({
@@ -3764,21 +3846,21 @@ var detectEnvironment = async ({
3764
3846
  rootPath,
3765
3847
  debug = false
3766
3848
  }) => {
3767
- const hasForestryConfig = await import_fs_extra8.default.pathExists(
3768
- import_path7.default.join(pathToForestryConfig, ".forestry", "settings.yml")
3849
+ const hasForestryConfig = await fs9.pathExists(
3850
+ path10.join(pathToForestryConfig, ".forestry", "settings.yml")
3769
3851
  );
3770
- const sampleContentPath = import_path7.default.join(
3852
+ const sampleContentPath = path10.join(
3771
3853
  baseDir,
3772
3854
  "content",
3773
3855
  "posts",
3774
3856
  "hello-world.md"
3775
3857
  );
3776
- 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")));
3777
- const tinaFolder = import_path7.default.join(baseDir, "tina");
3858
+ const usingSrc = fs9.pathExistsSync(path10.join(baseDir, "src")) && (fs9.pathExistsSync(path10.join(baseDir, "src", "app")) || fs9.pathExistsSync(path10.join(baseDir, "src", "pages")));
3859
+ const tinaFolder = path10.join(baseDir, "tina");
3778
3860
  const tinaConfigExists = Boolean(
3779
3861
  // Does the tina folder exist?
3780
- await import_fs_extra8.default.pathExists(tinaFolder) && // Does the tina folder contain a config file?
3781
- (await import_fs_extra8.default.readdir(tinaFolder)).find((x) => x.includes("config"))
3862
+ await fs9.pathExists(tinaFolder) && // Does the tina folder contain a config file?
3863
+ (await fs9.readdir(tinaFolder)).find((x) => x.includes("config"))
3782
3864
  );
3783
3865
  const pagesDir = [baseDir, usingSrc ? "src" : false, "pages"].filter(
3784
3866
  Boolean
@@ -3790,12 +3872,12 @@ var detectEnvironment = async ({
3790
3872
  "next-api-handler": await makeGeneratedFile(
3791
3873
  "[...routes]",
3792
3874
  "next-api-handler",
3793
- import_path7.default.join(...pagesDir, "api", "tina")
3875
+ path10.join(...pagesDir, "api", "tina")
3794
3876
  ),
3795
3877
  "reactive-example": await makeGeneratedFile(
3796
3878
  "[filename]",
3797
3879
  "reactive-example",
3798
- import_path7.default.join(...pagesDir, "demo", "blog"),
3880
+ path10.join(...pagesDir, "demo", "blog"),
3799
3881
  {
3800
3882
  typescriptSuffix: "tsx"
3801
3883
  }
@@ -3803,22 +3885,22 @@ var detectEnvironment = async ({
3803
3885
  "users-json": await makeGeneratedFile(
3804
3886
  "index",
3805
3887
  "users-json",
3806
- import_path7.default.join(baseDir, "content", "users"),
3888
+ path10.join(baseDir, "content", "users"),
3807
3889
  { extensionOverride: "json" }
3808
3890
  ),
3809
3891
  "sample-content": await makeGeneratedFile(
3810
3892
  "hello-world",
3811
3893
  "sample-content",
3812
- import_path7.default.join(baseDir, "content", "posts"),
3894
+ path10.join(baseDir, "content", "posts"),
3813
3895
  { extensionOverride: "md" }
3814
3896
  )
3815
3897
  };
3816
- const hasSampleContent = await import_fs_extra8.default.pathExists(sampleContentPath);
3817
- const hasPackageJSON = await import_fs_extra8.default.pathExists("package.json");
3898
+ const hasSampleContent = await fs9.pathExists(sampleContentPath);
3899
+ const hasPackageJSON = await fs9.pathExists("package.json");
3818
3900
  let hasTinaDeps = false;
3819
3901
  if (hasPackageJSON) {
3820
3902
  try {
3821
- const packageJSON = await import_fs_extra8.default.readJSON("package.json");
3903
+ const packageJSON = await fs9.readJSON("package.json");
3822
3904
  const deps = [];
3823
3905
  if (packageJSON?.dependencies) {
3824
3906
  deps.push(...Object.keys(packageJSON.dependencies));
@@ -3835,15 +3917,15 @@ var detectEnvironment = async ({
3835
3917
  );
3836
3918
  }
3837
3919
  }
3838
- const hasGitIgnore = await import_fs_extra8.default.pathExists(import_path7.default.join(".gitignore"));
3920
+ const hasGitIgnore = await fs9.pathExists(path10.join(".gitignore"));
3839
3921
  const hasGitIgnoreNodeModules = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: "node_modules" });
3840
3922
  const hasEnvTina = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: ".env.tina" });
3841
3923
  const hasGitIgnoreEnv = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: ".env" });
3842
3924
  let frontMatterFormat;
3843
3925
  if (hasForestryConfig) {
3844
- const hugoConfigPath = import_path7.default.join(rootPath, "config.toml");
3845
- if (await import_fs_extra8.default.pathExists(hugoConfigPath)) {
3846
- const hugoConfig = await import_fs_extra8.default.readFile(hugoConfigPath, "utf8");
3926
+ const hugoConfigPath = path10.join(rootPath, "config.toml");
3927
+ if (await fs9.pathExists(hugoConfigPath)) {
3928
+ const hugoConfig = await fs9.readFile(hugoConfigPath, "utf8");
3847
3929
  const metaDataFormat = hugoConfig.toString().match(/metaDataFormat = "(.*)"/)?.[1];
3848
3930
  if (metaDataFormat && (metaDataFormat === "yaml" || metaDataFormat === "toml" || metaDataFormat === "json")) {
3849
3931
  frontMatterFormat = metaDataFormat;
@@ -3874,10 +3956,10 @@ var detectEnvironment = async ({
3874
3956
  var detectEnvironment_default = detectEnvironment;
3875
3957
 
3876
3958
  // src/cmds/init/prompts/index.ts
3877
- var import_prompts6 = __toESM(require("prompts"));
3959
+ import prompts6 from "prompts";
3878
3960
 
3879
3961
  // src/cmds/init/prompts/askTinaCloudSetup.ts
3880
- var import_prompts2 = __toESM(require("prompts"));
3962
+ import prompts2 from "prompts";
3881
3963
  var tinaCloudSetupQuestions = [
3882
3964
  {
3883
3965
  name: "clientId",
@@ -3899,7 +3981,7 @@ ${logText(
3899
3981
  }
3900
3982
  ];
3901
3983
  var askTinaCloudSetup = async ({ config: config2 }) => {
3902
- const { clientId, token } = await (0, import_prompts2.default)(tinaCloudSetupQuestions);
3984
+ const { clientId, token } = await prompts2(tinaCloudSetupQuestions);
3903
3985
  config2.envVars.push(
3904
3986
  {
3905
3987
  key: "NEXT_PUBLIC_TINA_CLIENT_ID",
@@ -3913,7 +3995,7 @@ var askTinaCloudSetup = async ({ config: config2 }) => {
3913
3995
  };
3914
3996
 
3915
3997
  // src/cmds/init/prompts/gitProvider.ts
3916
- var import_prompts3 = __toESM(require("prompts"));
3998
+ import prompts3 from "prompts";
3917
3999
  var supportedGitProviders = {
3918
4000
  github: {
3919
4001
  imports: [
@@ -3935,7 +4017,7 @@ var supportedGitProviders = {
3935
4017
  }
3936
4018
  };
3937
4019
  var chooseGitProvider = async ({ config: config2 }) => {
3938
- const result = await (0, import_prompts3.default)([
4020
+ const result = await prompts3([
3939
4021
  {
3940
4022
  name: "githubToken",
3941
4023
  type: "text",
@@ -3943,7 +4025,7 @@ var chooseGitProvider = async ({ config: config2 }) => {
3943
4025
  ${logText(
3944
4026
  "Learn more here: "
3945
4027
  )}${linkText(
3946
- "https://tina.io/docs/self-hosted/existing-site/#github-personal-access-token"
4028
+ "https://tina.io/docs/r/self-hosting-nextjs/#github-personal-access-token"
3947
4029
  )}`,
3948
4030
  initial: process.env.GITHUB_PERSONAL_ACCESS_TOKEN
3949
4031
  },
@@ -3980,7 +4062,7 @@ ${logText(
3980
4062
  };
3981
4063
 
3982
4064
  // src/cmds/init/prompts/databaseAdapter.ts
3983
- var import_prompts4 = __toESM(require("prompts"));
4065
+ import prompts4 from "prompts";
3984
4066
  var supportedDatabaseAdapters = {
3985
4067
  ["upstash-redis"]: {
3986
4068
  databaseAdapterClassText: `new RedisLevel({
@@ -4026,7 +4108,7 @@ var databaseAdapterUpdateConfig = {
4026
4108
  other: async (_args) => {
4027
4109
  },
4028
4110
  mongodb: async ({ config: config2 }) => {
4029
- const result = await (0, import_prompts4.default)([
4111
+ const result = await prompts4([
4030
4112
  {
4031
4113
  name: "mongoDBUri",
4032
4114
  type: "text",
@@ -4041,7 +4123,7 @@ var databaseAdapterUpdateConfig = {
4041
4123
  });
4042
4124
  },
4043
4125
  "upstash-redis": async ({ config: config2 }) => {
4044
- const result = await (0, import_prompts4.default)([
4126
+ const result = await prompts4([
4045
4127
  {
4046
4128
  name: "kvRestApiUrl",
4047
4129
  type: "text",
@@ -4072,7 +4154,7 @@ var chooseDatabaseAdapter = async ({
4072
4154
  framework,
4073
4155
  config: config2
4074
4156
  }) => {
4075
- const answers = await (0, import_prompts4.default)([
4157
+ const answers = await prompts4([
4076
4158
  {
4077
4159
  name: "dataLayerAdapter",
4078
4160
  message: "Select a self-hosted Database Adapter",
@@ -4102,8 +4184,8 @@ var chooseDatabaseAdapter = async ({
4102
4184
  };
4103
4185
 
4104
4186
  // src/cmds/init/prompts/authProvider.ts
4105
- var import_crypto_js = __toESM(require("crypto-js"));
4106
- var import_prompts5 = __toESM(require("prompts"));
4187
+ import crypto2 from "crypto-js";
4188
+ import prompts5 from "prompts";
4107
4189
  var supportedAuthProviders = {
4108
4190
  other: {
4109
4191
  name: "other"
@@ -4152,12 +4234,12 @@ var authProviderUpdateConfig = {
4152
4234
  },
4153
4235
  "tina-cloud": askTinaCloudSetup,
4154
4236
  "next-auth": async ({ config: config2 }) => {
4155
- const result = await (0, import_prompts5.default)([
4237
+ const result = await prompts5([
4156
4238
  {
4157
4239
  name: "nextAuthSecret",
4158
4240
  type: "text",
4159
4241
  message: `What is the NextAuth.js Secret? (Hit enter to use a randomly generated secret)`,
4160
- initial: process.env.NEXTAUTH_SECRET || import_crypto_js.default.lib.WordArray.random(16).toString()
4242
+ initial: process.env.NEXTAUTH_SECRET || crypto2.lib.WordArray.random(16).toString()
4161
4243
  }
4162
4244
  ]);
4163
4245
  config2.envVars.push({
@@ -4182,7 +4264,7 @@ var forestryDisclaimer = logText(
4182
4264
  `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)`
4183
4265
  );
4184
4266
  var askCommonSetUp = async () => {
4185
- const answers = await (0, import_prompts6.default)([
4267
+ const answers = await prompts6([
4186
4268
  {
4187
4269
  name: "framework",
4188
4270
  type: "select",
@@ -4204,7 +4286,8 @@ var askCommonSetUp = async () => {
4204
4286
  choices: [
4205
4287
  { title: "PNPM", value: "pnpm" },
4206
4288
  { title: "Yarn", value: "yarn" },
4207
- { title: "NPM", value: "npm" }
4289
+ { title: "NPM", value: "npm" },
4290
+ { title: "Bun", value: "bun" }
4208
4291
  ]
4209
4292
  }
4210
4293
  ]);
@@ -4245,7 +4328,7 @@ ${forestryDisclaimer}`
4245
4328
  message: `What format are you using in your frontmatter?`
4246
4329
  });
4247
4330
  }
4248
- const answers = await (0, import_prompts6.default)(questions);
4331
+ const answers = await prompts6(questions);
4249
4332
  return answers;
4250
4333
  };
4251
4334
  var askTinaSetupPrompts = async (params) => {
@@ -4265,16 +4348,16 @@ var askTinaSetupPrompts = async (params) => {
4265
4348
  message: `Where are public assets stored? (default: "public")
4266
4349
  ` + logText(
4267
4350
  `Not sure what value to use? Refer to our "Frameworks" doc: ${linkText(
4268
- "https://tina.io/docs/integration/frameworks/#configuring-tina-with-each-framework"
4351
+ "https://tina.io/docs/r/framework-guides-overview"
4269
4352
  )}`
4270
4353
  )
4271
4354
  });
4272
4355
  }
4273
- const answers = await (0, import_prompts6.default)(questions);
4356
+ const answers = await prompts6(questions);
4274
4357
  return answers;
4275
4358
  };
4276
4359
  var askIfUsingSelfHosted = async () => {
4277
- const answers = await (0, import_prompts6.default)([
4360
+ const answers = await prompts6([
4278
4361
  {
4279
4362
  name: "hosting",
4280
4363
  type: "select",
@@ -4307,20 +4390,20 @@ var makeImportString = (imports) => {
4307
4390
  };
4308
4391
 
4309
4392
  // src/cmds/init/prompts/generatedFiles.ts
4310
- var import_prompts7 = __toESM(require("prompts"));
4393
+ import prompts7 from "prompts";
4311
4394
  var askIfOverride = async ({
4312
4395
  generatedFile,
4313
4396
  usingTypescript
4314
4397
  }) => {
4315
4398
  if (usingTypescript) {
4316
- const result = await (0, import_prompts7.default)({
4399
+ const result = await prompts7({
4317
4400
  name: `override`,
4318
4401
  type: "confirm",
4319
4402
  message: `Found existing file at ${generatedFile.fullPathTS}. Would you like to overwrite?`
4320
4403
  });
4321
4404
  return Boolean(result.override);
4322
4405
  } else {
4323
- const result = await (0, import_prompts7.default)({
4406
+ const result = await prompts7({
4324
4407
  name: `override`,
4325
4408
  type: "confirm",
4326
4409
  message: `Found existing file at ${generatedFile.fullPathJS}. Would you like to overwrite?`
@@ -4455,23 +4538,25 @@ var CLICommand = class {
4455
4538
  };
4456
4539
 
4457
4540
  // src/cmds/init/apply.ts
4458
- var import_path11 = __toESM(require("path"));
4541
+ import path14 from "path";
4459
4542
 
4460
4543
  // src/cmds/forestry-migrate/index.ts
4461
- var import_fs_extra10 = __toESM(require("fs-extra"));
4462
- var import_path9 = __toESM(require("path"));
4463
- var import_js_yaml2 = __toESM(require("js-yaml"));
4464
- var import_minimatch = __toESM(require("minimatch"));
4465
- var import_graphql16 = require("@tinacms/graphql");
4544
+ import fs11 from "fs-extra";
4545
+ import path12 from "path";
4546
+ import yaml2 from "js-yaml";
4547
+ import pkg from "minimatch";
4548
+ import { parseFile, stringifyFile } from "@tinacms/graphql";
4549
+ import { CONTENT_FORMATS } from "@tinacms/schema-tools";
4466
4550
 
4467
4551
  // src/cmds/forestry-migrate/util/index.ts
4468
- var import_fs_extra9 = __toESM(require("fs-extra"));
4469
- var import_path8 = __toESM(require("path"));
4470
- var import_js_yaml = __toESM(require("js-yaml"));
4471
- var import_zod = __toESM(require("zod"));
4552
+ import fs10 from "fs-extra";
4553
+ import path11 from "path";
4554
+ import yaml from "js-yaml";
4555
+ import z from "zod";
4472
4556
 
4473
4557
  // src/cmds/forestry-migrate/util/errorSingleton.ts
4474
4558
  var ErrorSingleton = class _ErrorSingleton {
4559
+ static instance;
4475
4560
  /**
4476
4561
  * The Singleton's constructor should always be private to prevent direct
4477
4562
  * construction calls with the `new` operator.
@@ -4491,6 +4576,7 @@ var ErrorSingleton = class _ErrorSingleton {
4491
4576
  }
4492
4577
  return _ErrorSingleton.instance;
4493
4578
  }
4579
+ collectionNameErrors;
4494
4580
  addErrorName(error) {
4495
4581
  this.collectionNameErrors.push(error);
4496
4582
  }
@@ -4513,8 +4599,8 @@ var ErrorSingleton = class _ErrorSingleton {
4513
4599
  };
4514
4600
 
4515
4601
  // src/cmds/forestry-migrate/util/codeTransformer.ts
4516
- var import_prettier = require("prettier");
4517
- var import_parser_typescript = __toESM(require("prettier/parser-typescript"));
4602
+ import { format } from "prettier";
4603
+ import TsParser from "prettier/parser-typescript.js";
4518
4604
  var addVariablesToCode = (codeWithTinaPrefix) => {
4519
4605
  const code = codeWithTinaPrefix.replace(
4520
4606
  /"__TINA_INTERNAL__:::(.*?):::"/g,
@@ -4551,7 +4637,7 @@ var makeTemplateFile = async ({
4551
4637
  `export function ${stringifyLabelWithField(
4552
4638
  template.templateObj.label
4553
4639
  )} (){
4554
- return ${addVariablesToCode(JSON.stringify(template.fields, null, 2)).code} ${usingTypescript ? "as TinaField[]" : ""}
4640
+ return ${addVariablesToCode(JSON.stringify(template.fields, null, 2)).code} ${usingTypescript ? "as TinaField[]" : ""}
4555
4641
  } `
4556
4642
  );
4557
4643
  }
@@ -4559,9 +4645,9 @@ var makeTemplateFile = async ({
4559
4645
  ${usingTypescript ? "import type { TinaField } from 'tinacms'" : ""}
4560
4646
  ${templateCodeText.join("\n")}
4561
4647
  `;
4562
- const formattedCode = (0, import_prettier.format)(templateCode, {
4648
+ const formattedCode = format(templateCode, {
4563
4649
  parser: "typescript",
4564
- plugins: [import_parser_typescript.default]
4650
+ plugins: [TsParser]
4565
4651
  });
4566
4652
  return { importStatements, templateCodeText: formattedCode };
4567
4653
  };
@@ -4593,82 +4679,82 @@ var stringifyTemplateName = (name2, template) => {
4593
4679
  return newName;
4594
4680
  }
4595
4681
  };
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")
4682
+ var forestryConfigSchema = z.object({
4683
+ sections: z.array(
4684
+ z.object({
4685
+ type: z.union([
4686
+ z.literal("directory"),
4687
+ z.literal("document"),
4688
+ z.literal("heading"),
4689
+ z.literal("jekyll-pages"),
4690
+ z.literal("jekyll-posts")
4605
4691
  ]),
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()
4692
+ label: z.string(),
4693
+ path: z.string().optional().nullable(),
4694
+ match: z.string().optional().nullable(),
4695
+ exclude: z.string().optional().nullable(),
4696
+ create: z.union([z.literal("all"), z.literal("documents"), z.literal("none")]).optional(),
4697
+ templates: z.array(z.string()).optional().nullable(),
4698
+ new_doc_ext: z.string().optional().nullable(),
4699
+ read_only: z.boolean().optional().nullable()
4614
4700
  })
4615
4701
  )
4616
4702
  });
4617
- var forestryFieldWithoutField = import_zod.default.object({
4703
+ var forestryFieldWithoutField = z.object({
4618
4704
  // 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")
4705
+ type: z.union([
4706
+ z.literal("text"),
4707
+ z.literal("datetime"),
4708
+ z.literal("list"),
4709
+ z.literal("file"),
4710
+ z.literal("image_gallery"),
4711
+ z.literal("textarea"),
4712
+ z.literal("tag_list"),
4713
+ z.literal("number"),
4714
+ z.literal("boolean"),
4715
+ z.literal("field_group"),
4716
+ z.literal("field_group_list"),
4717
+ z.literal("select"),
4718
+ z.literal("include"),
4719
+ z.literal("blocks"),
4720
+ z.literal("color")
4635
4721
  ]),
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({
4722
+ template_types: z.array(z.string()).optional().nullable(),
4723
+ name: z.string(),
4724
+ label: z.string(),
4725
+ default: z.any().optional(),
4726
+ template: z.string().optional(),
4727
+ config: z.object({
4642
4728
  // 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"),
4729
+ min: z.number().optional().nullable(),
4730
+ max: z.number().optional().nullable(),
4731
+ required: z.boolean().optional().nullable(),
4732
+ use_select: z.boolean().optional().nullable(),
4733
+ date_format: z.string().optional().nullable(),
4734
+ time_format: z.string().optional().nullable(),
4735
+ options: z.array(z.string()).optional().nullable(),
4736
+ source: z.object({
4737
+ type: z.union([
4738
+ z.literal("custom"),
4739
+ z.literal("pages"),
4740
+ z.literal("documents"),
4741
+ z.literal("simple"),
4656
4742
  // TODO: I want to ignore this key if its invalid
4657
- import_zod.default.string()
4743
+ z.string()
4658
4744
  ]).optional().nullable(),
4659
- section: import_zod.default.string().optional().nullable()
4745
+ section: z.string().optional().nullable()
4660
4746
  }).optional()
4661
4747
  }).optional()
4662
4748
  });
4663
- var forestryField = import_zod.default.lazy(
4749
+ var forestryField = z.lazy(
4664
4750
  () => forestryFieldWithoutField.extend({
4665
- fields: import_zod.default.array(forestryField).optional()
4751
+ fields: z.array(forestryField).optional()
4666
4752
  })
4667
4753
  );
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()
4754
+ var FrontmatterTemplateSchema = z.object({
4755
+ label: z.string(),
4756
+ hide_body: z.boolean().optional(),
4757
+ fields: z.array(forestryField).optional()
4672
4758
  });
4673
4759
  var transformForestryFieldsToTinaFields = ({
4674
4760
  fields,
@@ -4891,7 +4977,7 @@ var transformForestryFieldsToTinaFields = ({
4891
4977
  return tinaFields;
4892
4978
  };
4893
4979
  var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false }) => {
4894
- const templatePath = import_path8.default.join(
4980
+ const templatePath = path11.join(
4895
4981
  pathToForestryConfig,
4896
4982
  ".forestry",
4897
4983
  "front_matter",
@@ -4900,7 +4986,7 @@ var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false })
4900
4986
  );
4901
4987
  let templateString = "";
4902
4988
  try {
4903
- templateString = import_fs_extra9.default.readFileSync(templatePath).toString();
4989
+ templateString = fs10.readFileSync(templatePath).toString();
4904
4990
  } catch {
4905
4991
  throw new Error(
4906
4992
  `Could not find template ${tem} at ${templatePath}
@@ -4908,7 +4994,7 @@ var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false })
4908
4994
  This will require manual migration.`
4909
4995
  );
4910
4996
  }
4911
- const templateObj = import_js_yaml.default.load(templateString);
4997
+ const templateObj = yaml.load(templateString);
4912
4998
  const template = parseTemplates({ val: templateObj });
4913
4999
  const fields = transformForestryFieldsToTinaFields({
4914
5000
  fields: template.fields,
@@ -4928,6 +5014,7 @@ var parseSections = ({ val }) => {
4928
5014
  };
4929
5015
 
4930
5016
  // src/cmds/forestry-migrate/index.ts
5017
+ var { minimatch } = pkg;
4931
5018
  var BODY_FIELD = {
4932
5019
  // This is the body field
4933
5020
  type: "rich-text",
@@ -4956,7 +5043,7 @@ var transformForestryMatchToTinaMatch = (match) => {
4956
5043
  };
4957
5044
  function checkExt(ext) {
4958
5045
  const extReal = ext.replace(".", "");
4959
- if (["mdx", "md", "json", "yaml", "yml", "toml"].includes(extReal)) {
5046
+ if (CONTENT_FORMATS.includes(extReal)) {
4960
5047
  return extReal;
4961
5048
  } else {
4962
5049
  return false;
@@ -4965,9 +5052,9 @@ function checkExt(ext) {
4965
5052
  var generateAllTemplates = async ({
4966
5053
  pathToForestryConfig
4967
5054
  }) => {
4968
- const allTemplates = (await import_fs_extra10.default.readdir(
4969
- import_path9.default.join(pathToForestryConfig, ".forestry", "front_matter", "templates")
4970
- )).map((tem) => import_path9.default.basename(tem, ".yml"));
5055
+ const allTemplates = (await fs11.readdir(
5056
+ path12.join(pathToForestryConfig, ".forestry", "front_matter", "templates")
5057
+ )).map((tem) => path12.basename(tem, ".yml"));
4971
5058
  const templateMap = /* @__PURE__ */ new Map();
4972
5059
  const proms = allTemplates.map(async (tem) => {
4973
5060
  try {
@@ -4977,7 +5064,7 @@ var generateAllTemplates = async ({
4977
5064
  });
4978
5065
  templateMap.set(tem, { fields, templateObj });
4979
5066
  } catch (e) {
4980
- logger.log(`Error parsing template frontmatter template', tem + '.yml'`);
5067
+ logger.warn(`Error parsing template frontmatter template, ${tem}.yml`);
4981
5068
  console.error(e);
4982
5069
  templateMap.set(tem, { fields: [], templateObj: {} });
4983
5070
  }
@@ -5021,7 +5108,7 @@ var generateCollectionFromForestrySection = (args) => {
5021
5108
  }
5022
5109
  if (section.type === "directory") {
5023
5110
  if (!section?.path || section.path === "/" || section.path === "./" || section.path === ".") {
5024
- logger.log(
5111
+ logger.warn(
5025
5112
  warnText(
5026
5113
  `Warning: Section ${section.label} is using a Root Path. Currently, Tina Does not support Root paths see ${linkText(
5027
5114
  "https://github.com/tinacms/tinacms/issues/3768"
@@ -5042,7 +5129,7 @@ var generateCollectionFromForestrySection = (args) => {
5042
5129
  glob = section.path + "/" + section.match;
5043
5130
  }
5044
5131
  if (pages.some((page) => {
5045
- return (0, import_minimatch.default)(page, glob);
5132
+ return minimatch(page, glob);
5046
5133
  })) {
5047
5134
  forestryTemplates.push(templateKey);
5048
5135
  }
@@ -5112,9 +5199,9 @@ var generateCollectionFromForestrySection = (args) => {
5112
5199
  return c;
5113
5200
  } else if (section.type === "document") {
5114
5201
  const filePath = section.path;
5115
- const extname = import_path9.default.extname(filePath);
5116
- const fileName = import_path9.default.basename(filePath, extname);
5117
- const dir = import_path9.default.dirname(filePath);
5202
+ const extname = path12.extname(filePath);
5203
+ const fileName = path12.basename(filePath, extname);
5204
+ const dir = path12.dirname(filePath);
5118
5205
  const ext = checkExt(extname);
5119
5206
  if (ext) {
5120
5207
  const fields = [];
@@ -5134,7 +5221,7 @@ var generateCollectionFromForestrySection = (args) => {
5134
5221
  name: "dummy",
5135
5222
  label: "Dummy field",
5136
5223
  type: "string",
5137
- 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"
5224
+ 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"
5138
5225
  });
5139
5226
  logger.warn(
5140
5227
  warnText(
@@ -5158,7 +5245,7 @@ var generateCollectionFromForestrySection = (args) => {
5158
5245
  fields
5159
5246
  };
5160
5247
  } else {
5161
- logger.log(
5248
+ logger.warn(
5162
5249
  warnText(
5163
5250
  `Error: document section has an unsupported file extension: ${extname} in ${section.path}`
5164
5251
  )
@@ -5176,8 +5263,8 @@ var generateCollections = async ({
5176
5263
  templateMap,
5177
5264
  usingTypescript
5178
5265
  });
5179
- const forestryConfig = await import_fs_extra10.default.readFile(
5180
- import_path9.default.join(pathToForestryConfig, ".forestry", "settings.yml")
5266
+ const forestryConfig = await fs11.readFile(
5267
+ path12.join(pathToForestryConfig, ".forestry", "settings.yml")
5181
5268
  );
5182
5269
  rewriteTemplateKeysInDocs({
5183
5270
  templateMap,
@@ -5187,7 +5274,7 @@ var generateCollections = async ({
5187
5274
  }
5188
5275
  });
5189
5276
  const collections = parseSections({
5190
- val: import_js_yaml2.default.load(forestryConfig.toString())
5277
+ val: yaml2.load(forestryConfig.toString())
5191
5278
  }).sections.map(
5192
5279
  (section) => generateCollectionFromForestrySection({
5193
5280
  section,
@@ -5207,13 +5294,13 @@ var rewriteTemplateKeysInDocs = (args) => {
5207
5294
  const { templateObj } = templateMap.get(templateKey);
5208
5295
  templateObj?.pages?.forEach((page) => {
5209
5296
  try {
5210
- const filePath = import_path9.default.join(page);
5211
- if (import_fs_extra10.default.lstatSync(filePath).isDirectory()) {
5297
+ const filePath = path12.join(page);
5298
+ if (fs11.lstatSync(filePath).isDirectory()) {
5212
5299
  return;
5213
5300
  }
5214
- const extname = import_path9.default.extname(filePath);
5215
- const fileContent = import_fs_extra10.default.readFileSync(filePath).toString();
5216
- const content = (0, import_graphql16.parseFile)(
5301
+ const extname = path12.extname(filePath);
5302
+ const fileContent = fs11.readFileSync(filePath).toString();
5303
+ const content = parseFile(
5217
5304
  fileContent,
5218
5305
  extname,
5219
5306
  (yup) => yup.object({}),
@@ -5223,9 +5310,9 @@ var rewriteTemplateKeysInDocs = (args) => {
5223
5310
  _template: stringifyLabel(templateKey),
5224
5311
  ...content
5225
5312
  };
5226
- import_fs_extra10.default.writeFileSync(
5313
+ fs11.writeFileSync(
5227
5314
  filePath,
5228
- (0, import_graphql16.stringifyFile)(newContent, extname, true, markdownParseConfig)
5315
+ stringifyFile(newContent, extname, true, markdownParseConfig)
5229
5316
  );
5230
5317
  } catch (error) {
5231
5318
  console.log(
@@ -5237,32 +5324,25 @@ var rewriteTemplateKeysInDocs = (args) => {
5237
5324
  };
5238
5325
 
5239
5326
  // src/cmds/init/apply.ts
5240
- var import_metrics2 = require("@tinacms/metrics");
5241
- var import_fs_extra13 = __toESM(require("fs-extra"));
5327
+ import { Telemetry as Telemetry2 } from "@tinacms/metrics";
5328
+ import fs14 from "fs-extra";
5242
5329
 
5243
5330
  // src/next/commands/codemod-command/index.ts
5244
- var import_clipanion5 = require("clipanion");
5245
- var import_fs_extra11 = __toESM(require("fs-extra"));
5246
- var import_path10 = __toESM(require("path"));
5247
- var CodemodCommand = class extends import_clipanion5.Command {
5248
- constructor() {
5249
- super(...arguments);
5250
- this.rootPath = import_clipanion5.Option.String("--rootPath", {
5251
- description: "Specify the root directory to run the CLI from"
5252
- });
5253
- this.verbose = import_clipanion5.Option.Boolean("-v,--verbose", false, {
5254
- description: "increase verbosity of logged output"
5255
- });
5256
- }
5257
- static {
5258
- this.paths = [["codemod"], ["codemod", "move-tina-folder"]];
5259
- }
5260
- static {
5261
- this.usage = import_clipanion5.Command.Usage({
5262
- category: `Commands`,
5263
- description: `Use codemods for various Tina tasks`
5264
- });
5265
- }
5331
+ import { Command as Command5, Option as Option5 } from "clipanion";
5332
+ import fs12 from "fs-extra";
5333
+ import path13 from "path";
5334
+ var CodemodCommand = class extends Command5 {
5335
+ static paths = [["codemod"], ["codemod", "move-tina-folder"]];
5336
+ rootPath = Option5.String("--rootPath", {
5337
+ description: "Specify the root directory to run the CLI from"
5338
+ });
5339
+ verbose = Option5.Boolean("-v,--verbose", false, {
5340
+ description: "increase verbosity of logged output"
5341
+ });
5342
+ static usage = Command5.Usage({
5343
+ category: `Commands`,
5344
+ description: `Use codemods for various Tina tasks`
5345
+ });
5266
5346
  async catch(error) {
5267
5347
  console.log(error);
5268
5348
  }
@@ -5291,13 +5371,13 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
5291
5371
  logger.error(e.message);
5292
5372
  process.exit(1);
5293
5373
  }
5294
- const tinaDestination = import_path10.default.join(configManager.rootPath, "tina");
5295
- if (await import_fs_extra11.default.existsSync(tinaDestination)) {
5374
+ const tinaDestination = path13.join(configManager.rootPath, "tina");
5375
+ if (await fs12.existsSync(tinaDestination)) {
5296
5376
  logger.info(
5297
5377
  `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.`
5298
5378
  );
5299
5379
  } else {
5300
- await import_fs_extra11.default.moveSync(configManager.tinaFolderPath, tinaDestination);
5380
+ await fs12.moveSync(configManager.tinaFolderPath, tinaDestination);
5301
5381
  await writeGitignore(configManager.rootPath);
5302
5382
  logger.info(
5303
5383
  "Move to 'tina' folder complete. Be sure to update any imports of the autogenerated client!"
@@ -5305,8 +5385,8 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
5305
5385
  }
5306
5386
  };
5307
5387
  var writeGitignore = async (rootPath) => {
5308
- await import_fs_extra11.default.outputFileSync(
5309
- import_path10.default.join(rootPath, "tina", ".gitignore"),
5388
+ await fs12.outputFileSync(
5389
+ path13.join(rootPath, "tina", ".gitignore"),
5310
5390
  "__generated__"
5311
5391
  );
5312
5392
  };
@@ -5359,7 +5439,7 @@ const BlogPage = (props) => {
5359
5439
  <div className='bg-green-100 text-center'>
5360
5440
  Lost and looking for a place to start?
5361
5441
  <a
5362
- href='https://tina.io/guides/tina-cloud/getting-started/overview/'
5442
+ href='https://tina.io/docs/r/beginner-series'
5363
5443
  className='text-blue-500 underline'
5364
5444
  >
5365
5445
  {' '}
@@ -5641,7 +5721,7 @@ import { LocalAuthProvider } from "tinacms";`;
5641
5721
  publicFolder: "${args.publicFolder}",
5642
5722
  },
5643
5723
  },
5644
- // See docs on content modeling for more info on how to setup new content models: https://tina.io/docs/schema/
5724
+ // See docs on content modeling for more info on how to setup new content models: https://tina.io/docs/r/content-modelling-collections/
5645
5725
  schema: {
5646
5726
  collections: ${generateCollectionString(args)},
5647
5727
  },
@@ -5714,7 +5794,7 @@ Suspendisse facilisis, mi ac scelerisque interdum, ligula ex imperdiet felis, a
5714
5794
  `;
5715
5795
 
5716
5796
  // src/cmds/init/apply.ts
5717
- var import_prettier2 = require("prettier");
5797
+ import { format as format2 } from "prettier";
5718
5798
 
5719
5799
  // src/utils/script-helpers.ts
5720
5800
  function generateGqlScript(scriptValue, opts) {
@@ -5737,38 +5817,38 @@ function extendNextScripts(scripts, opts) {
5737
5817
  }
5738
5818
 
5739
5819
  // src/cmds/init/codegen/index.ts
5740
- var import_typescript3 = __toESM(require("typescript"));
5741
- var import_fs_extra12 = __toESM(require("fs-extra"));
5820
+ import ts2 from "typescript";
5821
+ import fs13 from "fs-extra";
5742
5822
 
5743
5823
  // src/cmds/init/codegen/util.ts
5744
- var import_typescript2 = __toESM(require("typescript"));
5745
- var makeTransformer = (makeVisitor) => (ctx) => (node) => import_typescript2.default.visitNode(node, makeVisitor(ctx));
5824
+ import ts from "typescript";
5825
+ var makeTransformer = (makeVisitor) => (ctx) => (node) => ts.visitNode(node, makeVisitor(ctx));
5746
5826
  function parseExpression(expression) {
5747
- const sourceFile = import_typescript2.default.createSourceFile(
5827
+ const sourceFile = ts.createSourceFile(
5748
5828
  "temp.ts",
5749
5829
  expression,
5750
- import_typescript2.default.ScriptTarget.Latest
5830
+ ts.ScriptTarget.Latest
5751
5831
  );
5752
5832
  if (sourceFile.statements.length !== 1) {
5753
5833
  throw new Error("Expected one statement");
5754
5834
  }
5755
5835
  const statement = sourceFile.statements[0];
5756
- if (!import_typescript2.default.isExpressionStatement(statement)) {
5836
+ if (!ts.isExpressionStatement(statement)) {
5757
5837
  throw new Error("Expected an expression statement");
5758
5838
  }
5759
5839
  return [sourceFile, statement.expression];
5760
5840
  }
5761
5841
  function parseVariableStatement(stmt) {
5762
- const sourceFile = import_typescript2.default.createSourceFile(
5842
+ const sourceFile = ts.createSourceFile(
5763
5843
  "temp.ts",
5764
5844
  stmt,
5765
- import_typescript2.default.ScriptTarget.Latest
5845
+ ts.ScriptTarget.Latest
5766
5846
  );
5767
5847
  if (sourceFile.statements.length !== 1) {
5768
5848
  throw new Error("Expected one statement");
5769
5849
  }
5770
5850
  const statement = sourceFile.statements[0];
5771
- if (!import_typescript2.default.isVariableStatement(statement)) {
5851
+ if (!ts.isVariableStatement(statement)) {
5772
5852
  throw new Error("Expected a variable statement");
5773
5853
  }
5774
5854
  return [sourceFile, statement];
@@ -5776,7 +5856,7 @@ function parseVariableStatement(stmt) {
5776
5856
 
5777
5857
  // src/cmds/init/codegen/index.ts
5778
5858
  var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variableStmt) => (ctx) => (node) => {
5779
- if (import_typescript3.default.isSourceFile(node)) {
5859
+ if (ts2.isSourceFile(node)) {
5780
5860
  const newStatements = [...node.statements];
5781
5861
  let encounteredImports = false;
5782
5862
  let firstNonImportStatementIdx = -1;
@@ -5784,7 +5864,7 @@ var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variable
5784
5864
  const [newVarDec] = variableStmt.declarationList.declarations;
5785
5865
  const newVarDecName = newVarDec.name.getText(variableStmtSourceFile);
5786
5866
  for (let i = 0; i < newStatements.length; i++) {
5787
- const isImport = import_typescript3.default.isImportDeclaration(newStatements[i]);
5867
+ const isImport = ts2.isImportDeclaration(newStatements[i]);
5788
5868
  if (isImport && !encounteredImports) {
5789
5869
  encounteredImports = true;
5790
5870
  }
@@ -5792,9 +5872,9 @@ var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variable
5792
5872
  firstNonImportStatementIdx = i;
5793
5873
  }
5794
5874
  const stmt = newStatements[i];
5795
- if (import_typescript3.default.isVariableStatement(stmt)) {
5875
+ if (ts2.isVariableStatement(stmt)) {
5796
5876
  const [dec] = stmt.declarationList.declarations;
5797
- if (dec.name && import_typescript3.default.isIdentifier(dec.name) && dec.name.getText(sourceFile) === newVarDecName) {
5877
+ if (dec.name && ts2.isIdentifier(dec.name) && dec.name.getText(sourceFile) === newVarDecName) {
5798
5878
  existingStatementIdx = i;
5799
5879
  }
5800
5880
  }
@@ -5808,19 +5888,19 @@ var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variable
5808
5888
  if (existingStatementIdx === -1) {
5809
5889
  newStatements.splice(firstNonImportStatementIdx, 0, variableStmt);
5810
5890
  }
5811
- return import_typescript3.default.factory.updateSourceFile(node, newStatements);
5891
+ return ts2.factory.updateSourceFile(node, newStatements);
5812
5892
  }
5813
5893
  };
5814
5894
  var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
5815
- if (import_typescript3.default.isSourceFile(node)) {
5895
+ if (ts2.isSourceFile(node)) {
5816
5896
  const newStatements = [...node.statements];
5817
5897
  let changed = false;
5818
5898
  for (const [moduleName, imports] of Object.entries(importMap)) {
5819
5899
  let foundImportStatement = false;
5820
5900
  for (const statement of newStatements) {
5821
- if (import_typescript3.default.isImportDeclaration(statement) && import_typescript3.default.isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === moduleName) {
5901
+ if (ts2.isImportDeclaration(statement) && ts2.isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === moduleName) {
5822
5902
  foundImportStatement = true;
5823
- const existingImports = statement.importClause?.namedBindings && import_typescript3.default.isNamedImports(statement.importClause.namedBindings) ? statement.importClause.namedBindings.elements.map(
5903
+ const existingImports = statement.importClause?.namedBindings && ts2.isNamedImports(statement.importClause.namedBindings) ? statement.importClause.namedBindings.elements.map(
5824
5904
  (e) => e.name.text
5825
5905
  ) : [];
5826
5906
  const newImports = [
@@ -5831,22 +5911,22 @@ var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
5831
5911
  ])
5832
5912
  ];
5833
5913
  const importSpecifiers = newImports.map(
5834
- (i) => import_typescript3.default.factory.createImportSpecifier(
5914
+ (i) => ts2.factory.createImportSpecifier(
5835
5915
  void 0,
5836
- import_typescript3.default.factory.createIdentifier(i),
5837
- import_typescript3.default.factory.createIdentifier(i)
5916
+ ts2.factory.createIdentifier(i),
5917
+ ts2.factory.createIdentifier(i)
5838
5918
  )
5839
5919
  );
5840
- const namedImports = import_typescript3.default.factory.createNamedImports(importSpecifiers);
5841
- const importClause = import_typescript3.default.factory.createImportClause(
5920
+ const namedImports = ts2.factory.createNamedImports(importSpecifiers);
5921
+ const importClause = ts2.factory.createImportClause(
5842
5922
  false,
5843
5923
  void 0,
5844
5924
  namedImports
5845
5925
  );
5846
- const importDec = import_typescript3.default.factory.createImportDeclaration(
5926
+ const importDec = ts2.factory.createImportDeclaration(
5847
5927
  void 0,
5848
5928
  importClause,
5849
- import_typescript3.default.factory.createStringLiteral(moduleName)
5929
+ ts2.factory.createStringLiteral(moduleName)
5850
5930
  );
5851
5931
  newStatements[newStatements.indexOf(statement)] = importDec;
5852
5932
  changed = true;
@@ -5854,45 +5934,45 @@ var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
5854
5934
  }
5855
5935
  if (!foundImportStatement) {
5856
5936
  const importSpecifiers = imports.map(
5857
- (i) => import_typescript3.default.factory.createImportSpecifier(
5937
+ (i) => ts2.factory.createImportSpecifier(
5858
5938
  void 0,
5859
- import_typescript3.default.factory.createIdentifier(i),
5860
- import_typescript3.default.factory.createIdentifier(i)
5939
+ ts2.factory.createIdentifier(i),
5940
+ ts2.factory.createIdentifier(i)
5861
5941
  )
5862
5942
  );
5863
- const namedImports = import_typescript3.default.factory.createNamedImports(importSpecifiers);
5864
- const importClause = import_typescript3.default.factory.createImportClause(
5943
+ const namedImports = ts2.factory.createNamedImports(importSpecifiers);
5944
+ const importClause = ts2.factory.createImportClause(
5865
5945
  false,
5866
5946
  void 0,
5867
5947
  namedImports
5868
5948
  );
5869
- const importDec = import_typescript3.default.factory.createImportDeclaration(
5949
+ const importDec = ts2.factory.createImportDeclaration(
5870
5950
  void 0,
5871
5951
  importClause,
5872
- import_typescript3.default.factory.createStringLiteral(moduleName)
5952
+ ts2.factory.createStringLiteral(moduleName)
5873
5953
  );
5874
5954
  newStatements.unshift(importDec);
5875
5955
  changed = true;
5876
5956
  }
5877
5957
  }
5878
5958
  if (changed) {
5879
- return import_typescript3.default.factory.updateSourceFile(node, newStatements);
5959
+ return ts2.factory.updateSourceFile(node, newStatements);
5880
5960
  }
5881
5961
  }
5882
5962
  };
5883
5963
  var makeAddExpressionToSchemaCollectionVisitor = (sourceFile, functionName, newExpressionSourceFile, newExpression) => (ctx) => {
5884
5964
  const visit2 = (node) => {
5885
- 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])) {
5965
+ if (ts2.isCallExpression(node) && ts2.isIdentifier(node.expression) && node.expression.text === functionName && node.arguments.length > 0 && ts2.isObjectLiteralExpression(node.arguments[0])) {
5886
5966
  const configObject = node.arguments[0];
5887
5967
  const updateProperties = configObject.properties.map((property) => {
5888
- if (import_typescript3.default.isPropertyAssignment(property)) {
5968
+ if (ts2.isPropertyAssignment(property)) {
5889
5969
  const thisPropertyName = property.name.getText(sourceFile);
5890
- if (thisPropertyName === "schema" && import_typescript3.default.isPropertyAssignment(property) && import_typescript3.default.isObjectLiteralExpression(property.initializer)) {
5970
+ if (thisPropertyName === "schema" && ts2.isPropertyAssignment(property) && ts2.isObjectLiteralExpression(property.initializer)) {
5891
5971
  const schemaObject = property.initializer;
5892
5972
  const collectionsProperty = schemaObject.properties.find(
5893
- (p) => import_typescript3.default.isPropertyAssignment(p) && p.name.getText(sourceFile) === "collections"
5973
+ (p) => ts2.isPropertyAssignment(p) && p.name.getText(sourceFile) === "collections"
5894
5974
  );
5895
- if (collectionsProperty && import_typescript3.default.isPropertyAssignment(collectionsProperty) && import_typescript3.default.isArrayLiteralExpression(collectionsProperty.initializer)) {
5975
+ if (collectionsProperty && ts2.isPropertyAssignment(collectionsProperty) && ts2.isArrayLiteralExpression(collectionsProperty.initializer)) {
5896
5976
  const collectionsArray = collectionsProperty.initializer;
5897
5977
  const collectionItems = collectionsArray.elements.map(
5898
5978
  (e) => e.getText(sourceFile)
@@ -5902,16 +5982,16 @@ var makeAddExpressionToSchemaCollectionVisitor = (sourceFile, functionName, newE
5902
5982
  )) {
5903
5983
  return property;
5904
5984
  }
5905
- return import_typescript3.default.factory.updatePropertyAssignment(
5985
+ return ts2.factory.updatePropertyAssignment(
5906
5986
  property,
5907
5987
  property.name,
5908
- import_typescript3.default.factory.createObjectLiteralExpression(
5988
+ ts2.factory.createObjectLiteralExpression(
5909
5989
  schemaObject.properties.map((subProp) => {
5910
- if (import_typescript3.default.isPropertyAssignment(subProp) && subProp.name.getText(sourceFile) === "collections" && import_typescript3.default.isArrayLiteralExpression(subProp.initializer)) {
5911
- return import_typescript3.default.factory.updatePropertyAssignment(
5990
+ if (ts2.isPropertyAssignment(subProp) && subProp.name.getText(sourceFile) === "collections" && ts2.isArrayLiteralExpression(subProp.initializer)) {
5991
+ return ts2.factory.updatePropertyAssignment(
5912
5992
  subProp,
5913
5993
  subProp.name,
5914
- import_typescript3.default.factory.createArrayLiteralExpression(
5994
+ ts2.factory.createArrayLiteralExpression(
5915
5995
  [newExpression, ...subProp.initializer.elements],
5916
5996
  true
5917
5997
  )
@@ -5927,56 +6007,56 @@ var makeAddExpressionToSchemaCollectionVisitor = (sourceFile, functionName, newE
5927
6007
  }
5928
6008
  return property;
5929
6009
  });
5930
- return import_typescript3.default.factory.createCallExpression(
6010
+ return ts2.factory.createCallExpression(
5931
6011
  node.expression,
5932
6012
  node.typeArguments,
5933
- [import_typescript3.default.factory.createObjectLiteralExpression(updateProperties, true)]
6013
+ [ts2.factory.createObjectLiteralExpression(updateProperties, true)]
5934
6014
  );
5935
6015
  }
5936
- return import_typescript3.default.visitEachChild(node, visit2, ctx);
6016
+ return ts2.visitEachChild(node, visit2, ctx);
5937
6017
  };
5938
6018
  return (sourceFile2) => {
5939
- return import_typescript3.default.visitEachChild(sourceFile2, visit2, ctx);
6019
+ return ts2.visitEachChild(sourceFile2, visit2, ctx);
5940
6020
  };
5941
6021
  };
5942
6022
  var makeUpdateObjectLiteralPropertyVisitor = (sourceFile, functionName, propertyName, propertyValueExpressionSourceFile, propertyValue) => (ctx) => {
5943
6023
  const visitor = (node) => {
5944
- 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])) {
6024
+ if (ts2.isCallExpression(node) && ts2.isIdentifier(node.expression) && node.expression.text === functionName && node.arguments.length > 0 && ts2.isObjectLiteralExpression(node.arguments[0])) {
5945
6025
  let foundProperty = false;
5946
6026
  const configObject = node.arguments[0];
5947
6027
  const updateProperties = configObject.properties.map((property) => {
5948
- if (import_typescript3.default.isPropertyAssignment(property) || import_typescript3.default.isShorthandPropertyAssignment(property)) {
6028
+ if (ts2.isPropertyAssignment(property) || ts2.isShorthandPropertyAssignment(property)) {
5949
6029
  const name2 = property.name.getText(sourceFile);
5950
6030
  if (name2 === propertyName) {
5951
6031
  foundProperty = true;
5952
- return import_typescript3.default.factory.createPropertyAssignment(name2, propertyValue);
6032
+ return ts2.factory.createPropertyAssignment(name2, propertyValue);
5953
6033
  }
5954
6034
  }
5955
6035
  return property;
5956
6036
  });
5957
6037
  if (!foundProperty) {
5958
6038
  updateProperties.unshift(
5959
- import_typescript3.default.factory.createPropertyAssignment(propertyName, propertyValue)
6039
+ ts2.factory.createPropertyAssignment(propertyName, propertyValue)
5960
6040
  );
5961
6041
  }
5962
- return import_typescript3.default.factory.createCallExpression(
6042
+ return ts2.factory.createCallExpression(
5963
6043
  node.expression,
5964
6044
  node.typeArguments,
5965
- [import_typescript3.default.factory.createObjectLiteralExpression(updateProperties, true)]
6045
+ [ts2.factory.createObjectLiteralExpression(updateProperties, true)]
5966
6046
  );
5967
6047
  }
5968
- return import_typescript3.default.visitEachChild(node, visitor, ctx);
6048
+ return ts2.visitEachChild(node, visitor, ctx);
5969
6049
  };
5970
6050
  return (sourceFile2) => {
5971
- return import_typescript3.default.visitNode(sourceFile2, visitor);
6051
+ return ts2.visitNode(sourceFile2, visitor);
5972
6052
  };
5973
6053
  };
5974
6054
  var addSelfHostedTinaAuthToConfig = async (config2, configFile) => {
5975
6055
  const pathToConfig = configFile.resolve(config2.typescript).path;
5976
- const sourceFile = import_typescript3.default.createSourceFile(
6056
+ const sourceFile = ts2.createSourceFile(
5977
6057
  pathToConfig,
5978
- import_fs_extra12.default.readFileSync(pathToConfig, "utf8"),
5979
- config2.typescript ? import_typescript3.default.ScriptTarget.Latest : import_typescript3.default.ScriptTarget.ESNext
6058
+ fs13.readFileSync(pathToConfig, "utf8"),
6059
+ config2.typescript ? ts2.ScriptTarget.Latest : ts2.ScriptTarget.ESNext
5980
6060
  );
5981
6061
  const { configImports, configAuthProviderClass, extraTinaCollections } = config2.authProvider;
5982
6062
  const importMap = {
@@ -5989,7 +6069,7 @@ var addSelfHostedTinaAuthToConfig = async (config2, configFile) => {
5989
6069
  {}
5990
6070
  )
5991
6071
  };
5992
- const transformedSourceFileResult = import_typescript3.default.transform(
6072
+ const transformedSourceFileResult = ts2.transform(
5993
6073
  sourceFile,
5994
6074
  [
5995
6075
  makeImportsVisitor(sourceFile, {
@@ -6025,13 +6105,14 @@ var addSelfHostedTinaAuthToConfig = async (config2, configFile) => {
6025
6105
  )
6026
6106
  ].map((visitor) => makeTransformer(visitor))
6027
6107
  );
6028
- return import_fs_extra12.default.writeFile(
6108
+ return fs13.writeFile(
6029
6109
  pathToConfig,
6030
- import_typescript3.default.createPrinter({ omitTrailingSemicolon: true }).printFile(transformedSourceFileResult.transformed[0])
6110
+ ts2.createPrinter({ omitTrailingSemicolon: true }).printFile(transformedSourceFileResult.transformed[0])
6031
6111
  );
6032
6112
  };
6033
6113
 
6034
6114
  // src/cmds/init/apply.ts
6115
+ import { exec } from "child_process";
6035
6116
  async function apply({
6036
6117
  env,
6037
6118
  params,
@@ -6142,8 +6223,8 @@ async function apply({
6142
6223
  await addConfigFile({
6143
6224
  configArgs: {
6144
6225
  config: config2,
6145
- publicFolder: import_path11.default.join(
6146
- import_path11.default.relative(process.cwd(), pathToForestryConfig),
6226
+ publicFolder: path14.join(
6227
+ path14.relative(process.cwd(), pathToForestryConfig),
6147
6228
  config2.publicFolder
6148
6229
  ),
6149
6230
  collections,
@@ -6200,7 +6281,7 @@ var reportTelemetry = async ({
6200
6281
  if (noTelemetry) {
6201
6282
  logger.info(logText("Telemetry disabled"));
6202
6283
  }
6203
- const telemetry = new import_metrics2.Telemetry({ disabled: noTelemetry });
6284
+ const telemetry = new Telemetry2({ disabled: noTelemetry });
6204
6285
  const schemaFileType = usingTypescript ? "ts" : "js";
6205
6286
  await telemetry.submitRecord({
6206
6287
  event: {
@@ -6216,18 +6297,18 @@ var createPackageJSON = async () => {
6216
6297
  };
6217
6298
  var createGitignore = async ({ baseDir }) => {
6218
6299
  logger.info(logText("No .gitignore found, creating one"));
6219
- import_fs_extra13.default.outputFileSync(import_path11.default.join(baseDir, ".gitignore"), "node_modules");
6300
+ fs14.outputFileSync(path14.join(baseDir, ".gitignore"), "node_modules");
6220
6301
  };
6221
6302
  var updateGitIgnore = async ({
6222
6303
  baseDir,
6223
6304
  items
6224
6305
  }) => {
6225
6306
  logger.info(logText(`Adding ${items.join(",")} to .gitignore`));
6226
- const gitignoreContent = import_fs_extra13.default.readFileSync(import_path11.default.join(baseDir, ".gitignore")).toString();
6307
+ const gitignoreContent = fs14.readFileSync(path14.join(baseDir, ".gitignore")).toString();
6227
6308
  const newGitignoreContent = [...gitignoreContent.split("\n"), ...items].join(
6228
6309
  "\n"
6229
6310
  );
6230
- await import_fs_extra13.default.writeFile(import_path11.default.join(baseDir, ".gitignore"), newGitignoreContent);
6311
+ await fs14.writeFile(path14.join(baseDir, ".gitignore"), newGitignoreContent);
6231
6312
  };
6232
6313
  var addDependencies = async (config2, env, params) => {
6233
6314
  const { packageManager } = config2;
@@ -6268,7 +6349,8 @@ var addDependencies = async (config2, env, params) => {
6268
6349
  let packageManagers = {
6269
6350
  pnpm: process.env.USE_WORKSPACE ? `pnpm add ${deps.join(" ")} --workspace` : `pnpm add ${deps.join(" ")}`,
6270
6351
  npm: `npm install ${deps.join(" ")}`,
6271
- yarn: `yarn add ${deps.join(" ")}`
6352
+ yarn: `yarn add ${deps.join(" ")}`,
6353
+ bun: `bun add ${deps.join(" ")}`
6272
6354
  };
6273
6355
  if (packageManagers[packageManager] && deps.length > 0) {
6274
6356
  logger.info(logText("Adding dependencies, this might take a moment..."));
@@ -6279,7 +6361,8 @@ var addDependencies = async (config2, env, params) => {
6279
6361
  packageManagers = {
6280
6362
  pnpm: process.env.USE_WORKSPACE ? `pnpm add -D ${devDeps.join(" ")} --workspace` : `pnpm add -D ${devDeps.join(" ")}`,
6281
6363
  npm: `npm install -D ${devDeps.join(" ")}`,
6282
- yarn: `yarn add -D ${devDeps.join(" ")}`
6364
+ yarn: `yarn add -D ${devDeps.join(" ")}`,
6365
+ bun: `bun add -D ${devDeps.join(" ")}`
6283
6366
  };
6284
6367
  if (packageManagers[packageManager]) {
6285
6368
  logger.info(
@@ -6296,22 +6379,22 @@ var writeGeneratedFile = async ({
6296
6379
  content,
6297
6380
  typescript
6298
6381
  }) => {
6299
- const { exists, path: path14, parentPath } = generatedFile.resolve(typescript);
6382
+ const { exists, path: path15, parentPath } = generatedFile.resolve(typescript);
6300
6383
  if (exists) {
6301
6384
  if (overwrite) {
6302
- logger.info(`Overwriting file at ${path14}... \u2705`);
6303
- import_fs_extra13.default.outputFileSync(path14, content);
6385
+ logger.info(`Overwriting file at ${path15}... \u2705`);
6386
+ fs14.outputFileSync(path15, content);
6304
6387
  } else {
6305
- logger.info(`Not overwriting file at ${path14}.`);
6388
+ logger.info(`Not overwriting file at ${path15}.`);
6306
6389
  logger.info(
6307
- logText(`Please add the following to ${path14}:
6390
+ logText(`Please add the following to ${path15}:
6308
6391
  ${indentText(content)}}`)
6309
6392
  );
6310
6393
  }
6311
6394
  } else {
6312
- logger.info(`Adding file at ${path14}... \u2705`);
6313
- await import_fs_extra13.default.ensureDir(parentPath);
6314
- import_fs_extra13.default.outputFileSync(path14, content);
6395
+ logger.info(`Adding file at ${path15}... \u2705`);
6396
+ await fs14.ensureDir(parentPath);
6397
+ fs14.outputFileSync(path15, content);
6315
6398
  }
6316
6399
  };
6317
6400
  var addConfigFile = async ({
@@ -6320,7 +6403,7 @@ var addConfigFile = async ({
6320
6403
  generatedFile,
6321
6404
  config: config2
6322
6405
  }) => {
6323
- const content = (0, import_prettier2.format)(generateConfig(configArgs), {
6406
+ const content = format2(generateConfig(configArgs), {
6324
6407
  parser: "babel"
6325
6408
  });
6326
6409
  await writeGeneratedFile({
@@ -6350,7 +6433,7 @@ var addNextApiRoute = async ({
6350
6433
  generatedFile,
6351
6434
  env
6352
6435
  }) => {
6353
- const content = (0, import_prettier2.format)(nextApiRouteTemplate({ config: config2, env }), {
6436
+ const content = format2(nextApiRouteTemplate({ config: config2, env }), {
6354
6437
  parser: "babel"
6355
6438
  });
6356
6439
  await writeGeneratedFile({
@@ -6389,7 +6472,7 @@ var addContentFile = async ({
6389
6472
  return () => ({
6390
6473
  exists: env.sampleContentExists,
6391
6474
  path: env.sampleContentPath,
6392
- parentPath: import_path11.default.dirname(env.sampleContentPath)
6475
+ parentPath: path14.dirname(env.sampleContentPath)
6393
6476
  });
6394
6477
  }
6395
6478
  },
@@ -6412,10 +6495,10 @@ ${titleText(" TinaCMS ")} backend initialized!`));
6412
6495
  return `${x.key}=${x.value || "***"}`;
6413
6496
  }).join("\n") + `
6414
6497
  TINA_PUBLIC_IS_LOCAL=true`;
6415
- const envFile = import_path11.default.join(process.cwd(), ".env");
6416
- if (!import_fs_extra13.default.existsSync(envFile)) {
6498
+ const envFile = path14.join(process.cwd(), ".env");
6499
+ if (!fs14.existsSync(envFile)) {
6417
6500
  logger.info(`Adding .env file to your project... \u2705`);
6418
- import_fs_extra13.default.writeFileSync(envFile, envFileText);
6501
+ fs14.writeFileSync(envFile, envFileText);
6419
6502
  } else {
6420
6503
  logger.info(
6421
6504
  "Please add the following environment variables to your .env file"
@@ -6437,9 +6520,7 @@ ${titleText(" TinaCMS ")} has been initialized!`));
6437
6520
  );
6438
6521
  if (framework.name === "hugo") {
6439
6522
  logger.info(
6440
- focusText("Hugo is required. "),
6441
- "Don't have Hugo installed? Follow this guide to set it up: ",
6442
- linkText("https://gohugo.io/installation/")
6523
+ focusText("Hugo is required. ") + "Don't have Hugo installed? Follow this guide to set it up: " + linkText("https://gohugo.io/installation/")
6443
6524
  );
6444
6525
  }
6445
6526
  logger.info(
@@ -6458,7 +6539,8 @@ var other = ({ packageManager }) => {
6458
6539
  pnpm: `pnpm`,
6459
6540
  npm: `npx`,
6460
6541
  // npx is the way to run executables that aren't in your "scripts"
6461
- yarn: `yarn`
6542
+ yarn: `yarn`,
6543
+ bun: `bun run`
6462
6544
  };
6463
6545
  return `${packageManagers[packageManager]} tinacms dev -c "<your dev command>"`;
6464
6546
  };
@@ -6471,7 +6553,8 @@ var frameworkDevCmds = {
6471
6553
  pnpm: `pnpm`,
6472
6554
  npm: `npm run`,
6473
6555
  // npx is the way to run executables that aren't in your "scripts"
6474
- yarn: `yarn`
6556
+ yarn: `yarn`,
6557
+ bun: `bun run`
6475
6558
  };
6476
6559
  return `${packageManagers[packageManager]} dev`;
6477
6560
  }
@@ -6484,7 +6567,7 @@ var addReactiveFile = {
6484
6567
  baseDir,
6485
6568
  dataLayer
6486
6569
  }) => {
6487
- const packageJsonPath = import_path11.default.join(baseDir, "package.json");
6570
+ const packageJsonPath = path14.join(baseDir, "package.json");
6488
6571
  await writeGeneratedFile({
6489
6572
  generatedFile,
6490
6573
  typescript: config2.typescript,
@@ -6497,7 +6580,7 @@ var addReactiveFile = {
6497
6580
  })
6498
6581
  });
6499
6582
  logger.info("Adding a nextjs example... \u2705");
6500
- const packageJson = JSON.parse(import_fs_extra13.default.readFileSync(packageJsonPath).toString());
6583
+ const packageJson = JSON.parse(fs14.readFileSync(packageJsonPath).toString());
6501
6584
  const scripts = packageJson.scripts || {};
6502
6585
  const updatedPackageJson = JSON.stringify(
6503
6586
  {
@@ -6510,11 +6593,10 @@ var addReactiveFile = {
6510
6593
  null,
6511
6594
  2
6512
6595
  );
6513
- import_fs_extra13.default.writeFileSync(packageJsonPath, updatedPackageJson);
6596
+ fs14.writeFileSync(packageJsonPath, updatedPackageJson);
6514
6597
  }
6515
6598
  };
6516
6599
  function execShellCommand(cmd) {
6517
- const exec = require("child_process").exec;
6518
6600
  return new Promise((resolve2, reject) => {
6519
6601
  exec(cmd, (error, stdout, stderr) => {
6520
6602
  if (error) {
@@ -6560,34 +6642,27 @@ var command = new CLICommand({
6560
6642
  });
6561
6643
 
6562
6644
  // src/next/commands/init-command/index.ts
6563
- var InitCommand = class extends import_clipanion6.Command {
6564
- constructor() {
6565
- super(...arguments);
6566
- this.pathToForestryConfig = import_clipanion6.Option.String("--forestryPath", {
6567
- description: "Specify the relative path to the .forestry directory, if importing an existing forestry site."
6568
- });
6569
- this.rootPath = import_clipanion6.Option.String("--rootPath", {
6570
- description: "Specify the root directory to run the CLI from (defaults to current working directory)"
6571
- });
6572
- this.debug = import_clipanion6.Option.Boolean("--debug", false, {
6573
- description: "Enable debug logging"
6574
- });
6575
- this.noTelemetry = import_clipanion6.Option.Boolean("--noTelemetry", false, {
6576
- description: "Disable anonymous telemetry that is collected"
6577
- });
6578
- this.tinaVersion = import_clipanion6.Option.String("--tinaVersion", {
6579
- description: "Specify a version for tina dependencies"
6580
- });
6581
- }
6582
- static {
6583
- this.paths = [["init"], ["init", "backend"]];
6584
- }
6585
- static {
6586
- this.usage = import_clipanion6.Command.Usage({
6587
- category: `Commands`,
6588
- description: `Add Tina to an existing project`
6589
- });
6590
- }
6645
+ var InitCommand = class extends Command6 {
6646
+ static paths = [["init"], ["init", "backend"]];
6647
+ pathToForestryConfig = Option6.String("--forestryPath", {
6648
+ description: "Specify the relative path to the .forestry directory, if importing an existing forestry site."
6649
+ });
6650
+ rootPath = Option6.String("--rootPath", {
6651
+ description: "Specify the root directory to run the CLI from (defaults to current working directory)"
6652
+ });
6653
+ debug = Option6.Boolean("--debug", false, {
6654
+ description: "Enable debug logging"
6655
+ });
6656
+ noTelemetry = Option6.Boolean("--noTelemetry", false, {
6657
+ description: "Disable anonymous telemetry that is collected"
6658
+ });
6659
+ tinaVersion = Option6.String("--tinaVersion", {
6660
+ description: "Specify a version for tina dependencies"
6661
+ });
6662
+ static usage = Command6.Usage({
6663
+ category: `Commands`,
6664
+ description: `Add Tina to an existing project`
6665
+ });
6591
6666
  async catch(error) {
6592
6667
  logger.error("Error occured during tinacms init");
6593
6668
  console.error(error);
@@ -6609,28 +6684,24 @@ var InitCommand = class extends import_clipanion6.Command {
6609
6684
  };
6610
6685
 
6611
6686
  // src/next/commands/searchindex-command/index.ts
6612
- var import_clipanion7 = require("clipanion");
6613
- var import_graphql17 = require("@tinacms/graphql");
6614
- var import_search3 = require("@tinacms/search");
6615
- var SearchIndexCommand = class extends import_clipanion7.Command {
6616
- constructor() {
6617
- super(...arguments);
6618
- this.rootPath = import_clipanion7.Option.String("--rootPath", {
6619
- description: "Specify the root directory to run the CLI from (defaults to current working directory)"
6620
- });
6621
- this.verbose = import_clipanion7.Option.Boolean("-v,--verbose", false, {
6622
- description: "increase verbosity of logged output"
6623
- });
6624
- }
6625
- static {
6626
- this.paths = [["search-index"]];
6627
- }
6628
- static {
6629
- this.usage = import_clipanion7.Command.Usage({
6630
- category: `Commands`,
6631
- description: `Index the site for search`
6632
- });
6633
- }
6687
+ import { Command as Command7, Option as Option7 } from "clipanion";
6688
+ import { createSchema, FilesystemBridge as FilesystemBridge4 } from "@tinacms/graphql";
6689
+ import {
6690
+ SearchIndexer as SearchIndexer3,
6691
+ TinaCMSSearchIndexClient as TinaCMSSearchIndexClient2
6692
+ } from "@tinacms/search";
6693
+ var SearchIndexCommand = class extends Command7 {
6694
+ static paths = [["search-index"]];
6695
+ rootPath = Option7.String("--rootPath", {
6696
+ description: "Specify the root directory to run the CLI from (defaults to current working directory)"
6697
+ });
6698
+ verbose = Option7.Boolean("-v,--verbose", false, {
6699
+ description: "increase verbosity of logged output"
6700
+ });
6701
+ static usage = Command7.Usage({
6702
+ category: `Commands`,
6703
+ description: `Index the site for search`
6704
+ });
6634
6705
  async catch(error) {
6635
6706
  logger.error("Error occured during tinacms search-index");
6636
6707
  console.error(error);
@@ -6652,7 +6723,7 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6652
6723
  process.exit(1);
6653
6724
  }
6654
6725
  const { schema } = configManager.config;
6655
- const tinaSchema = await (0, import_graphql17.createSchema)({
6726
+ const tinaSchema = await createSchema({
6656
6727
  schema: { ...schema, config: configManager.config }
6657
6728
  });
6658
6729
  let client;
@@ -6680,7 +6751,7 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6680
6751
  "indexerToken not configured in tina search configuration."
6681
6752
  );
6682
6753
  }
6683
- client = new import_search3.TinaCMSSearchIndexClient({
6754
+ client = new TinaCMSSearchIndexClient2({
6684
6755
  apiUrl: `${configManager.config.tinaioConfig?.contentApiUrlOverride || "https://content.tinajs.io"}/searchIndex/${configManager.config?.clientId}`,
6685
6756
  branch: configManager.config?.branch,
6686
6757
  indexerToken: configManager.config?.search?.tina?.indexerToken,
@@ -6689,9 +6760,9 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6689
6760
  } else {
6690
6761
  client = configManager.config?.search?.searchClient;
6691
6762
  }
6692
- const searchIndexer = new import_search3.SearchIndexer({
6763
+ const searchIndexer = new SearchIndexer3({
6693
6764
  batchSize: configManager.config.search?.indexBatchSize || 100,
6694
- bridge: new import_graphql17.FilesystemBridge(
6765
+ bridge: new FilesystemBridge4(
6695
6766
  configManager.rootPath,
6696
6767
  configManager.contentRootPath
6697
6768
  ),
@@ -6719,7 +6790,7 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6719
6790
  };
6720
6791
 
6721
6792
  // src/index.ts
6722
- var cli = new import_clipanion8.Cli({
6793
+ var cli = new Cli({
6723
6794
  binaryName: `tinacms`,
6724
6795
  binaryLabel: `TinaCMS`,
6725
6796
  binaryVersion: version
@@ -6730,7 +6801,10 @@ cli.register(AuditCommand);
6730
6801
  cli.register(InitCommand);
6731
6802
  cli.register(CodemodCommand);
6732
6803
  cli.register(SearchIndexCommand);
6733
- cli.register(import_clipanion8.Builtins.DefinitionsCommand);
6734
- cli.register(import_clipanion8.Builtins.HelpCommand);
6735
- cli.register(import_clipanion8.Builtins.VersionCommand);
6804
+ cli.register(Builtins.DefinitionsCommand);
6805
+ cli.register(Builtins.HelpCommand);
6806
+ cli.register(Builtins.VersionCommand);
6736
6807
  var index_default = cli;
6808
+ export {
6809
+ index_default as default
6810
+ };