CreateProject
This is simple CLI Tool to create projects from Templates scoped to specific user or organsization.
Usage
There is two ways to use create-project:
- By Installing it globaly
- Via npx
Global Install
Steps for first case(global install)
- First lets install it globaly,
npm i -g @ando_ghevian/create-project
- Set scope from which you want to download templates (Templates start with cpj-template[-templatename]),
create-project scope set @ando_ghevian
- Check that everything went smoothly, and scope is accepted
create-project scope get
- Create Project From:
create-project --template npm-package my-package
You can also use another scope when creating project:
create-project scope use @elseScope --template temp prj
-
create-project use @elseScope --template temp prj
(use is alias for scope use)
You can create project when setting scope:
create-project scope set @ando_ghevan -t npm-package my-package
You can also use templates from url, and in this case you dont need any scope to be set.
create-project -t git+https://git@github.com:AndoGhevian/cpj-template-npm-package.git proj
WORNING: Be shore that you specify protocol!!!
You can just test your local Templates:
create-project -t file:../../MyTemplate prj
create-project -t file:/path/from/root/to/template prj
NOTE: See below "How to create Templates"
NPX
Steps For npx:
npx @ando_ghevian/create-project use @Scope --template tmp prj
npx @ando_ghevian/create-project -t git+https://git@github.com:AndoGhevian/cpj-template-npm-package.git proj
How to create Templates
It's similar to create-react-app Custom Templates. Just few differences:
- Templates from npm registry must be scoped to organization or user and fit the format cpj-template[-templatename], where cpj-template will be used as default if --template(-t) is specified without value (Or not specified).
- You can Use Templates also from Code Hosting Platforms like github and gitlab. In this case scope is not needed. And Template Name can be anything, i.e. no need to start with cpj-template. Template just HAS TO stick to the rules, that we have defined.
- Default Key/Value Pairs of created projects package.json file, come from
npm init -y
command, and anything you specify in template.json in /package property, will replace default ones. - You MUST NOT specify package.json, package-lock.json and node_modules/ in template folder (/template). They will be simply ignored.
- And Currently We will replace all {{ProjectName}} occurrences in README.md with your project name.