@tinacms/cli 0.0.0-9594668-20241223035907 → 0.0.0-9931d5a-20250106011423

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -41,12 +45,12 @@ var import_chokidar = __toESM(require("chokidar"));
41
45
  var import_graphql10 = require("@tinacms/graphql");
42
46
 
43
47
  // src/next/config-manager.ts
44
- var import_fs_extra2 = __toESM(require("fs-extra"));
48
+ var import_fs_extra = __toESM(require("fs-extra"));
45
49
  var import_path = __toESM(require("path"));
46
50
  var import_os = __toESM(require("os"));
47
51
  var esbuild = __toESM(require("esbuild"));
48
52
  var dotenv = __toESM(require("dotenv"));
49
- var import_normalize_path2 = __toESM(require("normalize-path"));
53
+ var import_normalize_path = __toESM(require("normalize-path"));
50
54
  var import_chalk2 = __toESM(require("chalk"));
51
55
 
52
56
  // src/logger/index.ts
@@ -57,7 +61,10 @@ function isUnicodeSupported() {
57
61
  if (process.platform !== "win32") {
58
62
  return process.env.TERM !== "linux";
59
63
  }
60
- return Boolean(process.env.CI) || Boolean(process.env.WT_SESSION) || Boolean(process.env.TERMINUS_SUBLIME) || process.env.ConEmuTask === "{cmd::Cmder}" || process.env.TERM_PROGRAM === "Terminus-Sublime" || process.env.TERM_PROGRAM === "vscode" || process.env.TERM === "xterm-256color" || process.env.TERM === "alacritty" || process.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
64
+ return Boolean(process.env.CI) || Boolean(process.env.WT_SESSION) || // Windows Terminal
65
+ Boolean(process.env.TERMINUS_SUBLIME) || // Terminus (<0.2.27)
66
+ process.env.ConEmuTask === "{cmd::Cmder}" || // ConEmu and cmder
67
+ process.env.TERM_PROGRAM === "Terminus-Sublime" || process.env.TERM_PROGRAM === "vscode" || process.env.TERM === "xterm-256color" || process.env.TERM === "alacritty" || process.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
61
68
  }
62
69
 
63
70
  // src/logger/index.ts
@@ -157,490 +164,6 @@ var S_SUCCESS = s("\u25C6", "*");
157
164
  var S_WARN = s("\u25B2", "!");
158
165
  var S_ERROR = s("\u25A0", "x");
159
166
 
160
- // src/next/vite/index.ts
161
- var import_node_path2 = __toESM(require("path"));
162
- var import_plugin_react = __toESM(require("@vitejs/plugin-react"));
163
- var import_fs_extra = __toESM(require("fs-extra"));
164
- var import_normalize_path = __toESM(require("normalize-path"));
165
- var import_vite = require("vite");
166
-
167
- // src/next/vite/tailwind.ts
168
- var import_node_path = __toESM(require("path"));
169
- var import_aspect_ratio = __toESM(require("@tailwindcss/aspect-ratio"));
170
- var import_container_queries = __toESM(require("@tailwindcss/container-queries"));
171
- var import_typography = __toESM(require("@tailwindcss/typography"));
172
- var import_tailwindcss = __toESM(require("tailwindcss"));
173
- var import_defaultTheme = __toESM(require("tailwindcss/defaultTheme.js"));
174
- var tinaTailwind = (spaPath, prebuildFilePath) => {
175
- return {
176
- name: "vite-plugin-tina",
177
- config: (viteConfig) => {
178
- const plugins = [];
179
- const content = [
180
- import_node_path.default.join(spaPath, "src/**/*.{vue,js,ts,jsx,tsx,svelte}"),
181
- prebuildFilePath,
182
- require.resolve("tinacms")
183
- ];
184
- const tw = (0, import_tailwindcss.default)({
185
- theme: {
186
- columns: {
187
- auto: "auto",
188
- 1: "1",
189
- 2: "2",
190
- 3: "3",
191
- 4: "4",
192
- 5: "5",
193
- 6: "6",
194
- 7: "7",
195
- 8: "8",
196
- 9: "9",
197
- 10: "10",
198
- 11: "11",
199
- 12: "12",
200
- "3xs": "256px",
201
- "2xs": "288px",
202
- xs: "320px",
203
- sm: "384px",
204
- md: "448px",
205
- lg: "512px",
206
- xl: "576px",
207
- "2xl": "672px",
208
- "3xl": "768px",
209
- "4xl": "896px",
210
- "5xl": "1024px",
211
- "6xl": "1152px",
212
- "7xl": "1280px"
213
- },
214
- spacing: {
215
- px: "1px",
216
- 0: "0px",
217
- 0.5: "2px",
218
- 1: "4px",
219
- 1.5: "6px",
220
- 2: "8px",
221
- 2.5: "10px",
222
- 3: "12px",
223
- 3.5: "14px",
224
- 4: "16px",
225
- 5: "20px",
226
- 6: "24px",
227
- 7: "28px",
228
- 8: "32px",
229
- 9: "36px",
230
- 10: "40px",
231
- 11: "44px",
232
- 12: "48px",
233
- 14: "56px",
234
- 16: "64px",
235
- 18: "72px",
236
- 20: "80px",
237
- 24: "96px",
238
- 28: "114px",
239
- 32: "128px",
240
- 36: "144px",
241
- 40: "160px",
242
- 44: "176px",
243
- 48: "192px",
244
- 52: "208px",
245
- 56: "224px",
246
- 60: "240px",
247
- 64: "256px",
248
- 72: "288px",
249
- 80: "320px",
250
- 96: "384px"
251
- },
252
- borderRadius: {
253
- none: "0px",
254
- sm: "2px",
255
- DEFAULT: "4px",
256
- md: "6px",
257
- lg: "8px",
258
- xl: "12px",
259
- "2xl": "16px",
260
- "3xl": "24px",
261
- full: "9999px"
262
- },
263
- borderWidth: {
264
- DEFAULT: "1px",
265
- 0: "0",
266
- 2: "2px",
267
- 3: "3px",
268
- 4: "4px",
269
- 6: "6px",
270
- 8: "8px"
271
- },
272
- fontSize: {
273
- xs: ["13px", { lineHeight: "1.33" }],
274
- sm: ["14px", { lineHeight: "1.43" }],
275
- base: ["16px", { lineHeight: "1.5" }],
276
- md: ["16px", { lineHeight: "1.5" }],
277
- lg: ["18px", { lineHeight: "1.55" }],
278
- xl: ["20px", { lineHeight: "1.4" }],
279
- "2xl": ["24px", { lineHeight: "1.33" }],
280
- "3xl": ["30px", { lineHeight: "1.2" }],
281
- "4xl": ["36px", { lineHeight: "1.1" }],
282
- "5xl": ["48px", { lineHeight: "1" }],
283
- "6xl": ["60px", { lineHeight: "1" }],
284
- "7xl": ["72px", { lineHeight: "1" }],
285
- "8xl": ["96px", { lineHeight: "1" }],
286
- "9xl": ["128px", { lineHeight: "1" }]
287
- },
288
- opacity: {
289
- 0: "0",
290
- 5: ".05",
291
- 7: ".07",
292
- 10: ".1",
293
- 15: ".15",
294
- 20: ".2",
295
- 25: ".25",
296
- 30: ".3",
297
- 40: ".4",
298
- 50: ".5",
299
- 60: ".6",
300
- 70: ".7",
301
- 75: ".75",
302
- 80: ".8",
303
- 90: ".9",
304
- 100: "1"
305
- },
306
- zIndex: {
307
- "-1": "-1",
308
- base: "9000",
309
- panel: "9400",
310
- menu: "9800",
311
- chrome: "10200",
312
- overlay: "10600",
313
- modal: "10800",
314
- 0: "0",
315
- 10: "10",
316
- 20: "20",
317
- 30: "30",
318
- 40: "40",
319
- 25: "25",
320
- 50: "50",
321
- 75: "75",
322
- 100: "100",
323
- auto: "auto"
324
- },
325
- extend: {
326
- scale: {
327
- 97: ".97",
328
- 103: "1.03"
329
- },
330
- transitionDuration: {
331
- 0: "0ms",
332
- 2e3: "2000ms"
333
- },
334
- boxShadow: {
335
- xs: "0 0 0 1px rgba(0, 0, 0, 0.05)",
336
- outline: "0 0 0 3px rgba(66, 153, 225, 0.5)"
337
- },
338
- colors: {
339
- blue: {
340
- 50: "#DCEEFF",
341
- 100: "#B4DBFF",
342
- 200: "#85C5FE",
343
- 300: "#4EABFE",
344
- 400: "#2296fe",
345
- 500: "#0084FF",
346
- 600: "#0574e4",
347
- 700: "#0D5DBD",
348
- 800: "#144696",
349
- 900: "#1D2C6C",
350
- 1e3: "#241748"
351
- },
352
- gray: {
353
- 50: "#F6F6F9",
354
- 100: "#EDECF3",
355
- 150: "#E6E3EF",
356
- 200: "#E1DDEC",
357
- 250: "#C9C5D5",
358
- 300: "#b2adbe",
359
- 400: "#918c9e",
360
- 500: "#716c7f",
361
- 600: "#565165",
362
- 700: "#433e52",
363
- 800: "#363145",
364
- 900: "#252336",
365
- 1e3: "#1c1b2e"
366
- },
367
- orange: {
368
- 400: "#EB6337",
369
- 500: "#EC4815",
370
- 600: "#DC4419"
371
- },
372
- background: "#FFFFFF",
373
- foreground: "#0A0A0A",
374
- muted: "#F5F5F5",
375
- "muted-foreground": "#737373",
376
- popover: "#FFFFFF",
377
- "popover-foreground": "#0A0A0A",
378
- card: "#FFFFFF",
379
- "card-foreground": "#0A0A0A",
380
- border: "#E5E5E5",
381
- input: "#E5E5E5",
382
- primary: "#171717",
383
- "primary-foreground": "#FAFAFA",
384
- secondary: "#F5F5F5",
385
- "secondary-foreground": "#171717",
386
- accent: "#F5F5F5",
387
- "accent-foreground": "#171717",
388
- destructive: "#FF3B3B",
389
- "destructive-foreground": "#FAFAFA",
390
- ring: "#0A0A0A"
391
- },
392
- fontFamily: {
393
- sans: ["Inter", ...import_defaultTheme.default.fontFamily.sans]
394
- },
395
- lineHeight: {
396
- 3: "12px",
397
- 4: "16px",
398
- 5: "20px",
399
- 6: "24px",
400
- 7: "28px",
401
- 8: "32px",
402
- 9: "36px",
403
- 10: "40px"
404
- },
405
- maxWidth: {
406
- form: "900px"
407
- },
408
- screens: {
409
- xs: "320px",
410
- sm: "560px",
411
- md: "720px",
412
- lg: "1030px"
413
- }
414
- }
415
- },
416
- content,
417
- plugins: [
418
- (0, import_typography.default)({ className: "tina-prose" }),
419
- import_aspect_ratio.default,
420
- import_container_queries.default
421
- ]
422
- });
423
- plugins.push(tw);
424
- return {
425
- css: {
426
- postcss: {
427
- plugins
428
- }
429
- }
430
- };
431
- }
432
- };
433
- };
434
-
435
- // src/next/vite/index.ts
436
- async function listFilesRecursively({
437
- directoryPath,
438
- config: config2,
439
- roothPath
440
- }) {
441
- const fullDirectoryPath = import_node_path2.default.join(
442
- roothPath,
443
- config2.publicFolder,
444
- directoryPath
445
- );
446
- const exists = await import_fs_extra.default.pathExists(fullDirectoryPath);
447
- if (!exists) {
448
- return { "0": [] };
449
- }
450
- const items = await import_fs_extra.default.readdir(fullDirectoryPath);
451
- const staticMediaItems = [];
452
- for (const item of items) {
453
- const itemPath = import_node_path2.default.join(fullDirectoryPath, item);
454
- const stats = await import_fs_extra.default.promises.lstat(itemPath);
455
- const staticMediaItem = {
456
- id: item,
457
- filename: item,
458
- type: stats.isDirectory() ? "dir" : "file",
459
- directory: `${directoryPath.replace(config2.mediaRoot, "")}`,
460
- src: `/${import_node_path2.default.join(directoryPath, item)}`,
461
- thumbnails: {
462
- "75x75": `/${import_node_path2.default.join(directoryPath, item)}`,
463
- "400x400": `/${import_node_path2.default.join(directoryPath, item)}`,
464
- "1000x1000": `/${import_node_path2.default.join(directoryPath, item)}`
465
- }
466
- };
467
- if (stats.isDirectory()) {
468
- staticMediaItem.children = await listFilesRecursively({
469
- directoryPath: import_node_path2.default.join(directoryPath, item),
470
- config: config2,
471
- roothPath
472
- });
473
- }
474
- staticMediaItems.push(staticMediaItem);
475
- }
476
- function chunkArrayIntoObject(array, chunkSize) {
477
- const result = {};
478
- for (let i = 0; i < array.length; i += chunkSize) {
479
- const chunkKey = `${i / chunkSize * 20}`;
480
- result[chunkKey] = array.slice(i, i + chunkSize);
481
- }
482
- return result;
483
- }
484
- return chunkArrayIntoObject(staticMediaItems, 20);
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
- };
501
- var createConfig = async ({
502
- configManager,
503
- database,
504
- apiURL,
505
- plugins = [],
506
- noWatch,
507
- rollupOptions,
508
- viteConfigEnv
509
- }) => {
510
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
511
- const projectConfig = await loadProjectConfig({
512
- rootPath: configManager.rootPath,
513
- viteConfigEnv
514
- });
515
- const publicEnv = {};
516
- Object.keys(process.env).forEach((key) => {
517
- if (key.startsWith("TINA_PUBLIC_") || key.startsWith("NEXT_PUBLIC_") || key === "NODE_ENV" || key === "HEAD") {
518
- try {
519
- if (typeof process.env[key] === "string") {
520
- publicEnv[key] = process.env[key];
521
- } else {
522
- publicEnv[key] = JSON.stringify(process.env[key]);
523
- }
524
- } catch (error) {
525
- console.warn(
526
- `Could not stringify public env process.env.${key} env variable`
527
- );
528
- console.warn(error);
529
- }
530
- }
531
- });
532
- const staticMediaPath = import_node_path2.default.join(
533
- configManager.generatedFolderPath,
534
- "static-media.json"
535
- );
536
- if ((_b = (_a = configManager.config.media) == null ? void 0 : _a.tina) == null ? void 0 : _b.static) {
537
- const staticMedia = await listFilesRecursively({
538
- directoryPath: ((_c = configManager.config.media.tina) == null ? void 0 : _c.mediaRoot) || "",
539
- config: configManager.config.media.tina,
540
- roothPath: configManager.rootPath
541
- });
542
- await import_fs_extra.default.outputFile(staticMediaPath, JSON.stringify(staticMedia, null, 2));
543
- } else {
544
- await import_fs_extra.default.outputFile(staticMediaPath, `[]`);
545
- }
546
- const alias = {
547
- TINA_IMPORT: configManager.prebuildFilePath,
548
- SCHEMA_IMPORT: configManager.generatedGraphQLJSONPath,
549
- STATIC_MEDIA_IMPORT: staticMediaPath,
550
- crypto: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
551
- fs: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
552
- os: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
553
- path: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts")
554
- };
555
- if (configManager.shouldSkipSDK()) {
556
- alias["CLIENT_IMPORT"] = import_node_path2.default.join(
557
- configManager.spaRootPath,
558
- "src",
559
- "dummy-client.ts"
560
- );
561
- } else {
562
- alias["CLIENT_IMPORT"] = configManager.isUsingTs() ? configManager.generatedTypesTSFilePath : configManager.generatedTypesJSFilePath;
563
- }
564
- let basePath;
565
- if (configManager.config.build.basePath) {
566
- basePath = configManager.config.build.basePath;
567
- }
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
167
  // src/next/config-manager.ts
645
168
  var TINA_FOLDER = "tina";
646
169
  var LEGACY_TINA_FOLDER = ".tina";
@@ -655,7 +178,7 @@ var ConfigManager = class {
655
178
  tinaGraphQLVersion,
656
179
  legacyNoSDK
657
180
  }) {
658
- this.rootPath = (0, import_normalize_path2.default)(rootPath);
181
+ this.rootPath = (0, import_normalize_path.default)(rootPath);
659
182
  this.tinaGraphQLVersionFromCLI = tinaGraphQLVersion;
660
183
  this.legacyNoSDK = legacyNoSDK;
661
184
  }
@@ -696,7 +219,7 @@ var ConfigManager = class {
696
219
  this.generatedCachePath = import_path.default.join(
697
220
  this.generatedFolderPath,
698
221
  ".cache",
699
- String(new Date().getTime())
222
+ String((/* @__PURE__ */ new Date()).getTime())
700
223
  );
701
224
  this.generatedGraphQLGQLPath = import_path.default.join(
702
225
  this.generatedFolderPath,
@@ -766,13 +289,13 @@ var ConfigManager = class {
766
289
  this.generatedFolderPath,
767
290
  "databaseClient.js"
768
291
  );
769
- const clientExists = this.isUsingTs() ? await import_fs_extra2.default.pathExists(this.generatedClientTSFilePath) : await import_fs_extra2.default.pathExists(this.generatedClientJSFilePath);
292
+ const clientExists = this.isUsingTs() ? await import_fs_extra.default.pathExists(this.generatedClientTSFilePath) : await import_fs_extra.default.pathExists(this.generatedClientJSFilePath);
770
293
  if (!clientExists) {
771
294
  const file = "export default ()=>({})\nexport const client = ()=>({})";
772
295
  if (this.isUsingTs()) {
773
- await import_fs_extra2.default.outputFile(this.generatedClientTSFilePath, file);
296
+ await import_fs_extra.default.outputFile(this.generatedClientTSFilePath, file);
774
297
  } else {
775
- await import_fs_extra2.default.outputFile(this.generatedClientJSFilePath, file);
298
+ await import_fs_extra.default.outputFile(this.generatedClientJSFilePath, file);
776
299
  }
777
300
  }
778
301
  const { config: config2, prebuildPath, watchList } = await this.loadConfigFile(
@@ -797,7 +320,7 @@ var ConfigManager = class {
797
320
  this.config.localContentPath || ""
798
321
  );
799
322
  if (this.config.localContentPath) {
800
- const localContentPathExists = await import_fs_extra2.default.pathExists(fullLocalContentPath);
323
+ const localContentPathExists = await import_fs_extra.default.pathExists(fullLocalContentPath);
801
324
  if (localContentPathExists) {
802
325
  logger.info(`Using separate content repo at ${fullLocalContentPath}`);
803
326
  this.contentRootPath = fullLocalContentPath;
@@ -823,13 +346,13 @@ var ConfigManager = class {
823
346
  }
824
347
  async getTinaFolderPath(rootPath) {
825
348
  const tinaFolderPath = import_path.default.join(rootPath, TINA_FOLDER);
826
- const tinaFolderExists = await import_fs_extra2.default.pathExists(tinaFolderPath);
349
+ const tinaFolderExists = await import_fs_extra.default.pathExists(tinaFolderPath);
827
350
  if (tinaFolderExists) {
828
351
  this.isUsingLegacyFolder = false;
829
352
  return tinaFolderPath;
830
353
  }
831
354
  const legacyFolderPath = import_path.default.join(rootPath, LEGACY_TINA_FOLDER);
832
- const legacyFolderExists = await import_fs_extra2.default.pathExists(legacyFolderPath);
355
+ const legacyFolderExists = await import_fs_extra.default.pathExists(legacyFolderPath);
833
356
  if (legacyFolderExists) {
834
357
  this.isUsingLegacyFolder = true;
835
358
  return legacyFolderPath;
@@ -848,7 +371,7 @@ var ConfigManager = class {
848
371
  patch: version2[2] || "x"
849
372
  };
850
373
  }
851
- const generatedSchema = import_fs_extra2.default.readJSONSync(this.generatedSchemaJSONPath);
374
+ const generatedSchema = import_fs_extra.default.readJSONSync(this.generatedSchemaJSONPath);
852
375
  if (!generatedSchema || !(typeof (generatedSchema == null ? void 0 : generatedSchema.version) !== "undefined")) {
853
376
  throw new Error(
854
377
  `Can not find Tina GraphQL version in ${this.generatedSchemaJSONPath}`
@@ -883,6 +406,9 @@ var ConfigManager = class {
883
406
  }
884
407
  throw `No path provided to print`;
885
408
  }
409
+ /**
410
+ * Given a filepath without an extension, find the first match (eg. tsx, ts, jsx, js)
411
+ */
886
412
  async getPathWithExtension(filepath) {
887
413
  const extensions = ["tsx", "ts", "jsx", "js"];
888
414
  let result;
@@ -892,7 +418,7 @@ var ConfigManager = class {
892
418
  return;
893
419
  }
894
420
  const filepathWithExtension = `${filepath}.${ext}`;
895
- const exists = import_fs_extra2.default.existsSync(filepathWithExtension);
421
+ const exists = import_fs_extra.default.existsSync(filepathWithExtension);
896
422
  if (exists) {
897
423
  result = filepathWithExtension;
898
424
  }
@@ -911,11 +437,10 @@ var ConfigManager = class {
911
437
  loader: loaders
912
438
  });
913
439
  const result = require(outfile);
914
- import_fs_extra2.default.removeSync(outfile);
440
+ import_fs_extra.default.removeSync(outfile);
915
441
  return result.default;
916
442
  }
917
443
  async loadConfigFile(generatedFolderPath, configFilePath) {
918
- var _a;
919
444
  const tmpdir = import_path.default.join(import_os.default.tmpdir(), Date.now().toString());
920
445
  const preBuildConfigPath = import_path.default.join(
921
446
  this.generatedFolderPath,
@@ -924,9 +449,7 @@ var ConfigManager = class {
924
449
  const outfile = import_path.default.join(tmpdir, "config.build.jsx");
925
450
  const outfile2 = import_path.default.join(tmpdir, "config.build.js");
926
451
  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, "{}");
452
+ import_fs_extra.default.outputFileSync(tempTSConfigFile, "{}");
930
453
  const result2 = await esbuild.build({
931
454
  entryPoints: [configFilePath],
932
455
  bundle: true,
@@ -954,12 +477,12 @@ var ConfigManager = class {
954
477
  logLevel: "silent",
955
478
  platform: "node",
956
479
  outfile,
957
- loader: loaders,
958
- alias: (_a = viteConfig.config.resolve) == null ? void 0 : _a.alias
480
+ loader: loaders
959
481
  });
960
482
  await esbuild.build({
961
483
  entryPoints: [outfile],
962
484
  bundle: true,
485
+ // Suppress warning about comparison with -0 from client module
963
486
  logLevel: "silent",
964
487
  platform: "node",
965
488
  outfile: outfile2,
@@ -973,8 +496,8 @@ var ConfigManager = class {
973
496
  console.error(e);
974
497
  throw e;
975
498
  }
976
- import_fs_extra2.default.removeSync(outfile);
977
- import_fs_extra2.default.removeSync(outfile2);
499
+ import_fs_extra.default.removeSync(outfile);
500
+ import_fs_extra.default.removeSync(outfile2);
978
501
  return {
979
502
  config: result.default,
980
503
  prebuildPath: preBuildConfigPath,
@@ -1008,109 +531,578 @@ var loaders = {
1008
531
  ".tsx": "tsx"
1009
532
  };
1010
533
 
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;
534
+ // src/next/commands/dev-command/html.ts
535
+ var errorHTML = `<style type="text/css">
536
+ #no-assets-placeholder body {
537
+ font-family: sans-serif;
538
+ font-size: 16px;
539
+ line-height: 1.4;
540
+ color: #333;
541
+ background-color: #f5f5f5;
542
+ }
543
+ #no-assets-placeholder {
544
+ max-width: 600px;
545
+ margin: 0 auto;
546
+ padding: 40px;
547
+ text-align: center;
548
+ background-color: #fff;
549
+ box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.1);
550
+ }
551
+ #no-assets-placeholder h1 {
552
+ font-size: 24px;
553
+ margin-bottom: 20px;
554
+ }
555
+ #no-assets-placeholder p {
556
+ margin-bottom: 10px;
557
+ }
558
+ #no-assets-placeholder a {
559
+ color: #0077cc;
560
+ text-decoration: none;
561
+ }
562
+ #no-assets-placeholder a:hover {
563
+ text-decoration: underline;
564
+ }
565
+ </style>
566
+ <div id="no-assets-placeholder">
567
+ <h1>Failed loading TinaCMS assets</h1>
568
+ <p>
569
+ Your TinaCMS configuration may be misconfigured, and we could not load
570
+ the assets for this page.
571
+ </p>
572
+ <p>
573
+ 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.
574
+ </p>
575
+ </div>
576
+ </div>`.trim().replace(/[\r\n\s]+/g, " ");
577
+ var devHTML = (port) => `<!DOCTYPE html>
578
+ <html lang="en">
579
+ <head>
580
+ <meta charset="UTF-8" />
581
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
582
+ <title>TinaCMS</title>
583
+ </head>
584
+
585
+ <!-- if development -->
586
+ <script type="module">
587
+ import RefreshRuntime from 'http://localhost:${port}/@react-refresh'
588
+ RefreshRuntime.injectIntoGlobalHook(window)
589
+ window.$RefreshReg$ = () => {}
590
+ window.$RefreshSig$ = () => (type) => type
591
+ window.__vite_plugin_react_preamble_installed__ = true
592
+ </script>
593
+ <script type="module" src="http://localhost:${port}/@vite/client"></script>
594
+ <script>
595
+ function handleLoadError() {
596
+ // Assets have failed to load
597
+ document.getElementById('root').innerHTML = '${errorHTML}';
598
+ }
599
+ </script>
600
+ <script
601
+ type="module"
602
+ src="http://localhost:${port}/src/main.tsx"
603
+ onerror="handleLoadError()"
604
+ ></script>
605
+ <body class="tina-tailwind">
606
+ <div id="root"></div>
607
+ </body>
608
+ </html>`;
609
+
610
+ // src/utils/theme.ts
611
+ var import_chalk3 = __toESM(require("chalk"));
612
+ var successText = import_chalk3.default.bold.green;
613
+ var focusText = import_chalk3.default.bold;
614
+ var dangerText = import_chalk3.default.bold.red;
615
+ var neutralText = import_chalk3.default.bold.cyan;
616
+ var linkText = import_chalk3.default.bold.cyan;
617
+ var labelText = import_chalk3.default.bold;
618
+ var cmdText = import_chalk3.default.inverse;
619
+ var indentedCmd = (str) => {
620
+ return ` \u2503 ` + str;
621
+ };
622
+ var indentText = (str) => {
623
+ return String(str).split("\n").map((line) => ` ${line}`).join("\n");
624
+ };
625
+ var logText = import_chalk3.default.italic.gray;
626
+ var warnText = import_chalk3.default.yellowBright.bgBlack;
627
+ var titleText = import_chalk3.default.bgHex("d2f1f8").hex("ec4816");
628
+ var CONFIRMATION_TEXT = import_chalk3.default.dim("enter to confirm");
629
+
630
+ // src/next/commands/dev-command/server/index.ts
631
+ var import_vite3 = require("vite");
632
+
633
+ // src/next/vite/index.ts
634
+ var import_node_path2 = __toESM(require("path"));
635
+ var import_plugin_react = __toESM(require("@vitejs/plugin-react"));
636
+ var import_fs_extra2 = __toESM(require("fs-extra"));
637
+ var import_normalize_path2 = __toESM(require("normalize-path"));
638
+ var import_vite = require("vite");
639
+
640
+ // src/next/vite/tailwind.ts
641
+ var import_node_path = __toESM(require("path"));
642
+ var import_aspect_ratio = __toESM(require("@tailwindcss/aspect-ratio"));
643
+ var import_container_queries = __toESM(require("@tailwindcss/container-queries"));
644
+ var import_typography = __toESM(require("@tailwindcss/typography"));
645
+ var import_tailwindcss = __toESM(require("tailwindcss"));
646
+ var import_defaultTheme = __toESM(require("tailwindcss/defaultTheme.js"));
647
+ var tinaTailwind = (spaPath, prebuildFilePath) => {
648
+ return {
649
+ name: "vite-plugin-tina",
650
+ // @ts-ignore
651
+ config: (viteConfig) => {
652
+ const plugins = [];
653
+ const content = [
654
+ import_node_path.default.join(spaPath, "src/**/*.{vue,js,ts,jsx,tsx,svelte}"),
655
+ prebuildFilePath,
656
+ require.resolve("tinacms")
657
+ ];
658
+ const tw = (0, import_tailwindcss.default)({
659
+ theme: {
660
+ columns: {
661
+ auto: "auto",
662
+ 1: "1",
663
+ 2: "2",
664
+ 3: "3",
665
+ 4: "4",
666
+ 5: "5",
667
+ 6: "6",
668
+ 7: "7",
669
+ 8: "8",
670
+ 9: "9",
671
+ 10: "10",
672
+ 11: "11",
673
+ 12: "12",
674
+ "3xs": "256px",
675
+ "2xs": "288px",
676
+ xs: "320px",
677
+ sm: "384px",
678
+ md: "448px",
679
+ lg: "512px",
680
+ xl: "576px",
681
+ "2xl": "672px",
682
+ "3xl": "768px",
683
+ "4xl": "896px",
684
+ "5xl": "1024px",
685
+ "6xl": "1152px",
686
+ "7xl": "1280px"
687
+ },
688
+ spacing: {
689
+ px: "1px",
690
+ 0: "0px",
691
+ 0.5: "2px",
692
+ 1: "4px",
693
+ 1.5: "6px",
694
+ 2: "8px",
695
+ 2.5: "10px",
696
+ 3: "12px",
697
+ 3.5: "14px",
698
+ 4: "16px",
699
+ 5: "20px",
700
+ 6: "24px",
701
+ 7: "28px",
702
+ 8: "32px",
703
+ 9: "36px",
704
+ 10: "40px",
705
+ 11: "44px",
706
+ 12: "48px",
707
+ 14: "56px",
708
+ 16: "64px",
709
+ 18: "72px",
710
+ 20: "80px",
711
+ 24: "96px",
712
+ 28: "114px",
713
+ 32: "128px",
714
+ 36: "144px",
715
+ 40: "160px",
716
+ 44: "176px",
717
+ 48: "192px",
718
+ 52: "208px",
719
+ 56: "224px",
720
+ 60: "240px",
721
+ 64: "256px",
722
+ 72: "288px",
723
+ 80: "320px",
724
+ 96: "384px"
725
+ },
726
+ borderRadius: {
727
+ none: "0px",
728
+ sm: "2px",
729
+ DEFAULT: "4px",
730
+ md: "6px",
731
+ lg: "8px",
732
+ xl: "12px",
733
+ "2xl": "16px",
734
+ "3xl": "24px",
735
+ full: "9999px"
736
+ },
737
+ borderWidth: {
738
+ DEFAULT: "1px",
739
+ 0: "0",
740
+ 2: "2px",
741
+ 3: "3px",
742
+ 4: "4px",
743
+ 6: "6px",
744
+ 8: "8px"
745
+ },
746
+ fontSize: {
747
+ xs: ["13px", { lineHeight: "1.33" }],
748
+ sm: ["14px", { lineHeight: "1.43" }],
749
+ base: ["16px", { lineHeight: "1.5" }],
750
+ md: ["16px", { lineHeight: "1.5" }],
751
+ lg: ["18px", { lineHeight: "1.55" }],
752
+ xl: ["20px", { lineHeight: "1.4" }],
753
+ "2xl": ["24px", { lineHeight: "1.33" }],
754
+ "3xl": ["30px", { lineHeight: "1.2" }],
755
+ "4xl": ["36px", { lineHeight: "1.1" }],
756
+ "5xl": ["48px", { lineHeight: "1" }],
757
+ "6xl": ["60px", { lineHeight: "1" }],
758
+ "7xl": ["72px", { lineHeight: "1" }],
759
+ "8xl": ["96px", { lineHeight: "1" }],
760
+ "9xl": ["128px", { lineHeight: "1" }]
761
+ },
762
+ opacity: {
763
+ 0: "0",
764
+ 5: ".05",
765
+ 7: ".07",
766
+ 10: ".1",
767
+ 15: ".15",
768
+ 20: ".2",
769
+ 25: ".25",
770
+ 30: ".3",
771
+ 40: ".4",
772
+ 50: ".5",
773
+ 60: ".6",
774
+ 70: ".7",
775
+ 75: ".75",
776
+ 80: ".8",
777
+ 90: ".9",
778
+ 100: "1"
779
+ },
780
+ zIndex: {
781
+ "-1": "-1",
782
+ base: "9000",
783
+ panel: "9400",
784
+ menu: "9800",
785
+ chrome: "10200",
786
+ overlay: "10600",
787
+ modal: "10800",
788
+ 0: "0",
789
+ 10: "10",
790
+ 20: "20",
791
+ 30: "30",
792
+ 40: "40",
793
+ 25: "25",
794
+ 50: "50",
795
+ 75: "75",
796
+ 100: "100",
797
+ auto: "auto"
798
+ },
799
+ extend: {
800
+ scale: {
801
+ 97: ".97",
802
+ 103: "1.03"
803
+ },
804
+ transitionDuration: {
805
+ 0: "0ms",
806
+ 2e3: "2000ms"
807
+ },
808
+ boxShadow: {
809
+ xs: "0 0 0 1px rgba(0, 0, 0, 0.05)",
810
+ outline: "0 0 0 3px rgba(66, 153, 225, 0.5)"
811
+ },
812
+ colors: {
813
+ blue: {
814
+ 50: "#DCEEFF",
815
+ 100: "#B4DBFF",
816
+ 200: "#85C5FE",
817
+ 300: "#4EABFE",
818
+ 400: "#2296fe",
819
+ 500: "#0084FF",
820
+ 600: "#0574e4",
821
+ 700: "#0D5DBD",
822
+ 800: "#144696",
823
+ 900: "#1D2C6C",
824
+ 1e3: "#241748"
825
+ },
826
+ gray: {
827
+ 50: "#F6F6F9",
828
+ 100: "#EDECF3",
829
+ 150: "#E6E3EF",
830
+ 200: "#E1DDEC",
831
+ 250: "#C9C5D5",
832
+ 300: "#b2adbe",
833
+ 400: "#918c9e",
834
+ 500: "#716c7f",
835
+ 600: "#565165",
836
+ 700: "#433e52",
837
+ 800: "#363145",
838
+ 900: "#252336",
839
+ 1e3: "#1c1b2e"
840
+ },
841
+ orange: {
842
+ 400: "#EB6337",
843
+ 500: "#EC4815",
844
+ 600: "#DC4419"
845
+ },
846
+ background: "#FFFFFF",
847
+ foreground: "#0A0A0A",
848
+ muted: "#F5F5F5",
849
+ "muted-foreground": "#737373",
850
+ popover: "#FFFFFF",
851
+ "popover-foreground": "#0A0A0A",
852
+ card: "#FFFFFF",
853
+ "card-foreground": "#0A0A0A",
854
+ border: "#E5E5E5",
855
+ input: "#E5E5E5",
856
+ primary: "#171717",
857
+ "primary-foreground": "#FAFAFA",
858
+ secondary: "#F5F5F5",
859
+ "secondary-foreground": "#171717",
860
+ accent: "#F5F5F5",
861
+ "accent-foreground": "#171717",
862
+ destructive: "#FF3B3B",
863
+ "destructive-foreground": "#FAFAFA",
864
+ ring: "#0A0A0A"
865
+ },
866
+ fontFamily: {
867
+ sans: ["Inter", ...import_defaultTheme.default.fontFamily.sans]
868
+ },
869
+ lineHeight: {
870
+ 3: "12px",
871
+ 4: "16px",
872
+ 5: "20px",
873
+ 6: "24px",
874
+ 7: "28px",
875
+ 8: "32px",
876
+ 9: "36px",
877
+ 10: "40px"
878
+ },
879
+ maxWidth: {
880
+ form: "900px"
881
+ },
882
+ screens: {
883
+ xs: "320px",
884
+ sm: "560px",
885
+ md: "720px",
886
+ lg: "1030px"
887
+ }
888
+ }
889
+ },
890
+ content,
891
+ plugins: [
892
+ (0, import_typography.default)({ className: "tina-prose" }),
893
+ import_aspect_ratio.default,
894
+ import_container_queries.default
895
+ ]
896
+ });
897
+ plugins.push(tw);
898
+ return {
899
+ css: {
900
+ postcss: {
901
+ plugins
902
+ }
903
+ }
904
+ };
905
+ }
906
+ };
907
+ };
908
+
909
+ // src/next/vite/index.ts
910
+ async function listFilesRecursively({
911
+ directoryPath,
912
+ config: config2,
913
+ roothPath
914
+ }) {
915
+ const fullDirectoryPath = import_node_path2.default.join(
916
+ roothPath,
917
+ config2.publicFolder,
918
+ directoryPath
919
+ );
920
+ const exists = await import_fs_extra2.default.pathExists(fullDirectoryPath);
921
+ if (!exists) {
922
+ return { "0": [] };
923
+ }
924
+ const items = await import_fs_extra2.default.readdir(fullDirectoryPath);
925
+ const staticMediaItems = [];
926
+ for (const item of items) {
927
+ const itemPath = import_node_path2.default.join(fullDirectoryPath, item);
928
+ const stats = await import_fs_extra2.default.promises.lstat(itemPath);
929
+ const staticMediaItem = {
930
+ id: item,
931
+ filename: item,
932
+ type: stats.isDirectory() ? "dir" : "file",
933
+ directory: `${directoryPath.replace(config2.mediaRoot, "")}`,
934
+ src: `/${import_node_path2.default.join(directoryPath, item)}`,
935
+ thumbnails: {
936
+ "75x75": `/${import_node_path2.default.join(directoryPath, item)}`,
937
+ "400x400": `/${import_node_path2.default.join(directoryPath, item)}`,
938
+ "1000x1000": `/${import_node_path2.default.join(directoryPath, item)}`
939
+ }
940
+ };
941
+ if (stats.isDirectory()) {
942
+ staticMediaItem.children = await listFilesRecursively({
943
+ directoryPath: import_node_path2.default.join(directoryPath, item),
944
+ config: config2,
945
+ roothPath
946
+ });
947
+ }
948
+ staticMediaItems.push(staticMediaItem);
949
+ }
950
+ function chunkArrayIntoObject(array, chunkSize) {
951
+ const result = {};
952
+ for (let i = 0; i < array.length; i += chunkSize) {
953
+ const chunkKey = `${i / chunkSize * 20}`;
954
+ result[chunkKey] = array.slice(i, i + chunkSize);
955
+ }
956
+ return result;
957
+ }
958
+ return chunkArrayIntoObject(staticMediaItems, 20);
1041
959
  }
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}';
960
+ var createConfig = async ({
961
+ configManager,
962
+ apiURL,
963
+ plugins = [],
964
+ noWatch,
965
+ rollupOptions
966
+ }) => {
967
+ var _a, _b, _c, _d, _e, _f, _g, _h;
968
+ const publicEnv = {};
969
+ Object.keys(process.env).forEach((key) => {
970
+ if (key.startsWith("TINA_PUBLIC_") || key.startsWith("NEXT_PUBLIC_") || key === "NODE_ENV" || key === "HEAD") {
971
+ try {
972
+ if (typeof process.env[key] === "string") {
973
+ publicEnv[key] = process.env[key];
974
+ } else {
975
+ publicEnv[key] = JSON.stringify(process.env[key]);
976
+ }
977
+ } catch (error) {
978
+ console.warn(
979
+ `Could not stringify public env process.env.${key} env variable`
980
+ );
981
+ console.warn(error);
982
+ }
983
+ }
984
+ });
985
+ const staticMediaPath = import_node_path2.default.join(
986
+ configManager.generatedFolderPath,
987
+ "static-media.json"
988
+ );
989
+ if ((_b = (_a = configManager.config.media) == null ? void 0 : _a.tina) == null ? void 0 : _b.static) {
990
+ const staticMedia = await listFilesRecursively({
991
+ directoryPath: ((_c = configManager.config.media.tina) == null ? void 0 : _c.mediaRoot) || "",
992
+ config: configManager.config.media.tina,
993
+ roothPath: configManager.rootPath
994
+ });
995
+ await import_fs_extra2.default.outputFile(staticMediaPath, JSON.stringify(staticMedia, null, 2));
996
+ } else {
997
+ await import_fs_extra2.default.outputFile(staticMediaPath, `[]`);
1075
998
  }
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;
1098
- };
1099
- var indentText = (str) => {
1100
- return String(str).split("\n").map((line) => ` ${line}`).join("\n");
999
+ const alias = {
1000
+ TINA_IMPORT: configManager.prebuildFilePath,
1001
+ SCHEMA_IMPORT: configManager.generatedGraphQLJSONPath,
1002
+ STATIC_MEDIA_IMPORT: staticMediaPath,
1003
+ crypto: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
1004
+ fs: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
1005
+ os: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
1006
+ path: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts")
1007
+ };
1008
+ if (configManager.shouldSkipSDK()) {
1009
+ alias["CLIENT_IMPORT"] = import_node_path2.default.join(
1010
+ configManager.spaRootPath,
1011
+ "src",
1012
+ "dummy-client.ts"
1013
+ );
1014
+ } else {
1015
+ alias["CLIENT_IMPORT"] = configManager.isUsingTs() ? configManager.generatedTypesTSFilePath : configManager.generatedTypesJSFilePath;
1016
+ }
1017
+ let basePath;
1018
+ if (configManager.config.build.basePath) {
1019
+ basePath = configManager.config.build.basePath;
1020
+ }
1021
+ const fullVersion = configManager.getTinaGraphQLVersion();
1022
+ const version2 = `${fullVersion.major}.${fullVersion.minor}`;
1023
+ const config2 = {
1024
+ root: configManager.spaRootPath,
1025
+ base: `/${basePath ? `${(0, import_normalize_path2.default)(basePath)}/` : ""}${(0, import_normalize_path2.default)(
1026
+ configManager.config.build.outputFolder
1027
+ )}/`,
1028
+ appType: "spa",
1029
+ resolve: {
1030
+ alias,
1031
+ dedupe: ["graphql", "tinacms", "react", "react-dom", "react-router-dom"]
1032
+ },
1033
+ define: {
1034
+ /**
1035
+ * Since we prebuild the config.ts, it's possible for modules to be loaded which make
1036
+ * use of `process`. The main scenario where this is an issue is when co-locating schema
1037
+ * definitions with source files, and specifically source files which impor from NextJS.
1038
+ *
1039
+ * Some examples of what NextJS uses for `process.env` are:
1040
+ * - `process.env.__NEXT_TRAILING_SLASH`
1041
+ * - `process.env.__NEXT_CROSS_ORIGIN`
1042
+ * - `process.env.__NEXT_I18N_SUPPORT`
1043
+ *
1044
+ * Also, interestingly some of the advice for handling this doesn't work, references to replacing
1045
+ * `process.env` with `{}` are problematic, because browsers don't understand the `{}.` syntax,
1046
+ * but node does. This was a surprise, but using `new Object()` seems to do the trick.
1047
+ */
1048
+ "process.env": `new Object(${JSON.stringify(publicEnv)})`,
1049
+ // Used by picomatch https://github.com/micromatch/picomatch/blob/master/lib/utils.js#L4
1050
+ "process.platform": `"${process.platform}"`,
1051
+ __API_URL__: `"${apiURL}"`,
1052
+ __BASE_PATH__: `"${((_e = (_d = configManager.config) == null ? void 0 : _d.build) == null ? void 0 : _e.basePath) || ""}"`,
1053
+ __TINA_GRAPHQL_VERSION__: version2
1054
+ },
1055
+ logLevel: "error",
1056
+ // Vite import warnings are noisy
1057
+ optimizeDeps: {
1058
+ force: true,
1059
+ // Not 100% sure why this isn't being picked up automatically, this works from within the monorepo
1060
+ // but breaks externally
1061
+ include: ["react/jsx-runtime", "react/jsx-dev-runtime"]
1062
+ },
1063
+ server: {
1064
+ host: (_h = (_g = (_f = configManager.config) == null ? void 0 : _f.build) == null ? void 0 : _g.host) != null ? _h : false,
1065
+ watch: noWatch ? {
1066
+ ignored: ["**/*"]
1067
+ } : {
1068
+ // Ignore everything except for the alias fields we specified above
1069
+ ignored: [
1070
+ `${configManager.tinaFolderPath}/**/!(config.prebuild.jsx|_graphql.json)`
1071
+ ]
1072
+ },
1073
+ fs: {
1074
+ strict: false
1075
+ }
1076
+ },
1077
+ build: {
1078
+ sourcemap: false,
1079
+ outDir: configManager.outputFolderPath,
1080
+ emptyOutDir: true,
1081
+ rollupOptions
1082
+ },
1083
+ plugins: [
1084
+ /**
1085
+ * `splitVendorChunkPlugin` is needed because `tinacms` is quite large,
1086
+ * Vite's chunking strategy chokes on memory issues for smaller machines (ie. on CI).
1087
+ */
1088
+ (0, import_plugin_react.default)({
1089
+ babel: {
1090
+ // Supresses the warning [NOTE] babel The code generator has deoptimised the styling of
1091
+ compact: true
1092
+ }
1093
+ }),
1094
+ (0, import_vite.splitVendorChunkPlugin)(),
1095
+ tinaTailwind(configManager.spaRootPath, configManager.prebuildFilePath),
1096
+ ...plugins
1097
+ ]
1098
+ };
1099
+ return config2;
1101
1100
  };
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");
1109
1101
 
1110
1102
  // src/next/vite/plugins.ts
1111
1103
  var import_pluginutils = require("@rollup/pluginutils");
1112
1104
  var import_fs = __toESM(require("fs"));
1113
- var import_vite3 = require("vite");
1105
+ var import_vite2 = require("vite");
1114
1106
  var import_esbuild = require("esbuild");
1115
1107
  var import_path3 = __toESM(require("path"));
1116
1108
  var import_body_parser = __toESM(require("body-parser"));
@@ -1172,8 +1164,7 @@ var createMediaRouter = (config2) => {
1172
1164
  };
1173
1165
  var parseMediaFolder = (str) => {
1174
1166
  let returnString = str;
1175
- if (returnString.startsWith("/"))
1176
- returnString = returnString.substr(1);
1167
+ if (returnString.startsWith("/")) returnString = returnString.substr(1);
1177
1168
  if (returnString.endsWith("/"))
1178
1169
  returnString = returnString.substr(0, returnString.length - 1);
1179
1170
  return returnString;
@@ -1433,13 +1424,14 @@ function viteTransformExtension({
1433
1424
  previousExport: exportAsDefault ? null : code
1434
1425
  }
1435
1426
  });
1436
- const res = await (0, import_vite3.transformWithEsbuild)(componentCode, id, {
1427
+ const res = await (0, import_vite2.transformWithEsbuild)(componentCode, id, {
1437
1428
  loader: "jsx",
1438
1429
  ...esbuildOptions
1439
1430
  });
1440
1431
  return {
1441
1432
  code: res.code,
1442
1433
  map: null
1434
+ // TODO:
1443
1435
  };
1444
1436
  }
1445
1437
  }
@@ -1453,13 +1445,21 @@ var createDevServer = async (configManager, database, searchIndex, apiURL, noWat
1453
1445
  devServerEndPointsPlugin({ apiURL, configManager, database, searchIndex }),
1454
1446
  viteTransformExtension()
1455
1447
  ];
1456
- return (0, import_vite4.createServer)(
1448
+ return (0, import_vite3.createServer)(
1457
1449
  await createConfig({
1458
1450
  configManager,
1459
1451
  database,
1460
1452
  apiURL,
1461
1453
  plugins,
1462
1454
  noWatch,
1455
+ /**
1456
+ * Ensure Vite's import scan uses the spaMainPath as the input
1457
+ * so it properly finds everything. This is for dev only, and when
1458
+ * running the server outside of this monorepo vite fails to find
1459
+ * and optimize the imports, so you get errors about it not being
1460
+ * able to find an export from a module, and it's always a CJS
1461
+ * module that Vite would usually transform to an ES module.
1462
+ */
1463
1463
  rollupOptions: {
1464
1464
  input: configManager.spaMainPath,
1465
1465
  onwarn(warning, warn) {
@@ -1468,10 +1468,6 @@ var createDevServer = async (configManager, database, searchIndex, apiURL, noWat
1468
1468
  }
1469
1469
  warn(warning);
1470
1470
  }
1471
- },
1472
- viteConfigEnv: {
1473
- command: "serve",
1474
- mode: "development"
1475
1471
  }
1476
1472
  })
1477
1473
  );
@@ -1589,6 +1585,7 @@ var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBas
1589
1585
  node,
1590
1586
  documentVariableName,
1591
1587
  operationType,
1588
+ // This is the only line that is different
1592
1589
  operationResultType: `{data: ${operationResultType}, errors?: { message: string, locations: { line: number, column: number }[], path: string[] }[], variables: ${operationVariablesTypes}, query: string}`,
1593
1590
  operationVariablesTypes
1594
1591
  });
@@ -1637,6 +1634,8 @@ var plugin = (schema, documents, config2) => {
1637
1634
  const visitor = new GenericSdkVisitor(schema, allFragments, config2);
1638
1635
  const visitorResult = (0, import_graphql3.visit)(allAst, { leave: visitor });
1639
1636
  return {
1637
+ // We will take care of imports
1638
+ // prepend: visitor.getImports(),
1640
1639
  content: [
1641
1640
  visitor.fragments,
1642
1641
  ...visitorResult.definitions.filter((t) => typeof t === "string"),
@@ -1652,6 +1651,7 @@ var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath =
1652
1651
  docs = await loadGraphQLDocuments(queryPathGlob);
1653
1652
  fragDocs = await loadGraphQLDocuments(fragDocPath);
1654
1653
  const res = await (0, import_core.codegen)({
1654
+ // Filename is not used. This is because the typescript plugin returns a string instead of writing to a file.
1655
1655
  filename: process.cwd(),
1656
1656
  schema: (0, import_graphql5.parse)((0, import_graphql5.printSchema)(schema)),
1657
1657
  documents: [...docs, ...fragDocs],
@@ -1686,9 +1686,12 @@ var loadGraphQLDocuments = async (globPath) => {
1686
1686
  loaders: [new import_graphql_file_loader.GraphQLFileLoader()]
1687
1687
  });
1688
1688
  } catch (e) {
1689
- if ((e.message || "").includes(
1690
- "Unable to find any GraphQL type definitions for the following pointers:"
1691
- )) {
1689
+ if (
1690
+ // https://www.graphql-tools.com/docs/documents-loading#no-files-found
1691
+ (e.message || "").includes(
1692
+ "Unable to find any GraphQL type definitions for the following pointers:"
1693
+ )
1694
+ ) {
1692
1695
  } else {
1693
1696
  throw e;
1694
1697
  }
@@ -1850,12 +1853,9 @@ var Codegen = class {
1850
1853
  const baseUrl = ((_d = this.configManager.config.tinaioConfig) == null ? void 0 : _d.contentApiUrlOverride) || `https://${TINA_HOST}`;
1851
1854
  if ((!branch || !clientId || !token) && !this.port && !this.configManager.config.contentApiUrlOverride) {
1852
1855
  const missing = [];
1853
- if (!branch)
1854
- missing.push("branch");
1855
- if (!clientId)
1856
- missing.push("clientId");
1857
- if (!token)
1858
- missing.push("token");
1856
+ if (!branch) missing.push("branch");
1857
+ if (!clientId) missing.push("clientId");
1858
+ if (!token) missing.push("token");
1859
1859
  throw new Error(
1860
1860
  `Client not configured properly. Missing ${missing.join(
1861
1861
  ", "
@@ -2009,7 +2009,11 @@ schema {
2009
2009
  }
2010
2010
  };
2011
2011
  var maybeWarnFragmentSize = async (filepath) => {
2012
- if ((await import_fs_extra4.default.stat(filepath)).size > 100 * 1024) {
2012
+ if (
2013
+ // is the file bigger than 100kb?
2014
+ (await import_fs_extra4.default.stat(filepath)).size > // convert to 100 kb to bytes
2015
+ 100 * 1024
2016
+ ) {
2013
2017
  console.warn(
2014
2018
  "Warning: frags.gql is very large (>100kb). Consider setting the reference depth to 1 or 0. See code snippet below."
2015
2019
  );
@@ -2037,6 +2041,7 @@ var import_many_level = require("many-level");
2037
2041
  var import_memory_level = require("memory-level");
2038
2042
  var createDBServer = (port) => {
2039
2043
  const levelHost = new import_many_level.ManyLevelHost(
2044
+ // @ts-ignore
2040
2045
  new import_memory_level.MemoryLevel({
2041
2046
  valueEncoding: "json"
2042
2047
  })
@@ -2311,6 +2316,7 @@ var import_search = require("@tinacms/search");
2311
2316
  var DevCommand = class extends BaseCommand {
2312
2317
  constructor() {
2313
2318
  super(...arguments);
2319
+ // NOTE: camelCase commands for string options don't work if there's an `=` used https://github.com/arcanis/clipanion/issues/141
2314
2320
  this.watchFolders = import_clipanion2.Option.String("-w,--watchFolders", {
2315
2321
  description: "DEPRECATED - a list of folders (relative to where this is being run) that the cli will watch for changes"
2316
2322
  });
@@ -2529,6 +2535,20 @@ ${dangerText(e.message)}
2529
2535
  heading: "Tina Dev Server is running...",
2530
2536
  items: [
2531
2537
  ...summaryItems
2538
+ // {
2539
+ // emoji: '📚',
2540
+ // heading: 'Useful links',
2541
+ // subItems: [
2542
+ // {
2543
+ // key: 'Custom queries',
2544
+ // value: 'https://tina.io/querying',
2545
+ // },
2546
+ // {
2547
+ // key: 'Visual editing',
2548
+ // value: 'https://tina.io/visual-editing',
2549
+ // },
2550
+ // ],
2551
+ // },
2532
2552
  ]
2533
2553
  });
2534
2554
  await this.startSubCommand();
@@ -2600,7 +2620,7 @@ var import_path6 = __toESM(require("path"));
2600
2620
  var import_graphql11 = require("@tinacms/graphql");
2601
2621
 
2602
2622
  // src/next/commands/build-command/server.ts
2603
- var import_vite6 = require("vite");
2623
+ var import_vite5 = require("vite");
2604
2624
  var buildProductionSpa = async (configManager, database, apiURL) => {
2605
2625
  const publicEnv = {};
2606
2626
  Object.keys(process.env).forEach((key) => {
@@ -2632,13 +2652,9 @@ var buildProductionSpa = async (configManager, database, apiURL) => {
2632
2652
  }
2633
2653
  warn(warning);
2634
2654
  }
2635
- },
2636
- viteConfigEnv: {
2637
- command: "build",
2638
- mode: "production"
2639
2655
  }
2640
2656
  });
2641
- return (0, import_vite6.build)(config2);
2657
+ return (0, import_vite5.build)(config2);
2642
2658
  };
2643
2659
 
2644
2660
  // src/next/commands/build-command/index.ts
@@ -2775,6 +2791,9 @@ var BuildCommand = class extends BaseCommand {
2775
2791
  this.tinaGraphQLVersion = import_clipanion3.Option.String("--tina-graphql-version", {
2776
2792
  description: "Specify the version of @tinacms/graphql to use (defaults to latest)"
2777
2793
  });
2794
+ /**
2795
+ * This option allows the user to skip the tina cloud checks if they want to. This could be useful for mismatched GraphQL versions or if they want to build only using the local client and never connect to Tina Cloud
2796
+ */
2778
2797
  this.skipCloudChecks = import_clipanion3.Option.Boolean("--skip-cloud-checks", false, {
2779
2798
  description: "Skips checking the provided cloud config."
2780
2799
  });
@@ -3515,6 +3534,7 @@ var auditDocuments = async (args) => {
3515
3534
  logger.error(import_chalk5.default.red(err.message));
3516
3535
  if (err.originalError.originalError) {
3517
3536
  logger.error(
3537
+ // @ts-ignore FIXME: this doesn't seem right
3518
3538
  import_chalk5.default.red(` ${err.originalError.originalError.message}`)
3519
3539
  );
3520
3540
  }
@@ -3720,7 +3740,9 @@ var detectEnvironment = async ({
3720
3740
  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
3741
  const tinaFolder = import_path7.default.join(baseDir, "tina");
3722
3742
  const tinaConfigExists = Boolean(
3723
- await import_fs_extra8.default.pathExists(tinaFolder) && (await import_fs_extra8.default.readdir(tinaFolder)).find((x) => x.includes("config"))
3743
+ // Does the tina folder exist?
3744
+ await import_fs_extra8.default.pathExists(tinaFolder) && // Does the tina folder contain a config file?
3745
+ (await import_fs_extra8.default.readdir(tinaFolder)).find((x) => x.includes("config"))
3724
3746
  );
3725
3747
  const pagesDir = [baseDir, usingSrc ? "src" : false, "pages"].filter(
3726
3748
  Boolean
@@ -3955,6 +3977,7 @@ var supportedDatabaseAdapters = {
3955
3977
  {
3956
3978
  from: "mongodb",
3957
3979
  imported: [],
3980
+ // not explicitly imported
3958
3981
  packageName: "mongodb"
3959
3982
  }
3960
3983
  ]
@@ -4027,6 +4050,10 @@ var chooseDatabaseAdapter = async ({
4027
4050
  title: "MongoDB",
4028
4051
  value: "mongodb"
4029
4052
  }
4053
+ // {
4054
+ // title: "I'll create my own database adapter",
4055
+ // value: 'other',
4056
+ // },
4030
4057
  ]
4031
4058
  }
4032
4059
  ]);
@@ -4304,6 +4331,7 @@ async function configure(env, opts) {
4304
4331
  packageManager,
4305
4332
  forestryMigrate: false,
4306
4333
  isLocalEnvVarName: "TINA_PUBLIC_IS_LOCAL",
4334
+ // TODO: give this a better default
4307
4335
  typescript: false
4308
4336
  };
4309
4337
  if (config2.framework.name === "next") {
@@ -4407,15 +4435,25 @@ var import_js_yaml = __toESM(require("js-yaml"));
4407
4435
  var import_zod = __toESM(require("zod"));
4408
4436
 
4409
4437
  // src/cmds/forestry-migrate/util/errorSingleton.ts
4410
- var ErrorSingleton = class {
4438
+ var ErrorSingleton = class _ErrorSingleton {
4439
+ /**
4440
+ * The Singleton's constructor should always be private to prevent direct
4441
+ * construction calls with the `new` operator.
4442
+ */
4411
4443
  constructor() {
4412
4444
  }
4445
+ /**
4446
+ * The static method that controls the access to the singleton instance.
4447
+ *
4448
+ * This implementation let you subclass the Singleton class while keeping
4449
+ * just one instance of each subclass around.
4450
+ */
4413
4451
  static getInstance() {
4414
- if (!ErrorSingleton.instance) {
4415
- ErrorSingleton.instance = new ErrorSingleton();
4416
- ErrorSingleton.instance.collectionNameErrors = [];
4452
+ if (!_ErrorSingleton.instance) {
4453
+ _ErrorSingleton.instance = new _ErrorSingleton();
4454
+ _ErrorSingleton.instance.collectionNameErrors = [];
4417
4455
  }
4418
- return ErrorSingleton.instance;
4456
+ return _ErrorSingleton.instance;
4419
4457
  }
4420
4458
  addErrorName(error) {
4421
4459
  this.collectionNameErrors.push(error);
@@ -4458,8 +4496,7 @@ var makeFieldsWithInternalCode = ({
4458
4496
  if (hasBody) {
4459
4497
  return [bodyField, `__TINA_INTERNAL__:::...${field}():::`];
4460
4498
  } else {
4461
- if (spread)
4462
- return `__TINA_INTERNAL__:::...${field}():::`;
4499
+ if (spread) return `__TINA_INTERNAL__:::...${field}():::`;
4463
4500
  return `__TINA_INTERNAL__:::${field}():::`;
4464
4501
  }
4465
4502
  };
@@ -4543,6 +4580,7 @@ var forestryConfigSchema = import_zod.default.object({
4543
4580
  )
4544
4581
  });
4545
4582
  var forestryFieldWithoutField = import_zod.default.object({
4583
+ // TODO: maybe better type this?
4546
4584
  type: import_zod.default.union([
4547
4585
  import_zod.default.literal("text"),
4548
4586
  import_zod.default.literal("datetime"),
@@ -4566,6 +4604,7 @@ var forestryFieldWithoutField = import_zod.default.object({
4566
4604
  default: import_zod.default.any().optional(),
4567
4605
  template: import_zod.default.string().optional(),
4568
4606
  config: import_zod.default.object({
4607
+ // min and max are used for lists
4569
4608
  min: import_zod.default.number().optional().nullable(),
4570
4609
  max: import_zod.default.number().optional().nullable(),
4571
4610
  required: import_zod.default.boolean().optional().nullable(),
@@ -4579,6 +4618,7 @@ var forestryFieldWithoutField = import_zod.default.object({
4579
4618
  import_zod.default.literal("pages"),
4580
4619
  import_zod.default.literal("documents"),
4581
4620
  import_zod.default.literal("simple"),
4621
+ // TODO: I want to ignore this key if its invalid
4582
4622
  import_zod.default.string()
4583
4623
  ]).optional().nullable(),
4584
4624
  section: import_zod.default.string().optional().nullable()
@@ -4614,6 +4654,7 @@ var transformForestryFieldsToTinaFields = ({
4614
4654
  }
4615
4655
  let field;
4616
4656
  switch (forestryField2.type) {
4657
+ // Single filed types
4617
4658
  case "text":
4618
4659
  field = {
4619
4660
  type: "string",
@@ -4693,6 +4734,7 @@ var transformForestryFieldsToTinaFields = ({
4693
4734
  );
4694
4735
  }
4695
4736
  break;
4737
+ // List Types
4696
4738
  case "list":
4697
4739
  field = {
4698
4740
  type: "string",
@@ -4715,6 +4757,7 @@ var transformForestryFieldsToTinaFields = ({
4715
4757
  }
4716
4758
  };
4717
4759
  break;
4760
+ // Object (Group) types
4718
4761
  case "field_group":
4719
4762
  field = {
4720
4763
  type: "object",
@@ -4755,6 +4798,7 @@ var transformForestryFieldsToTinaFields = ({
4755
4798
  });
4756
4799
  const fieldsString = stringifyLabelWithField(template2.label);
4757
4800
  const t = {
4801
+ // @ts-ignore
4758
4802
  fields: makeFieldsWithInternalCode({
4759
4803
  hasBody: false,
4760
4804
  field: fieldsString
@@ -4792,6 +4836,7 @@ var transformForestryFieldsToTinaFields = ({
4792
4836
  spread: true
4793
4837
  });
4794
4838
  tinaFields.push(
4839
+ // @ts-ignore
4795
4840
  field2
4796
4841
  );
4797
4842
  break;
@@ -4851,6 +4896,7 @@ var parseSections = ({ val }) => {
4851
4896
 
4852
4897
  // src/cmds/forestry-migrate/index.ts
4853
4898
  var BODY_FIELD = {
4899
+ // This is the body field
4854
4900
  type: "rich-text",
4855
4901
  name: "body",
4856
4902
  label: "Body of Document",
@@ -4909,8 +4955,7 @@ var generateAllTemplates = async ({
4909
4955
  };
4910
4956
  var generateCollectionFromForestrySection = (args) => {
4911
4957
  const { section, templateMap } = args;
4912
- if (section.read_only)
4913
- return;
4958
+ if (section.read_only) return;
4914
4959
  let format3 = "md";
4915
4960
  if (section.new_doc_ext) {
4916
4961
  const ext = checkExt(section.new_doc_ext);
@@ -4977,12 +5022,14 @@ var generateCollectionFromForestrySection = (args) => {
4977
5022
  if (((forestryTemplates == null ? void 0 : forestryTemplates.length) || 0) > 1) {
4978
5023
  c = {
4979
5024
  ...baseCollection,
5025
+ // @ts-expect-error
4980
5026
  templates: forestryTemplates.map((tem) => {
4981
5027
  const currentTemplate = templateMap.get(tem);
4982
5028
  const fieldsString = stringifyLabelWithField(
4983
5029
  currentTemplate.templateObj.label
4984
5030
  );
4985
5031
  return {
5032
+ // fields: [BODY_FIELD],
4986
5033
  fields: makeFieldsWithInternalCode({
4987
5034
  hasBody,
4988
5035
  field: fieldsString,
@@ -5000,6 +5047,8 @@ var generateCollectionFromForestrySection = (args) => {
5000
5047
  const fieldsString = stringifyLabelWithField(template.templateObj.label);
5001
5048
  c = {
5002
5049
  ...baseCollection,
5050
+ // fields: [BODY_FIELD],
5051
+ // @ts-expect-error
5003
5052
  fields: makeFieldsWithInternalCode({
5004
5053
  field: fieldsString,
5005
5054
  hasBody,
@@ -5747,6 +5796,7 @@ var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
5747
5796
  ) : [];
5748
5797
  const newImports = [
5749
5798
  .../* @__PURE__ */ new Set([
5799
+ // we use Set to remove duplicates
5750
5800
  ...existingImports,
5751
5801
  ...imports
5752
5802
  ])
@@ -5901,6 +5951,7 @@ var addSelfHostedTinaAuthToConfig = async (config2, configFile) => {
5901
5951
  );
5902
5952
  const { configImports, configAuthProviderClass, extraTinaCollections } = config2.authProvider;
5903
5953
  const importMap = {
5954
+ // iterate over configImports and add them to the import map
5904
5955
  ...configImports.reduce((acc, { from, imported }) => {
5905
5956
  acc[from] = imported;
5906
5957
  return acc;
@@ -6075,7 +6126,13 @@ async function apply({
6075
6126
  config: config2
6076
6127
  });
6077
6128
  }
6078
- if (env.tinaConfigExists && params.isBackendInit && config2.hosting === "self-host" && (((_a = config2.authProvider) == null ? void 0 : _a.name) || "") !== "tina-cloud") {
6129
+ if (
6130
+ // if the config was just generated we do not need to update the config file because it will be generated correctly
6131
+ env.tinaConfigExists && // Are we running tinacms init backend
6132
+ params.isBackendInit && // Do the user choose the 'self-host' option
6133
+ config2.hosting === "self-host" && // the user did not choose the 'tina-cloud' auth provider
6134
+ (((_a = config2.authProvider) == null ? void 0 : _a.name) || "") !== "tina-cloud"
6135
+ ) {
6079
6136
  await addSelfHostedTinaAuthToConfig(config2, env.generatedFiles["config"]);
6080
6137
  }
6081
6138
  logNextSteps({
@@ -6368,6 +6425,7 @@ var other = ({ packageManager }) => {
6368
6425
  const packageManagers = {
6369
6426
  pnpm: `pnpm`,
6370
6427
  npm: `npx`,
6428
+ // npx is the way to run executables that aren't in your "scripts"
6371
6429
  yarn: `yarn`
6372
6430
  };
6373
6431
  return `${packageManagers[packageManager]} tinacms dev -c "<your dev command>"`;
@@ -6380,6 +6438,7 @@ var frameworkDevCmds = {
6380
6438
  const packageManagers = {
6381
6439
  pnpm: `pnpm`,
6382
6440
  npm: `npm run`,
6441
+ // npx is the way to run executables that aren't in your "scripts"
6383
6442
  yarn: `yarn`
6384
6443
  };
6385
6444
  return `${packageManagers[packageManager]} dev`;
@@ -6637,5 +6696,3 @@ cli.register(import_clipanion8.Builtins.DefinitionsCommand);
6637
6696
  cli.register(import_clipanion8.Builtins.HelpCommand);
6638
6697
  cli.register(import_clipanion8.Builtins.VersionCommand);
6639
6698
  var src_default = cli;
6640
- // Annotate the CommonJS export names for ESM import in node:
6641
- 0 && (module.exports = {});