Skip to content

Commit

Permalink
Towards getting a compiler script running
Browse files Browse the repository at this point in the history
  • Loading branch information
DamianReeves committed May 31, 2024
1 parent 1f9db2e commit f3978d0
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .moon/tasks/rust.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
fileGroups:
elm-sources:
- 'src/**/*.elm'
sources:
- 'apps/cli/src/**/*'
- 'crates/*/src/**/*'
Expand All @@ -11,12 +9,14 @@ fileGroups:
- 'crates/*/tests/**/*'

tasks:
cargo-build:
cargo-build-base:
command: 'cargo'
args:
- "build"
inputs:
- '@globs(sources)'
cargo-build:
extends: 'cargo-build-base'
cargo-check:
command: 'cargo check --workspace'
inputs:
Expand Down
2 changes: 2 additions & 0 deletions apps/cli/config/morphir.default.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[extensions]
directories = ["${WorkspaceRoot}/.${CliName}/extensions/"]
15 changes: 14 additions & 1 deletion apps/js-cli/moon.yml
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
language: typescript
language: typescript
platform: bun

tasks:
type-check-cjs:
#TODO: Remove no-op when typescript config is added
command: no-op
type-check-esm:
#TODO: Remove no-op when typescript config is added
command: no-op
fetch-quickjs:
command: 'bun run fetch-quickjs'
local: true
platform: system
13 changes: 11 additions & 2 deletions apps/js-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
{
"name": "@finos/morphir-cli",
"version": "0.0.0"
"name": "@finos/morphir-js-cli",
"version": "0.0.0",
"scripts": {
"fetch-quickjs": "bun scripts/fetch-quickjs.ts"
},
"devDependencies": {
"@terascope/fetch-github-release": "0.8.10",
"@tsconfig/node18": "^18.2.4",
"typescript": "5.4.5"
},
"dependencies": {}
}
38 changes: 38 additions & 0 deletions apps/js-cli/scripts/fetch-quickjs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { downloadRelease } from "@terascope/fetch-github-release";
import os from "node:os";

const user = "quickjs-ng";
const repo = "quickjs";
const outputDir = "out/quickjs/";
const leaveZipped = false;
const disableLogging = false;

function filterRelease(release) {
return release.prerelease === false;
}

function filterAsset(asset) {
const platform = os.platform();
if (asset.name.includes("wasi")) return true;
if (asset.name.includes(platform)) return true;
return false;
}

async function fetch() {
try {
await downloadRelease(
user,
repo,
outputDir,
filterRelease,
filterAsset,
leaveZipped,
disableLogging
);
console.log("QuickJS downloaded successfully");
} catch (error) {
console.error("Error downloading QuickJS", error);
}
}

await fetch();
8 changes: 3 additions & 5 deletions apps/js-cli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"extends": "../../tsconfig.options.json",
"include": [
"**/*"
],
"extends": "@tsconfig/node18/tsconfig.json",
"include": ["src/**/*"],
"references": []
}
}
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions moon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ tasks:
outputs:
- '.out/elm-out/finos/morphir'
check-elm-docs:
platform: 'bun'
command: 'elm make --docs=./.out/elm-out/finos/morphir/docs.json'
inputs:
- '@globs(elm-sources)'
Expand Down
23 changes: 22 additions & 1 deletion packages/morphir-elm-compiler/moon.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
language: typescript
type: application
platform: bun

fileGroups:
vite:
- "vite.config.ts"
- "**/*.ts"
- "**/*.tsx"
- "src/**/*.js"
- "src/**/*.jsx"
- "src/**/*.elm"
elmSources:
- "src"
tags:
- "elm"
- "elm"

tasks:
bundle:
command: "bunx --bun vite build --ssr"
inputs:
- '@globs(vite)'
outputs:
- "dist"
build:
deps:
- target: "~:bundle"
7 changes: 7 additions & 0 deletions packages/morphir-elm-compiler/src/compiler-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import CLI from "./elm/Morphir/Elm/CLI.elm";
const worker = CLI.init();

export function compileSource(source: string) {
console.log("Compiling source: ", source);
console.log("Worker: ", worker);
}
1 change: 1 addition & 0 deletions packages/morphir-elm-compiler/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default defineConfig(
input: {
morphir: resolve(__dirname, "src/morphir.ts"),
lib: resolve(__dirname, "src/lib.ts"),
"compiler-api": resolve(__dirname, "src/compiler-api.ts"),
},
},
},
Expand Down

0 comments on commit f3978d0

Please sign in to comment.