@verdaccio/middleware 8.0.0-next-8.13 → 8.0.0-next-8.15
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/build/middlewares/allow.js +1 -1
- package/build/middlewares/allow.js.map +1 -1
- package/build/middlewares/json.js +1 -2
- package/build/middlewares/json.js.map +1 -1
- package/build/middlewares/web/utils/renderHTML.js +7 -1
- package/build/middlewares/web/utils/renderHTML.js.map +1 -1
- package/build/middlewares/web/utils/template.d.ts +1 -1
- package/build/middlewares/web/utils/template.js +3 -3
- package/build/middlewares/web/utils/template.js.map +1 -1
- package/package.json +6 -6
|
@@ -21,7 +21,7 @@ function allow(auth, options = {
|
|
|
21
21
|
return function (action) {
|
|
22
22
|
return function (req, res, next) {
|
|
23
23
|
req.pause();
|
|
24
|
-
const packageName = req.params.scope ?
|
|
24
|
+
const packageName = req.params.scope ? `${req.params.scope}/${req.params.package}` : req.params.package;
|
|
25
25
|
const packageVersion = req.params.filename ? _core.tarballUtils.getVersionFromTarball(req.params.filename) : req.params.version ? req.params.version : undefined;
|
|
26
26
|
const remote_user = req.remote_user;
|
|
27
27
|
debug('check if user %o can %o package %o version %o', remote_user?.name, action, packageName, packageVersion);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"allow.js","names":["_debug","_interopRequireDefault","require","_core","e","__esModule","default","debug","buildDebug","allow","auth","options","beforeAll","_a","_b","afterAll","action","req","res","next","pause","packageName","params","scope","package","packageVersion","filename","tarballUtils","getVersionFromTarball","version","undefined","remote_user","name","user","error","allowed","resume","errorUtils","getInternalError","API_ERROR","PLUGIN_ERROR"],"sources":["../../src/middlewares/allow.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nimport { API_ERROR, errorUtils, tarballUtils } from '@verdaccio/core';\n\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nconst debug = buildDebug('verdaccio:middleware:allow');\n\nexport function allow<T>(\n auth: T,\n options = {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n beforeAll: (_a: any, _b: any) => {},\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n afterAll: (_a: any, _b: any) => {},\n }\n): Function {\n const { beforeAll, afterAll } = options;\n return function (action: string): Function {\n return function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {\n req.pause();\n const packageName = req.params.scope\n ?
|
|
1
|
+
{"version":3,"file":"allow.js","names":["_debug","_interopRequireDefault","require","_core","e","__esModule","default","debug","buildDebug","allow","auth","options","beforeAll","_a","_b","afterAll","action","req","res","next","pause","packageName","params","scope","package","packageVersion","filename","tarballUtils","getVersionFromTarball","version","undefined","remote_user","name","user","error","allowed","resume","errorUtils","getInternalError","API_ERROR","PLUGIN_ERROR"],"sources":["../../src/middlewares/allow.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nimport { API_ERROR, errorUtils, tarballUtils } from '@verdaccio/core';\n\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nconst debug = buildDebug('verdaccio:middleware:allow');\n\nexport function allow<T>(\n auth: T,\n options = {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n beforeAll: (_a: any, _b: any) => {},\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n afterAll: (_a: any, _b: any) => {},\n }\n): Function {\n const { beforeAll, afterAll } = options;\n return function (action: string): Function {\n return function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {\n req.pause();\n const packageName = req.params.scope\n ? `${req.params.scope}/${req.params.package}`\n : req.params.package;\n const packageVersion = req.params.filename\n ? tarballUtils.getVersionFromTarball(req.params.filename)\n : req.params.version\n ? req.params.version\n : undefined;\n const remote_user = req.remote_user;\n debug(\n 'check if user %o can %o package %o version %o',\n remote_user?.name,\n action,\n packageName,\n packageVersion\n );\n beforeAll?.(\n { action, user: remote_user?.name },\n `[middleware/allow][@{action}] allow for @{user}`\n );\n auth['allow_' + action](\n { packageName, packageVersion },\n remote_user,\n function (error, allowed): void {\n req.resume();\n if (error) {\n debug('user is NOT allowed to %o', action);\n next(error);\n } else if (allowed) {\n debug('user is allowed to %o', action);\n afterAll?.(\n { action, user: remote_user?.name },\n `[middleware/allow][@{action}] allowed for @{user}`\n );\n next();\n } else {\n // last plugin (that's our built-in one) returns either\n // cb(err) or cb(null, true), so this should never happen\n throw errorUtils.getInternalError(API_ERROR.PLUGIN_ERROR);\n }\n }\n );\n };\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AAAsE,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAItE,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,4BAA4B,CAAC;AAE/C,SAASC,KAAKA,CACnBC,IAAO,EACPC,OAAO,GAAG;EACR;EACAC,SAAS,EAAEA,CAACC,EAAO,EAAEC,EAAO,KAAK,CAAC,CAAC;EACnC;EACAC,QAAQ,EAAEA,CAACF,EAAO,EAAEC,EAAO,KAAK,CAAC;AACnC,CAAC,EACS;EACV,MAAM;IAAEF,SAAS;IAAEG;EAAS,CAAC,GAAGJ,OAAO;EACvC,OAAO,UAAUK,MAAc,EAAY;IACzC,OAAO,UAAUC,GAAmB,EAAEC,GAAoB,EAAEC,IAAsB,EAAQ;MACxFF,GAAG,CAACG,KAAK,CAAC,CAAC;MACX,MAAMC,WAAW,GAAGJ,GAAG,CAACK,MAAM,CAACC,KAAK,GAChC,GAAGN,GAAG,CAACK,MAAM,CAACC,KAAK,IAAIN,GAAG,CAACK,MAAM,CAACE,OAAO,EAAE,GAC3CP,GAAG,CAACK,MAAM,CAACE,OAAO;MACtB,MAAMC,cAAc,GAAGR,GAAG,CAACK,MAAM,CAACI,QAAQ,GACtCC,kBAAY,CAACC,qBAAqB,CAACX,GAAG,CAACK,MAAM,CAACI,QAAQ,CAAC,GACvDT,GAAG,CAACK,MAAM,CAACO,OAAO,GAChBZ,GAAG,CAACK,MAAM,CAACO,OAAO,GAClBC,SAAS;MACf,MAAMC,WAAW,GAAGd,GAAG,CAACc,WAAW;MACnCxB,KAAK,CACH,+CAA+C,EAC/CwB,WAAW,EAAEC,IAAI,EACjBhB,MAAM,EACNK,WAAW,EACXI,cACF,CAAC;MACDb,SAAS,GACP;QAAEI,MAAM;QAAEiB,IAAI,EAAEF,WAAW,EAAEC;MAAK,CAAC,EACnC,iDACF,CAAC;MACDtB,IAAI,CAAC,QAAQ,GAAGM,MAAM,CAAC,CACrB;QAAEK,WAAW;QAAEI;MAAe,CAAC,EAC/BM,WAAW,EACX,UAAUG,KAAK,EAAEC,OAAO,EAAQ;QAC9BlB,GAAG,CAACmB,MAAM,CAAC,CAAC;QACZ,IAAIF,KAAK,EAAE;UACT3B,KAAK,CAAC,2BAA2B,EAAES,MAAM,CAAC;UAC1CG,IAAI,CAACe,KAAK,CAAC;QACb,CAAC,MAAM,IAAIC,OAAO,EAAE;UAClB5B,KAAK,CAAC,uBAAuB,EAAES,MAAM,CAAC;UACtCD,QAAQ,GACN;YAAEC,MAAM;YAAEiB,IAAI,EAAEF,WAAW,EAAEC;UAAK,CAAC,EACnC,mDACF,CAAC;UACDb,IAAI,CAAC,CAAC;QACR,CAAC,MAAM;UACL;UACA;UACA,MAAMkB,gBAAU,CAACC,gBAAgB,CAACC,eAAS,CAACC,YAAY,CAAC;QAC3D;MACF,CACF,CAAC;IACH,CAAC;EACH,CAAC;AACH","ignoreList":[]}
|
|
@@ -5,9 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.expectJson = expectJson;
|
|
7
7
|
var _core = require("@verdaccio/core");
|
|
8
|
-
var _utils = require("@verdaccio/utils");
|
|
9
8
|
function expectJson(req, res, next) {
|
|
10
|
-
if (!
|
|
9
|
+
if (!_core.validationUtils.isObject(req.body)) {
|
|
11
10
|
return next(_core.errorUtils.getBadRequest("can't parse incoming json"));
|
|
12
11
|
}
|
|
13
12
|
next();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.js","names":["_core","require","
|
|
1
|
+
{"version":3,"file":"json.js","names":["_core","require","expectJson","req","res","next","validationUtils","isObject","body","errorUtils","getBadRequest"],"sources":["../../src/middlewares/json.ts"],"sourcesContent":["import { errorUtils, validationUtils } from '@verdaccio/core';\n\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nexport function expectJson(\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n): void {\n if (!validationUtils.isObject(req.body)) {\n return next(errorUtils.getBadRequest(\"can't parse incoming json\"));\n }\n next();\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAIO,SAASC,UAAUA,CACxBC,GAAmB,EACnBC,GAAoB,EACpBC,IAAsB,EAChB;EACN,IAAI,CAACC,qBAAe,CAACC,QAAQ,CAACJ,GAAG,CAACK,IAAI,CAAC,EAAE;IACvC,OAAOH,IAAI,CAACI,gBAAU,CAACC,aAAa,CAAC,2BAA2B,CAAC,CAAC;EACpE;EACAL,IAAI,CAAC,CAAC;AACR","ignoreList":[]}
|
|
@@ -68,6 +68,7 @@ function renderHTML(config, manifest, manifestFiles, requestOptions, res) {
|
|
|
68
68
|
scriptsBodyAfter,
|
|
69
69
|
metaScripts,
|
|
70
70
|
scriptsbodyBefore,
|
|
71
|
+
// deprecated
|
|
71
72
|
showInfo,
|
|
72
73
|
showSettings,
|
|
73
74
|
showThemeSwitch,
|
|
@@ -81,6 +82,11 @@ function renderHTML(config, manifest, manifestFiles, requestOptions, res) {
|
|
|
81
82
|
bodyBefore: [],
|
|
82
83
|
metaScripts: []
|
|
83
84
|
}, config?.web);
|
|
85
|
+
// Fallback
|
|
86
|
+
let scriptsBodyBefore = config?.web?.scriptsBodyBefore;
|
|
87
|
+
if (scriptsbodyBefore && !scriptsBodyBefore) {
|
|
88
|
+
scriptsBodyBefore = scriptsbodyBefore;
|
|
89
|
+
}
|
|
84
90
|
const options = {
|
|
85
91
|
showInfo,
|
|
86
92
|
showSettings,
|
|
@@ -116,7 +122,7 @@ function renderHTML(config, manifest, manifestFiles, requestOptions, res) {
|
|
|
116
122
|
options,
|
|
117
123
|
scriptsBodyAfter,
|
|
118
124
|
metaScripts,
|
|
119
|
-
|
|
125
|
+
scriptsBodyBefore
|
|
120
126
|
}, manifest);
|
|
121
127
|
if (needHtmlCache) {
|
|
122
128
|
cache.set('template', webPage);
|
|
@@ -1 +1 @@
|
|
|
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","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
|
|
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","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","scriptsBodyBefore","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, // deprecated\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 // Fallback\n let scriptsBodyBefore = config?.web?.scriptsBodyBefore;\n if (scriptsbodyBefore && !scriptsBodyBefore) {\n scriptsBodyBefore = scriptsbodyBefore;\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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;QAC9BhE,KAAK,CAAC,oBAAoB,CAAC;MAC7B;IACF,CAAC,MAAM;MACLA,KAAK,CAAC,sBAAsB,CAAC;IAC/B;EACF,CAAC,CAAC,OAAOoE,KAAU,EAAE;IACnB,MAAM,IAAIC,KAAK,CAAC,kCAAkCD,KAAK,CAACE,KAAK,EAAE,CAAC;EAClE;EACAnD,GAAG,CAACoD,SAAS,CAAC,cAAc,EAAEC,aAAO,CAACC,SAAS,CAAC;EAChDtD,GAAG,CAACuD,IAAI,CAACV,OAAO,CAAC;EACjBhE,KAAK,CAAC,cAAc,CAAC;AACvB","ignoreList":[]}
|
|
@@ -21,15 +21,15 @@ function renderTemplate(template, manifest) {
|
|
|
21
21
|
<meta charset="utf-8">
|
|
22
22
|
<base href="${template?.options.base}">
|
|
23
23
|
<title>${template?.options?.title ?? ''}</title>
|
|
24
|
-
<link rel="icon" href="${template?.options.base}-/static/favicon.ico"
|
|
25
|
-
<meta name="viewport" content="width=device-width, initial-scale=1"
|
|
24
|
+
<link rel="icon" href="${template?.options.base}-/static/favicon.ico">
|
|
25
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
26
26
|
<script>
|
|
27
27
|
window.__VERDACCIO_BASENAME_UI_OPTIONS=${JSON.stringify(template.options)}
|
|
28
28
|
</script>
|
|
29
29
|
${template?.metaScripts ? template.metaScripts.join('') : ''}
|
|
30
30
|
</head>
|
|
31
31
|
<body class="body">
|
|
32
|
-
${template?.
|
|
32
|
+
${template?.scriptsBodyBefore ? template.scriptsBodyBefore.join('') : ''}
|
|
33
33
|
<div id="root"></div>
|
|
34
34
|
${(0, _manifest.getManifestValue)(template.manifest.js, manifest, template?.options.base).map(item => `<script defer="defer" src="${item}"></script>`).join(`\n `)}
|
|
35
35
|
${template?.scriptsBodyAfter ? template.scriptsBodyAfter.join('') : ''}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","names":["_debug","_interopRequireDefault","require","_manifest","e","__esModule","default","debug","buildDebug","renderTemplate","template","manifest","options","base","title","JSON","stringify","metaScripts","join","
|
|
1
|
+
{"version":3,"file":"template.js","names":["_debug","_interopRequireDefault","require","_manifest","e","__esModule","default","debug","buildDebug","renderTemplate","template","manifest","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;A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|
{
|
|
2
2
|
"name": "@verdaccio/middleware",
|
|
3
|
-
"version": "8.0.0-next-8.
|
|
3
|
+
"version": "8.0.0-next-8.15",
|
|
4
4
|
"description": "Verdaccio Express Middleware",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"node": ">=18"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@verdaccio/config": "8.0.0-next-8.
|
|
37
|
-
"@verdaccio/core": "8.0.0-next-8.
|
|
38
|
-
"@verdaccio/url": "13.0.0-next-8.
|
|
39
|
-
"@verdaccio/utils": "8.1.0-next-8.
|
|
36
|
+
"@verdaccio/config": "8.0.0-next-8.15",
|
|
37
|
+
"@verdaccio/core": "8.0.0-next-8.15",
|
|
38
|
+
"@verdaccio/url": "13.0.0-next-8.15",
|
|
39
|
+
"@verdaccio/utils": "8.1.0-next-8.15",
|
|
40
40
|
"debug": "4.4.0",
|
|
41
41
|
"express": "4.21.2",
|
|
42
42
|
"express-rate-limit": "5.5.1",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"url": "https://opencollective.com/verdaccio"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@verdaccio/logger": "8.0.0-next-8.
|
|
52
|
+
"@verdaccio/logger": "8.0.0-next-8.15",
|
|
53
53
|
"body-parser": "1.20.3",
|
|
54
54
|
"supertest": "7.0.0",
|
|
55
55
|
"jsdom": "25.0.1"
|