Skip to content

Commit

Permalink
feat: migrate yeoman generator to monorepo (#4683)
Browse files Browse the repository at this point in the history
* feat: migrate geoman generator

* Create README.md
  • Loading branch information
juanpicado committed Jun 15, 2024
1 parent 117eb1c commit a528af4
Show file tree
Hide file tree
Showing 34 changed files with 3,302 additions and 349 deletions.
5 changes: 5 additions & 0 deletions .changeset/nervous-fireants-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'generator-verdaccio-plugin': major
---

feat: migration to monorepo
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ packages/plugins/ui-theme/static
# CI Pnpm cache
.pnpm-store/

#docs
#docs
website/docs/api/**/*.md
website/docs/api/**/*.yml
!website/docs/api/index.md
Expand All @@ -53,3 +53,6 @@ e2e/ui/cypress/screenshots/**/*

# storybook
packages/ui-components/storybook-static

# plugin generator
packages/tools/generator-verdaccio-plugin/generators/
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
"@types/http-errors": "2.0.4",
"@types/jest": "29.5.11",
"@types/jsonwebtoken": "9.0.5",
"@types/yeoman-environment": "2.10.11",
"@types/yeoman-generator": "5.2.14",
"@types/yeoman-test": "4.0.6",
"@types/lodash": "4.14.202",
"@types/mime": "3.0.4",
"@types/minimatch": "5.1.2",
Expand Down Expand Up @@ -127,7 +130,7 @@
"verdaccio-auth-memory": "workspace:*",
"verdaccio-htpasswd": "workspace:*",
"verdaccio-memory": "workspace:*",
"vitest": "0.34.6"
"vitest": "1.6.0"
},
"scripts": {
"prepare": "husky install",
Expand Down
3 changes: 3 additions & 0 deletions packages/tools/generator-verdaccio-plugin/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../../.babelrc"
}
41 changes: 41 additions & 0 deletions packages/tools/generator-verdaccio-plugin/README.md
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 packages/tools/generator-verdaccio-plugin/helpers/constants.js
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;
3 changes: 3 additions & 0 deletions packages/tools/generator-verdaccio-plugin/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const config = require('../../../jest/config');

module.exports = Object.assign({}, config, {});
49 changes: 49 additions & 0 deletions packages/tools/generator-verdaccio-plugin/package.json
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 packages/tools/generator-verdaccio-plugin/src/app/index.ts
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;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"@typescript-eslint/no-unused-vars": 0
}
}
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}\""
}
}

0 comments on commit a528af4

Please sign in to comment.