generator-verdaccio-plugin 6.1.0 → 7.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.
- package/README.md +107 -13
- package/generators/app/index.js +24 -29
- package/generators/app/templates/auth/_package.json +3 -3
- package/generators/app/templates/filter/_package.json +2 -2
- package/generators/app/templates/filter/src/filter-plugin.ts +9 -5
- package/generators/app/templates/filter/src/index.ts +1 -1
- package/generators/app/templates/middleware/_package.json +2 -2
- package/generators/app/templates/storage/_package.json +2 -2
- package/package.json +26 -18
package/README.md
CHANGED
|
@@ -5,33 +5,127 @@
|
|
|
5
5
|
[](https://opencollective.com/verdaccio)
|
|
6
6
|
[](http://chat.verdaccio.org/)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
A [Yeoman](http://yeoman.io) generator that scaffolds [Verdaccio](https://verdaccio.org) plugins with TypeScript and a ready-to-use project structure — so you can focus on writing plugin logic instead of boilerplate.
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Requirements
|
|
11
|
+
|
|
12
|
+
- [Node.js](https://nodejs.org/) >= 20
|
|
13
|
+
- [Yeoman](http://yeoman.io) (`yo`)
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
## Installation
|
|
13
16
|
|
|
14
17
|
```bash
|
|
15
|
-
npm install -g yo
|
|
16
|
-
npm install -g generator-verdaccio-plugin
|
|
18
|
+
npm install -g yo generator-verdaccio-plugin
|
|
17
19
|
```
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
## Quick Start
|
|
20
22
|
|
|
21
23
|
```bash
|
|
22
24
|
yo verdaccio-plugin
|
|
23
25
|
```
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
The generator walks you through a short set of prompts and creates a `verdaccio-<name>/` directory with everything you need.
|
|
28
|
+
|
|
29
|
+
## Interactive Prompts
|
|
30
|
+
|
|
31
|
+
| Prompt | Description |
|
|
32
|
+
| --------------------- | --------------------------------------------------------------------------- |
|
|
33
|
+
| Plugin type | `auth`, `storage`, `middleware`, or `filter` (see below) |
|
|
34
|
+
| Plugin name | Suffix after `verdaccio-` — e.g. `my-plugin` produces `verdaccio-my-plugin` |
|
|
35
|
+
| Description | Short description added to `package.json` |
|
|
36
|
+
| GitHub username / org | Populates the `repository` field in `package.json` |
|
|
37
|
+
| Author name & email | Stored locally and reused in future runs |
|
|
38
|
+
| Keywords | Comma-separated; `verdaccio` is always appended automatically |
|
|
39
|
+
|
|
40
|
+
## Plugin Types
|
|
41
|
+
|
|
42
|
+
| Type | Implements | Use when you want to… |
|
|
43
|
+
| ------------ | ----------------------------------------------- | ----------------------------------------------------------------- |
|
|
44
|
+
| `auth` | `authenticate`, `allow_access`, `allow_publish` | Control who can log in and access packages |
|
|
45
|
+
| `storage` | Custom storage backend | Store packages somewhere other than the local filesystem |
|
|
46
|
+
| `middleware` | Express middleware | Add custom HTTP routes or request/response processing |
|
|
47
|
+
| `filter` | `filter_metadata` | Transform or filter package metadata before it reaches the client |
|
|
48
|
+
|
|
49
|
+
### Registering your plugin in `verdaccio.yaml`
|
|
50
|
+
|
|
51
|
+
**Auth**
|
|
52
|
+
|
|
53
|
+
```yaml
|
|
54
|
+
auth:
|
|
55
|
+
verdaccio-my-plugin:
|
|
56
|
+
# your custom config
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Storage**
|
|
60
|
+
|
|
61
|
+
```yaml
|
|
62
|
+
store:
|
|
63
|
+
verdaccio-my-plugin:
|
|
64
|
+
# your custom config
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Middleware**
|
|
68
|
+
|
|
69
|
+
```yaml
|
|
70
|
+
middlewares:
|
|
71
|
+
verdaccio-my-plugin:
|
|
72
|
+
enabled: true
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Filter**
|
|
76
|
+
|
|
77
|
+
```yaml
|
|
78
|
+
filters:
|
|
79
|
+
verdaccio-my-plugin:
|
|
80
|
+
# your custom config
|
|
81
|
+
```
|
|
26
82
|
|
|
27
|
-
|
|
28
|
-
- Storage
|
|
29
|
-
- Middleware
|
|
83
|
+
## Generated Project Structure
|
|
30
84
|
|
|
31
|
-
|
|
85
|
+
```
|
|
86
|
+
verdaccio-<name>/
|
|
87
|
+
├── src/
|
|
88
|
+
│ ├── index.ts # Re-exports the plugin class
|
|
89
|
+
│ └── *-plugin.ts # Main plugin implementation
|
|
90
|
+
├── types/
|
|
91
|
+
│ └── index.d.ts # Custom configuration types
|
|
92
|
+
├── .editorconfig
|
|
93
|
+
├── .gitignore
|
|
94
|
+
├── .npmignore
|
|
95
|
+
├── .nvmrc
|
|
96
|
+
├── package.json
|
|
97
|
+
├── README.md
|
|
98
|
+
└── tsconfig.json
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
After scaffolding, build the plugin and link it for local testing:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
cd verdaccio-<name>
|
|
105
|
+
npm install
|
|
106
|
+
npm run build
|
|
107
|
+
npm link
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Then add the plugin name to your `verdaccio.yaml` and run Verdaccio.
|
|
111
|
+
|
|
112
|
+
## Contributing
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# Install dependencies
|
|
116
|
+
pnpm install
|
|
117
|
+
|
|
118
|
+
# Build the generator
|
|
119
|
+
pnpm build
|
|
120
|
+
|
|
121
|
+
# Run tests
|
|
122
|
+
pnpm test
|
|
123
|
+
|
|
124
|
+
# Run tests with coverage
|
|
125
|
+
pnpm test:coverage
|
|
126
|
+
```
|
|
32
127
|
|
|
33
|
-
|
|
34
|
-
- [Juan Picado](https://github.com/juanpicado)
|
|
128
|
+
See the [Verdaccio contributing guide](https://github.com/verdaccio/verdaccio/blob/master/CONTRIBUTING.md) for broader contribution guidelines.
|
|
35
129
|
|
|
36
130
|
## License
|
|
37
131
|
|
package/generators/app/index.js
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 {
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import _ from 'lodash';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
import Generator from 'yeoman-generator';
|
|
5
|
+
import yosay from 'yosay';
|
|
6
|
+
import rootPackageJSON from '../../package.json' with { type: 'json' };
|
|
7
|
+
export default class PluginGenerator extends Generator {
|
|
13
8
|
props = {};
|
|
14
9
|
projectName = 'verdaccio-';
|
|
15
10
|
destinationPathName = '';
|
|
@@ -17,7 +12,7 @@ class PluginGenerator extends yeoman_generator_1.default {
|
|
|
17
12
|
super(args, opts);
|
|
18
13
|
}
|
|
19
14
|
async prompting() {
|
|
20
|
-
this.log((
|
|
15
|
+
this.log(yosay(`Welcome to ${chalk.red('generator-verdaccio-plugin')} plugin generator!`));
|
|
21
16
|
const answers = await this.prompt([
|
|
22
17
|
{
|
|
23
18
|
type: 'list',
|
|
@@ -74,7 +69,7 @@ class PluginGenerator extends yeoman_generator_1.default {
|
|
|
74
69
|
type: 'input',
|
|
75
70
|
name: 'keywords',
|
|
76
71
|
message: 'Type your keywords (comma separated)',
|
|
77
|
-
filter: (keywords) =>
|
|
72
|
+
filter: (keywords) => _.uniq(_.words(keywords).concat(['verdaccio'])),
|
|
78
73
|
},
|
|
79
74
|
]);
|
|
80
75
|
this.props = {
|
|
@@ -82,7 +77,7 @@ class PluginGenerator extends yeoman_generator_1.default {
|
|
|
82
77
|
license: 'MIT',
|
|
83
78
|
};
|
|
84
79
|
this.projectName = `verdaccio-${answers.name}`;
|
|
85
|
-
this.destinationPathName =
|
|
80
|
+
this.destinationPathName = resolve(this.projectName);
|
|
86
81
|
this.props.name = this.projectName;
|
|
87
82
|
if (answers.githubUsername) {
|
|
88
83
|
this.props.repository = `${answers.githubUsername}/${answers.name}`;
|
|
@@ -96,28 +91,29 @@ class PluginGenerator extends yeoman_generator_1.default {
|
|
|
96
91
|
}
|
|
97
92
|
const pkg = this.fs.readJSON(this.templatePath(`${pluginType}/_package.json`));
|
|
98
93
|
// devDependencies
|
|
99
|
-
pkg.devDependencies['@types/node'] =
|
|
100
|
-
pkg.devDependencies['@types/express'] =
|
|
101
|
-
pkg.devDependencies['@types/debug'] =
|
|
102
|
-
pkg.devDependencies['typescript'] =
|
|
103
|
-
pkg.devDependencies['@verdaccio/types'] =
|
|
94
|
+
pkg.devDependencies['@types/node'] = rootPackageJSON.devDependencies['@types/node'];
|
|
95
|
+
pkg.devDependencies['@types/express'] = rootPackageJSON.devDependencies['@types/express'];
|
|
96
|
+
pkg.devDependencies['@types/debug'] = rootPackageJSON.devDependencies['@types/debug'];
|
|
97
|
+
pkg.devDependencies['typescript'] = rootPackageJSON.devDependencies['typescript'];
|
|
98
|
+
pkg.devDependencies['@verdaccio/types'] = rootPackageJSON.devDependencies['@verdaccio/types'];
|
|
104
99
|
// required by verdaccio types
|
|
105
|
-
pkg.devDependencies['@types/jsonwebtoken'] =
|
|
100
|
+
pkg.devDependencies['@types/jsonwebtoken'] =
|
|
101
|
+
rootPackageJSON.devDependencies['@types/jsonwebtoken'];
|
|
106
102
|
// dependencies
|
|
107
|
-
pkg.dependencies['@verdaccio/core'] =
|
|
108
|
-
pkg.dependencies['@verdaccio/config'] =
|
|
109
|
-
pkg.dependencies['debug'] =
|
|
103
|
+
pkg.dependencies['@verdaccio/core'] = rootPackageJSON.dependencies['@verdaccio/core'];
|
|
104
|
+
pkg.dependencies['@verdaccio/config'] = rootPackageJSON.dependencies['@verdaccio/config'];
|
|
105
|
+
pkg.dependencies['debug'] = rootPackageJSON.dependencies['debug'];
|
|
110
106
|
if (pluginType === 'auth') {
|
|
111
|
-
pkg.devDependencies['@verdaccio/auth'] =
|
|
107
|
+
pkg.devDependencies['@verdaccio/auth'] = rootPackageJSON.devDependencies['@verdaccio/auth'];
|
|
112
108
|
}
|
|
113
109
|
else if (pluginType === 'middleware') {
|
|
114
|
-
pkg.dependencies['express'] =
|
|
110
|
+
pkg.dependencies['express'] = rootPackageJSON.dependencies['express'];
|
|
115
111
|
}
|
|
116
112
|
this.fs.writeJSON(this.templatePath(`${pluginType}/_package.json`), pkg);
|
|
117
|
-
this.fs.copyTpl(this.templatePath(`${pluginType}/_package.json`), this.destinationPath(
|
|
113
|
+
this.fs.copyTpl(this.templatePath(`${pluginType}/_package.json`), this.destinationPath(resolve(this.destinationPathName, 'package.json')), this.props);
|
|
118
114
|
}
|
|
119
115
|
writing() {
|
|
120
|
-
const dest = (path) => this.destinationPath(
|
|
116
|
+
const dest = (path) => this.destinationPath(resolve(this.destinationPathName, path));
|
|
121
117
|
this.fs.copy(this.templatePath('common/gitignore'), dest('.gitignore'));
|
|
122
118
|
this.fs.copy(this.templatePath('common/npmignore'), dest('.npmignore'));
|
|
123
119
|
this.fs.copy(this.templatePath('common/nvmrc'), dest('.nvmrc'));
|
|
@@ -132,4 +128,3 @@ class PluginGenerator extends yeoman_generator_1.default {
|
|
|
132
128
|
this.destinationRoot(this.projectName);
|
|
133
129
|
}
|
|
134
130
|
}
|
|
135
|
-
exports.default = PluginGenerator;
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"debug": "4.4.3"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@types/node": "25.0.
|
|
17
|
-
"@types/express": "4.17.
|
|
16
|
+
"@types/node": "25.0.9",
|
|
17
|
+
"@types/express": "4.17.25",
|
|
18
18
|
"@types/debug": "4.1.12",
|
|
19
19
|
"typescript": "5.9.3",
|
|
20
20
|
"@verdaccio/types": "13.0.0-next-8.10",
|
|
21
21
|
"@types/jsonwebtoken": "9.0.10",
|
|
22
|
-
"@verdaccio/auth": "8.0.0-next-8.
|
|
22
|
+
"@verdaccio/auth": "8.0.0-next-8.29"
|
|
23
23
|
},
|
|
24
24
|
"keywords": [
|
|
25
25
|
"<%= keywords %>]"
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"debug": "4.4.3"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@types/node": "25.0.
|
|
17
|
-
"@types/express": "4.17.
|
|
16
|
+
"@types/node": "25.0.9",
|
|
17
|
+
"@types/express": "4.17.25",
|
|
18
18
|
"@types/debug": "4.1.12",
|
|
19
19
|
"typescript": "5.9.3",
|
|
20
20
|
"@verdaccio/types": "13.0.0-next-8.10",
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { Config, Logger, Manifest } from '@verdaccio/types';
|
|
2
|
-
|
|
3
1
|
import debugCore from 'debug';
|
|
4
|
-
const debug = debugCore('verdaccio:plugin:filter');
|
|
5
2
|
|
|
6
|
-
import { CustomConfig } from '../types';
|
|
7
3
|
import { pluginUtils } from '@verdaccio/core';
|
|
4
|
+
import { Config, Logger, Manifest } from '@verdaccio/types';
|
|
5
|
+
|
|
6
|
+
import { CustomConfig } from '../types';
|
|
7
|
+
|
|
8
|
+
const debug = debugCore('verdaccio:plugin:filter');
|
|
8
9
|
|
|
9
|
-
export default class FilterPlugin
|
|
10
|
+
export default class FilterPlugin
|
|
11
|
+
extends pluginUtils.Plugin<CustomConfig>
|
|
12
|
+
implements pluginUtils.ManifestFilter<CustomConfig>
|
|
13
|
+
{
|
|
10
14
|
private _logger: Logger;
|
|
11
15
|
private _config: {};
|
|
12
16
|
private _app_config: Config;
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"debug": "4.4.3"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@types/node": "25.0.
|
|
17
|
-
"@types/express": "4.17.
|
|
16
|
+
"@types/node": "25.0.9",
|
|
17
|
+
"@types/express": "4.17.25",
|
|
18
18
|
"@types/debug": "4.1.12",
|
|
19
19
|
"typescript": "5.9.3",
|
|
20
20
|
"@verdaccio/types": "13.0.0-next-8.10",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"debug": "4.4.3"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@types/node": "25.0.
|
|
18
|
-
"@types/express": "4.17.
|
|
17
|
+
"@types/node": "25.0.9",
|
|
18
|
+
"@types/express": "4.17.25",
|
|
19
19
|
"@types/debug": "4.1.12",
|
|
20
20
|
"typescript": "5.9.3",
|
|
21
21
|
"@verdaccio/types": "13.0.0-next-8.10",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "generator-verdaccio-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "plugin generator for verdaccio",
|
|
5
5
|
"homepage": "https://github.com/verdaccio",
|
|
6
6
|
"author": {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"email": "juanpicado19@gmail.com",
|
|
9
9
|
"url": "https://github.com/verdaccio/generator-verdaccio-plugin"
|
|
10
10
|
},
|
|
11
|
+
"type": "module",
|
|
11
12
|
"files": [
|
|
12
13
|
"generators"
|
|
13
14
|
],
|
|
@@ -20,32 +21,35 @@
|
|
|
20
21
|
"@verdaccio/core": "6.0.0-6-next.76",
|
|
21
22
|
"chalk": "4.1.2",
|
|
22
23
|
"debug": "4.4.3",
|
|
23
|
-
"lodash": "4.17.
|
|
24
|
+
"lodash": "4.17.23",
|
|
24
25
|
"yeoman-environment": "5.1.2",
|
|
25
26
|
"yeoman-generator": "7.5.1",
|
|
26
|
-
"yosay": "
|
|
27
|
+
"yosay": "3.0.0"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
|
-
"@changesets/changelog-github": "0.
|
|
30
|
-
"@changesets/cli": "2.
|
|
30
|
+
"@changesets/changelog-github": "0.5.2",
|
|
31
|
+
"@changesets/cli": "2.29.8",
|
|
31
32
|
"@changesets/get-dependents-graph": "1.3.5",
|
|
32
|
-
"@trivago/prettier-plugin-sort-imports": "4.
|
|
33
|
-
"@types/chalk": "2.2.
|
|
33
|
+
"@trivago/prettier-plugin-sort-imports": "4.3.0",
|
|
34
|
+
"@types/chalk": "2.2.4",
|
|
34
35
|
"@types/debug": "4.1.12",
|
|
35
|
-
"@types/express": "4.17.
|
|
36
|
+
"@types/express": "4.17.25",
|
|
36
37
|
"@types/jsonwebtoken": "9.0.10",
|
|
37
38
|
"@types/lodash": "4.14.195",
|
|
38
|
-
"@types/mocha": "10.0.
|
|
39
|
-
"@types/node": "25.0.
|
|
40
|
-
"@verdaccio/auth": "8.0.0-next-8.
|
|
41
|
-
"@verdaccio/eslint-config": "
|
|
39
|
+
"@types/mocha": "10.0.10",
|
|
40
|
+
"@types/node": "25.0.9",
|
|
41
|
+
"@verdaccio/auth": "8.0.0-next-8.29",
|
|
42
|
+
"@verdaccio/eslint-config": "12.0.0",
|
|
42
43
|
"@verdaccio/types": "13.0.0-next-8.10",
|
|
43
|
-
"@vitest/coverage-v8": "4.0.
|
|
44
|
-
"eslint": "
|
|
45
|
-
"express": "4.
|
|
46
|
-
"prettier": "3.
|
|
44
|
+
"@vitest/coverage-v8": "4.0.18",
|
|
45
|
+
"eslint": "10.0.2",
|
|
46
|
+
"express": "4.22.1",
|
|
47
|
+
"prettier": "3.8.1",
|
|
48
|
+
"typedoc": "0.28.17",
|
|
49
|
+
"typedoc-plugin-markdown": "4.10.0",
|
|
47
50
|
"typescript": "5.9.3",
|
|
48
|
-
"
|
|
51
|
+
"vitepress": "1.6.4",
|
|
52
|
+
"vitest": "4.0.18",
|
|
49
53
|
"yeoman-test": "11.2.0"
|
|
50
54
|
},
|
|
51
55
|
"engines": {
|
|
@@ -69,6 +73,10 @@
|
|
|
69
73
|
"ci:version:changeset": "changeset version",
|
|
70
74
|
"ci:version": "npm run ci:version:changeset && npm run ci:version:install",
|
|
71
75
|
"ci:version:install": "pnpm install --frozen-lockfile=false",
|
|
72
|
-
"ci:publish": "changeset publish"
|
|
76
|
+
"ci:publish": "changeset publish",
|
|
77
|
+
"docs:api": "typedoc",
|
|
78
|
+
"docs:dev": "pnpm docs:api && vitepress dev docs",
|
|
79
|
+
"docs:build": "pnpm docs:api && vitepress build docs",
|
|
80
|
+
"docs:preview": "vitepress preview docs"
|
|
73
81
|
}
|
|
74
82
|
}
|