gt-sanity 1.0.6 → 1.0.8
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 +8 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/translation/initProject.ts +20 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gt-sanity",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "General Translation integration with Sanity",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"jsonpath-plus": "^10.3.0",
|
|
52
52
|
"jsonpointer": "^5.0.1",
|
|
53
53
|
"lodash.merge": "^4.6.2",
|
|
54
|
-
"generaltranslation": "7.7.
|
|
54
|
+
"generaltranslation": "7.7.3"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@portabletext/types": "^2.0.15",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { gt, overrideConfig } from '../adapter/core';
|
|
1
|
+
import { gt, overrideConfig, pluginConfig } from '../adapter/core';
|
|
2
2
|
import type { Secrets } from '../types';
|
|
3
3
|
|
|
4
4
|
export async function initProject(
|
|
@@ -7,22 +7,19 @@ export async function initProject(
|
|
|
7
7
|
secrets: Secrets
|
|
8
8
|
): Promise<boolean> {
|
|
9
9
|
overrideConfig(secrets);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const { setupJobId } = await gt.setupProject(uploadResult.uploadedFiles);
|
|
25
|
-
|
|
10
|
+
// Calculate timeout once for setup fetching
|
|
11
|
+
// Accept number or numeric string, default to 600s
|
|
12
|
+
const timeoutVal =
|
|
13
|
+
options?.timeout !== undefined ? Number(options.timeout) : 600;
|
|
14
|
+
const setupTimeoutMs =
|
|
15
|
+
(Number.isFinite(timeoutVal) ? timeoutVal : 600) * 1000;
|
|
16
|
+
|
|
17
|
+
const setupResult = await gt.setupProject(uploadResult.uploadedFiles, {
|
|
18
|
+
locales: pluginConfig.getLocales(),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
if (setupResult?.status === 'queued') {
|
|
22
|
+
const { setupJobId } = setupResult;
|
|
26
23
|
const start = Date.now();
|
|
27
24
|
const pollInterval = 2000;
|
|
28
25
|
|
|
@@ -49,13 +46,14 @@ export async function initProject(
|
|
|
49
46
|
|
|
50
47
|
if (setupCompleted) {
|
|
51
48
|
console.log('Setup successfully completed');
|
|
52
|
-
return true;
|
|
53
49
|
} else {
|
|
54
|
-
console.log(
|
|
55
|
-
|
|
50
|
+
console.log(
|
|
51
|
+
`Setup ${setupFailedMessage ? 'failed' : 'timed out'} — proceeding without setup${
|
|
52
|
+
setupFailedMessage ? ` (${setupFailedMessage})` : ''
|
|
53
|
+
}`
|
|
54
|
+
);
|
|
56
55
|
}
|
|
57
|
-
} else {
|
|
58
|
-
console.log('Setup not needed');
|
|
59
56
|
}
|
|
57
|
+
|
|
60
58
|
return true;
|
|
61
59
|
}
|