@verdaccio/store 6.0.0-6-next.28 → 6.0.0-6-next.30
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 +35 -0
- package/build/lib/star-utils.d.ts +10 -8
- package/build/lib/star-utils.js +19 -35
- package/build/lib/star-utils.js.map +1 -1
- package/build/local-storage.d.ts +3 -3
- package/build/local-storage.js +1 -1
- package/build/local-storage.js.map +1 -1
- package/build/storage.d.ts +6 -5
- package/build/storage.js +55 -11
- package/build/storage.js.map +1 -1
- package/build/type.d.ts +6 -10
- package/build/type.js.map +1 -1
- package/jest.config.js +3 -3
- package/package.json +14 -14
- package/src/lib/star-utils.ts +24 -29
- package/src/local-storage.ts +9 -9
- package/src/storage.ts +84 -34
- package/src/type.ts +6 -11
- package/test/star-utils.test.ts +58 -0
- package/test/storage.spec.ts +211 -2
- package/tsconfig.json +0 -6
- package/types/patch.d.ts +12 -0
- package/test/star.spec.ts +0 -31
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @verdaccio/store
|
|
2
2
|
|
|
3
|
+
## 6.0.0-6-next.30
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @verdaccio/core@6.0.0-6-next.50
|
|
8
|
+
- @verdaccio/config@6.0.0-6-next.50
|
|
9
|
+
- @verdaccio/tarball@11.0.0-6-next.19
|
|
10
|
+
- @verdaccio/url@11.0.0-6-next.16
|
|
11
|
+
- @verdaccio/hooks@6.0.0-6-next.20
|
|
12
|
+
- @verdaccio/loaders@6.0.0-6-next.19
|
|
13
|
+
- @verdaccio/logger@6.0.0-6-next.18
|
|
14
|
+
- @verdaccio/local-storage@11.0.0-6-next.20
|
|
15
|
+
- @verdaccio/proxy@6.0.0-6-next.28
|
|
16
|
+
- @verdaccio/utils@6.0.0-6-next.18
|
|
17
|
+
|
|
18
|
+
## 6.0.0-6-next.29
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- ce013d2f: refactor: npm star command support reimplemented
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Updated dependencies [ce013d2f]
|
|
27
|
+
- @verdaccio/url@11.0.0-6-next.15
|
|
28
|
+
- @verdaccio/tarball@11.0.0-6-next.18
|
|
29
|
+
- @verdaccio/local-storage@11.0.0-6-next.19
|
|
30
|
+
- @verdaccio/core@6.0.0-6-next.49
|
|
31
|
+
- @verdaccio/config@6.0.0-6-next.49
|
|
32
|
+
- @verdaccio/hooks@6.0.0-6-next.19
|
|
33
|
+
- @verdaccio/loaders@6.0.0-6-next.18
|
|
34
|
+
- @verdaccio/logger@6.0.0-6-next.17
|
|
35
|
+
- @verdaccio/proxy@6.0.0-6-next.27
|
|
36
|
+
- @verdaccio/utils@6.0.0-6-next.17
|
|
37
|
+
|
|
3
38
|
## 6.0.0-6-next.28
|
|
4
39
|
|
|
5
40
|
### Major Changes
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { Manifest } from '@verdaccio/types';
|
|
2
|
-
import { Users } from '../type';
|
|
1
|
+
import { Manifest, PackageUsers } from '@verdaccio/types';
|
|
3
2
|
/**
|
|
4
|
-
* Check whether the package
|
|
3
|
+
* Check whether the package metadata has enough data to be published
|
|
5
4
|
* @param pkg metadata
|
|
6
5
|
*/
|
|
6
|
+
export declare function isPublishablePackage(pkg: Manifest): boolean;
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* Verify if the user is actually executing an action, to avoid unnecessary calls
|
|
9
|
+
* to the storage.
|
|
10
|
+
* @param localUsers current state at cache
|
|
11
|
+
* @param username user is executing the action
|
|
12
|
+
* @param userIsAddingStar whether user is removing or adding star
|
|
13
|
+
* @returns boolean
|
|
10
14
|
*/
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function isRelatedToDeprecation(pkgInfo: Manifest): boolean;
|
|
13
|
-
export declare function validateInputs(localUsers: Users, username: string, isStar: boolean): boolean;
|
|
15
|
+
export declare function isExecutingStarCommand(localUsers: PackageUsers, username: string, userIsAddingStar: boolean): boolean;
|
|
14
16
|
export declare function isStarManifest(manifest: Manifest): boolean;
|
package/build/lib/star-utils.js
CHANGED
|
@@ -3,59 +3,43 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.isExecutingStarCommand = isExecutingStarCommand;
|
|
6
7
|
exports.isPublishablePackage = isPublishablePackage;
|
|
7
|
-
exports.isRelatedToDeprecation = isRelatedToDeprecation;
|
|
8
8
|
exports.isStarManifest = isStarManifest;
|
|
9
|
-
exports.validateInputs = validateInputs;
|
|
10
|
-
|
|
11
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
12
9
|
|
|
13
10
|
var _core = require("@verdaccio/core");
|
|
14
11
|
|
|
15
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
|
|
17
12
|
/**
|
|
18
|
-
* Check whether the package
|
|
19
|
-
* @param pkg metadata
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Check whether the package metadta has enough data to be published
|
|
13
|
+
* Check whether the package metadata has enough data to be published
|
|
24
14
|
* @param pkg metadata
|
|
25
15
|
*/
|
|
26
16
|
function isPublishablePackage(pkg) {
|
|
27
17
|
// TODO: we can do better, no need get keys
|
|
28
18
|
const keys = Object.keys(pkg);
|
|
29
19
|
return keys.includes('versions');
|
|
30
|
-
} // @deprecated don't think this is used anymore (REMOVE)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
function isRelatedToDeprecation(pkgInfo) {
|
|
34
|
-
const {
|
|
35
|
-
versions
|
|
36
|
-
} = pkgInfo;
|
|
37
|
-
|
|
38
|
-
for (const version in versions) {
|
|
39
|
-
if (Object.prototype.hasOwnProperty.call(versions[version], 'deprecated')) {
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return false;
|
|
45
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Verify if the user is actually executing an action, to avoid unnecessary calls
|
|
23
|
+
* to the storage.
|
|
24
|
+
* @param localUsers current state at cache
|
|
25
|
+
* @param username user is executing the action
|
|
26
|
+
* @param userIsAddingStar whether user is removing or adding star
|
|
27
|
+
* @returns boolean
|
|
28
|
+
*/
|
|
29
|
+
|
|
46
30
|
|
|
47
|
-
function
|
|
48
|
-
const
|
|
31
|
+
function isExecutingStarCommand(localUsers, username, userIsAddingStar) {
|
|
32
|
+
const isExist = typeof localUsers[username] !== 'undefined'; // fails if user already exist and us trying to add star.
|
|
49
33
|
|
|
50
|
-
if (
|
|
51
|
-
return
|
|
52
|
-
} else if (!
|
|
34
|
+
if (userIsAddingStar && isExist && localUsers[username]) {
|
|
35
|
+
return false; // if is not adding a start but user exists (removing star)
|
|
36
|
+
} else if (!userIsAddingStar && isExist) {
|
|
37
|
+
return true; // fails if user does not exist and is not adding any star
|
|
38
|
+
} else if (!userIsAddingStar && !isExist) {
|
|
53
39
|
return false;
|
|
54
|
-
} else if (!isStar && !isExistlocalUsers) {
|
|
55
|
-
return true;
|
|
56
40
|
}
|
|
57
41
|
|
|
58
|
-
return
|
|
42
|
+
return true;
|
|
59
43
|
}
|
|
60
44
|
|
|
61
45
|
function isStarManifest(manifest) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"star-utils.js","names":["isPublishablePackage","pkg","keys","Object","includes","
|
|
1
|
+
{"version":3,"file":"star-utils.js","names":["isPublishablePackage","pkg","keys","Object","includes","isExecutingStarCommand","localUsers","username","userIsAddingStar","isExist","isStarManifest","manifest","validatioUtils","isObject","users"],"sources":["../../src/lib/star-utils.ts"],"sourcesContent":["import { validatioUtils } from '@verdaccio/core';\nimport { Manifest, PackageUsers } from '@verdaccio/types';\n\n/**\n * Check whether the package metadata has enough data to be published\n * @param pkg metadata\n */\nexport function isPublishablePackage(pkg: Manifest): boolean {\n // TODO: we can do better, no need get keys\n const keys: string[] = Object.keys(pkg);\n\n return keys.includes('versions');\n}\n\n/**\n * Verify if the user is actually executing an action, to avoid unnecessary calls\n * to the storage.\n * @param localUsers current state at cache\n * @param username user is executing the action\n * @param userIsAddingStar whether user is removing or adding star\n * @returns boolean\n */\nexport function isExecutingStarCommand(\n localUsers: PackageUsers,\n username: string,\n userIsAddingStar: boolean\n): boolean {\n const isExist = typeof localUsers[username] !== 'undefined';\n // fails if user already exist and us trying to add star.\n if (userIsAddingStar && isExist && localUsers[username]) {\n return false;\n // if is not adding a start but user exists (removing star)\n } else if (!userIsAddingStar && isExist) {\n return true;\n // fails if user does not exist and is not adding any star\n } else if (!userIsAddingStar && !isExist) {\n return false;\n }\n return true;\n}\n\nexport function isStarManifest(manifest: Manifest): boolean {\n return isPublishablePackage(manifest) === false && validatioUtils.isObject(manifest.users);\n}\n"],"mappings":";;;;;;;;;AAAA;;AAGA;AACA;AACA;AACA;AACO,SAASA,oBAAT,CAA8BC,GAA9B,EAAsD;EAC3D;EACA,MAAMC,IAAc,GAAGC,MAAM,CAACD,IAAP,CAAYD,GAAZ,CAAvB;EAEA,OAAOC,IAAI,CAACE,QAAL,CAAc,UAAd,CAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,sBAAT,CACLC,UADK,EAELC,QAFK,EAGLC,gBAHK,EAII;EACT,MAAMC,OAAO,GAAG,OAAOH,UAAU,CAACC,QAAD,CAAjB,KAAgC,WAAhD,CADS,CAET;;EACA,IAAIC,gBAAgB,IAAIC,OAApB,IAA+BH,UAAU,CAACC,QAAD,CAA7C,EAAyD;IACvD,OAAO,KAAP,CADuD,CAEvD;EACD,CAHD,MAGO,IAAI,CAACC,gBAAD,IAAqBC,OAAzB,EAAkC;IACvC,OAAO,IAAP,CADuC,CAEvC;EACD,CAHM,MAGA,IAAI,CAACD,gBAAD,IAAqB,CAACC,OAA1B,EAAmC;IACxC,OAAO,KAAP;EACD;;EACD,OAAO,IAAP;AACD;;AAEM,SAASC,cAAT,CAAwBC,QAAxB,EAAqD;EAC1D,OAAOX,oBAAoB,CAACW,QAAD,CAApB,KAAmC,KAAnC,IAA4CC,oBAAA,CAAeC,QAAf,CAAwBF,QAAQ,CAACG,KAAjC,CAAnD;AACD"}
|
package/build/local-storage.d.ts
CHANGED
|
@@ -2,17 +2,17 @@ import { pluginUtils } from '@verdaccio/core';
|
|
|
2
2
|
import { Config, Logger } from '@verdaccio/types';
|
|
3
3
|
export declare const noSuchFile = "ENOENT";
|
|
4
4
|
export declare const resourceNotAvailable = "EAGAIN";
|
|
5
|
-
export declare type
|
|
5
|
+
export declare type PluginStorage = pluginUtils.Storage<Config>;
|
|
6
6
|
/**
|
|
7
7
|
* Implements Storage interface (same for storage.js, local-storage.js, up-storage.js).
|
|
8
8
|
*/
|
|
9
9
|
declare class LocalStorage {
|
|
10
10
|
config: Config;
|
|
11
|
-
storagePlugin:
|
|
11
|
+
storagePlugin: PluginStorage;
|
|
12
12
|
logger: Logger;
|
|
13
13
|
constructor(config: Config, logger: Logger);
|
|
14
14
|
init(): Promise<void>;
|
|
15
|
-
getStoragePlugin():
|
|
15
|
+
getStoragePlugin(): PluginStorage;
|
|
16
16
|
getSecret(config: Config): Promise<void>;
|
|
17
17
|
private loadStorage;
|
|
18
18
|
private loadStorePlugin;
|
package/build/local-storage.js
CHANGED
|
@@ -84,7 +84,7 @@ class LocalStorage {
|
|
|
84
84
|
config: this.config,
|
|
85
85
|
logger: this.logger
|
|
86
86
|
}, plugin => {
|
|
87
|
-
return plugin.getPackageStorage;
|
|
87
|
+
return typeof plugin.getPackageStorage !== 'undefined';
|
|
88
88
|
}, (_this$config = this.config) === null || _this$config === void 0 ? void 0 : (_this$config$serverSe = _this$config.serverSettings) === null || _this$config$serverSe === void 0 ? void 0 : _this$config$serverSe.pluginPrefix);
|
|
89
89
|
|
|
90
90
|
if (plugins.length > 1) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-storage.js","names":["debug","buildDebug","noSuchFile","resourceNotAvailable","LocalStorage","constructor","config","logger","child","sub","storagePlugin","init","loadStorage","warn","getStoragePlugin","errorUtils","getInternalError","getSecret","secretKey","setSecret","checkSecretKey","Storage","loadStorePlugin","_","isNil","assert","storage","LocalDatabase","plugins","asyncLoadPlugin","store","plugin","getPackageStorage","serverSettings","pluginPrefix","length","head"],"sources":["../src/local-storage.ts"],"sourcesContent":["import assert from 'assert';\nimport buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport { errorUtils, pluginUtils } from '@verdaccio/core';\nimport { asyncLoadPlugin } from '@verdaccio/loaders';\nimport LocalDatabase from '@verdaccio/local-storage';\nimport { Config, Logger } from '@verdaccio/types';\n\nconst debug = buildDebug('verdaccio:storage:local');\n\nexport const noSuchFile = 'ENOENT';\nexport const resourceNotAvailable = 'EAGAIN';\nexport type
|
|
1
|
+
{"version":3,"file":"local-storage.js","names":["debug","buildDebug","noSuchFile","resourceNotAvailable","LocalStorage","constructor","config","logger","child","sub","storagePlugin","init","loadStorage","warn","getStoragePlugin","errorUtils","getInternalError","getSecret","secretKey","setSecret","checkSecretKey","Storage","loadStorePlugin","_","isNil","assert","storage","LocalDatabase","plugins","asyncLoadPlugin","store","plugin","getPackageStorage","serverSettings","pluginPrefix","length","head"],"sources":["../src/local-storage.ts"],"sourcesContent":["import assert from 'assert';\nimport buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport { errorUtils, pluginUtils } from '@verdaccio/core';\nimport { asyncLoadPlugin } from '@verdaccio/loaders';\nimport LocalDatabase from '@verdaccio/local-storage';\nimport { Config, Logger } from '@verdaccio/types';\n\nconst debug = buildDebug('verdaccio:storage:local');\n\nexport const noSuchFile = 'ENOENT';\nexport const resourceNotAvailable = 'EAGAIN';\nexport type PluginStorage = pluginUtils.Storage<Config>;\n\n/**\n * Implements Storage interface (same for storage.js, local-storage.js, up-storage.js).\n */\nclass LocalStorage {\n public config: Config;\n public storagePlugin: PluginStorage;\n public logger: Logger;\n\n public constructor(config: Config, logger: Logger) {\n debug('local storage created');\n this.logger = logger.child({ sub: 'fs' });\n this.config = config;\n // @ts-expect-error\n this.storagePlugin = null;\n }\n\n public async init() {\n if (this.storagePlugin === null) {\n this.storagePlugin = await this.loadStorage(this.config, this.logger);\n debug('storage plugin init');\n await this.storagePlugin.init();\n debug('storage plugin initialized');\n } else {\n this.logger.warn('storage plugin has been already initialized');\n }\n return;\n }\n\n public getStoragePlugin(): PluginStorage {\n if (this.storagePlugin === null) {\n throw errorUtils.getInternalError('storage plugin is not initialized');\n }\n\n return this.storagePlugin;\n }\n\n public async getSecret(config: Config): Promise<void> {\n const secretKey = await this.storagePlugin.getSecret();\n\n return this.storagePlugin.setSecret(config.checkSecretKey(secretKey));\n }\n\n private async loadStorage(config: Config, logger: Logger): Promise<PluginStorage> {\n const Storage = await this.loadStorePlugin();\n if (_.isNil(Storage)) {\n assert(this.config.storage, 'CONFIG: storage path not defined');\n debug('no custom storage found, loading default storage @verdaccio/local-storage');\n return new LocalDatabase(config, logger);\n }\n return Storage as PluginStorage;\n }\n\n private async loadStorePlugin(): Promise<PluginStorage | undefined> {\n const plugins: PluginStorage[] = await asyncLoadPlugin<pluginUtils.Storage<unknown>>(\n this.config.store,\n {\n config: this.config,\n logger: this.logger,\n },\n (plugin) => {\n return typeof plugin.getPackageStorage !== 'undefined';\n },\n this.config?.serverSettings?.pluginPrefix\n );\n\n if (plugins.length > 1) {\n this.logger.warn(\n 'more than one storage plugins has been detected, multiple storage are not supported, one will be selected automatically'\n );\n }\n\n return _.head(plugins);\n }\n}\n\nexport { LocalStorage };\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;AAGA,MAAMA,KAAK,GAAG,IAAAC,cAAA,EAAW,yBAAX,CAAd;AAEO,MAAMC,UAAU,GAAG,QAAnB;;AACA,MAAMC,oBAAoB,GAAG,QAA7B;;;AAGP;AACA;AACA;AACA,MAAMC,YAAN,CAAmB;EAKVC,WAAW,CAACC,MAAD,EAAiBC,MAAjB,EAAiC;IACjDP,KAAK,CAAC,uBAAD,CAAL;IACA,KAAKO,MAAL,GAAcA,MAAM,CAACC,KAAP,CAAa;MAAEC,GAAG,EAAE;IAAP,CAAb,CAAd;IACA,KAAKH,MAAL,GAAcA,MAAd,CAHiD,CAIjD;;IACA,KAAKI,aAAL,GAAqB,IAArB;EACD;;EAEgB,MAAJC,IAAI,GAAG;IAClB,IAAI,KAAKD,aAAL,KAAuB,IAA3B,EAAiC;MAC/B,KAAKA,aAAL,GAAqB,MAAM,KAAKE,WAAL,CAAiB,KAAKN,MAAtB,EAA8B,KAAKC,MAAnC,CAA3B;MACAP,KAAK,CAAC,qBAAD,CAAL;MACA,MAAM,KAAKU,aAAL,CAAmBC,IAAnB,EAAN;MACAX,KAAK,CAAC,4BAAD,CAAL;IACD,CALD,MAKO;MACL,KAAKO,MAAL,CAAYM,IAAZ,CAAiB,6CAAjB;IACD;;IACD;EACD;;EAEMC,gBAAgB,GAAkB;IACvC,IAAI,KAAKJ,aAAL,KAAuB,IAA3B,EAAiC;MAC/B,MAAMK,gBAAA,CAAWC,gBAAX,CAA4B,mCAA5B,CAAN;IACD;;IAED,OAAO,KAAKN,aAAZ;EACD;;EAEqB,MAATO,SAAS,CAACX,MAAD,EAAgC;IACpD,MAAMY,SAAS,GAAG,MAAM,KAAKR,aAAL,CAAmBO,SAAnB,EAAxB;IAEA,OAAO,KAAKP,aAAL,CAAmBS,SAAnB,CAA6Bb,MAAM,CAACc,cAAP,CAAsBF,SAAtB,CAA7B,CAAP;EACD;;EAEwB,MAAXN,WAAW,CAACN,MAAD,EAAiBC,MAAjB,EAAyD;IAChF,MAAMc,OAAO,GAAG,MAAM,KAAKC,eAAL,EAAtB;;IACA,IAAIC,eAAA,CAAEC,KAAF,CAAQH,OAAR,CAAJ,EAAsB;MACpB,IAAAI,eAAA,EAAO,KAAKnB,MAAL,CAAYoB,OAAnB,EAA4B,kCAA5B;MACA1B,KAAK,CAAC,2EAAD,CAAL;MACA,OAAO,IAAI2B,qBAAJ,CAAkBrB,MAAlB,EAA0BC,MAA1B,CAAP;IACD;;IACD,OAAOc,OAAP;EACD;;EAE4B,MAAfC,eAAe,GAAuC;IAAA;;IAClE,MAAMM,OAAwB,GAAG,MAAM,IAAAC,wBAAA,EACrC,KAAKvB,MAAL,CAAYwB,KADyB,EAErC;MACExB,MAAM,EAAE,KAAKA,MADf;MAEEC,MAAM,EAAE,KAAKA;IAFf,CAFqC,EAMpCwB,MAAD,IAAY;MACV,OAAO,OAAOA,MAAM,CAACC,iBAAd,KAAoC,WAA3C;IACD,CARoC,kBASrC,KAAK1B,MATgC,0EASrC,aAAa2B,cATwB,0DASrC,sBAA6BC,YATQ,CAAvC;;IAYA,IAAIN,OAAO,CAACO,MAAR,GAAiB,CAArB,EAAwB;MACtB,KAAK5B,MAAL,CAAYM,IAAZ,CACE,yHADF;IAGD;;IAED,OAAOU,eAAA,CAAEa,IAAF,CAAOR,OAAP,CAAP;EACD;;AArEgB"}
|
package/build/storage.d.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { PassThrough, Readable } from 'stream';
|
|
3
|
-
import { searchUtils } from '@verdaccio/core';
|
|
3
|
+
import { pluginUtils, searchUtils } from '@verdaccio/core';
|
|
4
4
|
import { ISyncUplinksOptions, ProxySearchParams } from '@verdaccio/proxy';
|
|
5
5
|
import { AbbreviatedManifest, Config, Logger, Manifest, MergeTags, StringValue, Token, TokenFilter, Version } from '@verdaccio/types';
|
|
6
6
|
import { UpdateManifestOptions } from '.';
|
|
7
7
|
import { ProxyInstanceList } from './lib/uplink-util';
|
|
8
8
|
import { LocalStorage } from './local-storage';
|
|
9
|
-
import { IGetPackageOptionsNext,
|
|
9
|
+
import { IGetPackageOptionsNext, StarManifestBody } from './type';
|
|
10
|
+
export declare type Filters = pluginUtils.ManifestFilter<Config>[];
|
|
10
11
|
export declare const noSuchFile = "ENOENT";
|
|
11
12
|
export declare const resourceNotAvailable = "EAGAIN";
|
|
12
13
|
export declare const PROTO_NAME = "__proto__";
|
|
13
14
|
declare class Storage {
|
|
14
15
|
localStorage: LocalStorage;
|
|
15
|
-
filters:
|
|
16
|
+
filters: Filters | null;
|
|
16
17
|
readonly config: Config;
|
|
17
18
|
readonly logger: Logger;
|
|
18
19
|
readonly uplinks: ProxyInstanceList;
|
|
@@ -67,7 +68,7 @@ declare class Storage {
|
|
|
67
68
|
/**
|
|
68
69
|
* Initialize the storage asynchronously.
|
|
69
70
|
* @param config Config
|
|
70
|
-
* @param filters
|
|
71
|
+
* @param filters Filters
|
|
71
72
|
* @returns Storage instance
|
|
72
73
|
*/
|
|
73
74
|
init(config: Config): Promise<void>;
|
|
@@ -114,7 +115,7 @@ declare class Storage {
|
|
|
114
115
|
*/
|
|
115
116
|
mergeTagsNext(name: string, tags: MergeTags): Promise<Manifest>;
|
|
116
117
|
private getUpLinkForDistFile;
|
|
117
|
-
updateManifest(manifest: Manifest, options: UpdateManifestOptions): Promise<
|
|
118
|
+
updateManifest(manifest: Manifest | StarManifestBody, options: UpdateManifestOptions): Promise<string | undefined>;
|
|
118
119
|
private deprecate;
|
|
119
120
|
private star;
|
|
120
121
|
/**
|
package/build/storage.js
CHANGED
|
@@ -631,7 +631,7 @@ class Storage {
|
|
|
631
631
|
/**
|
|
632
632
|
* Initialize the storage asynchronously.
|
|
633
633
|
* @param config Config
|
|
634
|
-
* @param filters
|
|
634
|
+
* @param filters Filters
|
|
635
635
|
* @returns Storage instance
|
|
636
636
|
*/
|
|
637
637
|
|
|
@@ -654,7 +654,7 @@ class Storage {
|
|
|
654
654
|
config: this.config,
|
|
655
655
|
logger: this.logger
|
|
656
656
|
}, plugin => {
|
|
657
|
-
return plugin.filterMetadata;
|
|
657
|
+
return typeof plugin.filterMetadata !== 'undefined';
|
|
658
658
|
}, (_this$config = this.config) === null || _this$config === void 0 ? void 0 : (_this$config$serverSe = _this$config.serverSettings) === null || _this$config$serverSe === void 0 ? void 0 : _this$config$serverSe.pluginPrefix);
|
|
659
659
|
debug('filters available %o', this.filters);
|
|
660
660
|
}
|
|
@@ -941,10 +941,11 @@ class Storage {
|
|
|
941
941
|
// if user request to apply a star to the manifest
|
|
942
942
|
await this.star(manifest, { ...options
|
|
943
943
|
});
|
|
944
|
+
return _core.API_MESSAGE.PKG_CHANGED;
|
|
944
945
|
} else if (_core.validatioUtils.validatePublishSingleVersion(manifest)) {
|
|
945
946
|
// if continue, the version to be published does not exist
|
|
946
947
|
// we create a new package
|
|
947
|
-
const [mergedManifest, version] = await this.publishANewVersion(manifest, { ...options
|
|
948
|
+
const [mergedManifest, version, message] = await this.publishANewVersion(manifest, { ...options
|
|
948
949
|
}); // send notification of publication (notification step, non transactional)
|
|
949
950
|
|
|
950
951
|
try {
|
|
@@ -962,6 +963,8 @@ class Storage {
|
|
|
962
963
|
error: error.message
|
|
963
964
|
}, 'notify batch service has failed: @{error}');
|
|
964
965
|
}
|
|
966
|
+
|
|
967
|
+
return message;
|
|
965
968
|
} else {
|
|
966
969
|
debug('invalid body format');
|
|
967
970
|
|
|
@@ -979,15 +982,52 @@ class Storage {
|
|
|
979
982
|
} = manifest;
|
|
980
983
|
debug('deprecating %s', name);
|
|
981
984
|
return this.changePackage(name, manifest, options.revision);
|
|
982
|
-
}
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
async star(manifest, options) {
|
|
988
|
+
const {
|
|
989
|
+
users
|
|
990
|
+
} = manifest;
|
|
991
|
+
const {
|
|
992
|
+
requestOptions,
|
|
993
|
+
name
|
|
994
|
+
} = options;
|
|
995
|
+
debug('star %s', name);
|
|
996
|
+
const {
|
|
997
|
+
username
|
|
998
|
+
} = requestOptions;
|
|
999
|
+
|
|
1000
|
+
if (!username) {
|
|
1001
|
+
throw _core.errorUtils.getBadRequest('update users only allowed to logged users');
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
const localPackage = await this.getPackageManifest({
|
|
1005
|
+
name,
|
|
1006
|
+
requestOptions,
|
|
1007
|
+
uplinksLook: false
|
|
1008
|
+
}); // backward compatible in case users are not in the storage.
|
|
1009
|
+
|
|
1010
|
+
const localStarUsers = localPackage.users || {}; // if trying to add a star
|
|
1011
|
+
|
|
1012
|
+
const userIsAddingStar = Object.keys(users).includes(username);
|
|
983
1013
|
|
|
1014
|
+
if (!(0, _starUtils.isExecutingStarCommand)(localPackage.users, username, userIsAddingStar)) {
|
|
1015
|
+
return _core.API_MESSAGE.PKG_CHANGED;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
const newUsers = userIsAddingStar ? { ...localStarUsers,
|
|
1019
|
+
[username]: true
|
|
1020
|
+
} : _lodash.default.reduce(localStarUsers, (users, value, key) => {
|
|
1021
|
+
if (key !== username) {
|
|
1022
|
+
users[key] = value;
|
|
1023
|
+
}
|
|
984
1024
|
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
1025
|
+
return users;
|
|
1026
|
+
}, {});
|
|
1027
|
+
await this.changePackage(name, { ...localPackage,
|
|
1028
|
+
users: newUsers
|
|
1029
|
+
}, options.revision);
|
|
1030
|
+
return _core.API_MESSAGE.PKG_CHANGED;
|
|
991
1031
|
}
|
|
992
1032
|
/**
|
|
993
1033
|
* Get local package, on fails return null.
|
|
@@ -1055,6 +1095,7 @@ class Storage {
|
|
|
1055
1095
|
name
|
|
1056
1096
|
} = options;
|
|
1057
1097
|
debug('publishing a new package for %o', name);
|
|
1098
|
+
let successResponseMessage;
|
|
1058
1099
|
const manifest = { ..._core.validatioUtils.normalizeMetadata(body, name)
|
|
1059
1100
|
};
|
|
1060
1101
|
const {
|
|
@@ -1099,6 +1140,9 @@ class Storage {
|
|
|
1099
1140
|
|
|
1100
1141
|
if (!hasPackageInStorage) {
|
|
1101
1142
|
await this.createNewLocalCachePackage(name, versionToPublish);
|
|
1143
|
+
successResponseMessage = _core.API_MESSAGE.PKG_CREATED;
|
|
1144
|
+
} else {
|
|
1145
|
+
successResponseMessage = _core.API_MESSAGE.PKG_CHANGED;
|
|
1102
1146
|
}
|
|
1103
1147
|
} catch (err) {
|
|
1104
1148
|
debug('error on change or update a package with %o', err.message);
|
|
@@ -1167,7 +1211,7 @@ class Storage {
|
|
|
1167
1211
|
version: versionToPublish
|
|
1168
1212
|
}, 'package @{name}@@{version} has been published');
|
|
1169
1213
|
|
|
1170
|
-
return [mergedManifest, versionToPublish];
|
|
1214
|
+
return [mergedManifest, versionToPublish, successResponseMessage];
|
|
1171
1215
|
} // TODO: pending implementation
|
|
1172
1216
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1173
1217
|
|