@tinacms/cli 1.5.10 → 1.5.11

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,12 +31,12 @@ module.exports = __toCommonJS(src_exports);
31
31
  var import_clipanion6 = require("clipanion");
32
32
 
33
33
  // package.json
34
- var version = "1.5.10";
34
+ var version = "1.5.11";
35
35
 
36
36
  // src/next/commands/dev-command/index.ts
37
37
  var import_clipanion = require("clipanion");
38
38
  var import_fs_extra4 = __toESM(require("fs-extra"));
39
- var import_path6 = __toESM(require("path"));
39
+ var import_path7 = __toESM(require("path"));
40
40
  var import_chokidar = __toESM(require("chokidar"));
41
41
  var import_graphql8 = require("@tinacms/graphql");
42
42
 
@@ -47,6 +47,7 @@ var import_os = __toESM(require("os"));
47
47
  var esbuild = __toESM(require("esbuild"));
48
48
  var dotenv = __toESM(require("dotenv"));
49
49
  var import_normalize_path = __toESM(require("normalize-path"));
50
+ var import_chalk2 = __toESM(require("chalk"));
50
51
 
51
52
  // src/logger/index.ts
52
53
  var import_chalk = __toESM(require("chalk"));
@@ -286,12 +287,28 @@ var ConfigManager = class {
286
287
  this.tinaFolderPath,
287
288
  this.config.localContentPath || ""
288
289
  );
289
- if (this.config.localContentPath && await import_fs_extra.default.existsSync(fullLocalContentPath)) {
290
- logger.info(`Using separate content repo at ${fullLocalContentPath}`);
291
- this.contentRootPath = fullLocalContentPath;
292
- } else {
290
+ if (this.config.localContentPath) {
291
+ const localContentPathExists = await import_fs_extra.default.pathExists(fullLocalContentPath);
292
+ if (localContentPathExists) {
293
+ logger.info(`Using separate content repo at ${fullLocalContentPath}`);
294
+ this.contentRootPath = fullLocalContentPath;
295
+ } else {
296
+ logger.warn(
297
+ `${import_chalk2.default.yellow("Warning:")} The localContentPath ${import_chalk2.default.cyan(
298
+ fullLocalContentPath
299
+ )} does not exist. Please create it or remove the localContentPath from your config file at ${import_chalk2.default.cyan(
300
+ this.tinaConfigFilePath
301
+ )}`
302
+ );
303
+ }
304
+ }
305
+ if (!this.contentRootPath) {
293
306
  this.contentRootPath = this.rootPath;
294
307
  }
308
+ this.generatedFolderPathContentRepo = import_path.default.join(
309
+ await this.getTinaFolderPath(this.contentRootPath),
310
+ GENERATED_FOLDER
311
+ );
295
312
  this.spaMainPath = require.resolve("@tinacms/app");
296
313
  this.spaRootPath = import_path.default.join(this.spaMainPath, "..", "..");
297
314
  }
@@ -1102,6 +1119,7 @@ var createDevServer = async (configManager, database, apiURL, noWatch) => {
1102
1119
 
1103
1120
  // src/next/codegen/index.ts
1104
1121
  var import_fs_extra3 = __toESM(require("fs-extra"));
1122
+ var import_path6 = __toESM(require("path"));
1105
1123
  var import_graphql6 = require("graphql");
1106
1124
 
1107
1125
  // src/next/codegen/codegen/index.ts
@@ -1303,15 +1321,33 @@ var Codegen = class {
1303
1321
  constructor({
1304
1322
  configManager,
1305
1323
  port,
1306
- schema,
1307
1324
  queryDoc,
1308
- fragDoc
1325
+ fragDoc,
1326
+ graphqlSchemaDoc,
1327
+ tinaSchema,
1328
+ lookup
1309
1329
  }) {
1330
+ this.graphqlSchemaDoc = graphqlSchemaDoc;
1310
1331
  this.configManager = configManager;
1311
1332
  this.port = port;
1312
- this.schema = schema;
1333
+ this.schema = (0, import_graphql6.buildASTSchema)(graphqlSchemaDoc);
1334
+ this.tinaSchema = tinaSchema;
1313
1335
  this.queryDoc = queryDoc;
1314
1336
  this.fragDoc = fragDoc;
1337
+ this.lookup = lookup;
1338
+ }
1339
+ async writeConfigFile(fileName, data) {
1340
+ const filePath = import_path6.default.join(this.configManager.generatedFolderPath, fileName);
1341
+ await import_fs_extra3.default.ensureFile(filePath);
1342
+ await import_fs_extra3.default.outputFile(filePath, data);
1343
+ if (this.configManager.hasSeparateContentRoot()) {
1344
+ const filePath2 = import_path6.default.join(
1345
+ this.configManager.generatedFolderPathContentRepo,
1346
+ fileName
1347
+ );
1348
+ await import_fs_extra3.default.ensureFile(filePath2);
1349
+ await import_fs_extra3.default.outputFile(filePath2, data);
1350
+ }
1315
1351
  }
1316
1352
  async removeGeneratedFilesIfExists() {
1317
1353
  await unlinkIfExists(this.configManager.generatedClientJSFilePath);
@@ -1323,6 +1359,16 @@ var Codegen = class {
1323
1359
  await unlinkIfExists(this.configManager.generatedFragmentsFilePath);
1324
1360
  }
1325
1361
  async execute() {
1362
+ console.log("Generating Tina Files");
1363
+ await this.writeConfigFile(
1364
+ "_graphql.json",
1365
+ JSON.stringify(this.graphqlSchemaDoc)
1366
+ );
1367
+ await this.writeConfigFile(
1368
+ "_schema.json",
1369
+ JSON.stringify(this.tinaSchema.schema)
1370
+ );
1371
+ await this.writeConfigFile("_lookup.json", JSON.stringify(this.lookup));
1326
1372
  const apiURL = this.getApiURL();
1327
1373
  if (this.configManager.shouldSkipSDK()) {
1328
1374
  await this.removeGeneratedFilesIfExists();
@@ -1464,27 +1510,27 @@ var unlinkIfExists = async (filepath) => {
1464
1510
  };
1465
1511
 
1466
1512
  // src/next/commands/dev-command/index.ts
1467
- var import_chalk3 = __toESM(require("chalk"));
1513
+ var import_chalk4 = __toESM(require("chalk"));
1468
1514
 
1469
1515
  // src/utils/start-subprocess.ts
1470
1516
  var import_child_process = __toESM(require("child_process"));
1471
1517
 
1472
1518
  // src/utils/theme.ts
1473
- var import_chalk2 = __toESM(require("chalk"));
1474
- var successText = import_chalk2.default.bold.green;
1475
- var focusText = import_chalk2.default.bold;
1476
- var dangerText = import_chalk2.default.bold.red;
1477
- var neutralText = import_chalk2.default.bold.cyan;
1478
- var linkText = import_chalk2.default.bold.cyan;
1479
- var labelText = import_chalk2.default.bold;
1480
- var cmdText = import_chalk2.default.inverse;
1519
+ var import_chalk3 = __toESM(require("chalk"));
1520
+ var successText = import_chalk3.default.bold.green;
1521
+ var focusText = import_chalk3.default.bold;
1522
+ var dangerText = import_chalk3.default.bold.red;
1523
+ var neutralText = import_chalk3.default.bold.cyan;
1524
+ var linkText = import_chalk3.default.bold.cyan;
1525
+ var labelText = import_chalk3.default.bold;
1526
+ var cmdText = import_chalk3.default.inverse;
1481
1527
  var indentedCmd = (str) => {
1482
1528
  return ` \u2503 ` + str;
1483
1529
  };
1484
- var logText = import_chalk2.default.italic.gray;
1485
- var warnText = import_chalk2.default.yellowBright.bgBlack;
1486
- var titleText = import_chalk2.default.bgHex("d2f1f8").hex("ec4816");
1487
- var CONFIRMATION_TEXT = import_chalk2.default.dim("enter to confirm");
1530
+ var logText = import_chalk3.default.italic.gray;
1531
+ var warnText = import_chalk3.default.yellowBright.bgBlack;
1532
+ var titleText = import_chalk3.default.bgHex("d2f1f8").hex("ec4816");
1533
+ var CONFIRMATION_TEXT = import_chalk3.default.dim("enter to confirm");
1488
1534
 
1489
1535
  // src/utils/start-subprocess.ts
1490
1536
  var startSubprocess2 = async ({ command }) => {
@@ -1693,7 +1739,17 @@ var DevCommand = class extends import_clipanion.Command {
1693
1739
  } else {
1694
1740
  database.clearCache();
1695
1741
  }
1696
- const { tinaSchema, graphQLSchema, queryDoc, fragDoc } = await (0, import_graphql8.buildSchema)(database, configManager.config);
1742
+ const { tinaSchema, graphQLSchema, lookup, queryDoc, fragDoc } = await (0, import_graphql8.buildSchema)(configManager.config);
1743
+ const codegen2 = new Codegen({
1744
+ configManager,
1745
+ port: Number(this.port),
1746
+ queryDoc,
1747
+ fragDoc,
1748
+ graphqlSchemaDoc: graphQLSchema,
1749
+ tinaSchema,
1750
+ lookup
1751
+ });
1752
+ const apiURL2 = await codegen2.execute();
1697
1753
  if (!configManager.isUsingLegacyFolder) {
1698
1754
  delete require.cache[configManager.generatedSchemaJSONPath];
1699
1755
  delete require.cache[configManager.generatedLookupJSONPath];
@@ -1702,7 +1758,7 @@ var DevCommand = class extends import_clipanion.Command {
1702
1758
  const lookupObject = require(configManager.generatedLookupJSONPath);
1703
1759
  const graphqlSchemaObject = require(configManager.generatedGraphQLJSONPath);
1704
1760
  await import_fs_extra4.default.writeFileSync(
1705
- import_path6.default.join(configManager.tinaFolderPath, "tina-lock.json"),
1761
+ import_path7.default.join(configManager.tinaFolderPath, "tina-lock.json"),
1706
1762
  JSON.stringify({
1707
1763
  schema: schemaObject,
1708
1764
  lookup: lookupObject,
@@ -1710,14 +1766,6 @@ var DevCommand = class extends import_clipanion.Command {
1710
1766
  })
1711
1767
  );
1712
1768
  }
1713
- const codegen2 = new Codegen({
1714
- schema: await (0, import_graphql8.getASTSchema)(database),
1715
- configManager,
1716
- port: Number(this.port),
1717
- queryDoc,
1718
- fragDoc
1719
- });
1720
- const apiURL2 = await codegen2.execute();
1721
1769
  if (!this.noWatch) {
1722
1770
  this.watchQueries(configManager, async () => await codegen2.execute());
1723
1771
  }
@@ -1726,7 +1774,8 @@ var DevCommand = class extends import_clipanion.Command {
1726
1774
  waitFor: async () => {
1727
1775
  const res = await database.indexContent({
1728
1776
  graphQLSchema,
1729
- tinaSchema
1777
+ tinaSchema,
1778
+ lookup
1730
1779
  });
1731
1780
  warnings.push(...res.warnings);
1732
1781
  },
@@ -1826,7 +1875,7 @@ var DevCommand = class extends import_clipanion.Command {
1826
1875
  let subProc;
1827
1876
  if (this.subCommand) {
1828
1877
  subProc = await startSubprocess2({ command: this.subCommand });
1829
- logger.info(`Starting subprocess: ${import_chalk3.default.cyan(this.subCommand)}`);
1878
+ logger.info(`Starting subprocess: ${import_chalk4.default.cyan(this.subCommand)}`);
1830
1879
  }
1831
1880
  function exitHandler(options, exitCode) {
1832
1881
  if (subProc) {
@@ -1843,7 +1892,7 @@ var DevCommand = class extends import_clipanion.Command {
1843
1892
  watchContentFiles(configManager, database) {
1844
1893
  const collectionContentFiles = [];
1845
1894
  configManager.config.schema.collections.forEach((collection) => {
1846
- const collectionGlob = `${import_path6.default.join(
1895
+ const collectionGlob = `${import_path7.default.join(
1847
1896
  configManager.contentRootPath,
1848
1897
  collection.path
1849
1898
  )}/**/*.${collection.format || "md"}`;
@@ -2101,15 +2150,14 @@ var BuildCommand = class extends import_clipanion2.Command {
2101
2150
  configManager,
2102
2151
  Number(this.datalayerPort)
2103
2152
  );
2104
- const { queryDoc, fragDoc } = await (0, import_graphql9.buildSchema)(
2105
- database,
2106
- configManager.config
2107
- );
2153
+ const { queryDoc, fragDoc, graphQLSchema, tinaSchema, lookup } = await (0, import_graphql9.buildSchema)(configManager.config);
2108
2154
  const codegen2 = new Codegen({
2109
- schema: await (0, import_graphql9.getASTSchema)(database),
2110
2155
  configManager,
2111
2156
  queryDoc,
2112
- fragDoc
2157
+ fragDoc,
2158
+ graphqlSchemaDoc: graphQLSchema,
2159
+ tinaSchema,
2160
+ lookup
2113
2161
  });
2114
2162
  const apiURL = await codegen2.execute();
2115
2163
  if (!configManager.hasSelfHostedConfig()) {
@@ -2355,7 +2403,7 @@ var import_graphql12 = require("@tinacms/graphql");
2355
2403
  var import_prompts = __toESM(require("prompts"));
2356
2404
  var import_metrics = require("@tinacms/metrics");
2357
2405
  var import_graphql11 = require("@tinacms/graphql");
2358
- var import_chalk4 = __toESM(require("chalk"));
2406
+ var import_chalk5 = __toESM(require("chalk"));
2359
2407
  var audit = async ({
2360
2408
  database,
2361
2409
  clean,
@@ -2373,7 +2421,7 @@ var audit = async ({
2373
2421
  });
2374
2422
  if (clean) {
2375
2423
  logger.info(
2376
- `You are using the \`--clean\` option. This will modify your content as if a user is submitting a form. Before running this you should have a ${import_chalk4.default.bold(
2424
+ `You are using the \`--clean\` option. This will modify your content as if a user is submitting a form. Before running this you should have a ${import_chalk5.default.bold(
2377
2425
  "clean git tree"
2378
2426
  )} so unwanted changes can be undone.
2379
2427
 
@@ -2385,13 +2433,13 @@ var audit = async ({
2385
2433
  message: `Do you want to continue?`
2386
2434
  });
2387
2435
  if (!res.useClean) {
2388
- logger.warn(import_chalk4.default.yellowBright("\u26A0\uFE0F Audit not complete"));
2436
+ logger.warn(import_chalk5.default.yellowBright("\u26A0\uFE0F Audit not complete"));
2389
2437
  process.exit(0);
2390
2438
  }
2391
2439
  }
2392
2440
  if (useDefaultValues && !clean) {
2393
2441
  logger.warn(
2394
- import_chalk4.default.yellowBright(
2442
+ import_chalk5.default.yellowBright(
2395
2443
  "WARNING: using the `--useDefaultValues` without the `--clean` flag has no effect. Please re-run audit and add the `--clean` flag"
2396
2444
  )
2397
2445
  );
@@ -2419,10 +2467,10 @@ var audit = async ({
2419
2467
  }
2420
2468
  if (error) {
2421
2469
  logger.error(
2422
- import_chalk4.default.redBright(`\u203C\uFE0F Audit ${import_chalk4.default.bold("failed")} with errors`)
2470
+ import_chalk5.default.redBright(`\u203C\uFE0F Audit ${import_chalk5.default.bold("failed")} with errors`)
2423
2471
  );
2424
2472
  } else {
2425
- logger.info(import_chalk4.default.greenBright("\u2705 Audit passed"));
2473
+ logger.info(import_chalk5.default.greenBright("\u2705 Audit passed"));
2426
2474
  }
2427
2475
  };
2428
2476
  var auditDocuments = async (args) => {
@@ -2450,10 +2498,10 @@ var auditDocuments = async (args) => {
2450
2498
  if (docResult.errors) {
2451
2499
  error = true;
2452
2500
  docResult.errors.forEach((err) => {
2453
- logger.error(import_chalk4.default.red(err.message));
2501
+ logger.error(import_chalk5.default.red(err.message));
2454
2502
  if (err.originalError.originalError) {
2455
2503
  logger.error(
2456
- import_chalk4.default.red(` ${err.originalError.originalError.message}`)
2504
+ import_chalk5.default.red(` ${err.originalError.originalError.message}`)
2457
2505
  );
2458
2506
  }
2459
2507
  });
@@ -2495,7 +2543,7 @@ var auditDocuments = async (args) => {
2495
2543
  if (mutationRes.errors) {
2496
2544
  mutationRes.errors.forEach((err) => {
2497
2545
  error = true;
2498
- logger.error(import_chalk4.default.red(err.message));
2546
+ logger.error(import_chalk5.default.red(err.message));
2499
2547
  });
2500
2548
  }
2501
2549
  }
@@ -2557,8 +2605,7 @@ var AuditCommand = class extends import_clipanion3.Command {
2557
2605
  Number(this.datalayerPort),
2558
2606
  this.clean ? void 0 : new import_graphql13.AuditFileSystemBridge(configManager.rootPath)
2559
2607
  );
2560
- const { tinaSchema, graphQLSchema } = await (0, import_graphql12.buildSchema)(
2561
- database,
2608
+ const { tinaSchema, graphQLSchema, lookup } = await (0, import_graphql12.buildSchema)(
2562
2609
  configManager.config
2563
2610
  );
2564
2611
  const warnings = [];
@@ -2566,7 +2613,8 @@ var AuditCommand = class extends import_clipanion3.Command {
2566
2613
  waitFor: async () => {
2567
2614
  const res = await database.indexContent({
2568
2615
  graphQLSchema,
2569
- tinaSchema
2616
+ tinaSchema,
2617
+ lookup
2570
2618
  });
2571
2619
  warnings.push(...res.warnings);
2572
2620
  },
@@ -2598,7 +2646,7 @@ AuditCommand.usage = import_clipanion3.Command.Usage({
2598
2646
  var import_clipanion5 = require("clipanion");
2599
2647
 
2600
2648
  // src/cmds/init/index.ts
2601
- var import_path10 = __toESM(require("path"));
2649
+ var import_path11 = __toESM(require("path"));
2602
2650
  var import_prettier2 = require("prettier");
2603
2651
  var import_fs_extra9 = __toESM(require("fs-extra"));
2604
2652
  var import_prompts2 = __toESM(require("prompts"));
@@ -2953,14 +3001,14 @@ var configExamples = {
2953
3001
 
2954
3002
  // src/cmds/forestry-migrate/index.ts
2955
3003
  var import_fs_extra7 = __toESM(require("fs-extra"));
2956
- var import_path8 = __toESM(require("path"));
3004
+ var import_path9 = __toESM(require("path"));
2957
3005
  var import_js_yaml2 = __toESM(require("js-yaml"));
2958
3006
  var import_minimatch = __toESM(require("minimatch"));
2959
3007
  var import_graphql14 = require("@tinacms/graphql");
2960
3008
 
2961
3009
  // src/cmds/forestry-migrate/util/index.ts
2962
3010
  var import_fs_extra6 = __toESM(require("fs-extra"));
2963
- var import_path7 = __toESM(require("path"));
3011
+ var import_path8 = __toESM(require("path"));
2964
3012
  var import_js_yaml = __toESM(require("js-yaml"));
2965
3013
  var import_zod = __toESM(require("zod"));
2966
3014
 
@@ -3371,7 +3419,7 @@ var transformForestryFieldsToTinaFields = ({
3371
3419
  return tinaFields;
3372
3420
  };
3373
3421
  var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false }) => {
3374
- const templatePath = import_path7.default.join(
3422
+ const templatePath = import_path8.default.join(
3375
3423
  pathToForestryConfig,
3376
3424
  ".forestry",
3377
3425
  "front_matter",
@@ -3446,8 +3494,8 @@ var generateAllTemplates = async ({
3446
3494
  pathToForestryConfig
3447
3495
  }) => {
3448
3496
  const allTemplates = (await import_fs_extra7.default.readdir(
3449
- import_path8.default.join(pathToForestryConfig, ".forestry", "front_matter", "templates")
3450
- )).map((tem) => import_path8.default.basename(tem, ".yml"));
3497
+ import_path9.default.join(pathToForestryConfig, ".forestry", "front_matter", "templates")
3498
+ )).map((tem) => import_path9.default.basename(tem, ".yml"));
3451
3499
  const templateMap = /* @__PURE__ */ new Map();
3452
3500
  const proms = allTemplates.map(async (tem) => {
3453
3501
  try {
@@ -3589,9 +3637,9 @@ var generateCollectionFromForestrySection = (args) => {
3589
3637
  return c;
3590
3638
  } else if (section.type === "document") {
3591
3639
  const filePath = section.path;
3592
- const extname = import_path8.default.extname(filePath);
3593
- const fileName = import_path8.default.basename(filePath, extname);
3594
- const dir = import_path8.default.dirname(filePath);
3640
+ const extname = import_path9.default.extname(filePath);
3641
+ const fileName = import_path9.default.basename(filePath, extname);
3642
+ const dir = import_path9.default.dirname(filePath);
3595
3643
  const ext = checkExt(extname);
3596
3644
  if (ext) {
3597
3645
  const fields = [];
@@ -3654,7 +3702,7 @@ var generateCollections = async ({
3654
3702
  usingTypescript
3655
3703
  });
3656
3704
  const forestryConfig = await import_fs_extra7.default.readFile(
3657
- import_path8.default.join(pathToForestryConfig, ".forestry", "settings.yml")
3705
+ import_path9.default.join(pathToForestryConfig, ".forestry", "settings.yml")
3658
3706
  );
3659
3707
  rewriteTemplateKeysInDocs({
3660
3708
  templateMap,
@@ -3685,11 +3733,11 @@ var rewriteTemplateKeysInDocs = (args) => {
3685
3733
  const { templateObj } = templateMap.get(templateKey);
3686
3734
  (_a = templateObj == null ? void 0 : templateObj.pages) == null ? void 0 : _a.forEach((page) => {
3687
3735
  try {
3688
- const filePath = import_path8.default.join(page);
3736
+ const filePath = import_path9.default.join(page);
3689
3737
  if (import_fs_extra7.default.lstatSync(filePath).isDirectory()) {
3690
3738
  return;
3691
3739
  }
3692
- const extname = import_path8.default.extname(filePath);
3740
+ const extname = import_path9.default.extname(filePath);
3693
3741
  const fileContent = import_fs_extra7.default.readFileSync(filePath).toString();
3694
3742
  const content2 = (0, import_graphql14.parseFile)(
3695
3743
  fileContent,
@@ -3717,7 +3765,7 @@ var rewriteTemplateKeysInDocs = (args) => {
3717
3765
  // src/next/commands/codemod-command/index.ts
3718
3766
  var import_clipanion4 = require("clipanion");
3719
3767
  var import_fs_extra8 = __toESM(require("fs-extra"));
3720
- var import_path9 = __toESM(require("path"));
3768
+ var import_path10 = __toESM(require("path"));
3721
3769
  var CodemodCommand = class extends import_clipanion4.Command {
3722
3770
  constructor() {
3723
3771
  super(...arguments);
@@ -3761,7 +3809,7 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
3761
3809
  logger.error(e.message);
3762
3810
  process.exit(1);
3763
3811
  }
3764
- const tinaDestination = import_path9.default.join(configManager.rootPath, "tina");
3812
+ const tinaDestination = import_path10.default.join(configManager.rootPath, "tina");
3765
3813
  if (await import_fs_extra8.default.existsSync(tinaDestination)) {
3766
3814
  logger.info(
3767
3815
  `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.`
@@ -3776,7 +3824,7 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
3776
3824
  };
3777
3825
  var writeGitignore = async (rootPath) => {
3778
3826
  await import_fs_extra8.default.outputFileSync(
3779
- import_path9.default.join(rootPath, "tina", ".gitignore"),
3827
+ import_path10.default.join(rootPath, "tina", ".gitignore"),
3780
3828
  "__generated__"
3781
3829
  );
3782
3830
  };
@@ -3802,7 +3850,7 @@ async function initStaticTina({
3802
3850
  let templateCode;
3803
3851
  let extraText;
3804
3852
  const hasForestryConfig = await import_fs_extra9.default.pathExists(
3805
- import_path10.default.join(pathToForestryConfig, ".forestry", "settings.yml")
3853
+ import_path11.default.join(pathToForestryConfig, ".forestry", "settings.yml")
3806
3854
  );
3807
3855
  let isForestryMigration = false;
3808
3856
  if (hasForestryConfig) {
@@ -3844,8 +3892,8 @@ async function initStaticTina({
3844
3892
  await addTemplateFile({ baseDir: "", usingTypescript, templateCode });
3845
3893
  }
3846
3894
  await addConfigFile({
3847
- publicFolder: import_path10.default.join(
3848
- import_path10.default.relative(process.cwd(), pathToForestryConfig),
3895
+ publicFolder: import_path11.default.join(
3896
+ import_path11.default.relative(process.cwd(), pathToForestryConfig),
3849
3897
  publicFolder
3850
3898
  ),
3851
3899
  baseDir: "",
@@ -3992,7 +4040,7 @@ ${disclaimer}`
3992
4040
  };
3993
4041
  var getFrontmatterFormat = async (rootPath) => {
3994
4042
  try {
3995
- const hugoConfigPath = import_path10.default.join(rootPath, "config.toml");
4043
+ const hugoConfigPath = import_path11.default.join(rootPath, "config.toml");
3996
4044
  const hugoConfig = await import_fs_extra9.default.readFile(hugoConfigPath, "utf8");
3997
4045
  const frontMatterFormat = hugoConfig.match(/metaDataFormat = "(.*)"/);
3998
4046
  console.log({ frontMatterFormat });
@@ -4040,22 +4088,22 @@ var createPackageJSON = async () => {
4040
4088
  };
4041
4089
  var createGitignore = async ({ baseDir }) => {
4042
4090
  logger.info(logText("No .gitignore found, creating one"));
4043
- await import_fs_extra9.default.outputFileSync(import_path10.default.join(baseDir, ".gitignore"), "node_modules");
4091
+ await import_fs_extra9.default.outputFileSync(import_path11.default.join(baseDir, ".gitignore"), "node_modules");
4044
4092
  };
4045
4093
  var checkGitignoreForNodeModules = async ({
4046
4094
  baseDir
4047
4095
  }) => {
4048
- const gitignoreContent = await import_fs_extra9.default.readFileSync(import_path10.default.join(baseDir, ".gitignore")).toString();
4096
+ const gitignoreContent = await import_fs_extra9.default.readFileSync(import_path11.default.join(baseDir, ".gitignore")).toString();
4049
4097
  return gitignoreContent.split("\n").some((item) => item === "node_modules");
4050
4098
  };
4051
4099
  var addNodeModulesToGitignore = async ({ baseDir }) => {
4052
4100
  logger.info(logText("Adding node_modules to .gitignore"));
4053
- const gitignoreContent = await import_fs_extra9.default.readFileSync(import_path10.default.join(baseDir, ".gitignore")).toString();
4101
+ const gitignoreContent = await import_fs_extra9.default.readFileSync(import_path11.default.join(baseDir, ".gitignore")).toString();
4054
4102
  const newGitignoreContent = [
4055
4103
  ...gitignoreContent.split("\n"),
4056
4104
  "node_modules"
4057
4105
  ].join("\n");
4058
- await import_fs_extra9.default.writeFileSync(import_path10.default.join(baseDir, ".gitignore"), newGitignoreContent);
4106
+ await import_fs_extra9.default.writeFileSync(import_path11.default.join(baseDir, ".gitignore"), newGitignoreContent);
4059
4107
  };
4060
4108
  var addDependencies = async (packageManager) => {
4061
4109
  logger.info(logText("Adding dependencies, this might take a moment..."));
@@ -4070,11 +4118,11 @@ var addDependencies = async (packageManager) => {
4070
4118
  };
4071
4119
  var addConfigFile = async (args) => {
4072
4120
  const { baseDir, usingTypescript } = args;
4073
- const configPath = import_path10.default.join(
4121
+ const configPath = import_path11.default.join(
4074
4122
  "tina",
4075
4123
  `config.${usingTypescript ? "ts" : "js"}`
4076
4124
  );
4077
- const fullConfigPath = import_path10.default.join(baseDir, configPath);
4125
+ const fullConfigPath = import_path11.default.join(baseDir, configPath);
4078
4126
  if (import_fs_extra9.default.pathExistsSync(fullConfigPath)) {
4079
4127
  const override = await (0, import_prompts2.default)({
4080
4128
  name: "selection",
@@ -4099,11 +4147,11 @@ var addConfigFile = async (args) => {
4099
4147
  };
4100
4148
  var addTemplateFile = async (args) => {
4101
4149
  const { baseDir, usingTypescript, templateCode } = args;
4102
- const templatesPath = import_path10.default.join(
4150
+ const templatesPath = import_path11.default.join(
4103
4151
  "tina",
4104
4152
  `templates.${usingTypescript ? "ts" : "js"}`
4105
4153
  );
4106
- const fullTemplatesPath = import_path10.default.join(baseDir, templatesPath);
4154
+ const fullTemplatesPath = import_path11.default.join(baseDir, templatesPath);
4107
4155
  if (import_fs_extra9.default.pathExistsSync(fullTemplatesPath)) {
4108
4156
  const override = await (0, import_prompts2.default)({
4109
4157
  name: "selection",
@@ -4122,8 +4170,8 @@ var addTemplateFile = async (args) => {
4122
4170
  }
4123
4171
  };
4124
4172
  var addContentFile = async ({ baseDir }) => {
4125
- const contentPath = import_path10.default.join("content", "posts", "hello-world.md");
4126
- const fullContentPath = import_path10.default.join(baseDir, contentPath);
4173
+ const contentPath = import_path11.default.join("content", "posts", "hello-world.md");
4174
+ const fullContentPath = import_path11.default.join(baseDir, contentPath);
4127
4175
  if (import_fs_extra9.default.pathExistsSync(fullContentPath)) {
4128
4176
  const override = await (0, import_prompts2.default)({
4129
4177
  name: "selection",
@@ -4198,11 +4246,11 @@ var addReactiveFile = {
4198
4246
  baseDir,
4199
4247
  usingTypescript
4200
4248
  }) => {
4201
- const usingSrc = !import_fs_extra9.default.pathExistsSync(import_path10.default.join(baseDir, "pages"));
4202
- const pagesPath = import_path10.default.join(baseDir, usingSrc ? "src" : "", "pages");
4203
- const packageJSONPath = import_path10.default.join(baseDir, "package.json");
4204
- const tinaBlogPagePath = import_path10.default.join(pagesPath, "demo", "blog");
4205
- const tinaBlogPagePathFile = import_path10.default.join(
4249
+ const usingSrc = !import_fs_extra9.default.pathExistsSync(import_path11.default.join(baseDir, "pages"));
4250
+ const pagesPath = import_path11.default.join(baseDir, usingSrc ? "src" : "", "pages");
4251
+ const packageJSONPath = import_path11.default.join(baseDir, "package.json");
4252
+ const tinaBlogPagePath = import_path11.default.join(pagesPath, "demo", "blog");
4253
+ const tinaBlogPagePathFile = import_path11.default.join(
4206
4254
  tinaBlogPagePath,
4207
4255
  `[filename].${usingTypescript ? "tsx" : "js"}`
4208
4256
  );
@@ -1,5 +1,6 @@
1
- import { GraphQLSchema } from 'graphql';
1
+ import type { TypeDefinitionNode, GraphQLSchema } from 'graphql';
2
2
  import { ConfigManager } from '../config-manager';
3
+ import type { TinaSchema } from '@tinacms/schema-tools';
3
4
  export declare const TINA_HOST = "content.tinajs.io";
4
5
  export declare class Codegen {
5
6
  configManager: ConfigManager;
@@ -7,13 +8,25 @@ export declare class Codegen {
7
8
  schema: GraphQLSchema;
8
9
  queryDoc: string;
9
10
  fragDoc: string;
10
- constructor({ configManager, port, schema, queryDoc, fragDoc, }: {
11
+ graphqlSchemaDoc: {
12
+ kind: 'Document';
13
+ definitions: TypeDefinitionNode[];
14
+ };
15
+ tinaSchema: TinaSchema;
16
+ lookup: any;
17
+ constructor({ configManager, port, queryDoc, fragDoc, graphqlSchemaDoc, tinaSchema, lookup, }: {
11
18
  configManager: ConfigManager;
12
19
  port?: number;
13
- schema: GraphQLSchema;
14
20
  queryDoc: string;
15
21
  fragDoc: string;
22
+ graphqlSchemaDoc: {
23
+ kind: 'Document';
24
+ definitions: TypeDefinitionNode[];
25
+ };
26
+ tinaSchema: TinaSchema;
27
+ lookup: any;
16
28
  });
29
+ writeConfigFile(fileName: string, data: string): Promise<void>;
17
30
  removeGeneratedFilesIfExists(): Promise<void>;
18
31
  execute(): Promise<string>;
19
32
  getApiURL(): string;
@@ -2,6 +2,7 @@ import type { Loader } from 'esbuild';
2
2
  import { Config } from '@tinacms/schema-tools';
3
3
  export declare const TINA_FOLDER = "tina";
4
4
  export declare const LEGACY_TINA_FOLDER = ".tina";
5
+ export declare const GENERATED_FOLDER = "__generated__";
5
6
  export declare class ConfigManager {
6
7
  config: Config;
7
8
  rootPath: string;
@@ -12,6 +13,7 @@ export declare class ConfigManager {
12
13
  contentRootPath?: string;
13
14
  envFilePath: string;
14
15
  generatedFolderPath: string;
16
+ generatedFolderPathContentRepo: string;
15
17
  generatedGraphQLGQLPath: string;
16
18
  generatedGraphQLJSONPath: string;
17
19
  generatedSchemaJSONPath: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/cli",
3
- "version": "1.5.10",
3
+ "version": "1.5.11",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [
@@ -58,9 +58,9 @@
58
58
  "@tailwindcss/aspect-ratio": "^0.4.0",
59
59
  "@tailwindcss/line-clamp": "^0.3.1",
60
60
  "@tailwindcss/typography": "^0.5.9",
61
- "@tinacms/app": "1.2.10",
62
- "@tinacms/datalayer": "1.2.10",
63
- "@tinacms/graphql": "1.4.10",
61
+ "@tinacms/app": "1.2.11",
62
+ "@tinacms/datalayer": "1.2.11",
63
+ "@tinacms/graphql": "1.4.11",
64
64
  "@tinacms/metrics": "1.0.2",
65
65
  "@tinacms/schema-tools": "1.4.3",
66
66
  "@vitejs/plugin-react": "3.1.0",