diff --git a/lib/package-lock.json b/lib/package-lock.json index d7eedff..3bca00b 100644 --- a/lib/package-lock.json +++ b/lib/package-lock.json @@ -9,11 +9,11 @@ "license": "AGPL-3.0-or-later", "dependencies": { "@expo/spawn-async": "^1.5.0", - "typescript": "^4.3.2" + "typescript": "^4.3.4" }, "devDependencies": { "jest": "^27.0.4", - "npm-check-updates": "^11.6.0", + "npm-check-updates": "^11.7.1", "ts-jest": "^27.0.3" } }, @@ -1063,12 +1063,12 @@ } }, "node_modules/@nodelib/fs.scandir": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.4.tgz", - "integrity": "sha512-33g3pMJk3bg5nXbL/+CY6I2eJDzZAni49PfJnL5fghPTggPvBd/pFNSgJsdAgWptuFu7qq/ERvOYFlhvsLTCKA==", + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", "dev": true, "dependencies": { - "@nodelib/fs.stat": "2.0.4", + "@nodelib/fs.stat": "2.0.5", "run-parallel": "^1.1.9" }, "engines": { @@ -1076,21 +1076,21 @@ } }, "node_modules/@nodelib/fs.stat": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.4.tgz", - "integrity": "sha512-IYlHJA0clt2+Vg7bccq+TzRdJvv19c2INqBSsoOLp1je7xjtr7J26+WXR72MCdvU9q1qTzIWDfhMf+DRvQJK4Q==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", "dev": true, "engines": { "node": ">= 8" } }, "node_modules/@nodelib/fs.walk": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.6.tgz", - "integrity": "sha512-8Broas6vTtW4GIXTAHDoE32hnN2M5ykgCpWGbuXHQ15vEMqr23pB76e/GZcYsZCHALv50ktd24qhEyKr6wBtow==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.7.tgz", + "integrity": "sha512-BTIhocbPBSrRmHxOAJFtR18oLhxTtAFDAvL8hY1S3iU8k+E60W/YFs4jrixGzQjMpF4qPXxIQHcjVD9dz1C2QA==", "dev": true, "dependencies": { - "@nodelib/fs.scandir": "2.1.4", + "@nodelib/fs.scandir": "2.1.5", "fastq": "^1.6.0" }, "engines": { @@ -3042,9 +3042,9 @@ } }, "node_modules/globby": { - "version": "11.0.3", - "resolved": "https://registry.npmjs.org/globby/-/globby-11.0.3.tgz", - "integrity": "sha512-ffdmosjA807y7+lA1NM0jELARVmYul/715xiILEjo3hBLPTcirgQNnXECn5g3mtR8TOLCVbkfua1Hpen25/Xcg==", + "version": "11.0.4", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.0.4.tgz", + "integrity": "sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg==", "dev": true, "dependencies": { "array-union": "^2.1.0", @@ -5009,9 +5009,9 @@ } }, "node_modules/npm-check-updates": { - "version": "11.6.0", - "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-11.6.0.tgz", - "integrity": "sha512-/l4S7Gh+8+Rg5itWsqFya5RRSHtPzw5neyAlbWNJfBfEeRX6lYVxKgs85QFBOKrZj3eL5MGBaUW8228TmjMhrw==", + "version": "11.7.1", + "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-11.7.1.tgz", + "integrity": "sha512-1ZH1le6fIuCS/Lrj9hKzds2bBcpc60cENZJ681rJ+cx202JmwsmnVmPj6lC4f9MNb0/D81QXR0QbIt5oqDKQtA==", "dev": true, "dependencies": { "chalk": "^4.1.1", @@ -5021,7 +5021,7 @@ "find-up": "5.0.0", "fp-and-or": "^0.1.3", "get-stdin": "^8.0.0", - "globby": "^11.0.3", + "globby": "^11.0.4", "hosted-git-info": "^4.0.2", "json-parse-helpfulerror": "^1.0.3", "jsonlines": "^0.1.1", @@ -5030,7 +5030,7 @@ "mem": "^8.1.1", "minimatch": "^3.0.4", "p-map": "^4.0.0", - "pacote": "^11.3.3", + "pacote": "^11.3.4", "parse-github-url": "^1.0.2", "progress": "^2.0.3", "prompts": "^2.4.1", @@ -6507,9 +6507,9 @@ } }, "node_modules/typescript": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.2.tgz", - "integrity": "sha512-zZ4hShnmnoVnAHpVHWpTcxdv7dWP60S2FsydQLV8V5PbS3FifjWFFRiHSWpDJahly88PRyV5teTSLoq4eG7mKw==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.4.tgz", + "integrity": "sha512-uauPG7XZn9F/mo+7MrsRjyvbxFpzemRjKEZXS4AK83oP2KKOJPvb+9cO/gmnv8arWZvhnjVOXz7B49m1l0e9Ew==", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -7879,28 +7879,28 @@ } }, "@nodelib/fs.scandir": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.4.tgz", - "integrity": "sha512-33g3pMJk3bg5nXbL/+CY6I2eJDzZAni49PfJnL5fghPTggPvBd/pFNSgJsdAgWptuFu7qq/ERvOYFlhvsLTCKA==", + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", "dev": true, "requires": { - "@nodelib/fs.stat": "2.0.4", + "@nodelib/fs.stat": "2.0.5", "run-parallel": "^1.1.9" } }, "@nodelib/fs.stat": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.4.tgz", - "integrity": "sha512-IYlHJA0clt2+Vg7bccq+TzRdJvv19c2INqBSsoOLp1je7xjtr7J26+WXR72MCdvU9q1qTzIWDfhMf+DRvQJK4Q==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", "dev": true }, "@nodelib/fs.walk": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.6.tgz", - "integrity": "sha512-8Broas6vTtW4GIXTAHDoE32hnN2M5ykgCpWGbuXHQ15vEMqr23pB76e/GZcYsZCHALv50ktd24qhEyKr6wBtow==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.7.tgz", + "integrity": "sha512-BTIhocbPBSrRmHxOAJFtR18oLhxTtAFDAvL8hY1S3iU8k+E60W/YFs4jrixGzQjMpF4qPXxIQHcjVD9dz1C2QA==", "dev": true, "requires": { - "@nodelib/fs.scandir": "2.1.4", + "@nodelib/fs.scandir": "2.1.5", "fastq": "^1.6.0" } }, @@ -9446,9 +9446,9 @@ "dev": true }, "globby": { - "version": "11.0.3", - "resolved": "https://registry.npmjs.org/globby/-/globby-11.0.3.tgz", - "integrity": "sha512-ffdmosjA807y7+lA1NM0jELARVmYul/715xiILEjo3hBLPTcirgQNnXECn5g3mtR8TOLCVbkfua1Hpen25/Xcg==", + "version": "11.0.4", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.0.4.tgz", + "integrity": "sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg==", "dev": true, "requires": { "array-union": "^2.1.0", @@ -10989,9 +10989,9 @@ } }, "npm-check-updates": { - "version": "11.6.0", - "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-11.6.0.tgz", - "integrity": "sha512-/l4S7Gh+8+Rg5itWsqFya5RRSHtPzw5neyAlbWNJfBfEeRX6lYVxKgs85QFBOKrZj3eL5MGBaUW8228TmjMhrw==", + "version": "11.7.1", + "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-11.7.1.tgz", + "integrity": "sha512-1ZH1le6fIuCS/Lrj9hKzds2bBcpc60cENZJ681rJ+cx202JmwsmnVmPj6lC4f9MNb0/D81QXR0QbIt5oqDKQtA==", "dev": true, "requires": { "chalk": "^4.1.1", @@ -11001,7 +11001,7 @@ "find-up": "5.0.0", "fp-and-or": "^0.1.3", "get-stdin": "^8.0.0", - "globby": "^11.0.3", + "globby": "^11.0.4", "hosted-git-info": "^4.0.2", "json-parse-helpfulerror": "^1.0.3", "jsonlines": "^0.1.1", @@ -11010,7 +11010,7 @@ "mem": "^8.1.1", "minimatch": "^3.0.4", "p-map": "^4.0.0", - "pacote": "^11.3.3", + "pacote": "^11.3.4", "parse-github-url": "^1.0.2", "progress": "^2.0.3", "prompts": "^2.4.1", @@ -12115,9 +12115,9 @@ } }, "typescript": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.2.tgz", - "integrity": "sha512-zZ4hShnmnoVnAHpVHWpTcxdv7dWP60S2FsydQLV8V5PbS3FifjWFFRiHSWpDJahly88PRyV5teTSLoq4eG7mKw==" + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.4.tgz", + "integrity": "sha512-uauPG7XZn9F/mo+7MrsRjyvbxFpzemRjKEZXS4AK83oP2KKOJPvb+9cO/gmnv8arWZvhnjVOXz7B49m1l0e9Ew==" }, "unique-filename": { "version": "1.1.1", diff --git a/lib/package.json b/lib/package.json index ae1e6b3..7f96c67 100644 --- a/lib/package.json +++ b/lib/package.json @@ -12,12 +12,16 @@ "types": "dist/lib.d.ts", "exports": { ".": "./dist/lib.js", + "./asset": "./dist/asset.js", "./fml": "./dist/fml.js", "./media": "./dist/media.js", "./gear": "./dist/gear.js" }, "typesVersions": { "*": { + "asset": [ + "dist/asset" + ], "fml": [ "dist/fml" ], @@ -33,11 +37,11 @@ "license": "AGPL-3.0-or-later", "devDependencies": { "jest": "^27.0.4", - "npm-check-updates": "^11.6.0", + "npm-check-updates": "^11.7.1", "ts-jest": "^27.0.3" }, "dependencies": { "@expo/spawn-async": "^1.5.0", - "typescript": "^4.3.2" + "typescript": "^4.3.4" } } diff --git a/lib/src/asset.test.ts b/lib/src/asset.test.ts new file mode 100644 index 0000000..ed06c7b --- /dev/null +++ b/lib/src/asset.test.ts @@ -0,0 +1,12 @@ +// https://jestjs.io/docs/api +import {describe, expect, it } from '@jest/globals'; +import Asset from './asset'; +import fs from 'fs/promises'; + +describe("Asset", () => { + it("Asset dir exists", async () => { + const asset = new Asset(); + const stat = await fs.stat(asset.pathOf('')); + expect(stat).not.toBeNull; + }); +}); diff --git a/lib/src/asset.ts b/lib/src/asset.ts new file mode 100644 index 0000000..a04d25b --- /dev/null +++ b/lib/src/asset.ts @@ -0,0 +1,10 @@ +import path from "path"; + +export default class Asset { + constructor() { + } + pathOf(filepath: string): string { + const paths = filepath.split('/'); + return path.join(__dirname, '..', '..', '_assets', ...paths); + } +} diff --git a/lib/src/lib.ts b/lib/src/lib.ts index bd2bada..c109ed1 100644 --- a/lib/src/lib.ts +++ b/lib/src/lib.ts @@ -1,9 +1,11 @@ -import * as gear from './gear'; +import * as asset from './asset'; import * as fml from './fml'; +import * as gear from './gear'; import * as media from './media'; export { - gear, + asset, fml, + gear, media, }; diff --git a/lib/src/media.test.ts b/lib/src/media.test.ts index d55f5c2..ed707f2 100644 --- a/lib/src/media.test.ts +++ b/lib/src/media.test.ts @@ -2,10 +2,11 @@ import {describe, expect, it } from '@jest/globals'; import * as media from './media'; import * as path from 'path'; +import Asset from './asset'; describe("Media", () => { it("parse jpeg", async () => { - const filepath = path.join(__dirname, '..', '..', '_assets', 'static', 'kaede.jpg'); + const filepath = new Asset().pathOf('static/kaede.jpg'); const r = await media.probe(filepath); expect(r.width).toEqual(1000); expect(r.height).toEqual(1000); diff --git a/server/src/controller/IndexController.ts b/server/src/controller/IndexController.ts new file mode 100644 index 0000000..b362213 --- /dev/null +++ b/server/src/controller/IndexController.ts @@ -0,0 +1,3 @@ +export default class IndexController { + +} \ No newline at end of file