0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00

feat: migrate yarn 1 to yarn 2 (#1962)

This commit is contained in:
Juan Picado 2020-10-11 10:06:21 -07:00 committed by GitHub
parent f7aad33925
commit 1ece11cfc0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 202 additions and 52 deletions

View file

@ -1,7 +0,0 @@
{
"presets": [["@verdaccio"]],
"plugins": [
"@babel/plugin-proposal-optional-chaining",
"@babel/plugin-proposal-nullish-coalescing-operator"
]
}

View file

@ -62,7 +62,7 @@ jobs:
key: *yarn_cache_key key: *yarn_cache_key
- run: - run:
name: Install dependencies name: Install dependencies
command: yarn install --no-progress --pure-lockfile command: yarn install --immutable
- run: - run:
name: Prepare CI name: Prepare CI
command: yarn run pre:ci command: yarn run pre:ci

View file

@ -8,14 +8,16 @@
.* .*
# you can add exceptions like in .gitignore to maintain a whitelist: # you can add exceptions like in .gitignore to maintain a whitelist:
# e.g. # e.g.
!.babelrc !babel.config.js
!.eslintrc !.eslintrc
!.prettierrc !.prettierrc
!.eslintignore !.eslintignore
!.stylelintrc !.stylelintrc
!.flowconfig
!.jest.config.js !.jest.config.js
!.jestEnvironment.js !.jestEnvironment.js
!.yarnrc.yml
!.yarn/releases/yarn-berry.cjs
!.yarn/plugins/*
# do not copy over node_modules we will run `npm install` anyway # do not copy over node_modules we will run `npm install` anyway
node_modules node_modules

View file

@ -9,7 +9,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
node_version: [8, 10, 12, 13, 14] node_version: [10, 12, 13, 14]
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -20,7 +20,7 @@ jobs:
with: with:
node_version: ${{ matrix.node_version }} node_version: ${{ matrix.node_version }}
- name: Install - name: Install
run: yarn install --pure-lockfile run: yarn install --immutable
- name: Build - name: Build
run: yarn code:build run: yarn code:build
- name: Lint - name: Lint

View file

@ -55,7 +55,7 @@ jobs:
- name: 'install latest npm' - name: 'install latest npm'
run: npm i -g npm run: npm i -g npm
- name: Install Dependencies - name: Install Dependencies
run: yarn install --pure-lockfile run: yarn install
- name: 'Run verdaccio in the background' - name: 'Run verdaccio in the background'
run: | run: |
nohup node ./scripts/run-verdaccio.js --config ./scripts/e2e-config.yaml & nohup node ./scripts/run-verdaccio.js --config ./scripts/e2e-config.yaml &
@ -92,7 +92,7 @@ jobs:
- name: 'install latest npm' - name: 'install latest npm'
run: npm i -g npm@next-7 run: npm i -g npm@next-7
- name: Install Dependencies - name: Install Dependencies
run: yarn install --pure-lockfile run: yarn install
- name: 'Run verdaccio in the background' - name: 'Run verdaccio in the background'
run: | run: |
nohup node ./scripts/run-verdaccio.js --config ./scripts/e2e-config.yaml & nohup node ./scripts/run-verdaccio.js --config ./scripts/e2e-config.yaml &

View file

@ -21,7 +21,7 @@ jobs:
- name: 'install latest npm' - name: 'install latest npm'
run: npm i -g npm run: npm i -g npm
- name: Install Dependencies - name: Install Dependencies
run: yarn install --pure-lockfile run: yarn install
- name: 'Run verdaccio in the background' - name: 'Run verdaccio in the background'
run: | run: |
nohup node ./scripts/run-verdaccio.js --config ./scripts/e2e-config.yaml & nohup node ./scripts/run-verdaccio.js --config ./scripts/e2e-config.yaml &

View file

@ -19,7 +19,7 @@ jobs:
with: with:
node-version: 10.x node-version: 10.x
- name: Install Dependencies - name: Install Dependencies
run: yarn install --pure-lockfile run: yarn install
- name: 'Run verdaccio in the background' - name: 'Run verdaccio in the background'
run: | run: |
nohup node ./scripts/run-verdaccio.js --config ./scripts/e2e-config.yaml & nohup node ./scripts/run-verdaccio.js --config ./scripts/e2e-config.yaml &
@ -50,7 +50,7 @@ jobs:
with: with:
node-version: 10.x node-version: 10.x
- name: Install Dependencies - name: Install Dependencies
run: yarn install --pure-lockfile run: yarn install
- name: 'Run verdaccio in the background' - name: 'Run verdaccio in the background'
run: | run: |
nohup node ./scripts/run-verdaccio.js --config ./scripts/e2e-config.yaml & nohup node ./scripts/run-verdaccio.js --config ./scripts/e2e-config.yaml &
@ -86,7 +86,7 @@ jobs:
- name: 'install latest npm' - name: 'install latest npm'
run: npm i -g npm run: npm i -g npm
- name: Install Dependencies - name: Install Dependencies
run: yarn install --pure-lockfile run: yarn install
- name: 'Run verdaccio in the background' - name: 'Run verdaccio in the background'
run: | run: |
nohup node ./scripts/run-verdaccio.js --config ./scripts/e2e-config.yaml & nohup node ./scripts/run-verdaccio.js --config ./scripts/e2e-config.yaml &
@ -119,7 +119,7 @@ jobs:
- name: 'install latest npm' - name: 'install latest npm'
run: npm i -g npm@next-7 run: npm i -g npm@next-7
- name: Install Dependencies - name: Install Dependencies
run: yarn install --pure-lockfile run: yarn install
- name: 'Run verdaccio in the background' - name: 'Run verdaccio in the background'
run: | run: |
nohup node ./scripts/run-verdaccio.js --config ./scripts/e2e-config.yaml & nohup node ./scripts/run-verdaccio.js --config ./scripts/e2e-config.yaml &
@ -153,7 +153,7 @@ jobs:
- name: 'install latest pnpm' - name: 'install latest pnpm'
run: npm i -g pnpm run: npm i -g pnpm
- name: Install Dependencies - name: Install Dependencies
run: yarn install --pure-lockfile run: yarn install
- name: 'Run verdaccio in the background' - name: 'Run verdaccio in the background'
run: | run: |
nohup node ./scripts/run-verdaccio.js & nohup node ./scripts/run-verdaccio.js &

View file

@ -16,7 +16,7 @@ jobs:
with: with:
node_version: 12 node_version: 12
- name: Install - name: Install
run: yarn install --frozen-lockfile run: yarn install
- name: Build - name: Build
run: yarn code:build run: yarn code:build
- name: Lint - name: Lint

7
.gitignore vendored
View file

@ -37,3 +37,10 @@ __tests__
# Compiled script # Compiled script
static/* static/*
# This is the Yarn build state; it's local to each clone
/.yarn/build-state.yml
# This is the Yarn install state cache, it can be rebuilt anytime
/.yarn/install-state.gz
.history

File diff suppressed because one or more lines are too long

55
.yarn/releases/yarn-berry.cjs vendored Executable file

File diff suppressed because one or more lines are too long

View file

@ -1,2 +0,0 @@
save-prefix ""
registry "http://registry.npmjs.org/"

19
.yarnrc.yml Normal file
View file

@ -0,0 +1,19 @@
defaultSemverRangePrefix: ""
enableGlobalCache: true
enableTelemetry: false
httpRetry: 10
httpTimeout: 100000
nodeLinker: node-modules
npmRegistryServer: "https://registry.verdaccio.org"
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
yarnPath: .yarn/releases/yarn-berry.cjs

View file

@ -12,12 +12,14 @@ RUN apk --no-cache add openssl ca-certificates wget && \
WORKDIR /opt/verdaccio-build WORKDIR /opt/verdaccio-build
COPY . . COPY . .
RUN yarn config set registry $VERDACCIO_BUILD_REGISTRY && \ RUN yarn config set npmRegistryServer $VERDACCIO_BUILD_REGISTRY && \
yarn install --production=false && \ yarn config set enableProgressBars false && \
yarn config set enableTelemetry false && \
yarn install && \
yarn lint && \ yarn lint && \
yarn code:docker-build && \ yarn code:docker-build && \
yarn cache clean && \ yarn cache clean && \
yarn install --production=true yarn workspaces focus --production

22
babel.config.js Normal file
View file

@ -0,0 +1,22 @@
module.exports = {
presets: [
[
'@babel/env',
{
targets: {
node: '8'
},
},
],
'@babel/typescript',
],
plugins: [
'babel-plugin-dynamic-import-node',
'@babel/proposal-class-properties',
'@babel/proposal-object-rest-spread',
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-nullish-coalescing-operator',
'@babel/syntax-dynamic-import',
],
ignore: ['**/*.d.ts'],
};

View file

@ -12,9 +12,7 @@
}, },
"homepage": "https://verdaccio.org", "homepage": "https://verdaccio.org",
"main": "build/index.js", "main": "build/index.js",
"bin": { "bin": "./bin/verdaccio",
"verdaccio": "./bin/verdaccio"
},
"funding": { "funding": {
"type": "opencollective", "type": "opencollective",
"url": "https://opencollective.com/verdaccio" "url": "https://opencollective.com/verdaccio"
@ -55,6 +53,27 @@
"verdaccio-htpasswd": "9.7.2" "verdaccio-htpasswd": "9.7.2"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "7.11.6",
"@babel/core": "7.11.6",
"@babel/node": "7.10.5",
"@babel/plugin-proposal-class-properties": "7.10.4",
"@babel/plugin-proposal-decorators": "7.10.5",
"@babel/plugin-proposal-export-namespace-from": "7.10.4",
"@babel/plugin-proposal-function-sent": "7.10.4",
"@babel/plugin-proposal-json-strings": "7.10.4",
"@babel/plugin-proposal-numeric-separator": "7.10.4",
"@babel/plugin-proposal-object-rest-spread": "7.11.0",
"@babel/plugin-proposal-throw-expressions": "7.10.4",
"@babel/plugin-syntax-dynamic-import": "7.8.3",
"@babel/plugin-syntax-import-meta": "7.10.4",
"@babel/plugin-transform-async-to-generator": "7.10.4",
"@babel/plugin-transform-classes": "7.10.4",
"@babel/plugin-transform-runtime": "7.11.5",
"@babel/polyfill": "^7.11.5",
"@babel/preset-env": "7.11.5",
"@babel/preset-typescript": "7.10.4",
"@babel/register": "7.11.5",
"@babel/runtime": "7.11.2",
"@commitlint/cli": "8.3.5", "@commitlint/cli": "8.3.5",
"@commitlint/config-conventional": "8.3.4", "@commitlint/config-conventional": "8.3.4",
"@octokit/rest": "16.36.0", "@octokit/rest": "16.36.0",
@ -62,7 +81,7 @@
"@types/bunyan": "1.8.6", "@types/bunyan": "1.8.6",
"@types/express": "4.17.1", "@types/express": "4.17.1",
"@types/http-errors": "1.6.3", "@types/http-errors": "1.6.3",
"@types/jest": "25.2.1", "@types/jest": "26.0.14",
"@types/lodash": "4.14.157", "@types/lodash": "4.14.157",
"@types/mime": "2.0.1", "@types/mime": "2.0.1",
"@types/minimatch": "3.0.3", "@types/minimatch": "3.0.3",
@ -70,10 +89,14 @@
"@types/request": "2.48.3", "@types/request": "2.48.3",
"@types/semver": "6.2.0", "@types/semver": "6.2.0",
"@typescript-eslint/eslint-plugin": "2.12.0", "@typescript-eslint/eslint-plugin": "2.12.0",
"@verdaccio/babel-preset": "^9.6.1",
"@verdaccio/eslint-config": "^8.5.0", "@verdaccio/eslint-config": "^8.5.0",
"@verdaccio/types": "^9.7.0", "@verdaccio/types": "^9.7.0",
"all-contributors-cli": "6.16.0", "all-contributors-cli": "6.16.0",
"babel-eslint": "10.1.0",
"babel-jest": "26.5.2",
"babel-loader": "^8.1.0",
"babel-plugin-dynamic-import-node": "2.3.3",
"babel-plugin-emotion": "10.0.33",
"codecov": "3.7.1", "codecov": "3.7.1",
"cross-env": "7.0.2", "cross-env": "7.0.2",
"detect-secrets": "1.0.6", "detect-secrets": "1.0.6",
@ -112,27 +135,28 @@
], ],
"scripts": { "scripts": {
"release": "standard-version -a -s", "release": "standard-version -a -s",
"prepublish": "in-publish && npm run code:build || not-in-publish", "prepublish": "in-publish && yarn run code:build || not-in-publish",
"type-check": "tsc --noEmit", "type-check": "tsc --noEmit",
"type-check:watch": "npm run type-check -- --watch", "type-check:watch": "yarn run type-check -- --watch",
"pretest": "npm run code:build", "pretest": "yarn run code:build",
"test": "npm run test:unit", "test": "yarn run test:unit",
"test:clean": "npx jest --clearCache", "test:clean": "npx jest --clearCache",
"test:unit": "cross-env NODE_ENV=test BABEL_ENV=test TZ=UTC FORCE_COLOR=1 jest --config ./jest.config.js --maxWorkers 2 --passWithNoTests", "test:unit": "cross-env NODE_ENV=test TZ=UTC FORCE_COLOR=1 jest --config ./jest.config.js --maxWorkers 2 --passWithNoTests",
"test:functional": "cross-env NODE_ENV=test jest --config ./test/jest.config.functional.js --testPathPattern ./test/functional/index* --passWithNoTests", "test:functional": "cross-env NODE_ENV=test jest --config ./test/jest.config.functional.js --testPathPattern ./test/functional/index* --passWithNoTests",
"test:e2e:cli": "cross-env NODE_ENV=test jest --config ./test/e2e-cli/jest.config.e2e.cli.js --passWithNoTests", "test:e2e:cli": "cross-env NODE_ENV=test jest --config ./test/e2e-cli/jest.config.e2e.cli.js --passWithNoTests",
"test:e2e": "cross-env BABEL_ENV=test jest --config ./test/jest.config.e2e.js", "test:e2e": "yarn jest --config ./test/jest.config.e2e.js",
"test:all": "npm run test && npm run test:functional && npm run test:e2e & npm run test:e2e:pkg", "test:all": "yarn run test && yarn run test:functional && yarn run test:e2e & yarn run test:e2e:pkg",
"pre:ci": "npm run lint", "pre:ci": "yarn run lint",
"coverage:publish": "codecov", "coverage:publish": "codecov",
"lint": "npm run type-check && npm run lint:ts && npm run lint:lockfile", "lint": "yarn run type-check && yarn run lint:ts",
"lint:ts": "eslint . --ext .js,.ts", "lint:ts": "eslint . --ext .js,.ts",
"lint:lockfile": "lockfile-lint --path yarn.lock --type yarn --validate-https --allowed-hosts verdaccio npm yarn", "lint:lockfile": "lockfile-lint --path yarn.lock --type yarn --validate-https --allowed-hosts verdaccio npm yarn",
"format": "prettier --single-quote --trailing-comma none --write \"{src,test}/**/*.ts\"", "format": "prettier --single-quote --trailing-comma none --write \"{src,test}/**/*.ts\"",
"dev:start": "cross-env BABEL_ENV=registry babel-node --extensions \".ts,.tsx\" src/lib/cli", "dev:start": "yarn babel-node --extensions \".ts,.tsx\" src/lib/cli",
"code:build": "cross-env BABEL_ENV=registry babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps inline", "code:build": "yarn babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps inline",
"code:docker-build": "cross-env BABEL_ENV=registry-docker babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\"", "code:docker-build": "yarn babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\"",
"build:docker": "docker build -t verdaccio/verdaccio:local . --no-cache" "docker:build": "docker build -t verdaccio/verdaccio:local . --no-cache",
"docker:run": "docker run -it --rm -p 4873:4873 verdaccio/verdaccio:local"
}, },
"engines": { "engines": {
"node": ">=8", "node": ">=8",

View file

@ -120,6 +120,7 @@ function addPackageWebApi(route: Router, storage: IStorageHandler, auth: IAuth,
let sideBarInfo: any = _.clone(info); let sideBarInfo: any = _.clone(info);
sideBarInfo.versions = convertDistRemoteToLocalTarballUrls(info, req, config.url_prefix).versions; sideBarInfo.versions = convertDistRemoteToLocalTarballUrls(info, req, config.url_prefix).versions;
if (isVersionValid(info, v)) { if (isVersionValid(info, v)) {
// @ts-ignore
sideBarInfo.latest = sideBarInfo.versions[v]; sideBarInfo.latest = sideBarInfo.versions[v];
sideBarInfo.latest.author = formatAuthor(sideBarInfo.latest.author); sideBarInfo.latest.author = formatAuthor(sideBarInfo.latest.author);
} else { } else {

View file

@ -20,9 +20,9 @@ module.exports = async () => {
// @ts-ignore // @ts-ignore
global.registryProcess = spawn( global.registryProcess = spawn(
'node', 'node',
[require.resolve('verdaccio/bin/verdaccio'), '-c', './verdaccio.yaml'], [path.resolve('./bin/verdaccio'), '-c', './verdaccio.yaml'],
// @ts-ignore // @ts-ignore
{ cwd: tempRoot, silence: true }, { cwd: tempRoot, silence: false },
); );
// publish current build version on local registry // publish current build version on local registry

View file

@ -3,7 +3,6 @@ import {runVerdaccio} from '../../utils/process';
import {installVerdaccio} from "../__partials/npm_commands"; import {installVerdaccio} from "../__partials/npm_commands";
describe('verdaccio info', ()=> { describe('verdaccio info', ()=> {
jest.setTimeout(90000);
// @ts-ignore // @ts-ignore
const tempRootFolder = global.__namespace.getItem('dir-root'); const tempRootFolder = global.__namespace.getItem('dir-root');
const verdaccioInstall = path.join(tempRootFolder, 'verdaccio-root-info'); const verdaccioInstall = path.join(tempRootFolder, 'verdaccio-root-info');
@ -11,8 +10,7 @@ describe('verdaccio info', ()=> {
beforeAll(async () => { beforeAll(async () => {
await installVerdaccio(verdaccioInstall); await installVerdaccio(verdaccioInstall);
}); }, 30000);
test('should run verdaccio info command', async () => { test('should run verdaccio info command', async () => {
const pathVerdaccioModule = require.resolve('verdaccio/bin/verdaccio', { const pathVerdaccioModule = require.resolve('verdaccio/bin/verdaccio', {
@ -21,7 +19,7 @@ describe('verdaccio info', ()=> {
const hasMatch = await runVerdaccio(pathVerdaccioModule, verdaccioInstall, ['--info'], /Environment/); const hasMatch = await runVerdaccio(pathVerdaccioModule, verdaccioInstall, ['--info'], /Environment/);
expect(hasMatch.ok).toBeTruthy(); expect(hasMatch.ok).toBeTruthy();
}); }, 20000);
afterAll(() => { afterAll(() => {
registryProcess.kill(); registryProcess.kill();

BIN
yarn.lock

Binary file not shown.