Skip to content

Commit 7f75321

Browse files
committed
Add support for providing a __stdlib__ field
1 parent 80da690 commit 7f75321

File tree

6 files changed

+325
-15
lines changed

6 files changed

+325
-15
lines changed

tools/pkg-json/schema/lib/schema.json

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,20 @@
148148
"type": "string",
149149
"minLength": 1
150150
},
151+
"license": {
152+
"description": "package license",
153+
"type": "string",
154+
"minLength": 1
155+
},
156+
"licenses": {
157+
"description": "package licenses",
158+
"type": "array",
159+
"items": {
160+
"$ref": "#/definitions/license-object"
161+
},
162+
"uniqueItems": true,
163+
"minItems": 1
164+
},
151165
"author": {
152166
"description": "package author",
153167
"$ref": "#/definitions/person"
@@ -279,27 +293,36 @@
279293
},
280294
"uniqueItems": true
281295
},
282-
"license": {
283-
"description": "package license",
284-
"type": "string",
285-
"minLength": 1
286-
},
287-
"licenses": {
288-
"description": "package licenses",
289-
"type": "array",
290-
"items": {
291-
"$ref": "#/definitions/license-object"
292-
},
293-
"uniqueItems": true,
294-
"minItems": 1
295-
},
296296
"keywords": {
297297
"description": "package keywords",
298298
"type": "array",
299299
"items": {
300300
"$ref": "#/definitions/keyword"
301301
},
302302
"uniqueItems": true
303+
},
304+
"__stdlib__": {
305+
"description": "project meta data",
306+
"type": "object",
307+
"properties": {
308+
"stability": {
309+
"description": "package stability",
310+
"type": "string"
311+
},
312+
"envs": {
313+
"description": "supported environments",
314+
"type": "object",
315+
"properties": {
316+
"node": {
317+
"type": "boolean"
318+
},
319+
"browser": {
320+
"type": "boolean"
321+
}
322+
}
323+
}
324+
},
325+
"required": []
303326
}
304327
},
305328
"required": [
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{
2+
"name": "beep",
3+
"version": "0.0.0",
4+
"description": "boop",
5+
"author": {
6+
"name": "Beep Boop",
7+
"email": "beep@boop.com",
8+
"url": "https://beep.boop.com"
9+
},
10+
"maintainers": [
11+
{
12+
"name": "Beep Boop",
13+
"email": "beep@boop.com"
14+
}
15+
],
16+
"contributors": [
17+
{
18+
"name": "Beep Boop",
19+
"email": "beep@boop.com"
20+
}
21+
],
22+
"bin": {
23+
"beep": "./bin/cli"
24+
},
25+
"scripts": {
26+
"test": "make test"
27+
},
28+
"main": "./lib",
29+
"gypfile": true,
30+
"directories": {
31+
"benchmark": "./benchmark",
32+
"bin": "./bin",
33+
"doc": "./doc",
34+
"example": "./examples",
35+
"lib": "./lib",
36+
"man": "./doc/man",
37+
"src": "./src",
38+
"test": "./test"
39+
},
40+
"repository": {
41+
"type": "git",
42+
"url": "git://github.com/stdlib-js/stdlib.git"
43+
},
44+
"repositories": [
45+
{
46+
"type": "git",
47+
"url": "git://github.com/stdlib-js/stdlib.git"
48+
}
49+
],
50+
"homepage": "https://github.com/stdlib-js/stdlib",
51+
"keywords": [
52+
"stdlib"
53+
],
54+
"bugs": {
55+
"url": "https://github.com/stdlib-js/stdlib/issues"
56+
},
57+
"dependencies": {
58+
"electron": "^1.4.1"
59+
},
60+
"devDependencies": {
61+
"browserify": "13.x.x"
62+
},
63+
"engines": {
64+
"node": ">=0.10.0"
65+
},
66+
"os": [
67+
"darwin",
68+
"linux",
69+
"win32"
70+
],
71+
"license": "Apache-2.0",
72+
"licenses": [
73+
{
74+
"type": "Apache-2.0",
75+
"url": "https://www.apache.org/licenses/LICENSE-2.0"
76+
}
77+
],
78+
"__stdlib__": "foo"
79+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
"name": "beep",
3+
"version": "0.0.0",
4+
"description": "boop",
5+
"author": {
6+
"name": "Beep Boop",
7+
"email": "beep@boop.com",
8+
"url": "https://beep.boop.com"
9+
},
10+
"maintainers": [
11+
{
12+
"name": "Beep Boop",
13+
"email": "beep@boop.com"
14+
}
15+
],
16+
"contributors": [
17+
{
18+
"name": "Beep Boop",
19+
"email": "beep@boop.com"
20+
}
21+
],
22+
"bin": {
23+
"beep": "./bin/cli"
24+
},
25+
"scripts": {
26+
"test": "make test"
27+
},
28+
"main": "./lib",
29+
"gypfile": true,
30+
"directories": {
31+
"benchmark": "./benchmark",
32+
"bin": "./bin",
33+
"doc": "./doc",
34+
"example": "./examples",
35+
"lib": "./lib",
36+
"man": "./doc/man",
37+
"src": "./src",
38+
"test": "./test"
39+
},
40+
"repository": {
41+
"type": "git",
42+
"url": "git://github.com/stdlib-js/stdlib.git"
43+
},
44+
"repositories": [
45+
{
46+
"type": "git",
47+
"url": "git://github.com/stdlib-js/stdlib.git"
48+
}
49+
],
50+
"homepage": "https://github.com/stdlib-js/stdlib",
51+
"keywords": [
52+
"stdlib"
53+
],
54+
"bugs": {
55+
"url": "https://github.com/stdlib-js/stdlib/issues"
56+
},
57+
"dependencies": {
58+
"electron": "^1.4.1"
59+
},
60+
"devDependencies": {
61+
"browserify": "13.x.x"
62+
},
63+
"engines": {
64+
"node": ">=0.10.0"
65+
},
66+
"os": [
67+
"darwin",
68+
"linux",
69+
"win32"
70+
],
71+
"license": "Apache-2.0",
72+
"licenses": [
73+
{
74+
"type": "Apache-2.0",
75+
"url": "https://www.apache.org/licenses/LICENSE-2.0"
76+
}
77+
],
78+
"__stdlib__": {
79+
"envs": {
80+
"node": 1234,
81+
"browser": 5678
82+
}
83+
}
84+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"name": "beep",
3+
"version": "0.0.0",
4+
"description": "boop",
5+
"author": {
6+
"name": "Beep Boop",
7+
"email": "beep@boop.com",
8+
"url": "https://beep.boop.com"
9+
},
10+
"maintainers": [
11+
{
12+
"name": "Beep Boop",
13+
"email": "beep@boop.com"
14+
}
15+
],
16+
"contributors": [
17+
{
18+
"name": "Beep Boop",
19+
"email": "beep@boop.com"
20+
}
21+
],
22+
"bin": {
23+
"beep": "./bin/cli"
24+
},
25+
"scripts": {
26+
"test": "make test"
27+
},
28+
"main": "./lib",
29+
"gypfile": true,
30+
"directories": {
31+
"benchmark": "./benchmark",
32+
"bin": "./bin",
33+
"doc": "./doc",
34+
"example": "./examples",
35+
"lib": "./lib",
36+
"man": "./doc/man",
37+
"src": "./src",
38+
"test": "./test"
39+
},
40+
"repository": {
41+
"type": "git",
42+
"url": "git://github.com/stdlib-js/stdlib.git"
43+
},
44+
"repositories": [
45+
{
46+
"type": "git",
47+
"url": "git://github.com/stdlib-js/stdlib.git"
48+
}
49+
],
50+
"homepage": "https://github.com/stdlib-js/stdlib",
51+
"keywords": [
52+
"stdlib"
53+
],
54+
"bugs": {
55+
"url": "https://github.com/stdlib-js/stdlib/issues"
56+
},
57+
"dependencies": {
58+
"electron": "^1.4.1"
59+
},
60+
"devDependencies": {
61+
"browserify": "13.x.x"
62+
},
63+
"engines": {
64+
"node": ">=0.10.0"
65+
},
66+
"os": [
67+
"darwin",
68+
"linux",
69+
"win32"
70+
],
71+
"license": "Apache-2.0",
72+
"licenses": [
73+
{
74+
"type": "Apache-2.0",
75+
"url": "https://www.apache.org/licenses/LICENSE-2.0"
76+
}
77+
],
78+
"__stdlib__": {
79+
"stability": 1234
80+
}
81+
}

tools/pkg-json/schema/test/fixtures/good.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,12 @@
7474
"type": "Apache-2.0",
7575
"url": "https://www.apache.org/licenses/LICENSE-2.0"
7676
}
77-
]
77+
],
78+
"__stdlib__": {
79+
"stability": "stable",
80+
"envs": {
81+
"node": true,
82+
"browser": true
83+
}
84+
}
7885
}

tools/pkg-json/schema/test/test.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,42 @@ tape( 'the function returns `false` if provided a package JSON having an invalid
759759
t.end();
760760
});
761761

762+
tape( 'the function returns `false` if provided a package JSON having an invalid `__stdlib__` field', function test( t ) {
763+
var bool;
764+
var pkg;
765+
766+
pkg = require( './fixtures/bad_stdlib.json' );
767+
768+
bool = validate( pkg );
769+
t.strictEqual( bool, false, 'returns false' );
770+
771+
t.end();
772+
});
773+
774+
tape( 'the function returns `false` if provided a package JSON having an invalid `__stdlib__` field', function test( t ) {
775+
var bool;
776+
var pkg;
777+
778+
pkg = require( './fixtures/bad_stdlib_stability.json' );
779+
780+
bool = validate( pkg );
781+
t.strictEqual( bool, false, 'returns false' );
782+
783+
t.end();
784+
});
785+
786+
tape( 'the function returns `false` if provided a package JSON having an invalid `__stdlib__` field', function test( t ) {
787+
var bool;
788+
var pkg;
789+
790+
pkg = require( './fixtures/bad_stdlib_envs.json' );
791+
792+
bool = validate( pkg );
793+
t.strictEqual( bool, false, 'returns false' );
794+
795+
t.end();
796+
});
797+
762798
tape( 'the function returns `false` if provided a package JSON having an invalid `version` field', function test( t ) {
763799
var bool;
764800
var pkg;

0 commit comments

Comments
 (0)