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
- run:
name: Install dependencies
command: yarn install --no-progress --pure-lockfile
command: yarn install --immutable
- run:
name: Prepare CI
command: yarn run pre:ci

View file

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

View file

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

View file

@ -55,7 +55,7 @@ jobs:
- name: 'install latest npm'
run: npm i -g npm
- name: Install Dependencies
run: yarn install --pure-lockfile
run: yarn install
- name: 'Run verdaccio in the background'
run: |
nohup node ./scripts/run-verdaccio.js --config ./scripts/e2e-config.yaml &
@ -92,7 +92,7 @@ jobs:
- name: 'install latest npm'
run: npm i -g npm@next-7
- name: Install Dependencies
run: yarn install --pure-lockfile
run: yarn install
- name: 'Run verdaccio in the background'
run: |
nohup node ./scripts/run-verdaccio.js --config ./scripts/e2e-config.yaml &
@ -114,7 +114,7 @@ jobs:
cd verdaccio-angular
npm install @angular-devkit/core@next @babel/preset-env @babel/core -D
npm run ng build --aot
npm run ng build --aot
# pnpm throws errors worth to check why
# pnpm:

View file

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

View file

@ -19,7 +19,7 @@ jobs:
with:
node-version: 10.x
- name: Install Dependencies
run: yarn install --pure-lockfile
run: yarn install
- name: 'Run verdaccio in the background'
run: |
nohup node ./scripts/run-verdaccio.js --config ./scripts/e2e-config.yaml &
@ -50,7 +50,7 @@ jobs:
with:
node-version: 10.x
- name: Install Dependencies
run: yarn install --pure-lockfile
run: yarn install
- name: 'Run verdaccio in the background'
run: |
nohup node ./scripts/run-verdaccio.js --config ./scripts/e2e-config.yaml &
@ -71,7 +71,7 @@ jobs:
yarn add left-pad
echo "const leftPad = require('left-pad'); it('should resolve a module', () => { expect(typeof leftPad).toBe('function');});" | tee module.test.js
yarn jest module.test.js
yarn jest module.test.js
npm:
name: 'npm:jest example'
runs-on: ubuntu-latest
@ -86,7 +86,7 @@ jobs:
- name: 'install latest npm'
run: npm i -g npm
- name: Install Dependencies
run: yarn install --pure-lockfile
run: yarn install
- name: 'Run verdaccio in the background'
run: |
nohup node ./scripts/run-verdaccio.js --config ./scripts/e2e-config.yaml &
@ -119,7 +119,7 @@ jobs:
- name: 'install latest npm'
run: npm i -g npm@next-7
- name: Install Dependencies
run: yarn install --pure-lockfile
run: yarn install
- name: 'Run verdaccio in the background'
run: |
nohup node ./scripts/run-verdaccio.js --config ./scripts/e2e-config.yaml &
@ -153,7 +153,7 @@ jobs:
- name: 'install latest pnpm'
run: npm i -g pnpm
- name: Install Dependencies
run: yarn install --pure-lockfile
run: yarn install
- name: 'Run verdaccio in the background'
run: |
nohup node ./scripts/run-verdaccio.js &

View file

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

7
.gitignore vendored
View file

@ -37,3 +37,10 @@ __tests__
# Compiled script
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
COPY . .
RUN yarn config set registry $VERDACCIO_BUILD_REGISTRY && \
yarn install --production=false && \
RUN yarn config set npmRegistryServer $VERDACCIO_BUILD_REGISTRY && \
yarn config set enableProgressBars false && \
yarn config set enableTelemetry false && \
yarn install && \
yarn lint && \
yarn code:docker-build && \
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",
"main": "build/index.js",
"bin": {
"verdaccio": "./bin/verdaccio"
},
"bin": "./bin/verdaccio",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/verdaccio"
@ -55,6 +53,27 @@
"verdaccio-htpasswd": "9.7.2"
},
"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/config-conventional": "8.3.4",
"@octokit/rest": "16.36.0",
@ -62,7 +81,7 @@
"@types/bunyan": "1.8.6",
"@types/express": "4.17.1",
"@types/http-errors": "1.6.3",
"@types/jest": "25.2.1",
"@types/jest": "26.0.14",
"@types/lodash": "4.14.157",
"@types/mime": "2.0.1",
"@types/minimatch": "3.0.3",
@ -70,10 +89,14 @@
"@types/request": "2.48.3",
"@types/semver": "6.2.0",
"@typescript-eslint/eslint-plugin": "2.12.0",
"@verdaccio/babel-preset": "^9.6.1",
"@verdaccio/eslint-config": "^8.5.0",
"@verdaccio/types": "^9.7.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",
"cross-env": "7.0.2",
"detect-secrets": "1.0.6",
@ -112,27 +135,28 @@
],
"scripts": {
"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:watch": "npm run type-check -- --watch",
"pretest": "npm run code:build",
"test": "npm run test:unit",
"type-check:watch": "yarn run type-check -- --watch",
"pretest": "yarn run code:build",
"test": "yarn run test:unit",
"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: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:all": "npm run test && npm run test:functional && npm run test:e2e & npm run test:e2e:pkg",
"pre:ci": "npm run lint",
"test:e2e": "yarn jest --config ./test/jest.config.e2e.js",
"test:all": "yarn run test && yarn run test:functional && yarn run test:e2e & yarn run test:e2e:pkg",
"pre:ci": "yarn run lint",
"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: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\"",
"dev:start": "cross-env BABEL_ENV=registry 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:docker-build": "cross-env BABEL_ENV=registry-docker babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\"",
"build:docker": "docker build -t verdaccio/verdaccio:local . --no-cache"
"dev:start": "yarn babel-node --extensions \".ts,.tsx\" src/lib/cli",
"code:build": "yarn babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps inline",
"code:docker-build": "yarn babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\"",
"docker:build": "docker build -t verdaccio/verdaccio:local . --no-cache",
"docker:run": "docker run -it --rm -p 4873:4873 verdaccio/verdaccio:local"
},
"engines": {
"node": ">=8",

View file

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

View file

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

View file

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

BIN
yarn.lock

Binary file not shown.