@tinacms/cli 1.5.29 → 1.5.31

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.
Files changed (3) hide show
  1. package/LICENSE +1 -9
  2. package/dist/index.js +58 -36
  3. package/package.json +7 -7
package/LICENSE CHANGED
@@ -1,12 +1,4 @@
1
- Copyright (c) 2023-present Forestry.io Holdings Inc.
2
-
3
- Portions of the TinaCMS software are licensed as follows:
4
-
5
- * All software that resides under the "packages/@tinacms/datalayer/" and the "packages/@tinacms/graphql/" directories (the "Tina Data Layer"), is licensed under the license defined in "packages/@tinacms/datalayer/LICENSE".
6
-
7
- * All software outside of the above-mentioned directories is available under the "Apache 2.0" license as set forth below.
8
-
9
- Apache License
1
+ Apache License
10
2
  Version 2.0, January 2004
11
3
  http://www.apache.org/licenses/
12
4
 
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ module.exports = __toCommonJS(src_exports);
31
31
  var import_clipanion8 = require("clipanion");
32
32
 
33
33
  // package.json
34
- var version = "1.5.29";
34
+ var version = "1.5.31";
35
35
 
36
36
  // src/next/commands/dev-command/index.ts
37
37
  var import_clipanion2 = require("clipanion");
@@ -1391,7 +1391,7 @@ const generateRequester = (
1391
1391
  url,
1392
1392
  })
1393
1393
 
1394
- return { data: data?.data, query: doc, variables: vars || {} }
1394
+ return { data: data?.data, errors: data?.errors, query: doc, variables: vars || {} }
1395
1395
  }
1396
1396
 
1397
1397
  return requester
@@ -1464,7 +1464,7 @@ var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBas
1464
1464
  node,
1465
1465
  documentVariableName,
1466
1466
  operationType,
1467
- operationResultType: `{data: ${operationResultType}, variables: ${operationVariablesTypes}, query: string}`,
1467
+ operationResultType: `{data: ${operationResultType}, errors?: { message: string, locations: { line: number, column: number }[], path: string[] }[], variables: ${operationVariablesTypes}, query: string}`,
1468
1468
  operationVariablesTypes
1469
1469
  });
1470
1470
  }
@@ -1718,12 +1718,13 @@ var Codegen = class {
1718
1718
  return this.apiURL;
1719
1719
  }
1720
1720
  async genClient() {
1721
- var _a;
1721
+ var _a, _b, _c;
1722
1722
  const token = (_a = this.configManager.config) == null ? void 0 : _a.token;
1723
+ const errorPolicy = (_c = (_b = this.configManager.config) == null ? void 0 : _b.client) == null ? void 0 : _c.errorPolicy;
1723
1724
  const apiURL = this.getApiURL();
1724
1725
  const clientString = `import { createClient } from "tinacms/dist/client";
1725
1726
  import { queries } from "./types";
1726
- export const client = createClient({ url: '${apiURL}', token: '${token}', queries });
1727
+ export const client = createClient({ url: '${apiURL}', token: '${token}', queries, ${errorPolicy ? `errorPolicy: '${errorPolicy}'` : ""} });
1727
1728
  export default client;
1728
1729
  `;
1729
1730
  return { apiURL, clientString };
@@ -1763,11 +1764,9 @@ var maybeWarnFragmentSize = async (filepath) => {
1763
1764
  );
1764
1765
  console.log(
1765
1766
  `const schema = defineSchema({
1766
- config: {
1767
- client: {
1768
- referenceDepth: 1,
1769
- },
1770
- }
1767
+ client: {
1768
+ referenceDepth: 1,
1769
+ },
1771
1770
  // ...
1772
1771
  })`
1773
1772
  );
@@ -1879,12 +1878,7 @@ async function localSpin({
1879
1878
  });
1880
1879
  spinner.setSpinnerString("\u280B\u2819\u2839\u2838\u283C\u2834\u2826\u2827\u2807\u280F");
1881
1880
  spinner.start();
1882
- let res;
1883
- try {
1884
- res = await waitFor();
1885
- } catch (e) {
1886
- console.error(e);
1887
- }
1881
+ const res = await waitFor();
1888
1882
  spinner.stop();
1889
1883
  console.log("");
1890
1884
  return res;
@@ -2000,8 +1994,9 @@ var BaseCommand = class extends import_clipanion.Command {
2000
1994
  }
2001
1995
  }
2002
1996
  const lastSha = await database.getMetadata("lastSha");
1997
+ const exists = lastSha && await (0, import_graphql8.shaExists)({ fs: import_fs_extra5.default, dir: rootPath, sha: lastSha });
2003
1998
  let res;
2004
- if (partialReindex && lastSha && sha) {
1999
+ if (partialReindex && lastSha && exists && sha) {
2005
2000
  const pathFilter = {};
2006
2001
  if (configManager.isUsingLegacyFolder) {
2007
2002
  pathFilter[".tina/__generated__/_schema.json"] = {};
@@ -2128,14 +2123,24 @@ var DevCommand = class extends BaseCommand {
2128
2123
  const schemaObject = require(configManager.generatedSchemaJSONPath);
2129
2124
  const lookupObject = require(configManager.generatedLookupJSONPath);
2130
2125
  const graphqlSchemaObject = require(configManager.generatedGraphQLJSONPath);
2131
- await import_fs_extra6.default.writeFileSync(
2132
- import_path7.default.join(configManager.tinaFolderPath, "tina-lock.json"),
2133
- JSON.stringify({
2134
- schema: schemaObject,
2135
- lookup: lookupObject,
2136
- graphql: graphqlSchemaObject
2137
- })
2126
+ const tinaLockFilename = "tina-lock.json";
2127
+ const tinaLockContent = JSON.stringify({
2128
+ schema: schemaObject,
2129
+ lookup: lookupObject,
2130
+ graphql: graphqlSchemaObject
2131
+ });
2132
+ import_fs_extra6.default.writeFileSync(
2133
+ import_path7.default.join(configManager.tinaFolderPath, tinaLockFilename),
2134
+ tinaLockContent
2138
2135
  );
2136
+ if (configManager.hasSeparateContentRoot()) {
2137
+ const rootPath = await configManager.getTinaFolderPath(
2138
+ configManager.contentRootPath
2139
+ );
2140
+ const filePath = import_path7.default.join(rootPath, tinaLockFilename);
2141
+ await import_fs_extra6.default.ensureFile(filePath);
2142
+ await import_fs_extra6.default.outputFile(filePath, tinaLockContent);
2143
+ }
2139
2144
  }
2140
2145
  if (!this.noWatch) {
2141
2146
  this.watchQueries(configManager, async () => await codegen2.execute());
@@ -2151,14 +2156,17 @@ var DevCommand = class extends BaseCommand {
2151
2156
  }
2152
2157
  return { apiURL: apiURL2, database, graphQLSchema: graphQLSchema2, tinaSchema: tinaSchema2 };
2153
2158
  } catch (e) {
2154
- logger.error(dangerText(e.message));
2159
+ logger.error(`
2160
+
2161
+ ${dangerText(e.message)}
2162
+ `);
2155
2163
  if (this.verbose) {
2156
2164
  console.error(e);
2157
2165
  }
2158
2166
  if (firstTime) {
2159
2167
  logger.error(
2160
2168
  warnText(
2161
- "Unable to start dev server, please fix your Tina config and try again"
2169
+ "Unable to start dev server, please fix your Tina config / resolve any errors above and try again"
2162
2170
  )
2163
2171
  );
2164
2172
  process.exit(1);
@@ -2512,8 +2520,11 @@ var BuildCommand = class extends BaseCommand {
2512
2520
  try {
2513
2521
  await configManager.processConfig();
2514
2522
  } catch (e) {
2515
- logger.error(e.message);
2516
- logger.error("Unable to build, please fix your Tina config and try again");
2523
+ logger.error(`
2524
+ ${dangerText(e.message)}`);
2525
+ logger.error(
2526
+ dangerText("Unable to build, please fix your Tina config and try again")
2527
+ );
2517
2528
  process.exit(1);
2518
2529
  }
2519
2530
  let server;
@@ -2536,14 +2547,25 @@ var BuildCommand = class extends BaseCommand {
2536
2547
  const apiURL = await codegen2.execute();
2537
2548
  if ((configManager.hasSelfHostedConfig() || this.localOption) && !this.skipIndexing) {
2538
2549
  const text = this.localOption ? void 0 : "Indexing to self-hosted data layer";
2539
- await this.indexContentWithSpinner({
2540
- text,
2541
- database,
2542
- graphQLSchema,
2543
- tinaSchema,
2544
- configManager,
2545
- partialReindex: this.partialReindex
2546
- });
2550
+ try {
2551
+ await this.indexContentWithSpinner({
2552
+ text,
2553
+ database,
2554
+ graphQLSchema,
2555
+ tinaSchema,
2556
+ configManager,
2557
+ partialReindex: this.partialReindex
2558
+ });
2559
+ } catch (e) {
2560
+ logger.error(`
2561
+
2562
+ ${dangerText(e.message)}
2563
+ `);
2564
+ if (this.verbose) {
2565
+ console.error(e);
2566
+ }
2567
+ process.exit(1);
2568
+ }
2547
2569
  }
2548
2570
  if (this.localOption) {
2549
2571
  server = await createDevServer(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/cli",
3
- "version": "1.5.29",
3
+ "version": "1.5.31",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [
@@ -58,13 +58,13 @@
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.27",
62
- "tinacms": "1.5.20",
63
- "@tinacms/datalayer": "1.2.25",
64
- "@tinacms/graphql": "1.4.25",
61
+ "@tinacms/app": "1.2.29",
62
+ "tinacms": "1.5.22",
63
+ "@tinacms/datalayer": "1.2.27",
64
+ "@tinacms/graphql": "1.4.27",
65
65
  "@tinacms/metrics": "1.0.2",
66
- "@tinacms/schema-tools": "1.4.12",
67
- "@tinacms/search": "1.0.10",
66
+ "@tinacms/schema-tools": "1.4.13",
67
+ "@tinacms/search": "1.0.12",
68
68
  "@vitejs/plugin-react": "3.1.0",
69
69
  "ajv": "^6.12.3",
70
70
  "altair-express-middleware": "4.0.6",