From be89516707f33d9f28cb7ccc90c535d1f4ee86cf Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 12 Nov 2021 11:42:47 +0900 Subject: [PATCH 01/13] add clean script --- gulpfile.js | 1 - package.json | 3 ++- packages/backend/package.json | 2 -- packages/backend/yarn.lock | 22 ---------------------- packages/client/package.json | 2 -- packages/client/yarn.lock | 8 -------- scripts/clean.js | 13 +++++++++++++ 7 files changed, 15 insertions(+), 36 deletions(-) create mode 100644 scripts/clean.js diff --git a/gulpfile.js b/gulpfile.js index c27abefcb8..a86185324a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,7 +4,6 @@ const fs = require('fs'); const gulp = require('gulp'); -const rimraf = require('rimraf'); const replace = require('gulp-replace'); const terser = require('gulp-terser'); const cssnano = require('gulp-cssnano'); diff --git a/package.json b/package.json index 64f5edcc90..07763b9003 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,8 @@ "e2e": "start-server-and-test start:test http://localhost:61812 cy:run", "mocha": "cd packages/backend && cross-env TS_NODE_FILES=true TS_NODE_TRANSPILE_ONLY=true TS_NODE_PROJECT=\"./test/tsconfig.json\" mocha", "test": "npm run mocha", - "format": "gulp format" + "format": "gulp format", + "clean": "node ./scripts/clean.js" }, "dependencies": { "@types/gulp": "4.0.9", diff --git a/packages/backend/package.json b/packages/backend/package.json index 871a0c5e9f..4376dc4887 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -59,7 +59,6 @@ "@types/redis": "2.8.32", "@types/rename": "1.0.4", "@types/request-stats": "3.0.0", - "@types/rimraf": "3.0.2", "@types/seedrandom": "2.4.28", "@types/sharp": "0.29.3", "@types/sinonjs__fake-timers": "6.0.4", @@ -162,7 +161,6 @@ "rename": "1.0.4", "request-stats": "3.0.0", "require-all": "3.0.0", - "rimraf": "3.0.2", "rndstr": "1.0.0", "s-age": "1.1.2", "seedrandom": "3.0.5", diff --git a/packages/backend/yarn.lock b/packages/backend/yarn.lock index 887b540767..0346380ee1 100644 --- a/packages/backend/yarn.lock +++ b/packages/backend/yarn.lock @@ -400,11 +400,6 @@ resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.46.tgz#0fb6bfbbeabd7a30880504993369c4bf1deab1fe" integrity sha512-laIjwTQaD+5DukBZaygQ79K1Z0jb1bPEMRrkXSLjtCcZm+abyp5YbrqpSLzD42FwWW6gK/aS4NYpJ804nG2brg== -"@types/events@*": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7" - integrity sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g== - "@types/express-serve-static-core@*": version "4.17.5" resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.5.tgz#a00ac7dadd746ae82477443e4d480a6a93ea083c" @@ -430,15 +425,6 @@ dependencies: "@types/node" "*" -"@types/glob@*": - version "7.1.1" - resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.1.tgz#aa59a1c6e3fbc421e07ccd31a944c30eba521575" - integrity sha512-1Bh06cbWJUHMC97acuD6UMG29nMt0Aqz1vF3guLfG+kHHJhy3AyohZFFxYk2f7Q1SQIrNwvncxAE0N/9s70F2w== - dependencies: - "@types/events" "*" - "@types/minimatch" "*" - "@types/node" "*" - "@types/glob@7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb" @@ -778,14 +764,6 @@ dependencies: "@types/node" "*" -"@types/rimraf@3.0.2": - version "3.0.2" - resolved "https://registry.yarnpkg.com/@types/rimraf/-/rimraf-3.0.2.tgz#a63d175b331748e5220ad48c901d7bbf1f44eef8" - integrity sha512-F3OznnSLAUxFrCEu/L5PY8+ny8DtcFRjx7fZZ9bycvXRi3KPTRS9HOitGZwvPg0juRhXFWIeKX58cnX5YqLohQ== - dependencies: - "@types/glob" "*" - "@types/node" "*" - "@types/rsvp@^4.0.4": version "4.0.4" resolved "https://registry.yarnpkg.com/@types/rsvp/-/rsvp-4.0.4.tgz#55e93e7054027f1ad4b4ebc1e60e59eb091e2d32" diff --git a/packages/client/package.json b/packages/client/package.json index 24345b969f..697faee417 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -39,7 +39,6 @@ "@types/random-seed": "0.3.3", "@types/rename": "1.0.4", "@types/request-stats": "3.0.0", - "@types/rimraf": "3.0.2", "@types/seedrandom": "2.4.28", "@types/sinonjs__fake-timers": "6.0.4", "@types/speakeasy": "2.0.6", @@ -113,7 +112,6 @@ "reflect-metadata": "0.1.13", "rename": "1.0.4", "request-stats": "3.0.0", - "rimraf": "3.0.2", "rndstr": "1.0.0", "s-age": "1.1.2", "sass": "1.43.4", diff --git a/packages/client/yarn.lock b/packages/client/yarn.lock index 8dd3579bb2..23d2213205 100644 --- a/packages/client/yarn.lock +++ b/packages/client/yarn.lock @@ -662,14 +662,6 @@ dependencies: "@types/node" "*" -"@types/rimraf@3.0.2": - version "3.0.2" - resolved "https://registry.yarnpkg.com/@types/rimraf/-/rimraf-3.0.2.tgz#a63d175b331748e5220ad48c901d7bbf1f44eef8" - integrity sha512-F3OznnSLAUxFrCEu/L5PY8+ny8DtcFRjx7fZZ9bycvXRi3KPTRS9HOitGZwvPg0juRhXFWIeKX58cnX5YqLohQ== - dependencies: - "@types/glob" "*" - "@types/node" "*" - "@types/seedrandom@2.4.28": version "2.4.28" resolved "https://registry.yarnpkg.com/@types/seedrandom/-/seedrandom-2.4.28.tgz#9ce8fa048c1e8c85cb71d7fe4d704e000226036f" diff --git a/scripts/clean.js b/scripts/clean.js new file mode 100644 index 0000000000..1dca10605f --- /dev/null +++ b/scripts/clean.js @@ -0,0 +1,13 @@ +const fs = require('fs'); +const execa = require('execa'); + +(async () => { + fs.rmSync(__dirname + '/../packages/backend/built', { recursive: true, force: true }); + fs.rmSync(__dirname + '/../packages/backend/node_modules', { recursive: true, force: true }); + + fs.rmSync(__dirname + '/../packages/client/built', { recursive: true, force: true }); + fs.rmSync(__dirname + '/../packages/client/node_modules', { recursive: true, force: true }); + + fs.rmSync(__dirname + '/../built', { recursive: true, force: true }); + fs.rmSync(__dirname + '/../node_modules', { recursive: true, force: true }); +})(); From 9acc36185bf2d057ad8c6d0913efbf4be56ce398 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 12 Nov 2021 11:46:17 +0900 Subject: [PATCH 02/13] Update Dockerfile --- Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Dockerfile b/Dockerfile index 58e3eda119..6ba8d296da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,6 +26,10 @@ ENTRYPOINT ["/sbin/tini", "--"] COPY --from=builder /misskey/node_modules ./node_modules COPY --from=builder /misskey/built ./built +COPY --from=builder /misskey/packages/backend/node_modules ./packages/backend/node_modules +COPY --from=builder /misskey/packages/backend/built ./packages/backend/built +COPY --from=builder /misskey/packages/client/node_modules ./packages/client/node_modules +COPY --from=builder /misskey/packages/client/built ./packages/client/built COPY . ./ CMD ["npm", "run", "migrateandstart"] From 7706c38d3d4c7b4d501dc68768b1ba61645a3019 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 12 Nov 2021 12:07:37 +0900 Subject: [PATCH 03/13] fix test --- package.json | 2 +- {test => packages/backend/test}/.eslintrc | 0 {test => packages/backend/test}/activitypub.ts | 0 {test => packages/backend/test}/ap-request.ts | 0 {test => packages/backend/test}/api-visibility.ts | 0 {test => packages/backend/test}/api.ts | 0 {test => packages/backend/test}/block.ts | 0 {test => packages/backend/test}/chart.ts | 0 {test => packages/backend/test}/docker-compose.yml | 0 {test => packages/backend/test}/extract-mentions.ts | 0 {test => packages/backend/test}/fetch-resource.ts | 0 {test => packages/backend/test}/ff-visibility.ts | 0 {test => packages/backend/test}/get-file-info.ts | 0 {test => packages/backend/test}/mfm.ts | 0 .../backend/test}/misc/mock-resolver.ts | 0 {test => packages/backend/test}/mute.ts | 0 {test => packages/backend/test}/note.ts | 0 {test => packages/backend/test}/prelude/maybe.ts | 0 {test => packages/backend/test}/prelude/url.ts | 0 {test => packages/backend/test}/reaction-lib.ts | 0 .../backend/test}/resources/25000x25000.png | Bin {test => packages/backend/test}/resources/Lenna.jpg | Bin {test => packages/backend/test}/resources/Lenna.png | Bin {test => packages/backend/test}/resources/anime.gif | Bin {test => packages/backend/test}/resources/anime.png | Bin {test => packages/backend/test}/resources/emptyfile | 0 {test => packages/backend/test}/resources/image.svg | 0 .../backend/test}/resources/with-alpha.png | Bin .../backend/test}/resources/with-xml-def.svg | 0 {test => packages/backend/test}/streaming.ts | 0 {test => packages/backend/test}/test.yml | 0 {test => packages/backend/test}/thread-mute.ts | 0 {test => packages/backend/test}/tsconfig.json | 0 {test => packages/backend/test}/user-notes.ts | 0 {test => packages/backend/test}/utils.ts | 2 +- 35 files changed, 2 insertions(+), 2 deletions(-) rename {test => packages/backend/test}/.eslintrc (100%) rename {test => packages/backend/test}/activitypub.ts (100%) rename {test => packages/backend/test}/ap-request.ts (100%) rename {test => packages/backend/test}/api-visibility.ts (100%) rename {test => packages/backend/test}/api.ts (100%) rename {test => packages/backend/test}/block.ts (100%) rename {test => packages/backend/test}/chart.ts (100%) rename {test => packages/backend/test}/docker-compose.yml (100%) rename {test => packages/backend/test}/extract-mentions.ts (100%) rename {test => packages/backend/test}/fetch-resource.ts (100%) rename {test => packages/backend/test}/ff-visibility.ts (100%) rename {test => packages/backend/test}/get-file-info.ts (100%) rename {test => packages/backend/test}/mfm.ts (100%) rename {test => packages/backend/test}/misc/mock-resolver.ts (100%) rename {test => packages/backend/test}/mute.ts (100%) rename {test => packages/backend/test}/note.ts (100%) rename {test => packages/backend/test}/prelude/maybe.ts (100%) rename {test => packages/backend/test}/prelude/url.ts (100%) rename {test => packages/backend/test}/reaction-lib.ts (100%) rename {test => packages/backend/test}/resources/25000x25000.png (100%) rename {test => packages/backend/test}/resources/Lenna.jpg (100%) rename {test => packages/backend/test}/resources/Lenna.png (100%) rename {test => packages/backend/test}/resources/anime.gif (100%) rename {test => packages/backend/test}/resources/anime.png (100%) rename {test => packages/backend/test}/resources/emptyfile (100%) rename {test => packages/backend/test}/resources/image.svg (100%) rename {test => packages/backend/test}/resources/with-alpha.png (100%) rename {test => packages/backend/test}/resources/with-xml-def.svg (100%) rename {test => packages/backend/test}/streaming.ts (100%) rename {test => packages/backend/test}/test.yml (100%) rename {test => packages/backend/test}/thread-mute.ts (100%) rename {test => packages/backend/test}/tsconfig.json (100%) rename {test => packages/backend/test}/user-notes.ts (100%) rename {test => packages/backend/test}/utils.ts (98%) diff --git a/package.json b/package.json index 07763b9003..f577fed1b8 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "cy:open": "cypress open", "cy:run": "cypress run", "e2e": "start-server-and-test start:test http://localhost:61812 cy:run", - "mocha": "cd packages/backend && cross-env TS_NODE_FILES=true TS_NODE_TRANSPILE_ONLY=true TS_NODE_PROJECT=\"./test/tsconfig.json\" mocha", + "mocha": "cd packages/backend && cross-env TS_NODE_FILES=true TS_NODE_TRANSPILE_ONLY=true TS_NODE_PROJECT=\"./test/tsconfig.json\" npx mocha", "test": "npm run mocha", "format": "gulp format", "clean": "node ./scripts/clean.js" diff --git a/test/.eslintrc b/packages/backend/test/.eslintrc similarity index 100% rename from test/.eslintrc rename to packages/backend/test/.eslintrc diff --git a/test/activitypub.ts b/packages/backend/test/activitypub.ts similarity index 100% rename from test/activitypub.ts rename to packages/backend/test/activitypub.ts diff --git a/test/ap-request.ts b/packages/backend/test/ap-request.ts similarity index 100% rename from test/ap-request.ts rename to packages/backend/test/ap-request.ts diff --git a/test/api-visibility.ts b/packages/backend/test/api-visibility.ts similarity index 100% rename from test/api-visibility.ts rename to packages/backend/test/api-visibility.ts diff --git a/test/api.ts b/packages/backend/test/api.ts similarity index 100% rename from test/api.ts rename to packages/backend/test/api.ts diff --git a/test/block.ts b/packages/backend/test/block.ts similarity index 100% rename from test/block.ts rename to packages/backend/test/block.ts diff --git a/test/chart.ts b/packages/backend/test/chart.ts similarity index 100% rename from test/chart.ts rename to packages/backend/test/chart.ts diff --git a/test/docker-compose.yml b/packages/backend/test/docker-compose.yml similarity index 100% rename from test/docker-compose.yml rename to packages/backend/test/docker-compose.yml diff --git a/test/extract-mentions.ts b/packages/backend/test/extract-mentions.ts similarity index 100% rename from test/extract-mentions.ts rename to packages/backend/test/extract-mentions.ts diff --git a/test/fetch-resource.ts b/packages/backend/test/fetch-resource.ts similarity index 100% rename from test/fetch-resource.ts rename to packages/backend/test/fetch-resource.ts diff --git a/test/ff-visibility.ts b/packages/backend/test/ff-visibility.ts similarity index 100% rename from test/ff-visibility.ts rename to packages/backend/test/ff-visibility.ts diff --git a/test/get-file-info.ts b/packages/backend/test/get-file-info.ts similarity index 100% rename from test/get-file-info.ts rename to packages/backend/test/get-file-info.ts diff --git a/test/mfm.ts b/packages/backend/test/mfm.ts similarity index 100% rename from test/mfm.ts rename to packages/backend/test/mfm.ts diff --git a/test/misc/mock-resolver.ts b/packages/backend/test/misc/mock-resolver.ts similarity index 100% rename from test/misc/mock-resolver.ts rename to packages/backend/test/misc/mock-resolver.ts diff --git a/test/mute.ts b/packages/backend/test/mute.ts similarity index 100% rename from test/mute.ts rename to packages/backend/test/mute.ts diff --git a/test/note.ts b/packages/backend/test/note.ts similarity index 100% rename from test/note.ts rename to packages/backend/test/note.ts diff --git a/test/prelude/maybe.ts b/packages/backend/test/prelude/maybe.ts similarity index 100% rename from test/prelude/maybe.ts rename to packages/backend/test/prelude/maybe.ts diff --git a/test/prelude/url.ts b/packages/backend/test/prelude/url.ts similarity index 100% rename from test/prelude/url.ts rename to packages/backend/test/prelude/url.ts diff --git a/test/reaction-lib.ts b/packages/backend/test/reaction-lib.ts similarity index 100% rename from test/reaction-lib.ts rename to packages/backend/test/reaction-lib.ts diff --git a/test/resources/25000x25000.png b/packages/backend/test/resources/25000x25000.png similarity index 100% rename from test/resources/25000x25000.png rename to packages/backend/test/resources/25000x25000.png diff --git a/test/resources/Lenna.jpg b/packages/backend/test/resources/Lenna.jpg similarity index 100% rename from test/resources/Lenna.jpg rename to packages/backend/test/resources/Lenna.jpg diff --git a/test/resources/Lenna.png b/packages/backend/test/resources/Lenna.png similarity index 100% rename from test/resources/Lenna.png rename to packages/backend/test/resources/Lenna.png diff --git a/test/resources/anime.gif b/packages/backend/test/resources/anime.gif similarity index 100% rename from test/resources/anime.gif rename to packages/backend/test/resources/anime.gif diff --git a/test/resources/anime.png b/packages/backend/test/resources/anime.png similarity index 100% rename from test/resources/anime.png rename to packages/backend/test/resources/anime.png diff --git a/test/resources/emptyfile b/packages/backend/test/resources/emptyfile similarity index 100% rename from test/resources/emptyfile rename to packages/backend/test/resources/emptyfile diff --git a/test/resources/image.svg b/packages/backend/test/resources/image.svg similarity index 100% rename from test/resources/image.svg rename to packages/backend/test/resources/image.svg diff --git a/test/resources/with-alpha.png b/packages/backend/test/resources/with-alpha.png similarity index 100% rename from test/resources/with-alpha.png rename to packages/backend/test/resources/with-alpha.png diff --git a/test/resources/with-xml-def.svg b/packages/backend/test/resources/with-xml-def.svg similarity index 100% rename from test/resources/with-xml-def.svg rename to packages/backend/test/resources/with-xml-def.svg diff --git a/test/streaming.ts b/packages/backend/test/streaming.ts similarity index 100% rename from test/streaming.ts rename to packages/backend/test/streaming.ts diff --git a/test/test.yml b/packages/backend/test/test.yml similarity index 100% rename from test/test.yml rename to packages/backend/test/test.yml diff --git a/test/thread-mute.ts b/packages/backend/test/thread-mute.ts similarity index 100% rename from test/thread-mute.ts rename to packages/backend/test/thread-mute.ts diff --git a/test/tsconfig.json b/packages/backend/test/tsconfig.json similarity index 100% rename from test/tsconfig.json rename to packages/backend/test/tsconfig.json diff --git a/test/user-notes.ts b/packages/backend/test/user-notes.ts similarity index 100% rename from test/user-notes.ts rename to packages/backend/test/user-notes.ts diff --git a/test/utils.ts b/packages/backend/test/utils.ts similarity index 98% rename from test/utils.ts rename to packages/backend/test/utils.ts index 54bcf65ab1..b7f6cfbdac 100644 --- a/test/utils.ts +++ b/packages/backend/test/utils.ts @@ -179,7 +179,7 @@ export function startServer(timeout = 30 * 1000): Promise Date: Fri, 12 Nov 2021 12:43:55 +0900 Subject: [PATCH 04/13] test --- .github/misskey/test.yml | 9 ++++++--- .github/workflows/test.yml | 4 ++-- packages/backend/test/test.yml | 12 ------------ 3 files changed, 8 insertions(+), 17 deletions(-) delete mode 100644 packages/backend/test/test.yml diff --git a/.github/misskey/test.yml b/.github/misskey/test.yml index ae18a841bd..cd33f8a93b 100644 --- a/.github/misskey/test.yml +++ b/.github/misskey/test.yml @@ -1,12 +1,15 @@ url: 'http://misskey.local' -port: 8080 + +# ローカルでテストするときにポートを被らないようにするためデフォルトのものとは変える(以下同じ) +port: 61812 + db: host: localhost - port: 5432 + port: 54312 db: test-misskey user: postgres pass: '' redis: host: localhost - port: 6379 + port: 56312 id: aid diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 045d209802..e220d714d0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,7 +41,7 @@ jobs: - name: Check yarn.lock run: git diff --exit-code yarn.lock - name: Copy Configure - run: cp test/test.yml .config + run: cp .github/misskey/test.yml .config - name: Build run: yarn build - name: Test @@ -80,7 +80,7 @@ jobs: - name: Check yarn.lock run: git diff --exit-code yarn.lock - name: Copy Configure - run: cp test/test.yml .config + run: cp .github/misskey/test.yml .config - name: Build run: yarn build - name: Test diff --git a/packages/backend/test/test.yml b/packages/backend/test/test.yml deleted file mode 100644 index 2d3094653e..0000000000 --- a/packages/backend/test/test.yml +++ /dev/null @@ -1,12 +0,0 @@ -url: 'http://misskey.local' -port: 61812 -db: - host: localhost - port: 54312 - db: test-misskey - user: postgres - pass: '' -redis: - host: localhost - port: 56312 -id: aid From 0484976afae36d7e900f8649102c54bf17496281 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 12 Nov 2021 12:58:11 +0900 Subject: [PATCH 05/13] fix e2e test --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f577fed1b8..5669ebc1f6 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "postinstall": "node ./scripts/install-packages.js", "build": "node ./scripts/build.js", "start": "cd packages/backend && node --experimental-json-modules ./built/index.js", - "start:test": "cd packages/backend && cross-env NODE_ENV=test node --experimental-json-modules ./index.js", + "start:test": "cd packages/backend && cross-env NODE_ENV=test node --experimental-json-modules ./built/index.js", "init": "npm run migrate", "ormconfig": "node ./packages/backend/ormconfig.js", "migrate": "cd packages/backend && npx typeorm migration:run", From 4786214e2a0374228263db108ec4fce7ceec8d50 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 12 Nov 2021 13:39:57 +0900 Subject: [PATCH 06/13] fix bug --- packages/backend/src/db/postgre.ts | 30 ++++++++++++++++++------ packages/backend/src/server/web/index.ts | 8 +++++++ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/packages/backend/src/db/postgre.ts b/packages/backend/src/db/postgre.ts index f52c2ab722..efbacf3d10 100644 --- a/packages/backend/src/db/postgre.ts +++ b/packages/backend/src/db/postgre.ts @@ -215,11 +215,27 @@ export function initDb(justBorrow = false, sync = false, forceRecreate = false) } export async function resetDb() { - const conn = await getConnection(); - const tables = await conn.query(`SELECT relname AS "table" - FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) - WHERE nspname NOT IN ('pg_catalog', 'information_schema') - AND C.relkind = 'r' - AND nspname !~ '^pg_toast';`); - await Promise.all(tables.map(t => t.table).map(x => conn.query(`DELETE FROM "${x}" CASCADE`))); + const reset = async () => { + const conn = await getConnection(); + const tables = await conn.query(`SELECT relname AS "table" + FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) + WHERE nspname NOT IN ('pg_catalog', 'information_schema') + AND C.relkind = 'r' + AND nspname !~ '^pg_toast';`); + await Promise.all(tables.map(t => t.table).map(x => conn.query(`DELETE FROM "${x}" CASCADE`))); + }; + + for (let i = 1; i <= 3; i++) { + try { + await reset(); + } catch (e) { + if (i === 3) { + throw e; + } else { + await new Promise(resolve => setTimeout(resolve, 1000)); + continue; + } + } + break; + } } diff --git a/packages/backend/src/server/web/index.ts b/packages/backend/src/server/web/index.ts index 969b155d4d..fc95a36a87 100644 --- a/packages/backend/src/server/web/index.ts +++ b/packages/backend/src/server/web/index.ts @@ -23,6 +23,7 @@ const _filename = __filename; const _dirname = dirname(_filename); const staticAssets = `${_dirname}/../../../assets/`; +const clientAssets = `${_dirname}/../../../../client/assets/`; const assets = `${_dirname}/../../../../../built/_client_dist_/`; // Init app @@ -59,6 +60,13 @@ router.get('/static-assets/(.*)', async ctx => { }); }); +router.get('/client-assets/(.*)', async ctx => { + await send(ctx as any, ctx.path.replace('/client-assets/', ''), { + root: clientAssets, + maxage: ms('7 days'), + }); +}); + router.get('/assets/(.*)', async ctx => { await send(ctx as any, ctx.path.replace('/assets/', ''), { root: assets, From b875b0faa2f4a857741eaae73d0f6aa5a8864a59 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 12 Nov 2021 14:45:01 +0900 Subject: [PATCH 07/13] Bump cypress from 8.5.0 to 9.0.0 (#7972) Bumps [cypress](https://github.com/cypress-io/cypress) from 8.5.0 to 9.0.0. - [Release notes](https://github.com/cypress-io/cypress/releases) - [Changelog](https://github.com/cypress-io/cypress/blob/develop/.releaserc.base.js) - [Commits](https://github.com/cypress-io/cypress/compare/v8.5.0...v9.0.0) --- updated-dependencies: - dependency-name: cypress dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 33 ++++++++++----------------------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index 5669ebc1f6..0bd5fe41bc 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@redocly/openapi-core": "1.0.0-beta.54", "@types/fluent-ffmpeg": "2.1.17", "cross-env": "7.0.3", - "cypress": "8.5.0", + "cypress": "9.0.0", "start-server-and-test": "1.14.0" } } diff --git a/yarn.lock b/yarn.lock index 3d82134974..2968bd3e9b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,10 +2,10 @@ # yarn lockfile v1 -"@cypress/request@^2.88.6": - version "2.88.6" - resolved "https://registry.yarnpkg.com/@cypress/request/-/request-2.88.6.tgz#a970dd675befc6bdf8a8921576c01f51cc5798e9" - integrity sha512-z0UxBE/+qaESAHY9p9sM2h8Y4XqtsbDCt0/DPOrqA/RZgKi4PkxdpXyK4wCCnSk1xHqWHZZAE+gV6aDAR6+caQ== +"@cypress/request@^2.88.7": + version "2.88.7" + resolved "https://registry.yarnpkg.com/@cypress/request/-/request-2.88.7.tgz#386d960ab845a96953723348088525d5a75aaac4" + integrity sha512-FTULIP2rnDJvZDT9t6B4nSfYR40ue19tVmv3wUcY05R9/FPCoMl1nAPJkzWzBCo7ltVn5ThQTbxiMoGBN7k0ig== dependencies: aws-sign2 "~0.7.0" aws4 "^1.8.0" @@ -1045,12 +1045,12 @@ csso@~2.3.1: clap "^1.0.9" source-map "^0.5.3" -cypress@8.5.0: - version "8.5.0" - resolved "https://registry.yarnpkg.com/cypress/-/cypress-8.5.0.tgz#5712ca170913f8344bf167301205c4217c1eb9bd" - integrity sha512-MMkXIS+Ro2KETn4gAlG3tIc/7FiljuuCZP0zpd9QsRG6MZSyZW/l1J3D4iQM6WHsVxuX4rFChn5jPFlC2tNSvQ== +cypress@9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/cypress/-/cypress-9.0.0.tgz#8c496f7f350e611604cc2f77b663fb81d0c235d2" + integrity sha512-/93SWBZTw7BjFZ+I9S8SqkFYZx7VhedDjTtRBmXO0VzTeDbmxgK/snMJm/VFjrqk/caWbI+XY4Qr80myDMQvYg== dependencies: - "@cypress/request" "^2.88.6" + "@cypress/request" "^2.88.7" "@cypress/xvfb" "^1.2.4" "@types/node" "^14.14.31" "@types/sinonjs__fake-timers" "^6.0.2" @@ -1085,7 +1085,6 @@ cypress@8.5.0: ospath "^1.2.2" pretty-bytes "^5.6.0" proxy-from-env "1.0.0" - ramda "~0.27.1" request-progress "^3.0.0" supports-color "^8.1.1" tmp "~0.2.1" @@ -1113,7 +1112,7 @@ dayjs@^1.10.4: resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.10.6.tgz#288b2aa82f2d8418a6c9d4df5898c0737ad02a63" integrity sha512-AztC/IOW4L1Q41A86phW5Thhcrco3xuAA+YX/BLpLWWjRcTj5TOt/QImBLmCKlrF7u7k47arTnOyL6GnbG8Hvw== -debug@4.3.2, debug@^4.3.2: +debug@4.3.2, debug@^4.1.1, debug@^4.3.2: version "4.3.2" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.2.tgz#f0a49c18ac8779e31d4a0c6029dfb76873c7428b" integrity sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw== @@ -1134,13 +1133,6 @@ debug@^3.1.0: dependencies: ms "^2.1.1" -debug@^4.1.1: - version "4.3.1" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.1.tgz#f0d229c505e0c6d8c49ac553d1b13dc183f6b2ee" - integrity sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ== - dependencies: - ms "2.1.2" - decamelize@^1.1.1, decamelize@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -3335,11 +3327,6 @@ querystring@0.2.0: resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" integrity sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA= -ramda@~0.27.1: - version "0.27.1" - resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.27.1.tgz#66fc2df3ef873874ffc2da6aa8984658abacf5c9" - integrity sha512-PgIdVpn5y5Yns8vqb8FzBUEYn98V3xcPgawAkkgj0YJ0qDsnHCiNmZYfOGMgOvoB0eWFLpYbhxUR3mxfDIMvpw== - read-pkg-up@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" From b404ce463fe6386f35f0a66ede6871082f1540bf Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 12 Nov 2021 15:08:36 +0900 Subject: [PATCH 08/13] refactor --- .../backend/src/queue/processors/db/export-notes.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/queue/processors/db/export-notes.ts b/packages/backend/src/queue/processors/db/export-notes.ts index 49850aa706..bd178556df 100644 --- a/packages/backend/src/queue/processors/db/export-notes.ts +++ b/packages/backend/src/queue/processors/db/export-notes.ts @@ -46,18 +46,18 @@ export async function exportNotes(job: Bull.Job, done: any): Prom }); let exportedNotesCount = 0; - let cursor: any = null; + let cursor: Note['id'] | null = null; while (true) { const notes = await Notes.find({ where: { userId: user.id, - ...(cursor ? { id: MoreThan(cursor) } : {}) + ...(cursor ? { id: MoreThan(cursor) } : {}), }, take: 100, order: { - id: 1 - } + id: 1, + }, }); if (notes.length === 0) { @@ -115,7 +115,7 @@ export async function exportNotes(job: Bull.Job, done: any): Prom done(); } -function serialize(note: Note, poll: Poll | null = null): any { +function serialize(note: Note, poll: Poll | null = null): Record { return { id: note.id, text: note.text, @@ -128,6 +128,6 @@ function serialize(note: Note, poll: Poll | null = null): any { viaMobile: note.viaMobile, visibility: note.visibility, visibleUserIds: note.visibleUserIds, - localOnly: note.localOnly + localOnly: note.localOnly, }; } From 6496835515f12c8221e6e852edba1e0ba4fdf663 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 12 Nov 2021 15:11:20 +0900 Subject: [PATCH 09/13] =?UTF-8?q?viaMobile=E3=83=95=E3=83=A9=E3=82=B0?= =?UTF-8?q?=E5=BB=83=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Close #7965 --- .../migration/1636697408073-remove-via-mobile.js | 13 +++++++++++++ packages/backend/src/models/entities/note.ts | 5 ----- packages/backend/src/models/repositories/note.ts | 5 ----- .../backend/src/queue/processors/db/export-notes.ts | 1 - .../backend/src/remote/activitypub/models/note.ts | 1 - .../src/server/api/endpoints/notes/create.ts | 6 ------ packages/backend/src/services/note/create.ts | 3 --- packages/client/src/components/note-detailed.vue | 1 - packages/client/src/components/note-header.vue | 5 ----- packages/client/src/components/post-form.vue | 2 -- packages/client/src/ui/chat/note-header.vue | 5 ----- packages/client/src/ui/chat/post-form.vue | 2 -- 12 files changed, 13 insertions(+), 36 deletions(-) create mode 100644 packages/backend/migration/1636697408073-remove-via-mobile.js diff --git a/packages/backend/migration/1636697408073-remove-via-mobile.js b/packages/backend/migration/1636697408073-remove-via-mobile.js new file mode 100644 index 0000000000..bb5157cf1d --- /dev/null +++ b/packages/backend/migration/1636697408073-remove-via-mobile.js @@ -0,0 +1,13 @@ +const { MigrationInterface, QueryRunner } = require("typeorm"); + +module.exports = class removeViaMobile1636697408073 { + name = 'removeViaMobile1636697408073' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "note" DROP COLUMN "viaMobile"`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "note" ADD "viaMobile" boolean NOT NULL DEFAULT false`); + } +} diff --git a/packages/backend/src/models/entities/note.ts b/packages/backend/src/models/entities/note.ts index 4a5411f93d..9dee25ea2a 100644 --- a/packages/backend/src/models/entities/note.ts +++ b/packages/backend/src/models/entities/note.ts @@ -81,11 +81,6 @@ export class Note { @JoinColumn() public user: User | null; - @Column('boolean', { - default: false - }) - public viaMobile: boolean; - @Column('boolean', { default: false }) diff --git a/packages/backend/src/models/repositories/note.ts b/packages/backend/src/models/repositories/note.ts index 0f00c34c9c..c076cb31e8 100644 --- a/packages/backend/src/models/repositories/note.ts +++ b/packages/backend/src/models/repositories/note.ts @@ -230,7 +230,6 @@ export class NoteRepository extends Repository { visibility: note.visibility, localOnly: note.localOnly || undefined, visibleUserIds: note.visibility === 'specified' ? note.visibleUserIds : undefined, - viaMobile: note.viaMobile || undefined, renoteCount: note.renoteCount, repliesCount: note.repliesCount, reactions: convertLegacyReactions(note.reactions), @@ -377,10 +376,6 @@ export const packedNoteSchema = { optional: true as const, nullable: true as const, ref: 'Note' as const, }, - viaMobile: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, - }, isHidden: { type: 'boolean' as const, optional: true as const, nullable: false as const, diff --git a/packages/backend/src/queue/processors/db/export-notes.ts b/packages/backend/src/queue/processors/db/export-notes.ts index bd178556df..761f4d827b 100644 --- a/packages/backend/src/queue/processors/db/export-notes.ts +++ b/packages/backend/src/queue/processors/db/export-notes.ts @@ -125,7 +125,6 @@ function serialize(note: Note, poll: Poll | null = null): Record { reply, renote, cw: ps.cw, - viaMobile: ps.viaMobile, localOnly: ps.localOnly, visibility: ps.visibility, visibleUsers, diff --git a/packages/backend/src/services/note/create.ts b/packages/backend/src/services/note/create.ts index 69d854ab1a..8f6c2fe3a5 100644 --- a/packages/backend/src/services/note/create.ts +++ b/packages/backend/src/services/note/create.ts @@ -98,7 +98,6 @@ type Option = { renote?: Note | null; files?: DriveFile[] | null; poll?: IPoll | null; - viaMobile?: boolean | null; localOnly?: boolean | null; cw?: string | null; visibility?: string; @@ -131,7 +130,6 @@ export default async (user: { id: User['id']; username: User['username']; host: if (data.createdAt == null) data.createdAt = new Date(); if (data.visibility == null) data.visibility = 'public'; - if (data.viaMobile == null) data.viaMobile = false; if (data.localOnly == null) data.localOnly = false; if (data.channel != null) data.visibility = 'public'; if (data.channel != null) data.visibleUsers = []; @@ -478,7 +476,6 @@ async function insertNote(user: { id: User['id']; host: User['host']; }, data: O tags: tags.map(tag => normalizeForSearch(tag)), emojis, userId: user.id, - viaMobile: data.viaMobile!, localOnly: data.localOnly!, visibility: data.visibility as any, visibleUserIds: data.visibility == 'specified' diff --git a/packages/client/src/components/note-detailed.vue b/packages/client/src/components/note-detailed.vue index 8b6905a0e4..7550153521 100644 --- a/packages/client/src/components/note-detailed.vue +++ b/packages/client/src/components/note-detailed.vue @@ -86,7 +86,6 @@