@environment-safe/file 0.0.1 → 0.1.1
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.
- package/.husky/pre-commit +5 -3
- package/README.md +25 -7
- package/package.json +19 -5
- package/src/buffer.d.mts +5 -0
- package/src/buffer.mjs +9 -3
- package/src/filesystem.d.mts +47 -0
- package/src/filesystem.mjs +449 -0
- package/src/index.d.mts +27 -0
- package/src/index.mjs +146 -519
- package/src/path.d.mts +35 -0
- package/src/path.mjs +835 -0
- package/test/isolated/crud.mjs +0 -0
- package/test/isolated/path.mjs +48 -0
- package/test/isolated-path.html +448 -0
- package/test/test.html +466 -0
- package/test/test.mjs +78 -22
- /package/test/{index.html → local-file-test.html} +0 -0
package/test/test.html
ADDED
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Moka Tests</title>
|
|
5
|
+
<base filesystem="/Users/khrome/Development/@environment-safe/file" user="khrome">
|
|
6
|
+
<link rel="stylesheet" href="../node_modules/mocha/mocha.css">
|
|
7
|
+
<script type="importmap"> { "imports": {
|
|
8
|
+
"express": "../node_modules/@open-automaton/moka/src/stub.mjs",
|
|
9
|
+
"module": "../node_modules/@open-automaton/moka/src/stub.mjs",
|
|
10
|
+
"fs": "../node_modules/@open-automaton/moka/src/stub.mjs",
|
|
11
|
+
"os": "../node_modules/@open-automaton/moka/src/stub.mjs",
|
|
12
|
+
"path": "../node_modules/@open-automaton/moka/src/stub.mjs",
|
|
13
|
+
"@environment-safe/package": "../node_modules/@environment-safe/package/./src/index.mjs",
|
|
14
|
+
"@environment-safe/runtime-context": "../node_modules/@environment-safe/runtime-context/./src/index.mjs",
|
|
15
|
+
"browser-or-node": "../node_modules/browser-or-node/src/index.js",
|
|
16
|
+
"typescript": "../node_modules/typescript/./lib/typescript.js",
|
|
17
|
+
"@babel/cli": "../node_modules/@babel/cli/",
|
|
18
|
+
"@babel/core": "../node_modules/@babel/core/./lib/index.js",
|
|
19
|
+
"@babel/plugin-transform-modules-commonjs": "../node_modules/@babel/plugin-transform-modules-commonjs/./lib/index.js",
|
|
20
|
+
"@environment-safe/chai": "../node_modules/@environment-safe/chai/./src/index.mjs",
|
|
21
|
+
"@environment-safe/commonjs-builder": "../node_modules/@environment-safe/commonjs-builder/./src/index.mjs",
|
|
22
|
+
"@open-automaton/moka": "../node_modules/@open-automaton/moka/./src/index.mjs",
|
|
23
|
+
"babel-plugin-search-and-replace": "../node_modules/babel-plugin-search-and-replace/lib/index.js",
|
|
24
|
+
"babel-plugin-transform-import-meta": "../node_modules/babel-plugin-transform-import-meta/lib/index.esm.mjs",
|
|
25
|
+
"chai": "../node_modules/chai/chai.js",
|
|
26
|
+
"eslint": "../node_modules/eslint/./lib/api.js",
|
|
27
|
+
"husky": "../node_modules/husky/lib/index.js",
|
|
28
|
+
"mocha": "../node_modules/mocha/",
|
|
29
|
+
"@jridgewell/trace-mapping": "../node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs",
|
|
30
|
+
"commander": "../node_modules/commander/index",
|
|
31
|
+
"convert-source-map": "../node_modules/convert-source-map/index.js",
|
|
32
|
+
"fs-readdir-recursive": "../node_modules/fs-readdir-recursive/",
|
|
33
|
+
"glob": "../node_modules/glob/glob.js",
|
|
34
|
+
"make-dir": "../node_modules/make-dir/",
|
|
35
|
+
"slash": "../node_modules/slash/",
|
|
36
|
+
"@ampproject/remapping": "../node_modules/@ampproject/remapping/dist/remapping.mjs",
|
|
37
|
+
"@babel/code-frame": "../node_modules/@babel/code-frame/./lib/index.js",
|
|
38
|
+
"@babel/generator": "../node_modules/@babel/generator/./lib/index.js",
|
|
39
|
+
"@babel/helper-compilation-targets": "../node_modules/@babel/helper-compilation-targets/./lib/index.js",
|
|
40
|
+
"@babel/helper-module-transforms": "../node_modules/@babel/helper-module-transforms/./lib/index.js",
|
|
41
|
+
"@babel/helpers": "../node_modules/@babel/helpers/./lib/index.js",
|
|
42
|
+
"@babel/parser": "../node_modules/@babel/parser/./lib/index.js",
|
|
43
|
+
"@babel/template": "../node_modules/@babel/template/./lib/index.js",
|
|
44
|
+
"@babel/traverse": "../node_modules/@babel/traverse/./lib/index.js",
|
|
45
|
+
"@babel/types": "../node_modules/@babel/types/./lib/index.js",
|
|
46
|
+
"debug": "../node_modules/debug/./src/index.js",
|
|
47
|
+
"gensync": "../node_modules/gensync/index.js",
|
|
48
|
+
"json5": "../node_modules/json5/dist/index.mjs",
|
|
49
|
+
"semver": "../node_modules/semver/semver.js",
|
|
50
|
+
"@babel/helper-plugin-utils": "../node_modules/@babel/helper-plugin-utils/./lib/index.js",
|
|
51
|
+
"@babel/helper-simple-access": "../node_modules/@babel/helper-simple-access/./lib/index.js",
|
|
52
|
+
"async-arrays": "../node_modules/async-arrays/async-arrays.mjs",
|
|
53
|
+
"@environment-safe/import-introspect": "../node_modules/@environment-safe/import-introspect/./src/index.mjs",
|
|
54
|
+
"@open-automaton/automaton": "../node_modules/@open-automaton/automaton/src/automaton.js",
|
|
55
|
+
"@open-automaton/cheerio-mining-engine": "../node_modules/@open-automaton/cheerio-mining-engine/src/cheerio.js",
|
|
56
|
+
"@open-automaton/jsdom-mining-engine": "../node_modules/@open-automaton/jsdom-mining-engine/src/jsdom.js",
|
|
57
|
+
"@open-automaton/playwright-mining-engine": "../node_modules/@open-automaton/playwright-mining-engine/src/playwright.js",
|
|
58
|
+
"@open-automaton/puppeteer-mining-engine": "../node_modules/@open-automaton/puppeteer-mining-engine/src/puppeteer.js",
|
|
59
|
+
"detect-browser": "../node_modules/detect-browser/es/index.js",
|
|
60
|
+
"why-is-node-running": "../node_modules/why-is-node-running/index.js",
|
|
61
|
+
"yargs": "../node_modules/yargs/./index.mjs",
|
|
62
|
+
"tslib": "../node_modules/tslib/[object Object]",
|
|
63
|
+
"assertion-error": "../node_modules/assertion-error/./index",
|
|
64
|
+
"check-error": "../node_modules/check-error/./index.js",
|
|
65
|
+
"deep-eql": "../node_modules/deep-eql/./index",
|
|
66
|
+
"get-func-name": "../node_modules/get-func-name/./index.js",
|
|
67
|
+
"loupe": "../node_modules/loupe/./index.js",
|
|
68
|
+
"pathval": "../node_modules/pathval/./index.js",
|
|
69
|
+
"type-detect": "../node_modules/type-detect/./type-detect.js",
|
|
70
|
+
"@eslint-community/eslint-utils": "../node_modules/@eslint-community/eslint-utils/./index.mjs",
|
|
71
|
+
"@eslint-community/regexpp": "../node_modules/@eslint-community/regexpp/./index.mjs",
|
|
72
|
+
"@eslint/eslintrc": "../node_modules/@eslint/eslintrc/./lib/index.js",
|
|
73
|
+
"@eslint/js": "../node_modules/@eslint/js/./src/index.js",
|
|
74
|
+
"@humanwhocodes/config-array": "../node_modules/@humanwhocodes/config-array/api.js",
|
|
75
|
+
"@humanwhocodes/module-importer": "../node_modules/@humanwhocodes/module-importer/src/module-importer.js",
|
|
76
|
+
"@nodelib/fs.walk": "../node_modules/@nodelib/fs.walk/out/index.js",
|
|
77
|
+
"ajv": "../node_modules/ajv/lib/ajv.js",
|
|
78
|
+
"chalk": "../node_modules/chalk/",
|
|
79
|
+
"cross-spawn": "../node_modules/cross-spawn/index.js",
|
|
80
|
+
"doctrine": "../node_modules/doctrine/lib/doctrine.js",
|
|
81
|
+
"escape-string-regexp": "../node_modules/escape-string-regexp/",
|
|
82
|
+
"eslint-scope": "../node_modules/eslint-scope/./lib/index.js",
|
|
83
|
+
"eslint-visitor-keys": "../node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs",
|
|
84
|
+
"espree": "../node_modules/espree/dist/espree.cjs",
|
|
85
|
+
"esquery": "../node_modules/esquery/dist/esquery.esm.min.js",
|
|
86
|
+
"esutils": "../node_modules/esutils/lib/utils.js",
|
|
87
|
+
"fast-deep-equal": "../node_modules/fast-deep-equal/index.js",
|
|
88
|
+
"file-entry-cache": "../node_modules/file-entry-cache/cache.js",
|
|
89
|
+
"find-up": "../node_modules/find-up/",
|
|
90
|
+
"glob-parent": "../node_modules/glob-parent/index.js",
|
|
91
|
+
"globals": "../node_modules/globals/",
|
|
92
|
+
"graphemer": "../node_modules/graphemer/./lib/index.js",
|
|
93
|
+
"ignore": "../node_modules/ignore/",
|
|
94
|
+
"imurmurhash": "../node_modules/imurmurhash/imurmurhash.js",
|
|
95
|
+
"is-glob": "../node_modules/is-glob/index.js",
|
|
96
|
+
"is-path-inside": "../node_modules/is-path-inside/",
|
|
97
|
+
"js-yaml": "../node_modules/js-yaml/./dist/js-yaml.mjs",
|
|
98
|
+
"json-stable-stringify-without-jsonify": "../node_modules/json-stable-stringify-without-jsonify/index.js",
|
|
99
|
+
"levn": "../node_modules/levn/./lib/",
|
|
100
|
+
"lodash.merge": "../node_modules/lodash.merge/",
|
|
101
|
+
"minimatch": "../node_modules/minimatch/minimatch.js",
|
|
102
|
+
"natural-compare": "../node_modules/natural-compare/index.js",
|
|
103
|
+
"optionator": "../node_modules/optionator/./lib/",
|
|
104
|
+
"strip-ansi": "../node_modules/strip-ansi/",
|
|
105
|
+
"text-table": "../node_modules/text-table/index.js",
|
|
106
|
+
"ansi-colors": "../node_modules/ansi-colors/index.js",
|
|
107
|
+
"browser-stdout": "../node_modules/browser-stdout/index.js",
|
|
108
|
+
"chokidar": "../node_modules/chokidar/index.js",
|
|
109
|
+
"diff": "../node_modules/diff/./lib/index.mjs",
|
|
110
|
+
"he": "../node_modules/he/he.js",
|
|
111
|
+
"log-symbols": "../node_modules/log-symbols/",
|
|
112
|
+
"ms": "../node_modules/ms/./index",
|
|
113
|
+
"nanoid": "../node_modules/nanoid/./index.js",
|
|
114
|
+
"serialize-javascript": "../node_modules/serialize-javascript/index.js",
|
|
115
|
+
"strip-json-comments": "../node_modules/strip-json-comments/",
|
|
116
|
+
"supports-color": "../node_modules/supports-color/",
|
|
117
|
+
"workerpool": "../node_modules/workerpool/src/index.js",
|
|
118
|
+
"yargs-parser": "../node_modules/yargs-parser/./build/lib/index.js",
|
|
119
|
+
"yargs-unparser": "../node_modules/yargs-unparser/index.js",
|
|
120
|
+
"@jridgewell/resolve-uri": "../node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs",
|
|
121
|
+
"@jridgewell/sourcemap-codec": "../node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs",
|
|
122
|
+
"fs.realpath": "../node_modules/fs.realpath/index.js",
|
|
123
|
+
"inflight": "../node_modules/inflight/inflight.js",
|
|
124
|
+
"inherits": "../node_modules/inherits/./inherits.js",
|
|
125
|
+
"once": "../node_modules/once/once.js",
|
|
126
|
+
"path-is-absolute": "../node_modules/path-is-absolute/",
|
|
127
|
+
"pify": "../node_modules/pify/",
|
|
128
|
+
"@jridgewell/gen-mapping": "../node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs",
|
|
129
|
+
"@babel/highlight": "../node_modules/@babel/highlight/./lib/index.js",
|
|
130
|
+
"jsesc": "../node_modules/jsesc/jsesc.js",
|
|
131
|
+
"@babel/helper-validator-option": "../node_modules/@babel/helper-validator-option/./lib/index.js",
|
|
132
|
+
"browserslist": "../node_modules/browserslist/",
|
|
133
|
+
"lru-cache": "../node_modules/lru-cache/index.js",
|
|
134
|
+
"@babel/helper-environment-visitor": "../node_modules/@babel/helper-environment-visitor/./lib/index.js",
|
|
135
|
+
"@babel/helper-module-imports": "../node_modules/@babel/helper-module-imports/./lib/index.js",
|
|
136
|
+
"@babel/helper-split-export-declaration": "../node_modules/@babel/helper-split-export-declaration/./lib/index.js",
|
|
137
|
+
"@babel/helper-validator-identifier": "../node_modules/@babel/helper-validator-identifier/./lib/index.js",
|
|
138
|
+
"@babel/helper-function-name": "../node_modules/@babel/helper-function-name/./lib/index.js",
|
|
139
|
+
"@babel/helper-hoist-variables": "../node_modules/@babel/helper-hoist-variables/./lib/index.js",
|
|
140
|
+
"@babel/helper-string-parser": "../node_modules/@babel/helper-string-parser/./lib/index.js",
|
|
141
|
+
"to-fast-properties": "../node_modules/to-fast-properties/",
|
|
142
|
+
"sift": "../node_modules/sift/./es5m/index.js",
|
|
143
|
+
"es-module-lexer": "../node_modules/es-module-lexer/./dist/lexer.js",
|
|
144
|
+
"@open-automaton/automaton-engine": "../node_modules/@open-automaton/automaton-engine/src/automaton-engine.js",
|
|
145
|
+
"carlton": "../node_modules/carlton/carlton.js",
|
|
146
|
+
"clone": "../node_modules/clone/clone.js",
|
|
147
|
+
"extended-emitter": "../node_modules/extended-emitter/./extended-emitter.mjs",
|
|
148
|
+
"html-parser": "../node_modules/html-parser/./src/parser.js",
|
|
149
|
+
"libxmljs2": "../node_modules/libxmljs2/./index",
|
|
150
|
+
"postman-request": "../node_modules/postman-request/index.js",
|
|
151
|
+
"simple-log-function": "../node_modules/simple-log-function/simple-log-function.js",
|
|
152
|
+
"url-parse": "../node_modules/url-parse/index.js",
|
|
153
|
+
"cheerio": "../node_modules/cheerio/./lib/esm/index.js",
|
|
154
|
+
"async-fn-callback": "../node_modules/async-fn-callback/",
|
|
155
|
+
"jsdom": "../node_modules/jsdom/./lib/api.js",
|
|
156
|
+
"playwright": "../node_modules/playwright/./index.mjs",
|
|
157
|
+
"puppeteer": "../node_modules/puppeteer/./cjs-entry.js",
|
|
158
|
+
"puppeteer-extra": "../node_modules/puppeteer-extra/dist/index.esm.js",
|
|
159
|
+
"puppeteer-extra-plugin-stealth": "../node_modules/puppeteer-extra-plugin-stealth/index.js",
|
|
160
|
+
"siginfo": "../node_modules/siginfo/index.js",
|
|
161
|
+
"stackback": "../node_modules/stackback/index.js",
|
|
162
|
+
"cliui": "../node_modules/cliui/./index.mjs",
|
|
163
|
+
"escalade": "../node_modules/escalade/dist/index.mjs",
|
|
164
|
+
"get-caller-file": "../node_modules/get-caller-file/index.js",
|
|
165
|
+
"require-directory": "../node_modules/require-directory/index.js",
|
|
166
|
+
"string-width": "../node_modules/string-width/",
|
|
167
|
+
"y18n": "../node_modules/y18n/./build/lib/index.js",
|
|
168
|
+
"import-fresh": "../node_modules/import-fresh/",
|
|
169
|
+
"@humanwhocodes/object-schema": "../node_modules/@humanwhocodes/object-schema/src/index.js",
|
|
170
|
+
"@nodelib/fs.scandir": "../node_modules/@nodelib/fs.scandir/out/index.js",
|
|
171
|
+
"fastq": "../node_modules/fastq/queue.js",
|
|
172
|
+
"fast-json-stable-stringify": "../node_modules/fast-json-stable-stringify/index.js",
|
|
173
|
+
"json-schema-traverse": "../node_modules/json-schema-traverse/index.js",
|
|
174
|
+
"uri-js": "../node_modules/uri-js/dist/es5/uri.all.js",
|
|
175
|
+
"ansi-styles": "../node_modules/ansi-styles/",
|
|
176
|
+
"path-key": "../node_modules/path-key/",
|
|
177
|
+
"shebang-command": "../node_modules/shebang-command/",
|
|
178
|
+
"which": "../node_modules/which/which.js",
|
|
179
|
+
"esrecurse": "../node_modules/esrecurse/esrecurse.js",
|
|
180
|
+
"estraverse": "../node_modules/estraverse/estraverse.js",
|
|
181
|
+
"acorn": "../node_modules/acorn/dist/acorn.mjs",
|
|
182
|
+
"acorn-jsx": "../node_modules/acorn-jsx/",
|
|
183
|
+
"flat-cache": "../node_modules/flat-cache/src/cache.js",
|
|
184
|
+
"locate-path": "../node_modules/locate-path/",
|
|
185
|
+
"path-exists": "../node_modules/path-exists/",
|
|
186
|
+
"is-extglob": "../node_modules/is-extglob/index.js",
|
|
187
|
+
"argparse": "../node_modules/argparse/argparse.js",
|
|
188
|
+
"prelude-ls": "../node_modules/prelude-ls/lib/",
|
|
189
|
+
"type-check": "../node_modules/type-check/./lib/",
|
|
190
|
+
"brace-expansion": "../node_modules/brace-expansion/index.js",
|
|
191
|
+
"deep-is": "../node_modules/deep-is/index.js",
|
|
192
|
+
"@aashutoshrathi/word-wrap": "../node_modules/@aashutoshrathi/word-wrap/index.js",
|
|
193
|
+
"fast-levenshtein": "../node_modules/fast-levenshtein/levenshtein.js",
|
|
194
|
+
"ansi-regex": "../node_modules/ansi-regex/",
|
|
195
|
+
"anymatch": "../node_modules/anymatch/",
|
|
196
|
+
"braces": "../node_modules/braces/index.js",
|
|
197
|
+
"is-binary-path": "../node_modules/is-binary-path/",
|
|
198
|
+
"normalize-path": "../node_modules/normalize-path/index.js",
|
|
199
|
+
"readdirp": "../node_modules/readdirp/index.js",
|
|
200
|
+
"is-unicode-supported": "../node_modules/is-unicode-supported/",
|
|
201
|
+
"randombytes": "../node_modules/randombytes/index.js",
|
|
202
|
+
"has-flag": "../node_modules/has-flag/",
|
|
203
|
+
"camelcase": "../node_modules/camelcase/",
|
|
204
|
+
"decamelize": "../node_modules/decamelize/",
|
|
205
|
+
"flat": "../node_modules/flat/index.js",
|
|
206
|
+
"is-plain-obj": "../node_modules/is-plain-obj/",
|
|
207
|
+
"wrappy": "../node_modules/wrappy/wrappy.js",
|
|
208
|
+
"@jridgewell/set-array": "../node_modules/@jridgewell/set-array/dist/set-array.mjs",
|
|
209
|
+
"js-tokens": "../node_modules/js-tokens/",
|
|
210
|
+
"caniuse-lite": "../node_modules/caniuse-lite/dist/unpacker/index.js",
|
|
211
|
+
"electron-to-chromium": "../node_modules/electron-to-chromium/index.js",
|
|
212
|
+
"update-browserslist-db": "../node_modules/update-browserslist-db/",
|
|
213
|
+
"yallist": "../node_modules/yallist/yallist.js",
|
|
214
|
+
"libxmljs": "../node_modules/libxmljs/dist/index.js",
|
|
215
|
+
"es6-template-strings": "../node_modules/es6-template-strings/",
|
|
216
|
+
"@mapbox/node-pre-gyp": "../node_modules/@mapbox/node-pre-gyp/./lib/node-pre-gyp.js",
|
|
217
|
+
"bindings": "../node_modules/bindings/./bindings.js",
|
|
218
|
+
"nan": "../node_modules/nan/include_dirs.js",
|
|
219
|
+
"@postman/form-data": "../node_modules/@postman/form-data/./lib/form_data",
|
|
220
|
+
"@postman/tough-cookie": "../node_modules/@postman/tough-cookie/./lib/cookie",
|
|
221
|
+
"@postman/tunnel-agent": "../node_modules/@postman/tunnel-agent/index.js",
|
|
222
|
+
"aws-sign2": "../node_modules/aws-sign2/index.js",
|
|
223
|
+
"aws4": "../node_modules/aws4/aws4.js",
|
|
224
|
+
"brotli": "../node_modules/brotli/index.js",
|
|
225
|
+
"caseless": "../node_modules/caseless/index.js",
|
|
226
|
+
"combined-stream": "../node_modules/combined-stream/./lib/combined_stream",
|
|
227
|
+
"extend": "../node_modules/extend/index",
|
|
228
|
+
"forever-agent": "../node_modules/forever-agent/index.js",
|
|
229
|
+
"har-validator": "../node_modules/har-validator/lib/promise.js",
|
|
230
|
+
"http-signature": "../node_modules/http-signature/lib/index.js",
|
|
231
|
+
"is-typedarray": "../node_modules/is-typedarray/index.js",
|
|
232
|
+
"isstream": "../node_modules/isstream/isstream.js",
|
|
233
|
+
"json-stringify-safe": "../node_modules/json-stringify-safe/stringify.js",
|
|
234
|
+
"mime-types": "../node_modules/mime-types/",
|
|
235
|
+
"oauth-sign": "../node_modules/oauth-sign/index.js",
|
|
236
|
+
"performance-now": "../node_modules/performance-now/lib/performance-now.js",
|
|
237
|
+
"qs": "../node_modules/qs/lib/index.js",
|
|
238
|
+
"safe-buffer": "../node_modules/safe-buffer/index.js",
|
|
239
|
+
"stream-length": "../node_modules/stream-length/index.js",
|
|
240
|
+
"uuid": "../node_modules/uuid/./dist/esm-node/index.js",
|
|
241
|
+
"loglevel": "../node_modules/loglevel/lib/loglevel.js",
|
|
242
|
+
"querystringify": "../node_modules/querystringify/index.js",
|
|
243
|
+
"requires-port": "../node_modules/requires-port/index.js",
|
|
244
|
+
"cheerio-select": "../node_modules/cheerio-select/lib/esm/index.js",
|
|
245
|
+
"dom-serializer": "../node_modules/dom-serializer/lib/esm/index.js",
|
|
246
|
+
"domhandler": "../node_modules/domhandler/lib/esm/index.js",
|
|
247
|
+
"domutils": "../node_modules/domutils/lib/esm/index.js",
|
|
248
|
+
"htmlparser2": "../node_modules/htmlparser2/./lib/esm/index.js",
|
|
249
|
+
"parse5": "../node_modules/parse5/dist/index.js",
|
|
250
|
+
"parse5-htmlparser2-tree-adapter": "../node_modules/parse5-htmlparser2-tree-adapter/dist/index.js",
|
|
251
|
+
"abab": "../node_modules/abab/index.js",
|
|
252
|
+
"acorn-globals": "../node_modules/acorn-globals/",
|
|
253
|
+
"cssom": "../node_modules/cssom/./lib/index.js",
|
|
254
|
+
"cssstyle": "../node_modules/cssstyle/./lib/CSSStyleDeclaration.js",
|
|
255
|
+
"data-urls": "../node_modules/data-urls/lib/parser.js",
|
|
256
|
+
"decimal.js": "../node_modules/decimal.js/./decimal.mjs",
|
|
257
|
+
"domexception": "../node_modules/domexception/index.js",
|
|
258
|
+
"escodegen": "../node_modules/escodegen/escodegen.js",
|
|
259
|
+
"form-data": "../node_modules/form-data/./lib/form_data",
|
|
260
|
+
"html-encoding-sniffer": "../node_modules/html-encoding-sniffer/lib/html-encoding-sniffer.js",
|
|
261
|
+
"http-proxy-agent": "../node_modules/http-proxy-agent/./dist/index.js",
|
|
262
|
+
"https-proxy-agent": "../node_modules/https-proxy-agent/dist/index",
|
|
263
|
+
"is-potential-custom-element-name": "../node_modules/is-potential-custom-element-name/index.js",
|
|
264
|
+
"nwsapi": "../node_modules/nwsapi/./src/nwsapi",
|
|
265
|
+
"saxes": "../node_modules/saxes/saxes.js",
|
|
266
|
+
"symbol-tree": "../node_modules/symbol-tree/lib/SymbolTree.js",
|
|
267
|
+
"tough-cookie": "../node_modules/tough-cookie/./lib/cookie",
|
|
268
|
+
"w3c-hr-time": "../node_modules/w3c-hr-time/index.js",
|
|
269
|
+
"w3c-xmlserializer": "../node_modules/w3c-xmlserializer/lib/serialize.js",
|
|
270
|
+
"webidl-conversions": "../node_modules/webidl-conversions/lib/index.js",
|
|
271
|
+
"whatwg-encoding": "../node_modules/whatwg-encoding/lib/whatwg-encoding.js",
|
|
272
|
+
"whatwg-mimetype": "../node_modules/whatwg-mimetype/lib/mime-type.js",
|
|
273
|
+
"whatwg-url": "../node_modules/whatwg-url/index.js",
|
|
274
|
+
"ws": "../node_modules/ws/./wrapper.mjs",
|
|
275
|
+
"xml-name-validator": "../node_modules/xml-name-validator/lib/xml-name-validator.js",
|
|
276
|
+
"playwright-core": "../node_modules/playwright-core/./index.mjs",
|
|
277
|
+
"cross-fetch": "../node_modules/cross-fetch/dist/node-ponyfill.js",
|
|
278
|
+
"extract-zip": "../node_modules/extract-zip/index.js",
|
|
279
|
+
"pkg-dir": "../node_modules/pkg-dir/",
|
|
280
|
+
"progress": "../node_modules/progress/./index.js",
|
|
281
|
+
"proxy-from-env": "../node_modules/proxy-from-env/index.js",
|
|
282
|
+
"rimraf": "../node_modules/rimraf/rimraf.js",
|
|
283
|
+
"tar-fs": "../node_modules/tar-fs/index.js",
|
|
284
|
+
"unbzip2-stream": "../node_modules/unbzip2-stream/index.js",
|
|
285
|
+
"deepmerge": "../node_modules/deepmerge/dist/cjs.js",
|
|
286
|
+
"puppeteer-extra-plugin": "../node_modules/puppeteer-extra-plugin/dist/index.esm.js",
|
|
287
|
+
"puppeteer-extra-plugin-user-preferences": "../node_modules/puppeteer-extra-plugin-user-preferences/index.js",
|
|
288
|
+
"wrap-ansi": "../node_modules/wrap-ansi/",
|
|
289
|
+
"emoji-regex": "../node_modules/emoji-regex/index.js",
|
|
290
|
+
"is-fullwidth-code-point": "../node_modules/is-fullwidth-code-point/",
|
|
291
|
+
"parent-module": "../node_modules/parent-module/",
|
|
292
|
+
"resolve-from": "../node_modules/resolve-from/",
|
|
293
|
+
"@nodelib/fs.stat": "../node_modules/@nodelib/fs.stat/out/index.js",
|
|
294
|
+
"run-parallel": "../node_modules/run-parallel/index.js",
|
|
295
|
+
"reusify": "../node_modules/reusify/reusify.js",
|
|
296
|
+
"color-convert": "../node_modules/color-convert/",
|
|
297
|
+
"shebang-regex": "../node_modules/shebang-regex/",
|
|
298
|
+
"isexe": "../node_modules/isexe/index.js",
|
|
299
|
+
"flatted": "../node_modules/flatted/./esm/index.js",
|
|
300
|
+
"keyv": "../node_modules/keyv/src/index.js",
|
|
301
|
+
"p-locate": "../node_modules/p-locate/",
|
|
302
|
+
"balanced-match": "../node_modules/balanced-match/index.js",
|
|
303
|
+
"concat-map": "../node_modules/concat-map/index.js",
|
|
304
|
+
"picomatch": "../node_modules/picomatch/index.js",
|
|
305
|
+
"fill-range": "../node_modules/fill-range/index.js",
|
|
306
|
+
"binary-extensions": "../node_modules/binary-extensions/",
|
|
307
|
+
"picocolors": "../node_modules/picocolors/./picocolors.js",
|
|
308
|
+
"es5-ext": "../node_modules/es5-ext/",
|
|
309
|
+
"esniff": "../node_modules/esniff/",
|
|
310
|
+
"detect-libc": "../node_modules/detect-libc/lib/detect-libc.js",
|
|
311
|
+
"node-fetch": "../node_modules/node-fetch/lib/index.mjs",
|
|
312
|
+
"nopt": "../node_modules/nopt/lib/nopt.js",
|
|
313
|
+
"npmlog": "../node_modules/npmlog/log.js",
|
|
314
|
+
"tar": "../node_modules/tar/",
|
|
315
|
+
"asynckit": "../node_modules/asynckit/index.js",
|
|
316
|
+
"psl": "../node_modules/psl/index.js",
|
|
317
|
+
"universalify": "../node_modules/universalify/",
|
|
318
|
+
"base64-js": "../node_modules/base64-js/index.js",
|
|
319
|
+
"delayed-stream": "../node_modules/delayed-stream/./lib/delayed_stream",
|
|
320
|
+
"har-schema": "../node_modules/har-schema/lib/index.js",
|
|
321
|
+
"assert-plus": "../node_modules/assert-plus/./assert.js",
|
|
322
|
+
"jsprim": "../node_modules/jsprim/./lib/jsprim.js",
|
|
323
|
+
"sshpk": "../node_modules/sshpk/lib/index.js",
|
|
324
|
+
"mime-db": "../node_modules/mime-db/",
|
|
325
|
+
"side-channel": "../node_modules/side-channel/index.js",
|
|
326
|
+
"bluebird": "../node_modules/bluebird/./js/release/bluebird.js",
|
|
327
|
+
"boolbase": "../node_modules/boolbase/index.js",
|
|
328
|
+
"css-select": "../node_modules/css-select/lib/esm/index.js",
|
|
329
|
+
"css-what": "../node_modules/css-what/lib/es/index.js",
|
|
330
|
+
"domelementtype": "../node_modules/domelementtype/lib/esm/index.js",
|
|
331
|
+
"entities": "../node_modules/entities/./lib/esm/index.js",
|
|
332
|
+
"acorn-walk": "../node_modules/acorn-walk/dist/walk.mjs",
|
|
333
|
+
"esprima": "../node_modules/esprima/dist/esprima.js",
|
|
334
|
+
"@tootallnate/once": "../node_modules/@tootallnate/once/./dist/index.js",
|
|
335
|
+
"agent-base": "../node_modules/agent-base/dist/src/index",
|
|
336
|
+
"xmlchars": "../node_modules/xmlchars/xmlchars.js",
|
|
337
|
+
"browser-process-hrtime": "../node_modules/browser-process-hrtime/index.js",
|
|
338
|
+
"iconv-lite": "../node_modules/iconv-lite/./lib/index.js",
|
|
339
|
+
"tr46": "../node_modules/tr46/index.js",
|
|
340
|
+
"get-stream": "../node_modules/get-stream/",
|
|
341
|
+
"yauzl": "../node_modules/yauzl/index.js",
|
|
342
|
+
"chownr": "../node_modules/chownr/chownr.js",
|
|
343
|
+
"mkdirp-classic": "../node_modules/mkdirp-classic/index.js",
|
|
344
|
+
"pump": "../node_modules/pump/",
|
|
345
|
+
"tar-stream": "../node_modules/tar-stream/index.js",
|
|
346
|
+
"through": "../node_modules/through/index.js",
|
|
347
|
+
"merge-deep": "../node_modules/merge-deep/index.js",
|
|
348
|
+
"puppeteer-extra-plugin-user-data-dir": "../node_modules/puppeteer-extra-plugin-user-data-dir/index.js",
|
|
349
|
+
"callsites": "../node_modules/callsites/",
|
|
350
|
+
"queue-microtask": "../node_modules/queue-microtask/index.js",
|
|
351
|
+
"color-name": "../node_modules/color-name/index.js",
|
|
352
|
+
"json-buffer": "../node_modules/json-buffer/",
|
|
353
|
+
"p-limit": "../node_modules/p-limit/",
|
|
354
|
+
"to-regex-range": "../node_modules/to-regex-range/index.js",
|
|
355
|
+
"es6-iterator": "../node_modules/es6-iterator/",
|
|
356
|
+
"es6-symbol": "../node_modules/es6-symbol/",
|
|
357
|
+
"next-tick": "../node_modules/next-tick/",
|
|
358
|
+
"d": "../node_modules/d/",
|
|
359
|
+
"abbrev": "../node_modules/abbrev/abbrev.js",
|
|
360
|
+
"are-we-there-yet": "../node_modules/are-we-there-yet/lib/index.js",
|
|
361
|
+
"console-control-strings": "../node_modules/console-control-strings/index.js",
|
|
362
|
+
"gauge": "../node_modules/gauge/index.js",
|
|
363
|
+
"set-blocking": "../node_modules/set-blocking/index.js",
|
|
364
|
+
"fs-minipass": "../node_modules/fs-minipass/index.js",
|
|
365
|
+
"minipass": "../node_modules/minipass/[object Object]",
|
|
366
|
+
"minizlib": "../node_modules/minizlib/index.js",
|
|
367
|
+
"mkdirp": "../node_modules/mkdirp/index.js",
|
|
368
|
+
"extsprintf": "../node_modules/extsprintf/./lib/extsprintf.js",
|
|
369
|
+
"json-schema": "../node_modules/json-schema/./lib/validate.js",
|
|
370
|
+
"verror": "../node_modules/verror/./lib/verror.js",
|
|
371
|
+
"asn1": "../node_modules/asn1/lib/index.js",
|
|
372
|
+
"dashdash": "../node_modules/dashdash/./lib/dashdash.js",
|
|
373
|
+
"getpass": "../node_modules/getpass/lib/index.js",
|
|
374
|
+
"safer-buffer": "../node_modules/safer-buffer/safer.js",
|
|
375
|
+
"jsbn": "../node_modules/jsbn/index.js",
|
|
376
|
+
"tweetnacl": "../node_modules/tweetnacl/nacl-fast.js",
|
|
377
|
+
"ecc-jsbn": "../node_modules/ecc-jsbn/index.js",
|
|
378
|
+
"bcrypt-pbkdf": "../node_modules/bcrypt-pbkdf/index.js",
|
|
379
|
+
"call-bind": "../node_modules/call-bind/index.js",
|
|
380
|
+
"get-intrinsic": "../node_modules/get-intrinsic/index.js",
|
|
381
|
+
"object-inspect": "../node_modules/object-inspect/index.js",
|
|
382
|
+
"nth-check": "../node_modules/nth-check/lib/esm/index.js",
|
|
383
|
+
"fd-slicer": "../node_modules/fd-slicer/index.js",
|
|
384
|
+
"buffer-crc32": "../node_modules/buffer-crc32/index.js",
|
|
385
|
+
"end-of-stream": "../node_modules/end-of-stream/index.js",
|
|
386
|
+
"bl": "../node_modules/bl/bl.js",
|
|
387
|
+
"fs-constants": "../node_modules/fs-constants/index.js",
|
|
388
|
+
"readable-stream": "../node_modules/readable-stream/readable.js",
|
|
389
|
+
"arr-union": "../node_modules/arr-union/index.js",
|
|
390
|
+
"clone-deep": "../node_modules/clone-deep/index.js",
|
|
391
|
+
"kind-of": "../node_modules/kind-of/index.js",
|
|
392
|
+
"fs-extra": "../node_modules/fs-extra/./lib/index.js",
|
|
393
|
+
"yocto-queue": "../node_modules/yocto-queue/",
|
|
394
|
+
"is-number": "../node_modules/is-number/index.js",
|
|
395
|
+
"delegates": "../node_modules/delegates/",
|
|
396
|
+
"aproba": "../node_modules/aproba/index.js",
|
|
397
|
+
"color-support": "../node_modules/color-support/index.js",
|
|
398
|
+
"has-unicode": "../node_modules/has-unicode/index.js",
|
|
399
|
+
"object-assign": "../node_modules/object-assign/",
|
|
400
|
+
"signal-exit": "../node_modules/signal-exit/index.js",
|
|
401
|
+
"wide-align": "../node_modules/wide-align/align.js",
|
|
402
|
+
"core-util-is": "../node_modules/core-util-is/lib/util.js",
|
|
403
|
+
"function-bind": "../node_modules/function-bind/index",
|
|
404
|
+
"has": "../node_modules/has/./src",
|
|
405
|
+
"has-proto": "../node_modules/has-proto/index.js",
|
|
406
|
+
"has-symbols": "../node_modules/has-symbols/index.js",
|
|
407
|
+
"pend": "../node_modules/pend/index.js",
|
|
408
|
+
"util-deprecate": "../node_modules/util-deprecate/node.js",
|
|
409
|
+
"for-own": "../node_modules/for-own/index.js",
|
|
410
|
+
"is-plain-object": "../node_modules/is-plain-object/index.js",
|
|
411
|
+
"lazy-cache": "../node_modules/lazy-cache/index.js",
|
|
412
|
+
"shallow-clone": "../node_modules/shallow-clone/index.js",
|
|
413
|
+
"is-buffer": "../node_modules/is-buffer/index.js",
|
|
414
|
+
"graceful-fs": "../node_modules/graceful-fs/graceful-fs.js",
|
|
415
|
+
"jsonfile": "../node_modules/jsonfile/index.js",
|
|
416
|
+
"for-in": "../node_modules/for-in/index.js",
|
|
417
|
+
"isobject": "../node_modules/isobject/index.js",
|
|
418
|
+
"is-extendable": "../node_modules/is-extendable/index.js",
|
|
419
|
+
"mixin-object": "../node_modules/mixin-object/index.js",
|
|
420
|
+
"@environment-safe/file": "../src/index.mjs"
|
|
421
|
+
} }</script>
|
|
422
|
+
<script type="module">
|
|
423
|
+
(async ()=>{
|
|
424
|
+
window.fixtures = await (await fetch('/fixtures.json')).json();
|
|
425
|
+
})();
|
|
426
|
+
/*(async ()=>{
|
|
427
|
+
window.testEvents = await (await fetch('/events.json')).json();
|
|
428
|
+
window.testEvents.forEach((eventType)=>{
|
|
429
|
+
document.body.addEventListener(eventType, (event)=>{
|
|
430
|
+
console.log('event', JSON.stringify([eventType, event]) );
|
|
431
|
+
});
|
|
432
|
+
});
|
|
433
|
+
})();*/
|
|
434
|
+
</script>
|
|
435
|
+
|
|
436
|
+
</head>
|
|
437
|
+
<body>
|
|
438
|
+
<input id="dummy-button" type="button" value="Add to favorites" >
|
|
439
|
+
|
|
440
|
+
<div id="mocha"></div>
|
|
441
|
+
<script type=module>
|
|
442
|
+
import { detect } from 'detect-browser';
|
|
443
|
+
const browser = detect();
|
|
444
|
+
if((browser && (
|
|
445
|
+
browser.name === 'safari' &&
|
|
446
|
+
parseInt(browser.version) < 16
|
|
447
|
+
)) || !browser){
|
|
448
|
+
throw new Error('Safari < 16.4 not supported!');
|
|
449
|
+
}
|
|
450
|
+
</script>
|
|
451
|
+
<script src="/node_modules/mocha/mocha.js"></script>
|
|
452
|
+
|
|
453
|
+
<script>mocha.setup({ui:'bdd', reporter: 'json-stream'})</script>
|
|
454
|
+
<script type="module" src="/test/test.mjs"></script>
|
|
455
|
+
|
|
456
|
+
<script type="module">
|
|
457
|
+
import { bind } from '@open-automaton/moka';
|
|
458
|
+
window.moka = { bind };
|
|
459
|
+
mocha.checkLeaks();
|
|
460
|
+
mocha.globals([]);
|
|
461
|
+
mocha.run();
|
|
462
|
+
</script>
|
|
463
|
+
|
|
464
|
+
</body>
|
|
465
|
+
<html>
|
|
466
|
+
|
package/test/test.mjs
CHANGED
|
@@ -1,48 +1,101 @@
|
|
|
1
1
|
/* global describe:false */
|
|
2
2
|
import { chai } from '@environment-safe/chai';
|
|
3
|
-
import { it } from '@open-automaton/moka';
|
|
4
|
-
import { File } from '../src/index.mjs';
|
|
3
|
+
import { it, configure, interactive } from '@open-automaton/moka';
|
|
4
|
+
import { File, Path, Download } from '../src/index.mjs';
|
|
5
5
|
const should = chai.should();
|
|
6
6
|
|
|
7
|
-
describe('
|
|
7
|
+
describe('@environment-safe/file', ()=>{
|
|
8
8
|
describe('performs a simple test suite', ()=>{
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const testKnownDirectory = 'videos';
|
|
10
|
+
const filesystemName = Path.join(
|
|
11
|
+
Path.location(testKnownDirectory),
|
|
12
|
+
`file${Math.floor( Math.random() * 1000000)}`
|
|
13
|
+
);
|
|
14
|
+
const fileProtocolName = `file://${Path.join(Path.current, 'src', 'index.mjs')}`;
|
|
15
|
+
const missingFileProtocolName = `file://${Path.join(Path.current, 'src', 'unknown.mjs')}`;
|
|
16
|
+
const fileRelativeName = Path.join('..', 'src', 'index.mjs');
|
|
17
|
+
const missingFileRelativeName = Path.join('..', 'src', 'unknown.mjs');
|
|
18
|
+
const download = new Download();
|
|
19
|
+
configure({
|
|
20
|
+
dialog : async (context, actions)=> await actions.confirm(), // OK everything,
|
|
21
|
+
wantsInput : async (context, actions)=> await actions.click('#mocha'), // click everything
|
|
22
|
+
downloads: (dl)=> download.observe(dl)
|
|
23
|
+
});
|
|
24
|
+
/**********************************************************
|
|
25
|
+
* Until Playwright supports the filesystem APIs this must
|
|
26
|
+
* tested interactively and should be skipped headless
|
|
27
|
+
**********************************************************/
|
|
28
|
+
interactive(`creates, saves, loads & deletes ${filesystemName} using FilesystemAPI`, async function(){
|
|
29
|
+
this.timeout(40000);
|
|
13
30
|
should.exist(File);
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
(await File.exists(file.path, file.directory)).should.equal(false);
|
|
31
|
+
const options = { cache: true, filesystemAPI: true };
|
|
32
|
+
const file = new File(filesystemName, options);
|
|
33
|
+
(await File.exists(filesystemName)).should.equal(false);
|
|
19
34
|
await file.body('{}').save();
|
|
20
|
-
(await File.exists(
|
|
35
|
+
(await File.exists(filesystemName)).should.equal(true);
|
|
21
36
|
await file.body('{"foo":"bar"}').save();
|
|
22
|
-
const newFile = new File(
|
|
23
|
-
directory: 'documents',
|
|
24
|
-
cache: true
|
|
25
|
-
});
|
|
37
|
+
const newFile = new File(filesystemName, options);
|
|
26
38
|
const body = (await newFile.load()).body();
|
|
27
39
|
const str = body.cast('string');
|
|
28
40
|
str.should.equal('{"foo":"bar"}');
|
|
29
41
|
await file.delete();
|
|
30
42
|
}); //*/
|
|
31
43
|
|
|
32
|
-
|
|
44
|
+
interactive(`lists file in user's ${testKnownDirectory} dir`, async function(){
|
|
33
45
|
//assumes you have some file in your documents directory
|
|
34
|
-
const list = await File.list(
|
|
46
|
+
const list = await File.list(Path.location(testKnownDirectory), {
|
|
35
47
|
files: true,
|
|
36
48
|
directories: false
|
|
37
49
|
});
|
|
38
50
|
should.exist(list);
|
|
39
|
-
|
|
51
|
+
should.exist(list[0]);
|
|
52
|
+
const file = new File(Path.join(
|
|
53
|
+
Path.location(testKnownDirectory),
|
|
54
|
+
list[0]
|
|
55
|
+
));
|
|
40
56
|
await file.load();
|
|
41
57
|
file.body().cast('string').length.should.be.above(1);
|
|
42
58
|
});
|
|
43
59
|
|
|
60
|
+
it(`examines & loads ${fileProtocolName}`, async function(){
|
|
61
|
+
this.timeout(40000);
|
|
62
|
+
should.exist(File);
|
|
63
|
+
(await File.exists(missingFileProtocolName)).should.equal(false);
|
|
64
|
+
(await File.exists(fileProtocolName)).should.equal(true);
|
|
65
|
+
const file = new File(fileProtocolName, { cache: true });
|
|
66
|
+
const body = (await file.load()).body();
|
|
67
|
+
const str = body.cast('string');
|
|
68
|
+
str.should.contain('export class File');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it(`examines & loads ${fileRelativeName}`, async function(){
|
|
72
|
+
this.timeout(40000);
|
|
73
|
+
should.exist(File);
|
|
74
|
+
(await File.exists(missingFileRelativeName)).should.equal(false);
|
|
75
|
+
(await File.exists(fileRelativeName)).should.equal(true);
|
|
76
|
+
const file = new File(fileRelativeName, { cache: true });
|
|
77
|
+
const body = (await file.load()).body();
|
|
78
|
+
const str = body.cast('string');
|
|
79
|
+
str.should.contain('export class File');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it(`saves ${fileRelativeName}`, async function(){
|
|
83
|
+
this.timeout(40000);
|
|
84
|
+
should.exist(File);
|
|
85
|
+
(await File.exists(fileRelativeName)).should.equal(true);
|
|
86
|
+
const file = new File(fileRelativeName, { cache: true });
|
|
87
|
+
//we're going to live dangerously and replace the source, because we save to downloads
|
|
88
|
+
await file.load();
|
|
89
|
+
file.body('foo!');
|
|
90
|
+
const anticipatedDownload = download.expect();
|
|
91
|
+
await file.save();
|
|
92
|
+
const result = await anticipatedDownload;
|
|
93
|
+
const downloadedText = await result.text();
|
|
94
|
+
downloadedText.should.equal('foo!');
|
|
95
|
+
});
|
|
96
|
+
|
|
44
97
|
it('loads an implicit, relative URL', async function(){
|
|
45
|
-
const file = new File('test
|
|
98
|
+
const file = new File('local-file-test.html');
|
|
46
99
|
await file.load();
|
|
47
100
|
const titleMatches = file.body().cast('string').match(/@environment-safe\/file/);
|
|
48
101
|
should.exist(titleMatches);
|
|
@@ -50,7 +103,10 @@ describe('module', ()=>{
|
|
|
50
103
|
});
|
|
51
104
|
|
|
52
105
|
it('loads an explicit, relative URL', async function(){
|
|
53
|
-
const file = new File(
|
|
106
|
+
const file = new File(Path.join(
|
|
107
|
+
'../node_modules/@environment-safe/chai',
|
|
108
|
+
'README.md'
|
|
109
|
+
));
|
|
54
110
|
await file.load();
|
|
55
111
|
file.body().cast('string').length.should.be.above(1);
|
|
56
112
|
});
|
|
File without changes
|