qa-control 0.5.0 → 0.6.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/README.md +2 -2
- package/bin/{0.3.0 → definition}/definition.js +688 -764
- package/bin/{0.3.0 → definition}/first-lines-both.txt +25 -25
- package/bin/definition/first-lines-client.txt +3 -0
- package/bin/{0.3.0 → definition}/first-lines-server-app.txt +2 -2
- package/bin/{0.3.0 → definition}/first-lines-server-cmd-tool.txt +2 -2
- package/bin/{0.3.0 → definition}/first-lines-server.txt +3 -3
- package/bin/definition/first-lines-web.txt +3 -0
- package/bin/qa-control.js +17 -42
- package/bin/qac-init.js +0 -18
- package/package.json +1 -1
- package/bin/0.0.1/definition.js +0 -556
- package/bin/0.0.1/first-lines-both.txt +0 -28
- package/bin/0.0.1/first-lines-client.txt +0 -6
- package/bin/0.0.1/first-lines-server-app.txt +0 -6
- package/bin/0.0.1/first-lines-server.txt +0 -6
- package/bin/0.0.2/definition.js +0 -577
- package/bin/0.0.2/first-lines-both.txt +0 -28
- package/bin/0.0.2/first-lines-client.txt +0 -6
- package/bin/0.0.2/first-lines-server-app.txt +0 -6
- package/bin/0.0.2/first-lines-server.txt +0 -6
- package/bin/0.1.3/definition.js +0 -653
- package/bin/0.1.3/first-lines-both.txt +0 -28
- package/bin/0.1.3/first-lines-client.txt +0 -6
- package/bin/0.1.3/first-lines-server-app.txt +0 -7
- package/bin/0.1.3/first-lines-server.txt +0 -7
- package/bin/0.1.4/definition.js +0 -706
- package/bin/0.1.4/first-lines-both.txt +0 -28
- package/bin/0.1.4/first-lines-client.txt +0 -6
- package/bin/0.1.4/first-lines-server-app.txt +0 -7
- package/bin/0.1.4/first-lines-server.txt +0 -7
- package/bin/0.2.0/definition.js +0 -771
- package/bin/0.2.0/first-lines-both.txt +0 -27
- package/bin/0.2.0/first-lines-client.txt +0 -5
- package/bin/0.2.0/first-lines-server-app.txt +0 -6
- package/bin/0.2.0/first-lines-server-cmd-tool.txt +0 -6
- package/bin/0.2.0/first-lines-server.txt +0 -6
- package/bin/0.3.0/first-lines-client.txt +0 -3
- package/bin/0.3.0/first-lines-web.txt +0 -3
package/bin/0.2.0/definition.js
DELETED
|
@@ -1,771 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var stripBom = require("strip-bom-string");
|
|
4
|
-
var semver = require("semver");
|
|
5
|
-
var jsh = require('jshint');
|
|
6
|
-
var esl = require('eslint');
|
|
7
|
-
var eslintLinter = new esl.Linter();
|
|
8
|
-
function eslintrcToFlatConfig(rc) {
|
|
9
|
-
var flat = {};
|
|
10
|
-
if (rc.rules) { flat.rules = rc.rules; }
|
|
11
|
-
var sourceType = (rc.env && rc.env.node) ? 'commonjs' : 'script';
|
|
12
|
-
flat.languageOptions = { ecmaVersion: 'latest', sourceType: sourceType };
|
|
13
|
-
flat.linterOptions = { reportUnusedDisableDirectives: 'off' };
|
|
14
|
-
return flat;
|
|
15
|
-
}
|
|
16
|
-
var multilang = require('multilang');
|
|
17
|
-
var fs = require('fs-promise');
|
|
18
|
-
var Path = require('path');
|
|
19
|
-
|
|
20
|
-
module.exports = function(qaControl){
|
|
21
|
-
return {
|
|
22
|
-
fileNameMainDoc: 'LEEME.md',
|
|
23
|
-
sections: { // podria llamarse 'json-sections'...
|
|
24
|
-
'run-in': {
|
|
25
|
-
mandatory: true,
|
|
26
|
-
values: {
|
|
27
|
-
server:{},
|
|
28
|
-
both:{},
|
|
29
|
-
client:{}
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
type: {
|
|
33
|
-
mandatory:true,
|
|
34
|
-
values: {
|
|
35
|
-
app: {},
|
|
36
|
-
lib: {},
|
|
37
|
-
"cmd-tool": {}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
files:{
|
|
42
|
-
'README.md':{ mandatory:true },
|
|
43
|
-
'LEEME.md':{ mandatory:true },
|
|
44
|
-
'.travis.yml':{ mandatory:true },
|
|
45
|
-
'.gitignore':{
|
|
46
|
-
mandatory:true,
|
|
47
|
-
mandatoryLines:['local-*','*-local.*']
|
|
48
|
-
},
|
|
49
|
-
'LICENSE':{ mandatory:true },
|
|
50
|
-
'appveyor.yml':{
|
|
51
|
-
presentIf:function(packageJson){
|
|
52
|
-
return !!packageJson['qa-control']["test-appveyor"];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
cucardas:{
|
|
57
|
-
'proof-of-concept':{
|
|
58
|
-
check: function(packageJson){
|
|
59
|
-
return packageJson['qa-control'].purpose==='proof-of-concept';
|
|
60
|
-
},
|
|
61
|
-
md:'',
|
|
62
|
-
imgExample:'https://img.shields.io/badge/stability-designing-red.svg'
|
|
63
|
-
},
|
|
64
|
-
designing:{
|
|
65
|
-
check: function(packageJson){
|
|
66
|
-
return semver.satisfies(packageJson.version,'0.0.x') && !packageJson['qa-control'].purpose;
|
|
67
|
-
},
|
|
68
|
-
md:'',
|
|
69
|
-
imgExample:'https://img.shields.io/badge/stability-designing-red.svg',
|
|
70
|
-
docDescription: 'opt. manual'
|
|
71
|
-
},
|
|
72
|
-
extending:{
|
|
73
|
-
check: function(packageJson){
|
|
74
|
-
return semver.satisfies(packageJson.version,'0.x.x') &&
|
|
75
|
-
!semver.satisfies(packageJson.version,'0.0.x') &&
|
|
76
|
-
!packageJson['qa-control'].purpose;
|
|
77
|
-
},
|
|
78
|
-
md:'',
|
|
79
|
-
imgExample:'https://img.shields.io/badge/stability-extending-orange.svg',
|
|
80
|
-
docDescription: 'opt. manual'
|
|
81
|
-
},
|
|
82
|
-
training:{
|
|
83
|
-
check: function(packageJson){
|
|
84
|
-
return packageJson['qa-control'].purpose==='training';
|
|
85
|
-
},
|
|
86
|
-
md:'',
|
|
87
|
-
imgExample:'https://img.shields.io/badge/stability-training-ffa0c0.svg'
|
|
88
|
-
},
|
|
89
|
-
example:{
|
|
90
|
-
check: function(packageJson){
|
|
91
|
-
return packageJson['qa-control'].purpose==='example';
|
|
92
|
-
},
|
|
93
|
-
md:'',
|
|
94
|
-
imgExample:'https://img.shields.io/badge/stability-example-a0a0f0.svg'
|
|
95
|
-
},
|
|
96
|
-
stable:{
|
|
97
|
-
check: function(packageJson){
|
|
98
|
-
return semver.satisfies(packageJson.version,'>=1.0.0') && !packageJson['qa-control'].purpose;
|
|
99
|
-
},
|
|
100
|
-
md:'',
|
|
101
|
-
imgExample:'https://img.shields.io/badge/stability-stable-brightgreen.svg'
|
|
102
|
-
},
|
|
103
|
-
'npm-version':{
|
|
104
|
-
mandatory:true,
|
|
105
|
-
md:'[](https://npmjs.org/package/yyy)',
|
|
106
|
-
imgExample:'https://raw.githubusercontent.com/codenautas/codenautas/master/img/npm-version.png',
|
|
107
|
-
docDescription: ''
|
|
108
|
-
},
|
|
109
|
-
downloads:{
|
|
110
|
-
mandatory:true,
|
|
111
|
-
md:'[](https://npmjs.org/package/yyy)',
|
|
112
|
-
imgExample:'https://raw.githubusercontent.com/codenautas/codenautas/master/img/downloads.png',
|
|
113
|
-
docDescription: ''
|
|
114
|
-
},
|
|
115
|
-
build:{
|
|
116
|
-
check: function(packageJson){
|
|
117
|
-
return !packageJson['qa-control']['test-appveyor'];
|
|
118
|
-
},
|
|
119
|
-
md:'[](https://travis-ci.org/xxx/yyy)',
|
|
120
|
-
imgExample:'https://raw.githubusercontent.com/codenautas/codenautas/master/img/medalla-ejemplo-linux.png',
|
|
121
|
-
docDescription: 'linux/build'
|
|
122
|
-
},
|
|
123
|
-
linux:{
|
|
124
|
-
check: function(packageJson){
|
|
125
|
-
return !!packageJson['qa-control']['test-appveyor'];
|
|
126
|
-
},
|
|
127
|
-
md:'[](https://travis-ci.org/xxx/yyy)',
|
|
128
|
-
imgExample:'https://raw.githubusercontent.com/codenautas/codenautas/master/img/medalla-ejemplo-linux.png',
|
|
129
|
-
hideInManual: true,
|
|
130
|
-
},
|
|
131
|
-
windows:{
|
|
132
|
-
check: function(packageJson){
|
|
133
|
-
return !!packageJson['qa-control']['test-appveyor'];
|
|
134
|
-
},
|
|
135
|
-
md:'[](https://ci.appveyor.com/project/xxx/yyy)',
|
|
136
|
-
imgExample:'https://ci.appveyor.com/api/projects/status/github/codenautas/pg-promise-strict?svg=true',
|
|
137
|
-
docDescription: 'casos especiales'
|
|
138
|
-
},
|
|
139
|
-
coverage:{
|
|
140
|
-
check: function(packageJson){
|
|
141
|
-
return packageJson['qa-control'].coverage;
|
|
142
|
-
},
|
|
143
|
-
md:'[](https://coveralls.io/r/xxx/yyy)',
|
|
144
|
-
imgExample:'https://raw.githubusercontent.com/codenautas/codenautas/master/img/coverage.png',
|
|
145
|
-
docDescription: ''
|
|
146
|
-
},
|
|
147
|
-
climate:{
|
|
148
|
-
check: function(packageJson){
|
|
149
|
-
return packageJson['qa-control'].coverage || ! packageJson['qa-control'].purpose;
|
|
150
|
-
},
|
|
151
|
-
md:'[](https://codeclimate.com/github/xxx/yyy)',
|
|
152
|
-
imgExample:'https://raw.githubusercontent.com/codenautas/codenautas/master/img/climate.png',
|
|
153
|
-
docDescription: ''
|
|
154
|
-
},
|
|
155
|
-
dependencies:{
|
|
156
|
-
mandatory:true,
|
|
157
|
-
md:'[](https://david-dm.org/xxx/yyy)',
|
|
158
|
-
imgExample:'https://raw.githubusercontent.com/codenautas/codenautas/master/img/medalla-ejemplo-dependencies.png',
|
|
159
|
-
docDescription: ''
|
|
160
|
-
},
|
|
161
|
-
'qa-control':{
|
|
162
|
-
mandatory:true,
|
|
163
|
-
md:'[](http://codenautas.com/github/xxx/yyy)',
|
|
164
|
-
docDescription: ''
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
customs:{
|
|
168
|
-
softRegExp:function(realRegex) {
|
|
169
|
-
var re=realRegex.replace(/\\/g, '\\\\')
|
|
170
|
-
.replace(/\s*(=+)\s*/g,'\\s*$1\\s*')
|
|
171
|
-
.replace(/ /g, '\\s+')
|
|
172
|
-
.replace(/\(/g, '\\(')
|
|
173
|
-
.replace(/\)/g, '\\)');
|
|
174
|
-
return new RegExp(re, 'im');
|
|
175
|
-
},
|
|
176
|
-
funtion_eid:{
|
|
177
|
-
detect:'function eid',
|
|
178
|
-
match:'function eid(id){ return document.getElementById(id); }'
|
|
179
|
-
},
|
|
180
|
-
var_winos:{
|
|
181
|
-
// separo los siguientes dos strings en dos partes para que no salte un warning
|
|
182
|
-
detect:'var '+'winos=',
|
|
183
|
-
match:"var "+"winOS = Path.sep==='\\\\';"
|
|
184
|
-
},
|
|
185
|
-
var_path:{
|
|
186
|
-
detect:'var path=',
|
|
187
|
-
match:"var Path = require('path');"
|
|
188
|
-
}
|
|
189
|
-
},
|
|
190
|
-
jshint_options: { "asi": false, "curly": true, "forin": true },
|
|
191
|
-
eslint_options: {
|
|
192
|
-
"env": {
|
|
193
|
-
"node": false
|
|
194
|
-
},
|
|
195
|
-
"rules": {
|
|
196
|
-
"strict": 0,
|
|
197
|
-
"no-console": 1,
|
|
198
|
-
"no-unused-vars": 1
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
|
-
// Si info.scoring == true, cada regla debe agregar junto al warning, un objeto 'scoring'
|
|
202
|
-
// con na o m�s de las siguientes propiedades:
|
|
203
|
-
// qac: 1
|
|
204
|
-
// mandatories: 1
|
|
205
|
-
// cucardas:1
|
|
206
|
-
// multilang:1
|
|
207
|
-
// versions:1
|
|
208
|
-
// parameters:1
|
|
209
|
-
// format:1
|
|
210
|
-
// customs:1
|
|
211
|
-
// jshint:1
|
|
212
|
-
// dependencies:1
|
|
213
|
-
// Emilio redefinir� valores de cada score
|
|
214
|
-
rules:{
|
|
215
|
-
exist_package_json:{
|
|
216
|
-
checks:[{
|
|
217
|
-
warnings:function(info){
|
|
218
|
-
if(!info.files['package.json']){
|
|
219
|
-
return [{warning:'no_package_json', scoring:{fatal:1}}];
|
|
220
|
-
}
|
|
221
|
-
return [];
|
|
222
|
-
}
|
|
223
|
-
}],
|
|
224
|
-
shouldAbort:true
|
|
225
|
-
},
|
|
226
|
-
qa_control_section_in_package_json:{
|
|
227
|
-
checks:[{
|
|
228
|
-
warnings:function(info){
|
|
229
|
-
if(!info.packageJson['qa-control']){
|
|
230
|
-
return [{warning:info.files['package.json'].content.match(/codenautas/)?
|
|
231
|
-
'no_qa_control_section_in_codenautas_project':
|
|
232
|
-
'no_qa_control_section_in_package_json', scoring:{fatal:1}}];
|
|
233
|
-
}
|
|
234
|
-
return [];
|
|
235
|
-
}
|
|
236
|
-
}],
|
|
237
|
-
shouldAbort:true
|
|
238
|
-
},
|
|
239
|
-
package_version_in_qa_control_section:{
|
|
240
|
-
checks:[{
|
|
241
|
-
warnings:function(info){
|
|
242
|
-
if(!info.packageJson['qa-control']['package-version']){
|
|
243
|
-
return [{warning:'no_package_version_in_qa_control_section', scoring:{fatal:1}}];
|
|
244
|
-
} else {
|
|
245
|
-
// defino la version para para siguientes checks
|
|
246
|
-
info.packageVersion = info.packageJson['qa-control']['package-version'];
|
|
247
|
-
}
|
|
248
|
-
return [];
|
|
249
|
-
}
|
|
250
|
-
}],
|
|
251
|
-
shouldAbort:true
|
|
252
|
-
},
|
|
253
|
-
invalid_qa_control_version: {
|
|
254
|
-
checks:[{
|
|
255
|
-
warnings:function(info){
|
|
256
|
-
var ver=info.packageVersion;
|
|
257
|
-
if(! semver.valid(ver)){
|
|
258
|
-
return [{warning:'invalid_qa_control_version',params:[ver], scoring:{versions:1}}];
|
|
259
|
-
}
|
|
260
|
-
return [];
|
|
261
|
-
}
|
|
262
|
-
}],
|
|
263
|
-
shouldAbort:true
|
|
264
|
-
},
|
|
265
|
-
deprecated_control_version: {
|
|
266
|
-
checks:[{
|
|
267
|
-
warnings:function(info) {
|
|
268
|
-
var ver=info.packageVersion;
|
|
269
|
-
if(semver.satisfies(ver, qaControl.deprecatedVersions)){
|
|
270
|
-
return [{warning:'deprecated_qa_control_version',params:[ver], scoring:{warning:1}}];
|
|
271
|
-
}
|
|
272
|
-
return [];
|
|
273
|
-
}
|
|
274
|
-
}],
|
|
275
|
-
shouldAbort:true
|
|
276
|
-
},
|
|
277
|
-
mandatory_files:{
|
|
278
|
-
checks:[{
|
|
279
|
-
warnings:function(info) {
|
|
280
|
-
var warns =[];
|
|
281
|
-
var files=qaControl.projectDefinition[info.packageVersion].files;
|
|
282
|
-
for(var fileName in files) {
|
|
283
|
-
if(files.hasOwnProperty(fileName)) {
|
|
284
|
-
var file = files[fileName];
|
|
285
|
-
if(file.mandatory && !info.files[fileName]) {
|
|
286
|
-
warns.push({warning:'lack_of_mandatory_file_1', params:[fileName], scoring:{mandatories:1}});
|
|
287
|
-
} else {
|
|
288
|
-
if(file.presentIf && file.presentIf(info.packageJson) && !info.files[fileName]) {
|
|
289
|
-
warns.push({warning:'lack_of_mandatory_file_1', params:[fileName], scoring:{mandatories:1}});
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
return warns;
|
|
295
|
-
}
|
|
296
|
-
}],
|
|
297
|
-
shouldAbort:true
|
|
298
|
-
},
|
|
299
|
-
repository_in_package_json:{
|
|
300
|
-
checks:[{
|
|
301
|
-
warnings:function(info) {
|
|
302
|
-
var warns = [];
|
|
303
|
-
if(!('repository' in info.packageJson)) {
|
|
304
|
-
warns.push({warning:'lack_of_repository_section_in_package_json', scoring:{mandatories:1}});
|
|
305
|
-
} else {
|
|
306
|
-
if(! qaControl.getRepositoryUrl(info.packageJson).match(/^([-a-zA-Z0-9_.]+\/[-a-zA-Z0-9_.]+)$/)){
|
|
307
|
-
return [{warning:'repository_name_not_found', scoring:{mandatories:1}}];
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
return warns;
|
|
311
|
-
}
|
|
312
|
-
}],
|
|
313
|
-
shouldAbort:true
|
|
314
|
-
},
|
|
315
|
-
valid_values_for_qa_control_keys:{
|
|
316
|
-
checks:[{
|
|
317
|
-
warnings:function(info){
|
|
318
|
-
var warns=[];
|
|
319
|
-
var qaControlSection=info.packageJson['qa-control'];
|
|
320
|
-
var sections=qaControl.projectDefinition[info.packageVersion].sections;
|
|
321
|
-
/*jshint forin: false */
|
|
322
|
-
for(var sectionName in sections){
|
|
323
|
-
var sectionDef=sections[sectionName];
|
|
324
|
-
if(sectionDef.mandatory && !(sectionName in qaControlSection)){
|
|
325
|
-
warns.push({warning:'lack_of_mandatory_section_1',params:[sectionName], scoring:{mandatories:1}});
|
|
326
|
-
}else{
|
|
327
|
-
var observedValue=qaControlSection[sectionName];
|
|
328
|
-
if(sectionDef.values && !(observedValue in sectionDef.values)){
|
|
329
|
-
warns.push({warning:'invalid_value_1_in_parameter_2',params:[observedValue,sectionName], scoring:{warnings:1}});
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
/*jshint forin: true */
|
|
334
|
-
return warns;
|
|
335
|
-
}
|
|
336
|
-
}],
|
|
337
|
-
shouldAbort:true
|
|
338
|
-
},
|
|
339
|
-
mandatory_lines:{
|
|
340
|
-
checks:[{
|
|
341
|
-
warnings:function(info) {
|
|
342
|
-
var warns =[];
|
|
343
|
-
var files=qaControl.projectDefinition[info.packageVersion].files;
|
|
344
|
-
for(var fileName in files) {
|
|
345
|
-
var file=files[fileName];
|
|
346
|
-
if(file.mandatoryLines) {
|
|
347
|
-
var fileContent = info.files[fileName].content;
|
|
348
|
-
file.mandatoryLines.forEach(function(mandatoryLine) {
|
|
349
|
-
// agrego '\n' antes para no utilizar expresiones regulares
|
|
350
|
-
if(fileContent.indexOf('\n'+mandatoryLine)===-1) {
|
|
351
|
-
warns.push({warning:'lack_of_mandatory_line_1_in_file_2',
|
|
352
|
-
params:[mandatoryLine, fileName],
|
|
353
|
-
scoring:{mandatories:1}});
|
|
354
|
-
}
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
};
|
|
358
|
-
return warns;
|
|
359
|
-
}
|
|
360
|
-
}]
|
|
361
|
-
}, // agregar desde ac�
|
|
362
|
-
no_test_in_node_four:{
|
|
363
|
-
checks:[{
|
|
364
|
-
warnings:function(info){
|
|
365
|
-
if(info.dotTravis && info.dotTravis.node_js.filter(function(x){ return x[0].match(/[45678]/); }).length<2){
|
|
366
|
-
return [{warning:'no_test_in_node_four', scoring:{conventions:1}}];
|
|
367
|
-
}
|
|
368
|
-
return [];
|
|
369
|
-
}
|
|
370
|
-
}],
|
|
371
|
-
},
|
|
372
|
-
no_multilang_section_in_1:{
|
|
373
|
-
checks:[{
|
|
374
|
-
warnings:function(info){
|
|
375
|
-
if(!info.files[qaControl.mainDoc()].content.match(/<!--multilang v[0-9]+\s+(.+)(-->)/)) {
|
|
376
|
-
return [{
|
|
377
|
-
warning:'no_multilang_section_in_1',
|
|
378
|
-
params:[qaControl.mainDoc()],
|
|
379
|
-
scoring:{multilang:1}
|
|
380
|
-
}];
|
|
381
|
-
}
|
|
382
|
-
return [];
|
|
383
|
-
}
|
|
384
|
-
}]
|
|
385
|
-
},
|
|
386
|
-
invalid_repository_in_package_json:{
|
|
387
|
-
checks:[{
|
|
388
|
-
warnings:function(info) {
|
|
389
|
-
var warns = [];
|
|
390
|
-
var repoParts = qaControl.getRepositoryUrl(info.packageJson).split('/');
|
|
391
|
-
var projName = repoParts[repoParts.length-1];
|
|
392
|
-
if(projName !== info.packageJson.name) {
|
|
393
|
-
return [{warning:'invalid_repository_section_in_package_json', scoring:{repository:1}}];
|
|
394
|
-
}
|
|
395
|
-
return warns;
|
|
396
|
-
}
|
|
397
|
-
}]
|
|
398
|
-
},
|
|
399
|
-
cucardas:{
|
|
400
|
-
eclipsers:['invalid_repository_section_in_package_json', 'lack_of_repository_section_in_package_json'],
|
|
401
|
-
checks:[{
|
|
402
|
-
warnings:function(info){
|
|
403
|
-
var warns=[];
|
|
404
|
-
var readme=info.files[qaControl.mainDoc()].content;
|
|
405
|
-
if(readme.indexOf(qaControl.cucaMarker) === -1) {
|
|
406
|
-
warns.push({warning:'lack_of_cucarda_marker_in_readme'});
|
|
407
|
-
}
|
|
408
|
-
var cucardas=qaControl.projectDefinition[info.packageVersion].cucardas;
|
|
409
|
-
var modulo=info.packageJson.name;
|
|
410
|
-
var repo=qaControl.getRepositoryUrl(info.packageJson).replace('/'+modulo,'');
|
|
411
|
-
/*jshint forin: false */
|
|
412
|
-
for(var nombreCucarda in cucardas) {
|
|
413
|
-
var cucarda = cucardas[nombreCucarda];
|
|
414
|
-
var cucaID = '!['+/!\[([-a-z]+)]/.exec(cucarda.md)[1]+']';
|
|
415
|
-
var cucaStr = cucarda.md.replace(/\bxxx\b/g,repo).replace(/\byyy\b/g,modulo);
|
|
416
|
-
if(readme.indexOf(cucaID) === -1) {
|
|
417
|
-
if(cucarda.mandatory) {
|
|
418
|
-
warns.push({warning:'lack_of_mandatory_cucarda_1', params:[nombreCucarda], scoring:{cucardas:1}});
|
|
419
|
-
}
|
|
420
|
-
} else {
|
|
421
|
-
if('check' in cucarda && ! cucarda.check(info.packageJson)) {
|
|
422
|
-
warns.push({warning:'wrong_format_in_cucarda_1', params:[nombreCucarda], scoring:{cucardas:1}});
|
|
423
|
-
}
|
|
424
|
-
if(readme.indexOf(cucaStr) === -1) {
|
|
425
|
-
// si tengo cucarda mal formada, devuelvo warning aunque no sea obligatoria
|
|
426
|
-
// porque existi� la intenci�n de definirla
|
|
427
|
-
warns.push({warning:'wrong_format_in_cucarda_1', params:[nombreCucarda], scoring:{cucardas:1}});
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
/*jshint forin: true */
|
|
432
|
-
if(warns.length || qaControl.cucardas_always) {
|
|
433
|
-
fs.writeFile(Path.normalize(info.projectDir+'/cucardas.log'), qaControl.generateCucardas(cucardas, info.packageJson));
|
|
434
|
-
}
|
|
435
|
-
return warns;
|
|
436
|
-
}
|
|
437
|
-
}]
|
|
438
|
-
},
|
|
439
|
-
customs:{
|
|
440
|
-
checks:[{
|
|
441
|
-
warnings:function(info) {
|
|
442
|
-
var warns=[];
|
|
443
|
-
var customs = qaControl.projectDefinition[info.packageVersion].customs;
|
|
444
|
-
function makeCheck(strOrRegexp, isMatchFunc) {
|
|
445
|
-
var checker;
|
|
446
|
-
if(!strOrRegexp){
|
|
447
|
-
checker=function() { return false; };
|
|
448
|
-
}else if(strOrRegexp instanceof RegExp) {
|
|
449
|
-
checker=function(str) {
|
|
450
|
-
return strOrRegexp.test(str);
|
|
451
|
-
};
|
|
452
|
-
} else {
|
|
453
|
-
checker=function(str) {
|
|
454
|
-
if(isMatchFunc) {
|
|
455
|
-
return str.indexOf(strOrRegexp) !== -1;
|
|
456
|
-
} else {
|
|
457
|
-
return customs.softRegExp(strOrRegexp).test(str);
|
|
458
|
-
}
|
|
459
|
-
};
|
|
460
|
-
}
|
|
461
|
-
return checker;
|
|
462
|
-
}
|
|
463
|
-
for(var file in info.files) {
|
|
464
|
-
if(file.match(/(.js)$/)) {
|
|
465
|
-
for(var customeName in customs) {
|
|
466
|
-
if(customs.hasOwnProperty(customeName)) {
|
|
467
|
-
var content = info.files[file].content;
|
|
468
|
-
var custom = customs[customeName];
|
|
469
|
-
var detect = makeCheck(custom.detect);
|
|
470
|
-
var match = makeCheck(custom.match, true);
|
|
471
|
-
//console.log(file, " detect:", detect(content), " match: ", match(content))
|
|
472
|
-
if(detect(content) && ! match(content)) {
|
|
473
|
-
warns.push({warning:'file_1_does_not_match_custom_2', params:[file,customeName], scoring:{conventions:1}});
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
return warns;
|
|
480
|
-
}
|
|
481
|
-
}]
|
|
482
|
-
},
|
|
483
|
-
first_lines:{
|
|
484
|
-
checks:[{
|
|
485
|
-
warnings:function(info) {
|
|
486
|
-
var warns=[];
|
|
487
|
-
var qaControlSection=info.packageJson['qa-control'];
|
|
488
|
-
var whichRunIn=qaControlSection['run-in'];
|
|
489
|
-
var whichType=qaControlSection.type;
|
|
490
|
-
var firstLines=qaControl.projectDefinition[info.packageVersion].firstLines[whichRunIn][whichType];
|
|
491
|
-
if(firstLines) {
|
|
492
|
-
var ProjectName = qaControl.jsProjectName(info.packageJson.name);
|
|
493
|
-
var projectName = qaControl.first("toLowerCase")(ProjectName);
|
|
494
|
-
var mainName = ('main' in info.packageJson) ? info.packageJson.main : 'index.js';
|
|
495
|
-
if(!(mainName in info.files)) {
|
|
496
|
-
warns.push({warning:'packagejson_main_file_1_does_not_exists', params:[mainName], scoring:{warning:1}});
|
|
497
|
-
} else {
|
|
498
|
-
var fileContent = stripBom(info.files[mainName].content);
|
|
499
|
-
|
|
500
|
-
if(!qaControl.startsWith(fileContent, firstLines.replace(/nombreDelModulo/g, ProjectName)) &&
|
|
501
|
-
!qaControl.startsWith(fileContent, firstLines.replace(/nombreDelModulo/g, projectName))
|
|
502
|
-
) {
|
|
503
|
-
if(qaControl.verbose){
|
|
504
|
-
var code=qaControl.fixEOL(fileContent);
|
|
505
|
-
var model1=qaControl.fixEOL(firstLines.replace(/nombreDelModulo/g, projectName));
|
|
506
|
-
var model2=qaControl.fixEOL(firstLines.replace(/nombreDelModulo/g, ProjectName));
|
|
507
|
-
for(var i=0; i<model1.length; i++){
|
|
508
|
-
if(code[i]!== model1[i] && code[i] !== model2[i]){
|
|
509
|
-
console.log('RUN-IN', whichRunIn);
|
|
510
|
-
console.log('DIF STARTS IN:',JSON.stringify(code.substring(i, Math.min(model1.length, i+20))));
|
|
511
|
-
console.log('MODEL 1 :',JSON.stringify(model1.substring(i, Math.min(model1.length, i+20))));
|
|
512
|
-
console.log('MODEL 2 :',JSON.stringify(model2.substring(i, Math.min(model1.length, i+20))));
|
|
513
|
-
console.log('FOR MODULE NAME:',projectName,'OR',ProjectName);
|
|
514
|
-
break;
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
warns.push({warning:'first_lines_does_not_match_in_file_1', params:[mainName], scoring:{warning:1}});
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
return warns;
|
|
523
|
-
}
|
|
524
|
-
}]
|
|
525
|
-
},
|
|
526
|
-
normal_promises:{
|
|
527
|
-
checks:[{
|
|
528
|
-
warnings:function(info){
|
|
529
|
-
var warns = [];
|
|
530
|
-
for(var file in info.files) {
|
|
531
|
-
if(file.match(/(.js)$/)) {
|
|
532
|
-
var content = info.files[file].content;
|
|
533
|
-
if(content.match(/require\(["'](promise|q|rsvp|es6promise)['"]\)/m)) {
|
|
534
|
-
warns.push({warning:'using_normal_promise_in_file_1', params:[file], scoring:{conventions:1}});
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
return warns;
|
|
539
|
-
}
|
|
540
|
-
}]
|
|
541
|
-
},
|
|
542
|
-
jshint_config:{
|
|
543
|
-
checks:[{
|
|
544
|
-
warnings:function(info){
|
|
545
|
-
var projDef = qaControl.projectDefinition[info.packageVersion];
|
|
546
|
-
return qaControl.checkLintConfig(info,
|
|
547
|
-
'jshintConfig', 'lack_of_jshintconfig_section_in_package_json',
|
|
548
|
-
projDef.jshint_options,
|
|
549
|
-
'incorrect_jshintconfig_option_1_in_package_json',
|
|
550
|
-
{jshint:1});
|
|
551
|
-
}
|
|
552
|
-
}]
|
|
553
|
-
},
|
|
554
|
-
eslint_config:{
|
|
555
|
-
checks:[{
|
|
556
|
-
warnings:function(info){
|
|
557
|
-
var projDef = qaControl.projectDefinition[info.packageVersion];
|
|
558
|
-
return qaControl.checkLintConfig(info,
|
|
559
|
-
'eslintConfig', 'lack_of_eslintconfig_section_in_package_json',
|
|
560
|
-
projDef.eslint_options,
|
|
561
|
-
'incorrect_eslintconfig_option_1_in_package_json',
|
|
562
|
-
{eslint:1});
|
|
563
|
-
}
|
|
564
|
-
}]
|
|
565
|
-
},
|
|
566
|
-
jshint:{
|
|
567
|
-
eclipsers:['packagejson_main_file_1_does_not_exists', 'first_lines_does_not_match_in_file_1',
|
|
568
|
-
'lack_of_jshintconfig_section_in_package_json', 'incorrect_jshintconfig_option_1_in_package_json'],
|
|
569
|
-
checks:[{
|
|
570
|
-
warnings:function(info){
|
|
571
|
-
var warns = [];
|
|
572
|
-
var jshintOpts =
|
|
573
|
-
info.packageJson.jshintConfig ||
|
|
574
|
-
qaControl.projectDefinition[info.packageVersion].jshint_options;
|
|
575
|
-
for(var file in info.files) {
|
|
576
|
-
if(file.match(/(.js)$/)) {
|
|
577
|
-
var content = info.files[file].content;
|
|
578
|
-
jsh.JSHINT(content, jshintOpts , false);
|
|
579
|
-
var data = jsh.JSHINT.data();
|
|
580
|
-
if(data.errors) {
|
|
581
|
-
if(qaControl.verbose){
|
|
582
|
-
console.log('JSHINT output:');
|
|
583
|
-
console.log('jshintOpts',jshintOpts);
|
|
584
|
-
console.log(data.errors.length, " JSHINT errors");
|
|
585
|
-
console.log(data.errors);
|
|
586
|
-
//console.log(data);
|
|
587
|
-
}
|
|
588
|
-
warns.push({warning:'jshint_warnings_in_file_1', params:[file], scoring:{jshint:1}});
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
return warns;
|
|
593
|
-
}
|
|
594
|
-
}]
|
|
595
|
-
},
|
|
596
|
-
eslint:{
|
|
597
|
-
eclipsers:['packagejson_main_file_1_does_not_exists', 'first_lines_does_not_match_in_file_1',
|
|
598
|
-
'lack_of_eslintconfig_section_in_package_json', 'incorrect_eslintconfig_option_1_in_package_json'],
|
|
599
|
-
checks:[{
|
|
600
|
-
warnings:function(info){
|
|
601
|
-
var warns = [];
|
|
602
|
-
var eslintOpts = eslintrcToFlatConfig(
|
|
603
|
-
info.packageJson.eslintConfig ||
|
|
604
|
-
qaControl.projectDefinition[info.packageVersion].eslint_options);
|
|
605
|
-
for(var file in info.files) {
|
|
606
|
-
if(file.match(/(.js)$/)) {
|
|
607
|
-
var content = info.files[file].content;
|
|
608
|
-
var data = eslintLinter.verify(content, eslintOpts);
|
|
609
|
-
if(data.length) {
|
|
610
|
-
if(qaControl.verbose){
|
|
611
|
-
console.log('ESLINT output:');
|
|
612
|
-
console.log('eslintOpts',eslintOpts);
|
|
613
|
-
console.log(data.length, " ESLINT errors");
|
|
614
|
-
console.log(data);
|
|
615
|
-
//console.log(data);
|
|
616
|
-
}
|
|
617
|
-
warns.push({warning:'eslint_warnings_in_file_1', params:[file], scoring:{eslint:1}});
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
return warns;
|
|
622
|
-
}
|
|
623
|
-
}]
|
|
624
|
-
},
|
|
625
|
-
multilang:{
|
|
626
|
-
checks:[{
|
|
627
|
-
warnings:function(info) {
|
|
628
|
-
var warns = [];
|
|
629
|
-
var defReadme = qaControl.mainDoc();
|
|
630
|
-
var content = info.files[defReadme].content;
|
|
631
|
-
var obtainedLangs = multilang.obtainLangs(content);
|
|
632
|
-
/*jshint forin: false */
|
|
633
|
-
for(var lang in obtainedLangs.langs) {
|
|
634
|
-
var file=obtainedLangs.langs[lang].fileName;
|
|
635
|
-
if(file !== defReadme) {
|
|
636
|
-
var mlContent = multilang.changeNamedDoc(file, content, lang);
|
|
637
|
-
if(mlContent !== info.files[file].content) {
|
|
638
|
-
warns.push({warning:'readme_multilang_not_sincronized_with_file_1', params:[file], scoring:{multilang:1}});
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
/*jshint forin: true */
|
|
643
|
-
return warns;
|
|
644
|
-
}
|
|
645
|
-
}]
|
|
646
|
-
},
|
|
647
|
-
dependencies:{
|
|
648
|
-
checks:[{
|
|
649
|
-
warnings:qaControl.checkDepVerNumberFormat
|
|
650
|
-
}]
|
|
651
|
-
},
|
|
652
|
-
use_strict:{
|
|
653
|
-
checks:[{
|
|
654
|
-
warnings:function(info){
|
|
655
|
-
var warns = [];
|
|
656
|
-
function hasColonOutsideQuotes(line) {
|
|
657
|
-
return line.replace(/([\'"])(.*?)\1/g,'').match(/:/);
|
|
658
|
-
}
|
|
659
|
-
for(var file in info.files) {
|
|
660
|
-
if(file.match(/(.js)$/)) {
|
|
661
|
-
var content = info.files[file].content;
|
|
662
|
-
var lines = info.files[file].content.split(/\r?\n/);
|
|
663
|
-
var prevLine = null;
|
|
664
|
-
for(var l=0; l<lines.length; ++l) {
|
|
665
|
-
var line = lines[l];
|
|
666
|
-
var trimLine = line.replace(/^(\s+)/,'');
|
|
667
|
-
//console.log("line:"+l, '['+line+']', "trimmed", '['+trimLine+']', "prev", '['+prevLine+']');
|
|
668
|
-
if(trimLine.length>0
|
|
669
|
-
&& trimLine[0].match(/['"]/)
|
|
670
|
-
&& prevLine
|
|
671
|
-
&& prevLine.match(/{\s?$/)
|
|
672
|
-
//&& ! line.match(/["'].*["']\s*:/)
|
|
673
|
-
&& ! hasColonOutsideQuotes(trimLine)
|
|
674
|
-
)
|
|
675
|
-
{
|
|
676
|
-
if(! trimLine.match(/"use strict";/)) {
|
|
677
|
-
if(qaControl.verbose){
|
|
678
|
-
console.log('['+file+']');
|
|
679
|
-
console.log(' '+(l-1)+':"'+prevLine+'"');
|
|
680
|
-
console.log(' '+(l)+':"'+line+'"');
|
|
681
|
-
}
|
|
682
|
-
warns.push({warning:'wrong_use_strict_spelling_in_file_1', params:[file], scoring:{conventions:1}});
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
prevLine = line;
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
return warns;
|
|
690
|
-
}
|
|
691
|
-
}]
|
|
692
|
-
},
|
|
693
|
-
files_in_package_json:{
|
|
694
|
-
checks:[{
|
|
695
|
-
warnings:function(info) {
|
|
696
|
-
var warns = [];
|
|
697
|
-
if(!('files' in info.packageJson)) {
|
|
698
|
-
warns.push({warning:'lack_of_files_section_in_package_json', scoring:{mandatories:1}});
|
|
699
|
-
} else {
|
|
700
|
-
var detail=[];
|
|
701
|
-
//console.log("info.files", Object.keys(info.files));
|
|
702
|
-
//console.log("files", info.packageJson.files.join(" "));
|
|
703
|
-
var qaFiles=qaControl.projectDefinition[info.packageVersion].files;
|
|
704
|
-
for(var fileName in info.packageJson.files) {
|
|
705
|
-
var file = info.packageJson.files[fileName];
|
|
706
|
-
if(file==='package.json') { detail.push('"'+file+'" is always included by npm'); }
|
|
707
|
-
if(file.match(/^(\.)/)) { detail.push('"'+file+'" is a .dot file'); }
|
|
708
|
-
if(file in qaFiles) {
|
|
709
|
-
detail.push('"'+file+'" cannot be in files section');
|
|
710
|
-
} else {
|
|
711
|
-
try {
|
|
712
|
-
var stat = fs.statSync(Path.resolve(info.projectDir+'/'+file));
|
|
713
|
-
if(! stat.isDirectory()) {
|
|
714
|
-
if(!(file in info.files)) { detail.push('"'+file+'" should exist'); }
|
|
715
|
-
}
|
|
716
|
-
} catch(e) { detail.push('"'+file+'" does not exists'); }
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
if(detail.length) {
|
|
720
|
-
warns.push({warning:'invalid_files_section_in_package_json', scoring:{mandatories:1}});
|
|
721
|
-
if(qaControl.verbose) {
|
|
722
|
-
console.log("Invalid files:");
|
|
723
|
-
console.log("\t"+detail.join("\n\t"));
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
return warns;
|
|
728
|
-
}
|
|
729
|
-
}]
|
|
730
|
-
},
|
|
731
|
-
ecma_version:{
|
|
732
|
-
eclipsers:['packagejson_main_file_1_does_not_exists', 'first_lines_does_not_match_in_file_1',
|
|
733
|
-
'lack_of_eslintconfig_section_in_package_json', 'incorrect_eslintconfig_option_1_in_package_json',
|
|
734
|
-
'lack_of_jshintconfig_section_in_package_json', 'incorrect_jshintconfig_option_1_in_package_json'],
|
|
735
|
-
checks:[{
|
|
736
|
-
warnings:function(info) {
|
|
737
|
-
var warns = [];
|
|
738
|
-
var ecmaVer = info.packageJson['qa-control']['ecmaVersion'];
|
|
739
|
-
var detail = [];
|
|
740
|
-
var jshint = info.packageJson.jshintConfig;
|
|
741
|
-
var eslint = info.packageJson.eslintConfig;
|
|
742
|
-
if(ecmaVer) {
|
|
743
|
-
if(!('esversion' in jshint)) {
|
|
744
|
-
detail.push('missing "esversion" in jshintConfig');
|
|
745
|
-
} else if(jshint['esversion'] !== ecmaVer) {
|
|
746
|
-
detail.push('incorrect "esversion" in jshintConfig');
|
|
747
|
-
}
|
|
748
|
-
if(!('parserOptions' in eslint) || !('ecmaVersion' in eslint['parserOptions'])) {
|
|
749
|
-
detail.push('missing "ecmaVersion" in eslintConfig');
|
|
750
|
-
} else if(eslint['parserOptions']['ecmaVersion'] !== ecmaVer) {
|
|
751
|
-
detail.push('incorrect "ecmaVersion" in eslintConfig');
|
|
752
|
-
}
|
|
753
|
-
} else {
|
|
754
|
-
if('esversion' in jshint) {
|
|
755
|
-
detail.push('unexpected "esversion" in jshintConfig');
|
|
756
|
-
}
|
|
757
|
-
if('parserOptions' in eslint && 'ecmaVersion' in eslint['parserOptions']) {
|
|
758
|
-
detail.push('unexpected "ecmaVersion" in eslintConfig');
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
if(detail.length) {
|
|
762
|
-
warns.push({warning:'incorrect_ecmascript_versions_in_package_json', scoring:{mandatories:1}});
|
|
763
|
-
if(qaControl.verbose) { console.log("\t"+detail.join("\n\t")); }
|
|
764
|
-
}
|
|
765
|
-
return warns;
|
|
766
|
-
}
|
|
767
|
-
}]
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
};
|
|
771
|
-
};
|