@tinacms/cli 0.0.0-9b91b31-20241023063504 → 0.0.0-9c44130-20241030170642

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ module.exports = __toCommonJS(src_exports);
31
31
  var import_clipanion8 = require("clipanion");
32
32
 
33
33
  // package.json
34
- var version = "1.6.10";
34
+ var version = "1.6.11";
35
35
 
36
36
  // src/next/commands/dev-command/index.ts
37
37
  var import_clipanion2 = require("clipanion");
@@ -977,17 +977,14 @@ var createConfig = async ({
977
977
  } else {
978
978
  await import_fs_extra2.default.outputFile(staticMediaPath, `[]`);
979
979
  }
980
- const isBrowser = typeof window !== "undefined";
981
980
  const alias = {
982
981
  TINA_IMPORT: configManager.prebuildFilePath,
983
982
  SCHEMA_IMPORT: configManager.generatedGraphQLJSONPath,
984
983
  STATIC_MEDIA_IMPORT: staticMediaPath,
985
- ...isBrowser && {
986
- crypto: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
987
- fs: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
988
- os: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
989
- path: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts")
990
- }
984
+ crypto: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
985
+ fs: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
986
+ os: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
987
+ path: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts")
991
988
  };
992
989
  if (configManager.shouldSkipSDK()) {
993
990
  alias["CLIENT_IMPORT"] = import_node_path2.default.join(
@@ -2540,6 +2537,7 @@ DevCommand.usage = import_clipanion2.Command.Usage({
2540
2537
  var import_clipanion3 = require("clipanion");
2541
2538
  var import_progress2 = __toESM(require("progress"));
2542
2539
  var import_fs_extra7 = __toESM(require("fs-extra"));
2540
+ var import_crypto = __toESM(require("crypto"));
2543
2541
  var import_graphql11 = require("@tinacms/graphql");
2544
2542
 
2545
2543
  // src/next/commands/build-command/server.ts
@@ -2842,6 +2840,13 @@ ${dangerText(e.message)}
2842
2840
  database,
2843
2841
  codegen2.productionUrl
2844
2842
  );
2843
+ await this.checkTinaSchema(
2844
+ configManager,
2845
+ database,
2846
+ codegen2.productionUrl,
2847
+ this.previewName,
2848
+ this.verbose
2849
+ );
2845
2850
  }
2846
2851
  await buildProductionSpa(configManager, database, codegen2.productionUrl);
2847
2852
  await import_fs_extra7.default.outputFile(
@@ -3151,6 +3156,67 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3151
3156
  }
3152
3157
  }
3153
3158
  }
3159
+ async checkTinaSchema(configManager, database, apiURL, previewName, verbose) {
3160
+ const bar2 = new import_progress2.default(
3161
+ "Checking local Tina Schema matches server. :prog",
3162
+ 1
3163
+ );
3164
+ const { config: config2 } = configManager;
3165
+ const token = config2.token;
3166
+ const { clientId, branch, isLocalClient, host } = (0, import_schema_tools2.parseURL)(apiURL);
3167
+ if (isLocalClient || !host || !clientId || !branch) {
3168
+ if (verbose) {
3169
+ logger.info(logText("Not using Tina Cloud, skipping Tina Schema check"));
3170
+ }
3171
+ return;
3172
+ }
3173
+ const { tinaSchema: remoteTinaSchemaSha } = await fetchSchemaSha({
3174
+ url: `https://${host}/db/${clientId}/${previewName || branch}/schemaSha`,
3175
+ token
3176
+ });
3177
+ console.log({ remoteTinaSchemaSha });
3178
+ if (!remoteTinaSchemaSha) {
3179
+ bar2.tick({
3180
+ prog: "\u274C"
3181
+ });
3182
+ let errorMessage = `The remote Tina schema does not exist. Check indexing for this branch.`;
3183
+ if (config2 == null ? void 0 : config2.branch) {
3184
+ errorMessage += `
3185
+
3186
+ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3187
+ }
3188
+ throw new Error(errorMessage);
3189
+ }
3190
+ if (!database.bridge) {
3191
+ throw new Error(`No bridge configured`);
3192
+ }
3193
+ try {
3194
+ const localTinaSchema = JSON.parse(
3195
+ await database.bridge.get(configManager.generatedSchemaJSONPath)
3196
+ );
3197
+ localTinaSchema.version = void 0;
3198
+ const localTinaSchemaSha = import_crypto.default.createHash("sha256").update(JSON.stringify(localTinaSchema)).digest("hex");
3199
+ console.log({ localTinaSchemaSha });
3200
+ if (localTinaSchemaSha !== remoteTinaSchemaSha) {
3201
+ bar2.tick({
3202
+ prog: "\u2705"
3203
+ });
3204
+ } else {
3205
+ bar2.tick({
3206
+ prog: "\u274C"
3207
+ });
3208
+ let errorMessage = `The local Tina schema doesn't match the remote Tina schema. Please push up your changes to GitHub to update your remote tina schema.`;
3209
+ if (config2 == null ? void 0 : config2.branch) {
3210
+ errorMessage += `
3211
+
3212
+ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3213
+ }
3214
+ throw new Error(errorMessage);
3215
+ }
3216
+ } catch (e) {
3217
+ throw e;
3218
+ }
3219
+ }
3154
3220
  };
3155
3221
  BuildCommand.paths = [["build"]];
3156
3222
  BuildCommand.usage = import_clipanion3.Command.Usage({
@@ -3219,6 +3285,23 @@ var fetchRemoteGraphqlSchema = async ({
3219
3285
  const data = await res.json();
3220
3286
  return data == null ? void 0 : data.data;
3221
3287
  };
3288
+ var fetchSchemaSha = async ({
3289
+ url,
3290
+ token
3291
+ }) => {
3292
+ console.log(url);
3293
+ const headers = new Headers();
3294
+ if (token) {
3295
+ headers.append("X-API-KEY", token);
3296
+ }
3297
+ const res = await fetch(url, {
3298
+ method: "GET",
3299
+ headers,
3300
+ cache: "no-cache"
3301
+ });
3302
+ const data = await res.json();
3303
+ return data == null ? void 0 : data.data;
3304
+ };
3222
3305
 
3223
3306
  // src/next/commands/audit-command/index.ts
3224
3307
  var import_clipanion4 = require("clipanion");
@@ -28,8 +28,13 @@ export declare class BuildCommand extends BaseCommand {
28
28
  previewName?: string;
29
29
  }): Promise<void>;
30
30
  checkGraphqlSchema(configManager: ConfigManager, database: Database, apiURL: string): Promise<void>;
31
+ checkTinaSchema(configManager: ConfigManager, database: Database, apiURL: string, previewName: string, verbose: boolean): Promise<void>;
31
32
  }
32
33
  export declare const fetchRemoteGraphqlSchema: ({ url, token, }: {
33
34
  url: string;
34
35
  token?: string;
35
36
  }) => Promise<any>;
37
+ export declare const fetchSchemaSha: ({ url, token, }: {
38
+ url: string;
39
+ token?: string;
40
+ }) => Promise<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/cli",
3
- "version": "0.0.0-9b91b31-20241023063504",
3
+ "version": "0.0.0-9c44130-20241030170642",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [
@@ -28,7 +28,7 @@
28
28
  "@types/express": "^4.17.21",
29
29
  "@types/express-graphql": "^0.9.0",
30
30
  "@types/figlet": "1.2.0",
31
- "@types/fs-extra": "^9.0.13",
31
+ "@types/fs-extra": "^11.0.4",
32
32
  "@types/jest": "26.0.4",
33
33
  "@types/js-yaml": "^4.0.9",
34
34
  "@types/listr": "0.14.2",
@@ -36,7 +36,7 @@
36
36
  "@types/multer": "^1.4.12",
37
37
  "@types/progress": "^2.0.7",
38
38
  "@types/prompts": "^2.4.9",
39
- "@types/yup": "^0.29.14",
39
+ "@types/yup": "^0.32.0",
40
40
  "jest": "^29.7.0",
41
41
  "@tinacms/scripts": "1.3.0"
42
42
  },
@@ -83,14 +83,14 @@
83
83
  "typanion": "3.13.0",
84
84
  "typescript": "^5.6.2",
85
85
  "vite": "^4.5.5",
86
- "yup": "^0.32.11",
86
+ "yup": "^1.4.0",
87
87
  "zod": "^3.23.8",
88
- "@tinacms/app": "0.0.0-9b91b31-20241023063504",
89
- "@tinacms/graphql": "1.5.6",
88
+ "@tinacms/app": "2.1.11",
89
+ "@tinacms/graphql": "1.5.7",
90
+ "@tinacms/schema-tools": "1.6.7",
90
91
  "@tinacms/metrics": "1.0.7",
91
- "@tinacms/search": "1.0.33",
92
- "@tinacms/schema-tools": "1.6.6",
93
- "tinacms": "0.0.0-9b91b31-20241023063504"
92
+ "@tinacms/search": "1.0.34",
93
+ "tinacms": "2.4.0"
94
94
  },
95
95
  "publishConfig": {
96
96
  "registry": "https://registry.npmjs.org"