gt 2.26.7-samsara.0 → 2.26.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/CHANGELOG.md +6 -9
- package/dist/cli/commands/api.js +3 -1
- package/dist/cli/commands/api.js.map +1 -1
- package/dist/cli/commands/upload.js +7 -1
- package/dist/cli/commands/upload.js.map +1 -1
- package/dist/formats/files/aggregateFiles.d.ts +5 -0
- package/dist/formats/files/aggregateFiles.js +20 -22
- package/dist/formats/files/aggregateFiles.js.map +1 -1
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +1 -1
- package/dist/generated/version.js.map +1 -1
- package/dist/workflows/upload.js +7 -1
- package/dist/workflows/upload.js.map +1 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
# gtx-cli
|
|
2
2
|
|
|
3
|
-
## 2.26.7
|
|
3
|
+
## 2.26.7
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
- @generaltranslation/python-extractor@0.2.63-samsara.0
|
|
13
|
-
- @generaltranslation/supported-locales@2.1.44-samsara.0
|
|
14
|
-
- @generaltranslation/vue-extractor@0.1.22-samsara.0
|
|
7
|
+
- [#2516](https://github.com/generaltranslation/gt/pull/2516) [`4fee937`](https://github.com/generaltranslation/gt/commit/4fee937e7c8645f8c05a7d4ef82867e2776648da) Thanks [@chenxin-yan](https://github.com/chenxin-yan)! - `gt api` now ends a non-2xx response body with a newline so the HTTP error message on stderr starts on its own line.
|
|
8
|
+
|
|
9
|
+
- [#2515](https://github.com/generaltranslation/gt/pull/2515) [`e5bc047`](https://github.com/generaltranslation/gt/commit/e5bc04712794f7c9d08e83ad7b0e22cd38a853ce) Thanks [@chenxin-yan](https://github.com/chenxin-yan)! - `gt upload` now skips unparsable JSON and YAML translation files with a warning, as it already does for source files, instead of sending them and losing the whole translation batch.
|
|
10
|
+
|
|
11
|
+
- [#2514](https://github.com/generaltranslation/gt/pull/2514) [`e2aee57`](https://github.com/generaltranslation/gt/commit/e2aee57260df269e77b7082ae2b428c2ec9076bb) Thanks [@chenxin-yan](https://github.com/chenxin-yan)! - `gt upload` now uploads translations to the resolved branch (for example, `--branch <name>`) instead of the project's default branch.
|
|
15
12
|
|
|
16
13
|
## 2.26.6
|
|
17
14
|
|
package/dist/cli/commands/api.js
CHANGED
|
@@ -220,8 +220,10 @@ async function handleApiCommand(endpoint, options, dependencies = {}) {
|
|
|
220
220
|
details: formatDiagnosticErrorDetails(result?.error)
|
|
221
221
|
}), dependencies);
|
|
222
222
|
if (options.include) writeResponseMetadata(rawResponse, writeStdout);
|
|
223
|
-
|
|
223
|
+
const responseBody = Buffer.from(await rawResponse.arrayBuffer());
|
|
224
|
+
writeStdout(responseBody);
|
|
224
225
|
if (!rawResponse.ok) {
|
|
226
|
+
if (responseBody.length > 0 && responseBody.at(-1) !== 10) writeStdout("\n");
|
|
225
227
|
writeStderr(`${method} ${normalizedEndpoint} returned HTTP ${rawResponse.status}${rawResponse.statusText ? ` ${rawResponse.statusText}` : ""}\n`);
|
|
226
228
|
(dependencies.exit ?? exitSync)(1);
|
|
227
229
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","names":[],"sources":["../../../src/cli/commands/api.ts"],"sourcesContent":["import fs from 'node:fs';\nimport {\n createApiClient,\n type ApiClientConfig,\n type Client,\n} from 'generaltranslation/api';\nimport openApiSpec from 'generaltranslation/api/openapi.json' with { type: 'json' };\nimport {\n createDiagnosticMessage,\n formatDiagnosticErrorDetails,\n} from 'generaltranslation/diagnostics';\nimport { resolveApiBaseUrl } from '../../utils/apiBaseUrl.js';\nimport { createUserTokenProvider } from '../../auth/oauth.js';\nimport { resolveConfig } from '../../config/resolveConfig.js';\nimport { exitSync } from '../../console/logging.js';\nimport { loadConfig, withJsonExtension } from '../../fs/config/loadConfig.js';\nimport { resolveProjectId } from '../../fs/utils.js';\nimport type { SharedFlags } from '../../types/index.js';\n\nexport type ApiCommandOptions = SharedFlags & {\n header?: string[];\n include?: boolean;\n input?: string;\n list?: boolean;\n method: string;\n spec?: boolean;\n};\n\ntype ApiCommandDependencies = {\n exit?: (code: number) => never;\n fetch?: ApiClientConfig['fetch'];\n writeStderr?: (output: string) => void;\n writeStdout?: (output: string | Uint8Array) => void;\n};\n\ntype ApiRequestOptions = Parameters<Client['request']>[0];\n\nconst STANDARD_HTTP_METHODS = new Set([\n 'GET',\n 'HEAD',\n 'POST',\n 'PUT',\n 'PATCH',\n 'DELETE',\n 'OPTIONS',\n]);\n\nfunction fail(\n diagnostic: string,\n {\n exit = exitSync,\n writeStderr = (output) => process.stderr.write(output),\n }: ApiCommandDependencies\n): never {\n writeStderr(`${diagnostic}\\n`);\n return exit(1);\n}\n\nfunction parseMethod(\n value: string,\n dependencies: ApiCommandDependencies\n): ApiRequestOptions['method'] {\n const method = value.toUpperCase();\n if (!STANDARD_HTTP_METHODS.has(method)) {\n fail(\n createDiagnosticMessage({\n source: 'gt',\n severity: 'Error',\n whatHappened: 'The API request method is invalid',\n details: value,\n fix: `Use one of ${[...STANDARD_HTTP_METHODS].join(', ')}`,\n }),\n dependencies\n );\n }\n // The set validation narrows Commander input to the generated HTTP method union.\n return method as ApiRequestOptions['method'];\n}\n\nfunction parseHeaders(\n values: string[],\n dependencies: ApiCommandDependencies\n): Headers {\n const headers = new Headers();\n for (const header of values) {\n const separator = header.indexOf(':');\n if (separator < 1) {\n fail(\n createDiagnosticMessage({\n source: 'gt',\n severity: 'Error',\n whatHappened: 'The API request header is invalid',\n details: header,\n fix: 'Pass headers as `--header \"Key: Value\"`',\n }),\n dependencies\n );\n }\n headers.append(\n header.slice(0, separator).trim(),\n header.slice(separator + 1).trim()\n );\n }\n return headers;\n}\n\nfunction readInput(\n input: string,\n dependencies: ApiCommandDependencies\n): string {\n try {\n return fs.readFileSync(input === '-' ? 0 : input, 'utf8');\n } catch (error) {\n return fail(\n createDiagnosticMessage({\n source: 'gt',\n severity: 'Error',\n whatHappened: 'The API request body could not be read',\n fix:\n input === '-'\n ? 'Pipe a request body to standard input or remove `--input -`'\n : 'Check the `--input` file path and permissions',\n details: formatDiagnosticErrorDetails(error),\n }),\n dependencies\n );\n }\n}\n\ntype SpecOperation = {\n operationId?: string;\n security?: Record<string, unknown>[];\n summary?: string;\n};\nconst specPaths: Record<\n string,\n Record<string, SpecOperation>\n> = openApiSpec.paths;\n\nfunction listOperations(): string {\n return Object.entries(specPaths)\n .flatMap(([specPath, operations]) =>\n Object.entries(operations).map(\n ([method, operation]) =>\n `${method.toUpperCase()}\\t${specPath}\\t${operation.operationId ?? ''}\\t${operation.summary ?? ''}\\n`\n )\n )\n .join('');\n}\n\nfunction lookupRef(ref: string): unknown {\n return ref\n .slice(2)\n .split('/')\n .reduce<unknown>(\n (node, key) => (node as Record<string, unknown> | undefined)?.[key],\n openApiSpec\n );\n}\n\nfunction collectRefs(value: unknown, refs: Set<string>): void {\n if (!value || typeof value !== 'object') return;\n for (const [key, child] of Object.entries(value)) {\n if (key === '$ref' && typeof child === 'string') refs.add(child);\n else collectRefs(child, refs);\n }\n}\n\n// Inlines local `#/...` references so one operation reads standalone. A ref\n// already being expanded is left as-is because schemas like JsonValue recurse.\nfunction resolveRefs(value: unknown, expanding: string[] = []): unknown {\n if (Array.isArray(value)) {\n return value.map((item) => resolveRefs(item, expanding));\n }\n if (!value || typeof value !== 'object') return value;\n const { $ref, ...siblings } = value as Record<string, unknown>;\n if (typeof $ref === 'string' && $ref.startsWith('#/')) {\n const target = lookupRef($ref);\n if (!expanding.includes($ref) && target && typeof target === 'object') {\n return resolveRefs({ ...target, ...siblings }, [...expanding, $ref]);\n }\n return value;\n }\n return Object.fromEntries(\n Object.entries(value).map(([key, child]) => [\n key,\n resolveRefs(child, expanding),\n ])\n );\n}\n\n// Shapes the output like the spec so the recursive refs resolveRefs leaves\n// behind and the security requirement names still resolve within it.\nfunction specFragment(\n operations: Record<string, Record<string, SpecOperation>>\n): Record<string, unknown> {\n const paths = resolveRefs(operations);\n const components: Record<string, Record<string, unknown>> = {};\n const addComponent = (type: string, name: string, definition: unknown) => {\n components[type] = { ...components[type], [name]: definition };\n };\n\n const pending = new Set<string>();\n collectRefs(paths, pending);\n const added = new Set<string>();\n for (const ref of pending) {\n const [root, type, name] = ref.slice(2).split('/');\n if (added.has(ref) || root !== 'components' || !type || !name) continue;\n added.add(ref);\n const definition = lookupRef(ref);\n addComponent(type, name, definition);\n // Set iteration visits refs added during the loop.\n collectRefs(definition, pending);\n }\n\n const securitySchemes: Record<string, unknown> =\n openApiSpec.components.securitySchemes;\n for (const operation of Object.values(operations).flatMap(Object.values)) {\n for (const name of (operation.security ?? []).flatMap(Object.keys)) {\n addComponent('securitySchemes', name, securitySchemes[name]);\n }\n }\n\n return Object.keys(components).length ? { paths, components } : { paths };\n}\n\n// Accepts an operationId, a spec path, or a concrete path such as\n// /v2/project/info/abc so agents can look up the request they are about to make.\nfunction findOperations(\n endpoint: string\n): Record<string, Record<string, SpecOperation>> {\n const byOperationId = Object.entries(specPaths).flatMap(\n ([specPath, operations]) =>\n Object.entries(operations)\n .filter(([, operation]) => operation.operationId === endpoint)\n .map(([method, operation]) => [specPath, { [method]: operation }])\n );\n if (byOperationId.length) return Object.fromEntries(byOperationId);\n\n const requestPath = `/${endpoint.replace(/^\\//, '').split('?')[0]}`;\n if (specPaths[requestPath]) {\n return { [requestPath]: specPaths[requestPath] };\n }\n return Object.fromEntries(\n Object.entries(specPaths).filter(([specPath]) =>\n new RegExp(\n `^${specPath\n .split(/\\{[^}]+\\}/)\n .map((literal) => literal.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'))\n .join('[^/]+')}$`\n ).test(requestPath)\n )\n );\n}\n\nfunction writeResponseMetadata(\n response: Response,\n writeStdout: (output: string | Uint8Array) => void\n): void {\n writeStdout(\n `HTTP ${response.status}${response.statusText ? ` ${response.statusText}` : ''}\\n`\n );\n response.headers.forEach((value, name) => {\n writeStdout(`${name}: ${value}\\n`);\n });\n writeStdout('\\n');\n}\n\nfunction resolveApiProjectId(\n config: Record<string, unknown>,\n flagProjectId: string | undefined,\n dependencies: ApiCommandDependencies\n): string | undefined {\n const configProjectId =\n typeof config.projectId === 'string' ? config.projectId : undefined;\n const environmentProjectId = resolveProjectId();\n\n if (configProjectId && flagProjectId && configProjectId !== flagProjectId) {\n fail(\n createDiagnosticMessage({\n source: 'gt',\n severity: 'Error',\n whatHappened: 'The project IDs do not match',\n details: [\n `Configuration: ${configProjectId}`,\n `--project-id: ${flagProjectId}`,\n ],\n fix: 'Use the same project ID in all configurations',\n }),\n dependencies\n );\n }\n\n if (\n configProjectId &&\n environmentProjectId &&\n configProjectId !== environmentProjectId\n ) {\n fail(\n createDiagnosticMessage({\n source: 'gt',\n severity: 'Error',\n whatHappened: 'The project IDs do not match',\n details: [\n `Configuration: ${configProjectId}`,\n `Environment: ${environmentProjectId}`,\n ],\n fix: 'Use the same project ID in all configurations',\n }),\n dependencies\n );\n }\n\n return flagProjectId ?? configProjectId ?? environmentProjectId;\n}\n\nexport async function handleApiCommand(\n endpoint: string | undefined,\n options: ApiCommandOptions,\n dependencies: ApiCommandDependencies = {}\n): Promise<void> {\n if (!dependencies.writeStdout) {\n process.stdout.once('error', (error: NodeJS.ErrnoException) => {\n if (error.code === 'EPIPE') process.exit(0);\n throw error;\n });\n }\n const writeStdout =\n dependencies.writeStdout ?? ((output) => process.stdout.write(output));\n const writeStderr =\n dependencies.writeStderr ?? ((output) => process.stderr.write(output));\n\n if (options.list) {\n writeStdout(listOperations());\n return;\n }\n\n if (options.spec) {\n if (!endpoint) {\n writeStdout(`${JSON.stringify(openApiSpec, null, 2)}\\n`);\n return;\n }\n const operations = findOperations(endpoint);\n if (!Object.keys(operations).length) {\n fail(\n createDiagnosticMessage({\n source: 'gt',\n severity: 'Error',\n whatHappened: 'No API operation matches the endpoint',\n details: endpoint,\n fix: 'Run `gt api --list` to see the available endpoints and operation IDs',\n }),\n dependencies\n );\n }\n writeStdout(`${JSON.stringify(specFragment(operations), null, 2)}\\n`);\n return;\n }\n\n if (!endpoint) {\n fail(\n createDiagnosticMessage({\n source: 'gt',\n severity: 'Error',\n whatHappened: 'No API endpoint was provided',\n fix: 'Pass an endpoint, run `gt api --list` to see the available endpoints, or run `gt api --spec <endpoint>` to inspect one',\n }),\n dependencies\n );\n }\n\n const method = parseMethod(options.method, dependencies);\n const config = options.config\n ? loadConfig(withJsonExtension(options.config))\n : (resolveConfig(process.cwd())?.config ?? {});\n const baseUrl = resolveApiBaseUrl(\n typeof config.baseUrl === 'string' ? config.baseUrl : undefined\n );\n const client = createApiClient({\n apiKey: options.apiKey ?? process.env.GT_API_KEY,\n userTokenProvider: createUserTokenProvider({ baseUrl }),\n baseUrl,\n fetch: dependencies.fetch,\n projectId: resolveApiProjectId(config, options.projectId, dependencies),\n retryPolicy: 'none',\n });\n const normalizedEndpoint = endpoint.startsWith('/')\n ? endpoint\n : `/${endpoint}`;\n const headers = parseHeaders(options.header ?? [], dependencies);\n const body = options.input\n ? readInput(options.input, dependencies)\n : undefined;\n let rawResponse: Response | undefined;\n\n client.interceptors.response.use((response) => {\n // Keep a clone because the generated client consumes non-2xx bodies.\n rawResponse = response.clone();\n return response;\n });\n\n const result = await client\n .request({\n body,\n bodySerializer: () => body,\n headers,\n method,\n parseAs: 'stream',\n throwOnError: false,\n url: normalizedEndpoint,\n })\n .catch((error) =>\n fail(\n createDiagnosticMessage({\n source: 'gt',\n severity: 'Error',\n whatHappened: 'The API request failed before a response was received',\n details: formatDiagnosticErrorDetails(error),\n }),\n dependencies\n )\n );\n\n if (!rawResponse) {\n fail(\n createDiagnosticMessage({\n source: 'gt',\n severity: 'Error',\n whatHappened: 'The API request did not return a response',\n details: formatDiagnosticErrorDetails(result?.error),\n }),\n dependencies\n );\n }\n\n if (options.include) writeResponseMetadata(rawResponse, writeStdout);\n writeStdout(Buffer.from(await rawResponse.arrayBuffer()));\n\n if (!rawResponse.ok) {\n writeStderr(\n `${method} ${normalizedEndpoint} returned HTTP ${rawResponse.status}${rawResponse.statusText ? ` ${rawResponse.statusText}` : ''}\\n`\n );\n (dependencies.exit ?? exitSync)(1);\n }\n}\n"],"mappings":";;;;;;;;;;;AAqCA,MAAM,wBAAwB,IAAI,IAAI;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,SAAS,KACP,YACA,EACE,OAAO,UACP,eAAe,WAAW,QAAQ,OAAO,MAAM,OAAO,IAEjD;AACP,aAAY,GAAG,WAAW,IAAI;AAC9B,QAAO,KAAK,EAAE;;AAGhB,SAAS,YACP,OACA,cAC6B;CAC7B,MAAM,SAAS,MAAM,aAAa;AAClC,KAAI,CAAC,sBAAsB,IAAI,OAAO,CACpC,MACE,wBAAwB;EACtB,QAAQ;EACR,UAAU;EACV,cAAc;EACd,SAAS;EACT,KAAK,cAAc,CAAC,GAAG,sBAAsB,CAAC,KAAK,KAAK;EACzD,CAAC,EACF,aACD;AAGH,QAAO;;AAGT,SAAS,aACP,QACA,cACS;CACT,MAAM,UAAU,IAAI,SAAS;AAC7B,MAAK,MAAM,UAAU,QAAQ;EAC3B,MAAM,YAAY,OAAO,QAAQ,IAAI;AACrC,MAAI,YAAY,EACd,MACE,wBAAwB;GACtB,QAAQ;GACR,UAAU;GACV,cAAc;GACd,SAAS;GACT,KAAK;GACN,CAAC,EACF,aACD;AAEH,UAAQ,OACN,OAAO,MAAM,GAAG,UAAU,CAAC,MAAM,EACjC,OAAO,MAAM,YAAY,EAAE,CAAC,MAAM,CACnC;;AAEH,QAAO;;AAGT,SAAS,UACP,OACA,cACQ;AACR,KAAI;AACF,SAAO,GAAG,aAAa,UAAU,MAAM,IAAI,OAAO,OAAO;UAClD,OAAO;AACd,SAAO,KACL,wBAAwB;GACtB,QAAQ;GACR,UAAU;GACV,cAAc;GACd,KACE,UAAU,MACN,gEACA;GACN,S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AAc,SAAS,OAAO;AAC9B,SAAO;GACP;CAEF,MAAM,SAAS,MAAM,OAClB,QAAQ;EACP;EACA,sBAAsB;EACtB;EACA;EACA,SAAS;EACT,cAAc;EACd,KAAK;EACN,CAAC,CACD,OAAO,UACN,KACE,wBAAwB;EACtB,QAAQ;EACR,UAAU;EACV,cAAc;EACd,SAAS,6BAA6B,MAAM;EAC7C,CAAC,EACF,aACD,CACF;AAEH,KAAI,CAAC,YACH,MACE,wBAAwB;EACtB,QAAQ;EACR,UAAU;EACV,cAAc;EACd,SAAS,6BAA6B,QAAQ,MAAM;EACrD,CAAC,EACF,aACD;AAGH,KAAI,QAAQ,QAAS,uBAAsB,aAAa,YAAY;AACpE,aAAY,OAAO,KAAK,MAAM,YAAY,aAAa,CAAC,CAAC;AAEzD,KAAI,CAAC,YAAY,IAAI;AACnB,cACE,GAAG,OAAO,GAAG,mBAAmB,iBAAiB,YAAY,SAAS,YAAY,aAAa,IAAI,YAAY,eAAe,GAAG,IAClI;AACD,GAAC,aAAa,QAAQ,UAAU,EAAE"}
|
|
1
|
+
{"version":3,"file":"api.js","names":[],"sources":["../../../src/cli/commands/api.ts"],"sourcesContent":["import fs from 'node:fs';\nimport {\n createApiClient,\n type ApiClientConfig,\n type Client,\n} from 'generaltranslation/api';\nimport openApiSpec from 'generaltranslation/api/openapi.json' with { type: 'json' };\nimport {\n createDiagnosticMessage,\n formatDiagnosticErrorDetails,\n} from 'generaltranslation/diagnostics';\nimport { resolveApiBaseUrl } from '../../utils/apiBaseUrl.js';\nimport { createUserTokenProvider } from '../../auth/oauth.js';\nimport { resolveConfig } from '../../config/resolveConfig.js';\nimport { exitSync } from '../../console/logging.js';\nimport { loadConfig, withJsonExtension } from '../../fs/config/loadConfig.js';\nimport { resolveProjectId } from '../../fs/utils.js';\nimport type { SharedFlags } from '../../types/index.js';\n\nexport type ApiCommandOptions = SharedFlags & {\n header?: string[];\n include?: boolean;\n input?: string;\n list?: boolean;\n method: string;\n spec?: boolean;\n};\n\ntype ApiCommandDependencies = {\n exit?: (code: number) => never;\n fetch?: ApiClientConfig['fetch'];\n writeStderr?: (output: string) => void;\n writeStdout?: (output: string | Uint8Array) => void;\n};\n\ntype ApiRequestOptions = Parameters<Client['request']>[0];\n\nconst STANDARD_HTTP_METHODS = new Set([\n 'GET',\n 'HEAD',\n 'POST',\n 'PUT',\n 'PATCH',\n 'DELETE',\n 'OPTIONS',\n]);\n\nfunction fail(\n diagnostic: string,\n {\n exit = exitSync,\n writeStderr = (output) => process.stderr.write(output),\n }: ApiCommandDependencies\n): never {\n writeStderr(`${diagnostic}\\n`);\n return exit(1);\n}\n\nfunction parseMethod(\n value: string,\n dependencies: ApiCommandDependencies\n): ApiRequestOptions['method'] {\n const method = value.toUpperCase();\n if (!STANDARD_HTTP_METHODS.has(method)) {\n fail(\n createDiagnosticMessage({\n source: 'gt',\n severity: 'Error',\n whatHappened: 'The API request method is invalid',\n details: value,\n fix: `Use one of ${[...STANDARD_HTTP_METHODS].join(', ')}`,\n }),\n dependencies\n );\n }\n // The set validation narrows Commander input to the generated HTTP method union.\n return method as ApiRequestOptions['method'];\n}\n\nfunction parseHeaders(\n values: string[],\n dependencies: ApiCommandDependencies\n): Headers {\n const headers = new Headers();\n for (const header of values) {\n const separator = header.indexOf(':');\n if (separator < 1) {\n fail(\n createDiagnosticMessage({\n source: 'gt',\n severity: 'Error',\n whatHappened: 'The API request header is invalid',\n details: header,\n fix: 'Pass headers as `--header \"Key: Value\"`',\n }),\n dependencies\n );\n }\n headers.append(\n header.slice(0, separator).trim(),\n header.slice(separator + 1).trim()\n );\n }\n return headers;\n}\n\nfunction readInput(\n input: string,\n dependencies: ApiCommandDependencies\n): string {\n try {\n return fs.readFileSync(input === '-' ? 0 : input, 'utf8');\n } catch (error) {\n return fail(\n createDiagnosticMessage({\n source: 'gt',\n severity: 'Error',\n whatHappened: 'The API request body could not be read',\n fix:\n input === '-'\n ? 'Pipe a request body to standard input or remove `--input -`'\n : 'Check the `--input` file path and permissions',\n details: formatDiagnosticErrorDetails(error),\n }),\n dependencies\n );\n }\n}\n\ntype SpecOperation = {\n operationId?: string;\n security?: Record<string, unknown>[];\n summary?: string;\n};\nconst specPaths: Record<\n string,\n Record<string, SpecOperation>\n> = openApiSpec.paths;\n\nfunction listOperations(): string {\n return Object.entries(specPaths)\n .flatMap(([specPath, operations]) =>\n Object.entries(operations).map(\n ([method, operation]) =>\n `${method.toUpperCase()}\\t${specPath}\\t${operation.operationId ?? ''}\\t${operation.summary ?? ''}\\n`\n )\n )\n .join('');\n}\n\nfunction lookupRef(ref: string): unknown {\n return ref\n .slice(2)\n .split('/')\n .reduce<unknown>(\n (node, key) => (node as Record<string, unknown> | undefined)?.[key],\n openApiSpec\n );\n}\n\nfunction collectRefs(value: unknown, refs: Set<string>): void {\n if (!value || typeof value !== 'object') return;\n for (const [key, child] of Object.entries(value)) {\n if (key === '$ref' && typeof child === 'string') refs.add(child);\n else collectRefs(child, refs);\n }\n}\n\n// Inlines local `#/...` references so one operation reads standalone. A ref\n// already being expanded is left as-is because schemas like JsonValue recurse.\nfunction resolveRefs(value: unknown, expanding: string[] = []): unknown {\n if (Array.isArray(value)) {\n return value.map((item) => resolveRefs(item, expanding));\n }\n if (!value || typeof value !== 'object') return value;\n const { $ref, ...siblings } = value as Record<string, unknown>;\n if (typeof $ref === 'string' && $ref.startsWith('#/')) {\n const target = lookupRef($ref);\n if (!expanding.includes($ref) && target && typeof target === 'object') {\n return resolveRefs({ ...target, ...siblings }, [...expanding, $ref]);\n }\n return value;\n }\n return Object.fromEntries(\n Object.entries(value).map(([key, child]) => [\n key,\n resolveRefs(child, expanding),\n ])\n );\n}\n\n// Shapes the output like the spec so the recursive refs resolveRefs leaves\n// behind and the security requirement names still resolve within it.\nfunction specFragment(\n operations: Record<string, Record<string, SpecOperation>>\n): Record<string, unknown> {\n const paths = resolveRefs(operations);\n const components: Record<string, Record<string, unknown>> = {};\n const addComponent = (type: string, name: string, definition: unknown) => {\n components[type] = { ...components[type], [name]: definition };\n };\n\n const pending = new Set<string>();\n collectRefs(paths, pending);\n const added = new Set<string>();\n for (const ref of pending) {\n const [root, type, name] = ref.slice(2).split('/');\n if (added.has(ref) || root !== 'components' || !type || !name) continue;\n added.add(ref);\n const definition = lookupRef(ref);\n addComponent(type, name, definition);\n // Set iteration visits refs added during the loop.\n collectRefs(definition, pending);\n }\n\n const securitySchemes: Record<string, unknown> =\n openApiSpec.components.securitySchemes;\n for (const operation of Object.values(operations).flatMap(Object.values)) {\n for (const name of (operation.security ?? []).flatMap(Object.keys)) {\n addComponent('securitySchemes', name, securitySchemes[name]);\n }\n }\n\n return Object.keys(components).length ? { paths, components } : { paths };\n}\n\n// Accepts an operationId, a spec path, or a concrete path such as\n// /v2/project/info/abc so agents can look up the request they are about to make.\nfunction findOperations(\n endpoint: string\n): Record<string, Record<string, SpecOperation>> {\n const byOperationId = Object.entries(specPaths).flatMap(\n ([specPath, operations]) =>\n Object.entries(operations)\n .filter(([, operation]) => operation.operationId === endpoint)\n .map(([method, operation]) => [specPath, { [method]: operation }])\n );\n if (byOperationId.length) return Object.fromEntries(byOperationId);\n\n const requestPath = `/${endpoint.replace(/^\\//, '').split('?')[0]}`;\n if (specPaths[requestPath]) {\n return { [requestPath]: specPaths[requestPath] };\n }\n return Object.fromEntries(\n Object.entries(specPaths).filter(([specPath]) =>\n new RegExp(\n `^${specPath\n .split(/\\{[^}]+\\}/)\n .map((literal) => literal.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'))\n .join('[^/]+')}$`\n ).test(requestPath)\n )\n );\n}\n\nfunction writeResponseMetadata(\n response: Response,\n writeStdout: (output: string | Uint8Array) => void\n): void {\n writeStdout(\n `HTTP ${response.status}${response.statusText ? ` ${response.statusText}` : ''}\\n`\n );\n response.headers.forEach((value, name) => {\n writeStdout(`${name}: ${value}\\n`);\n });\n writeStdout('\\n');\n}\n\nfunction resolveApiProjectId(\n config: Record<string, unknown>,\n flagProjectId: string | undefined,\n dependencies: ApiCommandDependencies\n): string | undefined {\n const configProjectId =\n typeof config.projectId === 'string' ? config.projectId : undefined;\n const environmentProjectId = resolveProjectId();\n\n if (configProjectId && flagProjectId && configProjectId !== flagProjectId) {\n fail(\n createDiagnosticMessage({\n source: 'gt',\n severity: 'Error',\n whatHappened: 'The project IDs do not match',\n details: [\n `Configuration: ${configProjectId}`,\n `--project-id: ${flagProjectId}`,\n ],\n fix: 'Use the same project ID in all configurations',\n }),\n dependencies\n );\n }\n\n if (\n configProjectId &&\n environmentProjectId &&\n configProjectId !== environmentProjectId\n ) {\n fail(\n createDiagnosticMessage({\n source: 'gt',\n severity: 'Error',\n whatHappened: 'The project IDs do not match',\n details: [\n `Configuration: ${configProjectId}`,\n `Environment: ${environmentProjectId}`,\n ],\n fix: 'Use the same project ID in all configurations',\n }),\n dependencies\n );\n }\n\n return flagProjectId ?? configProjectId ?? environmentProjectId;\n}\n\nexport async function handleApiCommand(\n endpoint: string | undefined,\n options: ApiCommandOptions,\n dependencies: ApiCommandDependencies = {}\n): Promise<void> {\n if (!dependencies.writeStdout) {\n process.stdout.once('error', (error: NodeJS.ErrnoException) => {\n if (error.code === 'EPIPE') process.exit(0);\n throw error;\n });\n }\n const writeStdout =\n dependencies.writeStdout ?? ((output) => process.stdout.write(output));\n const writeStderr =\n dependencies.writeStderr ?? ((output) => process.stderr.write(output));\n\n if (options.list) {\n writeStdout(listOperations());\n return;\n }\n\n if (options.spec) {\n if (!endpoint) {\n writeStdout(`${JSON.stringify(openApiSpec, null, 2)}\\n`);\n return;\n }\n const operations = findOperations(endpoint);\n if (!Object.keys(operations).length) {\n fail(\n createDiagnosticMessage({\n source: 'gt',\n severity: 'Error',\n whatHappened: 'No API operation matches the endpoint',\n details: endpoint,\n fix: 'Run `gt api --list` to see the available endpoints and operation IDs',\n }),\n dependencies\n );\n }\n writeStdout(`${JSON.stringify(specFragment(operations), null, 2)}\\n`);\n return;\n }\n\n if (!endpoint) {\n fail(\n createDiagnosticMessage({\n source: 'gt',\n severity: 'Error',\n whatHappened: 'No API endpoint was provided',\n fix: 'Pass an endpoint, run `gt api --list` to see the available endpoints, or run `gt api --spec <endpoint>` to inspect one',\n }),\n dependencies\n );\n }\n\n const method = parseMethod(options.method, dependencies);\n const config = options.config\n ? loadConfig(withJsonExtension(options.config))\n : (resolveConfig(process.cwd())?.config ?? {});\n const baseUrl = resolveApiBaseUrl(\n typeof config.baseUrl === 'string' ? config.baseUrl : undefined\n );\n const client = createApiClient({\n apiKey: options.apiKey ?? process.env.GT_API_KEY,\n userTokenProvider: createUserTokenProvider({ baseUrl }),\n baseUrl,\n fetch: dependencies.fetch,\n projectId: resolveApiProjectId(config, options.projectId, dependencies),\n retryPolicy: 'none',\n });\n const normalizedEndpoint = endpoint.startsWith('/')\n ? endpoint\n : `/${endpoint}`;\n const headers = parseHeaders(options.header ?? [], dependencies);\n const body = options.input\n ? readInput(options.input, dependencies)\n : undefined;\n let rawResponse: Response | undefined;\n\n client.interceptors.response.use((response) => {\n // Keep a clone because the generated client consumes non-2xx bodies.\n rawResponse = response.clone();\n return response;\n });\n\n const result = await client\n .request({\n body,\n bodySerializer: () => body,\n headers,\n method,\n parseAs: 'stream',\n throwOnError: false,\n url: normalizedEndpoint,\n })\n .catch((error) =>\n fail(\n createDiagnosticMessage({\n source: 'gt',\n severity: 'Error',\n whatHappened: 'The API request failed before a response was received',\n details: formatDiagnosticErrorDetails(error),\n }),\n dependencies\n )\n );\n\n if (!rawResponse) {\n fail(\n createDiagnosticMessage({\n source: 'gt',\n severity: 'Error',\n whatHappened: 'The API request did not return a response',\n details: formatDiagnosticErrorDetails(result?.error),\n }),\n dependencies\n );\n }\n\n if (options.include) writeResponseMetadata(rawResponse, writeStdout);\n const responseBody = Buffer.from(await rawResponse.arrayBuffer());\n writeStdout(responseBody);\n\n if (!rawResponse.ok) {\n if (responseBody.length > 0 && responseBody.at(-1) !== 0x0a) {\n writeStdout('\\n');\n }\n writeStderr(\n `${method} ${normalizedEndpoint} returned HTTP ${rawResponse.status}${rawResponse.statusText ? ` ${rawResponse.statusText}` : ''}\\n`\n );\n (dependencies.exit ?? exitSync)(1);\n }\n}\n"],"mappings":";;;;;;;;;;;AAqCA,MAAM,wBAAwB,IAAI,IAAI;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,SAAS,KACP,YACA,EACE,OAAO,UACP,eAAe,WAAW,QAAQ,OAAO,MAAM,OAAO,IAEjD;AACP,aAAY,GAAG,WAAW,IAAI;AAC9B,QAAO,KAAK,EAAE;;AAGhB,SAAS,YACP,OACA,cAC6B;CAC7B,MAAM,SAAS,MAAM,aAAa;AAClC,KAAI,CAAC,sBAAsB,IAAI,OAAO,CACpC,MACE,wBAAwB;EACtB,QAAQ;EACR,UAAU;EACV,cAAc;EACd,SAAS;EACT,KAAK,cAAc,CAAC,GAAG,sBAAsB,CAAC,KAAK,KAAK;EACzD,CAAC,EACF,aACD;AAGH,QAAO;;AAGT,SAAS,aACP,QACA,cACS;CACT,MAAM,UAAU,IAAI,SAAS;AAC7B,MAAK,MAAM,UAAU,QAAQ;EAC3B,MAAM,YAAY,OAAO,QAAQ,IAAI;AACrC,MAAI,YAAY,EACd,MACE,wBAAwB;GACtB,QAAQ;GACR,UAAU;GACV,cAAc;GACd,SAAS;GACT,KAAK;GACN,CAAC,EACF,aACD;AAEH,UAAQ,OACN,OAAO,MAAM,GAAG,UAAU,CAAC,MAAM,EACjC,OAAO,MAAM,YAAY,EAAE,CAAC,MAAM,CACnC;;AAEH,QAAO;;AAGT,SAAS,UACP,OACA,cACQ;AACR,KAAI;AACF,SAAO,GAAG,aAAa,UAAU,MAAM,IAAI,OAAO,OAAO;UAClD,OAAO;AACd,SAAO,KACL,wBAAwB;GACtB,QAAQ;GACR,UAAU;GACV,cAAc;GACd,KACE,UAAU,MACN,gEACA;GACN,SAAS,6BAA6B,MAAM;GAC7C,CAAC,EACF,aACD;;;AASL,MAAM,YAGF,YAAY;AAEhB,SAAS,iBAAyB;AAChC,QAAO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;EACA,SAAS;EACT,cAAc;EACd,KAAK;EACN,CAAC,CACD,OAAO,UACN,KACE,wBAAwB;EACtB,QAAQ;EACR,UAAU;EACV,cAAc;EACd,SAAS,6BAA6B,MAAM;EAC7C,CAAC,EACF,aACD,CACF;AAEH,KAAI,CAAC,YACH,MACE,wBAAwB;EACtB,QAAQ;EACR,UAAU;EACV,cAAc;EACd,SAAS,6BAA6B,QAAQ,MAAM;EACrD,CAAC,EACF,aACD;AAGH,KAAI,QAAQ,QAAS,uBAAsB,aAAa,YAAY;CACpE,MAAM,eAAe,OAAO,KAAK,MAAM,YAAY,aAAa,CAAC;AACjE,aAAY,aAAa;AAEzB,KAAI,CAAC,YAAY,IAAI;AACnB,MAAI,aAAa,SAAS,KAAK,aAAa,GAAG,GAAG,KAAK,GACrD,aAAY,KAAK;AAEnB,cACE,GAAG,OAAO,GAAG,mBAAmB,iBAAiB,YAAY,SAAS,YAAY,aAAa,IAAI,YAAY,eAAe,GAAG,IAClI;AACD,GAAC,aAAa,QAAQ,UAAU,EAAE"}
|
|
@@ -12,7 +12,7 @@ import { createFileMapping } from "../../formats/files/fileMapping.js";
|
|
|
12
12
|
import { hasValidCredentials, hasValidServiceLocales } from "./utils/validation.js";
|
|
13
13
|
import { runPublishWorkflow } from "../../workflows/publish.js";
|
|
14
14
|
import { parseXcstringsCatalog, serializeXcstringsSlice, sliceTranslationCatalog } from "../../formats/xcstrings/parseXcstrings.js";
|
|
15
|
-
import { aggregateFiles } from "../../formats/files/aggregateFiles.js";
|
|
15
|
+
import { aggregateFiles, isUnparsableFile } from "../../formats/files/aggregateFiles.js";
|
|
16
16
|
import { existsSync } from "node:fs";
|
|
17
17
|
//#region src/cli/commands/upload.ts
|
|
18
18
|
/**
|
|
@@ -35,6 +35,10 @@ async function upload(settings) {
|
|
|
35
35
|
content: readFile(filePath)
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
+
const skipValidation = additionalOptions.skipFileValidation;
|
|
39
|
+
const translationParseFormats = /* @__PURE__ */ new Map();
|
|
40
|
+
if (!skipValidation?.json) for (const filePath of [...filePaths.json ?? [], ...filePaths.twilioContentJson ?? []]) translationParseFormats.set(getRelative(filePath), "JSON");
|
|
41
|
+
if (!skipValidation?.yaml) for (const filePath of filePaths.yaml ?? []) translationParseFormats.set(getRelative(filePath), "YAML");
|
|
38
42
|
const xcstringsCatalogs = /* @__PURE__ */ new Map();
|
|
39
43
|
if (filePaths.xcstrings) for (const filePath of filePaths.xcstrings) {
|
|
40
44
|
const relativePath = getRelative(filePath);
|
|
@@ -91,6 +95,8 @@ async function upload(settings) {
|
|
|
91
95
|
recordWarning("skipped_file", relativePath, reason);
|
|
92
96
|
continue;
|
|
93
97
|
}
|
|
98
|
+
const parseFormat = translationParseFormats.get(file.fileName);
|
|
99
|
+
if (parseFormat && isUnparsableFile(translatedContent, getRelative(translatedFileName), parseFormat)) continue;
|
|
94
100
|
translations.push({
|
|
95
101
|
content: translatedContent,
|
|
96
102
|
fileName: translatedFileName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.js","names":[],"sources":["../../../src/cli/commands/upload.ts"],"sourcesContent":["import {\n fileEncodingSkipReason,\n noDefaultLocaleError,\n} from '../../console/index.js';\nimport { exitSync, logErrorAndExit } from '../../console/logging.js';\nimport { logger } from '../../console/logger.js';\nimport { getRelative, readFile } from '../../fs/findFilepath.js';\nimport { readFileContent } from '../../fs/fileContent.js';\nimport { Settings } from '../../types/index.js';\nimport { UploadOptions } from '../base.js';\nimport { extractJson } from '../../formats/json/extractJson.js';\nimport { validateJsonSchema } from '../../formats/json/utils.js';\nimport { runUploadFilesWorkflow } from '../../workflows/upload.js';\nimport { existsSync } from 'node:fs';\nimport { createFileMapping } from '../../formats/files/fileMapping.js';\nimport type { FileToUpload } from 'generaltranslation/types';\nimport {\n hasValidCredentials,\n hasValidServiceLocales,\n} from './utils/validation.js';\nimport { runPublishWorkflow } from '../../workflows/publish.js';\nimport { aggregateFiles } from '../../formats/files/aggregateFiles.js';\nimport { recordWarning } from '../../state/translateWarnings.js';\nimport {\n parseXcstringsCatalog,\n serializeXcstringsSlice,\n sliceTranslationCatalog,\n type XcstringsCatalog,\n} from '../../formats/xcstrings/parseXcstrings.js';\nimport { api } from '../../utils/api.js';\n\n/**\n * Sends multiple files to the API for translation\n * @param settings - Translation options including API settings\n * @returns Promise that resolves when translation is complete\n */\nexport async function upload(\n settings: Settings & UploadOptions\n): Promise<void> {\n if (!settings.files) {\n return;\n }\n\n const additionalOptions = settings.options || {};\n const {\n resolvedPaths: filePaths,\n placeholderPaths,\n transformPaths,\n transformFormats,\n } = settings.files;\n\n // Reuse the same source aggregation path as translate/stage so source\n // parsing behavior stays consistent across commands.\n const { files: allFiles, publishMap } = await aggregateFiles(settings);\n const sourceFileNames = new Set(allFiles.map((file) => file.fileName));\n const compositeJsonFiles = new Map<\n string,\n { filePath: string; content: string }\n >();\n\n if (filePaths.json) {\n for (const filePath of filePaths.json) {\n const relativePath = getRelative(filePath);\n if (!sourceFileNames.has(relativePath)) continue;\n\n const jsonSchema = validateJsonSchema(additionalOptions, filePath);\n if (jsonSchema?.composite) {\n compositeJsonFiles.set(relativePath, {\n filePath,\n content: readFile(filePath),\n });\n }\n }\n }\n\n // An .xcstrings catalog carries its own translations, so each locale's\n // upload is a slice of the same file rather than a separate translation\n // file. Catalogs aggregateFiles could not parse are already reported.\n const xcstringsCatalogs = new Map<string, XcstringsCatalog>();\n if (filePaths.xcstrings) {\n for (const filePath of filePaths.xcstrings) {\n const relativePath = getRelative(filePath);\n if (!sourceFileNames.has(relativePath)) continue;\n xcstringsCatalogs.set(\n relativePath,\n parseXcstringsCatalog(readFile(filePath))\n );\n }\n }\n\n if (allFiles.length === 0) {\n logger.error(\n 'No files to upload were found. Check your configuration and try again.'\n );\n return;\n }\n\n if (!settings.defaultLocale) {\n return logErrorAndExit(noDefaultLocaleError);\n }\n if (!hasValidCredentials(settings) || !hasValidServiceLocales(settings))\n return exitSync(1);\n\n const locales = settings.locales || [];\n // Create file mapping for all file types\n const fileMapping = createFileMapping(\n filePaths,\n placeholderPaths,\n transformPaths,\n transformFormats,\n locales,\n settings.defaultLocale\n );\n\n // construct object\n const uploadData = allFiles.map((file) => {\n const sourceFile: FileToUpload = { ...file };\n\n const translations: FileToUpload[] = [];\n const compositeInfo = compositeJsonFiles.get(file.fileName);\n const xcstringsCatalog = xcstringsCatalogs.get(file.fileName);\n\n for (const locale of locales) {\n if (xcstringsCatalog) {\n // Catalog keys are canonical tags; the configured locale may be an alias.\n const slice = sliceTranslationCatalog(\n xcstringsCatalog,\n api.resolveCanonicalLocale(locale)\n );\n // A locale the catalog does not carry has nothing to upload\n if (!slice) continue;\n translations.push({\n content: serializeXcstringsSlice(slice),\n fileName: file.fileName,\n fileFormat: file.transformFormat ?? file.fileFormat,\n dataFormat: file.dataFormat,\n locale,\n fileId: file.fileId,\n versionId: file.versionId,\n });\n } else if (compositeInfo) {\n // Composite JSON: extract translations from the same source file\n const extracted = extractJson(\n compositeInfo.content,\n compositeInfo.filePath,\n additionalOptions,\n locale,\n settings.defaultLocale\n );\n if (extracted) {\n translations.push({\n content: extracted,\n fileName: file.fileName,\n fileFormat: file.transformFormat ?? file.fileFormat,\n dataFormat: file.dataFormat,\n locale,\n fileId: file.fileId,\n versionId: file.versionId,\n });\n }\n } else {\n // Non-composite: look for separate translation files\n const translatedFileName = fileMapping[locale]?.[file.fileName];\n if (translatedFileName && existsSync(translatedFileName)) {\n const translationFormat = file.transformFormat ?? file.fileFormat;\n let translatedContent: string;\n try {\n translatedContent = readFileContent(\n translatedFileName,\n translationFormat\n );\n } catch (error) {\n // One undecodable locale should not block the others: skip it and\n // report it in the summary.\n const relativePath = getRelative(translatedFileName);\n const reason = fileEncodingSkipReason(error);\n logger.warn(`Skipping ${relativePath}: ${reason}`);\n recordWarning('skipped_file', relativePath, reason);\n continue;\n }\n translations.push({\n content: translatedContent,\n fileName: translatedFileName,\n fileFormat: translationFormat,\n dataFormat: file.dataFormat,\n locale,\n fileId: file.fileId,\n versionId: file.versionId,\n });\n }\n }\n }\n return {\n source: sourceFile,\n translations,\n };\n });\n\n try {\n // Send all files in a single API call\n const { branchData } = await runUploadFilesWorkflow({\n files: uploadData,\n options: settings,\n });\n\n // Publish files to CDN if publish config exists\n await runPublishWorkflow(\n allFiles,\n publishMap,\n branchData.currentBranch.id,\n settings\n );\n } catch (error) {\n logErrorAndExit(`Error uploading files: ${error}`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAoCA,eAAsB,OACpB,UACe;AACf,KAAI,CAAC,SAAS,MACZ;CAGF,MAAM,oBAAoB,SAAS,WAAW,EAAE;CAChD,MAAM,EACJ,eAAe,WACf,kBACA,gBACA,qBACE,SAAS;CAIb,MAAM,EAAE,OAAO,UAAU,eAAe,MAAM,eAAe,SAAS;CACtE,MAAM,kBAAkB,IAAI,IAAI,SAAS,KAAK,SAAS,KAAK,SAAS,CAAC;CACtE,MAAM,qCAAqB,IAAI,KAG5B;AAEH,KAAI,UAAU,KACZ,MAAK,MAAM,YAAY,UAAU,MAAM;EACrC,MAAM,eAAe,YAAY,SAAS;AAC1C,MAAI,CAAC,gBAAgB,IAAI,aAAa,CAAE;AAGxC,MADmB,mBAAmB,mBAAmB,SAC3C,EAAE,UACd,oBAAmB,IAAI,cAAc;GACnC;GACA,SAAS,SAAS,SAAS;GAC5B,CAAC;;CAQR,MAAM,oCAAoB,IAAI,KAA+B;AAC7D,KAAI,UAAU,UACZ,MAAK,MAAM,YAAY,UAAU,WAAW;EAC1C,MAAM,eAAe,YAAY,SAAS;AAC1C,MAAI,CAAC,gBAAgB,IAAI,aAAa,CAAE;AACxC,oBAAkB,IAChB,cACA,sBAAsB,SAAS,SAAS,CAAC,CAC1C;;AAIL,KAAI,SAAS,WAAW,GAAG;AACzB,SAAO,MACL,yEACD;AACD;;AAGF,KAAI,CAAC,SAAS,cACZ,QAAO,gBAAgB,qBAAqB;AAE9C,KAAI,CAAC,oBAAoB,SAAS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AAa,KAAK;KAChB,SAAS;KACT,UAAU;KACV,YAAY;KACZ,YAAY,KAAK;KACjB;KACA,QAAQ,KAAK;KACb,WAAW,KAAK;KACjB,CAAC;;;AAIR,SAAO;GACL,QAAQ;GACR;GACD;GACD;AAEF,KAAI;EAEF,MAAM,EAAE,eAAe,MAAM,uBAAuB;GAClD,OAAO;GACP,SAAS;GACV,CAAC;AAGF,QAAM,mBACJ,UACA,YACA,WAAW,cAAc,IACzB,SACD;UACM,OAAO;AACd,kBAAgB,0BAA0B,QAAQ"}
|
|
1
|
+
{"version":3,"file":"upload.js","names":[],"sources":["../../../src/cli/commands/upload.ts"],"sourcesContent":["import {\n fileEncodingSkipReason,\n noDefaultLocaleError,\n} from '../../console/index.js';\nimport { exitSync, logErrorAndExit } from '../../console/logging.js';\nimport { logger } from '../../console/logger.js';\nimport { getRelative, readFile } from '../../fs/findFilepath.js';\nimport { readFileContent } from '../../fs/fileContent.js';\nimport { Settings } from '../../types/index.js';\nimport { UploadOptions } from '../base.js';\nimport { extractJson } from '../../formats/json/extractJson.js';\nimport { validateJsonSchema } from '../../formats/json/utils.js';\nimport { runUploadFilesWorkflow } from '../../workflows/upload.js';\nimport { existsSync } from 'node:fs';\nimport { createFileMapping } from '../../formats/files/fileMapping.js';\nimport type { FileToUpload } from 'generaltranslation/types';\nimport {\n hasValidCredentials,\n hasValidServiceLocales,\n} from './utils/validation.js';\nimport { runPublishWorkflow } from '../../workflows/publish.js';\nimport {\n aggregateFiles,\n isUnparsableFile,\n} from '../../formats/files/aggregateFiles.js';\nimport { recordWarning } from '../../state/translateWarnings.js';\nimport {\n parseXcstringsCatalog,\n serializeXcstringsSlice,\n sliceTranslationCatalog,\n type XcstringsCatalog,\n} from '../../formats/xcstrings/parseXcstrings.js';\nimport { api } from '../../utils/api.js';\n\n/**\n * Sends multiple files to the API for translation\n * @param settings - Translation options including API settings\n * @returns Promise that resolves when translation is complete\n */\nexport async function upload(\n settings: Settings & UploadOptions\n): Promise<void> {\n if (!settings.files) {\n return;\n }\n\n const additionalOptions = settings.options || {};\n const {\n resolvedPaths: filePaths,\n placeholderPaths,\n transformPaths,\n transformFormats,\n } = settings.files;\n\n // Reuse the same source aggregation path as translate/stage so source\n // parsing behavior stays consistent across commands.\n const { files: allFiles, publishMap } = await aggregateFiles(settings);\n const sourceFileNames = new Set(allFiles.map((file) => file.fileName));\n const compositeJsonFiles = new Map<\n string,\n { filePath: string; content: string }\n >();\n\n if (filePaths.json) {\n for (const filePath of filePaths.json) {\n const relativePath = getRelative(filePath);\n if (!sourceFileNames.has(relativePath)) continue;\n\n const jsonSchema = validateJsonSchema(additionalOptions, filePath);\n if (jsonSchema?.composite) {\n compositeJsonFiles.set(relativePath, {\n filePath,\n content: readFile(filePath),\n });\n }\n }\n }\n\n // Translation files are validated like their sources in aggregateFiles.\n const skipValidation = additionalOptions.skipFileValidation;\n const translationParseFormats = new Map<string, 'JSON' | 'YAML'>();\n if (!skipValidation?.json) {\n for (const filePath of [\n ...(filePaths.json ?? []),\n ...(filePaths.twilioContentJson ?? []),\n ]) {\n translationParseFormats.set(getRelative(filePath), 'JSON');\n }\n }\n if (!skipValidation?.yaml) {\n for (const filePath of filePaths.yaml ?? []) {\n translationParseFormats.set(getRelative(filePath), 'YAML');\n }\n }\n\n // An .xcstrings catalog carries its own translations, so each locale's\n // upload is a slice of the same file rather than a separate translation\n // file. Catalogs aggregateFiles could not parse are already reported.\n const xcstringsCatalogs = new Map<string, XcstringsCatalog>();\n if (filePaths.xcstrings) {\n for (const filePath of filePaths.xcstrings) {\n const relativePath = getRelative(filePath);\n if (!sourceFileNames.has(relativePath)) continue;\n xcstringsCatalogs.set(\n relativePath,\n parseXcstringsCatalog(readFile(filePath))\n );\n }\n }\n\n if (allFiles.length === 0) {\n logger.error(\n 'No files to upload were found. Check your configuration and try again.'\n );\n return;\n }\n\n if (!settings.defaultLocale) {\n return logErrorAndExit(noDefaultLocaleError);\n }\n if (!hasValidCredentials(settings) || !hasValidServiceLocales(settings))\n return exitSync(1);\n\n const locales = settings.locales || [];\n // Create file mapping for all file types\n const fileMapping = createFileMapping(\n filePaths,\n placeholderPaths,\n transformPaths,\n transformFormats,\n locales,\n settings.defaultLocale\n );\n\n // construct object\n const uploadData = allFiles.map((file) => {\n const sourceFile: FileToUpload = { ...file };\n\n const translations: FileToUpload[] = [];\n const compositeInfo = compositeJsonFiles.get(file.fileName);\n const xcstringsCatalog = xcstringsCatalogs.get(file.fileName);\n\n for (const locale of locales) {\n if (xcstringsCatalog) {\n // Catalog keys are canonical tags; the configured locale may be an alias.\n const slice = sliceTranslationCatalog(\n xcstringsCatalog,\n api.resolveCanonicalLocale(locale)\n );\n // A locale the catalog does not carry has nothing to upload\n if (!slice) continue;\n translations.push({\n content: serializeXcstringsSlice(slice),\n fileName: file.fileName,\n fileFormat: file.transformFormat ?? file.fileFormat,\n dataFormat: file.dataFormat,\n locale,\n fileId: file.fileId,\n versionId: file.versionId,\n });\n } else if (compositeInfo) {\n // Composite JSON: extract translations from the same source file\n const extracted = extractJson(\n compositeInfo.content,\n compositeInfo.filePath,\n additionalOptions,\n locale,\n settings.defaultLocale\n );\n if (extracted) {\n translations.push({\n content: extracted,\n fileName: file.fileName,\n fileFormat: file.transformFormat ?? file.fileFormat,\n dataFormat: file.dataFormat,\n locale,\n fileId: file.fileId,\n versionId: file.versionId,\n });\n }\n } else {\n // Non-composite: look for separate translation files\n const translatedFileName = fileMapping[locale]?.[file.fileName];\n if (translatedFileName && existsSync(translatedFileName)) {\n const translationFormat = file.transformFormat ?? file.fileFormat;\n let translatedContent: string;\n try {\n translatedContent = readFileContent(\n translatedFileName,\n translationFormat\n );\n } catch (error) {\n // One undecodable locale should not block the others: skip it and\n // report it in the summary.\n const relativePath = getRelative(translatedFileName);\n const reason = fileEncodingSkipReason(error);\n logger.warn(`Skipping ${relativePath}: ${reason}`);\n recordWarning('skipped_file', relativePath, reason);\n continue;\n }\n const parseFormat = translationParseFormats.get(file.fileName);\n if (\n parseFormat &&\n isUnparsableFile(\n translatedContent,\n getRelative(translatedFileName),\n parseFormat\n )\n ) {\n continue;\n }\n translations.push({\n content: translatedContent,\n fileName: translatedFileName,\n fileFormat: translationFormat,\n dataFormat: file.dataFormat,\n locale,\n fileId: file.fileId,\n versionId: file.versionId,\n });\n }\n }\n }\n return {\n source: sourceFile,\n translations,\n };\n });\n\n try {\n // Send all files in a single API call\n const { branchData } = await runUploadFilesWorkflow({\n files: uploadData,\n options: settings,\n });\n\n // Publish files to CDN if publish config exists\n await runPublishWorkflow(\n allFiles,\n publishMap,\n branchData.currentBranch.id,\n settings\n );\n } catch (error) {\n logErrorAndExit(`Error uploading files: ${error}`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuCA,eAAsB,OACpB,UACe;AACf,KAAI,CAAC,SAAS,MACZ;CAGF,MAAM,oBAAoB,SAAS,WAAW,EAAE;CAChD,MAAM,EACJ,eAAe,WACf,kBACA,gBACA,qBACE,SAAS;CAIb,MAAM,EAAE,OAAO,UAAU,eAAe,MAAM,eAAe,SAAS;CACtE,MAAM,kBAAkB,IAAI,IAAI,SAAS,KAAK,SAAS,KAAK,SAAS,CAAC;CACtE,MAAM,qCAAqB,IAAI,KAG5B;AAEH,KAAI,UAAU,KACZ,MAAK,MAAM,YAAY,UAAU,MAAM;EACrC,MAAM,eAAe,YAAY,SAAS;AAC1C,MAAI,CAAC,gBAAgB,IAAI,aAAa,CAAE;AAGxC,MADmB,mBAAmB,mBAAmB,SAC3C,EAAE,UACd,oBAAmB,IAAI,cAAc;GACnC;GACA,SAAS,SAAS,SAAS;GAC5B,CAAC;;CAMR,MAAM,iBAAiB,kBAAkB;CACzC,MAAM,0CAA0B,IAAI,KAA8B;AAClE,KAAI,CAAC,gBAAgB,KACnB,MAAK,MAAM,YAAY,CACrB,GAAI,UAAU,QAAQ,EAAE,EACxB,GAAI,UAAU,qBAAqB,EAAE,CACtC,CACC,yBAAwB,IAAI,YAAY,SAAS,EAAE,OAAO;AAG9D,K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B,SAAS;IACT,UAAU,KAAK;IACf,YAAY,KAAK,mBAAmB,KAAK;IACzC,YAAY,KAAK;IACjB;IACA,QAAQ,KAAK;IACb,WAAW,KAAK;IACjB,CAAC;SAEC;GAEL,MAAM,qBAAqB,YAAY,UAAU,KAAK;AACtD,OAAI,sBAAsB,WAAW,mBAAmB,EAAE;IACxD,MAAM,oBAAoB,KAAK,mBAAmB,KAAK;IACvD,IAAI;AACJ,QAAI;AACF,yBAAoB,gBAClB,oBACA,kBACD;aACM,OAAO;KAGd,MAAM,eAAe,YAAY,mBAAmB;KACpD,MAAM,SAAS,uBAAuB,MAAM;AAC5C,YAAO,KAAK,YAAY,aAAa,IAAI,SAAS;AAClD,mBAAc,gBAAgB,cAAc,OAAO;AACnD;;IAEF,MAAM,cAAc,wBAAwB,IAAI,KAAK,SAAS;AAC9D,QACE,eACA,iBACE,mBACA,YAAY,mBAAmB,EAC/B,YACD,CAED;AAEF,iBAAa,KAAK;KAChB,SAAS;KACT,UAAU;KACV,YAAY;KACZ,YAAY,KAAK;KACjB;KACA,QAAQ,KAAK;KACb,WAAW,KAAK;KACjB,CAAC;;;AAIR,SAAO;GACL,QAAQ;GACR;GACD;GACD;AAEF,KAAI;EAEF,MAAM,EAAE,eAAe,MAAM,uBAAuB;GAClD,OAAO;GACP,SAAS;GACV,CAAC;AAGF,QAAM,mBACJ,UACA,YACA,WAAW,cAAc,IACzB,SACD;UACM,OAAO;AACd,kBAAgB,0BAA0B,QAAQ"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { Settings } from '../../types/index.js';
|
|
2
2
|
import type { FileToUpload } from '../../types/data.js';
|
|
3
|
+
/**
|
|
4
|
+
* Warns and records a skipped file when its content does not parse as JSON or
|
|
5
|
+
* YAML, so the caller can leave the file out of the upload.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isUnparsableFile(content: string, relativePath: string, format: 'JSON' | 'YAML'): boolean;
|
|
3
8
|
export declare function aggregateFiles(settings: Settings): Promise<{
|
|
4
9
|
files: FileToUpload[];
|
|
5
10
|
publishMap: Map<string, boolean>;
|
|
@@ -32,6 +32,22 @@ function isCompanionMetadataFile(filePath, allFilePaths) {
|
|
|
32
32
|
const sourceFilePath = filePath.replace(/\.metadata\.(json|yaml|yml)$/, ".$1");
|
|
33
33
|
return allFilePaths.includes(sourceFilePath);
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Warns and records a skipped file when its content does not parse as JSON or
|
|
37
|
+
* YAML, so the caller can leave the file out of the upload.
|
|
38
|
+
*/
|
|
39
|
+
function isUnparsableFile(content, relativePath, format) {
|
|
40
|
+
try {
|
|
41
|
+
if (format === "JSON") JSON.parse(content);
|
|
42
|
+
else YAML.parse(content);
|
|
43
|
+
return false;
|
|
44
|
+
} catch {
|
|
45
|
+
const reason = `${format} file is not parsable`;
|
|
46
|
+
logger.warn(`Skipping ${relativePath}: ${reason}`);
|
|
47
|
+
recordWarning("skipped_file", relativePath, reason);
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
35
51
|
async function aggregateFiles(settings) {
|
|
36
52
|
const files = [];
|
|
37
53
|
if (!settings.files || Object.keys(settings.files.placeholderPaths).length === 1 && settings.files.placeholderPaths.gt) return {
|
|
@@ -52,13 +68,7 @@ async function aggregateFiles(settings) {
|
|
|
52
68
|
const jsonFiles = filePaths.json.filter((filePath) => !isCompanionMetadataFile(filePath, filePaths.json)).map((filePath) => {
|
|
53
69
|
const content = readFile(filePath);
|
|
54
70
|
const relativePath = getRelative(filePath);
|
|
55
|
-
if (!skipValidation?.json)
|
|
56
|
-
JSON.parse(content);
|
|
57
|
-
} catch {
|
|
58
|
-
logger.warn(`Skipping ${relativePath}: JSON file is not parsable`);
|
|
59
|
-
recordWarning("skipped_file", relativePath, "JSON file is not parsable");
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
71
|
+
if (!skipValidation?.json && isUnparsableFile(content, relativePath, "JSON")) return null;
|
|
62
72
|
let contentForParsing = content;
|
|
63
73
|
if (shouldResolveRefs(filePath, settings.options)) try {
|
|
64
74
|
const { resolved, refMap } = resolveMintlifyRefs(JSON.parse(content), filePath);
|
|
@@ -108,13 +118,7 @@ async function aggregateFiles(settings) {
|
|
|
108
118
|
const yamlFiles = filePaths.yaml.filter((filePath) => !isCompanionMetadataFile(filePath, filePaths.yaml)).map((filePath) => {
|
|
109
119
|
const content = readFile(filePath);
|
|
110
120
|
const relativePath = getRelative(filePath);
|
|
111
|
-
if (!skipValidation?.yaml)
|
|
112
|
-
YAML.parse(content);
|
|
113
|
-
} catch {
|
|
114
|
-
logger.warn(`Skipping ${relativePath}: YAML file is not parsable`);
|
|
115
|
-
recordWarning("skipped_file", relativePath, "YAML file is not parsable");
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
121
|
+
if (!skipValidation?.yaml && isUnparsableFile(content, relativePath, "YAML")) return null;
|
|
118
122
|
const { content: parsedYaml, fileFormat } = parseYaml(content, filePath, settings.options || {});
|
|
119
123
|
let keyedMetadata;
|
|
120
124
|
try {
|
|
@@ -154,13 +158,7 @@ async function aggregateFiles(settings) {
|
|
|
154
158
|
const twilioContentJsonFiles = filePaths.twilioContentJson.map((filePath) => {
|
|
155
159
|
const content = readFile(filePath);
|
|
156
160
|
const relativePath = getRelative(filePath);
|
|
157
|
-
if (!skipValidation?.json)
|
|
158
|
-
JSON.parse(content);
|
|
159
|
-
} catch {
|
|
160
|
-
logger.warn(`Skipping ${relativePath}: JSON file is not parsable`);
|
|
161
|
-
recordWarning("skipped_file", relativePath, "JSON file is not parsable");
|
|
162
|
-
return null;
|
|
163
|
-
}
|
|
161
|
+
if (!skipValidation?.json && isUnparsableFile(content, relativePath, "JSON")) return null;
|
|
164
162
|
const parsedJson = parseJson(content, filePath, settings.options || {}, settings.defaultLocale);
|
|
165
163
|
return {
|
|
166
164
|
fileId: hashStringSync(relativePath),
|
|
@@ -324,6 +322,6 @@ async function aggregateFiles(settings) {
|
|
|
324
322
|
};
|
|
325
323
|
}
|
|
326
324
|
//#endregion
|
|
327
|
-
export { aggregateFiles };
|
|
325
|
+
export { aggregateFiles, isUnparsableFile };
|
|
328
326
|
|
|
329
327
|
//# sourceMappingURL=aggregateFiles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregateFiles.js","names":[],"sources":["../../../src/formats/files/aggregateFiles.ts"],"sourcesContent":["import { logger } from '../../console/logger.js';\nimport { logErrorAndExit } from '../../console/logging.js';\nimport {\n fileEncodingSkipReason,\n lottieExpressionsError,\n xcstringsSourceLanguageMismatchError,\n} from '../../console/index.js';\nimport { recordWarning } from '../../state/translateWarnings.js';\nimport { lottieHasExpressions } from './detectLottieExpressions.js';\nimport {\n getRelative,\n readFile,\n readBinaryFileBase64,\n} from '../../fs/findFilepath.js';\nimport { readFileContent } from '../../fs/fileContent.js';\nimport { Settings } from '../../types/index.js';\nimport type { DataFormat, FileToUpload } from '../../types/data.js';\nimport { SUPPORTED_FILE_EXTENSIONS } from './supportedFiles.js';\nimport { parseJson } from '../json/parseJson.js';\nimport {\n parseXcstringsCatalog,\n serializeXcstringsSlice,\n sliceSourceCatalog,\n type XcstringsCatalog,\n} from '../xcstrings/parseXcstrings.js';\nimport {\n resolveMintlifyRefs,\n shouldResolveRefs,\n} from '../../utils/resolveMintlifyRefs.js';\nimport { storeRefMap } from '../../state/mintlifyRefMap.js';\nimport parseYaml from '../yaml/parseYaml.js';\nimport { validateYamlSchema } from '../yaml/utils.js';\nimport { flattenJson } from '../json/flattenJson.js';\nimport type { JSONObject } from '../../types/data/json.js';\nimport YAML from 'yaml';\nimport { determineLibrary } from '../../fs/determineFramework/index.js';\nimport { hashStringSync, hashVersionId } from '../../utils/hash.js';\nimport { api } from '../../utils/api.js';\nimport { preprocessContent } from './preprocessContent.js';\nimport {\n parseKeyedMetadata,\n type KeyedMetadata,\n} from '../parseKeyedMetadata.js';\nimport { buildPublishMap } from '../../utils/resolvePublish.js';\nimport {\n CONFIG_FILE_TYPE_TO_FILE_FORMAT,\n getTransformFormatProperty,\n} from './transformFormat.js';\n\n/**\n * Checks if a file path is a metadata companion file (e.g. foo.metadata.json)\n * AND its corresponding source file (e.g. foo.json) exists in the file list.\n * If both conditions are true, the metadata file should be skipped as a translation source.\n */\nfunction isCompanionMetadataFile(\n filePath: string,\n allFilePaths: string[]\n): boolean {\n const metadataPattern = /\\.metadata\\.(json|yaml|yml)$/;\n if (!metadataPattern.test(filePath)) return false;\n\n // Derive the source file path: foo.metadata.json -> foo.json\n const sourceFilePath = filePath.replace(\n /\\.metadata\\.(json|yaml|yml)$/,\n '.$1'\n );\n return allFilePaths.includes(sourceFilePath);\n}\n\nexport async function aggregateFiles(\n settings: Settings\n): Promise<{ files: FileToUpload[]; publishMap: Map<string, boolean> }> {\n // Aggregate all files to translate\n const files: FileToUpload[] = [];\n if (\n !settings.files ||\n (Object.keys(settings.files.placeholderPaths).length === 1 &&\n settings.files.placeholderPaths.gt)\n ) {\n return { files, publishMap: new Map<string, boolean>() };\n }\n\n const { resolvedPaths: filePaths } = settings.files;\n // Tolerate partially-constructed settings from programmatic callers\n const requiresReviewPaths =\n settings.files.requiresReviewPaths ?? new Set<string>();\n const skipValidation = settings.options?.skipFileValidation;\n\n // Build publish map upfront from resolved paths.\n const publishMap = buildPublishMap(filePaths, settings);\n\n // Process JSON files\n if (filePaths.json) {\n const { library, additionalModules } = determineLibrary();\n\n // Determine dataFormat for JSONs\n let dataFormat: DataFormat;\n if (library === 'next-intl') {\n dataFormat = 'ICU';\n } else if (library === 'i18next') {\n if (additionalModules.includes('i18next-icu')) {\n dataFormat = 'ICU';\n } else {\n dataFormat = 'I18NEXT';\n }\n } else {\n dataFormat = 'STRING';\n }\n\n const jsonFiles = filePaths.json\n .filter((filePath) => !isCompanionMetadataFile(filePath, filePaths.json!))\n .map((filePath) => {\n const content = readFile(filePath);\n const relativePath = getRelative(filePath);\n\n // Pre-validate JSON parseability\n if (!skipValidation?.json) {\n try {\n JSON.parse(content);\n } catch {\n logger.warn(`Skipping ${relativePath}: JSON file is not parsable`);\n recordWarning(\n 'skipped_file',\n relativePath,\n 'JSON file is not parsable'\n );\n return null;\n }\n }\n\n // Resolve $ref before parsing if configured\n let contentForParsing = content;\n if (shouldResolveRefs(filePath, settings.options)) {\n try {\n const json = JSON.parse(content);\n const { resolved, refMap } = resolveMintlifyRefs(json, filePath);\n storeRefMap(refMap);\n contentForParsing = JSON.stringify(resolved, null, 2);\n } catch {\n // JSON parse errors are handled below by parseJson\n }\n }\n\n const parsedJson = parseJson(\n contentForParsing,\n filePath,\n settings.options || {},\n settings.defaultLocale\n );\n\n // Detect companion metadata file\n let keyedMetadata: KeyedMetadata | undefined;\n let parsedContent: JSONObject | undefined;\n try {\n parsedContent = JSON.parse(content) as JSONObject;\n } catch {\n // Content not parsable — skip metadata detection\n }\n if (parsedContent) {\n const rawMetadata = parseKeyedMetadata(filePath, parsedContent);\n if (rawMetadata) {\n // Run metadata through the same include/composite schema as the source\n // so key paths align at translation time\n const transformed = parseJson(\n JSON.stringify(rawMetadata),\n filePath,\n settings.options || {},\n settings.defaultLocale,\n false\n );\n const transformedMetadata = JSON.parse(transformed);\n\n // Filter metadata to only keep keys that exist in the transformed source\n // This prevents misaligned entries from wide JSONPath patterns\n const sourceKeys = new Set(Object.keys(JSON.parse(parsedJson)));\n const filtered = Object.fromEntries(\n Object.entries(transformedMetadata).filter(([k]) =>\n sourceKeys.has(k)\n )\n ) as KeyedMetadata;\n\n if (Object.keys(filtered).length > 0) {\n keyedMetadata = filtered;\n } else {\n logger.warn(\n `Companion metadata found for ${relativePath} but no keys aligned with the JSON schema — metadata was not attached`\n );\n }\n }\n }\n\n return {\n fileId: hashStringSync(relativePath),\n versionId: hashVersionId(\n parsedJson,\n requiresReviewPaths.has(filePath)\n ),\n content: parsedJson,\n fileName: relativePath,\n fileFormat: 'JSON' as const,\n ...getTransformFormatProperty(settings, 'json'),\n dataFormat,\n locale: settings.defaultLocale,\n ...(keyedMetadata && {\n formatMetadata: { keyedMetadata },\n }),\n } satisfies FileToUpload;\n })\n .filter((file) => {\n if (!file) return false;\n if (typeof file.content !== 'string' || !file.content.trim()) {\n logger.warn(`Skipping ${file.fileName}: JSON file is empty`);\n recordWarning('skipped_file', file.fileName, 'JSON file is empty');\n return false;\n }\n return true;\n });\n files.push(...jsonFiles.filter((file) => file !== null));\n }\n\n // Process YAML files\n if (filePaths.yaml) {\n const yamlFiles = filePaths.yaml\n .filter((filePath) => !isCompanionMetadataFile(filePath, filePaths.yaml!))\n .map((filePath) => {\n const content = readFile(filePath);\n const relativePath = getRelative(filePath);\n\n // Pre-validate YAML parseability\n if (!skipValidation?.yaml) {\n try {\n YAML.parse(content);\n } catch {\n logger.warn(`Skipping ${relativePath}: YAML file is not parsable`);\n recordWarning(\n 'skipped_file',\n relativePath,\n 'YAML file is not parsable'\n );\n return null;\n }\n }\n\n const { content: parsedYaml, fileFormat } = parseYaml(\n content,\n filePath,\n settings.options || {}\n );\n\n // Detect companion metadata file\n let keyedMetadata: KeyedMetadata | undefined;\n try {\n const parsedYamlContent = YAML.parse(content);\n const rawMetadata = parseKeyedMetadata(filePath, parsedYamlContent);\n if (rawMetadata) {\n const yamlSchema = validateYamlSchema(\n settings.options || {},\n filePath\n );\n if (yamlSchema?.include) {\n // Flatten metadata through the same include schema as the source\n const flattened = flattenJson(rawMetadata, yamlSchema.include);\n // Filter to only keep keys that exist in the transformed source\n const sourceKeys = new Set(Object.keys(JSON.parse(parsedYaml)));\n const filtered = Object.fromEntries(\n Object.entries(flattened).filter(([k]) => sourceKeys.has(k))\n ) as KeyedMetadata;\n if (Object.keys(filtered).length > 0) {\n keyedMetadata = filtered;\n } else {\n logger.warn(\n `Companion metadata found for ${relativePath} but no keys aligned with the YAML schema — metadata was not attached`\n );\n }\n } else {\n keyedMetadata = rawMetadata;\n }\n }\n } catch {\n // Content not parsable as YAML — skip metadata detection\n }\n\n return {\n content: parsedYaml,\n fileName: relativePath,\n fileFormat,\n ...getTransformFormatProperty(settings, 'yaml'),\n fileId: hashStringSync(relativePath),\n versionId: hashVersionId(\n parsedYaml,\n requiresReviewPaths.has(filePath)\n ),\n locale: settings.defaultLocale,\n ...(keyedMetadata && {\n formatMetadata: { keyedMetadata },\n }),\n } satisfies FileToUpload;\n })\n .filter((file) => {\n if (!file || typeof file.content !== 'string' || !file.content.trim()) {\n logger.warn(\n `Skipping ${file?.fileName ?? 'unknown'}: YAML file is empty`\n );\n recordWarning(\n 'skipped_file',\n file?.fileName ?? 'unknown',\n 'YAML file is empty'\n );\n return false;\n }\n return true;\n });\n files.push(...yamlFiles.filter((file) => file !== null));\n }\n\n // Process Twilio Content JSON files\n if (filePaths.twilioContentJson) {\n const twilioContentJsonFiles = filePaths.twilioContentJson\n .map((filePath) => {\n const content = readFile(filePath);\n const relativePath = getRelative(filePath);\n\n // Pre-validate JSON parseability\n if (!skipValidation?.json) {\n try {\n JSON.parse(content);\n } catch {\n logger.warn(`Skipping ${relativePath}: JSON file is not parsable`);\n recordWarning(\n 'skipped_file',\n relativePath,\n 'JSON file is not parsable'\n );\n return null;\n }\n }\n\n const parsedJson = parseJson(\n content,\n filePath,\n settings.options || {},\n settings.defaultLocale\n );\n\n return {\n fileId: hashStringSync(relativePath),\n versionId: hashVersionId(\n parsedJson,\n requiresReviewPaths.has(filePath)\n ),\n content: parsedJson,\n fileName: relativePath,\n fileFormat: 'TWILIO_CONTENT_JSON' as const,\n ...getTransformFormatProperty(settings, 'twilioContentJson'),\n dataFormat: 'STRING' as const,\n locale: settings.defaultLocale,\n } satisfies FileToUpload;\n })\n .filter((file) => {\n if (!file) return false;\n if (typeof file.content !== 'string' || !file.content.trim()) {\n logger.warn(`Skipping ${file.fileName}: JSON file is empty`);\n recordWarning('skipped_file', file.fileName, 'JSON file is empty');\n return false;\n }\n return true;\n });\n files.push(...twilioContentJsonFiles.filter((file) => file !== null));\n }\n\n // Process Lottie files (binary zip bundles). Content is read as raw bytes and\n // carried base64-encoded end-to-end; the downloaded translation is written\n // back as bytes. No text parsing/merge.\n if (filePaths.lottie) {\n // Lottie files carrying After Effects expressions (executable JS) are\n // rejected outright — collect every offender, then fail once with all of\n // them named rather than aborting on the first.\n const expressionOffenders: string[] = [];\n const lottieFiles = filePaths.lottie\n .map((filePath) => {\n const content = readBinaryFileBase64(filePath);\n const relativePath = getRelative(filePath);\n if (!content) {\n logger.warn(`Skipping ${relativePath}: file is empty or unreadable`);\n recordWarning(\n 'skipped_file',\n relativePath,\n 'File is empty or unreadable'\n );\n return null;\n }\n if (lottieHasExpressions(content)) {\n expressionOffenders.push(relativePath);\n return null;\n }\n return {\n content,\n fileName: relativePath,\n fileFormat: 'LOTTIE' as const,\n ...getTransformFormatProperty(settings, 'lottie'),\n fileId: hashStringSync(relativePath),\n versionId: hashStringSync(content),\n locale: settings.defaultLocale,\n } satisfies FileToUpload;\n })\n .filter((file) => file !== null);\n if (expressionOffenders.length > 0) {\n logErrorAndExit(lottieExpressionsError(expressionOffenders));\n }\n files.push(...lottieFiles);\n }\n\n // These formats are uploaded verbatim. Their backslash escapes, format\n // specifiers, timing lines, entity escapes and line breaks must survive\n // byte-for-byte, so they skip the generic markdown-oriented preprocessing\n // below.\n for (const [fileType, fileFormat] of [\n ['dotStrings', 'DOT_STRINGS'],\n ['dotStringsdict', 'DOT_STRINGSDICT'],\n ['androidStrings', 'ANDROID_STRINGS'],\n ['srt', 'SRT'],\n ['resx', 'RESX'],\n ] as const) {\n if (!filePaths[fileType]) continue;\n const verbatimFiles = filePaths[fileType]\n .map((filePath) => {\n const relativePath = getRelative(filePath);\n // Reading is the one place an encoding is resolved; from here on the\n // content is a UTF-8 string like every other format's.\n let content: string;\n try {\n content = readFileContent(filePath, fileFormat);\n } catch (error) {\n // One unreadable file should not abort the whole run: skip it and\n // report it in the summary\n const reason = fileEncodingSkipReason(error);\n logger.warn(`Skipping ${relativePath}: ${reason}`);\n recordWarning('skipped_file', relativePath, reason);\n return null;\n }\n return {\n content,\n fileName: relativePath,\n fileFormat,\n ...getTransformFormatProperty(settings, fileType),\n fileId: hashStringSync(relativePath),\n versionId: hashVersionId(content, requiresReviewPaths.has(filePath)),\n locale: settings.defaultLocale,\n } satisfies FileToUpload;\n })\n .filter((file) => {\n if (!file) return false;\n if (!file.content.trim()) {\n logger.warn(`Skipping ${file.fileName}: File is empty`);\n recordWarning('skipped_file', file.fileName, 'File is empty');\n return false;\n }\n return true;\n });\n files.push(...verbatimFiles.filter((file) => file !== null));\n }\n\n // Process Apple .xcstrings catalogs. One catalog holds every locale; only the\n // source-language slice is uploaded as the source document. The slice is\n // hashed into versionId, so an unchanged catalog re-slices byte-identically\n // and does not re-upload.\n if (filePaths.xcstrings) {\n const sourceLanguageMismatches: { file: string; sourceLanguage: string }[] =\n [];\n const xcstringsFiles = filePaths.xcstrings\n .map((filePath) => {\n const content = readFile(filePath);\n const relativePath = getRelative(filePath);\n\n let catalog: XcstringsCatalog;\n try {\n catalog = parseXcstringsCatalog(content);\n } catch (error) {\n const reason =\n error instanceof Error\n ? error.message\n : 'xcstrings file is not parsable';\n logger.warn(`Skipping ${relativePath}: ${reason}`);\n recordWarning('skipped_file', relativePath, reason);\n return null;\n }\n // Slicing follows the catalog's own sourceLanguage while the upload is\n // labeled settings.defaultLocale; a mismatch would upload mislabeled\n // source content, so it is a configuration error that stops the run\n // rather than a skipped file. The configured locale may be a custom\n // alias, so canonical forms are compared.\n if (\n api.resolveCanonicalLocale(catalog.sourceLanguage) !==\n api.resolveCanonicalLocale(settings.defaultLocale)\n ) {\n sourceLanguageMismatches.push({\n file: relativePath,\n sourceLanguage: catalog.sourceLanguage,\n });\n return null;\n }\n const sourceSlice = serializeXcstringsSlice(\n sliceSourceCatalog(catalog)\n );\n\n return {\n content: sourceSlice,\n fileName: relativePath,\n fileFormat: 'XCSTRINGS' as const,\n ...getTransformFormatProperty(settings, 'xcstrings'),\n fileId: hashStringSync(relativePath),\n versionId: hashVersionId(\n sourceSlice,\n requiresReviewPaths.has(filePath)\n ),\n locale: settings.defaultLocale,\n } satisfies FileToUpload;\n })\n .filter((file) => file !== null);\n if (sourceLanguageMismatches.length > 0) {\n logErrorAndExit(\n xcstringsSourceLanguageMismatchError(\n sourceLanguageMismatches,\n settings.defaultLocale\n )\n );\n }\n files.push(...xcstringsFiles);\n }\n\n for (const fileType of SUPPORTED_FILE_EXTENSIONS) {\n if (\n fileType === 'json' ||\n fileType === 'yaml' ||\n fileType === 'twilioContentJson' ||\n fileType === 'lottie' ||\n fileType === 'dotStrings' ||\n fileType === 'dotStringsdict' ||\n fileType === 'androidStrings' ||\n fileType === 'xcstrings' ||\n fileType === 'srt' ||\n fileType === 'resx'\n )\n continue;\n if (filePaths[fileType]) {\n const parsed = filePaths[fileType]\n .map((filePath) => {\n const content = readFile(filePath);\n const relativePath = getRelative(filePath);\n\n const processed = preprocessContent(\n content,\n relativePath,\n fileType,\n settings\n );\n\n if (typeof processed !== 'string') {\n logger.warn(`Skipping ${relativePath}: ${processed.skip}`);\n recordWarning('skipped_file', relativePath, processed.skip);\n return null;\n }\n\n return {\n content: processed,\n fileName: relativePath,\n fileFormat: CONFIG_FILE_TYPE_TO_FILE_FORMAT[fileType],\n ...getTransformFormatProperty(settings, fileType),\n fileId: hashStringSync(relativePath),\n versionId: hashVersionId(\n processed,\n requiresReviewPaths.has(filePath)\n ),\n locale: settings.defaultLocale,\n } satisfies FileToUpload;\n })\n .filter((file) => {\n if (\n !file ||\n typeof file.content !== 'string' ||\n !file.content.trim()\n ) {\n logger.warn(\n `Skipping ${file?.fileName ?? 'unknown'}: File is empty after sanitization`\n );\n recordWarning(\n 'skipped_file',\n file?.fileName ?? 'unknown',\n 'File is empty after sanitization'\n );\n return false;\n }\n return true;\n });\n files.push(...parsed.filter((file) => file !== null));\n }\n }\n\n // Remove stale entries for files that were skipped during validation\n const validFileIds = new Set(files.map((f) => f.fileId));\n for (const fileId of publishMap.keys()) {\n if (!validFileIds.has(fileId)) {\n publishMap.delete(fileId);\n }\n }\n\n return { files, publishMap };\n}\n"],"mappings":";;;;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,SACA,cACA,UACA,SACD;AAED,QAAI,OAAO,cAAc,UAAU;AACjC,YAAO,KAAK,YAAY,aAAa,IAAI,UAAU,OAAO;AAC1D,mBAAc,gBAAgB,cAAc,UAAU,KAAK;AAC3D,YAAO;;AAGT,WAAO;KACL,SAAS;KACT,UAAU;KACV,YAAY,gCAAgC;KAC5C,GAAG,2BAA2B,UAAU,SAAS;KACjD,QAAQ,eAAe,aAAa;KACpC,WAAW,cACT,WACA,oBAAoB,IAAI,SAAS,CAClC;KACD,QAAQ,SAAS;KAClB;KACD,CACD,QAAQ,SAAS;AAChB,QACE,CAAC,QACD,OAAO,KAAK,YAAY,YACxB,CAAC,KAAK,QAAQ,MAAM,EACpB;AACA,YAAO,KACL,YAAY,MAAM,YAAY,UAAU,oCACzC;AACD,mBACE,gBACA,MAAM,YAAY,WAClB,mCACD;AACD,YAAO;;AAET,WAAO;KACP;AACJ,SAAM,KAAK,GAAG,OAAO,QAAQ,SAAS,SAAS,KAAK,CAAC;;;CAKzD,MAAM,eAAe,IAAI,IAAI,MAAM,KAAK,MAAM,EAAE,OAAO,CAAC;AACxD,MAAK,MAAM,UAAU,WAAW,MAAM,CACpC,KAAI,CAAC,aAAa,IAAI,OAAO,CAC3B,YAAW,OAAO,OAAO;AAI7B,QAAO;EAAE;EAAO;EAAY"}
|
|
1
|
+
{"version":3,"file":"aggregateFiles.js","names":[],"sources":["../../../src/formats/files/aggregateFiles.ts"],"sourcesContent":["import { logger } from '../../console/logger.js';\nimport { logErrorAndExit } from '../../console/logging.js';\nimport {\n fileEncodingSkipReason,\n lottieExpressionsError,\n xcstringsSourceLanguageMismatchError,\n} from '../../console/index.js';\nimport { recordWarning } from '../../state/translateWarnings.js';\nimport { lottieHasExpressions } from './detectLottieExpressions.js';\nimport {\n getRelative,\n readFile,\n readBinaryFileBase64,\n} from '../../fs/findFilepath.js';\nimport { readFileContent } from '../../fs/fileContent.js';\nimport { Settings } from '../../types/index.js';\nimport type { DataFormat, FileToUpload } from '../../types/data.js';\nimport { SUPPORTED_FILE_EXTENSIONS } from './supportedFiles.js';\nimport { parseJson } from '../json/parseJson.js';\nimport {\n parseXcstringsCatalog,\n serializeXcstringsSlice,\n sliceSourceCatalog,\n type XcstringsCatalog,\n} from '../xcstrings/parseXcstrings.js';\nimport {\n resolveMintlifyRefs,\n shouldResolveRefs,\n} from '../../utils/resolveMintlifyRefs.js';\nimport { storeRefMap } from '../../state/mintlifyRefMap.js';\nimport parseYaml from '../yaml/parseYaml.js';\nimport { validateYamlSchema } from '../yaml/utils.js';\nimport { flattenJson } from '../json/flattenJson.js';\nimport type { JSONObject } from '../../types/data/json.js';\nimport YAML from 'yaml';\nimport { determineLibrary } from '../../fs/determineFramework/index.js';\nimport { hashStringSync, hashVersionId } from '../../utils/hash.js';\nimport { api } from '../../utils/api.js';\nimport { preprocessContent } from './preprocessContent.js';\nimport {\n parseKeyedMetadata,\n type KeyedMetadata,\n} from '../parseKeyedMetadata.js';\nimport { buildPublishMap } from '../../utils/resolvePublish.js';\nimport {\n CONFIG_FILE_TYPE_TO_FILE_FORMAT,\n getTransformFormatProperty,\n} from './transformFormat.js';\n\n/**\n * Checks if a file path is a metadata companion file (e.g. foo.metadata.json)\n * AND its corresponding source file (e.g. foo.json) exists in the file list.\n * If both conditions are true, the metadata file should be skipped as a translation source.\n */\nfunction isCompanionMetadataFile(\n filePath: string,\n allFilePaths: string[]\n): boolean {\n const metadataPattern = /\\.metadata\\.(json|yaml|yml)$/;\n if (!metadataPattern.test(filePath)) return false;\n\n // Derive the source file path: foo.metadata.json -> foo.json\n const sourceFilePath = filePath.replace(\n /\\.metadata\\.(json|yaml|yml)$/,\n '.$1'\n );\n return allFilePaths.includes(sourceFilePath);\n}\n\n/**\n * Warns and records a skipped file when its content does not parse as JSON or\n * YAML, so the caller can leave the file out of the upload.\n */\nexport function isUnparsableFile(\n content: string,\n relativePath: string,\n format: 'JSON' | 'YAML'\n): boolean {\n try {\n if (format === 'JSON') JSON.parse(content);\n else YAML.parse(content);\n return false;\n } catch {\n const reason = `${format} file is not parsable`;\n logger.warn(`Skipping ${relativePath}: ${reason}`);\n recordWarning('skipped_file', relativePath, reason);\n return true;\n }\n}\n\nexport async function aggregateFiles(\n settings: Settings\n): Promise<{ files: FileToUpload[]; publishMap: Map<string, boolean> }> {\n // Aggregate all files to translate\n const files: FileToUpload[] = [];\n if (\n !settings.files ||\n (Object.keys(settings.files.placeholderPaths).length === 1 &&\n settings.files.placeholderPaths.gt)\n ) {\n return { files, publishMap: new Map<string, boolean>() };\n }\n\n const { resolvedPaths: filePaths } = settings.files;\n // Tolerate partially-constructed settings from programmatic callers\n const requiresReviewPaths =\n settings.files.requiresReviewPaths ?? new Set<string>();\n const skipValidation = settings.options?.skipFileValidation;\n\n // Build publish map upfront from resolved paths.\n const publishMap = buildPublishMap(filePaths, settings);\n\n // Process JSON files\n if (filePaths.json) {\n const { library, additionalModules } = determineLibrary();\n\n // Determine dataFormat for JSONs\n let dataFormat: DataFormat;\n if (library === 'next-intl') {\n dataFormat = 'ICU';\n } else if (library === 'i18next') {\n if (additionalModules.includes('i18next-icu')) {\n dataFormat = 'ICU';\n } else {\n dataFormat = 'I18NEXT';\n }\n } else {\n dataFormat = 'STRING';\n }\n\n const jsonFiles = filePaths.json\n .filter((filePath) => !isCompanionMetadataFile(filePath, filePaths.json!))\n .map((filePath) => {\n const content = readFile(filePath);\n const relativePath = getRelative(filePath);\n\n if (\n !skipValidation?.json &&\n isUnparsableFile(content, relativePath, 'JSON')\n ) {\n return null;\n }\n\n // Resolve $ref before parsing if configured\n let contentForParsing = content;\n if (shouldResolveRefs(filePath, settings.options)) {\n try {\n const json = JSON.parse(content);\n const { resolved, refMap } = resolveMintlifyRefs(json, filePath);\n storeRefMap(refMap);\n contentForParsing = JSON.stringify(resolved, null, 2);\n } catch {\n // JSON parse errors are handled below by parseJson\n }\n }\n\n const parsedJson = parseJson(\n contentForParsing,\n filePath,\n settings.options || {},\n settings.defaultLocale\n );\n\n // Detect companion metadata file\n let keyedMetadata: KeyedMetadata | undefined;\n let parsedContent: JSONObject | undefined;\n try {\n parsedContent = JSON.parse(content) as JSONObject;\n } catch {\n // Content not parsable — skip metadata detection\n }\n if (parsedContent) {\n const rawMetadata = parseKeyedMetadata(filePath, parsedContent);\n if (rawMetadata) {\n // Run metadata through the same include/composite schema as the source\n // so key paths align at translation time\n const transformed = parseJson(\n JSON.stringify(rawMetadata),\n filePath,\n settings.options || {},\n settings.defaultLocale,\n false\n );\n const transformedMetadata = JSON.parse(transformed);\n\n // Filter metadata to only keep keys that exist in the transformed source\n // This prevents misaligned entries from wide JSONPath patterns\n const sourceKeys = new Set(Object.keys(JSON.parse(parsedJson)));\n const filtered = Object.fromEntries(\n Object.entries(transformedMetadata).filter(([k]) =>\n sourceKeys.has(k)\n )\n ) as KeyedMetadata;\n\n if (Object.keys(filtered).length > 0) {\n keyedMetadata = filtered;\n } else {\n logger.warn(\n `Companion metadata found for ${relativePath} but no keys aligned with the JSON schema — metadata was not attached`\n );\n }\n }\n }\n\n return {\n fileId: hashStringSync(relativePath),\n versionId: hashVersionId(\n parsedJson,\n requiresReviewPaths.has(filePath)\n ),\n content: parsedJson,\n fileName: relativePath,\n fileFormat: 'JSON' as const,\n ...getTransformFormatProperty(settings, 'json'),\n dataFormat,\n locale: settings.defaultLocale,\n ...(keyedMetadata && {\n formatMetadata: { keyedMetadata },\n }),\n } satisfies FileToUpload;\n })\n .filter((file) => {\n if (!file) return false;\n if (typeof file.content !== 'string' || !file.content.trim()) {\n logger.warn(`Skipping ${file.fileName}: JSON file is empty`);\n recordWarning('skipped_file', file.fileName, 'JSON file is empty');\n return false;\n }\n return true;\n });\n files.push(...jsonFiles.filter((file) => file !== null));\n }\n\n // Process YAML files\n if (filePaths.yaml) {\n const yamlFiles = filePaths.yaml\n .filter((filePath) => !isCompanionMetadataFile(filePath, filePaths.yaml!))\n .map((filePath) => {\n const content = readFile(filePath);\n const relativePath = getRelative(filePath);\n\n if (\n !skipValidation?.yaml &&\n isUnparsableFile(content, relativePath, 'YAML')\n ) {\n return null;\n }\n\n const { content: parsedYaml, fileFormat } = parseYaml(\n content,\n filePath,\n settings.options || {}\n );\n\n // Detect companion metadata file\n let keyedMetadata: KeyedMetadata | undefined;\n try {\n const parsedYamlContent = YAML.parse(content);\n const rawMetadata = parseKeyedMetadata(filePath, parsedYamlContent);\n if (rawMetadata) {\n const yamlSchema = validateYamlSchema(\n settings.options || {},\n filePath\n );\n if (yamlSchema?.include) {\n // Flatten metadata through the same include schema as the source\n const flattened = flattenJson(rawMetadata, yamlSchema.include);\n // Filter to only keep keys that exist in the transformed source\n const sourceKeys = new Set(Object.keys(JSON.parse(parsedYaml)));\n const filtered = Object.fromEntries(\n Object.entries(flattened).filter(([k]) => sourceKeys.has(k))\n ) as KeyedMetadata;\n if (Object.keys(filtered).length > 0) {\n keyedMetadata = filtered;\n } else {\n logger.warn(\n `Companion metadata found for ${relativePath} but no keys aligned with the YAML schema — metadata was not attached`\n );\n }\n } else {\n keyedMetadata = rawMetadata;\n }\n }\n } catch {\n // Content not parsable as YAML — skip metadata detection\n }\n\n return {\n content: parsedYaml,\n fileName: relativePath,\n fileFormat,\n ...getTransformFormatProperty(settings, 'yaml'),\n fileId: hashStringSync(relativePath),\n versionId: hashVersionId(\n parsedYaml,\n requiresReviewPaths.has(filePath)\n ),\n locale: settings.defaultLocale,\n ...(keyedMetadata && {\n formatMetadata: { keyedMetadata },\n }),\n } satisfies FileToUpload;\n })\n .filter((file) => {\n if (!file || typeof file.content !== 'string' || !file.content.trim()) {\n logger.warn(\n `Skipping ${file?.fileName ?? 'unknown'}: YAML file is empty`\n );\n recordWarning(\n 'skipped_file',\n file?.fileName ?? 'unknown',\n 'YAML file is empty'\n );\n return false;\n }\n return true;\n });\n files.push(...yamlFiles.filter((file) => file !== null));\n }\n\n // Process Twilio Content JSON files\n if (filePaths.twilioContentJson) {\n const twilioContentJsonFiles = filePaths.twilioContentJson\n .map((filePath) => {\n const content = readFile(filePath);\n const relativePath = getRelative(filePath);\n\n if (\n !skipValidation?.json &&\n isUnparsableFile(content, relativePath, 'JSON')\n ) {\n return null;\n }\n\n const parsedJson = parseJson(\n content,\n filePath,\n settings.options || {},\n settings.defaultLocale\n );\n\n return {\n fileId: hashStringSync(relativePath),\n versionId: hashVersionId(\n parsedJson,\n requiresReviewPaths.has(filePath)\n ),\n content: parsedJson,\n fileName: relativePath,\n fileFormat: 'TWILIO_CONTENT_JSON' as const,\n ...getTransformFormatProperty(settings, 'twilioContentJson'),\n dataFormat: 'STRING' as const,\n locale: settings.defaultLocale,\n } satisfies FileToUpload;\n })\n .filter((file) => {\n if (!file) return false;\n if (typeof file.content !== 'string' || !file.content.trim()) {\n logger.warn(`Skipping ${file.fileName}: JSON file is empty`);\n recordWarning('skipped_file', file.fileName, 'JSON file is empty');\n return false;\n }\n return true;\n });\n files.push(...twilioContentJsonFiles.filter((file) => file !== null));\n }\n\n // Process Lottie files (binary zip bundles). Content is read as raw bytes and\n // carried base64-encoded end-to-end; the downloaded translation is written\n // back as bytes. No text parsing/merge.\n if (filePaths.lottie) {\n // Lottie files carrying After Effects expressions (executable JS) are\n // rejected outright — collect every offender, then fail once with all of\n // them named rather than aborting on the first.\n const expressionOffenders: string[] = [];\n const lottieFiles = filePaths.lottie\n .map((filePath) => {\n const content = readBinaryFileBase64(filePath);\n const relativePath = getRelative(filePath);\n if (!content) {\n logger.warn(`Skipping ${relativePath}: file is empty or unreadable`);\n recordWarning(\n 'skipped_file',\n relativePath,\n 'File is empty or unreadable'\n );\n return null;\n }\n if (lottieHasExpressions(content)) {\n expressionOffenders.push(relativePath);\n return null;\n }\n return {\n content,\n fileName: relativePath,\n fileFormat: 'LOTTIE' as const,\n ...getTransformFormatProperty(settings, 'lottie'),\n fileId: hashStringSync(relativePath),\n versionId: hashStringSync(content),\n locale: settings.defaultLocale,\n } satisfies FileToUpload;\n })\n .filter((file) => file !== null);\n if (expressionOffenders.length > 0) {\n logErrorAndExit(lottieExpressionsError(expressionOffenders));\n }\n files.push(...lottieFiles);\n }\n\n // These formats are uploaded verbatim. Their backslash escapes, format\n // specifiers, timing lines, entity escapes and line breaks must survive\n // byte-for-byte, so they skip the generic markdown-oriented preprocessing\n // below.\n for (const [fileType, fileFormat] of [\n ['dotStrings', 'DOT_STRINGS'],\n ['dotStringsdict', 'DOT_STRINGSDICT'],\n ['androidStrings', 'ANDROID_STRINGS'],\n ['srt', 'SRT'],\n ['resx', 'RESX'],\n ] as const) {\n if (!filePaths[fileType]) continue;\n const verbatimFiles = filePaths[fileType]\n .map((filePath) => {\n const relativePath = getRelative(filePath);\n // Reading is the one place an encoding is resolved; from here on the\n // content is a UTF-8 string like every other format's.\n let content: string;\n try {\n content = readFileContent(filePath, fileFormat);\n } catch (error) {\n // One unreadable file should not abort the whole run: skip it and\n // report it in the summary\n const reason = fileEncodingSkipReason(error);\n logger.warn(`Skipping ${relativePath}: ${reason}`);\n recordWarning('skipped_file', relativePath, reason);\n return null;\n }\n return {\n content,\n fileName: relativePath,\n fileFormat,\n ...getTransformFormatProperty(settings, fileType),\n fileId: hashStringSync(relativePath),\n versionId: hashVersionId(content, requiresReviewPaths.has(filePath)),\n locale: settings.defaultLocale,\n } satisfies FileToUpload;\n })\n .filter((file) => {\n if (!file) return false;\n if (!file.content.trim()) {\n logger.warn(`Skipping ${file.fileName}: File is empty`);\n recordWarning('skipped_file', file.fileName, 'File is empty');\n return false;\n }\n return true;\n });\n files.push(...verbatimFiles.filter((file) => file !== null));\n }\n\n // Process Apple .xcstrings catalogs. One catalog holds every locale; only the\n // source-language slice is uploaded as the source document. The slice is\n // hashed into versionId, so an unchanged catalog re-slices byte-identically\n // and does not re-upload.\n if (filePaths.xcstrings) {\n const sourceLanguageMismatches: { file: string; sourceLanguage: string }[] =\n [];\n const xcstringsFiles = filePaths.xcstrings\n .map((filePath) => {\n const content = readFile(filePath);\n const relativePath = getRelative(filePath);\n\n let catalog: XcstringsCatalog;\n try {\n catalog = parseXcstringsCatalog(content);\n } catch (error) {\n const reason =\n error instanceof Error\n ? error.message\n : 'xcstrings file is not parsable';\n logger.warn(`Skipping ${relativePath}: ${reason}`);\n recordWarning('skipped_file', relativePath, reason);\n return null;\n }\n // Slicing follows the catalog's own sourceLanguage while the upload is\n // labeled settings.defaultLocale; a mismatch would upload mislabeled\n // source content, so it is a configuration error that stops the run\n // rather than a skipped file. The configured locale may be a custom\n // alias, so canonical forms are compared.\n if (\n api.resolveCanonicalLocale(catalog.sourceLanguage) !==\n api.resolveCanonicalLocale(settings.defaultLocale)\n ) {\n sourceLanguageMismatches.push({\n file: relativePath,\n sourceLanguage: catalog.sourceLanguage,\n });\n return null;\n }\n const sourceSlice = serializeXcstringsSlice(\n sliceSourceCatalog(catalog)\n );\n\n return {\n content: sourceSlice,\n fileName: relativePath,\n fileFormat: 'XCSTRINGS' as const,\n ...getTransformFormatProperty(settings, 'xcstrings'),\n fileId: hashStringSync(relativePath),\n versionId: hashVersionId(\n sourceSlice,\n requiresReviewPaths.has(filePath)\n ),\n locale: settings.defaultLocale,\n } satisfies FileToUpload;\n })\n .filter((file) => file !== null);\n if (sourceLanguageMismatches.length > 0) {\n logErrorAndExit(\n xcstringsSourceLanguageMismatchError(\n sourceLanguageMismatches,\n settings.defaultLocale\n )\n );\n }\n files.push(...xcstringsFiles);\n }\n\n for (const fileType of SUPPORTED_FILE_EXTENSIONS) {\n if (\n fileType === 'json' ||\n fileType === 'yaml' ||\n fileType === 'twilioContentJson' ||\n fileType === 'lottie' ||\n fileType === 'dotStrings' ||\n fileType === 'dotStringsdict' ||\n fileType === 'androidStrings' ||\n fileType === 'xcstrings' ||\n fileType === 'srt' ||\n fileType === 'resx'\n )\n continue;\n if (filePaths[fileType]) {\n const parsed = filePaths[fileType]\n .map((filePath) => {\n const content = readFile(filePath);\n const relativePath = getRelative(filePath);\n\n const processed = preprocessContent(\n content,\n relativePath,\n fileType,\n settings\n );\n\n if (typeof processed !== 'string') {\n logger.warn(`Skipping ${relativePath}: ${processed.skip}`);\n recordWarning('skipped_file', relativePath, processed.skip);\n return null;\n }\n\n return {\n content: processed,\n fileName: relativePath,\n fileFormat: CONFIG_FILE_TYPE_TO_FILE_FORMAT[fileType],\n ...getTransformFormatProperty(settings, fileType),\n fileId: hashStringSync(relativePath),\n versionId: hashVersionId(\n processed,\n requiresReviewPaths.has(filePath)\n ),\n locale: settings.defaultLocale,\n } satisfies FileToUpload;\n })\n .filter((file) => {\n if (\n !file ||\n typeof file.content !== 'string' ||\n !file.content.trim()\n ) {\n logger.warn(\n `Skipping ${file?.fileName ?? 'unknown'}: File is empty after sanitization`\n );\n recordWarning(\n 'skipped_file',\n file?.fileName ?? 'unknown',\n 'File is empty after sanitization'\n );\n return false;\n }\n return true;\n });\n files.push(...parsed.filter((file) => file !== null));\n }\n }\n\n // Remove stale entries for files that were skipped during validation\n const validFileIds = new Set(files.map((f) => f.fileId));\n for (const fileId of publishMap.keys()) {\n if (!validFileIds.has(fileId)) {\n publishMap.delete(fileId);\n }\n }\n\n return { files, publishMap };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,SAAS,wBACP,UACA,cACS;AAET,KAAI,CAAC,+BAAgB,KAAK,SAAS,CAAE,QAAO;CAG5C,MAAM,iBAAiB,SAAS,QAC9B,gCACA,MACD;AACD,QAAO,aAAa,SAAS,eAAe;;;;;;AAO9C,SAAgB,iBACd,SACA,cACA,QACS;AACT,KAAI;AACF,MAAI,WAAW,OAAQ,MAAK,MAAM,QAAQ;MACrC,MAAK,MAAM,QAAQ;AACxB,SAAO;SACD;EACN,MAAM,SAAS,GAAG,OAAO;AACzB,SAAO,KAAK,YAAY,aAAa,IAAI,SAAS;AAClD,gBAAc,gBAAgB,cAAc,OAAO;AACnD,SAAO;;;AAIX,eAAsB,eACpB,UACsE;CAEtE,MAAM,QAAwB,EAAE;AAChC,KACE,CAAC,SAAS,SACT,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAC,WAAW,KACvD,SAAS,MAAM,iBAA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,SAAM,KAAK,GAAG,OAAO,QAAQ,SAAS,SAAS,KAAK,CAAC;;;CAKzD,MAAM,eAAe,IAAI,IAAI,MAAM,KAAK,MAAM,EAAE,OAAO,CAAC;AACxD,MAAK,MAAM,UAAU,WAAW,MAAM,CACpC,KAAI,CAAC,aAAa,IAAI,OAAO,CAC3B,YAAW,OAAO,OAAO;AAI7B,QAAO;EAAE;EAAO;EAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PACKAGE_VERSION = "2.26.7
|
|
1
|
+
export declare const PACKAGE_VERSION = "2.26.7";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","names":[],"sources":["../../src/generated/version.ts"],"sourcesContent":["// This file is auto-generated. Do not edit manually.\nexport const PACKAGE_VERSION = '2.26.7
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../../src/generated/version.ts"],"sourcesContent":["// This file is auto-generated. Do not edit manually.\nexport const PACKAGE_VERSION = '2.26.7';\n"],"mappings":";AACA,MAAa,kBAAkB"}
|
package/dist/workflows/upload.js
CHANGED
|
@@ -27,7 +27,13 @@ async function runUploadFilesWorkflow({ files, options }) {
|
|
|
27
27
|
files: files.map((f) => f.source),
|
|
28
28
|
branchData
|
|
29
29
|
});
|
|
30
|
-
const filesWithTranslations = files.filter((f) => f.translations.length > 0)
|
|
30
|
+
const filesWithTranslations = files.filter((f) => f.translations.length > 0).map((f) => ({
|
|
31
|
+
...f,
|
|
32
|
+
source: {
|
|
33
|
+
...f.source,
|
|
34
|
+
branchId: f.source.branchId ?? branchData.currentBranch.id
|
|
35
|
+
}
|
|
36
|
+
}));
|
|
31
37
|
if (filesWithTranslations.length > 0) await uploadTranslationsStep.run({ files: filesWithTranslations });
|
|
32
38
|
logger.success("All files uploaded successfully");
|
|
33
39
|
return { branchData };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.js","names":[],"sources":["../../src/workflows/upload.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { branchResolutionError, withOriginalError } from '../console/index.js';\nimport { logger } from '../console/logger.js';\nimport { logErrorAndExit } from '../console/logging.js';\nimport { Settings } from '../types/index.js';\nimport { api } from '../utils/api.js';\nimport { syncFonts } from './utils/syncFonts.js';\nimport { BranchStep } from './steps/BranchStep.js';\nimport { UploadSourcesStep } from './steps/UploadSourcesStep.js';\nimport { UploadTranslationsStep } from './steps/UploadTranslationsStep.js';\nimport type { FileToUpload } from 'generaltranslation/types';\nimport { BranchData } from '../types/branch.js';\n\n/**\n * Uploads multiple files to the API using a workflow pattern\n * @param files - Array of file objects to upload\n * @param options - The options for the API call\n * @returns The branch data resolved during the workflow\n */\nexport async function runUploadFilesWorkflow({\n files,\n options,\n}: {\n files: {\n source: FileToUpload;\n translations: FileToUpload[];\n }[];\n options: Settings;\n}): Promise<{ branchData: BranchData }> {\n try {\n logger.message(\n chalk.cyan('Files to upload:') +\n '\\n' +\n files\n .map(\n (file) =>\n ` - ${chalk.bold(file.source.fileName)}${file.translations.length > 0 ? ` -> ${file.translations.map((t) => t.locale).join(', ')}` : ''}`\n )\n .join('\\n')\n );\n\n // Sync fonts first (locale-invariant) so they're available when\n // translating formats that need them.\n await syncFonts(options);\n\n // Create workflow steps\n const branchStep = new BranchStep(api, options);\n const uploadStep = new UploadSourcesStep(api, options);\n const uploadTranslationsStep = new UploadTranslationsStep(api, options);\n\n // Step 1: Resolve branch information\n const branchData = await branchStep.run();\n\n if (!branchData) {\n return logErrorAndExit(branchResolutionError);\n }\n\n await uploadStep.run({ files: files.map((f) => f.source), branchData });\n\n // Step 3: Upload translations (if any exist)\n const filesWithTranslations = files
|
|
1
|
+
{"version":3,"file":"upload.js","names":[],"sources":["../../src/workflows/upload.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { branchResolutionError, withOriginalError } from '../console/index.js';\nimport { logger } from '../console/logger.js';\nimport { logErrorAndExit } from '../console/logging.js';\nimport { Settings } from '../types/index.js';\nimport { api } from '../utils/api.js';\nimport { syncFonts } from './utils/syncFonts.js';\nimport { BranchStep } from './steps/BranchStep.js';\nimport { UploadSourcesStep } from './steps/UploadSourcesStep.js';\nimport { UploadTranslationsStep } from './steps/UploadTranslationsStep.js';\nimport type { FileToUpload } from 'generaltranslation/types';\nimport { BranchData } from '../types/branch.js';\n\n/**\n * Uploads multiple files to the API using a workflow pattern\n * @param files - Array of file objects to upload\n * @param options - The options for the API call\n * @returns The branch data resolved during the workflow\n */\nexport async function runUploadFilesWorkflow({\n files,\n options,\n}: {\n files: {\n source: FileToUpload;\n translations: FileToUpload[];\n }[];\n options: Settings;\n}): Promise<{ branchData: BranchData }> {\n try {\n logger.message(\n chalk.cyan('Files to upload:') +\n '\\n' +\n files\n .map(\n (file) =>\n ` - ${chalk.bold(file.source.fileName)}${file.translations.length > 0 ? ` -> ${file.translations.map((t) => t.locale).join(', ')}` : ''}`\n )\n .join('\\n')\n );\n\n // Sync fonts first (locale-invariant) so they're available when\n // translating formats that need them.\n await syncFonts(options);\n\n // Create workflow steps\n const branchStep = new BranchStep(api, options);\n const uploadStep = new UploadSourcesStep(api, options);\n const uploadTranslationsStep = new UploadTranslationsStep(api, options);\n\n // Step 1: Resolve branch information\n const branchData = await branchStep.run();\n\n if (!branchData) {\n return logErrorAndExit(branchResolutionError);\n }\n\n await uploadStep.run({ files: files.map((f) => f.source), branchData });\n\n // Step 3: Upload translations (if any exist)\n const filesWithTranslations = files\n .filter((f) => f.translations.length > 0)\n .map((f) => ({\n ...f,\n source: {\n ...f.source,\n branchId: f.source.branchId ?? branchData.currentBranch.id,\n },\n }));\n if (filesWithTranslations.length > 0) {\n await uploadTranslationsStep.run({\n files: filesWithTranslations,\n });\n }\n\n logger.success('All files uploaded successfully');\n return { branchData };\n } catch (error) {\n return logErrorAndExit(\n withOriginalError(\n 'Files could not be uploaded. Check the files, branch configuration, and API credentials, then try again.',\n error\n )\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,eAAsB,uBAAuB,EAC3C,OACA,WAOsC;AACtC,KAAI;AACF,SAAO,QACL,MAAM,KAAK,mBAAmB,GAC5B,OACA,MACG,KACE,SACC,OAAO,MAAM,KAAK,KAAK,OAAO,SAAS,GAAG,KAAK,aAAa,SAAS,IAAI,OAAO,KAAK,aAAa,KAAK,MAAM,EAAE,OAAO,CAAC,KAAK,KAAK,KAAK,KACzI,CACA,KAAK,KAAK,CAChB;AAID,QAAM,UAAU,QAAQ;EAGxB,MAAM,aAAa,IAAI,WAAW,KAAK,QAAQ;EAC/C,MAAM,aAAa,IAAI,kBAAkB,KAAK,QAAQ;EACtD,MAAM,yBAAyB,IAAI,uBAAuB,KAAK,QAAQ;EAGvE,MAAM,aAAa,MAAM,WAAW,KAAK;AAEzC,MAAI,CAAC,WACH,QAAO,gBAAgB,sBAAsB;AAG/C,QAAM,WAAW,IAAI;GAAE,OAAO,MAAM,KAAK,MAAM,EAAE,OAAO;GAAE;GAAY,CAAC;EAGvE,MAAM,wBAAwB,MAC3B,QAAQ,MAAM,EAAE,aAAa,SAAS,EAAE,CACxC,KAAK,OAAO;GACX,GAAG;GACH,QAAQ;IACN,GAAG,EAAE;IACL,UAAU,EAAE,OAAO,YAAY,WAAW,cAAc;IACzD;GACF,EAAE;AACL,MAAI,sBAAsB,SAAS,EACjC,OAAM,uBAAuB,IAAI,EAC/B,OAAO,uBACR,CAAC;AAGJ,SAAO,QAAQ,kCAAkC;AACjD,SAAO,EAAE,YAAY;UACd,OAAO;AACd,SAAO,gBACL,kBACE,4GACA,MACD,CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gt",
|
|
3
|
-
"version": "2.26.7
|
|
3
|
+
"version": "2.26.7",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"bin": "bin/main.js",
|
|
6
6
|
"files": [
|
|
@@ -115,13 +115,13 @@
|
|
|
115
115
|
"unified": "^11.0.5",
|
|
116
116
|
"unist-util-visit": "^5.0.0",
|
|
117
117
|
"yaml": "^2.8.0",
|
|
118
|
-
"@generaltranslation/format": "0.1.
|
|
119
|
-
"@generaltranslation/icu": "0.1.
|
|
120
|
-
"@generaltranslation/python-extractor": "0.2.
|
|
121
|
-
"@generaltranslation/supported-locales": "2.1.
|
|
122
|
-
"@generaltranslation/vue-extractor": "0.1.
|
|
123
|
-
"generaltranslation": "9.5.
|
|
124
|
-
"gt-remark": "1.0.
|
|
118
|
+
"@generaltranslation/format": "0.1.9",
|
|
119
|
+
"@generaltranslation/icu": "0.1.2",
|
|
120
|
+
"@generaltranslation/python-extractor": "0.2.62",
|
|
121
|
+
"@generaltranslation/supported-locales": "2.1.43",
|
|
122
|
+
"@generaltranslation/vue-extractor": "0.1.21",
|
|
123
|
+
"generaltranslation": "9.5.7",
|
|
124
|
+
"gt-remark": "1.0.12"
|
|
125
125
|
},
|
|
126
126
|
"devDependencies": {
|
|
127
127
|
"@types/babel__generator": "^7.27.0",
|