Skip to content

Commit 42e2d73

Browse files
feat(close #1): Init source (#2)
* feat: Close #1 - Init source * feat: Update README.md * refactor: Refactor * refactor: Refactor * docs(readme): remove About section * -Merge master * refactor: Refactor * refactor: Refactor * chore(package.json): remove dup repository info * feat(templates): remove tslint custom rules * refactor: Refactor * refactor: Refactor * feat(Close #1): Add release scripts * feat: Update dev dependencies * feat(templates): remove engines in package.json Co-authored-by: Phat Pham <phatpham9@gmail.com>
1 parent ebed48c commit 42e2d73

File tree

13 files changed

+2944
-0
lines changed

13 files changed

+2944
-0
lines changed

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,53 @@
2626
</a>
2727
</div>
2828
</div>
29+
30+
## Installation
31+
32+
Make sure `yeoman` is installed:
33+
34+
```sh
35+
$ yarn global add yo
36+
```
37+
38+
Then install the generator
39+
40+
```sh
41+
$ yarn global add @boringcodes/create-package
42+
```
43+
44+
## Usage
45+
46+
With [yo](https://github.com/yeoman/yo):
47+
48+
```sh
49+
$ yo create-package
50+
```
51+
52+
This scaffolds out:
53+
```
54+
├── CHANGELOG.md
55+
├── README.md
56+
├── package.json
57+
├── rollup.config.js
58+
├── src
59+
│   ├── index.ts
60+
│   └── package-name
61+
│   └── index.ts
62+
├── tsconfig.json
63+
└── tslint.json
64+
```
65+
66+
## Contributing
67+
68+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
69+
70+
Please make sure to update tests as appropriate.
71+
72+
## Authors
73+
74+
[BoringCodes](https://github.com/boringcodes)
75+
76+
## License
77+
78+
[MIT](https://github.com/boringcodes/create-package/blob/master/LICENSE)

generators/app/index.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
const Generator = require('yeoman-generator');
2+
const chalk = require("chalk");
3+
const yosay = require("yosay");
4+
const pkg = require('../../package.json');
5+
6+
module.exports = class extends Generator {
7+
async prompting() {
8+
this.log(
9+
yosay(
10+
`Welcome to the astounding ${chalk.red(pkg.name)} generator!`
11+
)
12+
);
13+
14+
const prompts = [
15+
{
16+
type: "input",
17+
name: "elementName",
18+
message: "What is the name of your package?",
19+
default: "my-awesome-package"
20+
},
21+
{
22+
type: "input",
23+
name: "elementDescription",
24+
message: "Give us some small description of your package",
25+
default: ""
26+
},
27+
{
28+
type: "input",
29+
name: "elementAuthor",
30+
message: "Who is the author of this package?",
31+
default: ""
32+
},
33+
];
34+
35+
return this.prompt(prompts).then(props => {
36+
// To access props later use this.props.someAnswer;
37+
this.props = props;
38+
});
39+
}
40+
41+
writing() {
42+
this.fs.copyTpl(
43+
[
44+
this.templatePath('**'),
45+
],
46+
this.destinationPath(),
47+
this.props,
48+
);
49+
}
50+
51+
install () {
52+
this.installDependencies();
53+
}
54+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.DS_Store
2+
node_modules
3+
.env
4+
.tmp
5+
.rpt2_cache

generators/app/templates/.huskyrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"hooks": {
3+
"pre-commit": "yarn lint",
4+
"pre-push": "yarn build"
5+
}
6+
}

generators/app/templates/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# <%= elementName %>
2+
3+
Library Starter Kit
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "<%= elementName %>",
3+
"description": "<%= elementDescription %>",
4+
"version": "0.0.0",
5+
"private": true,
6+
"license": "MIT",
7+
"author": "<%= elementAuthor %>",
8+
"repository": "",
9+
"bugs": "",
10+
"main": "dist/index.js",
11+
"typings": "dist/index.d.ts",
12+
"files": [
13+
"dist"
14+
],
15+
"scripts": {
16+
"clean": "rm -rf dist",
17+
"purge": "rm -rf node_modules",
18+
"dev": "rollup -cw",
19+
"prebuild": "yarn clean",
20+
"build": "rollup -c",
21+
"lint": "tslint --project tsconfig.json --config tslint.json",
22+
"release": "standard-version",
23+
"release:major": "yarn release --release-as major",
24+
"release:minor": "yarn release --release-as minor",
25+
"release:patch": "yarn release --release-as patch"
26+
},
27+
"devDependencies": {
28+
"@types/isomorphic-fetch": "^0.0.35",
29+
"husky": "^2.3.0",
30+
"rollup": "^1.12.3",
31+
"rollup-plugin-async": "^1.2.0",
32+
"rollup-plugin-commonjs": "^10.0.0",
33+
"rollup-plugin-node-resolve": "^5.0.0",
34+
"rollup-plugin-sourcemaps": "^0.4.2",
35+
"rollup-plugin-typescript2": "^0.21.1",
36+
"standard-version": "^6.0.1",
37+
"tslint": "^5.16.0",
38+
"tslint-config-airbnb": "^5.11.1",
39+
"tslint-immutable": "^5.5.2",
40+
"tslint-sonarts": "^1.9.0",
41+
"typescript": "^3.4.5"
42+
}
43+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import resolve from 'rollup-plugin-node-resolve';
2+
import commonjs from 'rollup-plugin-commonjs';
3+
import typescript from 'rollup-plugin-typescript2';
4+
import async from 'rollup-plugin-async';
5+
import sourceMaps from 'rollup-plugin-sourcemaps';
6+
7+
import pkg from './package.json';
8+
9+
const common = {
10+
external: [
11+
...Object.keys(pkg.dependencies || {}),
12+
...Object.keys(pkg.peerDependencies || {}),
13+
],
14+
plugins: [
15+
resolve(),
16+
commonjs(),
17+
typescript({ useTsconfigDeclarationDir: true, rollupCommonJSResolveHack: true }),
18+
async(),
19+
sourceMaps(),
20+
],
21+
};
22+
23+
export default [
24+
// package-name
25+
{
26+
...common,
27+
input: 'src/index.ts',
28+
output: [
29+
{
30+
file: pkg.main,
31+
format: 'cjs',
32+
sourcemap: true,
33+
},
34+
],
35+
}
36+
];
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './package-name';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"compilerOptions": {
3+
"moduleResolution": "node",
4+
"target": "es5",
5+
"module":"esNext",
6+
"lib": ["es2015", "es2016", "es2017", "dom"],
7+
"strict": true,
8+
"sourceMap": true,
9+
"declaration": true,
10+
"allowSyntheticDefaultImports": true,
11+
"experimentalDecorators": true,
12+
"emitDecoratorMetadata": true,
13+
"outDir": "dist",
14+
"declarationDir": "dist",
15+
"typeRoots": [
16+
"node_modules/@types"
17+
]
18+
},
19+
"include": [
20+
"src"
21+
],
22+
"exclude": [
23+
"node_modules",
24+
"dist",
25+
"**/*.js"
26+
]
27+
}

0 commit comments

Comments
 (0)