1.1.6 • Published 5 years ago

generator-xxproject v1.1.6

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

generator-xxproject

create new project or attach some config to exist project. such as editorconfig, eslint, express, faker, jest, mongodb, prettier, next, react, stylelint, sass.

we're enable typescript by default, that means every frame like faker, jest or package tool like webpack is support typescript.

install

npm install -g yo generator-xxproject

usage

new command(recommanded)

yo xxproject:dev-env

contain the most features I used in my work day.

and it is updating

for example:

cd folder
npm init --y
yo xxproject:dev-env

it's all done. and now you can use typescript, react, jest, faker, storybook. and the config of the eslint, prettier, editorconfig, stylelint are all setted, pretty easy.

we are supported a lot of scripts which can make our life easier. the most wonderful experience is that you can use is to build commonjs, amd, umd modules from typescript, just use npm run build:commonjs, npm run build:amd, npm run build:umd.

there is some error with the npm run build:umd:min, so don't use it; TODO:

  • [] full test
  • [] support more features
  • [] and so on.

Attach to exist project

need run npm init before, that means you shuold have a package.json file in current working directory.

Command: yo xxproject:projectName

projectName

projectNameexampleOptionsNote
editorconfigyo xxproject:editorconfgNonegenerate.editorconfigfile
typescriptyo xxproject:typescriptNoneAdd typescript to project
sassyo xxproject:sassNoneAdd sass to project
eslintyo xxproject:eslint—typescript —prettieradd eslint to project
stylelintyo xxproject:stylelint—sass —prettieradd stylelint to project
lint-stagedyo xxproject:lint-stagedNoneadd lint-staged to project
prettieryo xxproject:prettierNoneadd prettier to project
fakeryo xxproject:fakerNoneadd faker to project
Storybookyo xxproject:storybookNoneadd storybook to project
jestyo xxproject:jestNoneadd jest to project
eslint-prettieryo xxproject:eslint-prettierNoneAdd eslint-prettier to project
eslint-typescriptyo xxproject:eslint-typescriptNoneAdd eslint-typescript to project
stylelint-sassyo xxproject:stylelint-sassNoneAdd stylelint-sassto project
stylint-prettieryo xxproject:styline-prettierNoneAdd stylelint-prettier to project
rollup-react-libyo xxproject:rollup-react-libNoneYou can use it to create React UI Library
webpack-libyo xxproject:webpck-libNoneYou can use it to create React UI Library
dev-envyo xxproject:dev-envNonethe most common environment I'd like to use.

editorconfig

when run yo xxproject:editorconfig,you'll get .editorconfig in the current path. The content is list below.

# http://editorconfig.org
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 80
trim_trailing_whitespace = true

[*.md]
max_line_length = 0
trim_trailing_whitespace = false

[COMMIT_EDITMSG]
max_line_length = 0

prettier

this command will generate two files under the current path. .prettierrc.js and .prettierignore here is the prettierrc config

module.exports = {
	"printWidth": 80,
	"tabWidth": 2,
	"useTabs": false,
	"semi": true,
	"singleQuote": true,
	"trailingComma": "all"
};

and in the package.json script, we generate two command for prettier

	'prettier:lint': 'prettier --config .prettierrc.js --check src/**/*',
	'prettier:lint-fix': 'npm run prettier:lint -- --write'

TODO

  • complete this document
  • Full test

NOTE

To make things more clearly, I drawed a picture.

structure in think

The items I drawed in the picture like eslint, typescript, jest are the basic unit module, the line between them is the link, we use - in our project to relflect it, as eslint-prettier, eslint-typescript。 All of them can be installed separately, or combined with other unit module to build a develop environment