@tinacms/cli 1.5.40 → 1.5.42

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.5.40";
34
+ var version = "1.5.42";
35
35
 
36
36
  // src/next/commands/dev-command/index.ts
37
37
  var import_clipanion2 = require("clipanion");
@@ -2724,7 +2724,13 @@ ${dangerText(e.message)}
2724
2724
  }
2725
2725
  const skipCloudChecks = this.skipCloudChecks || configManager.hasSelfHostedConfig();
2726
2726
  if (!skipCloudChecks) {
2727
- await this.checkClientInfo(configManager, codegen2.productionUrl);
2727
+ const { hasUpstream } = await this.checkClientInfo(
2728
+ configManager,
2729
+ codegen2.productionUrl
2730
+ );
2731
+ if (hasUpstream) {
2732
+ await this.syncUpstreamProject(configManager, codegen2.productionUrl);
2733
+ }
2728
2734
  await waitForDB(configManager.config, codegen2.productionUrl, false);
2729
2735
  await this.checkGraphqlSchema(
2730
2736
  configManager,
@@ -2847,6 +2853,7 @@ ${dangerText(e.message)}
2847
2853
  const url = `https://${host}/db/${clientId}/status/${branch}`;
2848
2854
  const bar2 = new import_progress2.default("Checking clientId and token. :prog", 1);
2849
2855
  let branchKnown = false;
2856
+ let hasUpstream = false;
2850
2857
  try {
2851
2858
  const res = await request({
2852
2859
  token,
@@ -2858,6 +2865,9 @@ ${dangerText(e.message)}
2858
2865
  if (!(res.status === "unknown")) {
2859
2866
  branchKnown = true;
2860
2867
  }
2868
+ if (res.hasUpstream) {
2869
+ hasUpstream = true;
2870
+ }
2861
2871
  } catch (e) {
2862
2872
  summary({
2863
2873
  heading: "Error when checking client information",
@@ -2870,6 +2880,10 @@ ${dangerText(e.message)}
2870
2880
  key: "clientId",
2871
2881
  value: config2.clientId
2872
2882
  },
2883
+ {
2884
+ key: "branch",
2885
+ value: config2.branch
2886
+ },
2873
2887
  {
2874
2888
  key: "token",
2875
2889
  value: config2.token
@@ -2885,7 +2899,9 @@ ${dangerText(e.message)}
2885
2899
  branchBar.tick({
2886
2900
  prog: "\u2705"
2887
2901
  });
2888
- return;
2902
+ return {
2903
+ hasUpstream
2904
+ };
2889
2905
  }
2890
2906
  for (let i = 0; i <= 5; i++) {
2891
2907
  await sleepAndCallFunc({
@@ -2921,6 +2937,51 @@ ${dangerText(e.message)}
2921
2937
  );
2922
2938
  throw new Error("Branch is not on Tina Cloud");
2923
2939
  }
2940
+ async syncUpstreamProject(configManager, apiURL) {
2941
+ const { config: config2 } = configManager;
2942
+ const token = config2.token;
2943
+ const { clientId, branch, host } = (0, import_schema_tools2.parseURL)(apiURL);
2944
+ const url = `https://${host}/db/${clientId}/reset/${branch}?refreshSchema=true&skipIfSchemaCurrent=true`;
2945
+ const bar2 = new import_progress2.default("Syncing Upstream Project. :prog", 1);
2946
+ try {
2947
+ const res = await request({
2948
+ token,
2949
+ url,
2950
+ method: "POST"
2951
+ });
2952
+ bar2.tick({
2953
+ prog: "\u2705"
2954
+ });
2955
+ if (res.status === "success") {
2956
+ return;
2957
+ }
2958
+ } catch (e) {
2959
+ summary({
2960
+ heading: "Error when requesting upstream project sync",
2961
+ items: [
2962
+ {
2963
+ emoji: "\u274C",
2964
+ heading: "You provided",
2965
+ subItems: [
2966
+ {
2967
+ key: "clientId",
2968
+ value: config2.clientId
2969
+ },
2970
+ {
2971
+ key: "branch",
2972
+ value: config2.branch
2973
+ },
2974
+ {
2975
+ key: "token",
2976
+ value: config2.token
2977
+ }
2978
+ ]
2979
+ }
2980
+ ]
2981
+ });
2982
+ throw e;
2983
+ }
2984
+ }
2924
2985
  async checkGraphqlSchema(configManager, database, apiURL) {
2925
2986
  const bar2 = new import_progress2.default(
2926
2987
  "Checking local GraphQL Schema matches server. :prog",
@@ -2991,7 +3052,7 @@ async function request(args) {
2991
3052
  headers.append("Content-Type", "application/json");
2992
3053
  const url = args == null ? void 0 : args.url;
2993
3054
  const res = await (0, import_node_fetch2.default)(url, {
2994
- method: "GET",
3055
+ method: args.method || "GET",
2995
3056
  headers,
2996
3057
  redirect: "follow"
2997
3058
  });
@@ -3020,7 +3081,8 @@ Message from server: ${json.message}`;
3020
3081
  }
3021
3082
  return {
3022
3083
  status: json == null ? void 0 : json.status,
3023
- timestamp: json == null ? void 0 : json.timestamp
3084
+ timestamp: json == null ? void 0 : json.timestamp,
3085
+ hasUpstream: (json == null ? void 0 : json.hasUpstream) || false
3024
3086
  };
3025
3087
  }
3026
3088
  var fetchRemoteGraphqlSchema = async ({
@@ -15,7 +15,10 @@ export declare class BuildCommand extends BaseCommand {
15
15
  static usage: import("clipanion").Usage;
16
16
  catch(error: any): Promise<void>;
17
17
  execute(): Promise<number | void>;
18
- checkClientInfo(configManager: ConfigManager, apiURL: string): Promise<void>;
18
+ checkClientInfo(configManager: ConfigManager, apiURL: string): Promise<{
19
+ hasUpstream: boolean;
20
+ }>;
21
+ syncUpstreamProject(configManager: ConfigManager, apiURL: string): Promise<void>;
19
22
  checkGraphqlSchema(configManager: ConfigManager, database: Database, apiURL: string): Promise<void>;
20
23
  }
21
24
  export declare const fetchRemoteGraphqlSchema: ({ url, token, }: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/cli",
3
- "version": "1.5.40",
3
+ "version": "1.5.42",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [
@@ -57,8 +57,8 @@
57
57
  "@tailwindcss/aspect-ratio": "^0.4.0",
58
58
  "@tailwindcss/line-clamp": "^0.3.1",
59
59
  "@tailwindcss/typography": "^0.5.9",
60
- "@tinacms/app": "1.2.36",
61
- "tinacms": "1.5.29",
60
+ "@tinacms/app": "1.2.38",
61
+ "tinacms": "1.6.0",
62
62
  "@tinacms/datalayer": "1.2.33",
63
63
  "@tinacms/graphql": "1.4.33",
64
64
  "@tinacms/metrics": "1.0.2",