Skip to content

Commit

Permalink
start update import & loadProject & remove concept of InlangModule
Browse files Browse the repository at this point in the history
…which is now `InlangPlugin`

remove lint rules as inlang module type while migrating them to lix validation rules. cc @samuelstroschein @janfjohannes
  • Loading branch information
felixhaeberle committed Jul 29, 2024
1 parent 3d5c782 commit 3b842d1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions inlang/source-code/sdk-v2/src/import-utils.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ModuleImportError } from "./resolve-modules/errors.js"
import type { InlangModule } from "./types/module.js"
import type { InlangPlugin } from "./types/module.js"

/**
* @throws {ModuleImportError}
*/
type Importer = (uri: string) => Promise<InlangModule>
type Importer = (uri: string) => Promise<InlangPlugin>

export function createDebugImport(importMap: Record<string, InlangModule["default"]>): Importer {
export function createDebugImport(importMap: Record<string, InlangPlugin["default"]>): Importer {
return async (uri) => {
const resolved = importMap[uri]
if (resolved) return { default: resolved }
Expand Down
30 changes: 15 additions & 15 deletions inlang/source-code/sdk-v2/src/loadProjectOpfs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ import { BehaviorSubject, combineLatest, from, switchMap, tap } from "rxjs"
import { createDebugImport, importSequence } from "./import-utils.js"

// development only
import lintRule from "./dev-modules/lint-rule.js"
import makeOpralUppercase from "./dev-modules/opral-uppercase-lint-rule.js"
import missingSelectorLintRule from "./dev-modules/missing-selector-lint-rule.js"
import missingCatchallLintRule from "./dev-modules/missingCatchall.js"
// import lintRule from "./dev-modules/lint-rule.js"
// import makeOpralUppercase from "./dev-modules/opral-uppercase-lint-rule.js"
// import missingSelectorLintRule from "./dev-modules/missing-selector-lint-rule.js"
// import missingCatchallLintRule from "./dev-modules/missingCatchall.js"
import { resolveModules } from "./resolveModules2.js"
import type { InstalledLintRule, ProjectSettings2 } from "./types/project-settings.js"
import type { InlangProject } from "./types/project.js"
import type { LanguageTag } from "@inlang/plugin"
// import type { LanguageTag } from "@inlang/plugin"

// extend the SQLocalKysely class to expose a rawSql function
// needed for non parametrized queries
Expand Down Expand Up @@ -65,15 +65,15 @@ export async function loadProjectOpfs(args: { inlangFolderPath: string }): Promi
const projectSettings$ = new BehaviorSubject(projectSettings)

// TODO SDK-v2 LIX how to deal with plugins we want to load?
const _import = importSequence(
createDebugImport({
"sdk-dev:lint-rule.js": lintRule,
"sdk-dev:opral-uppercase-lint.js": makeOpralUppercase,
"sdk-dev:missing-selector-lint-rule.js": missingSelectorLintRule,
"sdk-dev:missing-catchall-variant": missingCatchallLintRule,
}) /*,
createImport(projectPath, nodeishFs)*/
)
const _import = importSequence()
// Lint rules are now Lix validation rules, therefore this needs to be reimplemented
// createDebugImport({
// "sdk-dev:lint-rule.js": lintRule,
// "sdk-dev:opral-uppercase-lint.js": makeOpralUppercase,
// "sdk-dev:missing-selector-lint-rule.js": missingSelectorLintRule,
// "sdk-dev:missing-catchall-variant": missingCatchallLintRule,
// }),
// createImport(projectPath, nodeishFs)
const lifecycle$ = new BehaviorSubject<ProjectState>("initializing")

const settings$ = projectSettings$.asObservable()
Expand Down Expand Up @@ -144,7 +144,7 @@ export async function loadProjectOpfs(args: { inlangFolderPath: string }): Promi
},
subscribe: () => projectSettings$.subscribe(),
},

bundle: {
/*
search: (args: { lintRulesIds: string[], locales: LanguageTag[], bundleIds: string[], text: string }): string[] {
Expand Down
4 changes: 2 additions & 2 deletions inlang/source-code/sdk-v2/src/validatedModuleSettings.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { TSchema } from "@sinclair/typebox"
import { Value, type ValueError } from "@sinclair/typebox/value"
import type { InlangModule } from "./types/module.js"
import type { InlangPlugin } from "./types/module.js"

export const validatedModuleSettings = (args: {
settingsSchema: InlangModule["default"]["settingsSchema"]
settingsSchema: InlangPlugin["default"]["settingsSchema"]
moduleSettings: unknown
}): "isValid" | ValueError[] => {
if (args.settingsSchema && args.moduleSettings) {
Expand Down

0 comments on commit 3b842d1

Please sign in to comment.