@inlang/sdk 2.4.8 → 2.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/import-export/upsertBundleNestedMatchByProperties.d.ts.map +1 -1
- package/dist/migrations/v2/createMessageV1.d.ts.map +1 -1
- package/dist/project/saveProjectToDirectory.d.ts.map +1 -1
- package/dist/project/saveProjectToDirectory.js +25 -18
- package/dist/project/saveProjectToDirectory.js.map +1 -1
- package/dist/query-utilities/insertBundleNested.d.ts.map +1 -1
- package/dist/query-utilities/selectBundleNested.d.ts.map +1 -1
- package/dist/query-utilities/updateBundleNested.d.ts.map +1 -1
- package/dist/query-utilities/upsertBundleNested.d.ts.map +1 -1
- package/dist/services/env-variables/index.js +1 -1
- package/dist/services/env-variables/index.js.map +1 -1
- package/dist/services/telemetry/capture.d.ts.map +1 -1
- package/dist/utilities/detectJsonFormatting.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/project/saveProjectToDirectory.ts +33 -24
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upsertBundleNestedMatchByProperties.d.ts","sourceRoot":"/","sources":["import-export/upsertBundleNestedMatchByProperties.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EACX,oBAAoB,EACpB,eAAe,EACf,MAAM,uBAAuB,CAAC;AAE/B,eAAO,MAAM,mCAAmC,
|
|
1
|
+
{"version":3,"file":"upsertBundleNestedMatchByProperties.d.ts","sourceRoot":"/","sources":["import-export/upsertBundleNestedMatchByProperties.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EACX,oBAAoB,EACpB,eAAe,EACf,MAAM,uBAAuB,CAAC;AAE/B,eAAO,MAAM,mCAAmC,GAC/C,IAAI,MAAM,CAAC,oBAAoB,CAAC,EAChC,QAAQ,eAAe,KACrB,OAAO,CAAC,IAAI,CAgEd,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMessageV1.d.ts","sourceRoot":"/","sources":["migrations/v2/createMessageV1.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEX,SAAS,EACT,MAAM,8CAA8C,CAAC;AAEtD;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"createMessageV1.d.ts","sourceRoot":"/","sources":["migrations/v2/createMessageV1.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEX,SAAS,EACT,MAAM,8CAA8C,CAAC;AAEtD;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,GAC3B,IAAI,MAAM,EACV,UAAU,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC;;;;;;;;;;;;;;;CAmBtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"saveProjectToDirectory.d.ts","sourceRoot":"/","sources":["project/saveProjectToDirectory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAU9C,wBAAsB,sBAAsB,CAAC,IAAI,EAAE;IAClD,EAAE,EAAE,OAAO,EAAE,CAAC;IACd,OAAO,EAAE,aAAa,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACb,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"saveProjectToDirectory.d.ts","sourceRoot":"/","sources":["project/saveProjectToDirectory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAU9C,wBAAsB,sBAAsB,CAAC,IAAI,EAAE;IAClD,EAAE,EAAE,OAAO,EAAE,CAAC;IACd,OAAO,EAAE,aAAa,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACb,GAAG,OAAO,CAAC,IAAI,CAAC,CA4GhB"}
|
|
@@ -52,28 +52,35 @@ export async function saveProjectToDirectory(args) {
|
|
|
52
52
|
});
|
|
53
53
|
for (const file of files) {
|
|
54
54
|
const pathPattern = settings[plugin.key]?.pathPattern;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
await args.fs.
|
|
55
|
+
// We need to check if pathPattern is a string or an array of strings
|
|
56
|
+
// and handle both cases.
|
|
57
|
+
const formattedPathPatterns = Array.isArray(pathPattern)
|
|
58
|
+
? pathPattern
|
|
59
|
+
: [pathPattern];
|
|
60
|
+
for (const pathPattern of formattedPathPatterns) {
|
|
61
|
+
const p = pathPattern
|
|
62
|
+
? absolutePathFromProject(args.path, pathPattern.replace(/\{(languageTag|locale)\}/g, file.locale))
|
|
63
|
+
: absolutePathFromProject(args.path, file.name);
|
|
64
|
+
const dirname = path.dirname(p);
|
|
65
|
+
if ((await args.fs.stat(dirname)).isDirectory() === false) {
|
|
66
|
+
await args.fs.mkdir(dirname, { recursive: true });
|
|
67
|
+
}
|
|
68
|
+
if (p.endsWith(".json")) {
|
|
69
|
+
try {
|
|
70
|
+
const existing = await args.fs.readFile(p, "utf-8");
|
|
71
|
+
const stringify = detectJsonFormatting(existing);
|
|
72
|
+
await args.fs.writeFile(p, new TextEncoder().encode(stringify(JSON.parse(new TextDecoder().decode(file.content)))));
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// write the file to disk (json doesn't exist yet)
|
|
76
|
+
// yeah ugly duplication of write file but it works.
|
|
77
|
+
await args.fs.writeFile(p, new Uint8Array(file.content));
|
|
78
|
+
}
|
|
67
79
|
}
|
|
68
|
-
|
|
69
|
-
// write the file to disk (json doesn't exist yet)
|
|
70
|
-
// yeah ugly duplication of write file but it works.
|
|
80
|
+
else {
|
|
71
81
|
await args.fs.writeFile(p, new Uint8Array(file.content));
|
|
72
82
|
}
|
|
73
83
|
}
|
|
74
|
-
else {
|
|
75
|
-
await args.fs.writeFile(p, new Uint8Array(file.content));
|
|
76
|
-
}
|
|
77
84
|
}
|
|
78
85
|
}
|
|
79
86
|
// old legacy remove with v3
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"saveProjectToDirectory.js","sourceRoot":"/","sources":["project/saveProjectToDirectory.ts"],"names":[],"mappings":"AAEA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,8CAA8C,CAAC;AAC3E,OAAO,EACN,uBAAuB,EACvB,iBAAiB,GACjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAE9E,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,IAI5C;IACA,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,KAAK,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACnD,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;SACrC,UAAU,CAAC,MAAM,CAAC;SAClB,SAAS,EAAE;SACX,OAAO,EAAE,CAAC;IAEZ,IAAI,YAAY,GAAG,KAAK,CAAC;IAEzB,mCAAmC;IACnC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YACrC,SAAS;QACV,CAAC;aAAM,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;YAC7C,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,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["import type fs from \"node:fs/promises\";\nimport type { InlangProject } from \"./api.js\";\nimport path from \"node:path\";\nimport { toMessageV1 } from \"../json-schema/old-v1-message/toMessageV1.js\";\nimport {\n\tabsolutePathFromProject,\n\twithAbsolutePaths,\n} from \"./loadProjectFromDirectory.js\";\nimport { detectJsonFormatting } from \"../utilities/detectJsonFormatting.js\";\nimport { selectBundleNested } from \"../query-utilities/selectBundleNested.js\";\n\nexport async function saveProjectToDirectory(args: {\n\tfs: typeof fs;\n\tproject: InlangProject;\n\tpath: string;\n}): Promise<void> {\n\tif (args.path.endsWith(\".inlang\") === false) {\n\t\tthrow new Error(\"The path must end with .inlang\");\n\t}\n\tconst files = await args.project.lix.db\n\t\t.selectFrom(\"file\")\n\t\t.selectAll()\n\t\t.execute();\n\n\tlet hasGitignore = false;\n\n\t// write all files to the directory\n\tfor (const file of files) {\n\t\tif (file.path.endsWith(\"db.sqlite\")) {\n\t\t\tcontinue;\n\t\t} else if (file.path.endsWith(\".gitignore\")) {\n\t\t\thasGitignore = true;\n\t\t}\n\t\tconst p = path.join(args.path, file.path);\n\t\tawait args.fs.mkdir(path.dirname(p), { recursive: true });\n\t\tawait args.fs.writeFile(p, new Uint8Array(file.data));\n\t}\n\n\tif (hasGitignore === false) {\n\t\tawait args.fs.writeFile(\n\t\t\tpath.join(args.path, \".gitignore\"),\n\t\t\tnew TextEncoder().encode(\"cache\")\n\t\t);\n\t}\n\n\t// run exporters\n\tconst plugins = await args.project.plugins.get();\n\tconst settings = await args.project.settings.get();\n\n\tfor (const plugin of plugins) {\n\t\tif (plugin.exportFiles) {\n\t\t\tconst bundles = await args.project.db\n\t\t\t\t.selectFrom(\"bundle\")\n\t\t\t\t.selectAll()\n\t\t\t\t.execute();\n\t\t\tconst messages = await args.project.db\n\t\t\t\t.selectFrom(\"message\")\n\t\t\t\t.selectAll()\n\t\t\t\t.execute();\n\t\t\tconst variants = await args.project.db\n\t\t\t\t.selectFrom(\"variant\")\n\t\t\t\t.selectAll()\n\t\t\t\t.execute();\n\t\t\tconst files = await plugin.exportFiles({\n\t\t\t\tbundles,\n\t\t\t\tmessages,\n\t\t\t\tvariants,\n\t\t\t\tsettings,\n\t\t\t});\n\t\t\tfor (const file of files) {\n\t\t\t\tconst pathPattern = settings[plugin.key]?.pathPattern;\n\n\t\t\t\t// We need to check if pathPattern is a string or an array of strings\n\t\t\t\t// and handle both cases.\n\t\t\t\tconst formattedPathPatterns = Array.isArray(pathPattern)\n\t\t\t\t\t? pathPattern\n\t\t\t\t\t: [pathPattern];\n\n\t\t\t\tfor (const pathPattern of formattedPathPatterns) {\n\t\t\t\t\tconst p = pathPattern\n\t\t\t\t\t\t? absolutePathFromProject(\n\t\t\t\t\t\t\t\targs.path,\n\t\t\t\t\t\t\t\tpathPattern.replace(/\\{(languageTag|locale)\\}/g, file.locale)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: absolutePathFromProject(args.path, file.name);\n\t\t\t\t\tconst dirname = path.dirname(p);\n\t\t\t\t\tif ((await args.fs.stat(dirname)).isDirectory() === false) {\n\t\t\t\t\t\tawait args.fs.mkdir(dirname, { recursive: true });\n\t\t\t\t\t}\n\t\t\t\t\tif (p.endsWith(\".json\")) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst existing = await args.fs.readFile(p, \"utf-8\");\n\t\t\t\t\t\t\tconst stringify = detectJsonFormatting(existing);\n\t\t\t\t\t\t\tawait args.fs.writeFile(\n\t\t\t\t\t\t\t\tp,\n\t\t\t\t\t\t\t\tnew TextEncoder().encode(\n\t\t\t\t\t\t\t\t\tstringify(JSON.parse(new TextDecoder().decode(file.content)))\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t// write the file to disk (json doesn't exist yet)\n\t\t\t\t\t\t\t// yeah ugly duplication of write file but it works.\n\t\t\t\t\t\t\tawait args.fs.writeFile(p, new Uint8Array(file.content));\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tawait args.fs.writeFile(p, new Uint8Array(file.content));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// old legacy remove with v3\n\t\telse if (plugin.saveMessages) {\n\t\t\t// in-efficient re-qeuery but it's a legacy function that will be removed.\n\t\t\t// the effort of adjusting the code to not re-query is not worth it.\n\t\t\tconst bundlesNested = await selectBundleNested(args.project.db).execute();\n\t\t\tawait plugin.saveMessages({\n\t\t\t\tmessages: bundlesNested.map((b) => toMessageV1(b)),\n\t\t\t\t// @ts-expect-error - legacy\n\t\t\t\tnodeishFs: withAbsolutePaths(args.fs, args.path),\n\t\t\t\tsettings,\n\t\t\t});\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insertBundleNested.d.ts","sourceRoot":"/","sources":["query-utilities/insertBundleNested.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EACX,oBAAoB,EACpB,eAAe,EACf,MAAM,uBAAuB,CAAC;AAE/B,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"insertBundleNested.d.ts","sourceRoot":"/","sources":["query-utilities/insertBundleNested.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EACX,oBAAoB,EACpB,eAAe,EACf,MAAM,uBAAuB,CAAC;AAE/B,eAAO,MAAM,kBAAkB,GAC9B,IAAI,MAAM,CAAC,oBAAoB,CAAC,EAChC,QAAQ,eAAe,KACrB,OAAO,CAAC,IAAI,CAoCd,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectBundleNested.d.ts","sourceRoot":"/","sources":["query-utilities/selectBundleNested.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAElE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"selectBundleNested.d.ts","sourceRoot":"/","sources":["query-utilities/selectBundleNested.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAElE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB,GAAI,IAAI,MAAM,CAAC,oBAAoB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BlE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateBundleNested.d.ts","sourceRoot":"/","sources":["query-utilities/updateBundleNested.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EACX,kBAAkB,EAClB,oBAAoB,EACpB,MAAM,uBAAuB,CAAC;AAE/B,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"updateBundleNested.d.ts","sourceRoot":"/","sources":["query-utilities/updateBundleNested.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EACX,kBAAkB,EAClB,oBAAoB,EACpB,MAAM,uBAAuB,CAAC;AAE/B,eAAO,MAAM,kBAAkB,GAC9B,IAAI,MAAM,CAAC,oBAAoB,CAAC,EAChC,QAAQ,kBAAkB,GAAG;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE;YAAE,EAAE,EAAE,MAAM,CAAA;SAAE,EAAE,CAAA;KAAE,EAAE,CAAC;CACvD,KACC,OAAO,CAAC,IAAI,CAsBd,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upsertBundleNested.d.ts","sourceRoot":"/","sources":["query-utilities/upsertBundleNested.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EACX,oBAAoB,EACpB,eAAe,EACf,MAAM,uBAAuB,CAAC;AAE/B,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"upsertBundleNested.d.ts","sourceRoot":"/","sources":["query-utilities/upsertBundleNested.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EACX,oBAAoB,EACpB,eAAe,EACf,MAAM,uBAAuB,CAAC;AAE/B,eAAO,MAAM,kBAAkB,GAC9B,IAAI,MAAM,CAAC,oBAAoB,CAAC,EAChC,QAAQ,eAAe,KACrB,OAAO,CAAC,IAAI,CAmDd,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const ENV_VARIABLES = {
|
|
2
2
|
PUBLIC_POSTHOG_TOKEN: "phc_m5yJZCxjOGxF8CJvP5sQ3H0d76xpnLrsmiZHduT4jDz",
|
|
3
3
|
PUBLIC_INLANG_SDK_SENTRY_DSN: "https://c3d92d5d011122e525e9f9b368e0905d@o4504345873285120.ingest.us.sentry.io/4507903389335553",
|
|
4
|
-
SDK_VERSION: "2.4.
|
|
4
|
+
SDK_VERSION: "2.4.9",
|
|
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.
|
|
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.9\",\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,
|
|
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,
|
|
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
|
@@ -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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
}
|