generator-verdaccio-plugin 4.0.0-next.0 → 4.0.0-next.3
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/README.md +11 -20
- package/{build → generators}/app/index.js +20 -17
- package/generators/app/index.js.map +1 -0
- package/{build → generators}/app/templates/typescript/auth/_package.json +5 -6
- package/{build/app/templates/typescript/auth/src/index.js → generators/app/templates/typescript/auth/src/index.ts} +20 -21
- package/generators/app/templates/typescript/auth/types/index.ts +5 -0
- package/{build → generators}/app/templates/typescript/common/README.md +0 -0
- package/{build → generators}/app/templates/typescript/common/editorconfig +0 -0
- package/{build → generators}/app/templates/typescript/common/eslintignore +0 -1
- package/{build → generators}/app/templates/typescript/common/eslintrc +0 -0
- package/{build → generators}/app/templates/typescript/common/gitignore +0 -0
- package/{build → generators}/app/templates/typescript/common/index.js +0 -1
- package/{build → generators}/app/templates/typescript/common/jest.config.js +0 -0
- package/{build → generators}/app/templates/typescript/common/npmignore +0 -1
- package/{build → generators}/app/templates/typescript/common/tsconfig.json +1 -5
- package/{build → generators}/app/templates/typescript/middleware/_package.json +5 -6
- package/generators/app/templates/typescript/middleware/src/index.ts +35 -0
- package/generators/app/templates/typescript/middleware/types/index.ts +5 -0
- package/{build → generators}/app/templates/typescript/storage/_package.json +7 -8
- package/{build/app/templates/typescript/storage/src/PackageStorage.js → generators/app/templates/typescript/storage/src/PackageStorage.ts} +52 -37
- package/generators/app/templates/typescript/storage/src/index.ts +1 -0
- package/{build/app/templates/typescript/storage/src/plugin.js → generators/app/templates/typescript/storage/src/plugin.ts} +51 -40
- package/generators/app/templates/typescript/storage/types/index.ts +5 -0
- package/package.json +9 -11
- package/build/app/index.js.map +0 -1
- package/build/app/templates/typescript/auth/src/index.js.map +0 -1
- package/build/app/templates/typescript/auth/types/index.js +0 -6
- package/build/app/templates/typescript/auth/types/index.js.map +0 -1
- package/build/app/templates/typescript/common/index.js.map +0 -1
- package/build/app/templates/typescript/middleware/src/index.js +0 -36
- package/build/app/templates/typescript/middleware/src/index.js.map +0 -1
- package/build/app/templates/typescript/middleware/types/index.js +0 -6
- package/build/app/templates/typescript/middleware/types/index.js.map +0 -1
- package/build/app/templates/typescript/storage/src/PackageStorage.js.map +0 -1
- package/build/app/templates/typescript/storage/src/index.js +0 -16
- package/build/app/templates/typescript/storage/src/index.js.map +0 -1
- package/build/app/templates/typescript/storage/src/plugin.js.map +0 -1
- package/build/app/templates/typescript/storage/types/index.js +0 -6
- package/build/app/templates/typescript/storage/types/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
[![NPM version][npm-image]][npm-url]
|
|
4
|
-
[![Dependency Status][daviddm-image]][daviddm-url]
|
|
5
|
-
[](https://dependabot.com)
|
|
6
|
-
[](https://david-dm.org/verdaccio/generator-verdaccio-plugin/master?type=dev)
|
|
7
|
-
[](./LICENSE)
|
|
1
|
+
# Plugin Generator
|
|
8
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/verdaccio)
|
|
4
|
+
[](https://www.npmjs.com/package/verdaccio)
|
|
5
|
+
[](https://verdaccio.org/docs/en/docker.html)
|
|
9
6
|
[](https://opencollective.com/verdaccio)
|
|
10
7
|
[](https://stackshare.io/verdaccio)
|
|
11
8
|
[](http://chat.verdaccio.org/)
|
|
@@ -13,11 +10,6 @@
|
|
|
13
10
|
|
|
14
11
|
Verdaccio plugin generator based in [Yeoman](http://yeoman.io) aims to help to scaffold plugins development
|
|
15
12
|
|
|
16
|
-
### Maintainers
|
|
17
|
-
|
|
18
|
-
* [Anix](https://github.com/anikethsaha)
|
|
19
|
-
* [Juan Picado](https://github.com/juanpicado)
|
|
20
|
-
|
|
21
13
|
## Installation
|
|
22
14
|
|
|
23
15
|
First, install [Yeoman](http://yeoman.io) and generator-verdaccio-plugin using [npm](https://www.npmjs.com/) (we assume you have pre-installed [node.js](https://nodejs.org/)).
|
|
@@ -35,16 +27,15 @@ yo verdaccio-plugin
|
|
|
35
27
|
|
|
36
28
|
## Plugin Types Supported
|
|
37
29
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
* Authentication
|
|
31
|
+
* Storage
|
|
32
|
+
* Middleware
|
|
41
33
|
|
|
34
|
+
### Maintainers
|
|
35
|
+
|
|
36
|
+
* [Anix](https://github.com/anikethsaha)
|
|
37
|
+
* [Juan Picado](https://github.com/juanpicado)
|
|
42
38
|
|
|
43
39
|
## License
|
|
44
40
|
|
|
45
41
|
MIT © [Juan Picado <@jotadeveloper>]()
|
|
46
|
-
|
|
47
|
-
[npm-image]: https://badge.fury.io/js/generator-verdaccio-plugin.svg
|
|
48
|
-
[npm-url]: https://npmjs.org/package/generator-verdaccio-plugin
|
|
49
|
-
[daviddm-image]: https://david-dm.org/verdaccio/generator-verdaccio-plugin.svg?theme=shields.io
|
|
50
|
-
[daviddm-url]: https://david-dm.org/verdaccio/generator-verdaccio-plugin
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
3
|
var _path = require("path");
|
|
9
4
|
|
|
10
5
|
var _yeomanGenerator = _interopRequireDefault(require("yeoman-generator"));
|
|
@@ -27,17 +22,8 @@ class VerdaccioPluginGenerator extends _yeomanGenerator.default {
|
|
|
27
22
|
}
|
|
28
23
|
|
|
29
24
|
prompting() {
|
|
30
|
-
this.log(yosay(
|
|
25
|
+
this.log(yosay(`Welcome to ${_chalk.default.red('generator-verdaccio-plugin')} plugin generator!`));
|
|
31
26
|
const prompts = [{
|
|
32
|
-
type: 'input',
|
|
33
|
-
name: 'name',
|
|
34
|
-
require: true,
|
|
35
|
-
message: 'What is the name of your plugin?',
|
|
36
|
-
default: 'customname',
|
|
37
|
-
validate: function (input) {
|
|
38
|
-
return input !== '';
|
|
39
|
-
}
|
|
40
|
-
}, {
|
|
41
27
|
type: 'list',
|
|
42
28
|
name: 'pluginType',
|
|
43
29
|
require: true,
|
|
@@ -49,7 +35,24 @@ class VerdaccioPluginGenerator extends _yeomanGenerator.default {
|
|
|
49
35
|
value: 'storage'
|
|
50
36
|
}, {
|
|
51
37
|
value: 'middleware'
|
|
38
|
+
}, {
|
|
39
|
+
value: 'theme'
|
|
52
40
|
}]
|
|
41
|
+
}, {
|
|
42
|
+
type: 'input',
|
|
43
|
+
name: 'name',
|
|
44
|
+
require: true,
|
|
45
|
+
message: `What's the plugin name? The prefix (verdaccio-xxx) will be added automatically`,
|
|
46
|
+
default: 'customname',
|
|
47
|
+
validate: function (input) {
|
|
48
|
+
if (input.startsWith('verdaccio-')) {
|
|
49
|
+
return false;
|
|
50
|
+
} else if (input === '') {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
53
56
|
}, {
|
|
54
57
|
type: 'input',
|
|
55
58
|
name: 'description',
|
|
@@ -117,7 +120,7 @@ class VerdaccioPluginGenerator extends _yeomanGenerator.default {
|
|
|
117
120
|
this.fs.copyTpl(this.templatePath(`typescript/common/eslintrc`), this.destinationPath((0, _path.resolve)(this.destinationPathName, '.eslintrc')), this.props);
|
|
118
121
|
this.fs.copyTpl(this.templatePath(`typescript/common/eslintignore`), this.destinationPath((0, _path.resolve)(this.destinationPathName, '.eslintignore')), this.props);
|
|
119
122
|
this.fs.copy(this.templatePath(`typescript/${this.props.pluginType}/src`), this.destinationPath((0, _path.resolve)(this.destinationPathName, 'src')));
|
|
120
|
-
this.fs.copy(this.templatePath(`typescript/common/index.
|
|
123
|
+
this.fs.copy(this.templatePath(`typescript/common/index.js`), this.destinationPath((0, _path.resolve)(this.destinationPathName, `index.js`)));
|
|
121
124
|
this.fs.copy(this.templatePath(`typescript/common/tsconfig.json`), this.destinationPath((0, _path.resolve)(this.destinationPathName, 'tsconfig.json')));
|
|
122
125
|
this.fs.copy(this.templatePath(`typescript/${this.props.pluginType}/types`), this.destinationPath((0, _path.resolve)(this.destinationPathName, 'types')));
|
|
123
126
|
this.fs.copy(this.templatePath(`typescript/common/editorconfig`), this.destinationPath((0, _path.resolve)(this.destinationPathName, '.editorconfig')));
|
|
@@ -129,5 +132,5 @@ class VerdaccioPluginGenerator extends _yeomanGenerator.default {
|
|
|
129
132
|
|
|
130
133
|
}
|
|
131
134
|
|
|
132
|
-
exports
|
|
135
|
+
module.exports = VerdaccioPluginGenerator;
|
|
133
136
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["yosay","require","VerdaccioPluginGenerator","Generator","projectName","destinationPathName","constructor","args","opts","props","prompting","log","chalk","red","prompts","type","name","message","store","choices","value","default","validate","input","startsWith","filter","keywords","_","uniq","words","concat","prompt","then","_props","githubUsername","license","repository","resolve","bind","packageJSON","pluginType","pkgJsonLocation","fs","copyTpl","templatePath","destinationPath","writing","copy","install","process","chdir","module","exports"],"sources":["../../src/app/index.ts"],"sourcesContent":["import {resolve} from 'path';\n\nimport Generator from 'yeoman-generator';\nimport chalk from 'chalk';\nimport _ from 'lodash';\n\ntype propsTypes = {\n name?: string;\n pluginType?: string;\n description?: string;\n githubUsername?: string;\n authorName?: string;\n authorEmail?: string;\n keywords?: string[];\n};\n\nconst yosay = require('yosay');\n\nclass VerdaccioPluginGenerator extends Generator {\n private props: propsTypes;\n private projectName = 'verdaccio-';\n private destinationPathName = 'verdaccio-';\n constructor(args, opts) {\n super(args, opts);\n this.props = {};\n }\n\n prompting() {\n this.log(\n yosay(\n `Welcome to ${chalk.red('generator-verdaccio-plugin')} plugin generator!`,\n ),\n );\n\n const prompts = [\n {\n type: 'list',\n name: 'pluginType',\n require: true,\n message: 'What kind of plugin you want to create?',\n store: true,\n choices: [\n {value: 'auth'},\n {value: 'storage'},\n {value: 'middleware'},\n {value: 'theme'},\n ],\n },\n {\n type: 'input',\n name: 'name',\n require: true,\n message: `What's the plugin name? The prefix (verdaccio-xxx) will be added automatically`,\n default: 'customname',\n validate: function(input: string) {\n if (input.startsWith('verdaccio-')) {\n return false;\n } else if (input === '') {\n return false;\n }\n return true;\n },\n },\n {\n type: 'input',\n name: 'description',\n message: 'Please, describe your plugin',\n default: 'An amazing verdaccio plugin',\n },\n {\n name: 'githubUsername',\n message: 'GitHub username or Organization',\n validate: function(input) {\n return input !== '';\n },\n },\n {\n name: 'authorName',\n message: 'Author\\'s Name',\n store: true,\n },\n {\n name: 'authorEmail',\n message: 'Author\\'s Email',\n store: true,\n },\n {\n name: 'keywords',\n message: 'Key your keywords (comma to split)',\n filter: function(keywords) {\n return _.uniq(_.words(keywords).concat(['verdaccio-']));\n },\n },\n ];\n\n return this.prompt(prompts).then(\n function(_props) {\n // To access props later use this.props.someAnswer;\n // @ts-ignore\n this.props = _props;\n const {name, githubUsername} = _props;\n // @ts-ignore\n this.props.license = 'MIT';\n if (githubUsername) {\n // @ts-ignore\n this.props.repository = githubUsername + '/' + name;\n }\n\n // @ts-ignore\n this.projectName = `verdaccio-${name}`;\n\n // @ts-ignore\n this.destinationPathName = resolve(this.projectName);\n // @ts-ignore\n this.props.name = this.projectName;\n }.bind(this),\n );\n }\n\n packageJSON() {\n const {pluginType} = this.props;\n const pkgJsonLocation = `typescript/${pluginType}/_package.json`;\n this.fs.copyTpl(\n this.templatePath(pkgJsonLocation),\n this.destinationPath(resolve(this.destinationPathName, 'package.json')),\n this.props,\n );\n }\n\n writing() {\n this.fs.copy(\n this.templatePath(`typescript/common/gitignore`),\n this.destinationPath(resolve(this.destinationPathName, '.gitignore')),\n );\n this.fs.copy(\n this.templatePath(`typescript/common/npmignore`),\n this.destinationPath(resolve(this.destinationPathName, '.npmignore')),\n );\n this.fs.copy(\n this.templatePath(`typescript/common/jest.config.js`),\n this.destinationPath(resolve(this.destinationPathName, 'jest.config.js')),\n );\n this.fs.copyTpl(\n this.templatePath(`typescript/common/README.md`),\n this.destinationPath(resolve(this.destinationPathName, 'README.md')),\n this.props,\n );\n this.fs.copyTpl(\n this.templatePath(`typescript/common/eslintrc`),\n this.destinationPath(resolve(this.destinationPathName, '.eslintrc')),\n this.props,\n );\n this.fs.copyTpl(\n this.templatePath(`typescript/common/eslintignore`),\n this.destinationPath(resolve(this.destinationPathName, '.eslintignore')),\n this.props,\n );\n\n this.fs.copy(\n this.templatePath(`typescript/${this.props.pluginType}/src`),\n this.destinationPath(resolve(this.destinationPathName, 'src')),\n );\n\n this.fs.copy(\n this.templatePath(\n `typescript/common/index.js`,\n ),\n this.destinationPath(\n resolve(\n this.destinationPathName,\n `index.js`,\n ),\n ),\n );\n\n this.fs.copy(\n this.templatePath(`typescript/common/tsconfig.json`),\n this.destinationPath(\n resolve(this.destinationPathName, 'tsconfig.json'),\n ),\n );\n this.fs.copy(\n this.templatePath(`typescript/${this.props.pluginType}/types`),\n this.destinationPath(resolve(this.destinationPathName, 'types')),\n );\n\n this.fs.copy(\n this.templatePath(`typescript/common/editorconfig`),\n this.destinationPath(resolve(this.destinationPathName, '.editorconfig')),\n );\n }\n\n install() {\n process.chdir(this.projectName);\n // this.installDependencies({ npm: true, bower: false });\n }\n}\n\nmodule.exports = VerdaccioPluginGenerator;\n"],"mappings":";;AAAA;;AAEA;;AACA;;AACA;;;;AAYA,MAAMA,KAAK,GAAGC,OAAO,CAAC,OAAD,CAArB;;AAEA,MAAMC,wBAAN,SAAuCC,wBAAvC,CAAiD;EAEvCC,WAAW,GAAG,YAAH;EACXC,mBAAmB,GAAG,YAAH;;EAC3BC,WAAW,CAACC,IAAD,EAAOC,IAAP,EAAa;IACtB,MAAMD,IAAN,EAAYC,IAAZ;IACA,KAAKC,KAAL,GAAa,EAAb;EACD;;EAEDC,SAAS,GAAG;IACV,KAAKC,GAAL,CACIX,KAAK,CACA,cAAaY,cAAA,CAAMC,GAAN,CAAU,4BAAV,CAAwC,oBADrD,CADT;IAMA,MAAMC,OAAO,GAAG,CACd;MACEC,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QK,IAAR,CACI,KAAKH,YAAL,CAAmB,iCAAnB,CADJ,EAEI,KAAKC,eAAL,CACI,IAAAR,aAAA,EAAQ,KAAKhC,mBAAb,EAAkC,eAAlC,CADJ,CAFJ;IAMA,KAAKqC,EAAL,CAAQK,IAAR,CACI,KAAKH,YAAL,CAAmB,cAAa,KAAKnC,KAAL,CAAW+B,UAAW,QAAtD,CADJ,EAEI,KAAKK,eAAL,CAAqB,IAAAR,aAAA,EAAQ,KAAKhC,mBAAb,EAAkC,OAAlC,CAArB,CAFJ;IAKA,KAAKqC,EAAL,CAAQK,IAAR,CACI,KAAKH,YAAL,CAAmB,gCAAnB,CADJ,EAEI,KAAKC,eAAL,CAAqB,IAAAR,aAAA,EAAQ,KAAKhC,mBAAb,EAAkC,eAAlC,CAArB,CAFJ;EAID;;EAED2C,OAAO,GAAG;IACRC,OAAO,CAACC,KAAR,CAAc,KAAK9C,WAAnB,EADQ,CAER;EACD;;AAjL8C;;AAoLjD+C,MAAM,CAACC,OAAP,GAAiBlD,wBAAjB"}
|
|
@@ -2,22 +2,21 @@
|
|
|
2
2
|
"name": "<%= name %>",
|
|
3
3
|
"version": "0.0.1",
|
|
4
4
|
"description": "<%= description %>",
|
|
5
|
-
"main": "
|
|
6
|
-
"types": "
|
|
7
|
-
"files": ["lib/"],
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"types": "src/index.d.ts",
|
|
8
7
|
"engines": {
|
|
9
8
|
"node": ">=12"
|
|
10
9
|
},
|
|
11
10
|
"dependencies": {
|
|
12
|
-
"@verdaccio/commons-api": "
|
|
11
|
+
"@verdaccio/commons-api": "10.2.0"
|
|
13
12
|
},
|
|
14
13
|
"devDependencies": {
|
|
15
14
|
"@types/jest": "27.5.1",
|
|
16
|
-
"@types/node": "
|
|
15
|
+
"@types/node": "12.12.5",
|
|
17
16
|
"@types/express": "4.17.13",
|
|
18
17
|
"@typescript-eslint/eslint-plugin": "5.26.0",
|
|
19
18
|
"@typescript-eslint/parser": "5.26.0",
|
|
20
|
-
"@verdaccio/types": "
|
|
19
|
+
"@verdaccio/types": "10.5.1",
|
|
21
20
|
"eslint": "8.16.0",
|
|
22
21
|
"jest": "28.1.1",
|
|
23
22
|
"typescript": "4.7.3"
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
|
+
PluginOptions,
|
|
3
|
+
AuthAccessCallback,
|
|
4
|
+
AuthCallback,
|
|
5
|
+
PackageAccess,
|
|
6
|
+
IPluginAuth,
|
|
7
|
+
RemoteUser,
|
|
8
|
+
Logger,
|
|
9
|
+
} from '@verdaccio/types';
|
|
2
10
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
11
|
+
import {CustomConfig} from '../types/index';
|
|
7
12
|
|
|
8
13
|
/**
|
|
9
14
|
* Custom Verdaccio Authenticate Plugin.
|
|
10
15
|
*/
|
|
11
|
-
class AuthCustomPlugin {
|
|
12
|
-
|
|
16
|
+
export default class AuthCustomPlugin implements IPluginAuth<CustomConfig> {
|
|
17
|
+
public logger: Logger;
|
|
18
|
+
private foo: string;
|
|
19
|
+
public constructor(config: CustomConfig, options: PluginOptions<CustomConfig>) {
|
|
13
20
|
this.logger = options.logger;
|
|
14
21
|
this.foo = config.foo;
|
|
15
22
|
return this;
|
|
@@ -20,9 +27,7 @@ class AuthCustomPlugin {
|
|
|
20
27
|
* @param password provided password
|
|
21
28
|
* @param cb callback function
|
|
22
29
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
authenticate(user, password, cb) {
|
|
30
|
+
public authenticate(user: string, password: string, cb: AuthCallback): void {
|
|
26
31
|
/**
|
|
27
32
|
* This code is just an example for demostration purpose
|
|
28
33
|
if (this.foo) {
|
|
@@ -32,15 +37,14 @@ class AuthCustomPlugin {
|
|
|
32
37
|
}
|
|
33
38
|
*/
|
|
34
39
|
}
|
|
40
|
+
|
|
35
41
|
/**
|
|
36
42
|
* Triggered on each access request
|
|
37
43
|
* @param user
|
|
38
44
|
* @param pkg
|
|
39
45
|
* @param cb
|
|
40
46
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
allow_access(user, pkg, cb) {
|
|
47
|
+
public allow_access(user: RemoteUser, pkg: PackageAccess, cb: AuthAccessCallback): void {
|
|
44
48
|
/**
|
|
45
49
|
* This code is just an example for demostration purpose
|
|
46
50
|
if (user.name === this.foo && pkg?.access?.includes[user.name]) {
|
|
@@ -52,15 +56,14 @@ class AuthCustomPlugin {
|
|
|
52
56
|
}
|
|
53
57
|
*/
|
|
54
58
|
}
|
|
59
|
+
|
|
55
60
|
/**
|
|
56
61
|
* Triggered on each publish request
|
|
57
62
|
* @param user
|
|
58
63
|
* @param pkg
|
|
59
64
|
* @param cb
|
|
60
65
|
*/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
allow_publish(user, pkg, cb) {
|
|
66
|
+
public allow_publish(user: RemoteUser, pkg: PackageAccess, cb: AuthAccessCallback): void {
|
|
64
67
|
/**
|
|
65
68
|
* This code is just an example for demostration purpose
|
|
66
69
|
if (user.name === this.foo && pkg?.access?.includes[user.name]) {
|
|
@@ -73,7 +76,7 @@ class AuthCustomPlugin {
|
|
|
73
76
|
*/
|
|
74
77
|
}
|
|
75
78
|
|
|
76
|
-
allow_unpublish(user, pkg, cb) {
|
|
79
|
+
public allow_unpublish(user: RemoteUser, pkg: PackageAccess, cb: AuthAccessCallback): void {
|
|
77
80
|
/**
|
|
78
81
|
* This code is just an example for demostration purpose
|
|
79
82
|
if (user.name === this.foo && pkg?.access?.includes[user.name]) {
|
|
@@ -85,8 +88,4 @@ class AuthCustomPlugin {
|
|
|
85
88
|
}
|
|
86
89
|
*/
|
|
87
90
|
}
|
|
88
|
-
|
|
89
91
|
}
|
|
90
|
-
|
|
91
|
-
exports.default = AuthCustomPlugin;
|
|
92
|
-
//# sourceMappingURL=index.js.map
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -8,11 +8,7 @@
|
|
|
8
8
|
"strict": true,
|
|
9
9
|
"outDir": "./lib",
|
|
10
10
|
"allowSyntheticDefaultImports": true,
|
|
11
|
-
"esModuleInterop": true
|
|
12
|
-
"typeRoots": [
|
|
13
|
-
"../../node_modules/@verdaccio/types/lib/verdaccio",
|
|
14
|
-
"../../node_modules/@types"
|
|
15
|
-
]
|
|
11
|
+
"esModuleInterop": true
|
|
16
12
|
},
|
|
17
13
|
"include": [
|
|
18
14
|
"src/*.ts",
|
|
@@ -2,23 +2,22 @@
|
|
|
2
2
|
"name": "<%= name %>",
|
|
3
3
|
"version": "0.0.1",
|
|
4
4
|
"description": "<%= description %>",
|
|
5
|
-
"main": "
|
|
6
|
-
"types": "
|
|
7
|
-
"files": ["lib/"],
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"types": "src/index.d.ts",
|
|
8
7
|
"engines": {
|
|
9
8
|
"node": ">=12"
|
|
10
9
|
},
|
|
11
10
|
"dependencies": {
|
|
12
|
-
"@verdaccio/commons-api": "
|
|
11
|
+
"@verdaccio/commons-api": "10.2.0",
|
|
13
12
|
"express": "4.18.1"
|
|
14
13
|
},
|
|
15
14
|
"devDependencies": {
|
|
16
15
|
"@types/jest": "27.5.1",
|
|
17
|
-
"@types/node": "
|
|
16
|
+
"@types/node": "12.12.5",
|
|
18
17
|
"@types/express": "4.17.13",
|
|
19
18
|
"@typescript-eslint/eslint-plugin": "5.26.0",
|
|
20
19
|
"@typescript-eslint/parser": "5.26.0",
|
|
21
|
-
"@verdaccio/types": "
|
|
20
|
+
"@verdaccio/types": "10.5.1",
|
|
22
21
|
"eslint": "8.16.0",
|
|
23
22
|
"jest": "28.1.1",
|
|
24
23
|
"typescript": "4.7.3"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {Logger, IPluginMiddleware, IBasicAuth, IStorageManager, PluginOptions} from '@verdaccio/types';
|
|
2
|
+
import {Router, Request, Response, NextFunction, Application} from 'express';
|
|
3
|
+
|
|
4
|
+
import {CustomConfig} from '../types/index';
|
|
5
|
+
|
|
6
|
+
export default class VerdaccioMiddlewarePlugin implements IPluginMiddleware<CustomConfig> {
|
|
7
|
+
public logger: Logger;
|
|
8
|
+
public foo: string;
|
|
9
|
+
public constructor(config: CustomConfig, options: PluginOptions<CustomConfig>) {
|
|
10
|
+
this.foo = config.foo !== undefined ? config.strict_ssl : true;
|
|
11
|
+
this.logger = options.logger;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public register_middlewares(
|
|
15
|
+
app: Application,
|
|
16
|
+
auth: IBasicAuth<CustomConfig>,
|
|
17
|
+
/* eslint @typescript-eslint/no-unused-vars: off */
|
|
18
|
+
_storage: IStorageManager<CustomConfig>,
|
|
19
|
+
): void {
|
|
20
|
+
/**
|
|
21
|
+
* This is just an example of implementation
|
|
22
|
+
// eslint new-cap:off
|
|
23
|
+
const router = Router();
|
|
24
|
+
router.post(
|
|
25
|
+
'/custom-endpoint',
|
|
26
|
+
(req: Request, res: Response & { report_error?: Function }, next: NextFunction): void => {
|
|
27
|
+
const encryptedString = auth.aesEncrypt(Buffer.from(this.foo, 'utf8'));
|
|
28
|
+
res.setHeader('X-Verdaccio-Token-Plugin', encryptedString.toString());
|
|
29
|
+
next();
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
app.use('/-/npm/something-new', router);
|
|
33
|
+
*/
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -2,23 +2,22 @@
|
|
|
2
2
|
"name": "<%= name %>",
|
|
3
3
|
"version": "0.0.1",
|
|
4
4
|
"description": "<%= description %>",
|
|
5
|
-
"main": "
|
|
6
|
-
"types": "
|
|
7
|
-
"files": ["lib/"],
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"types": "src/index.d.ts",
|
|
8
7
|
"engines": {
|
|
9
|
-
"node": ">=
|
|
8
|
+
"node": ">=12"
|
|
10
9
|
},
|
|
11
10
|
"dependencies": {
|
|
12
|
-
"@verdaccio/commons-api": "
|
|
13
|
-
"@verdaccio/streams": "
|
|
11
|
+
"@verdaccio/commons-api": "10.2.0",
|
|
12
|
+
"@verdaccio/streams": "10.2.0"
|
|
14
13
|
},
|
|
15
14
|
"devDependencies": {
|
|
16
15
|
"@types/jest": "27.5.1",
|
|
17
|
-
"@types/node": "
|
|
16
|
+
"@types/node": "12.12.5",
|
|
18
17
|
"@types/express": "4.17.13",
|
|
19
18
|
"@typescript-eslint/eslint-plugin": "5.26.0",
|
|
20
19
|
"@typescript-eslint/parser": "5.26.0",
|
|
21
|
-
"@verdaccio/types": "
|
|
20
|
+
"@verdaccio/types": "10.5.1",
|
|
22
21
|
"eslint": "8.16.0",
|
|
23
22
|
"jest": "28.1.1",
|
|
24
23
|
"typescript": "4.7.3"
|
|
@@ -1,16 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import {
|
|
2
|
+
Callback,
|
|
3
|
+
Logger,
|
|
4
|
+
ILocalPackageManager,
|
|
5
|
+
StorageUpdateCallback,
|
|
6
|
+
PackageTransformer,
|
|
7
|
+
StorageWriteCallback,
|
|
8
|
+
CallbackAction,
|
|
9
|
+
Package,
|
|
10
|
+
ReadPackageCallback,
|
|
11
|
+
} from '@verdaccio/types';
|
|
12
|
+
import {UploadTarball, ReadTarball} from '@verdaccio/streams';
|
|
13
|
+
import {getNotFound, getConflict, getInternalError} from '@verdaccio/commons-api';
|
|
14
|
+
|
|
15
|
+
import {CustomConfig} from '../types/index';
|
|
16
|
+
export default class StoragePluginManage implements ILocalPackageManager {
|
|
17
|
+
public logger: Logger;
|
|
18
|
+
public packageName: string;
|
|
19
|
+
public config: CustomConfig;
|
|
20
|
+
|
|
21
|
+
public constructor(
|
|
22
|
+
config: CustomConfig,
|
|
23
|
+
packageName: string,
|
|
24
|
+
logger: Logger,
|
|
25
|
+
) {
|
|
10
26
|
this.logger = logger;
|
|
11
27
|
this.packageName = packageName;
|
|
12
28
|
this.config = config;
|
|
13
29
|
}
|
|
30
|
+
|
|
14
31
|
/**
|
|
15
32
|
* Handle a metadata update and
|
|
16
33
|
* @param name
|
|
@@ -19,9 +36,13 @@ class StoragePluginManage {
|
|
|
19
36
|
* @param transformPackage
|
|
20
37
|
* @param onEnd
|
|
21
38
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
39
|
+
public updatePackage(
|
|
40
|
+
name: string,
|
|
41
|
+
updateHandler: StorageUpdateCallback,
|
|
42
|
+
onWrite: StorageWriteCallback,
|
|
43
|
+
transformPackage: PackageTransformer,
|
|
44
|
+
onEnd: CallbackAction,
|
|
45
|
+
): void {
|
|
25
46
|
/**
|
|
26
47
|
* Example of implementation:
|
|
27
48
|
this.customStore.get().then((pkg: Package) => {
|
|
@@ -35,14 +56,13 @@ class StoragePluginManage {
|
|
|
35
56
|
});
|
|
36
57
|
*/
|
|
37
58
|
}
|
|
59
|
+
|
|
38
60
|
/**
|
|
39
61
|
* Delete a specific file (tarball or package.json)
|
|
40
62
|
* @param fileName
|
|
41
63
|
* @param callback
|
|
42
64
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
deletePackage(fileName, callback) {
|
|
65
|
+
public deletePackage(fileName: string, callback: CallbackAction): void {
|
|
46
66
|
/**
|
|
47
67
|
* Example of implementation:
|
|
48
68
|
this.customStore.delete(fileName, (err) => {
|
|
@@ -54,14 +74,13 @@ class StoragePluginManage {
|
|
|
54
74
|
})
|
|
55
75
|
*/
|
|
56
76
|
}
|
|
77
|
+
|
|
57
78
|
/**
|
|
58
79
|
* Delete a package (folder, path)
|
|
59
80
|
* This happens after all versions ar tarballs have been removed.
|
|
60
81
|
* @param callback
|
|
61
82
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
removePackage(callback) {
|
|
83
|
+
public removePackage(callback: CallbackAction): void {
|
|
65
84
|
/**
|
|
66
85
|
* Example of implementation:
|
|
67
86
|
this.customStore.removePackage((err) => {
|
|
@@ -73,15 +92,18 @@ class StoragePluginManage {
|
|
|
73
92
|
})
|
|
74
93
|
*/
|
|
75
94
|
}
|
|
95
|
+
|
|
76
96
|
/**
|
|
77
97
|
* Publish a new package (version).
|
|
78
98
|
* @param name
|
|
79
99
|
* @param data
|
|
80
100
|
* @param callback
|
|
81
101
|
*/
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
102
|
+
public createPackage(
|
|
103
|
+
name: string,
|
|
104
|
+
data: Package,
|
|
105
|
+
callback: CallbackAction,
|
|
106
|
+
): void {
|
|
85
107
|
/**
|
|
86
108
|
* Example of implementation:
|
|
87
109
|
* this.customStore.create(name, data).then(err => {
|
|
@@ -95,6 +117,7 @@ class StoragePluginManage {
|
|
|
95
117
|
})
|
|
96
118
|
*/
|
|
97
119
|
}
|
|
120
|
+
|
|
98
121
|
/**
|
|
99
122
|
* Perform write anobject to the storage.
|
|
100
123
|
* Similar to updatePackage but without middleware handlers
|
|
@@ -102,9 +125,7 @@ class StoragePluginManage {
|
|
|
102
125
|
* @param pkg package metadata
|
|
103
126
|
* @param callback
|
|
104
127
|
*/
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
savePackage(pkgName, pkg, callback) {
|
|
128
|
+
public savePackage(pkgName: string, pkg: Package, callback: CallbackAction): void {
|
|
108
129
|
/*
|
|
109
130
|
Example of implementation:
|
|
110
131
|
this.cumstomStore.write(pkgName, pkgName).then(data => {
|
|
@@ -114,14 +135,13 @@ class StoragePluginManage {
|
|
|
114
135
|
})
|
|
115
136
|
*/
|
|
116
137
|
}
|
|
138
|
+
|
|
117
139
|
/**
|
|
118
140
|
* Read a package from storage
|
|
119
141
|
* @param pkgName package name
|
|
120
142
|
* @param callback
|
|
121
143
|
*/
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
readPackage(pkgName, callback) {
|
|
144
|
+
public readPackage(pkgName: string, callback: ReadPackageCallback): void {
|
|
125
145
|
/**
|
|
126
146
|
* Example of implementation:
|
|
127
147
|
* this.customStorage.read(name, (err, pkg: Package) => {
|
|
@@ -135,34 +155,29 @@ class StoragePluginManage {
|
|
|
135
155
|
});
|
|
136
156
|
*/
|
|
137
157
|
}
|
|
158
|
+
|
|
138
159
|
/**
|
|
139
160
|
* Create writtable stream (write a tarball)
|
|
140
161
|
* @param name
|
|
141
162
|
*/
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
writeTarball(name) {
|
|
163
|
+
public writeTarball(name: string): UploadTarball {
|
|
145
164
|
/**
|
|
146
165
|
* Example of implementation:
|
|
147
166
|
* const stream = new UploadTarball({});
|
|
148
167
|
return stream;
|
|
149
168
|
*/
|
|
169
|
+
|
|
150
170
|
}
|
|
171
|
+
|
|
151
172
|
/**
|
|
152
173
|
* Create a readable stream (read a from a tarball)
|
|
153
174
|
* @param name
|
|
154
175
|
*/
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
readTarball(name) {
|
|
176
|
+
public readTarball(name: string): ReadTarball {
|
|
158
177
|
/**
|
|
159
178
|
* Example of implementation:
|
|
160
179
|
* const stream = new ReadTarball({});
|
|
161
180
|
return stream;
|
|
162
181
|
*/
|
|
163
182
|
}
|
|
164
|
-
|
|
165
183
|
}
|
|
166
|
-
|
|
167
|
-
exports.default = StoragePluginManage;
|
|
168
|
-
//# sourceMappingURL=PackageStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default} from './plugin';
|
|
@@ -1,52 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import {
|
|
2
|
+
Logger,
|
|
3
|
+
Callback,
|
|
4
|
+
IPluginStorage,
|
|
5
|
+
PluginOptions,
|
|
6
|
+
IPackageStorage,
|
|
7
|
+
TokenFilter,
|
|
8
|
+
Token,
|
|
9
|
+
Config,
|
|
10
|
+
onEndSearchPackage,
|
|
11
|
+
onSearchPackage,
|
|
12
|
+
onValidatePackage,
|
|
13
|
+
} from '@verdaccio/types';
|
|
14
|
+
import {getInternalError} from '@verdaccio/commons-api';
|
|
15
|
+
|
|
16
|
+
import {CustomConfig} from '../types/index';
|
|
17
|
+
|
|
18
|
+
import PackageStorage from './PackageStorage';
|
|
19
|
+
|
|
20
|
+
export default class VerdaccioStoragePlugin implements IPluginStorage<CustomConfig> {
|
|
21
|
+
config: CustomConfig & Config;
|
|
22
|
+
version?: string;
|
|
23
|
+
public logger: Logger;
|
|
24
|
+
public constructor(
|
|
25
|
+
config: CustomConfig,
|
|
26
|
+
options: PluginOptions<CustomConfig>,
|
|
27
|
+
) {
|
|
14
28
|
this.config = config;
|
|
15
29
|
this.logger = options.logger;
|
|
16
30
|
}
|
|
31
|
+
|
|
17
32
|
/**
|
|
18
33
|
*
|
|
19
34
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
async getSecret() {
|
|
35
|
+
public async getSecret(): Promise<string> {
|
|
23
36
|
/**
|
|
24
37
|
* return await resolveSecret();
|
|
25
38
|
*/
|
|
26
39
|
}
|
|
27
40
|
|
|
28
|
-
async setSecret(secret) {
|
|
41
|
+
public async setSecret(secret: string): Promise<any> {
|
|
29
42
|
/**
|
|
30
43
|
* return await getYourSecret();
|
|
31
44
|
*/
|
|
32
45
|
}
|
|
46
|
+
|
|
33
47
|
/**
|
|
34
48
|
* Add a new element.
|
|
35
49
|
* @param {*} name
|
|
36
50
|
* @return {Error|*}
|
|
37
51
|
*/
|
|
52
|
+
public add(name: string, callback: Callback): void {
|
|
38
53
|
|
|
54
|
+
}
|
|
39
55
|
|
|
40
|
-
add(name, callback) {}
|
|
41
56
|
/**
|
|
42
57
|
* Perform a search in your registry
|
|
43
58
|
* @param onPackage
|
|
44
59
|
* @param onEnd
|
|
45
60
|
* @param validateName
|
|
46
61
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
62
|
+
public search(
|
|
63
|
+
onPackage: onSearchPackage,
|
|
64
|
+
onEnd: onEndSearchPackage,
|
|
65
|
+
validateName: onValidatePackage,
|
|
66
|
+
): void {
|
|
50
67
|
/**
|
|
51
68
|
* Example of implementation:
|
|
52
69
|
* try {
|
|
@@ -63,32 +80,31 @@ class VerdaccioStoragePlugin {
|
|
|
63
80
|
* });
|
|
64
81
|
*/
|
|
65
82
|
}
|
|
83
|
+
|
|
66
84
|
/**
|
|
67
85
|
* Remove an element from the database.
|
|
68
86
|
* @param {*} name
|
|
69
87
|
* @return {Error|*}
|
|
70
88
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
remove(name, callback) {
|
|
89
|
+
public remove(name: string, callback: Callback): void {
|
|
74
90
|
/**
|
|
75
91
|
* Example of implementation
|
|
76
92
|
database.getPackage(name, (item, err) => {
|
|
77
93
|
if (err) {
|
|
78
94
|
callback(getInternalError('your own message here'));
|
|
79
95
|
}
|
|
80
|
-
|
|
96
|
+
|
|
97
|
+
// if all goes well we return nothing
|
|
81
98
|
callback(null);
|
|
82
99
|
}
|
|
83
100
|
*/
|
|
84
101
|
}
|
|
102
|
+
|
|
85
103
|
/**
|
|
86
104
|
* Return all database elements.
|
|
87
105
|
* @return {Array}
|
|
88
106
|
*/
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
get(callback) {
|
|
107
|
+
public get(callback: Callback): void {
|
|
92
108
|
/*
|
|
93
109
|
Example of implementation
|
|
94
110
|
database.getAll((allItems, err) => {
|
|
@@ -96,34 +112,29 @@ class VerdaccioStoragePlugin {
|
|
|
96
112
|
})
|
|
97
113
|
*/
|
|
98
114
|
}
|
|
115
|
+
|
|
99
116
|
/**
|
|
100
117
|
* Create an instance of the `PackageStorage`
|
|
101
118
|
* @param packageInfo
|
|
102
119
|
*/
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
getPackageStorage(packageInfo) {
|
|
106
|
-
return new _PackageStorage.default(this.config, packageInfo, this.logger);
|
|
120
|
+
public getPackageStorage(packageInfo: string): IPackageStorage {
|
|
121
|
+
return new PackageStorage(this.config, packageInfo, this.logger);
|
|
107
122
|
}
|
|
123
|
+
|
|
108
124
|
/**
|
|
109
125
|
* All methods for npm token support
|
|
110
126
|
* more info here https://github.com/verdaccio/verdaccio/pull/1427
|
|
111
127
|
*/
|
|
112
128
|
|
|
113
|
-
|
|
114
|
-
saveToken(token) {
|
|
129
|
+
public saveToken(token: Token): Promise<any> {
|
|
115
130
|
throw new Error('Method not implemented.');
|
|
116
131
|
}
|
|
117
132
|
|
|
118
|
-
deleteToken(user, tokenKey) {
|
|
133
|
+
public deleteToken(user: string, tokenKey: string): Promise<any> {
|
|
119
134
|
throw new Error('Method not implemented.');
|
|
120
135
|
}
|
|
121
136
|
|
|
122
|
-
readTokens(filter) {
|
|
137
|
+
public readTokens(filter: TokenFilter): Promise<Token[]> {
|
|
123
138
|
throw new Error('Method not implemented.');
|
|
124
139
|
}
|
|
125
|
-
|
|
126
140
|
}
|
|
127
|
-
|
|
128
|
-
exports.default = VerdaccioStoragePlugin;
|
|
129
|
-
//# sourceMappingURL=plugin.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "generator-verdaccio-plugin",
|
|
3
|
-
"version": "4.0.0-next.
|
|
3
|
+
"version": "4.0.0-next.3",
|
|
4
4
|
"description": "plugin generator for verdaccio",
|
|
5
5
|
"homepage": "https://github.com/verdaccio",
|
|
6
6
|
"author": {
|
|
@@ -9,9 +9,8 @@
|
|
|
9
9
|
"url": "https://github.com/verdaccio/generator-verdaccio-plugin"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
|
-
"
|
|
12
|
+
"generators"
|
|
13
13
|
],
|
|
14
|
-
"main": "build/app/index.js",
|
|
15
14
|
"keywords": [
|
|
16
15
|
"verdaccio-plugin",
|
|
17
16
|
"yeoman-generator"
|
|
@@ -27,9 +26,9 @@
|
|
|
27
26
|
"@babel/cli": "7.16.8",
|
|
28
27
|
"@babel/core": "7.16.12",
|
|
29
28
|
"@babel/node": "7.16.8",
|
|
30
|
-
"@changesets/changelog-github": "0.4.
|
|
31
|
-
"@changesets/cli": "2.
|
|
32
|
-
"@changesets/get-dependents-graph": "1.2
|
|
29
|
+
"@changesets/changelog-github": "0.4.5",
|
|
30
|
+
"@changesets/cli": "2.23.0",
|
|
31
|
+
"@changesets/get-dependents-graph": "1.3.2",
|
|
33
32
|
"@babel/plugin-proposal-class-properties": "7.16.7",
|
|
34
33
|
"@babel/plugin-proposal-decorators": "7.16.7",
|
|
35
34
|
"@babel/plugin-proposal-export-namespace-from": "7.16.7",
|
|
@@ -61,7 +60,7 @@
|
|
|
61
60
|
"@types/yeoman-test": "4.0.3",
|
|
62
61
|
"@typescript-eslint/eslint-plugin": "5.25.0",
|
|
63
62
|
"@typescript-eslint/parser": "5.25.0",
|
|
64
|
-
"@verdaccio/types": "10.
|
|
63
|
+
"@verdaccio/types": "10.5.1",
|
|
65
64
|
"eslint": "8.17.0",
|
|
66
65
|
"eslint-config-google": "0.14.0",
|
|
67
66
|
"npm-run-all": "4.1.5",
|
|
@@ -80,7 +79,7 @@
|
|
|
80
79
|
"yeoman-test": "6.3.0"
|
|
81
80
|
},
|
|
82
81
|
"engines": {
|
|
83
|
-
"node": ">=
|
|
82
|
+
"node": ">=14"
|
|
84
83
|
},
|
|
85
84
|
"repository": {
|
|
86
85
|
"type": "git",
|
|
@@ -93,7 +92,7 @@
|
|
|
93
92
|
"release": "standard-version -a -s",
|
|
94
93
|
"type-check": "tsc --noEmit -p tsconfig.build.json",
|
|
95
94
|
"build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
|
|
96
|
-
"build": "babel
|
|
95
|
+
"build": "babel src/ --out-dir generators/ --copy-files --extensions \".ts,.tsx\" --source-maps --ignore src/app/templates",
|
|
97
96
|
"test": "jest",
|
|
98
97
|
"lint": "eslint --max-warnings 0 \"**/*.{js,ts}\"",
|
|
99
98
|
"changeset": "changeset",
|
|
@@ -102,6 +101,5 @@
|
|
|
102
101
|
"ci:version:install": "pnpm install --frozen-lockfile=false",
|
|
103
102
|
"ci:version:changeset": "changeset version",
|
|
104
103
|
"ci:publish": "changeset publish"
|
|
105
|
-
}
|
|
106
|
-
"readme": "# Verdaccio plugin generator\n\n[![NPM version][npm-image]][npm-url]\n[![Dependency Status][daviddm-image]][daviddm-url]\n[](https://dependabot.com)\n[](https://david-dm.org/verdaccio/generator-verdaccio-plugin/master?type=dev)\n[](./LICENSE)\n\n[](https://opencollective.com/verdaccio)\n[](https://stackshare.io/verdaccio)\n[](http://chat.verdaccio.org/)\n[](https://twitter.com/verdaccio_npm)\n\nVerdaccio plugin generator based in [Yeoman](http://yeoman.io) aims to help to scaffold plugins development\n\n### Maintainers\n\n* [Anix](https://github.com/anikethsaha)\n* [Juan Picado](https://github.com/juanpicado)\n\n## Installation\n\nFirst, install [Yeoman](http://yeoman.io) and generator-verdaccio-plugin using [npm](https://www.npmjs.com/) (we assume you have pre-installed [node.js](https://nodejs.org/)).\n\n```bash\nnpm install -g yo\nnpm install -g generator-verdaccio-plugin\n```\n\nThen generate your new project:\n\n```bash\nyo verdaccio-plugin\n```\n\n## Plugin Types Supported\n\n- Authentication\n- Storage\n- Middleware\n\n\n## License\n\nMIT © [Juan Picado <@jotadeveloper>]()\n\n[npm-image]: https://badge.fury.io/js/generator-verdaccio-plugin.svg\n[npm-url]: https://npmjs.org/package/generator-verdaccio-plugin\n[daviddm-image]: https://david-dm.org/verdaccio/generator-verdaccio-plugin.svg?theme=shields.io\n[daviddm-url]: https://david-dm.org/verdaccio/generator-verdaccio-plugin\n"
|
|
104
|
+
}
|
|
107
105
|
}
|
package/build/app/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["yosay","require","VerdaccioPluginGenerator","Generator","projectName","destinationPathName","constructor","args","opts","props","prompting","log","chalk","red","prompts","type","name","message","default","validate","input","store","choices","value","filter","keywords","_","uniq","words","concat","prompt","then","_props","githubUsername","license","repository","resolve","bind","packageJSON","pluginType","pkgJsonLocation","fs","copyTpl","templatePath","destinationPath","writing","copy","install","process","chdir"],"sources":["../../generators/app/index.ts"],"sourcesContent":["import {resolve} from 'path';\n\nimport Generator from 'yeoman-generator';\nimport chalk from 'chalk';\nimport _ from 'lodash';\n\ntype propsTypes = {\n name?: string;\n pluginType?: string;\n description?: string;\n githubUsername?: string;\n authorName?: string;\n authorEmail?: string;\n keywords?: string[];\n};\n\nconst yosay = require('yosay');\n\nexport default class VerdaccioPluginGenerator extends Generator {\n private props: propsTypes;\n private projectName = 'verdaccio-';\n private destinationPathName = 'verdaccio-';\n constructor(args, opts) {\n super(args, opts);\n this.props = {};\n }\n\n prompting() {\n this.log(\n yosay(\n 'Welcome to ' +\n chalk.red('generator-verdaccio-plugin') +\n ' plugin generator!',\n ),\n );\n\n const prompts = [\n {\n type: 'input',\n name: 'name',\n require: true,\n message: 'What is the name of your plugin?',\n default: 'customname',\n validate: function(input) {\n return input !== '';\n },\n },\n {\n type: 'list',\n name: 'pluginType',\n require: true,\n message: 'What kind of plugin you want to create?',\n store: true,\n choices: [\n {value: 'auth'},\n {value: 'storage'},\n {value: 'middleware'},\n ],\n },\n {\n type: 'input',\n name: 'description',\n message: 'Please, describe your plugin',\n default: 'An amazing verdaccio plugin',\n },\n {\n name: 'githubUsername',\n message: 'GitHub username or Organization',\n validate: function(input) {\n return input !== '';\n },\n },\n {\n name: 'authorName',\n message: 'Author\\'s Name',\n store: true,\n },\n {\n name: 'authorEmail',\n message: 'Author\\'s Email',\n store: true,\n },\n {\n name: 'keywords',\n message: 'Key your keywords (comma to split)',\n filter: function(keywords) {\n return _.uniq(_.words(keywords).concat(['verdaccio-']));\n },\n },\n ];\n\n return this.prompt(prompts).then(\n function(_props) {\n // To access props later use this.props.someAnswer;\n // @ts-ignore\n this.props = _props;\n const {name, githubUsername} = _props;\n // @ts-ignore\n this.props.license = 'MIT';\n if (githubUsername) {\n // @ts-ignore\n this.props.repository = githubUsername + '/' + name;\n }\n\n // @ts-ignore\n this.projectName = `verdaccio-${name}`;\n\n // @ts-ignore\n this.destinationPathName = resolve(this.projectName);\n // @ts-ignore\n this.props.name = this.projectName;\n }.bind(this),\n );\n }\n\n packageJSON() {\n const {pluginType} = this.props;\n const pkgJsonLocation = `typescript/${pluginType}/_package.json`;\n this.fs.copyTpl(\n this.templatePath(pkgJsonLocation),\n this.destinationPath(resolve(this.destinationPathName, 'package.json')),\n this.props,\n );\n }\n\n writing() {\n this.fs.copy(\n this.templatePath(`typescript/common/gitignore`),\n this.destinationPath(resolve(this.destinationPathName, '.gitignore')),\n );\n this.fs.copy(\n this.templatePath(`typescript/common/npmignore`),\n this.destinationPath(resolve(this.destinationPathName, '.npmignore')),\n );\n this.fs.copy(\n this.templatePath(`typescript/common/jest.config.js`),\n this.destinationPath(resolve(this.destinationPathName, 'jest.config.js')),\n );\n this.fs.copyTpl(\n this.templatePath(`typescript/common/README.md`),\n this.destinationPath(resolve(this.destinationPathName, 'README.md')),\n this.props,\n );\n this.fs.copyTpl(\n this.templatePath(`typescript/common/eslintrc`),\n this.destinationPath(resolve(this.destinationPathName, '.eslintrc')),\n this.props,\n );\n this.fs.copyTpl(\n this.templatePath(`typescript/common/eslintignore`),\n this.destinationPath(resolve(this.destinationPathName, '.eslintignore')),\n this.props,\n );\n\n this.fs.copy(\n this.templatePath(`typescript/${this.props.pluginType}/src`),\n this.destinationPath(resolve(this.destinationPathName, 'src')),\n );\n\n this.fs.copy(\n this.templatePath(\n `typescript/common/index.ts`,\n ),\n this.destinationPath(\n resolve(\n this.destinationPathName,\n `index.ts`,\n ),\n ),\n );\n\n this.fs.copy(\n this.templatePath(`typescript/common/tsconfig.json`),\n this.destinationPath(\n resolve(this.destinationPathName, 'tsconfig.json'),\n ),\n );\n this.fs.copy(\n this.templatePath(`typescript/${this.props.pluginType}/types`),\n this.destinationPath(resolve(this.destinationPathName, 'types')),\n );\n\n this.fs.copy(\n this.templatePath(`typescript/common/editorconfig`),\n this.destinationPath(resolve(this.destinationPathName, '.editorconfig')),\n );\n }\n\n install() {\n process.chdir(this.projectName);\n // this.installDependencies({ npm: true, bower: false });\n }\n}\n"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AACA;;;;AAYA,MAAMA,KAAK,GAAGC,OAAO,CAAC,OAAD,CAArB;;AAEe,MAAMC,wBAAN,SAAuCC,wBAAvC,CAAiD;EAEtDC,WAAW,GAAG,YAAH;EACXC,mBAAmB,GAAG,YAAH;;EAC3BC,WAAW,CAACC,IAAD,EAAOC,IAAP,EAAa;IACtB,MAAMD,IAAN,EAAYC,IAAZ;IACA,KAAKC,KAAL,GAAa,EAAb;EACD;;EAEDC,SAAS,GAAG;IACV,KAAKC,GAAL,CACIX,KAAK,CACD,gBACFY,cAAA,CAAMC,GAAN,CAAU,4BAAV,CADE,GAEF,oBAHG,CADT;IAQA,MAAMC,OAAO,GAAG,CACd;MACEC,IAAI,EAAE,OADR;MAEEC,IAAI,EAAE,MAFR;MAGEf,OAAO,EAAE,IAHX;MAIEgB,OAAO,EAAE,kCAJX;MAKEC,OAAO,EAAE,YALX;MAMEC,QAAQ,EAAE,UAASC,KAAT,EAAgB;QACxB,OAAOA,KAAK,KAAK,EAAjB;MACD;IARH,CADc,EAWd;MACEL,IAAI,EAAE,MADR;MAEEC,IAAI,EAAE,YAFR;MAGEf,OAAO,EAAE,IAHX;MAIEgB,OAAO,EAAE,yCAJX;MAKEI,KAAK,EAAE,IALT;MAMEC,OAAO,EAAE,CACP;QAACC,KAAK,EAAE;MAAR,CADO,EAEP;QAACA,KAAK,EAAE;MAAR,CAFO,EAGP;QAACA,KAAK,EAAE;MAAR,CAHO;IANX,CAXc,EAuBd;MACER,IAAI,EAAE,OADR;MAEEC,IAAI,EAAE,aAFR;MAGEC,OAAO,EAAE,8BAHX;MAIEC,OAAO,EAAE;IAJX,CAvBc,EA6Bd;MACEF,IAAI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AAR,aAAA,EAAQ,KAAK/B,mBAAb,EAAkC,eAAlC,CAArB,CAFJ,EAGI,KAAKI,KAHT;IAMA,KAAKgC,EAAL,CAAQK,IAAR,CACI,KAAKH,YAAL,CAAmB,cAAa,KAAKlC,KAAL,CAAW8B,UAAW,MAAtD,CADJ,EAEI,KAAKK,eAAL,CAAqB,IAAAR,aAAA,EAAQ,KAAK/B,mBAAb,EAAkC,KAAlC,CAArB,CAFJ;IAKA,KAAKoC,EAAL,CAAQK,IAAR,CACI,KAAKH,YAAL,CACK,4BADL,CADJ,EAII,KAAKC,eAAL,CACI,IAAAR,aAAA,EACI,KAAK/B,mBADT,EAEK,UAFL,CADJ,CAJJ;IAYA,KAAKoC,EAAL,CAAQK,IAAR,CACI,KAAKH,YAAL,CAAmB,iCAAnB,CADJ,EAEI,KAAKC,eAAL,CACI,IAAAR,aAAA,EAAQ,KAAK/B,mBAAb,EAAkC,eAAlC,CADJ,CAFJ;IAMA,KAAKoC,EAAL,CAAQK,IAAR,CACI,KAAKH,YAAL,CAAmB,cAAa,KAAKlC,KAAL,CAAW8B,UAAW,QAAtD,CADJ,EAEI,KAAKK,eAAL,CAAqB,IAAAR,aAAA,EAAQ,KAAK/B,mBAAb,EAAkC,OAAlC,CAArB,CAFJ;IAKA,KAAKoC,EAAL,CAAQK,IAAR,CACI,KAAKH,YAAL,CAAmB,gCAAnB,CADJ,EAEI,KAAKC,eAAL,CAAqB,IAAAR,aAAA,EAAQ,KAAK/B,mBAAb,EAAkC,eAAlC,CAArB,CAFJ;EAID;;EAED0C,OAAO,GAAG;IACRC,OAAO,CAACC,KAAR,CAAc,KAAK7C,WAAnB,EADQ,CAER;EACD;;AA7K6D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["AuthCustomPlugin","constructor","config","options","logger","foo","authenticate","user","password","cb","allow_access","pkg","allow_publish","allow_unpublish"],"sources":["../../../../../../generators/app/templates/typescript/auth/src/index.ts"],"sourcesContent":["import {\n PluginOptions,\n AuthAccessCallback,\n AuthCallback,\n PackageAccess,\n IPluginAuth,\n RemoteUser,\n Logger,\n} from '@verdaccio/types';\n\nimport {CustomConfig} from '../types/index';\n\n/**\n * Custom Verdaccio Authenticate Plugin.\n */\nexport default class AuthCustomPlugin implements IPluginAuth<CustomConfig> {\n public logger: Logger;\n private foo: string;\n public constructor(config: CustomConfig, options: PluginOptions<CustomConfig>) {\n this.logger = options.logger;\n this.foo = config.foo;\n return this;\n }\n /**\n * Authenticate an user.\n * @param user user to log\n * @param password provided password\n * @param cb callback function\n */\n public authenticate(user: string, password: string, cb: AuthCallback): void {\n /**\n * This code is just an example for demostration purpose\n if (this.foo) {\n cb(null, ['group-foo', 'group-bar']);\n } else {\n cb('error, try again', false);\n }\n */\n }\n\n /**\n * Triggered on each access request\n * @param user\n * @param pkg\n * @param cb\n */\n public allow_access(user: RemoteUser, pkg: PackageAccess, cb: AuthAccessCallback): void {\n /**\n * This code is just an example for demostration purpose\n if (user.name === this.foo && pkg?.access?.includes[user.name]) {\n this.logger.debug({name: user.name}, 'your package has been granted for @{name}');\n cb(null, true)\n } else {\n this.logger.error({name: user.name}, '@{name} is not allowed to access this package');\n cb('error, try again', false);\n }\n */\n }\n\n /**\n * Triggered on each publish request\n * @param user\n * @param pkg\n * @param cb\n */\n public allow_publish(user: RemoteUser, pkg: PackageAccess, cb: AuthAccessCallback): void {\n /**\n * This code is just an example for demostration purpose\n if (user.name === this.foo && pkg?.access?.includes[user.name]) {\n this.logger.debug({name: user.name}, '@{name} has been granted to publish');\n cb(null, true)\n } else {\n this.logger.error({name: user.name}, '@{name} is not allowed to publish this package');\n cb('error, try again', false);\n }\n */\n }\n\n public allow_unpublish(user: RemoteUser, pkg: PackageAccess, cb: AuthAccessCallback): void {\n /**\n * This code is just an example for demostration purpose\n if (user.name === this.foo && pkg?.access?.includes[user.name]) {\n this.logger.debug({name: user.name}, '@{name} has been granted to unpublish');\n cb(null, true)\n } else {\n this.logger.error({name: user.name}, '@{name} is not allowed to publish this package');\n cb('error, try again', false);\n }\n */\n }\n}\n"],"mappings":";;;;;;;AAYA;AACA;AACA;AACe,MAAMA,gBAAN,CAA4D;EAGlEC,WAAW,CAACC,MAAD,EAAuBC,OAAvB,EAA6D;IAC7E,KAAKC,MAAL,GAAcD,OAAO,CAACC,MAAtB;IACA,KAAKC,GAAL,GAAWH,MAAM,CAACG,GAAlB;IACA,OAAO,IAAP;EACD;EACD;AACF;AACA;AACA;AACA;AACA;;;EACSC,YAAY,CAACC,IAAD,EAAeC,QAAf,EAAiCC,EAAjC,EAAyD;IAC1E;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;EACG;EAED;AACF;AACA;AACA;AACA;AACA;;;EACSC,YAAY,CAACH,IAAD,EAAmBI,GAAnB,EAAuCF,EAAvC,EAAqE;IACtF;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACG;EAED;AACF;AACA;AACA;AACA;AACA;;;EACSG,aAAa,CAACL,IAAD,EAAmBI,GAAnB,EAAuCF,EAAvC,EAAqE;IACvF;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACG;;EAEMI,eAAe,CAACN,IAAD,EAAmBI,GAAnB,EAAuCF,EAAvC,EAAqE;IACzF;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACG;;AA1EwE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../../../generators/app/templates/typescript/auth/types/index.ts"],"sourcesContent":["import {Config} from '@verdaccio/types';\n\nexport interface CustomConfig extends Config {\n foo: string;\n}\n"],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["VerdaccioPlugin"],"sources":["../../../../../generators/app/templates/typescript/common/index.ts"],"sourcesContent":["import VerdaccioPlugin from './lib/index';\n\nexport default VerdaccioPlugin;\n"],"mappings":";;;;;;;AAAA;;;;eAEeA,c"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
class VerdaccioMiddlewarePlugin {
|
|
9
|
-
constructor(config, options) {
|
|
10
|
-
this.foo = config.foo !== undefined ? config.strict_ssl : true;
|
|
11
|
-
this.logger = options.logger;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
register_middlewares(app, auth,
|
|
15
|
-
/* eslint @typescript-eslint/no-unused-vars: off */
|
|
16
|
-
_storage) {
|
|
17
|
-
/**
|
|
18
|
-
* This is just an example of implementation
|
|
19
|
-
// eslint new-cap:off
|
|
20
|
-
const router = Router();
|
|
21
|
-
router.post(
|
|
22
|
-
'/custom-endpoint',
|
|
23
|
-
(req: Request, res: Response & { report_error?: Function }, next: NextFunction): void => {
|
|
24
|
-
const encryptedString = auth.aesEncrypt(Buffer.from(this.foo, 'utf8'));
|
|
25
|
-
res.setHeader('X-Verdaccio-Token-Plugin', encryptedString.toString());
|
|
26
|
-
next();
|
|
27
|
-
}
|
|
28
|
-
);
|
|
29
|
-
app.use('/-/npm/something-new', router);
|
|
30
|
-
*/
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
exports.default = VerdaccioMiddlewarePlugin;
|
|
36
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["VerdaccioMiddlewarePlugin","constructor","config","options","foo","undefined","strict_ssl","logger","register_middlewares","app","auth","_storage"],"sources":["../../../../../../generators/app/templates/typescript/middleware/src/index.ts"],"sourcesContent":["import {Logger, IPluginMiddleware, IBasicAuth, IStorageManager, PluginOptions} from '@verdaccio/types';\nimport {Router, Request, Response, NextFunction, Application} from 'express';\n\nimport {CustomConfig} from '../types/index';\n\nexport default class VerdaccioMiddlewarePlugin implements IPluginMiddleware<CustomConfig> {\n public logger: Logger;\n public foo: string;\n public constructor(config: CustomConfig, options: PluginOptions<CustomConfig>) {\n this.foo = config.foo !== undefined ? config.strict_ssl : true;\n this.logger = options.logger;\n }\n\n public register_middlewares(\n app: Application,\n auth: IBasicAuth<CustomConfig>,\n /* eslint @typescript-eslint/no-unused-vars: off */\n _storage: IStorageManager<CustomConfig>,\n ): void {\n /**\n * This is just an example of implementation\n // eslint new-cap:off\n const router = Router();\n router.post(\n '/custom-endpoint',\n (req: Request, res: Response & { report_error?: Function }, next: NextFunction): void => {\n const encryptedString = auth.aesEncrypt(Buffer.from(this.foo, 'utf8'));\n res.setHeader('X-Verdaccio-Token-Plugin', encryptedString.toString());\n next();\n }\n );\n app.use('/-/npm/something-new', router);\n */\n }\n}\n"],"mappings":";;;;;;;AAKe,MAAMA,yBAAN,CAA2E;EAGjFC,WAAW,CAACC,MAAD,EAAuBC,OAAvB,EAA6D;IAC7E,KAAKC,GAAL,GAAWF,MAAM,CAACE,GAAP,KAAeC,SAAf,GAA2BH,MAAM,CAACI,UAAlC,GAA+C,IAA1D;IACA,KAAKC,MAAL,GAAcJ,OAAO,CAACI,MAAtB;EACD;;EAEMC,oBAAoB,CACvBC,GADuB,EAEvBC,IAFuB;EAGvB;EACAC,QAJuB,EAKnB;IACN;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACG;;AA5BuF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../../../generators/app/templates/typescript/middleware/types/index.ts"],"sourcesContent":["import {Config} from '@verdaccio/types';\n\nexport interface CustomConfig extends Config {\n foo: string;\n}\n"],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PackageStorage.js","names":["StoragePluginManage","constructor","config","packageName","logger","updatePackage","name","updateHandler","onWrite","transformPackage","onEnd","deletePackage","fileName","callback","removePackage","createPackage","data","savePackage","pkgName","pkg","readPackage","writeTarball","readTarball"],"sources":["../../../../../../generators/app/templates/typescript/storage/src/PackageStorage.ts"],"sourcesContent":["import {\n Callback,\n Logger,\n ILocalPackageManager,\n StorageUpdateCallback,\n PackageTransformer,\n StorageWriteCallback,\n CallbackAction,\n Package,\n ReadPackageCallback,\n} from '@verdaccio/types';\nimport {UploadTarball, ReadTarball} from '@verdaccio/streams';\nimport {getNotFound, getConflict, getInternalError} from '@verdaccio/commons-api';\n\nimport {CustomConfig} from '../types/index';\nexport default class StoragePluginManage implements ILocalPackageManager {\n public logger: Logger;\n public packageName: string;\n public config: CustomConfig;\n\n public constructor(\n config: CustomConfig,\n packageName: string,\n logger: Logger,\n ) {\n this.logger = logger;\n this.packageName = packageName;\n this.config = config;\n }\n\n /**\n * Handle a metadata update and\n * @param name\n * @param updateHandler\n * @param onWrite\n * @param transformPackage\n * @param onEnd\n */\n public updatePackage(\n name: string,\n updateHandler: StorageUpdateCallback,\n onWrite: StorageWriteCallback,\n transformPackage: PackageTransformer,\n onEnd: CallbackAction,\n ): void {\n /**\n * Example of implementation:\n this.customStore.get().then((pkg: Package) => {\n updateHandler(pkg, function onUpdateFinish(err) {\n if (err) {\n onEnd(err);\n } else {\n onWrite(name, pkg, onEnd);\n }\n })\n });\n */\n }\n\n /**\n * Delete a specific file (tarball or package.json)\n * @param fileName\n * @param callback\n */\n public deletePackage(fileName: string, callback: CallbackAction): void {\n /**\n * Example of implementation:\n this.customStore.delete(fileName, (err) => {\n if (err) {\n callback(err);\n } else {\n callback(null);\n }\n })\n */\n }\n\n /**\n * Delete a package (folder, path)\n * This happens after all versions ar tarballs have been removed.\n * @param callback\n */\n public removePackage(callback: CallbackAction): void {\n /**\n * Example of implementation:\n this.customStore.removePackage((err) => {\n if (err) {\n callback(err);\n } else {\n callback(null);\n }\n })\n */\n }\n\n /**\n * Publish a new package (version).\n * @param name\n * @param data\n * @param callback\n */\n public createPackage(\n name: string,\n data: Package,\n callback: CallbackAction,\n ): void {\n /**\n * Example of implementation:\n * this.customStore.create(name, data).then(err => {\n if (err.notFound) {\n callback(getNotFound());\n } else if (err.alreadyExist) {\n callback(getConflict());\n } else {\n callback(null);\n }\n })\n */\n }\n\n /**\n * Perform write anobject to the storage.\n * Similar to updatePackage but without middleware handlers\n * @param pkgName package name\n * @param pkg package metadata\n * @param callback\n */\n public savePackage(pkgName: string, pkg: Package, callback: CallbackAction): void {\n /*\n Example of implementation:\n this.cumstomStore.write(pkgName, pkgName).then(data => {\n callback(null);\n }).catch(err => {\n callback(getInternalError(err.message));\n })\n */\n }\n\n /**\n * Read a package from storage\n * @param pkgName package name\n * @param callback\n */\n public readPackage(pkgName: string, callback: ReadPackageCallback): void {\n /**\n * Example of implementation:\n * this.customStorage.read(name, (err, pkg: Package) => {\n if (err.fooError) {\n callback(getInternalError(err))\n } else if (err.barError) {\n callback(getNotFound());\n } else {\n callback(null, pkg)\n }\n });\n */\n }\n\n /**\n * Create writtable stream (write a tarball)\n * @param name\n */\n public writeTarball(name: string): UploadTarball {\n /**\n * Example of implementation:\n * const stream = new UploadTarball({});\n return stream;\n */\n\n }\n\n /**\n * Create a readable stream (read a from a tarball)\n * @param name\n */\n public readTarball(name: string): ReadTarball {\n /**\n * Example of implementation:\n * const stream = new ReadTarball({});\n return stream;\n */\n }\n}\n"],"mappings":";;;;;;;AAee,MAAMA,mBAAN,CAA0D;EAKhEC,WAAW,CACdC,MADc,EAEdC,WAFc,EAGdC,MAHc,EAIhB;IACA,KAAKA,MAAL,GAAcA,MAAd;IACA,KAAKD,WAAL,GAAmBA,WAAnB;IACA,KAAKD,MAAL,GAAcA,MAAd;EACD;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;;EACSG,aAAa,CAChBC,IADgB,EAEhBC,aAFgB,EAGhBC,OAHgB,EAIhBC,gBAJgB,EAKhBC,KALgB,EAMZ;IACN;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACG;EAED;AACF;AACA;AACA;AACA;;;EACSC,aAAa,CAACC,QAAD,EAAmBC,QAAnB,EAAmD;IACrE;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACG;EAED;AACF;AACA;AACA;AACA;;;EACSC,aAAa,CAACD,QAAD,EAAiC;IACnD;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACG;EAED;AACF;AACA;AACA;AACA;AACA;;;EACSE,aAAa,CAChBT,IADgB,EAEhBU,IAFgB,EAGhBH,QAHgB,EAIZ;IACN;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACG;EAED;AACF;AACA;AACA;AACA;AACA;AACA;;;EACSI,WAAW,CAACC,OAAD,EAAkBC,GAAlB,EAAgCN,QAAhC,EAAgE;IAChF;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;EACG;EAED;AACF;AACA;AACA;AACA;;;EACSO,WAAW,CAACF,OAAD,EAAkBL,QAAlB,EAAuD;IACvE;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACG;EAED;AACF;AACA;AACA;;;EACSQ,YAAY,CAACf,IAAD,EAA8B;IAC/C;AACJ;AACA;AACA;AACA;EAEG;EAED;AACF;AACA;AACA;;;EACSgB,WAAW,CAAChB,IAAD,EAA4B;IAC5C;AACJ;AACA;AACA;AACA;EACG;;AAtKsE"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "default", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _plugin.default;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
var _plugin = _interopRequireDefault(require("./plugin"));
|
|
14
|
-
|
|
15
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../../../generators/app/templates/typescript/storage/src/index.ts"],"sourcesContent":["export {default} from './plugin';\n"],"mappings":";;;;;;;;;;;;AAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","names":["VerdaccioStoragePlugin","constructor","config","options","logger","getSecret","setSecret","secret","add","name","callback","search","onPackage","onEnd","validateName","remove","get","getPackageStorage","packageInfo","PackageStorage","saveToken","token","Error","deleteToken","user","tokenKey","readTokens","filter"],"sources":["../../../../../../generators/app/templates/typescript/storage/src/plugin.ts"],"sourcesContent":["import {\n Logger,\n Callback,\n IPluginStorage,\n PluginOptions,\n IPackageStorage,\n TokenFilter,\n Token,\n Config,\n onEndSearchPackage,\n onSearchPackage,\n onValidatePackage,\n} from '@verdaccio/types';\nimport {getInternalError} from '@verdaccio/commons-api';\n\nimport {CustomConfig} from '../types/index';\n\nimport PackageStorage from './PackageStorage';\n\nexport default class VerdaccioStoragePlugin implements IPluginStorage<CustomConfig> {\n config: CustomConfig & Config;\n version?: string;\n public logger: Logger;\n public constructor(\n config: CustomConfig,\n options: PluginOptions<CustomConfig>,\n ) {\n this.config = config;\n this.logger = options.logger;\n }\n\n /**\n *\n */\n public async getSecret(): Promise<string> {\n /**\n * return await resolveSecret();\n */\n }\n\n public async setSecret(secret: string): Promise<any> {\n /**\n * return await getYourSecret();\n */\n }\n\n /**\n * Add a new element.\n * @param {*} name\n * @return {Error|*}\n */\n public add(name: string, callback: Callback): void {\n\n }\n\n /**\n * Perform a search in your registry\n * @param onPackage\n * @param onEnd\n * @param validateName\n */\n public search(\n onPackage: onSearchPackage,\n onEnd: onEndSearchPackage,\n validateName: onValidatePackage,\n ): void {\n /**\n * Example of implementation:\n * try {\n * someApi.getPackages((items) => {\n * items.map(() => {\n * if (validateName(item.name)) {\n * onPackage(item);\n * }\n * });\n * onEnd();\n * } catch(err) {\n * onEnd(err);\n * }\n * });\n */\n }\n\n /**\n * Remove an element from the database.\n * @param {*} name\n * @return {Error|*}\n */\n public remove(name: string, callback: Callback): void {\n /**\n * Example of implementation\n database.getPackage(name, (item, err) => {\n if (err) {\n callback(getInternalError('your own message here'));\n }\n\n // if all goes well we return nothing\n callback(null);\n }\n */\n }\n\n /**\n * Return all database elements.\n * @return {Array}\n */\n public get(callback: Callback): void {\n /*\n Example of implementation\n database.getAll((allItems, err) => {\n callback(err, allItems);\n })\n */\n }\n\n /**\n * Create an instance of the `PackageStorage`\n * @param packageInfo\n */\n public getPackageStorage(packageInfo: string): IPackageStorage {\n return new PackageStorage(this.config, packageInfo, this.logger);\n }\n\n /**\n * All methods for npm token support\n * more info here https://github.com/verdaccio/verdaccio/pull/1427\n */\n\n public saveToken(token: Token): Promise<any> {\n throw new Error('Method not implemented.');\n }\n\n public deleteToken(user: string, tokenKey: string): Promise<any> {\n throw new Error('Method not implemented.');\n }\n\n public readTokens(filter: TokenFilter): Promise<Token[]> {\n throw new Error('Method not implemented.');\n }\n}\n"],"mappings":";;;;;;;AAiBA;;;;AAEe,MAAMA,sBAAN,CAAqE;EAI3EC,WAAW,CACdC,MADc,EAEdC,OAFc,EAGhB;IACA,KAAKD,MAAL,GAAcA,MAAd;IACA,KAAKE,MAAL,GAAcD,OAAO,CAACC,MAAtB;EACD;EAED;AACF;AACA;;;EACwB,MAATC,SAAS,GAAoB;IACxC;AACJ;AACA;EACG;;EAEqB,MAATC,SAAS,CAACC,MAAD,EAA+B;IACnD;AACJ;AACA;EACG;EAED;AACF;AACA;AACA;AACA;;;EACSC,GAAG,CAACC,IAAD,EAAeC,QAAf,EAAyC,CAElD;EAED;AACF;AACA;AACA;AACA;AACA;;;EACSC,MAAM,CACTC,SADS,EAETC,KAFS,EAGTC,YAHS,EAIL;IACN;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACG;EAED;AACF;AACA;AACA;AACA;;;EACSC,MAAM,CAACN,IAAD,EAAeC,QAAf,EAAyC;IACpD;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EAEG;EAED;AACF;AACA;AACA;;;EACSM,GAAG,CAACN,QAAD,EAA2B;IACnC;AACJ;AACA;AACA;AACA;AACA;EACG;EAED;AACF;AACA;AACA;;;EACSO,iBAAiB,CAACC,WAAD,EAAuC;IAC7D,OAAO,IAAIC,uBAAJ,CAAmB,KAAKjB,MAAxB,EAAgCgB,WAAhC,EAA6C,KAAKd,MAAlD,CAAP;EACD;EAED;AACF;AACA;AACA;;;EAESgB,SAAS,CAACC,KAAD,EAA6B;IAC3C,MAAM,IAAIC,KAAJ,CAAU,yBAAV,CAAN;EACD;;EAEMC,WAAW,CAACC,IAAD,EAAeC,QAAf,EAA+C;IAC/D,MAAM,IAAIH,KAAJ,CAAU,yBAAV,CAAN;EACD;;EAEMI,UAAU,CAACC,MAAD,EAAwC;IACvD,MAAM,IAAIL,KAAJ,CAAU,yBAAV,CAAN;EACD;;AAvHiF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../../../generators/app/templates/typescript/storage/types/index.ts"],"sourcesContent":["import {Config} from '@verdaccio/types';\n\nexport interface CustomConfig extends Config {\n foo: string;\n}\n"],"mappings":""}
|