generator-verdaccio-plugin 3.0.1 → 4.0.0-next.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 (73) hide show
  1. package/README.md +1 -1
  2. package/build/app/index.js +133 -0
  3. package/build/app/index.js.map +1 -0
  4. package/build/app/templates/typescript/auth/_package.json +34 -0
  5. package/{generators/app/templates/typescript/auth/src/index.ts → build/app/templates/typescript/auth/src/index.js} +21 -20
  6. package/build/app/templates/typescript/auth/src/index.js.map +1 -0
  7. package/build/app/templates/typescript/auth/types/index.js +6 -0
  8. package/build/app/templates/typescript/auth/types/index.js.map +1 -0
  9. package/{generators/app/templates/javascript → build/app/templates/typescript}/common/README.md +0 -0
  10. package/{generators/app/templates/javascript → build/app/templates/typescript}/common/editorconfig +0 -0
  11. package/{generators/app/templates/javascript → build/app/templates/typescript}/common/eslintignore +0 -0
  12. package/build/app/templates/typescript/common/eslintrc +12 -0
  13. package/{generators/app/templates/javascript → build/app/templates/typescript}/common/gitignore +0 -0
  14. package/build/app/templates/typescript/common/index.js +14 -0
  15. package/build/app/templates/typescript/common/index.js.map +1 -0
  16. package/build/app/templates/typescript/common/jest.config.js +4 -0
  17. package/{generators/app/templates/javascript → build/app/templates/typescript}/common/npmignore +1 -2
  18. package/{generators → build}/app/templates/typescript/common/tsconfig.json +2 -1
  19. package/build/app/templates/typescript/middleware/_package.json +35 -0
  20. package/build/app/templates/typescript/middleware/src/index.js +36 -0
  21. package/build/app/templates/typescript/middleware/src/index.js.map +1 -0
  22. package/build/app/templates/typescript/middleware/types/index.js +6 -0
  23. package/build/app/templates/typescript/middleware/types/index.js.map +1 -0
  24. package/build/app/templates/typescript/storage/_package.json +35 -0
  25. package/{generators/app/templates/javascript → build/app/templates/typescript}/storage/src/PackageStorage.js +35 -20
  26. package/build/app/templates/typescript/storage/src/PackageStorage.js.map +1 -0
  27. package/build/app/templates/typescript/storage/src/index.js +16 -0
  28. package/build/app/templates/typescript/storage/src/index.js.map +1 -0
  29. package/{generators/app/templates/javascript → build/app/templates/typescript}/storage/src/plugin.js +41 -18
  30. package/build/app/templates/typescript/storage/src/plugin.js.map +1 -0
  31. package/build/app/templates/typescript/storage/types/index.js +6 -0
  32. package/build/app/templates/typescript/storage/types/index.js.map +1 -0
  33. package/package.json +81 -39
  34. package/CHANGELOG.md +0 -106
  35. package/generators/app/index.d.ts +0 -11
  36. package/generators/app/index.js +0 -134
  37. package/generators/app/index.ts +0 -215
  38. package/generators/app/templates/.eslintrc +0 -5
  39. package/generators/app/templates/javascript/.eslintrc +0 -5
  40. package/generators/app/templates/javascript/auth/_package.json +0 -33
  41. package/generators/app/templates/javascript/auth/src/index.js +0 -35
  42. package/generators/app/templates/javascript/common/babelrc +0 -3
  43. package/generators/app/templates/javascript/common/eslintrc +0 -3
  44. package/generators/app/templates/javascript/common/index.js +0 -1
  45. package/generators/app/templates/javascript/common/jest.config.js +0 -10
  46. package/generators/app/templates/javascript/common/travis.yml +0 -6
  47. package/generators/app/templates/javascript/middleware/_package.json +0 -34
  48. package/generators/app/templates/javascript/middleware/src/index.js +0 -8
  49. package/generators/app/templates/javascript/storage/_package.json +0 -33
  50. package/generators/app/templates/javascript/storage/src/index.js +0 -1
  51. package/generators/app/templates/typescript/auth/_package.json +0 -40
  52. package/generators/app/templates/typescript/auth/types/index.ts +0 -5
  53. package/generators/app/templates/typescript/common/README.md +0 -22
  54. package/generators/app/templates/typescript/common/babelrc +0 -3
  55. package/generators/app/templates/typescript/common/editorconfig +0 -12
  56. package/generators/app/templates/typescript/common/eslintignore +0 -2
  57. package/generators/app/templates/typescript/common/eslintrc +0 -3
  58. package/generators/app/templates/typescript/common/gitignore +0 -3
  59. package/generators/app/templates/typescript/common/index.ts +0 -3
  60. package/generators/app/templates/typescript/common/jest.config.js +0 -10
  61. package/generators/app/templates/typescript/common/npmignore +0 -4
  62. package/generators/app/templates/typescript/common/travis.yml +0 -6
  63. package/generators/app/templates/typescript/middleware/_package.json +0 -41
  64. package/generators/app/templates/typescript/middleware/src/index.ts +0 -35
  65. package/generators/app/templates/typescript/middleware/types/index.ts +0 -5
  66. package/generators/app/templates/typescript/storage/_package.json +0 -40
  67. package/generators/app/templates/typescript/storage/src/PackageStorage.ts +0 -183
  68. package/generators/app/templates/typescript/storage/src/index.ts +0 -1
  69. package/generators/app/templates/typescript/storage/src/plugin.ts +0 -140
  70. package/generators/app/templates/typescript/storage/types/index.ts +0 -5
  71. package/generators/app/types.d.ts +0 -10
  72. package/generators/app/types.js +0 -2
  73. package/generators/app/types.ts +0 -10
@@ -1,6 +0,0 @@
1
- language: node_js
2
- node_js:
3
- - "8"
4
- - "10"
5
- sudo: false
6
- script: npm install . && npm run test
@@ -1,41 +0,0 @@
1
- {
2
- "name": "<%= name %>",
3
- "version": "0.0.1",
4
- "description": "<%= description %>",
5
- "main": "lib/index.js",
6
- "types": "lib/index.d.ts",
7
- "files": ["lib/"],
8
- "engines": {
9
- "node": ">=10"
10
- },
11
- "dependencies": {
12
- "@verdaccio/commons-api": "^9.6.1",
13
- "express": "^4.17.1"
14
- },
15
- "devDependencies": {
16
- "@types/jest": "^24.0.21",
17
- "@types/node": "^12.12.5",
18
- "@types/express": "^4.17.1",
19
- "@typescript-eslint/eslint-plugin": "^2.12.0",
20
- "@verdaccio/babel-preset": "^9.6.1",
21
- "@verdaccio/eslint-config": "^9.3.2",
22
- "@verdaccio/types": "^9.5.0",
23
- "eslint": "^6.6.0",
24
- "jest": "^26.0.1 ",
25
- "prettier": "^1.19.1",
26
- "standard-version": "^8.0.0",
27
- "typescript": "^3.9.5"
28
- },
29
- "keywords": ["<%= keywords %>"],
30
- "license": "<%= license %>",
31
- "repository": "<%= repository %>",
32
- "author": "<%= authorName %> <<%= authorEmail %>>",
33
- "scripts": {
34
- "release": "standard-version -a -s",
35
- "build": "npm run build:types && npm run build:js",
36
- "build:js": "babel src/ --out-dir lib --extensions \".ts,.tsx\"",
37
- "build:types": "tsc --emitDeclarationOnly",
38
- "test": "jest",
39
- "lint": "eslint \"**/*.{js,ts}\""
40
- }
41
- }
@@ -1,35 +0,0 @@
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
- }
@@ -1,5 +0,0 @@
1
- import { Config } from '@verdaccio/types';
2
-
3
- export interface CustomConfig extends Config {
4
- foo: string;
5
- }
@@ -1,40 +0,0 @@
1
- {
2
- "name": "<%= name %>",
3
- "version": "0.0.1",
4
- "description": "<%= description %>",
5
- "main": "lib/index.js",
6
- "types": "lib/index.d.ts",
7
- "files": ["lib/"],
8
- "engines": {
9
- "node": ">=10"
10
- },
11
- "dependencies": {
12
- "@verdaccio/commons-api": "^8.5.0",
13
- "@verdaccio/streams": "^9.6.1"
14
- },
15
- "devDependencies": {
16
- "@types/jest": "^24.0.21",
17
- "@types/node": "^12.12.5",
18
- "@types/express": "^4.17.1",
19
- "@typescript-eslint/eslint-plugin": "^2.12.0",
20
- "@verdaccio/babel-preset": "^9.6.1",
21
- "@verdaccio/eslint-config": "^9.3.2",
22
- "@verdaccio/types": "^9.5.0",
23
- "eslint": "^6.6.0",
24
- "jest": "^26.0.1 ",
25
- "prettier": "^1.19.1",
26
- "standard-version": "^8.0.0"
27
- },
28
- "keywords": ["<%= keywords %>"],
29
- "license": "<%= license %>",
30
- "repository": "<%= repository %>",
31
- "author": "<%= authorName %> <<%= authorEmail %>>",
32
- "scripts": {
33
- "release": "standard-version -a -s",
34
- "build": "npm run build:types && npm run build:js",
35
- "build:js": "babel src/ --out-dir lib --extensions \".ts,.tsx\"",
36
- "build:types": "tsc --emitDeclarationOnly",
37
- "test": "jest",
38
- "lint": "eslint \"**/*.{js,ts}\""
39
- }
40
- }
@@ -1,183 +0,0 @@
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
- ) {
26
- this.logger = logger;
27
- this.packageName = packageName;
28
- this.config = config;
29
- }
30
-
31
- /**
32
- * Handle a metadata update and
33
- * @param name
34
- * @param updateHandler
35
- * @param onWrite
36
- * @param transformPackage
37
- * @param onEnd
38
- */
39
- public updatePackage(
40
- name: string,
41
- updateHandler: StorageUpdateCallback,
42
- onWrite: StorageWriteCallback,
43
- transformPackage: PackageTransformer,
44
- onEnd: CallbackAction
45
- ): void {
46
- /**
47
- * Example of implementation:
48
- this.customStore.get().then((pkg: Package) => {
49
- updateHandler(pkg, function onUpdateFinish(err) {
50
- if (err) {
51
- onEnd(err);
52
- } else {
53
- onWrite(name, pkg, onEnd);
54
- }
55
- })
56
- });
57
- */
58
- }
59
-
60
- /**
61
- * Delete a specific file (tarball or package.json)
62
- * @param fileName
63
- * @param callback
64
- */
65
- public deletePackage(fileName: string, callback: CallbackAction): void {
66
- /**
67
- * Example of implementation:
68
- this.customStore.delete(fileName, (err) => {
69
- if (err) {
70
- callback(err);
71
- } else {
72
- callback(null);
73
- }
74
- })
75
- */
76
- }
77
-
78
- /**
79
- * Delete a package (folder, path)
80
- * This happens after all versions ar tarballs have been removed.
81
- * @param callback
82
- */
83
- public removePackage(callback: CallbackAction): void {
84
- /**
85
- * Example of implementation:
86
- this.customStore.removePackage((err) => {
87
- if (err) {
88
- callback(err);
89
- } else {
90
- callback(null);
91
- }
92
- })
93
- */
94
- }
95
-
96
- /**
97
- * Publish a new package (version).
98
- * @param name
99
- * @param data
100
- * @param callback
101
- */
102
- public createPackage(
103
- name: string,
104
- data: Package,
105
- callback: CallbackAction
106
- ): void {
107
- /**
108
- * Example of implementation:
109
- * this.customStore.create(name, data).then(err => {
110
- if (err.notFound) {
111
- callback(getNotFound());
112
- } else if (err.alreadyExist) {
113
- callback(getConflict());
114
- } else {
115
- callback(null);
116
- }
117
- })
118
- */
119
- }
120
-
121
- /**
122
- * Perform write anobject to the storage.
123
- * Similar to updatePackage but without middleware handlers
124
- * @param pkgName package name
125
- * @param pkg package metadata
126
- * @param callback
127
- */
128
- public savePackage(pkgName: string, pkg: Package, callback: CallbackAction): void {
129
- /*
130
- Example of implementation:
131
- this.cumstomStore.write(pkgName, pkgName).then(data => {
132
- callback(null);
133
- }).catch(err => {
134
- callback(getInternalError(err.message));
135
- })
136
- */
137
- }
138
-
139
- /**
140
- * Read a package from storage
141
- * @param pkgName package name
142
- * @param callback
143
- */
144
- public readPackage(pkgName: string, callback: ReadPackageCallback): void {
145
- /**
146
- * Example of implementation:
147
- * this.customStorage.read(name, (err, pkg: Package) => {
148
- if (err.fooError) {
149
- callback(getInternalError(err))
150
- } else if (err.barError) {
151
- callback(getNotFound());
152
- } else {
153
- callback(null, pkg)
154
- }
155
- });
156
- */
157
- }
158
-
159
- /**
160
- * Create writtable stream (write a tarball)
161
- * @param name
162
- */
163
- public writeTarball(name: string): UploadTarball {
164
- /**
165
- * Example of implementation:
166
- * const stream = new UploadTarball({});
167
- return stream;
168
- */
169
-
170
- }
171
-
172
- /**
173
- * Create a readable stream (read a from a tarball)
174
- * @param name
175
- */
176
- public readTarball(name: string): ReadTarball {
177
- /**
178
- * Example of implementation:
179
- * const stream = new ReadTarball({});
180
- return stream;
181
- */
182
- }
183
- }
@@ -1 +0,0 @@
1
- export { default } from './plugin';
@@ -1,140 +0,0 @@
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
- ) {
28
- this.config = config;
29
- this.logger = options.logger;
30
- }
31
-
32
- /**
33
- *
34
- */
35
- public async getSecret(): Promise<string> {
36
- /**
37
- * return await resolveSecret();
38
- */
39
- }
40
-
41
- public async setSecret(secret: string): Promise<any> {
42
- /**
43
- * return await getYourSecret();
44
- */
45
- }
46
-
47
- /**
48
- * Add a new element.
49
- * @param {*} name
50
- * @return {Error|*}
51
- */
52
- public add(name: string, callback: Callback): void {
53
-
54
- }
55
-
56
- /**
57
- * Perform a search in your registry
58
- * @param onPackage
59
- * @param onEnd
60
- * @param validateName
61
- */
62
- public search(
63
- onPackage: onSearchPackage,
64
- onEnd: onEndSearchPackage,
65
- validateName: onValidatePackage
66
- ): void {
67
- /**
68
- * Example of implementation:
69
- * try {
70
- * someApi.getPackages((items) => {
71
- * items.map(() => {
72
- * if (validateName(item.name)) {
73
- * onPackage(item);
74
- * }
75
- * });
76
- * onEnd();
77
- * } catch(err) {
78
- * onEnd(err);
79
- * }
80
- * });
81
- */
82
- }
83
-
84
- /**
85
- * Remove an element from the database.
86
- * @param {*} name
87
- * @return {Error|*}
88
- */
89
- public remove(name: string, callback: Callback): void {
90
- /**
91
- * Example of implementation
92
- database.getPackage(name, (item, err) => {
93
- if (err) {
94
- callback(getInternalError('your own message here'));
95
- }
96
-
97
- // if all goes well we return nothing
98
- callback(null);
99
- }
100
- */
101
- }
102
-
103
- /**
104
- * Return all database elements.
105
- * @return {Array}
106
- */
107
- public get(callback: Callback): void {
108
- /*
109
- Example of implementation
110
- database.getAll((allItems, err) => {
111
- callback(err, allItems);
112
- })
113
- */
114
- }
115
-
116
- /**
117
- * Create an instance of the `PackageStorage`
118
- * @param packageInfo
119
- */
120
- public getPackageStorage(packageInfo: string): IPackageStorage {
121
- return new PackageStorage(this.config, packageInfo, this.logger);
122
- }
123
-
124
- /**
125
- * All methods for npm token support
126
- * more info here https://github.com/verdaccio/verdaccio/pull/1427
127
- */
128
-
129
- public saveToken(token: Token): Promise<any> {
130
- throw new Error('Method not implemented.');
131
- }
132
-
133
- public deleteToken(user: string, tokenKey: string): Promise<any> {
134
- throw new Error('Method not implemented.');
135
- }
136
-
137
- public readTokens(filter: TokenFilter): Promise<Token[]> {
138
- throw new Error('Method not implemented.');
139
- }
140
- }
@@ -1,5 +0,0 @@
1
- import { Config } from '@verdaccio/types';
2
-
3
- export interface CustomConfig extends Config {
4
- foo: string;
5
- }
@@ -1,10 +0,0 @@
1
- export declare type propsTypes = {
2
- name?: string;
3
- pluginType?: string;
4
- description?: string;
5
- githubUsername?: string;
6
- authorName?: string;
7
- authorEmail?: string;
8
- keywords?: Array<string>;
9
- lang?: string;
10
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,10 +0,0 @@
1
- export type propsTypes = {
2
- name?: string;
3
- pluginType?: string;
4
- description?: string;
5
- githubUsername?: string;
6
- authorName?: string;
7
- authorEmail?: string;
8
- keywords?: Array<string>;
9
- lang?: string;
10
- };