-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved base_addon folder to fetch from github
- Loading branch information
Showing
8 changed files
with
115 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,17 @@ | ||
#!/usr/bin/env deno run --allow-read --allow-write --unstable | ||
import { getLibraryDirectory, path } from "./deps.ts" | ||
import { parseArgs } from "jsr:@std/[email protected]"; | ||
import { Colors } from "./deps.ts"; | ||
import { buildAddon } from "./cli/main.ts"; | ||
import type { AddonType } from "./lib/common.ts"; | ||
|
||
//const __dirname: string = getLibraryDirectory(); | ||
|
||
let __dirname: string //= path.dirname(path.fromFileUrl(import.meta.url)); | ||
|
||
if (import.meta.url.startsWith('file:')) { | ||
__dirname = path.fromFileUrl(import.meta.url); | ||
} else { | ||
// Обработка https: URL | ||
__dirname = new URL(import.meta.url).pathname; | ||
} | ||
|
||
const VERSION = '1.1.11' | ||
const VERSION = '1.1.12' | ||
|
||
type LostCommand = 'none' | 'help' | 'version' | 'build' | 'create' | 'serve'; | ||
|
||
async function main() { | ||
const { _, ...flags } = parseArgs(Deno.args, { | ||
boolean: ["plugin"], | ||
alias: {p: "plugin"}, | ||
boolean: ["plugin", "local-base"], | ||
alias: {p: "plugin", l: "local-base"}, | ||
"--": true, | ||
}); | ||
|
||
|
@@ -48,10 +36,20 @@ async function main() { | |
} | ||
break; | ||
case 'build': | ||
await buildAddon({ serve: false, LIB_PATH: __dirname }); | ||
if (!flags['local-base']) { | ||
await buildAddon({ serve: false, localBase: false}); | ||
} | ||
if (flags['local-base']) { | ||
await buildAddon({ serve: false, localBase: true }); | ||
} | ||
break; | ||
case 'serve': | ||
await buildAddon({ serve: true, LIB_PATH: __dirname }); | ||
if (!flags['local-base']) { | ||
await buildAddon({ serve: true, localBase: false}); | ||
} | ||
if (flags['local-base']) { | ||
await buildAddon({ serve: true, localBase: true }); | ||
} | ||
break; | ||
case 'none': | ||
console.error('❌', Colors.red(Colors.bold(`Unknown command:`)), Colors.italic(command)); | ||
|
@@ -97,5 +95,6 @@ function printHelp() { | |
console.log(' ⚙️', Colors.gray(' --plugin, -p'), ' Creates a bare-bones for "plugin" addon type.'); | ||
|
||
console.log(` ${Colors.yellow('build')}`); | ||
console.log(' ⚙️', Colors.gray(' --local-base, -c'), ' Builds addon with local addon base.'); | ||
console.log(` ${Colors.yellow('serve')}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,2 @@ | ||
import * as path from 'jsr:@std/[email protected]'; | ||
export * as Colors from 'jsr:@std/[email protected]/colors'; | ||
|
||
export function getLibraryDirectory(): string { | ||
// Получаем URL текущего модуля | ||
const moduleUrl = new URL(import.meta.url); | ||
|
||
console.log("Debug: Module URL:", moduleUrl.toString()); | ||
|
||
if (moduleUrl.protocol === "file:") { | ||
// Если это файловая система, преобразуем URL в путь | ||
const modulePath = path.fromFileUrl(moduleUrl); | ||
console.log("Debug: File path:", modulePath); | ||
return path.dirname(modulePath); | ||
} else if (moduleUrl.protocol === "https:") { | ||
// Если это HTTPS URL (например, при использовании через JSR) | ||
const denoDir = Deno.env.get("DENO_DIR") || getDefaultDenoDir(); | ||
console.log("Debug: Deno Dir:", denoDir); | ||
|
||
// Извлекаем относительный путь из URL | ||
const relativePath = moduleUrl.pathname.split("/").slice(1).join("/"); | ||
console.log("Debug: Relative path:", relativePath); | ||
|
||
// Формируем путь к кэшированной версии пакета | ||
const cachedPath = path.join(denoDir, "deps", "https", "jsr.io", relativePath); | ||
console.log("Debug: Cached path:", cachedPath); | ||
|
||
return path.dirname(cachedPath); | ||
} | ||
|
||
console.error("Error: Unable to determine library directory"); | ||
console.error("Module URL:", moduleUrl.toString()); | ||
console.error("DENO_DIR:", Deno.env.get("DENO_DIR")); | ||
console.error("Default Deno Dir:", getDefaultDenoDir()); | ||
|
||
throw new Error("Не удалось определить директорию библиотеки"); | ||
} | ||
|
||
function getDefaultDenoDir(): string { | ||
switch (Deno.build.os) { | ||
case "windows": | ||
return path.join(Deno.env.get("LOCALAPPDATA") || "", "deno"); | ||
case "darwin": | ||
return path.join(Deno.env.get("HOME") || "", "Library", "Caches", "deno"); | ||
default: // linux and other unix systems | ||
return path.join(Deno.env.get("XDG_CACHE_HOME") || path.join(Deno.env.get("HOME") || "", ".cache"), "deno"); | ||
} | ||
} | ||
|
||
export { path }; | ||
export * as path from 'jsr:@std/[email protected]'; | ||
export * as Colors from 'jsr:@std/[email protected]/colors'; |