@tinacms/cli 0.0.0-90b2aa2-20241028051505 → 0.0.0-9594668-20241223035907

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
@@ -31,7 +31,7 @@ module.exports = __toCommonJS(src_exports);
31
31
  var import_clipanion8 = require("clipanion");
32
32
 
33
33
  // package.json
34
- var version = "1.6.10";
34
+ var version = "1.7.0";
35
35
 
36
36
  // src/next/commands/dev-command/index.ts
37
37
  var import_clipanion2 = require("clipanion");
@@ -41,12 +41,12 @@ var import_chokidar = __toESM(require("chokidar"));
41
41
  var import_graphql10 = require("@tinacms/graphql");
42
42
 
43
43
  // src/next/config-manager.ts
44
- var import_fs_extra = __toESM(require("fs-extra"));
44
+ var import_fs_extra2 = __toESM(require("fs-extra"));
45
45
  var import_path = __toESM(require("path"));
46
46
  var import_os = __toESM(require("os"));
47
47
  var esbuild = __toESM(require("esbuild"));
48
48
  var dotenv = __toESM(require("dotenv"));
49
- var import_normalize_path = __toESM(require("normalize-path"));
49
+ var import_normalize_path2 = __toESM(require("normalize-path"));
50
50
  var import_chalk2 = __toESM(require("chalk"));
51
51
 
52
52
  // src/logger/index.ts
@@ -157,465 +157,11 @@ var S_SUCCESS = s("\u25C6", "*");
157
157
  var S_WARN = s("\u25B2", "!");
158
158
  var S_ERROR = s("\u25A0", "x");
159
159
 
160
- // src/next/config-manager.ts
161
- var TINA_FOLDER = "tina";
162
- var LEGACY_TINA_FOLDER = ".tina";
163
- var GENERATED_FOLDER = "__generated__";
164
- var GRAPHQL_JSON_FILE = "_graphql.json";
165
- var GRAPHQL_GQL_FILE = "schema.gql";
166
- var SCHEMA_JSON_FILE = "_schema.json";
167
- var LOOKUP_JSON_FILE = "_lookup.json";
168
- var ConfigManager = class {
169
- constructor({
170
- rootPath = process.cwd(),
171
- tinaGraphQLVersion,
172
- legacyNoSDK
173
- }) {
174
- this.rootPath = (0, import_normalize_path.default)(rootPath);
175
- this.tinaGraphQLVersionFromCLI = tinaGraphQLVersion;
176
- this.legacyNoSDK = legacyNoSDK;
177
- }
178
- isUsingTs() {
179
- return [".ts", ".tsx"].includes(import_path.default.extname(this.tinaConfigFilePath));
180
- }
181
- hasSelfHostedConfig() {
182
- return !!this.selfHostedDatabaseFilePath;
183
- }
184
- hasSeparateContentRoot() {
185
- return this.rootPath !== this.contentRootPath;
186
- }
187
- shouldSkipSDK() {
188
- var _a;
189
- if (this.legacyNoSDK) {
190
- return this.legacyNoSDK;
191
- }
192
- return ((_a = this.config.client) == null ? void 0 : _a.skip) || false;
193
- }
194
- async processConfig() {
195
- this.tinaFolderPath = await this.getTinaFolderPath(this.rootPath);
196
- this.envFilePath = import_path.default.resolve(
197
- import_path.default.join(this.tinaFolderPath, "..", ".env")
198
- );
199
- dotenv.config({ path: this.envFilePath });
200
- this.tinaConfigFilePath = await this.getPathWithExtension(
201
- import_path.default.join(this.tinaFolderPath, "config")
202
- );
203
- if (!this.tinaConfigFilePath) {
204
- throw new Error(
205
- `Unable to find config file in ${this.tinaFolderPath}. Looking for a file named "config.{ts,tsx,js,jsx}"`
206
- );
207
- }
208
- this.selfHostedDatabaseFilePath = await this.getPathWithExtension(
209
- import_path.default.join(this.tinaFolderPath, "database")
210
- );
211
- this.generatedFolderPath = import_path.default.join(this.tinaFolderPath, GENERATED_FOLDER);
212
- this.generatedCachePath = import_path.default.join(
213
- this.generatedFolderPath,
214
- ".cache",
215
- String(new Date().getTime())
216
- );
217
- this.generatedGraphQLGQLPath = import_path.default.join(
218
- this.generatedFolderPath,
219
- GRAPHQL_GQL_FILE
220
- );
221
- this.generatedGraphQLJSONPath = import_path.default.join(
222
- this.generatedFolderPath,
223
- GRAPHQL_JSON_FILE
224
- );
225
- this.generatedSchemaJSONPath = import_path.default.join(
226
- this.generatedFolderPath,
227
- SCHEMA_JSON_FILE
228
- );
229
- this.generatedLookupJSONPath = import_path.default.join(
230
- this.generatedFolderPath,
231
- LOOKUP_JSON_FILE
232
- );
233
- this.generatedQueriesFilePath = import_path.default.join(
234
- this.generatedFolderPath,
235
- "queries.gql"
236
- );
237
- this.generatedFragmentsFilePath = import_path.default.join(
238
- this.generatedFolderPath,
239
- "frags.gql"
240
- );
241
- this.generatedTypesTSFilePath = import_path.default.join(
242
- this.generatedFolderPath,
243
- "types.ts"
244
- );
245
- this.generatedTypesJSFilePath = import_path.default.join(
246
- this.generatedFolderPath,
247
- "types.js"
248
- );
249
- this.generatedTypesDFilePath = import_path.default.join(
250
- this.generatedFolderPath,
251
- "types.d.ts"
252
- );
253
- this.userQueriesAndFragmentsGlob = import_path.default.join(
254
- this.tinaFolderPath,
255
- "queries/**/*.{graphql,gql}"
256
- );
257
- this.generatedQueriesAndFragmentsGlob = import_path.default.join(
258
- this.generatedFolderPath,
259
- "*.{graphql,gql}"
260
- );
261
- this.generatedClientTSFilePath = import_path.default.join(
262
- this.generatedFolderPath,
263
- "client.ts"
264
- );
265
- this.generatedClientJSFilePath = import_path.default.join(
266
- this.generatedFolderPath,
267
- "client.js"
268
- );
269
- this.generatedClientDFilePath = import_path.default.join(
270
- this.generatedFolderPath,
271
- "client.d.ts"
272
- );
273
- this.generatedDatabaseClientDFilePath = import_path.default.join(
274
- this.generatedFolderPath,
275
- "databaseClient.d.ts"
276
- );
277
- this.generatedDatabaseClientTSFilePath = import_path.default.join(
278
- this.generatedFolderPath,
279
- "databaseClient.ts"
280
- );
281
- this.generatedDatabaseClientJSFilePath = import_path.default.join(
282
- this.generatedFolderPath,
283
- "databaseClient.js"
284
- );
285
- const clientExists = this.isUsingTs() ? await import_fs_extra.default.pathExists(this.generatedClientTSFilePath) : await import_fs_extra.default.pathExists(this.generatedClientJSFilePath);
286
- if (!clientExists) {
287
- const file = "export default ()=>({})\nexport const client = ()=>({})";
288
- if (this.isUsingTs()) {
289
- await import_fs_extra.default.outputFile(this.generatedClientTSFilePath, file);
290
- } else {
291
- await import_fs_extra.default.outputFile(this.generatedClientJSFilePath, file);
292
- }
293
- }
294
- const { config: config2, prebuildPath, watchList } = await this.loadConfigFile(
295
- this.generatedFolderPath,
296
- this.tinaConfigFilePath
297
- );
298
- this.watchList = watchList;
299
- this.config = config2;
300
- this.prebuildFilePath = prebuildPath;
301
- this.publicFolderPath = import_path.default.join(
302
- this.rootPath,
303
- this.config.build.publicFolder
304
- );
305
- this.outputFolderPath = import_path.default.join(
306
- this.publicFolderPath,
307
- this.config.build.outputFolder
308
- );
309
- this.outputHTMLFilePath = import_path.default.join(this.outputFolderPath, "index.html");
310
- this.outputGitignorePath = import_path.default.join(this.outputFolderPath, ".gitignore");
311
- const fullLocalContentPath = import_path.default.join(
312
- this.tinaFolderPath,
313
- this.config.localContentPath || ""
314
- );
315
- if (this.config.localContentPath) {
316
- const localContentPathExists = await import_fs_extra.default.pathExists(fullLocalContentPath);
317
- if (localContentPathExists) {
318
- logger.info(`Using separate content repo at ${fullLocalContentPath}`);
319
- this.contentRootPath = fullLocalContentPath;
320
- } else {
321
- logger.warn(
322
- `${import_chalk2.default.yellow("Warning:")} The localContentPath ${import_chalk2.default.cyan(
323
- fullLocalContentPath
324
- )} does not exist. Please create it or remove the localContentPath from your config file at ${import_chalk2.default.cyan(
325
- this.tinaConfigFilePath
326
- )}`
327
- );
328
- }
329
- }
330
- if (!this.contentRootPath) {
331
- this.contentRootPath = this.rootPath;
332
- }
333
- this.generatedFolderPathContentRepo = import_path.default.join(
334
- await this.getTinaFolderPath(this.contentRootPath),
335
- GENERATED_FOLDER
336
- );
337
- this.spaMainPath = require.resolve("@tinacms/app");
338
- this.spaRootPath = import_path.default.join(this.spaMainPath, "..", "..");
339
- }
340
- async getTinaFolderPath(rootPath) {
341
- const tinaFolderPath = import_path.default.join(rootPath, TINA_FOLDER);
342
- const tinaFolderExists = await import_fs_extra.default.pathExists(tinaFolderPath);
343
- if (tinaFolderExists) {
344
- this.isUsingLegacyFolder = false;
345
- return tinaFolderPath;
346
- }
347
- const legacyFolderPath = import_path.default.join(rootPath, LEGACY_TINA_FOLDER);
348
- const legacyFolderExists = await import_fs_extra.default.pathExists(legacyFolderPath);
349
- if (legacyFolderExists) {
350
- this.isUsingLegacyFolder = true;
351
- return legacyFolderPath;
352
- }
353
- throw new Error(
354
- `Unable to find Tina folder, if you're working in folder outside of the Tina config be sure to specify --rootPath`
355
- );
356
- }
357
- getTinaGraphQLVersion() {
358
- var _a, _b;
359
- if (this.tinaGraphQLVersionFromCLI) {
360
- return this.tinaGraphQLVersionFromCLI;
361
- }
362
- const generatedSchema = import_fs_extra.default.readJSONSync(this.generatedSchemaJSONPath);
363
- if (!generatedSchema || !(typeof (generatedSchema == null ? void 0 : generatedSchema.version) !== "undefined") || !(typeof ((_a = generatedSchema == null ? void 0 : generatedSchema.version) == null ? void 0 : _a.major) === "string") || !(typeof ((_b = generatedSchema == null ? void 0 : generatedSchema.version) == null ? void 0 : _b.minor) === "string")) {
364
- throw new Error(
365
- `Can not find Tina GraphQL version in ${this.generatedSchemaJSONPath}`
366
- );
367
- }
368
- return `${generatedSchema.version.major}.${generatedSchema.version.minor}`;
369
- }
370
- printGeneratedClientFilePath() {
371
- if (this.isUsingTs()) {
372
- return this.generatedClientTSFilePath.replace(`${this.rootPath}/`, "");
373
- }
374
- return this.generatedClientJSFilePath.replace(`${this.rootPath}/`, "");
375
- }
376
- printGeneratedTypesFilePath() {
377
- return this.generatedTypesTSFilePath.replace(`${this.rootPath}/`, "");
378
- }
379
- printoutputHTMLFilePath() {
380
- return this.outputHTMLFilePath.replace(`${this.publicFolderPath}/`, "");
381
- }
382
- printRelativePath(filename) {
383
- if (filename) {
384
- return filename.replace(/\\/g, "/").replace(`${this.rootPath}/`, "");
385
- }
386
- throw `No path provided to print`;
387
- }
388
- printPrebuildFilePath() {
389
- return this.prebuildFilePath.replace(/\\/g, "/").replace(`${this.rootPath}/${this.tinaFolderPath}/`, "");
390
- }
391
- printContentRelativePath(filename) {
392
- if (filename) {
393
- return filename.replace(/\\/g, "/").replace(`${this.contentRootPath}/`, "");
394
- }
395
- throw `No path provided to print`;
396
- }
397
- async getPathWithExtension(filepath) {
398
- const extensions = ["tsx", "ts", "jsx", "js"];
399
- let result;
400
- await Promise.all(
401
- extensions.map(async (ext) => {
402
- if (result) {
403
- return;
404
- }
405
- const filepathWithExtension = `${filepath}.${ext}`;
406
- const exists = import_fs_extra.default.existsSync(filepathWithExtension);
407
- if (exists) {
408
- result = filepathWithExtension;
409
- }
410
- })
411
- );
412
- return result;
413
- }
414
- async loadDatabaseFile() {
415
- const tmpdir = import_path.default.join(import_os.default.tmpdir(), Date.now().toString());
416
- const outfile = import_path.default.join(tmpdir, "database.build.js");
417
- await esbuild.build({
418
- entryPoints: [this.selfHostedDatabaseFilePath],
419
- bundle: true,
420
- platform: "node",
421
- outfile,
422
- loader: loaders
423
- });
424
- const result = require(outfile);
425
- import_fs_extra.default.removeSync(outfile);
426
- return result.default;
427
- }
428
- async loadConfigFile(generatedFolderPath, configFilePath) {
429
- const tmpdir = import_path.default.join(import_os.default.tmpdir(), Date.now().toString());
430
- const prebuild = import_path.default.join(this.generatedFolderPath, "config.prebuild.jsx");
431
- const outfile = import_path.default.join(tmpdir, "config.build.jsx");
432
- const outfile2 = import_path.default.join(tmpdir, "config.build.js");
433
- const tempTSConfigFile = import_path.default.join(tmpdir, "tsconfig.json");
434
- import_fs_extra.default.outputFileSync(tempTSConfigFile, "{}");
435
- const result2 = await esbuild.build({
436
- entryPoints: [configFilePath],
437
- bundle: true,
438
- target: ["es2020"],
439
- platform: "browser",
440
- format: "esm",
441
- logLevel: "silent",
442
- packages: "external",
443
- ignoreAnnotations: true,
444
- outfile: prebuild,
445
- loader: loaders,
446
- metafile: true
447
- });
448
- const flattenedList = [];
449
- Object.keys(result2.metafile.inputs).forEach((key) => {
450
- if (key.includes("node_modules") || key.includes("__generated__")) {
451
- return;
452
- }
453
- flattenedList.push(key);
454
- });
455
- await esbuild.build({
456
- entryPoints: [configFilePath],
457
- bundle: true,
458
- target: ["es2020"],
459
- logLevel: "silent",
460
- platform: "node",
461
- outfile,
462
- loader: loaders
463
- });
464
- await esbuild.build({
465
- entryPoints: [outfile],
466
- bundle: true,
467
- logLevel: "silent",
468
- platform: "node",
469
- outfile: outfile2,
470
- loader: loaders
471
- });
472
- let result;
473
- try {
474
- result = require(outfile2);
475
- } catch (e) {
476
- console.error("Unexpected error loading config");
477
- console.error(e);
478
- throw e;
479
- }
480
- import_fs_extra.default.removeSync(outfile);
481
- import_fs_extra.default.removeSync(outfile2);
482
- return {
483
- config: result.default,
484
- prebuildPath: prebuild,
485
- watchList: flattenedList
486
- };
487
- }
488
- };
489
- var loaders = {
490
- ".aac": "file",
491
- ".css": "file",
492
- ".eot": "file",
493
- ".flac": "file",
494
- ".gif": "file",
495
- ".jpeg": "file",
496
- ".jpg": "file",
497
- ".json": "json",
498
- ".mp3": "file",
499
- ".mp4": "file",
500
- ".ogg": "file",
501
- ".otf": "file",
502
- ".png": "file",
503
- ".svg": "file",
504
- ".ttf": "file",
505
- ".wav": "file",
506
- ".webm": "file",
507
- ".webp": "file",
508
- ".woff": "file",
509
- ".woff2": "file",
510
- ".js": "jsx",
511
- ".jsx": "jsx",
512
- ".tsx": "tsx"
513
- };
514
-
515
- // src/next/commands/dev-command/html.ts
516
- var errorHTML = `<style type="text/css">
517
- #no-assets-placeholder body {
518
- font-family: sans-serif;
519
- font-size: 16px;
520
- line-height: 1.4;
521
- color: #333;
522
- background-color: #f5f5f5;
523
- }
524
- #no-assets-placeholder {
525
- max-width: 600px;
526
- margin: 0 auto;
527
- padding: 40px;
528
- text-align: center;
529
- background-color: #fff;
530
- box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.1);
531
- }
532
- #no-assets-placeholder h1 {
533
- font-size: 24px;
534
- margin-bottom: 20px;
535
- }
536
- #no-assets-placeholder p {
537
- margin-bottom: 10px;
538
- }
539
- #no-assets-placeholder a {
540
- color: #0077cc;
541
- text-decoration: none;
542
- }
543
- #no-assets-placeholder a:hover {
544
- text-decoration: underline;
545
- }
546
- </style>
547
- <div id="no-assets-placeholder">
548
- <h1>Failed loading TinaCMS assets</h1>
549
- <p>
550
- Your TinaCMS configuration may be misconfigured, and we could not load
551
- the assets for this page.
552
- </p>
553
- <p>
554
- 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.
555
- </p>
556
- </div>
557
- </div>`.trim().replace(/[\r\n\s]+/g, " ");
558
- var devHTML = (port) => `<!DOCTYPE html>
559
- <html lang="en">
560
- <head>
561
- <meta charset="UTF-8" />
562
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
563
- <title>TinaCMS</title>
564
- </head>
565
-
566
- <!-- if development -->
567
- <script type="module">
568
- import RefreshRuntime from 'http://localhost:${port}/@react-refresh'
569
- RefreshRuntime.injectIntoGlobalHook(window)
570
- window.$RefreshReg$ = () => {}
571
- window.$RefreshSig$ = () => (type) => type
572
- window.__vite_plugin_react_preamble_installed__ = true
573
- <\/script>
574
- <script type="module" src="http://localhost:${port}/@vite/client"><\/script>
575
- <script>
576
- function handleLoadError() {
577
- // Assets have failed to load
578
- document.getElementById('root').innerHTML = '${errorHTML}';
579
- }
580
- <\/script>
581
- <script
582
- type="module"
583
- src="http://localhost:${port}/src/main.tsx"
584
- onerror="handleLoadError()"
585
- ><\/script>
586
- <body class="tina-tailwind">
587
- <div id="root"></div>
588
- </body>
589
- </html>`;
590
-
591
- // src/utils/theme.ts
592
- var import_chalk3 = __toESM(require("chalk"));
593
- var successText = import_chalk3.default.bold.green;
594
- var focusText = import_chalk3.default.bold;
595
- var dangerText = import_chalk3.default.bold.red;
596
- var neutralText = import_chalk3.default.bold.cyan;
597
- var linkText = import_chalk3.default.bold.cyan;
598
- var labelText = import_chalk3.default.bold;
599
- var cmdText = import_chalk3.default.inverse;
600
- var indentedCmd = (str) => {
601
- return ` \u2503 ` + str;
602
- };
603
- var indentText = (str) => {
604
- return String(str).split("\n").map((line) => ` ${line}`).join("\n");
605
- };
606
- var logText = import_chalk3.default.italic.gray;
607
- var warnText = import_chalk3.default.yellowBright.bgBlack;
608
- var titleText = import_chalk3.default.bgHex("d2f1f8").hex("ec4816");
609
- var CONFIRMATION_TEXT = import_chalk3.default.dim("enter to confirm");
610
-
611
- // src/next/commands/dev-command/server/index.ts
612
- var import_vite3 = require("vite");
613
-
614
160
  // src/next/vite/index.ts
615
161
  var import_node_path2 = __toESM(require("path"));
616
162
  var import_plugin_react = __toESM(require("@vitejs/plugin-react"));
617
- var import_fs_extra2 = __toESM(require("fs-extra"));
618
- var import_normalize_path2 = __toESM(require("normalize-path"));
163
+ var import_fs_extra = __toESM(require("fs-extra"));
164
+ var import_normalize_path = __toESM(require("normalize-path"));
619
165
  var import_vite = require("vite");
620
166
 
621
167
  // src/next/vite/tailwind.ts
@@ -897,15 +443,15 @@ async function listFilesRecursively({
897
443
  config2.publicFolder,
898
444
  directoryPath
899
445
  );
900
- const exists = await import_fs_extra2.default.pathExists(fullDirectoryPath);
446
+ const exists = await import_fs_extra.default.pathExists(fullDirectoryPath);
901
447
  if (!exists) {
902
448
  return { "0": [] };
903
449
  }
904
- const items = await import_fs_extra2.default.readdir(fullDirectoryPath);
450
+ const items = await import_fs_extra.default.readdir(fullDirectoryPath);
905
451
  const staticMediaItems = [];
906
452
  for (const item of items) {
907
453
  const itemPath = import_node_path2.default.join(fullDirectoryPath, item);
908
- const stats = await import_fs_extra2.default.promises.lstat(itemPath);
454
+ const stats = await import_fs_extra.default.promises.lstat(itemPath);
909
455
  const staticMediaItem = {
910
456
  id: item,
911
457
  filename: item,
@@ -937,15 +483,35 @@ async function listFilesRecursively({
937
483
  }
938
484
  return chunkArrayIntoObject(staticMediaItems, 20);
939
485
  }
486
+ var loadProjectConfig = async ({
487
+ rootPath,
488
+ viteConfigEnv
489
+ }) => {
490
+ if (viteConfigEnv) {
491
+ const configFileJs = import_node_path2.default.join(rootPath, "vite.config.js");
492
+ const configFileTs = import_node_path2.default.join(rootPath, "vite.config.ts");
493
+ if (import_fs_extra.default.existsSync(configFileJs)) {
494
+ return await (0, import_vite.loadConfigFromFile)(viteConfigEnv, configFileJs);
495
+ } else if (import_fs_extra.default.existsSync(configFileTs)) {
496
+ return await (0, import_vite.loadConfigFromFile)(viteConfigEnv, configFileTs);
497
+ }
498
+ }
499
+ return { config: {} };
500
+ };
940
501
  var createConfig = async ({
941
502
  configManager,
942
503
  database,
943
504
  apiURL,
944
505
  plugins = [],
945
506
  noWatch,
946
- rollupOptions
507
+ rollupOptions,
508
+ viteConfigEnv
947
509
  }) => {
948
- var _a, _b, _c, _d, _e, _f, _g, _h;
510
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
511
+ const projectConfig = await loadProjectConfig({
512
+ rootPath: configManager.rootPath,
513
+ viteConfigEnv
514
+ });
949
515
  const publicEnv = {};
950
516
  Object.keys(process.env).forEach((key) => {
951
517
  if (key.startsWith("TINA_PUBLIC_") || key.startsWith("NEXT_PUBLIC_") || key === "NODE_ENV" || key === "HEAD") {
@@ -973,9 +539,9 @@ var createConfig = async ({
973
539
  config: configManager.config.media.tina,
974
540
  roothPath: configManager.rootPath
975
541
  });
976
- await import_fs_extra2.default.outputFile(staticMediaPath, JSON.stringify(staticMedia, null, 2));
542
+ await import_fs_extra.default.outputFile(staticMediaPath, JSON.stringify(staticMedia, null, 2));
977
543
  } else {
978
- await import_fs_extra2.default.outputFile(staticMediaPath, `[]`);
544
+ await import_fs_extra.default.outputFile(staticMediaPath, `[]`);
979
545
  }
980
546
  const alias = {
981
547
  TINA_IMPORT: configManager.prebuildFilePath,
@@ -999,65 +565,552 @@ var createConfig = async ({
999
565
  if (configManager.config.build.basePath) {
1000
566
  basePath = configManager.config.build.basePath;
1001
567
  }
1002
- const config2 = {
1003
- root: configManager.spaRootPath,
1004
- base: `/${basePath ? `${(0, import_normalize_path2.default)(basePath)}/` : ""}${(0, import_normalize_path2.default)(
1005
- configManager.config.build.outputFolder
1006
- )}/`,
1007
- appType: "spa",
1008
- resolve: {
1009
- alias,
1010
- dedupe: ["graphql", "tinacms", "react", "react-dom", "react-router-dom"]
1011
- },
1012
- define: {
1013
- "process.env": `new Object(${JSON.stringify(publicEnv)})`,
1014
- "process.platform": `"${process.platform}"`,
1015
- __API_URL__: `"${apiURL}"`,
1016
- __BASE_PATH__: `"${((_e = (_d = configManager.config) == null ? void 0 : _d.build) == null ? void 0 : _e.basePath) || ""}"`,
1017
- __TINA_GRAPHQL_VERSION__: `"${configManager.getTinaGraphQLVersion()}"`
1018
- },
1019
- logLevel: "error",
1020
- optimizeDeps: {
1021
- force: true,
1022
- include: ["react/jsx-runtime", "react/jsx-dev-runtime"]
1023
- },
1024
- server: {
1025
- host: (_h = (_g = (_f = configManager.config) == null ? void 0 : _f.build) == null ? void 0 : _g.host) != null ? _h : false,
1026
- watch: noWatch ? {
1027
- ignored: ["**/*"]
1028
- } : {
1029
- ignored: [
1030
- `${configManager.tinaFolderPath}/**/!(config.prebuild.jsx|_graphql.json)`
1031
- ]
1032
- },
1033
- fs: {
1034
- strict: false
1035
- }
1036
- },
1037
- build: {
1038
- sourcemap: false,
1039
- outDir: configManager.outputFolderPath,
1040
- emptyOutDir: true,
1041
- rollupOptions
1042
- },
1043
- plugins: [
1044
- (0, import_plugin_react.default)({
1045
- babel: {
1046
- compact: true
1047
- }
1048
- }),
1049
- (0, import_vite.splitVendorChunkPlugin)(),
1050
- tinaTailwind(configManager.spaRootPath, configManager.prebuildFilePath),
1051
- ...plugins
1052
- ]
1053
- };
1054
- return config2;
568
+ const fullVersion = configManager.getTinaGraphQLVersion();
569
+ const version2 = `${fullVersion.major}.${fullVersion.minor}`;
570
+ const config2 = {
571
+ root: configManager.spaRootPath,
572
+ base: `/${basePath ? `${(0, import_normalize_path.default)(basePath)}/` : ""}${(0, import_normalize_path.default)(
573
+ configManager.config.build.outputFolder
574
+ )}/`,
575
+ appType: "spa",
576
+ resolve: {
577
+ alias: {
578
+ ...(_d = projectConfig.config.resolve) == null ? void 0 : _d.alias,
579
+ ...alias
580
+ },
581
+ dedupe: ["graphql", "tinacms", "react", "react-dom", "react-router-dom"]
582
+ },
583
+ define: {
584
+ "process.env": `new Object(${JSON.stringify(publicEnv)})`,
585
+ "process.platform": `"${process.platform}"`,
586
+ __API_URL__: `"${apiURL}"`,
587
+ __BASE_PATH__: `"${((_f = (_e = configManager.config) == null ? void 0 : _e.build) == null ? void 0 : _f.basePath) || ""}"`,
588
+ __TINA_GRAPHQL_VERSION__: version2
589
+ },
590
+ logLevel: "error",
591
+ optimizeDeps: {
592
+ force: true,
593
+ include: ["react/jsx-runtime", "react/jsx-dev-runtime"]
594
+ },
595
+ server: {
596
+ host: (_i = (_h = (_g = configManager.config) == null ? void 0 : _g.build) == null ? void 0 : _h.host) != null ? _i : false,
597
+ watch: noWatch ? {
598
+ ignored: ["**/*"]
599
+ } : {
600
+ ignored: [
601
+ `${configManager.tinaFolderPath}/**/!(config.prebuild.jsx|_graphql.json)`
602
+ ]
603
+ },
604
+ fs: {
605
+ strict: false
606
+ }
607
+ },
608
+ build: {
609
+ sourcemap: false,
610
+ outDir: configManager.outputFolderPath,
611
+ emptyOutDir: true,
612
+ rollupOptions
613
+ },
614
+ plugins: [
615
+ (0, import_plugin_react.default)({
616
+ babel: {
617
+ compact: true
618
+ }
619
+ }),
620
+ (0, import_vite.splitVendorChunkPlugin)(),
621
+ tinaTailwind(configManager.spaRootPath, configManager.prebuildFilePath),
622
+ ...plugins
623
+ ]
624
+ };
625
+ return config2;
626
+ };
627
+
628
+ // src/utils/resolve-alias-helpers.ts
629
+ async function loadViteConfig(rootPath) {
630
+ try {
631
+ return await loadProjectConfig({
632
+ rootPath,
633
+ viteConfigEnv: {
634
+ command: "build",
635
+ mode: "production"
636
+ }
637
+ });
638
+ } catch (error) {
639
+ console.error("Failed to load Vite config:", error.message);
640
+ throw new Error("Error loading Vite configuration");
641
+ }
642
+ }
643
+
644
+ // src/next/config-manager.ts
645
+ var TINA_FOLDER = "tina";
646
+ var LEGACY_TINA_FOLDER = ".tina";
647
+ var GENERATED_FOLDER = "__generated__";
648
+ var GRAPHQL_JSON_FILE = "_graphql.json";
649
+ var GRAPHQL_GQL_FILE = "schema.gql";
650
+ var SCHEMA_JSON_FILE = "_schema.json";
651
+ var LOOKUP_JSON_FILE = "_lookup.json";
652
+ var ConfigManager = class {
653
+ constructor({
654
+ rootPath = process.cwd(),
655
+ tinaGraphQLVersion,
656
+ legacyNoSDK
657
+ }) {
658
+ this.rootPath = (0, import_normalize_path2.default)(rootPath);
659
+ this.tinaGraphQLVersionFromCLI = tinaGraphQLVersion;
660
+ this.legacyNoSDK = legacyNoSDK;
661
+ }
662
+ isUsingTs() {
663
+ return [".ts", ".tsx"].includes(import_path.default.extname(this.tinaConfigFilePath));
664
+ }
665
+ hasSelfHostedConfig() {
666
+ return !!this.selfHostedDatabaseFilePath;
667
+ }
668
+ hasSeparateContentRoot() {
669
+ return this.rootPath !== this.contentRootPath;
670
+ }
671
+ shouldSkipSDK() {
672
+ var _a;
673
+ if (this.legacyNoSDK) {
674
+ return this.legacyNoSDK;
675
+ }
676
+ return ((_a = this.config.client) == null ? void 0 : _a.skip) || false;
677
+ }
678
+ async processConfig() {
679
+ this.tinaFolderPath = await this.getTinaFolderPath(this.rootPath);
680
+ this.envFilePath = import_path.default.resolve(
681
+ import_path.default.join(this.tinaFolderPath, "..", ".env")
682
+ );
683
+ dotenv.config({ path: this.envFilePath });
684
+ this.tinaConfigFilePath = await this.getPathWithExtension(
685
+ import_path.default.join(this.tinaFolderPath, "config")
686
+ );
687
+ if (!this.tinaConfigFilePath) {
688
+ throw new Error(
689
+ `Unable to find config file in ${this.tinaFolderPath}. Looking for a file named "config.{ts,tsx,js,jsx}"`
690
+ );
691
+ }
692
+ this.selfHostedDatabaseFilePath = await this.getPathWithExtension(
693
+ import_path.default.join(this.tinaFolderPath, "database")
694
+ );
695
+ this.generatedFolderPath = import_path.default.join(this.tinaFolderPath, GENERATED_FOLDER);
696
+ this.generatedCachePath = import_path.default.join(
697
+ this.generatedFolderPath,
698
+ ".cache",
699
+ String(new Date().getTime())
700
+ );
701
+ this.generatedGraphQLGQLPath = import_path.default.join(
702
+ this.generatedFolderPath,
703
+ GRAPHQL_GQL_FILE
704
+ );
705
+ this.generatedGraphQLJSONPath = import_path.default.join(
706
+ this.generatedFolderPath,
707
+ GRAPHQL_JSON_FILE
708
+ );
709
+ this.generatedSchemaJSONPath = import_path.default.join(
710
+ this.generatedFolderPath,
711
+ SCHEMA_JSON_FILE
712
+ );
713
+ this.generatedLookupJSONPath = import_path.default.join(
714
+ this.generatedFolderPath,
715
+ LOOKUP_JSON_FILE
716
+ );
717
+ this.generatedQueriesFilePath = import_path.default.join(
718
+ this.generatedFolderPath,
719
+ "queries.gql"
720
+ );
721
+ this.generatedFragmentsFilePath = import_path.default.join(
722
+ this.generatedFolderPath,
723
+ "frags.gql"
724
+ );
725
+ this.generatedTypesTSFilePath = import_path.default.join(
726
+ this.generatedFolderPath,
727
+ "types.ts"
728
+ );
729
+ this.generatedTypesJSFilePath = import_path.default.join(
730
+ this.generatedFolderPath,
731
+ "types.js"
732
+ );
733
+ this.generatedTypesDFilePath = import_path.default.join(
734
+ this.generatedFolderPath,
735
+ "types.d.ts"
736
+ );
737
+ this.userQueriesAndFragmentsGlob = import_path.default.join(
738
+ this.tinaFolderPath,
739
+ "queries/**/*.{graphql,gql}"
740
+ );
741
+ this.generatedQueriesAndFragmentsGlob = import_path.default.join(
742
+ this.generatedFolderPath,
743
+ "*.{graphql,gql}"
744
+ );
745
+ this.generatedClientTSFilePath = import_path.default.join(
746
+ this.generatedFolderPath,
747
+ "client.ts"
748
+ );
749
+ this.generatedClientJSFilePath = import_path.default.join(
750
+ this.generatedFolderPath,
751
+ "client.js"
752
+ );
753
+ this.generatedClientDFilePath = import_path.default.join(
754
+ this.generatedFolderPath,
755
+ "client.d.ts"
756
+ );
757
+ this.generatedDatabaseClientDFilePath = import_path.default.join(
758
+ this.generatedFolderPath,
759
+ "databaseClient.d.ts"
760
+ );
761
+ this.generatedDatabaseClientTSFilePath = import_path.default.join(
762
+ this.generatedFolderPath,
763
+ "databaseClient.ts"
764
+ );
765
+ this.generatedDatabaseClientJSFilePath = import_path.default.join(
766
+ this.generatedFolderPath,
767
+ "databaseClient.js"
768
+ );
769
+ const clientExists = this.isUsingTs() ? await import_fs_extra2.default.pathExists(this.generatedClientTSFilePath) : await import_fs_extra2.default.pathExists(this.generatedClientJSFilePath);
770
+ if (!clientExists) {
771
+ const file = "export default ()=>({})\nexport const client = ()=>({})";
772
+ if (this.isUsingTs()) {
773
+ await import_fs_extra2.default.outputFile(this.generatedClientTSFilePath, file);
774
+ } else {
775
+ await import_fs_extra2.default.outputFile(this.generatedClientJSFilePath, file);
776
+ }
777
+ }
778
+ const { config: config2, prebuildPath, watchList } = await this.loadConfigFile(
779
+ this.generatedFolderPath,
780
+ this.tinaConfigFilePath
781
+ );
782
+ this.watchList = watchList;
783
+ this.config = config2;
784
+ this.prebuildFilePath = prebuildPath;
785
+ this.publicFolderPath = import_path.default.join(
786
+ this.rootPath,
787
+ this.config.build.publicFolder
788
+ );
789
+ this.outputFolderPath = import_path.default.join(
790
+ this.publicFolderPath,
791
+ this.config.build.outputFolder
792
+ );
793
+ this.outputHTMLFilePath = import_path.default.join(this.outputFolderPath, "index.html");
794
+ this.outputGitignorePath = import_path.default.join(this.outputFolderPath, ".gitignore");
795
+ const fullLocalContentPath = import_path.default.join(
796
+ this.tinaFolderPath,
797
+ this.config.localContentPath || ""
798
+ );
799
+ if (this.config.localContentPath) {
800
+ const localContentPathExists = await import_fs_extra2.default.pathExists(fullLocalContentPath);
801
+ if (localContentPathExists) {
802
+ logger.info(`Using separate content repo at ${fullLocalContentPath}`);
803
+ this.contentRootPath = fullLocalContentPath;
804
+ } else {
805
+ logger.warn(
806
+ `${import_chalk2.default.yellow("Warning:")} The localContentPath ${import_chalk2.default.cyan(
807
+ fullLocalContentPath
808
+ )} does not exist. Please create it or remove the localContentPath from your config file at ${import_chalk2.default.cyan(
809
+ this.tinaConfigFilePath
810
+ )}`
811
+ );
812
+ }
813
+ }
814
+ if (!this.contentRootPath) {
815
+ this.contentRootPath = this.rootPath;
816
+ }
817
+ this.generatedFolderPathContentRepo = import_path.default.join(
818
+ await this.getTinaFolderPath(this.contentRootPath),
819
+ GENERATED_FOLDER
820
+ );
821
+ this.spaMainPath = require.resolve("@tinacms/app");
822
+ this.spaRootPath = import_path.default.join(this.spaMainPath, "..", "..");
823
+ }
824
+ async getTinaFolderPath(rootPath) {
825
+ const tinaFolderPath = import_path.default.join(rootPath, TINA_FOLDER);
826
+ const tinaFolderExists = await import_fs_extra2.default.pathExists(tinaFolderPath);
827
+ if (tinaFolderExists) {
828
+ this.isUsingLegacyFolder = false;
829
+ return tinaFolderPath;
830
+ }
831
+ const legacyFolderPath = import_path.default.join(rootPath, LEGACY_TINA_FOLDER);
832
+ const legacyFolderExists = await import_fs_extra2.default.pathExists(legacyFolderPath);
833
+ if (legacyFolderExists) {
834
+ this.isUsingLegacyFolder = true;
835
+ return legacyFolderPath;
836
+ }
837
+ throw new Error(
838
+ `Unable to find Tina folder, if you're working in folder outside of the Tina config be sure to specify --rootPath`
839
+ );
840
+ }
841
+ getTinaGraphQLVersion() {
842
+ if (this.tinaGraphQLVersionFromCLI) {
843
+ const version2 = this.tinaGraphQLVersionFromCLI.split(".");
844
+ return {
845
+ fullVersion: this.tinaGraphQLVersionFromCLI,
846
+ major: version2[0] || "x",
847
+ minor: version2[1] || "x",
848
+ patch: version2[2] || "x"
849
+ };
850
+ }
851
+ const generatedSchema = import_fs_extra2.default.readJSONSync(this.generatedSchemaJSONPath);
852
+ if (!generatedSchema || !(typeof (generatedSchema == null ? void 0 : generatedSchema.version) !== "undefined")) {
853
+ throw new Error(
854
+ `Can not find Tina GraphQL version in ${this.generatedSchemaJSONPath}`
855
+ );
856
+ }
857
+ return generatedSchema.version;
858
+ }
859
+ printGeneratedClientFilePath() {
860
+ if (this.isUsingTs()) {
861
+ return this.generatedClientTSFilePath.replace(`${this.rootPath}/`, "");
862
+ }
863
+ return this.generatedClientJSFilePath.replace(`${this.rootPath}/`, "");
864
+ }
865
+ printGeneratedTypesFilePath() {
866
+ return this.generatedTypesTSFilePath.replace(`${this.rootPath}/`, "");
867
+ }
868
+ printoutputHTMLFilePath() {
869
+ return this.outputHTMLFilePath.replace(`${this.publicFolderPath}/`, "");
870
+ }
871
+ printRelativePath(filename) {
872
+ if (filename) {
873
+ return filename.replace(/\\/g, "/").replace(`${this.rootPath}/`, "");
874
+ }
875
+ throw `No path provided to print`;
876
+ }
877
+ printPrebuildFilePath() {
878
+ return this.prebuildFilePath.replace(/\\/g, "/").replace(`${this.rootPath}/${this.tinaFolderPath}/`, "");
879
+ }
880
+ printContentRelativePath(filename) {
881
+ if (filename) {
882
+ return filename.replace(/\\/g, "/").replace(`${this.contentRootPath}/`, "");
883
+ }
884
+ throw `No path provided to print`;
885
+ }
886
+ async getPathWithExtension(filepath) {
887
+ const extensions = ["tsx", "ts", "jsx", "js"];
888
+ let result;
889
+ await Promise.all(
890
+ extensions.map(async (ext) => {
891
+ if (result) {
892
+ return;
893
+ }
894
+ const filepathWithExtension = `${filepath}.${ext}`;
895
+ const exists = import_fs_extra2.default.existsSync(filepathWithExtension);
896
+ if (exists) {
897
+ result = filepathWithExtension;
898
+ }
899
+ })
900
+ );
901
+ return result;
902
+ }
903
+ async loadDatabaseFile() {
904
+ const tmpdir = import_path.default.join(import_os.default.tmpdir(), Date.now().toString());
905
+ const outfile = import_path.default.join(tmpdir, "database.build.js");
906
+ await esbuild.build({
907
+ entryPoints: [this.selfHostedDatabaseFilePath],
908
+ bundle: true,
909
+ platform: "node",
910
+ outfile,
911
+ loader: loaders
912
+ });
913
+ const result = require(outfile);
914
+ import_fs_extra2.default.removeSync(outfile);
915
+ return result.default;
916
+ }
917
+ async loadConfigFile(generatedFolderPath, configFilePath) {
918
+ var _a;
919
+ const tmpdir = import_path.default.join(import_os.default.tmpdir(), Date.now().toString());
920
+ const preBuildConfigPath = import_path.default.join(
921
+ this.generatedFolderPath,
922
+ "config.prebuild.jsx"
923
+ );
924
+ const outfile = import_path.default.join(tmpdir, "config.build.jsx");
925
+ const outfile2 = import_path.default.join(tmpdir, "config.build.js");
926
+ const tempTSConfigFile = import_path.default.join(tmpdir, "tsconfig.json");
927
+ const viteConfig = await loadViteConfig(this.rootPath);
928
+ console.log("latest");
929
+ import_fs_extra2.default.outputFileSync(tempTSConfigFile, "{}");
930
+ const result2 = await esbuild.build({
931
+ entryPoints: [configFilePath],
932
+ bundle: true,
933
+ target: ["es2020"],
934
+ platform: "browser",
935
+ format: "esm",
936
+ logLevel: "silent",
937
+ packages: "external",
938
+ ignoreAnnotations: true,
939
+ outfile: preBuildConfigPath,
940
+ loader: loaders,
941
+ metafile: true
942
+ });
943
+ const flattenedList = [];
944
+ Object.keys(result2.metafile.inputs).forEach((key) => {
945
+ if (key.includes("node_modules") || key.includes("__generated__")) {
946
+ return;
947
+ }
948
+ flattenedList.push(key);
949
+ });
950
+ await esbuild.build({
951
+ entryPoints: [configFilePath],
952
+ bundle: true,
953
+ target: ["es2020"],
954
+ logLevel: "silent",
955
+ platform: "node",
956
+ outfile,
957
+ loader: loaders,
958
+ alias: (_a = viteConfig.config.resolve) == null ? void 0 : _a.alias
959
+ });
960
+ await esbuild.build({
961
+ entryPoints: [outfile],
962
+ bundle: true,
963
+ logLevel: "silent",
964
+ platform: "node",
965
+ outfile: outfile2,
966
+ loader: loaders
967
+ });
968
+ let result;
969
+ try {
970
+ result = require(outfile2);
971
+ } catch (e) {
972
+ console.error("Unexpected error loading config");
973
+ console.error(e);
974
+ throw e;
975
+ }
976
+ import_fs_extra2.default.removeSync(outfile);
977
+ import_fs_extra2.default.removeSync(outfile2);
978
+ return {
979
+ config: result.default,
980
+ prebuildPath: preBuildConfigPath,
981
+ watchList: flattenedList
982
+ };
983
+ }
984
+ };
985
+ var loaders = {
986
+ ".aac": "file",
987
+ ".css": "file",
988
+ ".eot": "file",
989
+ ".flac": "file",
990
+ ".gif": "file",
991
+ ".jpeg": "file",
992
+ ".jpg": "file",
993
+ ".json": "json",
994
+ ".mp3": "file",
995
+ ".mp4": "file",
996
+ ".ogg": "file",
997
+ ".otf": "file",
998
+ ".png": "file",
999
+ ".svg": "file",
1000
+ ".ttf": "file",
1001
+ ".wav": "file",
1002
+ ".webm": "file",
1003
+ ".webp": "file",
1004
+ ".woff": "file",
1005
+ ".woff2": "file",
1006
+ ".js": "jsx",
1007
+ ".jsx": "jsx",
1008
+ ".tsx": "tsx"
1009
+ };
1010
+
1011
+ // src/next/commands/dev-command/html.ts
1012
+ var errorHTML = `<style type="text/css">
1013
+ #no-assets-placeholder body {
1014
+ font-family: sans-serif;
1015
+ font-size: 16px;
1016
+ line-height: 1.4;
1017
+ color: #333;
1018
+ background-color: #f5f5f5;
1019
+ }
1020
+ #no-assets-placeholder {
1021
+ max-width: 600px;
1022
+ margin: 0 auto;
1023
+ padding: 40px;
1024
+ text-align: center;
1025
+ background-color: #fff;
1026
+ box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.1);
1027
+ }
1028
+ #no-assets-placeholder h1 {
1029
+ font-size: 24px;
1030
+ margin-bottom: 20px;
1031
+ }
1032
+ #no-assets-placeholder p {
1033
+ margin-bottom: 10px;
1034
+ }
1035
+ #no-assets-placeholder a {
1036
+ color: #0077cc;
1037
+ text-decoration: none;
1038
+ }
1039
+ #no-assets-placeholder a:hover {
1040
+ text-decoration: underline;
1041
+ }
1042
+ </style>
1043
+ <div id="no-assets-placeholder">
1044
+ <h1>Failed loading TinaCMS assets</h1>
1045
+ <p>
1046
+ Your TinaCMS configuration may be misconfigured, and we could not load
1047
+ the assets for this page.
1048
+ </p>
1049
+ <p>
1050
+ 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.
1051
+ </p>
1052
+ </div>
1053
+ </div>`.trim().replace(/[\r\n\s]+/g, " ");
1054
+ var devHTML = (port) => `<!DOCTYPE html>
1055
+ <html lang="en">
1056
+ <head>
1057
+ <meta charset="UTF-8" />
1058
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
1059
+ <title>TinaCMS</title>
1060
+ </head>
1061
+
1062
+ <!-- if development -->
1063
+ <script type="module">
1064
+ import RefreshRuntime from 'http://localhost:${port}/@react-refresh'
1065
+ RefreshRuntime.injectIntoGlobalHook(window)
1066
+ window.$RefreshReg$ = () => {}
1067
+ window.$RefreshSig$ = () => (type) => type
1068
+ window.__vite_plugin_react_preamble_installed__ = true
1069
+ <\/script>
1070
+ <script type="module" src="http://localhost:${port}/@vite/client"><\/script>
1071
+ <script>
1072
+ function handleLoadError() {
1073
+ // Assets have failed to load
1074
+ document.getElementById('root').innerHTML = '${errorHTML}';
1075
+ }
1076
+ <\/script>
1077
+ <script
1078
+ type="module"
1079
+ src="http://localhost:${port}/src/main.tsx"
1080
+ onerror="handleLoadError()"
1081
+ ><\/script>
1082
+ <body class="tina-tailwind">
1083
+ <div id="root"></div>
1084
+ </body>
1085
+ </html>`;
1086
+
1087
+ // src/utils/theme.ts
1088
+ var import_chalk3 = __toESM(require("chalk"));
1089
+ var successText = import_chalk3.default.bold.green;
1090
+ var focusText = import_chalk3.default.bold;
1091
+ var dangerText = import_chalk3.default.bold.red;
1092
+ var neutralText = import_chalk3.default.bold.cyan;
1093
+ var linkText = import_chalk3.default.bold.cyan;
1094
+ var labelText = import_chalk3.default.bold;
1095
+ var cmdText = import_chalk3.default.inverse;
1096
+ var indentedCmd = (str) => {
1097
+ return ` \u2503 ` + str;
1055
1098
  };
1099
+ var indentText = (str) => {
1100
+ return String(str).split("\n").map((line) => ` ${line}`).join("\n");
1101
+ };
1102
+ var logText = import_chalk3.default.italic.gray;
1103
+ var warnText = import_chalk3.default.yellowBright.bgBlack;
1104
+ var titleText = import_chalk3.default.bgHex("d2f1f8").hex("ec4816");
1105
+ var CONFIRMATION_TEXT = import_chalk3.default.dim("enter to confirm");
1106
+
1107
+ // src/next/commands/dev-command/server/index.ts
1108
+ var import_vite4 = require("vite");
1056
1109
 
1057
1110
  // src/next/vite/plugins.ts
1058
1111
  var import_pluginutils = require("@rollup/pluginutils");
1059
1112
  var import_fs = __toESM(require("fs"));
1060
- var import_vite2 = require("vite");
1113
+ var import_vite3 = require("vite");
1061
1114
  var import_esbuild = require("esbuild");
1062
1115
  var import_path3 = __toESM(require("path"));
1063
1116
  var import_body_parser = __toESM(require("body-parser"));
@@ -1380,7 +1433,7 @@ function viteTransformExtension({
1380
1433
  previousExport: exportAsDefault ? null : code
1381
1434
  }
1382
1435
  });
1383
- const res = await (0, import_vite2.transformWithEsbuild)(componentCode, id, {
1436
+ const res = await (0, import_vite3.transformWithEsbuild)(componentCode, id, {
1384
1437
  loader: "jsx",
1385
1438
  ...esbuildOptions
1386
1439
  });
@@ -1400,7 +1453,7 @@ var createDevServer = async (configManager, database, searchIndex, apiURL, noWat
1400
1453
  devServerEndPointsPlugin({ apiURL, configManager, database, searchIndex }),
1401
1454
  viteTransformExtension()
1402
1455
  ];
1403
- return (0, import_vite3.createServer)(
1456
+ return (0, import_vite4.createServer)(
1404
1457
  await createConfig({
1405
1458
  configManager,
1406
1459
  database,
@@ -1415,6 +1468,10 @@ var createDevServer = async (configManager, database, searchIndex, apiURL, noWat
1415
1468
  }
1416
1469
  warn(warning);
1417
1470
  }
1471
+ },
1472
+ viteConfigEnv: {
1473
+ command: "serve",
1474
+ mode: "development"
1418
1475
  }
1419
1476
  })
1420
1477
  );
@@ -1788,7 +1845,8 @@ var Codegen = class {
1788
1845
  const branch = (_a = this.configManager.config) == null ? void 0 : _a.branch;
1789
1846
  const clientId = (_b = this.configManager.config) == null ? void 0 : _b.clientId;
1790
1847
  const token = (_c = this.configManager.config) == null ? void 0 : _c.token;
1791
- const version2 = this.configManager.getTinaGraphQLVersion();
1848
+ const fullVersion = this.configManager.getTinaGraphQLVersion();
1849
+ const version2 = `${fullVersion.major}.${fullVersion.minor}`;
1792
1850
  const baseUrl = ((_d = this.configManager.config.tinaioConfig) == null ? void 0 : _d.contentApiUrlOverride) || `https://${TINA_HOST}`;
1793
1851
  if ((!branch || !clientId || !token) && !this.port && !this.configManager.config.contentApiUrlOverride) {
1794
1852
  const missing = [];
@@ -2209,7 +2267,7 @@ var BaseCommand = class extends import_clipanion.Command {
2209
2267
  pathFilter
2210
2268
  });
2211
2269
  const tinaPathUpdates = modified.filter(
2212
- (path13) => path13.startsWith(".tina/__generated__/_schema.json") || path13.startsWith("tina/tina-lock.json")
2270
+ (path14) => path14.startsWith(".tina/__generated__/_schema.json") || path14.startsWith("tina/tina-lock.json")
2213
2271
  );
2214
2272
  if (tinaPathUpdates.length > 0) {
2215
2273
  res = await database.indexContent({
@@ -2537,10 +2595,12 @@ DevCommand.usage = import_clipanion2.Command.Usage({
2537
2595
  var import_clipanion3 = require("clipanion");
2538
2596
  var import_progress2 = __toESM(require("progress"));
2539
2597
  var import_fs_extra7 = __toESM(require("fs-extra"));
2598
+ var import_crypto = __toESM(require("crypto"));
2599
+ var import_path6 = __toESM(require("path"));
2540
2600
  var import_graphql11 = require("@tinacms/graphql");
2541
2601
 
2542
2602
  // src/next/commands/build-command/server.ts
2543
- var import_vite5 = require("vite");
2603
+ var import_vite6 = require("vite");
2544
2604
  var buildProductionSpa = async (configManager, database, apiURL) => {
2545
2605
  const publicEnv = {};
2546
2606
  Object.keys(process.env).forEach((key) => {
@@ -2572,15 +2632,19 @@ var buildProductionSpa = async (configManager, database, apiURL) => {
2572
2632
  }
2573
2633
  warn(warning);
2574
2634
  }
2635
+ },
2636
+ viteConfigEnv: {
2637
+ command: "build",
2638
+ mode: "production"
2575
2639
  }
2576
2640
  });
2577
- return (0, import_vite5.build)(config2);
2641
+ return (0, import_vite6.build)(config2);
2578
2642
  };
2579
2643
 
2580
2644
  // src/next/commands/build-command/index.ts
2581
2645
  var import_schema_tools2 = require("@tinacms/schema-tools");
2582
2646
  var import_graphql12 = require("graphql");
2583
- var import_core2 = require("@graphql-inspector/core");
2647
+ var import_core3 = require("@graphql-inspector/core");
2584
2648
 
2585
2649
  // src/next/commands/build-command/waitForDB.ts
2586
2650
  var import_progress = __toESM(require("progress"));
@@ -2682,6 +2746,20 @@ var waitForDB = async (config2, apiUrl, previewName, verbose) => {
2682
2746
 
2683
2747
  // src/next/commands/build-command/index.ts
2684
2748
  var import_search2 = require("@tinacms/search");
2749
+
2750
+ // src/utils/index.ts
2751
+ var import_core2 = require("@graphql-inspector/core");
2752
+ var getFaqLink = (type) => {
2753
+ switch (type) {
2754
+ case import_core2.ChangeType.FieldRemoved: {
2755
+ return "https://tina.io/docs/introduction/faq#how-do-i-resolve-the-local-graphql-schema-doesnt-match-the-remote-graphql-schema-errors";
2756
+ }
2757
+ default:
2758
+ return null;
2759
+ }
2760
+ };
2761
+
2762
+ // src/next/commands/build-command/index.ts
2685
2763
  var BuildCommand = class extends BaseCommand {
2686
2764
  constructor() {
2687
2765
  super(...arguments);
@@ -2809,7 +2887,7 @@ ${dangerText(e.message)}
2809
2887
  }
2810
2888
  const skipCloudChecks = this.skipCloudChecks || configManager.hasSelfHostedConfig();
2811
2889
  if (!skipCloudChecks) {
2812
- const { hasUpstream } = await this.checkClientInfo(
2890
+ const { hasUpstream, timestamp } = await this.checkClientInfo(
2813
2891
  configManager,
2814
2892
  codegen2.productionUrl,
2815
2893
  this.previewBaseBranch
@@ -2837,7 +2915,16 @@ ${dangerText(e.message)}
2837
2915
  await this.checkGraphqlSchema(
2838
2916
  configManager,
2839
2917
  database,
2840
- codegen2.productionUrl
2918
+ codegen2.productionUrl,
2919
+ timestamp
2920
+ );
2921
+ await this.checkTinaSchema(
2922
+ configManager,
2923
+ database,
2924
+ codegen2.productionUrl,
2925
+ this.previewName,
2926
+ this.verbose,
2927
+ timestamp
2841
2928
  );
2842
2929
  }
2843
2930
  await buildProductionSpa(configManager, database, codegen2.productionUrl);
@@ -2956,11 +3043,13 @@ ${dangerText(e.message)}
2956
3043
  const bar2 = new import_progress2.default("Checking clientId and token. :prog", 1);
2957
3044
  let branchKnown = false;
2958
3045
  let hasUpstream = false;
3046
+ let timestamp;
2959
3047
  try {
2960
3048
  const res = await request({
2961
3049
  token,
2962
3050
  url
2963
3051
  });
3052
+ timestamp = res.timestamp || 0;
2964
3053
  bar2.tick({
2965
3054
  prog: "\u2705"
2966
3055
  });
@@ -3002,7 +3091,8 @@ ${dangerText(e.message)}
3002
3091
  prog: "\u2705"
3003
3092
  });
3004
3093
  return {
3005
- hasUpstream
3094
+ hasUpstream,
3095
+ timestamp
3006
3096
  };
3007
3097
  }
3008
3098
  for (let i = 0; i <= 5; i++) {
@@ -3092,14 +3182,14 @@ ${dangerText(e.message)}
3092
3182
  throw e;
3093
3183
  }
3094
3184
  }
3095
- async checkGraphqlSchema(configManager, database, apiURL) {
3185
+ async checkGraphqlSchema(configManager, database, apiURL, timestamp) {
3096
3186
  const bar2 = new import_progress2.default(
3097
3187
  "Checking local GraphQL Schema matches server. :prog",
3098
3188
  1
3099
3189
  );
3100
3190
  const { config: config2 } = configManager;
3101
3191
  const token = config2.token;
3102
- const remoteSchema = await fetchRemoteGraphqlSchema({
3192
+ const { remoteSchema, remoteProjectVersion } = await fetchRemoteGraphqlSchema({
3103
3193
  url: apiURL,
3104
3194
  token
3105
3195
  });
@@ -3119,7 +3209,7 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3119
3209
  const localSchemaDocument = await database.getGraphQLSchemaFromBridge();
3120
3210
  const localGraphqlSchema = (0, import_graphql12.buildASTSchema)(localSchemaDocument);
3121
3211
  try {
3122
- const diffResult = await (0, import_core2.diff)(localGraphqlSchema, remoteGqlSchema);
3212
+ const diffResult = await (0, import_core3.diff)(localGraphqlSchema, remoteGqlSchema);
3123
3213
  if (diffResult.length === 0) {
3124
3214
  bar2.tick({
3125
3215
  prog: "\u2705"
@@ -3128,12 +3218,30 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3128
3218
  bar2.tick({
3129
3219
  prog: "\u274C"
3130
3220
  });
3131
- let errorMessage = `The local GraphQL schema doesn't match the remote GraphQL schema. Please push up your changes to GitHub to update your remote GraphQL schema.`;
3132
- if (config2 == null ? void 0 : config2.branch) {
3133
- errorMessage += `
3221
+ const type = diffResult[0].type;
3222
+ const reason = diffResult[0].message;
3223
+ const errorLevel = diffResult[0].criticality.level;
3224
+ const faqLink = getFaqLink(type);
3225
+ const tinaGraphQLVersion = configManager.getTinaGraphQLVersion();
3226
+ let errorMessage = `The local GraphQL schema doesn't match the remote GraphQL schema. Please push up your changes to GitHub to update your remote GraphQL schema. ${faqLink && `
3227
+ Check out '${faqLink}' for possible solutions.`}`;
3228
+ errorMessage += `
3134
3229
 
3135
- Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3230
+ Additional info:
3231
+
3232
+ `;
3233
+ if (config2 == null ? void 0 : config2.branch) {
3234
+ errorMessage += ` Branch: ${config2.branch}, Client ID: ${config2.clientId}
3235
+ `;
3136
3236
  }
3237
+ errorMessage += ` Local GraphQL version: ${tinaGraphQLVersion.fullVersion} / Remote GraphQL version: ${remoteProjectVersion}
3238
+ `;
3239
+ errorMessage += ` Last indexed at: ${new Date(
3240
+ timestamp
3241
+ ).toUTCString()}
3242
+ `;
3243
+ errorMessage += ` Reason: [${errorLevel} - ${type}] ${reason}
3244
+ `;
3137
3245
  throw new Error(errorMessage);
3138
3246
  }
3139
3247
  } catch (e) {
@@ -3148,6 +3256,71 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3148
3256
  }
3149
3257
  }
3150
3258
  }
3259
+ async checkTinaSchema(configManager, database, apiURL, previewName, verbose, timestamp) {
3260
+ const bar2 = new import_progress2.default(
3261
+ "Checking local Tina Schema matches server. :prog",
3262
+ 1
3263
+ );
3264
+ const { config: config2 } = configManager;
3265
+ const token = config2.token;
3266
+ const { clientId, branch, isLocalClient, host } = (0, import_schema_tools2.parseURL)(apiURL);
3267
+ if (isLocalClient || !host || !clientId || !branch) {
3268
+ if (verbose) {
3269
+ logger.info(logText("Not using Tina Cloud, skipping Tina Schema check"));
3270
+ }
3271
+ return;
3272
+ }
3273
+ const { tinaSchema: remoteTinaSchemaSha } = await fetchSchemaSha({
3274
+ url: `https://${host}/db/${clientId}/${previewName || branch}/schemaSha`,
3275
+ token
3276
+ });
3277
+ if (!remoteTinaSchemaSha) {
3278
+ bar2.tick({
3279
+ prog: "\u274C"
3280
+ });
3281
+ let errorMessage = `The remote Tina schema does not exist. Check indexing for this branch.`;
3282
+ if (config2 == null ? void 0 : config2.branch) {
3283
+ errorMessage += `
3284
+
3285
+ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3286
+ }
3287
+ throw new Error(errorMessage);
3288
+ }
3289
+ if (!database.bridge) {
3290
+ throw new Error(`No bridge configured`);
3291
+ }
3292
+ const localTinaSchema = JSON.parse(
3293
+ await database.bridge.get(
3294
+ import_path6.default.join(database.tinaDirectory, "__generated__", "_schema.json")
3295
+ )
3296
+ );
3297
+ localTinaSchema.version = void 0;
3298
+ const localTinaSchemaSha = import_crypto.default.createHash("sha256").update(JSON.stringify(localTinaSchema)).digest("hex");
3299
+ if (localTinaSchemaSha === remoteTinaSchemaSha) {
3300
+ bar2.tick({
3301
+ prog: "\u2705"
3302
+ });
3303
+ } else {
3304
+ bar2.tick({
3305
+ prog: "\u274C"
3306
+ });
3307
+ let errorMessage = `The local Tina schema doesn't match the remote Tina schema. Please push up your changes to GitHub to update your remote tina schema.`;
3308
+ errorMessage += `
3309
+
3310
+ Additional info:
3311
+
3312
+ `;
3313
+ if (config2 == null ? void 0 : config2.branch) {
3314
+ errorMessage += ` Branch: ${config2.branch}, Client ID: ${config2.clientId}
3315
+ `;
3316
+ }
3317
+ errorMessage += ` Last indexed at: ${new Date(
3318
+ timestamp
3319
+ ).toUTCString()}
3320
+ `;
3321
+ throw new Error(errorMessage);
3322
+ }
3323
+ }
3151
3324
  };
3152
3325
  BuildCommand.paths = [["build"]];
3153
3326
  BuildCommand.usage = import_clipanion3.Command.Usage({
@@ -3214,7 +3387,26 @@ var fetchRemoteGraphqlSchema = async ({
3214
3387
  body
3215
3388
  });
3216
3389
  const data = await res.json();
3217
- return data == null ? void 0 : data.data;
3390
+ return {
3391
+ remoteSchema: data == null ? void 0 : data.data,
3392
+ remoteRuntimeVersion: res.headers.get("tinacms-grapqhl-version"),
3393
+ remoteProjectVersion: res.headers.get("tinacms-graphql-project-version")
3394
+ };
3395
+ };
3396
+ var fetchSchemaSha = async ({
3397
+ url,
3398
+ token
3399
+ }) => {
3400
+ const headers = new Headers();
3401
+ if (token) {
3402
+ headers.append("X-API-KEY", token);
3403
+ }
3404
+ const res = await fetch(url, {
3405
+ method: "GET",
3406
+ headers,
3407
+ cache: "no-cache"
3408
+ });
3409
+ return res.json();
3218
3410
  };
3219
3411
 
3220
3412
  // src/next/commands/audit-command/index.ts
@@ -3469,25 +3661,25 @@ var import_clipanion6 = require("clipanion");
3469
3661
 
3470
3662
  // src/cmds/init/detectEnvironment.ts
3471
3663
  var import_fs_extra8 = __toESM(require("fs-extra"));
3472
- var import_path6 = __toESM(require("path"));
3664
+ var import_path7 = __toESM(require("path"));
3473
3665
  var checkGitignoreForItem = async ({
3474
3666
  baseDir,
3475
3667
  line
3476
3668
  }) => {
3477
- const gitignoreContent = import_fs_extra8.default.readFileSync(import_path6.default.join(baseDir, ".gitignore")).toString();
3669
+ const gitignoreContent = import_fs_extra8.default.readFileSync(import_path7.default.join(baseDir, ".gitignore")).toString();
3478
3670
  return gitignoreContent.split("\n").some((item) => item === line);
3479
3671
  };
3480
3672
  var makeGeneratedFile = async (name2, generatedFileType, parentPath, opts) => {
3481
3673
  const result = {
3482
- fullPathTS: import_path6.default.join(
3674
+ fullPathTS: import_path7.default.join(
3483
3675
  parentPath,
3484
3676
  `${name2}.${(opts == null ? void 0 : opts.typescriptSuffix) || (opts == null ? void 0 : opts.extensionOverride) || "ts"}`
3485
3677
  ),
3486
- fullPathJS: import_path6.default.join(
3678
+ fullPathJS: import_path7.default.join(
3487
3679
  parentPath,
3488
3680
  `${name2}.${(opts == null ? void 0 : opts.extensionOverride) || "js"}`
3489
3681
  ),
3490
- fullPathOverride: (opts == null ? void 0 : opts.extensionOverride) ? import_path6.default.join(parentPath, `${name2}.${opts == null ? void 0 : opts.extensionOverride}`) : "",
3682
+ fullPathOverride: (opts == null ? void 0 : opts.extensionOverride) ? import_path7.default.join(parentPath, `${name2}.${opts == null ? void 0 : opts.extensionOverride}`) : "",
3491
3683
  generatedFileType,
3492
3684
  name: name2,
3493
3685
  parentPath,
@@ -3517,16 +3709,16 @@ var detectEnvironment = async ({
3517
3709
  }) => {
3518
3710
  var _a;
3519
3711
  const hasForestryConfig = await import_fs_extra8.default.pathExists(
3520
- import_path6.default.join(pathToForestryConfig, ".forestry", "settings.yml")
3712
+ import_path7.default.join(pathToForestryConfig, ".forestry", "settings.yml")
3521
3713
  );
3522
- const sampleContentPath = import_path6.default.join(
3714
+ const sampleContentPath = import_path7.default.join(
3523
3715
  baseDir,
3524
3716
  "content",
3525
3717
  "posts",
3526
3718
  "hello-world.md"
3527
3719
  );
3528
- const usingSrc = import_fs_extra8.default.pathExistsSync(import_path6.default.join(baseDir, "src")) && (import_fs_extra8.default.pathExistsSync(import_path6.default.join(baseDir, "src", "app")) || import_fs_extra8.default.pathExistsSync(import_path6.default.join(baseDir, "src", "pages")));
3529
- const tinaFolder = import_path6.default.join(baseDir, "tina");
3720
+ 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")));
3721
+ const tinaFolder = import_path7.default.join(baseDir, "tina");
3530
3722
  const tinaConfigExists = Boolean(
3531
3723
  await import_fs_extra8.default.pathExists(tinaFolder) && (await import_fs_extra8.default.readdir(tinaFolder)).find((x) => x.includes("config"))
3532
3724
  );
@@ -3540,12 +3732,12 @@ var detectEnvironment = async ({
3540
3732
  "next-api-handler": await makeGeneratedFile(
3541
3733
  "[...routes]",
3542
3734
  "next-api-handler",
3543
- import_path6.default.join(...pagesDir, "api", "tina")
3735
+ import_path7.default.join(...pagesDir, "api", "tina")
3544
3736
  ),
3545
3737
  "reactive-example": await makeGeneratedFile(
3546
3738
  "[filename]",
3547
3739
  "reactive-example",
3548
- import_path6.default.join(...pagesDir, "demo", "blog"),
3740
+ import_path7.default.join(...pagesDir, "demo", "blog"),
3549
3741
  {
3550
3742
  typescriptSuffix: "tsx"
3551
3743
  }
@@ -3553,13 +3745,13 @@ var detectEnvironment = async ({
3553
3745
  "users-json": await makeGeneratedFile(
3554
3746
  "index",
3555
3747
  "users-json",
3556
- import_path6.default.join(baseDir, "content", "users"),
3748
+ import_path7.default.join(baseDir, "content", "users"),
3557
3749
  { extensionOverride: "json" }
3558
3750
  ),
3559
3751
  "sample-content": await makeGeneratedFile(
3560
3752
  "hello-world",
3561
3753
  "sample-content",
3562
- import_path6.default.join(baseDir, "content", "posts"),
3754
+ import_path7.default.join(baseDir, "content", "posts"),
3563
3755
  { extensionOverride: "md" }
3564
3756
  )
3565
3757
  };
@@ -3585,13 +3777,13 @@ var detectEnvironment = async ({
3585
3777
  );
3586
3778
  }
3587
3779
  }
3588
- const hasGitIgnore = await import_fs_extra8.default.pathExists(import_path6.default.join(".gitignore"));
3780
+ const hasGitIgnore = await import_fs_extra8.default.pathExists(import_path7.default.join(".gitignore"));
3589
3781
  const hasGitIgnoreNodeModules = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: "node_modules" });
3590
3782
  const hasEnvTina = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: ".env.tina" });
3591
3783
  const hasGitIgnoreEnv = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: ".env" });
3592
3784
  let frontMatterFormat;
3593
3785
  if (hasForestryConfig) {
3594
- const hugoConfigPath = import_path6.default.join(rootPath, "config.toml");
3786
+ const hugoConfigPath = import_path7.default.join(rootPath, "config.toml");
3595
3787
  if (await import_fs_extra8.default.pathExists(hugoConfigPath)) {
3596
3788
  const hugoConfig = await import_fs_extra8.default.readFile(hugoConfigPath, "utf8");
3597
3789
  const metaDataFormat = (_a = hugoConfig.match(/metaDataFormat = "(.*)"/)) == null ? void 0 : _a[1];
@@ -4199,18 +4391,18 @@ var CLICommand = class {
4199
4391
  };
4200
4392
 
4201
4393
  // src/cmds/init/apply.ts
4202
- var import_path10 = __toESM(require("path"));
4394
+ var import_path11 = __toESM(require("path"));
4203
4395
 
4204
4396
  // src/cmds/forestry-migrate/index.ts
4205
4397
  var import_fs_extra10 = __toESM(require("fs-extra"));
4206
- var import_path8 = __toESM(require("path"));
4398
+ var import_path9 = __toESM(require("path"));
4207
4399
  var import_js_yaml2 = __toESM(require("js-yaml"));
4208
4400
  var import_minimatch = __toESM(require("minimatch"));
4209
4401
  var import_graphql16 = require("@tinacms/graphql");
4210
4402
 
4211
4403
  // src/cmds/forestry-migrate/util/index.ts
4212
4404
  var import_fs_extra9 = __toESM(require("fs-extra"));
4213
- var import_path7 = __toESM(require("path"));
4405
+ var import_path8 = __toESM(require("path"));
4214
4406
  var import_js_yaml = __toESM(require("js-yaml"));
4215
4407
  var import_zod = __toESM(require("zod"));
4216
4408
 
@@ -4621,7 +4813,7 @@ var transformForestryFieldsToTinaFields = ({
4621
4813
  return tinaFields;
4622
4814
  };
4623
4815
  var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false }) => {
4624
- const templatePath = import_path7.default.join(
4816
+ const templatePath = import_path8.default.join(
4625
4817
  pathToForestryConfig,
4626
4818
  ".forestry",
4627
4819
  "front_matter",
@@ -4696,8 +4888,8 @@ var generateAllTemplates = async ({
4696
4888
  pathToForestryConfig
4697
4889
  }) => {
4698
4890
  const allTemplates = (await import_fs_extra10.default.readdir(
4699
- import_path8.default.join(pathToForestryConfig, ".forestry", "front_matter", "templates")
4700
- )).map((tem) => import_path8.default.basename(tem, ".yml"));
4891
+ import_path9.default.join(pathToForestryConfig, ".forestry", "front_matter", "templates")
4892
+ )).map((tem) => import_path9.default.basename(tem, ".yml"));
4701
4893
  const templateMap = /* @__PURE__ */ new Map();
4702
4894
  const proms = allTemplates.map(async (tem) => {
4703
4895
  try {
@@ -4839,9 +5031,9 @@ var generateCollectionFromForestrySection = (args) => {
4839
5031
  return c;
4840
5032
  } else if (section.type === "document") {
4841
5033
  const filePath = section.path;
4842
- const extname = import_path8.default.extname(filePath);
4843
- const fileName = import_path8.default.basename(filePath, extname);
4844
- const dir = import_path8.default.dirname(filePath);
5034
+ const extname = import_path9.default.extname(filePath);
5035
+ const fileName = import_path9.default.basename(filePath, extname);
5036
+ const dir = import_path9.default.dirname(filePath);
4845
5037
  const ext = checkExt(extname);
4846
5038
  if (ext) {
4847
5039
  const fields = [];
@@ -4904,7 +5096,7 @@ var generateCollections = async ({
4904
5096
  usingTypescript
4905
5097
  });
4906
5098
  const forestryConfig = await import_fs_extra10.default.readFile(
4907
- import_path8.default.join(pathToForestryConfig, ".forestry", "settings.yml")
5099
+ import_path9.default.join(pathToForestryConfig, ".forestry", "settings.yml")
4908
5100
  );
4909
5101
  rewriteTemplateKeysInDocs({
4910
5102
  templateMap,
@@ -4935,11 +5127,11 @@ var rewriteTemplateKeysInDocs = (args) => {
4935
5127
  const { templateObj } = templateMap.get(templateKey);
4936
5128
  (_a = templateObj == null ? void 0 : templateObj.pages) == null ? void 0 : _a.forEach((page) => {
4937
5129
  try {
4938
- const filePath = import_path8.default.join(page);
5130
+ const filePath = import_path9.default.join(page);
4939
5131
  if (import_fs_extra10.default.lstatSync(filePath).isDirectory()) {
4940
5132
  return;
4941
5133
  }
4942
- const extname = import_path8.default.extname(filePath);
5134
+ const extname = import_path9.default.extname(filePath);
4943
5135
  const fileContent = import_fs_extra10.default.readFileSync(filePath).toString();
4944
5136
  const content = (0, import_graphql16.parseFile)(
4945
5137
  fileContent,
@@ -4971,7 +5163,7 @@ var import_fs_extra13 = __toESM(require("fs-extra"));
4971
5163
  // src/next/commands/codemod-command/index.ts
4972
5164
  var import_clipanion5 = require("clipanion");
4973
5165
  var import_fs_extra11 = __toESM(require("fs-extra"));
4974
- var import_path9 = __toESM(require("path"));
5166
+ var import_path10 = __toESM(require("path"));
4975
5167
  var CodemodCommand = class extends import_clipanion5.Command {
4976
5168
  constructor() {
4977
5169
  super(...arguments);
@@ -5015,7 +5207,7 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
5015
5207
  logger.error(e.message);
5016
5208
  process.exit(1);
5017
5209
  }
5018
- const tinaDestination = import_path9.default.join(configManager.rootPath, "tina");
5210
+ const tinaDestination = import_path10.default.join(configManager.rootPath, "tina");
5019
5211
  if (await import_fs_extra11.default.existsSync(tinaDestination)) {
5020
5212
  logger.info(
5021
5213
  `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.`
@@ -5030,7 +5222,7 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
5030
5222
  };
5031
5223
  var writeGitignore = async (rootPath) => {
5032
5224
  await import_fs_extra11.default.outputFileSync(
5033
- import_path9.default.join(rootPath, "tina", ".gitignore"),
5225
+ import_path10.default.join(rootPath, "tina", ".gitignore"),
5034
5226
  "__generated__"
5035
5227
  );
5036
5228
  };
@@ -5868,8 +6060,8 @@ async function apply({
5868
6060
  await addConfigFile({
5869
6061
  configArgs: {
5870
6062
  config: config2,
5871
- publicFolder: import_path10.default.join(
5872
- import_path10.default.relative(process.cwd(), pathToForestryConfig),
6063
+ publicFolder: import_path11.default.join(
6064
+ import_path11.default.relative(process.cwd(), pathToForestryConfig),
5873
6065
  config2.publicFolder
5874
6066
  ),
5875
6067
  collections,
@@ -5936,18 +6128,18 @@ var createPackageJSON = async () => {
5936
6128
  };
5937
6129
  var createGitignore = async ({ baseDir }) => {
5938
6130
  logger.info(logText("No .gitignore found, creating one"));
5939
- import_fs_extra13.default.outputFileSync(import_path10.default.join(baseDir, ".gitignore"), "node_modules");
6131
+ import_fs_extra13.default.outputFileSync(import_path11.default.join(baseDir, ".gitignore"), "node_modules");
5940
6132
  };
5941
6133
  var updateGitIgnore = async ({
5942
6134
  baseDir,
5943
6135
  items
5944
6136
  }) => {
5945
6137
  logger.info(logText(`Adding ${items.join(",")} to .gitignore`));
5946
- const gitignoreContent = import_fs_extra13.default.readFileSync(import_path10.default.join(baseDir, ".gitignore")).toString();
6138
+ const gitignoreContent = import_fs_extra13.default.readFileSync(import_path11.default.join(baseDir, ".gitignore")).toString();
5947
6139
  const newGitignoreContent = [...gitignoreContent.split("\n"), ...items].join(
5948
6140
  "\n"
5949
6141
  );
5950
- await import_fs_extra13.default.writeFile(import_path10.default.join(baseDir, ".gitignore"), newGitignoreContent);
6142
+ await import_fs_extra13.default.writeFile(import_path11.default.join(baseDir, ".gitignore"), newGitignoreContent);
5951
6143
  };
5952
6144
  var addDependencies = async (config2, env, params) => {
5953
6145
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
@@ -6017,22 +6209,22 @@ var writeGeneratedFile = async ({
6017
6209
  content,
6018
6210
  typescript
6019
6211
  }) => {
6020
- const { exists, path: path13, parentPath } = generatedFile.resolve(typescript);
6212
+ const { exists, path: path14, parentPath } = generatedFile.resolve(typescript);
6021
6213
  if (exists) {
6022
6214
  if (overwrite) {
6023
- logger.info(`Overwriting file at ${path13}... \u2705`);
6024
- import_fs_extra13.default.outputFileSync(path13, content);
6215
+ logger.info(`Overwriting file at ${path14}... \u2705`);
6216
+ import_fs_extra13.default.outputFileSync(path14, content);
6025
6217
  } else {
6026
- logger.info(`Not overwriting file at ${path13}.`);
6218
+ logger.info(`Not overwriting file at ${path14}.`);
6027
6219
  logger.info(
6028
- logText(`Please add the following to ${path13}:
6220
+ logText(`Please add the following to ${path14}:
6029
6221
  ${indentText(content)}}`)
6030
6222
  );
6031
6223
  }
6032
6224
  } else {
6033
- logger.info(`Adding file at ${path13}... \u2705`);
6225
+ logger.info(`Adding file at ${path14}... \u2705`);
6034
6226
  await import_fs_extra13.default.ensureDir(parentPath);
6035
- import_fs_extra13.default.outputFileSync(path13, content);
6227
+ import_fs_extra13.default.outputFileSync(path14, content);
6036
6228
  }
6037
6229
  };
6038
6230
  var addConfigFile = async ({
@@ -6115,7 +6307,7 @@ var addContentFile = async ({
6115
6307
  return () => ({
6116
6308
  exists: env.sampleContentExists,
6117
6309
  path: env.sampleContentPath,
6118
- parentPath: import_path10.default.dirname(env.sampleContentPath)
6310
+ parentPath: import_path11.default.dirname(env.sampleContentPath)
6119
6311
  });
6120
6312
  }
6121
6313
  },
@@ -6138,7 +6330,7 @@ ${titleText(" TinaCMS ")} backend initialized!`));
6138
6330
  return `${x.key}=${x.value || "***"}`;
6139
6331
  }).join("\n") + `
6140
6332
  TINA_PUBLIC_IS_LOCAL=true`;
6141
- const envFile = import_path10.default.join(process.cwd(), ".env");
6333
+ const envFile = import_path11.default.join(process.cwd(), ".env");
6142
6334
  if (!import_fs_extra13.default.existsSync(envFile)) {
6143
6335
  logger.info(`Adding .env file to your project... \u2705`);
6144
6336
  import_fs_extra13.default.writeFileSync(envFile, envFileText);
@@ -6202,7 +6394,7 @@ var addReactiveFile = {
6202
6394
  dataLayer
6203
6395
  }) => {
6204
6396
  var _a, _b;
6205
- const packageJsonPath = import_path10.default.join(baseDir, "package.json");
6397
+ const packageJsonPath = import_path11.default.join(baseDir, "package.json");
6206
6398
  await writeGeneratedFile({
6207
6399
  generatedFile,
6208
6400
  typescript: config2.typescript,