generator-verdaccio-plugin 6.0.0-next-8.27 → 6.0.0

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.
Files changed (27) hide show
  1. package/LICENSE +6 -6
  2. package/README.md +6 -76
  3. package/generators/app/index.d.ts +11 -0
  4. package/generators/app/index.js +131 -122
  5. package/generators/app/templates/auth/_package.json +3 -16
  6. package/generators/app/templates/auth/src/auth-plugin.ts +102 -0
  7. package/generators/app/templates/auth/src/index.ts +3 -90
  8. package/generators/app/templates/auth/types/index.ts +1 -1
  9. package/generators/app/templates/common/_package.json +26 -0
  10. package/generators/app/templates/common/npmignore +1 -1
  11. package/generators/app/templates/common/nvmrc +1 -0
  12. package/generators/app/templates/middleware/_package.json +3 -17
  13. package/generators/app/templates/middleware/src/index.ts +3 -40
  14. package/generators/app/templates/middleware/src/middleware-plugin.ts +40 -0
  15. package/generators/app/templates/middleware/types/index.ts +1 -1
  16. package/generators/app/templates/storage/_package.json +3 -15
  17. package/generators/app/templates/storage/src/index.ts +5 -1
  18. package/generators/app/templates/storage/src/storage-plugin.ts +70 -0
  19. package/generators/app/templates/storage/types/index.ts +1 -1
  20. package/package.json +50 -26
  21. package/generators/app/index.js.map +0 -1
  22. package/generators/app/templates/common/eslintignore +0 -2
  23. package/generators/app/templates/common/eslintrc +0 -12
  24. package/generators/app/templates/common/index.js +0 -15
  25. package/generators/app/templates/common/jest.config.js +0 -4
  26. package/generators/app/templates/storage/src/PackageStorage.ts +0 -175
  27. package/generators/app/templates/storage/src/plugin.ts +0 -134
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
- MIT License
1
+ The MIT License (MIT)
2
2
 
3
- Copyright (c) 2025 Verdaccio contributors
3
+ Copyright (c) 2024 Juan Picado <@jotadeveloper> <juanpicado19@gmail.com>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
9
  copies of the Software, and to permit persons to whom the Software is
10
10
  furnished to do so, subject to the following conditions:
11
11
 
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
14
 
15
15
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
16
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
17
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md CHANGED
@@ -1,19 +1,9 @@
1
- # generator-verdaccio-plugin - Plugin Generator for Verdaccio
1
+ # generator-verdaccio-plugin
2
2
 
3
- [![Verdaccio Home](https://img.shields.io/badge/Homepage-Verdaccio-405236?style=flat)](https://verdaccio.org)
4
- [![MIT License](https://img.shields.io/github/license/verdaccio/verdaccio?label=License&color=405236)](https://github.com/verdaccio/verdaccio/blob/master/LICENSE)
5
- [![Verdaccio Latest](https://img.shields.io/npm/v/verdaccio?label=Latest%20Version&color=405236)](https://github.com/verdaccio/verdaccio)
6
- [![This Package Latest](https://img.shields.io/npm/v/generator-verdaccio-plugin?label=generator-verdaccio-plugin&color=405236)](https://npmjs.com/package/generator-verdaccio-plugin)
7
-
8
- [![Documentation](https://img.shields.io/badge/Help-Verdaccio?style=flat&logo=Verdaccio&label=Verdaccio&color=cd4000)](https://verdaccio.org/docs)
9
- [![Discord](https://img.shields.io/badge/Chat-Discord?style=flat&logo=Discord&label=Discord&color=cd4000)](https://discord.com/channels/388674437219745793)
10
- [![Bluesky](https://img.shields.io/badge/Follow-Bluesky?style=flat&logo=Bluesky&label=Bluesky&color=cd4000)](https://bsky.app/profile/verdaccio.org)
11
- [![Backers](https://img.shields.io/opencollective/backers/verdaccio?style=flat&logo=opencollective&label=Join%20Backers&color=cd4000)](https://opencollective.com/verdaccio/contribute)
12
- [![Sponsors](https://img.shields.io/opencollective/sponsors/verdaccio?style=flat&logo=opencollective&label=Sponsor%20Us&color=cd4000)](https://opencollective.com/verdaccio/contribute)
13
-
14
- [![Verdaccio Downloads](https://img.shields.io/npm/dm/verdaccio?style=flat&logo=npm&label=Npm%20Downloads&color=lightgrey)](https://www.npmjs.com/package/verdaccio)
15
- [![Docker Pulls](https://img.shields.io/docker/pulls/verdaccio/verdaccio?style=flat&logo=docker&label=Docker%20Pulls&color=lightgrey)](https://hub.docker.com/r/verdaccio/verdaccio)
16
- [![GitHub Stars](https://img.shields.io/github/stars/verdaccio?style=flat&logo=github&label=GitHub%20Stars%20%E2%AD%90&color=lightgrey)](https://github.com/verdaccio/verdaccio/stargazers)
3
+ [![verdaccio (latest)](https://img.shields.io/npm/v/generator-verdaccio-plugin/latest.svg)](https://www.npmjs.com/package/generator-verdaccio-plugin)
4
+ [![verdaccio (downloads)](https://img.shields.io/npm/dy/generator-verdaccio-plugin.svg)](https://www.npmjs.com/package/generator-verdaccio-plugin)
5
+ [![Backers](https://opencollective.com/verdaccio/tiers/backer/badge.svg?label=Backer&color=brightgreen)](https://opencollective.com/verdaccio)
6
+ [![Discord](https://img.shields.io/discord/388674437219745793?logo=discord)](http://chat.verdaccio.org/)
17
7
 
18
8
  Verdaccio plugin generator based in [Yeoman](http://yeoman.io) aims to help to scaffold plugins development
19
9
 
@@ -43,66 +33,6 @@ yo verdaccio-plugin
43
33
  - [Anix](https://github.com/anikethsaha)
44
34
  - [Juan Picado](https://github.com/juanpicado)
45
35
 
46
- ## Donations
47
-
48
- Verdaccio is run by **volunteers**; nobody is working full-time on it. If you find this project to be useful and would like to support its development, consider making a donation - **your logo might end up in this readme.** 😉
49
-
50
- **[Donate](https://opencollective.com/verdaccio)** 💵👍🏻 starting from _\$1/month_ or just one single contribution.
51
-
52
- ## Report a vulnerability
53
-
54
- If you want to report a security vulnerability, please follow the steps which we have defined for you in our [security policy](https://github.com/verdaccio/verdaccio/security/policy).
55
-
56
- ## Open Collective Sponsors
57
-
58
- Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/verdaccio/contribute)]
59
-
60
- [![sponsor](https://opencollective.com/verdaccio/sponsor/0/avatar.svg)](https://opencollective.com/verdaccio/sponsor/0/website)
61
- [![sponsor](https://opencollective.com/verdaccio/sponsor/1/avatar.svg)](https://opencollective.com/verdaccio/sponsor/1/website)
62
- [![sponsor](https://opencollective.com/verdaccio/sponsor/2/avatar.svg)](https://opencollective.com/verdaccio/sponsor/2/website)
63
- [![sponsor](https://opencollective.com/verdaccio/sponsor/3/avatar.svg)](https://opencollective.com/verdaccio/sponsor/3/website)
64
- [![sponsor](https://opencollective.com/verdaccio/sponsor/4/avatar.svg)](https://opencollective.com/verdaccio/sponsor/4/website)
65
- [![sponsor](https://opencollective.com/verdaccio/sponsor/5/avatar.svg)](https://opencollective.com/verdaccio/sponsor/5/website)
66
- [![sponsor](https://opencollective.com/verdaccio/sponsor/6/avatar.svg)](https://opencollective.com/verdaccio/sponsor/6/website)
67
- [![sponsor](https://opencollective.com/verdaccio/sponsor/7/avatar.svg)](https://opencollective.com/verdaccio/sponsor/7/website)
68
- [![sponsor](https://opencollective.com/verdaccio/sponsor/8/avatar.svg)](https://opencollective.com/verdaccio/sponsor/8/website)
69
- [![sponsor](https://opencollective.com/verdaccio/sponsor/9/avatar.svg)](https://opencollective.com/verdaccio/sponsor/9/website)
70
-
71
- ## Open Collective Backers
72
-
73
- Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/verdaccio/contribute)]
74
-
75
- [![backers](https://opencollective.com/verdaccio/backers.svg?width=890)](https://opencollective.com/verdaccio/contributes)
76
-
77
- ## Special Thanks
78
-
79
- Thanks to the following companies to help us to achieve our goals providing free open source licenses.
80
-
81
- [![jetbrains](https://github.com/verdaccio/verdaccio/blob/master/assets/thanks/jetbrains/logo.jpg?raw=true)](https://www.jetbrains.com/)
82
- [![crowdin](https://github.com/verdaccio/verdaccio/blob/master/assets/thanks/crowdin/logo.png?raw=true)](https://crowdin.com/)
83
-
84
- ## Contributors
85
-
86
- This project exists thanks to all the people who contribute. [[Contribute](https://github.com/verdaccio/verdaccio/blob/master/CONTRIBUTING.md)].
87
-
88
- [![contributors](https://opencollective.com/verdaccio/contributors.svg?width=890&button=true)](https://github.com/verdaccio/verdaccio/graphs/contributors)
89
-
90
- ## FAQ / Contact / Troubleshoot
91
-
92
- If you have any issue you can try the following options. Do not hesitate to ask or check our issues database. Perhaps someone has asked already what you are looking for.
93
-
94
- - [Blog](https://verdaccio.org/blog/)
95
- - [Donations](https://opencollective.com/verdaccio)
96
- - [Reporting an issue](https://github.com/verdaccio/verdaccio/blob/master/CONTRIBUTING.md#reporting-a-bug)
97
- - [Running discussions](https://github.com/orgs/verdaccio/discussions)
98
- - [Chat](https://discord.com/channels/388674437219745793)
99
- - [Logos](https://verdaccio.org/docs/logo)
100
- - [Docker Examples](https://github.com/verdaccio/verdaccio/tree/master/docker-examples)
101
- - [FAQ](https://github.com/verdaccio/verdaccio/issues?utf8=%E2%9C%93&q=is%3Aissue%20label%3Aquestion%20)
102
-
103
36
  ## License
104
37
 
105
- Verdaccio is [MIT licensed](https://github.com/verdaccio/verdaccio/blob/master/LICENSE)
106
-
107
- The Verdaccio documentation and logos (excluding /thanks, e.g., .md, .png, .sketch files within the /assets folder) are
108
- [Creative Commons licensed](https://creativecommons.org/licenses/by/4.0/).
38
+ MIT © [Juan Picado &lt;@jotadeveloper&gt;]()
@@ -0,0 +1,11 @@
1
+ import Generator from 'yeoman-generator';
2
+ export default class PluginGenerator extends Generator {
3
+ private props;
4
+ private projectName;
5
+ private destinationPathName;
6
+ constructor(args: string | string[], opts: Record<string, unknown>);
7
+ prompting(): Promise<void>;
8
+ packageJSON(): void;
9
+ writing(): void;
10
+ install(): void;
11
+ }
@@ -1,125 +1,134 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _chalk = _interopRequireDefault(require("chalk"));
8
- var _lodash = _interopRequireDefault(require("lodash"));
9
- var _nodePath = require("node:path");
10
- var _yeomanGenerator = _interopRequireDefault(require("yeoman-generator"));
11
- var _yosay = _interopRequireDefault(require("yosay"));
12
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
- class PluginGenerator extends _yeomanGenerator.default {
14
- projectName = 'verdaccio-';
15
- destinationPathName = 'verdaccio-';
16
- constructor(args, opts) {
17
- super(args, opts);
18
- this.props = {};
19
- }
20
- prompting() {
21
- this.log((0, _yosay.default)(`Welcome to ${_chalk.default.red('generator-verdaccio-plugin')} plugin generator!`));
22
- const prompts = [{
23
- type: 'list',
24
- name: 'pluginType',
25
- require: true,
26
- message: 'What kind of plugin you want to create?',
27
- store: true,
28
- choices: [{
29
- value: 'auth'
30
- }, {
31
- value: 'storage'
32
- }, {
33
- value: 'middleware'
34
- }]
35
- }, {
36
- type: 'input',
37
- name: 'name',
38
- require: true,
39
- message: `What's the plugin name? The prefix (verdaccio-xxx) will be added automatically`,
40
- default: 'customname',
41
- validate: function (input) {
42
- if (input.startsWith('verdaccio-')) {
43
- return false;
44
- } else if (input === '') {
45
- return false;
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const chalk_1 = __importDefault(require("chalk"));
7
+ const lodash_1 = __importDefault(require("lodash"));
8
+ const node_path_1 = require("node:path");
9
+ const yeoman_generator_1 = __importDefault(require("yeoman-generator"));
10
+ const yosay_1 = __importDefault(require("yosay"));
11
+ const package_json_1 = __importDefault(require("../../package.json"));
12
+ class PluginGenerator extends yeoman_generator_1.default {
13
+ props = {};
14
+ projectName = 'verdaccio-';
15
+ destinationPathName = '';
16
+ constructor(args, opts) {
17
+ super(args, opts);
18
+ }
19
+ async prompting() {
20
+ this.log((0, yosay_1.default)(`Welcome to ${chalk_1.default.red('generator-verdaccio-plugin')} plugin generator!`));
21
+ const answers = await this.prompt([
22
+ {
23
+ type: 'list',
24
+ name: 'pluginType',
25
+ message: 'What kind of plugin do you want to create?',
26
+ default: process.env.PLUGIN_TYPE ?? 'auth',
27
+ choices: [
28
+ { name: 'Auth', value: 'auth' },
29
+ { name: 'Storage', value: 'storage' },
30
+ { name: 'Middleware', value: 'middleware' },
31
+ ],
32
+ },
33
+ {
34
+ type: 'input',
35
+ name: 'name',
36
+ message: 'What\'s the plugin name? The prefix (verdaccio-xxx) will be added automatically',
37
+ default: process.env.PLUGIN_NAME ?? 'my-plugin',
38
+ validate: (input) => {
39
+ if (!input) {
40
+ return 'Name cannot be empty';
41
+ }
42
+ if (input.startsWith('verdaccio-')) {
43
+ return 'Do not include the verdaccio- prefix';
44
+ }
45
+ return true;
46
+ },
47
+ },
48
+ {
49
+ type: 'input',
50
+ name: 'description',
51
+ message: 'Please, describe your plugin',
52
+ default: 'An amazing verdaccio plugin',
53
+ },
54
+ {
55
+ type: 'input',
56
+ name: 'githubUsername',
57
+ message: 'GitHub username or Organization',
58
+ validate: (input) => Boolean(input) || 'GitHub username is required',
59
+ },
60
+ {
61
+ type: 'input',
62
+ name: 'authorName',
63
+ message: 'Author\'s Name',
64
+ store: true,
65
+ },
66
+ {
67
+ type: 'input',
68
+ name: 'authorEmail',
69
+ message: 'Author\'s Email',
70
+ store: true,
71
+ },
72
+ {
73
+ type: 'input',
74
+ name: 'keywords',
75
+ message: 'Type your keywords (comma separated)',
76
+ filter: (keywords) => lodash_1.default.uniq(lodash_1.default.words(keywords).concat(['verdaccio'])),
77
+ },
78
+ ]);
79
+ this.props = {
80
+ ...answers,
81
+ license: 'MIT',
82
+ };
83
+ this.projectName = `verdaccio-${answers.name}`;
84
+ this.destinationPathName = (0, node_path_1.resolve)(this.projectName);
85
+ this.props.name = this.projectName;
86
+ if (answers.githubUsername) {
87
+ this.props.repository = `${answers.githubUsername}/${answers.name}`;
46
88
  }
47
- return true;
48
- }
49
- }, {
50
- type: 'input',
51
- name: 'description',
52
- message: 'Please, describe your plugin',
53
- default: 'An amazing verdaccio plugin'
54
- }, {
55
- name: 'githubUsername',
56
- message: 'GitHub username or Organization',
57
- validate: function (input) {
58
- return input !== '';
59
- }
60
- }, {
61
- name: 'authorName',
62
- message: "Author's Name",
63
- store: true
64
- }, {
65
- name: 'authorEmail',
66
- message: "Author's Email",
67
- store: true
68
- }, {
69
- name: 'keywords',
70
- message: 'Key your keywords (comma to split)',
71
- filter: function (keywords) {
72
- return _lodash.default.uniq(_lodash.default.words(keywords).concat(['verdaccio-']));
73
- }
74
- }];
75
- return this.prompt(prompts).then(function (_props) {
76
- // To access props later use this.props.someAnswer;
77
- // @ts-ignore
78
- this.props = _props;
79
- const {
80
- name,
81
- githubUsername
82
- } = _props;
83
- // @ts-ignore
84
- this.props.license = 'MIT';
85
- if (githubUsername) {
86
- // @ts-ignore
87
- this.props.repository = githubUsername + '/' + name;
88
- }
89
-
90
- // @ts-ignore
91
- this.projectName = `verdaccio-${name}`;
92
-
93
- // @ts-ignore
94
- this.destinationPathName = (0, _nodePath.resolve)(this.projectName);
95
- // @ts-ignore
96
- this.props.name = this.projectName;
97
- }.bind(this));
98
- }
99
- packageJSON() {
100
- const {
101
- pluginType
102
- } = this.props;
103
- const pkgJsonLocation = `${pluginType}/_package.json`;
104
- this.fs.copyTpl(this.templatePath(pkgJsonLocation), this.destinationPath((0, _nodePath.resolve)(this.destinationPathName, 'package.json')), this.props);
105
- }
106
- writing() {
107
- this.fs.copy(this.templatePath(`common/gitignore`), this.destinationPath((0, _nodePath.resolve)(this.destinationPathName, '.gitignore')));
108
- this.fs.copy(this.templatePath(`common/npmignore`), this.destinationPath((0, _nodePath.resolve)(this.destinationPathName, '.npmignore')));
109
- this.fs.copy(this.templatePath(`common/jest.config.js`), this.destinationPath((0, _nodePath.resolve)(this.destinationPathName, 'jest.config.js')));
110
- this.fs.copyTpl(this.templatePath(`common/README.md`), this.destinationPath((0, _nodePath.resolve)(this.destinationPathName, 'README.md')), this.props);
111
- this.fs.copyTpl(this.templatePath(`common/eslintrc`), this.destinationPath((0, _nodePath.resolve)(this.destinationPathName, '.eslintrc')), this.props);
112
- this.fs.copyTpl(this.templatePath(`common/eslintignore`), this.destinationPath((0, _nodePath.resolve)(this.destinationPathName, '.eslintignore')), this.props);
113
- this.fs.copy(this.templatePath(`${this.props.pluginType}/src`), this.destinationPath((0, _nodePath.resolve)(this.destinationPathName, 'src')));
114
- this.fs.copy(this.templatePath(`common/index.js`), this.destinationPath((0, _nodePath.resolve)(this.destinationPathName, `index.js`)));
115
- this.fs.copy(this.templatePath(`common/tsconfig.json`), this.destinationPath((0, _nodePath.resolve)(this.destinationPathName, 'tsconfig.json')));
116
- this.fs.copy(this.templatePath(`${this.props.pluginType}/types`), this.destinationPath((0, _nodePath.resolve)(this.destinationPathName, 'types')));
117
- this.fs.copy(this.templatePath(`common/editorconfig`), this.destinationPath((0, _nodePath.resolve)(this.destinationPathName, '.editorconfig')));
118
- }
119
- install() {
120
- process.chdir(this.projectName);
121
- // this.installDependencies({ npm: true, bower: false });
122
- }
89
+ }
90
+ packageJSON() {
91
+ const { pluginType } = this.props;
92
+ if (!pluginType) {
93
+ this.log.error('pluginType is required');
94
+ return;
95
+ }
96
+ const pkg = this.fs.readJSON(this.templatePath(`${pluginType}/_package.json`));
97
+ // devDependencies
98
+ pkg.devDependencies['@types/node'] = package_json_1.default.devDependencies['@types/node'];
99
+ pkg.devDependencies['@types/express'] = package_json_1.default.devDependencies['@types/express'];
100
+ pkg.devDependencies['@types/debug'] = package_json_1.default.devDependencies['@types/debug'];
101
+ pkg.devDependencies['typescript'] = package_json_1.default.devDependencies['typescript'];
102
+ pkg.devDependencies['@verdaccio/types'] = package_json_1.default.devDependencies['@verdaccio/types'];
103
+ // required by verdaccio types
104
+ pkg.devDependencies['@types/jsonwebtoken'] = package_json_1.default.devDependencies['@types/jsonwebtoken'];
105
+ // dependencies
106
+ pkg.dependencies['@verdaccio/core'] = package_json_1.default.dependencies['@verdaccio/core'];
107
+ pkg.dependencies['@verdaccio/config'] = package_json_1.default.dependencies['@verdaccio/config'];
108
+ pkg.dependencies['debug'] = package_json_1.default.dependencies['debug'];
109
+ if (pluginType === 'auth') {
110
+ pkg.devDependencies['@verdaccio/auth'] = package_json_1.default.devDependencies['@verdaccio/auth'];
111
+ }
112
+ else if (pluginType === 'middleware') {
113
+ pkg.dependencies['express'] = package_json_1.default.dependencies['express'];
114
+ }
115
+ this.fs.writeJSON(this.templatePath(`${pluginType}/_package.json`), pkg);
116
+ this.fs.copyTpl(this.templatePath(`${pluginType}/_package.json`), this.destinationPath((0, node_path_1.resolve)(this.destinationPathName, 'package.json')), this.props);
117
+ }
118
+ writing() {
119
+ const dest = (path) => this.destinationPath((0, node_path_1.resolve)(this.destinationPathName, path));
120
+ this.fs.copy(this.templatePath('common/gitignore'), dest('.gitignore'));
121
+ this.fs.copy(this.templatePath('common/npmignore'), dest('.npmignore'));
122
+ this.fs.copy(this.templatePath('common/nvmrc'), dest('.nvmrc'));
123
+ this.fs.copyTpl(this.templatePath('common/README.md'), dest('README.md'), this.props);
124
+ this.fs.copy(this.templatePath(`${this.props.pluginType}/src`), dest('src'));
125
+ // this.fs.copy(this.templatePath('common/index.ts'), dest('index.ts'));
126
+ this.fs.copy(this.templatePath('common/tsconfig.json'), dest('tsconfig.json'));
127
+ this.fs.copy(this.templatePath(`${this.props.pluginType}/types`), dest('types'));
128
+ this.fs.copy(this.templatePath('common/editorconfig'), dest('.editorconfig'));
129
+ }
130
+ install() {
131
+ this.destinationRoot(this.projectName);
132
+ }
123
133
  }
124
- var _default = exports.default = PluginGenerator;
125
- //# sourceMappingURL=index.js.map
134
+ exports.default = PluginGenerator;
@@ -7,27 +7,14 @@
7
7
  "engines": {
8
8
  "node": ">=18"
9
9
  },
10
- "dependencies": {
11
- "@verdaccio/commons-api": "10.2.0"
12
- },
13
- "devDependencies": {
14
- "@types/jest": "27.5.1",
15
- "@types/node": "12.12.5",
16
- "@types/express": "4.17.13",
17
- "@typescript-eslint/eslint-plugin": "5.26.0",
18
- "@typescript-eslint/parser": "5.26.0",
19
- "@verdaccio/types": "10.5.2",
20
- "eslint": "8.21.0",
21
- "jest": "28.1.3",
22
- "typescript": "4.7.4"
23
- },
10
+ "dependencies": {},
11
+ "devDependencies": {},
24
12
  "keywords": ["<%= keywords %>]"],
25
13
  "license": "<%= license %>",
26
14
  "repository": "<%= repository %>",
27
15
  "author": "<%= authorName %> <<%= authorEmail %>>",
28
16
  "scripts": {
29
17
  "build": "tsc",
30
- "test": "jest .",
31
- "lint": "eslint \"**/*.{js,ts}\""
18
+ "test": "echo \"Error: no test specified\" && exit 1"
32
19
  }
33
20
  }
@@ -0,0 +1,102 @@
1
+ import debugCore from 'debug';
2
+
3
+ import {API_ERROR, errorUtils, pluginUtils} from '@verdaccio/core';
4
+ import {Config, Logger, PackageAccess, RemoteUser} from '@verdaccio/types';
5
+
6
+ import {CustomConfig} from '../types/index';
7
+
8
+ const {Plugin} = pluginUtils;
9
+
10
+ // Initialize debug logging
11
+ // Replace 'custom-auth-plugin' with your plugin name
12
+ // This code is meant to help during development and debugging
13
+ const debug = debugCore('verdaccio:plugin:custom-auth-plugin');
14
+
15
+ /**
16
+ * Custom Verdaccio Authenticate Plugin.
17
+ */
18
+ export default class AuthCustomPlugin
19
+ extends Plugin<CustomConfig>
20
+ implements pluginUtils.Auth<CustomConfig> {
21
+ private _logger: Logger;
22
+ private _config: {};
23
+ private _app_config: Config;
24
+ public constructor(config: CustomConfig, appOptions: pluginUtils.PluginOptions) {
25
+ super(config, appOptions);
26
+ this._config = config;
27
+ this._logger = appOptions.logger;
28
+ this._app_config = appOptions.config;
29
+ debug('AuthCustomPlugin config: %o', this._config);
30
+ debug('App Config: %o', this._app_config);
31
+ }
32
+ /**
33
+ * Authenticate an user.
34
+ * @param user user to log
35
+ * @param password provided password
36
+ * @param cb callback function
37
+ */
38
+ public authenticate(user: string, password: string, cb: pluginUtils.AuthCallback): void {
39
+ debug('Authenticating user: %o', user);
40
+ debug('Password: %o', password);
41
+
42
+ // TODO: replace this code with your own authentication logic
43
+ // TODO: replace this code with your own authentication logic
44
+ // TODO: replace this code with your own authentication logic
45
+ if (password === 'verdaccio') {
46
+ this._logger.info(`User @{user} authenticated successfully`);
47
+ debug('User @{user} authenticated successfully', {user});
48
+ return cb(null, [user]);
49
+ } else {
50
+ this._logger.error(`User @{user} authentication failed`);
51
+ return cb(errorUtils.getUnauthorized(API_ERROR.BAD_USERNAME_PASSWORD));
52
+ }
53
+ // TODO: replace this code with your own authentication logic
54
+ // TODO: replace this code with your own authentication logic
55
+ // TODO: replace this code with your own authentication logic
56
+ }
57
+
58
+ public allow_access(user: RemoteUser, pkg: PackageAccess, cb: pluginUtils.AccessCallback): void {
59
+ debug('allow access for %o', user);
60
+ debug('package access list %o', pkg?.access);
61
+ // TODO: replace this code with your own access logic
62
+ // TODO: replace this code with your own access logic
63
+ // TODO: replace this code with your own access logic
64
+ if (pkg?.access?.includes('$anonymous')) {
65
+ debug('%o has been granted access', user?.name);
66
+ this._logger.info('Anonymous user granted access to package');
67
+ return cb(null, true);
68
+ } else if (pkg?.access?.includes('$all')) {
69
+ debug('%o has been granted access', user?.name);
70
+ this._logger.info('All users granted access to package');
71
+ return cb(null, false);
72
+ }
73
+ // TODO: replace this code with your own access logic
74
+ // TODO: replace this code with your own access logic
75
+ // TODO: replace this code with your own access logic
76
+ }
77
+
78
+ public allow_publish(
79
+ user: RemoteUser,
80
+ pkg: PackageAccess,
81
+ cb: pluginUtils.AuthAccessCallback,
82
+ ): void {
83
+ // TODO: replace this code with your own publish logic
84
+ // TODO: replace this code with your own publish logic
85
+ // TODO: replace this code with your own publish logic
86
+ // TODO: replace this code with your own publish logic
87
+ debug('allow publish for %o', user);
88
+ debug('package publish access list %o', pkg?.publish);
89
+ if (user?.name === 'verdaccio') {
90
+ debug('%o has been granted to publish', user?.name);
91
+ return cb(null, true);
92
+ } else {
93
+ const err = errorUtils.getForbidden('not allowed to publish package');
94
+ this._logger.error('%o not allowed to publish package');
95
+ debug('%o not allowed to publish package err %o', user?.name, err.message);
96
+ return cb(err);
97
+ }
98
+ // TODO: replace this code with your own publish logic
99
+ // TODO: replace this code with your own publish logic
100
+ // TODO: replace this code with your own publish logic
101
+ }
102
+ }
@@ -1,92 +1,5 @@
1
- import { getInternalError } from '@verdaccio/commons-api';
2
- import {
3
- AuthAccessCallback,
4
- AuthCallback,
5
- IPluginAuth,
6
- Logger,
7
- PackageAccess,
8
- PluginOptions,
9
- RemoteUser,
10
- } from '@verdaccio/types';
1
+ import AuthPlugin from './auth-plugin';
11
2
 
12
- import { CustomConfig } from '../types/index';
3
+ export {AuthPlugin};
13
4
 
14
- /**
15
- * Custom Verdaccio Authenticate Plugin.
16
- */
17
- export default class AuthCustomPlugin implements IPluginAuth<CustomConfig> {
18
- public logger: Logger;
19
- private foo: string;
20
- public constructor(config: CustomConfig, options: PluginOptions<CustomConfig>) {
21
- this.logger = options.logger;
22
- this.foo = config.foo;
23
- return this;
24
- }
25
- /**
26
- * Authenticate an user.
27
- * @param user user to log
28
- * @param password provided password
29
- * @param cb callback function
30
- */
31
- public authenticate(user: string, password: string, cb: AuthCallback): void {
32
- /**
33
- * This code is just an example for demostration purpose
34
- if (this.foo) {
35
- cb(null, ['group-foo', 'group-bar']);
36
- } else {
37
- cb(getInternalError("error, try again"), false);
38
- }
39
- */
40
- }
41
-
42
- /**
43
- * Triggered on each access request
44
- * @param user
45
- * @param pkg
46
- * @param cb
47
- */
48
- public allow_access(user: RemoteUser, pkg: PackageAccess, cb: AuthAccessCallback): void {
49
- /**
50
- * This code is just an example for demostration purpose
51
- if (user.name === this.foo && pkg?.access?.includes[user.name]) {
52
- this.logger.debug({name: user.name}, 'your package has been granted for @{name}');
53
- cb(null, true)
54
- } else {
55
- this.logger.error({name: user.name}, '@{name} is not allowed to access this package');
56
- cb(getInternalError("error, try again"), false);
57
- }
58
- */
59
- }
60
-
61
- /**
62
- * Triggered on each publish request
63
- * @param user
64
- * @param pkg
65
- * @param cb
66
- */
67
- public allow_publish(user: RemoteUser, pkg: PackageAccess, cb: AuthAccessCallback): void {
68
- /**
69
- * This code is just an example for demostration purpose
70
- if (user.name === this.foo && pkg?.access?.includes[user.name]) {
71
- this.logger.debug({name: user.name}, '@{name} has been granted to publish');
72
- cb(null, true)
73
- } else {
74
- this.logger.error({name: user.name}, '@{name} is not allowed to publish this package');
75
- cb(getInternalError("error, try again"), false);
76
- }
77
- */
78
- }
79
-
80
- public allow_unpublish(user: RemoteUser, pkg: PackageAccess, cb: AuthAccessCallback): void {
81
- /**
82
- * This code is just an example for demostration purpose
83
- if (user.name === this.foo && pkg?.access?.includes[user.name]) {
84
- this.logger.debug({name: user.name}, '@{name} has been granted to unpublish');
85
- cb(null, true)
86
- } else {
87
- this.logger.error({name: user.name}, '@{name} is not allowed to publish this package');
88
- cb(getInternalError("error, try again"), false);
89
- }
90
- */
91
- }
92
- }
5
+ export default AuthPlugin;
@@ -1,4 +1,4 @@
1
- import { Config } from '@verdaccio/types';
1
+ import {Config} from '@verdaccio/types';
2
2
 
3
3
  export interface CustomConfig extends Config {
4
4
  foo: string;