From 87e1802edb424ac19d2877734fbe495b684b7af5 Mon Sep 17 00:00:00 2001 From: Jakub Andrysek Date: Tue, 24 Mar 2026 21:04:28 +0100 Subject: [PATCH 1/5] refactor: add validateProjectTsCfg parameter to readProjectTsconfig and update compileProjectPath calls --- packages/project/src/compiler/index.ts | 17 ++++++++++++++--- packages/tools/src/commands/lib-build.ts | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/project/src/compiler/index.ts b/packages/project/src/compiler/index.ts index d110096..8079ea5 100644 --- a/packages/project/src/compiler/index.ts +++ b/packages/project/src/compiler/index.ts @@ -59,7 +59,8 @@ function readProjectTsconfig( system: ts.System, projectPath: string, outDir: string, - logger: Logger + logger: Logger, + validateProjectTsCfg: boolean = true ): Record { const tsconfig = ts.findConfigFile("./", system.fileExists, "tsconfig.json"); if (!tsconfig) { @@ -73,7 +74,9 @@ function readProjectTsconfig( } configJsonFile.config.compilerOptions ??= {}; - validateProjectTsconfig(configJsonFile.config.compilerOptions, outDir); + if (validateProjectTsCfg) { + validateProjectTsconfig(configJsonFile.config.compilerOptions, outDir); + } return configJsonFile.config; } @@ -159,6 +162,7 @@ export async function compileProjectTsconfig( * @param projectPath Path to the project directory (should contain tsconfig.json) * @param logger Logger for outputting messages and diagnostics * @param noCheck If true, compiles without type checking, emitting JavaScript even if there are type errors + * @param validateProjectTsCfg If true, validates the project's tsconfig.json * @param tsLibsPath Optional path to TypeScript libraries (lib.d.ts, etc.), defaults to the directory of the installed TypeScript package * @returns Promise that resolves to true if compilation succeeded */ @@ -167,13 +171,20 @@ export async function compileProjectPath( projectPath: string, logger: Logger, noCheck: boolean = false, + validateProjectTsCfg: boolean = true, tsLibsPath: string = path.dirname( fileURLToPath(import.meta.resolve?.("typescript") ?? "typescript") ) ): Promise { const outDir = "build"; const system = tsvfs.createSystem(fs, projectPath); - const configJson = readProjectTsconfig(system, projectPath, outDir, logger); + const configJson = readProjectTsconfig( + system, + projectPath, + outDir, + logger, + validateProjectTsCfg + ); return await compileProjectTsconfig(configJson, system, logger, noCheck, tsLibsPath); } diff --git a/packages/tools/src/commands/lib-build.ts b/packages/tools/src/commands/lib-build.ts index cdd3707..2a86a28 100644 --- a/packages/tools/src/commands/lib-build.ts +++ b/packages/tools/src/commands/lib-build.ts @@ -6,7 +6,7 @@ import { logger } from "../logger.js"; const cmd = new Command("List libraries from project package.json", { action: async (options: Record) => { const noCheck = options["no-check"] as boolean; - if (await compileProjectPath(fs, process.cwd(), logger, noCheck)) { + if (await compileProjectPath(fs, process.cwd(), logger, noCheck, false)) { logger.info("Compiled successfully\n"); } else { logger.error("Compilation failed\n"); From 6c094ffa44a6c63ce9508c549ecc75c1f712bfba Mon Sep 17 00:00:00 2001 From: Jakub Andrysek Date: Tue, 24 Mar 2026 21:52:15 +0100 Subject: [PATCH 2/5] refactor: update TypeScript compiler test to pass a boolean flag for logging --- test/project/compiler.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/project/compiler.test.ts b/test/project/compiler.test.ts index d3f65cf..f980380 100644 --- a/test/project/compiler.test.ts +++ b/test/project/compiler.test.ts @@ -87,6 +87,7 @@ describe("TypeScript Compiler", () => { testData.inputPath, logger, undefined, + true, testData.tsLibsPath ); From 38045cce70f02aa6080c06995ef318f64e632f97 Mon Sep 17 00:00:00 2001 From: Jakub Andrysek Date: Tue, 24 Mar 2026 23:57:55 +0100 Subject: [PATCH 3/5] refactor: add support for development registry in library installation command --- .husky/pre-commit | 1 + packages/project/src/registry.ts | 7 ++++++- packages/tools/src/commands/lib-install.ts | 14 ++++++++++---- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 46d9e90..b9b7350 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,2 +1,3 @@ npx pnpm lint npx pnpm format:check +npx pnpm test diff --git a/packages/project/src/registry.ts b/packages/project/src/registry.ts index 7467ba5..37409bf 100644 --- a/packages/project/src/registry.ts +++ b/packages/project/src/registry.ts @@ -9,6 +9,7 @@ import * as z from "zod"; import { getRequestJson, JaculusRequestError, Logger, RequestFunction } from "@jaculus/common"; export const DefaultRegistryUrl = ["https://registry.jaculus.org"]; +export const DevRegistryUrl = "http://127.0.0.1:3737"; /** * @@ -78,10 +79,14 @@ export class Registry { constructor( registryUri: string[] | undefined, public getRequest: RequestFunction, - logger: Logger + logger: Logger, + devRegistry?: boolean ) { this.registryUri = registryUri || DefaultRegistryUrl; this.logger = logger; + if (devRegistry) { + this.registryUri.unshift(DevRegistryUrl); + } } // return list of objects with id and description of all packages in the registry, excluding templates diff --git a/packages/tools/src/commands/lib-install.ts b/packages/tools/src/commands/lib-install.ts index 5e355d8..a859b96 100644 --- a/packages/tools/src/commands/lib-install.ts +++ b/packages/tools/src/commands/lib-install.ts @@ -1,20 +1,21 @@ -import { Arg, Command } from "./lib/command.js"; +import { Arg, Command, Opt } from "./lib/command.js"; import fs from "fs"; import { uriRequest } from "../util.js"; import path from "path"; import { loadPackageJson, splitLibraryNameVersion } from "@jaculus/project/package"; import { Project } from "@jaculus/project"; -import { Registry } from "@jaculus/project/registry"; +import { DevRegistryUrl, Registry } from "@jaculus/project/registry"; import { logger } from "../logger.js"; const cmd = new Command("Install Jaculus libraries base on project's package.json", { - action: async (_options: Record, args: Record) => { + action: async (options: Record, args: Record) => { const libraryName = args["library"] as string; + const devRegistry = options["dev-registry"] as boolean; const projectPath = process.cwd(); const pkg = await loadPackageJson(fs, path.join(projectPath, "package.json")); const project = new Project(fs, projectPath, logger); - const registry = new Registry(pkg.jaculus?.registry, uriRequest, logger); + const registry = new Registry(pkg.jaculus?.registry, uriRequest, logger, devRegistry); const { name, version } = splitLibraryNameVersion(libraryName); if (name && version) { @@ -32,6 +33,11 @@ const cmd = new Command("Install Jaculus libraries base on project's package.jso { defaultValue: "" } ), ], + options: { + "dev-registry": new Opt(`Try to use ${DevRegistryUrl} for library installation`, { + isFlag: true, + }), + }, chainable: true, }); From 7387031a2ee5cced4035e7be78197a8cf47e4e46 Mon Sep 17 00:00:00 2001 From: Jakub Andrysek Date: Wed, 25 Mar 2026 10:09:57 +0100 Subject: [PATCH 4/5] refactor: update devRegistry handling to accept a URI instead of a boolean flag --- packages/project/src/registry.ts | 5 ++--- packages/tools/src/commands/lib-install.ts | 11 +++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/project/src/registry.ts b/packages/project/src/registry.ts index 37409bf..339d586 100644 --- a/packages/project/src/registry.ts +++ b/packages/project/src/registry.ts @@ -9,7 +9,6 @@ import * as z from "zod"; import { getRequestJson, JaculusRequestError, Logger, RequestFunction } from "@jaculus/common"; export const DefaultRegistryUrl = ["https://registry.jaculus.org"]; -export const DevRegistryUrl = "http://127.0.0.1:3737"; /** * @@ -80,12 +79,12 @@ export class Registry { registryUri: string[] | undefined, public getRequest: RequestFunction, logger: Logger, - devRegistry?: boolean + devRegistry?: string ) { this.registryUri = registryUri || DefaultRegistryUrl; this.logger = logger; if (devRegistry) { - this.registryUri.unshift(DevRegistryUrl); + this.registryUri.unshift(devRegistry); } } diff --git a/packages/tools/src/commands/lib-install.ts b/packages/tools/src/commands/lib-install.ts index a859b96..b6b40cb 100644 --- a/packages/tools/src/commands/lib-install.ts +++ b/packages/tools/src/commands/lib-install.ts @@ -4,17 +4,20 @@ import { uriRequest } from "../util.js"; import path from "path"; import { loadPackageJson, splitLibraryNameVersion } from "@jaculus/project/package"; import { Project } from "@jaculus/project"; -import { DevRegistryUrl, Registry } from "@jaculus/project/registry"; +import { Registry } from "@jaculus/project/registry"; import { logger } from "../logger.js"; const cmd = new Command("Install Jaculus libraries base on project's package.json", { action: async (options: Record, args: Record) => { const libraryName = args["library"] as string; - const devRegistry = options["dev-registry"] as boolean; + const devRegistry = options["dev-registry"] as string | undefined; const projectPath = process.cwd(); const pkg = await loadPackageJson(fs, path.join(projectPath, "package.json")); const project = new Project(fs, projectPath, logger); + + console.log("Using registry:", devRegistry); + const registry = new Registry(pkg.jaculus?.registry, uriRequest, logger, devRegistry); const { name, version } = splitLibraryNameVersion(libraryName); @@ -34,8 +37,8 @@ const cmd = new Command("Install Jaculus libraries base on project's package.jso ), ], options: { - "dev-registry": new Opt(`Try to use ${DevRegistryUrl} for library installation`, { - isFlag: true, + "dev-registry": new Opt(`Force to use development registry (provided URI)`, { + required: false, }), }, chainable: true, From 016ac36e53901cd4cc1eab2e044dbbf46f3a772d Mon Sep 17 00:00:00 2001 From: Jakub Andrysek Date: Wed, 25 Mar 2026 10:45:30 +0100 Subject: [PATCH 5/5] refactor: rename devRegistry to userRegistry for clarity in registry handling --- packages/project/src/registry.ts | 6 +++--- packages/tools/src/commands/lib-install.ts | 15 ++++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/project/src/registry.ts b/packages/project/src/registry.ts index 339d586..d5c0d32 100644 --- a/packages/project/src/registry.ts +++ b/packages/project/src/registry.ts @@ -79,12 +79,12 @@ export class Registry { registryUri: string[] | undefined, public getRequest: RequestFunction, logger: Logger, - devRegistry?: string + userRegistry?: string ) { this.registryUri = registryUri || DefaultRegistryUrl; this.logger = logger; - if (devRegistry) { - this.registryUri.unshift(devRegistry); + if (userRegistry) { + this.registryUri.unshift(userRegistry); } } diff --git a/packages/tools/src/commands/lib-install.ts b/packages/tools/src/commands/lib-install.ts index b6b40cb..1dc8909 100644 --- a/packages/tools/src/commands/lib-install.ts +++ b/packages/tools/src/commands/lib-install.ts @@ -10,15 +10,13 @@ import { logger } from "../logger.js"; const cmd = new Command("Install Jaculus libraries base on project's package.json", { action: async (options: Record, args: Record) => { const libraryName = args["library"] as string; - const devRegistry = options["dev-registry"] as string | undefined; + const userRegistry = options["user-registry"] as string | undefined; const projectPath = process.cwd(); const pkg = await loadPackageJson(fs, path.join(projectPath, "package.json")); const project = new Project(fs, projectPath, logger); - console.log("Using registry:", devRegistry); - - const registry = new Registry(pkg.jaculus?.registry, uriRequest, logger, devRegistry); + const registry = new Registry(pkg.jaculus?.registry, uriRequest, logger, userRegistry); const { name, version } = splitLibraryNameVersion(libraryName); if (name && version) { @@ -37,9 +35,12 @@ const cmd = new Command("Install Jaculus libraries base on project's package.jso ), ], options: { - "dev-registry": new Opt(`Force to use development registry (provided URI)`, { - required: false, - }), + "user-registry": new Opt( + `Preferred registry URI. If a package exists in multiple registries, this one is used first.`, + { + required: false, + } + ), }, chainable: true, });