@tinacms/cli 0.0.0-b4c6a60-20241010070518 → 0.0.0-b60b14f-20241030173304

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.9";
34
+ var version = "1.6.11";
35
35
 
36
36
  // src/next/commands/dev-command/index.ts
37
37
  var import_clipanion2 = require("clipanion");
@@ -2537,6 +2537,7 @@ DevCommand.usage = import_clipanion2.Command.Usage({
2537
2537
  var import_clipanion3 = require("clipanion");
2538
2538
  var import_progress2 = __toESM(require("progress"));
2539
2539
  var import_fs_extra7 = __toESM(require("fs-extra"));
2540
+ var import_crypto = __toESM(require("crypto"));
2540
2541
  var import_graphql11 = require("@tinacms/graphql");
2541
2542
 
2542
2543
  // src/next/commands/build-command/server.ts
@@ -2839,6 +2840,13 @@ ${dangerText(e.message)}
2839
2840
  database,
2840
2841
  codegen2.productionUrl
2841
2842
  );
2843
+ await this.checkTinaSchema(
2844
+ configManager,
2845
+ database,
2846
+ codegen2.productionUrl,
2847
+ this.previewName,
2848
+ this.verbose
2849
+ );
2842
2850
  }
2843
2851
  await buildProductionSpa(configManager, database, codegen2.productionUrl);
2844
2852
  await import_fs_extra7.default.outputFile(
@@ -3148,6 +3156,67 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3148
3156
  }
3149
3157
  }
3150
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
+ }
3151
3220
  };
3152
3221
  BuildCommand.paths = [["build"]];
3153
3222
  BuildCommand.usage = import_clipanion3.Command.Usage({
@@ -3216,6 +3285,24 @@ var fetchRemoteGraphqlSchema = async ({
3216
3285
  const data = await res.json();
3217
3286
  return data == null ? void 0 : data.data;
3218
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
+ console.log({ data });
3304
+ return (data == null ? void 0 : data.data) || {};
3305
+ };
3219
3306
 
3220
3307
  // src/next/commands/audit-command/index.ts
3221
3308
  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-b4c6a60-20241010070518",
3
+ "version": "0.0.0-b60b14f-20241030173304",
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,9 +36,9 @@
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
- "@tinacms/scripts": "0.0.0-b4c6a60-20241010070518"
41
+ "@tinacms/scripts": "1.3.0"
42
42
  },
43
43
  "dependencies": {
44
44
  "@graphql-codegen/core": "^2.6.8",
@@ -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-b4c6a60-20241010070518",
89
- "@tinacms/graphql": "0.0.0-b4c6a60-20241010070518",
88
+ "@tinacms/app": "2.1.11",
89
+ "@tinacms/graphql": "1.5.7",
90
90
  "@tinacms/metrics": "1.0.7",
91
- "@tinacms/schema-tools": "0.0.0-b4c6a60-20241010070518",
92
- "@tinacms/search": "0.0.0-b4c6a60-20241010070518",
93
- "tinacms": "0.0.0-b4c6a60-20241010070518"
91
+ "@tinacms/search": "1.0.34",
92
+ "@tinacms/schema-tools": "1.6.7",
93
+ "tinacms": "2.4.0"
94
94
  },
95
95
  "publishConfig": {
96
96
  "registry": "https://registry.npmjs.org"