1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-02-21 07:29:37 +01:00

Merge pull request #869 from coolsp/feat-webui-scope

feat: adds option to set scope in webui instructions header
This commit is contained in:
Juan Picado @jotadeveloper 2018-07-31 13:55:18 +02:00 committed by GitHub
commit a97b0eb630
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 21 additions and 6 deletions

@ -13,6 +13,7 @@ plugins: ./plugins
web: web:
# WebUI is enabled as default, if you want disable it, just uncomment this line # WebUI is enabled as default, if you want disable it, just uncomment this line
#enable: false
title: Verdaccio title: Verdaccio
auth: auth:

@ -17,6 +17,7 @@ plugins: /verdaccio/plugins
web: web:
# WebUI is enabled as default, if you want disable it, just uncomment this line # WebUI is enabled as default, if you want disable it, just uncomment this line
#enable: false
title: Verdaccio title: Verdaccio
auth: auth:

@ -9,7 +9,11 @@ web:
title: Verdaccio title: Verdaccio
# logo: logo.png #logo: logo.png
# If you're using this registry for a specific module scope,
# specify that scope to set it in the webui instructions header (note: escape @ with \@)
#scope: \@myscope
auth: auth:
htpasswd: htpasswd:

@ -70,6 +70,7 @@ web:
enable: true enable: true
title: Verdaccio title: Verdaccio
logo: logo.png logo: logo.png
scope:
``` ```
### Uplinks ### Uplinks

@ -12,6 +12,7 @@ web:
enable: true enable: true
title: Verdaccio title: Verdaccio
logo: logo.png logo: logo.png
scope:
``` ```
All access restrictions defined to [protect your packages](protect-your-dependencies.md) will also apply to the Web Interface. All access restrictions defined to [protect your packages](protect-your-dependencies.md) will also apply to the Web Interface.
@ -23,3 +24,4 @@ Property | Type | Required | Example | Support | Description
enable | boolean | No | true/false | all | allow to display the web interface enable | boolean | No | true/false | all | allow to display the web interface
title | string | No | Verdaccio | all | HTML head title description title | string | No | Verdaccio | all | HTML head title description
logo | string | No | http://my.logo.domain/logo.png | all | a URI where logo is located logo | string | No | http://my.logo.domain/logo.png | all | a URI where logo is located
scope | string | No | \\@myscope | all | If you're using this registry for a specific module scope, specify that scope to set it in the webui instructions header (note: escape @ with \\@)

@ -43,7 +43,8 @@ module.exports = function(config, auth, storage) {
const base = Utils.combineBaseUrl(Utils.getWebProtocol(req), req.get('host'), config.url_prefix); const base = Utils.combineBaseUrl(Utils.getWebProtocol(req), req.get('host'), config.url_prefix);
let webPage = template let webPage = template
.replace(/ToReplaceByVerdaccio/g, base) .replace(/ToReplaceByVerdaccio/g, base)
.replace(/ToReplaceByTitle/g, _.get(config, 'web.title') ? config.web.title : WEB_TITLE); .replace(/ToReplaceByTitle/g, _.get(config, 'web.title') ? config.web.title : WEB_TITLE)
.replace(/ToReplaceByScope/g, _.get(config, 'web.scope') ? config.web.scope : '');
res.setHeader('Content-Type', 'text/html'); res.setHeader('Content-Type', 'text/html');

@ -21,8 +21,9 @@ export default class Header extends React.Component {
username: '', username: '',
password: '', password: '',
logo: '', logo: '',
loginError: null loginError: null,
} scope: (window.VERDACCIO_SCOPE) ? `${window.VERDACCIO_SCOPE}:` : ''
};
constructor(props) { constructor(props) {
super(props); super(props);
@ -158,7 +159,7 @@ export default class Header extends React.Component {
<img src={ this.state.logo } className={ classes.logo } /> <img src={ this.state.logo } className={ classes.logo } />
</Link> </Link>
<figure> <figure>
npm set registry { registryURL } npm set { this.state.scope }registry { registryURL }
<br/> <br/>
npm adduser --registry { registryURL } npm adduser --registry { registryURL }
</figure> </figure>

@ -7,6 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<script> <script>
window.VERDACCIO_API_URL = '<%= htmlWebpackPlugin.options.verdaccioURL %>/-/verdaccio/'; window.VERDACCIO_API_URL = '<%= htmlWebpackPlugin.options.verdaccioURL %>/-/verdaccio/';
window.VERDACCIO_SCOPE = '<%= htmlWebpackPlugin.options.scope %>';
</script> </script>
</head> </head>
<body class="body"> <body class="body">

@ -28,6 +28,7 @@ describe('<Header /> component shallow', () => {
username: '', username: '',
password: '', password: '',
logo: '', logo: '',
scope: '',
loginError: null loginError: null
}; };
const HeaderWrapper = wrapper.find(Header).dive(); const HeaderWrapper = wrapper.find(Header).dive();

@ -35,6 +35,7 @@ export default {
}), }),
new HTMLWebpackPlugin({ new HTMLWebpackPlugin({
title: 'Verdaccio', title: 'Verdaccio',
scope: '',
filename: 'index.html', filename: 'index.html',
verdaccioURL: '//localhost:4873', verdaccioURL: '//localhost:4873',
template: `${env.SRC_ROOT}/webui/template/index.html`, template: `${env.SRC_ROOT}/webui/template/index.html`,

@ -45,6 +45,7 @@ const prodConf = {
}), }),
new HTMLWebpackPlugin({ new HTMLWebpackPlugin({
title: 'ToReplaceByTitle', title: 'ToReplaceByTitle',
scope: 'ToReplaceByScope',
filename: 'index.html', filename: 'index.html',
favicon: `${env.SRC_ROOT}/webui/template/favicon.ico`, favicon: `${env.SRC_ROOT}/webui/template/favicon.ico`,
verdaccioURL: 'ToReplaceByVerdaccio', verdaccioURL: 'ToReplaceByVerdaccio',