First functional version

This commit is contained in:
Fabian Stamm 2021-08-09 22:43:58 +02:00
parent e21a9fad3f
commit cf1347ca3a
9 changed files with 1070 additions and 163 deletions

View File

@ -1,2 +1,3 @@
[*]
indent_size = 3
max_line_length = 100

1
.gitignore vendored
View File

@ -1 +1,2 @@
node_modules/
testrepo/

View File

@ -1,19 +1,22 @@
{
"name": "simplevsc",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"ts-node": "^10.2.0",
"typescript": "^4.3.5"
},
"dependencies": {
"jssha": "^3.2.0"
}
"name": "simplevsc",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "nodemon -e ts --exec ts-node src/test.ts",
"build": "tsc"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@types/node": "^16.4.13",
"nodemon": "^2.0.12",
"ts-node": "^10.2.0",
"typescript": "^4.3.5"
},
"dependencies": {
"jssha": "^3.2.0"
}
}

View File

@ -1,7 +1,9 @@
lockfileVersion: 5.3
specifiers:
'@types/node': ^16.4.13
jssha: ^3.2.0
nodemon: ^2.0.12
ts-node: ^10.2.0
typescript: ^4.3.5
@ -9,7 +11,9 @@ dependencies:
jssha: 3.2.0
devDependencies:
ts-node: 10.2.0_typescript@4.3.5
'@types/node': 16.4.13
nodemon: 2.0.12
ts-node: 10.2.0_dea0625f6d31b223e93dc3dc354b8b43
typescript: 4.3.5
packages:
@ -26,6 +30,18 @@ packages:
'@cspotcode/source-map-consumer': 0.8.0
dev: true
/@sindresorhus/is/0.14.0:
resolution: {integrity: sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ==}
engines: {node: '>=6'}
dev: true
/@szmarczak/http-timer/1.1.2:
resolution: {integrity: sha512-XIB2XbzHTN6ieIjfIMV9hlVcfPU26s2vafYWQcZHWXHOxiaRZYEDKEwdl129Zyg50+foYV2jCgtrqSA6qNuNSA==}
engines: {node: '>=6'}
dependencies:
defer-to-connect: 1.1.3
dev: true
/@tsconfig/node10/1.0.8:
resolution: {integrity: sha512-6XFfSQmMgq0CFLY1MslA/CPUfhIL919M1rMsa5lP2P097N2Wd1sSX0tx1u4olM16fLNhtHZpRhedZJphNJqmZg==}
dev: true
@ -42,6 +58,14 @@ packages:
resolution: {integrity: sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==}
dev: true
/@types/node/16.4.13:
resolution: {integrity: sha512-bLL69sKtd25w7p1nvg9pigE4gtKVpGTPojBFLMkGHXuUgap2sLqQt2qUnqmVCDfzGUL0DRNZP+1prIZJbMeAXg==}
dev: true
/abbrev/1.1.1:
resolution: {integrity: sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==}
dev: true
/acorn-walk/8.1.1:
resolution: {integrity: sha512-FbJdceMlPHEAWJOILDk1fXD8lnTlEIWFkqtfk+MvmL5q/qlHfN7GEHcsFZWt/Tea9jRNPWUZG4G976nqAAmU9w==}
engines: {node: '>=0.4.0'}
@ -53,28 +77,692 @@ packages:
hasBin: true
dev: true
/ansi-align/3.0.0:
resolution: {integrity: sha512-ZpClVKqXN3RGBmKibdfWzqCY4lnjEuoNzU5T0oEFpfd/z5qJHVarukridD4juLO2FXMiwUQxr9WqQtaYa8XRYw==}
dependencies:
string-width: 3.1.0
dev: true
/ansi-regex/4.1.0:
resolution: {integrity: sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==}
engines: {node: '>=6'}
dev: true
/ansi-regex/5.0.0:
resolution: {integrity: sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==}
engines: {node: '>=8'}
dev: true
/ansi-styles/4.3.0:
resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==}
engines: {node: '>=8'}
dependencies:
color-convert: 2.0.1
dev: true
/anymatch/3.1.2:
resolution: {integrity: sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==}
engines: {node: '>= 8'}
dependencies:
normalize-path: 3.0.0
picomatch: 2.3.0
dev: true
/arg/4.1.3:
resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==}
dev: true
/balanced-match/1.0.2:
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
dev: true
/binary-extensions/2.2.0:
resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==}
engines: {node: '>=8'}
dev: true
/boxen/4.2.0:
resolution: {integrity: sha512-eB4uT9RGzg2odpER62bBwSLvUeGC+WbRjjyyFhGsKnc8wp/m0+hQsMUvUe3H2V0D5vw0nBdO1hCJoZo5mKeuIQ==}
engines: {node: '>=8'}
dependencies:
ansi-align: 3.0.0
camelcase: 5.3.1
chalk: 3.0.0
cli-boxes: 2.2.1
string-width: 4.2.2
term-size: 2.2.1
type-fest: 0.8.1
widest-line: 3.1.0
dev: true
/brace-expansion/1.1.11:
resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==}
dependencies:
balanced-match: 1.0.2
concat-map: 0.0.1
dev: true
/braces/3.0.2:
resolution: {integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==}
engines: {node: '>=8'}
dependencies:
fill-range: 7.0.1
dev: true
/cacheable-request/6.1.0:
resolution: {integrity: sha512-Oj3cAGPCqOZX7Rz64Uny2GYAZNliQSqfbePrgAQ1wKAihYmCUnraBtJtKcGR4xz7wF+LoJC+ssFZvv5BgF9Igg==}
engines: {node: '>=8'}
dependencies:
clone-response: 1.0.2
get-stream: 5.2.0
http-cache-semantics: 4.1.0
keyv: 3.1.0
lowercase-keys: 2.0.0
normalize-url: 4.5.1
responselike: 1.0.2
dev: true
/camelcase/5.3.1:
resolution: {integrity: sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==}
engines: {node: '>=6'}
dev: true
/chalk/3.0.0:
resolution: {integrity: sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==}
engines: {node: '>=8'}
dependencies:
ansi-styles: 4.3.0
supports-color: 7.2.0
dev: true
/chokidar/3.5.2:
resolution: {integrity: sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==}
engines: {node: '>= 8.10.0'}
dependencies:
anymatch: 3.1.2
braces: 3.0.2
glob-parent: 5.1.2
is-binary-path: 2.1.0
is-glob: 4.0.1
normalize-path: 3.0.0
readdirp: 3.6.0
optionalDependencies:
fsevents: 2.3.2
dev: true
/ci-info/2.0.0:
resolution: {integrity: sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==}
dev: true
/cli-boxes/2.2.1:
resolution: {integrity: sha512-y4coMcylgSCdVinjiDBuR8PCC2bLjyGTwEmPb9NHR/QaNU6EUOXcTY/s6VjGMD6ENSEaeQYHCY0GNGS5jfMwPw==}
engines: {node: '>=6'}
dev: true
/clone-response/1.0.2:
resolution: {integrity: sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=}
dependencies:
mimic-response: 1.0.1
dev: true
/color-convert/2.0.1:
resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==}
engines: {node: '>=7.0.0'}
dependencies:
color-name: 1.1.4
dev: true
/color-name/1.1.4:
resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==}
dev: true
/concat-map/0.0.1:
resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=}
dev: true
/configstore/5.0.1:
resolution: {integrity: sha512-aMKprgk5YhBNyH25hj8wGt2+D52Sw1DRRIzqBwLp2Ya9mFmY8KPvvtvmna8SxVR9JMZ4kzMD68N22vlaRpkeFA==}
engines: {node: '>=8'}
dependencies:
dot-prop: 5.3.0
graceful-fs: 4.2.8
make-dir: 3.1.0
unique-string: 2.0.0
write-file-atomic: 3.0.3
xdg-basedir: 4.0.0
dev: true
/create-require/1.1.1:
resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==}
dev: true
/crypto-random-string/2.0.0:
resolution: {integrity: sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA==}
engines: {node: '>=8'}
dev: true
/debug/2.6.9:
resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==}
dependencies:
ms: 2.0.0
dev: true
/debug/3.2.7:
resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==}
dependencies:
ms: 2.1.3
dev: true
/decompress-response/3.3.0:
resolution: {integrity: sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M=}
engines: {node: '>=4'}
dependencies:
mimic-response: 1.0.1
dev: true
/deep-extend/0.6.0:
resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==}
engines: {node: '>=4.0.0'}
dev: true
/defer-to-connect/1.1.3:
resolution: {integrity: sha512-0ISdNousHvZT2EiFlZeZAHBUvSxmKswVCEf8hW7KWgG4a8MVEu/3Vb6uWYozkjylyCxe0JBIiRB1jV45S70WVQ==}
dev: true
/diff/4.0.2:
resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==}
engines: {node: '>=0.3.1'}
dev: true
/dot-prop/5.3.0:
resolution: {integrity: sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==}
engines: {node: '>=8'}
dependencies:
is-obj: 2.0.0
dev: true
/duplexer3/0.1.4:
resolution: {integrity: sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=}
dev: true
/emoji-regex/7.0.3:
resolution: {integrity: sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==}
dev: true
/emoji-regex/8.0.0:
resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==}
dev: true
/end-of-stream/1.4.4:
resolution: {integrity: sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==}
dependencies:
once: 1.4.0
dev: true
/escape-goat/2.1.1:
resolution: {integrity: sha512-8/uIhbG12Csjy2JEW7D9pHbreaVaS/OpN3ycnyvElTdwM5n6GY6W6e2IPemfvGZeUMqZ9A/3GqIZMgKnBhAw/Q==}
engines: {node: '>=8'}
dev: true
/fill-range/7.0.1:
resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==}
engines: {node: '>=8'}
dependencies:
to-regex-range: 5.0.1
dev: true
/fsevents/2.3.2:
resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==}
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
os: [darwin]
dev: true
optional: true
/get-stream/4.1.0:
resolution: {integrity: sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==}
engines: {node: '>=6'}
dependencies:
pump: 3.0.0
dev: true
/get-stream/5.2.0:
resolution: {integrity: sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==}
engines: {node: '>=8'}
dependencies:
pump: 3.0.0
dev: true
/glob-parent/5.1.2:
resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==}
engines: {node: '>= 6'}
dependencies:
is-glob: 4.0.1
dev: true
/global-dirs/2.1.0:
resolution: {integrity: sha512-MG6kdOUh/xBnyo9cJFeIKkLEc1AyFq42QTU4XiX51i2NEdxLxLWXIjEjmqKeSuKR7pAZjTqUVoT2b2huxVLgYQ==}
engines: {node: '>=8'}
dependencies:
ini: 1.3.7
dev: true
/got/9.6.0:
resolution: {integrity: sha512-R7eWptXuGYxwijs0eV+v3o6+XH1IqVK8dJOEecQfTmkncw9AV4dcw/Dhxi8MdlqPthxxpZyizMzyg8RTmEsG+Q==}
engines: {node: '>=8.6'}
dependencies:
'@sindresorhus/is': 0.14.0
'@szmarczak/http-timer': 1.1.2
cacheable-request: 6.1.0
decompress-response: 3.3.0
duplexer3: 0.1.4
get-stream: 4.1.0
lowercase-keys: 1.0.1
mimic-response: 1.0.1
p-cancelable: 1.1.0
to-readable-stream: 1.0.0
url-parse-lax: 3.0.0
dev: true
/graceful-fs/4.2.8:
resolution: {integrity: sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==}
dev: true
/has-flag/3.0.0:
resolution: {integrity: sha1-tdRU3CGZriJWmfNGfloH87lVuv0=}
engines: {node: '>=4'}
dev: true
/has-flag/4.0.0:
resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==}
engines: {node: '>=8'}
dev: true
/has-yarn/2.1.0:
resolution: {integrity: sha512-UqBRqi4ju7T+TqGNdqAO0PaSVGsDGJUBQvk9eUWNGRY1CFGDzYhLWoM7JQEemnlvVcv/YEmc2wNW8BC24EnUsw==}
engines: {node: '>=8'}
dev: true
/http-cache-semantics/4.1.0:
resolution: {integrity: sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ==}
dev: true
/ignore-by-default/1.0.1:
resolution: {integrity: sha1-SMptcvbGo68Aqa1K5odr44ieKwk=}
dev: true
/import-lazy/2.1.0:
resolution: {integrity: sha1-BWmOPUXIjo1+nZLLBYTnfwlvPkM=}
engines: {node: '>=4'}
dev: true
/imurmurhash/0.1.4:
resolution: {integrity: sha1-khi5srkoojixPcT7a21XbyMUU+o=}
engines: {node: '>=0.8.19'}
dev: true
/ini/1.3.7:
resolution: {integrity: sha512-iKpRpXP+CrP2jyrxvg1kMUpXDyRUFDWurxbnVT1vQPx+Wz9uCYsMIqYuSBLV+PAaZG/d7kRLKRFc9oDMsH+mFQ==}
dev: true
/ini/1.3.8:
resolution: {integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==}
dev: true
/is-binary-path/2.1.0:
resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==}
engines: {node: '>=8'}
dependencies:
binary-extensions: 2.2.0
dev: true
/is-ci/2.0.0:
resolution: {integrity: sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w==}
hasBin: true
dependencies:
ci-info: 2.0.0
dev: true
/is-extglob/2.1.1:
resolution: {integrity: sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=}
engines: {node: '>=0.10.0'}
dev: true
/is-fullwidth-code-point/2.0.0:
resolution: {integrity: sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=}
engines: {node: '>=4'}
dev: true
/is-fullwidth-code-point/3.0.0:
resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==}
engines: {node: '>=8'}
dev: true
/is-glob/4.0.1:
resolution: {integrity: sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==}
engines: {node: '>=0.10.0'}
dependencies:
is-extglob: 2.1.1
dev: true
/is-installed-globally/0.3.2:
resolution: {integrity: sha512-wZ8x1js7Ia0kecP/CHM/3ABkAmujX7WPvQk6uu3Fly/Mk44pySulQpnHG46OMjHGXApINnV4QhY3SWnECO2z5g==}
engines: {node: '>=8'}
dependencies:
global-dirs: 2.1.0
is-path-inside: 3.0.3
dev: true
/is-npm/4.0.0:
resolution: {integrity: sha512-96ECIfh9xtDDlPylNPXhzjsykHsMJZ18ASpaWzQyBr4YRTcVjUvzaHayDAES2oU/3KpljhHUjtSRNiDwi0F0ig==}
engines: {node: '>=8'}
dev: true
/is-number/7.0.0:
resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==}
engines: {node: '>=0.12.0'}
dev: true
/is-obj/2.0.0:
resolution: {integrity: sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==}
engines: {node: '>=8'}
dev: true
/is-path-inside/3.0.3:
resolution: {integrity: sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==}
engines: {node: '>=8'}
dev: true
/is-typedarray/1.0.0:
resolution: {integrity: sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=}
dev: true
/is-yarn-global/0.3.0:
resolution: {integrity: sha512-VjSeb/lHmkoyd8ryPVIKvOCn4D1koMqY+vqyjjUfc3xyKtP4dYOxM44sZrnqQSzSds3xyOrUTLTC9LVCVgLngw==}
dev: true
/json-buffer/3.0.0:
resolution: {integrity: sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg=}
dev: true
/jssha/3.2.0:
resolution: {integrity: sha512-QuruyBENDWdN4tZwJbQq7/eAK85FqrI4oDbXjy5IBhYD+2pTJyBUWZe8ctWaCkrV0gy6AaelgOZZBMeswEa/6Q==}
dev: false
/keyv/3.1.0:
resolution: {integrity: sha512-9ykJ/46SN/9KPM/sichzQ7OvXyGDYKGTaDlKMGCAlg2UK8KRy4jb0d8sFc+0Tt0YYnThq8X2RZgCg74RPxgcVA==}
dependencies:
json-buffer: 3.0.0
dev: true
/latest-version/5.1.0:
resolution: {integrity: sha512-weT+r0kTkRQdCdYCNtkMwWXQTMEswKrFBkm4ckQOMVhhqhIMI1UT2hMj+1iigIhgSZm5gTmrRXBNoGUgaTY1xA==}
engines: {node: '>=8'}
dependencies:
package-json: 6.5.0
dev: true
/lowercase-keys/1.0.1:
resolution: {integrity: sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==}
engines: {node: '>=0.10.0'}
dev: true
/lowercase-keys/2.0.0:
resolution: {integrity: sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==}
engines: {node: '>=8'}
dev: true
/make-dir/3.1.0:
resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==}
engines: {node: '>=8'}
dependencies:
semver: 6.3.0
dev: true
/make-error/1.3.6:
resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==}
dev: true
/ts-node/10.2.0_typescript@4.3.5:
/mimic-response/1.0.1:
resolution: {integrity: sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==}
engines: {node: '>=4'}
dev: true
/minimatch/3.0.4:
resolution: {integrity: sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==}
dependencies:
brace-expansion: 1.1.11
dev: true
/minimist/1.2.5:
resolution: {integrity: sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==}
dev: true
/ms/2.0.0:
resolution: {integrity: sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=}
dev: true
/ms/2.1.3:
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
dev: true
/nodemon/2.0.12:
resolution: {integrity: sha512-egCTmNZdObdBxUBw6ZNwvZ/xzk24CKRs5K6d+5zbmrMr7rOpPmfPeF6OxM3DDpaRx331CQRFEktn+wrFFfBSOA==}
engines: {node: '>=8.10.0'}
hasBin: true
requiresBuild: true
dependencies:
chokidar: 3.5.2
debug: 3.2.7
ignore-by-default: 1.0.1
minimatch: 3.0.4
pstree.remy: 1.1.8
semver: 5.7.1
supports-color: 5.5.0
touch: 3.1.0
undefsafe: 2.0.3
update-notifier: 4.1.3
dev: true
/nopt/1.0.10:
resolution: {integrity: sha1-bd0hvSoxQXuScn3Vhfim83YI6+4=}
hasBin: true
dependencies:
abbrev: 1.1.1
dev: true
/normalize-path/3.0.0:
resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==}
engines: {node: '>=0.10.0'}
dev: true
/normalize-url/4.5.1:
resolution: {integrity: sha512-9UZCFRHQdNrfTpGg8+1INIg93B6zE0aXMVFkw1WFwvO4SlZywU6aLg5Of0Ap/PgcbSw4LNxvMWXMeugwMCX0AA==}
engines: {node: '>=8'}
dev: true
/once/1.4.0:
resolution: {integrity: sha1-WDsap3WWHUsROsF9nFC6753Xa9E=}
dependencies:
wrappy: 1.0.2
dev: true
/p-cancelable/1.1.0:
resolution: {integrity: sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw==}
engines: {node: '>=6'}
dev: true
/package-json/6.5.0:
resolution: {integrity: sha512-k3bdm2n25tkyxcjSKzB5x8kfVxlMdgsbPr0GkZcwHsLpba6cBjqCt1KlcChKEvxHIcTB1FVMuwoijZ26xex5MQ==}
engines: {node: '>=8'}
dependencies:
got: 9.6.0
registry-auth-token: 4.2.1
registry-url: 5.1.0
semver: 6.3.0
dev: true
/picomatch/2.3.0:
resolution: {integrity: sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==}
engines: {node: '>=8.6'}
dev: true
/prepend-http/2.0.0:
resolution: {integrity: sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=}
engines: {node: '>=4'}
dev: true
/pstree.remy/1.1.8:
resolution: {integrity: sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==}
dev: true
/pump/3.0.0:
resolution: {integrity: sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==}
dependencies:
end-of-stream: 1.4.4
once: 1.4.0
dev: true
/pupa/2.1.1:
resolution: {integrity: sha512-l1jNAspIBSFqbT+y+5FosojNpVpF94nlI+wDUpqP9enwOTfHx9f0gh5nB96vl+6yTpsJsypeNrwfzPrKuHB41A==}
engines: {node: '>=8'}
dependencies:
escape-goat: 2.1.1
dev: true
/rc/1.2.8:
resolution: {integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==}
hasBin: true
dependencies:
deep-extend: 0.6.0
ini: 1.3.8
minimist: 1.2.5
strip-json-comments: 2.0.1
dev: true
/readdirp/3.6.0:
resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==}
engines: {node: '>=8.10.0'}
dependencies:
picomatch: 2.3.0
dev: true
/registry-auth-token/4.2.1:
resolution: {integrity: sha512-6gkSb4U6aWJB4SF2ZvLb76yCBjcvufXBqvvEx1HbmKPkutswjW1xNVRY0+daljIYRbogN7O0etYSlbiaEQyMyw==}
engines: {node: '>=6.0.0'}
dependencies:
rc: 1.2.8
dev: true
/registry-url/5.1.0:
resolution: {integrity: sha512-8acYXXTI0AkQv6RAOjE3vOaIXZkT9wo4LOFbBKYQEEnnMNBpKqdUrI6S4NT0KPIo/WVvJ5tE/X5LF/TQUf0ekw==}
engines: {node: '>=8'}
dependencies:
rc: 1.2.8
dev: true
/responselike/1.0.2:
resolution: {integrity: sha1-kYcg7ztjHFZCvgaPFa3lpG9Loec=}
dependencies:
lowercase-keys: 1.0.1
dev: true
/semver-diff/3.1.1:
resolution: {integrity: sha512-GX0Ix/CJcHyB8c4ykpHGIAvLyOwOobtM/8d+TQkAd81/bEjgPHrfba41Vpesr7jX/t8Uh+R3EX9eAS5be+jQYg==}
engines: {node: '>=8'}
dependencies:
semver: 6.3.0
dev: true
/semver/5.7.1:
resolution: {integrity: sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==}
hasBin: true
dev: true
/semver/6.3.0:
resolution: {integrity: sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==}
hasBin: true
dev: true
/signal-exit/3.0.3:
resolution: {integrity: sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==}
dev: true
/string-width/3.1.0:
resolution: {integrity: sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==}
engines: {node: '>=6'}
dependencies:
emoji-regex: 7.0.3
is-fullwidth-code-point: 2.0.0
strip-ansi: 5.2.0
dev: true
/string-width/4.2.2:
resolution: {integrity: sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==}
engines: {node: '>=8'}
dependencies:
emoji-regex: 8.0.0
is-fullwidth-code-point: 3.0.0
strip-ansi: 6.0.0
dev: true
/strip-ansi/5.2.0:
resolution: {integrity: sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==}
engines: {node: '>=6'}
dependencies:
ansi-regex: 4.1.0
dev: true
/strip-ansi/6.0.0:
resolution: {integrity: sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==}
engines: {node: '>=8'}
dependencies:
ansi-regex: 5.0.0
dev: true
/strip-json-comments/2.0.1:
resolution: {integrity: sha1-PFMZQukIwml8DsNEhYwobHygpgo=}
engines: {node: '>=0.10.0'}
dev: true
/supports-color/5.5.0:
resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==}
engines: {node: '>=4'}
dependencies:
has-flag: 3.0.0
dev: true
/supports-color/7.2.0:
resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==}
engines: {node: '>=8'}
dependencies:
has-flag: 4.0.0
dev: true
/term-size/2.2.1:
resolution: {integrity: sha512-wK0Ri4fOGjv/XPy8SBHZChl8CM7uMc5VML7SqiQ0zG7+J5Vr+RMQDoHa2CNT6KHUnTGIXH34UDMkPzAUyapBZg==}
engines: {node: '>=8'}
dev: true
/to-readable-stream/1.0.0:
resolution: {integrity: sha512-Iq25XBt6zD5npPhlLVXGFN3/gyR2/qODcKNNyTMd4vbm39HUaOiAM4PMq0eMVC/Tkxz+Zjdsc55g9yyz+Yq00Q==}
engines: {node: '>=6'}
dev: true
/to-regex-range/5.0.1:
resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
engines: {node: '>=8.0'}
dependencies:
is-number: 7.0.0
dev: true
/touch/3.1.0:
resolution: {integrity: sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==}
hasBin: true
dependencies:
nopt: 1.0.10
dev: true
/ts-node/10.2.0_dea0625f6d31b223e93dc3dc354b8b43:
resolution: {integrity: sha512-FstYHtQz6isj8rBtYMN4bZdnXN1vq4HCbqn9vdNQcInRqtB86PePJQIxE6es0PhxKWhj2PHuwbG40H+bxkZPmg==}
engines: {node: '>=12.0.0'}
hasBin: true
@ -94,6 +782,7 @@ packages:
'@tsconfig/node12': 1.0.9
'@tsconfig/node14': 1.0.1
'@tsconfig/node16': 1.0.2
'@types/node': 16.4.13
acorn: 8.4.1
acorn-walk: 8.1.1
arg: 4.1.3
@ -104,12 +793,87 @@ packages:
yn: 3.1.1
dev: true
/type-fest/0.8.1:
resolution: {integrity: sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==}
engines: {node: '>=8'}
dev: true
/typedarray-to-buffer/3.1.5:
resolution: {integrity: sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==}
dependencies:
is-typedarray: 1.0.0
dev: true
/typescript/4.3.5:
resolution: {integrity: sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==}
engines: {node: '>=4.2.0'}
hasBin: true
dev: true
/undefsafe/2.0.3:
resolution: {integrity: sha512-nrXZwwXrD/T/JXeygJqdCO6NZZ1L66HrxM/Z7mIq2oPanoN0F1nLx3lwJMu6AwJY69hdixaFQOuoYsMjE5/C2A==}
dependencies:
debug: 2.6.9
dev: true
/unique-string/2.0.0:
resolution: {integrity: sha512-uNaeirEPvpZWSgzwsPGtU2zVSTrn/8L5q/IexZmH0eH6SA73CmAA5U4GwORTxQAZs95TAXLNqeLoPPNO5gZfWg==}
engines: {node: '>=8'}
dependencies:
crypto-random-string: 2.0.0
dev: true
/update-notifier/4.1.3:
resolution: {integrity: sha512-Yld6Z0RyCYGB6ckIjffGOSOmHXj1gMeE7aROz4MG+XMkmixBX4jUngrGXNYz7wPKBmtoD4MnBa2Anu7RSKht/A==}
engines: {node: '>=8'}
dependencies:
boxen: 4.2.0
chalk: 3.0.0
configstore: 5.0.1
has-yarn: 2.1.0
import-lazy: 2.1.0
is-ci: 2.0.0
is-installed-globally: 0.3.2
is-npm: 4.0.0
is-yarn-global: 0.3.0
latest-version: 5.1.0
pupa: 2.1.1
semver-diff: 3.1.1
xdg-basedir: 4.0.0
dev: true
/url-parse-lax/3.0.0:
resolution: {integrity: sha1-FrXK/Afb42dsGxmZF3gj1lA6yww=}
engines: {node: '>=4'}
dependencies:
prepend-http: 2.0.0
dev: true
/widest-line/3.1.0:
resolution: {integrity: sha512-NsmoXalsWVDMGupxZ5R08ka9flZjjiLvHVAWYOKtiKM8ujtZWr9cRffak+uSE48+Ob8ObalXpwyeUiyDD6QFgg==}
engines: {node: '>=8'}
dependencies:
string-width: 4.2.2
dev: true
/wrappy/1.0.2:
resolution: {integrity: sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=}
dev: true
/write-file-atomic/3.0.3:
resolution: {integrity: sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==}
dependencies:
imurmurhash: 0.1.4
is-typedarray: 1.0.0
signal-exit: 3.0.3
typedarray-to-buffer: 3.1.5
dev: true
/xdg-basedir/4.0.0:
resolution: {integrity: sha512-PSNhEJDejZYV7h50BohL09Er9VaIefr2LMAf3OEmpCkjOi34eYyQYAXUTjEQtZJTKcF0E2UKTh+osDLsgNim9Q==}
engines: {node: '>=8'}
dev: true
/yn/3.1.1:
resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==}
engines: {node: '>=6'}

View File

@ -0,0 +1,53 @@
import type { IDataStore } from "../repo";
import * as Fs from "fs";
import * as Path from "path";
export default class FSDataStore implements IDataStore {
#path: string;
#l = false;
constructor(path: string) {
this.#path = path;
}
async get(name: string) {
return Fs.promises.readFile(Path.join(this.#path, name));
}
async has(name: string) {
return Fs.promises
.access(Path.join(this.#path, name))
.then(() => true)
.catch(() => false);
}
async set(name: string, data: Uint8Array) {
const path = Path.join(this.#path, name);
await Fs.promises.mkdir(Path.dirname(path), { recursive: true });
await Fs.promises.writeFile(path, data);
}
async _delete(name: string) {
await Fs.promises.rm(Path.join(this.#path, name));
}
async getLock() {
//TODO: This is not atomic yet! FIX
while ((await this.has("lock")) || this.#l) {
try {
let con = (await this.get("lock")).toString("utf-8");
if (Number(con) < Date.now() - 10000) break;
await new Promise((y) => setTimeout(y, 10));
} catch (err) {}
}
this.#l = true;
await this.set("lock", Buffer.from(`${Date.now()}`));
this.#l = false;
return async () => {
await this._delete("lock");
};
}
}

View File

@ -19,28 +19,25 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict';
"use strict";
// resolves . and .. elements in a path array with directory names there
// must be no slashes or device names (c:\) in the array
// (so also no leading and trailing slashes - it does not distinguish
// relative and absolute paths)
function normalizeArray(parts, allowAboveRoot) {
function normalizeArray(parts: string[], allowAboveRoot: boolean) {
var res = [];
for (var i = 0; i < parts.length; i++) {
var p = parts[i];
// ignore empty parts
if (!p || p === '.')
continue;
if (!p || p === ".") continue;
if (p === '..') {
if (res.length && res[res.length - 1] !== '..') {
if (p === "..") {
if (res.length && res[res.length - 1] !== "..") {
res.pop();
} else if (allowAboveRoot) {
res.push('..');
res.push("..");
}
} else {
res.push(p);
@ -52,107 +49,91 @@ function normalizeArray(parts, allowAboveRoot) {
// returns an array with empty elements removed from either end of the input
// array or the original array if no elements need to be removed
function trimArray(arr) {
function trimArray(arr: any[]) {
var lastIndex = arr.length - 1;
var start = 0;
for (; start <= lastIndex; start++) {
if (arr[start])
break;
if (arr[start]) break;
}
var end = lastIndex;
for (; end >= 0; end--) {
if (arr[end])
break;
if (arr[end]) break;
}
if (start === 0 && end === lastIndex)
return arr;
if (start > end)
return [];
if (start === 0 && end === lastIndex) return arr;
if (start > end) return [];
return arr.slice(start, end + 1);
}
// // Regex to split the tail part of the above into [*, dir, basename, ext]
// const splitTailRe =
// /^([\s\S]*?)((?:\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))(?:[\\\/]*)$/;
// function normalizeUNCRoot(device) {
// return '\\\\' + device.replace(/^[\\\/]+/, '').replace(/[\\\/]+/g, '\\');
// }
// Split a filename into [root, dir, basename, ext], unix version
// 'root' is just a slash, or nothing.
const splitPathRe =
/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
const splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
function posixSplitPath(filename) {
return splitPathRe.exec(filename).slice(1);
function posixSplitPath(filename: string) {
return splitPathRe.exec(filename)?.slice(1) as string[];
}
export class Posix {
static readonly sep = '/';
static readonly delimiter = ':';
static readonly sep = "/";
static readonly delimiter = ":";
static resolve(...paths: string[]) {
var resolvedPath = '',
var resolvedPath = "",
resolvedAbsolute = false;
for (var i = paths.length - 1; i >= -1 && !resolvedAbsolute; i--) {
var path = (i >= 0) ? paths[i] : "/";
var path = i >= 0 ? paths[i] : "/";
// Skip empty and invalid entries
if (typeof path !== "string") {
throw new TypeError('Arguments to path.resolve must be strings');
throw new TypeError("Arguments to path.resolve must be strings");
} else if (!path) {
continue;
}
resolvedPath = path + '/' + resolvedPath;
resolvedAbsolute = path[0] === '/';
resolvedPath = path + "/" + resolvedPath;
resolvedAbsolute = path[0] === "/";
}
// At this point the path should be resolved to a full absolute path, but
// handle relative paths to be safe (might happen when process.cwd() fails)
// Normalize the path
resolvedPath = normalizeArray(resolvedPath.split('/'),
!resolvedAbsolute).join('/');
resolvedPath = normalizeArray(resolvedPath.split("/"), !resolvedAbsolute).join("/");
return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
return (resolvedAbsolute ? "/" : "") + resolvedPath || ".";
}
static normalize(path: string) {
var isAbsolute = Posix.isAbsolute(path),
trailingSlash = path && path[path.length - 1] === '/';
trailingSlash = path && path[path.length - 1] === "/";
// Normalize the path
path = normalizeArray(path.split('/'), !isAbsolute).join('/');
path = normalizeArray(path.split("/"), !isAbsolute).join("/");
if (!path && !isAbsolute) {
path = '.';
path = ".";
}
if (path && trailingSlash) {
path += '/';
path += "/";
}
return (isAbsolute ? '/' : '') + path;
return (isAbsolute ? "/" : "") + path;
}
static join(...paths: string[]) {
var path = '';
var path = "";
for (var i = 0; i < arguments.length; i++) {
var segment = arguments[i];
if (typeof segment !== "string") {
throw new TypeError('Arguments to path.join must be strings');
throw new TypeError("Arguments to path.join must be strings");
}
if (segment) {
if (!path) {
path += segment;
} else {
path += '/' + segment;
path += "/" + segment;
}
}
}
@ -163,8 +144,8 @@ export class Posix {
from = Posix.resolve(from).substr(1);
to = Posix.resolve(to).substr(1);
var fromParts = trimArray(from.split('/'));
var toParts = trimArray(to.split('/'));
var fromParts = trimArray(from.split("/"));
var toParts = trimArray(to.split("/"));
var length = Math.min(fromParts.length, toParts.length);
var samePartsLength = length;
@ -177,22 +158,22 @@ export class Posix {
var outputParts = [];
for (var i = samePartsLength; i < fromParts.length; i++) {
outputParts.push('..');
outputParts.push("..");
}
outputParts = outputParts.concat(toParts.slice(samePartsLength));
return outputParts.join('/');
return outputParts.join("/");
}
static dirname(path: string) {
var result = posixSplitPath(path),
var result = posixSplitPath(path) as string[],
root = result[0],
dir = result[1];
if (!root && !dir) {
// No dirname whatsoever
return '.';
return ".";
}
if (dir) {
@ -218,52 +199,47 @@ export class Posix {
static format(pathObject: any) {
if (typeof pathObject !== "object") {
throw new TypeError(
"Parameter 'pathObject' must be an object, not " + typeof pathObject
);
throw new TypeError("Parameter 'pathObject' must be an object, not " + typeof pathObject);
}
var root = pathObject.root || '';
var root = pathObject.root || "";
if (typeof root !== "string") {
throw new TypeError(
"'pathObject.root' must be a string or undefined, not " +
typeof pathObject.root
"'pathObject.root' must be a string or undefined, not " + typeof pathObject.root
);
}
var dir = pathObject.dir ? pathObject.dir + Posix.sep : '';
var base = pathObject.base || '';
var dir = pathObject.dir ? pathObject.dir + Posix.sep : "";
var base = pathObject.base || "";
return dir + base;
}
static parse(pathString: string) {
if (typeof pathString !== "string") {
throw new TypeError(
"Parameter 'pathString' must be a string, not " + typeof pathString
);
throw new TypeError("Parameter 'pathString' must be a string, not " + typeof pathString);
}
var allParts = posixSplitPath(pathString);
if (!allParts || allParts.length !== 4) {
throw new TypeError("Invalid path '" + pathString + "'");
}
allParts[1] = allParts[1] || '';
allParts[2] = allParts[2] || '';
allParts[3] = allParts[3] || '';
allParts[1] = allParts[1] || "";
allParts[2] = allParts[2] || "";
allParts[3] = allParts[3] || "";
return {
root: allParts[0],
dir: allParts[0] + allParts[1].slice(0, -1),
base: allParts[2],
ext: allParts[3],
name: allParts[2].slice(0, allParts[2].length - allParts[3].length)
name: allParts[2].slice(0, allParts[2].length - allParts[3].length),
};
}
static isAbsolute(path: string) {
return path.charAt(0) === '/';
return path.charAt(0) === "/";
}
};
}
export const Path = Posix;
export default Path;

View File

@ -5,8 +5,10 @@ export interface IDataStore {
get(key: string): Promise<Uint8Array>;
set(key: string, data: Uint8Array): Promise<void>;
has(key: string): Promise<boolean>;
}
close?: () => Promise<void>;
getLock: () => Promise<() => Promise<void>>;
}
export type NodeType = "tree" | "blob";
export type NodeHash = string;
@ -14,10 +16,11 @@ export type NodeFilename = string;
export type TreeEntry = [NodeType, NodeHash, NodeFilename];
export type Commit = {
id: string;
root: string;
before: string;
date: Date;
}
};
// TODOs:
// - HEAD locks
@ -27,47 +30,46 @@ export type Commit = {
export default class Repository {
#store: IDataStore;
#head_lock: any;
constructor(store: IDataStore) {
this.#store = store;
this.init();
}
private sha1(data: Uint8Array) {
const s = new SHA("SHA-1", "UINT8ARRAY");
s.update(data)
s.update(data);
return s.getHash("HEX");
}
private sha256(data: Uint8Array) {
const s = new SHA("SHA3-256", "UINT8ARRAY");
s.update(data)
s.update(data);
return s.getHash("HEX");
}
private splitPath(path: string) {
return Path.resolve(path).slice(1).split(Path.delimiter);
const resolved = Path.resolve(path).slice(1);
if (resolved == "") return [];
return resolved.split(Path.delimiter);
}
private async writeObject(data: string, string: true): Promise<string>
private async writeObject(data: Uint8Array, string?: false): Promise<string>
private async writeObject(data: Uint8Array | string, string = false): Promise<string> {
private getHeadLock() {}
private async writeObject(data: Uint8Array | string): Promise<string> {
if (typeof data == "string") {
data = new TextEncoder().encode(data);
}
const objectID = this.sha1(data);
await this.#store.set("objects/" + objectID, data);
return objectID
return objectID;
}
private async hasObject(id: string): Promise<boolean> {
return this.#store.has("objects/" + id);
}
private async readObject(id: string, string: true): Promise<string>
private async readObject(id: string, string?: false): Promise<Uint8Array>
private async readObject(id: string, string: true): Promise<string>;
private async readObject(id: string, string?: false): Promise<Uint8Array>;
private async readObject(id: string, string = false): Promise<Uint8Array | string> {
let data = await this.#store.get("objects/" + id);
if (string) {
@ -77,105 +79,165 @@ export default class Repository {
}
}
async init() {
async clean() {
// TODO: Cleanup broken things
}
async read() {
async readdir(path: string): Promise<TreeEntry[] | undefined> {
const parts = this.splitPath(path);
console.log({ parts });
const head = await this.readHead();
if (!head) return undefined;
const treeID = await this.treeFindObjectID(head.root, parts, "tree");
if (!treeID) return undefined;
return this.readTree(treeID);
}
async read(path: string): Promise<Uint8Array | undefined> {
const parts = this.splitPath(path);
const head = await this.readHead();
if (!head) return undefined;
const objectID = await this.treeFindObjectID(head.root, parts, "blob");
if (!objectID) return undefined;
return this.readObject(objectID);
}
async write(path: string, data: Uint8Array) {
const parts = this.splitPath(path);
const objectID = await this.writeObject(data);
const head = await this.readHead();
// const file = parts[parts.length - 1];
// const folders = parts.slice(0, parts.length - 1)
const lock = await this.#store.getLock();
try {
//TODO: Improve need of locking.
const head = await this.readHead();
const makeTree = async (treeID: string | undefined, parts: string[]) => {
let tree: TreeEntry[];
if (treeID) {
tree = await this.readTree(treeID);
} else {
tree = [];
}
const makeTree = async (treeID: string | undefined, parts: string[]) => {
let tree: TreeEntry[];
if (treeID) {
tree = await this.readTree(treeID);
} else {
tree = [];
}
const current = parts[0];
const current = parts[0];
let existing = tree.findIndex(([, , name]) => name == current);
let existing = tree.findIndex(([, , name]) => name == current);
let entry: TreeEntry;
let entry: TreeEntry;
if (parts.length == 1) {
entry = ["blob", objectID, current];
} else {
entry = [
"tree",
await makeTree(existing >= 0 ? tree[existing][1] : undefined, parts.slice(1)),
current,
];
}
if (parts.length == 1) {
entry = ["blob", objectID, current];
} else {
entry = ["tree", await makeTree(existing >= 0 ? tree[existing][1] : undefined, parts.slice(1)), current];
}
if (existing >= 0) {
let ex = tree[existing];
if (parts.length == 1 && ex[0] == "tree")
throw new Error("This change would overwrite a folder!");
tree[existing] = entry;
} else {
tree.push(entry);
}
if (existing >= 0) {
let ex = tree[existing];
if (parts.length == 1 && ex[0] == "tree")
throw new Error("This change would overwrite a folder!");
tree[existing] = entry;
} else {
tree.push(entry);
}
let treeString = tree.map(([type, hash, name]) => `${type} ${hash} ${name}`).join("\n");
let newTreeID = await this.writeObject(treeString);
let treeString = tree.map(([type, hash, name]) => `${type} ${hash} ${name}`).join("\n");
return newTreeID;
};
let obj = this.writeObject(treeString, true);
let newTree = await makeTree(head?.root, parts);
let commit = await this.makeCommit(newTree, head);
await this.writeHead(commit);
} finally {
await lock();
}
}
let newTreeID = "";
return newTreeID;
async treeFindObjectID(
treeID: string,
parts: string[],
type: NodeType
): Promise<string | undefined> {
if (parts.length == 0) {
if (type == "tree") return treeID;
else throw new Error("Cannot open root as file!");
}
let newTree = makeTree(head?.root, parts);
const tree = await this.readTree(treeID);
const current = parts[0];
let entry = tree.find(([type, id, name]) => name == current);
if (!entry) {
return undefined;
}
if (parts.length == 1) {
if (entry[0] != type) throw new Error("Expected 'blob' found 'tree'!");
return entry[1];
} else {
if (entry[0] != "tree") throw new Error("Expected 'tree' found 'blob'!");
return this.treeFindObjectID(entry[1], parts.splice(1), type);
}
}
async readTree(id: string): Promise<TreeEntry[]> {
const tree = new TextDecoder().decode(await this.readObject(id));
return tree.split("\n").map(e => {
const tree = await this.readObject(id, true);
return tree.split("\n").map((e) => {
const entry = e.split(" ") as TreeEntry;
const [type] = entry;
switch (type) {
case "blob":
case "tree":
break
break;
default:
throw new Error("Invalid tree type.") //Might be a newer version or so
throw new Error("Invalid tree type."); //Might be a newer version or so
}
return entry;
})
});
}
async makeCommit(treeID: string, old?: Commit) {
if (!old) {
// Could be called once more than necessary, if no HEAD exists.
old = await this.readHead();
}
const commitStr =
`tree ${treeID}\ndate ${new Date().toISOString()}\n` + (old ? `before ${old?.id}\n` : "");
return await this.writeObject(commitStr);
}
async readCommit(id: string): Promise<Commit> {
if (!await this.hasObject(id))
throw new Error(`Commit with id ${id} not found!`);
if (!(await this.hasObject(id))) throw new Error(`Commit with id ${id} not found!`);
const commitStr = new TextDecoder().decode(await this.readObject(id));
const commitStr = await this.readObject(id, true);
let commit: Commit = {} as any;
for (const entry of commitStr.split("n")) {
const [type, value] = entry.split(" ", 1);
let commit: Commit = { id } as any;
for (const entry of commitStr.split("\n")) {
const [type] = entry.split(" ", 1);
const value = entry.slice(type.length + 1);
switch (type) {
case "tree": // TODO: Simple validity checks
commit.root = value;
break;
case "before": // TODO: Simple validity checks
case "before": // TODO: Simple validity checks
commit.before = value;
case "date":
commit.date = new Date(value)
commit.date = new Date(value);
}
}
@ -187,10 +249,17 @@ export default class Repository {
}
async readHead(): Promise<Commit | undefined> {
if (!await this.#store.has("HEAD"))
return undefined;
if (!(await this.#store.has("HEAD"))) return undefined;
const head = new TextDecoder().decode(await this.#store.get("HEAD"));
return this.readCommit(head);
}
async writeHead(commitID: string): Promise<void> {
await this.#store.set("HEAD", new TextEncoder().encode(commitID));
}
async close() {
if (this.#store.close) return this.#store?.close();
}
}

27
src/test.ts Normal file
View File

@ -0,0 +1,27 @@
import Repository from "./repo";
import FSDataStore from "./datasources/fs";
import * as Fs from "fs";
const t = (t: string) => new TextEncoder().encode(t);
async function test() {
await Fs.promises.rm("./testrepo", { recursive: true, force: true });
const ds = new FSDataStore("./testrepo");
const rep = new Repository(ds);
console.log(new TextDecoder().decode(await rep.read("hi.txt")));
await Promise.all([
rep.write("hi.txt", t("Hallo Welt: " + new Date().toLocaleString())),
rep.write("hi_hallo.txt", t("Hallo Welt: " + new Date().toLocaleString())),
rep.write("hi_hallo3.txt", t("Hallo Welt: " + new Date().toLocaleString())),
]);
console.log(new TextDecoder().decode(await rep.read("hi.txt")));
console.log((await rep.readdir("/"))?.map((e) => e[2]));
await rep.close();
}
test();

13
tsconfig.json Normal file
View File

@ -0,0 +1,13 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "CommonJS",
"moduleResolution": "Node",
"sourceMap": true,
"outDir": "./lib",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
}
}