diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index ed742a2..3d31965 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -3,10 +3,10 @@ name: build
on:
push:
branches:
- - master
+ - main
pull_request:
branches:
- - master
+ - main
jobs:
build:
@@ -22,12 +22,11 @@ jobs:
- uses: Swatinem/rust-cache@v2
with:
- save-if: ${{ github.ref == 'refs/heads/master' }}
+ save-if: ${{ github.ref == 'refs/heads/main' }}
- run: npm ci
- run: npm run build --workspace @project-gauntlet/api
- - run: npm run build --workspace @project-gauntlet/tools
- run: npm run build --workspace @project-gauntlet/deno
- run: npm run build --workspace @project-gauntlet/react
diff --git a/.idea-run/build-tools.run.xml b/.idea-run/build-tools.run.xml
deleted file mode 100644
index c316f2b..0000000
--- a/.idea-run/build-tools.run.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/js/tools/.gitignore b/js/tools/.gitignore
deleted file mode 100644
index 1521c8b..0000000
--- a/js/tools/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-dist
diff --git a/js/tools/bin/main.js b/js/tools/bin/main.js
deleted file mode 100755
index b939f11..0000000
--- a/js/tools/bin/main.js
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/usr/bin/env node
-import '../dist/main.js'
diff --git a/js/tools/package.json b/js/tools/package.json
deleted file mode 100644
index 7258491..0000000
--- a/js/tools/package.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "name": "@project-gauntlet/tools",
- "version": "0.1.0",
- "scripts": {
- "build": "tsc --noEmit && rollup --config rollup.config.ts --configPlugin typescript"
- },
- "type": "module",
- "bin": {
- "gauntlet": "./bin/main.js"
- },
- "dependencies": {
- "@rollup/plugin-commonjs": "^25.0.7",
- "@rollup/plugin-node-resolve": "^15.2.3",
- "@rollup/plugin-typescript": "^11.1.5",
- "chalk": "^5.3.0",
- "commander": "^11.1.0",
- "dbus-ts": "^0.0.7",
- "rollup": "^4.3.0",
- "toml": "^3.0.0",
- "zod": "^3.22.4"
- },
- "devDependencies": {
- "@rollup/plugin-json": "^6.1.0",
- "@types/node": "^18.17.1",
- "tslib": "^2.6.2",
- "typescript": "^5.2.2"
- }
-}
diff --git a/js/tools/rollup.config.ts b/js/tools/rollup.config.ts
deleted file mode 100644
index 9599846..0000000
--- a/js/tools/rollup.config.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import typescript from '@rollup/plugin-typescript';
-import json from '@rollup/plugin-json';
-import { defineConfig } from "rollup";
-
-export default defineConfig({
- input: [
- 'src/main.ts'
- ],
- output: [
- {
- dir: 'dist',
- format: 'esm',
- sourcemap: 'inline'
- }
- ],
- plugins: [
- typescript({
- tsconfig: './tsconfig.json',
- }),
- json()
- ]
-})
diff --git a/js/tools/src/build.ts b/js/tools/src/build.ts
deleted file mode 100644
index 3524d5b..0000000
--- a/js/tools/src/build.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import { rollup, RollupBuild } from "rollup";
-import { parseManifest, readManifest, rollupInputOptions, rollupOutputOptions, writeDistManifest } from "./config";
-
-
-export async function build() {
- const manifestText = readManifest();
-
- const manifest = parseManifest(manifestText);
-
- let rollupBuild: RollupBuild | undefined;
- let buildFailed = false;
- try {
- rollupBuild = await rollup(rollupInputOptions(manifest));
-
- await rollupBuild.write(rollupOutputOptions());
-
- writeDistManifest(manifestText)
- } catch (error) {
- buildFailed = true;
- console.error(error);
- }
-
- if (rollupBuild) {
- await rollupBuild.close();
- }
-
- process.exit(buildFailed ? 1 : 0);
-}
-
diff --git a/js/tools/src/config.ts b/js/tools/src/config.ts
deleted file mode 100644
index 8732a4f..0000000
--- a/js/tools/src/config.ts
+++ /dev/null
@@ -1,96 +0,0 @@
-import { z } from "zod";
-import { parse as parseToml } from "toml";
-import { InputOptions, OutputOptions } from "rollup";
-import nodeResolve from "@rollup/plugin-node-resolve";
-import commonjs from "@rollup/plugin-commonjs";
-import typescript from "@rollup/plugin-typescript";
-import { readFileSync, writeFileSync } from "node:fs";
-
-const Manifest = z.strictObject({
- gauntlet: z.strictObject({
- name: z.string()
- }),
- entrypoint: z.array(z.strictObject({
- id: z.string(),
- name: z.string(),
- path: z.string(),
- type: z.enum(["command", "view"])
- })),
- permissions: z.strictObject({
- environment: z.array(z.string()).default([]),
- high_resolution_time: z.boolean().default(false),
- network: z.array(z.string()).default([]),
- ffi: z.array(z.string()).default([]),
- fs_read_access: z.array(z.string()).default([]),
- fs_write_access: z.array(z.string()).default([]),
- run_subprocess: z.array(z.string()).default([]),
- system: z.array(z.string()).default([]),
- }).default({}),
- supported_system: z.array(z.discriminatedUnion("os", [
- z.strictObject({ os: z.literal("linux") })
- ])).default([]),
-});
-
-type Manifest = z.infer;
-
-export function readManifest(): string {
- return readFileSync("./gauntlet.toml", "utf8")
-}
-
-export function writeDistManifest(manifestText: string) {
- writeFileSync("dist/gauntlet.toml", manifestText)
-}
-
-export function parseManifest(manifestText: string) {
- const manifest = Manifest.parse(parseToml(manifestText));
-
- const permEnvExist = manifest.permissions.environment.length !== 0;
- const permFfiExist = manifest.permissions.ffi.length !== 0;
- const permFsReadExist = manifest.permissions.fs_read_access.length !== 0;
- const permFsWriteExist = manifest.permissions.fs_write_access.length !== 0;
- const permRunExist = manifest.permissions.run_subprocess.length !== 0;
- const permSystemExist = manifest.permissions.system.length !== 0;
-
- if (permEnvExist || permFfiExist || permFsReadExist || permFsWriteExist || permRunExist || permSystemExist) {
- if (manifest.supported_system.length === 0) {
- throw new Error('Permissions "environment", "ffi", "fs_read_access", "fs_write_access", "run_subprocess", "system" require you to specify "supported_system"')
- }
- }
-
- return manifest
-}
-
-
-export function rollupInputOptions(manifest: Manifest): InputOptions {
- const mapInputs = manifest.entrypoint.map(entrypoint => [entrypoint.id, entrypoint.path] as const);
- const entries = new Map(mapInputs);
- const inputs = Object.fromEntries(entries);
-
- return {
- input: inputs,
- external: ["react", "react/jsx-runtime", "@project-gauntlet/api/components"],
- plugins: [
- nodeResolve(),
- commonjs(),
- typescript({
- tsconfig: './tsconfig.json',
- }),
- ],
- }
-}
-
-export function rollupOutputOptions(): OutputOptions {
- return {
- dir: 'dist/js',
- format: 'esm',
- sourcemap: 'inline',
- manualChunks: (id, _meta) => {
- if (id.includes('node_modules') || id === '\x00commonjsHelpers.js') {
- return 'vendor';
- } else {
- return 'shared';
- }
- },
- chunkFileNames: '[name].js'
- }
-}
diff --git a/js/tools/src/dev.ts b/js/tools/src/dev.ts
deleted file mode 100644
index 324a62f..0000000
--- a/js/tools/src/dev.ts
+++ /dev/null
@@ -1,90 +0,0 @@
-import { parseManifest, readManifest, rollupInputOptions, rollupOutputOptions } from "./config";
-import { RollupError, watch } from "rollup";
-import chalk from "chalk";
-import { sessionBus } from "dbus-ts";
-
-
-export type Interfaces = {
- "dev.projectgauntlet.Server.Management": dev.projectgauntlet.Server.Management
-}
-export namespace dev {
- export namespace projectgauntlet {
- export namespace Server {
- export interface Management {
- SaveLocalPlugin(plugin_id: string): Promise
- }
- }
- }
-}
-
-export async function dev() {
- console.log(chalk.cyanBright(`\nwatching for file changes...`));
-
- const watcher = watch({
- watch: {
- exclude: [
- '**/node_modules/**',
- '**/.git/**',
- '**/dist/**',
- ],
- },
- ...rollupInputOptions(parseManifest(readManifest())),
- output: rollupOutputOptions()
- });
-
- const messageBus = await sessionBus();
-
- const management = await messageBus.getInterface(
- "dev.projectgauntlet.Gauntlet",
- "/dev/projectgauntlet/Server",
- "dev.projectgauntlet.Server.Management"
- );
-
- watcher.on('event', async (event) => {
- switch (event.code) {
- case "START": {
- break;
- }
- case "BUNDLE_START": {
- console.log(chalk.cyanBright(`\nrefresh started...`));
- break;
- }
- case "BUNDLE_END": {
- const manifestText = readManifest();
- parseManifest(manifestText); // TODO properly handle errors here
-
- await event.result.close()
-
- try {
- await management.SaveLocalPlugin(process.cwd() + "/dist")
- } catch (e) {
- console.error("Error returned by server");
- console.error(e);
- }
-
- console.log(chalk.cyanBright(`refreshed in ${event.duration}ms.`));
- break;
- }
- case "END": {
- break;
- }
- case "ERROR": {
- outputBuildError(event.error)
- break;
- }
- }
- });
-
- // watcher.close();
-}
-
-function outputBuildError(e: RollupError) {
- console.error(chalk.red(`${e.plugin ? `[${e.plugin}] ` : ''}${e.message}`))
- if (e.id) {
- const loc = e.loc ? `:${e.loc.line}:${e.loc.column}` : ''
- console.error(`file: ${chalk.cyan(`${e.id}${loc}`)}`)
- }
- if (e.frame) {
- console.error(chalk.yellow(e.frame))
- }
-}
\ No newline at end of file
diff --git a/js/tools/src/main.ts b/js/tools/src/main.ts
deleted file mode 100644
index 80ddc47..0000000
--- a/js/tools/src/main.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import { Command } from 'commander';
-import { build } from "./build";
-import { dev } from "./dev";
-import { version } from "../package.json";
-
-if (version === undefined) {
- throw new Error("Unexpected error. Version is not available")
-}
-
-const program = new Command();
-
-program
- .name('gauntlet')
- .description('Gauntlet CLI')
- .version(version, '-v, --version')
-
-program.command('dev')
- .description('Run a dev server that automatically refreshes plugin when source code changes detected')
- .action(async () => {
- await dev()
- });
-
-program.command('build')
- .description('Build a plugin')
- .action(async () => {
- await build()
- });
-
-await program.parseAsync(process.argv);
diff --git a/js/tools/tsconfig.json b/js/tools/tsconfig.json
deleted file mode 100644
index f9bb627..0000000
--- a/js/tools/tsconfig.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "compilerOptions": {
- "strict": true,
- "module": "ES2022",
- "esModuleInterop": true,
- "target": "ES2022",
- "moduleResolution": "bundler",
- "jsx": "react-jsx"
- },
- "lib": ["ES2020"]
-}
\ No newline at end of file