UNPKG

4.37 kBMarkdownView Raw
1# ∺ HingeJS - CLI Project Generator
2
3Command line interface and Simple Single Page Application and code generator
4
5> Most of the features have been implemented. This is a work in progress until a 1.0.0 release.
6
7### What is this for?
8
9This project generator creates a process to build web applications using web components in a single page application. The packaged services and custom elements are used to help make development easier. You can use any services or other custom element libraries.
10
11### Is this just another framework?
12
13Technically it is not. The libraries used in development have little to no dependencies. Custom Elements allow you to build reusable web components using plain JavaScript only. Long gone are the days of having to copy HTML/CSS/JS and manually insert them for one piece of functionality. This is now done in one file and used as a custom HTML tag, native to the browser.
14
15This generator sets you up so you have the following features available to you faster.
16
17- Build/Bundle process
18- Routing
19- Services
20- Web component suite
21- CSS/JS linting
22- Unit testing
23- Web dev server
24- HTML cached templates
25- i18n translation process
26- Templates generated for rapid development
27
28#### Wiki
29
30For more information, tips and guides visit:
31
32- https://github.com/hingejs/generator/wiki
33
34#### Related packages
35- https://www.npmjs.com/package/@hingejs/services
36- https://www.npmjs.com/package/@hingejs/webcomponents
37
38## Installation
39
40Install this package globally
41
42```sh
43$ npm install @hingejs/generator -g
44```
45
46## Generate Project
47
48> Please note: You can always Internationalize your application later but it is recommended to do this from the beginning rather than updating during development. This CLI will not be able to do that for you so choose carefully from the start.
49
50New project
51
52```sh
53$ hingejs new <projectFolderName>
54```
55
56> Alias `n`
57
58```sh
59$ hingejs n <projectFolderName>
60```
61
62example with project folder name
63
64```sh
65$ hingejs new test
66```
67
68Options
69
70| Command | ShortCut | Description |
71|:---------:|:---------:|:---------:|
72| --i18n | -i | Internationalize the new project |
73| --port <number> | -p | Integer argument ( Default: 9000) |
74
75> Internationalization Info: https://developer.mozilla.org/en-US/docs/Glossary/I18N
76
77Examples:
78
79```sh
80$ hingejs new test --i18n
81```
82
83```sh
84$ hingejs new test --port 7500
85```
86
87```sh
88$ hingejs new test --i18n --port 7500
89```
90
91Once generated you can run the following command to start the project
92> You can refer to the project README.md file
93```sh
94$ cd <projectFolderName>
95$ npm start
96```
97
98## Generate Files
99
100New template file
101
102```sh
103$ hingejs generate <type>
104```
105
106> Alias `g`
107
108```sh
109$ hingejs g <type>
110```
111
112Examples:
113
114```sh
115$ hingejs generate component
116$ hingejs generate element
117$ hingejs generate feature
118$ hingejs generate service
119
120$ hingejs g c
121$ hingejs g e
122$ hingejs g f
123$ hingejs g s
124```
125
126Types
127
128| Command | ShortCut | Description |
129|:---------:|:---------:|:---------:|
130| component | c | Components are project specific and have element/service dependencies |
131| element | e | Custom elements should be built dependency free to be used for any project |
132| feature | f | New route page for the application |
133| service | s | Singleton/Observable based services to manage business logic |
134
135
136Options
137
138| Command | ShortCut | Description |
139|:---------:|:---------:|:---------:|
140| --shadow | -s | Shadow dom for element |
141
142### Generate File Names
143
144#### Component and Elements
145 Follows rules for w3c custom elements. must start with an alpha character. Can be alpha-numeric, but must contain one hyphen(-).
146
147 > `tool-tip` to be used as `<tool-tip></tool-tip>`
148
149```sh
150$ hingejs generate component tool-tip
151```
152
153#### Services
154 Must be lowercase with hyphen's(-) to separate words.
155
156 > `todo` will become `TodoService`
157
158 > `to-do` will become `ToDoService`
159
160```sh
161$ hingejs generate service to-do
162```
163
164Using a service in the application you can do the following. Webpack is configured to resolve `'services'` as an alias to the correct path of `./src/services/index.js`.
165
166```js
167import { TodoService } from 'services'
168```
169
170#### Features
171 Must be lowercase with directory separators(/). This structure will be generated in the features folder.
172
173 > `todo` will become `todo/todo.js`
174
175 > `todo/home` will become `todo/home.js`
176
177```sh
178$ hingejs generate feature todo/home
179```