diff --git a/deno.json b/deno.json index 0748d36..10ac4cc 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,7 @@ { + "importMap": "importMap.json", "tasks": { - "install": "deno install -A --reload -f -n dash_compiler ./mod.ts", + "install": "deno install -A -f -n dash_compiler ./mod.ts", "install:full": "deno install -A --reload -f -n dash_compiler ./mod.ts", "build": "deno task build:apple-x86 && deno task build:apple-aarch64 && deno task build:windows-x86", "build:apple-x86": "deno compile --target x86_64-apple-darwin --output ./executables/dash-apple-x64 -A ./mod.ts", diff --git a/importMap.json b/importMap.json new file mode 100644 index 0000000..4750ad3 --- /dev/null +++ b/importMap.json @@ -0,0 +1,6 @@ +{ + "imports": { + "dash-compiler": "../dash-compiler/dist/dash-compiler.bundled.es.js", + "mc-project-core": "npm:mc-project-core" + } +} diff --git a/src/CLI.ts b/src/CLI.ts index 1124fc7..e270f80 100644 --- a/src/CLI.ts +++ b/src/CLI.ts @@ -18,13 +18,14 @@ export class CLI { const outFs = out ? new DenoFileSystem(out) : undefined const dash = new Dash(this.fs, outFs, { - config: './config.json', + config: path.join(Deno.cwd(), './config.json'), compilerConfig: compilerConfig ? path.join(Deno.cwd(), compilerConfig) : undefined, packType: new PackTypeImpl(undefined), fileType: new FileTypeImpl(undefined, isMatch), mode, + verbose: true, requestJsonData: (dataPath: string) => fetch( diff --git a/src/FileSystem.ts b/src/FileSystem.ts index bfe998a..cb4abdd 100644 --- a/src/FileSystem.ts +++ b/src/FileSystem.ts @@ -20,7 +20,9 @@ export class DenoFileSystem extends FileSystem { return new File([fileData], path.basename(filePath)) } async writeFile(filePath: string, content: string | Uint8Array) { - await Deno.mkdir(path.dirname(this.resolvePath(filePath)), { + const dirPath = path.dirname(this.resolvePath(filePath)) + + await Deno.mkdir(dirPath, { recursive: true, }) @@ -47,8 +49,20 @@ export class DenoFileSystem extends FileSystem { return entries } - async mkdir(path: string): Promise { - await Deno.mkdir(this.resolvePath(path), { recursive: true }) + async copyFile(from: string, to: string, destFs = this) { + // Fallback to slow path if destination fs !== this + if (destFs !== this) return super.copyFile(from, to, destFs) + + const transformedTo = this.resolvePath(to) + const dirPath = path.dirname(transformedTo) + await Deno.mkdir(dirPath, { + recursive: true, + }) + + await Deno.copyFile(this.resolvePath(from), transformedTo) + } + async mkdir(dirPath: string): Promise { + await Deno.mkdir(this.resolvePath(dirPath), { recursive: true }) } async lastModified(filePath: string) { return ( diff --git a/src/deps.ts b/src/deps.ts index 3dc31ee..598352b 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -4,19 +4,20 @@ export { FileType, PackType, ProjectConfig, -} from 'https://cdn.skypack.dev/mc-project-core?dts' -export { isMatch } from 'https://raw.githubusercontent.com/bridge-core/common-utils/main/src/glob/isMatch.ts' -// @deno-types="https://cdn.skypack.dev/-/dash-compiler@v0.9.26-rtDMyl7gGAKD0gZPrwEG/dist=es2019,mode=types/dist/main.d.ts" + type IFileType, +} from 'https://esm.sh/mc-project-core@0.3.21' +export { isMatch } from 'https://esm.sh/bridge-common-utils@0.3.3' +// @deno-types="https://esm.sh/dash-compiler@0.10.4" export { Dash, FileSystem, initRuntimes, } from 'https://raw.githubusercontent.com/bridge-core/dash-compiler/main/dist/dash-compiler.bundled.es.js' -export { default as json5 } from 'https://cdn.skypack.dev/json5' -export { debounce } from 'https://cdn.skypack.dev/lodash?dts' +export { default as json5 } from 'https://esm.sh/json5@2.2.1' +export { debounce } from 'https://deno.land/std@0.156.0/async/mod.ts?s=debounce' import { default as dashPackageJson } from 'https://raw.githubusercontent.com/bridge-core/dash-compiler/main/package.json' assert { type: 'json' } let swcVersion = dashPackageJson.dependencies['@swc/wasm-web'] -if(swcVersion.startsWith('^')) swcVersion = swcVersion.slice(1) +if (swcVersion.startsWith('^')) swcVersion = swcVersion.slice(1) -export {swcVersion} +export { swcVersion }