@cmmn/tools 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gen/component.ts.tpl +16 -0
- package/gen/gen.js +27 -0
- package/gen/style.less.tpl +3 -0
- package/gen/template.ts.tpl +8 -0
- package/package.json +3 -2
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {component, HtmlComponent, property} from "@cmmn/ui";
|
|
2
|
+
import {template, IState, IEvents} from "./$name$.template";
|
|
3
|
+
import style from "./$name$.style.less";
|
|
4
|
+
import {Injectable} from "@cmmn/core";
|
|
5
|
+
|
|
6
|
+
@Injectable(true)
|
|
7
|
+
@component({name: '$name$', template, style})
|
|
8
|
+
export class $Name$Component extends HtmlComponent<IState, IEvents> {
|
|
9
|
+
|
|
10
|
+
@property()
|
|
11
|
+
private property!: any;
|
|
12
|
+
|
|
13
|
+
get State() {
|
|
14
|
+
return this.property;
|
|
15
|
+
}
|
|
16
|
+
}
|
package/gen/gen.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import {fileURLToPath} from 'url';
|
|
4
|
+
import {execSync} from "child_process";
|
|
5
|
+
|
|
6
|
+
const currentDir = '__dirname' in global ? __dirname : path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
|
|
8
|
+
const templateTpl = fs.readFileSync(path.join(currentDir, './template.ts.tpl'), 'utf8');
|
|
9
|
+
const componentTpl = fs.readFileSync(path.join(currentDir, './component.ts.tpl'), 'utf8');
|
|
10
|
+
const styleTpl = fs.readFileSync(path.join(currentDir, './style.less.tpl'), 'utf8');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
export function gen(name, directory, nested = false) {
|
|
14
|
+
const Name = name.replace(/^./, c => c.toUpperCase());
|
|
15
|
+
name = Name.replace(/[A-Z]/g, (c, i) => (i ? '-' : '') + c.toLowerCase());
|
|
16
|
+
process.chdir(directory);
|
|
17
|
+
if (nested) {
|
|
18
|
+
fs.mkdirSync(name);
|
|
19
|
+
process.chdir(name);
|
|
20
|
+
}
|
|
21
|
+
fs.writeFileSync(name + '.component.ts', componentTpl.replace(/\$Name\$/g, Name).replace(/\$name\$/g, name), 'utf8');
|
|
22
|
+
fs.writeFileSync(name + '.template.ts', templateTpl.replace(/\$Name\$/g, Name).replace(/\$name\$/g, name), 'utf8');
|
|
23
|
+
fs.writeFileSync(name + '.style.less', styleTpl.replace(/\$Name\$/g, Name).replace(/\$name\$/g, name), 'utf8');
|
|
24
|
+
execSync(`git add ${name}.component.ts`);
|
|
25
|
+
execSync(`git add ${name}.template.ts`);
|
|
26
|
+
execSync(`git add ${name}.style.less`);
|
|
27
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmmn/tools",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "di, base extensions, useful functions",
|
|
5
5
|
"main": "dist/rollup.config.js",
|
|
6
6
|
"type": "module",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
15
|
"bin.js",
|
|
16
|
+
"gen/*",
|
|
16
17
|
"compile/*",
|
|
17
18
|
"bundle/*",
|
|
18
19
|
"plugins/*"
|
|
@@ -42,5 +43,5 @@
|
|
|
42
43
|
},
|
|
43
44
|
"author": "",
|
|
44
45
|
"license": "ISC",
|
|
45
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "37140dec485e2c4f9fa91fb06ede1c926ddeeadc"
|
|
46
47
|
}
|