@verdaccio/core 9.0.0-next-9.3 → 9.0.0-next-9.4
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/_virtual/_rolldown/runtime.js +33 -0
- package/build/_virtual/_rolldown/runtime.mjs +13 -0
- package/build/auth-utils.d.ts +1 -1
- package/build/auth-utils.js +23 -25
- package/build/auth-utils.js.map +1 -1
- package/build/auth-utils.mjs +32 -0
- package/build/auth-utils.mjs.map +1 -0
- package/build/constants.js +179 -155
- package/build/constants.js.map +1 -1
- package/build/constants.mjs +163 -0
- package/build/constants.mjs.map +1 -0
- package/build/crypto-utils.d.ts +1 -1
- package/build/crypto-utils.js +33 -29
- package/build/crypto-utils.js.map +1 -1
- package/build/crypto-utils.mjs +40 -0
- package/build/crypto-utils.mjs.map +1 -0
- package/build/error-utils.d.ts +1 -1
- package/build/error-utils.js +92 -80
- package/build/error-utils.js.map +1 -1
- package/build/error-utils.mjs +107 -0
- package/build/error-utils.mjs.map +1 -0
- package/build/file-utils.js +35 -31
- package/build/file-utils.js.map +1 -1
- package/build/file-utils.mjs +35 -0
- package/build/file-utils.mjs.map +1 -0
- package/build/index.d.ts +2 -1
- package/build/index.js +118 -183
- package/build/index.mjs +14 -0
- package/build/pkg-utils.d.ts +1 -1
- package/build/pkg-utils.js +60 -76
- package/build/pkg-utils.js.map +1 -1
- package/build/pkg-utils.mjs +69 -0
- package/build/pkg-utils.mjs.map +1 -0
- package/build/plugin-utils.d.ts +4 -4
- package/build/plugin-utils.js +27 -78
- package/build/plugin-utils.js.map +1 -1
- package/build/plugin-utils.mjs +26 -0
- package/build/plugin-utils.mjs.map +1 -0
- package/build/schemes/publish-manifest.js +33 -43
- package/build/schemes/publish-manifest.js.map +1 -1
- package/build/schemes/publish-manifest.mjs +36 -0
- package/build/schemes/publish-manifest.mjs.map +1 -0
- package/build/schemes/unpublish-manifest.js +51 -72
- package/build/schemes/unpublish-manifest.js.map +1 -1
- package/build/schemes/unpublish-manifest.mjs +54 -0
- package/build/schemes/unpublish-manifest.mjs.map +1 -0
- package/build/search-utils.js +9 -9
- package/build/search-utils.js.map +1 -1
- package/build/search-utils.mjs +8 -0
- package/build/search-utils.mjs.map +1 -0
- package/build/stream-utils.d.ts +1 -2
- package/build/stream-utils.js +29 -28
- package/build/stream-utils.js.map +1 -1
- package/build/stream-utils.mjs +30 -0
- package/build/stream-utils.mjs.map +1 -0
- package/build/string-utils.js +31 -34
- package/build/string-utils.js.map +1 -1
- package/build/string-utils.mjs +31 -0
- package/build/string-utils.mjs.map +1 -0
- package/build/tarball-utils.js +40 -39
- package/build/tarball-utils.js.map +1 -1
- package/build/tarball-utils.mjs +46 -0
- package/build/tarball-utils.mjs.map +1 -0
- package/build/validation-utils.d.ts +1 -1
- package/build/validation-utils.js +78 -112
- package/build/validation-utils.js.map +1 -1
- package/build/validation-utils.mjs +91 -0
- package/build/validation-utils.mjs.map +1 -0
- package/build/warning-utils.js +52 -52
- package/build/warning-utils.js.map +1 -1
- package/build/warning-utils.mjs +62 -0
- package/build/warning-utils.mjs.map +1 -0
- package/package.json +17 -6
- package/build/index.js.map +0 -1
- package/build/path-utils.js +0 -2
- package/build/path-utils.js.map +0 -1
package/build/pkg-utils.js
CHANGED
|
@@ -1,93 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.js");
|
|
2
|
+
const require_constants = require("./constants.js");
|
|
3
|
+
let node_path = require("node:path");
|
|
4
|
+
node_path = require_runtime.__toESM(node_path);
|
|
5
|
+
let node_fs = require("node:fs");
|
|
6
|
+
node_fs = require_runtime.__toESM(node_fs);
|
|
7
|
+
let semver = require("semver");
|
|
8
|
+
semver = require_runtime.__toESM(semver);
|
|
9
|
+
//#region src/pkg-utils.ts
|
|
10
|
+
var pkg_utils_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
11
|
+
getLatest: () => getLatest,
|
|
12
|
+
getPackageJson: () => getPackageJson,
|
|
13
|
+
mergeVersions: () => mergeVersions,
|
|
14
|
+
semverSanitize: () => semverSanitize,
|
|
15
|
+
semverSort: () => semverSort
|
|
5
16
|
});
|
|
6
|
-
exports.getLatest = getLatest;
|
|
7
|
-
exports.getPackageJson = getPackageJson;
|
|
8
|
-
exports.mergeVersions = mergeVersions;
|
|
9
|
-
exports.semverSanitize = semverSanitize;
|
|
10
|
-
exports.semverSort = semverSort;
|
|
11
|
-
var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
12
|
-
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
13
|
-
var _semver = _interopRequireDefault(require("semver"));
|
|
14
|
-
var _constants = require("./constants");
|
|
15
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
17
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
* Function filters out bad semver versions and sorts the array.
|
|
19
|
+
* @return {Array} sorted Array
|
|
20
|
+
*/
|
|
20
21
|
function semverSort(listVersions) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return true;
|
|
26
|
-
}).sort(_semver.default.compareLoose).map(String);
|
|
22
|
+
return listVersions.filter(function(x) {
|
|
23
|
+
if (!semver.default.parse(x, true)) return false;
|
|
24
|
+
return true;
|
|
25
|
+
}).sort(semver.default.compareLoose).map(String);
|
|
27
26
|
}
|
|
28
|
-
|
|
29
27
|
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
* Sanitize a version string to a valid semver version.
|
|
29
|
+
* @param version - The version string to sanitize.
|
|
30
|
+
* @returns The sanitized version string.
|
|
31
|
+
*/
|
|
34
32
|
function semverSanitize(version) {
|
|
35
|
-
|
|
36
|
-
includePrerelease: true
|
|
37
|
-
})?.version || '';
|
|
33
|
+
return semver.default.valid(version) || semver.default.coerce(version, { includePrerelease: true })?.version || "";
|
|
38
34
|
}
|
|
39
|
-
|
|
40
35
|
/**
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
* Get the latest publihsed version of a package.
|
|
37
|
+
* @param package metadata
|
|
38
|
+
**/
|
|
44
39
|
function getLatest(pkg) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const versions = semverSort(listVersions);
|
|
50
|
-
const latest = pkg[_constants.DIST_TAGS]?.latest ? pkg[_constants.DIST_TAGS].latest : versions[0];
|
|
51
|
-
return latest;
|
|
40
|
+
const listVersions = Object.keys(pkg.versions);
|
|
41
|
+
if (listVersions.length < 1) throw Error("cannot get lastest version of none");
|
|
42
|
+
const versions = semverSort(listVersions);
|
|
43
|
+
return pkg["dist-tags"]?.latest ? pkg[require_constants.DIST_TAGS].latest : versions[0];
|
|
52
44
|
}
|
|
53
|
-
|
|
54
45
|
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
// @deprecated
|
|
46
|
+
* Function gets a local info and an info from uplinks and tries to merge it
|
|
47
|
+
exported for unit tests only.
|
|
48
|
+
* @param {*} local
|
|
49
|
+
* @param {*} upstream
|
|
50
|
+
* @param {*} config sds
|
|
51
|
+
* @deprecated use @verdaccio/storage mergeVersions method
|
|
52
|
+
*/
|
|
63
53
|
function mergeVersions(local, upstream) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
for (const i in upstream[_constants.DIST_TAGS]) {
|
|
72
|
-
if (local[_constants.DIST_TAGS][i] !== upstream[_constants.DIST_TAGS][i]) {
|
|
73
|
-
if (!local[_constants.DIST_TAGS][i] || _semver.default.lte(local[_constants.DIST_TAGS][i], upstream[_constants.DIST_TAGS][i])) {
|
|
74
|
-
local[_constants.DIST_TAGS][i] = upstream[_constants.DIST_TAGS][i];
|
|
75
|
-
}
|
|
76
|
-
if (i === 'latest' && local[_constants.DIST_TAGS][i] === upstream[_constants.DIST_TAGS][i]) {
|
|
77
|
-
// if remote has more fresh package, we should borrow its readme
|
|
78
|
-
local.readme = upstream.readme;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
54
|
+
for (const i in upstream.versions) if (typeof local.versions[i] === "undefined") local.versions[i] = upstream.versions[i];
|
|
55
|
+
for (const i in upstream[require_constants.DIST_TAGS]) if (local["dist-tags"][i] !== upstream["dist-tags"][i]) {
|
|
56
|
+
if (!local["dist-tags"][i] || semver.default.lte(local["dist-tags"][i], upstream["dist-tags"][i])) local[require_constants.DIST_TAGS][i] = upstream[require_constants.DIST_TAGS][i];
|
|
57
|
+
if (i === "latest" && local["dist-tags"][i] === upstream["dist-tags"][i]) local.readme = upstream.readme;
|
|
58
|
+
}
|
|
82
59
|
}
|
|
83
|
-
|
|
84
60
|
/**
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
61
|
+
* Get package informations from package.json
|
|
62
|
+
* @param packagePath - The path to the package.json file.
|
|
63
|
+
* @returns The package.json content
|
|
64
|
+
*/
|
|
89
65
|
function getPackageJson(packagePath, relativePath) {
|
|
90
|
-
|
|
91
|
-
|
|
66
|
+
const packageJsonPath = node_path.default.join(packagePath, relativePath, "package.json");
|
|
67
|
+
return JSON.parse(node_fs.default.readFileSync(packageJsonPath, "utf8"));
|
|
92
68
|
}
|
|
69
|
+
//#endregion
|
|
70
|
+
Object.defineProperty(exports, "pkg_utils_exports", {
|
|
71
|
+
enumerable: true,
|
|
72
|
+
get: function() {
|
|
73
|
+
return pkg_utils_exports;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
93
77
|
//# sourceMappingURL=pkg-utils.js.map
|
package/build/pkg-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pkg-utils.js","names":[
|
|
1
|
+
{"version":3,"file":"pkg-utils.js","names":[],"sources":["../src/pkg-utils.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport semver from 'semver';\n\nimport type { Manifest } from '@verdaccio/types';\n\nimport { DIST_TAGS } from './constants';\n\n/**\n * Function filters out bad semver versions and sorts the array.\n * @return {Array} sorted Array\n */\nexport function semverSort(listVersions: string[]): string[] {\n return listVersions\n .filter(function (x): boolean {\n if (!semver.parse(x, true)) {\n return false;\n }\n return true;\n })\n .sort(semver.compareLoose)\n .map(String);\n}\n\n/**\n * Sanitize a version string to a valid semver version.\n * @param version - The version string to sanitize.\n * @returns The sanitized version string.\n */\nexport function semverSanitize(version: string): string {\n return (\n semver.valid(version) || semver.coerce(version, { includePrerelease: true })?.version || ''\n );\n}\n\n/**\n * Get the latest publihsed version of a package.\n * @param package metadata\n **/\nexport function getLatest(pkg: Manifest): string {\n const listVersions: string[] = Object.keys(pkg.versions);\n if (listVersions.length < 1) {\n throw Error('cannot get lastest version of none');\n }\n\n const versions: string[] = semverSort(listVersions);\n const latest: string | undefined = pkg[DIST_TAGS]?.latest ? pkg[DIST_TAGS].latest : versions[0];\n\n return latest;\n}\n\n/**\n * Function gets a local info and an info from uplinks and tries to merge it\n exported for unit tests only.\n * @param {*} local\n * @param {*} upstream\n * @param {*} config sds\n * @deprecated use @verdaccio/storage mergeVersions method\n */\n// @deprecated\nexport function mergeVersions(local: Manifest, upstream: Manifest) {\n // copy new versions to a cache\n // NOTE: if a certain version was updated, we can't refresh it reliably\n for (const i in upstream.versions) {\n if (typeof local.versions[i] === 'undefined') {\n local.versions[i] = upstream.versions[i];\n }\n }\n\n for (const i in upstream[DIST_TAGS]) {\n if (local[DIST_TAGS][i] !== upstream[DIST_TAGS][i]) {\n if (!local[DIST_TAGS][i] || semver.lte(local[DIST_TAGS][i], upstream[DIST_TAGS][i])) {\n local[DIST_TAGS][i] = upstream[DIST_TAGS][i];\n }\n if (i === 'latest' && local[DIST_TAGS][i] === upstream[DIST_TAGS][i]) {\n // if remote has more fresh package, we should borrow its readme\n local.readme = upstream.readme;\n }\n }\n }\n}\n\n/**\n * Get package informations from package.json\n * @param packagePath - The path to the package.json file.\n * @returns The package.json content\n */\nexport function getPackageJson(packagePath: string, relativePath: string): Record<string, unknown> {\n const packageJsonPath = path.join(packagePath, relativePath, 'package.json');\n return JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAYA,SAAgB,WAAW,cAAkC;AAC3D,QAAO,aACJ,OAAO,SAAU,GAAY;AAC5B,MAAI,CAAC,OAAA,QAAO,MAAM,GAAG,KAAK,CACxB,QAAO;AAET,SAAO;GACP,CACD,KAAK,OAAA,QAAO,aAAa,CACzB,IAAI,OAAO;;;;;;;AAQhB,SAAgB,eAAe,SAAyB;AACtD,QACE,OAAA,QAAO,MAAM,QAAQ,IAAI,OAAA,QAAO,OAAO,SAAS,EAAE,mBAAmB,MAAM,CAAC,EAAE,WAAW;;;;;;AAQ7F,SAAgB,UAAU,KAAuB;CAC/C,MAAM,eAAyB,OAAO,KAAK,IAAI,SAAS;AACxD,KAAI,aAAa,SAAS,EACxB,OAAM,MAAM,qCAAqC;CAGnD,MAAM,WAAqB,WAAW,aAAa;AAGnD,QAFmC,IAAA,cAAgB,SAAS,IAAI,kBAAA,WAAW,SAAS,SAAS;;;;;;;;;;AAc/F,SAAgB,cAAc,OAAiB,UAAoB;AAGjE,MAAK,MAAM,KAAK,SAAS,SACvB,KAAI,OAAO,MAAM,SAAS,OAAO,YAC/B,OAAM,SAAS,KAAK,SAAS,SAAS;AAI1C,MAAK,MAAM,KAAK,SAAS,kBAAA,WACvB,KAAI,MAAA,aAAiB,OAAO,SAAA,aAAoB,IAAI;AAClD,MAAI,CAAC,MAAA,aAAiB,MAAM,OAAA,QAAO,IAAI,MAAA,aAAiB,IAAI,SAAA,aAAoB,GAAG,CACjF,OAAM,kBAAA,WAAW,KAAK,SAAS,kBAAA,WAAW;AAE5C,MAAI,MAAM,YAAY,MAAA,aAAiB,OAAO,SAAA,aAAoB,GAEhE,OAAM,SAAS,SAAS;;;;;;;;AAWhC,SAAgB,eAAe,aAAqB,cAA+C;CACjG,MAAM,kBAAkB,UAAA,QAAK,KAAK,aAAa,cAAc,eAAe;AAC5E,QAAO,KAAK,MAAM,QAAA,QAAG,aAAa,iBAAiB,OAAO,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import { DIST_TAGS } from "./constants.mjs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import semver from "semver";
|
|
6
|
+
//#region src/pkg-utils.ts
|
|
7
|
+
var pkg_utils_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
+
getLatest: () => getLatest,
|
|
9
|
+
getPackageJson: () => getPackageJson,
|
|
10
|
+
mergeVersions: () => mergeVersions,
|
|
11
|
+
semverSanitize: () => semverSanitize,
|
|
12
|
+
semverSort: () => semverSort
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* Function filters out bad semver versions and sorts the array.
|
|
16
|
+
* @return {Array} sorted Array
|
|
17
|
+
*/
|
|
18
|
+
function semverSort(listVersions) {
|
|
19
|
+
return listVersions.filter(function(x) {
|
|
20
|
+
if (!semver.parse(x, true)) return false;
|
|
21
|
+
return true;
|
|
22
|
+
}).sort(semver.compareLoose).map(String);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Sanitize a version string to a valid semver version.
|
|
26
|
+
* @param version - The version string to sanitize.
|
|
27
|
+
* @returns The sanitized version string.
|
|
28
|
+
*/
|
|
29
|
+
function semverSanitize(version) {
|
|
30
|
+
return semver.valid(version) || semver.coerce(version, { includePrerelease: true })?.version || "";
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get the latest publihsed version of a package.
|
|
34
|
+
* @param package metadata
|
|
35
|
+
**/
|
|
36
|
+
function getLatest(pkg) {
|
|
37
|
+
const listVersions = Object.keys(pkg.versions);
|
|
38
|
+
if (listVersions.length < 1) throw Error("cannot get lastest version of none");
|
|
39
|
+
const versions = semverSort(listVersions);
|
|
40
|
+
return pkg["dist-tags"]?.latest ? pkg[DIST_TAGS].latest : versions[0];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Function gets a local info and an info from uplinks and tries to merge it
|
|
44
|
+
exported for unit tests only.
|
|
45
|
+
* @param {*} local
|
|
46
|
+
* @param {*} upstream
|
|
47
|
+
* @param {*} config sds
|
|
48
|
+
* @deprecated use @verdaccio/storage mergeVersions method
|
|
49
|
+
*/
|
|
50
|
+
function mergeVersions(local, upstream) {
|
|
51
|
+
for (const i in upstream.versions) if (typeof local.versions[i] === "undefined") local.versions[i] = upstream.versions[i];
|
|
52
|
+
for (const i in upstream[DIST_TAGS]) if (local["dist-tags"][i] !== upstream["dist-tags"][i]) {
|
|
53
|
+
if (!local["dist-tags"][i] || semver.lte(local["dist-tags"][i], upstream["dist-tags"][i])) local[DIST_TAGS][i] = upstream[DIST_TAGS][i];
|
|
54
|
+
if (i === "latest" && local["dist-tags"][i] === upstream["dist-tags"][i]) local.readme = upstream.readme;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get package informations from package.json
|
|
59
|
+
* @param packagePath - The path to the package.json file.
|
|
60
|
+
* @returns The package.json content
|
|
61
|
+
*/
|
|
62
|
+
function getPackageJson(packagePath, relativePath) {
|
|
63
|
+
const packageJsonPath = path.join(packagePath, relativePath, "package.json");
|
|
64
|
+
return JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
export { pkg_utils_exports };
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=pkg-utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pkg-utils.mjs","names":[],"sources":["../src/pkg-utils.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport semver from 'semver';\n\nimport type { Manifest } from '@verdaccio/types';\n\nimport { DIST_TAGS } from './constants';\n\n/**\n * Function filters out bad semver versions and sorts the array.\n * @return {Array} sorted Array\n */\nexport function semverSort(listVersions: string[]): string[] {\n return listVersions\n .filter(function (x): boolean {\n if (!semver.parse(x, true)) {\n return false;\n }\n return true;\n })\n .sort(semver.compareLoose)\n .map(String);\n}\n\n/**\n * Sanitize a version string to a valid semver version.\n * @param version - The version string to sanitize.\n * @returns The sanitized version string.\n */\nexport function semverSanitize(version: string): string {\n return (\n semver.valid(version) || semver.coerce(version, { includePrerelease: true })?.version || ''\n );\n}\n\n/**\n * Get the latest publihsed version of a package.\n * @param package metadata\n **/\nexport function getLatest(pkg: Manifest): string {\n const listVersions: string[] = Object.keys(pkg.versions);\n if (listVersions.length < 1) {\n throw Error('cannot get lastest version of none');\n }\n\n const versions: string[] = semverSort(listVersions);\n const latest: string | undefined = pkg[DIST_TAGS]?.latest ? pkg[DIST_TAGS].latest : versions[0];\n\n return latest;\n}\n\n/**\n * Function gets a local info and an info from uplinks and tries to merge it\n exported for unit tests only.\n * @param {*} local\n * @param {*} upstream\n * @param {*} config sds\n * @deprecated use @verdaccio/storage mergeVersions method\n */\n// @deprecated\nexport function mergeVersions(local: Manifest, upstream: Manifest) {\n // copy new versions to a cache\n // NOTE: if a certain version was updated, we can't refresh it reliably\n for (const i in upstream.versions) {\n if (typeof local.versions[i] === 'undefined') {\n local.versions[i] = upstream.versions[i];\n }\n }\n\n for (const i in upstream[DIST_TAGS]) {\n if (local[DIST_TAGS][i] !== upstream[DIST_TAGS][i]) {\n if (!local[DIST_TAGS][i] || semver.lte(local[DIST_TAGS][i], upstream[DIST_TAGS][i])) {\n local[DIST_TAGS][i] = upstream[DIST_TAGS][i];\n }\n if (i === 'latest' && local[DIST_TAGS][i] === upstream[DIST_TAGS][i]) {\n // if remote has more fresh package, we should borrow its readme\n local.readme = upstream.readme;\n }\n }\n }\n}\n\n/**\n * Get package informations from package.json\n * @param packagePath - The path to the package.json file.\n * @returns The package.json content\n */\nexport function getPackageJson(packagePath: string, relativePath: string): Record<string, unknown> {\n const packageJsonPath = path.join(packagePath, relativePath, 'package.json');\n return JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAYA,SAAgB,WAAW,cAAkC;AAC3D,QAAO,aACJ,OAAO,SAAU,GAAY;AAC5B,MAAI,CAAC,OAAO,MAAM,GAAG,KAAK,CACxB,QAAO;AAET,SAAO;GACP,CACD,KAAK,OAAO,aAAa,CACzB,IAAI,OAAO;;;;;;;AAQhB,SAAgB,eAAe,SAAyB;AACtD,QACE,OAAO,MAAM,QAAQ,IAAI,OAAO,OAAO,SAAS,EAAE,mBAAmB,MAAM,CAAC,EAAE,WAAW;;;;;;AAQ7F,SAAgB,UAAU,KAAuB;CAC/C,MAAM,eAAyB,OAAO,KAAK,IAAI,SAAS;AACxD,KAAI,aAAa,SAAS,EACxB,OAAM,MAAM,qCAAqC;CAGnD,MAAM,WAAqB,WAAW,aAAa;AAGnD,QAFmC,IAAA,cAAgB,SAAS,IAAI,WAAW,SAAS,SAAS;;;;;;;;;;AAc/F,SAAgB,cAAc,OAAiB,UAAoB;AAGjE,MAAK,MAAM,KAAK,SAAS,SACvB,KAAI,OAAO,MAAM,SAAS,OAAO,YAC/B,OAAM,SAAS,KAAK,SAAS,SAAS;AAI1C,MAAK,MAAM,KAAK,SAAS,WACvB,KAAI,MAAA,aAAiB,OAAO,SAAA,aAAoB,IAAI;AAClD,MAAI,CAAC,MAAA,aAAiB,MAAM,OAAO,IAAI,MAAA,aAAiB,IAAI,SAAA,aAAoB,GAAG,CACjF,OAAM,WAAW,KAAK,SAAS,WAAW;AAE5C,MAAI,MAAM,YAAY,MAAA,aAAiB,OAAO,SAAA,aAAoB,GAEhE,OAAM,SAAS,SAAS;;;;;;;;AAWhC,SAAgB,eAAe,aAAqB,cAA+C;CACjG,MAAM,kBAAkB,KAAK,KAAK,aAAa,cAAc,eAAe;AAC5E,QAAO,KAAK,MAAM,GAAG,aAAa,iBAAiB,OAAO,CAAC"}
|
package/build/plugin-utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { Express, RequestHandler } from 'express';
|
|
2
|
+
import { Readable, Writable } from 'node:stream';
|
|
3
|
+
import { AllowAccess, Callback, Config, Logger, Manifest, PackageAccess, RemoteUser, Token, TokenFilter } from '@verdaccio/types';
|
|
4
|
+
import { VerdaccioError, searchUtils } from '.';
|
|
5
5
|
export interface PluginOptions {
|
|
6
6
|
config: Config;
|
|
7
7
|
logger: Logger;
|
package/build/plugin-utils.js
CHANGED
|
@@ -1,81 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Plugin = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Base Plugin Class
|
|
9
|
-
*
|
|
10
|
-
* Set of utilities for developing plugins.
|
|
11
|
-
*/
|
|
12
|
-
class Plugin {
|
|
13
|
-
static version = 1;
|
|
14
|
-
constructor(config, options) {
|
|
15
|
-
this.version = Plugin.version;
|
|
16
|
-
this.config = config;
|
|
17
|
-
this.options = options;
|
|
18
|
-
}
|
|
19
|
-
getVersion() {
|
|
20
|
-
return this.version;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// --- STORAGE PLUGIN ---
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Storage Handler
|
|
28
|
-
*
|
|
29
|
-
* Used in storage plugin for managing packages and tarballs.
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Storage Plugin interface
|
|
34
|
-
*
|
|
35
|
-
* https://verdaccio.org/docs/plugin-storage
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
// --- MIDDLEWARE PLUGIN ---
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Middleware Plugin Interface
|
|
42
|
-
*
|
|
43
|
-
* https://verdaccio.org/docs/plugin-middleware
|
|
44
|
-
*
|
|
45
|
-
* This function allow add middleware to the application.
|
|
46
|
-
*
|
|
47
|
-
* ```ts
|
|
48
|
-
* import express, { Request, Response } from 'express';
|
|
49
|
-
*
|
|
50
|
-
* class Middleware extends Plugin {
|
|
51
|
-
* // instances of auth and storage are injected
|
|
52
|
-
* register_middlewares(app, auth, storage) {
|
|
53
|
-
* const router = express.Router();
|
|
54
|
-
* router.post('/my-endpoint', (req: Request, res: Response): void => {
|
|
55
|
-
res.status(200).end();
|
|
56
|
-
});
|
|
57
|
-
* }
|
|
58
|
-
* }
|
|
59
|
-
*
|
|
60
|
-
* const [plugin] = await asyncLoadPlugin(...);
|
|
61
|
-
* plugin.register_middlewares(app, auth, storage);
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
// --- AUTH PLUGIN ---
|
|
66
|
-
|
|
1
|
+
//#region src/plugin-utils.ts
|
|
2
|
+
var plugin_utils_exports = /* @__PURE__ */ require("./_virtual/_rolldown/runtime.js").__exportAll({ Plugin: () => Plugin });
|
|
67
3
|
/**
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
4
|
+
* Base Plugin Class
|
|
5
|
+
*
|
|
6
|
+
* Set of utilities for developing plugins.
|
|
7
|
+
*/
|
|
8
|
+
var Plugin = class Plugin {
|
|
9
|
+
static version = 1;
|
|
10
|
+
version;
|
|
11
|
+
config;
|
|
12
|
+
options;
|
|
13
|
+
constructor(config, options) {
|
|
14
|
+
this.version = Plugin.version;
|
|
15
|
+
this.config = config;
|
|
16
|
+
this.options = options;
|
|
17
|
+
}
|
|
18
|
+
getVersion() {
|
|
19
|
+
return this.version;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
Object.defineProperty(exports, "plugin_utils_exports", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function() {
|
|
26
|
+
return plugin_utils_exports;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
74
29
|
|
|
75
|
-
/**
|
|
76
|
-
* Filter Plugin Interface
|
|
77
|
-
*
|
|
78
|
-
* https://verdaccio.org/docs/plugin-filter
|
|
79
|
-
*/
|
|
80
|
-
exports.Plugin = Plugin;
|
|
81
30
|
//# sourceMappingURL=plugin-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-utils.js","names":[
|
|
1
|
+
{"version":3,"file":"plugin-utils.js","names":[],"sources":["../src/plugin-utils.ts"],"sourcesContent":["import type { Express, RequestHandler } from 'express';\nimport type { Readable, Writable } from 'node:stream';\n\nimport type {\n AllowAccess,\n Callback,\n Config,\n Logger,\n Manifest,\n PackageAccess,\n RemoteUser,\n Token,\n TokenFilter,\n} from '@verdaccio/types';\n\nimport type { VerdaccioError, searchUtils } from '.';\n\nexport interface PluginOptions {\n config: Config;\n logger: Logger;\n}\n\n/**\n * Base Plugin Class\n *\n * Set of utilities for developing plugins.\n */\nexport class Plugin<PluginConfig> {\n static version = 1;\n public readonly version: number;\n public readonly config: PluginConfig | unknown;\n public readonly options: PluginOptions;\n public constructor(config: PluginConfig, options: PluginOptions) {\n this.version = Plugin.version;\n this.config = config;\n this.options = options;\n }\n\n public getVersion() {\n return this.version;\n }\n}\n\n// --- STORAGE PLUGIN ---\n\n/**\n * Storage Handler\n *\n * Used in storage plugin for managing packages and tarballs.\n */\nexport interface StorageHandler {\n logger: Logger;\n deletePackage(fileName: string): Promise<void>;\n removePackage(packageName: string): Promise<void>;\n // next packages migration (this list is meant to replace the callback parent functions)\n updatePackage(\n packageName: string,\n handleUpdate: (manifest: Manifest) => Promise<Manifest>\n ): Promise<Manifest>;\n readPackage(packageName: string): Promise<Manifest>;\n savePackage(packageName: string, manifest: Manifest): Promise<void>;\n readTarball(fileName: string, { signal }: { signal: AbortSignal }): Promise<Readable>;\n createPackage(packageName: string, manifest: Manifest): Promise<void>;\n writeTarball(fileName: string, { signal }: { signal: AbortSignal }): Promise<Writable>;\n // verify if tarball exist in the storage\n hasTarball(fileName: string): Promise<boolean>;\n // verify if package exist in the storage\n hasPackage(packageName: string): Promise<boolean>;\n}\n\n/**\n * Storage Plugin interface\n *\n * https://verdaccio.org/docs/plugin-storage\n */\nexport interface Storage<PluginConfig> extends Plugin<PluginConfig> {\n add(packageName: string): Promise<void>;\n remove(packageName: string): Promise<void>;\n get(): Promise<string[]>;\n init(): Promise<void>;\n getSecret(): Promise<string>;\n setSecret(secret: string): Promise<any>;\n getPackageStorage(packageName: string): StorageHandler;\n search(query: searchUtils.SearchQuery): Promise<searchUtils.SearchItem[]>;\n saveToken(token: Token): Promise<any>;\n deleteToken(user: string, tokenKey: string): Promise<any>;\n readTokens(filter: TokenFilter): Promise<Token[]>;\n}\n\n// --- MIDDLEWARE PLUGIN ---\n\n/**\n * Middleware Plugin Interface\n *\n * https://verdaccio.org/docs/plugin-middleware\n *\n * This function allow add middleware to the application.\n *\n * ```ts\n * import express, { Request, Response } from 'express';\n * \n * class Middleware extends Plugin {\n * // instances of auth and storage are injected\n * register_middlewares(app, auth, storage) {\n * const router = express.Router();\n * router.post('/my-endpoint', (req: Request, res: Response): void => {\n res.status(200).end();\n });\n * }\n * }\n *\n * const [plugin] = await asyncLoadPlugin(...);\n * plugin.register_middlewares(app, auth, storage);\n * ```\n */\nexport interface ExpressMiddleware<PluginConfig, Storage, Auth> extends Plugin<PluginConfig> {\n register_middlewares(app: Express, auth: Auth, storage: Storage): void;\n}\n\n// --- AUTH PLUGIN ---\n\nexport type AuthCallback = (error: VerdaccioError | null, groups?: string[] | false) => void;\n\nexport type AuthAccessCallback = (error: VerdaccioError | null, access?: boolean) => void;\nexport type AuthUserCallback = (error: VerdaccioError | null, access?: boolean | string) => void;\nexport type AuthChangePasswordCallback = (error: VerdaccioError | null, access?: boolean) => void;\nexport type AccessCallback = (error: VerdaccioError | null, ok?: boolean) => void;\n\nexport interface AuthPluginPackage {\n packageName: string;\n packageVersion?: string;\n tag?: string;\n}\n\n/**\n * Authentication Plugin Interface\n *\n * https://verdaccio.org/docs/plugin-auth\n */\nexport interface Auth<T> extends Plugin<T> {\n /**\n * Handles the authenticated method.\n * ```ts\n * class Auth {\n public authenticate(user: string, password: string, done: AuthCallback): void {\n if (!password) {\n return done(errorUtils.getUnauthorized(API_ERROR.BAD_USERNAME_PASSWORD));\n }\n // always return an array of users\n return done(null, [user]); \n * }\n * ```\n */\n authenticate(user: string, password: string, cb: AuthCallback): void;\n /**\n * Handles the authenticated method.\n * ```ts\n * class Auth {\n public adduser(user: string, password: string, done: AuthCallback): void {\n if (!password) {\n return done(errorUtils.getUnauthorized(API_ERROR.BAD_USERNAME_PASSWORD));\n }\n // return boolean\n return done(null, true); \n * }\n * ```\n */\n adduser?(user: string, password: string, cb: AuthUserCallback): void;\n changePassword?(\n user: string,\n password: string,\n newPassword: string,\n cb: AuthChangePasswordCallback\n ): void;\n allow_publish?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;\n allow_publish?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: AuthAccessCallback): void;\n allow_access?(user: RemoteUser, pkg: T & PackageAccess, cb: AccessCallback): void;\n allow_access?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: AccessCallback): void;\n allow_unpublish?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;\n allow_unpublish?(\n user: RemoteUser,\n pkg: AllowAccess & PackageAccess,\n cb: AuthAccessCallback\n ): void;\n apiJWTmiddleware?(helpers: any): RequestHandler;\n}\n\nexport interface IBasicAuth {\n authenticate(user: string, password: string, cb: Callback): void;\n invalidateToken?(token: string): Promise<void>;\n changePassword(user: string, password: string, newPassword: string, cb: Callback): void;\n allow_access(pkg: AuthPluginPackage, user: RemoteUser, callback: Callback): void;\n add_user(user: string, password: string, cb: Callback): any;\n}\n\n// --- FILTER PLUGIN ---\n\n/**\n * Filter Plugin Interface\n *\n * https://verdaccio.org/docs/plugin-filter\n */\nexport interface ManifestFilter<T> extends Plugin<T> {\n filter_metadata(manifest: Manifest): Promise<Manifest>;\n}\n"],"mappings":";;;;;;;AA2BA,IAAa,SAAb,MAAa,OAAqB;CAChC,OAAO,UAAU;CACjB;CACA;CACA;CACA,YAAmB,QAAsB,SAAwB;AAC/D,OAAK,UAAU,OAAO;AACtB,OAAK,SAAS;AACd,OAAK,UAAU;;CAGjB,aAAoB;AAClB,SAAO,KAAK"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
//#region src/plugin-utils.ts
|
|
3
|
+
var plugin_utils_exports = /* @__PURE__ */ __exportAll({ Plugin: () => Plugin });
|
|
4
|
+
/**
|
|
5
|
+
* Base Plugin Class
|
|
6
|
+
*
|
|
7
|
+
* Set of utilities for developing plugins.
|
|
8
|
+
*/
|
|
9
|
+
var Plugin = class Plugin {
|
|
10
|
+
static version = 1;
|
|
11
|
+
version;
|
|
12
|
+
config;
|
|
13
|
+
options;
|
|
14
|
+
constructor(config, options) {
|
|
15
|
+
this.version = Plugin.version;
|
|
16
|
+
this.config = config;
|
|
17
|
+
this.options = options;
|
|
18
|
+
}
|
|
19
|
+
getVersion() {
|
|
20
|
+
return this.version;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { plugin_utils_exports };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=plugin-utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-utils.mjs","names":[],"sources":["../src/plugin-utils.ts"],"sourcesContent":["import type { Express, RequestHandler } from 'express';\nimport type { Readable, Writable } from 'node:stream';\n\nimport type {\n AllowAccess,\n Callback,\n Config,\n Logger,\n Manifest,\n PackageAccess,\n RemoteUser,\n Token,\n TokenFilter,\n} from '@verdaccio/types';\n\nimport type { VerdaccioError, searchUtils } from '.';\n\nexport interface PluginOptions {\n config: Config;\n logger: Logger;\n}\n\n/**\n * Base Plugin Class\n *\n * Set of utilities for developing plugins.\n */\nexport class Plugin<PluginConfig> {\n static version = 1;\n public readonly version: number;\n public readonly config: PluginConfig | unknown;\n public readonly options: PluginOptions;\n public constructor(config: PluginConfig, options: PluginOptions) {\n this.version = Plugin.version;\n this.config = config;\n this.options = options;\n }\n\n public getVersion() {\n return this.version;\n }\n}\n\n// --- STORAGE PLUGIN ---\n\n/**\n * Storage Handler\n *\n * Used in storage plugin for managing packages and tarballs.\n */\nexport interface StorageHandler {\n logger: Logger;\n deletePackage(fileName: string): Promise<void>;\n removePackage(packageName: string): Promise<void>;\n // next packages migration (this list is meant to replace the callback parent functions)\n updatePackage(\n packageName: string,\n handleUpdate: (manifest: Manifest) => Promise<Manifest>\n ): Promise<Manifest>;\n readPackage(packageName: string): Promise<Manifest>;\n savePackage(packageName: string, manifest: Manifest): Promise<void>;\n readTarball(fileName: string, { signal }: { signal: AbortSignal }): Promise<Readable>;\n createPackage(packageName: string, manifest: Manifest): Promise<void>;\n writeTarball(fileName: string, { signal }: { signal: AbortSignal }): Promise<Writable>;\n // verify if tarball exist in the storage\n hasTarball(fileName: string): Promise<boolean>;\n // verify if package exist in the storage\n hasPackage(packageName: string): Promise<boolean>;\n}\n\n/**\n * Storage Plugin interface\n *\n * https://verdaccio.org/docs/plugin-storage\n */\nexport interface Storage<PluginConfig> extends Plugin<PluginConfig> {\n add(packageName: string): Promise<void>;\n remove(packageName: string): Promise<void>;\n get(): Promise<string[]>;\n init(): Promise<void>;\n getSecret(): Promise<string>;\n setSecret(secret: string): Promise<any>;\n getPackageStorage(packageName: string): StorageHandler;\n search(query: searchUtils.SearchQuery): Promise<searchUtils.SearchItem[]>;\n saveToken(token: Token): Promise<any>;\n deleteToken(user: string, tokenKey: string): Promise<any>;\n readTokens(filter: TokenFilter): Promise<Token[]>;\n}\n\n// --- MIDDLEWARE PLUGIN ---\n\n/**\n * Middleware Plugin Interface\n *\n * https://verdaccio.org/docs/plugin-middleware\n *\n * This function allow add middleware to the application.\n *\n * ```ts\n * import express, { Request, Response } from 'express';\n * \n * class Middleware extends Plugin {\n * // instances of auth and storage are injected\n * register_middlewares(app, auth, storage) {\n * const router = express.Router();\n * router.post('/my-endpoint', (req: Request, res: Response): void => {\n res.status(200).end();\n });\n * }\n * }\n *\n * const [plugin] = await asyncLoadPlugin(...);\n * plugin.register_middlewares(app, auth, storage);\n * ```\n */\nexport interface ExpressMiddleware<PluginConfig, Storage, Auth> extends Plugin<PluginConfig> {\n register_middlewares(app: Express, auth: Auth, storage: Storage): void;\n}\n\n// --- AUTH PLUGIN ---\n\nexport type AuthCallback = (error: VerdaccioError | null, groups?: string[] | false) => void;\n\nexport type AuthAccessCallback = (error: VerdaccioError | null, access?: boolean) => void;\nexport type AuthUserCallback = (error: VerdaccioError | null, access?: boolean | string) => void;\nexport type AuthChangePasswordCallback = (error: VerdaccioError | null, access?: boolean) => void;\nexport type AccessCallback = (error: VerdaccioError | null, ok?: boolean) => void;\n\nexport interface AuthPluginPackage {\n packageName: string;\n packageVersion?: string;\n tag?: string;\n}\n\n/**\n * Authentication Plugin Interface\n *\n * https://verdaccio.org/docs/plugin-auth\n */\nexport interface Auth<T> extends Plugin<T> {\n /**\n * Handles the authenticated method.\n * ```ts\n * class Auth {\n public authenticate(user: string, password: string, done: AuthCallback): void {\n if (!password) {\n return done(errorUtils.getUnauthorized(API_ERROR.BAD_USERNAME_PASSWORD));\n }\n // always return an array of users\n return done(null, [user]); \n * }\n * ```\n */\n authenticate(user: string, password: string, cb: AuthCallback): void;\n /**\n * Handles the authenticated method.\n * ```ts\n * class Auth {\n public adduser(user: string, password: string, done: AuthCallback): void {\n if (!password) {\n return done(errorUtils.getUnauthorized(API_ERROR.BAD_USERNAME_PASSWORD));\n }\n // return boolean\n return done(null, true); \n * }\n * ```\n */\n adduser?(user: string, password: string, cb: AuthUserCallback): void;\n changePassword?(\n user: string,\n password: string,\n newPassword: string,\n cb: AuthChangePasswordCallback\n ): void;\n allow_publish?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;\n allow_publish?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: AuthAccessCallback): void;\n allow_access?(user: RemoteUser, pkg: T & PackageAccess, cb: AccessCallback): void;\n allow_access?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: AccessCallback): void;\n allow_unpublish?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;\n allow_unpublish?(\n user: RemoteUser,\n pkg: AllowAccess & PackageAccess,\n cb: AuthAccessCallback\n ): void;\n apiJWTmiddleware?(helpers: any): RequestHandler;\n}\n\nexport interface IBasicAuth {\n authenticate(user: string, password: string, cb: Callback): void;\n invalidateToken?(token: string): Promise<void>;\n changePassword(user: string, password: string, newPassword: string, cb: Callback): void;\n allow_access(pkg: AuthPluginPackage, user: RemoteUser, callback: Callback): void;\n add_user(user: string, password: string, cb: Callback): any;\n}\n\n// --- FILTER PLUGIN ---\n\n/**\n * Filter Plugin Interface\n *\n * https://verdaccio.org/docs/plugin-filter\n */\nexport interface ManifestFilter<T> extends Plugin<T> {\n filter_metadata(manifest: Manifest): Promise<Manifest>;\n}\n"],"mappings":";;;;;;;;AA2BA,IAAa,SAAb,MAAa,OAAqB;CAChC,OAAO,UAAU;CACjB;CACA;CACA;CACA,YAAmB,QAAsB,SAAwB;AAC/D,OAAK,UAAU,OAAO;AACtB,OAAK,SAAS;AACd,OAAK,UAAU;;CAGjB,aAAoB;AAClB,SAAO,KAAK"}
|
|
@@ -1,48 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.js");
|
|
2
|
+
let ajv = require("ajv");
|
|
3
|
+
ajv = require_runtime.__toESM(ajv);
|
|
4
|
+
//#region src/schemes/publish-manifest.ts
|
|
5
|
+
var validate = new ajv.default().compile({
|
|
6
|
+
type: "object",
|
|
7
|
+
properties: {
|
|
8
|
+
name: { type: "string" },
|
|
9
|
+
versions: {
|
|
10
|
+
type: "object",
|
|
11
|
+
maxProperties: 1
|
|
12
|
+
},
|
|
13
|
+
_attachments: {
|
|
14
|
+
type: "object",
|
|
15
|
+
maxProperties: 1
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
required: [
|
|
19
|
+
"name",
|
|
20
|
+
"versions",
|
|
21
|
+
"_attachments"
|
|
22
|
+
],
|
|
23
|
+
additionalProperties: true
|
|
5
24
|
});
|
|
6
|
-
exports.validatePublishSingleVersion = validatePublishSingleVersion;
|
|
7
|
-
var _ajv = _interopRequireDefault(require("ajv"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
const ajv = new _ajv.default();
|
|
10
|
-
|
|
11
|
-
// FIXME: this could extend from @verdaccio/types but we need
|
|
12
|
-
// schemas from @verdaccio/types to be able to validate them
|
|
13
|
-
|
|
14
|
-
const schema = {
|
|
15
|
-
type: 'object',
|
|
16
|
-
properties: {
|
|
17
|
-
name: {
|
|
18
|
-
type: 'string'
|
|
19
|
-
},
|
|
20
|
-
versions: {
|
|
21
|
-
type: 'object',
|
|
22
|
-
maxProperties: 1
|
|
23
|
-
},
|
|
24
|
-
_attachments: {
|
|
25
|
-
type: 'object',
|
|
26
|
-
maxProperties: 1
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
required: ['name', 'versions', '_attachments'],
|
|
30
|
-
additionalProperties: true
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// validate is a type guard for MyData - type is inferred from schema type
|
|
34
|
-
const validate = ajv.compile(schema);
|
|
35
|
-
|
|
36
25
|
/**
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
26
|
+
* Validate if a manifest has the correct structure when a new package
|
|
27
|
+
* is being created. The properties name, versions and _attachments must contain 1 element.
|
|
28
|
+
* @param data a manifest object
|
|
29
|
+
* @returns boolean
|
|
30
|
+
*/
|
|
42
31
|
function validatePublishSingleVersion(manifest) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
return validate(manifest);
|
|
32
|
+
if (!manifest) return false;
|
|
33
|
+
return validate(manifest);
|
|
47
34
|
}
|
|
35
|
+
//#endregion
|
|
36
|
+
exports.validatePublishSingleVersion = validatePublishSingleVersion;
|
|
37
|
+
|
|
48
38
|
//# sourceMappingURL=publish-manifest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish-manifest.js","names":[
|
|
1
|
+
{"version":3,"file":"publish-manifest.js","names":[],"sources":["../../src/schemes/publish-manifest.ts"],"sourcesContent":["import type { JSONSchemaType } from 'ajv';\nimport Ajv from 'ajv';\n\nconst ajv = new Ajv();\n\n// FIXME: this could extend from @verdaccio/types but we need\n// schemas from @verdaccio/types to be able to validate them\ninterface Manifest {\n name: string;\n versions: object;\n _attachments: object;\n}\n\nconst schema: JSONSchemaType<Manifest> = {\n type: 'object',\n properties: {\n name: { type: 'string' },\n versions: { type: 'object', maxProperties: 1 },\n _attachments: { type: 'object', maxProperties: 1 },\n },\n required: ['name', 'versions', '_attachments'],\n additionalProperties: true,\n};\n\n// validate is a type guard for MyData - type is inferred from schema type\nconst validate = ajv.compile(schema);\n\n/**\n * Validate if a manifest has the correct structure when a new package\n * is being created. The properties name, versions and _attachments must contain 1 element.\n * @param data a manifest object\n * @returns boolean\n */\nexport function validatePublishSingleVersion(manifest: any) {\n if (!manifest) {\n return false;\n }\n return validate(manifest);\n}\n"],"mappings":";;;;AAyBA,IAAM,WAtBM,IAAI,IAAA,SAAK,CAsBA,QAZoB;CACvC,MAAM;CACN,YAAY;EACV,MAAM,EAAE,MAAM,UAAU;EACxB,UAAU;GAAE,MAAM;GAAU,eAAe;GAAG;EAC9C,cAAc;GAAE,MAAM;GAAU,eAAe;GAAG;EACnD;CACD,UAAU;EAAC;EAAQ;EAAY;EAAe;CAC9C,sBAAsB;CACvB,CAGmC;;;;;;;AAQpC,SAAgB,6BAA6B,UAAe;AAC1D,KAAI,CAAC,SACH,QAAO;AAET,QAAO,SAAS,SAAS"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import Ajv from "ajv";
|
|
2
|
+
//#region src/schemes/publish-manifest.ts
|
|
3
|
+
var validate = new Ajv().compile({
|
|
4
|
+
type: "object",
|
|
5
|
+
properties: {
|
|
6
|
+
name: { type: "string" },
|
|
7
|
+
versions: {
|
|
8
|
+
type: "object",
|
|
9
|
+
maxProperties: 1
|
|
10
|
+
},
|
|
11
|
+
_attachments: {
|
|
12
|
+
type: "object",
|
|
13
|
+
maxProperties: 1
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
required: [
|
|
17
|
+
"name",
|
|
18
|
+
"versions",
|
|
19
|
+
"_attachments"
|
|
20
|
+
],
|
|
21
|
+
additionalProperties: true
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* Validate if a manifest has the correct structure when a new package
|
|
25
|
+
* is being created. The properties name, versions and _attachments must contain 1 element.
|
|
26
|
+
* @param data a manifest object
|
|
27
|
+
* @returns boolean
|
|
28
|
+
*/
|
|
29
|
+
function validatePublishSingleVersion(manifest) {
|
|
30
|
+
if (!manifest) return false;
|
|
31
|
+
return validate(manifest);
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { validatePublishSingleVersion };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=publish-manifest.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish-manifest.mjs","names":[],"sources":["../../src/schemes/publish-manifest.ts"],"sourcesContent":["import type { JSONSchemaType } from 'ajv';\nimport Ajv from 'ajv';\n\nconst ajv = new Ajv();\n\n// FIXME: this could extend from @verdaccio/types but we need\n// schemas from @verdaccio/types to be able to validate them\ninterface Manifest {\n name: string;\n versions: object;\n _attachments: object;\n}\n\nconst schema: JSONSchemaType<Manifest> = {\n type: 'object',\n properties: {\n name: { type: 'string' },\n versions: { type: 'object', maxProperties: 1 },\n _attachments: { type: 'object', maxProperties: 1 },\n },\n required: ['name', 'versions', '_attachments'],\n additionalProperties: true,\n};\n\n// validate is a type guard for MyData - type is inferred from schema type\nconst validate = ajv.compile(schema);\n\n/**\n * Validate if a manifest has the correct structure when a new package\n * is being created. The properties name, versions and _attachments must contain 1 element.\n * @param data a manifest object\n * @returns boolean\n */\nexport function validatePublishSingleVersion(manifest: any) {\n if (!manifest) {\n return false;\n }\n return validate(manifest);\n}\n"],"mappings":";;AAyBA,IAAM,WAtBM,IAAI,KAAK,CAsBA,QAZoB;CACvC,MAAM;CACN,YAAY;EACV,MAAM,EAAE,MAAM,UAAU;EACxB,UAAU;GAAE,MAAM;GAAU,eAAe;GAAG;EAC9C,cAAc;GAAE,MAAM;GAAU,eAAe;GAAG;EACnD;CACD,UAAU;EAAC;EAAQ;EAAY;EAAe;CAC9C,sBAAsB;CACvB,CAGmC;;;;;;;AAQpC,SAAgB,6BAA6B,UAAe;AAC1D,KAAI,CAAC,SACH,QAAO;AAET,QAAO,SAAS,SAAS"}
|