@inlang/sdk
Advanced tools
Comparing version 2.4.0 to 2.4.1
@@ -66,7 +66,7 @@ import { loadProjectInMemory } from "./loadProjectInMemory.js"; | ||
* @example | ||
* joinPathFromProject("/project.inlang", "./local-plugins/mock-plugin.js") -> "/local-plugins/mock-plugin.js" | ||
* absolutePathFromProject("/project.inlang", "./local-plugins/mock-plugin.js") -> "/local-plugins/mock-plugin.js" | ||
* | ||
* joinPathFromProject("/website/project.inlang", "./mock-plugin.js") -> "/website/mock-plugin.js" | ||
* absolutePathFromProject("/website/project.inlang", "./mock-plugin.js") -> "/website/mock-plugin.js" | ||
*/ | ||
export declare function absolutePathFromProject(projectPath: string, path: string): string; | ||
export declare function absolutePathFromProject(projectPath: string, filePath: string): string; | ||
export declare class ResourceFileImportError extends Error { | ||
@@ -73,0 +73,0 @@ path: string; |
@@ -571,15 +571,22 @@ import { newProject } from "./newProject.js"; | ||
* @example | ||
* joinPathFromProject("/project.inlang", "./local-plugins/mock-plugin.js") -> "/local-plugins/mock-plugin.js" | ||
* absolutePathFromProject("/project.inlang", "./local-plugins/mock-plugin.js") -> "/local-plugins/mock-plugin.js" | ||
* | ||
* joinPathFromProject("/website/project.inlang", "./mock-plugin.js") -> "/website/mock-plugin.js" | ||
* absolutePathFromProject("/website/project.inlang", "./mock-plugin.js") -> "/website/mock-plugin.js" | ||
*/ | ||
export function absolutePathFromProject(projectPath, path) { | ||
// need to remove the project path from the module path for legacy reasons | ||
// "/project.inlang/local-plugins/mock-plugin.js" -> "/local-plugins/mock-plugin.js" | ||
const pathWithoutProject = projectPath | ||
.split(nodePath.sep) | ||
.slice(0, -1) | ||
.join(nodePath.sep); | ||
const resolvedPath = nodePath.resolve(pathWithoutProject, path); | ||
return resolvedPath; | ||
export function absolutePathFromProject(projectPath, filePath) { | ||
// Normalize paths for consistency across platforms | ||
const normalizedProjectPath = nodePath | ||
.normalize(projectPath) | ||
.replace(/\\/g, "/"); | ||
const normalizedFilePath = nodePath.normalize(filePath).replace(/\\/g, "/"); | ||
// Remove the last part of the project path (file name) to get the project root | ||
const projectRoot = nodePath.dirname(normalizedProjectPath); | ||
// If filePath is already absolute, return it directly | ||
if (nodePath.isAbsolute(normalizedFilePath)) { | ||
return normalizedFilePath; | ||
} | ||
// Compute absolute resolved path | ||
const resolvedPath = nodePath.resolve(projectRoot, normalizedFilePath); | ||
// Ensure final path always uses forward slashes | ||
return resolvedPath.replace(/\\/g, "/"); | ||
} | ||
@@ -586,0 +593,0 @@ export class ResourceFileImportError extends Error { |
export const ENV_VARIABLES = { | ||
PUBLIC_POSTHOG_TOKEN: "phc_m5yJZCxjOGxF8CJvP5sQ3H0d76xpnLrsmiZHduT4jDz", | ||
PUBLIC_INLANG_SDK_SENTRY_DSN: "https://c3d92d5d011122e525e9f9b368e0905d@o4504345873285120.ingest.us.sentry.io/4507903389335553", | ||
SDK_VERSION: "2.4.0", | ||
SDK_VERSION: "2.4.1", | ||
}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@inlang/sdk", | ||
"version": "2.4.0", | ||
"version": "2.4.1", | ||
"type": "module", | ||
@@ -32,4 +32,4 @@ "license": "MIT", | ||
"uuid": "^10.0.0", | ||
"@lix-js/sdk": "0.4.1", | ||
"sqlite-wasm-kysely": "0.3.0" | ||
"sqlite-wasm-kysely": "0.3.0", | ||
"@lix-js/sdk": "0.4.1" | ||
}, | ||
@@ -36,0 +36,0 @@ "devDependencies": { |
@@ -708,17 +708,29 @@ import { newProject } from "./newProject.js"; | ||
* @example | ||
* joinPathFromProject("/project.inlang", "./local-plugins/mock-plugin.js") -> "/local-plugins/mock-plugin.js" | ||
* absolutePathFromProject("/project.inlang", "./local-plugins/mock-plugin.js") -> "/local-plugins/mock-plugin.js" | ||
* | ||
* joinPathFromProject("/website/project.inlang", "./mock-plugin.js") -> "/website/mock-plugin.js" | ||
* absolutePathFromProject("/website/project.inlang", "./mock-plugin.js") -> "/website/mock-plugin.js" | ||
*/ | ||
export function absolutePathFromProject(projectPath: string, path: string) { | ||
// need to remove the project path from the module path for legacy reasons | ||
// "/project.inlang/local-plugins/mock-plugin.js" -> "/local-plugins/mock-plugin.js" | ||
const pathWithoutProject = projectPath | ||
.split(nodePath.sep) | ||
.slice(0, -1) | ||
.join(nodePath.sep); | ||
export function absolutePathFromProject( | ||
projectPath: string, | ||
filePath: string | ||
): string { | ||
// Normalize paths for consistency across platforms | ||
const normalizedProjectPath = nodePath | ||
.normalize(projectPath) | ||
.replace(/\\/g, "/"); | ||
const normalizedFilePath = nodePath.normalize(filePath).replace(/\\/g, "/"); | ||
const resolvedPath = nodePath.resolve(pathWithoutProject, path); | ||
// Remove the last part of the project path (file name) to get the project root | ||
const projectRoot = nodePath.dirname(normalizedProjectPath); | ||
return resolvedPath; | ||
// If filePath is already absolute, return it directly | ||
if (nodePath.isAbsolute(normalizedFilePath)) { | ||
return normalizedFilePath; | ||
} | ||
// Compute absolute resolved path | ||
const resolvedPath = nodePath.resolve(projectRoot, normalizedFilePath); | ||
// Ensure final path always uses forward slashes | ||
return resolvedPath.replace(/\\/g, "/"); | ||
} | ||
@@ -725,0 +737,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1018098
16929