qa-control 0.6.1 → 0.6.3
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/README.md +2 -3
- package/bin/definition/definition.js +78 -94
- package/bin/qa-control-run.js +4 -2
- package/bin/qa-control.js +8 -8
- package/bin/qac-init.js +4 -4
- package/package.json +29 -22
package/README.md
CHANGED
|
@@ -6,11 +6,10 @@ Quality assurance tool for node/npm projects
|
|
|
6
6
|

|
|
7
7
|
[](https://npmjs.org/package/qa-control)
|
|
8
8
|
[](https://npmjs.org/package/qa-control)
|
|
9
|
-
[](https://github.com/codenautas/qa-control/actions/workflows/build-and-test.yml)
|
|
10
10
|
[](https://coveralls.io/r/codenautas/qa-control)
|
|
11
|
-
[](https://codeclimate.com/github/codenautas/qa-control)
|
|
12
11
|
[](https://snyk.io/test/github/codenautas/qa-control)
|
|
13
|
-
[](https://github.com/codenautas/qa-control/actions/workflows/qa-control.yml)
|
|
14
13
|
|
|
15
14
|
|
|
16
15
|
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var stripBom = require("strip-bom-string");
|
|
4
4
|
var semver = require("semver");
|
|
5
|
-
var jsh = require('jshint');
|
|
6
5
|
var esl = require('eslint');
|
|
7
6
|
var eslintLinter = new esl.Linter();
|
|
8
7
|
function eslintrcToFlatConfig(rc) {
|
|
@@ -10,7 +9,7 @@ function eslintrcToFlatConfig(rc) {
|
|
|
10
9
|
if (rc.rules) { flat.rules = rc.rules; }
|
|
11
10
|
var sourceType = (rc.env && rc.env.node) ? 'commonjs' : 'script';
|
|
12
11
|
flat.languageOptions = { ecmaVersion: 'latest', sourceType: sourceType };
|
|
13
|
-
flat.linterOptions = { reportUnusedDisableDirectives:
|
|
12
|
+
flat.linterOptions = { reportUnusedDisableDirectives: false };
|
|
14
13
|
return flat;
|
|
15
14
|
}
|
|
16
15
|
var multilang = require('multilang');
|
|
@@ -18,6 +17,20 @@ var fs = require('fs-promise');
|
|
|
18
17
|
var Path = require('path');
|
|
19
18
|
var yaml = require('js-yaml');
|
|
20
19
|
|
|
20
|
+
/** @param {string} realRegex */
|
|
21
|
+
function softRegExp(realRegex) {
|
|
22
|
+
var re=realRegex.replace(/\\/g, '\\\\')
|
|
23
|
+
.replace(/\s*(=+)\s*/g,'\\s*$1\\s*')
|
|
24
|
+
.replace(/ /g, '\\s+')
|
|
25
|
+
.replace(/\(/g, '\\(')
|
|
26
|
+
.replace(/\)/g, '\\)');
|
|
27
|
+
return new RegExp(re, 'im');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @param {object} qaControl
|
|
32
|
+
* @returns {QADefinition}
|
|
33
|
+
*/
|
|
21
34
|
module.exports = function(qaControl){
|
|
22
35
|
return {
|
|
23
36
|
fileNameMainDoc: 'LEEME.md',
|
|
@@ -42,7 +55,7 @@ module.exports = function(qaControl){
|
|
|
42
55
|
},
|
|
43
56
|
files:{
|
|
44
57
|
'README.md':{ mandatory:true },
|
|
45
|
-
'LEEME.md':{
|
|
58
|
+
'LEEME.md':{ presentIf: function(pj) { return !(pj['qa-control'] && pj['qa-control'].multilang === 'no'); } },
|
|
46
59
|
'.gitignore':{
|
|
47
60
|
mandatory:true,
|
|
48
61
|
mandatoryLines:['local-*','*-local.*']
|
|
@@ -53,7 +66,6 @@ module.exports = function(qaControl){
|
|
|
53
66
|
return !!packageJson['qa-control']["test-appveyor"];
|
|
54
67
|
}
|
|
55
68
|
},
|
|
56
|
-
'.jshintrc':{ presentIf: function(pj) { return pj['qa-control'] && pj['qa-control'].profile !== 'minimum'; } },
|
|
57
69
|
'.eslintrc.yml':{ presentIf: function(pj) { return pj['qa-control'] && pj['qa-control'].profile !== 'minimum'; } }
|
|
58
70
|
},
|
|
59
71
|
cucardas:{
|
|
@@ -119,7 +131,7 @@ module.exports = function(qaControl){
|
|
|
119
131
|
check: function(packageJson){
|
|
120
132
|
return !packageJson['qa-control']['test-appveyor'];
|
|
121
133
|
},
|
|
122
|
-
md:'[](https://github.com/xxx/yyy/actions/workflows/build-and-test.yml)',
|
|
123
135
|
imgExample:'https://raw.githubusercontent.com/codenautas/codenautas/master/img/medalla-ejemplo-linux.png',
|
|
124
136
|
docDescription: 'linux/build'
|
|
125
137
|
},
|
|
@@ -127,7 +139,7 @@ module.exports = function(qaControl){
|
|
|
127
139
|
check: function(packageJson){
|
|
128
140
|
return !!packageJson['qa-control']['test-appveyor'];
|
|
129
141
|
},
|
|
130
|
-
md:'[](https://github.com/xxx/yyy/actions/workflows/build-and-test.yml)',
|
|
131
143
|
imgExample:'https://raw.githubusercontent.com/codenautas/codenautas/master/img/medalla-ejemplo-linux.png',
|
|
132
144
|
hideInManual: true,
|
|
133
145
|
},
|
|
@@ -147,14 +159,6 @@ module.exports = function(qaControl){
|
|
|
147
159
|
imgExample:'https://raw.githubusercontent.com/codenautas/codenautas/master/img/coverage.png',
|
|
148
160
|
docDescription: ''
|
|
149
161
|
},
|
|
150
|
-
climate:{
|
|
151
|
-
check: function(packageJson){
|
|
152
|
-
return packageJson['qa-control'].coverage || ! packageJson['qa-control'].purpose;
|
|
153
|
-
},
|
|
154
|
-
md:'[](https://codeclimate.com/github/xxx/yyy)',
|
|
155
|
-
imgExample:'https://raw.githubusercontent.com/codenautas/codenautas/master/img/climate.png',
|
|
156
|
-
docDescription: ''
|
|
157
|
-
},
|
|
158
162
|
dependencies:{
|
|
159
163
|
mandatory:true,
|
|
160
164
|
md:'[](https://snyk.io/test/github/xxx/yyy)',
|
|
@@ -163,23 +167,17 @@ module.exports = function(qaControl){
|
|
|
163
167
|
},
|
|
164
168
|
'qa-control':{
|
|
165
169
|
mandatory:false,
|
|
166
|
-
md:'[](https://github.com/xxx/yyy/actions/workflows/qa-control.yml)',
|
|
167
171
|
docDescription: ''
|
|
168
172
|
},
|
|
169
173
|
'outdated-deps':{
|
|
170
|
-
forbidden:true
|
|
171
|
-
|
|
174
|
+
forbidden:true
|
|
175
|
+
},
|
|
176
|
+
'climate':{
|
|
177
|
+
forbidden:true
|
|
172
178
|
}
|
|
173
179
|
},
|
|
174
180
|
customs:{
|
|
175
|
-
softRegExp:function(realRegex) {
|
|
176
|
-
var re=realRegex.replace(/\\/g, '\\\\')
|
|
177
|
-
.replace(/\s*(=+)\s*/g,'\\s*$1\\s*')
|
|
178
|
-
.replace(/ /g, '\\s+')
|
|
179
|
-
.replace(/\(/g, '\\(')
|
|
180
|
-
.replace(/\)/g, '\\)');
|
|
181
|
-
return new RegExp(re, 'im');
|
|
182
|
-
},
|
|
183
181
|
funtion_eid:{
|
|
184
182
|
detect:'function eid',
|
|
185
183
|
match:'function eid(id){ return document.getElementById(id); }'
|
|
@@ -194,7 +192,6 @@ module.exports = function(qaControl){
|
|
|
194
192
|
match:"var Path = require('path');"
|
|
195
193
|
}
|
|
196
194
|
},
|
|
197
|
-
jshint_options: { "asi": false, "curly": true, "forin": true },
|
|
198
195
|
eslint_options: {
|
|
199
196
|
"env": {
|
|
200
197
|
"node": false
|
|
@@ -230,6 +227,49 @@ module.exports = function(qaControl){
|
|
|
230
227
|
}],
|
|
231
228
|
shouldAbort:true
|
|
232
229
|
},
|
|
230
|
+
repository_in_package_json:{
|
|
231
|
+
checks:[{
|
|
232
|
+
warnings:function(info) {
|
|
233
|
+
var warns = [];
|
|
234
|
+
if(!('repository' in info.packageJson)) {
|
|
235
|
+
warns.push({warning:'lack_of_repository_section_in_package_json', scoring:{mandatories:1}});
|
|
236
|
+
} else {
|
|
237
|
+
if(! qaControl.getRepositoryUrl(info.packageJson).match(/^([-a-zA-Z0-9_.]+\/[-a-zA-Z0-9_.]+)$/)){
|
|
238
|
+
return [{warning:'repository_name_not_found', scoring:{mandatories:1}}];
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return warns;
|
|
242
|
+
}
|
|
243
|
+
}],
|
|
244
|
+
shouldAbort:true
|
|
245
|
+
},
|
|
246
|
+
invalid_repository_in_package_json:{
|
|
247
|
+
checks:[{
|
|
248
|
+
warnings:function(info) {
|
|
249
|
+
var warns = [];
|
|
250
|
+
var repoParts = qaControl.getRepositoryUrl(info.packageJson).split('/');
|
|
251
|
+
var projName = repoParts[repoParts.length-1];
|
|
252
|
+
if(projName !== info.packageJson.name) {
|
|
253
|
+
return [{warning:'invalid_repository_section_in_package_json', scoring:{repository:1}}];
|
|
254
|
+
}
|
|
255
|
+
return warns;
|
|
256
|
+
}
|
|
257
|
+
}]
|
|
258
|
+
},
|
|
259
|
+
github_repository:{
|
|
260
|
+
eclipsers:['lack_of_repository_section_in_package_json', 'repository_name_not_found', 'invalid_repository_section_in_package_json'],
|
|
261
|
+
checks:[{
|
|
262
|
+
warnings:function(info) {
|
|
263
|
+
if(!qaControl.repoIs) { return []; }
|
|
264
|
+
var actual = qaControl.getRepositoryUrl(info.packageJson).replace(/\.git$/, '');
|
|
265
|
+
var expected = qaControl.repoIs.replace(/\.git$/, '');
|
|
266
|
+
if(actual !== expected) {
|
|
267
|
+
return [{warning:'repository_does_not_match_1', params:[expected], scoring:{repository:1}}];
|
|
268
|
+
}
|
|
269
|
+
return [];
|
|
270
|
+
}
|
|
271
|
+
}]
|
|
272
|
+
},
|
|
233
273
|
mandatory_files:{
|
|
234
274
|
checks:[{
|
|
235
275
|
warnings:function(info) {
|
|
@@ -252,22 +292,6 @@ module.exports = function(qaControl){
|
|
|
252
292
|
}],
|
|
253
293
|
shouldAbort:true
|
|
254
294
|
},
|
|
255
|
-
repository_in_package_json:{
|
|
256
|
-
checks:[{
|
|
257
|
-
warnings:function(info) {
|
|
258
|
-
var warns = [];
|
|
259
|
-
if(!('repository' in info.packageJson)) {
|
|
260
|
-
warns.push({warning:'lack_of_repository_section_in_package_json', scoring:{mandatories:1}});
|
|
261
|
-
} else {
|
|
262
|
-
if(! qaControl.getRepositoryUrl(info.packageJson).match(/^([-a-zA-Z0-9_.]+\/[-a-zA-Z0-9_.]+)$/)){
|
|
263
|
-
return [{warning:'repository_name_not_found', scoring:{mandatories:1}}];
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
return warns;
|
|
267
|
-
}
|
|
268
|
-
}],
|
|
269
|
-
shouldAbort:true
|
|
270
|
-
},
|
|
271
295
|
valid_values_for_qa_control_keys:{
|
|
272
296
|
checks:[{
|
|
273
297
|
warnings:function(info){
|
|
@@ -318,6 +342,7 @@ module.exports = function(qaControl){
|
|
|
318
342
|
no_multilang_section_in_1:{
|
|
319
343
|
checks:[{
|
|
320
344
|
warnings:function(info){
|
|
345
|
+
if(info.packageJson['qa-control'] && info.packageJson['qa-control'].multilang === 'no') { return []; }
|
|
321
346
|
if(!info.files[qaControl.mainDoc()].content.match(/<!--multilang v[0-9]+\s+(.+)(-->)/)) {
|
|
322
347
|
return [{
|
|
323
348
|
warning:'no_multilang_section_in_1',
|
|
@@ -329,23 +354,11 @@ module.exports = function(qaControl){
|
|
|
329
354
|
}
|
|
330
355
|
}]
|
|
331
356
|
},
|
|
332
|
-
invalid_repository_in_package_json:{
|
|
333
|
-
checks:[{
|
|
334
|
-
warnings:function(info) {
|
|
335
|
-
var warns = [];
|
|
336
|
-
var repoParts = qaControl.getRepositoryUrl(info.packageJson).split('/');
|
|
337
|
-
var projName = repoParts[repoParts.length-1];
|
|
338
|
-
if(projName !== info.packageJson.name) {
|
|
339
|
-
return [{warning:'invalid_repository_section_in_package_json', scoring:{repository:1}}];
|
|
340
|
-
}
|
|
341
|
-
return warns;
|
|
342
|
-
}
|
|
343
|
-
}]
|
|
344
|
-
},
|
|
345
357
|
cucardas:{
|
|
346
358
|
eclipsers:['invalid_repository_section_in_package_json', 'lack_of_repository_section_in_package_json'],
|
|
347
359
|
checks:[{
|
|
348
360
|
warnings:function(info){
|
|
361
|
+
if(info.packageJson['qa-control'] && info.packageJson['qa-control'].multilang === 'no') { return []; }
|
|
349
362
|
var warns=[];
|
|
350
363
|
var readme=info.files[qaControl.mainDoc()].content;
|
|
351
364
|
if(readme.indexOf(qaControl.cucaMarker) === -1) {
|
|
@@ -357,8 +370,8 @@ module.exports = function(qaControl){
|
|
|
357
370
|
/*jshint forin: false */
|
|
358
371
|
for(var nombreCucarda in cucardas) {
|
|
359
372
|
var cucarda = cucardas[nombreCucarda];
|
|
360
|
-
var cucaID = '!['+/!\[([-a-z]+)]/.exec(cucarda.md)[1]+']';
|
|
361
|
-
var cucaStr = cucarda.md.replace(/\bxxx\b/g,repo).replace(/\byyy\b/g,modulo);
|
|
373
|
+
var cucaID = cucarda.forbidden ? '!['+nombreCucarda+']' : '!['+/!\[([-a-z]+)]/.exec(cucarda.md)[1]+']';
|
|
374
|
+
var cucaStr = cucarda.md ? cucarda.md.replace(/\bxxx\b/g,repo).replace(/\byyy\b/g,modulo) : '';
|
|
362
375
|
if(cucarda.forbidden) {
|
|
363
376
|
if(readme.indexOf(cucaID) !== -1) {
|
|
364
377
|
warns.push({warning:'forbidden_cucarda_1', params:[nombreCucarda], scoring:{cucardas:1}});
|
|
@@ -404,7 +417,7 @@ module.exports = function(qaControl){
|
|
|
404
417
|
if(isMatchFunc) {
|
|
405
418
|
return str.indexOf(strOrRegexp) !== -1;
|
|
406
419
|
} else {
|
|
407
|
-
return
|
|
420
|
+
return softRegExp(strOrRegexp).test(str);
|
|
408
421
|
}
|
|
409
422
|
};
|
|
410
423
|
}
|
|
@@ -433,6 +446,7 @@ module.exports = function(qaControl){
|
|
|
433
446
|
first_lines:{
|
|
434
447
|
checks:[{
|
|
435
448
|
warnings:function(info) {
|
|
449
|
+
if(info.packageJson['qa-control'] && info.packageJson['qa-control'].profile === 'minimum') { return []; }
|
|
436
450
|
var warns=[];
|
|
437
451
|
var qaControlSection=info.packageJson['qa-control'];
|
|
438
452
|
var whichRunIn=qaControlSection['run-in'];
|
|
@@ -489,35 +503,6 @@ module.exports = function(qaControl){
|
|
|
489
503
|
}
|
|
490
504
|
}]
|
|
491
505
|
},
|
|
492
|
-
jshint:{
|
|
493
|
-
eclipsers:['packagejson_main_file_1_does_not_exists', 'first_lines_does_not_match_in_file_1'],
|
|
494
|
-
mandatory:false,
|
|
495
|
-
checks:[{
|
|
496
|
-
warnings:function(info){
|
|
497
|
-
if(info.packageJson['qa-control'] && info.packageJson['qa-control'].profile === 'minimum') { return []; }
|
|
498
|
-
var warns = [];
|
|
499
|
-
var jshintOpts = JSON.parse(info.files['.jshintrc'].content);
|
|
500
|
-
for(var file in info.files) {
|
|
501
|
-
if(file.match(/(.js)$/)) {
|
|
502
|
-
var content = info.files[file].content;
|
|
503
|
-
jsh.JSHINT(content, jshintOpts , false);
|
|
504
|
-
var data = jsh.JSHINT.data();
|
|
505
|
-
if(data.errors) {
|
|
506
|
-
if(qaControl.verbose){
|
|
507
|
-
console.log('JSHINT output:');
|
|
508
|
-
console.log('jshintOpts',jshintOpts);
|
|
509
|
-
console.log('There are '+data.length+ " JSHINT errors");
|
|
510
|
-
console.log(data.errors);
|
|
511
|
-
//console.log(data);
|
|
512
|
-
}
|
|
513
|
-
warns.push({warning:'jshint_warnings_in_file_1', params:[file], scoring:{jshint:1}});
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
return warns;
|
|
518
|
-
}
|
|
519
|
-
}]
|
|
520
|
-
},
|
|
521
506
|
eslint:{
|
|
522
507
|
eclipsers:['packagejson_main_file_1_does_not_exists', 'first_lines_does_not_match_in_file_1'],
|
|
523
508
|
checks:[{
|
|
@@ -528,7 +513,7 @@ module.exports = function(qaControl){
|
|
|
528
513
|
for(var file in info.files) {
|
|
529
514
|
if(file.match(/(.js)$/)) {
|
|
530
515
|
var content = info.files[file].content;
|
|
531
|
-
var data = eslintLinter.verify(content, eslintOpts);
|
|
516
|
+
var data = eslintLinter.verify(content || '', eslintOpts);
|
|
532
517
|
if(data.length) {
|
|
533
518
|
if(qaControl.verbose){
|
|
534
519
|
console.log('ESLINT output:');
|
|
@@ -548,6 +533,7 @@ module.exports = function(qaControl){
|
|
|
548
533
|
multilang:{
|
|
549
534
|
checks:[{
|
|
550
535
|
warnings:function(info) {
|
|
536
|
+
if(info.packageJson['qa-control'] && info.packageJson['qa-control'].multilang === 'no') { return []; }
|
|
551
537
|
var warns = [];
|
|
552
538
|
var defReadme = qaControl.mainDoc();
|
|
553
539
|
var content = info.files[defReadme].content;
|
|
@@ -582,7 +568,8 @@ module.exports = function(qaControl){
|
|
|
582
568
|
for(var file in info.files) {
|
|
583
569
|
if(file.match(/(.js)$/)) {
|
|
584
570
|
var content = info.files[file].content;
|
|
585
|
-
|
|
571
|
+
if(content === undefined) { continue; }
|
|
572
|
+
var lines = content.split(/\r?\n/);
|
|
586
573
|
var prevLine = null;
|
|
587
574
|
for(var l=0; l<lines.length; ++l) {
|
|
588
575
|
var line = lines[l];
|
|
@@ -655,9 +642,6 @@ module.exports = function(qaControl){
|
|
|
655
642
|
checks:[{
|
|
656
643
|
warnings:function(info) {
|
|
657
644
|
var warns = [];
|
|
658
|
-
if('jshintConfig' in info.packageJson) {
|
|
659
|
-
warns.push({warning:'unexpected_jshintconfig_section_in_package_json', scoring:{conventions:1}});
|
|
660
|
-
}
|
|
661
645
|
if('eslintConfig' in info.packageJson) {
|
|
662
646
|
warns.push({warning:'unexpected_eslintconfig_section_in_package_json', scoring:{conventions:1}});
|
|
663
647
|
}
|
|
@@ -669,12 +653,12 @@ module.exports = function(qaControl){
|
|
|
669
653
|
checks:[{
|
|
670
654
|
warnings:function(info) {
|
|
671
655
|
var warns = [];
|
|
672
|
-
var nonRecomended = ['best-promise', 'lodash', 'promise-plus'];
|
|
656
|
+
var nonRecomended = ['best-promise', 'jslint', 'lodash', 'promise-plus'];
|
|
673
657
|
var dependencies = info.packageJson.dependencies;
|
|
674
658
|
var devDependencies = info.packageJson.devDependencies;
|
|
675
659
|
if(dependencies) {
|
|
676
660
|
nonRecomended.forEach(function(badDep) {
|
|
677
|
-
if(badDep in dependencies || badDep in devDependencies) {
|
|
661
|
+
if(badDep in (dependencies||{}) || (devDependencies && badDep in devDependencies)) {
|
|
678
662
|
warns.push({warning:'non_recomended_dependency_1_in_package_json', params:[badDep], scoring:{dependencies:1}});
|
|
679
663
|
}
|
|
680
664
|
});
|
package/bin/qa-control-run.js
CHANGED
|
@@ -9,7 +9,7 @@ var fs = require('fs-promise');
|
|
|
9
9
|
var path = require('path');
|
|
10
10
|
|
|
11
11
|
program
|
|
12
|
-
.version(require('../package').version)
|
|
12
|
+
.version(require('../package.json').version)
|
|
13
13
|
.argument('[projectDirectory]', 'Project directory to check')
|
|
14
14
|
.usage('[[options] projectDirectory|--list-langs]')
|
|
15
15
|
.option('-l, --lang [lang]', 'Language to generate')
|
|
@@ -17,11 +17,12 @@ program
|
|
|
17
17
|
.option('-L, --list-langs', 'List available languages')
|
|
18
18
|
.option('-c, --cucardas', 'Always generate cucardas.log')
|
|
19
19
|
.option('-i, --init', 'Initialize project with qa-control specs')
|
|
20
|
+
.option('--repo-is <owner_or_org/repo>', 'Expected GitHub repository (owner_or_org/repo)')
|
|
20
21
|
.parse(process.argv);
|
|
21
22
|
|
|
22
23
|
var opts = program.opts();
|
|
23
24
|
|
|
24
|
-
if( ( !opts.init && !opts.listLangs && (
|
|
25
|
+
if( ( !opts.init && !opts.listLangs && (program.args.length===0 && !opts.projectDir))
|
|
25
26
|
|| (opts.lang && false === opts.lang in qaControl.msgs) )
|
|
26
27
|
{
|
|
27
28
|
program.help();
|
|
@@ -33,6 +34,7 @@ params.verbose = opts.verbose;
|
|
|
33
34
|
params.listLangs = opts.listLangs;
|
|
34
35
|
params.lang = opts.lang;
|
|
35
36
|
params.cucardas = opts.cucardas;
|
|
37
|
+
params.repoIs = opts.repoIs || process.env.GITHUB_REPOSITORY || null;
|
|
36
38
|
// console.log(opts); process.exit(0);
|
|
37
39
|
// console.log(params); process.exit(0);
|
|
38
40
|
|
package/bin/qa-control.js
CHANGED
|
@@ -25,6 +25,7 @@ function forEach(obj, func) {
|
|
|
25
25
|
|
|
26
26
|
qaControl.msgs={
|
|
27
27
|
en:{
|
|
28
|
+
lack_of_mandatory_section_1: 'lack of mandatory section "$1" in qa-control section of package.json',
|
|
28
29
|
repository_name_not_found: 'packageJson.repository must be in format /{[-a-zA-Z0-9_.]+}\/[-a-zA-Z0-9_.]+/'
|
|
29
30
|
},
|
|
30
31
|
es:{
|
|
@@ -48,19 +49,16 @@ qaControl.msgs={
|
|
|
48
49
|
repository_name_not_found: 'packageJson.repository no tiene el formato /{[-a-zA-Z0-9_.]+}\/[-a-zA-Z0-9_.]+/',
|
|
49
50
|
using_normal_promise_in_file_1: 'se han usado Promise(s) normales en "$1"',
|
|
50
51
|
packagejson_main_file_1_does_not_exists: 'no existe el archivo "main" ($1) declarado en package.json',
|
|
51
|
-
jshint_warnings_in_file_1: 'el archivo "$1" tiene warnings de JSHint',
|
|
52
52
|
eslint_warnings_in_file_1: 'el archivo "$1" tiene warnings de ESLint',
|
|
53
|
-
lack_of_jshintconfig_section_in_package_json: 'falta la sección "jshintConfig" en package.json',
|
|
54
|
-
incorrect_jshintconfig_option_1_in_package_json: 'la opcion "$1" en "jshintConfig" es incorrecta en package.json',
|
|
55
53
|
readme_multilang_not_sincronized_with_file_1: 'README.md no esta sincronizado con "$1" para multilang',
|
|
56
54
|
lack_of_repository_section_in_package_json: 'Falta la sección "repository" en package.json',
|
|
57
55
|
invalid_repository_section_in_package_json: 'La sección "repository" en package.json es inválida',
|
|
56
|
+
repository_does_not_match_1: 'el repositorio no coincide con el esperado "$1"',
|
|
58
57
|
invalid_dependency_version_number_format_in_dep_1: 'El formato del numero de version es incorrecto en "$1"',
|
|
59
58
|
wrong_use_strict_spelling_in_file_1: '"use strict" está mal escrito en "$1"',
|
|
60
59
|
lack_of_files_section_in_package_json: 'Falta la sección "files" en package.json',
|
|
61
60
|
invalid_files_section_in_package_json: 'La sección "files" en package.json es inválida',
|
|
62
61
|
incorrect_ecmascript_versions_in_package_json: 'Las versiones de ECMAScript utilizadas en package.json son incorrectas',
|
|
63
|
-
unexpected_jshintconfig_section_in_package_json: 'No se esperaba la sección jshintConfig en package.json',
|
|
64
62
|
non_recomended_dependency_1_in_package_json: 'Dependencia no recomendada "$1" en package.json'
|
|
65
63
|
}
|
|
66
64
|
};
|
|
@@ -179,6 +177,7 @@ qaControl.nodeVerInTravisRE = /[678]/;
|
|
|
179
177
|
|
|
180
178
|
qaControl.verbose = false;
|
|
181
179
|
qaControl.cucardas_always = false;
|
|
180
|
+
qaControl.repoIs = null;
|
|
182
181
|
qaControl.definition = require("./definition/definition.js")(qaControl);
|
|
183
182
|
|
|
184
183
|
qaControl.lang = process.env.qa_control_lang || 'en';
|
|
@@ -241,7 +240,7 @@ var configReading=(function(){
|
|
|
241
240
|
});
|
|
242
241
|
|
|
243
242
|
qaControl.loadProject = function loadProject(projectDir) {
|
|
244
|
-
var info = {projectDir:projectDir};
|
|
243
|
+
var info = /** @type {ProjectInfo} */ ({projectDir:projectDir});
|
|
245
244
|
var cmsgs = qaControl.cmdMsgs[qaControl.lang];
|
|
246
245
|
if(qaControl.verbose) { process.stdout.write(cmsgs.msg_starting+projectDir+"'...\n"); }
|
|
247
246
|
return Promise.resolve().then(function(){
|
|
@@ -268,7 +267,7 @@ qaControl.loadProject = function loadProject(projectDir) {
|
|
|
268
267
|
/*jshint forin: true */
|
|
269
268
|
/*eslint-enable guard-for-in */
|
|
270
269
|
if(files.indexOf('package.json') !== -1) {
|
|
271
|
-
info.packageJson = {};
|
|
270
|
+
info.packageJson = /** @type {PackageJson} */ ({});
|
|
272
271
|
}
|
|
273
272
|
return Promise.all(files.map(function(file){
|
|
274
273
|
var iFile = Path.normalize(projectDir+'/'+file);
|
|
@@ -320,7 +319,7 @@ qaControl.controlInfo=function controlInfo(info, opts){
|
|
|
320
319
|
var cmsgs = qaControl.cmdMsgs[qaControl.lang];
|
|
321
320
|
var rules = qaControl.definition.rules;
|
|
322
321
|
var silenced = ((info.packageJson || {})['qa-control'] || {}).silenced || [];
|
|
323
|
-
var cadenaDePromesas = Promise.resolve(
|
|
322
|
+
var cadenaDePromesas = Promise.resolve(/** @type {Warning[]} */ ([]));
|
|
324
323
|
info.scoring = opts && opts.scoring;
|
|
325
324
|
forEach(rules, function(rule, ruleName) {
|
|
326
325
|
rule.checks.forEach(function(checkInfo){
|
|
@@ -366,7 +365,7 @@ qaControl.stringizeWarnings = function stringizeWarnings(warns, lang) {
|
|
|
366
365
|
if(numParams) {
|
|
367
366
|
//console.log(warn.warning, msg, " tiene ", numParams.length, " parametros y params tiene ", warn.params)
|
|
368
367
|
for(var p=0; p<numParams.length; ++p) {
|
|
369
|
-
msg = msg.replace('$'+
|
|
368
|
+
msg = msg.replace('$'+(p+1), warn.params[p]);
|
|
370
369
|
}
|
|
371
370
|
}
|
|
372
371
|
if(qaControl.verbose) {
|
|
@@ -381,6 +380,7 @@ qaControl.stringizeWarnings = function stringizeWarnings(warns, lang) {
|
|
|
381
380
|
qaControl.controlProject=function controlProject(projectDir, opts){
|
|
382
381
|
qaControl.verbose = opts && opts.verbose;
|
|
383
382
|
qaControl.cucardas_always = opts && opts.cucardas;
|
|
383
|
+
qaControl.repoIs = (opts && opts.repoIs) || null;
|
|
384
384
|
return Promise.resolve().then(function(){
|
|
385
385
|
return qaControl.loadProject(projectDir);
|
|
386
386
|
}).then(function(info){
|
package/bin/qac-init.js
CHANGED
|
@@ -102,7 +102,7 @@ qacInit.ask = function ask(param, msgs, callback) {
|
|
|
102
102
|
stdin.resume();
|
|
103
103
|
var prompt = param.prompt || param.name.substring(0,1).toUpperCase()+param.name.substring(1);
|
|
104
104
|
stdout.write(prompt+def+ ": ");
|
|
105
|
-
stdin.once('data', function(data) {
|
|
105
|
+
stdin.once('data', function(/** @type {any} */ data) {
|
|
106
106
|
data = data.toString().trim();
|
|
107
107
|
if(data === '') { data = param.def; }
|
|
108
108
|
if((param.valid && param.valid(data)) || (! param.valid && data !== '')) {
|
|
@@ -254,7 +254,7 @@ qacInit.configParams = [
|
|
|
254
254
|
},
|
|
255
255
|
post: function(ctx) {
|
|
256
256
|
var contributors = ctx.input.existingJson.contributors || [];
|
|
257
|
-
var nae = this.parseNE(ctx.result[this.name]);
|
|
257
|
+
var nae = /** @type {{name: string, email: string}} */ (this.parseNE(ctx.result[this.name]));
|
|
258
258
|
contributors.push({'name':nae.name, 'email':nae.email});
|
|
259
259
|
return contributors.length ? contributors : null;
|
|
260
260
|
},
|
|
@@ -293,8 +293,8 @@ qacInit.init = function init(initParams) {
|
|
|
293
293
|
var inputParams;
|
|
294
294
|
var tplData = {
|
|
295
295
|
vars: {},
|
|
296
|
-
tpls: [],
|
|
297
|
-
other: []
|
|
296
|
+
tpls: /** @type {string[]} */ ([]),
|
|
297
|
+
other: /** @type {string[]} */ ([])
|
|
298
298
|
};
|
|
299
299
|
var packageJS;
|
|
300
300
|
return qacInit.initDefaults(initParams).then(function(initResult) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qa-control",
|
|
3
3
|
"description": "QA control of things that nobody controls",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.3",
|
|
5
5
|
"author": "Codenautas <codenautas@googlegroups.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "codenautas/qa-control",
|
|
@@ -19,37 +19,44 @@
|
|
|
19
19
|
"qa-control": "./bin/qa-control-run.js"
|
|
20
20
|
},
|
|
21
21
|
"main": "./bin/qa-control.js",
|
|
22
|
+
"overrides": {
|
|
23
|
+
"diff": ">=8.0.2",
|
|
24
|
+
"serialize-javascript": ">=7.0.0",
|
|
25
|
+
"uuid": ">=14.0.0"
|
|
26
|
+
},
|
|
22
27
|
"dependencies": {
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"fs-
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"semver": "
|
|
31
|
-
"strip-bom-string": "
|
|
32
|
-
"best-globals": "~2.1.3",
|
|
33
|
-
"multilang": "~1.2.0"
|
|
28
|
+
"best-globals": "^2.1.4",
|
|
29
|
+
"commander": "^14.0.3",
|
|
30
|
+
"eslint": "^10.3.0",
|
|
31
|
+
"fs-extra": "^11.3.5",
|
|
32
|
+
"fs-promise": "^2.0.3",
|
|
33
|
+
"js-yaml": "^4.1.1",
|
|
34
|
+
"multilang": "^1.2.1",
|
|
35
|
+
"semver": "^7.8.0",
|
|
36
|
+
"strip-bom-string": "^1.0.0"
|
|
34
37
|
},
|
|
35
38
|
"devDependencies": {
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
39
|
+
"@types/mocha": "^10.0.10",
|
|
40
|
+
"@types/node": "^25.7.0",
|
|
41
|
+
"expect-called": "^0.4.0",
|
|
42
|
+
"expect.js": "^0.3.1",
|
|
43
|
+
"mocha": "^11.7.5",
|
|
44
|
+
"nyc": "^18.0.0",
|
|
45
|
+
"sinon": "^22.0.0",
|
|
46
|
+
"typescript": "^6.0.3"
|
|
41
47
|
},
|
|
42
48
|
"engines": {
|
|
43
49
|
"node": ">= 10"
|
|
44
50
|
},
|
|
45
51
|
"scripts": {
|
|
46
|
-
"test": "mocha --reporter spec
|
|
52
|
+
"test": "mocha --reporter spec --check-leaks test/",
|
|
47
53
|
"test-nc": "mocha --reporter spec --bail --check-leaks --no-colors test/",
|
|
48
|
-
"test-ci": "
|
|
49
|
-
"test-cov": "
|
|
50
|
-
"start": "node
|
|
51
|
-
"report": "
|
|
54
|
+
"test-ci": "nyc --reporter=lcov mocha --reporter spec --check-leaks test/",
|
|
55
|
+
"test-cov": "nyc mocha --reporter dot --check-leaks test/",
|
|
56
|
+
"start": "node ./bin/qa-control-run.js",
|
|
57
|
+
"report": "nyc report",
|
|
52
58
|
"qac": "node bin/qa-control-run.js . -v",
|
|
59
|
+
"typecheck": "tsc",
|
|
53
60
|
"all": "npm test && npm run test-cov && npm run report && npm run qac"
|
|
54
61
|
},
|
|
55
62
|
"files": [
|