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:
# WebUI is enabled as default, if you want disable it, just uncomment this line
#enable: false
title: Verdaccio
auth:

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

@ -11,6 +11,10 @@ web:
#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:
htpasswd:
file: ./htpasswd

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

@ -12,6 +12,7 @@ web:
enable: true
title: Verdaccio
logo: logo.png
scope:
```
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
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
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);
let webPage = template
.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');

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

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

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

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

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