@tinacms/cli 1.5.41 → 1.5.43
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.
|
|
34
|
+
var version = "1.5.43";
|
|
35
35
|
|
|
36
36
|
// src/next/commands/dev-command/index.ts
|
|
37
37
|
var import_clipanion2 = require("clipanion");
|
|
@@ -1398,12 +1398,18 @@ import { createClient, TinaClient } from "tinacms/dist/client";
|
|
|
1398
1398
|
|
|
1399
1399
|
const generateRequester = (
|
|
1400
1400
|
client: TinaClient,
|
|
1401
|
-
options?: { branch?: string }
|
|
1402
1401
|
) => {
|
|
1403
1402
|
const requester: (
|
|
1404
1403
|
doc: any,
|
|
1405
1404
|
vars?: any,
|
|
1406
|
-
options?: {
|
|
1405
|
+
options?: {
|
|
1406
|
+
branch?: string,
|
|
1407
|
+
/**
|
|
1408
|
+
* Aside from \`method\` and \`body\`, all fetch options are passed
|
|
1409
|
+
* through to underlying fetch request
|
|
1410
|
+
*/
|
|
1411
|
+
fetchOptions?: Omit<Parameters<typeof fetch>[1], 'body' | 'method'>,
|
|
1412
|
+
},
|
|
1407
1413
|
client
|
|
1408
1414
|
) => Promise<any> = async (doc, vars, options) => {
|
|
1409
1415
|
let url = client.apiUrl
|
|
@@ -1415,7 +1421,7 @@ const generateRequester = (
|
|
|
1415
1421
|
query: doc,
|
|
1416
1422
|
variables: vars,
|
|
1417
1423
|
url,
|
|
1418
|
-
})
|
|
1424
|
+
}, options)
|
|
1419
1425
|
|
|
1420
1426
|
return { data: data?.data, errors: data?.errors, query: doc, variables: vars || {} }
|
|
1421
1427
|
}
|
|
@@ -1438,11 +1444,8 @@ export const ExperimentalGetTinaClient = () =>
|
|
|
1438
1444
|
|
|
1439
1445
|
export const queries = (
|
|
1440
1446
|
client: TinaClient,
|
|
1441
|
-
options?: {
|
|
1442
|
-
branch?: string
|
|
1443
|
-
}
|
|
1444
1447
|
) => {
|
|
1445
|
-
const requester = generateRequester(client
|
|
1448
|
+
const requester = generateRequester(client)
|
|
1446
1449
|
return getSdk(requester)
|
|
1447
1450
|
}
|
|
1448
1451
|
`;
|
|
@@ -2554,7 +2557,7 @@ var IndexFailedError = class extends Error {
|
|
|
2554
2557
|
this.name = "IndexFailedError";
|
|
2555
2558
|
}
|
|
2556
2559
|
};
|
|
2557
|
-
var waitForDB = async (config2, apiUrl, verbose) => {
|
|
2560
|
+
var waitForDB = async (config2, apiUrl, previewName, verbose) => {
|
|
2558
2561
|
const token = config2.token;
|
|
2559
2562
|
const { clientId, branch, isLocalClient, host } = (0, import_schema_tools.parseURL)(apiUrl);
|
|
2560
2563
|
if (isLocalClient || !host || !clientId || !branch) {
|
|
@@ -2578,7 +2581,7 @@ var waitForDB = async (config2, apiUrl, verbose) => {
|
|
|
2578
2581
|
headers.append("X-API-KEY", token);
|
|
2579
2582
|
}
|
|
2580
2583
|
const response = await (0, import_node_fetch.default)(
|
|
2581
|
-
`https://${host}/db/${clientId}/status/${branch}`,
|
|
2584
|
+
`https://${host}/db/${clientId}/status/${previewName || branch}`,
|
|
2582
2585
|
{
|
|
2583
2586
|
method: "GET",
|
|
2584
2587
|
headers,
|
|
@@ -2598,11 +2601,11 @@ var waitForDB = async (config2, apiUrl, verbose) => {
|
|
|
2598
2601
|
await sleepAndCallFunc({ fn: pollForStatus, ms: POLLING_INTERVAL });
|
|
2599
2602
|
} else if (status === STATUS_FAILED) {
|
|
2600
2603
|
throw new IndexFailedError(
|
|
2601
|
-
`Attempting to index but responded with status 'failed'. To retry the indexing process, click the "Reindex" button for '${branch}' in the Tina Cloud configuration for this project. ${error}`
|
|
2604
|
+
`Attempting to index but responded with status 'failed'. To retry the indexing process, click the "Reindex" button for '${previewName || branch}' in the Tina Cloud configuration for this project. ${error}`
|
|
2602
2605
|
);
|
|
2603
2606
|
} else {
|
|
2604
2607
|
throw new IndexFailedError(
|
|
2605
|
-
`Attempting to index but responded with status 'unknown'. To retry the indexing process, click the "Reindex" button for '${branch}' in the Tina Cloud configuration for this project. ${error}`
|
|
2608
|
+
`Attempting to index but responded with status 'unknown'. To retry the indexing process, click the "Reindex" button for '${previewName || branch}' in the Tina Cloud configuration for this project. ${error}`
|
|
2606
2609
|
);
|
|
2607
2610
|
}
|
|
2608
2611
|
} catch (e) {
|
|
@@ -2647,6 +2650,15 @@ var BuildCommand = class extends BaseCommand {
|
|
|
2647
2650
|
this.skipSearchIndex = import_clipanion3.Option.Boolean("--skip-search-index", false, {
|
|
2648
2651
|
description: "Skip indexing the site for search"
|
|
2649
2652
|
});
|
|
2653
|
+
this.upstreamBranch = import_clipanion3.Option.String("--upstream-branch", {
|
|
2654
|
+
description: "Optional upstream branch with the schema. If not specified, default will be used."
|
|
2655
|
+
});
|
|
2656
|
+
this.previewBaseBranch = import_clipanion3.Option.String("--preview-base-branch", {
|
|
2657
|
+
description: "The base branch for the preview"
|
|
2658
|
+
});
|
|
2659
|
+
this.previewName = import_clipanion3.Option.String("--preview-name", {
|
|
2660
|
+
description: "The name of the preview branch"
|
|
2661
|
+
});
|
|
2650
2662
|
}
|
|
2651
2663
|
async catch(error) {
|
|
2652
2664
|
console.error(error);
|
|
@@ -2661,6 +2673,22 @@ var BuildCommand = class extends BaseCommand {
|
|
|
2661
2673
|
tinaGraphQLVersion: this.tinaGraphQLVersion,
|
|
2662
2674
|
legacyNoSDK: this.noSDK
|
|
2663
2675
|
});
|
|
2676
|
+
if (this.previewName && !this.previewBaseBranch) {
|
|
2677
|
+
logger.error(
|
|
2678
|
+
`${dangerText(
|
|
2679
|
+
`ERROR: preview name provided without a preview base branch.`
|
|
2680
|
+
)}`
|
|
2681
|
+
);
|
|
2682
|
+
process.exit(1);
|
|
2683
|
+
}
|
|
2684
|
+
if (this.previewBaseBranch && !this.previewName) {
|
|
2685
|
+
logger.error(
|
|
2686
|
+
`${dangerText(
|
|
2687
|
+
`ERROR: preview base branch provided without a preview name.`
|
|
2688
|
+
)}`
|
|
2689
|
+
);
|
|
2690
|
+
process.exit(1);
|
|
2691
|
+
}
|
|
2664
2692
|
try {
|
|
2665
2693
|
await configManager.processConfig();
|
|
2666
2694
|
} catch (e) {
|
|
@@ -2724,8 +2752,31 @@ ${dangerText(e.message)}
|
|
|
2724
2752
|
}
|
|
2725
2753
|
const skipCloudChecks = this.skipCloudChecks || configManager.hasSelfHostedConfig();
|
|
2726
2754
|
if (!skipCloudChecks) {
|
|
2727
|
-
await this.checkClientInfo(
|
|
2728
|
-
|
|
2755
|
+
const { hasUpstream } = await this.checkClientInfo(
|
|
2756
|
+
configManager,
|
|
2757
|
+
codegen2.productionUrl,
|
|
2758
|
+
this.previewBaseBranch
|
|
2759
|
+
);
|
|
2760
|
+
if (!hasUpstream && this.upstreamBranch) {
|
|
2761
|
+
logger.warn(
|
|
2762
|
+
`${dangerText(
|
|
2763
|
+
`WARN: Upstream branch '${this.upstreamBranch}' specified but no upstream project was found.`
|
|
2764
|
+
)}`
|
|
2765
|
+
);
|
|
2766
|
+
}
|
|
2767
|
+
if (hasUpstream || this.previewBaseBranch && this.previewName) {
|
|
2768
|
+
await this.syncProject(configManager, codegen2.productionUrl, {
|
|
2769
|
+
upstreamBranch: this.upstreamBranch,
|
|
2770
|
+
previewBaseBranch: this.previewBaseBranch,
|
|
2771
|
+
previewName: this.previewName
|
|
2772
|
+
});
|
|
2773
|
+
}
|
|
2774
|
+
await waitForDB(
|
|
2775
|
+
configManager.config,
|
|
2776
|
+
codegen2.productionUrl,
|
|
2777
|
+
this.previewName,
|
|
2778
|
+
false
|
|
2779
|
+
);
|
|
2729
2780
|
await this.checkGraphqlSchema(
|
|
2730
2781
|
configManager,
|
|
2731
2782
|
database,
|
|
@@ -2840,13 +2891,14 @@ ${dangerText(e.message)}
|
|
|
2840
2891
|
process.exit();
|
|
2841
2892
|
}
|
|
2842
2893
|
}
|
|
2843
|
-
async checkClientInfo(configManager, apiURL) {
|
|
2894
|
+
async checkClientInfo(configManager, apiURL, previewBaseBranch) {
|
|
2844
2895
|
const { config: config2 } = configManager;
|
|
2845
2896
|
const token = config2.token;
|
|
2846
2897
|
const { clientId, branch, host } = (0, import_schema_tools2.parseURL)(apiURL);
|
|
2847
|
-
const url = `https://${host}/db/${clientId}/status/${branch}`;
|
|
2898
|
+
const url = `https://${host}/db/${clientId}/status/${previewBaseBranch || branch}`;
|
|
2848
2899
|
const bar2 = new import_progress2.default("Checking clientId and token. :prog", 1);
|
|
2849
2900
|
let branchKnown = false;
|
|
2901
|
+
let hasUpstream = false;
|
|
2850
2902
|
try {
|
|
2851
2903
|
const res = await request({
|
|
2852
2904
|
token,
|
|
@@ -2858,6 +2910,9 @@ ${dangerText(e.message)}
|
|
|
2858
2910
|
if (!(res.status === "unknown")) {
|
|
2859
2911
|
branchKnown = true;
|
|
2860
2912
|
}
|
|
2913
|
+
if (res.hasUpstream) {
|
|
2914
|
+
hasUpstream = true;
|
|
2915
|
+
}
|
|
2861
2916
|
} catch (e) {
|
|
2862
2917
|
summary({
|
|
2863
2918
|
heading: "Error when checking client information",
|
|
@@ -2870,6 +2925,10 @@ ${dangerText(e.message)}
|
|
|
2870
2925
|
key: "clientId",
|
|
2871
2926
|
value: config2.clientId
|
|
2872
2927
|
},
|
|
2928
|
+
{
|
|
2929
|
+
key: "branch",
|
|
2930
|
+
value: config2.branch
|
|
2931
|
+
},
|
|
2873
2932
|
{
|
|
2874
2933
|
key: "token",
|
|
2875
2934
|
value: config2.token
|
|
@@ -2885,7 +2944,9 @@ ${dangerText(e.message)}
|
|
|
2885
2944
|
branchBar.tick({
|
|
2886
2945
|
prog: "\u2705"
|
|
2887
2946
|
});
|
|
2888
|
-
return
|
|
2947
|
+
return {
|
|
2948
|
+
hasUpstream
|
|
2949
|
+
};
|
|
2889
2950
|
}
|
|
2890
2951
|
for (let i = 0; i <= 5; i++) {
|
|
2891
2952
|
await sleepAndCallFunc({
|
|
@@ -2921,6 +2982,59 @@ ${dangerText(e.message)}
|
|
|
2921
2982
|
);
|
|
2922
2983
|
throw new Error("Branch is not on Tina Cloud");
|
|
2923
2984
|
}
|
|
2985
|
+
async syncProject(configManager, apiURL, options) {
|
|
2986
|
+
const { config: config2 } = configManager;
|
|
2987
|
+
const token = config2.token;
|
|
2988
|
+
const { clientId, branch, host } = (0, import_schema_tools2.parseURL)(apiURL);
|
|
2989
|
+
const { previewName, previewBaseBranch, upstreamBranch } = options || {};
|
|
2990
|
+
let url = `https://${host}/db/${clientId}/reset/${branch}?refreshSchema=true&skipIfSchemaCurrent=true`;
|
|
2991
|
+
if (upstreamBranch && previewBaseBranch && previewName) {
|
|
2992
|
+
url = `https://${host}/db/${clientId}/reset/${previewBaseBranch}?refreshSchema=true&skipIfSchemaCurrent=true&upstreamBranch=${upstreamBranch}&previewName=${previewName}`;
|
|
2993
|
+
} else if (!upstreamBranch && previewBaseBranch && previewName) {
|
|
2994
|
+
url = `https://${host}/db/${clientId}/reset/${previewBaseBranch}?refreshSchema=true&skipIfSchemaCurrent=true&previewName=${branch}`;
|
|
2995
|
+
} else if (upstreamBranch && !previewBaseBranch && !previewName) {
|
|
2996
|
+
url = `https://${host}/db/${clientId}/reset/${branch}?refreshSchema=true&skipIfSchemaCurrent=true&upstreamBranch=${upstreamBranch}`;
|
|
2997
|
+
}
|
|
2998
|
+
const bar2 = new import_progress2.default("Syncing Project. :prog", 1);
|
|
2999
|
+
try {
|
|
3000
|
+
const res = await request({
|
|
3001
|
+
token,
|
|
3002
|
+
url,
|
|
3003
|
+
method: "POST"
|
|
3004
|
+
});
|
|
3005
|
+
bar2.tick({
|
|
3006
|
+
prog: "\u2705"
|
|
3007
|
+
});
|
|
3008
|
+
if (res.status === "success") {
|
|
3009
|
+
return;
|
|
3010
|
+
}
|
|
3011
|
+
} catch (e) {
|
|
3012
|
+
summary({
|
|
3013
|
+
heading: `Error when requesting project sync`,
|
|
3014
|
+
items: [
|
|
3015
|
+
{
|
|
3016
|
+
emoji: "\u274C",
|
|
3017
|
+
heading: "You provided",
|
|
3018
|
+
subItems: [
|
|
3019
|
+
{
|
|
3020
|
+
key: "clientId",
|
|
3021
|
+
value: config2.clientId
|
|
3022
|
+
},
|
|
3023
|
+
{
|
|
3024
|
+
key: "branch",
|
|
3025
|
+
value: config2.branch
|
|
3026
|
+
},
|
|
3027
|
+
{
|
|
3028
|
+
key: "token",
|
|
3029
|
+
value: config2.token
|
|
3030
|
+
}
|
|
3031
|
+
]
|
|
3032
|
+
}
|
|
3033
|
+
]
|
|
3034
|
+
});
|
|
3035
|
+
throw e;
|
|
3036
|
+
}
|
|
3037
|
+
}
|
|
2924
3038
|
async checkGraphqlSchema(configManager, database, apiURL) {
|
|
2925
3039
|
const bar2 = new import_progress2.default(
|
|
2926
3040
|
"Checking local GraphQL Schema matches server. :prog",
|
|
@@ -2991,7 +3105,7 @@ async function request(args) {
|
|
|
2991
3105
|
headers.append("Content-Type", "application/json");
|
|
2992
3106
|
const url = args == null ? void 0 : args.url;
|
|
2993
3107
|
const res = await (0, import_node_fetch2.default)(url, {
|
|
2994
|
-
method: "GET",
|
|
3108
|
+
method: args.method || "GET",
|
|
2995
3109
|
headers,
|
|
2996
3110
|
redirect: "follow"
|
|
2997
3111
|
});
|
|
@@ -3020,7 +3134,8 @@ Message from server: ${json.message}`;
|
|
|
3020
3134
|
}
|
|
3021
3135
|
return {
|
|
3022
3136
|
status: json == null ? void 0 : json.status,
|
|
3023
|
-
timestamp: json == null ? void 0 : json.timestamp
|
|
3137
|
+
timestamp: json == null ? void 0 : json.timestamp,
|
|
3138
|
+
hasUpstream: (json == null ? void 0 : json.hasUpstream) || false
|
|
3024
3139
|
};
|
|
3025
3140
|
}
|
|
3026
3141
|
var fetchRemoteGraphqlSchema = async ({
|
|
@@ -12,10 +12,20 @@ export declare class BuildCommand extends BaseCommand {
|
|
|
12
12
|
*/
|
|
13
13
|
skipCloudChecks: boolean;
|
|
14
14
|
skipSearchIndex: boolean;
|
|
15
|
+
upstreamBranch: string;
|
|
16
|
+
previewBaseBranch: string;
|
|
17
|
+
previewName: string;
|
|
15
18
|
static usage: import("clipanion").Usage;
|
|
16
19
|
catch(error: any): Promise<void>;
|
|
17
20
|
execute(): Promise<number | void>;
|
|
18
|
-
checkClientInfo(configManager: ConfigManager, apiURL: string): Promise<
|
|
21
|
+
checkClientInfo(configManager: ConfigManager, apiURL: string, previewBaseBranch?: string): Promise<{
|
|
22
|
+
hasUpstream: boolean;
|
|
23
|
+
}>;
|
|
24
|
+
syncProject(configManager: ConfigManager, apiURL: string, options?: {
|
|
25
|
+
upstreamBranch?: string;
|
|
26
|
+
previewBaseBranch?: string;
|
|
27
|
+
previewName?: string;
|
|
28
|
+
}): Promise<void>;
|
|
19
29
|
checkGraphqlSchema(configManager: ConfigManager, database: Database, apiURL: string): Promise<void>;
|
|
20
30
|
}
|
|
21
31
|
export declare const fetchRemoteGraphqlSchema: ({ url, token, }: {
|
|
@@ -4,4 +4,4 @@ export interface IndexStatusResponse {
|
|
|
4
4
|
timestamp: number;
|
|
5
5
|
error?: string;
|
|
6
6
|
}
|
|
7
|
-
export declare const waitForDB: (config: Config<true>, apiUrl: string, verbose?: boolean) => Promise<void>;
|
|
7
|
+
export declare const waitForDB: (config: Config<true>, apiUrl: string, previewName?: string, verbose?: boolean) => Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/cli",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.43",
|
|
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.
|
|
61
|
-
"tinacms": "1.
|
|
60
|
+
"@tinacms/app": "1.2.39",
|
|
61
|
+
"tinacms": "1.6.1",
|
|
62
62
|
"@tinacms/datalayer": "1.2.33",
|
|
63
63
|
"@tinacms/graphql": "1.4.33",
|
|
64
64
|
"@tinacms/metrics": "1.0.2",
|