-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: migrate yeoman generator to monorepo (#4683)
* feat: migrate geoman generator * Create README.md
- Loading branch information
1 parent
117eb1c
commit a528af4
Showing
34 changed files
with
3,302 additions
and
349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'generator-verdaccio-plugin': major | ||
--- | ||
|
||
feat: migration to monorepo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "../../../.babelrc" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Plugin Generator | ||
|
||
[![verdaccio (latest)](https://img.shields.io/npm/v/generator-verdaccio-plugin/latest.svg)](https://www.npmjs.com/package/generator-verdaccio-plugin) | ||
[![verdaccio (downloads)](https://img.shields.io/npm/dy/generator-verdaccio-plugin.svg)](https://www.npmjs.com/package/generator-verdaccio-plugin) | ||
[![docker pulls](https://img.shields.io/docker/pulls/verdaccio/verdaccio.svg?maxAge=43200)](https://verdaccio.org/docs/en/docker.html) | ||
[![Backers](https://opencollective.com/verdaccio/tiers/backer/badge.svg?label=Backer&color=brightgreen)](https://opencollective.com/verdaccio) | ||
[![Stackshare](https://img.shields.io/badge/Follow%20on-StackShare-blue.svg?logo=stackshare&style=flat)](https://stackshare.io/verdaccio) | ||
[![Discord](https://img.shields.io/discord/388674437219745793?logo=discord)](http://chat.verdaccio.org/) | ||
[![Twitter followers](https://img.shields.io/twitter/follow/verdaccio_npm.svg?style=social&label=Follow)](https://twitter.com/verdaccio_npm) | ||
|
||
Verdaccio plugin generator based in [Yeoman](http://yeoman.io) aims to help to scaffold plugins development | ||
|
||
## Installation | ||
|
||
First, install [Yeoman](http://yeoman.io) and generator-verdaccio-plugin using [npm](https://www.npmjs.com/) (we assume you have pre-installed [node.js](https://nodejs.org/)). | ||
|
||
```bash | ||
npm install -g yo | ||
npm install -g generator-verdaccio-plugin | ||
``` | ||
|
||
Then generate your new project: | ||
|
||
```bash | ||
yo verdaccio-plugin | ||
``` | ||
|
||
## Plugin Types Supported | ||
|
||
- Authentication | ||
- Storage | ||
- Middleware | ||
|
||
### Maintainers | ||
|
||
- [Anix](https://github.com/anikethsaha) | ||
- [Juan Picado](https://github.com/juanpicado) | ||
|
||
## License | ||
|
||
MIT © [Juan Picado <@jotadeveloper>]() |
11 changes: 11 additions & 0 deletions
11
packages/tools/generator-verdaccio-plugin/helpers/constants.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const defaultConfigFiles = [ | ||
'jest.config.js', | ||
'.editorconfig', | ||
'.gitignore', | ||
'package.json', | ||
'README.md', | ||
'.eslintrc', | ||
'.npmignore', | ||
]; | ||
|
||
module.exports = defaultConfigFiles; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const config = require('../../../jest/config'); | ||
|
||
module.exports = Object.assign({}, config, {}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"name": "generator-verdaccio-plugin", | ||
"version": "4.1.0", | ||
"description": "plugin generator for verdaccio", | ||
"homepage": "https://github.com/verdaccio", | ||
"author": { | ||
"name": "Juan Picado <@jotadeveloper>", | ||
"email": "juanpicado19@gmail.com", | ||
"url": "https://github.com/verdaccio/generator-verdaccio-plugin" | ||
}, | ||
"files": [ | ||
"generators" | ||
], | ||
"keywords": [ | ||
"verdaccio-plugin", | ||
"yeoman-generator" | ||
], | ||
"dependencies": { | ||
"chalk": "4.1.2", | ||
"lodash": "4.17.21", | ||
"yeoman-environment": "3.19.3", | ||
"yeoman-generator": "5.9.0", | ||
"yosay": "2.0.2", | ||
"@verdaccio/core": "workspace:7.0.0-next-7.16", | ||
"@verdaccio/config": "workspace:7.0.0-next-7.16" | ||
}, | ||
"devDependencies": { | ||
"@verdaccio/test-helper": "workspace:3.0.0-next-7.2", | ||
"@verdaccio/types": "workspace:12.0.0-next-7.3", | ||
"ts-jest": "29.1.0", | ||
"yeoman-assert": "3.1.1", | ||
"yeoman-test": "6.3.0" | ||
}, | ||
"engines": { | ||
"node": ">18.0.0" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/verdaccio/generator-verdaccio-plugin" | ||
}, | ||
"scripts": { | ||
"type-check": "tsc --noEmit -p tsconfig.build.json", | ||
"build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json", | ||
"build": "babel src/ --out-dir generators/ --copy-files --extensions \".ts,.tsx\" --source-maps --ignore src/app/templates", | ||
"test": "vitest run --pool=forks", | ||
"lint": "eslint --max-warnings 0 \"**/*.{js,ts}\"" | ||
}, | ||
"license": "MIT" | ||
} |
179 changes: 179 additions & 0 deletions
179
packages/tools/generator-verdaccio-plugin/src/app/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
import chalk from 'chalk'; | ||
import _ from 'lodash'; | ||
import { resolve } from 'path'; | ||
import Generator from 'yeoman-generator'; | ||
import yosay from 'yosay'; | ||
|
||
type propsTypes = { | ||
name?: string; | ||
pluginType?: string; | ||
description?: string; | ||
githubUsername?: string; | ||
authorName?: string; | ||
authorEmail?: string; | ||
keywords?: string[]; | ||
}; | ||
|
||
class PluginGenerator extends Generator { | ||
private props: propsTypes; | ||
private projectName = 'verdaccio-'; | ||
private destinationPathName = 'verdaccio-'; | ||
constructor(args, opts) { | ||
super(args, opts); | ||
this.props = {}; | ||
} | ||
|
||
prompting() { | ||
this.log(yosay(`Welcome to ${chalk.red('generator-verdaccio-plugin')} plugin generator!`)); | ||
|
||
const prompts = [ | ||
{ | ||
type: 'list', | ||
name: 'pluginType', | ||
require: true, | ||
message: 'What kind of plugin you want to create?', | ||
store: true, | ||
choices: [{ value: 'auth' }, { value: 'storage' }, { value: 'middleware' }], | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'name', | ||
require: true, | ||
message: `What's the plugin name? The prefix (verdaccio-xxx) will be added automatically`, | ||
default: 'customname', | ||
validate: function (input: string) { | ||
if (input.startsWith('verdaccio-')) { | ||
return false; | ||
} else if (input === '') { | ||
return false; | ||
} | ||
return true; | ||
}, | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'description', | ||
message: 'Please, describe your plugin', | ||
default: 'An amazing verdaccio plugin', | ||
}, | ||
{ | ||
name: 'githubUsername', | ||
message: 'GitHub username or Organization', | ||
validate: function (input) { | ||
return input !== ''; | ||
}, | ||
}, | ||
{ | ||
name: 'authorName', | ||
message: "Author's Name", | ||
store: true, | ||
}, | ||
{ | ||
name: 'authorEmail', | ||
message: "Author's Email", | ||
store: true, | ||
}, | ||
{ | ||
name: 'keywords', | ||
message: 'Key your keywords (comma to split)', | ||
filter: function (keywords) { | ||
return _.uniq(_.words(keywords).concat(['verdaccio-'])); | ||
}, | ||
}, | ||
]; | ||
|
||
return this.prompt(prompts).then( | ||
function (_props) { | ||
// To access props later use this.props.someAnswer; | ||
// @ts-ignore | ||
this.props = _props; | ||
const { name, githubUsername } = _props; | ||
// @ts-ignore | ||
this.props.license = 'MIT'; | ||
if (githubUsername) { | ||
// @ts-ignore | ||
this.props.repository = githubUsername + '/' + name; | ||
} | ||
|
||
// @ts-ignore | ||
this.projectName = `verdaccio-${name}`; | ||
|
||
// @ts-ignore | ||
this.destinationPathName = resolve(this.projectName); | ||
// @ts-ignore | ||
this.props.name = this.projectName; | ||
}.bind(this) | ||
); | ||
} | ||
|
||
packageJSON() { | ||
const { pluginType } = this.props; | ||
const pkgJsonLocation = `${pluginType}/_package.json`; | ||
this.fs.copyTpl( | ||
this.templatePath(pkgJsonLocation), | ||
this.destinationPath(resolve(this.destinationPathName, 'package.json')), | ||
this.props | ||
); | ||
} | ||
|
||
writing() { | ||
this.fs.copy( | ||
this.templatePath(`common/gitignore`), | ||
this.destinationPath(resolve(this.destinationPathName, '.gitignore')) | ||
); | ||
this.fs.copy( | ||
this.templatePath(`common/npmignore`), | ||
this.destinationPath(resolve(this.destinationPathName, '.npmignore')) | ||
); | ||
this.fs.copy( | ||
this.templatePath(`common/jest.config.js`), | ||
this.destinationPath(resolve(this.destinationPathName, 'jest.config.js')) | ||
); | ||
this.fs.copyTpl( | ||
this.templatePath(`common/README.md`), | ||
this.destinationPath(resolve(this.destinationPathName, 'README.md')), | ||
this.props | ||
); | ||
this.fs.copyTpl( | ||
this.templatePath(`common/eslintrc`), | ||
this.destinationPath(resolve(this.destinationPathName, '.eslintrc')), | ||
this.props | ||
); | ||
this.fs.copyTpl( | ||
this.templatePath(`common/eslintignore`), | ||
this.destinationPath(resolve(this.destinationPathName, '.eslintignore')), | ||
this.props | ||
); | ||
|
||
this.fs.copy( | ||
this.templatePath(`${this.props.pluginType}/src`), | ||
this.destinationPath(resolve(this.destinationPathName, 'src')) | ||
); | ||
|
||
this.fs.copy( | ||
this.templatePath(`common/index.js`), | ||
this.destinationPath(resolve(this.destinationPathName, `index.js`)) | ||
); | ||
|
||
this.fs.copy( | ||
this.templatePath(`common/tsconfig.json`), | ||
this.destinationPath(resolve(this.destinationPathName, 'tsconfig.json')) | ||
); | ||
this.fs.copy( | ||
this.templatePath(`${this.props.pluginType}/types`), | ||
this.destinationPath(resolve(this.destinationPathName, 'types')) | ||
); | ||
|
||
this.fs.copy( | ||
this.templatePath(`common/editorconfig`), | ||
this.destinationPath(resolve(this.destinationPathName, '.editorconfig')) | ||
); | ||
} | ||
|
||
install() { | ||
process.chdir(this.projectName); | ||
// this.installDependencies({ npm: true, bower: false }); | ||
} | ||
} | ||
|
||
export default PluginGenerator; |
5 changes: 5 additions & 0 deletions
5
packages/tools/generator-verdaccio-plugin/src/app/templates/.eslintrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"rules": { | ||
"@typescript-eslint/no-unused-vars": 0 | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
packages/tools/generator-verdaccio-plugin/src/app/templates/auth/_package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "<%= name %>", | ||
"version": "0.0.1", | ||
"description": "<%= description %>", | ||
"main": "lib/src/index.js", | ||
"types": "lib/src/index.d.ts", | ||
"engines": { | ||
"node": ">=12" | ||
}, | ||
"dependencies": { | ||
"@verdaccio/commons-api": "10.2.0" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "27.5.1", | ||
"@types/node": "12.12.5", | ||
"@types/express": "4.17.13", | ||
"@typescript-eslint/eslint-plugin": "5.26.0", | ||
"@typescript-eslint/parser": "5.26.0", | ||
"@verdaccio/types": "10.5.2", | ||
"eslint": "8.21.0", | ||
"jest": "28.1.3", | ||
"typescript": "4.7.4" | ||
}, | ||
"keywords": ["<%= keywords %>]"], | ||
"license": "<%= license %>", | ||
"repository": "<%= repository %>", | ||
"author": "<%= authorName %> <<%= authorEmail %>>", | ||
"scripts": { | ||
"build": "tsc", | ||
"test": "jest .", | ||
"lint": "eslint \"**/*.{js,ts}\"" | ||
} | ||
} |
Oops, something went wrong.