Skip to content

Commit cb57e8e

Browse files
committed
Manifest: create file from code of respective grunt task
1 parent bfa553c commit cb57e8e

File tree

2 files changed

+88
-75
lines changed

2 files changed

+88
-75
lines changed

build/manifest.js

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
var categories, flatten, manifest, pkg;
2+
3+
categories = {
4+
core: {
5+
name: "ui.{plugin}",
6+
title: "jQuery UI {Plugin}"
7+
},
8+
widget: {
9+
name: "ui.{plugin}",
10+
title: "jQuery UI {Plugin}",
11+
dependencies: [ "core", "widget" ]
12+
},
13+
interaction: {
14+
name: "ui.{plugin}",
15+
title: "jQuery UI {Plugin}",
16+
dependencies: [ "core", "widget", "mouse" ]
17+
},
18+
effect: {
19+
name: "ui.effect-{plugin}",
20+
title: "jQuery UI {Plugin} Effect",
21+
keywords: [ "effect", "show", "hide" ],
22+
homepage: "http://jqueryui.com/effect/",
23+
demo: "http://jqueryui.com/effect/",
24+
docs: "http://api.jqueryui.com/{plugin}-effect/",
25+
dependencies: [ "effect" ]
26+
}
27+
};
28+
29+
flatten = function( flat, arr ) {
30+
return flat.concat( arr );
31+
};
32+
33+
pkg = require( "../package.json" );
34+
35+
manifest = function() {
36+
return Object.keys( categories ).map(function( category ) {
37+
var baseManifest = categories[ category ],
38+
plugins = require( "./" + category );
39+
40+
return Object.keys( plugins ).map(function( plugin ) {
41+
var manifest,
42+
data = plugins[ plugin ],
43+
name = plugin.charAt( 0 ).toUpperCase() + plugin.substr( 1 );
44+
45+
function replace( str ) {
46+
return str.replace( "{plugin}", plugin ).replace( "{Plugin}", name );
47+
}
48+
49+
manifest = {
50+
name: data.name || replace( baseManifest.name ),
51+
title: data.title || replace( baseManifest.title ),
52+
description: data.description,
53+
keywords: [ "ui", plugin ]
54+
.concat( baseManifest.keywords || [] )
55+
.concat( data.keywords || [] ),
56+
version: pkg.version,
57+
author: pkg.author,
58+
maintainers: pkg.maintainers,
59+
licenses: pkg.licenses,
60+
bugs: pkg.bugs,
61+
homepage: data.homepage || replace( baseManifest.homepage ||
62+
"http://jqueryui.com/{plugin}/" ),
63+
demo: data.demo || replace( baseManifest.demo ||
64+
"http://jqueryui.com/{plugin}/" ),
65+
docs: data.docs || replace( baseManifest.docs ||
66+
"http://api.jqueryui.com/{plugin}/" ),
67+
download: "http://jqueryui.com/download/",
68+
dependencies: {
69+
jquery: ">=1.6"
70+
},
71+
// custom
72+
category: data.category || category
73+
};
74+
75+
(baseManifest.dependencies || [])
76+
.concat(data.dependencies || [])
77+
.forEach(function( dependency ) {
78+
manifest.dependencies[ "ui." + dependency ] = pkg.version;
79+
});
80+
81+
return manifest;
82+
});
83+
}).reduce( flatten, [] );
84+
};
85+
86+
module.exports = manifest;

build/tasks/build.js

Lines changed: 2 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -19,81 +19,8 @@ function expandFiles( files ) {
1919
}
2020

2121
grunt.registerTask( "manifest", "Generate jquery.json manifest files", function() {
22-
var pkg = grunt.config( "pkg" ),
23-
base = {
24-
core: {
25-
name: "ui.{plugin}",
26-
title: "jQuery UI {Plugin}"
27-
},
28-
widget: {
29-
name: "ui.{plugin}",
30-
title: "jQuery UI {Plugin}",
31-
dependencies: [ "core", "widget" ]
32-
},
33-
interaction: {
34-
name: "ui.{plugin}",
35-
title: "jQuery UI {Plugin}",
36-
dependencies: [ "core", "widget", "mouse" ]
37-
},
38-
effect: {
39-
name: "ui.effect-{plugin}",
40-
title: "jQuery UI {Plugin} Effect",
41-
keywords: [ "effect", "show", "hide" ],
42-
homepage: "http://jqueryui.com/effect/",
43-
demo: "http://jqueryui.com/effect/",
44-
docs: "http://api.jqueryui.com/{plugin}-effect/",
45-
dependencies: [ "effect" ]
46-
}
47-
};
48-
49-
Object.keys( base ).forEach(function( type ) {
50-
var baseManifest = base[ type ],
51-
plugins = grunt.file.readJSON( "build/" + type + ".json" );
52-
53-
Object.keys( plugins ).forEach(function( plugin ) {
54-
var manifest,
55-
data = plugins[ plugin ],
56-
name = plugin.charAt( 0 ).toUpperCase() + plugin.substr( 1 );
57-
58-
function replace( str ) {
59-
return str.replace( "{plugin}", plugin ).replace( "{Plugin}", name );
60-
}
61-
62-
manifest = {
63-
name: data.name || replace( baseManifest.name ),
64-
title: data.title || replace( baseManifest.title ),
65-
description: data.description,
66-
keywords: [ "ui", plugin ]
67-
.concat( baseManifest.keywords || [] )
68-
.concat( data.keywords || [] ),
69-
version: pkg.version,
70-
author: pkg.author,
71-
maintainers: pkg.maintainers,
72-
licenses: pkg.licenses,
73-
bugs: pkg.bugs,
74-
homepage: data.homepage || replace( baseManifest.homepage ||
75-
"http://jqueryui.com/{plugin}/" ),
76-
demo: data.demo || replace( baseManifest.demo ||
77-
"http://jqueryui.com/{plugin}/" ),
78-
docs: data.docs || replace( baseManifest.docs ||
79-
"http://api.jqueryui.com/{plugin}/" ),
80-
download: "http://jqueryui.com/download/",
81-
dependencies: {
82-
jquery: ">=1.6"
83-
},
84-
// custom
85-
category: data.category || type
86-
};
87-
88-
(baseManifest.dependencies || [])
89-
.concat(data.dependencies || [])
90-
.forEach(function( dependency ) {
91-
manifest.dependencies[ "ui." + dependency ] = pkg.version;
92-
});
93-
94-
grunt.file.write( manifest.name + ".jquery.json",
95-
JSON.stringify( manifest, null, "\t" ) + "\n" );
96-
});
22+
require( "../manifest" )().forEach(function( manifest ) {
23+
grunt.file.write( manifest.name + ".jquery.json", JSON.stringify( manifest, null, "\t" ) + "\n" );
9724
});
9825
});
9926

0 commit comments

Comments
 (0)