@tinacms/cli 0.0.0-c0f1b7d-20250702023438 → 0.0.0-c19d29e-20251224001156

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.9";
5
+ var version = "2.0.5";
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() {
@@ -498,7 +488,15 @@ var Codegen = class {
498
488
  JSON.stringify(this.graphqlSchemaDoc)
499
489
  );
500
490
  const { search, ...rest } = this.tinaSchema.schema.config;
501
- this.tinaSchema.schema.config = rest;
491
+ if (search?.tina) {
492
+ const { indexerToken, ...safeSearchConfig } = search.tina;
493
+ this.tinaSchema.schema.config = {
494
+ ...rest,
495
+ search: { tina: safeSearchConfig }
496
+ };
497
+ } else {
498
+ this.tinaSchema.schema.config = rest;
499
+ }
502
500
  await this.writeConfigFile(
503
501
  "_schema.json",
504
502
  JSON.stringify(this.tinaSchema.schema)
@@ -512,11 +510,11 @@ var Codegen = class {
512
510
  await this.removeGeneratedFilesIfExists();
513
511
  return apiURL;
514
512
  }
515
- await import_fs_extra.default.outputFile(
513
+ await fs.outputFile(
516
514
  this.configManager.generatedQueriesFilePath,
517
515
  this.queryDoc
518
516
  );
519
- await import_fs_extra.default.outputFile(
517
+ await fs.outputFile(
520
518
  this.configManager.generatedFragmentsFilePath,
521
519
  this.fragDoc
522
520
  );
@@ -524,21 +522,21 @@ var Codegen = class {
524
522
  const { clientString } = await this.genClient();
525
523
  const databaseClientString = this.configManager.hasSelfHostedConfig() ? await this.genDatabaseClient() : "";
526
524
  const { codeString, schemaString } = await this.genTypes();
527
- await import_fs_extra.default.outputFile(
525
+ await fs.outputFile(
528
526
  this.configManager.generatedGraphQLGQLPath,
529
527
  schemaString
530
528
  );
531
529
  if (this.configManager.isUsingTs()) {
532
- await import_fs_extra.default.outputFile(
530
+ await fs.outputFile(
533
531
  this.configManager.generatedTypesTSFilePath,
534
532
  codeString
535
533
  );
536
- await import_fs_extra.default.outputFile(
534
+ await fs.outputFile(
537
535
  this.configManager.generatedClientTSFilePath,
538
536
  clientString
539
537
  );
540
538
  if (this.configManager.hasSelfHostedConfig()) {
541
- await import_fs_extra.default.outputFile(
539
+ await fs.outputFile(
542
540
  this.configManager.generatedDatabaseClientTSFilePath,
543
541
  databaseClientString
544
542
  );
@@ -547,35 +545,35 @@ var Codegen = class {
547
545
  await unlinkIfExists(this.configManager.generatedTypesDFilePath);
548
546
  await unlinkIfExists(this.configManager.generatedTypesJSFilePath);
549
547
  } else {
550
- await import_fs_extra.default.outputFile(
548
+ await fs.outputFile(
551
549
  this.configManager.generatedTypesDFilePath,
552
550
  codeString
553
551
  );
554
- const jsTypes = await (0, import_esbuild.transform)(codeString, { loader: "ts" });
555
- await import_fs_extra.default.outputFile(
552
+ const jsTypes = await transform(codeString, { loader: "ts" });
553
+ await fs.outputFile(
556
554
  this.configManager.generatedTypesJSFilePath,
557
555
  jsTypes.code
558
556
  );
559
- await import_fs_extra.default.outputFile(
557
+ await fs.outputFile(
560
558
  this.configManager.generatedClientDFilePath,
561
559
  clientString
562
560
  );
563
- const jsClient = await (0, import_esbuild.transform)(clientString, { loader: "ts" });
564
- await import_fs_extra.default.outputFile(
561
+ const jsClient = await transform(clientString, { loader: "ts" });
562
+ await fs.outputFile(
565
563
  this.configManager.generatedClientJSFilePath,
566
564
  jsClient.code
567
565
  );
568
566
  await unlinkIfExists(this.configManager.generatedTypesTSFilePath);
569
567
  await unlinkIfExists(this.configManager.generatedClientTSFilePath);
570
568
  if (this.configManager.hasSelfHostedConfig()) {
571
- const jsDatabaseClient = await (0, import_esbuild.transform)(databaseClientString, {
569
+ const jsDatabaseClient = await transform(databaseClientString, {
572
570
  loader: "ts"
573
571
  });
574
- await import_fs_extra.default.outputFile(
572
+ await fs.outputFile(
575
573
  this.configManager.generatedDatabaseClientJSFilePath,
576
574
  jsDatabaseClient.code
577
575
  );
578
- await import_fs_extra.default.outputFile(
576
+ await fs.outputFile(
579
577
  this.configManager.generatedDatabaseClientDFilePath,
580
578
  databaseClientString
581
579
  );
@@ -601,7 +599,7 @@ var Codegen = class {
601
599
  throw new Error(
602
600
  `Client not configured properly. Missing ${missing.join(
603
601
  ", "
604
- )}. Please visit https://tina.io/docs/tina-cloud/overview for more information`
602
+ )}. Please visit https://tina.io/docs/r/what-is-tinacloud for more information`
605
603
  );
606
604
  }
607
605
  let localUrl = `http://localhost:${this.port}/graphql`;
@@ -623,7 +621,7 @@ var Codegen = class {
623
621
  const authCollection = this.tinaSchema.getCollections().find((c) => c.isAuthCollection);
624
622
  let authFields = [];
625
623
  if (authCollection) {
626
- const usersFields = (0, import_graphql6.mapUserFields)(authCollection, []);
624
+ const usersFields = mapUserFields(authCollection, []);
627
625
  if (usersFields.length === 0) {
628
626
  throw new Error("No user field found");
629
627
  }
@@ -713,7 +711,7 @@ export default databaseClient;
713
711
  const apiURL = this.getApiURL();
714
712
  const clientString = `import { createClient } from "tinacms/dist/client";
715
713
  import { queries } from "./types";
716
- export const client = createClient({ ${this.noClientBuildCache === false ? `cacheDir: '${(0, import_normalize_path.default)(
714
+ export const client = createClient({ ${this.noClientBuildCache === false ? `cacheDir: '${normalizePath(
717
715
  this.configManager.generatedCachePath
718
716
  )}', ` : ""}url: '${apiURL}', token: '${token}', queries, ${errorPolicy ? `errorPolicy: '${errorPolicy}'` : ""} });
719
717
  export default client;
@@ -739,7 +737,7 @@ export default client;
739
737
  ${typescriptTypes}
740
738
  `;
741
739
  const schemaString = `# DO NOT MODIFY THIS FILE. This file is automatically generated by Tina
742
- ${(0, import_graphql5.printSchema)(this.schema)}
740
+ ${printSchema2(this.schema)}
743
741
  schema {
744
742
  query: Query
745
743
  mutation: Mutation
@@ -751,7 +749,7 @@ schema {
751
749
  var maybeWarnFragmentSize = async (filepath) => {
752
750
  if (
753
751
  // is the file bigger than 100kb?
754
- (await import_fs_extra.default.stat(filepath)).size > // convert to 100 kb to bytes
752
+ (await fs.stat(filepath)).size > // convert to 100 kb to bytes
755
753
  100 * 1024
756
754
  ) {
757
755
  console.warn(
@@ -768,19 +766,34 @@ var maybeWarnFragmentSize = async (filepath) => {
768
766
  }
769
767
  };
770
768
  var unlinkIfExists = async (filepath) => {
771
- if (import_fs_extra.default.existsSync(filepath)) {
772
- import_fs_extra.default.unlinkSync(filepath);
769
+ if (fs.existsSync(filepath)) {
770
+ fs.unlinkSync(filepath);
773
771
  }
774
772
  };
775
773
 
776
774
  // 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"));
775
+ import fs2 from "fs-extra";
776
+ import path3 from "path";
777
+ import os from "os";
778
+ import { pathToFileURL } from "url";
779
+ import * as esbuild from "esbuild";
780
+ import * as dotenv from "dotenv";
781
+ import normalizePath2 from "normalize-path";
782
+ import chalk3 from "chalk";
783
+ import { createRequire } from "module";
784
+
785
+ // src/utils/path.ts
786
+ import path2 from "path";
787
+ function stripNativeTrailingSlash(p) {
788
+ const { root } = path2.parse(p);
789
+ let str = p;
790
+ while (str.length > root.length && str.endsWith(path2.sep)) {
791
+ str = str.slice(0, -1);
792
+ }
793
+ return str;
794
+ }
795
+
796
+ // src/next/config-manager.ts
784
797
  var TINA_FOLDER = "tina";
785
798
  var LEGACY_TINA_FOLDER = ".tina";
786
799
  var GENERATED_FOLDER = "__generated__";
@@ -789,17 +802,57 @@ var GRAPHQL_GQL_FILE = "schema.gql";
789
802
  var SCHEMA_JSON_FILE = "_schema.json";
790
803
  var LOOKUP_JSON_FILE = "_lookup.json";
791
804
  var ConfigManager = class {
805
+ config;
806
+ rootPath;
807
+ tinaFolderPath;
808
+ isUsingLegacyFolder;
809
+ tinaConfigFilePath;
810
+ tinaSpaPackagePath;
811
+ contentRootPath;
812
+ envFilePath;
813
+ generatedCachePath;
814
+ generatedFolderPath;
815
+ generatedFolderPathContentRepo;
816
+ generatedGraphQLGQLPath;
817
+ generatedGraphQLJSONPath;
818
+ generatedSchemaJSONPath;
819
+ generatedLookupJSONPath;
820
+ generatedTypesTSFilePath;
821
+ generatedTypesJSFilePath;
822
+ generatedTypesDFilePath;
823
+ generatedClientTSFilePath;
824
+ generatedClientJSFilePath;
825
+ generatedClientDFilePath;
826
+ generatedDatabaseClientJSFilePath;
827
+ generatedDatabaseClientTSFilePath;
828
+ generatedDatabaseClientDFilePath;
829
+ generatedQueriesFilePath;
830
+ generatedFragmentsFilePath;
831
+ generatedQueriesAndFragmentsGlob;
832
+ userQueriesAndFragmentsGlob;
833
+ publicFolderPath;
834
+ outputFolderPath;
835
+ outputHTMLFilePath;
836
+ outputGitignorePath;
837
+ selfHostedDatabaseFilePath;
838
+ prebuildFilePath;
839
+ spaRootPath;
840
+ spaMainPath;
841
+ spaHTMLPath;
842
+ tinaGraphQLVersionFromCLI;
843
+ legacyNoSDK;
844
+ watchList;
792
845
  constructor({
793
846
  rootPath = process.cwd(),
794
847
  tinaGraphQLVersion,
795
848
  legacyNoSDK
796
849
  }) {
797
- this.rootPath = (0, import_normalize_path2.default)(rootPath);
850
+ this.rootPath = normalizePath2(rootPath);
798
851
  this.tinaGraphQLVersionFromCLI = tinaGraphQLVersion;
799
852
  this.legacyNoSDK = legacyNoSDK;
800
853
  }
801
854
  isUsingTs() {
802
- return [".ts", ".tsx"].includes(import_path2.default.extname(this.tinaConfigFilePath));
855
+ return [".ts", ".tsx"].includes(path3.extname(this.tinaConfigFilePath));
803
856
  }
804
857
  hasSelfHostedConfig() {
805
858
  return !!this.selfHostedDatabaseFilePath;
@@ -814,13 +867,14 @@ var ConfigManager = class {
814
867
  return this.config.client?.skip || false;
815
868
  }
816
869
  async processConfig() {
870
+ const require2 = createRequire(import.meta.url);
817
871
  this.tinaFolderPath = await this.getTinaFolderPath(this.rootPath);
818
- this.envFilePath = import_path2.default.resolve(
819
- import_path2.default.join(this.tinaFolderPath, "..", ".env")
872
+ this.envFilePath = path3.resolve(
873
+ path3.join(this.tinaFolderPath, "..", ".env")
820
874
  );
821
875
  dotenv.config({ path: this.envFilePath });
822
876
  this.tinaConfigFilePath = await this.getPathWithExtension(
823
- import_path2.default.join(this.tinaFolderPath, "config")
877
+ path3.join(this.tinaFolderPath, "config")
824
878
  );
825
879
  if (!this.tinaConfigFilePath) {
826
880
  throw new Error(
@@ -828,89 +882,89 @@ var ConfigManager = class {
828
882
  );
829
883
  }
830
884
  this.selfHostedDatabaseFilePath = await this.getPathWithExtension(
831
- import_path2.default.join(this.tinaFolderPath, "database")
885
+ path3.join(this.tinaFolderPath, "database")
832
886
  );
833
- this.generatedFolderPath = import_path2.default.join(this.tinaFolderPath, GENERATED_FOLDER);
834
- this.generatedCachePath = import_path2.default.join(
887
+ this.generatedFolderPath = path3.join(this.tinaFolderPath, GENERATED_FOLDER);
888
+ this.generatedCachePath = path3.join(
835
889
  this.generatedFolderPath,
836
890
  ".cache",
837
891
  String((/* @__PURE__ */ new Date()).getTime())
838
892
  );
839
- this.generatedGraphQLGQLPath = import_path2.default.join(
893
+ this.generatedGraphQLGQLPath = path3.join(
840
894
  this.generatedFolderPath,
841
895
  GRAPHQL_GQL_FILE
842
896
  );
843
- this.generatedGraphQLJSONPath = import_path2.default.join(
897
+ this.generatedGraphQLJSONPath = path3.join(
844
898
  this.generatedFolderPath,
845
899
  GRAPHQL_JSON_FILE
846
900
  );
847
- this.generatedSchemaJSONPath = import_path2.default.join(
901
+ this.generatedSchemaJSONPath = path3.join(
848
902
  this.generatedFolderPath,
849
903
  SCHEMA_JSON_FILE
850
904
  );
851
- this.generatedLookupJSONPath = import_path2.default.join(
905
+ this.generatedLookupJSONPath = path3.join(
852
906
  this.generatedFolderPath,
853
907
  LOOKUP_JSON_FILE
854
908
  );
855
- this.generatedQueriesFilePath = import_path2.default.join(
909
+ this.generatedQueriesFilePath = path3.join(
856
910
  this.generatedFolderPath,
857
911
  "queries.gql"
858
912
  );
859
- this.generatedFragmentsFilePath = import_path2.default.join(
913
+ this.generatedFragmentsFilePath = path3.join(
860
914
  this.generatedFolderPath,
861
915
  "frags.gql"
862
916
  );
863
- this.generatedTypesTSFilePath = import_path2.default.join(
917
+ this.generatedTypesTSFilePath = path3.join(
864
918
  this.generatedFolderPath,
865
919
  "types.ts"
866
920
  );
867
- this.generatedTypesJSFilePath = import_path2.default.join(
921
+ this.generatedTypesJSFilePath = path3.join(
868
922
  this.generatedFolderPath,
869
923
  "types.js"
870
924
  );
871
- this.generatedTypesDFilePath = import_path2.default.join(
925
+ this.generatedTypesDFilePath = path3.join(
872
926
  this.generatedFolderPath,
873
927
  "types.d.ts"
874
928
  );
875
- this.userQueriesAndFragmentsGlob = import_path2.default.join(
929
+ this.userQueriesAndFragmentsGlob = path3.join(
876
930
  this.tinaFolderPath,
877
931
  "queries/**/*.{graphql,gql}"
878
932
  );
879
- this.generatedQueriesAndFragmentsGlob = import_path2.default.join(
933
+ this.generatedQueriesAndFragmentsGlob = path3.join(
880
934
  this.generatedFolderPath,
881
935
  "*.{graphql,gql}"
882
936
  );
883
- this.generatedClientTSFilePath = import_path2.default.join(
937
+ this.generatedClientTSFilePath = path3.join(
884
938
  this.generatedFolderPath,
885
939
  "client.ts"
886
940
  );
887
- this.generatedClientJSFilePath = import_path2.default.join(
941
+ this.generatedClientJSFilePath = path3.join(
888
942
  this.generatedFolderPath,
889
943
  "client.js"
890
944
  );
891
- this.generatedClientDFilePath = import_path2.default.join(
945
+ this.generatedClientDFilePath = path3.join(
892
946
  this.generatedFolderPath,
893
947
  "client.d.ts"
894
948
  );
895
- this.generatedDatabaseClientDFilePath = import_path2.default.join(
949
+ this.generatedDatabaseClientDFilePath = path3.join(
896
950
  this.generatedFolderPath,
897
951
  "databaseClient.d.ts"
898
952
  );
899
- this.generatedDatabaseClientTSFilePath = import_path2.default.join(
953
+ this.generatedDatabaseClientTSFilePath = path3.join(
900
954
  this.generatedFolderPath,
901
955
  "databaseClient.ts"
902
956
  );
903
- this.generatedDatabaseClientJSFilePath = import_path2.default.join(
957
+ this.generatedDatabaseClientJSFilePath = path3.join(
904
958
  this.generatedFolderPath,
905
959
  "databaseClient.js"
906
960
  );
907
- const clientExists = this.isUsingTs() ? await import_fs_extra2.default.pathExists(this.generatedClientTSFilePath) : await import_fs_extra2.default.pathExists(this.generatedClientJSFilePath);
961
+ const clientExists = this.isUsingTs() ? await fs2.pathExists(this.generatedClientTSFilePath) : await fs2.pathExists(this.generatedClientJSFilePath);
908
962
  if (!clientExists) {
909
963
  const file = "export default ()=>({})\nexport const client = ()=>({})";
910
964
  if (this.isUsingTs()) {
911
- await import_fs_extra2.default.outputFile(this.generatedClientTSFilePath, file);
965
+ await fs2.outputFile(this.generatedClientTSFilePath, file);
912
966
  } else {
913
- await import_fs_extra2.default.outputFile(this.generatedClientJSFilePath, file);
967
+ await fs2.outputFile(this.generatedClientJSFilePath, file);
914
968
  }
915
969
  }
916
970
  const { config: config2, prebuildPath, watchList } = await this.loadConfigFile(
@@ -920,30 +974,29 @@ var ConfigManager = class {
920
974
  this.watchList = watchList;
921
975
  this.config = config2;
922
976
  this.prebuildFilePath = prebuildPath;
923
- this.publicFolderPath = import_path2.default.join(
977
+ this.publicFolderPath = path3.join(
924
978
  this.rootPath,
925
979
  this.config.build.publicFolder
926
980
  );
927
- this.outputFolderPath = import_path2.default.join(
981
+ this.outputFolderPath = path3.join(
928
982
  this.publicFolderPath,
929
983
  this.config.build.outputFolder
930
984
  );
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 || ""
985
+ this.outputHTMLFilePath = path3.join(this.outputFolderPath, "index.html");
986
+ this.outputGitignorePath = path3.join(this.outputFolderPath, ".gitignore");
987
+ const fullLocalContentPath = stripNativeTrailingSlash(
988
+ path3.join(this.tinaFolderPath, this.config.localContentPath || "")
936
989
  );
937
990
  if (this.config.localContentPath) {
938
- const localContentPathExists = await import_fs_extra2.default.pathExists(fullLocalContentPath);
991
+ const localContentPathExists = await fs2.pathExists(fullLocalContentPath);
939
992
  if (localContentPathExists) {
940
993
  logger.info(`Using separate content repo at ${fullLocalContentPath}`);
941
994
  this.contentRootPath = fullLocalContentPath;
942
995
  } else {
943
996
  logger.warn(
944
- `${import_chalk3.default.yellow("Warning:")} The localContentPath ${import_chalk3.default.cyan(
997
+ `${chalk3.yellow("Warning:")} The localContentPath ${chalk3.cyan(
945
998
  fullLocalContentPath
946
- )} does not exist. Please create it or remove the localContentPath from your config file at ${import_chalk3.default.cyan(
999
+ )} does not exist. Please create it or remove the localContentPath from your config file at ${chalk3.cyan(
947
1000
  this.tinaConfigFilePath
948
1001
  )}`
949
1002
  );
@@ -952,22 +1005,22 @@ var ConfigManager = class {
952
1005
  if (!this.contentRootPath) {
953
1006
  this.contentRootPath = this.rootPath;
954
1007
  }
955
- this.generatedFolderPathContentRepo = import_path2.default.join(
1008
+ this.generatedFolderPathContentRepo = path3.join(
956
1009
  await this.getTinaFolderPath(this.contentRootPath),
957
1010
  GENERATED_FOLDER
958
1011
  );
959
- this.spaMainPath = require.resolve("@tinacms/app");
960
- this.spaRootPath = import_path2.default.join(this.spaMainPath, "..", "..");
1012
+ this.spaMainPath = require2.resolve("@tinacms/app");
1013
+ this.spaRootPath = path3.join(this.spaMainPath, "..", "..");
961
1014
  }
962
1015
  async getTinaFolderPath(rootPath) {
963
- const tinaFolderPath = import_path2.default.join(rootPath, TINA_FOLDER);
964
- const tinaFolderExists = await import_fs_extra2.default.pathExists(tinaFolderPath);
1016
+ const tinaFolderPath = path3.join(rootPath, TINA_FOLDER);
1017
+ const tinaFolderExists = await fs2.pathExists(tinaFolderPath);
965
1018
  if (tinaFolderExists) {
966
1019
  this.isUsingLegacyFolder = false;
967
1020
  return tinaFolderPath;
968
1021
  }
969
- const legacyFolderPath = import_path2.default.join(rootPath, LEGACY_TINA_FOLDER);
970
- const legacyFolderExists = await import_fs_extra2.default.pathExists(legacyFolderPath);
1022
+ const legacyFolderPath = path3.join(rootPath, LEGACY_TINA_FOLDER);
1023
+ const legacyFolderExists = await fs2.pathExists(legacyFolderPath);
971
1024
  if (legacyFolderExists) {
972
1025
  this.isUsingLegacyFolder = true;
973
1026
  return legacyFolderPath;
@@ -986,7 +1039,7 @@ var ConfigManager = class {
986
1039
  patch: version2[2] || "x"
987
1040
  };
988
1041
  }
989
- const generatedSchema = import_fs_extra2.default.readJSONSync(this.generatedSchemaJSONPath);
1042
+ const generatedSchema = fs2.readJSONSync(this.generatedSchemaJSONPath);
990
1043
  if (!generatedSchema || !(typeof generatedSchema?.version !== "undefined")) {
991
1044
  throw new Error(
992
1045
  `Can not find Tina GraphQL version in ${this.generatedSchemaJSONPath}`
@@ -1033,7 +1086,7 @@ var ConfigManager = class {
1033
1086
  return;
1034
1087
  }
1035
1088
  const filepathWithExtension = `${filepath}.${ext}`;
1036
- const exists = import_fs_extra2.default.existsSync(filepathWithExtension);
1089
+ const exists = fs2.existsSync(filepathWithExtension);
1037
1090
  if (exists) {
1038
1091
  result = filepathWithExtension;
1039
1092
  }
@@ -1042,33 +1095,45 @@ var ConfigManager = class {
1042
1095
  return result;
1043
1096
  }
1044
1097
  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");
1098
+ const tmpdir = path3.join(os.tmpdir(), Date.now().toString());
1099
+ const outfile = path3.join(tmpdir, "database.build.mjs");
1047
1100
  await esbuild.build({
1048
1101
  entryPoints: [this.selfHostedDatabaseFilePath],
1049
1102
  bundle: true,
1050
1103
  platform: "node",
1104
+ format: "esm",
1051
1105
  outfile,
1052
- loader: loaders
1106
+ loader: loaders,
1107
+ // Provide a require() polyfill for ESM bundles containing CommonJS packages.
1108
+ // Some bundled packages (e.g., 'scmp' used by 'mongodb-level') use require('crypto').
1109
+ // When esbuild inlines these CommonJS packages, it keeps the require() calls,
1110
+ // but ESM doesn't have a global require. This banner creates one using Node.js's
1111
+ // official createRequire API, allowing the bundled CommonJS code to work in ESM.
1112
+ banner: {
1113
+ js: `import { createRequire } from 'module';const require = createRequire(import.meta.url);`
1114
+ }
1053
1115
  });
1054
- const result = require(outfile);
1055
- import_fs_extra2.default.removeSync(outfile);
1116
+ const result = await import(pathToFileURL(outfile).href);
1117
+ fs2.removeSync(outfile);
1056
1118
  return result.default;
1057
1119
  }
1058
1120
  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(
1121
+ const tmpdir = path3.join(os.tmpdir(), Date.now().toString());
1122
+ const preBuildConfigPath = path3.join(
1061
1123
  this.generatedFolderPath,
1062
1124
  "config.prebuild.jsx"
1063
1125
  );
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, "{}");
1126
+ const outfile = path3.join(tmpdir, "config.build.jsx");
1127
+ const outfile2 = path3.join(tmpdir, "config.build.mjs");
1128
+ const tempTSConfigFile = path3.join(tmpdir, "tsconfig.json");
1129
+ const esmRequireBanner = {
1130
+ js: `import { createRequire } from 'module';const require = createRequire(import.meta.url);`
1131
+ };
1132
+ fs2.outputFileSync(tempTSConfigFile, "{}");
1068
1133
  const result2 = await esbuild.build({
1069
1134
  entryPoints: [configFilePath],
1070
1135
  bundle: true,
1071
- target: ["es2020"],
1136
+ target: ["esnext"],
1072
1137
  platform: "browser",
1073
1138
  format: "esm",
1074
1139
  logLevel: "silent",
@@ -1088,31 +1153,34 @@ var ConfigManager = class {
1088
1153
  await esbuild.build({
1089
1154
  entryPoints: [configFilePath],
1090
1155
  bundle: true,
1091
- target: ["es2020"],
1156
+ target: ["esnext"],
1092
1157
  logLevel: "silent",
1093
1158
  platform: "node",
1159
+ format: "esm",
1094
1160
  outfile,
1095
- loader: loaders
1161
+ loader: loaders,
1162
+ banner: esmRequireBanner
1096
1163
  });
1097
1164
  await esbuild.build({
1098
1165
  entryPoints: [outfile],
1099
1166
  bundle: true,
1100
- // Suppress warning about comparison with -0 from client module
1101
1167
  logLevel: "silent",
1102
1168
  platform: "node",
1169
+ target: ["esnext"],
1170
+ format: "esm",
1103
1171
  outfile: outfile2,
1104
1172
  loader: loaders
1105
1173
  });
1106
1174
  let result;
1107
1175
  try {
1108
- result = require(outfile2);
1176
+ result = await import(pathToFileURL(outfile2).href);
1109
1177
  } catch (e) {
1110
1178
  console.error("Unexpected error loading config");
1111
1179
  console.error(e);
1112
1180
  throw e;
1113
1181
  }
1114
- import_fs_extra2.default.removeSync(outfile);
1115
- import_fs_extra2.default.removeSync(outfile2);
1182
+ fs2.removeSync(outfile);
1183
+ fs2.removeSync(outfile2);
1116
1184
  return {
1117
1185
  config: result.default,
1118
1186
  prebuildPath: preBuildConfigPath,
@@ -1147,20 +1215,24 @@ var loaders = {
1147
1215
  };
1148
1216
 
1149
1217
  // 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");
1218
+ import {
1219
+ createDatabaseInternal,
1220
+ FilesystemBridge,
1221
+ TinaLevelClient
1222
+ } from "@tinacms/graphql";
1223
+ import { pipeline } from "readable-stream";
1224
+ import { createServer } from "net";
1225
+ import { ManyLevelHost } from "many-level";
1226
+ import { MemoryLevel } from "memory-level";
1155
1227
  var createDBServer = (port) => {
1156
- const levelHost = new import_many_level.ManyLevelHost(
1228
+ const levelHost = new ManyLevelHost(
1157
1229
  // @ts-ignore
1158
- new import_memory_level.MemoryLevel({
1230
+ new MemoryLevel({
1159
1231
  valueEncoding: "json"
1160
1232
  })
1161
1233
  );
1162
- const dbServer = (0, import_net.createServer)(function(socket) {
1163
- return (0, import_readable_stream.pipeline)(socket, levelHost.createRpcStream(), socket, () => {
1234
+ const dbServer = createServer(function(socket) {
1235
+ return pipeline(socket, levelHost.createRpcStream(), socket, () => {
1164
1236
  });
1165
1237
  });
1166
1238
  dbServer.once("error", (err) => {
@@ -1174,7 +1246,7 @@ var createDBServer = (port) => {
1174
1246
  };
1175
1247
  async function createAndInitializeDatabase(configManager, datalayerPort, bridgeOverride) {
1176
1248
  let database;
1177
- const bridge = bridgeOverride || new import_graphql7.FilesystemBridge(configManager.rootPath, configManager.contentRootPath);
1249
+ const bridge = bridgeOverride || new FilesystemBridge(configManager.rootPath, configManager.contentRootPath);
1178
1250
  if (configManager.hasSelfHostedConfig() && configManager.config.contentApiUrlOverride) {
1179
1251
  database = await configManager.loadDatabaseFile();
1180
1252
  database.bridge = bridge;
@@ -1186,9 +1258,9 @@ async function createAndInitializeDatabase(configManager, datalayerPort, bridgeO
1186
1258
  )} but there was no "contentApiUrlOverride" set. Falling back to built-in datalayer`
1187
1259
  );
1188
1260
  }
1189
- const level = new import_graphql7.TinaLevelClient(datalayerPort);
1261
+ const level = new TinaLevelClient(datalayerPort);
1190
1262
  level.openConnection();
1191
- database = (0, import_graphql7.createDatabaseInternal)({
1263
+ database = createDatabaseInternal({
1192
1264
  bridge,
1193
1265
  level,
1194
1266
  tinaDirectory: configManager.isUsingLegacyFolder ? LEGACY_TINA_FOLDER : TINA_FOLDER
@@ -1198,17 +1270,17 @@ async function createAndInitializeDatabase(configManager, datalayerPort, bridgeO
1198
1270
  }
1199
1271
 
1200
1272
  // src/next/commands/baseCommands.ts
1201
- var import_clipanion = require("clipanion");
1202
- var import_chalk4 = __toESM(require("chalk"));
1273
+ import { Command, Option } from "clipanion";
1274
+ import chalk4 from "chalk";
1203
1275
 
1204
1276
  // src/utils/start-subprocess.ts
1205
- var import_child_process = __toESM(require("child_process"));
1277
+ import childProcess from "child_process";
1206
1278
  var startSubprocess2 = async ({ command: command2 }) => {
1207
1279
  if (typeof command2 === "string") {
1208
1280
  const commands = command2.split(" ");
1209
1281
  const firstCommand = commands[0];
1210
1282
  const args = commands.slice(1) || [];
1211
- const ps = import_child_process.default.spawn(firstCommand, args, {
1283
+ const ps = childProcess.spawn(firstCommand, args, {
1212
1284
  stdio: "inherit",
1213
1285
  shell: true
1214
1286
  });
@@ -1232,45 +1304,42 @@ stack: ${code.stack || "No stack was provided"}`);
1232
1304
  };
1233
1305
 
1234
1306
  // 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
- }
1307
+ import { getChangedFiles, getSha, shaExists } from "@tinacms/graphql";
1308
+ import fs3 from "fs-extra";
1309
+ var BaseCommand = class extends Command {
1310
+ experimentalDataLayer = Option.Boolean("--experimentalData", {
1311
+ description: "DEPRECATED - Build the server with additional data querying capabilities"
1312
+ });
1313
+ isomorphicGitBridge = Option.Boolean("--isomorphicGitBridge", {
1314
+ description: "DEPRECATED - Enable Isomorphic Git Bridge Implementation"
1315
+ });
1316
+ port = Option.String("-p,--port", "4001", {
1317
+ description: "Specify a port to run the server on. (default 4001)"
1318
+ });
1319
+ datalayerPort = Option.String("--datalayer-port", "9000", {
1320
+ description: "Specify a port to run the datalayer server on. (default 9000)"
1321
+ });
1322
+ subCommand = Option.String("-c,--command", {
1323
+ description: "The sub-command to run"
1324
+ });
1325
+ rootPath = Option.String("--rootPath", {
1326
+ description: "Specify the root directory to run the CLI from (defaults to current working directory)"
1327
+ });
1328
+ verbose = Option.Boolean("-v,--verbose", false, {
1329
+ description: "increase verbosity of logged output"
1330
+ });
1331
+ noSDK = Option.Boolean("--noSDK", false, {
1332
+ description: "DEPRECATED - This should now be set in the config at client.skip = true'. Don't generate the generated client SDK"
1333
+ });
1334
+ noTelemetry = Option.Boolean("--noTelemetry", false, {
1335
+ description: "Disable anonymous telemetry that is collected"
1336
+ });
1268
1337
  async startSubCommand() {
1269
1338
  let subProc;
1270
1339
  if (this.subCommand) {
1271
1340
  subProc = await startSubprocess2({ command: this.subCommand });
1272
1341
  logger.info(
1273
- `Running web application with command: ${import_chalk4.default.cyan(this.subCommand)}`
1342
+ `Running web application with command: ${chalk4.cyan(this.subCommand)}`
1274
1343
  );
1275
1344
  }
1276
1345
  function exitHandler(options, exitCode) {
@@ -1318,7 +1387,7 @@ var BaseCommand = class extends import_clipanion.Command {
1318
1387
  const rootPath = configManager.rootPath;
1319
1388
  let sha;
1320
1389
  try {
1321
- sha = await (0, import_graphql8.getSha)({ fs: import_fs_extra3.default, dir: rootPath });
1390
+ sha = await getSha({ fs: fs3, dir: rootPath });
1322
1391
  } catch (e) {
1323
1392
  if (partialReindex) {
1324
1393
  console.error(
@@ -1328,7 +1397,7 @@ var BaseCommand = class extends import_clipanion.Command {
1328
1397
  }
1329
1398
  }
1330
1399
  const lastSha = await database.getMetadata("lastSha");
1331
- const exists = lastSha && await (0, import_graphql8.shaExists)({ fs: import_fs_extra3.default, dir: rootPath, sha: lastSha });
1400
+ const exists = lastSha && await shaExists({ fs: fs3, dir: rootPath, sha: lastSha });
1332
1401
  let res;
1333
1402
  if (partialReindex && lastSha && exists && sha) {
1334
1403
  const pathFilter = {};
@@ -1342,15 +1411,15 @@ var BaseCommand = class extends import_clipanion.Command {
1342
1411
  matches: collection.match?.exclude || collection.match?.include ? tinaSchema.getMatches({ collection }) : void 0
1343
1412
  };
1344
1413
  }
1345
- const { added, modified, deleted } = await (0, import_graphql8.getChangedFiles)({
1346
- fs: import_fs_extra3.default,
1414
+ const { added, modified, deleted } = await getChangedFiles({
1415
+ fs: fs3,
1347
1416
  dir: rootPath,
1348
1417
  from: lastSha,
1349
1418
  to: sha,
1350
1419
  pathFilter
1351
1420
  });
1352
1421
  const tinaPathUpdates = modified.filter(
1353
- (path14) => path14.startsWith(".tina/__generated__/_schema.json") || path14.startsWith("tina/tina-lock.json")
1422
+ (path15) => path15.startsWith(".tina/__generated__/_schema.json") || path15.startsWith("tina/tina-lock.json")
1354
1423
  );
1355
1424
  if (tinaPathUpdates.length > 0) {
1356
1425
  res = await database.indexContent({
@@ -1428,7 +1497,7 @@ var errorHTML = `<style type="text/css">
1428
1497
  the assets for this page.
1429
1498
  </p>
1430
1499
  <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.
1500
+ 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
1501
  </p>
1433
1502
  </div>
1434
1503
  </div>`.trim().replace(/[\r\n\s]+/g, " ");
@@ -1466,34 +1535,38 @@ var devHTML = (port) => `<!DOCTYPE html>
1466
1535
  </html>`;
1467
1536
 
1468
1537
  // src/next/commands/dev-command/server/index.ts
1469
- var import_vite3 = require("vite");
1538
+ import { createServer as createViteServer } from "vite";
1470
1539
 
1471
1540
  // 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");
1541
+ import path5 from "node:path";
1542
+ import react from "@vitejs/plugin-react";
1543
+ import fs4 from "fs-extra";
1544
+ import normalizePath3 from "normalize-path";
1545
+ import {
1546
+ splitVendorChunkPlugin
1547
+ } from "vite";
1477
1548
 
1478
1549
  // 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"));
1550
+ import path4 from "node:path";
1551
+ import aspectRatio from "@tailwindcss/aspect-ratio";
1552
+ import containerQueries from "@tailwindcss/container-queries";
1553
+ import twTypography from "@tailwindcss/typography";
1554
+ import tailwind from "tailwindcss";
1555
+ import defaultTheme from "tailwindcss/defaultTheme.js";
1556
+ import { createRequire as createRequire2 } from "module";
1485
1557
  var tinaTailwind = (spaPath, prebuildFilePath) => {
1486
1558
  return {
1487
1559
  name: "vite-plugin-tina",
1488
1560
  // @ts-ignore
1489
1561
  config: (viteConfig) => {
1562
+ const require2 = createRequire2(import.meta.url);
1490
1563
  const plugins = [];
1491
1564
  const content = [
1492
- import_node_path.default.join(spaPath, "src/**/*.{vue,js,ts,jsx,tsx,svelte}"),
1565
+ path4.join(spaPath, "src/**/*.{vue,js,ts,jsx,tsx,svelte}"),
1493
1566
  prebuildFilePath,
1494
- require.resolve("tinacms")
1567
+ require2.resolve("tinacms")
1495
1568
  ];
1496
- const tw = (0, import_tailwindcss.default)({
1569
+ const tw = tailwind({
1497
1570
  theme: {
1498
1571
  columns: {
1499
1572
  auto: "auto",
@@ -1645,7 +1718,7 @@ var tinaTailwind = (spaPath, prebuildFilePath) => {
1645
1718
  },
1646
1719
  boxShadow: {
1647
1720
  xs: "0 0 0 1px rgba(0, 0, 0, 0.05)",
1648
- outline: "0 0 0 3px rgba(66, 153, 225, 0.5)"
1721
+ outline: "0 0 0 3px rgba(194, 65, 12, 0.2)"
1649
1722
  },
1650
1723
  colors: {
1651
1724
  blue: {
@@ -1681,6 +1754,9 @@ var tinaTailwind = (spaPath, prebuildFilePath) => {
1681
1754
  500: "#EC4815",
1682
1755
  600: "#DC4419"
1683
1756
  },
1757
+ "tina-orange": "#EC4815",
1758
+ "tina-orange-dark": "#C2410C",
1759
+ "tina-orange-light": "#FFF7ED",
1684
1760
  background: "#FFFFFF",
1685
1761
  foreground: "#0A0A0A",
1686
1762
  muted: "#F5F5F5",
@@ -1699,10 +1775,10 @@ var tinaTailwind = (spaPath, prebuildFilePath) => {
1699
1775
  "accent-foreground": "#171717",
1700
1776
  destructive: "#FF3B3B",
1701
1777
  "destructive-foreground": "#FAFAFA",
1702
- ring: "#0A0A0A"
1778
+ ring: "#C2410C"
1703
1779
  },
1704
1780
  fontFamily: {
1705
- sans: ["Inter", ...import_defaultTheme.default.fontFamily.sans]
1781
+ sans: ["Inter", ...defaultTheme.fontFamily.sans]
1706
1782
  },
1707
1783
  lineHeight: {
1708
1784
  3: "12px",
@@ -1727,9 +1803,9 @@ var tinaTailwind = (spaPath, prebuildFilePath) => {
1727
1803
  },
1728
1804
  content,
1729
1805
  plugins: [
1730
- (0, import_typography.default)({ className: "tina-prose" }),
1731
- import_aspect_ratio.default,
1732
- import_container_queries.default
1806
+ twTypography({ className: "tina-prose" }),
1807
+ aspectRatio,
1808
+ containerQueries
1733
1809
  ]
1734
1810
  });
1735
1811
  plugins.push(tw);
@@ -1750,35 +1826,35 @@ async function listFilesRecursively({
1750
1826
  config: config2,
1751
1827
  roothPath
1752
1828
  }) {
1753
- const fullDirectoryPath = import_node_path2.default.join(
1829
+ const fullDirectoryPath = path5.join(
1754
1830
  roothPath,
1755
1831
  config2.publicFolder,
1756
1832
  directoryPath
1757
1833
  );
1758
- const exists = await import_fs_extra4.default.pathExists(fullDirectoryPath);
1834
+ const exists = await fs4.pathExists(fullDirectoryPath);
1759
1835
  if (!exists) {
1760
1836
  return { "0": [] };
1761
1837
  }
1762
- const items = await import_fs_extra4.default.readdir(fullDirectoryPath);
1838
+ const items = await fs4.readdir(fullDirectoryPath);
1763
1839
  const staticMediaItems = [];
1764
1840
  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);
1841
+ const itemPath = path5.join(fullDirectoryPath, item);
1842
+ const stats = await fs4.promises.lstat(itemPath);
1767
1843
  const staticMediaItem = {
1768
1844
  id: item,
1769
1845
  filename: item,
1770
1846
  type: stats.isDirectory() ? "dir" : "file",
1771
1847
  directory: `${directoryPath.replace(config2.mediaRoot, "")}`,
1772
- src: `/${import_node_path2.default.join(directoryPath, item)}`,
1848
+ src: `/${path5.join(directoryPath, item)}`,
1773
1849
  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)}`
1850
+ "75x75": `/${path5.join(directoryPath, item)}`,
1851
+ "400x400": `/${path5.join(directoryPath, item)}`,
1852
+ "1000x1000": `/${path5.join(directoryPath, item)}`
1777
1853
  }
1778
1854
  };
1779
1855
  if (stats.isDirectory()) {
1780
1856
  staticMediaItem.children = await listFilesRecursively({
1781
- directoryPath: import_node_path2.default.join(directoryPath, item),
1857
+ directoryPath: path5.join(directoryPath, item),
1782
1858
  config: config2,
1783
1859
  roothPath
1784
1860
  });
@@ -1819,7 +1895,7 @@ var createConfig = async ({
1819
1895
  }
1820
1896
  }
1821
1897
  });
1822
- const staticMediaPath = import_node_path2.default.join(
1898
+ const staticMediaPath = path5.join(
1823
1899
  configManager.generatedFolderPath,
1824
1900
  "static-media.json"
1825
1901
  );
@@ -1829,21 +1905,21 @@ var createConfig = async ({
1829
1905
  config: configManager.config.media.tina,
1830
1906
  roothPath: configManager.rootPath
1831
1907
  });
1832
- await import_fs_extra4.default.outputFile(staticMediaPath, JSON.stringify(staticMedia, null, 2));
1908
+ await fs4.outputFile(staticMediaPath, JSON.stringify(staticMedia, null, 2));
1833
1909
  } else {
1834
- await import_fs_extra4.default.outputFile(staticMediaPath, `[]`);
1910
+ await fs4.outputFile(staticMediaPath, `[]`);
1835
1911
  }
1836
1912
  const alias = {
1837
1913
  TINA_IMPORT: configManager.prebuildFilePath,
1838
1914
  SCHEMA_IMPORT: configManager.generatedGraphQLJSONPath,
1839
1915
  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")
1916
+ crypto: path5.join(configManager.spaRootPath, "src", "dummy-client.ts"),
1917
+ fs: path5.join(configManager.spaRootPath, "src", "dummy-client.ts"),
1918
+ os: path5.join(configManager.spaRootPath, "src", "dummy-client.ts"),
1919
+ path: path5.join(configManager.spaRootPath, "src", "dummy-client.ts")
1844
1920
  };
1845
1921
  if (configManager.shouldSkipSDK()) {
1846
- alias["CLIENT_IMPORT"] = import_node_path2.default.join(
1922
+ alias["CLIENT_IMPORT"] = path5.join(
1847
1923
  configManager.spaRootPath,
1848
1924
  "src",
1849
1925
  "dummy-client.ts"
@@ -1859,7 +1935,7 @@ var createConfig = async ({
1859
1935
  const version2 = `${fullVersion.major}.${fullVersion.minor}`;
1860
1936
  const config2 = {
1861
1937
  root: configManager.spaRootPath,
1862
- base: `/${basePath ? `${(0, import_normalize_path3.default)(basePath)}/` : ""}${(0, import_normalize_path3.default)(
1938
+ base: `/${basePath ? `${normalizePath3(basePath)}/` : ""}${normalizePath3(
1863
1939
  configManager.config.build.outputFolder
1864
1940
  )}/`,
1865
1941
  appType: "spa",
@@ -1922,13 +1998,14 @@ var createConfig = async ({
1922
1998
  * `splitVendorChunkPlugin` is needed because `tinacms` is quite large,
1923
1999
  * Vite's chunking strategy chokes on memory issues for smaller machines (ie. on CI).
1924
2000
  */
1925
- (0, import_plugin_react.default)({
2001
+ react({
1926
2002
  babel: {
1927
2003
  // Supresses the warning [NOTE] babel The code generator has deoptimised the styling of
1928
2004
  compact: true
1929
- }
2005
+ },
2006
+ fastRefresh: false
1930
2007
  }),
1931
- (0, import_vite.splitVendorChunkPlugin)(),
2008
+ splitVendorChunkPlugin(),
1932
2009
  tinaTailwind(configManager.spaRootPath, configManager.prebuildFilePath),
1933
2010
  ...plugins
1934
2011
  ]
@@ -1937,21 +2014,21 @@ var createConfig = async ({
1937
2014
  };
1938
2015
 
1939
2016
  // 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");
2017
+ import { createFilter } from "@rollup/pluginutils";
2018
+ import fs6 from "fs";
2019
+ import { transformWithEsbuild } from "vite";
2020
+ import { transform as esbuildTransform } from "esbuild";
2021
+ import path7 from "path";
2022
+ import bodyParser from "body-parser";
2023
+ import cors from "cors";
2024
+ import { resolve as gqlResolve } from "@tinacms/graphql";
1948
2025
 
1949
2026
  // 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"));
2027
+ import fs5 from "fs-extra";
2028
+ import path6, { join } from "path";
2029
+ import busboy from "busboy";
1953
2030
  var createMediaRouter = (config2) => {
1954
- const mediaFolder = import_path3.default.join(
2031
+ const mediaFolder = path6.join(
1955
2032
  config2.rootPath,
1956
2033
  config2.publicFolder,
1957
2034
  config2.mediaRoot
@@ -1975,12 +2052,12 @@ var createMediaRouter = (config2) => {
1975
2052
  res.end(JSON.stringify(didDelete));
1976
2053
  };
1977
2054
  const handlePost = async function(req, res) {
1978
- const bb = (0, import_busboy.default)({ headers: req.headers });
2055
+ const bb = busboy({ headers: req.headers });
1979
2056
  bb.on("file", async (_name, file, _info) => {
1980
2057
  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));
2058
+ const saveTo = path6.join(mediaFolder, ...fullPath.split("/"));
2059
+ await fs5.ensureDir(path6.dirname(saveTo));
2060
+ file.pipe(fs5.createWriteStream(saveTo));
1984
2061
  });
1985
2062
  bb.on("error", (error) => {
1986
2063
  res.statusCode = 500;
@@ -2006,6 +2083,9 @@ var parseMediaFolder = (str) => {
2006
2083
  return returnString;
2007
2084
  };
2008
2085
  var MediaModel = class {
2086
+ rootPath;
2087
+ publicFolder;
2088
+ mediaRoot;
2009
2089
  constructor({ rootPath, publicFolder, mediaRoot }) {
2010
2090
  this.rootPath = rootPath;
2011
2091
  this.mediaRoot = mediaRoot;
@@ -2013,23 +2093,23 @@ var MediaModel = class {
2013
2093
  }
2014
2094
  async listMedia(args) {
2015
2095
  try {
2016
- const folderPath = (0, import_path3.join)(
2096
+ const folderPath = join(
2017
2097
  this.rootPath,
2018
2098
  this.publicFolder,
2019
2099
  this.mediaRoot,
2020
2100
  decodeURIComponent(args.searchPath)
2021
2101
  );
2022
2102
  const searchPath = parseMediaFolder(args.searchPath);
2023
- if (!await import_fs_extra5.default.pathExists(folderPath)) {
2103
+ if (!await fs5.pathExists(folderPath)) {
2024
2104
  return {
2025
2105
  files: [],
2026
2106
  directories: []
2027
2107
  };
2028
2108
  }
2029
- const filesStr = await import_fs_extra5.default.readdir(folderPath);
2109
+ const filesStr = await fs5.readdir(folderPath);
2030
2110
  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);
2111
+ const filePath = join(folderPath, file);
2112
+ const stat = await fs5.stat(filePath);
2033
2113
  let src = `/${file}`;
2034
2114
  const isFile = stat.isFile();
2035
2115
  if (!isFile) {
@@ -2085,14 +2165,14 @@ var MediaModel = class {
2085
2165
  }
2086
2166
  async deleteMedia(args) {
2087
2167
  try {
2088
- const file = (0, import_path3.join)(
2168
+ const file = join(
2089
2169
  this.rootPath,
2090
2170
  this.publicFolder,
2091
2171
  this.mediaRoot,
2092
2172
  decodeURIComponent(args.searchPath)
2093
2173
  );
2094
- await import_fs_extra5.default.stat(file);
2095
- await import_fs_extra5.default.remove(file);
2174
+ await fs5.stat(file);
2175
+ await fs5.remove(file);
2096
2176
  return { ok: true };
2097
2177
  } catch (error) {
2098
2178
  console.error(error);
@@ -2107,34 +2187,127 @@ var createSearchIndexRouter = ({
2107
2187
  searchIndex
2108
2188
  }) => {
2109
2189
  const put = async (req, res) => {
2110
- const { docs } = req.body;
2190
+ const docs = req.body?.docs ?? [];
2111
2191
  const result = await searchIndex.PUT(docs);
2112
2192
  res.writeHead(200, { "Content-Type": "application/json" });
2113
2193
  res.end(JSON.stringify({ result }));
2114
2194
  };
2115
2195
  const get = async (req, res) => {
2116
- const requestURL = new URL(req.url, config2.apiURL);
2196
+ const requestURL = new URL(req.url ?? "", config2.apiURL);
2197
+ const isV2 = requestURL.pathname.startsWith("/v2/searchIndex");
2198
+ res.writeHead(200, { "Content-Type": "application/json" });
2199
+ if (isV2) {
2200
+ const queryParam = requestURL.searchParams.get("query");
2201
+ const collectionParam = requestURL.searchParams.get("collection");
2202
+ const limitParam = requestURL.searchParams.get("limit");
2203
+ const cursorParam = requestURL.searchParams.get("cursor");
2204
+ if (!queryParam) {
2205
+ res.end(JSON.stringify({ RESULT: [], RESULT_LENGTH: 0 }));
2206
+ return;
2207
+ }
2208
+ if (!searchIndex.fuzzySearchWrapper) {
2209
+ res.end(JSON.stringify({ RESULT: [], RESULT_LENGTH: 0 }));
2210
+ return;
2211
+ }
2212
+ try {
2213
+ const paginationOptions = {};
2214
+ if (limitParam) {
2215
+ paginationOptions.limit = parseInt(limitParam, 10);
2216
+ }
2217
+ if (cursorParam) {
2218
+ paginationOptions.cursor = cursorParam;
2219
+ }
2220
+ const searchQuery = collectionParam ? `${queryParam} _collection:${collectionParam}` : queryParam;
2221
+ const result2 = await searchIndex.fuzzySearchWrapper.query(searchQuery, {
2222
+ ...paginationOptions
2223
+ });
2224
+ if (collectionParam) {
2225
+ result2.results = result2.results.filter(
2226
+ (r) => r._id && r._id.startsWith(`${collectionParam}:`)
2227
+ );
2228
+ }
2229
+ res.end(
2230
+ JSON.stringify({
2231
+ RESULT: result2.results,
2232
+ RESULT_LENGTH: result2.total,
2233
+ NEXT_CURSOR: result2.nextCursor,
2234
+ PREV_CURSOR: result2.prevCursor,
2235
+ FUZZY_MATCHES: result2.fuzzyMatches || {}
2236
+ })
2237
+ );
2238
+ return;
2239
+ } catch (error) {
2240
+ console.warn(
2241
+ "[search] v2 fuzzy search failed:",
2242
+ error instanceof Error ? error.message : error
2243
+ );
2244
+ res.end(JSON.stringify({ RESULT: [], RESULT_LENGTH: 0 }));
2245
+ return;
2246
+ }
2247
+ }
2117
2248
  const query = requestURL.searchParams.get("q");
2118
2249
  const optionsParam = requestURL.searchParams.get("options");
2119
- let options = {
2120
- DOCUMENTS: false
2121
- };
2250
+ const fuzzyParam = requestURL.searchParams.get("fuzzy");
2251
+ const fuzzyOptionsParam = requestURL.searchParams.get("fuzzyOptions");
2252
+ if (!query) {
2253
+ res.end(JSON.stringify({ RESULT: [] }));
2254
+ return;
2255
+ }
2256
+ let searchIndexOptions = { DOCUMENTS: false };
2122
2257
  if (optionsParam) {
2123
- options = {
2124
- ...options,
2258
+ searchIndexOptions = {
2259
+ ...searchIndexOptions,
2125
2260
  ...JSON.parse(optionsParam)
2126
2261
  };
2127
2262
  }
2128
- res.writeHead(200, { "Content-Type": "application/json" });
2129
- if (query) {
2130
- const result = await searchIndex.QUERY(JSON.parse(query), options);
2131
- res.end(JSON.stringify(result));
2132
- } else {
2133
- res.end(JSON.stringify({ RESULT: [] }));
2263
+ const queryObj = JSON.parse(query);
2264
+ if (fuzzyParam === "true" && searchIndex.fuzzySearchWrapper) {
2265
+ try {
2266
+ const fuzzyOptions = fuzzyOptionsParam ? JSON.parse(fuzzyOptionsParam) : {};
2267
+ const searchTerms = queryObj.AND ? queryObj.AND.filter(
2268
+ (term) => !term.includes("_collection:")
2269
+ ) : [];
2270
+ const collectionFilter = queryObj.AND?.find(
2271
+ (term) => term.includes("_collection:")
2272
+ );
2273
+ const paginationOptions = {};
2274
+ if (searchIndexOptions.PAGE) {
2275
+ paginationOptions.limit = searchIndexOptions.PAGE.SIZE;
2276
+ paginationOptions.cursor = searchIndexOptions.PAGE.NUMBER.toString();
2277
+ }
2278
+ const searchQuery = collectionFilter ? `${searchTerms.join(" ")} ${collectionFilter}` : searchTerms.join(" ");
2279
+ const result2 = await searchIndex.fuzzySearchWrapper.query(searchQuery, {
2280
+ ...paginationOptions,
2281
+ fuzzyOptions
2282
+ });
2283
+ if (collectionFilter) {
2284
+ const collection = collectionFilter.split(":")[1];
2285
+ result2.results = result2.results.filter(
2286
+ (r) => r._id && r._id.startsWith(`${collection}:`)
2287
+ );
2288
+ }
2289
+ res.end(
2290
+ JSON.stringify({
2291
+ RESULT: result2.results,
2292
+ RESULT_LENGTH: result2.total,
2293
+ NEXT_CURSOR: result2.nextCursor,
2294
+ PREV_CURSOR: result2.prevCursor,
2295
+ FUZZY_MATCHES: result2.fuzzyMatches || {}
2296
+ })
2297
+ );
2298
+ return;
2299
+ } catch (error) {
2300
+ console.warn(
2301
+ "[search] Fuzzy search failed, falling back to standard search:",
2302
+ error instanceof Error ? error.message : error
2303
+ );
2304
+ }
2134
2305
  }
2306
+ const result = await searchIndex.QUERY(queryObj, searchIndexOptions);
2307
+ res.end(JSON.stringify(result));
2135
2308
  };
2136
2309
  const del = async (req, res) => {
2137
- const requestURL = new URL(req.url, config2.apiURL);
2310
+ const requestURL = new URL(req.url ?? "", config2.apiURL);
2138
2311
  const docId = requestURL.pathname.split("/").filter(Boolean).slice(1).join("/");
2139
2312
  const result = await searchIndex.DELETE(docId);
2140
2313
  res.writeHead(200, { "Content-Type": "application/json" });
@@ -2150,9 +2323,9 @@ var transformTsxPlugin = ({
2150
2323
  const plug = {
2151
2324
  name: "transform-tsx",
2152
2325
  async transform(code, id) {
2153
- const extName = import_path4.default.extname(id);
2326
+ const extName = path7.extname(id);
2154
2327
  if (extName.startsWith(".tsx") || extName.startsWith(".ts")) {
2155
- const result = await (0, import_esbuild2.transform)(code, { loader: "tsx" });
2328
+ const result = await esbuildTransform(code, { loader: "tsx" });
2156
2329
  return {
2157
2330
  code: result.code
2158
2331
  };
@@ -2171,8 +2344,8 @@ var devServerEndPointsPlugin = ({
2171
2344
  const plug = {
2172
2345
  name: "graphql-endpoints",
2173
2346
  configureServer(server) {
2174
- server.middlewares.use((0, import_cors.default)());
2175
- server.middlewares.use(import_body_parser.default.json({ limit: "5mb" }));
2347
+ server.middlewares.use(cors());
2348
+ server.middlewares.use(bodyParser.json({ limit: "5mb" }));
2176
2349
  server.middlewares.use(async (req, res, next) => {
2177
2350
  const mediaPaths = configManager.config.media?.tina;
2178
2351
  const mediaRouter = createMediaRouter({
@@ -2211,7 +2384,7 @@ var devServerEndPointsPlugin = ({
2211
2384
  const { query, variables } = req.body;
2212
2385
  let result;
2213
2386
  await databaseLock(async () => {
2214
- result = await (0, import_graphql9.resolve)({
2387
+ result = await gqlResolve({
2215
2388
  config: {
2216
2389
  useRelativeMedia: true
2217
2390
  },
@@ -2224,7 +2397,7 @@ var devServerEndPointsPlugin = ({
2224
2397
  res.end(JSON.stringify(result));
2225
2398
  return;
2226
2399
  }
2227
- if (req.url.startsWith("/searchIndex")) {
2400
+ if (req.url.startsWith("/searchIndex") || req.url.startsWith("/v2/searchIndex")) {
2228
2401
  if (req.method === "POST") {
2229
2402
  await searchIndexRouter.put(req, res);
2230
2403
  } else if (req.method === "GET") {
@@ -2247,13 +2420,13 @@ function viteTransformExtension({
2247
2420
  include = "**/*.svg",
2248
2421
  exclude
2249
2422
  } = {}) {
2250
- const filter = (0, import_pluginutils.createFilter)(include, exclude);
2423
+ const filter = createFilter(include, exclude);
2251
2424
  return {
2252
2425
  name: "vite-plugin-svgr",
2253
2426
  async transform(code, id) {
2254
2427
  if (filter(id)) {
2255
2428
  const { transform: transform2 } = await import("@svgr/core");
2256
- const svgCode = await import_fs.default.promises.readFile(
2429
+ const svgCode = await fs6.promises.readFile(
2257
2430
  id.replace(/\?.*$/, ""),
2258
2431
  "utf8"
2259
2432
  );
@@ -2263,7 +2436,7 @@ function viteTransformExtension({
2263
2436
  previousExport: exportAsDefault ? null : code
2264
2437
  }
2265
2438
  });
2266
- const res = await (0, import_vite2.transformWithEsbuild)(componentCode, id, {
2439
+ const res = await transformWithEsbuild(componentCode, id, {
2267
2440
  loader: "jsx",
2268
2441
  ...esbuildOptions
2269
2442
  });
@@ -2290,7 +2463,7 @@ var createDevServer = async (configManager, database, searchIndex, apiURL, noWat
2290
2463
  }),
2291
2464
  viteTransformExtension()
2292
2465
  ];
2293
- return (0, import_vite3.createServer)(
2466
+ return createViteServer(
2294
2467
  await createConfig({
2295
2468
  configManager,
2296
2469
  database,
@@ -2320,37 +2493,30 @@ var createDevServer = async (configManager, database, searchIndex, apiURL, noWat
2320
2493
 
2321
2494
  // src/next/commands/dev-command/index.ts
2322
2495
  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
- }
2496
+ static paths = [["dev"], ["server:start"]];
2497
+ // NOTE: camelCase commands for string options don't work if there's an `=` used https://github.com/arcanis/clipanion/issues/141
2498
+ watchFolders = Option2.String("-w,--watchFolders", {
2499
+ description: "DEPRECATED - a list of folders (relative to where this is being run) that the cli will watch for changes"
2500
+ });
2501
+ noWatch = Option2.Boolean("--noWatch", false, {
2502
+ description: "Don't regenerate config on file changes"
2503
+ });
2504
+ outputSearchIndexPath = Option2.String("--outputSearchIndexPath", {
2505
+ description: "Path to write the search index to"
2506
+ });
2507
+ noServer = Option2.Boolean("--no-server", false, {
2508
+ description: "Do not start the dev server"
2509
+ });
2510
+ indexingLock = new AsyncLock();
2511
+ // Prevent indexes and reads occurring at once
2512
+ static usage = Command2.Usage({
2513
+ category: `Commands`,
2514
+ description: `Builds Tina and starts the dev server`,
2515
+ examples: [
2516
+ [`A basic example`, `$0 dev`],
2517
+ [`A second example`, `$0 dev --rootPath`]
2518
+ ]
2519
+ });
2354
2520
  async catch(error) {
2355
2521
  logger.error("Error occured during tinacms dev");
2356
2522
  console.error(error);
@@ -2387,7 +2553,7 @@ var DevCommand = class extends BaseCommand {
2387
2553
  } else {
2388
2554
  database.clearCache();
2389
2555
  }
2390
- const { tinaSchema: tinaSchema2, graphQLSchema: graphQLSchema2, lookup, queryDoc, fragDoc } = await (0, import_graphql10.buildSchema)(configManager.config);
2556
+ const { tinaSchema: tinaSchema2, graphQLSchema: graphQLSchema2, lookup, queryDoc, fragDoc } = await buildSchema(configManager.config);
2391
2557
  const codegen2 = new Codegen({
2392
2558
  isLocal: true,
2393
2559
  configManager,
@@ -2401,29 +2567,32 @@ var DevCommand = class extends BaseCommand {
2401
2567
  });
2402
2568
  const apiURL2 = await codegen2.execute();
2403
2569
  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);
2570
+ const schemaObject = await fs7.readJSON(
2571
+ configManager.generatedSchemaJSONPath
2572
+ );
2573
+ const lookupObject = await fs7.readJSON(
2574
+ configManager.generatedLookupJSONPath
2575
+ );
2576
+ const graphqlSchemaObject = await fs7.readJSON(
2577
+ configManager.generatedGraphQLJSONPath
2578
+ );
2410
2579
  const tinaLockFilename = "tina-lock.json";
2411
2580
  const tinaLockContent = JSON.stringify({
2412
2581
  schema: schemaObject,
2413
2582
  lookup: lookupObject,
2414
2583
  graphql: graphqlSchemaObject
2415
2584
  });
2416
- import_fs_extra6.default.writeFileSync(
2417
- import_path5.default.join(configManager.tinaFolderPath, tinaLockFilename),
2585
+ fs7.writeFileSync(
2586
+ path8.join(configManager.tinaFolderPath, tinaLockFilename),
2418
2587
  tinaLockContent
2419
2588
  );
2420
2589
  if (configManager.hasSeparateContentRoot()) {
2421
2590
  const rootPath = await configManager.getTinaFolderPath(
2422
2591
  configManager.contentRootPath
2423
2592
  );
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);
2593
+ const filePath = path8.join(rootPath, tinaLockFilename);
2594
+ await fs7.ensureFile(filePath);
2595
+ await fs7.outputFile(filePath, tinaLockContent);
2427
2596
  }
2428
2597
  }
2429
2598
  await this.indexContentWithSpinner({
@@ -2466,19 +2635,19 @@ ${dangerText(e.message)}
2466
2635
  const { apiURL, graphQLSchema, tinaSchema } = await setup({
2467
2636
  firstTime: true
2468
2637
  });
2469
- await import_fs_extra6.default.outputFile(configManager.outputHTMLFilePath, devHTML(this.port));
2470
- await import_fs_extra6.default.outputFile(
2638
+ await fs7.outputFile(configManager.outputHTMLFilePath, devHTML(this.port));
2639
+ await fs7.outputFile(
2471
2640
  configManager.outputGitignorePath,
2472
2641
  "index.html\nassets/"
2473
2642
  );
2474
- const searchIndexClient = new import_search.LocalSearchIndexClient({
2643
+ const searchIndexClient = new LocalSearchIndexClient({
2475
2644
  stopwordLanguages: configManager.config.search?.tina?.stopwordLanguages,
2476
2645
  tokenSplitRegex: configManager.config.search?.tina?.tokenSplitRegex
2477
2646
  });
2478
2647
  await searchIndexClient.onStartIndexing();
2479
- const searchIndexer = new import_search.SearchIndexer({
2648
+ const searchIndexer = new SearchIndexer({
2480
2649
  batchSize: configManager.config.search?.indexBatchSize || 100,
2481
- bridge: new import_graphql10.FilesystemBridge(
2650
+ bridge: new FilesystemBridge2(
2482
2651
  configManager.rootPath,
2483
2652
  configManager.contentRootPath
2484
2653
  ),
@@ -2509,17 +2678,21 @@ ${dangerText(e.message)}
2509
2678
  configManager.config.search && searchIndexer
2510
2679
  );
2511
2680
  }
2681
+ const searchIndexWithFuzzy = searchIndexClient.searchIndex;
2682
+ if (searchIndexWithFuzzy && searchIndexClient.fuzzySearchWrapper) {
2683
+ searchIndexWithFuzzy.fuzzySearchWrapper = searchIndexClient.fuzzySearchWrapper;
2684
+ }
2512
2685
  const server = await createDevServer(
2513
2686
  configManager,
2514
2687
  database,
2515
- searchIndexClient.searchIndex,
2688
+ searchIndexWithFuzzy,
2516
2689
  apiURL,
2517
2690
  this.noWatch,
2518
2691
  dbLock
2519
2692
  );
2520
2693
  await server.listen(Number(this.port));
2521
2694
  if (!this.noWatch) {
2522
- import_chokidar.default.watch(configManager.watchList).on("change", async () => {
2695
+ chokidar.watch(configManager.watchList).on("change", async () => {
2523
2696
  await dbLock(async () => {
2524
2697
  logger.info(`Tina config change detected, rebuilding`);
2525
2698
  await setup({ firstTime: false });
@@ -2581,11 +2754,11 @@ ${dangerText(e.message)}
2581
2754
  // subItems: [
2582
2755
  // {
2583
2756
  // key: 'Custom queries',
2584
- // value: 'https://tina.io/querying',
2757
+ // value: 'https://tina.io/docs/r/content-api-overview',
2585
2758
  // },
2586
2759
  // {
2587
2760
  // key: 'Visual editing',
2588
- // value: 'https://tina.io/visual-editing',
2761
+ // value: 'https://tina.io/docs/r/visual-editing-setup',
2589
2762
  // },
2590
2763
  // ],
2591
2764
  // },
@@ -2596,14 +2769,14 @@ ${dangerText(e.message)}
2596
2769
  watchContentFiles(configManager, database, databaseLock, searchIndexer) {
2597
2770
  const collectionContentFiles = [];
2598
2771
  configManager.config.schema.collections.forEach((collection) => {
2599
- const collectionGlob = `${import_path5.default.join(
2772
+ const collectionGlob = `${path8.join(
2600
2773
  configManager.contentRootPath,
2601
2774
  collection.path
2602
2775
  )}/**/*.${collection.format || "md"}`;
2603
2776
  collectionContentFiles.push(collectionGlob);
2604
2777
  });
2605
2778
  let ready = false;
2606
- import_chokidar.default.watch(collectionContentFiles).on("ready", () => {
2779
+ chokidar.watch(collectionContentFiles).on("ready", () => {
2607
2780
  ready = true;
2608
2781
  }).on("add", async (addedFile) => {
2609
2782
  if (!ready) {
@@ -2640,28 +2813,35 @@ ${dangerText(e.message)}
2640
2813
  await callback();
2641
2814
  });
2642
2815
  };
2643
- import_chokidar.default.watch(configManager.userQueriesAndFragmentsGlob).on("add", executeCallback).on("change", executeCallback).on("unlink", executeCallback);
2816
+ chokidar.watch(configManager.userQueriesAndFragmentsGlob).on("add", executeCallback).on("change", executeCallback).on("unlink", executeCallback);
2644
2817
  }
2645
2818
  };
2646
2819
 
2647
2820
  // 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"));
2821
+ import crypto from "crypto";
2822
+ import path9 from "path";
2823
+ import { diff } from "@graphql-inspector/core";
2824
+ import { FilesystemBridge as FilesystemBridge3, buildSchema as buildSchema2 } from "@tinacms/graphql";
2825
+ import { parseURL as parseURL2 } from "@tinacms/schema-tools";
2826
+ import {
2827
+ SearchIndexer as SearchIndexer2,
2828
+ TinaCMSSearchIndexClient
2829
+ } from "@tinacms/search";
2830
+ import { Command as Command3, Option as Option3 } from "clipanion";
2831
+ import fs8 from "fs-extra";
2832
+ import {
2833
+ buildASTSchema as buildASTSchema2,
2834
+ buildClientSchema,
2835
+ getIntrospectionQuery
2836
+ } from "graphql";
2837
+ import Progress2 from "progress";
2658
2838
 
2659
2839
  // src/utils/index.ts
2660
- var import_core2 = require("@graphql-inspector/core");
2840
+ import { ChangeType } from "@graphql-inspector/core";
2661
2841
  var getFaqLink = (type) => {
2662
2842
  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";
2843
+ case ChangeType.FieldRemoved: {
2844
+ return "https://tina.io/docs/r/FAQ/#2-how-do-i-resolve-the-local-graphql-schema-doesnt-match-the-remote-graphql-schema-error";
2665
2845
  }
2666
2846
  default:
2667
2847
  return null;
@@ -2682,7 +2862,7 @@ async function sleepAndCallFunc({
2682
2862
  }
2683
2863
 
2684
2864
  // src/next/commands/build-command/server.ts
2685
- var import_vite5 = require("vite");
2865
+ import { build as build2 } from "vite";
2686
2866
  var buildProductionSpa = async (configManager, database, apiURL) => {
2687
2867
  const publicEnv = {};
2688
2868
  Object.keys(process.env).forEach((key) => {
@@ -2716,12 +2896,12 @@ var buildProductionSpa = async (configManager, database, apiURL) => {
2716
2896
  }
2717
2897
  }
2718
2898
  });
2719
- return (0, import_vite5.build)(config2);
2899
+ return build2(config2);
2720
2900
  };
2721
2901
 
2722
2902
  // src/next/commands/build-command/waitForDB.ts
2723
- var import_schema_tools = require("@tinacms/schema-tools");
2724
- var import_progress = __toESM(require("progress"));
2903
+ import { parseURL } from "@tinacms/schema-tools";
2904
+ import Progress from "progress";
2725
2905
  var POLLING_INTERVAL = 5e3;
2726
2906
  var STATUS_INPROGRESS = "inprogress";
2727
2907
  var STATUS_COMPLETE = "complete";
@@ -2734,14 +2914,14 @@ var IndexFailedError = class extends Error {
2734
2914
  };
2735
2915
  var waitForDB = async (config2, apiUrl, previewName, verbose) => {
2736
2916
  const token = config2.token;
2737
- const { clientId, branch, isLocalClient, host } = (0, import_schema_tools.parseURL)(apiUrl);
2917
+ const { clientId, branch, isLocalClient, host } = parseURL(apiUrl);
2738
2918
  if (isLocalClient || !host || !clientId || !branch) {
2739
2919
  if (verbose) {
2740
2920
  logger.info(logText("Not using TinaCloud, skipping DB check"));
2741
2921
  }
2742
2922
  return;
2743
2923
  }
2744
- const bar2 = new import_progress.default(
2924
+ const bar2 = new Progress(
2745
2925
  "Checking indexing process in TinaCloud... :prog",
2746
2926
  1
2747
2927
  );
@@ -2804,51 +2984,44 @@ var waitForDB = async (config2, apiUrl, previewName, verbose) => {
2804
2984
 
2805
2985
  // src/next/commands/build-command/index.ts
2806
2986
  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
- }
2987
+ static paths = [["build"]];
2988
+ localOption = Option3.Boolean("--local", {
2989
+ description: "Starts local Graphql server and builds the local client instead of production client"
2990
+ });
2991
+ skipIndexing = Option3.Boolean("--skip-indexing", false, {
2992
+ description: "Skips indexing the content. This can be used for building the site without indexing the content (defaults to false)"
2993
+ });
2994
+ partialReindex = Option3.Boolean("--partial-reindex", false, {
2995
+ description: "Re-indexes only the content that has changed since the last build (defaults to false). Not currently supported for separate content repos."
2996
+ });
2997
+ tinaGraphQLVersion = Option3.String("--tina-graphql-version", {
2998
+ description: "Specify the version of @tinacms/graphql to use (defaults to latest)"
2999
+ });
3000
+ /**
3001
+ * 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
3002
+ */
3003
+ skipCloudChecks = Option3.Boolean("--skip-cloud-checks", false, {
3004
+ description: "Skips checking the provided cloud config."
3005
+ });
3006
+ skipSearchIndex = Option3.Boolean("--skip-search-index", false, {
3007
+ description: "Skip indexing the site for search"
3008
+ });
3009
+ upstreamBranch = Option3.String("--upstream-branch", {
3010
+ description: "Optional upstream branch with the schema. If not specified, default will be used."
3011
+ });
3012
+ previewBaseBranch = Option3.String("--preview-base-branch", {
3013
+ description: "The base branch for the preview"
3014
+ });
3015
+ previewName = Option3.String("--preview-name", {
3016
+ description: "The name of the preview branch"
3017
+ });
3018
+ noClientBuildCache = Option3.Boolean("--no-client-build-cache", false, {
3019
+ description: "Disables the client build cache"
3020
+ });
3021
+ static usage = Command3.Usage({
3022
+ category: `Commands`,
3023
+ description: `Build the CMS and autogenerated modules for usage with TinaCloud`
3024
+ });
2852
3025
  async catch(error) {
2853
3026
  console.error(error);
2854
3027
  process.exit(1);
@@ -2893,7 +3066,7 @@ ${dangerText(e.message)}`);
2893
3066
  configManager,
2894
3067
  Number(this.datalayerPort)
2895
3068
  );
2896
- const { queryDoc, fragDoc, graphQLSchema, tinaSchema, lookup } = await (0, import_graphql11.buildSchema)(configManager.config);
3069
+ const { queryDoc, fragDoc, graphQLSchema, tinaSchema, lookup } = await buildSchema2(configManager.config);
2897
3070
  const codegen2 = new Codegen({
2898
3071
  configManager,
2899
3072
  port: this.localOption ? Number(this.port) : void 0,
@@ -3001,7 +3174,7 @@ ${dangerText(e.message)}
3001
3174
  }
3002
3175
  }
3003
3176
  await buildProductionSpa(configManager, database, codegen2.productionUrl);
3004
- await import_fs_extra7.default.outputFile(
3177
+ await fs8.outputFile(
3005
3178
  configManager.outputGitignorePath,
3006
3179
  "index.html\nassets/"
3007
3180
  );
@@ -3033,7 +3206,7 @@ ${dangerText(e.message)}
3033
3206
  "indexerToken not configured in tina search configuration."
3034
3207
  );
3035
3208
  }
3036
- client = new import_search2.TinaCMSSearchIndexClient({
3209
+ client = new TinaCMSSearchIndexClient({
3037
3210
  apiUrl: `${configManager.config.tinaioConfig?.contentApiUrlOverride || "https://content.tinajs.io"}/searchIndex/${configManager.config?.clientId}`,
3038
3211
  branch: configManager.config?.branch,
3039
3212
  indexerToken: configManager.config?.search?.tina?.indexerToken,
@@ -3042,9 +3215,9 @@ ${dangerText(e.message)}
3042
3215
  } else {
3043
3216
  client = configManager.config?.search?.searchClient;
3044
3217
  }
3045
- const searchIndexer = new import_search2.SearchIndexer({
3218
+ const searchIndexer = new SearchIndexer2({
3046
3219
  batchSize: configManager.config.search?.indexBatchSize || 100,
3047
- bridge: new import_graphql11.FilesystemBridge(
3220
+ bridge: new FilesystemBridge3(
3048
3221
  configManager.rootPath,
3049
3222
  configManager.contentRootPath
3050
3223
  ),
@@ -3114,8 +3287,8 @@ ${dangerText(e.message)}
3114
3287
  const MAX_RETRIES = 5;
3115
3288
  const { config: config2 } = configManager;
3116
3289
  const token = config2.token;
3117
- const { clientId, branch, host } = (0, import_schema_tools2.parseURL)(apiURL);
3118
- const bar2 = new import_progress2.default("Checking clientId and token. :prog", 1);
3290
+ const { clientId, branch, host } = parseURL2(apiURL);
3291
+ const bar2 = new Progress2("Checking clientId and token. :prog", 1);
3119
3292
  const getBranchInfo = async () => {
3120
3293
  const url = `https://${host}/db/${clientId}/status/${previewBaseBranch || branch}`;
3121
3294
  const branchInfo2 = {
@@ -3169,7 +3342,7 @@ ${dangerText(e.message)}
3169
3342
  bar2.tick({
3170
3343
  prog: "\u2705"
3171
3344
  });
3172
- const branchBar = new import_progress2.default(
3345
+ const branchBar = new Progress2(
3173
3346
  `Checking branch '${config2.branch}' is on TinaCloud. :prog`,
3174
3347
  1
3175
3348
  );
@@ -3209,7 +3382,7 @@ ${dangerText(e.message)}
3209
3382
  async syncProject(configManager, apiURL, options) {
3210
3383
  const { config: config2 } = configManager;
3211
3384
  const token = config2.token;
3212
- const { clientId, branch, host } = (0, import_schema_tools2.parseURL)(apiURL);
3385
+ const { clientId, branch, host } = parseURL2(apiURL);
3213
3386
  const { previewName, previewBaseBranch, upstreamBranch } = options || {};
3214
3387
  let url = `https://${host}/db/${clientId}/reset/${branch}?refreshSchema=true&skipIfSchemaCurrent=true`;
3215
3388
  if (upstreamBranch && previewBaseBranch && previewName) {
@@ -3219,7 +3392,7 @@ ${dangerText(e.message)}
3219
3392
  } else if (upstreamBranch && !previewBaseBranch && !previewName) {
3220
3393
  url = `https://${host}/db/${clientId}/reset/${branch}?refreshSchema=true&skipIfSchemaCurrent=true&upstreamBranch=${upstreamBranch}`;
3221
3394
  }
3222
- const bar2 = new import_progress2.default("Syncing Project. :prog", 1);
3395
+ const bar2 = new Progress2("Syncing Project. :prog", 1);
3223
3396
  try {
3224
3397
  const res = await request({
3225
3398
  token,
@@ -3260,7 +3433,7 @@ ${dangerText(e.message)}
3260
3433
  }
3261
3434
  }
3262
3435
  async checkGraphqlSchema(configManager, database, apiURL, timestamp) {
3263
- const bar2 = new import_progress2.default(
3436
+ const bar2 = new Progress2(
3264
3437
  "Checking local GraphQL Schema matches server. :prog",
3265
3438
  1
3266
3439
  );
@@ -3282,11 +3455,11 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3282
3455
  }
3283
3456
  throw new Error(errorMessage);
3284
3457
  }
3285
- const remoteGqlSchema = (0, import_graphql12.buildClientSchema)(remoteSchema);
3458
+ const remoteGqlSchema = buildClientSchema(remoteSchema);
3286
3459
  const localSchemaDocument = await database.getGraphQLSchemaFromBridge();
3287
- const localGraphqlSchema = (0, import_graphql12.buildASTSchema)(localSchemaDocument);
3460
+ const localGraphqlSchema = buildASTSchema2(localSchemaDocument);
3288
3461
  try {
3289
- const diffResult = await (0, import_core3.diff)(remoteGqlSchema, localGraphqlSchema);
3462
+ const diffResult = await diff(remoteGqlSchema, localGraphqlSchema);
3290
3463
  if (diffResult.length === 0) {
3291
3464
  bar2.tick({
3292
3465
  prog: "\u2705"
@@ -3334,13 +3507,13 @@ Additional info:
3334
3507
  }
3335
3508
  }
3336
3509
  async checkTinaSchema(configManager, database, apiURL, previewName, verbose, timestamp) {
3337
- const bar2 = new import_progress2.default(
3510
+ const bar2 = new Progress2(
3338
3511
  "Checking local Tina Schema matches server. :prog",
3339
3512
  1
3340
3513
  );
3341
3514
  const { config: config2 } = configManager;
3342
3515
  const token = config2.token;
3343
- const { clientId, branch, isLocalClient, host } = (0, import_schema_tools2.parseURL)(apiURL);
3516
+ const { clientId, branch, isLocalClient, host } = parseURL2(apiURL);
3344
3517
  if (isLocalClient || !host || !clientId || !branch) {
3345
3518
  if (verbose) {
3346
3519
  logger.info(logText("Not using TinaCloud, skipping Tina Schema check"));
@@ -3368,11 +3541,11 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3368
3541
  }
3369
3542
  const localTinaSchema = JSON.parse(
3370
3543
  await database.bridge.get(
3371
- import_path6.default.join(database.tinaDirectory, "__generated__", "_schema.json")
3544
+ path9.join(database.tinaDirectory, "__generated__", "_schema.json")
3372
3545
  )
3373
3546
  );
3374
3547
  localTinaSchema.version = void 0;
3375
- const localTinaSchemaSha = import_crypto.default.createHash("sha256").update(JSON.stringify(localTinaSchema)).digest("hex");
3548
+ const localTinaSchemaSha = crypto.createHash("sha256").update(JSON.stringify(localTinaSchema)).digest("hex");
3376
3549
  if (localTinaSchemaSha === remoteTinaSchemaSha) {
3377
3550
  bar2.tick({
3378
3551
  prog: "\u2705"
@@ -3423,12 +3596,12 @@ async function request(args) {
3423
3596
  Message from server: ${json.message}`;
3424
3597
  }
3425
3598
  throw new Error(
3426
- `Server responded with status code ${res.status}, ${res.statusText}. ${additionalInfo ? additionalInfo : ""} Please see our FAQ for more information: https://tina.io/docs/errors/faq/`
3599
+ `Server responded with status code ${res.status}, ${res.statusText}. ${additionalInfo ? additionalInfo : ""} Please see our FAQ for more information: https://tina.io/docs/r/FAQ/`
3427
3600
  );
3428
3601
  }
3429
3602
  if (json.errors) {
3430
3603
  throw new Error(
3431
- `Unable to fetch, please see our FAQ for more information: https://tina.io/docs/errors/faq/
3604
+ `Unable to fetch, please see our FAQ for more information: https://tina.io/docs/r/FAQ/
3432
3605
 
3433
3606
  Errors:
3434
3607
  ${json.errors.map((error) => error.message).join("\n")}`
@@ -3450,7 +3623,7 @@ var fetchRemoteGraphqlSchema = async ({
3450
3623
  headers.append("X-API-KEY", token);
3451
3624
  }
3452
3625
  const body = JSON.stringify({
3453
- query: (0, import_graphql12.getIntrospectionQuery)(),
3626
+ query: getIntrospectionQuery(),
3454
3627
  variables: {}
3455
3628
  });
3456
3629
  headers.append("Content-Type", "application/json");
@@ -3483,14 +3656,14 @@ var fetchSchemaSha = async ({
3483
3656
  };
3484
3657
 
3485
3658
  // src/next/commands/audit-command/index.ts
3486
- var import_clipanion4 = require("clipanion");
3487
- var import_graphql14 = require("@tinacms/graphql");
3659
+ import { Command as Command4, Option as Option4 } from "clipanion";
3660
+ import { buildSchema as buildSchema3 } from "@tinacms/graphql";
3488
3661
 
3489
3662
  // src/next/commands/audit-command/audit.ts
3490
- var import_prompts = __toESM(require("prompts"));
3491
- var import_metrics = require("@tinacms/metrics");
3492
- var import_graphql13 = require("@tinacms/graphql");
3493
- var import_chalk5 = __toESM(require("chalk"));
3663
+ import prompts from "prompts";
3664
+ import { Telemetry } from "@tinacms/metrics";
3665
+ import { resolve } from "@tinacms/graphql";
3666
+ import chalk5 from "chalk";
3494
3667
  var audit = async ({
3495
3668
  database,
3496
3669
  clean,
@@ -3498,7 +3671,7 @@ var audit = async ({
3498
3671
  noTelemetry,
3499
3672
  verbose
3500
3673
  }) => {
3501
- const telemetry = new import_metrics.Telemetry({ disabled: noTelemetry });
3674
+ const telemetry = new Telemetry({ disabled: noTelemetry });
3502
3675
  await telemetry.submitRecord({
3503
3676
  event: {
3504
3677
  name: "tinacms:cli:audit:invoke",
@@ -3508,25 +3681,25 @@ var audit = async ({
3508
3681
  });
3509
3682
  if (clean) {
3510
3683
  logger.info(
3511
- `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(
3684
+ `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(
3512
3685
  "clean git tree"
3513
3686
  )} so unwanted changes can be undone.
3514
3687
 
3515
3688
  `
3516
3689
  );
3517
- const res = await (0, import_prompts.default)({
3690
+ const res = await prompts({
3518
3691
  name: "useClean",
3519
3692
  type: "confirm",
3520
3693
  message: `Do you want to continue?`
3521
3694
  });
3522
3695
  if (!res.useClean) {
3523
- logger.warn(import_chalk5.default.yellowBright("\u26A0\uFE0F Audit not complete"));
3696
+ logger.warn(chalk5.yellowBright("\u26A0\uFE0F Audit not complete"));
3524
3697
  process.exit(0);
3525
3698
  }
3526
3699
  }
3527
3700
  if (useDefaultValues && !clean) {
3528
3701
  logger.warn(
3529
- import_chalk5.default.yellowBright(
3702
+ chalk5.yellowBright(
3530
3703
  "WARNING: using the `--useDefaultValues` without the `--clean` flag has no effect. Please re-run audit and add the `--clean` flag"
3531
3704
  )
3532
3705
  );
@@ -3554,10 +3727,10 @@ var audit = async ({
3554
3727
  }
3555
3728
  if (error) {
3556
3729
  logger.error(
3557
- import_chalk5.default.redBright(`\u203C\uFE0F Audit ${import_chalk5.default.bold("failed")} with errors`)
3730
+ chalk5.redBright(`\u203C\uFE0F Audit ${chalk5.bold("failed")} with errors`)
3558
3731
  );
3559
3732
  } else {
3560
- logger.info(import_chalk5.default.greenBright("\u2705 Audit passed"));
3733
+ logger.info(chalk5.greenBright("\u2705 Audit passed"));
3561
3734
  }
3562
3735
  };
3563
3736
  var auditDocuments = async (args) => {
@@ -3574,7 +3747,7 @@ var auditDocuments = async (args) => {
3574
3747
  }
3575
3748
  }
3576
3749
  }`;
3577
- const docResult = await (0, import_graphql13.resolve)({
3750
+ const docResult = await resolve({
3578
3751
  database,
3579
3752
  query: documentQuery,
3580
3753
  variables: {},
@@ -3585,11 +3758,11 @@ var auditDocuments = async (args) => {
3585
3758
  if (docResult.errors) {
3586
3759
  error = true;
3587
3760
  docResult.errors.forEach((err) => {
3588
- logger.error(import_chalk5.default.red(err.message));
3761
+ logger.error(chalk5.red(err.message));
3589
3762
  if (err.originalError.originalError) {
3590
3763
  logger.error(
3591
3764
  // @ts-ignore FIXME: this doesn't seem right
3592
- import_chalk5.default.red(` ${err.originalError.originalError.message}`)
3765
+ chalk5.red(` ${err.originalError.originalError.message}`)
3593
3766
  );
3594
3767
  }
3595
3768
  });
@@ -3616,7 +3789,7 @@ var auditDocuments = async (args) => {
3616
3789
  params: $params
3617
3790
  ){__typename}
3618
3791
  }`;
3619
- const mutationRes = await (0, import_graphql13.resolve)({
3792
+ const mutationRes = await resolve({
3620
3793
  database,
3621
3794
  query: mutation,
3622
3795
  variables: {
@@ -3631,7 +3804,7 @@ var auditDocuments = async (args) => {
3631
3804
  if (mutationRes.errors) {
3632
3805
  mutationRes.errors.forEach((err) => {
3633
3806
  error = true;
3634
- logger.error(import_chalk5.default.red(err.message));
3807
+ logger.error(chalk5.red(err.message));
3635
3808
  });
3636
3809
  }
3637
3810
  }
@@ -3648,38 +3821,31 @@ function filterObject(obj) {
3648
3821
  }
3649
3822
 
3650
3823
  // src/next/commands/audit-command/index.ts
3651
- var import_graphql15 = require("@tinacms/graphql");
3652
- var AuditCommand = class extends import_clipanion4.Command {
3653
- constructor() {
3654
- super(...arguments);
3655
- this.rootPath = import_clipanion4.Option.String("--rootPath", {
3656
- description: "Specify the root directory to run the CLI from"
3657
- });
3658
- this.verbose = import_clipanion4.Option.Boolean("-v,--verbose", false, {
3659
- description: "increase verbosity of logged output"
3660
- });
3661
- this.clean = import_clipanion4.Option.Boolean("--clean", false, {
3662
- description: "Clean the output"
3663
- });
3664
- this.useDefaultValues = import_clipanion4.Option.Boolean("--useDefaultValues", false, {
3665
- description: "When cleaning the output, use defaults on the config"
3666
- });
3667
- this.noTelemetry = import_clipanion4.Option.Boolean("--noTelemetry", false, {
3668
- description: "Disable anonymous telemetry that is collected"
3669
- });
3670
- this.datalayerPort = import_clipanion4.Option.String("--datalayer-port", "9000", {
3671
- description: "Specify a port to run the datalayer server on. (default 9000)"
3672
- });
3673
- }
3674
- static {
3675
- this.paths = [["audit"]];
3676
- }
3677
- static {
3678
- this.usage = import_clipanion4.Command.Usage({
3679
- category: `Commands`,
3680
- description: `Audit config and content files`
3681
- });
3682
- }
3824
+ import { AuditFileSystemBridge } from "@tinacms/graphql";
3825
+ var AuditCommand = class extends Command4 {
3826
+ static paths = [["audit"]];
3827
+ rootPath = Option4.String("--rootPath", {
3828
+ description: "Specify the root directory to run the CLI from"
3829
+ });
3830
+ verbose = Option4.Boolean("-v,--verbose", false, {
3831
+ description: "increase verbosity of logged output"
3832
+ });
3833
+ clean = Option4.Boolean("--clean", false, {
3834
+ description: "Clean the output"
3835
+ });
3836
+ useDefaultValues = Option4.Boolean("--useDefaultValues", false, {
3837
+ description: "When cleaning the output, use defaults on the config"
3838
+ });
3839
+ noTelemetry = Option4.Boolean("--noTelemetry", false, {
3840
+ description: "Disable anonymous telemetry that is collected"
3841
+ });
3842
+ datalayerPort = Option4.String("--datalayer-port", "9000", {
3843
+ description: "Specify a port to run the datalayer server on. (default 9000)"
3844
+ });
3845
+ static usage = Command4.Usage({
3846
+ category: `Commands`,
3847
+ description: `Audit config and content files`
3848
+ });
3683
3849
  async catch(error) {
3684
3850
  logger.error("Error occured during tinacms audit");
3685
3851
  if (this.verbose) {
@@ -3700,9 +3866,9 @@ var AuditCommand = class extends import_clipanion4.Command {
3700
3866
  const database = await createAndInitializeDatabase(
3701
3867
  configManager,
3702
3868
  Number(this.datalayerPort),
3703
- this.clean ? void 0 : new import_graphql15.AuditFileSystemBridge(configManager.rootPath)
3869
+ this.clean ? void 0 : new AuditFileSystemBridge(configManager.rootPath)
3704
3870
  );
3705
- const { tinaSchema, graphQLSchema, lookup } = await (0, import_graphql14.buildSchema)(
3871
+ const { tinaSchema, graphQLSchema, lookup } = await buildSchema3(
3706
3872
  configManager.config
3707
3873
  );
3708
3874
  const warnings = [];
@@ -3735,29 +3901,29 @@ var AuditCommand = class extends import_clipanion4.Command {
3735
3901
  };
3736
3902
 
3737
3903
  // src/next/commands/init-command/index.ts
3738
- var import_clipanion6 = require("clipanion");
3904
+ import { Command as Command6, Option as Option6 } from "clipanion";
3739
3905
 
3740
3906
  // src/cmds/init/detectEnvironment.ts
3741
- var import_fs_extra8 = __toESM(require("fs-extra"));
3742
- var import_path7 = __toESM(require("path"));
3907
+ import fs9 from "fs-extra";
3908
+ import path10 from "path";
3743
3909
  var checkGitignoreForItem = async ({
3744
3910
  baseDir,
3745
3911
  line
3746
3912
  }) => {
3747
- const gitignoreContent = import_fs_extra8.default.readFileSync(import_path7.default.join(baseDir, ".gitignore")).toString();
3913
+ const gitignoreContent = fs9.readFileSync(path10.join(baseDir, ".gitignore")).toString();
3748
3914
  return gitignoreContent.split("\n").some((item) => item === line);
3749
3915
  };
3750
3916
  var makeGeneratedFile = async (name2, generatedFileType, parentPath, opts) => {
3751
3917
  const result = {
3752
- fullPathTS: import_path7.default.join(
3918
+ fullPathTS: path10.join(
3753
3919
  parentPath,
3754
3920
  `${name2}.${opts?.typescriptSuffix || opts?.extensionOverride || "ts"}`
3755
3921
  ),
3756
- fullPathJS: import_path7.default.join(
3922
+ fullPathJS: path10.join(
3757
3923
  parentPath,
3758
3924
  `${name2}.${opts?.extensionOverride || "js"}`
3759
3925
  ),
3760
- fullPathOverride: opts?.extensionOverride ? import_path7.default.join(parentPath, `${name2}.${opts?.extensionOverride}`) : "",
3926
+ fullPathOverride: opts?.extensionOverride ? path10.join(parentPath, `${name2}.${opts?.extensionOverride}`) : "",
3761
3927
  generatedFileType,
3762
3928
  name: name2,
3763
3929
  parentPath,
@@ -3775,8 +3941,8 @@ var makeGeneratedFile = async (name2, generatedFileType, parentPath, opts) => {
3775
3941
  };
3776
3942
  }
3777
3943
  };
3778
- result.typescriptExists = await import_fs_extra8.default.pathExists(result.fullPathTS);
3779
- result.javascriptExists = await import_fs_extra8.default.pathExists(result.fullPathJS);
3944
+ result.typescriptExists = await fs9.pathExists(result.fullPathTS);
3945
+ result.javascriptExists = await fs9.pathExists(result.fullPathJS);
3780
3946
  return result;
3781
3947
  };
3782
3948
  var detectEnvironment = async ({
@@ -3785,21 +3951,21 @@ var detectEnvironment = async ({
3785
3951
  rootPath,
3786
3952
  debug = false
3787
3953
  }) => {
3788
- const hasForestryConfig = await import_fs_extra8.default.pathExists(
3789
- import_path7.default.join(pathToForestryConfig, ".forestry", "settings.yml")
3954
+ const hasForestryConfig = await fs9.pathExists(
3955
+ path10.join(pathToForestryConfig, ".forestry", "settings.yml")
3790
3956
  );
3791
- const sampleContentPath = import_path7.default.join(
3957
+ const sampleContentPath = path10.join(
3792
3958
  baseDir,
3793
3959
  "content",
3794
3960
  "posts",
3795
3961
  "hello-world.md"
3796
3962
  );
3797
- 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")));
3798
- const tinaFolder = import_path7.default.join(baseDir, "tina");
3963
+ const usingSrc = fs9.pathExistsSync(path10.join(baseDir, "src")) && (fs9.pathExistsSync(path10.join(baseDir, "src", "app")) || fs9.pathExistsSync(path10.join(baseDir, "src", "pages")));
3964
+ const tinaFolder = path10.join(baseDir, "tina");
3799
3965
  const tinaConfigExists = Boolean(
3800
3966
  // Does the tina folder exist?
3801
- await import_fs_extra8.default.pathExists(tinaFolder) && // Does the tina folder contain a config file?
3802
- (await import_fs_extra8.default.readdir(tinaFolder)).find((x) => x.includes("config"))
3967
+ await fs9.pathExists(tinaFolder) && // Does the tina folder contain a config file?
3968
+ (await fs9.readdir(tinaFolder)).find((x) => x.includes("config"))
3803
3969
  );
3804
3970
  const pagesDir = [baseDir, usingSrc ? "src" : false, "pages"].filter(
3805
3971
  Boolean
@@ -3811,12 +3977,12 @@ var detectEnvironment = async ({
3811
3977
  "next-api-handler": await makeGeneratedFile(
3812
3978
  "[...routes]",
3813
3979
  "next-api-handler",
3814
- import_path7.default.join(...pagesDir, "api", "tina")
3980
+ path10.join(...pagesDir, "api", "tina")
3815
3981
  ),
3816
3982
  "reactive-example": await makeGeneratedFile(
3817
3983
  "[filename]",
3818
3984
  "reactive-example",
3819
- import_path7.default.join(...pagesDir, "demo", "blog"),
3985
+ path10.join(...pagesDir, "demo", "blog"),
3820
3986
  {
3821
3987
  typescriptSuffix: "tsx"
3822
3988
  }
@@ -3824,22 +3990,22 @@ var detectEnvironment = async ({
3824
3990
  "users-json": await makeGeneratedFile(
3825
3991
  "index",
3826
3992
  "users-json",
3827
- import_path7.default.join(baseDir, "content", "users"),
3993
+ path10.join(baseDir, "content", "users"),
3828
3994
  { extensionOverride: "json" }
3829
3995
  ),
3830
3996
  "sample-content": await makeGeneratedFile(
3831
3997
  "hello-world",
3832
3998
  "sample-content",
3833
- import_path7.default.join(baseDir, "content", "posts"),
3999
+ path10.join(baseDir, "content", "posts"),
3834
4000
  { extensionOverride: "md" }
3835
4001
  )
3836
4002
  };
3837
- const hasSampleContent = await import_fs_extra8.default.pathExists(sampleContentPath);
3838
- const hasPackageJSON = await import_fs_extra8.default.pathExists("package.json");
4003
+ const hasSampleContent = await fs9.pathExists(sampleContentPath);
4004
+ const hasPackageJSON = await fs9.pathExists("package.json");
3839
4005
  let hasTinaDeps = false;
3840
4006
  if (hasPackageJSON) {
3841
4007
  try {
3842
- const packageJSON = await import_fs_extra8.default.readJSON("package.json");
4008
+ const packageJSON = await fs9.readJSON("package.json");
3843
4009
  const deps = [];
3844
4010
  if (packageJSON?.dependencies) {
3845
4011
  deps.push(...Object.keys(packageJSON.dependencies));
@@ -3856,15 +4022,15 @@ var detectEnvironment = async ({
3856
4022
  );
3857
4023
  }
3858
4024
  }
3859
- const hasGitIgnore = await import_fs_extra8.default.pathExists(import_path7.default.join(".gitignore"));
4025
+ const hasGitIgnore = await fs9.pathExists(path10.join(".gitignore"));
3860
4026
  const hasGitIgnoreNodeModules = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: "node_modules" });
3861
4027
  const hasEnvTina = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: ".env.tina" });
3862
4028
  const hasGitIgnoreEnv = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: ".env" });
3863
4029
  let frontMatterFormat;
3864
4030
  if (hasForestryConfig) {
3865
- const hugoConfigPath = import_path7.default.join(rootPath, "config.toml");
3866
- if (await import_fs_extra8.default.pathExists(hugoConfigPath)) {
3867
- const hugoConfig = await import_fs_extra8.default.readFile(hugoConfigPath, "utf8");
4031
+ const hugoConfigPath = path10.join(rootPath, "config.toml");
4032
+ if (await fs9.pathExists(hugoConfigPath)) {
4033
+ const hugoConfig = await fs9.readFile(hugoConfigPath, "utf8");
3868
4034
  const metaDataFormat = hugoConfig.toString().match(/metaDataFormat = "(.*)"/)?.[1];
3869
4035
  if (metaDataFormat && (metaDataFormat === "yaml" || metaDataFormat === "toml" || metaDataFormat === "json")) {
3870
4036
  frontMatterFormat = metaDataFormat;
@@ -3895,10 +4061,10 @@ var detectEnvironment = async ({
3895
4061
  var detectEnvironment_default = detectEnvironment;
3896
4062
 
3897
4063
  // src/cmds/init/prompts/index.ts
3898
- var import_prompts6 = __toESM(require("prompts"));
4064
+ import prompts6 from "prompts";
3899
4065
 
3900
4066
  // src/cmds/init/prompts/askTinaCloudSetup.ts
3901
- var import_prompts2 = __toESM(require("prompts"));
4067
+ import prompts2 from "prompts";
3902
4068
  var tinaCloudSetupQuestions = [
3903
4069
  {
3904
4070
  name: "clientId",
@@ -3920,7 +4086,7 @@ ${logText(
3920
4086
  }
3921
4087
  ];
3922
4088
  var askTinaCloudSetup = async ({ config: config2 }) => {
3923
- const { clientId, token } = await (0, import_prompts2.default)(tinaCloudSetupQuestions);
4089
+ const { clientId, token } = await prompts2(tinaCloudSetupQuestions);
3924
4090
  config2.envVars.push(
3925
4091
  {
3926
4092
  key: "NEXT_PUBLIC_TINA_CLIENT_ID",
@@ -3934,7 +4100,7 @@ var askTinaCloudSetup = async ({ config: config2 }) => {
3934
4100
  };
3935
4101
 
3936
4102
  // src/cmds/init/prompts/gitProvider.ts
3937
- var import_prompts3 = __toESM(require("prompts"));
4103
+ import prompts3 from "prompts";
3938
4104
  var supportedGitProviders = {
3939
4105
  github: {
3940
4106
  imports: [
@@ -3956,7 +4122,7 @@ var supportedGitProviders = {
3956
4122
  }
3957
4123
  };
3958
4124
  var chooseGitProvider = async ({ config: config2 }) => {
3959
- const result = await (0, import_prompts3.default)([
4125
+ const result = await prompts3([
3960
4126
  {
3961
4127
  name: "githubToken",
3962
4128
  type: "text",
@@ -3964,7 +4130,7 @@ var chooseGitProvider = async ({ config: config2 }) => {
3964
4130
  ${logText(
3965
4131
  "Learn more here: "
3966
4132
  )}${linkText(
3967
- "https://tina.io/docs/self-hosted/existing-site/#github-personal-access-token"
4133
+ "https://tina.io/docs/r/self-hosting-nextjs/#github-personal-access-token"
3968
4134
  )}`,
3969
4135
  initial: process.env.GITHUB_PERSONAL_ACCESS_TOKEN
3970
4136
  },
@@ -4001,7 +4167,7 @@ ${logText(
4001
4167
  };
4002
4168
 
4003
4169
  // src/cmds/init/prompts/databaseAdapter.ts
4004
- var import_prompts4 = __toESM(require("prompts"));
4170
+ import prompts4 from "prompts";
4005
4171
  var supportedDatabaseAdapters = {
4006
4172
  ["upstash-redis"]: {
4007
4173
  databaseAdapterClassText: `new RedisLevel({
@@ -4047,7 +4213,7 @@ var databaseAdapterUpdateConfig = {
4047
4213
  other: async (_args) => {
4048
4214
  },
4049
4215
  mongodb: async ({ config: config2 }) => {
4050
- const result = await (0, import_prompts4.default)([
4216
+ const result = await prompts4([
4051
4217
  {
4052
4218
  name: "mongoDBUri",
4053
4219
  type: "text",
@@ -4062,7 +4228,7 @@ var databaseAdapterUpdateConfig = {
4062
4228
  });
4063
4229
  },
4064
4230
  "upstash-redis": async ({ config: config2 }) => {
4065
- const result = await (0, import_prompts4.default)([
4231
+ const result = await prompts4([
4066
4232
  {
4067
4233
  name: "kvRestApiUrl",
4068
4234
  type: "text",
@@ -4093,7 +4259,7 @@ var chooseDatabaseAdapter = async ({
4093
4259
  framework,
4094
4260
  config: config2
4095
4261
  }) => {
4096
- const answers = await (0, import_prompts4.default)([
4262
+ const answers = await prompts4([
4097
4263
  {
4098
4264
  name: "dataLayerAdapter",
4099
4265
  message: "Select a self-hosted Database Adapter",
@@ -4123,8 +4289,8 @@ var chooseDatabaseAdapter = async ({
4123
4289
  };
4124
4290
 
4125
4291
  // src/cmds/init/prompts/authProvider.ts
4126
- var import_crypto_js = __toESM(require("crypto-js"));
4127
- var import_prompts5 = __toESM(require("prompts"));
4292
+ import crypto2 from "crypto-js";
4293
+ import prompts5 from "prompts";
4128
4294
  var supportedAuthProviders = {
4129
4295
  other: {
4130
4296
  name: "other"
@@ -4173,12 +4339,12 @@ var authProviderUpdateConfig = {
4173
4339
  },
4174
4340
  "tina-cloud": askTinaCloudSetup,
4175
4341
  "next-auth": async ({ config: config2 }) => {
4176
- const result = await (0, import_prompts5.default)([
4342
+ const result = await prompts5([
4177
4343
  {
4178
4344
  name: "nextAuthSecret",
4179
4345
  type: "text",
4180
4346
  message: `What is the NextAuth.js Secret? (Hit enter to use a randomly generated secret)`,
4181
- initial: process.env.NEXTAUTH_SECRET || import_crypto_js.default.lib.WordArray.random(16).toString()
4347
+ initial: process.env.NEXTAUTH_SECRET || crypto2.lib.WordArray.random(16).toString()
4182
4348
  }
4183
4349
  ]);
4184
4350
  config2.envVars.push({
@@ -4203,7 +4369,7 @@ var forestryDisclaimer = logText(
4203
4369
  `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)`
4204
4370
  );
4205
4371
  var askCommonSetUp = async () => {
4206
- const answers = await (0, import_prompts6.default)([
4372
+ const answers = await prompts6([
4207
4373
  {
4208
4374
  name: "framework",
4209
4375
  type: "select",
@@ -4225,7 +4391,8 @@ var askCommonSetUp = async () => {
4225
4391
  choices: [
4226
4392
  { title: "PNPM", value: "pnpm" },
4227
4393
  { title: "Yarn", value: "yarn" },
4228
- { title: "NPM", value: "npm" }
4394
+ { title: "NPM", value: "npm" },
4395
+ { title: "Bun", value: "bun" }
4229
4396
  ]
4230
4397
  }
4231
4398
  ]);
@@ -4266,7 +4433,7 @@ ${forestryDisclaimer}`
4266
4433
  message: `What format are you using in your frontmatter?`
4267
4434
  });
4268
4435
  }
4269
- const answers = await (0, import_prompts6.default)(questions);
4436
+ const answers = await prompts6(questions);
4270
4437
  return answers;
4271
4438
  };
4272
4439
  var askTinaSetupPrompts = async (params) => {
@@ -4286,16 +4453,16 @@ var askTinaSetupPrompts = async (params) => {
4286
4453
  message: `Where are public assets stored? (default: "public")
4287
4454
  ` + logText(
4288
4455
  `Not sure what value to use? Refer to our "Frameworks" doc: ${linkText(
4289
- "https://tina.io/docs/integration/frameworks/#configuring-tina-with-each-framework"
4456
+ "https://tina.io/docs/r/framework-guides-overview"
4290
4457
  )}`
4291
4458
  )
4292
4459
  });
4293
4460
  }
4294
- const answers = await (0, import_prompts6.default)(questions);
4461
+ const answers = await prompts6(questions);
4295
4462
  return answers;
4296
4463
  };
4297
4464
  var askIfUsingSelfHosted = async () => {
4298
- const answers = await (0, import_prompts6.default)([
4465
+ const answers = await prompts6([
4299
4466
  {
4300
4467
  name: "hosting",
4301
4468
  type: "select",
@@ -4328,20 +4495,20 @@ var makeImportString = (imports) => {
4328
4495
  };
4329
4496
 
4330
4497
  // src/cmds/init/prompts/generatedFiles.ts
4331
- var import_prompts7 = __toESM(require("prompts"));
4498
+ import prompts7 from "prompts";
4332
4499
  var askIfOverride = async ({
4333
4500
  generatedFile,
4334
4501
  usingTypescript
4335
4502
  }) => {
4336
4503
  if (usingTypescript) {
4337
- const result = await (0, import_prompts7.default)({
4504
+ const result = await prompts7({
4338
4505
  name: `override`,
4339
4506
  type: "confirm",
4340
4507
  message: `Found existing file at ${generatedFile.fullPathTS}. Would you like to overwrite?`
4341
4508
  });
4342
4509
  return Boolean(result.override);
4343
4510
  } else {
4344
- const result = await (0, import_prompts7.default)({
4511
+ const result = await prompts7({
4345
4512
  name: `override`,
4346
4513
  type: "confirm",
4347
4514
  message: `Found existing file at ${generatedFile.fullPathJS}. Would you like to overwrite?`
@@ -4476,24 +4643,25 @@ var CLICommand = class {
4476
4643
  };
4477
4644
 
4478
4645
  // src/cmds/init/apply.ts
4479
- var import_path11 = __toESM(require("path"));
4646
+ import path14 from "path";
4480
4647
 
4481
4648
  // src/cmds/forestry-migrate/index.ts
4482
- var import_fs_extra10 = __toESM(require("fs-extra"));
4483
- var import_path9 = __toESM(require("path"));
4484
- var import_js_yaml2 = __toESM(require("js-yaml"));
4485
- var import_minimatch = __toESM(require("minimatch"));
4486
- var import_graphql16 = require("@tinacms/graphql");
4487
- var import_schema_tools3 = require("@tinacms/schema-tools");
4649
+ import fs11 from "fs-extra";
4650
+ import path12 from "path";
4651
+ import yaml2 from "js-yaml";
4652
+ import pkg from "minimatch";
4653
+ import { parseFile, stringifyFile } from "@tinacms/graphql";
4654
+ import { CONTENT_FORMATS } from "@tinacms/schema-tools";
4488
4655
 
4489
4656
  // src/cmds/forestry-migrate/util/index.ts
4490
- var import_fs_extra9 = __toESM(require("fs-extra"));
4491
- var import_path8 = __toESM(require("path"));
4492
- var import_js_yaml = __toESM(require("js-yaml"));
4493
- var import_zod = __toESM(require("zod"));
4657
+ import fs10 from "fs-extra";
4658
+ import path11 from "path";
4659
+ import yaml from "js-yaml";
4660
+ import z from "zod";
4494
4661
 
4495
4662
  // src/cmds/forestry-migrate/util/errorSingleton.ts
4496
4663
  var ErrorSingleton = class _ErrorSingleton {
4664
+ static instance;
4497
4665
  /**
4498
4666
  * The Singleton's constructor should always be private to prevent direct
4499
4667
  * construction calls with the `new` operator.
@@ -4513,6 +4681,7 @@ var ErrorSingleton = class _ErrorSingleton {
4513
4681
  }
4514
4682
  return _ErrorSingleton.instance;
4515
4683
  }
4684
+ collectionNameErrors;
4516
4685
  addErrorName(error) {
4517
4686
  this.collectionNameErrors.push(error);
4518
4687
  }
@@ -4535,8 +4704,8 @@ var ErrorSingleton = class _ErrorSingleton {
4535
4704
  };
4536
4705
 
4537
4706
  // src/cmds/forestry-migrate/util/codeTransformer.ts
4538
- var import_prettier = require("prettier");
4539
- var import_parser_typescript = __toESM(require("prettier/parser-typescript"));
4707
+ import { format } from "prettier";
4708
+ import TsParser from "prettier/parser-typescript.js";
4540
4709
  var addVariablesToCode = (codeWithTinaPrefix) => {
4541
4710
  const code = codeWithTinaPrefix.replace(
4542
4711
  /"__TINA_INTERNAL__:::(.*?):::"/g,
@@ -4573,7 +4742,7 @@ var makeTemplateFile = async ({
4573
4742
  `export function ${stringifyLabelWithField(
4574
4743
  template.templateObj.label
4575
4744
  )} (){
4576
- return ${addVariablesToCode(JSON.stringify(template.fields, null, 2)).code} ${usingTypescript ? "as TinaField[]" : ""}
4745
+ return ${addVariablesToCode(JSON.stringify(template.fields, null, 2)).code} ${usingTypescript ? "as TinaField[]" : ""}
4577
4746
  } `
4578
4747
  );
4579
4748
  }
@@ -4581,9 +4750,9 @@ var makeTemplateFile = async ({
4581
4750
  ${usingTypescript ? "import type { TinaField } from 'tinacms'" : ""}
4582
4751
  ${templateCodeText.join("\n")}
4583
4752
  `;
4584
- const formattedCode = (0, import_prettier.format)(templateCode, {
4753
+ const formattedCode = format(templateCode, {
4585
4754
  parser: "typescript",
4586
- plugins: [import_parser_typescript.default]
4755
+ plugins: [TsParser]
4587
4756
  });
4588
4757
  return { importStatements, templateCodeText: formattedCode };
4589
4758
  };
@@ -4615,82 +4784,82 @@ var stringifyTemplateName = (name2, template) => {
4615
4784
  return newName;
4616
4785
  }
4617
4786
  };
4618
- var forestryConfigSchema = import_zod.default.object({
4619
- sections: import_zod.default.array(
4620
- import_zod.default.object({
4621
- type: import_zod.default.union([
4622
- import_zod.default.literal("directory"),
4623
- import_zod.default.literal("document"),
4624
- import_zod.default.literal("heading"),
4625
- import_zod.default.literal("jekyll-pages"),
4626
- import_zod.default.literal("jekyll-posts")
4787
+ var forestryConfigSchema = z.object({
4788
+ sections: z.array(
4789
+ z.object({
4790
+ type: z.union([
4791
+ z.literal("directory"),
4792
+ z.literal("document"),
4793
+ z.literal("heading"),
4794
+ z.literal("jekyll-pages"),
4795
+ z.literal("jekyll-posts")
4627
4796
  ]),
4628
- label: import_zod.default.string(),
4629
- path: import_zod.default.string().optional().nullable(),
4630
- match: import_zod.default.string().optional().nullable(),
4631
- exclude: import_zod.default.string().optional().nullable(),
4632
- create: import_zod.default.union([import_zod.default.literal("all"), import_zod.default.literal("documents"), import_zod.default.literal("none")]).optional(),
4633
- templates: import_zod.default.array(import_zod.default.string()).optional().nullable(),
4634
- new_doc_ext: import_zod.default.string().optional().nullable(),
4635
- read_only: import_zod.default.boolean().optional().nullable()
4797
+ label: z.string(),
4798
+ path: z.string().optional().nullable(),
4799
+ match: z.string().optional().nullable(),
4800
+ exclude: z.string().optional().nullable(),
4801
+ create: z.union([z.literal("all"), z.literal("documents"), z.literal("none")]).optional(),
4802
+ templates: z.array(z.string()).optional().nullable(),
4803
+ new_doc_ext: z.string().optional().nullable(),
4804
+ read_only: z.boolean().optional().nullable()
4636
4805
  })
4637
4806
  )
4638
4807
  });
4639
- var forestryFieldWithoutField = import_zod.default.object({
4808
+ var forestryFieldWithoutField = z.object({
4640
4809
  // TODO: maybe better type this?
4641
- type: import_zod.default.union([
4642
- import_zod.default.literal("text"),
4643
- import_zod.default.literal("datetime"),
4644
- import_zod.default.literal("list"),
4645
- import_zod.default.literal("file"),
4646
- import_zod.default.literal("image_gallery"),
4647
- import_zod.default.literal("textarea"),
4648
- import_zod.default.literal("tag_list"),
4649
- import_zod.default.literal("number"),
4650
- import_zod.default.literal("boolean"),
4651
- import_zod.default.literal("field_group"),
4652
- import_zod.default.literal("field_group_list"),
4653
- import_zod.default.literal("select"),
4654
- import_zod.default.literal("include"),
4655
- import_zod.default.literal("blocks"),
4656
- import_zod.default.literal("color")
4810
+ type: z.union([
4811
+ z.literal("text"),
4812
+ z.literal("datetime"),
4813
+ z.literal("list"),
4814
+ z.literal("file"),
4815
+ z.literal("image_gallery"),
4816
+ z.literal("textarea"),
4817
+ z.literal("tag_list"),
4818
+ z.literal("number"),
4819
+ z.literal("boolean"),
4820
+ z.literal("field_group"),
4821
+ z.literal("field_group_list"),
4822
+ z.literal("select"),
4823
+ z.literal("include"),
4824
+ z.literal("blocks"),
4825
+ z.literal("color")
4657
4826
  ]),
4658
- template_types: import_zod.default.array(import_zod.default.string()).optional().nullable(),
4659
- name: import_zod.default.string(),
4660
- label: import_zod.default.string(),
4661
- default: import_zod.default.any().optional(),
4662
- template: import_zod.default.string().optional(),
4663
- config: import_zod.default.object({
4827
+ template_types: z.array(z.string()).optional().nullable(),
4828
+ name: z.string(),
4829
+ label: z.string(),
4830
+ default: z.any().optional(),
4831
+ template: z.string().optional(),
4832
+ config: z.object({
4664
4833
  // min and max are used for lists
4665
- min: import_zod.default.number().optional().nullable(),
4666
- max: import_zod.default.number().optional().nullable(),
4667
- required: import_zod.default.boolean().optional().nullable(),
4668
- use_select: import_zod.default.boolean().optional().nullable(),
4669
- date_format: import_zod.default.string().optional().nullable(),
4670
- time_format: import_zod.default.string().optional().nullable(),
4671
- options: import_zod.default.array(import_zod.default.string()).optional().nullable(),
4672
- source: import_zod.default.object({
4673
- type: import_zod.default.union([
4674
- import_zod.default.literal("custom"),
4675
- import_zod.default.literal("pages"),
4676
- import_zod.default.literal("documents"),
4677
- import_zod.default.literal("simple"),
4834
+ min: z.number().optional().nullable(),
4835
+ max: z.number().optional().nullable(),
4836
+ required: z.boolean().optional().nullable(),
4837
+ use_select: z.boolean().optional().nullable(),
4838
+ date_format: z.string().optional().nullable(),
4839
+ time_format: z.string().optional().nullable(),
4840
+ options: z.array(z.string()).optional().nullable(),
4841
+ source: z.object({
4842
+ type: z.union([
4843
+ z.literal("custom"),
4844
+ z.literal("pages"),
4845
+ z.literal("documents"),
4846
+ z.literal("simple"),
4678
4847
  // TODO: I want to ignore this key if its invalid
4679
- import_zod.default.string()
4848
+ z.string()
4680
4849
  ]).optional().nullable(),
4681
- section: import_zod.default.string().optional().nullable()
4850
+ section: z.string().optional().nullable()
4682
4851
  }).optional()
4683
4852
  }).optional()
4684
4853
  });
4685
- var forestryField = import_zod.default.lazy(
4854
+ var forestryField = z.lazy(
4686
4855
  () => forestryFieldWithoutField.extend({
4687
- fields: import_zod.default.array(forestryField).optional()
4856
+ fields: z.array(forestryField).optional()
4688
4857
  })
4689
4858
  );
4690
- var FrontmatterTemplateSchema = import_zod.default.object({
4691
- label: import_zod.default.string(),
4692
- hide_body: import_zod.default.boolean().optional(),
4693
- fields: import_zod.default.array(forestryField).optional()
4859
+ var FrontmatterTemplateSchema = z.object({
4860
+ label: z.string(),
4861
+ hide_body: z.boolean().optional(),
4862
+ fields: z.array(forestryField).optional()
4694
4863
  });
4695
4864
  var transformForestryFieldsToTinaFields = ({
4696
4865
  fields,
@@ -4913,7 +5082,7 @@ var transformForestryFieldsToTinaFields = ({
4913
5082
  return tinaFields;
4914
5083
  };
4915
5084
  var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false }) => {
4916
- const templatePath = import_path8.default.join(
5085
+ const templatePath = path11.join(
4917
5086
  pathToForestryConfig,
4918
5087
  ".forestry",
4919
5088
  "front_matter",
@@ -4922,7 +5091,7 @@ var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false })
4922
5091
  );
4923
5092
  let templateString = "";
4924
5093
  try {
4925
- templateString = import_fs_extra9.default.readFileSync(templatePath).toString();
5094
+ templateString = fs10.readFileSync(templatePath).toString();
4926
5095
  } catch {
4927
5096
  throw new Error(
4928
5097
  `Could not find template ${tem} at ${templatePath}
@@ -4930,7 +5099,7 @@ var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false })
4930
5099
  This will require manual migration.`
4931
5100
  );
4932
5101
  }
4933
- const templateObj = import_js_yaml.default.load(templateString);
5102
+ const templateObj = yaml.load(templateString);
4934
5103
  const template = parseTemplates({ val: templateObj });
4935
5104
  const fields = transformForestryFieldsToTinaFields({
4936
5105
  fields: template.fields,
@@ -4950,6 +5119,7 @@ var parseSections = ({ val }) => {
4950
5119
  };
4951
5120
 
4952
5121
  // src/cmds/forestry-migrate/index.ts
5122
+ var { minimatch } = pkg;
4953
5123
  var BODY_FIELD = {
4954
5124
  // This is the body field
4955
5125
  type: "rich-text",
@@ -4978,7 +5148,7 @@ var transformForestryMatchToTinaMatch = (match) => {
4978
5148
  };
4979
5149
  function checkExt(ext) {
4980
5150
  const extReal = ext.replace(".", "");
4981
- if (import_schema_tools3.CONTENT_FORMATS.includes(extReal)) {
5151
+ if (CONTENT_FORMATS.includes(extReal)) {
4982
5152
  return extReal;
4983
5153
  } else {
4984
5154
  return false;
@@ -4987,9 +5157,9 @@ function checkExt(ext) {
4987
5157
  var generateAllTemplates = async ({
4988
5158
  pathToForestryConfig
4989
5159
  }) => {
4990
- const allTemplates = (await import_fs_extra10.default.readdir(
4991
- import_path9.default.join(pathToForestryConfig, ".forestry", "front_matter", "templates")
4992
- )).map((tem) => import_path9.default.basename(tem, ".yml"));
5160
+ const allTemplates = (await fs11.readdir(
5161
+ path12.join(pathToForestryConfig, ".forestry", "front_matter", "templates")
5162
+ )).map((tem) => path12.basename(tem, ".yml"));
4993
5163
  const templateMap = /* @__PURE__ */ new Map();
4994
5164
  const proms = allTemplates.map(async (tem) => {
4995
5165
  try {
@@ -4999,7 +5169,7 @@ var generateAllTemplates = async ({
4999
5169
  });
5000
5170
  templateMap.set(tem, { fields, templateObj });
5001
5171
  } catch (e) {
5002
- logger.log(`Error parsing template frontmatter template', tem + '.yml'`);
5172
+ logger.warn(`Error parsing template frontmatter template, ${tem}.yml`);
5003
5173
  console.error(e);
5004
5174
  templateMap.set(tem, { fields: [], templateObj: {} });
5005
5175
  }
@@ -5043,7 +5213,7 @@ var generateCollectionFromForestrySection = (args) => {
5043
5213
  }
5044
5214
  if (section.type === "directory") {
5045
5215
  if (!section?.path || section.path === "/" || section.path === "./" || section.path === ".") {
5046
- logger.log(
5216
+ logger.warn(
5047
5217
  warnText(
5048
5218
  `Warning: Section ${section.label} is using a Root Path. Currently, Tina Does not support Root paths see ${linkText(
5049
5219
  "https://github.com/tinacms/tinacms/issues/3768"
@@ -5064,7 +5234,7 @@ var generateCollectionFromForestrySection = (args) => {
5064
5234
  glob = section.path + "/" + section.match;
5065
5235
  }
5066
5236
  if (pages.some((page) => {
5067
- return (0, import_minimatch.default)(page, glob);
5237
+ return minimatch(page, glob);
5068
5238
  })) {
5069
5239
  forestryTemplates.push(templateKey);
5070
5240
  }
@@ -5134,9 +5304,9 @@ var generateCollectionFromForestrySection = (args) => {
5134
5304
  return c;
5135
5305
  } else if (section.type === "document") {
5136
5306
  const filePath = section.path;
5137
- const extname = import_path9.default.extname(filePath);
5138
- const fileName = import_path9.default.basename(filePath, extname);
5139
- const dir = import_path9.default.dirname(filePath);
5307
+ const extname = path12.extname(filePath);
5308
+ const fileName = path12.basename(filePath, extname);
5309
+ const dir = path12.dirname(filePath);
5140
5310
  const ext = checkExt(extname);
5141
5311
  if (ext) {
5142
5312
  const fields = [];
@@ -5156,7 +5326,7 @@ var generateCollectionFromForestrySection = (args) => {
5156
5326
  name: "dummy",
5157
5327
  label: "Dummy field",
5158
5328
  type: "string",
5159
- 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"
5329
+ 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"
5160
5330
  });
5161
5331
  logger.warn(
5162
5332
  warnText(
@@ -5180,7 +5350,7 @@ var generateCollectionFromForestrySection = (args) => {
5180
5350
  fields
5181
5351
  };
5182
5352
  } else {
5183
- logger.log(
5353
+ logger.warn(
5184
5354
  warnText(
5185
5355
  `Error: document section has an unsupported file extension: ${extname} in ${section.path}`
5186
5356
  )
@@ -5198,8 +5368,8 @@ var generateCollections = async ({
5198
5368
  templateMap,
5199
5369
  usingTypescript
5200
5370
  });
5201
- const forestryConfig = await import_fs_extra10.default.readFile(
5202
- import_path9.default.join(pathToForestryConfig, ".forestry", "settings.yml")
5371
+ const forestryConfig = await fs11.readFile(
5372
+ path12.join(pathToForestryConfig, ".forestry", "settings.yml")
5203
5373
  );
5204
5374
  rewriteTemplateKeysInDocs({
5205
5375
  templateMap,
@@ -5209,7 +5379,7 @@ var generateCollections = async ({
5209
5379
  }
5210
5380
  });
5211
5381
  const collections = parseSections({
5212
- val: import_js_yaml2.default.load(forestryConfig.toString())
5382
+ val: yaml2.load(forestryConfig.toString())
5213
5383
  }).sections.map(
5214
5384
  (section) => generateCollectionFromForestrySection({
5215
5385
  section,
@@ -5229,13 +5399,13 @@ var rewriteTemplateKeysInDocs = (args) => {
5229
5399
  const { templateObj } = templateMap.get(templateKey);
5230
5400
  templateObj?.pages?.forEach((page) => {
5231
5401
  try {
5232
- const filePath = import_path9.default.join(page);
5233
- if (import_fs_extra10.default.lstatSync(filePath).isDirectory()) {
5402
+ const filePath = path12.join(page);
5403
+ if (fs11.lstatSync(filePath).isDirectory()) {
5234
5404
  return;
5235
5405
  }
5236
- const extname = import_path9.default.extname(filePath);
5237
- const fileContent = import_fs_extra10.default.readFileSync(filePath).toString();
5238
- const content = (0, import_graphql16.parseFile)(
5406
+ const extname = path12.extname(filePath);
5407
+ const fileContent = fs11.readFileSync(filePath).toString();
5408
+ const content = parseFile(
5239
5409
  fileContent,
5240
5410
  extname,
5241
5411
  (yup) => yup.object({}),
@@ -5245,9 +5415,9 @@ var rewriteTemplateKeysInDocs = (args) => {
5245
5415
  _template: stringifyLabel(templateKey),
5246
5416
  ...content
5247
5417
  };
5248
- import_fs_extra10.default.writeFileSync(
5418
+ fs11.writeFileSync(
5249
5419
  filePath,
5250
- (0, import_graphql16.stringifyFile)(newContent, extname, true, markdownParseConfig)
5420
+ stringifyFile(newContent, extname, true, markdownParseConfig)
5251
5421
  );
5252
5422
  } catch (error) {
5253
5423
  console.log(
@@ -5259,32 +5429,25 @@ var rewriteTemplateKeysInDocs = (args) => {
5259
5429
  };
5260
5430
 
5261
5431
  // src/cmds/init/apply.ts
5262
- var import_metrics2 = require("@tinacms/metrics");
5263
- var import_fs_extra13 = __toESM(require("fs-extra"));
5432
+ import { Telemetry as Telemetry2 } from "@tinacms/metrics";
5433
+ import fs14 from "fs-extra";
5264
5434
 
5265
5435
  // src/next/commands/codemod-command/index.ts
5266
- var import_clipanion5 = require("clipanion");
5267
- var import_fs_extra11 = __toESM(require("fs-extra"));
5268
- var import_path10 = __toESM(require("path"));
5269
- var CodemodCommand = class extends import_clipanion5.Command {
5270
- constructor() {
5271
- super(...arguments);
5272
- this.rootPath = import_clipanion5.Option.String("--rootPath", {
5273
- description: "Specify the root directory to run the CLI from"
5274
- });
5275
- this.verbose = import_clipanion5.Option.Boolean("-v,--verbose", false, {
5276
- description: "increase verbosity of logged output"
5277
- });
5278
- }
5279
- static {
5280
- this.paths = [["codemod"], ["codemod", "move-tina-folder"]];
5281
- }
5282
- static {
5283
- this.usage = import_clipanion5.Command.Usage({
5284
- category: `Commands`,
5285
- description: `Use codemods for various Tina tasks`
5286
- });
5287
- }
5436
+ import { Command as Command5, Option as Option5 } from "clipanion";
5437
+ import fs12 from "fs-extra";
5438
+ import path13 from "path";
5439
+ var CodemodCommand = class extends Command5 {
5440
+ static paths = [["codemod"], ["codemod", "move-tina-folder"]];
5441
+ rootPath = Option5.String("--rootPath", {
5442
+ description: "Specify the root directory to run the CLI from"
5443
+ });
5444
+ verbose = Option5.Boolean("-v,--verbose", false, {
5445
+ description: "increase verbosity of logged output"
5446
+ });
5447
+ static usage = Command5.Usage({
5448
+ category: `Commands`,
5449
+ description: `Use codemods for various Tina tasks`
5450
+ });
5288
5451
  async catch(error) {
5289
5452
  console.log(error);
5290
5453
  }
@@ -5313,13 +5476,13 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
5313
5476
  logger.error(e.message);
5314
5477
  process.exit(1);
5315
5478
  }
5316
- const tinaDestination = import_path10.default.join(configManager.rootPath, "tina");
5317
- if (await import_fs_extra11.default.existsSync(tinaDestination)) {
5479
+ const tinaDestination = path13.join(configManager.rootPath, "tina");
5480
+ if (await fs12.existsSync(tinaDestination)) {
5318
5481
  logger.info(
5319
5482
  `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.`
5320
5483
  );
5321
5484
  } else {
5322
- await import_fs_extra11.default.moveSync(configManager.tinaFolderPath, tinaDestination);
5485
+ await fs12.moveSync(configManager.tinaFolderPath, tinaDestination);
5323
5486
  await writeGitignore(configManager.rootPath);
5324
5487
  logger.info(
5325
5488
  "Move to 'tina' folder complete. Be sure to update any imports of the autogenerated client!"
@@ -5327,8 +5490,8 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
5327
5490
  }
5328
5491
  };
5329
5492
  var writeGitignore = async (rootPath) => {
5330
- await import_fs_extra11.default.outputFileSync(
5331
- import_path10.default.join(rootPath, "tina", ".gitignore"),
5493
+ await fs12.outputFileSync(
5494
+ path13.join(rootPath, "tina", ".gitignore"),
5332
5495
  "__generated__"
5333
5496
  );
5334
5497
  };
@@ -5381,7 +5544,7 @@ const BlogPage = (props) => {
5381
5544
  <div className='bg-green-100 text-center'>
5382
5545
  Lost and looking for a place to start?
5383
5546
  <a
5384
- href='https://tina.io/guides/tina-cloud/getting-started/overview/'
5547
+ href='https://tina.io/docs/r/beginner-series'
5385
5548
  className='text-blue-500 underline'
5386
5549
  >
5387
5550
  {' '}
@@ -5663,7 +5826,7 @@ import { LocalAuthProvider } from "tinacms";`;
5663
5826
  publicFolder: "${args.publicFolder}",
5664
5827
  },
5665
5828
  },
5666
- // See docs on content modeling for more info on how to setup new content models: https://tina.io/docs/schema/
5829
+ // See docs on content modeling for more info on how to setup new content models: https://tina.io/docs/r/content-modelling-collections/
5667
5830
  schema: {
5668
5831
  collections: ${generateCollectionString(args)},
5669
5832
  },
@@ -5736,7 +5899,7 @@ Suspendisse facilisis, mi ac scelerisque interdum, ligula ex imperdiet felis, a
5736
5899
  `;
5737
5900
 
5738
5901
  // src/cmds/init/apply.ts
5739
- var import_prettier2 = require("prettier");
5902
+ import { format as format2 } from "prettier";
5740
5903
 
5741
5904
  // src/utils/script-helpers.ts
5742
5905
  function generateGqlScript(scriptValue, opts) {
@@ -5759,38 +5922,38 @@ function extendNextScripts(scripts, opts) {
5759
5922
  }
5760
5923
 
5761
5924
  // src/cmds/init/codegen/index.ts
5762
- var import_typescript3 = __toESM(require("typescript"));
5763
- var import_fs_extra12 = __toESM(require("fs-extra"));
5925
+ import ts2 from "typescript";
5926
+ import fs13 from "fs-extra";
5764
5927
 
5765
5928
  // src/cmds/init/codegen/util.ts
5766
- var import_typescript2 = __toESM(require("typescript"));
5767
- var makeTransformer = (makeVisitor) => (ctx) => (node) => import_typescript2.default.visitNode(node, makeVisitor(ctx));
5929
+ import ts from "typescript";
5930
+ var makeTransformer = (makeVisitor) => (ctx) => (node) => ts.visitNode(node, makeVisitor(ctx));
5768
5931
  function parseExpression(expression) {
5769
- const sourceFile = import_typescript2.default.createSourceFile(
5932
+ const sourceFile = ts.createSourceFile(
5770
5933
  "temp.ts",
5771
5934
  expression,
5772
- import_typescript2.default.ScriptTarget.Latest
5935
+ ts.ScriptTarget.Latest
5773
5936
  );
5774
5937
  if (sourceFile.statements.length !== 1) {
5775
5938
  throw new Error("Expected one statement");
5776
5939
  }
5777
5940
  const statement = sourceFile.statements[0];
5778
- if (!import_typescript2.default.isExpressionStatement(statement)) {
5941
+ if (!ts.isExpressionStatement(statement)) {
5779
5942
  throw new Error("Expected an expression statement");
5780
5943
  }
5781
5944
  return [sourceFile, statement.expression];
5782
5945
  }
5783
5946
  function parseVariableStatement(stmt) {
5784
- const sourceFile = import_typescript2.default.createSourceFile(
5947
+ const sourceFile = ts.createSourceFile(
5785
5948
  "temp.ts",
5786
5949
  stmt,
5787
- import_typescript2.default.ScriptTarget.Latest
5950
+ ts.ScriptTarget.Latest
5788
5951
  );
5789
5952
  if (sourceFile.statements.length !== 1) {
5790
5953
  throw new Error("Expected one statement");
5791
5954
  }
5792
5955
  const statement = sourceFile.statements[0];
5793
- if (!import_typescript2.default.isVariableStatement(statement)) {
5956
+ if (!ts.isVariableStatement(statement)) {
5794
5957
  throw new Error("Expected a variable statement");
5795
5958
  }
5796
5959
  return [sourceFile, statement];
@@ -5798,7 +5961,7 @@ function parseVariableStatement(stmt) {
5798
5961
 
5799
5962
  // src/cmds/init/codegen/index.ts
5800
5963
  var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variableStmt) => (ctx) => (node) => {
5801
- if (import_typescript3.default.isSourceFile(node)) {
5964
+ if (ts2.isSourceFile(node)) {
5802
5965
  const newStatements = [...node.statements];
5803
5966
  let encounteredImports = false;
5804
5967
  let firstNonImportStatementIdx = -1;
@@ -5806,7 +5969,7 @@ var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variable
5806
5969
  const [newVarDec] = variableStmt.declarationList.declarations;
5807
5970
  const newVarDecName = newVarDec.name.getText(variableStmtSourceFile);
5808
5971
  for (let i = 0; i < newStatements.length; i++) {
5809
- const isImport = import_typescript3.default.isImportDeclaration(newStatements[i]);
5972
+ const isImport = ts2.isImportDeclaration(newStatements[i]);
5810
5973
  if (isImport && !encounteredImports) {
5811
5974
  encounteredImports = true;
5812
5975
  }
@@ -5814,9 +5977,9 @@ var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variable
5814
5977
  firstNonImportStatementIdx = i;
5815
5978
  }
5816
5979
  const stmt = newStatements[i];
5817
- if (import_typescript3.default.isVariableStatement(stmt)) {
5980
+ if (ts2.isVariableStatement(stmt)) {
5818
5981
  const [dec] = stmt.declarationList.declarations;
5819
- if (dec.name && import_typescript3.default.isIdentifier(dec.name) && dec.name.getText(sourceFile) === newVarDecName) {
5982
+ if (dec.name && ts2.isIdentifier(dec.name) && dec.name.getText(sourceFile) === newVarDecName) {
5820
5983
  existingStatementIdx = i;
5821
5984
  }
5822
5985
  }
@@ -5830,19 +5993,19 @@ var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variable
5830
5993
  if (existingStatementIdx === -1) {
5831
5994
  newStatements.splice(firstNonImportStatementIdx, 0, variableStmt);
5832
5995
  }
5833
- return import_typescript3.default.factory.updateSourceFile(node, newStatements);
5996
+ return ts2.factory.updateSourceFile(node, newStatements);
5834
5997
  }
5835
5998
  };
5836
5999
  var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
5837
- if (import_typescript3.default.isSourceFile(node)) {
6000
+ if (ts2.isSourceFile(node)) {
5838
6001
  const newStatements = [...node.statements];
5839
6002
  let changed = false;
5840
6003
  for (const [moduleName, imports] of Object.entries(importMap)) {
5841
6004
  let foundImportStatement = false;
5842
6005
  for (const statement of newStatements) {
5843
- if (import_typescript3.default.isImportDeclaration(statement) && import_typescript3.default.isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === moduleName) {
6006
+ if (ts2.isImportDeclaration(statement) && ts2.isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === moduleName) {
5844
6007
  foundImportStatement = true;
5845
- const existingImports = statement.importClause?.namedBindings && import_typescript3.default.isNamedImports(statement.importClause.namedBindings) ? statement.importClause.namedBindings.elements.map(
6008
+ const existingImports = statement.importClause?.namedBindings && ts2.isNamedImports(statement.importClause.namedBindings) ? statement.importClause.namedBindings.elements.map(
5846
6009
  (e) => e.name.text
5847
6010
  ) : [];
5848
6011
  const newImports = [
@@ -5853,22 +6016,22 @@ var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
5853
6016
  ])
5854
6017
  ];
5855
6018
  const importSpecifiers = newImports.map(
5856
- (i) => import_typescript3.default.factory.createImportSpecifier(
6019
+ (i) => ts2.factory.createImportSpecifier(
5857
6020
  void 0,
5858
- import_typescript3.default.factory.createIdentifier(i),
5859
- import_typescript3.default.factory.createIdentifier(i)
6021
+ ts2.factory.createIdentifier(i),
6022
+ ts2.factory.createIdentifier(i)
5860
6023
  )
5861
6024
  );
5862
- const namedImports = import_typescript3.default.factory.createNamedImports(importSpecifiers);
5863
- const importClause = import_typescript3.default.factory.createImportClause(
6025
+ const namedImports = ts2.factory.createNamedImports(importSpecifiers);
6026
+ const importClause = ts2.factory.createImportClause(
5864
6027
  false,
5865
6028
  void 0,
5866
6029
  namedImports
5867
6030
  );
5868
- const importDec = import_typescript3.default.factory.createImportDeclaration(
6031
+ const importDec = ts2.factory.createImportDeclaration(
5869
6032
  void 0,
5870
6033
  importClause,
5871
- import_typescript3.default.factory.createStringLiteral(moduleName)
6034
+ ts2.factory.createStringLiteral(moduleName)
5872
6035
  );
5873
6036
  newStatements[newStatements.indexOf(statement)] = importDec;
5874
6037
  changed = true;
@@ -5876,45 +6039,45 @@ var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
5876
6039
  }
5877
6040
  if (!foundImportStatement) {
5878
6041
  const importSpecifiers = imports.map(
5879
- (i) => import_typescript3.default.factory.createImportSpecifier(
6042
+ (i) => ts2.factory.createImportSpecifier(
5880
6043
  void 0,
5881
- import_typescript3.default.factory.createIdentifier(i),
5882
- import_typescript3.default.factory.createIdentifier(i)
6044
+ ts2.factory.createIdentifier(i),
6045
+ ts2.factory.createIdentifier(i)
5883
6046
  )
5884
6047
  );
5885
- const namedImports = import_typescript3.default.factory.createNamedImports(importSpecifiers);
5886
- const importClause = import_typescript3.default.factory.createImportClause(
6048
+ const namedImports = ts2.factory.createNamedImports(importSpecifiers);
6049
+ const importClause = ts2.factory.createImportClause(
5887
6050
  false,
5888
6051
  void 0,
5889
6052
  namedImports
5890
6053
  );
5891
- const importDec = import_typescript3.default.factory.createImportDeclaration(
6054
+ const importDec = ts2.factory.createImportDeclaration(
5892
6055
  void 0,
5893
6056
  importClause,
5894
- import_typescript3.default.factory.createStringLiteral(moduleName)
6057
+ ts2.factory.createStringLiteral(moduleName)
5895
6058
  );
5896
6059
  newStatements.unshift(importDec);
5897
6060
  changed = true;
5898
6061
  }
5899
6062
  }
5900
6063
  if (changed) {
5901
- return import_typescript3.default.factory.updateSourceFile(node, newStatements);
6064
+ return ts2.factory.updateSourceFile(node, newStatements);
5902
6065
  }
5903
6066
  }
5904
6067
  };
5905
6068
  var makeAddExpressionToSchemaCollectionVisitor = (sourceFile, functionName, newExpressionSourceFile, newExpression) => (ctx) => {
5906
6069
  const visit2 = (node) => {
5907
- 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])) {
6070
+ if (ts2.isCallExpression(node) && ts2.isIdentifier(node.expression) && node.expression.text === functionName && node.arguments.length > 0 && ts2.isObjectLiteralExpression(node.arguments[0])) {
5908
6071
  const configObject = node.arguments[0];
5909
6072
  const updateProperties = configObject.properties.map((property) => {
5910
- if (import_typescript3.default.isPropertyAssignment(property)) {
6073
+ if (ts2.isPropertyAssignment(property)) {
5911
6074
  const thisPropertyName = property.name.getText(sourceFile);
5912
- if (thisPropertyName === "schema" && import_typescript3.default.isPropertyAssignment(property) && import_typescript3.default.isObjectLiteralExpression(property.initializer)) {
6075
+ if (thisPropertyName === "schema" && ts2.isPropertyAssignment(property) && ts2.isObjectLiteralExpression(property.initializer)) {
5913
6076
  const schemaObject = property.initializer;
5914
6077
  const collectionsProperty = schemaObject.properties.find(
5915
- (p) => import_typescript3.default.isPropertyAssignment(p) && p.name.getText(sourceFile) === "collections"
6078
+ (p) => ts2.isPropertyAssignment(p) && p.name.getText(sourceFile) === "collections"
5916
6079
  );
5917
- if (collectionsProperty && import_typescript3.default.isPropertyAssignment(collectionsProperty) && import_typescript3.default.isArrayLiteralExpression(collectionsProperty.initializer)) {
6080
+ if (collectionsProperty && ts2.isPropertyAssignment(collectionsProperty) && ts2.isArrayLiteralExpression(collectionsProperty.initializer)) {
5918
6081
  const collectionsArray = collectionsProperty.initializer;
5919
6082
  const collectionItems = collectionsArray.elements.map(
5920
6083
  (e) => e.getText(sourceFile)
@@ -5924,16 +6087,16 @@ var makeAddExpressionToSchemaCollectionVisitor = (sourceFile, functionName, newE
5924
6087
  )) {
5925
6088
  return property;
5926
6089
  }
5927
- return import_typescript3.default.factory.updatePropertyAssignment(
6090
+ return ts2.factory.updatePropertyAssignment(
5928
6091
  property,
5929
6092
  property.name,
5930
- import_typescript3.default.factory.createObjectLiteralExpression(
6093
+ ts2.factory.createObjectLiteralExpression(
5931
6094
  schemaObject.properties.map((subProp) => {
5932
- if (import_typescript3.default.isPropertyAssignment(subProp) && subProp.name.getText(sourceFile) === "collections" && import_typescript3.default.isArrayLiteralExpression(subProp.initializer)) {
5933
- return import_typescript3.default.factory.updatePropertyAssignment(
6095
+ if (ts2.isPropertyAssignment(subProp) && subProp.name.getText(sourceFile) === "collections" && ts2.isArrayLiteralExpression(subProp.initializer)) {
6096
+ return ts2.factory.updatePropertyAssignment(
5934
6097
  subProp,
5935
6098
  subProp.name,
5936
- import_typescript3.default.factory.createArrayLiteralExpression(
6099
+ ts2.factory.createArrayLiteralExpression(
5937
6100
  [newExpression, ...subProp.initializer.elements],
5938
6101
  true
5939
6102
  )
@@ -5949,56 +6112,56 @@ var makeAddExpressionToSchemaCollectionVisitor = (sourceFile, functionName, newE
5949
6112
  }
5950
6113
  return property;
5951
6114
  });
5952
- return import_typescript3.default.factory.createCallExpression(
6115
+ return ts2.factory.createCallExpression(
5953
6116
  node.expression,
5954
6117
  node.typeArguments,
5955
- [import_typescript3.default.factory.createObjectLiteralExpression(updateProperties, true)]
6118
+ [ts2.factory.createObjectLiteralExpression(updateProperties, true)]
5956
6119
  );
5957
6120
  }
5958
- return import_typescript3.default.visitEachChild(node, visit2, ctx);
6121
+ return ts2.visitEachChild(node, visit2, ctx);
5959
6122
  };
5960
6123
  return (sourceFile2) => {
5961
- return import_typescript3.default.visitEachChild(sourceFile2, visit2, ctx);
6124
+ return ts2.visitEachChild(sourceFile2, visit2, ctx);
5962
6125
  };
5963
6126
  };
5964
6127
  var makeUpdateObjectLiteralPropertyVisitor = (sourceFile, functionName, propertyName, propertyValueExpressionSourceFile, propertyValue) => (ctx) => {
5965
6128
  const visitor = (node) => {
5966
- 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])) {
6129
+ if (ts2.isCallExpression(node) && ts2.isIdentifier(node.expression) && node.expression.text === functionName && node.arguments.length > 0 && ts2.isObjectLiteralExpression(node.arguments[0])) {
5967
6130
  let foundProperty = false;
5968
6131
  const configObject = node.arguments[0];
5969
6132
  const updateProperties = configObject.properties.map((property) => {
5970
- if (import_typescript3.default.isPropertyAssignment(property) || import_typescript3.default.isShorthandPropertyAssignment(property)) {
6133
+ if (ts2.isPropertyAssignment(property) || ts2.isShorthandPropertyAssignment(property)) {
5971
6134
  const name2 = property.name.getText(sourceFile);
5972
6135
  if (name2 === propertyName) {
5973
6136
  foundProperty = true;
5974
- return import_typescript3.default.factory.createPropertyAssignment(name2, propertyValue);
6137
+ return ts2.factory.createPropertyAssignment(name2, propertyValue);
5975
6138
  }
5976
6139
  }
5977
6140
  return property;
5978
6141
  });
5979
6142
  if (!foundProperty) {
5980
6143
  updateProperties.unshift(
5981
- import_typescript3.default.factory.createPropertyAssignment(propertyName, propertyValue)
6144
+ ts2.factory.createPropertyAssignment(propertyName, propertyValue)
5982
6145
  );
5983
6146
  }
5984
- return import_typescript3.default.factory.createCallExpression(
6147
+ return ts2.factory.createCallExpression(
5985
6148
  node.expression,
5986
6149
  node.typeArguments,
5987
- [import_typescript3.default.factory.createObjectLiteralExpression(updateProperties, true)]
6150
+ [ts2.factory.createObjectLiteralExpression(updateProperties, true)]
5988
6151
  );
5989
6152
  }
5990
- return import_typescript3.default.visitEachChild(node, visitor, ctx);
6153
+ return ts2.visitEachChild(node, visitor, ctx);
5991
6154
  };
5992
6155
  return (sourceFile2) => {
5993
- return import_typescript3.default.visitNode(sourceFile2, visitor);
6156
+ return ts2.visitNode(sourceFile2, visitor);
5994
6157
  };
5995
6158
  };
5996
6159
  var addSelfHostedTinaAuthToConfig = async (config2, configFile) => {
5997
6160
  const pathToConfig = configFile.resolve(config2.typescript).path;
5998
- const sourceFile = import_typescript3.default.createSourceFile(
6161
+ const sourceFile = ts2.createSourceFile(
5999
6162
  pathToConfig,
6000
- import_fs_extra12.default.readFileSync(pathToConfig, "utf8"),
6001
- config2.typescript ? import_typescript3.default.ScriptTarget.Latest : import_typescript3.default.ScriptTarget.ESNext
6163
+ fs13.readFileSync(pathToConfig, "utf8"),
6164
+ config2.typescript ? ts2.ScriptTarget.Latest : ts2.ScriptTarget.ESNext
6002
6165
  );
6003
6166
  const { configImports, configAuthProviderClass, extraTinaCollections } = config2.authProvider;
6004
6167
  const importMap = {
@@ -6011,7 +6174,7 @@ var addSelfHostedTinaAuthToConfig = async (config2, configFile) => {
6011
6174
  {}
6012
6175
  )
6013
6176
  };
6014
- const transformedSourceFileResult = import_typescript3.default.transform(
6177
+ const transformedSourceFileResult = ts2.transform(
6015
6178
  sourceFile,
6016
6179
  [
6017
6180
  makeImportsVisitor(sourceFile, {
@@ -6047,13 +6210,14 @@ var addSelfHostedTinaAuthToConfig = async (config2, configFile) => {
6047
6210
  )
6048
6211
  ].map((visitor) => makeTransformer(visitor))
6049
6212
  );
6050
- return import_fs_extra12.default.writeFile(
6213
+ return fs13.writeFile(
6051
6214
  pathToConfig,
6052
- import_typescript3.default.createPrinter({ omitTrailingSemicolon: true }).printFile(transformedSourceFileResult.transformed[0])
6215
+ ts2.createPrinter({ omitTrailingSemicolon: true }).printFile(transformedSourceFileResult.transformed[0])
6053
6216
  );
6054
6217
  };
6055
6218
 
6056
6219
  // src/cmds/init/apply.ts
6220
+ import { exec } from "child_process";
6057
6221
  async function apply({
6058
6222
  env,
6059
6223
  params,
@@ -6164,8 +6328,8 @@ async function apply({
6164
6328
  await addConfigFile({
6165
6329
  configArgs: {
6166
6330
  config: config2,
6167
- publicFolder: import_path11.default.join(
6168
- import_path11.default.relative(process.cwd(), pathToForestryConfig),
6331
+ publicFolder: path14.join(
6332
+ path14.relative(process.cwd(), pathToForestryConfig),
6169
6333
  config2.publicFolder
6170
6334
  ),
6171
6335
  collections,
@@ -6222,7 +6386,7 @@ var reportTelemetry = async ({
6222
6386
  if (noTelemetry) {
6223
6387
  logger.info(logText("Telemetry disabled"));
6224
6388
  }
6225
- const telemetry = new import_metrics2.Telemetry({ disabled: noTelemetry });
6389
+ const telemetry = new Telemetry2({ disabled: noTelemetry });
6226
6390
  const schemaFileType = usingTypescript ? "ts" : "js";
6227
6391
  await telemetry.submitRecord({
6228
6392
  event: {
@@ -6238,18 +6402,18 @@ var createPackageJSON = async () => {
6238
6402
  };
6239
6403
  var createGitignore = async ({ baseDir }) => {
6240
6404
  logger.info(logText("No .gitignore found, creating one"));
6241
- import_fs_extra13.default.outputFileSync(import_path11.default.join(baseDir, ".gitignore"), "node_modules");
6405
+ fs14.outputFileSync(path14.join(baseDir, ".gitignore"), "node_modules");
6242
6406
  };
6243
6407
  var updateGitIgnore = async ({
6244
6408
  baseDir,
6245
6409
  items
6246
6410
  }) => {
6247
6411
  logger.info(logText(`Adding ${items.join(",")} to .gitignore`));
6248
- const gitignoreContent = import_fs_extra13.default.readFileSync(import_path11.default.join(baseDir, ".gitignore")).toString();
6412
+ const gitignoreContent = fs14.readFileSync(path14.join(baseDir, ".gitignore")).toString();
6249
6413
  const newGitignoreContent = [...gitignoreContent.split("\n"), ...items].join(
6250
6414
  "\n"
6251
6415
  );
6252
- await import_fs_extra13.default.writeFile(import_path11.default.join(baseDir, ".gitignore"), newGitignoreContent);
6416
+ await fs14.writeFile(path14.join(baseDir, ".gitignore"), newGitignoreContent);
6253
6417
  };
6254
6418
  var addDependencies = async (config2, env, params) => {
6255
6419
  const { packageManager } = config2;
@@ -6290,7 +6454,8 @@ var addDependencies = async (config2, env, params) => {
6290
6454
  let packageManagers = {
6291
6455
  pnpm: process.env.USE_WORKSPACE ? `pnpm add ${deps.join(" ")} --workspace` : `pnpm add ${deps.join(" ")}`,
6292
6456
  npm: `npm install ${deps.join(" ")}`,
6293
- yarn: `yarn add ${deps.join(" ")}`
6457
+ yarn: `yarn add ${deps.join(" ")}`,
6458
+ bun: `bun add ${deps.join(" ")}`
6294
6459
  };
6295
6460
  if (packageManagers[packageManager] && deps.length > 0) {
6296
6461
  logger.info(logText("Adding dependencies, this might take a moment..."));
@@ -6301,7 +6466,8 @@ var addDependencies = async (config2, env, params) => {
6301
6466
  packageManagers = {
6302
6467
  pnpm: process.env.USE_WORKSPACE ? `pnpm add -D ${devDeps.join(" ")} --workspace` : `pnpm add -D ${devDeps.join(" ")}`,
6303
6468
  npm: `npm install -D ${devDeps.join(" ")}`,
6304
- yarn: `yarn add -D ${devDeps.join(" ")}`
6469
+ yarn: `yarn add -D ${devDeps.join(" ")}`,
6470
+ bun: `bun add -D ${devDeps.join(" ")}`
6305
6471
  };
6306
6472
  if (packageManagers[packageManager]) {
6307
6473
  logger.info(
@@ -6318,22 +6484,22 @@ var writeGeneratedFile = async ({
6318
6484
  content,
6319
6485
  typescript
6320
6486
  }) => {
6321
- const { exists, path: path14, parentPath } = generatedFile.resolve(typescript);
6487
+ const { exists, path: path15, parentPath } = generatedFile.resolve(typescript);
6322
6488
  if (exists) {
6323
6489
  if (overwrite) {
6324
- logger.info(`Overwriting file at ${path14}... \u2705`);
6325
- import_fs_extra13.default.outputFileSync(path14, content);
6490
+ logger.info(`Overwriting file at ${path15}... \u2705`);
6491
+ fs14.outputFileSync(path15, content);
6326
6492
  } else {
6327
- logger.info(`Not overwriting file at ${path14}.`);
6493
+ logger.info(`Not overwriting file at ${path15}.`);
6328
6494
  logger.info(
6329
- logText(`Please add the following to ${path14}:
6495
+ logText(`Please add the following to ${path15}:
6330
6496
  ${indentText(content)}}`)
6331
6497
  );
6332
6498
  }
6333
6499
  } else {
6334
- logger.info(`Adding file at ${path14}... \u2705`);
6335
- await import_fs_extra13.default.ensureDir(parentPath);
6336
- import_fs_extra13.default.outputFileSync(path14, content);
6500
+ logger.info(`Adding file at ${path15}... \u2705`);
6501
+ await fs14.ensureDir(parentPath);
6502
+ fs14.outputFileSync(path15, content);
6337
6503
  }
6338
6504
  };
6339
6505
  var addConfigFile = async ({
@@ -6342,7 +6508,7 @@ var addConfigFile = async ({
6342
6508
  generatedFile,
6343
6509
  config: config2
6344
6510
  }) => {
6345
- const content = (0, import_prettier2.format)(generateConfig(configArgs), {
6511
+ const content = format2(generateConfig(configArgs), {
6346
6512
  parser: "babel"
6347
6513
  });
6348
6514
  await writeGeneratedFile({
@@ -6372,7 +6538,7 @@ var addNextApiRoute = async ({
6372
6538
  generatedFile,
6373
6539
  env
6374
6540
  }) => {
6375
- const content = (0, import_prettier2.format)(nextApiRouteTemplate({ config: config2, env }), {
6541
+ const content = format2(nextApiRouteTemplate({ config: config2, env }), {
6376
6542
  parser: "babel"
6377
6543
  });
6378
6544
  await writeGeneratedFile({
@@ -6411,7 +6577,7 @@ var addContentFile = async ({
6411
6577
  return () => ({
6412
6578
  exists: env.sampleContentExists,
6413
6579
  path: env.sampleContentPath,
6414
- parentPath: import_path11.default.dirname(env.sampleContentPath)
6580
+ parentPath: path14.dirname(env.sampleContentPath)
6415
6581
  });
6416
6582
  }
6417
6583
  },
@@ -6434,10 +6600,10 @@ ${titleText(" TinaCMS ")} backend initialized!`));
6434
6600
  return `${x.key}=${x.value || "***"}`;
6435
6601
  }).join("\n") + `
6436
6602
  TINA_PUBLIC_IS_LOCAL=true`;
6437
- const envFile = import_path11.default.join(process.cwd(), ".env");
6438
- if (!import_fs_extra13.default.existsSync(envFile)) {
6603
+ const envFile = path14.join(process.cwd(), ".env");
6604
+ if (!fs14.existsSync(envFile)) {
6439
6605
  logger.info(`Adding .env file to your project... \u2705`);
6440
- import_fs_extra13.default.writeFileSync(envFile, envFileText);
6606
+ fs14.writeFileSync(envFile, envFileText);
6441
6607
  } else {
6442
6608
  logger.info(
6443
6609
  "Please add the following environment variables to your .env file"
@@ -6459,9 +6625,7 @@ ${titleText(" TinaCMS ")} has been initialized!`));
6459
6625
  );
6460
6626
  if (framework.name === "hugo") {
6461
6627
  logger.info(
6462
- focusText("Hugo is required. "),
6463
- "Don't have Hugo installed? Follow this guide to set it up: ",
6464
- linkText("https://gohugo.io/installation/")
6628
+ focusText("Hugo is required. ") + "Don't have Hugo installed? Follow this guide to set it up: " + linkText("https://gohugo.io/installation/")
6465
6629
  );
6466
6630
  }
6467
6631
  logger.info(
@@ -6480,7 +6644,8 @@ var other = ({ packageManager }) => {
6480
6644
  pnpm: `pnpm`,
6481
6645
  npm: `npx`,
6482
6646
  // npx is the way to run executables that aren't in your "scripts"
6483
- yarn: `yarn`
6647
+ yarn: `yarn`,
6648
+ bun: `bun run`
6484
6649
  };
6485
6650
  return `${packageManagers[packageManager]} tinacms dev -c "<your dev command>"`;
6486
6651
  };
@@ -6493,7 +6658,8 @@ var frameworkDevCmds = {
6493
6658
  pnpm: `pnpm`,
6494
6659
  npm: `npm run`,
6495
6660
  // npx is the way to run executables that aren't in your "scripts"
6496
- yarn: `yarn`
6661
+ yarn: `yarn`,
6662
+ bun: `bun run`
6497
6663
  };
6498
6664
  return `${packageManagers[packageManager]} dev`;
6499
6665
  }
@@ -6506,7 +6672,7 @@ var addReactiveFile = {
6506
6672
  baseDir,
6507
6673
  dataLayer
6508
6674
  }) => {
6509
- const packageJsonPath = import_path11.default.join(baseDir, "package.json");
6675
+ const packageJsonPath = path14.join(baseDir, "package.json");
6510
6676
  await writeGeneratedFile({
6511
6677
  generatedFile,
6512
6678
  typescript: config2.typescript,
@@ -6519,7 +6685,7 @@ var addReactiveFile = {
6519
6685
  })
6520
6686
  });
6521
6687
  logger.info("Adding a nextjs example... \u2705");
6522
- const packageJson = JSON.parse(import_fs_extra13.default.readFileSync(packageJsonPath).toString());
6688
+ const packageJson = JSON.parse(fs14.readFileSync(packageJsonPath).toString());
6523
6689
  const scripts = packageJson.scripts || {};
6524
6690
  const updatedPackageJson = JSON.stringify(
6525
6691
  {
@@ -6532,11 +6698,10 @@ var addReactiveFile = {
6532
6698
  null,
6533
6699
  2
6534
6700
  );
6535
- import_fs_extra13.default.writeFileSync(packageJsonPath, updatedPackageJson);
6701
+ fs14.writeFileSync(packageJsonPath, updatedPackageJson);
6536
6702
  }
6537
6703
  };
6538
6704
  function execShellCommand(cmd) {
6539
- const exec = require("child_process").exec;
6540
6705
  return new Promise((resolve2, reject) => {
6541
6706
  exec(cmd, (error, stdout, stderr) => {
6542
6707
  if (error) {
@@ -6582,34 +6747,27 @@ var command = new CLICommand({
6582
6747
  });
6583
6748
 
6584
6749
  // src/next/commands/init-command/index.ts
6585
- var InitCommand = class extends import_clipanion6.Command {
6586
- constructor() {
6587
- super(...arguments);
6588
- this.pathToForestryConfig = import_clipanion6.Option.String("--forestryPath", {
6589
- description: "Specify the relative path to the .forestry directory, if importing an existing forestry site."
6590
- });
6591
- this.rootPath = import_clipanion6.Option.String("--rootPath", {
6592
- description: "Specify the root directory to run the CLI from (defaults to current working directory)"
6593
- });
6594
- this.debug = import_clipanion6.Option.Boolean("--debug", false, {
6595
- description: "Enable debug logging"
6596
- });
6597
- this.noTelemetry = import_clipanion6.Option.Boolean("--noTelemetry", false, {
6598
- description: "Disable anonymous telemetry that is collected"
6599
- });
6600
- this.tinaVersion = import_clipanion6.Option.String("--tinaVersion", {
6601
- description: "Specify a version for tina dependencies"
6602
- });
6603
- }
6604
- static {
6605
- this.paths = [["init"], ["init", "backend"]];
6606
- }
6607
- static {
6608
- this.usage = import_clipanion6.Command.Usage({
6609
- category: `Commands`,
6610
- description: `Add Tina to an existing project`
6611
- });
6612
- }
6750
+ var InitCommand = class extends Command6 {
6751
+ static paths = [["init"], ["init", "backend"]];
6752
+ pathToForestryConfig = Option6.String("--forestryPath", {
6753
+ description: "Specify the relative path to the .forestry directory, if importing an existing forestry site."
6754
+ });
6755
+ rootPath = Option6.String("--rootPath", {
6756
+ description: "Specify the root directory to run the CLI from (defaults to current working directory)"
6757
+ });
6758
+ debug = Option6.Boolean("--debug", false, {
6759
+ description: "Enable debug logging"
6760
+ });
6761
+ noTelemetry = Option6.Boolean("--noTelemetry", false, {
6762
+ description: "Disable anonymous telemetry that is collected"
6763
+ });
6764
+ tinaVersion = Option6.String("--tinaVersion", {
6765
+ description: "Specify a version for tina dependencies"
6766
+ });
6767
+ static usage = Command6.Usage({
6768
+ category: `Commands`,
6769
+ description: `Add Tina to an existing project`
6770
+ });
6613
6771
  async catch(error) {
6614
6772
  logger.error("Error occured during tinacms init");
6615
6773
  console.error(error);
@@ -6631,28 +6789,24 @@ var InitCommand = class extends import_clipanion6.Command {
6631
6789
  };
6632
6790
 
6633
6791
  // src/next/commands/searchindex-command/index.ts
6634
- var import_clipanion7 = require("clipanion");
6635
- var import_graphql17 = require("@tinacms/graphql");
6636
- var import_search3 = require("@tinacms/search");
6637
- var SearchIndexCommand = class extends import_clipanion7.Command {
6638
- constructor() {
6639
- super(...arguments);
6640
- this.rootPath = import_clipanion7.Option.String("--rootPath", {
6641
- description: "Specify the root directory to run the CLI from (defaults to current working directory)"
6642
- });
6643
- this.verbose = import_clipanion7.Option.Boolean("-v,--verbose", false, {
6644
- description: "increase verbosity of logged output"
6645
- });
6646
- }
6647
- static {
6648
- this.paths = [["search-index"]];
6649
- }
6650
- static {
6651
- this.usage = import_clipanion7.Command.Usage({
6652
- category: `Commands`,
6653
- description: `Index the site for search`
6654
- });
6655
- }
6792
+ import { Command as Command7, Option as Option7 } from "clipanion";
6793
+ import { createSchema, FilesystemBridge as FilesystemBridge4 } from "@tinacms/graphql";
6794
+ import {
6795
+ SearchIndexer as SearchIndexer3,
6796
+ TinaCMSSearchIndexClient as TinaCMSSearchIndexClient2
6797
+ } from "@tinacms/search";
6798
+ var SearchIndexCommand = class extends Command7 {
6799
+ static paths = [["search-index"]];
6800
+ rootPath = Option7.String("--rootPath", {
6801
+ description: "Specify the root directory to run the CLI from (defaults to current working directory)"
6802
+ });
6803
+ verbose = Option7.Boolean("-v,--verbose", false, {
6804
+ description: "increase verbosity of logged output"
6805
+ });
6806
+ static usage = Command7.Usage({
6807
+ category: `Commands`,
6808
+ description: `Index the site for search`
6809
+ });
6656
6810
  async catch(error) {
6657
6811
  logger.error("Error occured during tinacms search-index");
6658
6812
  console.error(error);
@@ -6674,7 +6828,7 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6674
6828
  process.exit(1);
6675
6829
  }
6676
6830
  const { schema } = configManager.config;
6677
- const tinaSchema = await (0, import_graphql17.createSchema)({
6831
+ const tinaSchema = await createSchema({
6678
6832
  schema: { ...schema, config: configManager.config }
6679
6833
  });
6680
6834
  let client;
@@ -6702,7 +6856,7 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6702
6856
  "indexerToken not configured in tina search configuration."
6703
6857
  );
6704
6858
  }
6705
- client = new import_search3.TinaCMSSearchIndexClient({
6859
+ client = new TinaCMSSearchIndexClient2({
6706
6860
  apiUrl: `${configManager.config.tinaioConfig?.contentApiUrlOverride || "https://content.tinajs.io"}/searchIndex/${configManager.config?.clientId}`,
6707
6861
  branch: configManager.config?.branch,
6708
6862
  indexerToken: configManager.config?.search?.tina?.indexerToken,
@@ -6711,9 +6865,9 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6711
6865
  } else {
6712
6866
  client = configManager.config?.search?.searchClient;
6713
6867
  }
6714
- const searchIndexer = new import_search3.SearchIndexer({
6868
+ const searchIndexer = new SearchIndexer3({
6715
6869
  batchSize: configManager.config.search?.indexBatchSize || 100,
6716
- bridge: new import_graphql17.FilesystemBridge(
6870
+ bridge: new FilesystemBridge4(
6717
6871
  configManager.rootPath,
6718
6872
  configManager.contentRootPath
6719
6873
  ),
@@ -6741,7 +6895,7 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6741
6895
  };
6742
6896
 
6743
6897
  // src/index.ts
6744
- var cli = new import_clipanion8.Cli({
6898
+ var cli = new Cli({
6745
6899
  binaryName: `tinacms`,
6746
6900
  binaryLabel: `TinaCMS`,
6747
6901
  binaryVersion: version
@@ -6752,7 +6906,10 @@ cli.register(AuditCommand);
6752
6906
  cli.register(InitCommand);
6753
6907
  cli.register(CodemodCommand);
6754
6908
  cli.register(SearchIndexCommand);
6755
- cli.register(import_clipanion8.Builtins.DefinitionsCommand);
6756
- cli.register(import_clipanion8.Builtins.HelpCommand);
6757
- cli.register(import_clipanion8.Builtins.VersionCommand);
6909
+ cli.register(Builtins.DefinitionsCommand);
6910
+ cli.register(Builtins.HelpCommand);
6911
+ cli.register(Builtins.VersionCommand);
6758
6912
  var index_default = cli;
6913
+ export {
6914
+ index_default as default
6915
+ };