qa-control 0.6.3 → 0.6.4
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/bin/definition/definition.js +41 -29
- package/bin/qa-control-run.js +2 -0
- package/bin/qa-control.js +22 -4
- package/package.json +1 -1
|
@@ -17,6 +17,15 @@ var fs = require('fs-promise');
|
|
|
17
17
|
var Path = require('path');
|
|
18
18
|
var yaml = require('js-yaml');
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @param {PackageJson} packageJson
|
|
23
|
+
* @returns boolean
|
|
24
|
+
*/
|
|
25
|
+
function testAppVeyor(packageJson){
|
|
26
|
+
return !!packageJson?.['qa-control']?.["test-appveyor"];
|
|
27
|
+
}
|
|
28
|
+
|
|
20
29
|
/** @param {string} realRegex */
|
|
21
30
|
function softRegExp(realRegex) {
|
|
22
31
|
var re=realRegex.replace(/\\/g, '\\\\')
|
|
@@ -62,23 +71,21 @@ module.exports = function(qaControl){
|
|
|
62
71
|
},
|
|
63
72
|
'LICENSE':{ mandatory:true },
|
|
64
73
|
'appveyor.yml':{
|
|
65
|
-
presentIf:
|
|
66
|
-
return !!packageJson['qa-control']["test-appveyor"];
|
|
67
|
-
}
|
|
74
|
+
presentIf: testAppVeyor
|
|
68
75
|
},
|
|
69
76
|
'.eslintrc.yml':{ presentIf: function(pj) { return pj['qa-control'] && pj['qa-control'].profile !== 'minimum'; } }
|
|
70
77
|
},
|
|
71
78
|
cucardas:{
|
|
72
79
|
'proof-of-concept':{
|
|
73
80
|
check: function(packageJson){
|
|
74
|
-
return packageJson['qa-control']
|
|
81
|
+
return packageJson?.['qa-control']?.purpose==='proof-of-concept';
|
|
75
82
|
},
|
|
76
83
|
md:'',
|
|
77
84
|
imgExample:'https://img.shields.io/badge/stability-designing-red.svg'
|
|
78
85
|
},
|
|
79
86
|
designing:{
|
|
80
87
|
check: function(packageJson){
|
|
81
|
-
return semver.satisfies(packageJson.version,'0.0.x') && !packageJson['qa-control']
|
|
88
|
+
return semver.satisfies(packageJson.version,'0.0.x') && !packageJson?.['qa-control']?.purpose;
|
|
82
89
|
},
|
|
83
90
|
md:'',
|
|
84
91
|
imgExample:'https://img.shields.io/badge/stability-designing-red.svg',
|
|
@@ -88,7 +95,7 @@ module.exports = function(qaControl){
|
|
|
88
95
|
check: function(packageJson){
|
|
89
96
|
return semver.satisfies(packageJson.version,'0.x.x') &&
|
|
90
97
|
!semver.satisfies(packageJson.version,'0.0.x') &&
|
|
91
|
-
!packageJson['qa-control'].purpose;
|
|
98
|
+
!packageJson?.['qa-control'].purpose;
|
|
92
99
|
},
|
|
93
100
|
md:'',
|
|
94
101
|
imgExample:'https://img.shields.io/badge/stability-extending-orange.svg',
|
|
@@ -96,21 +103,21 @@ module.exports = function(qaControl){
|
|
|
96
103
|
},
|
|
97
104
|
training:{
|
|
98
105
|
check: function(packageJson){
|
|
99
|
-
return packageJson['qa-control']
|
|
106
|
+
return packageJson?.['qa-control']?.purpose==='training';
|
|
100
107
|
},
|
|
101
108
|
md:'',
|
|
102
109
|
imgExample:'https://img.shields.io/badge/stability-training-ffa0c0.svg'
|
|
103
110
|
},
|
|
104
111
|
example:{
|
|
105
112
|
check: function(packageJson){
|
|
106
|
-
return packageJson['qa-control']
|
|
113
|
+
return packageJson?.['qa-control']?.purpose==='example';
|
|
107
114
|
},
|
|
108
115
|
md:'',
|
|
109
116
|
imgExample:'https://img.shields.io/badge/stability-example-a0a0f0.svg'
|
|
110
117
|
},
|
|
111
118
|
stable:{
|
|
112
119
|
check: function(packageJson){
|
|
113
|
-
return semver.satisfies(packageJson.version,'>=1.0.0') && !packageJson['qa-control']
|
|
120
|
+
return semver.satisfies(packageJson.version,'>=1.0.0') && !packageJson?.['qa-control']?.purpose;
|
|
114
121
|
},
|
|
115
122
|
md:'',
|
|
116
123
|
imgExample:'https://img.shields.io/badge/stability-stable-blue.svg'
|
|
@@ -128,32 +135,26 @@ module.exports = function(qaControl){
|
|
|
128
135
|
docDescription: ''
|
|
129
136
|
},
|
|
130
137
|
build:{
|
|
131
|
-
check:
|
|
132
|
-
return !packageJson['qa-control']['test-appveyor'];
|
|
133
|
-
},
|
|
138
|
+
check: (...args) => !testAppVeyor(...args),
|
|
134
139
|
md:'[](https://github.com/xxx/yyy/actions/workflows/build-and-test.yml)',
|
|
135
140
|
imgExample:'https://raw.githubusercontent.com/codenautas/codenautas/master/img/medalla-ejemplo-linux.png',
|
|
136
141
|
docDescription: 'linux/build'
|
|
137
142
|
},
|
|
138
143
|
linux:{
|
|
139
|
-
check:
|
|
140
|
-
return !!packageJson['qa-control']['test-appveyor'];
|
|
141
|
-
},
|
|
144
|
+
check: testAppVeyor,
|
|
142
145
|
md:'[](https://github.com/xxx/yyy/actions/workflows/build-and-test.yml)',
|
|
143
146
|
imgExample:'https://raw.githubusercontent.com/codenautas/codenautas/master/img/medalla-ejemplo-linux.png',
|
|
144
147
|
hideInManual: true,
|
|
145
148
|
},
|
|
146
149
|
windows:{
|
|
147
|
-
check:
|
|
148
|
-
return !!packageJson['qa-control']['test-appveyor'];
|
|
149
|
-
},
|
|
150
|
+
check: testAppVeyor,
|
|
150
151
|
md:'[](https://ci.appveyor.com/project/xxx/yyy)',
|
|
151
152
|
imgExample:'https://ci.appveyor.com/api/projects/status/github/codenautas/pg-promise-strict?svg=true',
|
|
152
153
|
docDescription: 'casos especiales'
|
|
153
154
|
},
|
|
154
155
|
coverage:{
|
|
155
156
|
check: function(packageJson){
|
|
156
|
-
return packageJson['qa-control']
|
|
157
|
+
return packageJson?.['qa-control']?.coverage;
|
|
157
158
|
},
|
|
158
159
|
md:'[](https://coveralls.io/r/xxx/yyy)',
|
|
159
160
|
imgExample:'https://raw.githubusercontent.com/codenautas/codenautas/master/img/coverage.png',
|
|
@@ -206,26 +207,26 @@ module.exports = function(qaControl){
|
|
|
206
207
|
exist_package_json:{
|
|
207
208
|
checks:[{
|
|
208
209
|
warnings:function(info){
|
|
209
|
-
if(!info.files['package.json']){
|
|
210
|
+
if(!info.files?.['package.json']){
|
|
210
211
|
return [{warning:'no_package_json', scoring:{fatal:1}}];
|
|
211
212
|
}
|
|
212
213
|
return [];
|
|
213
214
|
}
|
|
214
215
|
}],
|
|
215
|
-
|
|
216
|
+
couldBail:true
|
|
216
217
|
},
|
|
217
218
|
qa_control_section_in_package_json:{
|
|
218
219
|
checks:[{
|
|
219
220
|
warnings:function(info){
|
|
220
|
-
if(!info.packageJson['qa-control']){
|
|
221
|
-
return [{warning:info.files['package.json']
|
|
221
|
+
if(!info.packageJson?.['qa-control']){
|
|
222
|
+
return [{warning:info.files?.['package.json']?.content?.match(/codenautas/)?
|
|
222
223
|
'no_qa_control_section_in_codenautas_project':
|
|
223
224
|
'no_qa_control_section_in_package_json', scoring:{fatal:1}}];
|
|
224
225
|
}
|
|
225
226
|
return [];
|
|
226
227
|
}
|
|
227
228
|
}],
|
|
228
|
-
|
|
229
|
+
mustAbort:true
|
|
229
230
|
},
|
|
230
231
|
repository_in_package_json:{
|
|
231
232
|
checks:[{
|
|
@@ -241,7 +242,7 @@ module.exports = function(qaControl){
|
|
|
241
242
|
return warns;
|
|
242
243
|
}
|
|
243
244
|
}],
|
|
244
|
-
|
|
245
|
+
couldBail:true
|
|
245
246
|
},
|
|
246
247
|
invalid_repository_in_package_json:{
|
|
247
248
|
checks:[{
|
|
@@ -290,13 +291,13 @@ module.exports = function(qaControl){
|
|
|
290
291
|
return warns;
|
|
291
292
|
}
|
|
292
293
|
}],
|
|
293
|
-
|
|
294
|
+
couldBail:true
|
|
294
295
|
},
|
|
295
296
|
valid_values_for_qa_control_keys:{
|
|
296
297
|
checks:[{
|
|
297
298
|
warnings:function(info){
|
|
298
299
|
var warns=[];
|
|
299
|
-
var qaControlSection=info.packageJson['qa-control'];
|
|
300
|
+
var qaControlSection=info.packageJson?.['qa-control'] ?? {};
|
|
300
301
|
var sections=qaControl.definition.sections;
|
|
301
302
|
/*jshint forin: false */
|
|
302
303
|
for(var sectionName in sections){
|
|
@@ -314,7 +315,18 @@ module.exports = function(qaControl){
|
|
|
314
315
|
return warns;
|
|
315
316
|
}
|
|
316
317
|
}],
|
|
317
|
-
|
|
318
|
+
couldBail:true
|
|
319
|
+
},
|
|
320
|
+
cant_continue:{
|
|
321
|
+
checks:[{
|
|
322
|
+
warnings: function(info){
|
|
323
|
+
if (info.warningCount) {
|
|
324
|
+
return [{warning:'cant_continue', scoring:{fatal:1}}];
|
|
325
|
+
}
|
|
326
|
+
return []
|
|
327
|
+
}
|
|
328
|
+
}],
|
|
329
|
+
mustAbort:true
|
|
318
330
|
},
|
|
319
331
|
mandatory_lines:{
|
|
320
332
|
checks:[{
|
|
@@ -448,7 +460,7 @@ module.exports = function(qaControl){
|
|
|
448
460
|
warnings:function(info) {
|
|
449
461
|
if(info.packageJson['qa-control'] && info.packageJson['qa-control'].profile === 'minimum') { return []; }
|
|
450
462
|
var warns=[];
|
|
451
|
-
var qaControlSection=info.packageJson['qa-control'];
|
|
463
|
+
var qaControlSection=info.packageJson['qa-control'] ?? {};
|
|
452
464
|
var whichRunIn=qaControlSection['run-in'];
|
|
453
465
|
var whichType=qaControlSection.type;
|
|
454
466
|
var firstLines=qaControl.definition.firstLines[whichRunIn][whichType];
|
package/bin/qa-control-run.js
CHANGED
|
@@ -16,6 +16,7 @@ program
|
|
|
16
16
|
.option('-v, --verbose', 'Show progress information')
|
|
17
17
|
.option('-L, --list-langs', 'List available languages')
|
|
18
18
|
.option('-c, --cucardas', 'Always generate cucardas.log')
|
|
19
|
+
.option('-b, --bail', 'Stop at first blocking issue')
|
|
19
20
|
.option('-i, --init', 'Initialize project with qa-control specs')
|
|
20
21
|
.option('--repo-is <owner_or_org/repo>', 'Expected GitHub repository (owner_or_org/repo)')
|
|
21
22
|
.parse(process.argv);
|
|
@@ -34,6 +35,7 @@ params.verbose = opts.verbose;
|
|
|
34
35
|
params.listLangs = opts.listLangs;
|
|
35
36
|
params.lang = opts.lang;
|
|
36
37
|
params.cucardas = opts.cucardas;
|
|
38
|
+
params.bail = opts.bail || false;
|
|
37
39
|
params.repoIs = opts.repoIs || process.env.GITHUB_REPOSITORY || null;
|
|
38
40
|
// console.log(opts); process.exit(0);
|
|
39
41
|
// console.log(params); process.exit(0);
|
package/bin/qa-control.js
CHANGED
|
@@ -26,7 +26,8 @@ function forEach(obj, func) {
|
|
|
26
26
|
qaControl.msgs={
|
|
27
27
|
en:{
|
|
28
28
|
lack_of_mandatory_section_1: 'lack of mandatory section "$1" in qa-control section of package.json',
|
|
29
|
-
repository_name_not_found: 'packageJson.repository must be in format /{[-a-zA-Z0-9_.]+}\/[-a-zA-Z0-9_.]+/'
|
|
29
|
+
repository_name_not_found: 'packageJson.repository must be in format /{[-a-zA-Z0-9_.]+}\/[-a-zA-Z0-9_.]+/',
|
|
30
|
+
bailing_could_be_more: '--bail(ing)! There could be more issues'
|
|
30
31
|
},
|
|
31
32
|
es:{
|
|
32
33
|
deprecated_version: 'la version es demasiado vieja',
|
|
@@ -59,7 +60,8 @@ qaControl.msgs={
|
|
|
59
60
|
lack_of_files_section_in_package_json: 'Falta la sección "files" en package.json',
|
|
60
61
|
invalid_files_section_in_package_json: 'La sección "files" en package.json es inválida',
|
|
61
62
|
incorrect_ecmascript_versions_in_package_json: 'Las versiones de ECMAScript utilizadas en package.json son incorrectas',
|
|
62
|
-
non_recomended_dependency_1_in_package_json: 'Dependencia no recomendada "$1" en package.json'
|
|
63
|
+
non_recomended_dependency_1_in_package_json: 'Dependencia no recomendada "$1" en package.json',
|
|
64
|
+
bailing_could_be_more: '¡Qué --bail(e)! Podrían haber más problemas, correr de nuevo después de corregir estos'
|
|
63
65
|
}
|
|
64
66
|
};
|
|
65
67
|
|
|
@@ -103,7 +105,7 @@ qaControl.startsWith = function startsWith(bufTest, bufStart) {
|
|
|
103
105
|
};
|
|
104
106
|
|
|
105
107
|
qaControl.getRepositoryUrl = function getRepositoryUrl(packageJson) {
|
|
106
|
-
var repo = packageJson.repository
|
|
108
|
+
var repo = packageJson.repository?.url ?? packageJson.repository ?? "";
|
|
107
109
|
var ghRepo = /(https:\/\/github\.com\/)/.exec(repo);
|
|
108
110
|
if(ghRepo) { repo = repo.replace(ghRepo[1], ''); }
|
|
109
111
|
return repo;
|
|
@@ -313,6 +315,12 @@ qaControl.loadProject = function loadProject(projectDir) {
|
|
|
313
315
|
});
|
|
314
316
|
};
|
|
315
317
|
|
|
318
|
+
/**
|
|
319
|
+
*
|
|
320
|
+
* @param {ProjectInfo} info
|
|
321
|
+
* @param {QAOptions} opts
|
|
322
|
+
* @returns
|
|
323
|
+
*/
|
|
316
324
|
qaControl.controlInfo=function controlInfo(info, opts){
|
|
317
325
|
var resultWarnings=[];
|
|
318
326
|
var existingWarnings={};
|
|
@@ -321,6 +329,8 @@ qaControl.controlInfo=function controlInfo(info, opts){
|
|
|
321
329
|
var silenced = ((info.packageJson || {})['qa-control'] || {}).silenced || [];
|
|
322
330
|
var cadenaDePromesas = Promise.resolve(/** @type {Warning[]} */ ([]));
|
|
323
331
|
info.scoring = opts && opts.scoring;
|
|
332
|
+
var bailed = false;
|
|
333
|
+
info.warningCount = 0;
|
|
324
334
|
forEach(rules, function(rule, ruleName) {
|
|
325
335
|
rule.checks.forEach(function(checkInfo){
|
|
326
336
|
cadenaDePromesas = cadenaDePromesas.then(function() {
|
|
@@ -336,8 +346,15 @@ qaControl.controlInfo=function controlInfo(info, opts){
|
|
|
336
346
|
activeWarnings.forEach(function(warning){
|
|
337
347
|
existingWarnings[warning.warning]=true;
|
|
338
348
|
});
|
|
339
|
-
if(rule.
|
|
349
|
+
if(rule.couldBail && opts && opts.bail) {
|
|
350
|
+
bailed = true;
|
|
351
|
+
throw new Error("ruleIsAborting");
|
|
352
|
+
}
|
|
353
|
+
if(rule.mustAbort) {
|
|
354
|
+
throw new Error("ruleIsAborting");
|
|
355
|
+
}
|
|
340
356
|
}
|
|
357
|
+
info.warningCount += warningsOfThisRule.length;
|
|
341
358
|
return resultWarnings;
|
|
342
359
|
});
|
|
343
360
|
});
|
|
@@ -347,6 +364,7 @@ qaControl.controlInfo=function controlInfo(info, opts){
|
|
|
347
364
|
throw err;
|
|
348
365
|
}
|
|
349
366
|
}).then(function(){
|
|
367
|
+
if(bailed) { resultWarnings.push({warning:'bailing_could_be_more'}); }
|
|
350
368
|
return resultWarnings;
|
|
351
369
|
});
|
|
352
370
|
return cadenaDePromesas;
|
package/package.json
CHANGED