bids-validator-deno 2.0.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. bids_validator_deno-2.0.5/LICENSE +20 -0
  2. bids_validator_deno-2.0.5/PKG-INFO +118 -0
  3. bids_validator_deno-2.0.5/README.md +101 -0
  4. bids_validator_deno-2.0.5/deno.json +59 -0
  5. bids_validator_deno-2.0.5/pdm_build.py +39 -0
  6. bids_validator_deno-2.0.5/pyproject.toml +65 -0
  7. bids_validator_deno-2.0.5/src/.git-meta.json +6 -0
  8. bids_validator_deno-2.0.5/src/bids-validator.ts +8 -0
  9. bids_validator_deno-2.0.5/src/files/browser.test.ts +164 -0
  10. bids_validator_deno-2.0.5/src/files/browser.ts +65 -0
  11. bids_validator_deno-2.0.5/src/files/deno.test.ts +93 -0
  12. bids_validator_deno-2.0.5/src/files/deno.ts +158 -0
  13. bids_validator_deno-2.0.5/src/files/dwi.test.ts +34 -0
  14. bids_validator_deno-2.0.5/src/files/dwi.ts +16 -0
  15. bids_validator_deno-2.0.5/src/files/filetree.test.ts +68 -0
  16. bids_validator_deno-2.0.5/src/files/filetree.ts +54 -0
  17. bids_validator_deno-2.0.5/src/files/gzip.test.ts +42 -0
  18. bids_validator_deno-2.0.5/src/files/gzip.ts +53 -0
  19. bids_validator_deno-2.0.5/src/files/ignore.test.ts +28 -0
  20. bids_validator_deno-2.0.5/src/files/ignore.ts +50 -0
  21. bids_validator_deno-2.0.5/src/files/inheritance.test.ts +50 -0
  22. bids_validator_deno-2.0.5/src/files/inheritance.ts +51 -0
  23. bids_validator_deno-2.0.5/src/files/json.test.ts +63 -0
  24. bids_validator_deno-2.0.5/src/files/json.ts +30 -0
  25. bids_validator_deno-2.0.5/src/files/nifti.test.ts +75 -0
  26. bids_validator_deno-2.0.5/src/files/nifti.ts +72 -0
  27. bids_validator_deno-2.0.5/src/files/streams.test.ts +37 -0
  28. bids_validator_deno-2.0.5/src/files/streams.ts +51 -0
  29. bids_validator_deno-2.0.5/src/files/tiff.test.ts +55 -0
  30. bids_validator_deno-2.0.5/src/files/tiff.ts +75 -0
  31. bids_validator_deno-2.0.5/src/files/tsv.test.ts +180 -0
  32. bids_validator_deno-2.0.5/src/files/tsv.ts +64 -0
  33. bids_validator_deno-2.0.5/src/issues/datasetIssues.test.ts +58 -0
  34. bids_validator_deno-2.0.5/src/issues/datasetIssues.ts +87 -0
  35. bids_validator_deno-2.0.5/src/issues/list.test.ts +53 -0
  36. bids_validator_deno-2.0.5/src/issues/list.ts +192 -0
  37. bids_validator_deno-2.0.5/src/main.ts +58 -0
  38. bids_validator_deno-2.0.5/src/schema/applyRules.test.ts +154 -0
  39. bids_validator_deno-2.0.5/src/schema/applyRules.ts +294 -0
  40. bids_validator_deno-2.0.5/src/schema/associations.ts +190 -0
  41. bids_validator_deno-2.0.5/src/schema/context.test.ts +36 -0
  42. bids_validator_deno-2.0.5/src/schema/context.ts +358 -0
  43. bids_validator_deno-2.0.5/src/schema/entities.test.ts +72 -0
  44. bids_validator_deno-2.0.5/src/schema/entities.ts +32 -0
  45. bids_validator_deno-2.0.5/src/schema/expressionLanguage.test.ts +237 -0
  46. bids_validator_deno-2.0.5/src/schema/expressionLanguage.ts +120 -0
  47. bids_validator_deno-2.0.5/src/schema/fixtures.test.ts +39 -0
  48. bids_validator_deno-2.0.5/src/schema/modalities.ts +16 -0
  49. bids_validator_deno-2.0.5/src/schema/tables.test.ts +205 -0
  50. bids_validator_deno-2.0.5/src/schema/tables.ts +318 -0
  51. bids_validator_deno-2.0.5/src/schema/walk.test.ts +57 -0
  52. bids_validator_deno-2.0.5/src/schema/walk.ts +59 -0
  53. bids_validator_deno-2.0.5/src/setup/loadSchema.test.ts +36 -0
  54. bids_validator_deno-2.0.5/src/setup/loadSchema.ts +43 -0
  55. bids_validator_deno-2.0.5/src/setup/options.test.ts +16 -0
  56. bids_validator_deno-2.0.5/src/setup/options.ts +118 -0
  57. bids_validator_deno-2.0.5/src/setup/requestPermissions.ts +27 -0
  58. bids_validator_deno-2.0.5/src/summary/collectSubjectMetadata.ts +71 -0
  59. bids_validator_deno-2.0.5/src/summary/summary.test.ts +15 -0
  60. bids_validator_deno-2.0.5/src/summary/summary.ts +171 -0
  61. bids_validator_deno-2.0.5/src/tests/README.md +1 -0
  62. bids_validator_deno-2.0.5/src/tests/bom-utf16.tsv +0 -0
  63. bids_validator_deno-2.0.5/src/tests/bom-utf8.json +3 -0
  64. bids_validator_deno-2.0.5/src/tests/generate-filenames.ts +26 -0
  65. bids_validator_deno-2.0.5/src/tests/local/bids_examples.test.ts +75 -0
  66. bids_validator_deno-2.0.5/src/tests/local/common.ts +43 -0
  67. bids_validator_deno-2.0.5/src/tests/local/derivatives.test.ts +13 -0
  68. bids_validator_deno-2.0.5/src/tests/local/empty_files.test.ts +43 -0
  69. bids_validator_deno-2.0.5/src/tests/local/hed-integration.test.ts +50 -0
  70. bids_validator_deno-2.0.5/src/tests/local/valid_dataset.test.ts +20 -0
  71. bids_validator_deno-2.0.5/src/tests/local/valid_filenames.test.ts +20 -0
  72. bids_validator_deno-2.0.5/src/tests/local/valid_headers.test.ts +44 -0
  73. bids_validator_deno-2.0.5/src/tests/nullReadBytes.ts +3 -0
  74. bids_validator_deno-2.0.5/src/tests/regression.test.ts +44 -0
  75. bids_validator_deno-2.0.5/src/tests/schema-expression-language.test.ts +70 -0
  76. bids_validator_deno-2.0.5/src/tests/simple-dataset.ts +11 -0
  77. bids_validator_deno-2.0.5/src/tests/utils.ts +12 -0
  78. bids_validator_deno-2.0.5/src/types/check.ts +21 -0
  79. bids_validator_deno-2.0.5/src/types/columns.test.ts +53 -0
  80. bids_validator_deno-2.0.5/src/types/columns.ts +48 -0
  81. bids_validator_deno-2.0.5/src/types/filetree.ts +76 -0
  82. bids_validator_deno-2.0.5/src/types/issues.ts +37 -0
  83. bids_validator_deno-2.0.5/src/types/schema.ts +116 -0
  84. bids_validator_deno-2.0.5/src/types/validation-result.ts +38 -0
  85. bids_validator_deno-2.0.5/src/utils/errors.ts +8 -0
  86. bids_validator_deno-2.0.5/src/utils/logger.test.ts +32 -0
  87. bids_validator_deno-2.0.5/src/utils/logger.ts +44 -0
  88. bids_validator_deno-2.0.5/src/utils/memoize.ts +38 -0
  89. bids_validator_deno-2.0.5/src/utils/objectPathHandler.ts +24 -0
  90. bids_validator_deno-2.0.5/src/utils/output.ts +186 -0
  91. bids_validator_deno-2.0.5/src/validators/bids.test.ts +64 -0
  92. bids_validator_deno-2.0.5/src/validators/bids.ts +180 -0
  93. bids_validator_deno-2.0.5/src/validators/citation.test.ts +27 -0
  94. bids_validator_deno-2.0.5/src/validators/citation.ts +39 -0
  95. bids_validator_deno-2.0.5/src/validators/filenameIdentify.test.ts +132 -0
  96. bids_validator_deno-2.0.5/src/validators/filenameIdentify.ts +237 -0
  97. bids_validator_deno-2.0.5/src/validators/filenameValidate.test.ts +48 -0
  98. bids_validator_deno-2.0.5/src/validators/filenameValidate.ts +342 -0
  99. bids_validator_deno-2.0.5/src/validators/hed.ts +99 -0
  100. bids_validator_deno-2.0.5/src/validators/internal/emptyFile.ts +12 -0
  101. bids_validator_deno-2.0.5/src/validators/internal/unusedFile.ts +45 -0
  102. bids_validator_deno-2.0.5/src/validators/json.ts +29 -0
  103. bids_validator_deno-2.0.5/src/validators/validateFiles.test.ts +125 -0
  104. bids_validator_deno-2.0.5/src/version.ts +53 -0
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 The Board of Trustees of the Leland Stanford Junior University
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,118 @@
1
+ Metadata-Version: 2.1
2
+ Name: bids-validator-deno
3
+ Version: 2.0.5
4
+ Summary: Typescript implementation of the BIDS validator
5
+ Keywords: BIDS,BIDS validator
6
+ Author: bids-standard developers
7
+ License: MIT
8
+ Classifier: Development Status :: 5 - Production/Stable
9
+ Classifier: Intended Audience :: Science/Research
10
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: JavaScript
13
+ Project-URL: Documentation, https://bids-validator.readthedocs.io/
14
+ Project-URL: Source code, https://github.com/bids-standard/bids-validator
15
+ Project-URL: Issues, https://github.com/bids-standard/bids-validator/issues
16
+ Description-Content-Type: text/markdown
17
+
18
+ [![Deno build](https://github.com/bids-standard/bids-validator/actions/workflows/deno_tests.yml/badge.svg)](https://github.com/bids-standard/bids-validator/actions/workflows/deno_tests.yml)
19
+ [![Web validator](https://github.com/bids-standard/bids-validator/actions/workflows/web_build.yml/badge.svg)](https://github.com/bids-standard/bids-validator/actions/workflows/web_build.yml)
20
+ [![Documentation Status](https://readthedocs.org/projects/bids-validator/badge/?version=latest)](https://bids-validator.readthedocs.io/en/latest/?badge=latest)
21
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3688707.svg)](https://doi.org/10.5281/zenodo.3688707)
22
+
23
+ # The BIDS Validator
24
+
25
+ The BIDS Validator is a web application, command-line utility,
26
+ and Javascript/Typescript library for assessing compliance with the
27
+ [Brain Imaging Data Structure (BIDS)][BIDS] standard.
28
+
29
+ ## Getting Started
30
+
31
+ In most cases,
32
+ the simplest way to use the validator is to browse to the [BIDS Validator][] web page:
33
+
34
+ ![The web interface to the BIDS Validator with the "Select Dataset Files" button highlighted.
35
+ (Dark theme)](docs/_static/web_entrypoint_dark.png#gh-dark-mode-only)
36
+ ![The web interface to the BIDS Validator with the "Select Dataset Files" button highlighted.
37
+ (Light theme)](docs/_static/web_entrypoint_light.png#gh-light-mode-only)
38
+
39
+ The web validator runs in-browser, and does not transfer data to any remote server.
40
+
41
+ In some contexts, such as when working on a remote server,
42
+ it may be easier to use the command-line.
43
+ The BIDS Validator can be run with the [Deno][] runtime
44
+ (see [Deno - Installation][] for detailed installation instructions):
45
+
46
+ ```shell
47
+ deno run -ERWN jsr:@bids/validator
48
+ ```
49
+
50
+ Deno by default sandboxes applications like a web browser.
51
+ `-E`, `-R`, `-W`, and `-N` allow the validator to read environment variables,
52
+ read/write local files, and read network locations.
53
+
54
+ A pre-compiled binary is published to [PyPI][] and may be installed with:
55
+
56
+ ```
57
+ pip install bids-validator-deno
58
+ bids-validator-deno --help
59
+ ```
60
+
61
+ ### Configuration file
62
+
63
+ The schema validator accepts a JSON configuration file that reclassifies issues as
64
+ warnings, errors or ignored.
65
+
66
+ ```json
67
+ {
68
+ "ignore": [
69
+ { "code": "JSON_KEY_RECOMMENDED", "location": "/T1w.json" }
70
+ ],
71
+ "warning": [],
72
+ "error": [
73
+ { "code": "NO_AUTHORS" }
74
+ ]
75
+ }
76
+ ```
77
+
78
+ The issues are partial matches of the `issues` that the validator accumulates.
79
+ Pass the `--json` flag to see the issues in detail.
80
+
81
+ ### Development tools
82
+
83
+ From the repository root, use `./local-run` to run with all permissions enabled by default:
84
+
85
+ ```shell
86
+ # Run from within the /bids-validator directory
87
+ cd bids-validator
88
+ # Run validator:
89
+ ./local-run path/to/dataset
90
+ ```
91
+
92
+ ## Schema validator test suite
93
+
94
+ ```shell
95
+ # Run tests:
96
+ deno test --allow-env --allow-read --allow-write src/
97
+ ```
98
+
99
+ This test suite includes running expected output from bids-examples and may throw some expected failures for bids-examples datasets where either the schema or validator are misaligned with the example dataset while under development.
100
+
101
+ ## Modifying and building a new schema
102
+
103
+ To modify the schema a clone of bids-standard/bids-specification will need to be made. README and schema itself live here https://github.com/bids-standard/bids-specification/tree/master/src/schema.
104
+
105
+ After changes to the schema have been made to a local copy the dereferenced single json file used by the validator will need to be built. The `bidsschematools` python package does this. It can be installed from pypi via pip or a local installation can be made. It lives in the specification repository here https://github.com/bids-standard/bids-specification/tree/master/tools/schemacode
106
+
107
+ The command to compile a dereferenced schema is `bst -v export --schema src/schema --output src/schema.json` (this assumes you are in the root of the bids-specification repo). Once compiled it can be passed to the validator via the `-s` flag, `./bids-validator-deno -s <path to schema> <path to dataset>`
108
+
109
+
110
+ ## Documentation
111
+
112
+ The BIDS validator documentation is available on [Read the Docs](https://bids-validator.readthedocs.io/en/latest/).
113
+
114
+ [BIDS]: https://bids.neuroimaging.io
115
+ [BIDS Validator]: https://bids-standard.github.io/bids-validator/
116
+ [Deno]: https://deno.com/
117
+ [Deno - Installation]: https://docs.deno.com/runtime/getting_started/installation/
118
+ [PyPI]: https://pypi.org/project/bids-validator-deno/
@@ -0,0 +1,101 @@
1
+ [![Deno build](https://github.com/bids-standard/bids-validator/actions/workflows/deno_tests.yml/badge.svg)](https://github.com/bids-standard/bids-validator/actions/workflows/deno_tests.yml)
2
+ [![Web validator](https://github.com/bids-standard/bids-validator/actions/workflows/web_build.yml/badge.svg)](https://github.com/bids-standard/bids-validator/actions/workflows/web_build.yml)
3
+ [![Documentation Status](https://readthedocs.org/projects/bids-validator/badge/?version=latest)](https://bids-validator.readthedocs.io/en/latest/?badge=latest)
4
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3688707.svg)](https://doi.org/10.5281/zenodo.3688707)
5
+
6
+ # The BIDS Validator
7
+
8
+ The BIDS Validator is a web application, command-line utility,
9
+ and Javascript/Typescript library for assessing compliance with the
10
+ [Brain Imaging Data Structure (BIDS)][BIDS] standard.
11
+
12
+ ## Getting Started
13
+
14
+ In most cases,
15
+ the simplest way to use the validator is to browse to the [BIDS Validator][] web page:
16
+
17
+ ![The web interface to the BIDS Validator with the "Select Dataset Files" button highlighted.
18
+ (Dark theme)](docs/_static/web_entrypoint_dark.png#gh-dark-mode-only)
19
+ ![The web interface to the BIDS Validator with the "Select Dataset Files" button highlighted.
20
+ (Light theme)](docs/_static/web_entrypoint_light.png#gh-light-mode-only)
21
+
22
+ The web validator runs in-browser, and does not transfer data to any remote server.
23
+
24
+ In some contexts, such as when working on a remote server,
25
+ it may be easier to use the command-line.
26
+ The BIDS Validator can be run with the [Deno][] runtime
27
+ (see [Deno - Installation][] for detailed installation instructions):
28
+
29
+ ```shell
30
+ deno run -ERWN jsr:@bids/validator
31
+ ```
32
+
33
+ Deno by default sandboxes applications like a web browser.
34
+ `-E`, `-R`, `-W`, and `-N` allow the validator to read environment variables,
35
+ read/write local files, and read network locations.
36
+
37
+ A pre-compiled binary is published to [PyPI][] and may be installed with:
38
+
39
+ ```
40
+ pip install bids-validator-deno
41
+ bids-validator-deno --help
42
+ ```
43
+
44
+ ### Configuration file
45
+
46
+ The schema validator accepts a JSON configuration file that reclassifies issues as
47
+ warnings, errors or ignored.
48
+
49
+ ```json
50
+ {
51
+ "ignore": [
52
+ { "code": "JSON_KEY_RECOMMENDED", "location": "/T1w.json" }
53
+ ],
54
+ "warning": [],
55
+ "error": [
56
+ { "code": "NO_AUTHORS" }
57
+ ]
58
+ }
59
+ ```
60
+
61
+ The issues are partial matches of the `issues` that the validator accumulates.
62
+ Pass the `--json` flag to see the issues in detail.
63
+
64
+ ### Development tools
65
+
66
+ From the repository root, use `./local-run` to run with all permissions enabled by default:
67
+
68
+ ```shell
69
+ # Run from within the /bids-validator directory
70
+ cd bids-validator
71
+ # Run validator:
72
+ ./local-run path/to/dataset
73
+ ```
74
+
75
+ ## Schema validator test suite
76
+
77
+ ```shell
78
+ # Run tests:
79
+ deno test --allow-env --allow-read --allow-write src/
80
+ ```
81
+
82
+ This test suite includes running expected output from bids-examples and may throw some expected failures for bids-examples datasets where either the schema or validator are misaligned with the example dataset while under development.
83
+
84
+ ## Modifying and building a new schema
85
+
86
+ To modify the schema a clone of bids-standard/bids-specification will need to be made. README and schema itself live here https://github.com/bids-standard/bids-specification/tree/master/src/schema.
87
+
88
+ After changes to the schema have been made to a local copy the dereferenced single json file used by the validator will need to be built. The `bidsschematools` python package does this. It can be installed from pypi via pip or a local installation can be made. It lives in the specification repository here https://github.com/bids-standard/bids-specification/tree/master/tools/schemacode
89
+
90
+ The command to compile a dereferenced schema is `bst -v export --schema src/schema --output src/schema.json` (this assumes you are in the root of the bids-specification repo). Once compiled it can be passed to the validator via the `-s` flag, `./bids-validator-deno -s <path to schema> <path to dataset>`
91
+
92
+
93
+ ## Documentation
94
+
95
+ The BIDS validator documentation is available on [Read the Docs](https://bids-validator.readthedocs.io/en/latest/).
96
+
97
+ [BIDS]: https://bids.neuroimaging.io
98
+ [BIDS Validator]: https://bids-standard.github.io/bids-validator/
99
+ [Deno]: https://deno.com/
100
+ [Deno - Installation]: https://docs.deno.com/runtime/getting_started/installation/
101
+ [PyPI]: https://pypi.org/project/bids-validator-deno/
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@bids/validator",
3
+ "version": "2.0.5",
4
+ "exports": {
5
+ ".": "./src/bids-validator.ts",
6
+ "./main": "./src/main.ts",
7
+ "./output": "./src/utils/output.ts",
8
+ "./files": "./src/files/deno.ts",
9
+ "./options": "./src/setup/options.ts",
10
+ "./issues": "./src/issues/datasetIssues.ts"
11
+ },
12
+ "exclude": [
13
+ "docs/",
14
+ "tools/",
15
+ "web/",
16
+ ".*",
17
+ "CITATION.cff",
18
+ "Dockerfile",
19
+ "build.ts",
20
+ "local-run"
21
+ ],
22
+ "publish": {
23
+ "exclude": [
24
+ "**/tests/",
25
+ "**/*.test.ts",
26
+ "deno.lock"
27
+ ]
28
+ },
29
+ "imports": {
30
+ "@ajv": "npm:ajv@8.17.1",
31
+ "@bids/schema": "jsr:@bids/schema@1.0.4",
32
+ "@cliffy/command": "jsr:@effigies/cliffy-command@1.0.0-dev.8",
33
+ "@cliffy/table": "jsr:@effigies/cliffy-table@1.0.0-dev.5",
34
+ "@hed/validator": "npm:hed-validator@4.0.1",
35
+ "@ignore": "npm:ignore@7.0.3",
36
+ "@libs/xml": "jsr:@libs/xml@6.0.4",
37
+ "@mango/nifti": "npm:@bids/nifti-reader-js@0.6.9",
38
+ "@std/assert": "jsr:@std/assert@1.0.12",
39
+ "@std/fmt": "jsr:@std/fmt@1.0.6",
40
+ "@std/fs": "jsr:@std/fs@1.0.15",
41
+ "@std/io": "jsr:@std/io@0.225.2",
42
+ "@std/log": "jsr:@std/log@0.224.14",
43
+ "@std/path": "jsr:@std/path@1.0.8",
44
+ "@std/streams": "jsr:@std/streams@1.0.9",
45
+ "@std/yaml": "jsr:@std/yaml@^1.0.5"
46
+ },
47
+ "tasks": {
48
+ "test": "deno test -A src/"
49
+ },
50
+ "fmt": {
51
+ "lineWidth": 99,
52
+ "semiColons": false,
53
+ "singleQuote": true,
54
+ "proseWrap": "preserve",
55
+ "include": [
56
+ "src/"
57
+ ]
58
+ }
59
+ }
@@ -0,0 +1,39 @@
1
+ import json
2
+ import shutil
3
+ import subprocess
4
+ import sysconfig
5
+
6
+
7
+ def pdm_build_initialize(context):
8
+ context.ensure_build_dir()
9
+
10
+ deno_json = context.root / "deno.json"
11
+ deno_config = json.loads(deno_json.read_text())
12
+ context.config.metadata["version"] = deno_config["version"]
13
+
14
+ if context.target == "sdist":
15
+ return
16
+
17
+ # Inject compiled binary into scripts/, so it will be picked up to install
18
+ target = context.root / "scripts" / "bids-validator-deno"
19
+
20
+ deno = shutil.which("deno")
21
+ if deno is None:
22
+ raise OSError("Deno is not installed or not in PATH")
23
+
24
+ subprocess.run(
25
+ [
26
+ deno,
27
+ "compile",
28
+ "-ERNW",
29
+ "--allow-run",
30
+ "-o",
31
+ str(target),
32
+ "src/bids-validator.ts",
33
+ ],
34
+ check=True,
35
+ )
36
+
37
+ # Add the current platform tag so the wheel is specific to the OS/architecture
38
+ platform_tag = sysconfig.get_platform().replace("-", "_").replace(".", "_")
39
+ context.config_settings["--plat-name"] = platform_tag
@@ -0,0 +1,65 @@
1
+ [project]
2
+ name = "bids-validator-deno"
3
+ description = "Typescript implementation of the BIDS validator"
4
+ authors = [
5
+ { name = "bids-standard developers" },
6
+ ]
7
+ dependencies = []
8
+ readme = "README.md"
9
+ classifiers = [
10
+ "Development Status :: 5 - Production/Stable",
11
+ "Intended Audience :: Science/Research",
12
+ "Topic :: Scientific/Engineering :: Bio-Informatics",
13
+ "License :: OSI Approved :: MIT License",
14
+ "Programming Language :: JavaScript",
15
+ ]
16
+ keywords = [
17
+ "BIDS",
18
+ "BIDS validator",
19
+ ]
20
+ dynamic = []
21
+ version = "2.0.5"
22
+
23
+ [project.license]
24
+ text = "MIT"
25
+
26
+ [project.urls]
27
+ Documentation = "https://bids-validator.readthedocs.io/"
28
+ "Source code" = "https://github.com/bids-standard/bids-validator"
29
+ Issues = "https://github.com/bids-standard/bids-validator/issues"
30
+
31
+ [build-system]
32
+ requires = [
33
+ "pdm-backend",
34
+ ]
35
+ build-backend = "pdm.backend"
36
+
37
+ [tool.pdm]
38
+ distribution = true
39
+
40
+ [tool.pdm.build]
41
+ source-includes = [
42
+ "src/",
43
+ "deno.json",
44
+ ]
45
+ excludes = [
46
+ ".*",
47
+ ]
48
+
49
+ [tool.pdm.build.wheel-data]
50
+ scripts = [
51
+ "scripts/*",
52
+ ]
53
+
54
+ [tool.cibuildwheel]
55
+ build = "cp39-*"
56
+ skip = "*musllinux* *_i686 *-win32"
57
+ build-frontend = "build"
58
+ manylinux-x86_64-image = "quay.io/pypa/manylinux_2_24_x86_64:latest"
59
+ manylinux-aarch64-image = "quay.io/pypa/manylinux_2_24_aarch64:latest"
60
+ before-build = "curl -fsSL https://deno.land/install.sh | DENO_INSTALL=/usr/local sh && deno --version"
61
+ test-command = "bids-validator-deno --version"
62
+ overrides = [
63
+ { select = "*musllinux*", before-build = "apk add deno" },
64
+ { select = "*win*", before-build = "npm install -g deno & deno --version" },
65
+ ]
@@ -0,0 +1,6 @@
1
+ {
2
+ "node": "$Format:%H$",
3
+ "date": "$Format:%cI$",
4
+ "description": "$Format:%(describe:tags=true,match=*[0-9]*)$",
5
+ "refnames": "$Format:%D$"
6
+ }
@@ -0,0 +1,8 @@
1
+ import { main } from './main.ts'
2
+
3
+ const result = await main()
4
+
5
+ const errors = result.issues.get({ severity: 'error' })
6
+ if (errors.length) {
7
+ Deno.exit(1)
8
+ }
@@ -0,0 +1,164 @@
1
+ import { FileIgnoreRules } from './ignore.ts'
2
+ import { FileTree } from '../types/filetree.ts'
3
+ import { assertEquals, assertObjectMatch } from '@std/assert'
4
+ import { BIDSFileBrowser, fileListToTree } from './browser.ts'
5
+ import { streamFromString } from '../tests/utils.ts'
6
+
7
+ const nullstream = streamFromString('')
8
+
9
+ class TestFile extends File {
10
+ override webkitRelativePath: string
11
+ constructor(
12
+ fileBits: BlobPart[],
13
+ fileName: string,
14
+ webkitRelativePath: string,
15
+ options?: FilePropertyBag | undefined,
16
+ ) {
17
+ super(fileBits, fileName, options)
18
+ this.webkitRelativePath = webkitRelativePath
19
+ this.stream = () => nullstream
20
+ }
21
+ }
22
+
23
+ Deno.test('Browser implementation of FileTree', async (t) => {
24
+ await t.step('converts a basic FileList', async () => {
25
+ const ignore = new FileIgnoreRules([])
26
+ const files = [
27
+ new TestFile(
28
+ ['{}'],
29
+ 'dataset_description.json',
30
+ 'ds/dataset_description.json',
31
+ ),
32
+ new TestFile(['flat test dataset'], 'README.md', 'ds/README.md'),
33
+ ]
34
+ const tree = await fileListToTree(files)
35
+ const expectedTree = new FileTree('/', '/', undefined)
36
+ expectedTree.files = files.map((f) => {
37
+ const file = new BIDSFileBrowser(f, ignore)
38
+ file.parent = expectedTree
39
+ return file
40
+ })
41
+ assertEquals(tree, expectedTree)
42
+ })
43
+ await t.step('converts a simple FileList with several levels', async () => {
44
+ const ignore = new FileIgnoreRules([])
45
+ const files = [
46
+ new TestFile(
47
+ ['{}'],
48
+ 'dataset_description.json',
49
+ 'ds/dataset_description.json',
50
+ ),
51
+ new TestFile(
52
+ ['tsv headers\n', 'column\tdata'],
53
+ 'participants.tsv',
54
+ 'ds/participants.tsv',
55
+ ),
56
+ new TestFile(
57
+ ['single subject test dataset'],
58
+ 'README.md',
59
+ 'ds/README.md',
60
+ ),
61
+ new TestFile(
62
+ ['nifti file goes here'],
63
+ 'sub-01_T1w.nii.gz',
64
+ 'ds/sub-01/anat/sub-01_T1w.nii.gz',
65
+ ),
66
+ ]
67
+ const tree = await fileListToTree(files)
68
+ const expectedTree = new FileTree('/', '/', undefined)
69
+ const sub01Tree = new FileTree('/sub-01', 'sub-01', expectedTree)
70
+ const anatTree = new FileTree('/sub-01/anat', 'anat', sub01Tree)
71
+ expectedTree.files = files
72
+ .slice(0, 3)
73
+ .map((f) => {
74
+ const file = new BIDSFileBrowser(f, ignore)
75
+ file.parent = expectedTree
76
+ return file
77
+ })
78
+ expectedTree.directories.push(sub01Tree)
79
+ anatTree.files = [new BIDSFileBrowser(files[3], ignore)]
80
+ anatTree.files[0].parent = anatTree
81
+ sub01Tree.directories.push(anatTree)
82
+ assertEquals(tree, expectedTree)
83
+ })
84
+
85
+ await t.step('reads .bidsignore during load', async () => {
86
+ const ignore = new FileIgnoreRules(['ignored_but_absent', 'ignored_and_present'])
87
+ const files = [
88
+ new TestFile(
89
+ ['ignored_but_absent\n', 'ignored_and_present\n'],
90
+ '.bidsignore',
91
+ 'ds/.bidsignore',
92
+ ),
93
+ new TestFile(
94
+ ['{}'],
95
+ 'dataset_description.json',
96
+ 'ds/dataset_description.json',
97
+ ),
98
+ new TestFile(
99
+ ['tsv headers\n', 'column\tdata'],
100
+ 'participants.tsv',
101
+ 'ds/participants.tsv',
102
+ ),
103
+ new TestFile(
104
+ ['single subject test dataset'],
105
+ 'README.md',
106
+ 'ds/README.md',
107
+ ),
108
+ new TestFile(
109
+ ['Anything can be in an ignored file'],
110
+ 'ignored_and_present',
111
+ 'ds/ignored_and_present',
112
+ ),
113
+ new TestFile(
114
+ ['nifti file goes here'],
115
+ 'sub-01_T1w.nii.gz',
116
+ 'ds/sub-01/anat/sub-01_T1w.nii.gz',
117
+ ),
118
+ ]
119
+ const tree = await fileListToTree(files)
120
+ const expectedTree = new FileTree('/', '/', undefined)
121
+ const sub01Tree = new FileTree('/sub-01', 'sub-01', expectedTree)
122
+ const anatTree = new FileTree('/sub-01/anat', 'anat', sub01Tree)
123
+ expectedTree.files = files
124
+ .slice(0, 5)
125
+ .map((f) => {
126
+ const file = new BIDSFileBrowser(f, ignore)
127
+ file.parent = expectedTree
128
+ return file
129
+ })
130
+ expectedTree.directories.push(sub01Tree)
131
+ anatTree.files = [new BIDSFileBrowser(files[5], ignore)]
132
+ anatTree.files[0].parent = anatTree
133
+ sub01Tree.directories.push(anatTree)
134
+ assertEquals(tree, expectedTree)
135
+
136
+ assertEquals(tree.get('ignored_and_present')?.ignored, true)
137
+ })
138
+ })
139
+
140
+ Deno.test('Spread copies of BIDSFileBrowser contain name and path properties', async () => {
141
+ const ignore = new FileIgnoreRules([])
142
+ const files = [
143
+ new TestFile(
144
+ ['{}'],
145
+ 'dataset_description.json',
146
+ 'ds/dataset_description.json',
147
+ ),
148
+ new TestFile(['flat test dataset'], 'README.md', 'ds/README.md'),
149
+ ]
150
+ const tree = await fileListToTree(files)
151
+ const expectedTree = new FileTree('/', '/', undefined)
152
+ expectedTree.files = files.map((f) => {
153
+ const file = new BIDSFileBrowser(f, ignore)
154
+ file.parent = expectedTree
155
+ return file
156
+ })
157
+ assertEquals(tree, expectedTree)
158
+ const spreadFile = { ...expectedTree.files[0], evidence: 'test evidence' }
159
+ assertObjectMatch(spreadFile, {
160
+ name: 'dataset_description.json',
161
+ path: '/dataset_description.json',
162
+ evidence: 'test evidence',
163
+ })
164
+ })
@@ -0,0 +1,65 @@
1
+ import { type BIDSFile, FileTree } from '../types/filetree.ts'
2
+ import { filesToTree } from './filetree.ts'
3
+ import { FileIgnoreRules, readBidsIgnore } from './ignore.ts'
4
+ import { parse, SEPARATOR_PATTERN } from '@std/path'
5
+ import * as posix from '@std/path/posix'
6
+
7
+ /**
8
+ * Browser implement of BIDSFile wrapping native File/FileList types
9
+ */
10
+ export class BIDSFileBrowser implements BIDSFile {
11
+ #ignore: FileIgnoreRules
12
+ #file: File
13
+ name: string
14
+ path: string
15
+ parent: FileTree
16
+ viewed: boolean = false
17
+
18
+ constructor(file: File, ignore: FileIgnoreRules, parent?: FileTree) {
19
+ this.#file = file
20
+ this.#ignore = ignore
21
+ this.name = file.name
22
+ const relativePath = this.#file.webkitRelativePath
23
+ const prefixLength = relativePath.indexOf('/')
24
+ this.path = relativePath.substring(prefixLength)
25
+ this.parent = parent ?? new FileTree('', '/', undefined)
26
+ }
27
+
28
+ get size(): number {
29
+ return this.#file.size
30
+ }
31
+
32
+ get stream(): ReadableStream<Uint8Array> {
33
+ return this.#file.stream()
34
+ }
35
+
36
+ get ignored(): boolean {
37
+ return this.#ignore.test(this.path)
38
+ }
39
+
40
+ text(): Promise<string> {
41
+ return this.#file.text()
42
+ }
43
+
44
+ async readBytes(size: number, offset = 0): Promise<Uint8Array<ArrayBuffer>> {
45
+ return new Uint8Array(await this.#file.slice(offset, size).arrayBuffer())
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Convert from FileList (created with webkitDirectory: true) to FileTree for validator use
51
+ */
52
+ export async function fileListToTree(files: File[]): Promise<FileTree> {
53
+ const ignore = new FileIgnoreRules([])
54
+ const root = new FileTree('/', '/', undefined)
55
+ const tree = filesToTree(files.map((f) => new BIDSFileBrowser(f, ignore, root)), ignore)
56
+ const bidsignore = tree.get('.bidsignore')
57
+ if (bidsignore) {
58
+ try {
59
+ ignore.add(await readBidsIgnore(bidsignore as BIDSFile))
60
+ } catch (err) {
61
+ console.log(`Failed to read '.bidsignore' file with the following error:\n${err}`)
62
+ }
63
+ }
64
+ return tree
65
+ }