-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Export manifest logic #1015
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export manifest logic #1015
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
manifest: require( "./manifest" ) | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
var categories, flatten, manifest, pkg; | ||
|
||
categories = { | ||
core: { | ||
name: "ui.{plugin}", | ||
title: "jQuery UI {Plugin}" | ||
}, | ||
widget: { | ||
name: "ui.{plugin}", | ||
title: "jQuery UI {Plugin}", | ||
dependencies: [ "core", "widget" ] | ||
}, | ||
interaction: { | ||
name: "ui.{plugin}", | ||
title: "jQuery UI {Plugin}", | ||
dependencies: [ "core", "widget", "mouse" ] | ||
}, | ||
effect: { | ||
name: "ui.effect-{plugin}", | ||
title: "jQuery UI {Plugin} Effect", | ||
keywords: [ "effect", "show", "hide" ], | ||
homepage: "http://jqueryui.com/effect/", | ||
demo: "http://jqueryui.com/effect/", | ||
docs: "http://api.jqueryui.com/{plugin}-effect/", | ||
dependencies: [ "effect" ] | ||
} | ||
}; | ||
|
||
flatten = function( flat, arr ) { | ||
return flat.concat( arr ); | ||
}; | ||
|
||
pkg = require( "../package.json" ); | ||
|
||
manifest = function( options ) { | ||
options = options || {}; | ||
|
||
return Object.keys( categories ).map(function( category ) { | ||
var baseManifest = categories[ category ], | ||
plugins = require( "./" + category ); | ||
|
||
return Object.keys( plugins ).map(function( plugin ) { | ||
var manifest, | ||
data = plugins[ plugin ], | ||
name = plugin.charAt( 0 ).toUpperCase() + plugin.substr( 1 ); | ||
|
||
function replace( str ) { | ||
return str.replace( "{plugin}", plugin ).replace( "{Plugin}", name ); | ||
} | ||
|
||
manifest = { | ||
name: data.name || replace( baseManifest.name ), | ||
title: data.title || replace( baseManifest.title ), | ||
description: data.description, | ||
keywords: [ "ui", plugin ] | ||
.concat( baseManifest.keywords || [] ) | ||
.concat( data.keywords || [] ), | ||
version: pkg.version, | ||
author: pkg.author, | ||
maintainers: pkg.maintainers, | ||
licenses: pkg.licenses, | ||
bugs: pkg.bugs, | ||
homepage: data.homepage || replace( baseManifest.homepage || | ||
"http://jqueryui.com/{plugin}/" ), | ||
demo: data.demo || replace( baseManifest.demo || | ||
"http://jqueryui.com/{plugin}/" ), | ||
docs: data.docs || replace( baseManifest.docs || | ||
"http://api.jqueryui.com/{plugin}/" ), | ||
download: "http://jqueryui.com/download/", | ||
dependencies: { | ||
jquery: ">=1.6" | ||
}, | ||
// custom | ||
category: data.category || category | ||
}; | ||
|
||
if ( options.extra ) { | ||
Object.keys( data._ || {} ).forEach(function( prop ) { | ||
manifest[ prop ] = data._[ prop ]; | ||
}); | ||
} | ||
|
||
(baseManifest.dependencies || []) | ||
.concat(data.dependencies || []) | ||
.forEach(function( dependency ) { | ||
manifest.dependencies[ "ui." + dependency ] = pkg.version; | ||
}); | ||
|
||
return manifest; | ||
}); | ||
}).reduce( flatten, [] ); | ||
}; | ||
|
||
module.exports = manifest; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
"name": "jQuery Foundation and other contributors", | ||
"url": "https://github.com/jquery/jquery-ui/blob/master/AUTHORS.txt" | ||
}, | ||
"main": "build/main.js", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Although this is practical for our urgent need, this seems wrong. Exporting API this way allows 3rd parties (eg download builder) to do the following: manifest = require("jquery-ui").manifest; This is practical, but isn't it wrong to have the main entry of jquery-ui not being the jquery-ui scripts? Eg. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps, we could have a custom-entry in
Or DB could hijack it with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no need for main to point at a source file since the source files are worthless in node. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, that's perhaps what a potential |
||
"maintainers": [ | ||
{ | ||
"name": "Scott González", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't want an API that takes options. We have exactly two use cases and they are more clearly served with two functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any name suggestions? I need your creativity help here ;)
Manifest: {
regular: fn // that grunt task will use
withExtras: fn // that db will use
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nicer named API is what is used externally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. If we are going to have those two forms, it means:
_
fromrawManifests
);manifests
the invalid (full merged) manifests, which is only useful for download builder;If we expose one only option (raw format), it will mean the same for the grunt task (it will have to process it anyway), and we move the merge logic (which is only useful for db) to db.
What do you think if we only export the raw manifests then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The manifests are only invalid in terms of what the plugin registery expects. Our manifests can be more feature complete than that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't make sense to ask a 3rd party (which DB is) to process the
_
fields.