Skip to content

Commit

Permalink
Merge pull request #2412 from opral/nilsjacobsen/mesdk-38-feat-settin…
Browse files Browse the repository at this point in the history
…gs-schema-in-installedplugin

feat: add settingsSchema to installedPlugin & installedMessageLintRule
  • Loading branch information
NilsJacobsen authored Mar 21, 2024
2 parents 2a815b2 + 1e43ae4 commit 6eb5d8c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/two-hornets-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@inlang/sdk": minor
---

Add settingsSchema to installedPlugin & installedMessageLintRule
2 changes: 2 additions & 0 deletions inlang/source-code/sdk/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type InstalledPlugin = {
* The module which the plugin is installed from.
*/
module: string
settingsSchema: Plugin["settingsSchema"]
// disabled: boolean
}

Expand All @@ -31,6 +32,7 @@ export type InstalledMessageLintRule = {
*/
module: string
level: MessageLintLevel
settingsSchema: MessageLintRule["settingsSchema"]
}

export type InlangProject = {
Expand Down
2 changes: 2 additions & 0 deletions inlang/source-code/sdk/src/loadProject.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ describe("functionality", () => {
description: mockPlugin.description,
displayName: mockPlugin.displayName,
module: settings.modules[0],
settingsSchema: mockPlugin.settingsSchema,
})

expect(project.installed.messageLintRules()[0]).toEqual({
Expand All @@ -560,6 +561,7 @@ describe("functionality", () => {
displayName: mockMessageLintRule.displayName,
module: settings.modules[1],
level: "warning",
settingsSchema: mockMessageLintRule.settingsSchema,
})
})

Expand Down
2 changes: 2 additions & 0 deletions inlang/source-code/sdk/src/loadProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ export async function loadProject(args: {
"Unknown module. You stumbled on a bug in inlang's source code. Please open an issue.",
// default to warning, see https://github.com/opral/monorepo/issues/1254
level: settingsValue["messageLintRuleLevels"]?.[rule.id] ?? "warning",
settingsSchema: rule.settingsSchema,
} satisfies InstalledMessageLintRule)
) satisfies Array<InstalledMessageLintRule>
}
Expand All @@ -294,6 +295,7 @@ export async function loadProject(args: {
module:
resolvedModules()?.meta.find((m) => m.id.includes(plugin.id))?.module ??
"Unknown module. You stumbled on a bug in inlang's source code. Please open an issue.",
settingsSchema: plugin.settingsSchema,
})) satisfies Array<InstalledPlugin>
}

Expand Down

0 comments on commit 6eb5d8c

Please sign in to comment.