From 20f244222bf9d2f8ccf8d5c7f7237b268843aeb7 Mon Sep 17 00:00:00 2001 From: Juan Picado Date: Thu, 17 Mar 2022 19:56:15 +0100 Subject: [PATCH] chore: move blog docs to pages (#3069) * chore: move blog docs to pages Interesting info is being located here https://verdaccio.org/blog/2021/04/14/verdaccio-5-migration-guide but people does not find it. * chore: move blog docs to pages * chore: move blog docs to pages --- website/docs/config.md | 28 +++++++++++++++- website/docs/plugins.md | 64 ++++++++++++++++++++++++++++++++++++ website/docs/web.md | 14 +++++++- website/docusaurus.config.js | 2 +- website/package.json | 2 +- 5 files changed, 106 insertions(+), 4 deletions(-) diff --git a/website/docs/config.md b/website/docs/config.md index 26e02f10e..9e8a79b8e 100644 --- a/website/docs/config.md +++ b/website/docs/config.md @@ -153,11 +153,37 @@ publish: The prefix is intended to be used when the server runs behinds the proxy and won't work properly if is used without a reverse proxy, check the **reverse proxy setup** page for more details. +The internal logic builds correctly the public url, validates the `host` header and and bad shaped `url_prefix`. + +eg: `url_prefix: /verdaccio`, `url_prefix: verdaccio/`, `url_prefix: verdaccio` would be `/verdaccio/` + ```yaml url_prefix: /verdaccio/ ``` -> Verdaccio 5 has an improved prefix behaviour and the `VERDACCIO_PUBLIC_URL` is available for use, learn how to [here](https://verdaccio.org/blog/2021/04/14/verdaccio-5-migration-guide#url_prefix-improved-behavior). +The new `VERDACCIO_PUBLIC_URL` is intended to be used behind proxies, this variable will be used for: + +- Used as base path to serve UI resources as (js, favicon, etc) +- Used on return metadata `dist` base path +- Ignores `host` and `X-Forwarded-Proto` headers +- If `url_prefix` is defined would be appened to the env variable. + +``` +VERDACCIO_PUBLIC_URL='https://somedomain.org'; +url_prefix: '/my_prefix' + +// url -> https://somedomain.org/my_prefix/ + +VERDACCIO_PUBLIC_URL='https://somedomain.org'; +url_prefix: '/' + +// url -> https://somedomain.org/ + +VERDACCIO_PUBLIC_URL='https://somedomain.org/first_prefix'; +url_prefix: '/second_prefix' + +// url -> https://somedomain.org/second_prefix/' +``` ### User Agent {#user-agent} diff --git a/website/docs/plugins.md b/website/docs/plugins.md index f0620e72c..93612651b 100644 --- a/website/docs/plugins.md +++ b/website/docs/plugins.md @@ -113,6 +113,70 @@ theme: option2: bar ``` +### Theme plugin development + +> Since v.5.0.0 + +If you have a custom UI plugin for the them you will need to adapt your build to the new requirements. + +The previous version you only need to return a function with a string and the path of the directory. + +``` +const path = require('path'); + +module.exports = () => { + return path.join(__dirname, 'static'); +}; +``` + +The module must return an object and the `index.html` is ignored since support dynamic rendering, eg: + +``` + staticPath: '/somePath/node_modules/verdaccio-theme-custom/static', + manifest: { + 'main.js': '-/static/main.c21a97b1dbe8456a9c76.js', + 'runtime.js': '-/static/runtime.c21a97b1dbe8456a9c76.js', + 'NotFound.js': '-/static/NotFound.c21a97b1dbe8456a9c76.js', + 'Provider.js': '-/static/Provider.c21a97b1dbe8456a9c76.js', + 'Version.js': '-/static/Version.c21a97b1dbe8456a9c76.js', + 'Home.js': '-/static/Home.c21a97b1dbe8456a9c76.js', + 'Versions.js': '-/static/Versions.c21a97b1dbe8456a9c76.js', + 'UpLinks.js': '-/static/UpLinks.c21a97b1dbe8456a9c76.js', + 'Dependencies.js': '-/static/Dependencies.c21a97b1dbe8456a9c76.js', + 'Engines.js': '-/static/Engines.c21a97b1dbe8456a9c76.js', + 'Dist.js': '-/static/Dist.c21a97b1dbe8456a9c76.js', + 'Install.js': '-/static/Install.c21a97b1dbe8456a9c76.js', + 'Repository.js': '-/static/Repository.c21a97b1dbe8456a9c76.js', + 'vendors.js': '-/static/vendors.c21a97b1dbe8456a9c76.js', + '718.c21a97b1dbe8456a9c76.js': '-/static/718.c21a97b1dbe8456a9c76.js', + '238.c21a97b1dbe8456a9c76.js': '-/static/238.c21a97b1dbe8456a9c76.js', + '73.c21a97b1dbe8456a9c76.js': '-/static/73.c21a97b1dbe8456a9c76.js' + }, + manifestFiles: { js: [ 'runtime.js', 'vendors.js', 'main.js' ] } +``` +- `staticPath`: is the same data returned in Verdaccio 4. +- `manifest`: A webpack manifest object. +- `manifestFiles`: A object with one property `js` and the array (order matters) of the manifest id to be loaded in the template dynamically. + +#### Manifest and Webpack {#manifest-and-webpack} + +Verdaccio uses the webpack [manifest](https://webpack.js.org/concepts/manifest/) object to render the html dynamically, in combination with the `manifestFiles` the application understand what to render. + +> Currently only support `js` but if you also need `css`, we are open to discuss it and further improvements. + +``` +const { WebpackManifestPlugin } = require('webpack-manifest-plugin'); + + plugins: [ + ... + new WebpackManifestPlugin({ + removeKeyHash: true, + }), + ... + ], + +``` + ## Legacy plugins {#legacy-plugins} ### Sinopia Plugins {#sinopia-plugins} diff --git a/website/docs/web.md b/website/docs/web.md index 682bfd09e..bf505f674 100644 --- a/website/docs/web.md +++ b/website/docs/web.md @@ -25,7 +25,15 @@ web: - npm - yarn - pnpm - login: true + login: true + scriptsBodyAfter: + - '' + metaScripts: + - '' + - '' + - '' + scriptsbodyBefore: + - '
html before webpack scripts
' ``` All access restrictions defined to [protect your packages](protect-your-dependencies.md) will also apply to the Web Interface. @@ -62,6 +70,10 @@ i18n: | rateLimit | object | No | use `userRateLimit` configuration | `>=v5.4.0` | Increase or decrease rate limit, by default is 5k request every 2 minutes, only limit web api endpoints, the CSS, JS, etcc are ingnored | | pkgManagers | npm, pnpm or yarn | false | npm | `>=v5.5.0` | Allow customise which package managers on the side bar and registry information dialog are visible | | login | boolean | true | true or false | `>=v5.5.0` | Allow disable login on the UI (also include web endpoints). | +| scriptsBodyAfter | string[] | No | any list of strings | `>=5.0.0` | inject scripts after the tag | +| metaScripts | string[] | No | any list of strings | `>=5.0.0` | inject scripts inside | +| scriptsbodyBefore | string[] | No | any list of strings | `>=5.0.0` | inject scripts before the | + > The recommended logo size is `40x40` pixels. diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index 4f00f951e..5adc75b36 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -59,7 +59,7 @@ module.exports = { announcementBar: { id: 'announcementBar', content: - 'Verdaccio stands for peace, we will be yellow/blue until Russia stop the criminal war, Help Ukraine Donating to Refugees! πŸ‡ΊπŸ‡¦', + 'You could help provide humanitarian support to Ukraine refugees, click here!', isCloseable: false, backgroundColor: '#1595de', textColor: '#ffffff', diff --git a/website/package.json b/website/package.json index 7fed5ab53..b10002399 100644 --- a/website/package.json +++ b/website/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@verdaccio/website", - "version": "5.7.0", + "version": "5.8.0", "scripts": { "docusaurus": "docusaurus", "start": "docusaurus start",