@inlang/sdk 2.4.8 → 2.4.10

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.
Files changed (56) hide show
  1. package/dist/database/jsonPlugin.d.ts +11 -0
  2. package/dist/database/jsonPlugin.d.ts.map +1 -0
  3. package/dist/database/jsonPlugin.js +197 -0
  4. package/dist/database/jsonPlugin.js.map +1 -0
  5. package/dist/import-export/upsertBundleNestedMatchByProperties.d.ts.map +1 -1
  6. package/dist/migrations/v2/createMessageV1.d.ts.map +1 -1
  7. package/dist/project/fs-sync.playground.test.d.ts +2 -0
  8. package/dist/project/fs-sync.playground.test.d.ts.map +1 -0
  9. package/dist/project/fs-sync.playground.test.js +535 -0
  10. package/dist/project/fs-sync.playground.test.js.map +1 -0
  11. package/dist/project/loadProjectFromDirectory.d.ts.map +1 -1
  12. package/dist/project/loadProjectFromDirectory.js +7 -3
  13. package/dist/project/loadProjectFromDirectory.js.map +1 -1
  14. package/dist/project/saveProjectToDirectory.d.ts.map +1 -1
  15. package/dist/project/saveProjectToDirectory.js +25 -18
  16. package/dist/project/saveProjectToDirectory.js.map +1 -1
  17. package/dist/query-utilities/insertBundleNested.d.ts.map +1 -1
  18. package/dist/query-utilities/selectBundleNested.d.ts.map +1 -1
  19. package/dist/query-utilities/updateBundleNested.d.ts.map +1 -1
  20. package/dist/query-utilities/upsertBundleNested.d.ts.map +1 -1
  21. package/dist/schema-definitions/bundle.d.ts +22 -0
  22. package/dist/schema-definitions/bundle.d.ts.map +1 -0
  23. package/dist/schema-definitions/bundle.js +18 -0
  24. package/dist/schema-definitions/bundle.js.map +1 -0
  25. package/dist/schema-definitions/bundle.test.d.ts +2 -0
  26. package/dist/schema-definitions/bundle.test.d.ts.map +1 -0
  27. package/dist/schema-definitions/bundle.test.js +23 -0
  28. package/dist/schema-definitions/bundle.test.js.map +1 -0
  29. package/dist/schema-definitions/index.d.ts +4 -0
  30. package/dist/schema-definitions/index.d.ts.map +1 -0
  31. package/dist/schema-definitions/index.js +4 -0
  32. package/dist/schema-definitions/index.js.map +1 -0
  33. package/dist/schema-definitions/message.d.ts +35 -0
  34. package/dist/schema-definitions/message.d.ts.map +1 -0
  35. package/dist/schema-definitions/message.js +26 -0
  36. package/dist/schema-definitions/message.js.map +1 -0
  37. package/dist/schema-definitions/message.test.d.ts +2 -0
  38. package/dist/schema-definitions/message.test.d.ts.map +1 -0
  39. package/dist/schema-definitions/message.test.js +45 -0
  40. package/dist/schema-definitions/message.test.js.map +1 -0
  41. package/dist/schema-definitions/variant.d.ts +35 -0
  42. package/dist/schema-definitions/variant.d.ts.map +1 -0
  43. package/dist/schema-definitions/variant.js +26 -0
  44. package/dist/schema-definitions/variant.js.map +1 -0
  45. package/dist/schema-definitions/variant.test.d.ts +2 -0
  46. package/dist/schema-definitions/variant.test.d.ts.map +1 -0
  47. package/dist/schema-definitions/variant.test.js +67 -0
  48. package/dist/schema-definitions/variant.test.js.map +1 -0
  49. package/dist/services/env-variables/index.d.ts +2 -2
  50. package/dist/services/env-variables/index.js +3 -3
  51. package/dist/services/env-variables/index.js.map +1 -1
  52. package/dist/services/telemetry/capture.d.ts.map +1 -1
  53. package/dist/utilities/detectJsonFormatting.d.ts.map +1 -1
  54. package/package.json +4 -4
  55. package/src/project/loadProjectFromDirectory.ts +10 -5
  56. package/src/project/saveProjectToDirectory.ts +33 -24
@@ -0,0 +1,35 @@
1
+ export declare const InlangVariantSchema: {
2
+ readonly "x-lix-key": "inlang_variant";
3
+ readonly "x-lix-version": "1.0";
4
+ readonly "x-lix-primary-key": ["/id"];
5
+ readonly "x-lix-foreign-keys": [{
6
+ readonly properties: ["/messageId"];
7
+ readonly references: {
8
+ readonly schemaKey: "inlang_message";
9
+ readonly properties: ["/id"];
10
+ };
11
+ }];
12
+ readonly "x-lix-override-lixcols": {
13
+ readonly lixcol_file_id: "\"inlang\"";
14
+ readonly lixcol_plugin_key: "\"inlang_sdk\"";
15
+ };
16
+ readonly type: "object";
17
+ readonly properties: {
18
+ readonly id: {
19
+ readonly type: "string";
20
+ readonly "x-lix-default": "lix_uuid_v7()";
21
+ };
22
+ readonly messageId: {
23
+ readonly type: "string";
24
+ };
25
+ readonly matches: {
26
+ readonly default: readonly [];
27
+ };
28
+ readonly pattern: {
29
+ readonly default: readonly [];
30
+ };
31
+ };
32
+ readonly required: readonly ["id", "messageId", "matches", "pattern"];
33
+ readonly additionalProperties: false;
34
+ };
35
+ //# sourceMappingURL=variant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variant.d.ts","sourceRoot":"/","sources":["schema-definitions/variant.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuBQ,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { JSONTypeSchema } from "@lix-js/sdk";
2
+ export const InlangVariantSchema = {
3
+ "x-lix-key": "inlang_variant",
4
+ "x-lix-version": "1.0",
5
+ "x-lix-primary-key": ["/id"],
6
+ "x-lix-foreign-keys": [
7
+ {
8
+ properties: ["/messageId"],
9
+ references: { schemaKey: "inlang_message", properties: ["/id"] },
10
+ },
11
+ ],
12
+ "x-lix-override-lixcols": {
13
+ lixcol_file_id: '"inlang"',
14
+ lixcol_plugin_key: '"inlang_sdk"',
15
+ },
16
+ type: "object",
17
+ properties: {
18
+ id: { type: "string", "x-lix-default": "lix_uuid_v7()" },
19
+ messageId: { type: "string" },
20
+ matches: { ...JSONTypeSchema, default: [] },
21
+ pattern: { ...JSONTypeSchema, default: [] },
22
+ },
23
+ required: ["id", "messageId", "matches", "pattern"],
24
+ additionalProperties: false,
25
+ };
26
+ //# sourceMappingURL=variant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variant.js","sourceRoot":"/","sources":["schema-definitions/variant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA4B,MAAM,aAAa,CAAC;AAEvE,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAClC,WAAW,EAAE,gBAAgB;IAC7B,eAAe,EAAE,KAAK;IACtB,mBAAmB,EAAE,CAAC,KAAK,CAAC;IAC5B,oBAAoB,EAAE;QACrB;YACC,UAAU,EAAE,CAAC,YAAY,CAAC;YAC1B,UAAU,EAAE,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAE,CAAC,KAAK,CAAC,EAAE;SAChE;KACD;IACD,wBAAwB,EAAE;QACzB,cAAc,EAAE,UAAU;QAC1B,iBAAiB,EAAE,cAAc;KACjC;IACD,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACX,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,eAAe,EAAE;QACxD,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC7B,OAAO,EAAE,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,EAAE,EAAE;QAC3C,OAAO,EAAE,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,EAAE,EAAE;KAC3C;IACD,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,CAAC;IACnD,oBAAoB,EAAE,KAAK;CACY,CAAC","sourcesContent":["import { JSONTypeSchema, type LixSchemaDefinition } from \"@lix-js/sdk\";\n\nexport const InlangVariantSchema = {\n\t\"x-lix-key\": \"inlang_variant\",\n\t\"x-lix-version\": \"1.0\",\n\t\"x-lix-primary-key\": [\"/id\"],\n\t\"x-lix-foreign-keys\": [\n\t\t{\n\t\t\tproperties: [\"/messageId\"],\n\t\t\treferences: { schemaKey: \"inlang_message\", properties: [\"/id\"] },\n\t\t},\n\t],\n\t\"x-lix-override-lixcols\": {\n\t\tlixcol_file_id: '\"inlang\"',\n\t\tlixcol_plugin_key: '\"inlang_sdk\"',\n\t},\n\ttype: \"object\",\n\tproperties: {\n\t\tid: { type: \"string\", \"x-lix-default\": \"lix_uuid_v7()\" },\n\t\tmessageId: { type: \"string\" },\n\t\tmatches: { ...JSONTypeSchema, default: [] },\n\t\tpattern: { ...JSONTypeSchema, default: [] },\n\t},\n\trequired: [\"id\", \"messageId\", \"matches\", \"pattern\"],\n\tadditionalProperties: false,\n} as const satisfies LixSchemaDefinition;\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=variant.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variant.test.d.ts","sourceRoot":"/","sources":["schema-definitions/variant.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,67 @@
1
+ import { expect, test } from "vitest";
2
+ import { uuidV7 } from "@lix-js/sdk";
3
+ import { newProject } from "../project/newProject.js";
4
+ import { loadProjectInMemory } from "../project/loadProjectInMemory.js";
5
+ test("variant schema persists matches and pattern JSON", async () => {
6
+ const project = await loadProjectInMemory({ blob: await newProject() });
7
+ const bundleId = "bundle-for-variant";
8
+ await project.db
9
+ .insertInto("bundle")
10
+ .values({ id: bundleId, declarations: [] })
11
+ .execute();
12
+ const messageId = await uuidV7({ lix: project.lix });
13
+ await project.db
14
+ .insertInto("message")
15
+ .values({
16
+ id: messageId,
17
+ bundleId,
18
+ locale: "en",
19
+ selectors: [],
20
+ })
21
+ .execute();
22
+ const variantId = await uuidV7({ lix: project.lix });
23
+ const matches = [
24
+ { type: "literal-match", key: "platform", value: "web" },
25
+ ];
26
+ const pattern = [{ type: "text", value: "Hello web" }];
27
+ await expect(project.db
28
+ .insertInto("variant")
29
+ .values({
30
+ id: variantId,
31
+ messageId,
32
+ matches,
33
+ pattern,
34
+ })
35
+ .execute()).resolves.not.toThrow();
36
+ const stored = await project.db
37
+ .selectFrom("variant")
38
+ .selectAll()
39
+ .where("id", "=", variantId)
40
+ .executeTakeFirstOrThrow();
41
+ expect(stored.messageId).toBe(messageId);
42
+ expect(stored.matches).toEqual(matches);
43
+ expect(stored.pattern).toEqual(pattern);
44
+ await project.close();
45
+ });
46
+ test("variant schema enforces message foreign key", async () => {
47
+ const project = await loadProjectInMemory({ blob: await newProject() });
48
+ let wasRejected = false;
49
+ try {
50
+ await project.db
51
+ .insertInto("variant")
52
+ .values({
53
+ id: await uuidV7({ lix: project.lix }),
54
+ messageId: "missing-message",
55
+ matches: [],
56
+ pattern: [],
57
+ })
58
+ .execute();
59
+ }
60
+ catch (error) {
61
+ wasRejected = true;
62
+ expect(error?.resultCode ?? error.message).toBeDefined();
63
+ }
64
+ expect(wasRejected).toBe(true);
65
+ await project.close();
66
+ });
67
+ //# sourceMappingURL=variant.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variant.test.js","sourceRoot":"/","sources":["schema-definitions/variant.test.ts"],"names":[],"mappings":"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","sourcesContent":["import { expect, test } from \"vitest\";\nimport { uuidV7 } from \"@lix-js/sdk\";\nimport { newProject } from \"../project/newProject.js\";\nimport { loadProjectInMemory } from \"../project/loadProjectInMemory.js\";\n\ntest(\"variant schema persists matches and pattern JSON\", async () => {\n\tconst project = await loadProjectInMemory({ blob: await newProject() });\n\tconst bundleId = \"bundle-for-variant\";\n\tawait project.db\n\t\t.insertInto(\"bundle\")\n\t\t.values({ id: bundleId, declarations: [] })\n\t\t.execute();\n\n\tconst messageId = await uuidV7({ lix: project.lix });\n\tawait project.db\n\t\t.insertInto(\"message\")\n\t\t.values({\n\t\t\tid: messageId,\n\t\t\tbundleId,\n\t\t\tlocale: \"en\",\n\t\t\tselectors: [],\n\t\t})\n\t\t.execute();\n\n\tconst variantId = await uuidV7({ lix: project.lix });\n\tconst matches = [\n\t\t{ type: \"literal-match\" as const, key: \"platform\", value: \"web\" },\n\t];\n\tconst pattern = [{ type: \"text\" as const, value: \"Hello web\" }];\n\n\tawait expect(\n\t\tproject.db\n\t\t\t.insertInto(\"variant\")\n\t\t\t.values({\n\t\t\t\tid: variantId,\n\t\t\t\tmessageId,\n\t\t\t\tmatches,\n\t\t\t\tpattern,\n\t\t\t})\n\t\t\t.execute()\n\t).resolves.not.toThrow();\n\n\tconst stored = await project.db\n\t\t.selectFrom(\"variant\")\n\t\t.selectAll()\n\t\t.where(\"id\", \"=\", variantId)\n\t\t.executeTakeFirstOrThrow();\n\n\texpect(stored.messageId).toBe(messageId);\n\texpect(stored.matches).toEqual(matches);\n\texpect(stored.pattern).toEqual(pattern);\n\n\tawait project.close();\n});\n\ntest(\"variant schema enforces message foreign key\", async () => {\n\tconst project = await loadProjectInMemory({ blob: await newProject() });\n\n\tlet wasRejected = false;\n\ttry {\n\t\tawait project.db\n\t\t\t.insertInto(\"variant\")\n\t\t\t.values({\n\t\t\t\tid: await uuidV7({ lix: project.lix }),\n\t\t\t\tmessageId: \"missing-message\",\n\t\t\t\tmatches: [],\n\t\t\t\tpattern: [],\n\t\t\t})\n\t\t\t.execute();\n\t} catch (error) {\n\t\twasRejected = true;\n\t\texpect(\n\t\t\t(error as any)?.resultCode ?? (error as Error).message\n\t\t).toBeDefined();\n\t}\n\texpect(wasRejected).toBe(true);\n\n\tawait project.close();\n});\n"]}
@@ -1,6 +1,6 @@
1
1
  export declare const ENV_VARIABLES: {
2
- PUBLIC_POSTHOG_TOKEN: string;
3
- PUBLIC_INLANG_SDK_SENTRY_DSN: string;
2
+ PUBLIC_POSTHOG_TOKEN: undefined;
3
+ PUBLIC_INLANG_SDK_SENTRY_DSN: undefined;
4
4
  SDK_VERSION: string;
5
5
  };
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,6 @@
1
1
  export const ENV_VARIABLES = {
2
- PUBLIC_POSTHOG_TOKEN: "phc_m5yJZCxjOGxF8CJvP5sQ3H0d76xpnLrsmiZHduT4jDz",
3
- PUBLIC_INLANG_SDK_SENTRY_DSN: "https://c3d92d5d011122e525e9f9b368e0905d@o4504345873285120.ingest.us.sentry.io/4507903389335553",
4
- SDK_VERSION: "2.4.8",
2
+ PUBLIC_POSTHOG_TOKEN: undefined,
3
+ PUBLIC_INLANG_SDK_SENTRY_DSN: undefined,
4
+ SDK_VERSION: "2.4.10",
5
5
  };
6
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["services/env-variables/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,oBAAoB,EAAE,iDAAiD;IACxE,4BAA4B,EAAE,iGAAiG;IAC/H,WAAW,EAAE,OAAO;CACpB,CAAA","sourcesContent":["\nexport const ENV_VARIABLES = {\n PUBLIC_POSTHOG_TOKEN: \"phc_m5yJZCxjOGxF8CJvP5sQ3H0d76xpnLrsmiZHduT4jDz\",\n\tPUBLIC_INLANG_SDK_SENTRY_DSN: \"https://c3d92d5d011122e525e9f9b368e0905d@o4504345873285120.ingest.us.sentry.io/4507903389335553\",\n\tSDK_VERSION: \"2.4.8\",\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["services/env-variables/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,oBAAoB,EAAE,SAAS;IAChC,4BAA4B,EAAE,SAAS;IACvC,WAAW,EAAE,QAAQ;CACrB,CAAA","sourcesContent":["\nexport const ENV_VARIABLES = {\n PUBLIC_POSTHOG_TOKEN: undefined,\n\tPUBLIC_INLANG_SDK_SENTRY_DSN: undefined,\n\tSDK_VERSION: \"2.4.10\",\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"capture.d.ts","sourceRoot":"/","sources":["services/telemetry/capture.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGrE;;;;;GAKG;AACH,KAAK,cAAc,GAAG,oBAAoB,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,OAAO,UACZ,cAAc,QACf;IACL,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,QAAQ,EAAE,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;CAC7C,kBA8BD,CAAC"}
1
+ {"version":3,"file":"capture.d.ts","sourceRoot":"/","sources":["services/telemetry/capture.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGrE;;;;;GAKG;AACH,KAAK,cAAc,GAAG,oBAAoB,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,OAAO,GACnB,OAAO,cAAc,EACrB,MAAM;IACL,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,QAAQ,EAAE,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;CAC7C,kBA8BD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"detectJsonFormatting.d.ts","sourceRoot":"/","sources":["utilities/detectJsonFormatting.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,SAC1B,MAAM,KACV,CAAC,CACH,KAAK,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAC3C,QAAQ,CAAC,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAE3C,MAAM,CAOV,CAAC"}
1
+ {"version":3,"file":"detectJsonFormatting.d.ts","sourceRoot":"/","sources":["utilities/detectJsonFormatting.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,GAChC,MAAM,MAAM,KACV,CAAC,CACH,KAAK,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAC3C,QAAQ,CAAC,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAE3C,MAAM,CAOV,CAAC"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@inlang/sdk",
3
- "version": "2.4.8",
3
+ "version": "2.4.10",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
- "homepage": "https://inlang.com/documentation/sdk",
9
+ "homepage": "https://github.com/opral/inlang-sdk",
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "https://github.com/opral/inlang-sdk"
@@ -30,8 +30,8 @@
30
30
  "@sinclair/typebox": "^0.31.17",
31
31
  "kysely": "^0.27.4",
32
32
  "uuid": "^10.0.0",
33
- "sqlite-wasm-kysely": "0.3.0",
34
- "@lix-js/sdk": "0.4.7"
33
+ "@lix-js/sdk": "0.4.7",
34
+ "sqlite-wasm-kysely": "0.3.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@eslint/js": "^9.12.0",
@@ -679,12 +679,17 @@ async function importLocalPlugins(args: {
679
679
  if (args.preprocessPluginBeforeImport) {
680
680
  moduleAsText = await args.preprocessPluginBeforeImport(moduleAsText);
681
681
  }
682
- const moduleWithMimeType =
683
- "data:application/javascript," + encodeURIComponent(moduleAsText);
684
- const { default: plugin } = await import(
685
- /* @vite-ignore */ moduleWithMimeType
686
- );
682
+
683
+ // In bun we need to do dynamic imports differently
684
+ const pluginAsUrl = process.versions.bun
685
+ ? URL.createObjectURL(
686
+ new Blob([moduleAsText], { type: "text/javascript" })
687
+ )
688
+ : "data:application/javascript," + encodeURIComponent(moduleAsText);
689
+
690
+ const { default: plugin } = await import(/* @vite-ignore */ pluginAsUrl);
687
691
  locallyImportedPlugins.push(plugin);
692
+ if (process.versions.bun) URL.revokeObjectURL(pluginAsUrl);
688
693
  } catch (e) {
689
694
  errors.push(new PluginImportError({ plugin: module, cause: e as Error }));
690
695
  continue;
@@ -69,33 +69,42 @@ export async function saveProjectToDirectory(args: {
69
69
  });
70
70
  for (const file of files) {
71
71
  const pathPattern = settings[plugin.key]?.pathPattern;
72
- const p = pathPattern
73
- ? absolutePathFromProject(
74
- args.path,
75
- pathPattern.replace(/\{(languageTag|locale)\}/g, file.locale)
76
- )
77
- : absolutePathFromProject(args.path, file.name);
78
- const dirname = path.dirname(p);
79
- if ((await args.fs.stat(dirname)).isDirectory() === false) {
80
- await args.fs.mkdir(dirname, { recursive: true });
81
- }
82
- if (p.endsWith(".json")) {
83
- try {
84
- const existing = await args.fs.readFile(p, "utf-8");
85
- const stringify = detectJsonFormatting(existing);
86
- await args.fs.writeFile(
87
- p,
88
- new TextEncoder().encode(
89
- stringify(JSON.parse(new TextDecoder().decode(file.content)))
72
+
73
+ // We need to check if pathPattern is a string or an array of strings
74
+ // and handle both cases.
75
+ const formattedPathPatterns = Array.isArray(pathPattern)
76
+ ? pathPattern
77
+ : [pathPattern];
78
+
79
+ for (const pathPattern of formattedPathPatterns) {
80
+ const p = pathPattern
81
+ ? absolutePathFromProject(
82
+ args.path,
83
+ pathPattern.replace(/\{(languageTag|locale)\}/g, file.locale)
90
84
  )
91
- );
92
- } catch {
93
- // write the file to disk (json doesn't exist yet)
94
- // yeah ugly duplication of write file but it works.
85
+ : absolutePathFromProject(args.path, file.name);
86
+ const dirname = path.dirname(p);
87
+ if ((await args.fs.stat(dirname)).isDirectory() === false) {
88
+ await args.fs.mkdir(dirname, { recursive: true });
89
+ }
90
+ if (p.endsWith(".json")) {
91
+ try {
92
+ const existing = await args.fs.readFile(p, "utf-8");
93
+ const stringify = detectJsonFormatting(existing);
94
+ await args.fs.writeFile(
95
+ p,
96
+ new TextEncoder().encode(
97
+ stringify(JSON.parse(new TextDecoder().decode(file.content)))
98
+ )
99
+ );
100
+ } catch {
101
+ // write the file to disk (json doesn't exist yet)
102
+ // yeah ugly duplication of write file but it works.
103
+ await args.fs.writeFile(p, new Uint8Array(file.content));
104
+ }
105
+ } else {
95
106
  await args.fs.writeFile(p, new Uint8Array(file.content));
96
107
  }
97
- } else {
98
- await args.fs.writeFile(p, new Uint8Array(file.content));
99
108
  }
100
109
  }
101
110
  }