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/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"] 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..20824aca10 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", @@ -25,9 +25,10 @@ "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" + "format": "gulp format", + "clean": "node ./scripts/clean.js" }, "dependencies": { "@types/gulp": "4.0.9", @@ -37,14 +38,13 @@ "gulp-cssnano": "2.1.3", "gulp-rename": "2.0.0", "gulp-replace": "1.1.3", - "gulp-terser": "2.1.0", - "gulp-tslint": "8.1.4" + "gulp-terser": "2.1.0" }, "devDependencies": { "@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/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/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/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/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 49850aa706..761f4d827b 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, @@ -125,9 +125,8 @@ function serialize(note: Note, poll: Poll | null = null): any { renoteId: note.renoteId, poll: poll, cw: note.cw, - viaMobile: note.viaMobile, visibility: note.visibility, visibleUserIds: note.visibleUserIds, - localOnly: note.localOnly + localOnly: note.localOnly, }; } diff --git a/packages/backend/src/remote/activitypub/models/note.ts b/packages/backend/src/remote/activitypub/models/note.ts index 492dc05248..39efadc65b 100644 --- a/packages/backend/src/remote/activitypub/models/note.ts +++ b/packages/backend/src/remote/activitypub/models/note.ts @@ -250,7 +250,6 @@ export async function createNote(value: string | IObject, resolver?: Resolver, s name: note.name, cw, text, - viaMobile: false, localOnly: false, visibility, visibleUsers, diff --git a/packages/backend/src/server/api/endpoints/notes/create.ts b/packages/backend/src/server/api/endpoints/notes/create.ts index 751673f955..8257ea1d0f 100644 --- a/packages/backend/src/server/api/endpoints/notes/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/create.ts @@ -57,11 +57,6 @@ export const meta = { validator: $.optional.nullable.str.pipe(Notes.validateCw), }, - viaMobile: { - validator: $.optional.bool, - default: false, - }, - localOnly: { validator: $.optional.bool, default: false, @@ -283,7 +278,6 @@ export default define(meta, async (ps, user) => { reply, renote, cw: ps.cw, - viaMobile: ps.viaMobile, localOnly: ps.localOnly, visibility: ps.visibility, visibleUsers, 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, 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/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/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