qcobjects-cli 2.4.34 → 2.4.37
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/.eslintignore +1 -4
- package/.eslintrc.cjs +3 -19
- package/README.md +1 -0
- package/VERSION +1 -1
- package/package.json +4 -2
- package/src/org.quickcorp.qcobjects.cli.js +201 -303
- package/src/org.quickcorp.qcobjects.defaultsettings.js +65 -9
- package/tsconfig.d.json +5 -0
- package/tsconfig.json +10 -0
package/.eslintignore
CHANGED
package/.eslintrc.cjs
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
env: {
|
|
3
|
-
browser: true,
|
|
4
|
-
node: true,
|
|
5
|
-
es2021: true,
|
|
6
|
-
es2020: true,
|
|
7
|
-
es2017: true,
|
|
8
|
-
es6: true
|
|
9
|
-
},
|
|
10
|
-
|
|
11
2
|
extends: [
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
"eslint:recommended", "plugin:@typescript-eslint/recommended",
|
|
16
|
-
"qcobjects"
|
|
17
|
-
|
|
18
|
-
],
|
|
19
|
-
parser: "@typescript-eslint/parser",
|
|
20
|
-
plugins: ["@typescript-eslint"],
|
|
21
|
-
root: true
|
|
3
|
+
"qcobjects",
|
|
4
|
+
"qcobjects-typescript"
|
|
5
|
+
]
|
|
22
6
|
};
|
package/README.md
CHANGED
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.4.
|
|
1
|
+
2.4.37
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qcobjects-cli",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.37",
|
|
4
4
|
"description": "qcobjects cli command line tool",
|
|
5
5
|
"main": "src/index.cjs",
|
|
6
6
|
"module": "src/index.mjs",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"eslint": "^8.38.0",
|
|
37
37
|
"eslint-config-prettier": "^8.8.0",
|
|
38
38
|
"eslint-config-qcobjects": "^0.0.26",
|
|
39
|
+
"eslint-config-qcobjects-typescript": "^2.4.5",
|
|
39
40
|
"eslint-config-semistandard": "^17.0.0",
|
|
40
41
|
"eslint-config-standard": "^17.0.0",
|
|
41
42
|
"eslint-plugin-import": "^2.27.5",
|
|
@@ -43,7 +44,8 @@
|
|
|
43
44
|
"eslint-plugin-promise": "^6.1.1",
|
|
44
45
|
"jasmine": "^3.99.0",
|
|
45
46
|
"qcobjects": "^2.4.67",
|
|
46
|
-
"qcobjects-sdk": "^2.4.30"
|
|
47
|
+
"qcobjects-sdk": "^2.4.30",
|
|
48
|
+
"qcobjects-tsconfig": "^2.4.10"
|
|
47
49
|
},
|
|
48
50
|
"peerDependencies": {
|
|
49
51
|
"qcobjects": "^2.4.67",
|
|
@@ -73,238 +73,133 @@ Package("org.quickcorp.qcobjects.cli",[
|
|
|
73
73
|
let switchCommander = this;
|
|
74
74
|
let appName = (typeof _appName ==="undefined" || _appName === true)?("MyAppName"):(_appName);
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
let _package_json_content;
|
|
77
|
+
|
|
78
|
+
_package_json_content = `{
|
|
79
|
+
"name": "${appName}"
|
|
80
|
+
"version": "1.0.0",
|
|
81
|
+
"dependencies":{
|
|
82
|
+
"qcobjectsnewphp": "latest",
|
|
83
|
+
"qcobjects": "${version.qcobjects}",
|
|
84
|
+
"qcobjects-sdk": "^${version.sdk}"
|
|
85
|
+
}
|
|
86
|
+
}`;
|
|
87
|
+
|
|
88
|
+
let createAppCommand;
|
|
89
|
+
let appTemplateName;
|
|
90
|
+
|
|
91
|
+
if (options.createAmp){
|
|
92
|
+
appTemplateName = "qcobjects-ecommerce-amp";
|
|
93
|
+
} else if (options.createPwa){
|
|
94
|
+
appTemplateName = "qcobjectsnewapp";
|
|
95
|
+
} else if (options.createPhp){
|
|
96
|
+
appTemplateName = "qcobjectsnewphp";
|
|
97
|
+
} else if (options.createCustom){
|
|
98
|
+
appTemplateName = options.createCustom;
|
|
99
|
+
} else {
|
|
100
|
+
appTemplateName = "qcobjectsnewapp";
|
|
101
|
+
}
|
|
102
|
+
CONFIG.set("qcobjectsnewapp_path",CONFIG.get("node_modules_path")+"/"+appTemplateName);
|
|
77
103
|
|
|
78
|
-
|
|
79
|
-
input: process.stdin,
|
|
80
|
-
output: process.stdout
|
|
81
|
-
});
|
|
104
|
+
let _package_json_template_fname = path.resolve(CONFIG.get("qcobjectsnewapp_path", "qcobjectsnewapp"), "./package.json");
|
|
82
105
|
|
|
83
|
-
rl.question(`Please tell me your git repository url
|
|
84
|
-
[press ENTER \u{21b5} to leave it blank or Ctrl+C to cancel]:
|
|
85
|
-
`, (answer) => {
|
|
86
|
-
logger.info(`your git repository url is ${answer}`);
|
|
87
|
-
rl.close();
|
|
88
|
-
let giturl = answer;
|
|
89
|
-
|
|
90
|
-
let createAppCommandCustom = `
|
|
91
|
-
{
|
|
92
|
-
"name": "${appName.toLowerCase()}",
|
|
93
|
-
"version": "0.0.1",
|
|
94
|
-
"repository": {
|
|
95
|
-
"type": "git",
|
|
96
|
-
"url": "${giturl}"
|
|
97
|
-
},
|
|
98
|
-
"description": "This is a custom NPM template app from ${options.createCustom} generated with QCObjects.",
|
|
99
|
-
"main": "js/init.js",
|
|
100
|
-
"license": "LGPL-3.0-or-later",
|
|
101
|
-
"scripts": {
|
|
102
|
-
"test": "(npx eslint *.js js/*.js js/packages/*.js --fix) && (npx jasmine)",
|
|
103
|
-
"sync": "git add . && git commit -am ",
|
|
104
|
-
"preversion": "npm i --upgrade && npm test",
|
|
105
|
-
"postversion": "git push && git push --tags",
|
|
106
|
-
"coverage": "nyc --reporter=lcov --reporter=text-summary npm run test",
|
|
107
|
-
"start": "node app.js",
|
|
108
|
-
"build": "exit 0"
|
|
109
|
-
},
|
|
110
|
-
"dependencies": {
|
|
111
|
-
"${options.createCustom}": "latest",
|
|
112
|
-
"qcobjects": "^${version.qcobjects}",
|
|
113
|
-
"qcobjects-sdk": "^${version.sdk}"
|
|
114
|
-
},
|
|
115
|
-
"devDependencies": {
|
|
116
|
-
"eslint": "^8.2.0",
|
|
117
|
-
"eslint-config-qcobjects": "latest",
|
|
118
|
-
"jasmine": "latest",
|
|
119
|
-
"qcobjects-cli": "^${version.cli}",
|
|
120
|
-
"grunt": "^1.4.1",
|
|
121
|
-
"grunt-contrib-jasmine": "^2.0.2",
|
|
122
|
-
"nyc": "^15.1.0"
|
|
123
|
-
}
|
|
124
|
-
}`;
|
|
125
|
-
|
|
126
|
-
let createAppCommandPWA = `
|
|
127
|
-
{
|
|
128
|
-
"name": "${appName.toLowerCase()}",
|
|
129
|
-
"version": "0.0.1",
|
|
130
|
-
"repository": {
|
|
131
|
-
"type": "git",
|
|
132
|
-
"url": "${giturl}"
|
|
133
|
-
},
|
|
134
|
-
"description": "Awesome PWA application that will help you achieve your dreams.",
|
|
135
|
-
"main": "js/init.js",
|
|
136
|
-
"license": "LGPL-3.0-or-later",
|
|
137
|
-
"scripts": {
|
|
138
|
-
"test": "(npx eslint *.js js/*.js js/packages/*.js --fix) && (npx jasmine)",
|
|
139
|
-
"sync": "git add . && git commit -am ",
|
|
140
|
-
"preversion": "npm i --upgrade && npm test",
|
|
141
|
-
"postversion": "git push && git push --tags",
|
|
142
|
-
"coverage": "nyc --reporter=lcov --reporter=text-summary npm run test",
|
|
143
|
-
"start": "node app.js",
|
|
144
|
-
"build": "exit 0"
|
|
145
|
-
},
|
|
146
|
-
"dependencies": {
|
|
147
|
-
"qcobjectsnewapp": "latest",
|
|
148
|
-
"qcobjects": "^${version.qcobjects}",
|
|
149
|
-
"qcobjects-sdk": "^${version.sdk}"
|
|
150
|
-
},
|
|
151
|
-
"devDependencies": {
|
|
152
|
-
"eslint": "^8.2.0",
|
|
153
|
-
"eslint-config-qcobjects": "latest",
|
|
154
|
-
"jasmine": "latest",
|
|
155
|
-
"qcobjects-cli": "^${version.cli}",
|
|
156
|
-
"grunt": "^1.4.1",
|
|
157
|
-
"grunt-contrib-jasmine": "^2.0.2",
|
|
158
|
-
"nyc": "^15.1.0"
|
|
159
|
-
}
|
|
160
|
-
}`;
|
|
161
|
-
|
|
162
|
-
let createAppCommandAMP = `echo
|
|
163
|
-
{
|
|
164
|
-
"name": "${appName.toLowerCase()}",
|
|
165
|
-
"version": "0.0.1",
|
|
166
|
-
"repository": {
|
|
167
|
-
"type": "git",
|
|
168
|
-
"url": "${giturl}"
|
|
169
|
-
},
|
|
170
|
-
"description": "Awesome AMP application that will help you achieve your dreams.",
|
|
171
|
-
"main": "js/init.js",
|
|
172
|
-
"license": "LGPL-3.0-or-later",
|
|
173
|
-
"scripts": {
|
|
174
|
-
"test": "(npx eslint *.js js/*.js js/packages/*.js --fix) && (npx jasmine)",
|
|
175
|
-
"sync": "git add . && git commit -am ",
|
|
176
|
-
"preversion": "npm i --upgrade && npm test",
|
|
177
|
-
"postversion": "git push && git push --tags",
|
|
178
|
-
"coverage": "nyc --reporter=lcov --reporter=text-summary npm run test",
|
|
179
|
-
"start": "node app.js",
|
|
180
|
-
"build": "exit 0"
|
|
181
|
-
},
|
|
182
|
-
"dependencies": {
|
|
183
|
-
"qcobjects-ecommerce-amp": "latest",
|
|
184
|
-
"qcobjects": "^${version.qcobjects}",
|
|
185
|
-
"qcobjects-sdk": "^${version.sdk}"
|
|
186
|
-
},
|
|
187
|
-
"devDependencies": {
|
|
188
|
-
"eslint": "^8.2.0",
|
|
189
|
-
"eslint-config-qcobjects": "latest",
|
|
190
|
-
"jasmine": "latest",
|
|
191
|
-
"qcobjects-cli": "^${version.cli}",
|
|
192
|
-
"grunt": "^1.4.1",
|
|
193
|
-
"grunt-contrib-jasmine": "^2.0.2",
|
|
194
|
-
"nyc": "^15.1.0"
|
|
195
|
-
}
|
|
196
|
-
}`;
|
|
197
|
-
|
|
198
|
-
let createAppCommandPHP = `
|
|
199
|
-
{
|
|
200
|
-
"name": "${appName.toLowerCase()}",
|
|
201
|
-
"version": "0.0.1",
|
|
202
|
-
"repository": {
|
|
203
|
-
"type": "git",
|
|
204
|
-
"url": "${giturl}"
|
|
205
|
-
},
|
|
206
|
-
"description": "Awesome PHP application that will help you achieve your dreams.",
|
|
207
|
-
"main": "js/init.js",
|
|
208
|
-
"license": "LGPL-3.0-or-later",
|
|
209
|
-
"scripts": {
|
|
210
|
-
"test": "(npx eslint *.js js/*.js js/packages/*.js --fix) && (npx jasmine)",
|
|
211
|
-
"sync": "git add . && git commit -am ",
|
|
212
|
-
"preversion": "npm i --upgrade && npm test",
|
|
213
|
-
"postversion": "git push && git push --tags",
|
|
214
|
-
"coverage": "nyc --reporter=lcov --reporter=text-summary npm run test",
|
|
215
|
-
"start": "node app.js",
|
|
216
|
-
"build": "exit 0"
|
|
217
|
-
},
|
|
218
|
-
"dependencies": {
|
|
219
|
-
"qcobjectsnewphp": "latest",
|
|
220
|
-
"qcobjects": "^${version.qcobjects}",
|
|
221
|
-
"qcobjects-sdk": "^${version.sdk}"
|
|
222
|
-
},
|
|
223
|
-
"devDependencies": {
|
|
224
|
-
"eslint": "^8.2.0",
|
|
225
|
-
"eslint-config-qcobjects": "latest",
|
|
226
|
-
"jasmine": "latest",
|
|
227
|
-
"qcobjects-cli": "^${version.cli}",
|
|
228
|
-
"grunt": "^1.4.1",
|
|
229
|
-
"grunt-contrib-jasmine": "^2.0.2",
|
|
230
|
-
"nyc": "^15.1.0"
|
|
231
|
-
}
|
|
232
|
-
}`;
|
|
233
|
-
|
|
234
|
-
let createAppCommand;
|
|
235
|
-
let appTemplateName;
|
|
236
|
-
let _package_json_content;
|
|
237
|
-
|
|
238
|
-
if (options.createAmp){
|
|
239
|
-
appTemplateName = "qcobjects-ecommerce-amp";
|
|
240
|
-
_package_json_content = createAppCommandAMP;
|
|
241
|
-
} else if (options.createPwa){
|
|
242
|
-
appTemplateName = "qcobjectsnewapp";
|
|
243
|
-
_package_json_content = createAppCommandPWA;
|
|
244
|
-
} else if (options.createPhp){
|
|
245
|
-
appTemplateName = "qcobjectsnewphp";
|
|
246
|
-
_package_json_content = createAppCommandPHP;
|
|
247
|
-
} else if (options.createCustom){
|
|
248
|
-
appTemplateName = options.createCustom;
|
|
249
|
-
_package_json_content = createAppCommandCustom;
|
|
250
|
-
} else {
|
|
251
|
-
appTemplateName = "qcobjectsnewapp";
|
|
252
|
-
_package_json_content = createAppCommandPWA;
|
|
253
|
-
}
|
|
254
|
-
CONFIG.set("qcobjectsnewapp_path",CONFIG.get("node_modules_path")+"/"+appTemplateName);
|
|
255
106
|
/* if (!process.platform.toLowerCase().startsWith("win")){
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
107
|
+
_package_json_content = _package_json_content.replace(/(")/g, String.fromCharCode(92)+"\"");
|
|
108
|
+
}*/
|
|
109
|
+
|
|
110
|
+
createAppCommand = "npm init -y";
|
|
111
|
+
let _package_json_file = path.resolve(CONFIG.get("projectPath"),"./package.json");
|
|
112
|
+
logger.debug("_package_json_file: "+_package_json_file);
|
|
113
|
+
logger.debug(createAppCommand);
|
|
114
|
+
|
|
115
|
+
exec(createAppCommand, (err, stdout, stderr) => {
|
|
116
|
+
if (err) {
|
|
117
|
+
throw Error (err.message);
|
|
118
|
+
process.exit(1);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
exec(`npm i --save-dev ${appTemplateName}`, ()=> {
|
|
123
|
+
let _package_json_template_file = require (_package_json_template_fname);
|
|
124
|
+
_package_json_template_file.name = appName;
|
|
125
|
+
_package_json_template_file.version = "1.0.0";
|
|
126
|
+
_package_json_template_file.repository = {};
|
|
127
|
+
fs.writeFileSync(_package_json_file, JSON.stringify(_package_json_template_file,null,4));
|
|
128
|
+
logger.info("Good! App Templates was installed!");
|
|
129
|
+
|
|
130
|
+
console.log(`Starting to copy files from app template ${appTemplateName} to your project...`);
|
|
131
|
+
|
|
132
|
+
switchCommander.copyTemplate(path.resolve(findPackageNodePath(appTemplateName),appTemplateName),path.resolve(CONFIG.get("projectPath"),"./") )
|
|
133
|
+
.then(()=>{
|
|
134
|
+
|
|
135
|
+
exec("npm uninstall "+appTemplateName+" --save && npm cache verify",(err,stdout,stderr)=>{
|
|
277
136
|
if (err) {
|
|
278
|
-
|
|
137
|
+
throw Error (err.message);
|
|
279
138
|
process.exit(1);
|
|
280
139
|
return;
|
|
281
140
|
}
|
|
282
141
|
|
|
283
|
-
|
|
142
|
+
/*
|
|
143
|
+
switchCommander.generateServiceWorker(appName)
|
|
284
144
|
.then(()=>{
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
145
|
+
execSync("npm install --save-dev qcobjects-cli ");
|
|
146
|
+
});
|
|
147
|
+
*/
|
|
148
|
+
execSync("npm install --save-dev qcobjects-cli ");
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
exec("npm cache verify && npm i ", (err, stdout, stderr) => {
|
|
152
|
+
if (err) {
|
|
153
|
+
throw Error (err.message);
|
|
154
|
+
process.exit(1);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
logger.info("Good! Your application is done. You can play with QCObjects now!");
|
|
159
|
+
|
|
160
|
+
logger.info("I will create the SSL certificates now. It may take some time...");
|
|
161
|
+
exec("qcobjects-createcert",(err,stdout,stderr)=>{
|
|
162
|
+
logger.info("Test certificates generated");
|
|
163
|
+
|
|
164
|
+
let githubService = New(Service);
|
|
165
|
+
githubService.url= "https://raw.githubusercontent.com/QuickCorp/QCObjects/main/.gitignore";
|
|
166
|
+
githubService.headers= {
|
|
167
|
+
Accept: 'application/vnd.github+json',
|
|
168
|
+
'X-GitHub-Api-Version': '2022-11-28',
|
|
169
|
+
'User-Agent': 'qcobjects-cli'
|
|
170
|
+
};
|
|
171
|
+
githubService.done = ()=>{};
|
|
172
|
+
serviceLoader(githubService)
|
|
173
|
+
.then (({service})=> {
|
|
174
|
+
fs.writeFileSync(path.resolve(CONFIG.get("projectPath"),"./.gitignore"),service.template);
|
|
175
|
+
try {
|
|
176
|
+
execSync("git init");
|
|
177
|
+
logger.debug("Git initialized.");
|
|
178
|
+
} catch (e){
|
|
179
|
+
logger.debug("Could not initialize git.");
|
|
180
|
+
}
|
|
296
181
|
});
|
|
182
|
+
|
|
183
|
+
}).stdout.on("data", function(data) {
|
|
184
|
+
console.log(data);
|
|
297
185
|
});
|
|
186
|
+
|
|
298
187
|
}).stdout.on("data", function(data) {
|
|
299
188
|
console.log(data);
|
|
300
189
|
});
|
|
301
|
-
|
|
190
|
+
|
|
191
|
+
})
|
|
192
|
+
.catch((e)=>{
|
|
193
|
+
console.log(e);
|
|
302
194
|
});
|
|
303
|
-
|
|
195
|
+
|
|
196
|
+
|
|
304
197
|
}).stdout.on("data", function(data) {
|
|
305
|
-
|
|
198
|
+
console.log(data);
|
|
306
199
|
});
|
|
307
200
|
|
|
201
|
+
}).stdout.on("data", function(data) {
|
|
202
|
+
console.log("App generation started...");
|
|
308
203
|
});
|
|
309
204
|
|
|
310
205
|
},
|
|
@@ -388,101 +283,104 @@ Package("org.quickcorp.qcobjects.cli",[
|
|
|
388
283
|
}
|
|
389
284
|
|
|
390
285
|
generateServiceWorker(appName){
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
286
|
+
return new Promise( (resolve, reject) => {
|
|
287
|
+
var filelist = ["/"].concat(this.fileListRecursive("./"));
|
|
288
|
+
filelist = filelist.filter(function (fl){return fl !== "sw.js" && (!fl.startsWith("node_modules/")); });
|
|
289
|
+
filelist = filelist.filter(fname => !fname.endsWith(".pem"));
|
|
290
|
+
filelist = filelist.filter(fname => !fname.endsWith(".sh"));
|
|
291
|
+
filelist = filelist.filter(fname => !(new RegExp("^package(.*).json$")).test(fname));
|
|
292
|
+
filelist = filelist.filter(fname => !fname.startsWith("."));
|
|
293
|
+
var fileListString = "\n\t\""+filelist.join("\",\n\t\"")+"\"";
|
|
294
|
+
var component = New(Component, {
|
|
295
|
+
templateURI: "sw.js",
|
|
296
|
+
basePath:templatePwaPath,
|
|
297
|
+
name:"sw",
|
|
298
|
+
cached:false,
|
|
299
|
+
tplsource: "default",
|
|
300
|
+
data: {
|
|
301
|
+
appName: appName,
|
|
302
|
+
appVersion: "1.0.0",
|
|
303
|
+
filelist: fileListString
|
|
304
|
+
},
|
|
305
|
+
done ({request, component}) {
|
|
306
|
+
return new Promise ((resolve, reject)=> {
|
|
307
|
+
fs.writeFile("./sw.js", component.parsedAssignmentText, err => {
|
|
308
|
+
logger.info("Service Worker Generated");
|
|
309
|
+
console.log("");
|
|
310
|
+
console.log("Now simply put:");
|
|
311
|
+
console.log("CONFIG.set('serviceWorkerURI','/sw.js');");
|
|
312
|
+
console.log(" In your init.js file ");
|
|
313
|
+
console.log("");
|
|
314
|
+
console.log("To start your app in a local server ");
|
|
315
|
+
console.log("Execute the command: ");
|
|
316
|
+
console.log("> qcobjects launch <appname>");
|
|
317
|
+
console.log("");
|
|
318
|
+
});
|
|
319
|
+
resolve({request, component});
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
} );
|
|
427
325
|
}
|
|
428
326
|
|
|
429
|
-
copyTemplate(){
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
327
|
+
copyTemplate(source, dest){
|
|
328
|
+
return new Promise ((resolve, reject)=> {
|
|
329
|
+
|
|
330
|
+
const copyDir = (source, dest, exclude) => {
|
|
331
|
+
source = path.resolve(source);
|
|
332
|
+
dest = path.resolve(dest);
|
|
333
|
+
const dname = path.basename(source);
|
|
334
|
+
const dirExcluded = (exclude.includes(dname));
|
|
335
|
+
|
|
336
|
+
const isDir = (d) => {
|
|
337
|
+
return (fs.existsSync(d) && fs.statSync(d).isDirectory())?(true):(false);
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
const isFile = (d) => {
|
|
341
|
+
return (fs.existsSync(d) && fs.statSync(d).isFile())?(true):(false);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
if (isDir(source) && !dirExcluded){
|
|
345
|
+
fs.mkdirSync(dest, {recursive:true});
|
|
346
|
+
const paths = fs.readdirSync(source, {withFileTypes:true})
|
|
347
|
+
const dirs = paths.filter(d=>d.isDirectory());
|
|
348
|
+
const files = paths.filter(f=>f.isFile());
|
|
349
|
+
(async function (paths, dirs, files, exclude){
|
|
350
|
+
files.map((f)=>{
|
|
351
|
+
const sourceFile = path.resolve(source, f.name);
|
|
352
|
+
const destFile = path.resolve(dest, f.name);
|
|
353
|
+
const fileExcluded = exclude.includes(f.name);
|
|
354
|
+
if (isFile(sourceFile) && !fileExcluded){
|
|
355
|
+
logger.debug(`[publish:static] Copying files from ${sourceFile} to ${destFile} excluding ${exclude}...`);
|
|
356
|
+
fs.copyFileSync(sourceFile, destFile);
|
|
357
|
+
logger.debug(`[publish:static] Copying files from ${sourceFile} to ${destFile} excluding ${exclude}...DONE!`);
|
|
358
|
+
}
|
|
437
359
|
});
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
};
|
|
443
|
-
var map_dirnames = function (pathname,callback){
|
|
444
|
-
var _main_pathnames = [];
|
|
445
|
-
var _dirnames = function (pathname){
|
|
446
|
-
fs.readdir(pathname,{withFileTypes:true},function (err,files){
|
|
447
|
-
var _pathnames = [];
|
|
448
|
-
if (typeof files !== "undefined"){
|
|
449
|
-
files.filter((f)=>{return f.isDirectory();}).map((d)=>{
|
|
450
|
-
_pathnames.push(pathname+"/"+d.name);
|
|
451
|
-
callback(pathname+"/"+d.name);
|
|
452
|
-
_dirnames(pathname+"/"+d.name);
|
|
360
|
+
dirs.map((d)=>{
|
|
361
|
+
const sourceDir = path.resolve(source, d.name);
|
|
362
|
+
const destDir = path.resolve(dest, d.name);
|
|
363
|
+
copyDir(sourceDir,destDir, exclude);
|
|
453
364
|
});
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
return _main_pathnames;
|
|
365
|
+
})(paths, dirs, files, exclude);
|
|
366
|
+
}
|
|
367
|
+
|
|
458
368
|
};
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
fs.mkdir(relativePath(dirname),()=>{
|
|
473
|
-
map_files(dirname,(filename)=>{
|
|
474
|
-
logger.debug("Creating file: "+relativePath(filename));
|
|
475
|
-
copyTemplateFile(filename,relativePath(filename));
|
|
476
|
-
});
|
|
477
|
-
});
|
|
478
|
-
});
|
|
479
|
-
map_files(CONFIG.get("qcobjectsnewapp_path"),(filename)=>{
|
|
480
|
-
if (!["./package.json",
|
|
481
|
-
"./package-lock.json",
|
|
482
|
-
"./sw.js"].includes(relativePath(filename))){
|
|
483
|
-
logger.info("Creating file: "+relativePath(filename));
|
|
484
|
-
copyTemplateFile(filename,relativePath(filename));
|
|
369
|
+
|
|
370
|
+
try {
|
|
371
|
+
const exclude = [
|
|
372
|
+
"package.json",
|
|
373
|
+
"node_modules",
|
|
374
|
+
".DS_Store"
|
|
375
|
+
]
|
|
376
|
+
logger.info(`[create] Copying files from ${source} to ${dest} excluding ${exclude}...`);
|
|
377
|
+
copyDir(source, dest, (typeof exclude !== "undefined") ? (exclude) : ([]));
|
|
378
|
+
resolve();
|
|
379
|
+
} catch (e) {
|
|
380
|
+
logger.warn(`Something went wrong trying to publish static files: ${e.message}`);
|
|
381
|
+
reject(e);
|
|
485
382
|
}
|
|
383
|
+
|
|
486
384
|
});
|
|
487
385
|
|
|
488
386
|
}
|
|
@@ -184,35 +184,65 @@ try {
|
|
|
184
184
|
(function () {
|
|
185
185
|
/* Auto Discover dependencies (lib, handlers, commands) */
|
|
186
186
|
const path = require("path");
|
|
187
|
+
const fs = require ("fs");
|
|
187
188
|
const projectPath = CONFIG.get("projectPath", `${process.cwd()}/`);
|
|
188
189
|
logger.debug(`CONFIG.projectPath is set to ${projectPath}`);
|
|
190
|
+
const findPath = (p) => {
|
|
191
|
+
const packagePath = path.resolve(findPackageNodePath(p), p);
|
|
192
|
+
return packagePath;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
const getPackageJSON = (p) => {
|
|
196
|
+
let _json;
|
|
197
|
+
try {
|
|
198
|
+
let packagePath = findPath(p);
|
|
199
|
+
if (typeof packagePath !== "undefined"){
|
|
200
|
+
_json = JSON.parse(fs.readFileSync(path.resolve(`${packagePath}`,"./package.json")).toString());
|
|
201
|
+
} else {
|
|
202
|
+
_json = {};
|
|
203
|
+
}
|
|
204
|
+
} catch (e){
|
|
205
|
+
logger.debug(`It was impossible to get the package.json from ${p}: ${e}`);
|
|
206
|
+
_json = {}
|
|
207
|
+
}
|
|
208
|
+
return _json;
|
|
209
|
+
};
|
|
210
|
+
|
|
189
211
|
const hasKeyword = (p, keyword) => {
|
|
190
212
|
if (typeof hasKeyword.keywords === "undefined"){
|
|
191
213
|
hasKeyword.keywords = {};
|
|
192
214
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
keywords
|
|
196
|
-
}
|
|
197
|
-
|
|
215
|
+
try {
|
|
216
|
+
if (typeof hasKeyword.keywords[p] === "undefined"){
|
|
217
|
+
hasKeyword.keywords[p] = getPackageJSON(p).keywords;
|
|
218
|
+
}
|
|
219
|
+
} catch (e){
|
|
220
|
+
throw Error (`Something went wrong when trying to get the keywords of ${p}`);
|
|
198
221
|
}
|
|
199
222
|
return typeof hasKeyword.keywords[p] !== "undefined" && hasKeyword.keywords[p].includes(keyword);
|
|
200
223
|
};
|
|
201
224
|
|
|
202
225
|
const dependencies = () => {
|
|
203
226
|
if (typeof dependencies.deps === "undefined"){
|
|
204
|
-
dependencies.deps = Object.keys(
|
|
227
|
+
dependencies.deps = Object.keys(JSON.parse(fs.readFileSync(path.resolve(`${projectPath}`,"./package.json")).toString()).dependencies);
|
|
205
228
|
}
|
|
206
229
|
return dependencies.deps;
|
|
207
230
|
};
|
|
208
231
|
|
|
232
|
+
const devDependencies = () => {
|
|
233
|
+
if (typeof devDependencies.deps === "undefined"){
|
|
234
|
+
devDependencies.deps = Object.keys(JSON.parse(fs.readFileSync(path.resolve(`${projectPath}`,"./package.json")).toString()).devDependencies);
|
|
235
|
+
}
|
|
236
|
+
return devDependencies.deps;
|
|
237
|
+
};
|
|
238
|
+
|
|
209
239
|
const loadLibs = () => {
|
|
210
240
|
let _ret_;
|
|
211
241
|
if (CONFIG.get("autodiscover", false) || CONFIG.get("autodiscover_libs", false)) {
|
|
212
242
|
const libs = dependencies().filter((p) => hasKeyword(p, "qcobjects-lib"));
|
|
213
243
|
if (libs.length>0){
|
|
214
244
|
logger.debug(`Plugin Libs found: ${libs}`);
|
|
215
|
-
_ret_ = Promise.all(libs.map((p) => {return
|
|
245
|
+
_ret_ = Promise.all(libs.map((p) => {return require(findPath(p));})).then(() => logger.info("Libs loaded"));
|
|
216
246
|
} else {
|
|
217
247
|
logger.debug("No Plugin Libs found.");
|
|
218
248
|
_ret_ = Promise.resolve();
|
|
@@ -229,7 +259,7 @@ try {
|
|
|
229
259
|
const handlers = dependencies().filter((p) => hasKeyword(p, "qcobjects-handler"));
|
|
230
260
|
if (handlers.length>0){
|
|
231
261
|
logger.debug(`Plugin Handlers found: ${handlers}`);
|
|
232
|
-
_ret_ = Promise.all(handlers.map((p) => {return
|
|
262
|
+
_ret_ = Promise.all(handlers.map((p) => {return require(findPath(p));})).then(() => logger.info("Handlers loaded"));
|
|
233
263
|
} else {
|
|
234
264
|
logger.debug("No Plugin Handlers found.");
|
|
235
265
|
_ret_ = Promise.resolve();
|
|
@@ -247,7 +277,7 @@ try {
|
|
|
247
277
|
const commands = dependencies().filter((p) => hasKeyword(p, "qcobjects-command"));
|
|
248
278
|
if (commands.length>0){
|
|
249
279
|
logger.debug(`Plugin Commands found: ${commands}`);
|
|
250
|
-
_ret_ = Promise.all(commands.map((p) => {return
|
|
280
|
+
_ret_ = Promise.all(commands.map((p) => {return require(findPath(p));})).then(() => logger.info("Commands loaded"));
|
|
251
281
|
} else {
|
|
252
282
|
logger.debug("No Plugin Commands found.");
|
|
253
283
|
_ret_ = Promise.resolve();
|
|
@@ -258,6 +288,25 @@ try {
|
|
|
258
288
|
}
|
|
259
289
|
return _ret_;
|
|
260
290
|
};
|
|
291
|
+
const loadDevCommands = () => {
|
|
292
|
+
let _ret_;
|
|
293
|
+
logger.debug(`Looking for custom commands as dev dependencies in: ${projectPath}/package.json`);
|
|
294
|
+
if (CONFIG.get("autodiscover", false) || CONFIG.get("autodiscover_commands", false)) {
|
|
295
|
+
const commands = devDependencies().filter((p) => hasKeyword(p, "qcobjects-command"));
|
|
296
|
+
if (commands.length>0){
|
|
297
|
+
logger.debug(`Dev Plugin Commands found: ${commands}`);
|
|
298
|
+
_ret_ = Promise.all(commands.map((p) => {return require(findPath(p));})).then(() => logger.info("Commands loaded"));
|
|
299
|
+
} else {
|
|
300
|
+
logger.debug("No Plugin Commands found in dev dependencies.");
|
|
301
|
+
_ret_ = Promise.resolve();
|
|
302
|
+
}
|
|
303
|
+
} else {
|
|
304
|
+
logger.debug("To load commands, set autodiscover_commands to true in your config.json");
|
|
305
|
+
_ret_ = Promise.resolve();
|
|
306
|
+
}
|
|
307
|
+
return _ret_;
|
|
308
|
+
};
|
|
309
|
+
|
|
261
310
|
if (CONFIG.get("autodiscover", false) ||
|
|
262
311
|
CONFIG.get("autodiscover_libs", false) ||
|
|
263
312
|
CONFIG.get("autodiscover_handlers", false) ||
|
|
@@ -289,5 +338,12 @@ try {
|
|
|
289
338
|
} catch (e) {
|
|
290
339
|
throw Error(`Something went wrong trying to load commands: ${e.message}`);
|
|
291
340
|
}
|
|
341
|
+
try {
|
|
342
|
+
logger.debug("Loading Dev Commands...");
|
|
343
|
+
loadDevCommands();
|
|
344
|
+
} catch (e) {
|
|
345
|
+
throw Error(`Something went wrong trying to load Dev commands: ${e.message}`);
|
|
346
|
+
}
|
|
347
|
+
|
|
292
348
|
logger.info("Dependencies loaded");
|
|
293
349
|
})();
|
package/tsconfig.d.json
ADDED
package/tsconfig.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "qcobjects-tsconfig/tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"rootDir": "src", /* Specify the root folder within your source files. */
|
|
5
|
+
"allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
6
|
+
"outDir": "build", /* Specify an output folder for all emitted files. */
|
|
7
|
+
},
|
|
8
|
+
"include": ["src/**/*.ts"],
|
|
9
|
+
"exclude": ["src/**/*.spec.js", "src/*.js"]
|
|
10
|
+
}
|