generator-verdaccio-plugin 6.0.0-next-8.28 → 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.
- package/LICENSE +6 -6
- package/README.md +6 -76
- package/generators/app/index.d.ts +11 -0
- package/generators/app/index.js +131 -122
- package/generators/app/templates/auth/_package.json +3 -16
- package/generators/app/templates/auth/src/auth-plugin.ts +102 -0
- package/generators/app/templates/auth/src/index.ts +3 -90
- package/generators/app/templates/auth/types/index.ts +1 -1
- package/generators/app/templates/common/_package.json +26 -0
- package/generators/app/templates/common/npmignore +1 -1
- package/generators/app/templates/common/nvmrc +1 -0
- package/generators/app/templates/middleware/_package.json +3 -17
- package/generators/app/templates/middleware/src/index.ts +3 -40
- package/generators/app/templates/middleware/src/middleware-plugin.ts +40 -0
- package/generators/app/templates/middleware/types/index.ts +1 -1
- package/generators/app/templates/storage/_package.json +3 -15
- package/generators/app/templates/storage/src/index.ts +5 -1
- package/generators/app/templates/storage/src/storage-plugin.ts +70 -0
- package/generators/app/templates/storage/types/index.ts +1 -1
- package/package.json +50 -26
- package/generators/app/index.js.map +0 -1
- package/generators/app/templates/common/eslintignore +0 -2
- package/generators/app/templates/common/eslintrc +0 -12
- package/generators/app/templates/common/index.js +0 -15
- package/generators/app/templates/common/jest.config.js +0 -4
- package/generators/app/templates/storage/src/PackageStorage.ts +0 -175
- package/generators/app/templates/storage/src/plugin.ts +0 -134
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "<%= name %>",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "<%= description %>",
|
|
5
|
+
"main": "lib/src/index.js",
|
|
6
|
+
"types": "lib/src/index.d.ts",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=18"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@verdaccio/core": "10.2.0",
|
|
12
|
+
"@verdaccio/streams": "10.2.0"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@types/express": "4.17.13",
|
|
16
|
+
"@verdaccio/types": "13.0.0-next-8.10",
|
|
17
|
+
"typescript": "4.7.4"
|
|
18
|
+
},
|
|
19
|
+
"keywords": ["<%= keywords %>"],
|
|
20
|
+
"license": "<%= license %>",
|
|
21
|
+
"repository": "<%= repository %>",
|
|
22
|
+
"author": "<%= authorName %> <<%= authorEmail %>>",
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
src/
|
|
2
|
-
.
|
|
2
|
+
tsconfig.json
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
lts/iron
|
|
@@ -7,28 +7,14 @@
|
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=18"
|
|
9
9
|
},
|
|
10
|
-
"dependencies": {
|
|
11
|
-
|
|
12
|
-
"express": "4.18.1"
|
|
13
|
-
},
|
|
14
|
-
"devDependencies": {
|
|
15
|
-
"@types/jest": "27.5.1",
|
|
16
|
-
"@types/node": "12.12.5",
|
|
17
|
-
"@types/express": "4.17.13",
|
|
18
|
-
"@typescript-eslint/eslint-plugin": "5.26.0",
|
|
19
|
-
"@typescript-eslint/parser": "5.26.0",
|
|
20
|
-
"@verdaccio/types": "10.5.2",
|
|
21
|
-
"eslint": "8.21.0",
|
|
22
|
-
"jest": "28.1.3",
|
|
23
|
-
"typescript": "4.7.4"
|
|
24
|
-
},
|
|
10
|
+
"dependencies": {},
|
|
11
|
+
"devDependencies": {},
|
|
25
12
|
"keywords": ["<%= keywords %>"],
|
|
26
13
|
"license": "<%= license %>",
|
|
27
14
|
"repository": "<%= repository %>",
|
|
28
15
|
"author": "<%= authorName %> <<%= authorEmail %>>",
|
|
29
16
|
"scripts": {
|
|
30
17
|
"build": "tsc",
|
|
31
|
-
"test": "
|
|
32
|
-
"lint": "eslint \"**/*.{js,ts}\""
|
|
18
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
33
19
|
}
|
|
34
20
|
}
|
|
@@ -1,42 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import MiddlewarePlugin from './middleware-plugin';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
IBasicAuth,
|
|
5
|
-
IPluginMiddleware,
|
|
6
|
-
IStorageManager,
|
|
7
|
-
Logger,
|
|
8
|
-
PluginOptions,
|
|
9
|
-
} from '@verdaccio/types';
|
|
3
|
+
export {MiddlewarePlugin};
|
|
10
4
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export default class VerdaccioMiddlewarePlugin implements IPluginMiddleware<CustomConfig> {
|
|
14
|
-
public logger: Logger;
|
|
15
|
-
public foo: string;
|
|
16
|
-
public constructor(config: CustomConfig, options: PluginOptions<CustomConfig>) {
|
|
17
|
-
this.foo = config.foo !== undefined ? config.strict_ssl : true;
|
|
18
|
-
this.logger = options.logger;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
public register_middlewares(
|
|
22
|
-
app: Application,
|
|
23
|
-
auth: IBasicAuth<CustomConfig>,
|
|
24
|
-
/* eslint @typescript-eslint/no-unused-vars: off */
|
|
25
|
-
_storage: IStorageManager<CustomConfig>
|
|
26
|
-
): void {
|
|
27
|
-
/**
|
|
28
|
-
* This is just an example of implementation
|
|
29
|
-
// eslint new-cap:off
|
|
30
|
-
const router = Router();
|
|
31
|
-
router.post(
|
|
32
|
-
'/custom-endpoint',
|
|
33
|
-
(req: Request, res: Response & { report_error?: Function }, next: NextFunction): void => {
|
|
34
|
-
const encryptedString = auth.aesEncrypt(Buffer.from(this.foo, 'utf8'));
|
|
35
|
-
res.setHeader('X-Verdaccio-Token-Plugin', encryptedString.toString());
|
|
36
|
-
next();
|
|
37
|
-
}
|
|
38
|
-
);
|
|
39
|
-
app.use('/-/npm/something-new', router);
|
|
40
|
-
*/
|
|
41
|
-
}
|
|
42
|
-
}
|
|
5
|
+
export default MiddlewarePlugin;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
import express, {type Express, type Request, type Response} from 'express';
|
|
3
|
+
|
|
4
|
+
import type {Auth} from '@verdaccio/auth';
|
|
5
|
+
import {pluginUtils} from '@verdaccio/core';
|
|
6
|
+
import {Logger} from '@verdaccio/types';
|
|
7
|
+
|
|
8
|
+
import {CustomConfig} from '../types';
|
|
9
|
+
|
|
10
|
+
export default class ProxyAudit
|
|
11
|
+
extends pluginUtils.Plugin<CustomConfig>
|
|
12
|
+
implements pluginUtils.ExpressMiddleware<CustomConfig, {}, Auth> {
|
|
13
|
+
readonly logger: Logger;
|
|
14
|
+
public constructor(config: CustomConfig, options: pluginUtils.PluginOptions) {
|
|
15
|
+
super(config, options);
|
|
16
|
+
this.logger = options.logger;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// TODO: implement your middleware logic here
|
|
20
|
+
// TODO: implement your middleware logic here
|
|
21
|
+
// TODO: implement your middleware logic here
|
|
22
|
+
// TODO: implement your middleware logic here
|
|
23
|
+
public register_middlewares(app: Express, _auth: Auth): void {
|
|
24
|
+
/* eslint new-cap:off */
|
|
25
|
+
const router = express.Router();
|
|
26
|
+
/* eslint new-cap:off */
|
|
27
|
+
|
|
28
|
+
router.post('/custom-endpoint', express.json({limit: '10mb'}), (req, res, next) => {
|
|
29
|
+
this.logger.info({method: req.method, url: req.url}, 'middleware-demo: incoming request');
|
|
30
|
+
res.setHeader('x-verdaccio-middleware', 'demo');
|
|
31
|
+
next();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
app.use('/-/npm/v2/my-middleware-endpoint', router);
|
|
35
|
+
}
|
|
36
|
+
// TODO: implement your middleware logic here
|
|
37
|
+
// TODO: implement your middleware logic here
|
|
38
|
+
// TODO: implement your middleware logic here
|
|
39
|
+
// TODO: implement your middleware logic here
|
|
40
|
+
}
|
|
@@ -8,27 +8,15 @@
|
|
|
8
8
|
"node": ">=18"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@verdaccio/
|
|
12
|
-
"@verdaccio/streams": "10.2.0"
|
|
13
|
-
},
|
|
14
|
-
"devDependencies": {
|
|
15
|
-
"@types/jest": "27.5.1",
|
|
16
|
-
"@types/node": "12.12.5",
|
|
17
|
-
"@types/express": "4.17.13",
|
|
18
|
-
"@typescript-eslint/eslint-plugin": "5.32.0",
|
|
19
|
-
"@typescript-eslint/parser": "5.32.0",
|
|
20
|
-
"@verdaccio/types": "10.5.2",
|
|
21
|
-
"eslint": "8.21.0",
|
|
22
|
-
"jest": "28.1.3",
|
|
23
|
-
"typescript": "4.7.4"
|
|
11
|
+
"@verdaccio/streams": "10.2.1"
|
|
24
12
|
},
|
|
13
|
+
"devDependencies": {},
|
|
25
14
|
"keywords": ["<%= keywords %>"],
|
|
26
15
|
"license": "<%= license %>",
|
|
27
16
|
"repository": "<%= repository %>",
|
|
28
17
|
"author": "<%= authorName %> <<%= authorEmail %>>",
|
|
29
18
|
"scripts": {
|
|
30
19
|
"build": "tsc",
|
|
31
|
-
"test": "
|
|
32
|
-
"lint": "eslint \"**/*.{js,ts}\""
|
|
20
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
33
21
|
}
|
|
34
22
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
import debugCore from 'debug';
|
|
3
|
+
|
|
4
|
+
import {errorUtils, searchUtils} from '@verdaccio/core';
|
|
5
|
+
import {Callback, Config, Logger} from '@verdaccio/types';
|
|
6
|
+
|
|
7
|
+
// Initialize debug logging
|
|
8
|
+
// Replace 'custom-auth-plugin' with your plugin name
|
|
9
|
+
// This code is meant to help during development and debugging
|
|
10
|
+
const debug = debugCore('verdaccio:plugin:custom-storage-plugin');
|
|
11
|
+
|
|
12
|
+
class LocalDatabase {
|
|
13
|
+
public config: Config;
|
|
14
|
+
public logger: Logger;
|
|
15
|
+
|
|
16
|
+
public constructor(config: Config, logger: Logger) {
|
|
17
|
+
this.config = config;
|
|
18
|
+
this.logger = logger;
|
|
19
|
+
debug('LocalDatabase config: %o', this.config);
|
|
20
|
+
debug('Logger instance: %o', this.logger);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public getSecret(): Promise<string> {
|
|
24
|
+
debug('Getting secret');
|
|
25
|
+
return Promise.reject(errorUtils.getServiceUnavailable());
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public setSecret(_secret: string): Promise<Error | null> {
|
|
29
|
+
debug('Setting secret');
|
|
30
|
+
return Promise.resolve(errorUtils.getServiceUnavailable());
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public add(_name: string, cb: Callback): void {
|
|
34
|
+
debug('Adding package: %o', _name);
|
|
35
|
+
cb(errorUtils.getServiceUnavailable());
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public async filterByQuery(
|
|
39
|
+
_results: searchUtils.SearchItemPkg[],
|
|
40
|
+
_query: searchUtils.SearchQuery,
|
|
41
|
+
): Promise<searchUtils.SearchItemPkg[]> {
|
|
42
|
+
throw errorUtils.getServiceUnavailable();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public async getScore(_pkg: searchUtils.SearchItemPkg): Promise<searchUtils.Score> {
|
|
46
|
+
throw errorUtils.getServiceUnavailable();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public async search(_query: searchUtils.SearchQuery): Promise<searchUtils.SearchItem[]> {
|
|
50
|
+
throw errorUtils.getServiceUnavailable();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public remove(_name: string, cb: Callback): void {
|
|
54
|
+
cb(errorUtils.getServiceUnavailable());
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public get(cb: Callback): void {
|
|
58
|
+
cb(errorUtils.getServiceUnavailable());
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public getPackageStorage(_packageName: string) {
|
|
62
|
+
throw errorUtils.getServiceUnavailable();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public clean(): void {
|
|
66
|
+
throw errorUtils.getServiceUnavailable();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default LocalDatabase;
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "generator-verdaccio-plugin",
|
|
3
|
-
"version": "6.0.0
|
|
4
|
-
"description": "
|
|
5
|
-
"homepage": "https://verdaccio
|
|
3
|
+
"version": "6.0.0",
|
|
4
|
+
"description": "plugin generator for verdaccio",
|
|
5
|
+
"homepage": "https://github.com/verdaccio",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Juan Picado <@jotadeveloper>",
|
|
8
8
|
"email": "juanpicado19@gmail.com",
|
|
@@ -16,43 +16,67 @@
|
|
|
16
16
|
"yeoman-generator"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@verdaccio/config": "
|
|
20
|
-
"@verdaccio/core": "
|
|
19
|
+
"@verdaccio/config": "6.0.0-6-next.76",
|
|
20
|
+
"@verdaccio/core": "6.0.0-6-next.76",
|
|
21
21
|
"chalk": "4.1.2",
|
|
22
|
+
"debug": "4.4.3",
|
|
22
23
|
"lodash": "4.17.21",
|
|
23
|
-
"yeoman-environment": "
|
|
24
|
-
"yeoman-generator": "5.
|
|
24
|
+
"yeoman-environment": "5.1.2",
|
|
25
|
+
"yeoman-generator": "7.5.1",
|
|
25
26
|
"yosay": "2.0.2"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
|
-
"@
|
|
29
|
+
"@changesets/changelog-github": "0.4.8",
|
|
30
|
+
"@changesets/cli": "2.26.1",
|
|
31
|
+
"@changesets/get-dependents-graph": "1.3.5",
|
|
32
|
+
"@trivago/prettier-plugin-sort-imports": "4.2.0",
|
|
33
|
+
"@types/chalk": "2.2.0",
|
|
34
|
+
"@types/debug": "4.1.12",
|
|
35
|
+
"@types/express": "4.17.13",
|
|
36
|
+
"@types/jsonwebtoken": "9.0.10",
|
|
37
|
+
"@types/lodash": "4.14.195",
|
|
38
|
+
"@types/mocha": "10.0.1",
|
|
39
|
+
"@types/node": "25.0.3",
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "6.21.0",
|
|
41
|
+
"@typescript-eslint/parser": "6.21.0",
|
|
42
|
+
"@verdaccio/auth": "8.0.0-next-8.28",
|
|
29
43
|
"@verdaccio/types": "13.0.0-next-8.10",
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
44
|
+
"@vitest/coverage-v8": "4.0.16",
|
|
45
|
+
"eslint": "8.57.1",
|
|
46
|
+
"eslint-config-google": "0.14.0",
|
|
47
|
+
"eslint-config-prettier": "10.1.8",
|
|
48
|
+
"eslint-plugin-babel": "5.3.1",
|
|
49
|
+
"eslint-plugin-import": "2.32.0",
|
|
50
|
+
"eslint-plugin-prettier": "5.5.4",
|
|
51
|
+
"eslint-plugin-simple-import-sort": "12.1.1",
|
|
52
|
+
"eslint-plugin-vitest-globals": "1.5.0",
|
|
53
|
+
"express": "4.18.2",
|
|
54
|
+
"prettier": "3.4.2",
|
|
55
|
+
"typescript": "5.9.3",
|
|
56
|
+
"vitest": "4.0.16",
|
|
57
|
+
"yeoman-test": "11.2.0"
|
|
33
58
|
},
|
|
34
59
|
"engines": {
|
|
35
|
-
"node": ">=
|
|
60
|
+
"node": ">=20"
|
|
36
61
|
},
|
|
37
62
|
"repository": {
|
|
38
|
-
"type": "
|
|
39
|
-
"url": "
|
|
40
|
-
"directory": "packages/tools/generator-verdaccio-plugin"
|
|
41
|
-
},
|
|
42
|
-
"bugs": {
|
|
43
|
-
"url": "https://github.com/verdaccio/verdaccio/issues"
|
|
63
|
+
"type": "git",
|
|
64
|
+
"url": "git://github.com/verdaccio/generator-verdaccio-plugin"
|
|
44
65
|
},
|
|
45
66
|
"license": "MIT",
|
|
46
|
-
"funding": {
|
|
47
|
-
"type": "opencollective",
|
|
48
|
-
"url": "https://opencollective.com/verdaccio"
|
|
49
|
-
},
|
|
50
67
|
"scripts": {
|
|
68
|
+
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,yml,yaml,md}\"",
|
|
69
|
+
"format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,json,yml,yaml,md}\"",
|
|
70
|
+
"release": "standard-version -a -s",
|
|
51
71
|
"type-check": "tsc --noEmit -p tsconfig.build.json",
|
|
52
72
|
"build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
|
|
53
|
-
"build": "
|
|
54
|
-
"test": "
|
|
55
|
-
"test:
|
|
56
|
-
"lint": "eslint --max-warnings
|
|
73
|
+
"build": "rm -Rf ./generators && tsc && cp -R ./src/app/templates generators/app/",
|
|
74
|
+
"test": "pnpm build && vitest run",
|
|
75
|
+
"test:coverage": "pnpm build && vitest run --coverage",
|
|
76
|
+
"lint": "eslint --max-warnings 10 \"**/*.ts\" --fix",
|
|
77
|
+
"ci:version:changeset": "changeset version",
|
|
78
|
+
"ci:version": "npm run ci:version:changeset && npm run ci:version:install",
|
|
79
|
+
"ci:version:install": "pnpm install --frozen-lockfile=false",
|
|
80
|
+
"ci:publish": "changeset publish"
|
|
57
81
|
}
|
|
58
82
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_chalk","_interopRequireDefault","require","_lodash","_nodePath","_yeomanGenerator","_yosay","e","__esModule","default","PluginGenerator","Generator","projectName","destinationPathName","constructor","args","opts","props","prompting","log","yosay","chalk","red","prompts","type","name","message","store","choices","value","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","_default","exports"],"sources":["../../src/app/index.ts"],"sourcesContent":["import chalk from 'chalk';\nimport _ from 'lodash';\nimport { resolve } from 'node:path';\nimport Generator from 'yeoman-generator';\nimport yosay from 'yosay';\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\nclass PluginGenerator 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(yosay(`Welcome to ${chalk.red('generator-verdaccio-plugin')} plugin generator!`));\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: [{ value: 'auth' }, { value: 'storage' }, { value: 'middleware' }],\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 = `${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(`common/gitignore`),\n this.destinationPath(resolve(this.destinationPathName, '.gitignore'))\n );\n this.fs.copy(\n this.templatePath(`common/npmignore`),\n this.destinationPath(resolve(this.destinationPathName, '.npmignore'))\n );\n this.fs.copy(\n this.templatePath(`common/jest.config.js`),\n this.destinationPath(resolve(this.destinationPathName, 'jest.config.js'))\n );\n this.fs.copyTpl(\n this.templatePath(`common/README.md`),\n this.destinationPath(resolve(this.destinationPathName, 'README.md')),\n this.props\n );\n this.fs.copyTpl(\n this.templatePath(`common/eslintrc`),\n this.destinationPath(resolve(this.destinationPathName, '.eslintrc')),\n this.props\n );\n this.fs.copyTpl(\n this.templatePath(`common/eslintignore`),\n this.destinationPath(resolve(this.destinationPathName, '.eslintignore')),\n this.props\n );\n\n this.fs.copy(\n this.templatePath(`${this.props.pluginType}/src`),\n this.destinationPath(resolve(this.destinationPathName, 'src'))\n );\n\n this.fs.copy(\n this.templatePath(`common/index.js`),\n this.destinationPath(resolve(this.destinationPathName, `index.js`))\n );\n\n this.fs.copy(\n this.templatePath(`common/tsconfig.json`),\n this.destinationPath(resolve(this.destinationPathName, 'tsconfig.json'))\n );\n this.fs.copy(\n this.templatePath(`${this.props.pluginType}/types`),\n this.destinationPath(resolve(this.destinationPathName, 'types'))\n );\n\n this.fs.copy(\n this.templatePath(`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\nexport default PluginGenerator;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,SAAA,GAA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IAAI,CACV,IAAI,CAACH,YAAY,CAAC,qBAAqB,CAAC,EACxC,IAAI,CAACC,eAAe,CAAC,IAAAR,iBAAO,EAAC,IAAI,CAAChC,mBAAmB,EAAE,eAAe,CAAC,CACzE,CAAC;EACH;EAEA2C,OAAOA,CAAA,EAAG;IACRC,OAAO,CAACC,KAAK,CAAC,IAAI,CAAC9C,WAAW,CAAC;IAC/B;EACF;AACF;AAAC,IAAA+C,QAAA,GAAAC,OAAA,CAAAnD,OAAA,GAEcC,eAAe","ignoreList":[]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true,
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
let _index = _interopRequireDefault(require('./lib/index'));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) {
|
|
11
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
let _default = _index.default;
|
|
15
|
-
exports.default = _default;
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { getConflict, getInternalError, getNotFound } from '@verdaccio/commons-api';
|
|
2
|
-
import { ReadTarball, UploadTarball } from '@verdaccio/streams';
|
|
3
|
-
import {
|
|
4
|
-
Callback,
|
|
5
|
-
CallbackAction,
|
|
6
|
-
ILocalPackageManager,
|
|
7
|
-
Logger,
|
|
8
|
-
Package,
|
|
9
|
-
PackageTransformer,
|
|
10
|
-
ReadPackageCallback,
|
|
11
|
-
StorageUpdateCallback,
|
|
12
|
-
StorageWriteCallback,
|
|
13
|
-
} from '@verdaccio/types';
|
|
14
|
-
|
|
15
|
-
import { CustomConfig } from '../types/index';
|
|
16
|
-
|
|
17
|
-
export default class StoragePluginManage implements ILocalPackageManager {
|
|
18
|
-
public logger: Logger;
|
|
19
|
-
public packageName: string;
|
|
20
|
-
public config: CustomConfig;
|
|
21
|
-
|
|
22
|
-
public constructor(config: CustomConfig, packageName: string, logger: Logger) {
|
|
23
|
-
this.logger = logger;
|
|
24
|
-
this.packageName = packageName;
|
|
25
|
-
this.config = config;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Handle a metadata update and
|
|
30
|
-
* @param name
|
|
31
|
-
* @param updateHandler
|
|
32
|
-
* @param onWrite
|
|
33
|
-
* @param transformPackage
|
|
34
|
-
* @param onEnd
|
|
35
|
-
*/
|
|
36
|
-
public updatePackage(
|
|
37
|
-
name: string,
|
|
38
|
-
updateHandler: StorageUpdateCallback,
|
|
39
|
-
onWrite: StorageWriteCallback,
|
|
40
|
-
transformPackage: PackageTransformer,
|
|
41
|
-
onEnd: CallbackAction
|
|
42
|
-
): void {
|
|
43
|
-
/**
|
|
44
|
-
* Example of implementation:
|
|
45
|
-
this.customStore.get().then((pkg: Package) => {
|
|
46
|
-
updateHandler(pkg, function onUpdateFinish(err) {
|
|
47
|
-
if (err) {
|
|
48
|
-
onEnd(err);
|
|
49
|
-
} else {
|
|
50
|
-
onWrite(name, pkg, onEnd);
|
|
51
|
-
}
|
|
52
|
-
})
|
|
53
|
-
});
|
|
54
|
-
*/
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Delete a specific file (tarball or package.json)
|
|
59
|
-
* @param fileName
|
|
60
|
-
* @param callback
|
|
61
|
-
*/
|
|
62
|
-
public deletePackage(fileName: string, callback: CallbackAction): void {
|
|
63
|
-
/**
|
|
64
|
-
* Example of implementation:
|
|
65
|
-
this.customStore.delete(fileName, (err) => {
|
|
66
|
-
if (err) {
|
|
67
|
-
callback(err);
|
|
68
|
-
} else {
|
|
69
|
-
callback(null);
|
|
70
|
-
}
|
|
71
|
-
})
|
|
72
|
-
*/
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Delete a package (folder, path)
|
|
77
|
-
* This happens after all versions ar tarballs have been removed.
|
|
78
|
-
* @param callback
|
|
79
|
-
*/
|
|
80
|
-
public removePackage(callback: CallbackAction): void {
|
|
81
|
-
/**
|
|
82
|
-
* Example of implementation:
|
|
83
|
-
this.customStore.removePackage((err) => {
|
|
84
|
-
if (err) {
|
|
85
|
-
callback(err);
|
|
86
|
-
} else {
|
|
87
|
-
callback(null);
|
|
88
|
-
}
|
|
89
|
-
})
|
|
90
|
-
*/
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Publish a new package (version).
|
|
95
|
-
* @param name
|
|
96
|
-
* @param data
|
|
97
|
-
* @param callback
|
|
98
|
-
*/
|
|
99
|
-
public createPackage(name: string, data: Package, callback: CallbackAction): void {
|
|
100
|
-
/**
|
|
101
|
-
* Example of implementation:
|
|
102
|
-
* this.customStore.create(name, data).then(err => {
|
|
103
|
-
if (err.notFound) {
|
|
104
|
-
callback(getNotFound());
|
|
105
|
-
} else if (err.alreadyExist) {
|
|
106
|
-
callback(getConflict());
|
|
107
|
-
} else {
|
|
108
|
-
callback(null);
|
|
109
|
-
}
|
|
110
|
-
})
|
|
111
|
-
*/
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Perform write anobject to the storage.
|
|
116
|
-
* Similar to updatePackage but without middleware handlers
|
|
117
|
-
* @param pkgName package name
|
|
118
|
-
* @param pkg package metadata
|
|
119
|
-
* @param callback
|
|
120
|
-
*/
|
|
121
|
-
public savePackage(pkgName: string, pkg: Package, callback: CallbackAction): void {
|
|
122
|
-
/*
|
|
123
|
-
Example of implementation:
|
|
124
|
-
this.cumstomStore.write(pkgName, pkgName).then(data => {
|
|
125
|
-
callback(null);
|
|
126
|
-
}).catch(err => {
|
|
127
|
-
callback(getInternalError(err.message));
|
|
128
|
-
})
|
|
129
|
-
*/
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Read a package from storage
|
|
134
|
-
* @param pkgName package name
|
|
135
|
-
* @param callback
|
|
136
|
-
*/
|
|
137
|
-
public readPackage(pkgName: string, callback: ReadPackageCallback): void {
|
|
138
|
-
/**
|
|
139
|
-
* Example of implementation:
|
|
140
|
-
* this.customStorage.read(name, (err, pkg: Package) => {
|
|
141
|
-
if (err.fooError) {
|
|
142
|
-
callback(getInternalError(err))
|
|
143
|
-
} else if (err.barError) {
|
|
144
|
-
callback(getNotFound());
|
|
145
|
-
} else {
|
|
146
|
-
callback(null, pkg)
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
*/
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Create writtable stream (write a tarball)
|
|
154
|
-
* @param name
|
|
155
|
-
*/
|
|
156
|
-
public writeTarball(name: string): UploadTarball {
|
|
157
|
-
/**
|
|
158
|
-
* Example of implementation:
|
|
159
|
-
* const stream = new UploadTarball({});
|
|
160
|
-
return stream;
|
|
161
|
-
*/
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Create a readable stream (read a from a tarball)
|
|
166
|
-
* @param name
|
|
167
|
-
*/
|
|
168
|
-
public readTarball(name: string): ReadTarball {
|
|
169
|
-
/**
|
|
170
|
-
* Example of implementation:
|
|
171
|
-
* const stream = new ReadTarball({});
|
|
172
|
-
return stream;
|
|
173
|
-
*/
|
|
174
|
-
}
|
|
175
|
-
}
|