Skip to content

Commit 87bbb4c

Browse files
committed
feat(create-itk-wasm): generate itk-wasm-env.bash
1 parent 753f760 commit 87bbb4c

File tree

5 files changed

+242
-78
lines changed

5 files changed

+242
-78
lines changed

packages/core/typescript/create-itk-wasm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"lint": "prettier --check .",
1919
"lint:fix": "prettier --write .",
2020
"test": "pnpm test:help && pnpm test:defaultPipeline && pnpm test:imagePipeline && pnpm test:meshPipeline && pnpm test:polyDataPipeline",
21-
"test:defaultPipeline": "shx rm -rf test/default && node dist/create-itk-wasm.js -o test/default -n \"default-pipeline\" -a \"Test Monkey\" -d \"Default pipeline description\" --pipeline-name default-pipeline --pipeline-description \"Default pipeline description\" -r \"http://test.repo\" --pipeline-inputs \"default-input:string:A default input\" --pipeline-parameters \"a-double-param:double:A double param\" --pipeline-outputs \"a-json-output:JsonCompatible:A JSON compatible output\" --no-input --build-and-test",
21+
"test:defaultPipeline": "shx rm -rf test/default && node dist/create-itk-wasm.js -o test/default -n \"default-pipeline\" -a \"Test Monkey\" -d \"Default pipeline description\" --pipeline-name default-pipeline --pipeline-description \"Default pipeline description\" -r \"http://test.repo\" --pipeline-inputs \"default-input:string:A default input\" --pipeline-parameters \"a-double-param:double:A double param\" --pipeline-outputs \"a-json-output:JsonCompatible:A JSON compatible output\" --no-input && cd test/default && pixi run build && pixi run test",
2222
"test:imagePipeline": "shx rm -rf test/image && node dist/create-itk-wasm.js -o test/image -n \"image-pipeline\" -a \"Test Monkey\" -d \"Image pipeline description\" --pipeline-name image-pipeline --pipeline-description \"Image pipeline description\" -r \"http://test.repo\" --pipeline-inputs \"input-image:Image:An input image\" --pipeline-parameters \"a-float-param:float:A float param\" --pipeline-outputs \"output-image:Image:An output image\" --pipeline-dispatch Image --no-input --build-and-test",
2323
"test:meshPipeline": "shx rm -rf test/mesh && node dist/create-itk-wasm.js -o test/mesh -n \"mesh-pipeline\" -a \"Test Monkey\" -d \"Mesh pipeline description\" --pipeline-name mesh-pipeline --pipeline-description \"Mesh pipeline description\" -r \"http://test.repo\" --pipeline-inputs \"input-mesh:Mesh:An input mesh\" --pipeline-parameters \"a-float-param:float:A float param\" --pipeline-outputs \"output-mesh:Mesh:An output mesh\" --pipeline-dispatch Mesh --no-input --build-and-test",
2424
"test:polyDataPipeline": "shx rm -rf test/poly-data && node dist/create-itk-wasm.js -o test/poly-data -n \"poly-data-pipeline\" -a \"Test Monkey\" -d \"PolyData pipeline description\" --pipeline-name poly-data-pipeline --pipeline-description \"PolyData pipeline description\" -r \"http://test.repo\" --pipeline-inputs \"input-poly-data:PolyData:An input poly-data\" --pipeline-parameters \"a-float-param:float:A float param\" --pipeline-outputs \"output-poly-data:PolyData:An output poly-data\" --pipeline-dispatch PolyData --no-input --build-and-test",
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import fs from 'fs'
2+
import path from 'path'
3+
4+
import ProjectSpec from '../project-spec.js'
5+
6+
function generateItkWasmEnvBash(project: ProjectSpec) {
7+
const itkWasmEnvBashPath = path.join(project.directory, 'itk_wasm_env.bash')
8+
if (fs.existsSync(itkWasmEnvBashPath)) {
9+
return
10+
}
11+
12+
const content = `#!/usr/bin/env bash
13+
14+
function die() {
15+
echo "$1"
16+
exit 1
17+
}
18+
19+
export ITK_WASM_TEST_DATA_HASH=\${ITK_WASM_TEST_DATA_HASH:-$(cat package.json | jq -e -r '."itk-wasm"."test-data-hash"')}
20+
export ITK_WASM_TEST_DATA_URLS=\${ITK_WASM_TEST_DATA_URLS:-$(cat package.json | jq -e -r '."itk-wasm"."test-data-urls" | join(" ")')}
21+
22+
export ITK_WASM_ITK_REPOSITORY=\${ITK_WASM_ITK_REPOSITORY:-"https://github.com/thewtex/ITK"}
23+
export ITK_WASM_ITK_BRANCH=\${ITK_WASM_ITK_BRANCH:-"itkwasm-2024-05-20-5db055d7ad3b-4"}
24+
25+
export ITK_WASM_NATIVE_WORKSPACE=\${ITK_WASM_NATIVE_WORKSPACE:-$(pwd)/native}
26+
27+
export ITK_WASM_ITK_SOURCE_DIR=\${ITK_WASM_ITK_SOURCE_DIR:-\${ITK_WASM_NATIVE_WORKSPACE}/ITK}
28+
export ITK_WASM_ITK_BUILD_DIR=\${ITK_WASM_ITK_BUILD_DIR:-\${ITK_WASM_NATIVE_WORKSPACE}/ITK-build}
29+
mkdir -p \${ITK_WASM_ITK_BUILD_DIR} || die "Could not create ITK build directory"
30+
31+
export ITK_WASM_WEBASSEMBLY_INTERFACE_REPOSITORY=\${ITK_WASM_WEBASSEMBLY_INTERFACE_REPOSITORY:-"https://github.com/InsightSoftwareConsortium/ITK-Wasm"}
32+
export ITK_WASM_WEBASSEMBLY_INTERFACE_BRANCH=\${ITK_WASM_WEBASSEMBLY_INTERFACE_BRANCH:-"main"}
33+
34+
export ITK_WASM_WEBASSEMBLY_INTERFACE_SOURCE_DIR=\${ITK_WASM_WEBASSEMBLY_INTERFACE_SOURCE_DIR:-\${ITK_WASM_NATIVE_WORKSPACE}/ITK-Wasm}
35+
export ITK_WASM_WEBASSEMBLY_INTERFACE_BUILD_DIR=\${ITK_WASM_WEBASSEMBLY_INTERFACE_BUILD_DIR:-\${ITK_WASM_NATIVE_WORKSPACE}/ITK-Wasm-build}
36+
mkdir -p \${ITK_WASM_WEBASSEMBLY_INTERFACE_BUILD_DIR} || die "Could not create ITK-Wasm build directory"
37+
`
38+
39+
fs.writeFileSync(itkWasmEnvBashPath, content)
40+
}
41+
42+
export default generateItkWasmEnvBash

packages/core/typescript/create-itk-wasm/src/generate/package-json.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ function generatePackageJson(project: ProjectSpec) {
1414

1515
const itkWasm = {
1616
'test-data-hash':
17-
'bafkreiha6oye3fd5cxfadnua5r2jlkaco2xuyeek454d2ihiffsx7rauqe',
18-
'test-data-urls': ['https://placeholder'],
17+
'bafkreidnoz54py66bn56uq6itwkfgngflaqilflfvwkxlps4ycmygstzja',
18+
'test-data-urls': [
19+
'https://github.com/InsightSoftwareConsortium/ITK-Wasm/releases/download/itk-wasm-v1.0.0-b.179/sample-data.tar.gz',
20+
'https://bafybeidxatrsrrphfmntdyze6ec3jbiak527wj3kalwjptv4bimpcnzxdq.ipfs.w3s.link/ipfs/bafybeidxatrsrrphfmntdyze6ec3jbiak527wj3kalwjptv4bimpcnzxdq/sample-data.tar.gz'
21+
],
1922
'package-description': project.packageDescription,
2023
'typescript-package-name': project.typescriptPackageName,
2124
'python-package-name': project.pythonPackageName,
@@ -47,7 +50,7 @@ function generatePackageJson(project: ProjectSpec) {
4750
'bindgen:python': 'itk-wasm pnpm-script bindgen:python',
4851
'build:gen:typescript': 'itk-wasm pnpm-script build:gen:typescript',
4952
'build:gen:python': 'itk-wasm pnpm-script build:gen:python',
50-
test: 'pixi run test-data-download && pnpm build:gen:python && pnpm test:python',
53+
test: 'pixi run download-test-data && pnpm build:gen:python && pnpm test:python',
5154
'test:python:wasi': 'itk-wasm pnpm-script test:python:wasi',
5255
'test:python:emscripten': 'itk-wasm pnpm-script test:python:emscripten',
5356
'test:python:dispatch': 'itk-wasm pnpm-script test:python:emscripten',

0 commit comments

Comments
 (0)