owl-cli 6.148.0 → 6.149.0
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/.eslintrc.json +2 -2
- package/.vscode/launch.json +22 -22
- package/.vscode/settings.json +2 -2
- package/bin/createTables.js +94 -94
- package/bin/deploy.js +66 -66
- package/bin/dsl.js +223 -223
- package/bin/genEvents.js +188 -188
- package/bin/owl-init.js +50 -50
- package/bin/owl.js +305 -305
- package/bin/owlconfig.json +16 -16
- package/bin/table_mysql.js +189 -189
- package/bin/undeploy.js +56 -56
- package/defaultTemplate/api/build.xml +94 -94
- package/defaultTemplate/api/src/about.html +12 -12
- package/defaultTemplate/api/src/about.jsx +11 -11
- package/defaultTemplate/api/src/handlers/aggs.jsx +161 -161
- package/defaultTemplate/api/src/handlers/batchImport.jsx +78 -78
- package/defaultTemplate/api/src/handlers/delete.jsx +88 -88
- package/defaultTemplate/api/src/handlers/export.jsx +117 -117
- package/defaultTemplate/api/src/handlers/exportDoc.jsx +27 -27
- package/defaultTemplate/api/src/handlers/exportEx.jsx +77 -77
- package/defaultTemplate/api/src/handlers/exportWithTemplates.jsx +50 -50
- package/defaultTemplate/api/src/handlers/exportZip.jsx +26 -26
- package/defaultTemplate/api/src/handlers/get.jsx +50 -50
- package/defaultTemplate/api/src/handlers/getByIds.jsx +51 -51
- package/defaultTemplate/api/src/handlers/getChildren.jsx +96 -96
- package/defaultTemplate/api/src/handlers/getExportTaskInfo.jsx +34 -34
- package/defaultTemplate/api/src/handlers/getSpec.jsx +40 -40
- package/defaultTemplate/api/src/handlers/include/checklogin.jsx +786 -786
- package/defaultTemplate/api/src/handlers/include/diff.jsx +315 -315
- package/defaultTemplate/api/src/handlers/include/util.jsx +60 -60
- package/defaultTemplate/api/src/handlers/list.jsx +252 -252
- package/defaultTemplate/api/src/handlers/listEx.jsx +136 -135
- package/defaultTemplate/api/src/handlers/reIndex.jsx +63 -63
- package/defaultTemplate/api/src/handlers/recovery.jsx +53 -53
- package/defaultTemplate/api/src/handlers/save.jsx +125 -125
- package/defaultTemplate/api/src/handlers/upload.jsx +72 -72
- package/defaultTemplate/api/src/init/indexConfigs/changeMapping.json +14 -14
- package/defaultTemplate/api/src/init/indexConfigs/createAliase.json +10 -10
- package/defaultTemplate/api/src/init/indexConfigs/createIndex.json +55 -55
- package/defaultTemplate/api/src/init/indexConfigs/rebuildIndex.sh +27 -27
- package/defaultTemplate/api/src/init/indexConfigs/reindex.json +10 -10
- package/defaultTemplate/api/src/init/init.jsx +25 -25
- package/defaultTemplate/api/src/meta.json +10 -10
- package/defaultTemplate/api/src/services/dblayer.jsx +251 -251
- package/defaultTemplate/api/src/services/modelService.jsx +1239 -1239
- package/defaultTemplate/api/src/services/sqlstring.jsx +240 -240
- package/defaultTemplate/api/src/tasks/export.jsx +366 -366
- package/defaultTemplate/api/src/tasks/exportDoc.jsx +99 -99
- package/defaultTemplate/api/src/tasks/exportExTask.jsx +332 -332
- package/defaultTemplate/api/src/tasks/exportWithTemplateTask.jsx +128 -128
- package/defaultTemplate/api/src/tasks/exportZip.jsx +49 -49
- package/examples/buildProperties/build.properties +2 -2
- package/examples/gitignore/gitignore_example.txt +1 -1
- package/examples/models/product.json +52 -52
- package/examples/models/shop.json +71 -71
- package/examples/models/sku.json +254 -254
- package/examples/models/user.json +49 -49
- package/examples/owlconfig.json +13 -13
- package/package.json +33 -33
- package/todo.txt +4 -4
package/bin/genEvents.js
CHANGED
|
@@ -1,189 +1,189 @@
|
|
|
1
|
-
const { lstatSync, readdirSync } = require('fs')
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const { join,resolve } = require('path')
|
|
4
|
-
const {spawnSync} = require('child_process');
|
|
5
|
-
const {getFormSpecs} = require('./dsl');
|
|
6
|
-
const template= require("art-template");
|
|
7
|
-
|
|
8
|
-
var context = {
|
|
9
|
-
eventHandlers:[]
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const isDirectory = source => lstatSync(source).isDirectory()
|
|
13
|
-
const getDirectories = source =>
|
|
14
|
-
readdirSync(resolve(__dirname, source)).map(name => join(source, name)).filter(isDirectory);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
function readOwlEvent(fullPath){
|
|
19
|
-
var content = fs.readFileSync(fullPath,{encoding:"utf-8"});
|
|
20
|
-
var owlEvent = JSON.parse(content);
|
|
21
|
-
return owlEvent;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
function buildEventHandlers(owlEvent,ctx){
|
|
26
|
-
var appId = owlEvent.appId;
|
|
27
|
-
var eventHandlers = [];
|
|
28
|
-
var events = owlEvent.events;
|
|
29
|
-
for(var eventName in events){
|
|
30
|
-
var evt = events[eventName];
|
|
31
|
-
var description = evt.rem;
|
|
32
|
-
var pageId = "eventHandlers/"+eventName+ ".jsx";
|
|
33
|
-
var handlerId = appId + "_" + eventName;
|
|
34
|
-
eventHandlers.push({
|
|
35
|
-
eventName:eventName,
|
|
36
|
-
pageId:pageId,
|
|
37
|
-
handlerId:handlerId,
|
|
38
|
-
description:description
|
|
39
|
-
})
|
|
40
|
-
}
|
|
41
|
-
ctx.eventHandlers = eventHandlers;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function buildServices(evt,evtName,owlEvent,ctx){
|
|
45
|
-
var pickItem = evt.process.pickItem;
|
|
46
|
-
var types = {};
|
|
47
|
-
if(pickItem){
|
|
48
|
-
for(var k in pickItem){
|
|
49
|
-
var item = pickItem[k];
|
|
50
|
-
if(item._t){
|
|
51
|
-
types[item._t] = item._t;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
var actions = evt.process.actions;
|
|
57
|
-
if(actions){
|
|
58
|
-
actions.forEach(function(action){
|
|
59
|
-
if(action._t){
|
|
60
|
-
types[action._t] = action._t;
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
var pickService = evt.process.pickService;
|
|
66
|
-
if(pickService){
|
|
67
|
-
pickService.forEach(function(type){types[type] = type;})
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
var services = [];
|
|
72
|
-
var imports = [];
|
|
73
|
-
for(var _t in types){
|
|
74
|
-
var service = "context.services['" + _t +"']="+"erp_"+_t+"Service;";
|
|
75
|
-
services.push(service);
|
|
76
|
-
ctx.services = services.join("\n");
|
|
77
|
-
|
|
78
|
-
var importStr = "//#import $erp_" + _t + ":services/modelService.jsx" ;
|
|
79
|
-
imports.push(importStr);
|
|
80
|
-
ctx.imports = imports.join("\n");
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function buildCheck(evt,evtName,owlEvent,ctx){
|
|
85
|
-
var check = "null";
|
|
86
|
-
if(evt.check){
|
|
87
|
-
check = evt.check.replace(/\$/g,"context.$");
|
|
88
|
-
ctx.check = "function(context){ return (" + check + ")}";
|
|
89
|
-
}
|
|
90
|
-
else{
|
|
91
|
-
ctx.check = null;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function processOwlEvent(owlEvent,outdir,templateDir,ctx){
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if(!ctx){
|
|
100
|
-
ctx = {};
|
|
101
|
-
buildEventHandlers(owlEvent,ctx);
|
|
102
|
-
//1.创建app
|
|
103
|
-
var appId = owlEvent.appId;
|
|
104
|
-
var appDir = join(outdir,appId);
|
|
105
|
-
try{fs.mkdirSync(appDir);}catch(e){}
|
|
106
|
-
outdir = appDir;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
var fullTemplatePath = resolve(__dirname,templateDir);
|
|
111
|
-
readdirSync(fullTemplatePath).map(name => {
|
|
112
|
-
var fullname = resolve(fullTemplatePath,name);
|
|
113
|
-
if(isDirectory(fullname)){
|
|
114
|
-
subOutDir = resolve(outdir,name);
|
|
115
|
-
try{fs.mkdirSync(subOutDir);}catch(e){};
|
|
116
|
-
processOwlEvent(owlEvent,subOutDir,fullname,ctx);
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
if(name.indexOf(".png")>-1 || name.indexOf(".PNG") >-1
|
|
120
|
-
|| name.indexOf(".jpg")>-1 || name.indexOf(".jpeg")>-1 ||
|
|
121
|
-
name.indexOf(".JPG")>-1 || name.indexOf(".jpeg")>-1){
|
|
122
|
-
var dst = resolve(outdir,name);
|
|
123
|
-
fs.copyFileSync(fullname,dst);
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if(name.indexOf("handlerTemplate.jsx")==-1){
|
|
130
|
-
|
|
131
|
-
var fileContent = fs.readFileSync(fullname,{encoding:"utf-8"});
|
|
132
|
-
fileContent = fileContent.replace(/@appId/g,owlEvent.appId);
|
|
133
|
-
fileContent = fileContent.replace(/@appName/g,owlEvent.appName);
|
|
134
|
-
fileContent = fileContent.replace(/@eventHandlers/g,JSON.stringify(ctx.eventHandlers));
|
|
135
|
-
var dst = resolve(outdir,name);
|
|
136
|
-
fs.writeFileSync(dst,fileContent,{flag:'w'});
|
|
137
|
-
}
|
|
138
|
-
else{
|
|
139
|
-
var events = owlEvent.events;
|
|
140
|
-
for(var eventName in events){
|
|
141
|
-
var fileContent = fs.readFileSync(fullname,{encoding:"utf-8"});
|
|
142
|
-
fileContent = fileContent.replace(/@appId/g,owlEvent.appId);
|
|
143
|
-
fileContent = fileContent.replace(/@appName/g,owlEvent.appName);
|
|
144
|
-
fileContent = fileContent.replace(/@eventHandlers/g,JSON.stringify(ctx.eventHandlers));
|
|
145
|
-
|
|
146
|
-
var eventConfig = events[eventName];
|
|
147
|
-
buildServices(eventConfig,eventName,owlEvent,ctx);
|
|
148
|
-
buildCheck(eventConfig,eventName,owlEvent,ctx);
|
|
149
|
-
|
|
150
|
-
fileContent = fileContent.replace(/@services/g,ctx.services);
|
|
151
|
-
fileContent = fileContent.replace(/@imports/g,ctx.imports);
|
|
152
|
-
fileContent = fileContent.replace(/@check/g,ctx.check);
|
|
153
|
-
fileContent = fileContent.replace(/@eventConfig/g,JSON.stringify(eventConfig));
|
|
154
|
-
var dst = resolve(outdir,eventName + ".jsx");
|
|
155
|
-
fs.writeFileSync(dst,fileContent,{flag:'w'});
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function processInputDir(inDir,outDir,templateDir){
|
|
163
|
-
readdirSync(inDir).map(function(name){
|
|
164
|
-
if(isDirectory(join(inDir,name))){
|
|
165
|
-
var newOut = join(outDir,name);
|
|
166
|
-
try{fs.mkdirSync(newOut);}catch(e){}
|
|
167
|
-
processInputDir(join(inDir,name),newOut,templateDir);
|
|
168
|
-
}
|
|
169
|
-
else{
|
|
170
|
-
if(name.indexOf(".json")>-1){
|
|
171
|
-
var fullpath = join(inDir,name);
|
|
172
|
-
var owlEvent = readOwlEvent(fullpath);
|
|
173
|
-
processOwlEvent(owlEvent,outDir,templateDir,null);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function main(){
|
|
180
|
-
var eventsDir = process.argv[2];
|
|
181
|
-
var eventsAppOut = process.argv[3];
|
|
182
|
-
var eventsAppTemplate = process.argv[4];
|
|
183
|
-
|
|
184
|
-
try{fs.mkdirSync(eventsAppOut);}catch(e){}
|
|
185
|
-
//遍历eventsDir,读取每一个.json文件
|
|
186
|
-
processInputDir(eventsDir,eventsAppOut,eventsAppTemplate);
|
|
187
|
-
}
|
|
188
|
-
|
|
1
|
+
const { lstatSync, readdirSync } = require('fs')
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const { join,resolve } = require('path')
|
|
4
|
+
const {spawnSync} = require('child_process');
|
|
5
|
+
const {getFormSpecs} = require('./dsl');
|
|
6
|
+
const template= require("art-template");
|
|
7
|
+
|
|
8
|
+
var context = {
|
|
9
|
+
eventHandlers:[]
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const isDirectory = source => lstatSync(source).isDirectory()
|
|
13
|
+
const getDirectories = source =>
|
|
14
|
+
readdirSync(resolve(__dirname, source)).map(name => join(source, name)).filter(isDirectory);
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
function readOwlEvent(fullPath){
|
|
19
|
+
var content = fs.readFileSync(fullPath,{encoding:"utf-8"});
|
|
20
|
+
var owlEvent = JSON.parse(content);
|
|
21
|
+
return owlEvent;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
function buildEventHandlers(owlEvent,ctx){
|
|
26
|
+
var appId = owlEvent.appId;
|
|
27
|
+
var eventHandlers = [];
|
|
28
|
+
var events = owlEvent.events;
|
|
29
|
+
for(var eventName in events){
|
|
30
|
+
var evt = events[eventName];
|
|
31
|
+
var description = evt.rem;
|
|
32
|
+
var pageId = "eventHandlers/"+eventName+ ".jsx";
|
|
33
|
+
var handlerId = appId + "_" + eventName;
|
|
34
|
+
eventHandlers.push({
|
|
35
|
+
eventName:eventName,
|
|
36
|
+
pageId:pageId,
|
|
37
|
+
handlerId:handlerId,
|
|
38
|
+
description:description
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
ctx.eventHandlers = eventHandlers;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function buildServices(evt,evtName,owlEvent,ctx){
|
|
45
|
+
var pickItem = evt.process.pickItem;
|
|
46
|
+
var types = {};
|
|
47
|
+
if(pickItem){
|
|
48
|
+
for(var k in pickItem){
|
|
49
|
+
var item = pickItem[k];
|
|
50
|
+
if(item._t){
|
|
51
|
+
types[item._t] = item._t;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
var actions = evt.process.actions;
|
|
57
|
+
if(actions){
|
|
58
|
+
actions.forEach(function(action){
|
|
59
|
+
if(action._t){
|
|
60
|
+
types[action._t] = action._t;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
var pickService = evt.process.pickService;
|
|
66
|
+
if(pickService){
|
|
67
|
+
pickService.forEach(function(type){types[type] = type;})
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
var services = [];
|
|
72
|
+
var imports = [];
|
|
73
|
+
for(var _t in types){
|
|
74
|
+
var service = "context.services['" + _t +"']="+"erp_"+_t+"Service;";
|
|
75
|
+
services.push(service);
|
|
76
|
+
ctx.services = services.join("\n");
|
|
77
|
+
|
|
78
|
+
var importStr = "//#import $erp_" + _t + ":services/modelService.jsx" ;
|
|
79
|
+
imports.push(importStr);
|
|
80
|
+
ctx.imports = imports.join("\n");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function buildCheck(evt,evtName,owlEvent,ctx){
|
|
85
|
+
var check = "null";
|
|
86
|
+
if(evt.check){
|
|
87
|
+
check = evt.check.replace(/\$/g,"context.$");
|
|
88
|
+
ctx.check = "function(context){ return (" + check + ")}";
|
|
89
|
+
}
|
|
90
|
+
else{
|
|
91
|
+
ctx.check = null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function processOwlEvent(owlEvent,outdir,templateDir,ctx){
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
if(!ctx){
|
|
100
|
+
ctx = {};
|
|
101
|
+
buildEventHandlers(owlEvent,ctx);
|
|
102
|
+
//1.创建app
|
|
103
|
+
var appId = owlEvent.appId;
|
|
104
|
+
var appDir = join(outdir,appId);
|
|
105
|
+
try{fs.mkdirSync(appDir);}catch(e){}
|
|
106
|
+
outdir = appDir;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
var fullTemplatePath = resolve(__dirname,templateDir);
|
|
111
|
+
readdirSync(fullTemplatePath).map(name => {
|
|
112
|
+
var fullname = resolve(fullTemplatePath,name);
|
|
113
|
+
if(isDirectory(fullname)){
|
|
114
|
+
subOutDir = resolve(outdir,name);
|
|
115
|
+
try{fs.mkdirSync(subOutDir);}catch(e){};
|
|
116
|
+
processOwlEvent(owlEvent,subOutDir,fullname,ctx);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if(name.indexOf(".png")>-1 || name.indexOf(".PNG") >-1
|
|
120
|
+
|| name.indexOf(".jpg")>-1 || name.indexOf(".jpeg")>-1 ||
|
|
121
|
+
name.indexOf(".JPG")>-1 || name.indexOf(".jpeg")>-1){
|
|
122
|
+
var dst = resolve(outdir,name);
|
|
123
|
+
fs.copyFileSync(fullname,dst);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
if(name.indexOf("handlerTemplate.jsx")==-1){
|
|
130
|
+
|
|
131
|
+
var fileContent = fs.readFileSync(fullname,{encoding:"utf-8"});
|
|
132
|
+
fileContent = fileContent.replace(/@appId/g,owlEvent.appId);
|
|
133
|
+
fileContent = fileContent.replace(/@appName/g,owlEvent.appName);
|
|
134
|
+
fileContent = fileContent.replace(/@eventHandlers/g,JSON.stringify(ctx.eventHandlers));
|
|
135
|
+
var dst = resolve(outdir,name);
|
|
136
|
+
fs.writeFileSync(dst,fileContent,{flag:'w'});
|
|
137
|
+
}
|
|
138
|
+
else{
|
|
139
|
+
var events = owlEvent.events;
|
|
140
|
+
for(var eventName in events){
|
|
141
|
+
var fileContent = fs.readFileSync(fullname,{encoding:"utf-8"});
|
|
142
|
+
fileContent = fileContent.replace(/@appId/g,owlEvent.appId);
|
|
143
|
+
fileContent = fileContent.replace(/@appName/g,owlEvent.appName);
|
|
144
|
+
fileContent = fileContent.replace(/@eventHandlers/g,JSON.stringify(ctx.eventHandlers));
|
|
145
|
+
|
|
146
|
+
var eventConfig = events[eventName];
|
|
147
|
+
buildServices(eventConfig,eventName,owlEvent,ctx);
|
|
148
|
+
buildCheck(eventConfig,eventName,owlEvent,ctx);
|
|
149
|
+
|
|
150
|
+
fileContent = fileContent.replace(/@services/g,ctx.services);
|
|
151
|
+
fileContent = fileContent.replace(/@imports/g,ctx.imports);
|
|
152
|
+
fileContent = fileContent.replace(/@check/g,ctx.check);
|
|
153
|
+
fileContent = fileContent.replace(/@eventConfig/g,JSON.stringify(eventConfig));
|
|
154
|
+
var dst = resolve(outdir,eventName + ".jsx");
|
|
155
|
+
fs.writeFileSync(dst,fileContent,{flag:'w'});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function processInputDir(inDir,outDir,templateDir){
|
|
163
|
+
readdirSync(inDir).map(function(name){
|
|
164
|
+
if(isDirectory(join(inDir,name))){
|
|
165
|
+
var newOut = join(outDir,name);
|
|
166
|
+
try{fs.mkdirSync(newOut);}catch(e){}
|
|
167
|
+
processInputDir(join(inDir,name),newOut,templateDir);
|
|
168
|
+
}
|
|
169
|
+
else{
|
|
170
|
+
if(name.indexOf(".json")>-1){
|
|
171
|
+
var fullpath = join(inDir,name);
|
|
172
|
+
var owlEvent = readOwlEvent(fullpath);
|
|
173
|
+
processOwlEvent(owlEvent,outDir,templateDir,null);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function main(){
|
|
180
|
+
var eventsDir = process.argv[2];
|
|
181
|
+
var eventsAppOut = process.argv[3];
|
|
182
|
+
var eventsAppTemplate = process.argv[4];
|
|
183
|
+
|
|
184
|
+
try{fs.mkdirSync(eventsAppOut);}catch(e){}
|
|
185
|
+
//遍历eventsDir,读取每一个.json文件
|
|
186
|
+
processInputDir(eventsDir,eventsAppOut,eventsAppTemplate);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
189
|
main();
|
package/bin/owl-init.js
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const fs = require('fs')
|
|
4
|
-
const {join, resolve} = require('path')
|
|
5
|
-
|
|
6
|
-
let cwd = process.cwd();
|
|
7
|
-
|
|
8
|
-
//复制owlconfig.json到 当前目录
|
|
9
|
-
var templatePath = join(__dirname, "../defaultTemplate")
|
|
10
|
-
var buildProperties = join(cwd,'build.properties');
|
|
11
|
-
var antLibPath = join(__dirname,'../antLib')
|
|
12
|
-
let owlconfig = {
|
|
13
|
-
"models":"models",
|
|
14
|
-
"templates":templatePath,
|
|
15
|
-
"generatedApps":"generatedApps",
|
|
16
|
-
"buildType":"release",
|
|
17
|
-
"buildProperties":buildProperties,
|
|
18
|
-
"libpath":antLibPath
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
let dst = resolve(cwd, "owlconfig.json")
|
|
22
|
-
fs.writeFileSync(dst, JSON.stringify(owlconfig), {flag: 'w'})
|
|
23
|
-
|
|
24
|
-
//在当前目录创建models目录
|
|
25
|
-
|
|
26
|
-
let modelsDir = join(cwd,"models");
|
|
27
|
-
fs.mkdirSync(modelsDir)
|
|
28
|
-
|
|
29
|
-
//在models Dir 目录下创建一个example.json
|
|
30
|
-
let exampleDir = resolve( __dirname,"../examples/models")
|
|
31
|
-
fs.readdirSync(exampleDir).map(name => {
|
|
32
|
-
let fullname = resolve(exampleDir,name)
|
|
33
|
-
let dst = resolve(modelsDir,name)
|
|
34
|
-
fs.copyFileSync(fullname, dst)
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
//在project目录下面创建一个build.properties
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
let buildPropertiesPath = join(__dirname,'../examples/buildProperties');
|
|
41
|
-
let fullname = resolve(buildPropertiesPath,'build.properties');
|
|
42
|
-
let dstBuildProperties = resolve(cwd,'build.properties')
|
|
43
|
-
fs.copyFileSync(fullname, dstBuildProperties)
|
|
44
|
-
|
|
45
|
-
//生成.gitignore
|
|
46
|
-
let gitignorePath = join(__dirname,'../examples/gitignore');
|
|
47
|
-
let gitignoreSrc = resolve(gitignorePath,'gitignore_example.txt');
|
|
48
|
-
let gitignoreDst = resolve(cwd,'.gitignore')
|
|
49
|
-
fs.copyFileSync(gitignoreSrc, gitignoreDst)
|
|
50
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs')
|
|
4
|
+
const {join, resolve} = require('path')
|
|
5
|
+
|
|
6
|
+
let cwd = process.cwd();
|
|
7
|
+
|
|
8
|
+
//复制owlconfig.json到 当前目录
|
|
9
|
+
var templatePath = join(__dirname, "../defaultTemplate")
|
|
10
|
+
var buildProperties = join(cwd,'build.properties');
|
|
11
|
+
var antLibPath = join(__dirname,'../antLib')
|
|
12
|
+
let owlconfig = {
|
|
13
|
+
"models":"models",
|
|
14
|
+
"templates":templatePath,
|
|
15
|
+
"generatedApps":"generatedApps",
|
|
16
|
+
"buildType":"release",
|
|
17
|
+
"buildProperties":buildProperties,
|
|
18
|
+
"libpath":antLibPath
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let dst = resolve(cwd, "owlconfig.json")
|
|
22
|
+
fs.writeFileSync(dst, JSON.stringify(owlconfig), {flag: 'w'})
|
|
23
|
+
|
|
24
|
+
//在当前目录创建models目录
|
|
25
|
+
|
|
26
|
+
let modelsDir = join(cwd,"models");
|
|
27
|
+
fs.mkdirSync(modelsDir)
|
|
28
|
+
|
|
29
|
+
//在models Dir 目录下创建一个example.json
|
|
30
|
+
let exampleDir = resolve( __dirname,"../examples/models")
|
|
31
|
+
fs.readdirSync(exampleDir).map(name => {
|
|
32
|
+
let fullname = resolve(exampleDir,name)
|
|
33
|
+
let dst = resolve(modelsDir,name)
|
|
34
|
+
fs.copyFileSync(fullname, dst)
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
//在project目录下面创建一个build.properties
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
let buildPropertiesPath = join(__dirname,'../examples/buildProperties');
|
|
41
|
+
let fullname = resolve(buildPropertiesPath,'build.properties');
|
|
42
|
+
let dstBuildProperties = resolve(cwd,'build.properties')
|
|
43
|
+
fs.copyFileSync(fullname, dstBuildProperties)
|
|
44
|
+
|
|
45
|
+
//生成.gitignore
|
|
46
|
+
let gitignorePath = join(__dirname,'../examples/gitignore');
|
|
47
|
+
let gitignoreSrc = resolve(gitignorePath,'gitignore_example.txt');
|
|
48
|
+
let gitignoreDst = resolve(cwd,'.gitignore')
|
|
49
|
+
fs.copyFileSync(gitignoreSrc, gitignoreDst)
|
|
50
|
+
|