Use pnpm for package manager (#9531)

* Use pnpm for package manager

* Fix

* Change github workflow

* use pnpm in workflow

* fix

* Fix test (e2e/jest)

* Update Dockerfile for pnpm

* Exclude node_modules from file search on VSCode

* Update pnpm-lock.yaml

* Update pnpm-lock.yaml

* Move typescript from devDependencies to dependencies

* Fix Dockerfile

Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
This commit is contained in:
CyberRex 2023-01-16 06:08:42 +09:00 committed by GitHub
parent 39349dcba5
commit 6e2d7e9792
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 13580 additions and 19342 deletions

View file

@ -8,22 +8,26 @@ on:
pull_request: pull_request:
jobs: jobs:
yarn_install: pnpm_install:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3.3.0 - uses: actions/checkout@v3.3.0
with: with:
fetch-depth: 0 fetch-depth: 0
submodules: true submodules: true
- uses: pnpm/action-setup@v2
with:
version: 7
run_install: false
- uses: actions/setup-node@v3.6.0 - uses: actions/setup-node@v3.6.0
with: with:
node-version: 18.x node-version: 18.x
cache: 'yarn' cache: 'pnpm'
- run: corepack enable - run: corepack enable
- run: yarn install --immutable - run: pnpm i --frozen-lockfile
lint: lint:
needs: [yarn_install] needs: [pnpm_install]
runs-on: ubuntu-latest runs-on: ubuntu-latest
continue-on-error: true continue-on-error: true
strategy: strategy:
@ -37,10 +41,14 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
submodules: true submodules: true
- uses: pnpm/action-setup@v2
with:
version: 7
run_install: false
- uses: actions/setup-node@v3.6.0 - uses: actions/setup-node@v3.6.0
with: with:
node-version: 18.x node-version: 18.x
cache: 'yarn' cache: 'pnpm'
- run: corepack enable - run: corepack enable
- run: yarn install --immutable - run: pnpm i --frozen-lockfile
- run: yarn workspace ${{ matrix.workspace }} run lint - run: pnpm --filter ${{ matrix.workspace }} run lint

View file

@ -23,7 +23,6 @@ jobs:
env: env:
POSTGRES_DB: test-misskey POSTGRES_DB: test-misskey
POSTGRES_HOST_AUTH_METHOD: trust POSTGRES_HOST_AUTH_METHOD: trust
YARN_CHECKSUM_BEHAVIOR: update
redis: redis:
image: redis:6 image: redis:6
ports: ports:
@ -33,21 +32,26 @@ jobs:
- uses: actions/checkout@v3.3.0 - uses: actions/checkout@v3.3.0
with: with:
submodules: true submodules: true
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 7
run_install: false
- name: Use Node.js ${{ matrix.node-version }} - name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3.6.0 uses: actions/setup-node@v3.6.0
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
cache: 'yarn' cache: 'pnpm'
- run: corepack enable - run: corepack enable
- run: yarn install --immutable - run: pnpm i --frozen-lockfile
- name: Check yarn.lock - name: Check pnpm-lock.yaml
run: git diff --exit-code yarn.lock run: git diff --exit-code pnpm-lock.yaml
- name: Copy Configure - name: Copy Configure
run: cp .github/misskey/test.yml .config run: cp .github/misskey/test.yml .config
- name: Build - name: Build
run: yarn build run: pnpm build
- name: Test - name: Test
run: yarn jest-and-coverage run: pnpm jest-and-coverage
- name: Upload Coverage - name: Upload Coverage
uses: codecov/codecov-action@v3 uses: codecov/codecov-action@v3
with: with:
@ -86,19 +90,22 @@ jobs:
# if: ${{ matrix.browser == 'firefox' }} # if: ${{ matrix.browser == 'firefox' }}
#- uses: browser-actions/setup-firefox@latest #- uses: browser-actions/setup-firefox@latest
# if: ${{ matrix.browser == 'firefox' }} # if: ${{ matrix.browser == 'firefox' }}
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 7
run_install: false
- name: Use Node.js ${{ matrix.node-version }} - name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3.6.0 uses: actions/setup-node@v3.6.0
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
cache: 'yarn' cache: 'pnpm'
- run: corepack enable - run: corepack enable
- run: yarn install --immutable - run: pnpm i --frozen-lockfile
env:
YARN_CHECKSUM_BEHAVIOR: update
- name: Copy Configure - name: Copy Configure
run: cp .github/misskey/test.yml .config run: cp .github/misskey/test.yml .config
- name: Build - name: Build
run: yarn build run: pnpm build
# https://github.com/cypress-io/cypress/issues/4351#issuecomment-559489091 # https://github.com/cypress-io/cypress/issues/4351#issuecomment-559489091
- name: ALSA Env - name: ALSA Env
run: echo -e 'pcm.!default {\n type hw\n card 0\n}\n\nctl.!default {\n type hw\n card 0\n}' > ~/.asoundrc run: echo -e 'pcm.!default {\n type hw\n card 0\n}\n\nctl.!default {\n type hw\n card 0\n}' > ~/.asoundrc
@ -106,7 +113,7 @@ jobs:
uses: cypress-io/github-action@v4 uses: cypress-io/github-action@v4
with: with:
install: false install: false
start: yarn start:test start: pnpm start:test
wait-on: 'http://localhost:61812' wait-on: 'http://localhost:61812'
headless: false headless: false
browser: ${{ matrix.browser }} browser: ${{ matrix.browser }}

5
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,5 @@
{
"search.exclude": {
"**/node_modules": true
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1 +0,0 @@
network-timeout 600000

View file

@ -1,42 +0,0 @@
httpTimeout: 600000
nmHoistingLimits: none
nodeLinker: pnpm
packageExtensions:
"@bull-board/api@*":
peerDependencies:
"@bull-board/ui": "*"
"@tensorflow/tfjs@*":
dependencies:
long: "*"
chartjs-adapter-date-fns@*:
peerDependencies:
date-fns: "*"
consolidate@*:
dependencies:
ejs: "*"
# these are needed to extend fastify types
"@fastify/accepts@*":
peerDependencies:
fastify: "*"
"@fastify/cookie@*":
peerDependencies:
fastify: "*"
"@fastify/static@*":
peerDependencies:
fastify: "*"
"@fastify/view@*":
peerDependencies:
fastify: "*"
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
progressBarStyle: patrick
yarnPath: .yarn/releases/yarn-3.3.0.cjs

View file

@ -2,27 +2,27 @@ ARG NODE_VERSION=18.13.0-bullseye
FROM node:${NODE_VERSION} AS builder FROM node:${NODE_VERSION} AS builder
ARG NODE_ENV=production
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
build-essential build-essential
WORKDIR /misskey WORKDIR /misskey
COPY [".yarnrc.yml", "package.json", "yarn.lock", "./"] COPY ["pnpm-lock.yaml", "pnpm-workspace.yaml", "package.json", "./"]
COPY [".yarn", "./.yarn"]
COPY ["scripts", "./scripts"] COPY ["scripts", "./scripts"]
COPY ["packages/backend/package.json", "./packages/backend/"] COPY ["packages/backend/package.json", "./packages/backend/"]
COPY ["packages/frontend/package.json", "./packages/frontend/"] COPY ["packages/frontend/package.json", "./packages/frontend/"]
COPY ["packages/sw/package.json", "./packages/sw/"] COPY ["packages/sw/package.json", "./packages/sw/"]
RUN yarn install --immutable RUN npm i -g pnpm
RUN pnpm i --frozen-lockfile
COPY . ./ COPY . ./
ARG NODE_ENV=production
RUN git submodule update --init RUN git submodule update --init
RUN yarn build RUN pnpm build
FROM node:${NODE_VERSION}-slim AS runner FROM node:${NODE_VERSION}-slim AS runner
@ -37,10 +37,10 @@ RUN apt-get update \
&& groupadd -g "${GID}" misskey \ && groupadd -g "${GID}" misskey \
&& useradd -l -u "${UID}" -g "${GID}" -m -d /misskey misskey && useradd -l -u "${UID}" -g "${GID}" -m -d /misskey misskey
RUN npm i -g pnpm
USER misskey USER misskey
WORKDIR /misskey WORKDIR /misskey
COPY --chown=misskey:misskey --from=builder /misskey/.yarn/install-state.gz ./.yarn/install-state.gz
COPY --chown=misskey:misskey --from=builder /misskey/node_modules ./node_modules COPY --chown=misskey:misskey --from=builder /misskey/node_modules ./node_modules
COPY --chown=misskey:misskey --from=builder /misskey/built ./built COPY --chown=misskey:misskey --from=builder /misskey/built ./built
COPY --chown=misskey:misskey --from=builder /misskey/packages/backend/node_modules ./packages/backend/node_modules COPY --chown=misskey:misskey --from=builder /misskey/packages/backend/node_modules ./packages/backend/node_modules
@ -51,4 +51,4 @@ COPY --chown=misskey:misskey . ./
ENV NODE_ENV=production ENV NODE_ENV=production
ENTRYPOINT ["/usr/bin/tini", "--"] ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["yarn", "run", "migrateandstart"] CMD ["pnpm", "run", "migrateandstart"]

View file

@ -6,7 +6,7 @@
"type": "git", "type": "git",
"url": "https://github.com/misskey-dev/misskey.git" "url": "https://github.com/misskey-dev/misskey.git"
}, },
"packageManager": "yarn@3.3.0", "packageManager": "pnpm@7.24.3",
"workspaces": [ "workspaces": [
"packages/frontend", "packages/frontend",
"packages/backend", "packages/backend",
@ -15,27 +15,27 @@
"private": true, "private": true,
"scripts": { "scripts": {
"build-pre": "node ./scripts/build-pre.js", "build-pre": "node ./scripts/build-pre.js",
"build": "yarn build-pre && yarn workspaces foreach run build && yarn run gulp", "build": "pnpm build-pre && pnpm -r build && pnpm gulp",
"start": "cd packages/backend && node ./built/boot/index.js", "start": "cd packages/backend && node ./built/boot/index.js",
"start:test": "cd packages/backend && cross-env NODE_ENV=test node ./built/boot/index.js", "start:test": "cd packages/backend && cross-env NODE_ENV=test node ./built/boot/index.js",
"init": "yarn migrate", "init": "pnpm migrate",
"migrate": "cd packages/backend && yarn run typeorm migration:run -d ormconfig.js", "migrate": "cd packages/backend && pnpm typeorm migration:run -d ormconfig.js",
"migrateandstart": "yarn migrate && yarn start", "migrateandstart": "pnpm migrate && pnpm start",
"gulp": "gulp build", "gulp": "pnpm exec gulp build",
"watch": "yarn dev", "watch": "pnpm dev",
"dev": "node ./scripts/dev.js", "dev": "node ./scripts/dev.js",
"lint": "yarn workspaces foreach run lint", "lint": "pnpm -r lint",
"cy:open": "cypress open --browser --e2e --config-file=cypress.config.ts", "cy:open": "pnpm cypress open --browser --e2e --config-file=cypress.config.ts",
"cy:run": "cypress run", "cy:run": "pnpm cypress run",
"e2e": "start-server-and-test start:test http://localhost:61812 cy:run", "e2e": "pnpm start-server-and-test start:test http://localhost:61812 cy:run",
"jest": "cd packages/backend && cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve node_modules/jest/bin/jest.js --forceExit --runInBand", "jest": "cd packages/backend && pnpm cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve node_modules/jest/bin/jest.js --forceExit --runInBand",
"jest-and-coverage": "cd packages/backend && cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve node_modules/jest/bin/jest.js --coverage --forceExit --runInBand", "jest-and-coverage": "cd packages/backend && pnpm cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve node_modules/jest/bin/jest.js --coverage --forceExit --runInBand",
"test": "yarn jest", "test": "pnpm jest",
"test-and-coverage": "yarn jest-and-coverage", "test-and-coverage": "pnpm jest-and-coverage",
"format": "gulp format", "format": "pnpm exec gulp format",
"clean": "node ./scripts/clean.js", "clean": "node ./scripts/clean.js",
"clean-all": "node ./scripts/clean-all.js", "clean-all": "node ./scripts/clean-all.js",
"cleanall": "yarn clean-all" "cleanall": "pnpm clean-all"
}, },
"resolutions": { "resolutions": {
"chokidar": "^3.3.1", "chokidar": "^3.3.1",
@ -48,7 +48,8 @@
"gulp-rename": "2.0.0", "gulp-rename": "2.0.0",
"gulp-replace": "1.1.4", "gulp-replace": "1.1.4",
"gulp-terser": "2.1.0", "gulp-terser": "2.1.0",
"js-yaml": "4.1.0" "js-yaml": "4.1.0",
"typescript": "4.9.4"
}, },
"devDependencies": { "devDependencies": {
"@types/gulp": "4.0.10", "@types/gulp": "4.0.10",
@ -58,8 +59,7 @@
"cross-env": "7.0.3", "cross-env": "7.0.3",
"cypress": "12.3.0", "cypress": "12.3.0",
"eslint": "^8.31.0", "eslint": "^8.31.0",
"start-server-and-test": "1.15.2", "start-server-and-test": "1.15.2"
"typescript": "4.9.4"
}, },
"optionalDependencies": { "optionalDependencies": {
"@tensorflow/tfjs-core": "^4.2.0" "@tensorflow/tfjs-core": "^4.2.0"

View file

@ -6,15 +6,15 @@
"scripts": { "scripts": {
"start": "node ./built/index.js", "start": "node ./built/index.js",
"start:test": "NODE_ENV=test node ./built/index.js", "start:test": "NODE_ENV=test node ./built/index.js",
"migrate": "typeorm migration:run -d ormconfig.js", "migrate": "pnpm typeorm migration:run -d ormconfig.js",
"build": "tsc -p tsconfig.json || echo done. && tsc-alias -p tsconfig.json", "build": "tsc -p tsconfig.json || echo done. && tsc-alias -p tsconfig.json",
"watch": "node watch.mjs", "watch": "node watch.mjs",
"lint": "tsc --noEmit && eslint --quiet \"src/**/*.ts\"", "lint": "tsc --noEmit && eslint --quiet \"src/**/*.ts\"",
"jest": "cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve node_modules/jest/bin/jest.js --forceExit --runInBand", "jest": "cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve node_modules/jest/bin/jest.js --forceExit --runInBand",
"jest-and-coverage": "cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve node_modules/jest/bin/jest.js --coverage --forceExit --runInBand", "jest-and-coverage": "cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve node_modules/jest/bin/jest.js --coverage --forceExit --runInBand",
"jest-clear": "cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve node_modules/jest/bin/jest.js --clearCache", "jest-clear": "cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve node_modules/jest/bin/jest.js --clearCache",
"test": "yarn jest", "test": "pnpm jest",
"test-and-coverage": "yarn jest-and-coverage" "test-and-coverage": "pnpm jest-and-coverage"
}, },
"optionalDependencies": { "optionalDependencies": {
"@tensorflow/tfjs": "^4.1.0", "@tensorflow/tfjs": "^4.1.0",
@ -116,6 +116,7 @@
"tsconfig-paths": "4.1.2", "tsconfig-paths": "4.1.2",
"twemoji-parser": "14.0.0", "twemoji-parser": "14.0.0",
"typeorm": "0.3.11", "typeorm": "0.3.11",
"typescript": "4.9.4",
"ulid": "2.3.0", "ulid": "2.3.0",
"undici": "^5.15.0", "undici": "^5.15.0",
"unzipper": "0.10.11", "unzipper": "0.10.11",
@ -180,7 +181,6 @@
"execa": "6.1.0", "execa": "6.1.0",
"jest": "29.3.1", "jest": "29.3.1",
"jest-mock": "^29.3.1", "jest-mock": "^29.3.1",
"node-fetch": "3.3.0", "node-fetch": "3.3.0"
"typescript": "4.9.4"
} }
} }

13495
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load diff

4
pnpm-workspace.yaml Normal file
View file

@ -0,0 +1,4 @@
packages:
- 'packages/backend'
- 'packages/frontend'
- 'packages/sw'

View file

@ -14,7 +14,7 @@ const fs = require('fs');
fs.rmSync(__dirname + '/../built', { recursive: true, force: true }); fs.rmSync(__dirname + '/../built', { recursive: true, force: true });
fs.rmSync(__dirname + '/../node_modules', { recursive: true, force: true }); fs.rmSync(__dirname + '/../node_modules', { recursive: true, force: true });
execSync('yarn cache clean --all', { execSync('pnpm store prune', {
cwd: __dirname + '/../', cwd: __dirname + '/../',
stdio: 'inherit', stdio: 'inherit',
}); });

View file

@ -2,37 +2,37 @@ const execa = require('execa');
const fs = require('fs'); const fs = require('fs');
(async () => { (async () => {
await execa('yarn', ['clean'], { await execa('pnpm', ['clean'], {
cwd: __dirname + '/../', cwd: __dirname + '/../',
stdout: process.stdout, stdout: process.stdout,
stderr: process.stderr, stderr: process.stderr,
}); });
await execa('yarn', ['build-pre'], { await execa('pnpm', ['build-pre'], {
cwd: __dirname + '/../', cwd: __dirname + '/../',
stdout: process.stdout, stdout: process.stdout,
stderr: process.stderr, stderr: process.stderr,
}); });
execa('yarn', ['dlx', 'gulp', 'watch'], { execa('pnpm', ['dlx', 'gulp', 'watch'], {
cwd: __dirname + '/../', cwd: __dirname + '/../',
stdout: process.stdout, stdout: process.stdout,
stderr: process.stderr, stderr: process.stderr,
}); });
execa('yarn', ['workspace', 'backend', 'watch'], { execa('pnpm', ['--filter', 'backend', 'watch'], {
cwd: __dirname + '/../', cwd: __dirname + '/../',
stdout: process.stdout, stdout: process.stdout,
stderr: process.stderr, stderr: process.stderr,
}); });
execa('yarn', ['workspace', 'frontend', 'watch'], { execa('pnpm', ['--filter', 'frontend', 'watch'], {
cwd: __dirname + '/../', cwd: __dirname + '/../',
stdout: process.stdout, stdout: process.stdout,
stderr: process.stderr, stderr: process.stderr,
}); });
execa('yarn', ['workspace', 'sw', 'watch'], { execa('pnpm', ['--filter', 'sw', 'watch'], {
cwd: __dirname + '/../', cwd: __dirname + '/../',
stdout: process.stdout, stdout: process.stdout,
stderr: process.stderr, stderr: process.stderr,
@ -43,7 +43,7 @@ const fs = require('fs');
const exist = fs.existsSync(__dirname + '/../packages/backend/built/boot/index.js') const exist = fs.existsSync(__dirname + '/../packages/backend/built/boot/index.js')
if (!exist) throw new Error('not exist yet'); if (!exist) throw new Error('not exist yet');
await execa('yarn', ['start'], { await execa('pnpm', ['start'], {
cwd: __dirname + '/../', cwd: __dirname + '/../',
stdout: process.stdout, stdout: process.stdout,
stderr: process.stderr, stderr: process.stderr,

17857
yarn.lock

File diff suppressed because it is too large Load diff