1
0
mirror of https://github.com/MisskeyIO/misskey synced 2024-11-27 06:18:40 +09:00

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

View File

@ -23,7 +23,6 @@ jobs:
env:
POSTGRES_DB: test-misskey
POSTGRES_HOST_AUTH_METHOD: trust
YARN_CHECKSUM_BEHAVIOR: update
redis:
image: redis:6
ports:
@ -33,21 +32,26 @@ jobs:
- uses: actions/checkout@v3.3.0
with:
submodules: true
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 7
run_install: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3.6.0
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
cache: 'pnpm'
- run: corepack enable
- run: yarn install --immutable
- name: Check yarn.lock
run: git diff --exit-code yarn.lock
- run: pnpm i --frozen-lockfile
- name: Check pnpm-lock.yaml
run: git diff --exit-code pnpm-lock.yaml
- name: Copy Configure
run: cp .github/misskey/test.yml .config
- name: Build
run: yarn build
run: pnpm build
- name: Test
run: yarn jest-and-coverage
run: pnpm jest-and-coverage
- name: Upload Coverage
uses: codecov/codecov-action@v3
with:
@ -86,19 +90,22 @@ jobs:
# if: ${{ matrix.browser == 'firefox' }}
#- uses: browser-actions/setup-firefox@latest
# 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 }}
uses: actions/setup-node@v3.6.0
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
cache: 'pnpm'
- run: corepack enable
- run: yarn install --immutable
env:
YARN_CHECKSUM_BEHAVIOR: update
- run: pnpm i --frozen-lockfile
- name: Copy Configure
run: cp .github/misskey/test.yml .config
- name: Build
run: yarn build
run: pnpm build
# https://github.com/cypress-io/cypress/issues/4351#issuecomment-559489091
- 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
@ -106,7 +113,7 @@ jobs:
uses: cypress-io/github-action@v4
with:
install: false
start: yarn start:test
start: pnpm start:test
wait-on: 'http://localhost:61812'
headless: false
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
ARG NODE_ENV=production
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential
WORKDIR /misskey
COPY [".yarnrc.yml", "package.json", "yarn.lock", "./"]
COPY [".yarn", "./.yarn"]
COPY ["pnpm-lock.yaml", "pnpm-workspace.yaml", "package.json", "./"]
COPY ["scripts", "./scripts"]
COPY ["packages/backend/package.json", "./packages/backend/"]
COPY ["packages/frontend/package.json", "./packages/frontend/"]
COPY ["packages/sw/package.json", "./packages/sw/"]
RUN yarn install --immutable
RUN npm i -g pnpm
RUN pnpm i --frozen-lockfile
COPY . ./
ARG NODE_ENV=production
RUN git submodule update --init
RUN yarn build
RUN pnpm build
FROM node:${NODE_VERSION}-slim AS runner
@ -37,10 +37,10 @@ RUN apt-get update \
&& groupadd -g "${GID}" misskey \
&& useradd -l -u "${UID}" -g "${GID}" -m -d /misskey misskey
RUN npm i -g pnpm
USER 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/built ./built
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
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["yarn", "run", "migrateandstart"]
CMD ["pnpm", "run", "migrateandstart"]

View File

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

View File

@ -6,15 +6,15 @@
"scripts": {
"start": "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",
"watch": "node watch.mjs",
"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-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",
"test": "yarn jest",
"test-and-coverage": "yarn jest-and-coverage"
"test": "pnpm jest",
"test-and-coverage": "pnpm jest-and-coverage"
},
"optionalDependencies": {
"@tensorflow/tfjs": "^4.1.0",
@ -116,6 +116,7 @@
"tsconfig-paths": "4.1.2",
"twemoji-parser": "14.0.0",
"typeorm": "0.3.11",
"typescript": "4.9.4",
"ulid": "2.3.0",
"undici": "^5.15.0",
"unzipper": "0.10.11",
@ -180,7 +181,6 @@
"execa": "6.1.0",
"jest": "29.3.1",
"jest-mock": "^29.3.1",
"node-fetch": "3.3.0",
"typescript": "4.9.4"
"node-fetch": "3.3.0"
}
}

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 + '/../node_modules', { recursive: true, force: true });
execSync('yarn cache clean --all', {
execSync('pnpm store prune', {
cwd: __dirname + '/../',
stdio: 'inherit',
});

View File

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

17857
yarn.lock

File diff suppressed because it is too large Load Diff