Skip to content

Commit 39ff142

Browse files
authored
Merge pull request #1915 from nellh/schema-web-validator
Add vite web validator for the schema validator
2 parents d626096 + 4834715 commit 39ff142

File tree

16 files changed

+1969
-3
lines changed

16 files changed

+1969
-3
lines changed

bids-validator/build.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,16 @@
77
import * as esbuild from 'https://deno.land/x/[email protected]/mod.js'
88
import { parse } from 'https://deno.land/[email protected]/flags/mod.ts'
99
import { denoPlugins } from "https://deno.land/x/[email protected]/mod.ts"
10+
import * as path from "https://deno.land/[email protected]/path/mod.ts"
1011

11-
const MAIN_ENTRY = 'src/main.ts'
12-
const CLI_ENTRY = 'src/bids-validator.ts'
12+
function getModuleDir(importMeta: ImportMeta): string {
13+
return path.resolve(path.dirname(path.fromFileUrl(importMeta.url)));
14+
}
15+
16+
const dir = getModuleDir(import.meta);
17+
18+
const MAIN_ENTRY = path.join(dir, 'src', 'main.ts')
19+
const CLI_ENTRY = path.join(dir, 'src', 'bids-validator.ts')
1320

1421
const flags = parse(Deno.args, {
1522
boolean: ['minify'],
@@ -20,7 +27,7 @@ const result = await esbuild.build({
2027
format: 'esm',
2128
entryPoints: [MAIN_ENTRY, CLI_ENTRY],
2229
bundle: true,
23-
outdir: 'dist/validator',
30+
outdir: path.join('dist','validator'),
2431
minify: flags.minify,
2532
target: ['chrome109', 'firefox109', 'safari16'],
2633
plugins: [...denoPlugins()],

web/.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
.vite
14+
*.local
15+
16+
# Editor directories and files
17+
.vscode/*
18+
!.vscode/extensions.json
19+
.idea
20+
.DS_Store
21+
*.suo
22+
*.ntvs*
23+
*.njsproj
24+
*.sln
25+
*.sw?

web/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# BIDS Validator web app
2+
3+
This is a web app for running the schema based BIDS validator in the browser. For local development, this is run using deno and uses an esbuild bundle created from the native deno codebase. A bundle is generated in `dist/validator` and used by the otherwise static vite app.
4+
5+
## Running
6+
7+
You need to have Deno v1.28.0 or later installed to run this repo.
8+
9+
Start a dev server:
10+
11+
```
12+
$ deno task dev
13+
```
14+
15+
## Deploy
16+
17+
Build production assets:
18+
19+
```
20+
$ deno task build
21+
```
22+
23+
## Notes
24+
25+
- You need to use `.mjs` or `.mts` extension for the `vite.config.[ext]` file.
26+
27+
## Papercuts
28+
29+
Currently there's a "papercut" for Deno users:
30+
31+
- peer dependencies need to be referenced in `vite.config.js` - in this example
32+
it is `react` and `react-dom` packages that need to be referenced

web/deno.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"tasks": {
3+
"dev": "../bids-validator/build.ts && deno run -A --node-modules-dir npm:vite",
4+
"build": "../bids-validator/build.ts && deno run -A --node-modules-dir npm:vite build",
5+
"preview": "deno run -A --node-modules-dir npm:vite preview",
6+
"serve": "deno run --allow-net --allow-read https://deno.land/[email protected]/http/file_server.ts dist/"
7+
}
8+
}

0 commit comments

Comments
 (0)