Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasm from emscripten #25

Closed
wants to merge 16 commits into from
25 changes: 15 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

defaults:
run:
shell: bash
shell: bash -e -l {0}

jobs:
test:
Expand All @@ -24,23 +24,28 @@ jobs:
with:
fetch-depth: 0

- name: Install node
uses: actions/setup-node@v4
- name: Set conda environment
uses: mamba-org/setup-micromamba@main
with:
node-version: 20
environment-name: cockle
environment-file: environment-dev.yml
init-shell: bash
cache-downloads: true

- name: Install dependencies
run: |
npm install
run: npm install

- name: Fetch wasm dependencies
run: npm run fetch:wasm

- name: Build
run: |
npm run build

- name: Lint
run: |
npm run lint:check

- name: Run tests
run: |
npm t

- name: Lint
run: |
npm run lint:check
6 changes: 6 additions & 0 deletions environment-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: cockle
channels:
- conda-forge
dependencies:
- micromamba
- nodejs =20
269 changes: 136 additions & 133 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,134 +1,137 @@
{
"name": "@jupyterlite/cockle",
"version": "0.0.5",
"description": "In browser bash-like shell",
"homepage": "https://github.com/jupyterlite/cockle",
"license": "BSD-3-Clause",
"author": "Ian Thomas",
"repository": {
"type": "git",
"url": "git+https://github.com/jupyterlite/cockle.git"
},
"bugs": {
"url": "https://github.com/jupyterlite/cockle/issues"
},
"files": [
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
"src/**/*.ts"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"build": "tsc",
"eslint": "npm run eslint:check -- --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"lint": "npm run prettier && npm run eslint",
"lint:check": "npm run prettier:check && npm run eslint:check",
"prepack": "npm install && npm run build",
"prettier": "prettier --list-different --write \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md,.yml}\"",
"prettier:check": "prettier --list-different \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md,.yml}\"",
"test": "jest"
},
"dependencies": {
"@jupyterlab/services": "^7.1.6",
"@jupyterlite/contents": "^0.4.0-beta.0"
},
"devDependencies": {
"@playwright/test": "^1.45.1",
"@types/jest": "^29.5.12",
"@types/json-schema": "^7.0.15",
"@types/react": "^18.2.79",
"@typescript-eslint/eslint-plugin": "^7.16.1",
"@typescript-eslint/parser": "^7.16.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"prettier": "^3.3.3",
"ts-jest": "^29.1.2",
"typescript": "^5.4.5"
},
"eslintIgnore": [
"node_modules",
"dist",
"coverage",
"**/*.d.ts",
"tests",
"**/__tests__",
"ui-tests",
"**/package-lock.json"
],
"eslintConfig": {
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "interface",
"format": [
"PascalCase"
],
"custom": {
"regex": "^I[A-Z]",
"match": true
}
}
],
"@typescript-eslint/no-unused-vars": [
"warn",
{
"args": "none"
}
],
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/quotes": [
"error",
"single",
{
"avoidEscape": true,
"allowTemplateLiterals": false
}
],
"curly": [
"error",
"all"
],
"eqeqeq": "error",
"prefer-arrow-callback": "error"
}
},
"prettier": {
"printWidth": 100,
"singleQuote": true,
"trailingComma": "none",
"arrowParens": "avoid",
"endOfLine": "auto",
"overrides": [
{
"files": "package.json",
"options": {
"tabWidth": 4
}
}
]
},
"publishConfig": {
"access": "public"
}
}
"name": "@jupyterlite/cockle",
"version": "0.0.5",
"description": "In browser bash-like shell",
"homepage": "https://github.com/jupyterlite/cockle",
"license": "BSD-3-Clause",
"author": "Ian Thomas",
"repository": {
"type": "git",
"url": "git+https://github.com/jupyterlite/cockle.git"
},
"bugs": {
"url": "https://github.com/jupyterlite/cockle/issues"
},
"files": [
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
"src/**/*.ts"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"fetch:wasm:create-env": "micromamba create -p $(pwd)/cockle_wasm_env -y lua cockle_fs grep coreutils --platform=emscripten-wasm32 -c https://repo.mamba.pm/emscripten-forge -c https://repo.mamba.pm/conda-forge",
"fetch:wasm:copy": "cp -r $(pwd)/cockle_wasm_env/bin/*.js src/wasm && cp -r $(pwd)/cockle_wasm_env/bin/*.wasm src/wasm",
"fetch:wasm" : "npm run fetch:wasm:create-env && npm run fetch:wasm:copy",
"build": "tsc",
"eslint": "npm run eslint:check -- --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"lint": "npm run prettier && npm run eslint",
"lint:check": "npm run prettier:check && npm run eslint:check",
"prepack": "npm install && npm run build",
"prettier": "prettier --list-different --write \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md,.yml}\"",
"prettier:check": "prettier --list-different \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md,.yml}\"",
"test": "jest"
},
"dependencies": {
"@jupyterlab/services": "^7.1.6",
"@jupyterlite/contents": "^0.4.0-beta.0"
},
"devDependencies": {
"@playwright/test": "^1.45.1",
"@types/jest": "^29.5.12",
"@types/json-schema": "^7.0.15",
"@types/react": "^18.2.79",
"@typescript-eslint/eslint-plugin": "^7.16.1",
"@typescript-eslint/parser": "^7.16.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"prettier": "^3.3.3",
"ts-jest": "^29.1.2",
"typescript": "^5.4.5"
},
"eslintIgnore": [
"node_modules",
"dist",
"coverage",
"**/*.d.ts",
"tests",
"**/__tests__",
"ui-tests",
"**/package-lock.json"
],
"eslintConfig": {
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "interface",
"format": [
"PascalCase"
],
"custom": {
"regex": "^I[A-Z]",
"match": true
}
}
],
"@typescript-eslint/no-unused-vars": [
"warn",
{
"args": "none"
}
],
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/quotes": [
"error",
"single",
{
"avoidEscape": true,
"allowTemplateLiterals": false
}
],
"curly": [
"error",
"all"
],
"eqeqeq": "error",
"prefer-arrow-callback": "error"
}
},
"prettier": {
"printWidth": 100,
"singleQuote": true,
"trailingComma": "none",
"arrowParens": "avoid",
"endOfLine": "auto",
"overrides": [
{
"files": "package.json",
"options": {
"tabWidth": 4
}
}
]
},
"publishConfig": {
"access": "public"
}
}
14 changes: 8 additions & 6 deletions src/command_registry.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { ICommandRunner } from './commands/command_runner';
import { BuiltinCommandRunner } from './commands/builtin_command_runner';
import { CoreutilsCommandRunner } from './commands/coreutils_command_runner';
import { GrepCommandRunner } from './commands/grep_command_runner';
import { ICommandRunner } from "./commands/command_runner"
import { BuiltinCommandRunner } from "./commands/builtin_command_runner"
import { CoreutilsCommandRunner } from "./commands/coreutils_command_runner"
import { GrepCommandRunner } from "./commands/grep_command_runner"
import { LuaCommandRunner } from "./commands/lua_command_runner"

export class CommandRegistry {
private constructor() {
this._commandRunners = [
new BuiltinCommandRunner(),
new CoreutilsCommandRunner(),
new GrepCommandRunner()
];
new GrepCommandRunner(),
new LuaCommandRunner(),
]

// Command name -> runner mapping
for (const runner of this._commandRunners) {
Expand Down
12 changes: 12 additions & 0 deletions src/commands/lua_command_runner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as LuaModule from "../wasm/lua.js"

Check failure on line 1 in src/commands/lua_command_runner.ts

View workflow job for this annotation

GitHub Actions / check_release

Cannot find module '../wasm/lua.js' or its corresponding type declarations.
import { WasmCommandRunner } from "./wasm_command_runner"

export class LuaCommandRunner extends WasmCommandRunner {
names(): string[] {
return ["lua"]
}

protected _getWasmModule(): any {
return LuaModule.default
}
}
4 changes: 4 additions & 0 deletions src/wasm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# the wasm files (and the js glue code) are generated by the build process
# via npm run
*.wasm
*.js
Loading
Loading