Skip to content

Commit 0b275ae

Browse files
committed
initial
0 parents  commit 0b275ae

12 files changed

+5003
-0
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
*.js
3+
*.d.ts
4+
.vscode

.npmignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*.ts
2+
!*.d.ts
3+
tsconfig.json
4+
tslint.json
5+
snapshots*
6+
.vscode

.prettierrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"trailingComma": "es5",
3+
"singleQuote": true,
4+
"semi": false
5+
}

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# merry-plugin-flutter
2+
3+
> Plugin for [@merryjs/cli](https://github.com/merryjs/cli)
4+
> generate flutter models pages and widgets
5+
6+
## Installation
7+
8+
### Install the cli `npm install -g @merryjs/cli` if you have installed you can skip this.
9+
10+
### Install plugin in your current workspace
11+
12+
```sh
13+
npm i merry-plugin-flutter --save-dev # or
14+
yarn add merry-plugin-flutter --dev
15+
```
16+
17+
## Usage
18+
19+
```sh
20+
merry flutter -h
21+
```

action.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export enum FlutterAction{
2+
widget,
3+
page,
4+
model,
5+
}
6+
7+
export interface FlutterOptions {
8+
name: string
9+
stateful?: boolean
10+
}

index.ts

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { Plugin } from '@merryjs/cli/lib/plugin'
2+
import path from 'path'
3+
import widget from './widget'
4+
import { FlutterAction, FlutterOptions } from './action'
5+
6+
/**
7+
* FlutterAnswers
8+
*/
9+
10+
export default (api: Plugin) => {
11+
api
12+
.command('flutter [action]')
13+
.option('-n, --name [value]', 'name of your widget/model/page')
14+
.option('-s, --stateful', 'stateful widget')
15+
.action(
16+
async (
17+
action: FlutterAction,
18+
options: FlutterOptions = {
19+
name: '',
20+
}
21+
) => {
22+
if (action === undefined) {
23+
api.log(
24+
`action required, supported actions: ${Object.keys(FlutterAction)
25+
.filter(f => !(parseInt(f, 10) >= 0))
26+
.map(f => f).join(' ')}`
27+
)
28+
return
29+
}
30+
if (!options.name || typeof options.name === 'function') {
31+
api.log('name option required')
32+
return
33+
}
34+
35+
switch (action) {
36+
case FlutterAction.page:
37+
break
38+
case FlutterAction.widget:
39+
default:
40+
await widget(api, options)
41+
break
42+
}
43+
}
44+
)
45+
}

0 commit comments

Comments
 (0)