gt-sanity 1.0.5 → 1.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gt-sanity",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
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.0"
54
+ "generaltranslation": "7.7.2"
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
- const setupDecision = await Promise.resolve(gt.shouldSetupProject?.())
11
- .then((v: any) => v)
12
- .catch(() => ({ shouldSetupProject: false }));
13
- const shouldSetupProject = Boolean(setupDecision?.shouldSetupProject);
14
-
15
- // Step 2: Setup if needed and poll until complete
16
- if (shouldSetupProject) {
17
- // Calculate timeout once for setup fetching
18
- // Accept number or numeric string, default to 600s
19
- const timeoutVal =
20
- options?.timeout !== undefined ? Number(options.timeout) : 600;
21
- const setupTimeoutMs =
22
- (Number.isFinite(timeoutVal) ? timeoutVal : 600) * 1000;
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(`Setup ${setupFailedMessage ? 'failed' : 'timed out'} `);
55
- return false;
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
  }