Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,53 @@
</a>
</div>
</div>

## Installation

Make sure `yeoman` is installed:

```sh
$ yarn global add yo
```

Then install the generator

```sh
$ yarn global add @boringcodes/create-package
```

## Usage

With [yo](https://github.com/yeoman/yo):

```sh
$ yo create-package
```

This scaffolds out:
```
├── CHANGELOG.md
├── README.md
├── package.json
├── rollup.config.js
├── src
│   ├── index.ts
│   └── package-name
│   └── index.ts
├── tsconfig.json
└── tslint.json
```

## Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

## Authors

[BoringCodes](https://github.com/boringcodes)

## License

[MIT](https://github.com/boringcodes/create-package/blob/master/LICENSE)
54 changes: 54 additions & 0 deletions generators/app/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const Generator = require('yeoman-generator');
const chalk = require("chalk");
const yosay = require("yosay");
const pkg = require('../../package.json');

module.exports = class extends Generator {
async prompting() {
this.log(
yosay(
`Welcome to the astounding ${chalk.red(pkg.name)} generator!`
)
);

const prompts = [
{
type: "input",
name: "elementName",
message: "What is the name of your package?",
default: "my-awesome-package"
},
{
type: "input",
name: "elementDescription",
message: "Give us some small description of your package",
default: ""
},
{
type: "input",
name: "elementAuthor",
message: "Who is the author of this package?",
default: ""
},
];

return this.prompt(prompts).then(props => {
// To access props later use this.props.someAnswer;
this.props = props;
});
}

writing() {
this.fs.copyTpl(
[
this.templatePath('**'),
],
this.destinationPath(),
this.props,
);
}

install () {
this.installDependencies();
}
};
5 changes: 5 additions & 0 deletions generators/app/templates/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.DS_Store
node_modules
.env
.tmp
.rpt2_cache
6 changes: 6 additions & 0 deletions generators/app/templates/.huskyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"hooks": {
"pre-commit": "yarn lint",
"pre-push": "yarn build"
}
}
3 changes: 3 additions & 0 deletions generators/app/templates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# <%= elementName %>

Library Starter Kit
43 changes: 43 additions & 0 deletions generators/app/templates/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "<%= elementName %>",
"description": "<%= elementDescription %>",
"version": "0.0.0",
"private": true,
"license": "MIT",
"author": "<%= elementAuthor %>",
"repository": "",
"bugs": "",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"clean": "rm -rf dist",
"purge": "rm -rf node_modules",
"dev": "rollup -cw",
"prebuild": "yarn clean",
"build": "rollup -c",
"lint": "tslint --project tsconfig.json --config tslint.json",
"release": "standard-version",
"release:major": "yarn release --release-as major",
"release:minor": "yarn release --release-as minor",
"release:patch": "yarn release --release-as patch"
},
"devDependencies": {
"@types/isomorphic-fetch": "^0.0.35",
"husky": "^2.3.0",
"rollup": "^1.12.3",
"rollup-plugin-async": "^1.2.0",
"rollup-plugin-commonjs": "^10.0.0",
"rollup-plugin-node-resolve": "^5.0.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-typescript2": "^0.21.1",
"standard-version": "^6.0.1",
"tslint": "^5.16.0",
"tslint-config-airbnb": "^5.11.1",
"tslint-immutable": "^5.5.2",
"tslint-sonarts": "^1.9.0",
"typescript": "^3.4.5"
}
}
36 changes: 36 additions & 0 deletions generators/app/templates/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import typescript from 'rollup-plugin-typescript2';
import async from 'rollup-plugin-async';
import sourceMaps from 'rollup-plugin-sourcemaps';

import pkg from './package.json';

const common = {
external: [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
],
plugins: [
resolve(),
commonjs(),
typescript({ useTsconfigDeclarationDir: true, rollupCommonJSResolveHack: true }),
async(),
sourceMaps(),
],
};

export default [
// package-name
{
...common,
input: 'src/index.ts',
output: [
{
file: pkg.main,
format: 'cjs',
sourcemap: true,
},
],
}
];
1 change: 1 addition & 0 deletions generators/app/templates/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './package-name';
1 change: 1 addition & 0 deletions generators/app/templates/src/package-name/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
27 changes: 27 additions & 0 deletions generators/app/templates/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"compilerOptions": {
"moduleResolution": "node",
"target": "es5",
"module":"esNext",
"lib": ["es2015", "es2016", "es2017", "dom"],
"strict": true,
"sourceMap": true,
"declaration": true,
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"outDir": "dist",
"declarationDir": "dist",
"typeRoots": [
"node_modules/@types"
]
},
"include": [
"src"
],
"exclude": [
"node_modules",
"dist",
"**/*.js"
]
}
15 changes: 15 additions & 0 deletions generators/app/templates/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"enable": true,
"extends": [
"tslint-config-airbnb",
"tslint-immutable",
"tslint-sonarts"
],
"linterOptions": {
"exclude": [
"node_modules",
"dist",
"**/*.js"
]
}
}
32 changes: 32 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "@boringcodes/create-package",
"version": "0.0.0",
"description": "Boring Node.js Package Generator",
"main": "generators/app/index.js",
"author": "BoringCodes <hi@boringcodes.com> (https://boringcodes.com)",
"repository": "https://github.com/boringcodes/create-package.git",
"bugs": "https://github.com/boringcodes/create-package/issues",
"license": "MIT",
"files": [
"generators"
],
"scripts": {
"purge": "rm -rf node_modules",
"release": "standard-version",
"release:major": "yarn release --release-as major",
"release:minor": "yarn release --release-as minor",
"release:patch": "yarn release --release-as patch"
},
"keywords": [
"yeoman-generator",
"create-package"
],
"dependencies": {
"chalk": "^3.0.0",
"yeoman-generator": "^4.5.0",
"yosay": "^2.0.2"
},
"devDependencies": {
"standard-version": "^7.1.0"
}
}
Loading