@verdaccio/middleware 7.0.0-next-7.18 → 7.0.0-next-7.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/build/index.js.map +1 -1
- package/build/middlewares/allow.js +2 -2
- package/build/middlewares/allow.js.map +1 -1
- package/build/middlewares/antiLoop.js +1 -1
- package/build/middlewares/antiLoop.js.map +1 -1
- package/build/middlewares/encode-pkg.js.map +1 -1
- package/build/middlewares/error.js +1 -1
- package/build/middlewares/error.js.map +1 -1
- package/build/middlewares/final.js +2 -2
- package/build/middlewares/final.js.map +1 -1
- package/build/middlewares/json.js.map +1 -1
- package/build/middlewares/log.js +1 -1
- package/build/middlewares/log.js.map +1 -1
- package/build/middlewares/match.js.map +1 -1
- package/build/middlewares/media.js.map +1 -1
- package/build/middlewares/rate-limit.js +1 -1
- package/build/middlewares/rate-limit.js.map +1 -1
- package/build/middlewares/security-headers.js.map +1 -1
- package/build/middlewares/user-agent.js.map +1 -1
- package/build/middlewares/validation.js.map +1 -1
- package/build/middlewares/web/index.js +1 -1
- package/build/middlewares/web/index.js.map +1 -1
- package/build/middlewares/web/render-web.js +17 -7
- package/build/middlewares/web/render-web.js.map +1 -1
- package/build/middlewares/web/security.js.map +1 -1
- package/build/middlewares/web/utils/manifest.js +8 -2
- package/build/middlewares/web/utils/manifest.js.map +1 -1
- package/build/middlewares/web/utils/renderHTML.js +14 -12
- package/build/middlewares/web/utils/renderHTML.js.map +1 -1
- package/build/middlewares/web/utils/template.js +7 -7
- package/build/middlewares/web/utils/template.js.map +1 -1
- package/build/middlewares/web/utils/web-utils.js +2 -2
- package/build/middlewares/web/utils/web-utils.js.map +1 -1
- package/build/middlewares/web/web-api.js +1 -1
- package/build/middlewares/web/web-api.js.map +1 -1
- package/build/middlewares/web/web-middleware.js +1 -1
- package/build/middlewares/web/web-middleware.js.map +1 -1
- package/build/types.js.map +1 -1
- package/package.json +11 -10
- package/src/middlewares/web/render-web.ts +9 -1
- package/src/middlewares/web/utils/manifest.ts +9 -1
- package/src/middlewares/web/utils/renderHTML.ts +2 -0
- package/src/middlewares/web/utils/template.ts +6 -6
- package/test/__snapshots__/template.test.ts.snap +49 -69
- package/test/config/favicon.ico +0 -0
- package/test/config/file-logo.yaml +1 -0
- package/test/config/http-logo.yaml +26 -0
- package/test/config/no-logo.yaml +1 -0
- package/test/manifest.test.ts +12 -0
- package/test/render.spec.ts +16 -0
- package/test/template.test.ts +10 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderHTML.js","names":["_debug","_interopRequireDefault","require","_lruCache","_path","_url","_config","_core","_url2","_template","_webUtils","obj","__esModule","default","DEFAULT_LANGUAGE","cache","LRU","max","ttl","debug","buildDebug","defaultManifestFiles","js","ico","css","resolveLogo","logo","url_prefix","requestOptions","isLocalFile","isURLhasValidProtocol","getPublicUrl","path","basename","renderHTML","config","manifest","manifestFiles","res","_config$i18n$web","_config$i18n","_config$web$hideDepre","_config$web","_config$web2","_config$web3","_config$web$darkMode","_config$web4","_config$web$title","_config$web5","_config$web$scope","_config$web6","_config$web7","_config$web8","_config$web$pkgManage","_config$web9","_res$locals$app_versi","_validatePrimaryColor","_config$web$primary_c","_config$web10","_config$web11","base","URL","pathname","language","i18n","web","hideDeprecatedVersions","needHtmlCache","undefined","includes","html_cache","darkMode","title","WEB_TITLE","login","hasLogin","scope","logoDark","pkgManagers","version","locals","app_version","flags","experiments","primaryColor","validatePrimaryColor","primary_color","scriptsBodyAfter","metaScripts","scriptsbodyBefore","showInfo","showSettings","showThemeSwitch","showFooter","showSearch","showDownloadTarball","showRaw","showUplinks","Object","assign","bodyBefore","options","webPage","get","renderTemplate","set","error","Error","stack","setHeader","HEADERS","TEXT_HTML","send"],"sources":["../../../../src/middlewares/web/utils/renderHTML.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport type { Response } from 'express';\nimport LRU from 'lru-cache';\nimport path from 'path';\nimport { URL } from 'url';\n\nimport { WEB_TITLE } from '@verdaccio/config';\nimport { HEADERS } from '@verdaccio/core';\nimport { ConfigYaml, TemplateUIOptions } from '@verdaccio/types';\nimport type { RequestOptions } from '@verdaccio/url';\nimport { getPublicUrl, isURLhasValidProtocol } from '@verdaccio/url';\n\nimport type { Manifest } from './manifest';\nimport renderTemplate from './template';\nimport type { WebpackManifest } from './template';\nimport { hasLogin, validatePrimaryColor } from './web-utils';\n\nconst DEFAULT_LANGUAGE = 'es-US';\nconst cache = new LRU({ max: 500, ttl: 1000 * 60 * 60 });\n\nconst debug = buildDebug('verdaccio:web:render');\n\nconst defaultManifestFiles: Manifest = {\n js: ['runtime.js', 'vendors.js', 'main.js'],\n ico: 'favicon.ico',\n css: [],\n};\n\nexport function resolveLogo(\n logo: string | undefined,\n url_prefix: string | undefined,\n requestOptions: RequestOptions\n) {\n if (typeof logo !== 'string') {\n return '';\n }\n const isLocalFile = logo && !isURLhasValidProtocol(logo);\n\n if (isLocalFile) {\n return `${getPublicUrl(url_prefix, requestOptions)}-/static/${path.basename(logo)}`;\n } else if (isURLhasValidProtocol(logo)) {\n return logo;\n } else {\n return '';\n }\n}\n\nexport default function renderHTML(\n config: ConfigYaml,\n manifest: WebpackManifest,\n manifestFiles: Manifest | null | undefined,\n requestOptions: RequestOptions,\n res: Response\n) {\n const { url_prefix } = config;\n const base = getPublicUrl(config?.url_prefix, requestOptions);\n const basename = new URL(base).pathname;\n const language = config?.i18n?.web ?? DEFAULT_LANGUAGE;\n const hideDeprecatedVersions = config?.web?.hideDeprecatedVersions ?? false;\n // @ts-ignore\n const needHtmlCache = [undefined, null].includes(config?.web?.html_cache)\n ? true\n : config?.web?.html_cache;\n const darkMode = config?.web?.darkMode ?? false;\n const title = config?.web?.title ?? WEB_TITLE;\n const login = hasLogin(config);\n const scope = config?.web?.scope ?? '';\n const logo = resolveLogo(config?.web?.logo, config?.url_prefix, requestOptions);\n const logoDark = resolveLogo(config?.web?.logoDark, config?.url_prefix, requestOptions);\n const pkgManagers = config?.web?.pkgManagers ?? ['yarn', 'pnpm', 'npm'];\n const version = res.locals.app_version ?? '';\n const flags = {\n ...config.flags,\n // legacy from 5.x\n ...config.experiments,\n };\n const primaryColor =\n validatePrimaryColor(config?.web?.primary_color ?? config?.web?.primaryColor) ?? '#4b5e40';\n const {\n scriptsBodyAfter,\n metaScripts,\n scriptsbodyBefore,\n showInfo,\n showSettings,\n showThemeSwitch,\n showFooter,\n showSearch,\n showDownloadTarball,\n showRaw,\n showUplinks,\n } = Object.assign(\n {},\n {\n scriptsBodyAfter: [],\n bodyBefore: [],\n metaScripts: [],\n },\n config?.web\n );\n const options: TemplateUIOptions = {\n showInfo,\n showSettings,\n showThemeSwitch,\n showFooter,\n showSearch,\n showDownloadTarball,\n showRaw,\n showUplinks,\n darkMode,\n url_prefix,\n basename,\n base,\n primaryColor,\n version,\n logo,\n logoDark,\n flags,\n login,\n pkgManagers,\n title,\n scope,\n language,\n hideDeprecatedVersions,\n };\n\n let webPage;\n\n try {\n webPage = cache.get('template');\n if (!webPage) {\n webPage = renderTemplate(\n {\n manifest: manifestFiles ?? defaultManifestFiles,\n options,\n scriptsBodyAfter,\n metaScripts,\n scriptsbodyBefore,\n },\n manifest\n );\n\n if (needHtmlCache) {\n cache.set('template', webPage);\n debug('set template cache');\n }\n } else {\n debug('reuse template cache');\n }\n } catch (error: any) {\n throw new Error(`theme could not be load, stack ${error.stack}`);\n }\n res.setHeader('Content-Type', HEADERS.TEXT_HTML);\n res.send(webPage);\n debug('web rendered');\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAGA,IAAAM,KAAA,GAAAN,OAAA;AA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,IAAIoC,OAAO;EAEX,IAAI;IACFA,OAAO,GAAGvF,KAAK,CAACwF,GAAG,CAAC,UAAU,CAAC;IAC/B,IAAI,CAACD,OAAO,EAAE;MACZA,OAAO,GAAG,IAAAE,iBAAc,EACtB;QACEpE,QAAQ,EAAEC,aAAa,aAAbA,aAAa,cAAbA,aAAa,GAAIhB,oBAAoB;QAC/CgF,OAAO;QACPd,gBAAgB;QAChBC,WAAW;QACXC;MACF,CAAC,EACDrD,QACF,CAAC;MAED,IAAI+B,aAAa,EAAE;QACjBpD,KAAK,CAAC0F,GAAG,CAAC,UAAU,EAAEH,OAAO,CAAC;QAC9BnF,KAAK,CAAC,oBAAoB,CAAC;MAC7B;IACF,CAAC,MAAM;MACLA,KAAK,CAAC,sBAAsB,CAAC;IAC/B;EACF,CAAC,CAAC,OAAOuF,KAAU,EAAE;IACnB,MAAM,IAAIC,KAAK,CAAE,kCAAiCD,KAAK,CAACE,KAAM,EAAC,CAAC;EAClE;EACAtE,GAAG,CAACuE,SAAS,CAAC,cAAc,EAAEC,aAAO,CAACC,SAAS,CAAC;EAChDzE,GAAG,CAAC0E,IAAI,CAACV,OAAO,CAAC;EACjBnF,KAAK,CAAC,cAAc,CAAC;AACvB"}
|
|
1
|
+
{"version":3,"file":"renderHTML.js","names":["_debug","_interopRequireDefault","require","_lruCache","_path","_url","_config","_core","_url2","_template","_webUtils","e","__esModule","default","DEFAULT_LANGUAGE","cache","LRU","max","ttl","debug","buildDebug","defaultManifestFiles","js","ico","css","resolveLogo","logo","url_prefix","requestOptions","isLocalFile","isURLhasValidProtocol","getPublicUrl","path","basename","renderHTML","config","manifest","manifestFiles","res","_config$i18n$web","_config$i18n","_config$web$hideDepre","_config$web","_config$web2","_config$web3","_config$web$darkMode","_config$web4","_config$web$title","_config$web5","_config$web$scope","_config$web6","_config$web7","_config$web8","_config$web9","_config$web$pkgManage","_config$web10","_res$locals$app_versi","_validatePrimaryColor","_config$web$primary_c","_config$web11","_config$web12","base","URL","pathname","language","i18n","web","hideDeprecatedVersions","needHtmlCache","undefined","includes","html_cache","darkMode","title","WEB_TITLE","login","hasLogin","scope","favicon","logoDark","pkgManagers","version","locals","app_version","flags","experiments","primaryColor","validatePrimaryColor","primary_color","scriptsBodyAfter","metaScripts","scriptsbodyBefore","showInfo","showSettings","showThemeSwitch","showFooter","showSearch","showDownloadTarball","showRaw","showUplinks","Object","assign","bodyBefore","options","webPage","get","renderTemplate","set","error","Error","stack","setHeader","HEADERS","TEXT_HTML","send"],"sources":["../../../../src/middlewares/web/utils/renderHTML.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport type { Response } from 'express';\nimport LRU from 'lru-cache';\nimport path from 'path';\nimport { URL } from 'url';\n\nimport { WEB_TITLE } from '@verdaccio/config';\nimport { HEADERS } from '@verdaccio/core';\nimport { ConfigYaml, TemplateUIOptions } from '@verdaccio/types';\nimport type { RequestOptions } from '@verdaccio/url';\nimport { getPublicUrl, isURLhasValidProtocol } from '@verdaccio/url';\n\nimport type { Manifest } from './manifest';\nimport renderTemplate from './template';\nimport type { WebpackManifest } from './template';\nimport { hasLogin, validatePrimaryColor } from './web-utils';\n\nconst DEFAULT_LANGUAGE = 'es-US';\nconst cache = new LRU({ max: 500, ttl: 1000 * 60 * 60 });\n\nconst debug = buildDebug('verdaccio:web:render');\n\nconst defaultManifestFiles: Manifest = {\n js: ['runtime.js', 'vendors.js', 'main.js'],\n ico: 'favicon.ico',\n css: [],\n};\n\nexport function resolveLogo(\n logo: string | undefined,\n url_prefix: string | undefined,\n requestOptions: RequestOptions\n) {\n if (typeof logo !== 'string') {\n return '';\n }\n const isLocalFile = logo && !isURLhasValidProtocol(logo);\n\n if (isLocalFile) {\n return `${getPublicUrl(url_prefix, requestOptions)}-/static/${path.basename(logo)}`;\n } else if (isURLhasValidProtocol(logo)) {\n return logo;\n } else {\n return '';\n }\n}\n\nexport default function renderHTML(\n config: ConfigYaml,\n manifest: WebpackManifest,\n manifestFiles: Manifest | null | undefined,\n requestOptions: RequestOptions,\n res: Response\n) {\n const { url_prefix } = config;\n const base = getPublicUrl(config?.url_prefix, requestOptions);\n const basename = new URL(base).pathname;\n const language = config?.i18n?.web ?? DEFAULT_LANGUAGE;\n const hideDeprecatedVersions = config?.web?.hideDeprecatedVersions ?? false;\n // @ts-ignore\n const needHtmlCache = [undefined, null].includes(config?.web?.html_cache)\n ? true\n : config?.web?.html_cache;\n const darkMode = config?.web?.darkMode ?? false;\n const title = config?.web?.title ?? WEB_TITLE;\n const login = hasLogin(config);\n const scope = config?.web?.scope ?? '';\n const favicon = resolveLogo(config?.web?.favicon, config?.url_prefix, requestOptions);\n const logo = resolveLogo(config?.web?.logo, config?.url_prefix, requestOptions);\n const logoDark = resolveLogo(config?.web?.logoDark, config?.url_prefix, requestOptions);\n const pkgManagers = config?.web?.pkgManagers ?? ['yarn', 'pnpm', 'npm'];\n const version = res.locals.app_version ?? '';\n const flags = {\n ...config.flags,\n // legacy from 5.x\n ...config.experiments,\n };\n const primaryColor =\n validatePrimaryColor(config?.web?.primary_color ?? config?.web?.primaryColor) ?? '#4b5e40';\n const {\n scriptsBodyAfter,\n metaScripts,\n scriptsbodyBefore,\n showInfo,\n showSettings,\n showThemeSwitch,\n showFooter,\n showSearch,\n showDownloadTarball,\n showRaw,\n showUplinks,\n } = Object.assign(\n {},\n {\n scriptsBodyAfter: [],\n bodyBefore: [],\n metaScripts: [],\n },\n config?.web\n );\n const options: TemplateUIOptions = {\n showInfo,\n showSettings,\n showThemeSwitch,\n showFooter,\n showSearch,\n showDownloadTarball,\n showRaw,\n showUplinks,\n darkMode,\n url_prefix,\n basename,\n base,\n primaryColor,\n version,\n logo,\n logoDark,\n favicon,\n flags,\n login,\n pkgManagers,\n title,\n scope,\n language,\n hideDeprecatedVersions,\n };\n\n let webPage;\n\n try {\n webPage = cache.get('template');\n if (!webPage) {\n webPage = renderTemplate(\n {\n manifest: manifestFiles ?? defaultManifestFiles,\n options,\n scriptsBodyAfter,\n metaScripts,\n scriptsbodyBefore,\n },\n manifest\n );\n\n if (needHtmlCache) {\n cache.set('template', webPage);\n debug('set template cache');\n }\n } else {\n debug('reuse template cache');\n }\n } catch (error: any) {\n throw new Error(`theme could not be load, stack ${error.stack}`);\n }\n res.setHeader('Content-Type', HEADERS.TEXT_HTML);\n res.send(webPage);\n debug('web rendered');\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAGA,IAAAM,KAAA,GAAAN,OAAA;AAGA,IAAAO,SAAA,GAAAR,sBAAA,CAAAC,OAAA;AAEA,IAAAQ,SAAA,GAAAR,OAAA;AAA6D,SAAAD,uBAAAU,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE7D,MAAMG,gBAAgB,GAAG,OAAO;AAChC,MAAMC,KAAK,GAAG,IAAIC,iBAAG,CAAC;EAAEC,GAAG,EAAE,GAAG;EAAEC,GAAG,EAAE,IAAI,GAAG,EAAE,GAAG;AAAG,CAAC,CAAC;AAExD,MAAMC,KAAK,GAAG,IAAAC,cAAU,EAAC,sBAAsB,CAAC;AAEhD,MAAMC,oBAA8B,GAAG;EACrCC,EAAE,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,SAAS,CAAC;EAC3CC,GAAG,EAAE,aAAa;EAClBC,GAAG,EAAE;AACP,CAAC;AAEM,SAASC,WAAWA,CACzBC,IAAwB,EACxBC,UAA8B,EAC9BC,cAA8B,EAC9B;EACA,IAAI,OAAOF,IAAI,KAAK,QAAQ,EAAE;IAC5B,OAAO,EAAE;EACX;EACA,MAAMG,WAAW,GAAGH,IAAI,IAAI,CAAC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AAC,CAAC,OAAOyF,KAAU,EAAE;IACnB,MAAM,IAAIC,KAAK,CAAC,kCAAkCD,KAAK,CAACE,KAAK,EAAE,CAAC;EAClE;EACAxE,GAAG,CAACyE,SAAS,CAAC,cAAc,EAAEC,aAAO,CAACC,SAAS,CAAC;EAChD3E,GAAG,CAAC4E,IAAI,CAACV,OAAO,CAAC;EACjBrF,KAAK,CAAC,cAAc,CAAC;AACvB","ignoreList":[]}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = renderTemplate;
|
|
7
7
|
var _debug = _interopRequireDefault(require("debug"));
|
|
8
8
|
var _manifest = require("./manifest");
|
|
9
|
-
function _interopRequireDefault(
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
10
|
const debug = (0, _debug.default)('verdaccio:web:render:template');
|
|
11
11
|
|
|
12
12
|
// the outcome of the Webpack Manifest Plugin
|
|
@@ -17,22 +17,22 @@ function renderTemplate(template, manifest) {
|
|
|
17
17
|
debug('manifest %o', manifest);
|
|
18
18
|
return `
|
|
19
19
|
<!DOCTYPE html>
|
|
20
|
-
<html lang="en-us">
|
|
20
|
+
<html lang="en-us">
|
|
21
21
|
<head>
|
|
22
22
|
<meta charset="utf-8">
|
|
23
23
|
<base href="${template === null || template === void 0 ? void 0 : template.options.base}">
|
|
24
|
-
<title>${(_template$options$tit = template === null || template === void 0
|
|
24
|
+
<title>${(_template$options$tit = template === null || template === void 0 || (_template$options = template.options) === null || _template$options === void 0 ? void 0 : _template$options.title) !== null && _template$options$tit !== void 0 ? _template$options$tit : ''}</title>
|
|
25
25
|
<link rel="icon" href="${template === null || template === void 0 ? void 0 : template.options.base}-/static/favicon.ico"/>
|
|
26
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
26
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
27
27
|
<script>
|
|
28
28
|
window.__VERDACCIO_BASENAME_UI_OPTIONS=${JSON.stringify(template.options)}
|
|
29
29
|
</script>
|
|
30
30
|
${template !== null && template !== void 0 && template.metaScripts ? template.metaScripts.join('') : ''}
|
|
31
|
-
</head>
|
|
31
|
+
</head>
|
|
32
32
|
<body class="body">
|
|
33
|
-
|
|
33
|
+
${template !== null && template !== void 0 && template.scriptsbodyBefore ? template.scriptsbodyBefore.join('') : ''}
|
|
34
34
|
<div id="root"></div>
|
|
35
|
-
${(0, _manifest.getManifestValue)(template.manifest.js, manifest, template === null || template === void 0 ? void 0 : template.options.base).map(item => `<script defer="defer" src="${item}"></script>`).join(
|
|
35
|
+
${(0, _manifest.getManifestValue)(template.manifest.js, manifest, template === null || template === void 0 ? void 0 : template.options.base).map(item => `<script defer="defer" src="${item}"></script>`).join(`\n `)}
|
|
36
36
|
${template !== null && template !== void 0 && template.scriptsBodyAfter ? template.scriptsBodyAfter.join('') : ''}
|
|
37
37
|
</body>
|
|
38
38
|
</html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","names":["_debug","_interopRequireDefault","require","_manifest","
|
|
1
|
+
{"version":3,"file":"template.js","names":["_debug","_interopRequireDefault","require","_manifest","e","__esModule","default","debug","buildDebug","renderTemplate","template","manifest","_template$options$tit","_template$options","options","base","title","JSON","stringify","metaScripts","join","scriptsbodyBefore","getManifestValue","js","map","item","scriptsBodyAfter"],"sources":["../../../../src/middlewares/web/utils/template.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nimport { TemplateUIOptions } from '@verdaccio/types';\n\nimport { Manifest, getManifestValue } from './manifest';\n\nconst debug = buildDebug('verdaccio:web:render:template');\n\nexport type Template = {\n manifest: Manifest;\n options: TemplateUIOptions;\n metaScripts?: string[];\n scriptsBodyAfter?: string[];\n scriptsbodyBefore?: string[];\n};\n\n// the outcome of the Webpack Manifest Plugin\nexport interface WebpackManifest {\n [key: string]: string;\n}\n\nexport default function renderTemplate(template: Template, manifest: WebpackManifest) {\n debug('template %o', template);\n debug('manifest %o', manifest);\n\n return `\n <!DOCTYPE html>\n <html lang=\"en-us\">\n <head>\n <meta charset=\"utf-8\">\n <base href=\"${template?.options.base}\">\n <title>${template?.options?.title ?? ''}</title>\n <link rel=\"icon\" href=\"${template?.options.base}-/static/favicon.ico\"/>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <script>\n window.__VERDACCIO_BASENAME_UI_OPTIONS=${JSON.stringify(template.options)}\n </script>\n ${template?.metaScripts ? template.metaScripts.join('') : ''}\n </head>\n <body class=\"body\">\n ${template?.scriptsbodyBefore ? template.scriptsbodyBefore.join('') : ''}\n <div id=\"root\"></div>\n ${getManifestValue(template.manifest.js, manifest, template?.options.base)\n .map((item) => `<script defer=\"defer\" src=\"${item}\"></script>`)\n .join(`\\n `)}\n ${template?.scriptsBodyAfter ? template.scriptsBodyAfter.join('') : ''}\n </body>\n </html>\n `;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA,IAAAC,SAAA,GAAAD,OAAA;AAAwD,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAExD,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,+BAA+B,CAAC;;AAUzD;;AAKe,SAASC,cAAcA,CAACC,QAAkB,EAAEC,QAAyB,EAAE;EAAA,IAAAC,qBAAA,EAAAC,iBAAA;EACpFN,KAAK,CAAC,aAAa,EAAEG,QAAQ,CAAC;EAC9BH,KAAK,CAAC,aAAa,EAAEI,QAAQ,CAAC;EAE9B,OAAO;AACT;AACA;AACA;AACA;AACA,sBAAsBD,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEI,OAAO,CAACC,IAAI;AAC5C,iBAD4C,CAAAH,qBAAA,GAC3BF,QAAQ,aAARA,QAAQ,gBAAAG,iBAAA,GAARH,QAAQ,CAAEI,OAAO,cAAAD,iBAAA,uBAAjBA,iBAAA,CAAmBG,KAAK,cAAAJ,qBAAA,cAAAA,qBAAA,GAAI,EAAE;AAC/C,iCAAiCF,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEI,OAAO,CAACC,IAAI;AACvD;AACA;AACA,qDAAqDE,IAAI,CAACC,SAAS,CAACR,QAAQ,CAACI,OAAO,CAAC;AACrF;AACA,UAAUJ,QAAQ,aAARA,QAAQ,eAARA,QAAQ,CAAES,WAAW,GAAGT,QAAQ,CAACS,WAAW,CAACC,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE;AACpE;AACA;AACA,UAAUV,QAAQ,aAARA,QAAQ,eAARA,QAAQ,CAAEW,iBAAiB,GAAGX,QAAQ,CAACW,iBAAiB,CAACD,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE;AAChF;AACA,UAAU,IAAAE,0BAAgB,EAACZ,QAAQ,CAACC,QAAQ,CAACY,EAAE,EAAEZ,QAAQ,EAAED,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEI,OAAO,CAACC,IAAI,CAAC,CACvES,GAAG,CAAEC,IAAI,IAAK,8BAA8BA,IAAI,aAAa,CAAC,CAC9DL,IAAI,CAAC,YAAY,CAAC;AAC7B,UAAUV,QAAQ,aAARA,QAAQ,eAARA,QAAQ,CAAEgB,gBAAgB,GAAGhB,QAAQ,CAACgB,gBAAgB,CAACN,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE;AAC9E;AACA;AACA,GAAG;AACH","ignoreList":[]}
|
|
@@ -7,7 +7,7 @@ exports.hasLogin = hasLogin;
|
|
|
7
7
|
exports.validatePrimaryColor = validatePrimaryColor;
|
|
8
8
|
var _debug = _interopRequireDefault(require("debug"));
|
|
9
9
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
10
|
-
function _interopRequireDefault(
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
11
|
const debug = (0, _debug.default)('verdaccio:web:middlwares');
|
|
12
12
|
function validatePrimaryColor(primaryColor) {
|
|
13
13
|
const isHex = /^#([0-9A-F]{3}){1,2}$/i.test(primaryColor);
|
|
@@ -19,6 +19,6 @@ function validatePrimaryColor(primaryColor) {
|
|
|
19
19
|
}
|
|
20
20
|
function hasLogin(config) {
|
|
21
21
|
var _config$web, _config$web2;
|
|
22
|
-
return _lodash.default.isNil(config === null || config === void 0
|
|
22
|
+
return _lodash.default.isNil(config === null || config === void 0 || (_config$web = config.web) === null || _config$web === void 0 ? void 0 : _config$web.login) || (config === null || config === void 0 || (_config$web2 = config.web) === null || _config$web2 === void 0 ? void 0 : _config$web2.login) === true;
|
|
23
23
|
}
|
|
24
24
|
//# sourceMappingURL=web-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-utils.js","names":["_debug","_interopRequireDefault","require","_lodash","
|
|
1
|
+
{"version":3,"file":"web-utils.js","names":["_debug","_interopRequireDefault","require","_lodash","e","__esModule","default","debug","buildDebug","validatePrimaryColor","primaryColor","isHex","test","hasLogin","config","_config$web","_config$web2","_","isNil","web","login"],"sources":["../../../../src/middlewares/web/utils/web-utils.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\n\nconst debug = buildDebug('verdaccio:web:middlwares');\n\nexport function validatePrimaryColor(primaryColor) {\n const isHex = /^#([0-9A-F]{3}){1,2}$/i.test(primaryColor);\n if (!isHex) {\n debug('invalid primary color %o', primaryColor);\n return;\n }\n\n return primaryColor;\n}\n\nexport function hasLogin(config: any) {\n return _.isNil(config?.web?.login) || config?.web?.login === true;\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAuB,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEvB,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,0BAA0B,CAAC;AAE7C,SAASC,oBAAoBA,CAACC,YAAY,EAAE;EACjD,MAAMC,KAAK,GAAG,wBAAwB,CAACC,IAAI,CAACF,YAAY,CAAC;EACzD,IAAI,CAACC,KAAK,EAAE;IACVJ,KAAK,CAAC,0BAA0B,EAAEG,YAAY,CAAC;IAC/C;EACF;EAEA,OAAOA,YAAY;AACrB;AAEO,SAASG,QAAQA,CAACC,MAAW,EAAE;EAAA,IAAAC,WAAA,EAAAC,YAAA;EACpC,OAAOC,eAAC,CAACC,KAAK,CAACJ,MAAM,aAANA,MAAM,gBAAAC,WAAA,GAAND,MAAM,CAAEK,GAAG,cAAAJ,WAAA,uBAAXA,WAAA,CAAaK,KAAK,CAAC,IAAI,CAAAN,MAAM,aAANA,MAAM,gBAAAE,YAAA,GAANF,MAAM,CAAEK,GAAG,cAAAH,YAAA,uBAAXA,YAAA,CAAaI,KAAK,MAAK,IAAI;AACnE","ignoreList":[]}
|
|
@@ -8,7 +8,7 @@ var _express = _interopRequireWildcard(require("express"));
|
|
|
8
8
|
var _validation = require("../validation");
|
|
9
9
|
var _security = require("./security");
|
|
10
10
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
11
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
12
12
|
function webAPIMiddleware(tokenMiddleware, webEndpointsApi) {
|
|
13
13
|
// eslint-disable-next-line new-cap
|
|
14
14
|
const route = (0, _express.Router)();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-api.js","names":["_express","_interopRequireWildcard","require","_validation","_security","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","
|
|
1
|
+
{"version":3,"file":"web-api.js","names":["_express","_interopRequireWildcard","require","_validation","_security","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","webAPIMiddleware","tokenMiddleware","webEndpointsApi","route","Router","param","validatePackage","validateName","use","express","urlencoded","extended","setSecurityWebHeaders"],"sources":["../../../src/middlewares/web/web-api.ts"],"sourcesContent":["import express from 'express';\nimport { RequestHandler, Router } from 'express';\n\nimport { validateName, validatePackage } from '../validation';\nimport { setSecurityWebHeaders } from './security';\n\nexport function webAPIMiddleware(\n tokenMiddleware: RequestHandler,\n webEndpointsApi: RequestHandler\n): Router {\n // eslint-disable-next-line new-cap\n const route = Router();\n // validate all of these params as a package name\n // this might be too harsh, so ask if it causes trouble=\n route.param('package', validatePackage);\n route.param('filename', validateName);\n route.param('version', validateName);\n route.use(express.urlencoded({ extended: false }));\n route.use(setSecurityWebHeaders);\n\n if (typeof tokenMiddleware === 'function') {\n route.use(tokenMiddleware);\n }\n\n if (typeof webEndpointsApi === 'function') {\n route.use(webEndpointsApi);\n }\n\n return route;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,uBAAA,CAAAC,OAAA;AAGA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAA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,CAAC,SAAS,EAAEC,2BAAe,CAAC;EACvCH,KAAK,CAACE,KAAK,CAAC,UAAU,EAAEE,wBAAY,CAAC;EACrCJ,KAAK,CAACE,KAAK,CAAC,SAAS,EAAEE,wBAAY,CAAC;EACpCJ,KAAK,CAACK,GAAG,CAACC,gBAAO,CAACC,UAAU,CAAC;IAAEC,QAAQ,EAAE;EAAM,CAAC,CAAC,CAAC;EAClDR,KAAK,CAACK,GAAG,CAACI,+BAAqB,CAAC;EAEhC,IAAI,OAAOX,eAAe,KAAK,UAAU,EAAE;IACzCE,KAAK,CAACK,GAAG,CAACP,eAAe,CAAC;EAC5B;EAEA,IAAI,OAAOC,eAAe,KAAK,UAAU,EAAE;IACzCC,KAAK,CAACK,GAAG,CAACN,eAAe,CAAC;EAC5B;EAEA,OAAOC,KAAK;AACd","ignoreList":[]}
|
|
@@ -7,7 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
var _express = _interopRequireDefault(require("express"));
|
|
8
8
|
var _renderWeb = require("./render-web");
|
|
9
9
|
var _webApi = require("./web-api");
|
|
10
|
-
function _interopRequireDefault(
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
11
|
var _default = (config, middlewares, pluginOptions) => {
|
|
12
12
|
// eslint-disable-next-line new-cap
|
|
13
13
|
const router = _express.default.Router();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-middleware.js","names":["_express","_interopRequireDefault","require","_renderWeb","_webApi","
|
|
1
|
+
{"version":3,"file":"web-middleware.js","names":["_express","_interopRequireDefault","require","_renderWeb","_webApi","e","__esModule","default","_default","config","middlewares","pluginOptions","router","express","Router","tokenMiddleware","webEndpointsApi","use","renderWebMiddleware","webAPIMiddleware","exports"],"sources":["../../../src/middlewares/web/web-middleware.ts"],"sourcesContent":["import express from 'express';\n\nimport { renderWebMiddleware } from './render-web';\nimport { webAPIMiddleware } from './web-api';\n\nexport default (config, middlewares, pluginOptions): any => {\n // eslint-disable-next-line new-cap\n const router = express.Router();\n const { tokenMiddleware, webEndpointsApi } = middlewares;\n // render web\n router.use('/', renderWebMiddleware(config, tokenMiddleware, pluginOptions));\n // web endpoints, search, packages, etc\n router.use('/-/verdaccio/', webAPIMiddleware(tokenMiddleware, webEndpointsApi));\n return router;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAA6C,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,IAAAG,QAAA,GAE9BA,CAACC,MAAM,EAAEC,WAAW,EAAEC,aAAa,KAAU;EAC1D;EACA,MAAMC,MAAM,GAAGC,gBAAO,CAACC,MAAM,CAAC,CAAC;EAC/B,MAAM;IAAEC,eAAe;IAAEC;EAAgB,CAAC,GAAGN,WAAW;EACxD;EACAE,MAAM,CAACK,GAAG,CAAC,GAAG,EAAE,IAAAC,8BAAmB,EAACT,MAAM,EAAEM,eAAe,EAAEJ,aAAa,CAAC,CAAC;EAC5E;EACAC,MAAM,CAACK,GAAG,CAAC,eAAe,EAAE,IAAAE,wBAAgB,EAACJ,eAAe,EAAEC,eAAe,CAAC,CAAC;EAC/E,OAAOJ,MAAM;AACf,CAAC;AAAAQ,OAAA,CAAAb,OAAA,GAAAC,QAAA","ignoreList":[]}
|
package/build/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import { NextFunction, Request, Response } from 'express';\n\nimport { Logger, RemoteUser } from '@verdaccio/types';\n\nexport type $RequestExtend = Request & { remote_user?: RemoteUser; log: Logger };\nexport type $ResponseExtend = Response & { cookies?: any };\nexport type $NextFunctionVer = NextFunction & any;\n\nexport interface MiddlewareError {\n error: string;\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import { NextFunction, Request, Response } from 'express';\n\nimport { Logger, RemoteUser } from '@verdaccio/types';\n\nexport type $RequestExtend = Request & { remote_user?: RemoteUser; log: Logger };\nexport type $ResponseExtend = Response & { cookies?: any };\nexport type $NextFunctionVer = NextFunction & any;\n\nexport interface MiddlewareError {\n error: string;\n}\n"],"mappings":"","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/middleware",
|
|
3
|
-
"version": "7.0.0-next-7.
|
|
3
|
+
"version": "7.0.0-next-7.20",
|
|
4
4
|
"description": "express middleware utils",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -29,25 +29,25 @@
|
|
|
29
29
|
"node": ">=12"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@verdaccio/
|
|
33
|
-
"@verdaccio/
|
|
34
|
-
"@verdaccio/
|
|
35
|
-
"@verdaccio/
|
|
32
|
+
"@verdaccio/config": "7.0.0-next-7.20",
|
|
33
|
+
"@verdaccio/core": "7.0.0-next-7.20",
|
|
34
|
+
"@verdaccio/url": "12.0.0-next-7.20",
|
|
35
|
+
"@verdaccio/utils": "7.0.0-next-7.20",
|
|
36
36
|
"debug": "4.3.4",
|
|
37
|
-
"lru-cache": "7.18.3",
|
|
38
37
|
"express": "4.19.2",
|
|
38
|
+
"express-rate-limit": "5.5.1",
|
|
39
39
|
"lodash": "4.17.21",
|
|
40
|
-
"
|
|
41
|
-
"
|
|
40
|
+
"lru-cache": "7.18.3",
|
|
41
|
+
"mime": "2.6.0"
|
|
42
42
|
},
|
|
43
43
|
"funding": {
|
|
44
44
|
"type": "opencollective",
|
|
45
45
|
"url": "https://opencollective.com/verdaccio"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@verdaccio/logger": "7.0.0-next-7.
|
|
48
|
+
"@verdaccio/logger": "7.0.0-next-7.20",
|
|
49
49
|
"body-parser": "1.20.2",
|
|
50
|
-
"supertest": "
|
|
50
|
+
"supertest": "7.0.0"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"clean": "rimraf ./build",
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps",
|
|
57
57
|
"watch": "pnpm build:js -- --watch",
|
|
58
58
|
"test": "jest",
|
|
59
|
+
"test:snap": "jest --updateSnapshot",
|
|
59
60
|
"build": "pnpm run build:js && pnpm run build:types"
|
|
60
61
|
}
|
|
61
62
|
}
|
|
@@ -37,7 +37,15 @@ export function renderWebMiddleware(config, tokenMiddleware, pluginOptions) {
|
|
|
37
37
|
// any match within the static is routed to the file system
|
|
38
38
|
router.get('/-/static/*', function (req, res, next) {
|
|
39
39
|
const filename = req.params[0];
|
|
40
|
-
|
|
40
|
+
let file = `${staticPath}/${filename}`;
|
|
41
|
+
if (filename === 'favicon.ico' && config?.web?.favicon) {
|
|
42
|
+
file = config?.web?.favicon;
|
|
43
|
+
if (isURLhasValidProtocol(file)) {
|
|
44
|
+
debug('redirect to favicon %s', file);
|
|
45
|
+
req.url = file;
|
|
46
|
+
return next();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
41
49
|
debug('render static file %o', file);
|
|
42
50
|
res.sendFile(file, sendFileCallback(next));
|
|
43
51
|
});
|
|
@@ -16,8 +16,16 @@ export function getManifestValue(
|
|
|
16
16
|
): string[] {
|
|
17
17
|
return manifestItems?.map((item) => {
|
|
18
18
|
debug('resolve item %o', item);
|
|
19
|
-
const resolvedItem = `${basePath}
|
|
19
|
+
const resolvedItem = `${stripTrailingSlash(basePath)}/${stripLeadingSlash(manifest[item])}`;
|
|
20
20
|
debug('resolved item %o', resolvedItem);
|
|
21
21
|
return resolvedItem;
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
function stripTrailingSlash(path: string): string {
|
|
26
|
+
return path.replace(/\/$/, '');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function stripLeadingSlash(path: string): string {
|
|
30
|
+
return path.replace(/^\//, '');
|
|
31
|
+
}
|
|
@@ -65,6 +65,7 @@ export default function renderHTML(
|
|
|
65
65
|
const title = config?.web?.title ?? WEB_TITLE;
|
|
66
66
|
const login = hasLogin(config);
|
|
67
67
|
const scope = config?.web?.scope ?? '';
|
|
68
|
+
const favicon = resolveLogo(config?.web?.favicon, config?.url_prefix, requestOptions);
|
|
68
69
|
const logo = resolveLogo(config?.web?.logo, config?.url_prefix, requestOptions);
|
|
69
70
|
const logoDark = resolveLogo(config?.web?.logoDark, config?.url_prefix, requestOptions);
|
|
70
71
|
const pkgManagers = config?.web?.pkgManagers ?? ['yarn', 'pnpm', 'npm'];
|
|
@@ -114,6 +115,7 @@ export default function renderHTML(
|
|
|
114
115
|
version,
|
|
115
116
|
logo,
|
|
116
117
|
logoDark,
|
|
118
|
+
favicon,
|
|
117
119
|
flags,
|
|
118
120
|
login,
|
|
119
121
|
pkgManagers,
|
|
@@ -25,24 +25,24 @@ export default function renderTemplate(template: Template, manifest: WebpackMani
|
|
|
25
25
|
|
|
26
26
|
return `
|
|
27
27
|
<!DOCTYPE html>
|
|
28
|
-
<html lang="en-us">
|
|
28
|
+
<html lang="en-us">
|
|
29
29
|
<head>
|
|
30
30
|
<meta charset="utf-8">
|
|
31
31
|
<base href="${template?.options.base}">
|
|
32
|
-
<title>${template?.options?.title ?? ''}</title>
|
|
32
|
+
<title>${template?.options?.title ?? ''}</title>
|
|
33
33
|
<link rel="icon" href="${template?.options.base}-/static/favicon.ico"/>
|
|
34
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
34
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
35
35
|
<script>
|
|
36
36
|
window.__VERDACCIO_BASENAME_UI_OPTIONS=${JSON.stringify(template.options)}
|
|
37
37
|
</script>
|
|
38
38
|
${template?.metaScripts ? template.metaScripts.join('') : ''}
|
|
39
|
-
</head>
|
|
39
|
+
</head>
|
|
40
40
|
<body class="body">
|
|
41
|
-
|
|
41
|
+
${template?.scriptsbodyBefore ? template.scriptsbodyBefore.join('') : ''}
|
|
42
42
|
<div id="root"></div>
|
|
43
43
|
${getManifestValue(template.manifest.js, manifest, template?.options.base)
|
|
44
44
|
.map((item) => `<script defer="defer" src="${item}"></script>`)
|
|
45
|
-
.join(
|
|
45
|
+
.join(`\n `)}
|
|
46
46
|
${template?.scriptsBodyAfter ? template.scriptsBodyAfter.join('') : ''}
|
|
47
47
|
</body>
|
|
48
48
|
</html>
|
|
@@ -3,22 +3,23 @@
|
|
|
3
3
|
exports[`template custom body after 1`] = `
|
|
4
4
|
"
|
|
5
5
|
<!DOCTYPE html>
|
|
6
|
-
<html lang="en-us">
|
|
6
|
+
<html lang="en-us">
|
|
7
7
|
<head>
|
|
8
8
|
<meta charset="utf-8">
|
|
9
|
-
<base href="http://domain.com">
|
|
10
|
-
<title></title>
|
|
11
|
-
<link rel="icon" href="http://domain.com
|
|
12
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
9
|
+
<base href="http://domain.com/">
|
|
10
|
+
<title></title>
|
|
11
|
+
<link rel="icon" href="http://domain.com/-/static/favicon.ico"/>
|
|
12
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
13
13
|
<script>
|
|
14
|
-
window.__VERDACCIO_BASENAME_UI_OPTIONS={"base":"http://domain.com"}
|
|
14
|
+
window.__VERDACCIO_BASENAME_UI_OPTIONS={"base":"http://domain.com/"}
|
|
15
15
|
</script>
|
|
16
16
|
|
|
17
|
-
</head>
|
|
17
|
+
</head>
|
|
18
18
|
<body class="body">
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
<div id="root"></div>
|
|
21
|
-
<script defer="defer" src="http://domain.com/-/static/runtime.6126058572f989c948b1.js"></script
|
|
21
|
+
<script defer="defer" src="http://domain.com/-/static/runtime.6126058572f989c948b1.js"></script>
|
|
22
|
+
<script defer="defer" src="http://domain.com/-/static/main.6126058572f989c948b1.js"></script>
|
|
22
23
|
<script src="foo"/>
|
|
23
24
|
</body>
|
|
24
25
|
</html>
|
|
@@ -28,22 +29,23 @@ exports[`template custom body after 1`] = `
|
|
|
28
29
|
exports[`template custom body before 1`] = `
|
|
29
30
|
"
|
|
30
31
|
<!DOCTYPE html>
|
|
31
|
-
<html lang="en-us">
|
|
32
|
+
<html lang="en-us">
|
|
32
33
|
<head>
|
|
33
34
|
<meta charset="utf-8">
|
|
34
|
-
<base href="http://domain.com">
|
|
35
|
-
<title></title>
|
|
36
|
-
<link rel="icon" href="http://domain.com
|
|
37
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
35
|
+
<base href="http://domain.com/">
|
|
36
|
+
<title></title>
|
|
37
|
+
<link rel="icon" href="http://domain.com/-/static/favicon.ico"/>
|
|
38
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
38
39
|
<script>
|
|
39
|
-
window.__VERDACCIO_BASENAME_UI_OPTIONS={"base":"http://domain.com"}
|
|
40
|
+
window.__VERDACCIO_BASENAME_UI_OPTIONS={"base":"http://domain.com/"}
|
|
40
41
|
</script>
|
|
41
42
|
|
|
42
|
-
</head>
|
|
43
|
+
</head>
|
|
43
44
|
<body class="body">
|
|
44
|
-
|
|
45
|
+
<script src="fooBefore"/><script src="barBefore"/>
|
|
45
46
|
<div id="root"></div>
|
|
46
|
-
<script defer="defer" src="http://domain.com/-/static/runtime.6126058572f989c948b1.js"></script
|
|
47
|
+
<script defer="defer" src="http://domain.com/-/static/runtime.6126058572f989c948b1.js"></script>
|
|
48
|
+
<script defer="defer" src="http://domain.com/-/static/main.6126058572f989c948b1.js"></script>
|
|
47
49
|
|
|
48
50
|
</body>
|
|
49
51
|
</html>
|
|
@@ -53,22 +55,23 @@ exports[`template custom body before 1`] = `
|
|
|
53
55
|
exports[`template custom render 1`] = `
|
|
54
56
|
"
|
|
55
57
|
<!DOCTYPE html>
|
|
56
|
-
<html lang="en-us">
|
|
58
|
+
<html lang="en-us">
|
|
57
59
|
<head>
|
|
58
60
|
<meta charset="utf-8">
|
|
59
|
-
<base href="http://domain.com">
|
|
60
|
-
<title></title>
|
|
61
|
-
<link rel="icon" href="http://domain.com
|
|
62
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
61
|
+
<base href="http://domain.com/">
|
|
62
|
+
<title></title>
|
|
63
|
+
<link rel="icon" href="http://domain.com/-/static/favicon.ico"/>
|
|
64
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
63
65
|
<script>
|
|
64
|
-
window.__VERDACCIO_BASENAME_UI_OPTIONS={"base":"http://domain.com"}
|
|
66
|
+
window.__VERDACCIO_BASENAME_UI_OPTIONS={"base":"http://domain.com/"}
|
|
65
67
|
</script>
|
|
66
68
|
|
|
67
|
-
</head>
|
|
69
|
+
</head>
|
|
68
70
|
<body class="body">
|
|
69
|
-
|
|
71
|
+
|
|
70
72
|
<div id="root"></div>
|
|
71
|
-
<script defer="defer" src="http://domain.com/-/static/runtime.6126058572f989c948b1.js"></script
|
|
73
|
+
<script defer="defer" src="http://domain.com/-/static/runtime.6126058572f989c948b1.js"></script>
|
|
74
|
+
<script defer="defer" src="http://domain.com/-/static/main.6126058572f989c948b1.js"></script>
|
|
72
75
|
|
|
73
76
|
</body>
|
|
74
77
|
</html>
|
|
@@ -78,47 +81,23 @@ exports[`template custom render 1`] = `
|
|
|
78
81
|
exports[`template custom title 1`] = `
|
|
79
82
|
"
|
|
80
83
|
<!DOCTYPE html>
|
|
81
|
-
<html lang="en-us">
|
|
84
|
+
<html lang="en-us">
|
|
82
85
|
<head>
|
|
83
86
|
<meta charset="utf-8">
|
|
84
|
-
<base href="http://domain.com">
|
|
85
|
-
<title>foo title</title>
|
|
86
|
-
<link rel="icon" href="http://domain.com
|
|
87
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
87
|
+
<base href="http://domain.com/">
|
|
88
|
+
<title>foo title</title>
|
|
89
|
+
<link rel="icon" href="http://domain.com/-/static/favicon.ico"/>
|
|
90
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
88
91
|
<script>
|
|
89
|
-
window.__VERDACCIO_BASENAME_UI_OPTIONS={"base":"http://domain.com","title":"foo title"}
|
|
92
|
+
window.__VERDACCIO_BASENAME_UI_OPTIONS={"base":"http://domain.com/","title":"foo title"}
|
|
90
93
|
</script>
|
|
91
94
|
|
|
92
|
-
</head>
|
|
95
|
+
</head>
|
|
93
96
|
<body class="body">
|
|
94
|
-
|
|
95
|
-
<div id="root"></div>
|
|
96
|
-
<script defer="defer" src="http://domain.com/-/static/runtime.6126058572f989c948b1.js"></script><script defer="defer" src="http://domain.com/-/static/main.6126058572f989c948b1.js"></script>
|
|
97
97
|
|
|
98
|
-
</body>
|
|
99
|
-
</html>
|
|
100
|
-
"
|
|
101
|
-
`;
|
|
102
|
-
|
|
103
|
-
exports[`template custom title 2`] = `
|
|
104
|
-
"
|
|
105
|
-
<!DOCTYPE html>
|
|
106
|
-
<html lang="en-us">
|
|
107
|
-
<head>
|
|
108
|
-
<meta charset="utf-8">
|
|
109
|
-
<base href="http://domain.com">
|
|
110
|
-
<title>foo title</title>
|
|
111
|
-
<link rel="icon" href="http://domain.com-/static/favicon.ico"/>
|
|
112
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
113
|
-
<script>
|
|
114
|
-
window.__VERDACCIO_BASENAME_UI_OPTIONS={"base":"http://domain.com","title":"foo title"}
|
|
115
|
-
</script>
|
|
116
|
-
|
|
117
|
-
</head>
|
|
118
|
-
<body class="body">
|
|
119
|
-
|
|
120
98
|
<div id="root"></div>
|
|
121
|
-
<script defer="defer" src="http://domain.com/-/static/runtime.6126058572f989c948b1.js"></script
|
|
99
|
+
<script defer="defer" src="http://domain.com/-/static/runtime.6126058572f989c948b1.js"></script>
|
|
100
|
+
<script defer="defer" src="http://domain.com/-/static/main.6126058572f989c948b1.js"></script>
|
|
122
101
|
|
|
123
102
|
</body>
|
|
124
103
|
</html>
|
|
@@ -128,22 +107,23 @@ exports[`template custom title 2`] = `
|
|
|
128
107
|
exports[`template meta scripts 1`] = `
|
|
129
108
|
"
|
|
130
109
|
<!DOCTYPE html>
|
|
131
|
-
<html lang="en-us">
|
|
110
|
+
<html lang="en-us">
|
|
132
111
|
<head>
|
|
133
112
|
<meta charset="utf-8">
|
|
134
|
-
<base href="http://domain.com">
|
|
135
|
-
<title></title>
|
|
136
|
-
<link rel="icon" href="http://domain.com
|
|
137
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
113
|
+
<base href="http://domain.com/">
|
|
114
|
+
<title></title>
|
|
115
|
+
<link rel="icon" href="http://domain.com/-/static/favicon.ico"/>
|
|
116
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
138
117
|
<script>
|
|
139
|
-
window.__VERDACCIO_BASENAME_UI_OPTIONS={"base":"http://domain.com"}
|
|
118
|
+
window.__VERDACCIO_BASENAME_UI_OPTIONS={"base":"http://domain.com/"}
|
|
140
119
|
</script>
|
|
141
120
|
<style>.someclass{font-size:10px;}</style>
|
|
142
|
-
</head>
|
|
121
|
+
</head>
|
|
143
122
|
<body class="body">
|
|
144
|
-
|
|
123
|
+
|
|
145
124
|
<div id="root"></div>
|
|
146
|
-
<script defer="defer" src="http://domain.com/-/static/runtime.6126058572f989c948b1.js"></script
|
|
125
|
+
<script defer="defer" src="http://domain.com/-/static/runtime.6126058572f989c948b1.js"></script>
|
|
126
|
+
<script defer="defer" src="http://domain.com/-/static/main.6126058572f989c948b1.js"></script>
|
|
147
127
|
|
|
148
128
|
</body>
|
|
149
129
|
</html>
|
|
Binary file
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
web:
|
|
2
|
+
title: verdaccio web
|
|
3
|
+
login: true
|
|
4
|
+
scope: '@scope'
|
|
5
|
+
pkgManagers:
|
|
6
|
+
- pnpm
|
|
7
|
+
- yarn
|
|
8
|
+
showInfo: true
|
|
9
|
+
showSettings: true
|
|
10
|
+
showSearch: true
|
|
11
|
+
showFooter: true
|
|
12
|
+
showThemeSwitch: true
|
|
13
|
+
showDownloadTarball: true
|
|
14
|
+
showRaw: true
|
|
15
|
+
primary_color: '#ffffff'
|
|
16
|
+
logo: https://raw.githubusercontent.com/verdaccio/verdaccio/master/assets/svg/logo-small.svg
|
|
17
|
+
logoDark: https://raw.githubusercontent.com/verdaccio/verdaccio/master/assets/svg/logo-blackwhite.svg
|
|
18
|
+
favicon: https://raw.githubusercontent.com/verdaccio/verdaccio/master/website/static/img/favicon/favicon.ico
|
|
19
|
+
html_cache: false
|
|
20
|
+
|
|
21
|
+
url_prefix: /prefix
|
|
22
|
+
|
|
23
|
+
log: { type: stdout, format: pretty, level: trace }
|
|
24
|
+
|
|
25
|
+
flags:
|
|
26
|
+
changePassword: true
|
package/test/config/no-logo.yaml
CHANGED
package/test/manifest.test.ts
CHANGED
|
@@ -8,4 +8,16 @@ describe('manifest', () => {
|
|
|
8
8
|
'/-/static/main.6126058572f989c948b1.js',
|
|
9
9
|
]);
|
|
10
10
|
});
|
|
11
|
+
|
|
12
|
+
test('getManifestValue with base', () => {
|
|
13
|
+
expect(getManifestValue(['favicon.ico'], manifest, 'http://domain.com')).toEqual([
|
|
14
|
+
'http://domain.com/-/static/favicon.ico',
|
|
15
|
+
]);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('getManifestValue with base with trailing slash', () => {
|
|
19
|
+
expect(getManifestValue(['favicon.ico'], manifest, 'http://domain.com/')).toEqual([
|
|
20
|
+
'http://domain.com/-/static/favicon.ico',
|
|
21
|
+
]);
|
|
22
|
+
});
|
|
11
23
|
});
|