@tinacms/cli 1.5.11 → 1.5.13

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
@@ -28,13 +28,13 @@ __export(src_exports, {
28
28
  default: () => src_default
29
29
  });
30
30
  module.exports = __toCommonJS(src_exports);
31
- var import_clipanion6 = require("clipanion");
31
+ var import_clipanion7 = require("clipanion");
32
32
 
33
33
  // package.json
34
- var version = "1.5.11";
34
+ var version = "1.5.13";
35
35
 
36
36
  // src/next/commands/dev-command/index.ts
37
- var import_clipanion = require("clipanion");
37
+ var import_clipanion2 = require("clipanion");
38
38
  var import_fs_extra4 = __toESM(require("fs-extra"));
39
39
  var import_path7 = __toESM(require("path"));
40
40
  var import_chokidar = __toESM(require("chokidar"));
@@ -92,15 +92,16 @@ ${message}
92
92
  len - strip(ln).length
93
93
  )}${import_chalk.default.gray(bar)}`
94
94
  ).join("\n");
95
+ const underscoreLen = len - title.length - 1 > 0 ? len - title.length - 1 : 0;
95
96
  process.stdout.write(
96
97
  `${import_chalk.default.gray(bar)}
97
98
  ${import_chalk.default.green("\u25CB")} ${import_chalk.default.reset(
98
99
  title
99
- )} ${import_chalk.default.gray(
100
- "\u2500".repeat(len - title.length - 1) + "\u256E"
101
- )}
100
+ )} ${import_chalk.default.gray("\u2500".repeat(underscoreLen) + "\u256E")}
102
101
  ${msg}
103
- ${import_chalk.default.gray("\u251C" + "\u2500".repeat(len + 2) + "\u256F")}
102
+ ${import_chalk.default.gray(
103
+ "\u251C" + "\u2500".repeat(len + 2) + "\u256F"
104
+ )}
104
105
  `
105
106
  );
106
107
  };
@@ -451,6 +452,48 @@ var loaders = {
451
452
  };
452
453
 
453
454
  // src/next/commands/dev-command/html.ts
455
+ var errorHTML = `<style type="text/css">
456
+ #no-assets-placeholder body {
457
+ font-family: sans-serif;
458
+ font-size: 16px;
459
+ line-height: 1.4;
460
+ color: #333;
461
+ background-color: #f5f5f5;
462
+ }
463
+ #no-assets-placeholder {
464
+ max-width: 600px;
465
+ margin: 0 auto;
466
+ padding: 40px;
467
+ text-align: center;
468
+ background-color: #fff;
469
+ box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.1);
470
+ }
471
+ #no-assets-placeholder h1 {
472
+ font-size: 24px;
473
+ margin-bottom: 20px;
474
+ }
475
+ #no-assets-placeholder p {
476
+ margin-bottom: 10px;
477
+ }
478
+ #no-assets-placeholder a {
479
+ color: #0077cc;
480
+ text-decoration: none;
481
+ }
482
+ #no-assets-placeholder a:hover {
483
+ text-decoration: underline;
484
+ }
485
+ </style>
486
+ <div id="no-assets-placeholder">
487
+ <h1>Failed loading TinaCMS assets</h1>
488
+ <p>
489
+ Your TinaCMS configuration may be misconfigured, and we could not load
490
+ the assets for this page.
491
+ </p>
492
+ <p>
493
+ 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.
494
+ </p>
495
+ </div>
496
+ </div>`.trim().replace(/[\r\n\s]+/g, " ");
454
497
  var devHTML = (port) => `<!DOCTYPE html>
455
498
  <html lang="en">
456
499
  <head>
@@ -468,9 +511,16 @@ var devHTML = (port) => `<!DOCTYPE html>
468
511
  window.__vite_plugin_react_preamble_installed__ = true
469
512
  <\/script>
470
513
  <script type="module" src="http://localhost:${port}/@vite/client"><\/script>
514
+ <script>
515
+ function handleLoadError() {
516
+ // Assets have failed to load
517
+ document.getElementById('root').innerHTML = '${errorHTML}';
518
+ }
519
+ <\/script>
471
520
  <script
472
521
  type="module"
473
522
  src="http://localhost:${port}/src/main.tsx"
523
+ onerror="handleLoadError()"
474
524
  ><\/script>
475
525
  <body class="tina-tailwind">
476
526
  <div id="root"></div>
@@ -779,9 +829,15 @@ var createConfig = async ({
779
829
  } else {
780
830
  alias["CLIENT_IMPORT"] = configManager.isUsingTs() ? configManager.generatedTypesTSFilePath : configManager.generatedTypesJSFilePath;
781
831
  }
832
+ let basePath;
833
+ if (configManager.config.build.basePath) {
834
+ basePath = configManager.config.build.basePath;
835
+ }
782
836
  const config3 = {
783
837
  root: configManager.spaRootPath,
784
- base: `/${(0, import_normalize_path2.default)(configManager.config.build.outputFolder)}/`,
838
+ base: `/${basePath ? `${(0, import_normalize_path2.default)(basePath)}/` : ""}${(0, import_normalize_path2.default)(
839
+ configManager.config.build.outputFolder
840
+ )}/`,
785
841
  appType: "spa",
786
842
  resolve: {
787
843
  alias,
@@ -794,6 +850,7 @@ var createConfig = async ({
794
850
  __TOKEN__: `"${configManager.config.token}"`,
795
851
  __TINA_GRAPHQL_VERSION__: `"${configManager.getTinaGraphQLVersion()}"`
796
852
  },
853
+ logLevel: "error",
797
854
  optimizeDeps: {
798
855
  force: true,
799
856
  include: ["react/jsx-runtime", "react/jsx-dev-runtime"]
@@ -863,8 +920,11 @@ var createMediaRouter = (config3) => {
863
920
  };
864
921
  const handlePost = async function(req, res) {
865
922
  const bb = (0, import_busboy.default)({ headers: req.headers });
866
- bb.on("file", (name2, file, info) => {
867
- const saveTo = import_path4.default.join(mediaFolder, info.filename);
923
+ bb.on("file", async (_name, file, _info) => {
924
+ var _a;
925
+ const fullPath = (_a = req.url) == null ? void 0 : _a.slice("/media/upload/".length);
926
+ const saveTo = import_path4.default.join(mediaFolder, ...fullPath.split("/"));
927
+ await import_fs_extra2.default.ensureDir(import_path4.default.dirname(saveTo));
868
928
  file.pipe(import_fs_extra2.default.createWriteStream(saveTo));
869
929
  });
870
930
  bb.on("error", (error) => {
@@ -906,6 +966,12 @@ var MediaModel = class {
906
966
  args.searchPath
907
967
  );
908
968
  const searchPath = parseMediaFolder(args.searchPath);
969
+ if (!await import_fs_extra2.default.pathExists(folderPath)) {
970
+ return {
971
+ files: [],
972
+ directories: []
973
+ };
974
+ }
909
975
  const filesStr = await import_fs_extra2.default.readdir(folderPath);
910
976
  const filesProm = filesStr.map(async (file) => {
911
977
  const filePath = (0, import_path4.join)(folderPath, file);
@@ -1323,10 +1389,12 @@ var Codegen = class {
1323
1389
  port,
1324
1390
  queryDoc,
1325
1391
  fragDoc,
1392
+ isLocal,
1326
1393
  graphqlSchemaDoc,
1327
1394
  tinaSchema,
1328
1395
  lookup
1329
1396
  }) {
1397
+ this.isLocal = isLocal;
1330
1398
  this.graphqlSchemaDoc = graphqlSchemaDoc;
1331
1399
  this.configManager = configManager;
1332
1400
  this.port = port;
@@ -1359,7 +1427,6 @@ var Codegen = class {
1359
1427
  await unlinkIfExists(this.configManager.generatedFragmentsFilePath);
1360
1428
  }
1361
1429
  async execute() {
1362
- console.log("Generating Tina Files");
1363
1430
  await this.writeConfigFile(
1364
1431
  "_graphql.json",
1365
1432
  JSON.stringify(this.graphqlSchemaDoc)
@@ -1369,7 +1436,10 @@ var Codegen = class {
1369
1436
  JSON.stringify(this.tinaSchema.schema)
1370
1437
  );
1371
1438
  await this.writeConfigFile("_lookup.json", JSON.stringify(this.lookup));
1372
- const apiURL = this.getApiURL();
1439
+ const { apiURL, localUrl, tinaCloudUrl } = this._createApiUrl();
1440
+ this.apiURL = apiURL;
1441
+ this.localUrl = localUrl;
1442
+ this.productionUrl = tinaCloudUrl;
1373
1443
  if (this.configManager.shouldSkipSDK()) {
1374
1444
  await this.removeGeneratedFilesIfExists();
1375
1445
  return apiURL;
@@ -1420,7 +1490,7 @@ var Codegen = class {
1420
1490
  }
1421
1491
  return apiURL;
1422
1492
  }
1423
- getApiURL() {
1493
+ _createApiUrl() {
1424
1494
  var _a, _b, _c, _d;
1425
1495
  const branch = (_a = this.configManager.config) == null ? void 0 : _a.branch;
1426
1496
  const clientId = (_b = this.configManager.config) == null ? void 0 : _b.clientId;
@@ -1441,11 +1511,20 @@ var Codegen = class {
1441
1511
  )}. Please visit https://tina.io/docs/tina-cloud/connecting-site/ for more information`
1442
1512
  );
1443
1513
  }
1444
- let apiURL = this.port ? `http://localhost:${this.port}/graphql` : `${baseUrl}/${version2}/content/${clientId}/github/${branch}`;
1514
+ let localUrl = `http://localhost:${this.port}/graphql`;
1515
+ let tinaCloudUrl = `${baseUrl}/${version2}/content/${clientId}/github/${branch}`;
1516
+ let apiURL = this.isLocal ? `http://localhost:${this.port}/graphql` : `${baseUrl}/${version2}/content/${clientId}/github/${branch}`;
1445
1517
  if (this.configManager.config.contentApiUrlOverride) {
1446
1518
  apiURL = this.configManager.config.contentApiUrlOverride;
1519
+ localUrl = apiURL;
1520
+ tinaCloudUrl = apiURL;
1447
1521
  }
1448
- return apiURL;
1522
+ return { apiURL, localUrl, tinaCloudUrl };
1523
+ }
1524
+ getApiURL() {
1525
+ if (!this.apiURL)
1526
+ throw new Error("apiURL not set. Please run execute() first");
1527
+ return this.apiURL;
1449
1528
  }
1450
1529
  async genClient() {
1451
1530
  var _a;
@@ -1509,7 +1588,58 @@ var unlinkIfExists = async (filepath) => {
1509
1588
  }
1510
1589
  };
1511
1590
 
1512
- // src/next/commands/dev-command/index.ts
1591
+ // src/next/database.ts
1592
+ var import_graphql7 = require("@tinacms/graphql");
1593
+ var import_readable_stream = require("readable-stream");
1594
+ var import_net = require("net");
1595
+ var import_many_level = require("many-level");
1596
+ var import_memory_level = require("memory-level");
1597
+ var createDBServer = (port) => {
1598
+ const levelHost = new import_many_level.ManyLevelHost(
1599
+ new import_memory_level.MemoryLevel({
1600
+ valueEncoding: "json"
1601
+ })
1602
+ );
1603
+ const dbServer = (0, import_net.createServer)(function(socket) {
1604
+ return (0, import_readable_stream.pipeline)(socket, levelHost.createRpcStream(), socket, () => {
1605
+ });
1606
+ });
1607
+ dbServer.once("error", (err) => {
1608
+ if ((err == null ? void 0 : err.code) === "EADDRINUSE") {
1609
+ throw new Error(
1610
+ `Tina Dev server is already in use. Datalayer server is busy on port ${port}`
1611
+ );
1612
+ }
1613
+ });
1614
+ dbServer.listen(port);
1615
+ };
1616
+ async function createAndInitializeDatabase(configManager, datalayerPort, bridgeOverride) {
1617
+ let database;
1618
+ const bridge = bridgeOverride || new import_graphql7.FilesystemBridge(configManager.rootPath, configManager.contentRootPath);
1619
+ if (configManager.hasSelfHostedConfig() && configManager.config.contentApiUrlOverride) {
1620
+ database = await configManager.loadDatabaseFile();
1621
+ database.bridge = bridge;
1622
+ } else {
1623
+ if (configManager.hasSelfHostedConfig() && !configManager.config.contentApiUrlOverride) {
1624
+ logger.warn(
1625
+ `Found a database config file at ${configManager.printRelativePath(
1626
+ configManager.selfHostedDatabaseFilePath
1627
+ )} but there was no "contentApiUrlOverride" set. Falling back to built-in datalayer`
1628
+ );
1629
+ }
1630
+ const level = new import_graphql7.TinaLevelClient(datalayerPort);
1631
+ level.openConnection();
1632
+ database = (0, import_graphql7.createDatabase)({
1633
+ bridge,
1634
+ level,
1635
+ tinaDirectory: configManager.isUsingLegacyFolder ? LEGACY_TINA_FOLDER : TINA_FOLDER
1636
+ });
1637
+ }
1638
+ return database;
1639
+ }
1640
+
1641
+ // src/next/commands/baseCommands.ts
1642
+ var import_clipanion = require("clipanion");
1513
1643
  var import_chalk4 = __toESM(require("chalk"));
1514
1644
 
1515
1645
  // src/utils/start-subprocess.ts
@@ -1561,56 +1691,6 @@ stack: ${code.stack || "No stack was provided"}`);
1561
1691
  }
1562
1692
  };
1563
1693
 
1564
- // src/next/database.ts
1565
- var import_graphql7 = require("@tinacms/graphql");
1566
- var import_readable_stream = require("readable-stream");
1567
- var import_net = require("net");
1568
- var import_many_level = require("many-level");
1569
- var import_memory_level = require("memory-level");
1570
- var createDBServer = (port) => {
1571
- const levelHost = new import_many_level.ManyLevelHost(
1572
- new import_memory_level.MemoryLevel({
1573
- valueEncoding: "json"
1574
- })
1575
- );
1576
- const dbServer = (0, import_net.createServer)(function(socket) {
1577
- return (0, import_readable_stream.pipeline)(socket, levelHost.createRpcStream(), socket, () => {
1578
- });
1579
- });
1580
- dbServer.once("error", (err) => {
1581
- if ((err == null ? void 0 : err.code) === "EADDRINUSE") {
1582
- throw new Error(
1583
- `Tina Dev server is already in use. Datalayer server is busy on port ${port}`
1584
- );
1585
- }
1586
- });
1587
- dbServer.listen(port);
1588
- };
1589
- async function createAndInitializeDatabase(configManager, datalayerPort, bridgeOverride) {
1590
- let database;
1591
- const bridge = bridgeOverride || new import_graphql7.FilesystemBridge(configManager.rootPath, configManager.contentRootPath);
1592
- if (configManager.hasSelfHostedConfig() && configManager.config.contentApiUrlOverride) {
1593
- database = await configManager.loadDatabaseFile();
1594
- database.bridge = bridge;
1595
- } else {
1596
- if (configManager.hasSelfHostedConfig() && !configManager.config.contentApiUrlOverride) {
1597
- logger.warn(
1598
- `Found a database config file at ${configManager.printRelativePath(
1599
- configManager.selfHostedDatabaseFilePath
1600
- )} but there was no "contentApiUrlOverride" set. Falling back to built-in datalayer`
1601
- );
1602
- }
1603
- const level = new import_graphql7.TinaLevelClient(datalayerPort);
1604
- level.openConnection();
1605
- database = (0, import_graphql7.createDatabase)({
1606
- bridge,
1607
- level,
1608
- tinaDirectory: configManager.isUsingLegacyFolder ? LEGACY_TINA_FOLDER : TINA_FOLDER
1609
- });
1610
- }
1611
- return database;
1612
- }
1613
-
1614
1694
  // src/utils/spinner.ts
1615
1695
  var import_cli_spinner = require("cli-spinner");
1616
1696
  async function localSpin({
@@ -1647,10 +1727,16 @@ function spin({
1647
1727
  }
1648
1728
  }
1649
1729
 
1650
- // src/next/commands/dev-command/index.ts
1651
- var DevCommand = class extends import_clipanion.Command {
1730
+ // src/next/commands/baseCommands.ts
1731
+ var BaseCommand = class extends import_clipanion.Command {
1652
1732
  constructor() {
1653
1733
  super(...arguments);
1734
+ this.experimentalDataLayer = import_clipanion.Option.Boolean("--experimentalData", {
1735
+ description: "DEPRECATED - Build the server with additional data querying capabilities"
1736
+ });
1737
+ this.isomorphicGitBridge = import_clipanion.Option.Boolean("--isomorphicGitBridge", {
1738
+ description: "DEPRECATED - Enable Isomorphic Git Bridge Implementation"
1739
+ });
1654
1740
  this.port = import_clipanion.Option.String("-p,--port", "4001", {
1655
1741
  description: "Specify a port to run the server on. (default 4001)"
1656
1742
  });
@@ -1663,21 +1749,9 @@ var DevCommand = class extends import_clipanion.Command {
1663
1749
  this.rootPath = import_clipanion.Option.String("--rootPath", {
1664
1750
  description: "Specify the root directory to run the CLI from (defaults to current working directory)"
1665
1751
  });
1666
- this.watchFolders = import_clipanion.Option.String("-w,--watchFolders", {
1667
- description: "DEPRECATED - a list of folders (relative to where this is being run) that the cli will watch for changes"
1668
- });
1669
- this.isomorphicGitBridge = import_clipanion.Option.Boolean("--isomorphicGitBridge", {
1670
- description: "DEPRECATED - Enable Isomorphic Git Bridge Implementation"
1671
- });
1672
- this.experimentalDataLayer = import_clipanion.Option.Boolean("--experimentalData", {
1673
- description: "DEPRECATED - Build the server with additional data querying capabilities"
1674
- });
1675
1752
  this.verbose = import_clipanion.Option.Boolean("-v,--verbose", false, {
1676
1753
  description: "increase verbosity of logged output"
1677
1754
  });
1678
- this.noWatch = import_clipanion.Option.Boolean("--noWatch", false, {
1679
- description: "Don't regenerate config on file changes"
1680
- });
1681
1755
  this.noSDK = import_clipanion.Option.Boolean("--noSDK", false, {
1682
1756
  description: "DEPRECATED - This should now be set in the config at client.skip = true'. Don't generate the generated client SDK"
1683
1757
  });
@@ -1685,17 +1759,25 @@ var DevCommand = class extends import_clipanion.Command {
1685
1759
  description: "Disable anonymous telemetry that is collected"
1686
1760
  });
1687
1761
  }
1688
- async catch(error) {
1689
- logger.error("Error occured during tinacms dev");
1690
- console.error(error);
1691
- process.exit(1);
1692
- }
1693
- async execute() {
1694
- if (this.watchFolders) {
1695
- logger.warn(
1696
- "--watchFolders has been deprecated, imports from your Tina config file will be watched automatically. If you still need it please open a ticket at https://github.com/tinacms/tinacms/issues"
1697
- );
1762
+ async startSubCommand() {
1763
+ let subProc;
1764
+ if (this.subCommand) {
1765
+ subProc = await startSubprocess2({ command: this.subCommand });
1766
+ logger.info(`Starting subprocess: ${import_chalk4.default.cyan(this.subCommand)}`);
1698
1767
  }
1768
+ function exitHandler(options, exitCode) {
1769
+ if (subProc) {
1770
+ subProc.kill();
1771
+ }
1772
+ process.exit();
1773
+ }
1774
+ process.on("exit", exitHandler);
1775
+ process.on("SIGINT", exitHandler);
1776
+ process.on("SIGUSR1", exitHandler);
1777
+ process.on("SIGUSR2", exitHandler);
1778
+ process.on("uncaughtException", exitHandler);
1779
+ }
1780
+ logDeprecationWarnings() {
1699
1781
  if (this.isomorphicGitBridge) {
1700
1782
  logger.warn("--isomorphicGitBridge has been deprecated");
1701
1783
  }
@@ -1709,11 +1791,63 @@ var DevCommand = class extends import_clipanion.Command {
1709
1791
  "--noSDK has been deprecated, and will be unsupported in a future release. This should be set in the config at client.skip = true"
1710
1792
  );
1711
1793
  }
1794
+ }
1795
+ async indexContentWithSpinner({
1796
+ database,
1797
+ graphQLSchema,
1798
+ tinaSchema
1799
+ }) {
1800
+ const warnings = [];
1801
+ await spin({
1802
+ waitFor: async () => {
1803
+ const res = await database.indexContent({
1804
+ graphQLSchema,
1805
+ tinaSchema
1806
+ });
1807
+ warnings.push(...res.warnings);
1808
+ },
1809
+ text: "Indexing local files"
1810
+ });
1811
+ if (warnings.length > 0) {
1812
+ logger.warn(`Indexing completed with ${warnings.length} warning(s)`);
1813
+ warnings.forEach((warning) => {
1814
+ logger.warn(warnText(`${warning}`));
1815
+ });
1816
+ }
1817
+ }
1818
+ };
1819
+
1820
+ // src/next/commands/dev-command/index.ts
1821
+ var DevCommand = class extends BaseCommand {
1822
+ constructor() {
1823
+ super(...arguments);
1824
+ this.watchFolders = import_clipanion2.Option.String("-w,--watchFolders", {
1825
+ description: "DEPRECATED - a list of folders (relative to where this is being run) that the cli will watch for changes"
1826
+ });
1827
+ this.noWatch = import_clipanion2.Option.Boolean("--noWatch", false, {
1828
+ description: "Don't regenerate config on file changes"
1829
+ });
1830
+ }
1831
+ async catch(error) {
1832
+ logger.error("Error occured during tinacms dev");
1833
+ console.error(error);
1834
+ process.exit(1);
1835
+ }
1836
+ logDeprecationWarnings() {
1837
+ super.logDeprecationWarnings();
1838
+ if (this.watchFolders) {
1839
+ logger.warn(
1840
+ "--watchFolders has been deprecated, imports from your Tina config file will be watched automatically. If you still need it please open a ticket at https://github.com/tinacms/tinacms/issues"
1841
+ );
1842
+ }
1843
+ }
1844
+ async execute() {
1712
1845
  const configManager = new ConfigManager({
1713
1846
  rootPath: this.rootPath,
1714
1847
  legacyNoSDK: this.noSDK
1715
1848
  });
1716
1849
  logger.info("Starting Tina Dev Server");
1850
+ this.logDeprecationWarnings();
1717
1851
  createDBServer(Number(this.datalayerPort));
1718
1852
  let database = null;
1719
1853
  const setup = async ({ firstTime }) => {
@@ -1741,6 +1875,7 @@ var DevCommand = class extends import_clipanion.Command {
1741
1875
  }
1742
1876
  const { tinaSchema, graphQLSchema, lookup, queryDoc, fragDoc } = await (0, import_graphql8.buildSchema)(configManager.config);
1743
1877
  const codegen2 = new Codegen({
1878
+ isLocal: true,
1744
1879
  configManager,
1745
1880
  port: Number(this.port),
1746
1881
  queryDoc,
@@ -1769,24 +1904,11 @@ var DevCommand = class extends import_clipanion.Command {
1769
1904
  if (!this.noWatch) {
1770
1905
  this.watchQueries(configManager, async () => await codegen2.execute());
1771
1906
  }
1772
- const warnings = [];
1773
- await spin({
1774
- waitFor: async () => {
1775
- const res = await database.indexContent({
1776
- graphQLSchema,
1777
- tinaSchema,
1778
- lookup
1779
- });
1780
- warnings.push(...res.warnings);
1781
- },
1782
- text: "Indexing local files"
1907
+ await this.indexContentWithSpinner({
1908
+ database,
1909
+ graphQLSchema,
1910
+ tinaSchema
1783
1911
  });
1784
- if (warnings.length > 0) {
1785
- logger.warn(`Indexing completed with ${warnings.length} warning(s)`);
1786
- warnings.forEach((warning) => {
1787
- logger.warn(warnText(`${warning}`));
1788
- });
1789
- }
1790
1912
  return { apiURL: apiURL2, database };
1791
1913
  };
1792
1914
  const { apiURL } = await setup({ firstTime: true });
@@ -1872,22 +1994,7 @@ var DevCommand = class extends import_clipanion.Command {
1872
1994
  ...summaryItems
1873
1995
  ]
1874
1996
  });
1875
- let subProc;
1876
- if (this.subCommand) {
1877
- subProc = await startSubprocess2({ command: this.subCommand });
1878
- logger.info(`Starting subprocess: ${import_chalk4.default.cyan(this.subCommand)}`);
1879
- }
1880
- function exitHandler(options, exitCode) {
1881
- if (subProc) {
1882
- subProc.kill();
1883
- }
1884
- process.exit();
1885
- }
1886
- process.on("exit", exitHandler);
1887
- process.on("SIGINT", exitHandler);
1888
- process.on("SIGUSR1", exitHandler);
1889
- process.on("SIGUSR2", exitHandler);
1890
- process.on("uncaughtException", exitHandler);
1997
+ await this.startSubCommand();
1891
1998
  }
1892
1999
  watchContentFiles(configManager, database) {
1893
2000
  const collectionContentFiles = [];
@@ -1929,7 +2036,7 @@ var DevCommand = class extends import_clipanion.Command {
1929
2036
  }
1930
2037
  };
1931
2038
  DevCommand.paths = [["dev"], ["server:start"]];
1932
- DevCommand.usage = import_clipanion.Command.Usage({
2039
+ DevCommand.usage = import_clipanion2.Command.Usage({
1933
2040
  category: `Commands`,
1934
2041
  description: `Builds Tina and starts the dev server`,
1935
2042
  examples: [
@@ -1940,7 +2047,7 @@ DevCommand.usage = import_clipanion.Command.Usage({
1940
2047
 
1941
2048
  // src/next/commands/build-command/index.ts
1942
2049
  var import_node_fetch2 = __toESM(require("node-fetch"));
1943
- var import_clipanion2 = require("clipanion");
2050
+ var import_clipanion3 = require("clipanion");
1944
2051
  var import_progress2 = __toESM(require("progress"));
1945
2052
  var import_fs_extra5 = __toESM(require("fs-extra"));
1946
2053
  var import_graphql9 = require("@tinacms/graphql");
@@ -2080,64 +2187,31 @@ var waitForDB = async (config3, apiUrl, verbose) => {
2080
2187
  };
2081
2188
 
2082
2189
  // src/next/commands/build-command/index.ts
2083
- var BuildCommand = class extends import_clipanion2.Command {
2190
+ var BuildCommand = class extends BaseCommand {
2084
2191
  constructor() {
2085
2192
  super(...arguments);
2086
- this.rootPath = import_clipanion2.Option.String("--rootPath", {
2087
- description: "Specify the root directory to run the CLI from (defaults to current working directory)"
2088
- });
2089
- this.verbose = import_clipanion2.Option.Boolean("-v,--verbose", false, {
2090
- description: "increase verbosity of logged output"
2091
- });
2092
- this.noSDK = import_clipanion2.Option.Boolean("--noSDK", false, {
2093
- description: "DEPRECATED - This should now be set in the config at client.skip = true'. Don't generate the generated client SDK"
2094
- });
2095
- this.datalayerPort = import_clipanion2.Option.String("--datalayer-port", "9000", {
2096
- description: "Specify a port to run the datalayer server on. (default 9000)"
2097
- });
2098
- this.isomorphicGitBridge = import_clipanion2.Option.Boolean("--isomorphicGitBridge", {
2099
- description: "DEPRECATED - Enable Isomorphic Git Bridge Implementation"
2100
- });
2101
- this.localOption = import_clipanion2.Option.Boolean("--local", {
2102
- description: "DEPRECATED: Uses the local file system graphql server"
2103
- });
2104
- this.experimentalDataLayer = import_clipanion2.Option.Boolean("--experimentalData", {
2105
- description: "DEPRECATED - Build the server with additional data querying capabilities"
2106
- });
2107
- this.noTelemetry = import_clipanion2.Option.Boolean("--noTelemetry", false, {
2108
- description: "Disable anonymous telemetry that is collected"
2193
+ this.localOption = import_clipanion3.Option.Boolean("--local", {
2194
+ description: "Starts local Graphql server and builds the local client instead of production client"
2109
2195
  });
2110
- this.tinaGraphQLVersion = import_clipanion2.Option.String("--tina-graphql-version", {
2196
+ this.tinaGraphQLVersion = import_clipanion3.Option.String("--tina-graphql-version", {
2111
2197
  description: "Specify the version of @tinacms/graphql to use (defaults to latest)"
2112
2198
  });
2199
+ this.skipCloudChecks = import_clipanion3.Option.Boolean("--skip-cloud-checks", false, {
2200
+ description: "Skips checking the provided cloud config."
2201
+ });
2113
2202
  }
2114
2203
  async catch(error) {
2115
2204
  console.error(error);
2116
2205
  process.exit(1);
2117
2206
  }
2118
2207
  async execute() {
2208
+ logger.info("Starting Tina build");
2209
+ this.logDeprecationWarnings();
2119
2210
  const configManager = new ConfigManager({
2120
2211
  rootPath: this.rootPath,
2121
2212
  tinaGraphQLVersion: this.tinaGraphQLVersion,
2122
2213
  legacyNoSDK: this.noSDK
2123
2214
  });
2124
- logger.info("Starting Tina build");
2125
- if (this.isomorphicGitBridge) {
2126
- logger.warn("--isomorphicGitBridge has been deprecated");
2127
- }
2128
- if (this.experimentalDataLayer) {
2129
- logger.warn(
2130
- "--experimentalDataLayer has been deprecated, the data layer is now built-in automatically"
2131
- );
2132
- }
2133
- if (this.localOption) {
2134
- logger.warn("--local has been deprecated");
2135
- }
2136
- if (this.noSDK) {
2137
- logger.warn(
2138
- "--noSDK has been deprecated, and will be unsupported in a future release. This should be set in the config at client.skip = true"
2139
- );
2140
- }
2141
2215
  try {
2142
2216
  await configManager.processConfig();
2143
2217
  } catch (e) {
@@ -2145,6 +2219,7 @@ var BuildCommand = class extends import_clipanion2.Command {
2145
2219
  logger.error("Unable to build, please fix your Tina config and try again");
2146
2220
  process.exit(1);
2147
2221
  }
2222
+ let server;
2148
2223
  createDBServer(Number(this.datalayerPort));
2149
2224
  const database = await createAndInitializeDatabase(
2150
2225
  configManager,
@@ -2153,6 +2228,8 @@ var BuildCommand = class extends import_clipanion2.Command {
2153
2228
  const { queryDoc, fragDoc, graphQLSchema, tinaSchema, lookup } = await (0, import_graphql9.buildSchema)(configManager.config);
2154
2229
  const codegen2 = new Codegen({
2155
2230
  configManager,
2231
+ port: this.localOption ? Number(this.port) : void 0,
2232
+ isLocal: this.localOption,
2156
2233
  queryDoc,
2157
2234
  fragDoc,
2158
2235
  graphqlSchemaDoc: graphQLSchema,
@@ -2160,12 +2237,27 @@ var BuildCommand = class extends import_clipanion2.Command {
2160
2237
  lookup
2161
2238
  });
2162
2239
  const apiURL = await codegen2.execute();
2163
- if (!configManager.hasSelfHostedConfig()) {
2164
- await this.checkClientInfo(configManager, apiURL);
2165
- await waitForDB(configManager.config, apiURL, false);
2166
- await this.checkGraphqlSchema(configManager, database, apiURL);
2240
+ if (this.localOption) {
2241
+ await this.indexContentWithSpinner({
2242
+ database,
2243
+ graphQLSchema,
2244
+ tinaSchema
2245
+ });
2246
+ server = await createDevServer(configManager, database, apiURL, true);
2247
+ await server.listen(Number(this.port));
2248
+ console.log("server listening on port", this.port);
2249
+ }
2250
+ const skipCloudChecks = this.skipCloudChecks || configManager.hasSelfHostedConfig();
2251
+ if (!skipCloudChecks) {
2252
+ await this.checkClientInfo(configManager, codegen2.productionUrl);
2253
+ await waitForDB(configManager.config, codegen2.productionUrl, false);
2254
+ await this.checkGraphqlSchema(
2255
+ configManager,
2256
+ database,
2257
+ codegen2.productionUrl
2258
+ );
2167
2259
  }
2168
- await buildProductionSpa(configManager, database, apiURL);
2260
+ await buildProductionSpa(configManager, database, codegen2.productionUrl);
2169
2261
  await import_fs_extra5.default.outputFile(
2170
2262
  configManager.outputGitignorePath,
2171
2263
  "index.html\nassets/"
@@ -2203,7 +2295,11 @@ var BuildCommand = class extends import_clipanion2.Command {
2203
2295
  ...summaryItems
2204
2296
  ]
2205
2297
  });
2206
- process.exit();
2298
+ if (this.subCommand) {
2299
+ await this.startSubCommand();
2300
+ } else {
2301
+ process.exit();
2302
+ }
2207
2303
  }
2208
2304
  async checkClientInfo(configManager, apiURL) {
2209
2305
  const { config: config3 } = configManager;
@@ -2332,7 +2428,7 @@ Additional info: Branch: ${config3.branch}, Client ID: ${config3.clientId} `;
2332
2428
  }
2333
2429
  };
2334
2430
  BuildCommand.paths = [["build"]];
2335
- BuildCommand.usage = import_clipanion2.Command.Usage({
2431
+ BuildCommand.usage = import_clipanion3.Command.Usage({
2336
2432
  category: `Commands`,
2337
2433
  description: `Build the CMS and autogenerated modules for usage with Tina Cloud`
2338
2434
  });
@@ -2396,7 +2492,7 @@ var fetchRemoteGraphqlSchema = async ({
2396
2492
  };
2397
2493
 
2398
2494
  // src/next/commands/audit-command/index.ts
2399
- var import_clipanion3 = require("clipanion");
2495
+ var import_clipanion4 = require("clipanion");
2400
2496
  var import_graphql12 = require("@tinacms/graphql");
2401
2497
 
2402
2498
  // src/next/commands/audit-command/audit.ts
@@ -2561,25 +2657,25 @@ function filterObject(obj) {
2561
2657
 
2562
2658
  // src/next/commands/audit-command/index.ts
2563
2659
  var import_graphql13 = require("@tinacms/graphql");
2564
- var AuditCommand = class extends import_clipanion3.Command {
2660
+ var AuditCommand = class extends import_clipanion4.Command {
2565
2661
  constructor() {
2566
2662
  super(...arguments);
2567
- this.rootPath = import_clipanion3.Option.String("--rootPath", {
2663
+ this.rootPath = import_clipanion4.Option.String("--rootPath", {
2568
2664
  description: "Specify the root directory to run the CLI from"
2569
2665
  });
2570
- this.verbose = import_clipanion3.Option.Boolean("-v,--verbose", false, {
2666
+ this.verbose = import_clipanion4.Option.Boolean("-v,--verbose", false, {
2571
2667
  description: "increase verbosity of logged output"
2572
2668
  });
2573
- this.clean = import_clipanion3.Option.Boolean("--clean", false, {
2669
+ this.clean = import_clipanion4.Option.Boolean("--clean", false, {
2574
2670
  description: "Clean the output"
2575
2671
  });
2576
- this.useDefaultValues = import_clipanion3.Option.Boolean("--useDefaultValues", false, {
2672
+ this.useDefaultValues = import_clipanion4.Option.Boolean("--useDefaultValues", false, {
2577
2673
  description: "When cleaning the output, use defaults on the config"
2578
2674
  });
2579
- this.noTelemetry = import_clipanion3.Option.Boolean("--noTelemetry", false, {
2675
+ this.noTelemetry = import_clipanion4.Option.Boolean("--noTelemetry", false, {
2580
2676
  description: "Disable anonymous telemetry that is collected"
2581
2677
  });
2582
- this.datalayerPort = import_clipanion3.Option.String("--datalayer-port", "9000", {
2678
+ this.datalayerPort = import_clipanion4.Option.String("--datalayer-port", "9000", {
2583
2679
  description: "Specify a port to run the datalayer server on. (default 9000)"
2584
2680
  });
2585
2681
  }
@@ -2637,13 +2733,13 @@ var AuditCommand = class extends import_clipanion3.Command {
2637
2733
  }
2638
2734
  };
2639
2735
  AuditCommand.paths = [["audit"]];
2640
- AuditCommand.usage = import_clipanion3.Command.Usage({
2736
+ AuditCommand.usage = import_clipanion4.Command.Usage({
2641
2737
  category: `Commands`,
2642
2738
  description: `Audit config and content files`
2643
2739
  });
2644
2740
 
2645
2741
  // src/next/commands/init-command/index.ts
2646
- var import_clipanion5 = require("clipanion");
2742
+ var import_clipanion6 = require("clipanion");
2647
2743
 
2648
2744
  // src/cmds/init/index.ts
2649
2745
  var import_path11 = __toESM(require("path"));
@@ -3763,16 +3859,16 @@ var rewriteTemplateKeysInDocs = (args) => {
3763
3859
  };
3764
3860
 
3765
3861
  // src/next/commands/codemod-command/index.ts
3766
- var import_clipanion4 = require("clipanion");
3862
+ var import_clipanion5 = require("clipanion");
3767
3863
  var import_fs_extra8 = __toESM(require("fs-extra"));
3768
3864
  var import_path10 = __toESM(require("path"));
3769
- var CodemodCommand = class extends import_clipanion4.Command {
3865
+ var CodemodCommand = class extends import_clipanion5.Command {
3770
3866
  constructor() {
3771
3867
  super(...arguments);
3772
- this.rootPath = import_clipanion4.Option.String("--rootPath", {
3868
+ this.rootPath = import_clipanion5.Option.String("--rootPath", {
3773
3869
  description: "Specify the root directory to run the CLI from"
3774
3870
  });
3775
- this.verbose = import_clipanion4.Option.Boolean("-v,--verbose", false, {
3871
+ this.verbose = import_clipanion5.Option.Boolean("-v,--verbose", false, {
3776
3872
  description: "increase verbosity of logged output"
3777
3873
  });
3778
3874
  }
@@ -3797,7 +3893,7 @@ var CodemodCommand = class extends import_clipanion4.Command {
3797
3893
  }
3798
3894
  };
3799
3895
  CodemodCommand.paths = [["codemod"], ["codemod", "move-tina-folder"]];
3800
- CodemodCommand.usage = import_clipanion4.Command.Usage({
3896
+ CodemodCommand.usage = import_clipanion5.Command.Usage({
3801
3897
  category: `Commands`,
3802
3898
  description: `Use codemods for various Tina tasks`
3803
3899
  });
@@ -4285,16 +4381,16 @@ function execShellCommand(cmd) {
4285
4381
  }
4286
4382
 
4287
4383
  // src/next/commands/init-command/index.ts
4288
- var InitCommand = class extends import_clipanion5.Command {
4384
+ var InitCommand = class extends import_clipanion6.Command {
4289
4385
  constructor() {
4290
4386
  super(...arguments);
4291
- this.pathToForestryConfig = import_clipanion5.Option.String("--forestryPath", {
4387
+ this.pathToForestryConfig = import_clipanion6.Option.String("--forestryPath", {
4292
4388
  description: "Specify the relative path to the .forestry directory, if importing an existing forestry site."
4293
4389
  });
4294
- this.rootPath = import_clipanion5.Option.String("--rootPath", {
4390
+ this.rootPath = import_clipanion6.Option.String("--rootPath", {
4295
4391
  description: "Specify the root directory to run the CLI from (defaults to current working directory)"
4296
4392
  });
4297
- this.noTelemetry = import_clipanion5.Option.Boolean("--noTelemetry", false, {
4393
+ this.noTelemetry = import_clipanion6.Option.Boolean("--noTelemetry", false, {
4298
4394
  description: "Disable anonymous telemetry that is collected"
4299
4395
  });
4300
4396
  }
@@ -4314,13 +4410,13 @@ var InitCommand = class extends import_clipanion5.Command {
4314
4410
  }
4315
4411
  };
4316
4412
  InitCommand.paths = [["init"]];
4317
- InitCommand.usage = import_clipanion5.Command.Usage({
4413
+ InitCommand.usage = import_clipanion6.Command.Usage({
4318
4414
  category: `Commands`,
4319
4415
  description: `Add Tina to an existing project`
4320
4416
  });
4321
4417
 
4322
4418
  // src/index.ts
4323
- var cli = new import_clipanion6.Cli({
4419
+ var cli = new import_clipanion7.Cli({
4324
4420
  binaryName: `tinacms`,
4325
4421
  binaryLabel: `TinaCMS`,
4326
4422
  binaryVersion: version
@@ -4330,9 +4426,9 @@ cli.register(BuildCommand);
4330
4426
  cli.register(AuditCommand);
4331
4427
  cli.register(InitCommand);
4332
4428
  cli.register(CodemodCommand);
4333
- cli.register(import_clipanion6.Builtins.DefinitionsCommand);
4334
- cli.register(import_clipanion6.Builtins.HelpCommand);
4335
- cli.register(import_clipanion6.Builtins.VersionCommand);
4429
+ cli.register(import_clipanion7.Builtins.DefinitionsCommand);
4430
+ cli.register(import_clipanion7.Builtins.HelpCommand);
4431
+ cli.register(import_clipanion7.Builtins.VersionCommand);
4336
4432
  var src_default = cli;
4337
4433
  // Annotate the CommonJS export names for ESM import in node:
4338
4434
  0 && (module.exports = {});
@@ -8,17 +8,22 @@ export declare class Codegen {
8
8
  schema: GraphQLSchema;
9
9
  queryDoc: string;
10
10
  fragDoc: string;
11
+ isLocal: boolean;
12
+ apiURL: string;
13
+ localUrl: string;
14
+ productionUrl: string;
11
15
  graphqlSchemaDoc: {
12
16
  kind: 'Document';
13
17
  definitions: TypeDefinitionNode[];
14
18
  };
15
19
  tinaSchema: TinaSchema;
16
20
  lookup: any;
17
- constructor({ configManager, port, queryDoc, fragDoc, graphqlSchemaDoc, tinaSchema, lookup, }: {
21
+ constructor({ configManager, port, queryDoc, fragDoc, isLocal, graphqlSchemaDoc, tinaSchema, lookup, }: {
18
22
  configManager: ConfigManager;
19
23
  port?: number;
20
24
  queryDoc: string;
21
25
  fragDoc: string;
26
+ isLocal: boolean;
22
27
  graphqlSchemaDoc: {
23
28
  kind: 'Document';
24
29
  definitions: TypeDefinitionNode[];
@@ -29,6 +34,7 @@ export declare class Codegen {
29
34
  writeConfigFile(fileName: string, data: string): Promise<void>;
30
35
  removeGeneratedFilesIfExists(): Promise<void>;
31
36
  execute(): Promise<string>;
37
+ private _createApiUrl;
32
38
  getApiURL(): string;
33
39
  genClient(): Promise<{
34
40
  apiURL: string;
@@ -0,0 +1,26 @@
1
+ import { Command } from 'clipanion';
2
+ import type { DocumentNode } from 'graphql';
3
+ import type { Database } from '@tinacms/graphql';
4
+ import type { TinaSchema } from '@tinacms/schema-tools';
5
+ /**
6
+ * Base Command for Dev and build
7
+ */
8
+ export declare abstract class BaseCommand extends Command {
9
+ experimentalDataLayer: boolean;
10
+ isomorphicGitBridge: boolean;
11
+ port: string;
12
+ datalayerPort: string;
13
+ subCommand: string;
14
+ rootPath: string;
15
+ verbose: boolean;
16
+ noSDK: boolean;
17
+ noTelemetry: boolean;
18
+ abstract execute(): Promise<number | void>;
19
+ startSubCommand(): Promise<void>;
20
+ logDeprecationWarnings(): void;
21
+ indexContentWithSpinner({ database, graphQLSchema, tinaSchema, }: {
22
+ database: Database;
23
+ graphQLSchema: DocumentNode;
24
+ tinaSchema: TinaSchema;
25
+ }): Promise<void>;
26
+ }
@@ -1,17 +1,14 @@
1
- import { Command } from 'clipanion';
2
1
  import { Database } from '@tinacms/graphql';
3
2
  import { ConfigManager } from '../../config-manager';
4
- export declare class BuildCommand extends Command {
3
+ import { BaseCommand } from '../baseCommands';
4
+ export declare class BuildCommand extends BaseCommand {
5
5
  static paths: string[][];
6
- rootPath: string;
7
- verbose: boolean;
8
- noSDK: boolean;
9
- datalayerPort: string;
10
- isomorphicGitBridge: boolean;
11
6
  localOption: boolean;
12
- experimentalDataLayer: boolean;
13
- noTelemetry: boolean;
14
7
  tinaGraphQLVersion: string;
8
+ /**
9
+ * 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
10
+ */
11
+ skipCloudChecks: boolean;
15
12
  static usage: import("clipanion").Usage;
16
13
  catch(error: any): Promise<void>;
17
14
  execute(): Promise<number | void>;
@@ -1,21 +1,13 @@
1
- import { Command } from 'clipanion';
2
1
  import { Database } from '@tinacms/graphql';
3
2
  import { ConfigManager } from '../../config-manager';
4
- export declare class DevCommand extends Command {
3
+ import { BaseCommand } from '../baseCommands';
4
+ export declare class DevCommand extends BaseCommand {
5
5
  static paths: string[][];
6
- port: string;
7
- datalayerPort: string;
8
- subCommand: string;
9
- rootPath: string;
10
6
  watchFolders: string;
11
- isomorphicGitBridge: boolean;
12
- experimentalDataLayer: boolean;
13
- verbose: boolean;
14
7
  noWatch: boolean;
15
- noSDK: boolean;
16
- noTelemetry: boolean;
17
8
  static usage: import("clipanion").Usage;
18
9
  catch(error: any): Promise<void>;
10
+ logDeprecationWarnings(): void;
19
11
  execute(): Promise<number | void>;
20
12
  watchContentFiles(configManager: ConfigManager, database: Database): void;
21
13
  watchQueries(configManager: ConfigManager, callback: () => Promise<string>): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/cli",
3
- "version": "1.5.11",
3
+ "version": "1.5.13",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [
@@ -58,11 +58,11 @@
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.11",
62
- "@tinacms/datalayer": "1.2.11",
63
- "@tinacms/graphql": "1.4.11",
61
+ "@tinacms/app": "1.2.13",
62
+ "@tinacms/datalayer": "1.2.13",
63
+ "@tinacms/graphql": "1.4.13",
64
64
  "@tinacms/metrics": "1.0.2",
65
- "@tinacms/schema-tools": "1.4.3",
65
+ "@tinacms/schema-tools": "1.4.4",
66
66
  "@vitejs/plugin-react": "3.1.0",
67
67
  "ajv": "^6.12.3",
68
68
  "altair-express-middleware": "4.0.6",
@@ -74,7 +74,6 @@
74
74
  "chokidar": "^3.5.1",
75
75
  "cli-spinner": "^0.2.10",
76
76
  "clipanion": "^3.2.0",
77
- "commander": "^9.0.0",
78
77
  "cors": "^2.8.5",
79
78
  "dotenv": "^16.0.1",
80
79
  "esbuild": "^0.15.5",