@tinacms/cli 1.5.42 → 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) {
|
|
@@ -2726,12 +2754,29 @@ ${dangerText(e.message)}
|
|
|
2726
2754
|
if (!skipCloudChecks) {
|
|
2727
2755
|
const { hasUpstream } = await this.checkClientInfo(
|
|
2728
2756
|
configManager,
|
|
2729
|
-
codegen2.productionUrl
|
|
2757
|
+
codegen2.productionUrl,
|
|
2758
|
+
this.previewBaseBranch
|
|
2730
2759
|
);
|
|
2731
|
-
if (hasUpstream) {
|
|
2732
|
-
|
|
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
|
+
);
|
|
2733
2766
|
}
|
|
2734
|
-
|
|
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
|
+
);
|
|
2735
2780
|
await this.checkGraphqlSchema(
|
|
2736
2781
|
configManager,
|
|
2737
2782
|
database,
|
|
@@ -2846,11 +2891,11 @@ ${dangerText(e.message)}
|
|
|
2846
2891
|
process.exit();
|
|
2847
2892
|
}
|
|
2848
2893
|
}
|
|
2849
|
-
async checkClientInfo(configManager, apiURL) {
|
|
2894
|
+
async checkClientInfo(configManager, apiURL, previewBaseBranch) {
|
|
2850
2895
|
const { config: config2 } = configManager;
|
|
2851
2896
|
const token = config2.token;
|
|
2852
2897
|
const { clientId, branch, host } = (0, import_schema_tools2.parseURL)(apiURL);
|
|
2853
|
-
const url = `https://${host}/db/${clientId}/status/${branch}`;
|
|
2898
|
+
const url = `https://${host}/db/${clientId}/status/${previewBaseBranch || branch}`;
|
|
2854
2899
|
const bar2 = new import_progress2.default("Checking clientId and token. :prog", 1);
|
|
2855
2900
|
let branchKnown = false;
|
|
2856
2901
|
let hasUpstream = false;
|
|
@@ -2937,12 +2982,20 @@ ${dangerText(e.message)}
|
|
|
2937
2982
|
);
|
|
2938
2983
|
throw new Error("Branch is not on Tina Cloud");
|
|
2939
2984
|
}
|
|
2940
|
-
async
|
|
2985
|
+
async syncProject(configManager, apiURL, options) {
|
|
2941
2986
|
const { config: config2 } = configManager;
|
|
2942
2987
|
const token = config2.token;
|
|
2943
2988
|
const { clientId, branch, host } = (0, import_schema_tools2.parseURL)(apiURL);
|
|
2944
|
-
const
|
|
2945
|
-
|
|
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);
|
|
2946
2999
|
try {
|
|
2947
3000
|
const res = await request({
|
|
2948
3001
|
token,
|
|
@@ -2957,7 +3010,7 @@ ${dangerText(e.message)}
|
|
|
2957
3010
|
}
|
|
2958
3011
|
} catch (e) {
|
|
2959
3012
|
summary({
|
|
2960
|
-
heading:
|
|
3013
|
+
heading: `Error when requesting project sync`,
|
|
2961
3014
|
items: [
|
|
2962
3015
|
{
|
|
2963
3016
|
emoji: "\u274C",
|
|
@@ -12,13 +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<{
|
|
19
22
|
hasUpstream: boolean;
|
|
20
23
|
}>;
|
|
21
|
-
|
|
24
|
+
syncProject(configManager: ConfigManager, apiURL: string, options?: {
|
|
25
|
+
upstreamBranch?: string;
|
|
26
|
+
previewBaseBranch?: string;
|
|
27
|
+
previewName?: string;
|
|
28
|
+
}): Promise<void>;
|
|
22
29
|
checkGraphqlSchema(configManager: ConfigManager, database: Database, apiURL: string): Promise<void>;
|
|
23
30
|
}
|
|
24
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.6.
|
|
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",
|