Skip to content

Commit f72c43f

Browse files
committed
fix packageJson validate content
1 parent a6a66cd commit f72c43f

File tree

5 files changed

+28
-30
lines changed

5 files changed

+28
-30
lines changed

lib/cli.js

100644100755
File mode changed.

lib/validate/packageJson.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,59 +3,59 @@ var pJKeys = [{
33
name: 'name',
44
validate: function (name) { return !!name.match(/^coderoad-[A-Za-z0-9\-]+$/); },
55
msg: 'must be kebabcased and start with "coderoad"',
6-
example: 'coderoad-tutorial-name',
6+
example: '"coderoad-tut-name"',
77
}, {
88
name: 'version',
99
validate: function (version) { return !!version.match(/^[0-9]+\.[0-9]+\.[0-9]+$/); },
1010
msg: 'must be 3 numbers separated by dots',
11-
example: '0.1.0',
11+
example: '"0.1.0"',
1212
}, {
1313
name: 'main',
1414
validate: function (main) { return main === 'coderoad.json'; },
1515
msg: 'must point to coderoad.json',
16-
example: 'coderoad.json',
16+
example: '"coderoad.json"',
1717
}, {
1818
name: 'description',
1919
validate: function (desc) { return typeof desc === 'string' && desc.length > 3; },
2020
msg: 'must be long enough to describe a package',
21-
example: 'CodeRoad tutorial on ES2015 new features.'
21+
example: '"CodeRoad tutorial on ES2015 new features."'
2222
}, {
2323
name: 'keywords',
2424
validate: function (keywords) { return Array.isArray(keywords) && !!keywords.length && keywords.includes('coderoad'); },
2525
msg: 'must be an array containing "coderoad"',
26-
example: '["coderoad", "tutorial", "js"]',
26+
example: '[\n"coderoad",\n"tutorial",\n"js"\n]',
2727
}, {
2828
name: 'author',
2929
validate: function (author) { return typeof author === 'string' && author.length > 2; },
3030
msg: 'must have an author name and optional email',
31-
example: 'Shawn McKay <me@email.com> (http://blog)',
31+
example: '"Shawn McKay <me@email.com> (http://blog)"',
3232
}, {
3333
name: 'config',
3434
validate: function (config) { return typeof config === 'object'; },
3535
msg: 'must be an object',
36-
example: '"config": {"language": "JS", "runner": "mocha-coderoad"}',
36+
example: '{\n"language": "JS",\n"runner": "mocha-coderoad"\n}',
3737
}, {
3838
name: 'files',
3939
validate: function (files) { return Array.isArray(files) && files.includes('coderoad.json') && files.includes('tutorial'); },
4040
msg: 'must be an array including "coderoad.json" & "tutorial"',
41-
example: '["coderoad.json", "tutorial"]',
41+
example: '[\n"coderoad.json",\n "tutorial"\n]',
4242
}, {
4343
name: 'engines',
4444
validate: function (engines) { return typeof engines === 'object' && !!engines.node && !!engines.node.match(/^(>=)?[0-9]+/); },
4545
msg: 'must specify a valid node version',
46-
example: '"engines": { "node": ">=0.10.3"}',
46+
example: '{\n "node": ">=0.10.3"\n}',
4747
}, {
4848
name: 'language',
4949
config: true,
5050
validate: function (lang) { return typeof lang === 'string' && !!lang.length; },
5151
msg: 'must specify a programming language',
52-
example: 'JS',
52+
example: '"JS"',
5353
}, {
5454
name: 'runner',
5555
config: true,
5656
validate: function (runner) { return typeof runner === 'string' && !!runner.length; },
5757
msg: 'must specify a test runner',
58-
example: 'mocha-coderoad',
58+
example: '"mocha-coderoad"',
5959
}, {
6060
name: 'repository',
6161
optional: true,
@@ -66,20 +66,20 @@ var pJKeys = [{
6666
repo.hasOwnProperty('url') && typeof repo.url === 'string';
6767
},
6868
msg: 'should have a valid repository',
69-
example: 'https://github.com/shmck/coderoad-tutorial-name',
69+
example: '"https:\/\/github.com/shmck/coderoad-tutorial-name"',
7070
}, {
7171
name: 'bugs',
7272
optional: true,
7373
validate: function (bugs) { return typeof bugs === 'object' &&
7474
bugs.hasOwnProperty('url') && typeof bugs.url === 'string'; },
7575
msg: 'should have a link to where to post bugs',
76-
example: '"bugs": { "url": "https://github.com/shmck/coderoad-tutorial-name" }'
76+
example: '{\n"url": "https:\/\/github.com/shmck/coderoad-tut-name"\n}'
7777
}, {
7878
name: 'license',
7979
optional: true,
8080
validate: function (license) { return typeof license === 'string' && !!license.length; },
8181
msg: 'should have a valid license (ex: MIT, ISC, etc.)',
82-
example: 'MIT',
82+
example: '"MIT"',
8383
}];
8484
function validatePackageJson(pj) {
8585
var errors = [];

src/typings/tsd.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/validate/packageJson.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,59 @@ const pJKeys: PJKeys[] = [{
22
name: 'name',
33
validate: name => !!name.match(/^coderoad-[A-Za-z0-9\-]+$/),
44
msg: 'must be kebabcased and start with "coderoad"',
5-
example: 'coderoad-tutorial-name',
5+
example: '"coderoad-tut-name"',
66
}, {
77
name: 'version',
88
validate: version => !!version.match(/^[0-9]+\.[0-9]+\.[0-9]+$/),
99
msg: 'must be 3 numbers separated by dots',
10-
example: '0.1.0',
10+
example: '"0.1.0"',
1111
}, {
1212
name: 'main',
1313
validate: main => main === 'coderoad.json',
1414
msg: 'must point to coderoad.json',
15-
example: 'coderoad.json',
15+
example: '"coderoad.json"',
1616
}, {
1717
name: 'description',
1818
validate: desc => typeof desc === 'string' && desc.length > 3,
1919
msg: 'must be long enough to describe a package',
20-
example: 'CodeRoad tutorial on ES2015 new features.'
20+
example: '"CodeRoad tutorial on ES2015 new features."'
2121
}, {
2222
name: 'keywords',
2323
validate: keywords => Array.isArray(keywords) && !!keywords.length && keywords.includes('coderoad'),
2424
msg: 'must be an array containing "coderoad"',
25-
example: '["coderoad", "tutorial", "js"]',
25+
example: '[\n"coderoad",\n"tutorial",\n"js"\n]',
2626
}, {
2727
name: 'author',
2828
validate: author => typeof author === 'string' && author.length > 2,
2929
msg: 'must have an author name and optional email',
30-
example: 'Shawn McKay <me@email.com> (http://blog)',
30+
example: '"Shawn McKay <me@email.com> (http://blog)"',
3131
}, {
3232
name: 'config',
3333
validate: config => typeof config === 'object',
3434
msg: 'must be an object',
35-
example: '"config": {"language": "JS", "runner": "mocha-coderoad"}',
35+
example: '{\n"language": "JS",\n"runner": "mocha-coderoad"\n}',
3636
}, {
3737
name: 'files',
3838
validate: files => Array.isArray(files) && files.includes('coderoad.json') && files.includes('tutorial'),
3939
msg: 'must be an array including "coderoad.json" & "tutorial"',
40-
example: '["coderoad.json", "tutorial"]',
40+
example: '[\n"coderoad.json",\n "tutorial"\n]',
4141
}, {
4242
name: 'engines',
4343
validate: engines => typeof engines === 'object' && !!engines.node && !!engines.node.match(/^(>=)?[0-9]+/),
4444
msg: 'must specify a valid node version',
45-
example: '"engines": { "node": ">=0.10.3"}',
45+
example: '{\n "node": ">=0.10.3"\n}',
4646
}, {
4747
name: 'language',
4848
config: true,
4949
validate: lang => typeof lang === 'string' && !!lang.length,
5050
msg: 'must specify a programming language',
51-
example: 'JS',
51+
example: '"JS"',
5252
}, {
5353
name: 'runner',
5454
config: true,
5555
validate: runner => typeof runner === 'string' && !!runner.length,
5656
msg: 'must specify a test runner',
57-
example: 'mocha-coderoad',
57+
example: '"mocha-coderoad"',
5858
}, {
5959
name: 'repository',
6060
optional: true,
@@ -65,20 +65,20 @@ const pJKeys: PJKeys[] = [{
6565
repo.hasOwnProperty('url') && typeof repo.url === 'string';
6666
},
6767
msg: 'should have a valid repository',
68-
example: 'https://github.com/shmck/coderoad-tutorial-name',
68+
example: '"https:\/\/github.com/shmck/coderoad-tutorial-name"',
6969
}, {
7070
name: 'bugs',
7171
optional: true,
7272
validate: (bugs: { url: string }) => typeof bugs === 'object' &&
7373
bugs.hasOwnProperty('url') && typeof bugs.url === 'string',
7474
msg: 'should have a link to where to post bugs',
75-
example: '"bugs": { "url": "https://github.com/shmck/coderoad-tutorial-name" }'
75+
example: '{\n"url": "https:\/\/github.com/shmck/coderoad-tut-name"\n}'
7676
}, {
7777
name: 'license',
7878
optional: true,
7979
validate: license => typeof license === 'string' && !!license.length,
8080
msg: 'should have a valid license (ex: MIT, ISC, etc.)',
81-
example: 'MIT',
81+
example: '"MIT"',
8282
}];
8383

8484
export default function validatePackageJson(pj: PackageJson): ValidatePjOutput {

tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
"src/typings/node/node.d.ts",
5858
"src/typings/prompt/prompt.d.ts",
5959
"src/typings/sort-package-json/index.d.ts",
60-
"src/typings/tsd.d.ts",
6160
"src/update/index.ts",
6261
"src/validate/coderoadJson.ts",
6362
"src/validate/index.ts",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy