Compare commits
127 Commits
@verdaccio
...
@verdaccio
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64c8221d35 | ||
|
|
c908963132 | ||
|
|
46db10fc4f | ||
|
|
fadba40a9f | ||
|
|
02023afd74 | ||
|
|
f130817828 | ||
|
|
d2f9013ece | ||
|
|
b8554c8935 | ||
|
|
8ea24df16a | ||
|
|
67bbd93379 | ||
|
|
d09ea21bc9 | ||
|
|
0b72c32400 | ||
|
|
2d137274c4 | ||
|
|
cc30a85d3d | ||
|
|
85a01746a5 | ||
|
|
94f5e765a8 | ||
|
|
4cd71c6409 | ||
|
|
be71d77511 | ||
|
|
92a6f9a3fd | ||
|
|
b9a947aa2f | ||
|
|
110d90d888 | ||
|
|
6bed458925 | ||
|
|
73b3479a3a | ||
|
|
459af1cd39 | ||
|
|
e0d639a1a6 | ||
|
|
b78f35257e | ||
|
|
06e400cb34 | ||
|
|
dd380c5a5e | ||
|
|
ad3151c3f3 | ||
|
|
cca1f7f32a | ||
|
|
3d86b836c3 | ||
|
|
7f48edc254 | ||
|
|
9245b4d39b | ||
|
|
3b363fb531 | ||
|
|
5b39aeb623 | ||
|
|
edc7a538f3 | ||
|
|
d585216153 | ||
|
|
1367beae51 | ||
|
|
944ecf6874 | ||
|
|
2bd10d6010 | ||
|
|
7ff4808be6 | ||
|
|
7bb3c2bf0e | ||
|
|
736e7de600 | ||
|
|
048ac95e8b | ||
|
|
91fff48cb1 | ||
|
|
de3eb0fbf3 | ||
|
|
531e8d0fd1 | ||
|
|
f38cc44694 | ||
|
|
bc7f8668a8 | ||
|
|
cbd12c8f7c | ||
|
|
50968398f9 | ||
|
|
aca6ee3d92 | ||
|
|
85eaa8b043 | ||
|
|
19e5599692 | ||
|
|
96f324e9ed | ||
|
|
0a269d37b7 | ||
|
|
136a251cb6 | ||
|
|
9b8d0bb458 | ||
|
|
59435a9f46 | ||
|
|
ff6d6f4755 | ||
|
|
0847b7f99d | ||
|
|
10bd9bd5a3 | ||
|
|
02be97fc3a | ||
|
|
7ada36f5f6 | ||
|
|
0e7b266adc | ||
|
|
9c10955988 | ||
|
|
9aa77d92c8 | ||
|
|
937bbd0454 | ||
|
|
ce92b87305 | ||
|
|
5be1475204 | ||
|
|
563d65c9ea | ||
|
|
299f9cbf0f | ||
|
|
c85f98ce4d | ||
|
|
b5887ba3f5 | ||
|
|
0cde4e8e98 | ||
|
|
b1b6a94e3c | ||
|
|
84201b43b5 | ||
|
|
070f9477a7 | ||
|
|
935b4ff583 | ||
|
|
7cf4abb99d | ||
|
|
df39b4624a | ||
|
|
68c65f418a | ||
|
|
4b7d0b0c0c | ||
|
|
f8740598a3 | ||
|
|
730b5d8cc0 | ||
|
|
dd54d82000 | ||
|
|
c847a8b61d | ||
|
|
22093ebffe | ||
|
|
7ec9c8772b | ||
|
|
926e519dd3 | ||
|
|
5106fcb287 | ||
|
|
52d3442856 | ||
|
|
4fd84f589b | ||
|
|
ab61e1adc9 | ||
|
|
5983625ff7 | ||
|
|
fe6fcb9950 | ||
|
|
d3ab11a6f0 | ||
|
|
508247ce70 | ||
|
|
dd65119454 | ||
|
|
a87364b839 | ||
|
|
57743e7150 | ||
|
|
80f498c037 | ||
|
|
d13408b4fc | ||
|
|
493fdebea3 | ||
|
|
85675d6fed | ||
|
|
8592ebb5f1 | ||
|
|
a40f39d7ec | ||
|
|
c070bfcd73 | ||
|
|
a32b0a6c06 | ||
|
|
d778f2cd18 | ||
|
|
d36beaf650 | ||
|
|
0634d90f05 | ||
|
|
1a3b0db563 | ||
|
|
fc05d3bfb2 | ||
|
|
8ec8ba5758 | ||
|
|
2def2ca635 | ||
|
|
89cbc06151 | ||
|
|
d2c68f2195 | ||
|
|
b260feafee | ||
|
|
49ebe86dd5 | ||
|
|
8177f81780 | ||
|
|
ebcafd2739 | ||
|
|
651092d08e | ||
|
|
47f36463a8 | ||
|
|
f7e4e5c196 | ||
|
|
2cf0371c0e | ||
|
|
b60e20037d |
19
.babelrc
19
.babelrc
@@ -1,15 +1,14 @@
|
||||
{
|
||||
"presets": [ [
|
||||
"@babel/env",
|
||||
{
|
||||
"targets": {
|
||||
"node": 14
|
||||
"presets": [
|
||||
[
|
||||
"@babel/env",
|
||||
{
|
||||
"targets": {
|
||||
"node": 16
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
],
|
||||
"@babel/typescript"
|
||||
],
|
||||
"ignore": [
|
||||
"**/*.d.ts"
|
||||
]
|
||||
"ignore": ["**/*.d.ts"]
|
||||
}
|
||||
|
||||
5
.changeset/fuzzy-drinks-taste.md
Normal file
5
.changeset/fuzzy-drinks-taste.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@verdaccio/ui-theme': minor
|
||||
---
|
||||
|
||||
fix: remove engines from ui-theme
|
||||
7
.changeset/light-walls-begin.md
Normal file
7
.changeset/light-walls-begin.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
'@verdaccio/ui-theme': minor
|
||||
'@verdaccio/server': minor
|
||||
'@verdaccio/web': minor
|
||||
---
|
||||
|
||||
feat: align with v5 ui endpoints and ui small bugfix
|
||||
@@ -41,10 +41,10 @@
|
||||
"@verdaccio/fastify-migration": "6.0.0-6-next.9",
|
||||
"@verdaccio/eslint-config": "1.0.0",
|
||||
"@verdaccio/benchmark": "1.0.0",
|
||||
"@verdaccio/website": "5.1.3",
|
||||
"@verdaccio/core": "6.0.0-next.0",
|
||||
"@verdaccio/helper": "1.0.0",
|
||||
"docusaurus-plugin-contributors": "1.0.0"
|
||||
"docusaurus-plugin-contributors": "1.0.0",
|
||||
"@verdaccio/website": "5.4.0"
|
||||
},
|
||||
"changesets": [
|
||||
"afraid-mice-obey",
|
||||
@@ -58,6 +58,7 @@
|
||||
"few-cooks-destroy",
|
||||
"few-mangos-grow",
|
||||
"fifty-jars-rest",
|
||||
"fuzzy-drinks-taste",
|
||||
"fuzzy-onions-draw",
|
||||
"gentle-parrots-lay",
|
||||
"gentle-trains-switch",
|
||||
@@ -68,6 +69,7 @@
|
||||
"hip-hounds-destroy",
|
||||
"late-adults-love",
|
||||
"late-parents-act",
|
||||
"light-walls-begin",
|
||||
"little-stingrays-rule",
|
||||
"many-vans-care",
|
||||
"modern-spies-tell",
|
||||
@@ -82,6 +84,7 @@
|
||||
"pretty-hounds-tap",
|
||||
"proud-jeans-walk",
|
||||
"red-chefs-float",
|
||||
"red-yaks-sell",
|
||||
"rich-ghosts-rule",
|
||||
"shaggy-carrots-unite",
|
||||
"shaggy-parrots-smash",
|
||||
@@ -89,10 +92,13 @@
|
||||
"smart-apricots-kneel",
|
||||
"sour-buses-shout",
|
||||
"spicy-frogs-press",
|
||||
"spicy-snakes-sip",
|
||||
"ten-parents-breathe",
|
||||
"tender-bags-call",
|
||||
"thick-countries-move",
|
||||
"three-moles-drop",
|
||||
"three-pots-sit",
|
||||
"tiny-seals-join",
|
||||
"two-dolls-check",
|
||||
"wild-jokes-beam"
|
||||
]
|
||||
|
||||
5
.changeset/red-yaks-sell.md
Normal file
5
.changeset/red-yaks-sell.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@verdaccio/logger': patch
|
||||
---
|
||||
|
||||
Fix re-opening log files using SIGUSR2
|
||||
5
.changeset/spicy-snakes-sip.md
Normal file
5
.changeset/spicy-snakes-sip.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@verdaccio/ui-theme': patch
|
||||
---
|
||||
|
||||
fix: specific version package detail page not showing
|
||||
6
.changeset/thick-countries-move.md
Normal file
6
.changeset/thick-countries-move.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
'@verdaccio/logger': major
|
||||
'@verdaccio/logger-prettify': major
|
||||
---
|
||||
|
||||
feat: upgrade to pino v7
|
||||
5
.changeset/tiny-seals-join.md
Normal file
5
.changeset/tiny-seals-join.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@verdaccio/ui-theme': minor
|
||||
---
|
||||
|
||||
feat: improve registry info dialog and language switch
|
||||
14
.github/workflows/benchmark.yml
vendored
14
.github/workflows/benchmark.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
||||
with:
|
||||
node-version: 14.x
|
||||
- name: install pnpm
|
||||
run: sudo npm i pnpm@6.6.1 -g
|
||||
run: sudo npm i pnpm@6.24.1 -g
|
||||
- name: set store
|
||||
run: |
|
||||
mkdir ~/.pnpm-store
|
||||
@@ -57,8 +57,8 @@ jobs:
|
||||
# - local
|
||||
- 3.13.1
|
||||
- 4.12.2
|
||||
- 5.3.0
|
||||
- 6.0.0-6-next.27
|
||||
- 5.5.2
|
||||
- 6.0.0-6-next.31
|
||||
name: Benchmark autocannon
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
@@ -73,7 +73,7 @@ jobs:
|
||||
run: tar -xzvf pkg.tar.gz -C ${{ github.workspace }}/packages
|
||||
- name: install pnpm
|
||||
# require fixed version
|
||||
run: sudo npm i pnpm@6.6.1 -g
|
||||
run: sudo npm i pnpm@6.24.1 -g
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.pnpm-store
|
||||
@@ -118,8 +118,8 @@ jobs:
|
||||
# old versions to compare same test along previous releases
|
||||
- 3.13.1
|
||||
- 4.12.2
|
||||
- 5.3.0
|
||||
- 6.0.0-6-next.27
|
||||
- 5.5.2
|
||||
- 6.0.0-6-next.31
|
||||
name: Benchmark hyperfine
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
@@ -134,7 +134,7 @@ jobs:
|
||||
run: tar -xzvf pkg.tar.gz -C ${{ github.workspace }}/packages
|
||||
- name: install pnpm
|
||||
# require fixed version
|
||||
run: sudo npm i pnpm@6.6.1 -g
|
||||
run: sudo npm i pnpm@6.24.1 -g
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.pnpm-store
|
||||
|
||||
151
.github/workflows/ci.yml
vendored
151
.github/workflows/ci.yml
vendored
@@ -10,7 +10,7 @@ on:
|
||||
- .changeset/**
|
||||
- .github/workflows/ci.yml
|
||||
- 'packages/**'
|
||||
- 'docker-examples/**'
|
||||
- 'docker-examples/**'
|
||||
- 'jest/**'
|
||||
- 'package.json'
|
||||
- 'pnpm-workspace.yaml'
|
||||
@@ -25,14 +25,14 @@ jobs:
|
||||
- 4873:4873
|
||||
steps:
|
||||
- uses: actions/checkout@v2.4.0
|
||||
- name: Use Node 14
|
||||
- name: Use Node 16
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 14
|
||||
node-version: 16
|
||||
- name: Install pnpm
|
||||
run: npm i pnpm@6.10.3 -g
|
||||
run: npm i pnpm@6.24.1 -g
|
||||
- name: set store
|
||||
run: |
|
||||
run: |
|
||||
mkdir ~/.pnpm-store
|
||||
pnpm config set store-dir ~/.pnpm-store
|
||||
- name: Install
|
||||
@@ -55,11 +55,11 @@ jobs:
|
||||
with:
|
||||
node-version: 16
|
||||
- name: Install pnpm
|
||||
run: npm i pnpm@6.10.3 -g
|
||||
run: npm i pnpm@6.24.1 -g
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.pnpm-store
|
||||
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
||||
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
||||
- name: Install
|
||||
run: pnpm recursive install --frozen-lockfile --ignore-scripts
|
||||
- name: Lint
|
||||
@@ -75,60 +75,23 @@ jobs:
|
||||
with:
|
||||
node-version: 16
|
||||
- name: Install pnpm
|
||||
run: npm i pnpm@6.10.3 -g
|
||||
run: npm i pnpm@6.24.1 -g
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.pnpm-store
|
||||
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
||||
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
||||
- name: Install
|
||||
run: pnpm recursive install --frozen-lockfile --ignore-scripts
|
||||
- name: Lint
|
||||
run: pnpm format:check
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
name: build
|
||||
needs: [format, lint]
|
||||
steps:
|
||||
- uses: actions/checkout@v2.4.0
|
||||
- name: Use Node 16
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 16
|
||||
- name: Install pnpm
|
||||
run: npm i pnpm@6.10.3 -g
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.pnpm-store
|
||||
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
||||
- name: Install
|
||||
run: pnpm recursive install --frozen-lockfile --ignore-scripts
|
||||
- name: crowdin download
|
||||
env:
|
||||
CROWDIN_VERDACCIO_PROJECT_ID: ${{ secrets.CROWDIN_VERDACCIO_PROJECT_ID }}
|
||||
CROWDIN_VERDACCIO_API_KEY: ${{ secrets.CROWDIN_VERDACCIO_API_KEY }}
|
||||
CONTEXT: production
|
||||
run: pnpm crowdin:download
|
||||
## this step is optional, translations are not mandatory for PR
|
||||
## secrets keys are not available on forks, the failure here is guaranteed
|
||||
continue-on-error: true
|
||||
- name: build
|
||||
run: pnpm build
|
||||
- name: tar packages
|
||||
run: |
|
||||
tar -czvf ${{ github.workspace }}/pkg.tar.gz -C ${{ github.workspace }}/packages .
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: verdaccio-artifact
|
||||
path: pkg.tar.gz
|
||||
test:
|
||||
needs: build
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
## Node 16 breaks UI test, jest issue
|
||||
node_version: [14]
|
||||
node_version: [16, 17]
|
||||
name: ${{ matrix.os }} / Node ${{ matrix.node_version }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
@@ -137,100 +100,69 @@ jobs:
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node_version }}
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: verdaccio-artifact
|
||||
- name: untar packages
|
||||
run: tar -xzvf pkg.tar.gz -C ${{ github.workspace }}/packages
|
||||
- name: Install pnpm
|
||||
run: npm i pnpm@6.10.3 -g
|
||||
run: npm i pnpm@6.24.1 -g
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.pnpm-store
|
||||
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
||||
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
||||
- name: Install
|
||||
run: pnpm recursive install --frozen-lockfile --ignore-scripts
|
||||
run: pnpm recursive install --frozen-lockfile --ignore-scripts
|
||||
- name: build
|
||||
run: pnpm build
|
||||
- name: Test
|
||||
run: pnpm test
|
||||
ci-e2e-ui:
|
||||
needs: build
|
||||
needs: [format, lint]
|
||||
runs-on: ubuntu-latest
|
||||
name: UI Test E2E Node 14
|
||||
name: UI Test E2E Node 16
|
||||
steps:
|
||||
- uses: actions/checkout@v2.4.0
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 14
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: verdaccio-artifact
|
||||
- name: untar packages
|
||||
run: tar -xzvf pkg.tar.gz -C ${{ github.workspace }}/packages
|
||||
node-version: 16
|
||||
- name: Install pnpm
|
||||
run: npm i pnpm@6.10.3 -g
|
||||
run: npm i pnpm@6.24.1 -g
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.pnpm-store
|
||||
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
||||
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
||||
- name: Install
|
||||
## we need scripts, pupetter downloads aditional content
|
||||
run: pnpm recursive install --frozen-lockfile
|
||||
run: pnpm recursive install --frozen-lockfile
|
||||
- name: build
|
||||
run: pnpm build
|
||||
- name: Test UI
|
||||
run: pnpm test:e2e:ui
|
||||
# env:
|
||||
# DEBUG: verdaccio:e2e*
|
||||
# DEBUG: verdaccio:e2e*
|
||||
ci-e2e-cli:
|
||||
needs: build
|
||||
needs: [format, lint]
|
||||
runs-on: ubuntu-latest
|
||||
# TODO: fails on migrate to node 16, we need to check why
|
||||
name: CLI Test E2E Node 14
|
||||
steps:
|
||||
- uses: actions/checkout@v2.4.0
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 14
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: verdaccio-artifact
|
||||
- name: untar packages
|
||||
run: tar -xzvf pkg.tar.gz -C ${{ github.workspace }}/packages
|
||||
- name: Install pnpm
|
||||
run: npm i pnpm@6.10.3 -g
|
||||
run: npm i pnpm@6.24.1 -g
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.pnpm-store
|
||||
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
||||
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
||||
- name: Install
|
||||
## we need scripts, pupetter downloads aditional content
|
||||
run: pnpm recursive install --frozen-lockfile
|
||||
- name: build
|
||||
run: pnpm build
|
||||
- name: Test CLI
|
||||
run: pnpm test:e2e:cli
|
||||
env:
|
||||
DEBUG: verdaccio*
|
||||
test-windows:
|
||||
needs: [format, lint]
|
||||
runs-on: windows-latest
|
||||
name: windows test node 14
|
||||
steps:
|
||||
- uses: actions/checkout@v2.4.0
|
||||
- name: Use Node 14
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 14
|
||||
- name: Install pnpm
|
||||
run: npm i pnpm@6.10.3 -g
|
||||
# pnpm cache is not working for windows (we need a solution)
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.pnpm-store
|
||||
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
||||
- name: Install
|
||||
run: pnpm recursive install --frozen-lockfile --ignore-scripts
|
||||
- name: build
|
||||
run: pnpm build
|
||||
- name: Test
|
||||
run: pnpm test
|
||||
DEBUG: verdaccio*
|
||||
sync-translations:
|
||||
needs: [ci-e2e-cli, ci-e2e-ui, test-windows, test]
|
||||
needs: [ci-e2e-cli, ci-e2e-ui]
|
||||
runs-on: ubuntu-latest
|
||||
name: synchronize translations
|
||||
if: (github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event_name == 'workflow_dispatch'
|
||||
@@ -238,26 +170,23 @@ jobs:
|
||||
- uses: actions/checkout@v2.4.0
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 14
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: verdaccio-artifact
|
||||
- name: untar packages
|
||||
run: tar -xzvf pkg.tar.gz -C ${{ github.workspace }}/packages
|
||||
node-version: 16
|
||||
- name: Install pnpm
|
||||
run: npm i pnpm@6.10.3 -g
|
||||
run: npm i pnpm@6.24.1 -g
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.pnpm-store
|
||||
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
||||
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
||||
- name: Install
|
||||
## we need scripts, pupetter downloads aditional content
|
||||
run: pnpm recursive install --frozen-lockfile
|
||||
- name: build
|
||||
run: pnpm build
|
||||
- name: generate website translations
|
||||
run: pnpm write-translations --filter ...@verdaccio/website
|
||||
run: pnpm write-translations --filter ...@verdaccio/website
|
||||
- name: sync
|
||||
env:
|
||||
CROWDIN_VERDACCIO_PROJECT_ID: ${{ secrets.CROWDIN_VERDACCIO_PROJECT_ID }}
|
||||
CROWDIN_VERDACCIO_API_KEY: ${{ secrets.CROWDIN_VERDACCIO_API_KEY }}
|
||||
CONTEXT: production
|
||||
run: pnpm crowdin:sync
|
||||
run: pnpm crowdin:sync
|
||||
|
||||
48
.github/workflows/contributors.yml
vendored
Normal file
48
.github/workflows/contributors.yml
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
---
|
||||
name: contributors
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
# twice peer week
|
||||
- cron: '0 0 * * 1,4'
|
||||
# for now, scheduled, we can enable on push master but not make much sense now
|
||||
# push:
|
||||
# branches:
|
||||
# - master
|
||||
jobs:
|
||||
prepare:
|
||||
name: Run script
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
persist-credentials: false
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 17.x
|
||||
- name: install pnpm
|
||||
run: sudo npm i pnpm@6.24.1 -g
|
||||
- name: set store
|
||||
run: |
|
||||
mkdir ~/.pnpm-store
|
||||
pnpm config set store-dir ~/.pnpm-store
|
||||
- name: setup pnpm config registry
|
||||
run: pnpm config set registry https://registry.verdaccio.org
|
||||
- name: install dependencies
|
||||
run: pnpm install
|
||||
- name: update contributors
|
||||
run: pnpm run contributors
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: format
|
||||
run: pnpm format
|
||||
- name: Commit & Push changes
|
||||
uses: actions-js/push@v1.3
|
||||
with:
|
||||
github_token: ${{ secrets.TOKEN_VERDACCIOBOT_GITHUB }}
|
||||
message: "chore: updated contributors list"
|
||||
branch: master
|
||||
author_email: verdaccio.npm@gmail.com
|
||||
author_name: verdacciobot
|
||||
7
.github/workflows/website.yml
vendored
7
.github/workflows/website.yml
vendored
@@ -41,7 +41,7 @@ jobs:
|
||||
restore-keys: |
|
||||
${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}-
|
||||
|
||||
- uses: pnpm/action-setup@v2.0.1
|
||||
- uses: pnpm/action-setup@v2.1.0
|
||||
with:
|
||||
version: 6.10.2
|
||||
run_install: |
|
||||
@@ -49,11 +49,6 @@ jobs:
|
||||
args: [--frozen-lockfile]
|
||||
- name: Build Plugins
|
||||
run: pnpm build --filter "docusaurus-plugin-contributors"
|
||||
- name: Lint And Pretty
|
||||
run: |
|
||||
pnpm eslint:check --filter ...@verdaccio/website
|
||||
pnpm prettier:check --filter ...@verdaccio/website
|
||||
|
||||
- name: Cache Docusaurus Build
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM --platform=${BUILDPLATFORM:-linux/amd64} node:14.18.1-alpine as builder
|
||||
FROM --platform=${BUILDPLATFORM:-linux/amd64} node:16.13.2-alpine as builder
|
||||
|
||||
ENV NODE_ENV=development \
|
||||
VERDACCIO_BUILD_REGISTRY=https://registry.verdaccio.org
|
||||
@@ -11,7 +11,7 @@ RUN apk --no-cache add openssl ca-certificates wget && \
|
||||
|
||||
WORKDIR /opt/verdaccio-build
|
||||
COPY . .
|
||||
RUN npm -g i pnpm@6.10.3 && \
|
||||
RUN npm -g i pnpm@6.24.1 && \
|
||||
pnpm config set registry $VERDACCIO_BUILD_REGISTRY && \
|
||||
pnpm recursive install --frozen-lockfile --ignore-scripts && \
|
||||
rm -Rf test && \
|
||||
@@ -20,7 +20,7 @@ RUN npm -g i pnpm@6.10.3 && \
|
||||
# FIXME: need to remove devDependencies from the build
|
||||
# RUN pnpm install --prod --ignore-scripts
|
||||
|
||||
FROM node:14.18.1-alpine
|
||||
FROM node:16.13.2-alpine
|
||||
LABEL maintainer="https://github.com/verdaccio/verdaccio"
|
||||
|
||||
ENV VERDACCIO_APPDIR=/opt/verdaccio \
|
||||
|
||||
27
README.md
27
README.md
@@ -29,7 +29,7 @@ Google Cloud Storage** or create your own plugin.
|
||||
|
||||
## Install
|
||||
|
||||
> Latest Node.js v14
|
||||
> Latest Node.js v16 required
|
||||
|
||||
Install with npm:
|
||||
|
||||
@@ -45,7 +45,7 @@ docker pull verdaccio/verdaccio:nightly-master
|
||||
|
||||
## Donations
|
||||
|
||||
Verdaccio is run by **volunteers**; nobody is working full-time on it. If you find this project to be useful and would like to support its development, consider making a donation - **your logo might end up in this readme.** 😉
|
||||
Verdaccio is run by **volunteers**; nobody is working full-time on it. If you find this project to be useful and would like to support its development, consider do a long support donation - **and your logo will be on this section of the readme.**
|
||||
|
||||
**[Donate](https://github.com/sponsors/verdaccio)** 💵👍🏻 starting from _$1/month_ or just one single contribution.
|
||||
|
||||
@@ -73,17 +73,26 @@ If you want to use a modified version of some 3rd-party package (for example, yo
|
||||
Verdaccio has proved to be a lightweight registry that can be
|
||||
booted in a couple of seconds, fast enough for any CI. Many open source projects use verdaccio for end to end testing, to mention some examples, **create-react-app**, **mozilla neutrino**, **pnpm**, **storybook**, **alfresco** or **eclipse theia**. You can read more in dedicated article to E2E in our blog.
|
||||
|
||||
## Talks
|
||||
## Watch our Videos
|
||||
|
||||
### **Testing the integrity of your React components by publishing in a private registry - React Finland 2021**.
|
||||
**Node Congress 2022, February 2022, Online Free**
|
||||
|
||||
[](https://www.youtube.com/watch?v=bRKZbrlQqLY&t=16s&ab_channel=ReactFinland)
|
||||
<div>
|
||||
<a href="https://nodecongress.com/">
|
||||
<img src="https://cdn.verdaccio.dev/readme/nodejscongress2022.jpg" alt="nodejs" width="300"/>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
### **Using Docker and Verdaccio to make Integration Testing Easy - Docker All Hands #4 December - 2021**.
|
||||
|
||||
[](https://www.youtube.com/watch?v=zRI0skF1f8I)
|
||||
|
||||
You might want to check out as well our previous talks:
|
||||
|
||||
- [**Juan Picado** – Testing the integrity of React components by publishing in a private registry - React Finland - 2021](https://www.youtube.com/watch?v=bRKZbrlQqLY&t=16s&ab_channel=ReactFinland)
|
||||
- [BeerJS Cba Meetup No. 53 May 2021 - **Juan Picado**](https://www.youtube.com/watch?v=6SyjqBmS49Y&ab_channel=BeerJSCba)
|
||||
- [Node.js Dependency Confusion Attacks - April 2021 - **Juan Picado\***](https://www.youtube.com/watch?v=qTRADSp3Hpo)
|
||||
- [**OpenJS World 2020** about \*Cover your Projects with a Multi purpose Lightweight Node.js Registry - **Juan Picado\***](https://www.youtube.com/watch?v=oVCjDWeehAQ)
|
||||
- [Node.js Dependency Confusion Attacks - April 2021 - **Juan Picado**](https://www.youtube.com/watch?v=qTRADSp3Hpo)
|
||||
- [**OpenJS World 2020** about \*Cover your Projects with a Multi purpose Lightweight Node.js Registry - **Juan Picado**](https://www.youtube.com/watch?v=oVCjDWeehAQ)
|
||||
- [ViennaJS Meetup - Introduction to Verdaccio by **Priscila Olivera** and **Juan Picado**](https://www.youtube.com/watch?v=hDIFKzmoCa)
|
||||
- [Open Source? trivago - Verdaccio (**Ayush** and **Juan Picado**) January 2020](https://www.youtube.com/watch?v=A5CWxJC9xzc)
|
||||
- [GitNation Open Source Stage - How we have built a Node.js Registry with React - **Juan Picado** December 2019](https://www.youtube.com/watch?v=gpjC8Qp9B9A)
|
||||
@@ -100,7 +109,7 @@ verdaccio
|
||||
You would need set some npm configuration, this is optional.
|
||||
|
||||
```bash
|
||||
$ npm set registry http://localhost:4873/
|
||||
npm set registry http://localhost:4873/
|
||||
```
|
||||
|
||||
For one-off commands or to avoid setting the registry globally:
|
||||
@@ -124,7 +133,7 @@ npm adduser --registry http://localhost:4873
|
||||
> if you use HTTPS, add an appropriate CA information ("null" means get CA list from OS)
|
||||
|
||||
```bash
|
||||
$ npm set ca null
|
||||
npm set ca null
|
||||
```
|
||||
|
||||
#### 2. publish your package
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
# see https://github.com/verdaccio/verdaccio/blob/master/wiki/docker.md#docker-and-custom-port-configuration
|
||||
#
|
||||
# Look here for more config file examples:
|
||||
# https://github.com/verdaccio/verdaccio/tree/master/conf
|
||||
# https://github.com/verdaccio/verdaccio/tree/master/packages/config/src/conf
|
||||
#
|
||||
|
||||
# path to a directory with all packages
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
# see https://github.com/verdaccio/verdaccio/blob/master/wiki/docker.md#docker-and-custom-port-configuration
|
||||
#
|
||||
# Look here for more config file examples:
|
||||
# https://github.com/verdaccio/verdaccio/tree/master/conf
|
||||
# https://github.com/verdaccio/verdaccio/tree/master/packages/config/src/conf
|
||||
#
|
||||
|
||||
# path to a directory with all packages
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
# see https://github.com/verdaccio/verdaccio/blob/master/wiki/docker.md#docker-and-custom-port-configuration
|
||||
#
|
||||
# Look here for more config file examples:
|
||||
# https://github.com/verdaccio/verdaccio/tree/master/conf
|
||||
# https://github.com/verdaccio/verdaccio/tree/master/packages/config/src/conf
|
||||
#
|
||||
|
||||
# path to a directory with all packages
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
# see https://github.com/verdaccio/verdaccio/blob/master/wiki/docker.md#docker-and-custom-port-configuration
|
||||
#
|
||||
# Look here for more config file examples:
|
||||
# https://github.com/verdaccio/verdaccio/tree/master/conf
|
||||
# https://github.com/verdaccio/verdaccio/tree/master/packages/config/src/conf
|
||||
#
|
||||
|
||||
# path to a directory with all packages
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
# see https://github.com/verdaccio/verdaccio/blob/master/wiki/docker.md#docker-and-custom-port-configuration
|
||||
#
|
||||
# Look here for more config file examples:
|
||||
# https://github.com/verdaccio/verdaccio/tree/master/conf
|
||||
# https://github.com/verdaccio/verdaccio/tree/master/packages/config/src/conf
|
||||
#
|
||||
|
||||
# path to a directory with all packages
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
# see https://github.com/verdaccio/verdaccio/blob/master/wiki/docker.md#docker-and-custom-port-configuration
|
||||
#
|
||||
# Look here for more config file examples:
|
||||
# https://github.com/verdaccio/verdaccio/tree/master/conf
|
||||
# https://github.com/verdaccio/verdaccio/tree/master/packages/config/src/conf
|
||||
#
|
||||
|
||||
# path to a directory with all packages
|
||||
|
||||
101
package.json
101
package.json
@@ -15,91 +15,93 @@
|
||||
"url": "https://opencollective.com/verdaccio"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "7.16.0",
|
||||
"@babel/core": "7.16.0",
|
||||
"@babel/node": "7.16.0",
|
||||
"@babel/plugin-proposal-class-properties": "7.16.0",
|
||||
"@babel/plugin-proposal-decorators": "7.16.4",
|
||||
"@babel/plugin-proposal-export-namespace-from": "7.16.0",
|
||||
"@babel/plugin-proposal-function-sent": "7.16.0",
|
||||
"@babel/plugin-proposal-json-strings": "7.16.0",
|
||||
"@babel/plugin-proposal-nullish-coalescing-operator": "7.16.0",
|
||||
"@babel/plugin-proposal-numeric-separator": "7.16.0",
|
||||
"@babel/plugin-proposal-object-rest-spread": "7.16.0",
|
||||
"@babel/plugin-proposal-optional-chaining": "7.16.0",
|
||||
"@babel/plugin-proposal-throw-expressions": "7.16.0",
|
||||
"@babel/cli": "7.16.8",
|
||||
"@babel/core": "7.16.12",
|
||||
"@babel/node": "7.16.8",
|
||||
"@babel/plugin-proposal-class-properties": "7.16.7",
|
||||
"@babel/plugin-proposal-decorators": "7.16.7",
|
||||
"@babel/plugin-proposal-export-namespace-from": "7.16.7",
|
||||
"@babel/plugin-proposal-function-sent": "7.16.7",
|
||||
"@babel/plugin-proposal-json-strings": "7.16.7",
|
||||
"@babel/plugin-proposal-nullish-coalescing-operator": "7.16.7",
|
||||
"@babel/plugin-proposal-numeric-separator": "7.16.7",
|
||||
"@babel/plugin-proposal-object-rest-spread": "7.16.7",
|
||||
"@babel/plugin-proposal-optional-chaining": "7.16.7",
|
||||
"@babel/plugin-proposal-throw-expressions": "7.16.7",
|
||||
"@babel/plugin-syntax-dynamic-import": "7.8.3",
|
||||
"@babel/plugin-syntax-import-meta": "7.10.4",
|
||||
"@babel/plugin-transform-async-to-generator": "7.16.0",
|
||||
"@babel/plugin-transform-classes": "7.16.0",
|
||||
"@babel/plugin-transform-runtime": "7.16.4",
|
||||
"@babel/preset-env": "7.16.4",
|
||||
"@babel/preset-react": "7.16.0",
|
||||
"@babel/preset-typescript": "7.16.0",
|
||||
"@babel/register": "7.16.0",
|
||||
"@babel/runtime": "7.16.3",
|
||||
"@changesets/changelog-github": "0.2.8",
|
||||
"@babel/plugin-transform-async-to-generator": "7.16.8",
|
||||
"@babel/plugin-transform-classes": "7.16.7",
|
||||
"@babel/plugin-transform-runtime": "7.16.10",
|
||||
"@babel/preset-env": "7.16.11",
|
||||
"@babel/preset-react": "7.16.7",
|
||||
"@babel/preset-typescript": "7.16.7",
|
||||
"@babel/register": "7.16.9",
|
||||
"@babel/runtime": "7.16.7",
|
||||
"@dianmora/contributors": "2.0.2",
|
||||
"@changesets/changelog-github": "0.4.2",
|
||||
"@changesets/cli": "2.15.0",
|
||||
"@changesets/get-dependents-graph": "1.2.4",
|
||||
"@crowdin/cli": "3.7.2",
|
||||
"@trivago/prettier-plugin-sort-imports": "3.1.1",
|
||||
"@types/async": "3.2.7",
|
||||
"@crowdin/cli": "3.7.7",
|
||||
"@trivago/prettier-plugin-sort-imports": "3.2.0",
|
||||
"@types/async": "3.2.12",
|
||||
"@types/autocannon": "4.1.1",
|
||||
"@types/express": "4.17.13",
|
||||
"@types/http-errors": "1.8.1",
|
||||
"@types/jest": "27.0.3",
|
||||
"@types/http-errors": "1.8.2",
|
||||
"@types/jest": "27.4.0",
|
||||
"@types/lodash": "4.14.178",
|
||||
"@types/mime": "2.0.3",
|
||||
"@types/minimatch": "3.0.5",
|
||||
"@types/node": "14.6.0",
|
||||
"@types/request": "2.48.7",
|
||||
"@types/node": "16.11.21",
|
||||
"@types/jsonwebtoken": "8.5.1",
|
||||
"@types/request": "2.48.8",
|
||||
"@types/semver": "7.3.9",
|
||||
"@types/supertest": "2.0.11",
|
||||
"@types/testing-library__jest-dom": "5.14.2",
|
||||
"@types/validator": "13.7.0",
|
||||
"@types/validator": "13.7.1",
|
||||
"@types/webpack": "5.28.0",
|
||||
"@types/webpack-env": "1.16.3",
|
||||
"@typescript-eslint/eslint-plugin": "4.33.0",
|
||||
"@typescript-eslint/parser": "4.33.0",
|
||||
"@typescript-eslint/eslint-plugin": "5.10.2",
|
||||
"@typescript-eslint/parser": "5.10.2",
|
||||
"@verdaccio/benchmark": "workspace:*",
|
||||
"@verdaccio/eslint-config": "workspace:*",
|
||||
"@verdaccio/types": "workspace:*",
|
||||
"@verdaccio/ui-theme": "workspace:*",
|
||||
"autocannon": "7.5.0",
|
||||
"autocannon": "7.6.0",
|
||||
"babel-core": "7.0.0-bridge.0",
|
||||
"babel-eslint": "10.1.0",
|
||||
"babel-jest": "27.3.1",
|
||||
"babel-jest": "27.4.6",
|
||||
"babel-plugin-dynamic-import-node": "2.3.3",
|
||||
"babel-plugin-emotion": "10.2.2",
|
||||
"codecov": "3.8.3",
|
||||
"concurrently": "6.4.0",
|
||||
"core-js": "3.17.2",
|
||||
"concurrently": "6.5.1",
|
||||
"core-js": "3.20.3",
|
||||
"cross-env": "7.0.3",
|
||||
"debug": "4.3.3",
|
||||
"detect-secrets": "1.0.6",
|
||||
"eslint": "7.32.0",
|
||||
"eslint": "8.8.0",
|
||||
"fs-extra": "10.0.0",
|
||||
"husky": "7.0.4",
|
||||
"in-publish": "2.0.1",
|
||||
"jest": "27.3.1",
|
||||
"jest-environment-jsdom": "27.3.1",
|
||||
"jest": "27.4.7",
|
||||
"jest-environment-jsdom": "27.4.6",
|
||||
"jest-environment-jsdom-global": "3.0.0",
|
||||
"jest-environment-node": "27.3.1",
|
||||
"jest-environment-node": "27.4.6",
|
||||
"jest-junit": "12.3.0",
|
||||
"kleur": "3.0.3",
|
||||
"lint-staged": "11.1.2",
|
||||
"lint-staged": "11.2.6",
|
||||
"nock": "12.0.3",
|
||||
"node-fetch": "3.0.0-beta.6-exportfix",
|
||||
"node-fetch": "cjs",
|
||||
"nodemon": "2.0.15",
|
||||
"npm-run-all": "4.1.5",
|
||||
"prettier": "2.3.2",
|
||||
"prettier": "2.5.1",
|
||||
"rimraf": "3.0.2",
|
||||
"selfsigned": "1.10.11",
|
||||
"supertest": "6.1.6",
|
||||
"ts-node": "10.2.1",
|
||||
"typescript": "4.4.4",
|
||||
"selfsigned": "1.10.14",
|
||||
"supertest": "6.2.2",
|
||||
"ts-node": "10.4.0",
|
||||
"typescript": "4.5.5",
|
||||
"update-ts-references": "2.4.1",
|
||||
"verdaccio": "5.3.1",
|
||||
"verdaccio": "5.5.0",
|
||||
"verdaccio-audit": "workspace:*",
|
||||
"verdaccio-auth-memory": "workspace:*",
|
||||
"verdaccio-htpasswd": "workspace:*",
|
||||
@@ -112,7 +114,7 @@
|
||||
"docker": "docker build -t verdaccio/verdaccio:local . --no-cache",
|
||||
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,yml,yaml,md}\"",
|
||||
"format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,json,yml,yaml,md}\"",
|
||||
"lint": "eslint --max-warnings 47 \"**/*.{js,jsx,ts,tsx}\"",
|
||||
"lint": "eslint --max-warnings 44 \"**/*.{js,jsx,ts,tsx}\"",
|
||||
"test": "pnpm recursive test --filter ./packages",
|
||||
"test:e2e:cli": "pnpm test --filter ...@verdaccio/e2e-cli",
|
||||
"test:e2e:ui": "pnpm test --filter ...@verdaccio/e2e-ui",
|
||||
@@ -120,6 +122,7 @@
|
||||
"benchmark:hyper": "verdaccio-benchmark hyper -r ./hyper-results.json",
|
||||
"benchmark:api": "verdaccio-benchmark api",
|
||||
"benchmark:submit": "pnpm ts-node ./scripts/submit-metrics.ts",
|
||||
"contributors": "ts-node ./scripts/contributors-update.ts",
|
||||
"start:watch": "concurrently --kill-others \"pnpm _build:watch\" \"pnpm _start:server\" \"pnpm _debug:reload\"",
|
||||
"_build:watch": "pnpm run --parallel watch --filter ./packages",
|
||||
"_start:server": "node --inspect packages/verdaccio/debug/bootstrap.js --listen 8000",
|
||||
|
||||
@@ -1,5 +1,27 @@
|
||||
# @verdaccio/api
|
||||
|
||||
## 6.0.0-6-next.21
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [b78f3525]
|
||||
- @verdaccio/logger@6.0.0-6-next.10
|
||||
- @verdaccio/auth@6.0.0-6-next.18
|
||||
- @verdaccio/hooks@6.0.0-6-next.12
|
||||
- @verdaccio/middleware@6.0.0-6-next.18
|
||||
- @verdaccio/store@6.0.0-6-next.19
|
||||
|
||||
## 6.0.0-6-next.20
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [730b5d8c]
|
||||
- @verdaccio/logger@6.0.0-6-next.9
|
||||
- @verdaccio/auth@6.0.0-6-next.17
|
||||
- @verdaccio/hooks@6.0.0-6-next.11
|
||||
- @verdaccio/middleware@6.0.0-6-next.17
|
||||
- @verdaccio/store@6.0.0-6-next.18
|
||||
|
||||
## 6.0.0-6-next.19
|
||||
|
||||
### Major Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@verdaccio/api",
|
||||
"version": "6.0.0-6-next.19",
|
||||
"version": "6.0.0-6-next.21",
|
||||
"description": "loaders logic",
|
||||
"main": "./build/index.js",
|
||||
"types": "build/index.d.ts",
|
||||
@@ -39,29 +39,29 @@
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@verdaccio/auth": "workspace:6.0.0-6-next.16",
|
||||
"@verdaccio/auth": "workspace:6.0.0-6-next.18",
|
||||
"@verdaccio/config": "workspace:6.0.0-6-next.12",
|
||||
"@verdaccio/core": "workspace:6.0.0-6-next.4",
|
||||
"@verdaccio/hooks": "workspace:6.0.0-6-next.10",
|
||||
"@verdaccio/logger": "workspace:6.0.0-6-next.8",
|
||||
"@verdaccio/middleware": "workspace:6.0.0-6-next.16",
|
||||
"@verdaccio/store": "workspace:6.0.0-6-next.17",
|
||||
"@verdaccio/hooks": "workspace:6.0.0-6-next.12",
|
||||
"@verdaccio/logger": "workspace:6.0.0-6-next.10",
|
||||
"@verdaccio/middleware": "workspace:6.0.0-6-next.18",
|
||||
"@verdaccio/store": "workspace:6.0.0-6-next.19",
|
||||
"@verdaccio/utils": "workspace:6.0.0-6-next.10",
|
||||
"abortcontroller-polyfill": "1.7.3",
|
||||
"cookies": "0.8.0",
|
||||
"debug": "4.3.3",
|
||||
"body-parser": "1.19.1",
|
||||
"express": "4.17.1",
|
||||
"express": "4.17.2",
|
||||
"lodash": "4.17.21",
|
||||
"mime": "2.6.0",
|
||||
"semver": "7.3.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "16.11.12",
|
||||
"@verdaccio/server": "workspace:6.0.0-6-next.24",
|
||||
"@types/node": "16.11.21",
|
||||
"@verdaccio/server": "workspace:6.0.0-6-next.26",
|
||||
"@verdaccio/types": "workspace:11.0.0-6-next.10",
|
||||
"@verdaccio/helper": "1.0.0",
|
||||
"supertest": "6.1.6"
|
||||
"supertest": "6.2.2"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
|
||||
@@ -55,13 +55,13 @@ export default function (route: Router, auth: IAuth, storage: Storage): void {
|
||||
try {
|
||||
// TODO: this is just temporary while I migrate all plugins to use the new API
|
||||
// the method will be renamed to getPackage again but Promise Based.
|
||||
if (!storage.getPackageNext) {
|
||||
if (!storage.getPackageByOptions) {
|
||||
throw errorUtils.getInternalError(
|
||||
'getPackageNext not implemented, check pr-2750 for more details'
|
||||
'getPackageByOptions not implemented, check pr-2750 for more details'
|
||||
);
|
||||
}
|
||||
|
||||
const manifest = await storage.getPackageNext({
|
||||
const manifest = await storage.getPackageByOptions({
|
||||
name,
|
||||
uplinksLook: true,
|
||||
req,
|
||||
|
||||
@@ -8,6 +8,7 @@ import { Package } from '@verdaccio/types';
|
||||
*/
|
||||
|
||||
export function isPublishablePackage(pkg: Package): boolean {
|
||||
// TODO: we can do better, no need get keys
|
||||
const keys: string[] = Object.keys(pkg);
|
||||
|
||||
return _.includes(keys, 'versions');
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
# @verdaccio/auth
|
||||
|
||||
## 6.0.0-6-next.18
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [b78f3525]
|
||||
- @verdaccio/logger@6.0.0-6-next.10
|
||||
- @verdaccio/loaders@6.0.0-6-next.10
|
||||
|
||||
## 6.0.0-6-next.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [730b5d8c]
|
||||
- @verdaccio/logger@6.0.0-6-next.9
|
||||
- @verdaccio/loaders@6.0.0-6-next.9
|
||||
|
||||
## 6.0.0-6-next.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@verdaccio/auth",
|
||||
"version": "6.0.0-6-next.16",
|
||||
"version": "6.0.0-6-next.18",
|
||||
"description": "logger",
|
||||
"main": "./build/index.js",
|
||||
"types": "build/index.d.ts",
|
||||
@@ -41,11 +41,11 @@
|
||||
"dependencies": {
|
||||
"@verdaccio/core": "workspace:6.0.0-6-next.4",
|
||||
"@verdaccio/config": "workspace:6.0.0-6-next.12",
|
||||
"@verdaccio/loaders": "workspace:6.0.0-6-next.8",
|
||||
"@verdaccio/logger": "workspace:6.0.0-6-next.8",
|
||||
"@verdaccio/loaders": "workspace:6.0.0-6-next.10",
|
||||
"@verdaccio/logger": "workspace:6.0.0-6-next.10",
|
||||
"@verdaccio/utils": "workspace:6.0.0-6-next.10",
|
||||
"debug": "4.3.3",
|
||||
"express": "4.17.1",
|
||||
"express": "4.17.2",
|
||||
"jsonwebtoken": "8.5.1",
|
||||
"lodash": "4.17.21",
|
||||
"verdaccio-htpasswd": "workspace:11.0.0-6-next.11"
|
||||
|
||||
@@ -21,12 +21,14 @@ export async function signPayload(
|
||||
return jwt.sign(
|
||||
payload,
|
||||
secretOrPrivateKey,
|
||||
// FIXME: upgrade to the latest library and types
|
||||
// @ts-ignore
|
||||
{
|
||||
// 1 === 1ms (one millisecond)
|
||||
notBefore: '1', // Make sure the time will not rollback :)
|
||||
...options,
|
||||
},
|
||||
(error, token) => {
|
||||
(error, token: string) => {
|
||||
debug('error on sign jwt token');
|
||||
return error ? reject(error) : resolve(token);
|
||||
}
|
||||
@@ -36,5 +38,5 @@ export async function signPayload(
|
||||
|
||||
export function verifyPayload(token: string, secretOrPrivateKey: string): RemoteUser {
|
||||
debug('verify jwt token');
|
||||
return jwt.verify(token, secretOrPrivateKey);
|
||||
return jwt.verify(token, secretOrPrivateKey) as RemoteUser;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
HexBase64BinaryEncoding,
|
||||
Utf8AsciiBinaryEncoding,
|
||||
BinaryToTextEncoding,
|
||||
CharacterEncoding,
|
||||
createCipheriv,
|
||||
createDecipheriv,
|
||||
randomBytes,
|
||||
@@ -12,8 +12,8 @@ import { TOKEN_VALID_LENGTH } from '@verdaccio/config';
|
||||
const debug = buildDebug('verdaccio:auth:token:legacy');
|
||||
|
||||
export const defaultAlgorithm = process.env.VERDACCIO_LEGACY_ALGORITHM || 'aes-256-ctr';
|
||||
const inputEncoding: Utf8AsciiBinaryEncoding = 'utf8';
|
||||
const outputEncoding: HexBase64BinaryEncoding = 'hex';
|
||||
const inputEncoding: CharacterEncoding = 'utf8';
|
||||
const outputEncoding: BinaryToTextEncoding = 'hex';
|
||||
// For AES, this is always 16
|
||||
const IV_LENGTH = 16;
|
||||
// Must be 256 bits (32 characters)
|
||||
@@ -56,7 +56,8 @@ export function aesDecrypt(value: string, key: string): string | void {
|
||||
const secretKey = VERDACCIO_LEGACY_ENCRYPTION_KEY || key;
|
||||
// decipher the string
|
||||
const decipher = createDecipheriv(defaultAlgorithm, secretKey, IV);
|
||||
let decrypted = decipher.update(encryptedText, outputEncoding, inputEncoding);
|
||||
// FIXME: fix type here should allow Buffer
|
||||
let decrypted = decipher.update(encryptedText as any, outputEncoding, inputEncoding);
|
||||
decrypted += decipher.final(inputEncoding);
|
||||
debug('token decrypted successfully');
|
||||
return decrypted.toString();
|
||||
|
||||
@@ -1,5 +1,23 @@
|
||||
# @verdaccio/cli
|
||||
|
||||
## 6.0.0-6-next.28
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [b78f3525]
|
||||
- @verdaccio/logger@6.0.0-6-next.10
|
||||
- @verdaccio/fastify-migration@6.0.0-6-next.19
|
||||
- @verdaccio/node-api@6.0.0-6-next.27
|
||||
|
||||
## 6.0.0-6-next.27
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [730b5d8c]
|
||||
- @verdaccio/logger@6.0.0-6-next.9
|
||||
- @verdaccio/node-api@6.0.0-6-next.26
|
||||
- @verdaccio/fastify-migration@6.0.0-6-next.18
|
||||
|
||||
## 6.0.0-6-next.26
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@verdaccio/cli",
|
||||
"version": "6.0.0-6-next.26",
|
||||
"version": "6.0.0-6-next.28",
|
||||
"author": {
|
||||
"name": "Juan Picado",
|
||||
"email": "juanpicado19@gmail.com"
|
||||
@@ -46,16 +46,16 @@
|
||||
"dependencies": {
|
||||
"@verdaccio/core": "workspace:6.0.0-6-next.4",
|
||||
"@verdaccio/config": "workspace:6.0.0-6-next.12",
|
||||
"@verdaccio/logger": "workspace:6.0.0-6-next.8",
|
||||
"@verdaccio/node-api": "workspace:6.0.0-6-next.25",
|
||||
"@verdaccio/fastify-migration": "workspace:6.0.0-6-next.17",
|
||||
"@verdaccio/logger": "workspace:6.0.0-6-next.10",
|
||||
"@verdaccio/node-api": "workspace:6.0.0-6-next.27",
|
||||
"@verdaccio/fastify-migration": "workspace:6.0.0-6-next.19",
|
||||
"clipanion": "3.1.0",
|
||||
"envinfo": "7.8.1",
|
||||
"kleur": "3.0.3",
|
||||
"semver": "7.3.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ts-node": "10.2.1"
|
||||
"ts-node": "10.4.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# so don't use it on production systems.
|
||||
#
|
||||
# Look here for more config file examples:
|
||||
# https://github.com/verdaccio/verdaccio/tree/master/conf
|
||||
# https://github.com/verdaccio/verdaccio/tree/master/packages/config/src/conf
|
||||
#
|
||||
|
||||
# path to a directory with all packages
|
||||
@@ -67,7 +67,7 @@ packages:
|
||||
# and three keywords: "$all", "$anonymous", "$authenticated"
|
||||
access: $all
|
||||
|
||||
# allow all known users to publish/publish packages
|
||||
# allow all known users to publish/unpublish packages
|
||||
# (anyone can register by default, remember?)
|
||||
publish: $authenticated
|
||||
unpublish: $authenticated
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
# see https://verdaccio.org/docs/en/docker#docker-and-custom-port-configuration
|
||||
#
|
||||
# Look here for more config file examples:
|
||||
# https://github.com/verdaccio/verdaccio/tree/master/conf
|
||||
# https://github.com/verdaccio/verdaccio/tree/master/packages/config/src/conf
|
||||
#
|
||||
|
||||
# path to a directory with all packages
|
||||
@@ -58,7 +58,7 @@ packages:
|
||||
# and three keywords: "$all", "$anonymous", "$authenticated"
|
||||
access: $all
|
||||
|
||||
# allow all known users to publish/publish packages
|
||||
# allow all known users to publish/unpublish packages
|
||||
# (anyone can register by default, remember?)
|
||||
publish: $authenticated
|
||||
unpublish: $authenticated
|
||||
|
||||
@@ -35,10 +35,10 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"http-errors": "1.8.1",
|
||||
"http-status-codes": "2.1.4",
|
||||
"http-status-codes": "2.2.0",
|
||||
"semver": "7.3.5",
|
||||
"fastify-warning": "0.2.0",
|
||||
"core-js": "3.17.2"
|
||||
"process-warning": "1.0.0",
|
||||
"core-js": "3.20.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@verdaccio/types": "workspace:11.0.0-6-next.10"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import warning from 'fastify-warning';
|
||||
import warning from 'process-warning';
|
||||
|
||||
const warningInstance = warning();
|
||||
const verdaccioWarning = 'VerdaccioWarning';
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
export * from './unclock';
|
||||
export * from './readFile';
|
||||
export * from './lockfile';
|
||||
// callback support
|
||||
export * from './legacy/unclock';
|
||||
export * from './legacy/readFile';
|
||||
export * from './legacy/lockfile';
|
||||
// promsie support
|
||||
export { readFileNext } from './readFile';
|
||||
export { lockFileNext } from './lockfile';
|
||||
export { unlockFileNext } from './utils';
|
||||
|
||||
29
packages/core/file-locking/src/legacy/lockfile.ts
Normal file
29
packages/core/file-locking/src/legacy/lockfile.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Callback } from '@verdaccio/types';
|
||||
|
||||
import { lockfile, statDir, statfile } from './utils';
|
||||
|
||||
/**
|
||||
* locks a file by creating a lock file
|
||||
* @param name
|
||||
* @param callback
|
||||
*/
|
||||
const lockFile = function (name: string, callback: Callback): void {
|
||||
Promise.resolve()
|
||||
.then(() => {
|
||||
return statDir(name);
|
||||
})
|
||||
.then(() => {
|
||||
return statfile(name);
|
||||
})
|
||||
.then(() => {
|
||||
return lockfile(name);
|
||||
})
|
||||
.then(() => {
|
||||
callback(null);
|
||||
})
|
||||
.catch((err) => {
|
||||
callback(err);
|
||||
});
|
||||
};
|
||||
|
||||
export { lockFile };
|
||||
87
packages/core/file-locking/src/legacy/readFile.ts
Normal file
87
packages/core/file-locking/src/legacy/readFile.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
/* eslint-disable no-undef */
|
||||
import fs from 'fs';
|
||||
|
||||
import { Callback } from '@verdaccio/types';
|
||||
|
||||
import { lockFile } from './lockfile';
|
||||
|
||||
export type ReadFileOptions = {
|
||||
parse?: boolean;
|
||||
lock?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* Reads a local file, which involves
|
||||
* optionally taking a lock
|
||||
* reading the file contents
|
||||
* optionally parsing JSON contents
|
||||
* @param {*} name
|
||||
* @param {*} options
|
||||
* @param {*} callback
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
function readFile(
|
||||
name: string,
|
||||
options: ReadFileOptions = {},
|
||||
callback: Callback = (): void => {}
|
||||
): void {
|
||||
if (typeof options === 'function') {
|
||||
callback = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
options.lock = options.lock || false;
|
||||
options.parse = options.parse || false;
|
||||
|
||||
const lock = function (options: ReadFileOptions): Promise<null | NodeJS.ErrnoException> {
|
||||
return new Promise((resolve, reject): void => {
|
||||
if (!options.lock) {
|
||||
return resolve(null);
|
||||
}
|
||||
|
||||
lockFile(name, function (err: NodeJS.ErrnoException | null) {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
return resolve(null);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const read = function (): Promise<NodeJS.ErrnoException | string> {
|
||||
return new Promise((resolve, reject): void => {
|
||||
fs.readFile(name, 'utf8', function (err, contents) {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
|
||||
resolve(contents);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const parseJSON = function (contents: string): Promise<unknown> {
|
||||
return new Promise((resolve, reject): void => {
|
||||
if (!options.parse) {
|
||||
return resolve(contents);
|
||||
}
|
||||
try {
|
||||
contents = JSON.parse(contents);
|
||||
return resolve(contents);
|
||||
} catch (err: any) {
|
||||
return reject(err);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Promise.resolve()
|
||||
.then(() => lock(options))
|
||||
.then(() => read())
|
||||
.then((content) => parseJSON(content as string))
|
||||
.then(
|
||||
(result) => callback(null, result),
|
||||
(err) => callback(err)
|
||||
);
|
||||
}
|
||||
|
||||
export { readFile };
|
||||
55
packages/core/file-locking/src/legacy/utils.ts
Normal file
55
packages/core/file-locking/src/legacy/utils.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import fs from 'fs';
|
||||
import locker from 'lockfile';
|
||||
import path from 'path';
|
||||
|
||||
export const statDir = (name: string): Promise<Error | null> => {
|
||||
return new Promise((resolve, reject): void => {
|
||||
// test to see if the directory exists
|
||||
const dirPath = path.dirname(name);
|
||||
fs.stat(dirPath, function (err, stats) {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
} else if (!stats.isDirectory()) {
|
||||
return resolve(new Error(`${path.dirname(name)} is not a directory`));
|
||||
} else {
|
||||
return resolve(null);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const statfile = (name: string): Promise<Error | null> => {
|
||||
return new Promise((resolve, reject): void => {
|
||||
// test to see if the directory exists
|
||||
fs.stat(name, function (err, stats) {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
} else if (!stats.isFile()) {
|
||||
return resolve(new Error(`${path.dirname(name)} is not a file`));
|
||||
} else {
|
||||
return resolve(null);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const lockfile = (name: string): Promise<unknown> => {
|
||||
return new Promise<void>((resolve): void => {
|
||||
const lockOpts = {
|
||||
// time (ms) to wait when checking for stale locks
|
||||
wait: 1000,
|
||||
// how often (ms) to re-check stale locks
|
||||
pollPeriod: 100,
|
||||
// locks are considered stale after 5 minutes
|
||||
stale: 5 * 60 * 1000,
|
||||
// number of times to attempt to create a lock
|
||||
retries: 100,
|
||||
// time (ms) between tries
|
||||
retryWait: 100,
|
||||
};
|
||||
const lockFileName = `${name}.lock`;
|
||||
locker.lock(lockFileName, lockOpts, () => {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -1,29 +1,15 @@
|
||||
import { Callback } from '@verdaccio/types';
|
||||
|
||||
import { lockfile, statDir, statfile } from './utils';
|
||||
import { lockFileWithOptions, statDir, statFile } from './utils';
|
||||
|
||||
/**
|
||||
* locks a file by creating a lock file
|
||||
* @param name
|
||||
* @param callback
|
||||
*/
|
||||
const lockFile = function (name: string, callback: Callback): void {
|
||||
Promise.resolve()
|
||||
.then(() => {
|
||||
return statDir(name);
|
||||
})
|
||||
.then(() => {
|
||||
return statfile(name);
|
||||
})
|
||||
.then(() => {
|
||||
return lockfile(name);
|
||||
})
|
||||
.then(() => {
|
||||
callback(null);
|
||||
})
|
||||
.catch((err) => {
|
||||
callback(err);
|
||||
});
|
||||
};
|
||||
|
||||
export { lockFile };
|
||||
export async function lockFileNext(name: string): Promise<void> {
|
||||
// check if dir exist
|
||||
await statDir(name);
|
||||
// check if file exist
|
||||
await statFile(name);
|
||||
// lock fhe the file
|
||||
await lockFileWithOptions(name);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,37 @@
|
||||
/* eslint-disable no-undef */
|
||||
import fs from 'fs';
|
||||
|
||||
import { Callback } from '@verdaccio/types';
|
||||
|
||||
import { lockFile } from './lockfile';
|
||||
import { lockFileNext } from './lockfile';
|
||||
import { readFile } from './utils';
|
||||
|
||||
export type ReadFileOptions = {
|
||||
parse?: boolean;
|
||||
lock?: boolean;
|
||||
};
|
||||
|
||||
async function lock(name: string, options: ReadFileOptions): Promise<null | void> {
|
||||
if (!options.lock) {
|
||||
return null;
|
||||
}
|
||||
|
||||
await lockFileNext(name);
|
||||
}
|
||||
|
||||
async function read(name: string): Promise<string> {
|
||||
return readFile(name, 'utf8');
|
||||
}
|
||||
|
||||
function parseJSON(contents: string, options): Promise<unknown> {
|
||||
return new Promise((resolve, reject): void => {
|
||||
if (!options.parse) {
|
||||
return resolve(contents);
|
||||
}
|
||||
try {
|
||||
contents = JSON.parse(contents);
|
||||
return resolve(contents);
|
||||
} catch (err: any) {
|
||||
return reject(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a local file, which involves
|
||||
* optionally taking a lock
|
||||
@@ -19,69 +41,13 @@ export type ReadFileOptions = {
|
||||
* @param {*} options
|
||||
* @param {*} callback
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
function readFile(
|
||||
name: string,
|
||||
options: ReadFileOptions = {},
|
||||
callback: Callback = (): void => {}
|
||||
): void {
|
||||
if (typeof options === 'function') {
|
||||
callback = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
options.lock = options.lock || false;
|
||||
options.parse = options.parse || false;
|
||||
|
||||
const lock = function (options: ReadFileOptions): Promise<null | NodeJS.ErrnoException> {
|
||||
return new Promise((resolve, reject): void => {
|
||||
if (!options.lock) {
|
||||
return resolve(null);
|
||||
}
|
||||
|
||||
lockFile(name, function (err: NodeJS.ErrnoException | null) {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
return resolve(null);
|
||||
});
|
||||
});
|
||||
export async function readFileNext<T>(name: string, options: ReadFileOptions = {}): Promise<T> {
|
||||
const _options = {
|
||||
lock: options?.lock || false,
|
||||
parse: options?.parse || false,
|
||||
};
|
||||
|
||||
const read = function (): Promise<NodeJS.ErrnoException | string> {
|
||||
return new Promise((resolve, reject): void => {
|
||||
fs.readFile(name, 'utf8', function (err, contents) {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
|
||||
resolve(contents);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const parseJSON = function (contents: string): Promise<unknown> {
|
||||
return new Promise((resolve, reject): void => {
|
||||
if (!options.parse) {
|
||||
return resolve(contents);
|
||||
}
|
||||
try {
|
||||
contents = JSON.parse(contents);
|
||||
return resolve(contents);
|
||||
} catch (err: any) {
|
||||
return reject(err);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Promise.resolve()
|
||||
.then(() => lock(options))
|
||||
.then(() => read())
|
||||
.then((content) => parseJSON(content as string))
|
||||
.then(
|
||||
(result) => callback(null, result),
|
||||
(err) => callback(err)
|
||||
);
|
||||
await lock(name, _options);
|
||||
const content = await read(name);
|
||||
const parsed = await parseJSON(content, options);
|
||||
return parsed as T;
|
||||
}
|
||||
|
||||
export { readFile };
|
||||
|
||||
@@ -1,55 +1,64 @@
|
||||
import fs from 'fs';
|
||||
import fs from 'fs/promises';
|
||||
import locker from 'lockfile';
|
||||
import path from 'path';
|
||||
import { promisify } from 'util';
|
||||
|
||||
export const statDir = (name: string): Promise<Error | null> => {
|
||||
return new Promise((resolve, reject): void => {
|
||||
// test to see if the directory exists
|
||||
const dirPath = path.dirname(name);
|
||||
fs.stat(dirPath, function (err, stats) {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
} else if (!stats.isDirectory()) {
|
||||
return resolve(new Error(`${path.dirname(name)} is not a directory`));
|
||||
} else {
|
||||
return resolve(null);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
export const readFile = fs.readFile;
|
||||
const statPromise = fs.stat;
|
||||
// https://github.com/npm/lockfile/issues/33
|
||||
const lfLock = promisify(locker.lock);
|
||||
const lfUnlock = promisify(locker.unlock);
|
||||
|
||||
export const statfile = (name: string): Promise<Error | null> => {
|
||||
return new Promise((resolve, reject): void => {
|
||||
// test to see if the directory exists
|
||||
fs.stat(name, function (err, stats) {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
} else if (!stats.isFile()) {
|
||||
return resolve(new Error(`${path.dirname(name)} is not a file`));
|
||||
} else {
|
||||
return resolve(null);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Test to see if the directory exists
|
||||
* @param name
|
||||
* @returns
|
||||
*/
|
||||
export async function statDir(name: string): Promise<void> {
|
||||
const dirPath = path.dirname(name);
|
||||
const stats = await statPromise(dirPath);
|
||||
if (!stats.isDirectory()) {
|
||||
throw new Error(`${path.dirname(name)} is not a directory`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
export const lockfile = (name: string): Promise<unknown> => {
|
||||
return new Promise<void>((resolve): void => {
|
||||
const lockOpts = {
|
||||
// time (ms) to wait when checking for stale locks
|
||||
wait: 1000,
|
||||
// how often (ms) to re-check stale locks
|
||||
pollPeriod: 100,
|
||||
// locks are considered stale after 5 minutes
|
||||
stale: 5 * 60 * 1000,
|
||||
// number of times to attempt to create a lock
|
||||
retries: 100,
|
||||
// time (ms) between tries
|
||||
retryWait: 100,
|
||||
};
|
||||
const lockFileName = `${name}.lock`;
|
||||
locker.lock(lockFileName, lockOpts, () => {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* test to see if the directory exists
|
||||
* @param name
|
||||
* @returns
|
||||
*/
|
||||
export async function statFile(name: string): Promise<void> {
|
||||
const stats = await statPromise(name);
|
||||
if (!stats.isFile()) {
|
||||
throw new Error(`${path.dirname(name)} is not a file`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock a file
|
||||
* @param name name of the file to lock
|
||||
*/
|
||||
export async function lockFileWithOptions(name: string, options?: any): Promise<void> {
|
||||
const lockOpts = {
|
||||
// time (ms) to wait when checking for stale locks
|
||||
wait: 1000,
|
||||
// how often (ms) to re-check stale locks
|
||||
pollPeriod: 100,
|
||||
// locks are considered stale after 5 minutes
|
||||
stale: 5 * 60 * 1000,
|
||||
// number of times to attempt to create a lock
|
||||
retries: 100,
|
||||
// time (ms) between tries
|
||||
retryWait: 100,
|
||||
...options,
|
||||
};
|
||||
await lfLock(`${name}.lock`, lockOpts);
|
||||
}
|
||||
|
||||
// unlocks file by removing existing lock file
|
||||
export async function unlockFileNext(name: string): Promise<void> {
|
||||
const lockFileName = `${name}.lock`;
|
||||
return lfUnlock(lockFileName);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "assets",
|
||||
"version": "0.0.1"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "assets",
|
||||
"version": "0.0.1"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "assets",
|
||||
"version": "0.0.1",
|
||||
}
|
||||
138
packages/core/file-locking/tests/lock.legacy.spec.ts
Normal file
138
packages/core/file-locking/tests/lock.legacy.spec.ts
Normal file
@@ -0,0 +1,138 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import { lockFile, readFile, unlockFile } from '../src/index';
|
||||
|
||||
interface Error {
|
||||
message: string;
|
||||
}
|
||||
|
||||
const getFilePath = (filename: string): string => {
|
||||
return path.resolve(__dirname, `assets/legacy/${filename}`);
|
||||
};
|
||||
|
||||
const removeTempFile = (filename: string): void => {
|
||||
const filepath = getFilePath(filename);
|
||||
fs.unlink(filepath, (error) => {
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
describe('testing locking', () => {
|
||||
describe('lockFile', () => {
|
||||
test('file should be found to be locked', (done) => {
|
||||
lockFile(getFilePath('package.json'), (error: Error) => {
|
||||
expect(error).toBeNull();
|
||||
removeTempFile('package.json.lock');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('file should fail to be found to be locked', (done) => {
|
||||
lockFile(getFilePath('package.fail.json'), (error: Error) => {
|
||||
expect(error.message).toMatch(
|
||||
/ENOENT: no such file or directory, stat '(.*)package.fail.json'/
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('unlockFile', () => {
|
||||
test('file should to be found to be unLock', (done) => {
|
||||
unlockFile(getFilePath('package.json.lock'), (error: Error) => {
|
||||
expect(error).toBeNull();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('readFile', () => {
|
||||
test('read file with no options should to be found to be read it as string', (done) => {
|
||||
readFile(getFilePath('package.json'), {}, (error: Error, data: string) => {
|
||||
expect(error).toBeNull();
|
||||
expect(data).toMatchInlineSnapshot(`
|
||||
"{
|
||||
\\"name\\": \\"assets\\",
|
||||
\\"version\\": \\"0.0.1\\"
|
||||
}
|
||||
"
|
||||
`);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('read file with no options should to be found to be read it as object', (done) => {
|
||||
const options = {
|
||||
parse: true,
|
||||
};
|
||||
readFile(getFilePath('package.json'), options, (error: Error, data: string) => {
|
||||
expect(error).toBeNull();
|
||||
expect(data).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"name": "assets",
|
||||
"version": "0.0.1",
|
||||
}
|
||||
`);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('read file with options (parse) should to be not found to be read it', (done) => {
|
||||
const options = {
|
||||
parse: true,
|
||||
};
|
||||
readFile(getFilePath('package.fail.json'), options, (error: Error) => {
|
||||
expect(error.message).toMatch(
|
||||
/ENOENT: no such file or directory, open '(.*)package.fail.json'/
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('read file with options should be found to be read it and fails to be parsed', (done) => {
|
||||
const options = {
|
||||
parse: true,
|
||||
};
|
||||
readFile(getFilePath('wrong.package.json'), options, (error: Error) => {
|
||||
expect(error.message).toMatch(/Unexpected token } in JSON at position \d+/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('read file with options (parse, lock) should be found to be read it as object', (done) => {
|
||||
const options = {
|
||||
parse: true,
|
||||
lock: true,
|
||||
};
|
||||
readFile(getFilePath('package2.json'), options, (error: Error, data: string) => {
|
||||
expect(error).toBeNull();
|
||||
expect(data).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"name": "assets",
|
||||
"version": "0.0.1",
|
||||
}
|
||||
`);
|
||||
removeTempFile('package2.json.lock');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test(
|
||||
'read file with options (parse, lock) should be found to be read and ' + 'fails to be parsed',
|
||||
(done) => {
|
||||
const options = {
|
||||
parse: true,
|
||||
lock: true,
|
||||
};
|
||||
readFile(getFilePath('wrong.package.json'), options, (error: Error) => {
|
||||
expect(error.message).toMatch(/Unexpected token } in JSON at position \d+/);
|
||||
removeTempFile('wrong.package.json.lock');
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1,11 +1,8 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import { lockFile, readFile, unlockFile } from '../src/index';
|
||||
|
||||
interface Error {
|
||||
message: string;
|
||||
}
|
||||
import { lockFileNext, readFileNext, unlockFileNext } from '../src/index';
|
||||
import { statDir, statFile } from '../src/utils';
|
||||
|
||||
const getFilePath = (filename: string): string => {
|
||||
return path.resolve(__dirname, `assets/${filename}`);
|
||||
@@ -22,116 +19,110 @@ const removeTempFile = (filename: string): void => {
|
||||
|
||||
describe('testing locking', () => {
|
||||
describe('lockFile', () => {
|
||||
test('file should be found to be locked', (done) => {
|
||||
lockFile(getFilePath('package.json'), (error: Error) => {
|
||||
expect(error).toBeNull();
|
||||
removeTempFile('package.json.lock');
|
||||
done();
|
||||
});
|
||||
test('file should be found to be locked', async () => {
|
||||
await lockFileNext(getFilePath('package.json'));
|
||||
removeTempFile('package.json.lock');
|
||||
});
|
||||
|
||||
test('file should fail to be found to be locked', (done) => {
|
||||
lockFile(getFilePath('package.fail.json'), (error: Error) => {
|
||||
expect(error.message).toMatch(
|
||||
/ENOENT: no such file or directory, stat '(.*)package.fail.json'/
|
||||
);
|
||||
done();
|
||||
});
|
||||
test('file should fail to be found to be locked', async () => {
|
||||
await expect(lockFileNext(getFilePath('package.fail.json'))).rejects.toThrow(
|
||||
'ENOENT: no such file or directory'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('unlockFile', () => {
|
||||
test('file should to be found to be unLock', (done) => {
|
||||
unlockFile(getFilePath('package.json.lock'), (error: Error) => {
|
||||
expect(error).toBeNull();
|
||||
done();
|
||||
});
|
||||
test('file should to be found to be unLock', async () => {
|
||||
await expect(unlockFileNext(getFilePath('package.json.lock'))).resolves.toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('statDir', () => {
|
||||
test('error on missing dir', async () => {
|
||||
await expect(statDir(getFilePath('package.json/package.json'))).rejects.toThrow(
|
||||
'is not a directory'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('statFile', () => {
|
||||
test('error on missing dir', async () => {
|
||||
await expect(statFile(getFilePath(''))).rejects.toThrow('is not a file');
|
||||
});
|
||||
});
|
||||
|
||||
describe('readFile', () => {
|
||||
test('read file with no options should to be found to be read it as string', (done) => {
|
||||
readFile(getFilePath('package.json'), {}, (error: Error, data: string) => {
|
||||
expect(error).toBeNull();
|
||||
expect(data).toMatchInlineSnapshot(`
|
||||
test('read file with no options should to be found to be read it as string', async () => {
|
||||
const data = await readFileNext(getFilePath('package.json'), {});
|
||||
expect(data).toMatchInlineSnapshot(`
|
||||
"{
|
||||
\\"name\\": \\"assets\\",
|
||||
\\"version\\": \\"0.0.1\\"
|
||||
}
|
||||
"
|
||||
`);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('read file with no options should to be found to be read it as object', (done) => {
|
||||
test('read file with no options should to be found to be read it as object', async () => {
|
||||
const options = {
|
||||
parse: true,
|
||||
};
|
||||
readFile(getFilePath('package.json'), options, (error: Error, data: string) => {
|
||||
expect(error).toBeNull();
|
||||
expect(data).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"name": "assets",
|
||||
"version": "0.0.1",
|
||||
}
|
||||
`);
|
||||
done();
|
||||
});
|
||||
const data = await readFileNext(getFilePath('package.json'), options);
|
||||
expect(data).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"name": "assets",
|
||||
"version": "0.0.1",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('read file with options (parse) should to be not found to be read it', (done) => {
|
||||
test('read file with options (parse) should to be not found to be read it', async () => {
|
||||
const options = {
|
||||
parse: true,
|
||||
};
|
||||
readFile(getFilePath('package.fail.json'), options, (error: Error) => {
|
||||
expect(error.message).toMatch(
|
||||
/ENOENT: no such file or directory, open '(.*)package.fail.json'/
|
||||
);
|
||||
done();
|
||||
});
|
||||
await expect(readFileNext(getFilePath('package.fail.json'), options)).rejects.toThrow(
|
||||
/ENOENT: no such file or directory, open '(.*)package.fail.json'/
|
||||
);
|
||||
});
|
||||
|
||||
test('read file with options should be found to be read it and fails to be parsed', (done) => {
|
||||
test('read file with options should be found to be read it and fails to be parsed', async () => {
|
||||
const options = {
|
||||
parse: true,
|
||||
};
|
||||
readFile(getFilePath('wrong.package.json'), options, (error: Error) => {
|
||||
expect(error.message).toMatch(/Unexpected token } in JSON at position \d+/);
|
||||
done();
|
||||
});
|
||||
await expect(readFileNext(getFilePath('wrong.package.json'), options)).rejects.toThrow(
|
||||
'Unexpected token } in JSON at position 44'
|
||||
);
|
||||
});
|
||||
|
||||
test('read file with options (parse, lock) should be found to be read it as object', (done) => {
|
||||
test('read file with options (parse, lock) should be found to be read it as object', async () => {
|
||||
const options = {
|
||||
parse: true,
|
||||
lock: true,
|
||||
};
|
||||
readFile(getFilePath('package2.json'), options, (error: Error, data: string) => {
|
||||
expect(error).toBeNull();
|
||||
expect(data).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"name": "assets",
|
||||
"version": "0.0.1",
|
||||
}
|
||||
`);
|
||||
removeTempFile('package2.json.lock');
|
||||
done();
|
||||
});
|
||||
await expect(
|
||||
readFileNext(getFilePath('package2.json'), options)
|
||||
).resolves.toMatchInlineSnapshot(
|
||||
`
|
||||
Object {
|
||||
"name": "assets",
|
||||
"version": "0.0.1",
|
||||
}
|
||||
`
|
||||
);
|
||||
removeTempFile('package2.json.lock');
|
||||
});
|
||||
|
||||
test(
|
||||
'read file with options (parse, lock) should be found to be read and ' + 'fails to be parsed',
|
||||
(done) => {
|
||||
async () => {
|
||||
const options = {
|
||||
parse: true,
|
||||
lock: true,
|
||||
};
|
||||
readFile(getFilePath('wrong.package.json'), options, (error: Error) => {
|
||||
expect(error.message).toMatch(/Unexpected token } in JSON at position \d+/);
|
||||
removeTempFile('wrong.package.json.lock');
|
||||
done();
|
||||
});
|
||||
await expect(readFileNext(getFilePath('wrong.package.json'), options)).rejects.toThrow(
|
||||
'Unexpected token } in JSON at position 44'
|
||||
);
|
||||
removeTempFile('wrong.package.json.lock');
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,5 +1,23 @@
|
||||
# @verdaccio/fastify-migration
|
||||
|
||||
## 6.0.0-6-next.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [b78f3525]
|
||||
- @verdaccio/logger@6.0.0-6-next.10
|
||||
- @verdaccio/auth@6.0.0-6-next.18
|
||||
- @verdaccio/store@6.0.0-6-next.19
|
||||
|
||||
## 6.0.0-6-next.18
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [730b5d8c]
|
||||
- @verdaccio/logger@6.0.0-6-next.9
|
||||
- @verdaccio/auth@6.0.0-6-next.17
|
||||
- @verdaccio/store@6.0.0-6-next.18
|
||||
|
||||
## 6.0.0-6-next.17
|
||||
|
||||
### Major Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@verdaccio/fastify-migration",
|
||||
"version": "6.0.0-6-next.17",
|
||||
"version": "6.0.0-6-next.19",
|
||||
"description": "Fastify server migration package",
|
||||
"keywords": [
|
||||
"private",
|
||||
@@ -36,24 +36,24 @@
|
||||
"dependencies": {
|
||||
"@verdaccio/core": "workspace:6.0.0-6-next.4",
|
||||
"@verdaccio/config": "workspace:6.0.0-6-next.12",
|
||||
"@verdaccio/auth": "workspace:6.0.0-6-next.16",
|
||||
"@verdaccio/logger": "workspace:6.0.0-6-next.8",
|
||||
"@verdaccio/store": "workspace:6.0.0-6-next.17",
|
||||
"@verdaccio/auth": "workspace:6.0.0-6-next.18",
|
||||
"@verdaccio/logger": "workspace:6.0.0-6-next.10",
|
||||
"@verdaccio/store": "workspace:6.0.0-6-next.19",
|
||||
"@verdaccio/tarball": "workspace:11.0.0-6-next.11",
|
||||
"@verdaccio/utils": "workspace:6.0.0-6-next.10",
|
||||
"@verdaccio/readme": "workspace:11.0.0-6-next.4",
|
||||
"abortcontroller-polyfill": "1.7.3",
|
||||
"core-js": "3.17.2",
|
||||
"core-js": "3.20.3",
|
||||
"debug": "4.3.3",
|
||||
"fastify": "3.24.1",
|
||||
"fastify": "3.27.0",
|
||||
"fastify-plugin": "3.0.0",
|
||||
"lodash": "4.17.21",
|
||||
"semver": "7.3.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "16.11.12",
|
||||
"@types/node": "16.11.21",
|
||||
"@verdaccio/types": "workspace:11.0.0-6-next.10",
|
||||
"ts-node": "10.2.1"
|
||||
"ts-node": "10.4.0"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "rimraf ./build",
|
||||
|
||||
@@ -12,7 +12,7 @@ async function manifestRoute(fastify: FastifyInstance) {
|
||||
const { packageName } = request.params;
|
||||
const storage = fastify.storage;
|
||||
debug('pkg name %s ', packageName);
|
||||
const data = await storage?.getPackageNext({
|
||||
const data = await storage?.getPackageByOptions({
|
||||
name: packageName,
|
||||
req: request.raw,
|
||||
uplinksLook: true,
|
||||
@@ -30,7 +30,7 @@ async function manifestRoute(fastify: FastifyInstance) {
|
||||
const { packageName, version } = request.params;
|
||||
const storage = fastify.storage;
|
||||
debug('pkg name %s, with version / tag: %s ', packageName, version);
|
||||
const data = await storage?.getPackageNext({
|
||||
const data = await storage?.getPackageByOptions({
|
||||
name: packageName,
|
||||
req: request.raw,
|
||||
version,
|
||||
|
||||
30
packages/core/server/src/endpoints/publish.ts
Normal file
30
packages/core/server/src/endpoints/publish.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
// import buildDebug from 'debug';
|
||||
// import { FastifyInstance } from 'fastify';
|
||||
|
||||
// import { Package, Version } from '@verdaccio/types';
|
||||
|
||||
// const debug = buildDebug('verdaccio:web:api:sidebar');
|
||||
// export type $SidebarPackage = Package & { latest: Version };
|
||||
|
||||
// async function manifestRoute(fastify: FastifyInstance) {
|
||||
// // TODO: review // :_rev?/:revision?
|
||||
// fastify.put('/:packageName', async (request) => {
|
||||
// // @ts-ignore
|
||||
// const { packageName } = request.params;
|
||||
// const storage = fastify.storage;
|
||||
// debug('pkg name %s ', packageName);
|
||||
// // const data = await storage?.getPackageNext({
|
||||
// // name: packageName,
|
||||
// // req: request.raw,
|
||||
// // uplinksLook: true,
|
||||
// // requestOptions: {
|
||||
// // protocol: request.protocol,
|
||||
// // headers: request.headers as any,
|
||||
// // host: request.hostname,
|
||||
// // },
|
||||
// // });
|
||||
// // return data;
|
||||
// });
|
||||
// }
|
||||
|
||||
// export default manifestRoute;
|
||||
@@ -42,7 +42,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@verdaccio/types": "workspace:11.0.0-6-next.10",
|
||||
"node-mocks-http": "1.10.1"
|
||||
"node-mocks-http": "1.11.0"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "rimraf ./build",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import _ from 'lodash';
|
||||
|
||||
import { Package } from '@verdaccio/types';
|
||||
import { Package, Version } from '@verdaccio/types';
|
||||
import { RequestOptions } from '@verdaccio/url';
|
||||
|
||||
import { getLocalRegistryTarballUri } from './getLocalRegistryTarballUri';
|
||||
@@ -17,19 +17,47 @@ export function convertDistRemoteToLocalTarballUrls(
|
||||
request: RequestOptions,
|
||||
urlPrefix: string | void
|
||||
): Package {
|
||||
const { name, versions } = pkg;
|
||||
const convertedPkg = { ...pkg };
|
||||
const convertedVersions = versions;
|
||||
for (const ver in pkg.versions) {
|
||||
if (Object.prototype.hasOwnProperty.call(pkg.versions, ver)) {
|
||||
const distName = pkg.versions[ver].dist;
|
||||
|
||||
if (_.isNull(distName) === false && _.isNull(distName.tarball) === false) {
|
||||
distName.tarball = getLocalRegistryTarballUri(
|
||||
distName.tarball,
|
||||
pkg.name,
|
||||
request,
|
||||
urlPrefix
|
||||
);
|
||||
}
|
||||
const version = versions[ver];
|
||||
convertedVersions[ver] = convertDistVersionToLocalTarballsUrl(
|
||||
name,
|
||||
version,
|
||||
request,
|
||||
urlPrefix
|
||||
);
|
||||
}
|
||||
}
|
||||
return pkg;
|
||||
|
||||
return {
|
||||
...convertedPkg,
|
||||
versions: convertedVersions,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert single Version disst tarball
|
||||
* @param name
|
||||
* @param version
|
||||
* @param request
|
||||
* @param urlPrefix
|
||||
* @returns
|
||||
*/
|
||||
export function convertDistVersionToLocalTarballsUrl(name, version: Version, request, urlPrefix) {
|
||||
const distName = version.dist;
|
||||
|
||||
if (_.isNull(distName) === false && _.isNull(distName.tarball) === false) {
|
||||
return {
|
||||
...version,
|
||||
dist: {
|
||||
...distName,
|
||||
tarball: getLocalRegistryTarballUri(distName.tarball, name, request, urlPrefix),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { RequestOptions } from '@verdaccio/url';
|
||||
|
||||
export { convertDistRemoteToLocalTarballUrls } from './convertDistRemoteToLocalTarballUrls';
|
||||
export {
|
||||
convertDistRemoteToLocalTarballUrls,
|
||||
convertDistVersionToLocalTarballsUrl,
|
||||
} from './convertDistRemoteToLocalTarballUrls';
|
||||
export { getLocalRegistryTarballUri } from './getLocalRegistryTarballUri';
|
||||
|
||||
export { RequestOptions };
|
||||
|
||||
25
packages/core/types/index.d.ts
vendored
25
packages/core/types/index.d.ts
vendored
@@ -178,6 +178,9 @@ declare module '@verdaccio/types' {
|
||||
[key: string]: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use Manifest instead
|
||||
*/
|
||||
interface Package {
|
||||
_id?: string;
|
||||
name: string;
|
||||
@@ -192,6 +195,20 @@ declare module '@verdaccio/types' {
|
||||
_rev: string;
|
||||
}
|
||||
|
||||
interface Manifest {
|
||||
_id?: string;
|
||||
name: string;
|
||||
versions: Versions;
|
||||
'dist-tags': GenericBody;
|
||||
time: GenericBody;
|
||||
readme?: string;
|
||||
users?: PackageUsers;
|
||||
_distfiles: DistFiles;
|
||||
_attachments: AttachMents;
|
||||
_uplinks: UpLinks;
|
||||
_rev: string;
|
||||
}
|
||||
|
||||
interface IUploadTarball extends PassThrough {
|
||||
abort(): void;
|
||||
done(): void;
|
||||
@@ -477,6 +494,7 @@ declare module '@verdaccio/types' {
|
||||
createPackage(pkgName: string, value: Package, cb: CallbackAction): void;
|
||||
deletePackage(fileName: string): Promise<void>;
|
||||
removePackage(): Promise<void>;
|
||||
// @deprecated
|
||||
updatePackage(
|
||||
pkgFileName: string,
|
||||
updateHandler: StorageUpdateCallback,
|
||||
@@ -484,7 +502,14 @@ declare module '@verdaccio/types' {
|
||||
transformPackage: PackageTransformer,
|
||||
onEnd: Callback
|
||||
): void;
|
||||
// @deprecated
|
||||
savePackage(fileName: string, json: Package, callback: CallbackAction): void;
|
||||
// next packages migration (this list is meant to replace the callback parent functions)
|
||||
updatePackageNext(
|
||||
packageName: string,
|
||||
handleUpdate: (manifest: Package) => Promise<Package>
|
||||
): Promise<Package>;
|
||||
savePackageNext(name: string, value: Package): Promise<void>;
|
||||
}
|
||||
|
||||
interface TarballActions {
|
||||
|
||||
@@ -38,8 +38,8 @@
|
||||
"build": "exit 0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "14.6.0",
|
||||
"tsd": "0.18.0"
|
||||
"@types/node": "16.11.21",
|
||||
"tsd": "0.19.1"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@verdaccio/types": "workspace:11.0.0-6-next.10",
|
||||
"node-mocks-http": "1.10.1"
|
||||
"node-mocks-http": "1.11.0"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "rimraf ./build",
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
# @verdaccio/hooks
|
||||
|
||||
## 6.0.0-6-next.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [b78f3525]
|
||||
- @verdaccio/logger@6.0.0-6-next.10
|
||||
|
||||
## 6.0.0-6-next.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [730b5d8c]
|
||||
- @verdaccio/logger@6.0.0-6-next.9
|
||||
|
||||
## 6.0.0-6-next.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@verdaccio/hooks",
|
||||
"version": "6.0.0-6-next.10",
|
||||
"version": "6.0.0-6-next.12",
|
||||
"description": "loaders logic",
|
||||
"main": "./build/index.js",
|
||||
"types": "build/index.d.ts",
|
||||
@@ -31,16 +31,16 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@verdaccio/core": "workspace:6.0.0-6-next.4",
|
||||
"@verdaccio/logger": "workspace:6.0.0-6-next.8",
|
||||
"core-js": "3.17.2",
|
||||
"@verdaccio/logger": "workspace:6.0.0-6-next.10",
|
||||
"core-js": "3.20.3",
|
||||
"debug": "4.3.3",
|
||||
"handlebars": "4.7.7",
|
||||
"undici": "4.7.3",
|
||||
"undici": "4.12.2",
|
||||
"undici-fetch": "1.0.0-rc.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "16.11.12",
|
||||
"@verdaccio/auth": "workspace:6.0.0-6-next.16",
|
||||
"@types/node": "16.11.21",
|
||||
"@verdaccio/auth": "workspace:6.0.0-6-next.18",
|
||||
"@verdaccio/config": "workspace:6.0.0-6-next.12",
|
||||
"@verdaccio/types": "workspace:11.0.0-6-next.10"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
# @verdaccio/loaders
|
||||
|
||||
## 6.0.0-6-next.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [b78f3525]
|
||||
- @verdaccio/logger@6.0.0-6-next.10
|
||||
|
||||
## 6.0.0-6-next.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [730b5d8c]
|
||||
- @verdaccio/logger@6.0.0-6-next.9
|
||||
|
||||
## 6.0.0-6-next.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@verdaccio/loaders",
|
||||
"version": "6.0.0-6-next.8",
|
||||
"version": "6.0.0-6-next.10",
|
||||
"description": "loaders logic",
|
||||
"main": "./build/index.js",
|
||||
"types": "build/index.d.ts",
|
||||
@@ -13,7 +13,7 @@
|
||||
"url": "https://github.com/verdaccio/verdaccio"
|
||||
},
|
||||
"dependencies": {
|
||||
"@verdaccio/logger": "workspace:6.0.0-6-next.8",
|
||||
"@verdaccio/logger": "workspace:6.0.0-6-next.10",
|
||||
"debug": "4.3.3",
|
||||
"lodash": "4.17.21"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @verdaccio/logger-prettify
|
||||
|
||||
## 6.0.0-6-next.6
|
||||
|
||||
### Major Changes
|
||||
|
||||
- 730b5d8c: feat: upgrade to pino v7
|
||||
|
||||
## 6.0.0-6-next.5
|
||||
|
||||
### Minor Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@verdaccio/logger-prettify",
|
||||
"version": "6.0.0-6-next.5",
|
||||
"version": "6.0.0-6-next.6",
|
||||
"description": "logger",
|
||||
"main": "./build/index.js",
|
||||
"types": "build/index.d.ts",
|
||||
@@ -46,8 +46,7 @@
|
||||
"prettier-bytes": "1.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/pino": "^6.3.3",
|
||||
"pino": "6.13.3"
|
||||
"pino": "7.6.4"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# @verdaccio/logger
|
||||
|
||||
## 6.0.0-6-next.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- b78f3525: Fix re-opening log files using SIGUSR2
|
||||
|
||||
## 6.0.0-6-next.9
|
||||
|
||||
### Major Changes
|
||||
|
||||
- 730b5d8c: feat: upgrade to pino v7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [730b5d8c]
|
||||
- @verdaccio/logger-prettify@6.0.0-6-next.6
|
||||
|
||||
## 6.0.0-6-next.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@verdaccio/logger",
|
||||
"version": "6.0.0-6-next.8",
|
||||
"version": "6.0.0-6-next.10",
|
||||
"description": "logger",
|
||||
"main": "./build/index.js",
|
||||
"types": "build/index.d.ts",
|
||||
@@ -40,13 +40,12 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@verdaccio/core": "workspace:6.0.0-6-next.4",
|
||||
"@verdaccio/logger-prettify": "workspace:6.0.0-6-next.5",
|
||||
"@verdaccio/logger-prettify": "workspace:6.0.0-6-next.6",
|
||||
"debug": "4.3.3",
|
||||
"lodash": "4.17.21",
|
||||
"pino": "6.13.3"
|
||||
"pino": "7.6.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/pino": "6.3.12",
|
||||
"@verdaccio/types": "workspace:11.0.0-6-next.10"
|
||||
},
|
||||
"funding": {
|
||||
|
||||
@@ -141,7 +141,9 @@ export function setup(options: LoggerConfig | LoggerConfigItem = DEFAULT_LOGGER_
|
||||
const pinoConfig = { level: loggerConfig.level };
|
||||
if (loggerConfig.type === 'file') {
|
||||
debug('logging file enabled');
|
||||
logger = createLogger(pinoConfig, pino.destination(loggerConfig.path), loggerConfig.format);
|
||||
const destination = pino.destination(loggerConfig.path);
|
||||
process.on('SIGUSR2', () => destination.reopen());
|
||||
logger = createLogger(pinoConfig, destination, loggerConfig.format);
|
||||
} else if (loggerConfig.type === 'rotating-file') {
|
||||
warningUtils.emit(warningUtils.Codes.VERWAR003);
|
||||
debug('logging stdout enabled');
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
# @verdaccio/middleware
|
||||
|
||||
## 6.0.0-6-next.18
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [b78f3525]
|
||||
- @verdaccio/logger@6.0.0-6-next.10
|
||||
- @verdaccio/auth@6.0.0-6-next.18
|
||||
|
||||
## 6.0.0-6-next.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [730b5d8c]
|
||||
- @verdaccio/logger@6.0.0-6-next.9
|
||||
- @verdaccio/auth@6.0.0-6-next.17
|
||||
|
||||
## 6.0.0-6-next.16
|
||||
|
||||
### Minor Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@verdaccio/middleware",
|
||||
"version": "6.0.0-6-next.16",
|
||||
"version": "6.0.0-6-next.18",
|
||||
"description": "loaders logic",
|
||||
"main": "./build/index.js",
|
||||
"types": "build/index.d.ts",
|
||||
@@ -40,9 +40,9 @@
|
||||
"dependencies": {
|
||||
"debug": "4.3.3",
|
||||
"body-parser": "1.19.1",
|
||||
"@verdaccio/auth": "workspace:6.0.0-6-next.16",
|
||||
"@verdaccio/auth": "workspace:6.0.0-6-next.18",
|
||||
"@verdaccio/core": "workspace:6.0.0-6-next.4",
|
||||
"@verdaccio/logger": "workspace:6.0.0-6-next.8",
|
||||
"@verdaccio/logger": "workspace:6.0.0-6-next.10",
|
||||
"@verdaccio/utils": "workspace:6.0.0-6-next.10",
|
||||
"lodash": "4.17.21"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# @verdaccio/node-api
|
||||
|
||||
## 6.0.0-6-next.27
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [b78f3525]
|
||||
- @verdaccio/logger@6.0.0-6-next.10
|
||||
- @verdaccio/server@6.0.0-6-next.26
|
||||
|
||||
## 6.0.0-6-next.26
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [048ac95e]
|
||||
- Updated dependencies [730b5d8c]
|
||||
- @verdaccio/server@6.0.0-6-next.25
|
||||
- @verdaccio/logger@6.0.0-6-next.9
|
||||
|
||||
## 6.0.0-6-next.25
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@verdaccio/node-api",
|
||||
"version": "6.0.0-6-next.25",
|
||||
"version": "6.0.0-6-next.27",
|
||||
"description": "node API",
|
||||
"main": "build/index.js",
|
||||
"types": "build/index.d.ts",
|
||||
@@ -41,19 +41,19 @@
|
||||
"dependencies": {
|
||||
"@verdaccio/core": "workspace:6.0.0-6-next.4",
|
||||
"@verdaccio/config": "workspace:6.0.0-6-next.12",
|
||||
"@verdaccio/logger": "workspace:6.0.0-6-next.8",
|
||||
"@verdaccio/server": "workspace:6.0.0-6-next.24",
|
||||
"core-js": "3.17.2",
|
||||
"@verdaccio/logger": "workspace:6.0.0-6-next.10",
|
||||
"@verdaccio/server": "workspace:6.0.0-6-next.26",
|
||||
"core-js": "3.20.3",
|
||||
"debug": "4.3.3",
|
||||
"lodash": "4.17.21"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "16.11.12",
|
||||
"@types/node": "16.11.21",
|
||||
"@verdaccio/mock": "workspace:6.0.0-6-next.13",
|
||||
"@verdaccio/types": "workspace:11.0.0-6-next.10",
|
||||
"jest-mock-process": "1.4.1",
|
||||
"selfsigned": "1.10.11",
|
||||
"supertest": "6.1.6"
|
||||
"selfsigned": "1.10.14",
|
||||
"supertest": "6.2.2"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
||||
@@ -31,15 +31,15 @@
|
||||
"npm": ">=6"
|
||||
},
|
||||
"dependencies": {
|
||||
"express": "4.17.1",
|
||||
"express": "4.17.2",
|
||||
"body-parser": "1.19.1",
|
||||
"https-proxy-agent": "5.0.0",
|
||||
"node-fetch": "3.0.0-beta.6-exportfix"
|
||||
"node-fetch": "cjs"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@verdaccio/types": "workspace:11.0.0-6-next.10",
|
||||
"nock": "12.0.3",
|
||||
"supertest": "6.1.6"
|
||||
"supertest": "6.2.2"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "rimraf ./build",
|
||||
|
||||
@@ -314,7 +314,7 @@ export default class S3PackageManager implements ILocalPackageManager {
|
||||
const error: HttpError = convertS3Error(err);
|
||||
this.logger.error(
|
||||
{ error: error.message },
|
||||
`s3: [S3PackageManager writeTarball managedUpload send]
|
||||
`s3: [S3PackageManager writeTarball managedUpload send]
|
||||
emit error @{error}`
|
||||
);
|
||||
|
||||
@@ -363,7 +363,7 @@ export default class S3PackageManager implements ILocalPackageManager {
|
||||
} else {
|
||||
this.logger.trace(
|
||||
{ name },
|
||||
`s3: [S3PackageManager writeTarball uploadStream] streamEnded
|
||||
`s3: [S3PackageManager writeTarball uploadStream] streamEnded
|
||||
false emit end @{name}`
|
||||
);
|
||||
uploadStream.on('end', onEnd);
|
||||
@@ -386,7 +386,7 @@ export default class S3PackageManager implements ILocalPackageManager {
|
||||
} finally {
|
||||
this.logger.debug(
|
||||
{ name, baseS3Params },
|
||||
`s3: [S3PackageManager writeTarball uploadStream abort]
|
||||
`s3: [S3PackageManager writeTarball uploadStream abort]
|
||||
s3.deleteObject @{name}/@baseS3Params`
|
||||
);
|
||||
|
||||
@@ -495,4 +495,24 @@ export default class S3PackageManager implements ILocalPackageManager {
|
||||
|
||||
return readTarballStream;
|
||||
}
|
||||
|
||||
// migration pending
|
||||
public async updatePackageNext(
|
||||
packageName: string,
|
||||
handleUpdate: (manifest: Package) => Promise<Package>
|
||||
): Promise<Package> {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(packageName);
|
||||
// @ts-expect-error
|
||||
await handleUpdate({});
|
||||
// @ts-expect-error
|
||||
return Promise.resolve({});
|
||||
}
|
||||
|
||||
public async savePackageNext(name: string, value: Package): Promise<void> {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(name);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,6 +406,26 @@ class GoogleCloudStorageHandler implements IPackageStorageManager {
|
||||
.pipe(localReadStream);
|
||||
return localReadStream;
|
||||
}
|
||||
|
||||
// migration pending
|
||||
public async updatePackageNext(
|
||||
packageName: string,
|
||||
handleUpdate: (manifest: Package) => Promise<Package>
|
||||
): Promise<Package> {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(packageName);
|
||||
// @ts-expect-error
|
||||
await handleUpdate({});
|
||||
// @ts-expect-error
|
||||
return Promise.resolve({});
|
||||
}
|
||||
|
||||
public async savePackageNext(name: string, value: Package): Promise<void> {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(name);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(value);
|
||||
}
|
||||
}
|
||||
|
||||
export default GoogleCloudStorageHandler;
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
"@verdaccio/file-locking": "workspace:11.0.0-6-next.4",
|
||||
"apache-md5": "1.1.7",
|
||||
"bcryptjs": "2.4.3",
|
||||
"core-js": "3.17.2",
|
||||
"core-js": "3.20.3",
|
||||
"http-errors": "1.8.1",
|
||||
"unix-crypt-td-js": "1.1.4"
|
||||
},
|
||||
|
||||
@@ -209,6 +209,9 @@ describe('HTPasswd', () => {
|
||||
test('reload should fails on check file', (done) => {
|
||||
jest.doMock('fs', () => {
|
||||
return {
|
||||
readFile: (_name, callback): void => {
|
||||
callback(new Error('stat error'), null);
|
||||
},
|
||||
stat: (_name, callback): void => {
|
||||
callback(new Error('stat error'), null);
|
||||
},
|
||||
@@ -228,6 +231,9 @@ describe('HTPasswd', () => {
|
||||
test('reload times match', (done) => {
|
||||
jest.doMock('fs', () => {
|
||||
return {
|
||||
readFile: (_name, callback): void => {
|
||||
callback(new Error('stat error'), null);
|
||||
},
|
||||
stat: (_name, callback): void => {
|
||||
callback(null, {
|
||||
mtime: null,
|
||||
|
||||
@@ -40,10 +40,10 @@
|
||||
"@verdaccio/core": "workspace:6.0.0-6-next.4",
|
||||
"@verdaccio/file-locking": "workspace:11.0.0-6-next.4",
|
||||
"@verdaccio/streams": "workspace:11.0.0-6-next.5",
|
||||
"async": "3.2.1",
|
||||
"core-js": "3.17.2",
|
||||
"async": "3.2.3",
|
||||
"core-js": "3.20.3",
|
||||
"debug": "4.3.3",
|
||||
"globby": "11.0.4",
|
||||
"globby": "11.1.0",
|
||||
"lockfile": "1.0.4",
|
||||
"sanitize-filename": "1.6.3",
|
||||
"lodash": "4.17.21",
|
||||
|
||||
@@ -1,17 +1,24 @@
|
||||
import fs from 'fs';
|
||||
import { promisify } from 'util';
|
||||
import fs from 'fs/promises';
|
||||
|
||||
// FUTURE: when v15 is min replace by fs/promises
|
||||
const readFile = promisify(fs.readFile);
|
||||
const mkdirPromise = promisify(fs.mkdir);
|
||||
const writeFilePromise = promisify(fs.writeFile);
|
||||
const readdirPromise = promisify(fs.readdir);
|
||||
const statPromise = promisify(fs.stat);
|
||||
const unlinkPromise = promisify(fs.unlink);
|
||||
const rmdirPromise = promisify(fs.rmdir);
|
||||
const readFile = fs.readFile;
|
||||
const mkdirPromise = fs.mkdir;
|
||||
const writeFilePromise = fs.writeFile;
|
||||
const readdirPromise = fs.readdir;
|
||||
const statPromise = fs.stat;
|
||||
const unlinkPromise = fs.unlink;
|
||||
const rmdirPromise = fs.rmdir;
|
||||
const renamePromise = fs.rename;
|
||||
|
||||
export const readFilePromise = async (path) => {
|
||||
return await readFile(path, 'utf8');
|
||||
};
|
||||
|
||||
export { mkdirPromise, writeFilePromise, readdirPromise, statPromise, unlinkPromise, rmdirPromise };
|
||||
export {
|
||||
renamePromise,
|
||||
mkdirPromise,
|
||||
writeFilePromise,
|
||||
readdirPromise,
|
||||
statPromise,
|
||||
unlinkPromise,
|
||||
rmdirPromise,
|
||||
};
|
||||
|
||||
@@ -5,11 +5,18 @@ import _ from 'lodash';
|
||||
import path from 'path';
|
||||
|
||||
import { VerdaccioError, errorUtils } from '@verdaccio/core';
|
||||
import { readFile, unlockFile } from '@verdaccio/file-locking';
|
||||
import { readFile, readFileNext, unlockFile, unlockFileNext } from '@verdaccio/file-locking';
|
||||
import { ReadTarball, UploadTarball } from '@verdaccio/streams';
|
||||
import { Callback, ILocalPackageManager, IUploadTarball, Logger, Package } from '@verdaccio/types';
|
||||
|
||||
import { readFilePromise, rmdirPromise, unlinkPromise } from './fs';
|
||||
import {
|
||||
mkdirPromise,
|
||||
readFilePromise,
|
||||
renamePromise,
|
||||
rmdirPromise,
|
||||
unlinkPromise,
|
||||
writeFilePromise,
|
||||
} from './fs';
|
||||
|
||||
export const fileExist = 'EEXISTS';
|
||||
export const noSuchFile = 'ENOENT';
|
||||
@@ -54,6 +61,21 @@ const renameTmp = function (src, dst, _cb): void {
|
||||
});
|
||||
};
|
||||
|
||||
export async function renameTmpNext(src: string, dst: string): Promise<void> {
|
||||
if (process.platform !== 'win32') {
|
||||
await renamePromise(src, dst);
|
||||
await unlinkPromise(src);
|
||||
} else {
|
||||
// TODO: review if this still the cases
|
||||
// windows can't remove opened file,
|
||||
// but it seem to be able to rename it
|
||||
const tmp = tempFile(dst);
|
||||
await renamePromise(dst, tmp);
|
||||
await renamePromise(src, dst);
|
||||
await unlinkPromise(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
export type ILocalFSPackageManager = ILocalPackageManager & { path: string };
|
||||
|
||||
export default class LocalFS implements ILocalFSPackageManager {
|
||||
@@ -110,6 +132,7 @@ export default class LocalFS implements ILocalFSPackageManager {
|
||||
onEnd(..._args);
|
||||
}
|
||||
};
|
||||
// //////////////////////////////////////
|
||||
|
||||
if (!err) {
|
||||
locked = true;
|
||||
@@ -136,6 +159,74 @@ export default class LocalFS implements ILocalFSPackageManager {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This function allows to update the package
|
||||
* This function handle the update package logic, for this plugin
|
||||
* we need to lock/unlock handlers for thread-safely and then apply
|
||||
* the `handleUpdate` and return the result.
|
||||
*
|
||||
* The lock could fail on several steps so we need to ensure the
|
||||
* file does not get locked if the whole process fails.
|
||||
*
|
||||
Algorithm:
|
||||
1. lock package.json for writing
|
||||
2. read package.json
|
||||
3. apply external update package handler
|
||||
4. return manifest (write is being hanlded into the core)
|
||||
5. rename package.json.tmp package.json
|
||||
* @param {*} packageName
|
||||
* The update package handler could be different based
|
||||
* on the action and handled into the core.
|
||||
* @param {*} handleUpdate
|
||||
*/
|
||||
public async updatePackageNext(
|
||||
packageName: string,
|
||||
handleUpdate: (manifest: Package) => Promise<Package>
|
||||
): Promise<Package> {
|
||||
// this plugin lock files on write, we handle all possible scenarios
|
||||
let locked = false;
|
||||
let manifestUpdated: Package;
|
||||
try {
|
||||
const manifest = await this._lockAndReadJSONNext(packageJSONFileName);
|
||||
locked = true;
|
||||
manifestUpdated = await handleUpdate(manifest);
|
||||
if (locked) {
|
||||
debug('unlock %s', packageJSONFileName);
|
||||
await this._unlockJSONNext(packageJSONFileName);
|
||||
this.logger.debug({ packageName }, 'the package @{packageName} has been updated');
|
||||
return manifestUpdated;
|
||||
} else {
|
||||
this.logger.debug({ packageName }, 'the package @{packageName} has been updated');
|
||||
return manifestUpdated;
|
||||
}
|
||||
} catch (err: any) {
|
||||
// we ensure lock the file
|
||||
this.logger.error(
|
||||
{ err, packageName },
|
||||
'error @{err.message} on update package @{packageName}'
|
||||
);
|
||||
if (locked) {
|
||||
// eslint-disable-next-line no-useless-catch
|
||||
try {
|
||||
await this._unlockJSONNext(packageJSONFileName);
|
||||
// after unlock bubble up error.
|
||||
throw err;
|
||||
} catch (err: any) {
|
||||
// unlock could fail, we bubble up error
|
||||
throw errorUtils.getInternalError('resource temporarily unavailable');
|
||||
}
|
||||
} else {
|
||||
if (err.code === resourceNotAvailable) {
|
||||
throw errorUtils.getInternalError('resource temporarily unavailable');
|
||||
} else if (err.code === noSuchFile) {
|
||||
throw errorUtils.getNotFound();
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async deletePackage(packageName: string): Promise<void> {
|
||||
debug('delete a file/package %o', packageName);
|
||||
|
||||
@@ -160,6 +251,12 @@ export default class LocalFS implements ILocalFSPackageManager {
|
||||
this._writeFile(this._getStorage(packageJSONFileName), this._convertToString(value), cb);
|
||||
}
|
||||
|
||||
public async savePackageNext(name: string, value: Package): Promise<void> {
|
||||
debug('save a package %o', name);
|
||||
|
||||
await this.writeFileNext(this._getStorage(packageJSONFileName), this._convertToString(value));
|
||||
}
|
||||
|
||||
public async readPackageNext(name: string): Promise<Package> {
|
||||
debug('read a package %o', name);
|
||||
try {
|
||||
@@ -371,6 +468,35 @@ export default class LocalFS implements ILocalFSPackageManager {
|
||||
});
|
||||
}
|
||||
|
||||
private async writeTempFileAndRename(dest: string, fileContent: string): Promise<any> {
|
||||
const tempFilePath = tempFile(dest);
|
||||
try {
|
||||
// write file on temp location
|
||||
await writeFilePromise(tempFilePath, fileContent);
|
||||
debug('creating a new file:: %o', dest);
|
||||
// rename tmp file to original
|
||||
await renameTmpNext(tempFilePath, dest);
|
||||
} catch (err: any) {
|
||||
debug('error on write the file: %o', dest);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
private async writeFileNext(destiny: string, fileContent: string): Promise<void> {
|
||||
try {
|
||||
await this.writeTempFileAndRename(destiny, fileContent);
|
||||
} catch (err: any) {
|
||||
if (err && err.code === noSuchFile) {
|
||||
// if fails, we create the folder for the package
|
||||
await mkdirPromise(path.dirname(destiny), { recursive: true });
|
||||
// we try again create the temp file
|
||||
await this.writeTempFileAndRename(destiny, fileContent);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private _lockAndReadJSON(name: string, cb: Function): void {
|
||||
const fileName: string = this._getStorage(name);
|
||||
debug('lock and read a file %o', fileName);
|
||||
@@ -397,4 +523,25 @@ export default class LocalFS implements ILocalFSPackageManager {
|
||||
private _unlockJSON(name: string, cb: Function): void {
|
||||
unlockFile(this._getStorage(name), cb);
|
||||
}
|
||||
|
||||
private async _lockAndReadJSONNext(name: string): Promise<Package> {
|
||||
const fileName: string = this._getStorage(name);
|
||||
debug('lock and read a file %o', fileName);
|
||||
try {
|
||||
const data = await readFileNext<Package>(fileName, {
|
||||
lock: true,
|
||||
parse: true,
|
||||
});
|
||||
return data;
|
||||
} catch (err) {
|
||||
this.logger.error({ err }, 'error on lock file @{err.message}');
|
||||
debug('error on lock and read json for file: %o', name);
|
||||
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
private async _unlockJSONNext(name: string): Promise<void> {
|
||||
await unlockFileNext(this._getStorage(name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
"@verdaccio/streams": "workspace:11.0.0-6-next.5",
|
||||
"memory-fs": "0.5.0",
|
||||
"debug": "4.3.3",
|
||||
"memfs": "3.2.4"
|
||||
"memfs": "3.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@verdaccio/types": "workspace:11.0.0-6-next.10"
|
||||
|
||||
@@ -193,6 +193,23 @@ class MemoryHandler implements IPackageStorageManager {
|
||||
debug('get storage %o', name);
|
||||
return this.data[name];
|
||||
}
|
||||
|
||||
// migration pending
|
||||
public async updatePackageNext(
|
||||
packageName: string,
|
||||
handleUpdate: (manifest: Package) => Promise<Package>
|
||||
): Promise<Package> {
|
||||
debug(packageName);
|
||||
// @ts-expect-error
|
||||
await handleUpdate({});
|
||||
// @ts-expect-error
|
||||
return Promise.resolve({});
|
||||
}
|
||||
|
||||
public async savePackageNext(name: string, value: Package): Promise<void> {
|
||||
debug(name);
|
||||
debug(value);
|
||||
}
|
||||
}
|
||||
|
||||
export default MemoryHandler;
|
||||
|
||||
4
packages/plugins/ui-theme/.npmignore
Normal file
4
packages/plugins/ui-theme/.npmignore
Normal file
@@ -0,0 +1,4 @@
|
||||
/*
|
||||
!/static/**/*
|
||||
!index.js
|
||||
!README.md
|
||||
@@ -1,5 +1,29 @@
|
||||
# @verdaccio/ui-theme
|
||||
|
||||
## 6.0.0-6-next.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- c9089631: fix: specific version package detail page not showing
|
||||
|
||||
## 6.0.0-6-next.16
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- ad3151c3: fix: remove engines from ui-theme
|
||||
|
||||
## 6.0.0-6-next.15
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 7ff4808b: feat: improve registry info dialog and language switch
|
||||
|
||||
## 6.0.0-6-next.14
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 048ac95e: feat: align with v5 ui endpoints and ui small bugfix
|
||||
|
||||
## 6.0.0-6-next.13
|
||||
|
||||
### Major Changes
|
||||
|
||||
@@ -35,5 +35,7 @@ module.exports = Object.assign({}, config, {
|
||||
'verdaccio-ui/utils/(.*)': '<rootDir>/src/utils/$1',
|
||||
'verdaccio-ui/providers/(.*)': '<rootDir>/src/providers/$1',
|
||||
'verdaccio-ui/design-tokens/(.*)': '<rootDir>/src/design-tokens/$1',
|
||||
'react-markdown': '<rootDir>/src/__mocks__/react-markdown.tsx',
|
||||
'remark-*': '<rootDir>/src/__mocks__/remark-plugin.ts',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ import { rest } from 'msw';
|
||||
const packagesPayload = require('./api/packages.json');
|
||||
|
||||
export const handlers = [
|
||||
rest.get('http://localhost:9000/-/verdaccio/packages', (req, res, ctx) => {
|
||||
rest.get('http://localhost:9000/-/verdaccio/data/packages', (req, res, ctx) => {
|
||||
return res(ctx.json(packagesPayload));
|
||||
}),
|
||||
];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@verdaccio/ui-theme",
|
||||
"version": "6.0.0-6-next.13",
|
||||
"version": "6.0.0-6-next.17",
|
||||
"description": "Verdaccio User Interface",
|
||||
"author": {
|
||||
"name": "Verdaccio Contributors",
|
||||
@@ -12,32 +12,28 @@
|
||||
},
|
||||
"homepage": "https://verdaccio.org",
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=14",
|
||||
"npm": ">=6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "17.0.37",
|
||||
"@types/react": "17.0.38",
|
||||
"@types/react-autosuggest": "10.1.5",
|
||||
"@types/react-dom": "17.0.11",
|
||||
"@types/react-helmet": "6.1.4",
|
||||
"@types/react-helmet": "6.1.5",
|
||||
"@types/redux": "3.6.0",
|
||||
"@types/react-router-dom": "5.3.2",
|
||||
"@types/react-virtualized": "9.21.15",
|
||||
"@emotion/react": "11.5.0",
|
||||
"@emotion/jest": "11.5.0",
|
||||
"@emotion/styled": "11.3.0",
|
||||
"@emotion/css": "11.5.0",
|
||||
"@emotion/babel-plugin": "11.0.0",
|
||||
"@mui/icons-material": "5.0.5",
|
||||
"@mui/material": "5.0.6",
|
||||
"@mui/styles": "5.0.2",
|
||||
"@types/react-router-dom": "5.3.3",
|
||||
"@types/react-virtualized": "9.21.16",
|
||||
"@emotion/react": "11.7.1",
|
||||
"@emotion/jest": "11.7.1",
|
||||
"@emotion/styled": "11.6.0",
|
||||
"@emotion/css": "11.7.1",
|
||||
"@emotion/babel-plugin": "11.7.2",
|
||||
"@mui/icons-material": "5.3.0",
|
||||
"@mui/material": "5.3.0",
|
||||
"@mui/styles": "5.3.0",
|
||||
"@rematch/core": "2.2.0",
|
||||
"@rematch/loading": "2.1.2",
|
||||
"@testing-library/dom": "8.11.1",
|
||||
"@testing-library/dom": "8.11.2",
|
||||
"@testing-library/jest-dom": "5.16.1",
|
||||
"@testing-library/react": "12.1.2",
|
||||
"@verdaccio/node-api": "workspace:6.0.0-6-next.25",
|
||||
"@verdaccio/node-api": "workspace:6.0.0-6-next.27",
|
||||
"@verdaccio/types": "workspace:*",
|
||||
"babel-loader": "8.2.3",
|
||||
"babel-plugin-dynamic-import-node": "2.3.3",
|
||||
@@ -48,7 +44,7 @@
|
||||
"github-markdown-css": "4.0.0",
|
||||
"harmony-reflect": "1.6.2",
|
||||
"history": "4.10.1",
|
||||
"html-webpack-plugin": "5.4.0",
|
||||
"html-webpack-plugin": "5.5.0",
|
||||
"i18next": "20.6.1",
|
||||
"in-publish": "2.0.1",
|
||||
"country-flag-icons": "1.4.19",
|
||||
@@ -56,42 +52,42 @@
|
||||
"js-yaml": "3.14.1",
|
||||
"localstorage-memory": "1.0.3",
|
||||
"lodash": "4.17.21",
|
||||
"mini-css-extract-plugin": "2.2.2",
|
||||
"mini-css-extract-plugin": "2.5.2",
|
||||
"mutationobserver-shim": "0.3.7",
|
||||
"node-mocks-http": "1.10.1",
|
||||
"node-mocks-http": "1.11.0",
|
||||
"normalize.css": "8.0.1",
|
||||
"react-markdown": "8.0.0",
|
||||
"remark-gfm": "3.0.1",
|
||||
"optimize-css-assets-webpack-plugin": "6.0.1",
|
||||
"ora": "5.4.1",
|
||||
"prop-types": "15.7.2",
|
||||
"react": "17.0.2",
|
||||
"react-dom": "17.0.2",
|
||||
"react-hook-form": "7.15.3",
|
||||
"react-hook-form": "7.25.0",
|
||||
"react-hot-loader": "4.13.0",
|
||||
"react-i18next": "11.12.0",
|
||||
"react-i18next": "11.15.3",
|
||||
"react-router": "5.2.1",
|
||||
"react-router-dom": "5.3.0",
|
||||
"react-virtualized": "9.22.3",
|
||||
"react-redux": "7.2.6",
|
||||
"redux": "4.1.2",
|
||||
"rimraf": "3.0.2",
|
||||
"msw": "0.35.0",
|
||||
"standard-version": "9.3.1",
|
||||
"style-loader": "3.2.1",
|
||||
"stylelint": "13.13.1",
|
||||
"stylelint-config-recommended": "5.0.0",
|
||||
"msw": "0.36.5",
|
||||
"style-loader": "3.3.1",
|
||||
"stylelint": "14.3.0",
|
||||
"stylelint-config-recommended": "6.0.0",
|
||||
"stylelint-config-styled-components": "0.1.1",
|
||||
"stylelint-processor-styled-components": "1.10.0",
|
||||
"stylelint-webpack-plugin": "3.0.1",
|
||||
"supertest": "6.1.6",
|
||||
"terser-webpack-plugin": "5.2.5",
|
||||
"stylelint-webpack-plugin": "3.1.1",
|
||||
"supertest": "6.2.2",
|
||||
"terser-webpack-plugin": "5.3.0",
|
||||
"url-loader": "4.1.1",
|
||||
"validator": "13.7.0",
|
||||
"webpack": "5.64.0",
|
||||
"webpack-bundle-analyzer": "4.4.2",
|
||||
"webpack": "5.67.0",
|
||||
"webpack-bundle-analyzer": "4.5.0",
|
||||
"webpack-bundle-size-analyzer": "3.1.0",
|
||||
"webpack-cli": "^4.7.2",
|
||||
"webpack-dev-server": "3.11.3",
|
||||
"webpack-manifest-plugin": "4.0.2",
|
||||
"webpack-manifest-plugin": "4.1.1",
|
||||
"webpack-merge": "5.8.0",
|
||||
"whatwg-fetch": "3.6.2",
|
||||
"xss": "1.0.10"
|
||||
|
||||
@@ -23,7 +23,6 @@ const Header: React.FC<Props> = ({ withoutSearch }) => {
|
||||
const [showMobileNavBar, setShowMobileNavBar] = useState<boolean>(false);
|
||||
const [showLoginModal, setShowLoginModal] = useState<boolean>(false);
|
||||
const loginStore = useSelector((state: RootState) => state.login);
|
||||
const configStore = useSelector((state: RootState) => state.configuration.config);
|
||||
const { configOptions } = useConfig();
|
||||
const dispatch = useDispatch<Dispatch>();
|
||||
const handleLogout = () => {
|
||||
@@ -45,12 +44,12 @@ const Header: React.FC<Props> = ({ withoutSearch }) => {
|
||||
withoutSearch={withoutSearch}
|
||||
/>
|
||||
</InnerNavBar>
|
||||
<HeaderInfoDialog
|
||||
isOpen={isInfoDialogOpen}
|
||||
onCloseDialog={() => setOpenInfoDialog(false)}
|
||||
registryUrl={configOptions.base}
|
||||
scope={configStore.scope}
|
||||
/>
|
||||
{
|
||||
<HeaderInfoDialog
|
||||
isOpen={isInfoDialogOpen}
|
||||
onCloseDialog={() => setOpenInfoDialog(false)}
|
||||
/>
|
||||
}
|
||||
</NavBar>
|
||||
{showMobileNavBar && !withoutSearch && (
|
||||
<MobileNavBar>
|
||||
|
||||
@@ -1,19 +1,82 @@
|
||||
/* eslint-disable verdaccio/jsx-spread */
|
||||
import styled from '@emotion/styled';
|
||||
import Box from '@mui/material/Box';
|
||||
import Tab from '@mui/material/Tab';
|
||||
import Tabs from '@mui/material/Tabs';
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import { useSelector } from 'react-redux';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
import { Theme } from 'verdaccio-ui/design-tokens/theme';
|
||||
|
||||
import { RootState } from '../../store/store';
|
||||
import LanguageSwitch from './LanguageSwitch';
|
||||
import RegistryInfoContent from './RegistryInfoContent';
|
||||
import RegistryInfoDialog from './RegistryInfoDialog';
|
||||
|
||||
interface Props {
|
||||
isOpen: boolean;
|
||||
onCloseDialog: () => void;
|
||||
registryUrl: string;
|
||||
scope: string;
|
||||
}
|
||||
|
||||
const HeaderInfoDialog: React.FC<Props> = ({ onCloseDialog, isOpen, registryUrl, scope }) => (
|
||||
<RegistryInfoDialog onClose={onCloseDialog} open={isOpen}>
|
||||
<RegistryInfoContent registryUrl={registryUrl} scope={scope} />
|
||||
</RegistryInfoDialog>
|
||||
);
|
||||
function a11yProps(index) {
|
||||
return {
|
||||
id: `simple-tab-${index}`,
|
||||
'aria-controls': `simple-tabpanel-${index}`,
|
||||
};
|
||||
}
|
||||
|
||||
function TabPanel(props) {
|
||||
const { children, value, index, ...other } = props;
|
||||
|
||||
return (
|
||||
<div
|
||||
aria-labelledby={`simple-tab-${index}`}
|
||||
hidden={value !== index}
|
||||
id={`simple-tabpanel-${index}`}
|
||||
role="tabpanel"
|
||||
{...other}
|
||||
>
|
||||
{value === index && <Box sx={{ paddingTop: 3 }}>{children}</Box>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const TextContent = styled('div')<{ theme?: Theme }>(({ theme }) => ({
|
||||
padding: '10px 0',
|
||||
backgroundColor: theme?.palette.background.default,
|
||||
}));
|
||||
|
||||
const HeaderInfoDialog: React.FC<Props> = ({ onCloseDialog, isOpen }) => {
|
||||
const [value, setValue] = React.useState(0);
|
||||
|
||||
const handleChange = (event, newValue) => {
|
||||
setValue(newValue);
|
||||
};
|
||||
const configStore = useSelector((state: RootState) => state.configuration.config);
|
||||
const { scope, base } = configStore;
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<RegistryInfoDialog onClose={onCloseDialog} open={isOpen}>
|
||||
<Box sx={{ width: '100%' }}>
|
||||
<Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
|
||||
<Tabs aria-label="basic tabs example" onChange={handleChange} value={value}>
|
||||
<Tab label={t('packageManagers.title')} {...a11yProps(0)} />
|
||||
<Tab label={t('language.title')} {...a11yProps(1)} />
|
||||
</Tabs>
|
||||
</Box>
|
||||
<TabPanel index={0} value={value}>
|
||||
<RegistryInfoContent registryUrl={base} scope={scope} />
|
||||
</TabPanel>
|
||||
<TabPanel index={1} value={value}>
|
||||
<TextContent>{t('language.description')}</TextContent>
|
||||
<LanguageSwitch />
|
||||
<ReactMarkdown remarkPlugins={[remarkGfm]}>{t('language.contribute')}</ReactMarkdown>
|
||||
</TabPanel>
|
||||
</Box>
|
||||
</RegistryInfoDialog>
|
||||
);
|
||||
};
|
||||
|
||||
export default HeaderInfoDialog;
|
||||
|
||||
@@ -32,7 +32,8 @@ const HeaderMenu: React.FC<Props> = ({
|
||||
data-testid="logInDialogIcon"
|
||||
id="header--button-account"
|
||||
onClick={onLoggedInMenu}
|
||||
size="large">
|
||||
size="large"
|
||||
>
|
||||
<AccountCircle />
|
||||
</IconButton>
|
||||
<Menu
|
||||
@@ -46,15 +47,12 @@ const HeaderMenu: React.FC<Props> = ({
|
||||
transformOrigin={{
|
||||
vertical: 'top',
|
||||
horizontal: 'right',
|
||||
}}>
|
||||
}}
|
||||
>
|
||||
<MenuItem>
|
||||
<HeaderGreetings username={username} />
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
button={true}
|
||||
data-testid="logOutDialogIcon"
|
||||
id="logOutDialogIcon"
|
||||
onClick={onLogout}>
|
||||
<MenuItem data-testid="logOutDialogIcon" id="logOutDialogIcon" onClick={onLogout}>
|
||||
{t('button.logout')}
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
|
||||
@@ -5,7 +5,6 @@ import ThemeContext from 'verdaccio-ui/design-tokens/ThemeContext';
|
||||
|
||||
import HeaderMenu from './HeaderMenu';
|
||||
import HeaderToolTip from './HeaderToolTip';
|
||||
import LanguageSwitch from './LanguageSwitch';
|
||||
import { RightSide } from './styles';
|
||||
|
||||
interface Props {
|
||||
@@ -79,7 +78,6 @@ const HeaderRight: React.FC<Props> = ({
|
||||
tooltipIconType={'search'}
|
||||
/>
|
||||
)}
|
||||
<LanguageSwitch />
|
||||
<HeaderToolTip title={t('header.documentation')} tooltipIconType={'help'} />
|
||||
<HeaderToolTip
|
||||
onClick={onOpenRegistryInfoDialog}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React from 'react';
|
||||
import Tooltip from 'verdaccio-ui/components/Tooltip';
|
||||
|
||||
import HeaderToolTipIcon, { TooltipIconType } from './HeaderToolTipIcon';
|
||||
|
||||
@@ -9,10 +8,8 @@ interface Props {
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
const HeaderToolTip: React.FC<Props> = ({ tooltipIconType, title, onClick }) => (
|
||||
<Tooltip disableFocusListener={true} title={title}>
|
||||
<HeaderToolTipIcon onClick={onClick} tooltipIconType={tooltipIconType} />
|
||||
</Tooltip>
|
||||
const HeaderToolTip: React.FC<Props> = ({ tooltipIconType, onClick }) => (
|
||||
<HeaderToolTipIcon onClick={onClick} tooltipIconType={tooltipIconType} />
|
||||
);
|
||||
|
||||
export default HeaderToolTip;
|
||||
|
||||
@@ -28,7 +28,8 @@ const HeaderToolTipIcon = forwardRef<HeaderToolTipIconRef, Props>(function Heade
|
||||
<StyledLink
|
||||
data-testid={'header--tooltip-documentation'}
|
||||
external={true}
|
||||
to={'https://verdaccio.org/docs/en/installation'}>
|
||||
to={'https://verdaccio.org/docs/en/installation'}
|
||||
>
|
||||
<IconButton color={'inherit'} size="large">
|
||||
<Help />
|
||||
</IconButton>
|
||||
@@ -42,13 +43,14 @@ const HeaderToolTipIcon = forwardRef<HeaderToolTipIconRef, Props>(function Heade
|
||||
id="header--button-registryInfo"
|
||||
onClick={onClick}
|
||||
ref={ref}
|
||||
size="large">
|
||||
size="large"
|
||||
>
|
||||
<Info />
|
||||
</IconButton>
|
||||
);
|
||||
case 'search':
|
||||
return (
|
||||
<IconSearchButton color="inherit" onClick={onClick}>
|
||||
<IconSearchButton color="inherit" onClick={onClick} ref={ref}>
|
||||
<Search />
|
||||
</IconSearchButton>
|
||||
);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/* eslint-disable react/jsx-pascal-case */
|
||||
import styled from '@emotion/styled';
|
||||
import LanguageIcon from '@mui/icons-material/Language';
|
||||
import withStyles from '@mui/styles/withStyles';
|
||||
import Card from '@mui/material/Card';
|
||||
import CardContent from '@mui/material/CardContent';
|
||||
import Grid from '@mui/material/Grid';
|
||||
import Typography from '@mui/material/Typography';
|
||||
import i18next from 'i18next';
|
||||
import React, { useCallback, useContext, useMemo, useState } from 'react';
|
||||
import React, { useCallback, useContext, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { AutoComplete } from 'verdaccio-ui/components/AutoComplete/AutoCompleteV2';
|
||||
import MenuItem from 'verdaccio-ui/components/MenuItem';
|
||||
import ThemeContext from 'verdaccio-ui/design-tokens/ThemeContext';
|
||||
import { Theme } from 'verdaccio-ui/design-tokens/theme';
|
||||
|
||||
@@ -20,26 +20,42 @@ const listConverted = listLanguages.reduce((prev, item) => {
|
||||
return prev;
|
||||
}, {});
|
||||
|
||||
export const CardSelected = styled(Card)<{ theme?: Theme }>(({ theme }) => {
|
||||
return {
|
||||
backgroundColor: theme?.palette?.grey['600'],
|
||||
opacity: '0.9',
|
||||
color: theme?.palette?.error.contrastText,
|
||||
fontWeight: 'bold',
|
||||
};
|
||||
});
|
||||
|
||||
export const CardUnSelected = styled(Card)<{ theme?: Theme }>(({ theme }) => {
|
||||
return {
|
||||
cursor: 'pointer',
|
||||
':hover': {
|
||||
backgroundColor: theme?.palette.greyGainsboro,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
const LanguageContent = ({ translation, icon }) => (
|
||||
<>
|
||||
<CardContent>
|
||||
<Typography display="block" gutterBottom={true} variant="caption">
|
||||
{translation}
|
||||
</Typography>
|
||||
</CardContent>
|
||||
<CardContent>{icon}</CardContent>
|
||||
</>
|
||||
);
|
||||
|
||||
const LanguageSwitch = () => {
|
||||
const themeContext = useContext(ThemeContext);
|
||||
const themeContext = useContext(ThemeContext) as any;
|
||||
const [languages] = useState<Language[]>(
|
||||
Object.keys(i18next.options?.resources || {}) as Language[]
|
||||
);
|
||||
const { t } = useTranslation();
|
||||
|
||||
if (!themeContext) {
|
||||
throw Error(t('theme-context-not-correct-used'));
|
||||
}
|
||||
|
||||
const currentLanguage = themeContext.language;
|
||||
|
||||
const switchLanguage = useCallback(
|
||||
({ language }: { language: Language }) => {
|
||||
themeContext.setLanguage(language);
|
||||
},
|
||||
[themeContext]
|
||||
);
|
||||
|
||||
const getCurrentLngDetails = useCallback(
|
||||
(language: Language) => {
|
||||
const lng = listConverted[language] || listConverted['en-US'];
|
||||
@@ -50,75 +66,35 @@ const LanguageSwitch = () => {
|
||||
},
|
||||
[t]
|
||||
);
|
||||
|
||||
const options = useMemo(
|
||||
() =>
|
||||
languages.map((language) => {
|
||||
const { icon, translation } = getCurrentLngDetails(language);
|
||||
return {
|
||||
language,
|
||||
icon,
|
||||
translation,
|
||||
};
|
||||
}),
|
||||
[languages, getCurrentLngDetails]
|
||||
);
|
||||
|
||||
const option = useCallback(
|
||||
({ icon, translation }: ReturnType<typeof getCurrentLngDetails>) => (
|
||||
<StyledMenuItem component="div">
|
||||
{icon}
|
||||
{translation}
|
||||
</StyledMenuItem>
|
||||
),
|
||||
[]
|
||||
);
|
||||
|
||||
const optionLabel = useCallback(
|
||||
({ translation }: ReturnType<typeof getCurrentLngDetails>) => translation,
|
||||
[]
|
||||
const handleChangeLanguage = useCallback(
|
||||
(language: Language) => {
|
||||
themeContext.setLanguage(language);
|
||||
},
|
||||
[themeContext]
|
||||
);
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<AutoComplete
|
||||
defaultValue={getCurrentLngDetails(currentLanguage).translation}
|
||||
getOptionLabel={optionLabel}
|
||||
hasClearIcon={true}
|
||||
inputStartAdornment={<StyledLanguageIcon />}
|
||||
onClick={switchLanguage}
|
||||
options={options}
|
||||
renderOption={option}
|
||||
variant="outlined"
|
||||
/>
|
||||
</Wrapper>
|
||||
<div>
|
||||
<Grid columns={{ xs: 12, sm: 12, md: 12 }} container={true} spacing={{ xs: 1, md: 1 }}>
|
||||
{languages.map((language, index) => {
|
||||
const { icon, translation } = getCurrentLngDetails(language);
|
||||
return (
|
||||
<Grid item={true} key={index} sm={2} xs={6}>
|
||||
{language === currentLanguage ? (
|
||||
<CardSelected sx={{ maxWidth: 80 }}>
|
||||
<LanguageContent icon={icon} translation={translation} />
|
||||
</CardSelected>
|
||||
) : (
|
||||
<CardUnSelected onClick={() => handleChangeLanguage(language)}>
|
||||
<LanguageContent icon={icon} translation={translation} />
|
||||
</CardUnSelected>
|
||||
)}
|
||||
</Grid>
|
||||
);
|
||||
})}
|
||||
</Grid>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default LanguageSwitch;
|
||||
|
||||
const StyledLanguageIcon = styled(LanguageIcon)<{ theme?: Theme }>(({ theme }) => ({
|
||||
color: theme?.palette.white,
|
||||
}));
|
||||
|
||||
const Wrapper = styled('div')<{ theme?: Theme }>(({ theme }) => ({
|
||||
width: 220,
|
||||
display: 'none',
|
||||
[`@media screen and (min-width: ${theme?.breakPoints.medium}px)`]: {
|
||||
display: 'inline-block',
|
||||
},
|
||||
}));
|
||||
|
||||
const StyledMenuItem = withStyles((theme: Theme) => ({
|
||||
root: {
|
||||
display: 'grid',
|
||||
cursor: 'pointer',
|
||||
gridGap: theme?.spacing(0.5),
|
||||
gridTemplateColumns: '20px 1fr',
|
||||
alignItems: 'center',
|
||||
'&:first-child': {
|
||||
borderTopLeftRadius: 4,
|
||||
borderTopRightRadius: 4,
|
||||
},
|
||||
},
|
||||
}))(MenuItem);
|
||||
|
||||
@@ -66,7 +66,8 @@ const LoginDialog: React.FC<Props> = ({ onClose, open = false }) => {
|
||||
id="login--dialog"
|
||||
maxWidth="sm"
|
||||
onClose={onClose}
|
||||
open={open}>
|
||||
open={open}
|
||||
>
|
||||
<LoginDialogCloseButton onClose={onClose} />
|
||||
<DialogContent data-testid="dialogContentLogin">
|
||||
<LoginDialogHeader />
|
||||
|
||||
@@ -86,7 +86,8 @@ const LoginDialogForm = memo(({ onSubmit, error }: Props) => {
|
||||
id="login--dialog-button-submit"
|
||||
size="large"
|
||||
type="submit"
|
||||
variant="contained">
|
||||
variant="contained"
|
||||
>
|
||||
{t('button.login')}
|
||||
</StyledButton>
|
||||
</StyledForm>
|
||||
|
||||
@@ -9,8 +9,10 @@ describe('<RegistryInfoContent /> component', () => {
|
||||
});
|
||||
|
||||
test('should load the component with no data', () => {
|
||||
render(<RegistryInfoContent registryUrl={''} scope={''} />);
|
||||
expect(screen.getByText('No configurations available')).toBeInTheDocument();
|
||||
render(<RegistryInfoContent registryUrl="http://localhost:4873" scope={''} />);
|
||||
expect(
|
||||
screen.getByText(/This is the configuration details for the registry./)
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('should load the appropiate tab content when the tab is clicked', () => {
|
||||
|
||||
@@ -9,18 +9,23 @@ import Typography from '@mui/material/Typography';
|
||||
import makeStyles from '@mui/styles/makeStyles';
|
||||
import React, { FC } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
import CopyToClipBoard from 'verdaccio-ui/components/CopyToClipBoard';
|
||||
import { useConfig } from 'verdaccio-ui/providers/config';
|
||||
import {
|
||||
getCLIChangePassword,
|
||||
getCLISBerryYamlRegistry,
|
||||
getCLISetConfigRegistry,
|
||||
getCLISetRegistry,
|
||||
} from 'verdaccio-ui/utils/cli-utils';
|
||||
import { NODE_MANAGER } from 'verdaccio-ui/utils/constants';
|
||||
|
||||
const renderNpmTab = (scope: string, registryUrl: string): JSX.Element => {
|
||||
import { Description, TextContent } from './styles';
|
||||
|
||||
const renderNpmTab = (scope: string | undefined, registryUrl: string): JSX.Element => {
|
||||
return (
|
||||
<Box display="flex" flexDirection="column" p={1}>
|
||||
<Box display="flex" flexDirection="column">
|
||||
<CopyToClipBoard
|
||||
text={getCLISetConfigRegistry(`${NODE_MANAGER.npm} set`, scope, registryUrl)}
|
||||
/>
|
||||
@@ -30,9 +35,9 @@ const renderNpmTab = (scope: string, registryUrl: string): JSX.Element => {
|
||||
);
|
||||
};
|
||||
|
||||
const renderPnpmTab = (scope: string, registryUrl: string): JSX.Element => {
|
||||
const renderPnpmTab = (scope: string | undefined, registryUrl: string): JSX.Element => {
|
||||
return (
|
||||
<Box display="flex" flexDirection="column" p={1}>
|
||||
<Box display="flex" flexDirection="column">
|
||||
<CopyToClipBoard
|
||||
text={getCLISetConfigRegistry(`${NODE_MANAGER.pnpm} set`, scope, registryUrl)}
|
||||
/>
|
||||
@@ -42,9 +47,9 @@ const renderPnpmTab = (scope: string, registryUrl: string): JSX.Element => {
|
||||
);
|
||||
};
|
||||
|
||||
const renderYarnTab = (scope: string, registryUrl: string): JSX.Element => {
|
||||
const renderYarnTab = (scope: string | undefined, registryUrl: string): JSX.Element => {
|
||||
return (
|
||||
<Box display="flex" flexDirection="column" p={1}>
|
||||
<Box display="flex" flexDirection="column">
|
||||
<CopyToClipBoard
|
||||
text={getCLISetConfigRegistry(`${NODE_MANAGER.yarn} config set`, scope, registryUrl)}
|
||||
/>
|
||||
@@ -52,6 +57,14 @@ const renderYarnTab = (scope: string, registryUrl: string): JSX.Element => {
|
||||
);
|
||||
};
|
||||
|
||||
const renderYarnBerryTab = (scope: string | undefined, registryUrl: string): JSX.Element => {
|
||||
return (
|
||||
<Box display="flex" flexDirection="column">
|
||||
<CopyToClipBoard text={getCLISBerryYamlRegistry(scope, registryUrl)} />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
width: '100%',
|
||||
@@ -63,7 +76,7 @@ const useStyles = makeStyles((theme) => ({
|
||||
}));
|
||||
|
||||
export const AccordionContainer = styled('div')({
|
||||
padding: 30,
|
||||
padding: 0,
|
||||
paddingLeft: 0,
|
||||
paddingRight: 0,
|
||||
});
|
||||
@@ -79,7 +92,7 @@ export const LinkContainer = styled('div')({
|
||||
|
||||
export type Props = {
|
||||
registryUrl: string;
|
||||
scope: string;
|
||||
scope: string | undefined;
|
||||
};
|
||||
|
||||
const RegistryInfoContent: FC<Props> = ({ scope, registryUrl }) => {
|
||||
@@ -90,19 +103,18 @@ const RegistryInfoContent: FC<Props> = ({ scope, registryUrl }) => {
|
||||
const hasNpm = configOptions?.pkgManagers?.includes('npm');
|
||||
const hasYarn = configOptions?.pkgManagers?.includes('yarn');
|
||||
const hasPnpm = configOptions?.pkgManagers?.includes('pnpm');
|
||||
const hasPkgManagers = hasNpm | hasPnpm | hasYarn;
|
||||
if (!hasPkgManagers || !scope || !registryUrl) {
|
||||
return <AccordionContainer>{t('header.registry-no-conf')}</AccordionContainer>;
|
||||
}
|
||||
|
||||
return hasPkgManagers ? (
|
||||
<AccordionContainer>
|
||||
{hasNpm && (
|
||||
<Accordion>
|
||||
// TODO: we can improve this logic, expanding only one accordion based on which package manager is enabled
|
||||
// feel free to contribute here
|
||||
return (
|
||||
<>
|
||||
<TextContent>{t('packageManagers.description')}</TextContent>
|
||||
<AccordionContainer>
|
||||
<Accordion disabled={!hasNpm}>
|
||||
<AccordionSummary
|
||||
aria-controls="panel1a-content"
|
||||
expandIcon={<ExpandMoreIcon />}
|
||||
id="panel1a-header">
|
||||
id="panel1a-header"
|
||||
>
|
||||
<Typography className={classes.heading}>{'npm'}</Typography>
|
||||
</AccordionSummary>
|
||||
<AccordionDetails>
|
||||
@@ -111,28 +123,40 @@ const RegistryInfoContent: FC<Props> = ({ scope, registryUrl }) => {
|
||||
</CommandContainer>
|
||||
</AccordionDetails>
|
||||
</Accordion>
|
||||
)}
|
||||
{hasYarn && (
|
||||
<Accordion>
|
||||
<Accordion disabled={!hasYarn}>
|
||||
<AccordionSummary
|
||||
aria-controls="panel2a-content"
|
||||
expandIcon={<ExpandMoreIcon />}
|
||||
id="panel2a-header">
|
||||
id="panel2a-header"
|
||||
>
|
||||
<Typography className={classes.heading}>{'yarn'}</Typography>
|
||||
</AccordionSummary>
|
||||
<AccordionDetails>
|
||||
<Description>
|
||||
<ReactMarkdown remarkPlugins={[remarkGfm]}>
|
||||
{t('packageManagers.yarnclassicDetails')}
|
||||
</ReactMarkdown>
|
||||
</Description>
|
||||
<CommandContainer data-testid={'tab-content'}>
|
||||
{renderYarnTab(scope, registryUrl)}
|
||||
</CommandContainer>
|
||||
<Description>
|
||||
<ReactMarkdown remarkPlugins={[remarkGfm]}>
|
||||
{t('packageManagers.yarnBerryDetails')}
|
||||
</ReactMarkdown>
|
||||
</Description>
|
||||
<CommandContainer data-testid={'tab-content'}>
|
||||
{renderYarnBerryTab(scope, registryUrl)}
|
||||
</CommandContainer>
|
||||
</AccordionDetails>
|
||||
</Accordion>
|
||||
)}
|
||||
{hasPnpm && (
|
||||
<Accordion>
|
||||
|
||||
<Accordion disabled={!hasPnpm}>
|
||||
<AccordionSummary
|
||||
aria-controls="panel3a-content"
|
||||
expandIcon={<ExpandMoreIcon />}
|
||||
id="panel3a-header">
|
||||
id="panel3a-header"
|
||||
>
|
||||
{'pnpm'}
|
||||
</AccordionSummary>
|
||||
<AccordionDetails>
|
||||
@@ -141,14 +165,15 @@ const RegistryInfoContent: FC<Props> = ({ scope, registryUrl }) => {
|
||||
</CommandContainer>
|
||||
</AccordionDetails>
|
||||
</Accordion>
|
||||
)}
|
||||
<LinkContainer>
|
||||
<Link href="https://verdaccio.org/docs/en/cli-registry" target="_blank">
|
||||
<Typography>{t('header.registry-info-link')}</Typography>
|
||||
</Link>
|
||||
</LinkContainer>
|
||||
</AccordionContainer>
|
||||
) : null;
|
||||
|
||||
<LinkContainer>
|
||||
<Link href="https://verdaccio.org/docs/en/cli-registry" target="_blank">
|
||||
<Typography>{t('header.registry-info-link')}</Typography>
|
||||
</Link>
|
||||
</LinkContainer>
|
||||
</AccordionContainer>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default RegistryInfoContent;
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import styled from '@emotion/styled';
|
||||
import { Theme } from 'verdaccio-ui/design-tokens/theme';
|
||||
|
||||
export const TextContent = styled('div')<{ theme?: Theme }>(({ theme }) => ({
|
||||
paddingBottom: '10px',
|
||||
backgroundColor: theme?.palette.background.default,
|
||||
}));
|
||||
|
||||
export const Description = styled('div')<{ theme?: Theme }>(() => ({
|
||||
fontSize: '1rem',
|
||||
fontStyle: 'italic',
|
||||
}));
|
||||
@@ -14,8 +14,9 @@ const RegistryInfoDialog: React.FC<Props> = ({ open = false, children, onClose }
|
||||
data-testid={'registryInfo--dialog'}
|
||||
id="registryInfo--dialog-container"
|
||||
onClose={onClose}
|
||||
open={open}>
|
||||
<Title disableTypography={true}>{t('dialog.registry-info.title')}</Title>
|
||||
open={open}
|
||||
>
|
||||
<Title>{t('dialog.registry-info.title')}</Title>
|
||||
<Content>{children}</Content>
|
||||
<DialogActions>
|
||||
<Button color="inherit" id="registryInfo--dialog-close" onClick={onClose}>
|
||||
|
||||
@@ -13,3 +13,8 @@ export const Content = styled(DialogContent)<{ theme?: Theme }>(({ theme }) => (
|
||||
padding: '0 24px',
|
||||
backgroundColor: theme?.palette.background.default,
|
||||
}));
|
||||
|
||||
export const TextContent = styled('div')<{ theme?: Theme }>(({ theme }) => ({
|
||||
padding: '10px 24px',
|
||||
backgroundColor: theme?.palette.background.default,
|
||||
}));
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user