Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

Commit

Permalink
fix: issue on generate template (#15)
Browse files Browse the repository at this point in the history
* fix: issue on generate template

add other features
- best template for middleware
- add verdaccio core libraries

* chore: update lock file

* chore: add standard-version for release

* chore: remove file
  • Loading branch information
juanpicado authored Dec 22, 2019
1 parent 4efc367 commit 61eeae8
Show file tree
Hide file tree
Showing 27 changed files with 1,332 additions and 235 deletions.
32 changes: 32 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release

on:
push:
tags:
- '*'

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Use Node (latest)
uses: actions/setup-node@v1
with:
node_version: 12
- name: Install
run: yarn install --frozen-lockfile
- name: Lint
run: yarn lint
- name: Build
run: yarn build
- name: Publish
run: sh scripts/publish.sh
env:
REGISTRY_AUTH_TOKEN: ${{ secrets.REGISTRY_AUTH_TOKEN }}
REGISTRY_URL: registry.npmjs.org
- name: Create release notes
run: sh scripts/github-release.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
coverage
generators/app/*.js
yarn-error.log
yarn-error.log
.idea/*
11 changes: 11 additions & 0 deletions generators/app/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Generator from "yeoman-generator";
export default class VerdaccioPluginGenerator extends Generator {
private props;
private projectName;
private destinationPathName;
constructor(args: any, opts: any);
prompting(): Promise<void>;
packageJSON(): void;
writing(): void;
install(): void;
}
35 changes: 22 additions & 13 deletions generators/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { propsTypes } from "./types";
const yosay = require("yosay");

export default class VerdaccioPluginGenerator extends Generator {
private pkg: any;
private props: propsTypes;
private projectName: string = "verdaccio-plugin";
private destinationPathName: string = "verdaccio-plugin";
Expand Down Expand Up @@ -117,9 +116,10 @@ export default class VerdaccioPluginGenerator extends Generator {
}

packageJSON() {
const { lang } = this.props;
const { lang, pluginType } = this.props;
const pkgJsonLocation = `${lang}/${pluginType}/_package.json`;
this.fs.copyTpl(
this.templatePath(lang + "/common/_package.json"),
this.templatePath(pkgJsonLocation),
this.destinationPath(resolve(this.destinationPathName, "package.json")),
this.props
);
Expand All @@ -128,37 +128,41 @@ export default class VerdaccioPluginGenerator extends Generator {
writing() {
const { lang } = this.props;
this.fs.copy(
this.templatePath(lang + "/common/gitignore"),
this.templatePath(`${lang}/common/gitignore`),
this.destinationPath(resolve(this.destinationPathName, ".gitignore"))
);
this.fs.copy(
this.templatePath(lang + "/common/npmignore"),
this.templatePath(`${lang}/common/npmignore`),
this.destinationPath(resolve(this.destinationPathName, ".npmignore"))
);
this.fs.copy(
this.templatePath(lang + "/common/babelrc"),
this.templatePath(`${lang}/common/jest.config.js`),
this.destinationPath(resolve(this.destinationPathName, "jest.config.js"))
);
this.fs.copy(
this.templatePath(`${lang}/common/babelrc`),
this.destinationPath(resolve(this.destinationPathName, ".babelrc"))
);
this.fs.copy(
this.templatePath(lang + "/common/travis.yml"),
this.templatePath(`${lang}/common/travis.yml`),
this.destinationPath(resolve(this.destinationPathName, ".travis.yml"))
);
this.fs.copy(
this.templatePath(lang + "/common/travis.yml"),
this.templatePath(`${lang}/common/travis.yml`),
this.destinationPath(resolve(this.destinationPathName, ".travis.yml"))
);
this.fs.copyTpl(
this.templatePath(lang + "/common/README.md"),
this.templatePath(`${lang}/common/README.md`),
this.destinationPath(resolve(this.destinationPathName, "README.md")),
this.props
);
this.fs.copyTpl(
this.templatePath(lang + "/common/eslintrc"),
this.templatePath(`${lang}/common/eslintrc`),
this.destinationPath(resolve(this.destinationPathName, ".eslintrc")),
this.props
);
this.fs.copyTpl(
this.templatePath(lang + "/common/eslintignore"),
this.templatePath(`${lang}/common/eslintignore`),
this.destinationPath(resolve(this.destinationPathName, ".eslintignore")),
this.props
);
Expand All @@ -171,7 +175,7 @@ export default class VerdaccioPluginGenerator extends Generator {

this.fs.copy(
this.templatePath(
lang + `/common/index.${lang == "typescript" ? "ts" : "js"}`
`${lang}/common/index.${lang == "typescript" ? "ts" : "js"}`
),
this.destinationPath(
resolve(
Expand All @@ -190,10 +194,15 @@ export default class VerdaccioPluginGenerator extends Generator {
),
this.props
);
this.fs.copy(
this.templatePath(`${lang}/${this.props.pluginType}/types`),
this.destinationPath(resolve(this.destinationPathName, "types")),
this.props
);
}

this.fs.copy(
this.templatePath(lang + "/common/editorconfig"),
this.templatePath(`${lang}/common/editorconfig`),
this.destinationPath(resolve(this.destinationPathName, ".editorconfig")),
this.props
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@
"engines": {
"node": ">=10"
},
"dependencies": {
"@verdaccio/commons-api": "^8.4.2",
"express": "^4.17.1"
},
"devDependencies": {
"@babel/cli": "^7.7.0",
"@babel/core": "^7.7.2",
"@verdaccio/babel-preset": "^8.2.0",
"@verdaccio/types": "^8.3.0",
"@verdaccio/babel-preset": "^8.4.2",
"@verdaccio/eslint-config": "^8.4.2",
"@verdaccio/types": "^8.4.2",
"eslint": "^6.6.0",
"typescript": "^3.7.2"
"jest": "^24.9.0",
"prettier": "^1.19.1",
"standard-version": "^7.0.0"
},
"keywords": "[<%= keywords %>]",
"license": "<%= license %>",
Expand All @@ -24,8 +29,7 @@
"build": "npm run build:types && npm run build:js",
"build:js": "babel src/ --out-dir lib --extensions \".ts,.tsx\"",
"build:types": "tsc --emitDeclarationOnly",
"test": "npm run lint",
"lint": "eslint .",
"prepublish": "npm run lint && npm run build"
"test": "jest",
"lint": "eslint \"**/*.{js,ts}\""
}
}
25 changes: 0 additions & 25 deletions generators/app/templates/javascript/common/_package.json

This file was deleted.

2 changes: 1 addition & 1 deletion generators/app/templates/javascript/common/babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"presets": ["@verdaccio"]
"presets": ["@verdaccio", {typescript: false} ]
}
17 changes: 2 additions & 15 deletions generators/app/templates/javascript/common/eslintrc
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
{
"env": {
"es6": true,
"node": true,
"mocha": true
},

"parserOptions": {
"sourceType": "module"
},

"rules": {
"quotes": [2, "single"],
"no-underscore-dangle": [0]
}
}
"extends": ["@verdaccio"]
}
10 changes: 10 additions & 0 deletions generators/app/templates/javascript/common/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
name: 'verdaccio-<%= name %>',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
transform: {
'^.+\\.(js|jsx|ts|tsx)$': 'babel-jest',
},
verbose: true,
collectCoverage: true,
coveragePathIgnorePatterns: ['node_modules'],
};
35 changes: 35 additions & 0 deletions generators/app/templates/javascript/middleware/_package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "<%= name %>",
"version": "0.0.1",
"description": "<%= description %>",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"files": ["lib/"],
"engines": {
"node": ">=10"
},
"dependencies": {
"@verdaccio/commons-api": "^8.4.2",
"express": "^4.17.1"
},
"devDependencies": {
"@verdaccio/babel-preset": "^8.4.2",
"@verdaccio/eslint-config": "^8.4.2",
"@verdaccio/types": "^8.4.2",
"eslint": "^6.6.0",
"jest": "^24.9.0",
"prettier": "^1.19.1",
"standard-version": "^7.0.0"
},
"keywords": "[<%= keywords %>]",
"license": "<%= license %>",
"repository": "<%= repository %>",
"author": "<%= authorName %> <<%= authorEmail %>>",
"scripts": {
"build": "npm run build:types && npm run build:js",
"build:js": "babel src/ --out-dir lib --extensions \".ts,.tsx\"",
"build:types": "tsc --emitDeclarationOnly",
"test": "jest",
"lint": "eslint \"**/*.{js,ts}\""
}
}
35 changes: 35 additions & 0 deletions generators/app/templates/javascript/storage/_package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "<%= name %>",
"version": "0.0.1",
"description": "<%= description %>",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"files": ["lib/"],
"engines": {
"node": ">=10"
},
"dependencies": {
"@verdaccio/commons-api": "^8.4.2",
"express": "^4.17.1"
},
"devDependencies": {
"@verdaccio/babel-preset": "^8.4.2",
"@verdaccio/eslint-config": "^8.4.2",
"@verdaccio/types": "^8.4.2",
"eslint": "^6.6.0",
"jest": "^24.9.0",
"prettier": "^1.19.1",
"standard-version": "^7.0.0"
},
"keywords": "[<%= keywords %>]",
"license": "<%= license %>",
"repository": "<%= repository %>",
"author": "<%= authorName %> <<%= authorEmail %>>",
"scripts": {
"build": "npm run build:types && npm run build:js",
"build:js": "babel src/ --out-dir lib --extensions \".ts,.tsx\"",
"build:types": "tsc --emitDeclarationOnly",
"test": "jest",
"lint": "eslint \"**/*.{js,ts}\""
}
}
36 changes: 36 additions & 0 deletions generators/app/templates/typescript/auth/_package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "<%= name %>",
"version": "0.0.1",
"description": "<%= description %>",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"files": ["lib/"],
"engines": {
"node": ">=10"
},
"devDependencies": {
"@types/jest": "^24.0.21",
"@types/node": "^12.12.5",
"@types/express": "^4.17.1",
"@typescript-eslint/eslint-plugin": "2.12.0",
"@verdaccio/babel-preset": "^8.4.2",
"@verdaccio/eslint-config": "^8.4.2",
"@verdaccio/types": "^8.4.2",
"eslint": "^6.6.0",
"jest": "^24.9.0",
"prettier": "1.19.1",
"standard-version": "^7.0.0",
"typescript": "^3.7.2"
},
"keywords": "[<%= keywords %>]",
"license": "<%= license %>",
"repository": "<%= repository %>",
"author": "<%= authorName %> <<%= authorEmail %>>",
"scripts": {
"build": "npm run build:types && npm run build:js",
"build:js": "babel src/ --out-dir lib --extensions \".ts,.tsx\"",
"build:types": "tsc --emitDeclarationOnly",
"test": "jest",
"lint": "eslint \"**/*.{js,ts}\""
}
}
6 changes: 4 additions & 2 deletions generators/app/templates/typescript/auth/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Config } from "@verdaccio/types";
import { Config } from '@verdaccio/types';

export interface CustomConfig extends Config {}
export interface CustomConfig extends Config {
foo: string;
}
17 changes: 2 additions & 15 deletions generators/app/templates/typescript/common/eslintrc
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
{
"env": {
"es6": true,
"node": true,
"mocha": true
},

"parserOptions": {
"sourceType": "module"
},

"rules": {
"quotes": [2, "single"],
"no-underscore-dangle": [0]
}
}
"extends": ["@verdaccio"]
}
2 changes: 1 addition & 1 deletion generators/app/templates/typescript/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import VerdaccioPlugin from "./lib/index";
import VerdaccioPlugin from './lib/index';

export default VerdaccioPlugin;
10 changes: 10 additions & 0 deletions generators/app/templates/typescript/common/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
name: 'verdaccio-<%= name %>',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
transform: {
'^.+\\.(js|jsx|ts|tsx)$': 'babel-jest',
},
verbose: true,
collectCoverage: true,
coveragePathIgnorePatterns: ['node_modules'],
};
Loading

0 comments on commit 61eeae8

Please sign in to comment.