Skip to content

Commit

Permalink
Upgrade to Deno 2 #17 from bridge-core/next/Deno2Upgrade
Browse files Browse the repository at this point in the history
Upgrade to Deno 2
  • Loading branch information
outercloudstudio authored Nov 11, 2024
2 parents c797fa0 + d97488e commit 14f11e7
Show file tree
Hide file tree
Showing 11 changed files with 224 additions and 153 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,21 @@ jobs:
with:
persist-credentials: false
- name: Install Deno 🦕
uses: denoland/setup-deno@v1
uses: denoland/setup-deno@v2
with:
deno-version: v1.x
deno-version: v2.x
- name: 'Build Executable'
run: deno task build
- name: Upload Executables as Artifacts
if: github.ref_type == 'branch'
uses: actions/upload-artifact@v4
with:
name: ${{ format('dash-{0}-{1}-{2}', github.run_id, github.run_number, github.run_attempt) }}
path: 'executables/*'
name: ${{ format('dash-{0}-{1}-{2}', github.run_id, github.run_number, github.run_attempt) }}
path: 'executables/*'
- name: Upload Executables as Release
if: github.ref_type == 'tag'
uses: AButler/upload-release-assets@v3.0
with:
files: 'executables/*'
release-tag: ${{ github.ref_name }}
repo-token: ${{ secrets.GITHUB_TOKEN }}

files: 'executables/*'
release-tag: ${{ github.ref_name }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"deno.enable": true
"deno.enable": true,
"deno.lint": true
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Releases page](https://github.com/bridge-core/deno-dash-compiler/releases).
Open your terminal and run:

```shell
deno install -A -f --reload -n dash_compiler https://raw.githubusercontent.com/bridge-core/deno-dash-compiler/main/mod.ts
deno install -A --global -f --reload -n dash_compiler https://raw.githubusercontent.com/bridge-core/deno-dash-compiler/main/mod.ts
```

#### Via Deno's Task Runner
Expand Down
36 changes: 20 additions & 16 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
{
"importMap": "importMap.json",
"imports": {
"@bridge-editor/common-utils": "npm:@bridge-editor/common-utils@^0.3.3",
"@bridge-editor/mc-project-core": "npm:@bridge-editor/mc-project-core@^0.4.0",
"@std/async": "jsr:@std/async@^1.0.7",
"@std/path": "jsr:@std/path@^1.0.7",
"@std/semver": "jsr:@std/semver@^1.0.3",
"dash-compiler-local": "../dash-compiler/dist/dash-compiler.bundled.es.js"
},
"version": "1.0.0",
"tasks": {
"install": "deno install -A -f -n dash_compiler ./mod.ts",
"install:full": "deno install -A --reload -f -n dash_compiler ./mod.ts",
"install": "deno install --global -A -f -n dash_compiler ./mod.ts",
"install:full": "deno install --global -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",
"build:apple-aarch64": "deno compile --target aarch64-apple-darwin --output ./executables/dash-apple-aarch64 -A ./mod.ts",
"build:windows-x86": "deno compile --target x86_64-pc-windows-msvc --output ./executables/dash.exe -A ./mod.ts"
},
"fmt": {
"files": {
"include": ["*.json", "*.ts", "*.tsx", "src/"]
},
"options": {
"useTabs": true,
"lineWidth": 80,
"indentWidth": 4,
"singleQuote": true
}
"include": ["*.json", "*.ts", "*.tsx", "src/"],
"exclude": ["dist/", ".vscode/", ".github/", "README.md", "deno.lock"],
"useTabs": true,
"lineWidth": 80,
"semiColons": false,
"indentWidth": 4,
"singleQuote": true
},
"lint": {
"files": {
"include": ["*.ts", "src/"],
"exclude": ["dist/", ".vscode/", ".github/"]
},
"include": ["*.ts", "src/"],
"exclude": ["dist/", ".vscode/", ".github/"],
"rules": {
"tags": ["recommended"],
"include": ["ban-untagged-todo"],
Expand Down
86 changes: 86 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions importMap.json

This file was deleted.

14 changes: 3 additions & 11 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
// deno-lint-ignore-file no-explicit-any
import { CLI } from './src/CLI.ts'
import yargs from 'https://deno.land/x/yargs@v17.5.1-deno/deno.ts'
import { parse as semverParse, compare as semverCompare } from "jsr:@std/semver";
import yargs from 'https://deno.land/x/yargs@v17.7.2-deno/deno.ts'
import { parse as semverParse, compare as semverCompare } from 'jsr:@std/semver'
import { comMojangFolder } from './src/comMojangFolder.ts'
import { initRuntimes, swcVersion } from './src/deps.ts'

// @ts-ignore: Required by some of our dependencies
window.global = window
// @ts-ignore: Required by some of our dependencies
window.process = {
cwd: () => '',
env: {},
}

type YargsInstance = ReturnType<typeof yargs>
const CURRENT_VERSION = `0.4.7`
const CURRENT_VERSION = `1.0.0`

async function fetchLatestVersion(): Promise<string | null> {
try {
Expand Down
8 changes: 4 additions & 4 deletions src/FileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class DenoFileSystem extends FileSystem {
await Deno.writeTextFile(this.resolvePath(filePath), content)
else return Deno.writeFile(this.resolvePath(filePath), content)
}
async readJson(filePath: string) {
override async readJson(filePath: string) {
const fileContent = await Deno.readTextFile(this.resolvePath(filePath))
return json5.parse(fileContent)
}
Expand All @@ -42,14 +42,14 @@ export class DenoFileSystem extends FileSystem {

for await (const entry of Deno.readDir(this.resolvePath(path))) {
entries.push(<const>{
name: entry.name,
kind: entry.isDirectory ? 'directory' : 'file',
name: entry.name,
kind: entry.isDirectory ? 'directory' : 'file',
})
}

return entries
}
async copyFile(from: string, to: string, destFs = this) {
override 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)

Expand Down
4 changes: 2 additions & 2 deletions src/McProjectCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ export class FileTypeImpl extends FileType<void> {
).then((resp) => resp.json())
}

addPluginFileType(fileDef: IFileType) {
override addPluginFileType(fileDef: IFileType) {
this._cache.clear()

return super.addPluginFileType(fileDef)
}

get(filePath?: string, searchFileType?: string, checkFileExtension = true) {
override get(filePath?: string, searchFileType?: string, checkFileExtension = true) {
if (!filePath || !checkFileExtension || searchFileType !== undefined) {
return super.get(filePath, searchFileType, checkFileExtension)
}
Expand Down
Loading

0 comments on commit 14f11e7

Please sign in to comment.