From c27eba4d39ca244ce657ab41bb55fc4cfb63df9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Acid=20Chicken=20=28=E7=A1=AB=E9=85=B8=E9=B6=8F=29?= Date: Mon, 12 Feb 2024 00:36:18 +0900 Subject: [PATCH 1/5] feat: provide tarball --- package.json | 6 ++- .../src/server/web/ClientServerService.ts | 8 ++++ packages/frontend/src/pages/about.vue | 1 + pnpm-lock.yaml | 19 ++++++++- scripts/tarball.mjs | 42 +++++++++++++++++++ 5 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 scripts/tarball.mjs diff --git a/package.json b/package.json index 6136ef39df67..ea8e9f0e6398 100644 --- a/package.json +++ b/package.json @@ -48,8 +48,8 @@ "lodash": "4.17.21" }, "dependencies": { - "execa": "8.0.1", "cssnano": "6.0.3", + "execa": "8.0.1", "js-yaml": "4.1.0", "postcss": "8.4.33", "terser": "5.27.0", @@ -61,8 +61,10 @@ "cross-env": "7.0.3", "cypress": "13.6.3", "eslint": "8.56.0", + "fast-glob": "3.3.2", + "ncp": "2.0.0", "start-server-and-test": "2.0.3", - "ncp": "2.0.0" + "tar": "6.2.0" }, "optionalDependencies": { "@tensorflow/tfjs-core": "4.4.0" diff --git a/packages/backend/src/server/web/ClientServerService.ts b/packages/backend/src/server/web/ClientServerService.ts index 8e1a89d55f9a..a5094e6a86a9 100644 --- a/packages/backend/src/server/web/ClientServerService.ts +++ b/packages/backend/src/server/web/ClientServerService.ts @@ -51,6 +51,7 @@ const clientAssets = `${_dirname}/../../../../frontend/assets/`; const assets = `${_dirname}/../../../../../built/_frontend_dist_/`; const swAssets = `${_dirname}/../../../../../built/_sw_dist_/`; const viteOut = `${_dirname}/../../../../../built/_vite_/`; +const tarball = `${_dirname}/../../../../../built/tarball/`; @Injectable() export class ClientServerService { @@ -291,6 +292,13 @@ export class ClientServerService { decorateReply: false, }); + fastify.register(fastifyStatic, { + root: tarball, + prefix: '/tarball/', + immutable: true, + decorateReply: false, + }); + fastify.get('/favicon.ico', async (request, reply) => { return reply.sendFile('/favicon.ico', staticAssets); }); diff --git a/packages/frontend/src/pages/about.vue b/packages/frontend/src/pages/about.vue index 69cb6ef647cf..8e5fcda283f9 100644 --- a/packages/frontend/src/pages/about.vue +++ b/packages/frontend/src/pages/about.vue @@ -86,6 +86,7 @@ SPDX-License-Identifier: AGPL-3.0-only nodeinfo robots.txt manifest.json + source code diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 640713067fcc..d3e0b2b9137b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -50,12 +50,18 @@ importers: eslint: specifier: 8.56.0 version: 8.56.0 + fast-glob: + specifier: 3.3.2 + version: 3.3.2 ncp: specifier: 2.0.0 version: 2.0.0 start-server-and-test: specifier: 2.0.3 version: 2.0.3 + tar: + specifier: 6.2.0 + version: 6.2.0 packages/backend: dependencies: @@ -15456,7 +15462,6 @@ packages: /minipass@5.0.0: resolution: {integrity: sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==} engines: {node: '>=8'} - dev: false /minipass@7.0.4: resolution: {integrity: sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==} @@ -19095,6 +19100,18 @@ packages: mkdirp: 1.0.4 yallist: 4.0.0 + /tar@6.2.0: + resolution: {integrity: sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ==} + engines: {node: '>=10'} + dependencies: + chownr: 2.0.0 + fs-minipass: 2.1.0 + minipass: 5.0.0 + minizlib: 2.1.2 + mkdirp: 1.0.4 + yallist: 4.0.0 + dev: true + /taskkill@5.0.0: resolution: {integrity: sha512-+HRtZ40Vc+6YfCDWCeAsixwxJgMbPY4HHuTgzPYH3JXvqHWUlsCfy+ylXlAKhFNcuLp4xVeWeFBUhDk+7KYUvQ==} engines: {node: '>=14.16'} diff --git a/scripts/tarball.mjs b/scripts/tarball.mjs new file mode 100644 index 000000000000..2652a182f512 --- /dev/null +++ b/scripts/tarball.mjs @@ -0,0 +1,42 @@ +import { createWriteStream } from 'node:fs'; +import { mkdir } from 'node:fs/promises'; +import { resolve } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import glob from 'fast-glob'; +import Pack from 'tar/lib/pack.js'; +import meta from '../package.json' assert { type: "json" }; + +const cwd = fileURLToPath(new URL('..', import.meta.url)); +const mkdirPromise = mkdir(resolve(cwd, 'built', 'tarball'), { recursive: true }); +const patterns = [ + '{assets,fluent-emojis,locales,misskey-assets}/**/*', + 'packages/.config/example.yml', + 'packages/{backend,frontend,misskey-bubble-game,misskey-js,misskey-js/generator,misskey-reversi,sw}/{src/**/*,.swcrc,*}', + 'packages/backend/{assets,migration,nsfw-model}/**/*', + 'packages/frontend/{.storybook,@types,assets,lib,public}/**/*', + '!packages/frontend/.storybook/{locale.ts,themes.ts,*.js}', + '!packages/misskey-js/CONTRIBUTING.md', + 'packages/meta.json', + 'scripts/{changelog-checker/{src/**/*,*},*}', + '.node-version', + '.npmrc', + 'CHANGELOD.md', + 'COPYING', + 'LICENSE', + 'README.md', + 'SECURITY.md', + 'package.json', + 'pnpm-lock.yaml', + 'pnpm-workspace.yaml', +]; +const pack = new Pack({ cwd, gzip: true }); + +for await (const entry of glob.stream(patterns)) { + pack.add(entry); +} + +pack.end(); + +await mkdirPromise; + +pack.pipe(createWriteStream(resolve(cwd, 'built', 'tarball', `misskey-${meta.version}.tar.gz`))); From 30224a847407a09f066df2996d18f7399dfc0973 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Acid=20Chicken=20=28=E7=A1=AB=E9=85=B8=E9=B6=8F=29?= Date: Mon, 12 Feb 2024 00:41:46 +0900 Subject: [PATCH 2/5] build: pack on build-assets --- scripts/build-assets.mjs | 4 +++- scripts/tarball.mjs | 21 ++++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/scripts/build-assets.mjs b/scripts/build-assets.mjs index d2dabe85326c..8a8a50d9ba38 100644 --- a/scripts/build-assets.mjs +++ b/scripts/build-assets.mjs @@ -12,6 +12,7 @@ import * as terser from 'terser'; import { build as buildLocales } from '../locales/index.js'; import generateDTS from '../locales/generateDTS.js'; import meta from '../package.json' assert { type: "json" }; +import buildTarball from './tarball.mjs'; let locales = buildLocales(); @@ -77,12 +78,13 @@ async function build() { copyBackendViews(), buildBackendScript(), buildBackendStyle(), + buildTarball(), ]); } await build(); -if (process.argv.includes("--watch")) { +if (process.argv.includes('--watch')) { const watcher = fs.watch('./locales'); for await (const event of watcher) { const filename = event.filename?.replaceAll('\\', '/'); diff --git a/scripts/tarball.mjs b/scripts/tarball.mjs index 2652a182f512..9de9c03e1d5d 100644 --- a/scripts/tarball.mjs +++ b/scripts/tarball.mjs @@ -6,8 +6,6 @@ import glob from 'fast-glob'; import Pack from 'tar/lib/pack.js'; import meta from '../package.json' assert { type: "json" }; -const cwd = fileURLToPath(new URL('..', import.meta.url)); -const mkdirPromise = mkdir(resolve(cwd, 'built', 'tarball'), { recursive: true }); const patterns = [ '{assets,fluent-emojis,locales,misskey-assets}/**/*', 'packages/.config/example.yml', @@ -29,14 +27,19 @@ const patterns = [ 'pnpm-lock.yaml', 'pnpm-workspace.yaml', ]; -const pack = new Pack({ cwd, gzip: true }); -for await (const entry of glob.stream(patterns)) { - pack.add(entry); -} +export default async function build() { + const cwd = fileURLToPath(new URL('..', import.meta.url)); + const mkdirPromise = mkdir(resolve(cwd, 'built', 'tarball'), { recursive: true }); + const pack = new Pack({ cwd, gzip: true }); + + for await (const entry of glob.stream(patterns)) { + pack.add(entry); + } -pack.end(); + pack.end(); -await mkdirPromise; + await mkdirPromise; -pack.pipe(createWriteStream(resolve(cwd, 'built', 'tarball', `misskey-${meta.version}.tar.gz`))); + pack.pipe(createWriteStream(resolve(cwd, 'built', 'tarball', `misskey-${meta.version}.tar.gz`))); +} From 95c4bb47e112f900dde3c1b334195075ab54409e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Acid=20Chicken=20=28=E7=A1=AB=E9=85=B8=E9=B6=8F=29?= Date: Mon, 12 Feb 2024 01:24:14 +0900 Subject: [PATCH 3/5] chore: use ignore-walk --- package.json | 1 + pnpm-lock.yaml | 10 ++++++++++ scripts/tarball.mjs | 32 ++++++++++---------------------- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index ea8e9f0e6398..4add6dbbc3fe 100644 --- a/package.json +++ b/package.json @@ -62,6 +62,7 @@ "cypress": "13.6.3", "eslint": "8.56.0", "fast-glob": "3.3.2", + "ignore-walk": "6.0.4", "ncp": "2.0.0", "start-server-and-test": "2.0.3", "tar": "6.2.0" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d3e0b2b9137b..a9ccaa3b99cf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -53,6 +53,9 @@ importers: fast-glob: specifier: 3.3.2 version: 3.3.2 + ignore-walk: + specifier: 6.0.4 + version: 6.0.4 ncp: specifier: 2.0.0 version: 2.0.0 @@ -13494,6 +13497,13 @@ packages: resolution: {integrity: sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==} dev: true + /ignore-walk@6.0.4: + resolution: {integrity: sha512-t7sv42WkwFkyKbivUCglsQW5YWMskWtbEf4MNKX5u/CCWHKSPzN4FtBQGsQZgCLbxOzpVlcbWVK5KB3auIOjSw==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + dependencies: + minimatch: 9.0.3 + dev: true + /ignore@5.2.4: resolution: {integrity: sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==} engines: {node: '>= 4'} diff --git a/scripts/tarball.mjs b/scripts/tarball.mjs index 9de9c03e1d5d..5f01faec9919 100644 --- a/scripts/tarball.mjs +++ b/scripts/tarball.mjs @@ -3,37 +3,25 @@ import { mkdir } from 'node:fs/promises'; import { resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; import glob from 'fast-glob'; +import walk from 'ignore-walk'; import Pack from 'tar/lib/pack.js'; import meta from '../package.json' assert { type: "json" }; -const patterns = [ - '{assets,fluent-emojis,locales,misskey-assets}/**/*', - 'packages/.config/example.yml', - 'packages/{backend,frontend,misskey-bubble-game,misskey-js,misskey-js/generator,misskey-reversi,sw}/{src/**/*,.swcrc,*}', - 'packages/backend/{assets,migration,nsfw-model}/**/*', - 'packages/frontend/{.storybook,@types,assets,lib,public}/**/*', - '!packages/frontend/.storybook/{locale.ts,themes.ts,*.js}', - '!packages/misskey-js/CONTRIBUTING.md', - 'packages/meta.json', - 'scripts/{changelog-checker/{src/**/*,*},*}', - '.node-version', - '.npmrc', - 'CHANGELOD.md', - 'COPYING', - 'LICENSE', - 'README.md', - 'SECURITY.md', - 'package.json', - 'pnpm-lock.yaml', - 'pnpm-workspace.yaml', +const cwd = fileURLToPath(new URL('..', import.meta.url)); +const ignore = [ + '**/.git/**/*', + '**/*ignore', + '**/.gitmodules', + // Exclude files you don't want to include in the tarball here ]; export default async function build() { - const cwd = fileURLToPath(new URL('..', import.meta.url)); const mkdirPromise = mkdir(resolve(cwd, 'built', 'tarball'), { recursive: true }); const pack = new Pack({ cwd, gzip: true }); + const patterns = await walk({ path: cwd, ignoreFiles: ['.gitignore'] }); - for await (const entry of glob.stream(patterns)) { + for await (const entry of glob.stream(patterns, { cwd, ignore, dot: true })) { + console.log(entry); pack.add(entry); } From b3ad56bcb52e5f8cbb897e09618092b485fde976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Acid=20Chicken=20=28=E7=A1=AB=E9=85=B8=E9=B6=8F=29?= Date: Mon, 12 Feb 2024 01:25:35 +0900 Subject: [PATCH 4/5] chore: debug --- scripts/tarball.mjs | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/tarball.mjs b/scripts/tarball.mjs index 5f01faec9919..936a43d27017 100644 --- a/scripts/tarball.mjs +++ b/scripts/tarball.mjs @@ -21,7 +21,6 @@ export default async function build() { const patterns = await walk({ path: cwd, ignoreFiles: ['.gitignore'] }); for await (const entry of glob.stream(patterns, { cwd, ignore, dot: true })) { - console.log(entry); pack.add(entry); } From 33f6b06b61c3a792584dac6b1d7481560e1f9d4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Acid=20Chicken=20=28=E7=A1=AB=E9=85=B8=E9=B6=8F=29?= Date: Mon, 12 Feb 2024 02:01:08 +0900 Subject: [PATCH 5/5] build: dependencies --- package.json | 8 ++++---- pnpm-lock.yaml | 23 ++++++++++++----------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 4add6dbbc3fe..c670e232e488 100644 --- a/package.json +++ b/package.json @@ -50,8 +50,11 @@ "dependencies": { "cssnano": "6.0.3", "execa": "8.0.1", + "fast-glob": "3.3.2", + "ignore-walk": "6.0.4", "js-yaml": "4.1.0", "postcss": "8.4.33", + "tar": "6.2.0", "terser": "5.27.0", "typescript": "5.3.3" }, @@ -61,11 +64,8 @@ "cross-env": "7.0.3", "cypress": "13.6.3", "eslint": "8.56.0", - "fast-glob": "3.3.2", - "ignore-walk": "6.0.4", "ncp": "2.0.0", - "start-server-and-test": "2.0.3", - "tar": "6.2.0" + "start-server-and-test": "2.0.3" }, "optionalDependencies": { "@tensorflow/tfjs-core": "4.4.0" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a9ccaa3b99cf..64352982643e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -18,12 +18,21 @@ importers: execa: specifier: 8.0.1 version: 8.0.1 + fast-glob: + specifier: 3.3.2 + version: 3.3.2 + ignore-walk: + specifier: 6.0.4 + version: 6.0.4 js-yaml: specifier: 4.1.0 version: 4.1.0 postcss: specifier: 8.4.33 version: 8.4.33 + tar: + specifier: 6.2.0 + version: 6.2.0 terser: specifier: 5.27.0 version: 5.27.0 @@ -50,21 +59,12 @@ importers: eslint: specifier: 8.56.0 version: 8.56.0 - fast-glob: - specifier: 3.3.2 - version: 3.3.2 - ignore-walk: - specifier: 6.0.4 - version: 6.0.4 ncp: specifier: 2.0.0 version: 2.0.0 start-server-and-test: specifier: 2.0.3 version: 2.0.3 - tar: - specifier: 6.2.0 - version: 6.2.0 packages/backend: dependencies: @@ -13502,7 +13502,7 @@ packages: engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} dependencies: minimatch: 9.0.3 - dev: true + dev: false /ignore@5.2.4: resolution: {integrity: sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==} @@ -15472,6 +15472,7 @@ packages: /minipass@5.0.0: resolution: {integrity: sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==} engines: {node: '>=8'} + dev: false /minipass@7.0.4: resolution: {integrity: sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==} @@ -19120,7 +19121,7 @@ packages: minizlib: 2.1.2 mkdirp: 1.0.4 yallist: 4.0.0 - dev: true + dev: false /taskkill@5.0.0: resolution: {integrity: sha512-+HRtZ40Vc+6YfCDWCeAsixwxJgMbPY4HHuTgzPYH3JXvqHWUlsCfy+ylXlAKhFNcuLp4xVeWeFBUhDk+7KYUvQ==}