@inlang/sdk 2.0.0 → 2.0.1
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/json-schema/settings.d.ts +8 -10
- package/dist/json-schema/settings.d.ts.map +1 -1
- package/dist/json-schema/settings.js +4 -27
- package/dist/json-schema/settings.js.map +1 -1
- package/dist/json-schema/settings.test.d.ts +2 -0
- package/dist/json-schema/settings.test.d.ts.map +1 -0
- package/dist/json-schema/settings.test.js +26 -0
- package/dist/json-schema/settings.test.js.map +1 -0
- package/dist/plugin/importPlugins.test.js +2 -3
- package/dist/plugin/importPlugins.test.js.map +1 -1
- package/dist/project/loadProjectFromDirectory.d.ts +2 -1
- package/dist/project/loadProjectFromDirectory.d.ts.map +1 -1
- package/dist/project/loadProjectFromDirectory.js +40 -52
- package/dist/project/loadProjectFromDirectory.js.map +1 -1
- package/dist/project/loadProjectFromDirectory.test.js +59 -3
- package/dist/project/loadProjectFromDirectory.test.js.map +1 -1
- package/dist/services/env-variables/index.js +3 -3
- package/dist/services/env-variables/index.js.map +1 -1
- package/package.json +4 -5
- package/src/json-schema/settings.test.ts +26 -0
- package/src/json-schema/settings.ts +3 -36
- package/src/plugin/importPlugins.test.ts +0 -1
- package/src/project/loadProjectFromDirectory.test.ts +69 -1
- package/src/project/loadProjectFromDirectory.ts +48 -97
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Static
|
|
1
|
+
import { type Static } from "@sinclair/typebox";
|
|
2
2
|
export type ProjectSettings = Omit<Static<typeof ProjectSettings>, "languageTags" | "sourceLanguageTag"> & {
|
|
3
3
|
/** @deprecated Use `baseLocale` */
|
|
4
4
|
sourceLanguageTag?: string;
|
|
@@ -6,9 +6,9 @@ export type ProjectSettings = Omit<Static<typeof ProjectSettings>, "languageTags
|
|
|
6
6
|
languageTags?: string[];
|
|
7
7
|
/** @deprecated This will soon be replaced by `Lix Validation Rules` */
|
|
8
8
|
messageLintRuleLevels?: Record<string, "error" | "warning">;
|
|
9
|
-
}
|
|
10
|
-
export declare const ProjectSettings: import("@sinclair/typebox").
|
|
11
|
-
$schema: import("@sinclair/typebox").TOptional<TLiteral<"https://inlang.com/schema/project-settings">>;
|
|
9
|
+
} & Record<string, any>;
|
|
10
|
+
export declare const ProjectSettings: import("@sinclair/typebox").TObject<{
|
|
11
|
+
$schema: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TLiteral<"https://inlang.com/schema/project-settings">>;
|
|
12
12
|
baseLocale: import("@sinclair/typebox").TString;
|
|
13
13
|
locales: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
|
|
14
14
|
sourceLanguageTag: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
@@ -22,10 +22,8 @@ export declare const ProjectSettings: import("@sinclair/typebox").TIntersect<[im
|
|
|
22
22
|
* "https://cdn.jsdelivr.net/npm/@inlang/plugin-csv@1/dist/index.js",
|
|
23
23
|
* ]
|
|
24
24
|
*/
|
|
25
|
-
modules: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TString
|
|
26
|
-
telemetry: import("@sinclair/typebox").TOptional<TLiteral<"off">>;
|
|
27
|
-
experimental: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, TLiteral<true>>>;
|
|
28
|
-
}
|
|
29
|
-
[x: `plugin.${string}`]: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TAny>;
|
|
30
|
-
}>]>;
|
|
25
|
+
modules: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TString]>>>;
|
|
26
|
+
telemetry: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TLiteral<"off">>;
|
|
27
|
+
experimental: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TLiteral<true>>>;
|
|
28
|
+
}>;
|
|
31
29
|
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"/","sources":["json-schema/settings.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"/","sources":["json-schema/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,mBAAmB,CAAC;AA6FtD,MAAM,MAAM,eAAe,GAAG,IAAI,CACjC,MAAM,CAAC,OAAO,eAAe,CAAC,EAC9B,cAAc,GAAG,mBAAmB,CACpC,GAAG;IACH,mCAAmC;IACnC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gCAAgC;IAChC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,uEAAuE;IACvE,qBAAqB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC,CAAC;CAC5D,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACxB,eAAO,MAAM,eAAe;;;;;;IArE3B;;;;;;;;OAQG;;;;EA6DsC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
-
import { Type
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="0ab441fa-e6ed-5327-b6ba-da781e2b1e94")}catch(e){}}();
|
|
3
|
+
import { Type } from "@sinclair/typebox";
|
|
4
4
|
const SDKSettings = Type.Object({
|
|
5
5
|
// TODO SDK-v2 SETTINGS do we need to generate a settings v2 schema?
|
|
6
6
|
$schema: Type.Optional(Type.Literal("https://inlang.com/schema/project-settings")),
|
|
@@ -44,10 +44,6 @@ const SDKSettings = Type.Object({
|
|
|
44
44
|
description: "The module must end with `.js`.",
|
|
45
45
|
pattern: ".*\\.js$",
|
|
46
46
|
}),
|
|
47
|
-
Type.String({
|
|
48
|
-
description: "The module can only contain a major version number.",
|
|
49
|
-
pattern: "^(?!.*@\\d\\.)[^]*$",
|
|
50
|
-
}),
|
|
51
47
|
]), {
|
|
52
48
|
uniqueItems: true,
|
|
53
49
|
description: "The modules to load. Must be a valid URI but can be relative.",
|
|
@@ -72,25 +68,6 @@ const SDKSettings = Type.Object({
|
|
|
72
68
|
* The plugin settings are validated when importing plugins
|
|
73
69
|
*/
|
|
74
70
|
});
|
|
75
|
-
|
|
76
|
-
* Settings defined via apps, plugins, lint rules, etc.
|
|
77
|
-
*
|
|
78
|
-
* Using external settings to only allow `plugin.*` keys
|
|
79
|
-
* and don't block the SDK from adding new settings.
|
|
80
|
-
*/
|
|
81
|
-
const ExternalSettings = Type.Record(Type.String({
|
|
82
|
-
pattern: `^((plugin)\\.([a-z][a-zA-Z0-9]*(?:[A-Z][a-z0-9]*)*)|\\$schema|${
|
|
83
|
-
// pattern must include the settings properties
|
|
84
|
-
Object.keys(SDKSettings.properties)
|
|
85
|
-
.map((key) => key.replaceAll(".", "\\."))
|
|
86
|
-
.join("|")})$`,
|
|
87
|
-
description: "The key must be conform to `plugin.*`.",
|
|
88
|
-
examples: ["plugin.csv-importer", "plugin.i18next"],
|
|
89
|
-
}),
|
|
90
|
-
// Using JSON (array and object) as a workaround to make the
|
|
91
|
-
// intersection between `InternalSettings`, which contains an array,
|
|
92
|
-
// and `ExternalSettings` which are objects possible
|
|
93
|
-
Type.Record(Type.String(), Type.Any()), { description: "Settings defined by apps, plugins, etc." });
|
|
94
|
-
export const ProjectSettings = Type.Intersect([SDKSettings, ExternalSettings]);
|
|
71
|
+
export const ProjectSettings = SDKSettings;
|
|
95
72
|
//# sourceMappingURL=settings.js.map
|
|
96
|
-
//# debugId=
|
|
73
|
+
//# debugId=0ab441fa-e6ed-5327-b6ba-da781e2b1e94
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sources":["json-schema/settings.ts"],"sourceRoot":"/","sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"settings.js","sources":["json-schema/settings.ts"],"sourceRoot":"/","sourcesContent":["import { type Static, Type } from \"@sinclair/typebox\";\n\nconst SDKSettings = Type.Object({\n\t// TODO SDK-v2 SETTINGS do we need to generate a settings v2 schema?\n\t$schema: Type.Optional(\n\t\tType.Literal(\"https://inlang.com/schema/project-settings\")\n\t),\n\tbaseLocale: Type.String({\n\t\ttitle: \"Base locale\",\n\t\tdescription:\n\t\t\t\"The base locale of the project. We recommend BCP-47 language tags.\",\n\t}),\n\tlocales: Type.Array(Type.String(), {\n\t\tuniqueItems: true,\n\t\ttitle: \"Project Locales\",\n\t\tdescription:\n\t\t\t\"Set the locales that are available in your project. All locales needs to be a valid BCP-47 language tag. Needs to include the base locale tag.\",\n\t}),\n\t// exits for backwards compatibility\n\t// remove in SDK-v3\n\tsourceLanguageTag: Type.Optional(\n\t\tType.String({\n\t\t\tdescription: \"Use baseLocale instead.\",\n\t\t\tdeprecated: true,\n\t\t})\n\t),\n\t// exits for backwards compatibility\n\t// remove in SDK-v3\n\tlanguageTags: Type.Optional(\n\t\tType.Array(Type.String(), {\n\t\t\tuniqueItems: true,\n\t\t\tdeprecated: true,\n\t\t\tdescription: \"Use locales instead.\",\n\t\t})\n\t),\n\t/**\n\t * The modules to load.\n\t *\n\t * @example\n\t * modules: [\n\t * \t \"https://cdn.jsdelivr.net/npm/@inlang/plugin-i18next@3/dist/index.js\",\n\t * \t \"https://cdn.jsdelivr.net/npm/@inlang/plugin-csv@1/dist/index.js\",\n\t * ]\n\t */\n\tmodules: Type.Optional(\n\t\tType.Array(\n\t\t\tType.Intersect([\n\t\t\t\tType.String({\n\t\t\t\t\tdescription: \"The module must be a valid URI according to RFC 3986.\",\n\t\t\t\t\tpattern:\n\t\t\t\t\t\t\"(?:[A-Za-z][A-Za-z0-9+.-]*:/{2})?(?:(?:[A-Za-z0-9-._~]|%[A-Fa-f0-9]{2})+(?::([A-Za-z0-9-._~]?|[%][A-Fa-f0-9]{2})+)?@)?(?:[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?\\\\.){1,126}[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?::[0-9]+)?(?:/(?:[A-Za-z0-9-._~]|%[A-Fa-f0-9]{2})*)*(?:\\\\?(?:[A-Za-z0-9-._~]+(?:=(?:[A-Za-z0-9-._~+]|%[A-Fa-f0-9]{2})+)?)(?:&|;[A-Za-z0-9-._~]+(?:=(?:[A-Za-z0-9-._~+]|%[A-Fa-f0-9]{2})+)?)*)?\",\n\t\t\t\t}),\n\t\t\t\tType.String({\n\t\t\t\t\tdescription: \"The module must end with `.js`.\",\n\t\t\t\t\tpattern: \".*\\\\.js$\",\n\t\t\t\t}),\n\t\t\t]),\n\t\t\t{\n\t\t\t\tuniqueItems: true,\n\t\t\t\tdescription:\n\t\t\t\t\t\"The modules to load. Must be a valid URI but can be relative.\",\n\t\t\t\texamples: [\n\t\t\t\t\t\"https://cdn.jsdelivr.net/npm/@inlang/plugin-i18next@3/dist/index.js\",\n\t\t\t\t\t\"https://cdn.jsdelivr.net/npm/@inlang/plugin-csv@1/dist/index.js\",\n\t\t\t\t\t\"./local-testing-plugin.js\",\n\t\t\t\t],\n\t\t\t}\n\t\t)\n\t),\n\ttelemetry: Type.Optional(\n\t\tType.Union(\n\t\t\t[\n\t\t\t\tType.Literal(\"off\", {\n\t\t\t\t\tdescription: \"No telemetry events \",\n\t\t\t\t}),\n\t\t\t],\n\t\t\t{ description: \"If not set, defaults to all\" }\n\t\t)\n\t),\n\texperimental: Type.Optional(\n\t\tType.Record(Type.String(), Type.Literal(true), {\n\t\t\ttitle: \"Experimental settings\",\n\t\t\tdescription:\n\t\t\t\t\"Experimental settings that are used for product development.\",\n\t\t})\n\t),\n\t/**\n\t * plugin.*: JSONObject\n\t *\n\t * The plugin settings are validated when importing plugins\n\t */\n});\n\nexport type ProjectSettings = Omit<\n\tStatic<typeof ProjectSettings>,\n\t\"languageTags\" | \"sourceLanguageTag\"\n> & {\n\t/** @deprecated Use `baseLocale` */\n\tsourceLanguageTag?: string;\n\t/** @deprecated Use `locales` */\n\tlanguageTags?: string[];\n\t/** @deprecated This will soon be replaced by `Lix Validation Rules` */\n\tmessageLintRuleLevels?: Record<string, \"error\" | \"warning\">;\n} & Record<string, any>;\nexport const ProjectSettings = SDKSettings;\n"],"names":[],"mappings":";;AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC;IAC/B,oEAAoE;IACpE,OAAO,EAAE,IAAI,CAAC,QAAQ,CACrB,IAAI,CAAC,OAAO,CAAC,4CAA4C,CAAC,CAC1D;IACD,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC;QACvB,KAAK,EAAE,aAAa;QACpB,WAAW,EACV,oEAAoE;KACrE,CAAC;IACF,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE;QAClC,WAAW,EAAE,IAAI;QACjB,KAAK,EAAE,iBAAiB;QACxB,WAAW,EACV,gJAAgJ;KACjJ,CAAC;IACF,oCAAoC;IACpC,mBAAmB;IACnB,iBAAiB,EAAE,IAAI,CAAC,QAAQ,CAC/B,IAAI,CAAC,MAAM,CAAC;QACX,WAAW,EAAE,yBAAyB;QACtC,UAAU,EAAE,IAAI;KAChB,CAAC,CACF;IACD,oCAAoC;IACpC,mBAAmB;IACnB,YAAY,EAAE,IAAI,CAAC,QAAQ,CAC1B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE;QACzB,WAAW,EAAE,IAAI;QACjB,UAAU,EAAE,IAAI;QAChB,WAAW,EAAE,sBAAsB;KACnC,CAAC,CACF;IACD;;;;;;;;OAQG;IACH,OAAO,EAAE,IAAI,CAAC,QAAQ,CACrB,IAAI,CAAC,KAAK,CACT,IAAI,CAAC,SAAS,CAAC;QACd,IAAI,CAAC,MAAM,CAAC;YACX,WAAW,EAAE,uDAAuD;YACpE,OAAO,EACN,sZAAsZ;SACvZ,CAAC;QACF,IAAI,CAAC,MAAM,CAAC;YACX,WAAW,EAAE,iCAAiC;YAC9C,OAAO,EAAE,UAAU;SACnB,CAAC;KACF,CAAC,EACF;QACC,WAAW,EAAE,IAAI;QACjB,WAAW,EACV,+DAA+D;QAChE,QAAQ,EAAE;YACT,qEAAqE;YACrE,iEAAiE;YACjE,2BAA2B;SAC3B;KACD,CACD,CACD;IACD,SAAS,EAAE,IAAI,CAAC,QAAQ,CACvB,IAAI,CAAC,KAAK,CACT;QACC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;YACnB,WAAW,EAAE,sBAAsB;SACnC,CAAC;KACF,EACD,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAC9C,CACD;IACD,YAAY,EAAE,IAAI,CAAC,QAAQ,CAC1B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAC9C,KAAK,EAAE,uBAAuB;QAC9B,WAAW,EACV,8DAA8D;KAC/D,CAAC,CACF;IACD;;;;OAIG;CACH,CAAC,CAAC;AAaH,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC","debug_id":"0ab441fa-e6ed-5327-b6ba-da781e2b1e94"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.test.d.ts","sourceRoot":"/","sources":["json-schema/settings.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9b1af2ee-57bc-53aa-87a7-58e094655f60")}catch(e){}}();
|
|
3
|
+
import { TypeCompiler } from "@sinclair/typebox/compiler";
|
|
4
|
+
import { ProjectSettings } from "./settings.js";
|
|
5
|
+
import { test, expect } from "vitest";
|
|
6
|
+
const C = TypeCompiler.Compile(ProjectSettings);
|
|
7
|
+
test("valid settings file", () => {
|
|
8
|
+
const settings = {
|
|
9
|
+
baseLocale: "en",
|
|
10
|
+
locales: ["en", "de"],
|
|
11
|
+
modules: [
|
|
12
|
+
"https://cdn.jsdelivr.net/npm/@inlang/plugin-i18next@3/dist/index.js",
|
|
13
|
+
"https://cdn.jsdelivr.net/npm/@inlang/plugin-csv@1/dist/index.js",
|
|
14
|
+
],
|
|
15
|
+
"plugin.something": {
|
|
16
|
+
key: "value",
|
|
17
|
+
nested: {
|
|
18
|
+
moreNested: {},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
const errors = [...C.Errors(settings)];
|
|
23
|
+
expect(errors).toEqual([]);
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=settings.test.js.map
|
|
26
|
+
//# debugId=9b1af2ee-57bc-53aa-87a7-58e094655f60
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.test.js","sources":["json-schema/settings.test.ts"],"sourceRoot":"/","sourcesContent":["import { TypeCompiler } from \"@sinclair/typebox/compiler\";\nimport { ProjectSettings } from \"./settings.js\";\nimport { test, expect } from \"vitest\";\n\nconst C = TypeCompiler.Compile(ProjectSettings);\n\ntest(\"valid settings file\", () => {\n\tconst settings: ProjectSettings = {\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t\tmodules: [\n\t\t\t\"https://cdn.jsdelivr.net/npm/@inlang/plugin-i18next@3/dist/index.js\",\n\t\t\t\"https://cdn.jsdelivr.net/npm/@inlang/plugin-csv@1/dist/index.js\",\n\t\t],\n\t\t\"plugin.something\": {\n\t\t\tkey: \"value\",\n\t\t\tnested: {\n\t\t\t\tmoreNested: {},\n\t\t\t},\n\t\t},\n\t};\n\n\tconst errors = [...C.Errors(settings)];\n\n\texpect(errors).toEqual([]);\n});\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;AAEhD,IAAI,CAAC,qBAAqB,EAAE,GAAG,EAAE;IAChC,MAAM,QAAQ,GAAoB;QACjC,UAAU,EAAE,IAAI;QAChB,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;QACrB,OAAO,EAAE;YACR,qEAAqE;YACrE,iEAAiE;SACjE;QACD,kBAAkB,EAAE;YACnB,GAAG,EAAE,OAAO;YACZ,MAAM,EAAE;gBACP,UAAU,EAAE,EAAE;aACd;SACD;KACD,CAAC;IAEF,MAAM,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEvC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAC5B,CAAC,CAAC,CAAC","debug_id":"9b1af2ee-57bc-53aa-87a7-58e094655f60"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d56eea49-1483-5227-ae80-1f01de298ace")}catch(e){}}();
|
|
3
3
|
import { test, expect, vi } from "vitest";
|
|
4
4
|
import { importPlugins } from "./importPlugins.js";
|
|
5
5
|
import { PluginImportError } from "./errors.js";
|
|
@@ -21,7 +21,6 @@ test("it should preprocess a plugin", async () => {
|
|
|
21
21
|
return moduleText.replace("mock", "preprocessed");
|
|
22
22
|
},
|
|
23
23
|
});
|
|
24
|
-
expect(global.fetch).toHaveBeenCalledTimes(1);
|
|
25
24
|
expect(result.plugins.length).toBe(1);
|
|
26
25
|
expect(result.errors.length).toBe(0);
|
|
27
26
|
expect(result.plugins[0]?.key).toBe("preprocessed");
|
|
@@ -92,4 +91,4 @@ test("cache should work", async () => {
|
|
|
92
91
|
expect(result.plugins[0]?.key).toBe("mock");
|
|
93
92
|
});
|
|
94
93
|
//# sourceMappingURL=importPlugins.test.js.map
|
|
95
|
-
//# debugId=
|
|
94
|
+
//# debugId=d56eea49-1483-5227-ae80-1f01de298ace
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"importPlugins.test.js","sources":["plugin/importPlugins.test.ts"],"sourceRoot":"/","sourcesContent":["import { test, expect, vi } from \"vitest\";\nimport { importPlugins } from \"./importPlugins.js\";\nimport { PluginImportError } from \"./errors.js\";\nimport { newLixFile, openLixInMemory } from \"@lix-js/sdk\";\n\ntest(\"it should preprocess a plugin\", async () => {\n\tglobal.fetch = vi.fn().mockResolvedValue({\n\t\tok: true,\n\t\ttext: vi.fn().mockResolvedValue(\"export default { key: 'mock' }\"),\n\t});\n\n\tconst lix = await openLixInMemory({ blob: await newLixFile() });\n\tconst result = await importPlugins({\n\t\tlix,\n\t\tsettings: {\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\"],\n\t\t\tmodules: [\"https://mock.com/module.js\"],\n\t\t},\n\t\tpreprocessPluginBeforeImport: async (moduleText) => {\n\t\t\treturn moduleText.replace(\"mock\", \"preprocessed\");\n\t\t},\n\t});\n\n\texpect(
|
|
1
|
+
{"version":3,"file":"importPlugins.test.js","sources":["plugin/importPlugins.test.ts"],"sourceRoot":"/","sourcesContent":["import { test, expect, vi } from \"vitest\";\nimport { importPlugins } from \"./importPlugins.js\";\nimport { PluginImportError } from \"./errors.js\";\nimport { newLixFile, openLixInMemory } from \"@lix-js/sdk\";\n\ntest(\"it should preprocess a plugin\", async () => {\n\tglobal.fetch = vi.fn().mockResolvedValue({\n\t\tok: true,\n\t\ttext: vi.fn().mockResolvedValue(\"export default { key: 'mock' }\"),\n\t});\n\n\tconst lix = await openLixInMemory({ blob: await newLixFile() });\n\tconst result = await importPlugins({\n\t\tlix,\n\t\tsettings: {\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\"],\n\t\t\tmodules: [\"https://mock.com/module.js\"],\n\t\t},\n\t\tpreprocessPluginBeforeImport: async (moduleText) => {\n\t\t\treturn moduleText.replace(\"mock\", \"preprocessed\");\n\t\t},\n\t});\n\n\texpect(result.plugins.length).toBe(1);\n\texpect(result.errors.length).toBe(0);\n\texpect(result.plugins[0]?.key).toBe(\"preprocessed\");\n});\n\ntest(\"if a fetch fails, a plugin import error is expected\", async () => {\n\tglobal.fetch = vi.fn().mockResolvedValue({\n\t\tok: false,\n\t\tstatusText: \"HTTP 404\",\n\t});\n\tconst lix = await openLixInMemory({ blob: await newLixFile() });\n\n\tconst result = await importPlugins({\n\t\tlix,\n\t\tsettings: {\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\"],\n\t\t\tmodules: [\"https://mock.com/module.js\"],\n\t\t},\n\t});\n\n\texpect(global.fetch).toHaveBeenCalledTimes(1);\n\texpect(result.plugins.length).toBe(0);\n\texpect(result.errors.length).toBe(1);\n\texpect(result.errors[0]).toBeInstanceOf(PluginImportError);\n});\n\ntest(\"it should filter message lint rules for legacy reasons\", async () => {\n\tglobal.fetch = vi.fn().mockResolvedValue({\n\t\tok: true,\n\t\ttext: vi\n\t\t\t.fn()\n\t\t\t.mockResolvedValue(\"export default { id: 'messageLintRule.something' }\"),\n\t});\n\n\tconst lix = await openLixInMemory({ blob: await newLixFile() });\n\n\tconst result = await importPlugins({\n\t\tlix,\n\t\tsettings: {\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\"],\n\t\t\tmodules: [\"https://mock.com/module.js\"],\n\t\t},\n\t});\n\n\texpect(result.plugins.length).toBe(0);\n\texpect(result.errors.length).toBe(0);\n});\n\n// more tests are found in cache.test.ts\ntest(\"cache should work\", async () => {\n\tglobal.fetch = vi.fn().mockResolvedValue({\n\t\tok: false,\n\t});\n\n\tconst mockModulePath = \"https://mock.com/module.js\";\n\tconst mockModuleCachePath = \"/cache/plugins/31i1etp0l413h\";\n\n\tconst lix = await openLixInMemory({ blob: await newLixFile() });\n\n\tawait lix.db\n\t\t.insertInto(\"file\")\n\t\t.values({\n\t\t\tpath: mockModuleCachePath,\n\t\t\tdata: new TextEncoder().encode(\"export default { key: 'mock' }\"),\n\t\t})\n\t\t.execute();\n\n\tconst result = await importPlugins({\n\t\tlix,\n\t\tsettings: {\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\"],\n\t\t\tmodules: [mockModulePath],\n\t\t},\n\t});\n\n\texpect(result.errors).lengthOf(0);\n\texpect(result.plugins).lengthOf(1);\n\texpect(result.plugins[0]?.key).toBe(\"mock\");\n});\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE1D,IAAI,CAAC,+BAA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fs from "node:fs";
|
|
4
4
|
import type { InlangPlugin, NodeFsPromisesSubsetLegacy } from "../plugin/schema.js";
|
|
5
5
|
import type { ProjectSettings } from "../json-schema/settings.js";
|
|
6
|
+
import type { ImportFile } from "./api.js";
|
|
6
7
|
/**
|
|
7
8
|
* Loads a project from a directory.
|
|
8
9
|
*
|
|
@@ -32,7 +33,7 @@ export declare function loadProjectFromDirectory(args: {
|
|
|
32
33
|
lix: Lix;
|
|
33
34
|
importFiles: (args: {
|
|
34
35
|
pluginKey: InlangPlugin["key"];
|
|
35
|
-
files:
|
|
36
|
+
files: ImportFile[];
|
|
36
37
|
}) => Promise<void>;
|
|
37
38
|
exportFiles: (args: {
|
|
38
39
|
pluginKey: InlangPlugin["key"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadProjectFromDirectory.d.ts","sourceRoot":"/","sources":["project/loadProjectFromDirectory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"loadProjectFromDirectory.d.ts","sourceRoot":"/","sources":["project/loadProjectFromDirectory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,KAAK,EACX,YAAY,EACZ,0BAA0B,EAC1B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAIlE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC7C,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,OAAO,EAAE,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAClE,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC,EACzC,MAAM,CACN;;;;;;;;;;;;;;;;;;;;;;;;;;GA0HD;AAgeD,qBAAa,yBAA0B,SAAQ,KAAK;gBACvC,MAAM,EAAE,MAAM;CAM1B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAChC,EAAE,EAAE,0BAA0B,EAC9B,WAAW,EAAE,MAAM,GACjB,0BAA0B,CAgB5B;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAWxE;AAED,qBAAa,uBAAwB,SAAQ,KAAK;IACjD,IAAI,EAAE,MAAM,CAAC;gBAED,IAAI,EAAE;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;CAMhD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9753a988-ad27-5056-92c0-c24779eb1720")}catch(e){}}();
|
|
3
3
|
import { newProject } from "./newProject.js";
|
|
4
4
|
import { loadProjectInMemory } from "./loadProjectInMemory.js";
|
|
5
5
|
import {} from "@lix-js/sdk";
|
|
@@ -43,55 +43,34 @@ export async function loadProjectFromDirectory(args) {
|
|
|
43
43
|
lix: project.lix,
|
|
44
44
|
syncInterval: args.syncInterval,
|
|
45
45
|
});
|
|
46
|
-
const
|
|
46
|
+
const allPlugins = await project.plugins.get();
|
|
47
|
+
const { loadSavePlugins, importExportPlugins } = categorizePlugins(allPlugins);
|
|
47
48
|
// TODO i guess we should move this validation logic into sdk2/src/project/loadProject.ts
|
|
48
49
|
// Two scenarios could arise:
|
|
49
50
|
// 1. set settings is called from an app - it should detect and reject the setting of settings -> app need to be able to validate before calling set
|
|
50
51
|
// 2. the settings file loaded from disc here is corrupted -> user has to fix the file on disc
|
|
51
|
-
if (
|
|
52
|
+
if (loadSavePlugins.length > 1) {
|
|
52
53
|
throw new Error("Max one loadMessages (found: " +
|
|
53
|
-
|
|
54
|
+
loadSavePlugins.length +
|
|
54
55
|
") and one saveMessages plugins (found: " +
|
|
55
|
-
|
|
56
|
+
loadSavePlugins.length +
|
|
56
57
|
") are allowed ");
|
|
57
58
|
}
|
|
58
59
|
const importedResourceFileErrors = [];
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
throw new Error("Plugins for loadMessages (found: " +
|
|
62
|
-
loadMessagesPlugins.length +
|
|
63
|
-
") and saveMessages plugins (found: " +
|
|
64
|
-
saveMessagesPlugins.length +
|
|
65
|
-
") must not coexist with import (found: " +
|
|
66
|
-
importPlugins.length +
|
|
67
|
-
") or export (found: " +
|
|
68
|
-
exportPlugins.length +
|
|
69
|
-
") ");
|
|
70
|
-
}
|
|
71
|
-
else if (loadMessagesPlugins.length > 1 || saveMessagesPlugins.length > 1) {
|
|
72
|
-
throw new Error("Max one loadMessages (found: " +
|
|
73
|
-
loadMessagesPlugins.length +
|
|
74
|
-
") and one saveMessages plugins (found: " +
|
|
75
|
-
saveMessagesPlugins.length +
|
|
76
|
-
") are allowed ");
|
|
77
|
-
}
|
|
78
|
-
else if (importPlugins[0]) {
|
|
79
|
-
const importer = importPlugins[0];
|
|
60
|
+
// import files from local fs
|
|
61
|
+
for (const plugin of importExportPlugins) {
|
|
80
62
|
const files = [];
|
|
81
|
-
if (
|
|
82
|
-
const toBeImportedFiles = await
|
|
63
|
+
if (plugin.toBeImportedFiles) {
|
|
64
|
+
const toBeImportedFiles = await plugin.toBeImportedFiles({
|
|
83
65
|
settings: await project.settings.get(),
|
|
84
66
|
});
|
|
85
67
|
for (const toBeImported of toBeImportedFiles) {
|
|
86
68
|
const absolute = absolutePathFromProject(args.path, toBeImported.path);
|
|
87
69
|
try {
|
|
88
70
|
const data = await args.fs.promises.readFile(absolute);
|
|
89
|
-
const name = nodePath.basename(toBeImported.path);
|
|
90
71
|
files.push({
|
|
91
|
-
name,
|
|
92
72
|
locale: toBeImported.locale,
|
|
93
73
|
content: data,
|
|
94
|
-
pluginKey: importer.key,
|
|
95
74
|
toBeImportedFilesMetadata: toBeImported.metadata,
|
|
96
75
|
});
|
|
97
76
|
}
|
|
@@ -108,18 +87,17 @@ export async function loadProjectFromDirectory(args) {
|
|
|
108
87
|
}
|
|
109
88
|
}
|
|
110
89
|
await project.importFiles({
|
|
111
|
-
pluginKey:
|
|
112
|
-
files
|
|
90
|
+
pluginKey: plugin.key,
|
|
91
|
+
files,
|
|
113
92
|
});
|
|
114
93
|
}
|
|
115
|
-
|
|
116
|
-
// TODO create resource files from loadMessageFn call - to poll?
|
|
94
|
+
for (const plugin of loadSavePlugins) {
|
|
117
95
|
await loadLegacyMessages({
|
|
118
96
|
project,
|
|
97
|
+
pluginKey: plugin.key ?? plugin.id,
|
|
98
|
+
loadMessagesFn: plugin.loadMessages,
|
|
119
99
|
projectPath: args.path,
|
|
120
100
|
fs: args.fs,
|
|
121
|
-
pluginKey: loadMessagesPlugins[0].key ?? loadMessagesPlugins[0].id,
|
|
122
|
-
loadMessagesFn: loadMessagesPlugins[0].loadMessages,
|
|
123
101
|
});
|
|
124
102
|
}
|
|
125
103
|
return {
|
|
@@ -454,9 +432,12 @@ async function syncLixFsFiles(args) {
|
|
|
454
432
|
return;
|
|
455
433
|
}
|
|
456
434
|
async function upsertFileInLix(args, path, data) {
|
|
457
|
-
//
|
|
458
|
-
//
|
|
459
|
-
|
|
435
|
+
// force posix path when upserting into lix
|
|
436
|
+
// https://github.com/opral/inlang-sdk/issues/229
|
|
437
|
+
let posixPath = path.split(nodePath.win32.sep).join(nodePath.posix.sep);
|
|
438
|
+
if (posixPath.startsWith("/") === false) {
|
|
439
|
+
posixPath = "/" + posixPath;
|
|
440
|
+
}
|
|
460
441
|
await args.lix.db
|
|
461
442
|
.insertInto("file") // change queue
|
|
462
443
|
.values({
|
|
@@ -466,18 +447,25 @@ async function upsertFileInLix(args, path, data) {
|
|
|
466
447
|
.onConflict((oc) => oc.column("path").doUpdateSet({ data: new Uint8Array(data) }))
|
|
467
448
|
.execute();
|
|
468
449
|
}
|
|
469
|
-
|
|
450
|
+
/**
|
|
451
|
+
* Filters legacy load and save messages plugins.
|
|
452
|
+
*
|
|
453
|
+
* Legacy plugins are plugins that implement loadMessages and saveMessages but not importFiles and exportFiles.
|
|
454
|
+
*/
|
|
470
455
|
function categorizePlugins(plugins) {
|
|
471
|
-
const
|
|
472
|
-
const
|
|
473
|
-
const
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
456
|
+
const loadSavePlugins = [];
|
|
457
|
+
const importExportPlugins = [];
|
|
458
|
+
for (const plugin of plugins) {
|
|
459
|
+
if (plugin.loadMessages &&
|
|
460
|
+
plugin.saveMessages &&
|
|
461
|
+
!(plugin.importFiles && plugin.exportFiles)) {
|
|
462
|
+
loadSavePlugins.push(plugin);
|
|
463
|
+
}
|
|
464
|
+
else if (plugin.importFiles || plugin.exportFiles) {
|
|
465
|
+
importExportPlugins.push(plugin);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
return { loadSavePlugins, importExportPlugins };
|
|
481
469
|
}
|
|
482
470
|
/**
|
|
483
471
|
* Imports local plugins for backwards compatibility.
|
|
@@ -581,4 +569,4 @@ export class ResourceFileImportError extends Error {
|
|
|
581
569
|
}
|
|
582
570
|
}
|
|
583
571
|
//# sourceMappingURL=loadProjectFromDirectory.js.map
|
|
584
|
-
//# debugId=
|
|
572
|
+
//# debugId=9753a988-ad27-5056-92c0-c24779eb1720
|