Skip to content

Commit cb62dcd

Browse files
committed
Handle new manifest file format.
1 parent 92041cc commit cb62dcd

File tree

10 files changed

+400
-187
lines changed

10 files changed

+400
-187
lines changed

docs/jquery.json.md

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
Specification of the jQuery Plugins Site jquery.json
2-
====================================================
1+
Specification of the jQuery Plugins Site Manifest File
2+
======================================================
33

44
# LIVING SPEC (heavily inspired by that of npm, thanks isaacs)
55

66
This document is all you need to know about what's required in your jquery.json
7-
file(s). It must be actual JSON, not just a JavaScript object literal.
7+
manifest file(s). It must be actual JSON, not just a JavaScript object literal.
88

9-
**NOTE: While we refer to the file as jquery.json, the file name must actually be {name}.jquery.json.**
9+
**NOTE: Manifest file names must contain the plugin name, e.g. foo.jquery.json.**
1010

1111
# Fields
1212

@@ -31,15 +31,15 @@ file(s). It must be actual JSON, not just a JavaScript object literal.
3131

3232
## <a name="field-name">name</a>
3333

34-
The *most* important things in your jquery.json are the name and version fields.
34+
The *most* important things in your manifest file are the name and version fields.
3535
The name and version together form an identifier that is assumed
3636
to be completely unique. Changes to the plugin should come along with
3737
changes to the version.
3838

3939
The name is what your thing is called. Some tips:
4040

4141
* Don't put "js" or "jquery" in the name. It's assumed that it's js and jquery, since
42-
you're writing a jquery.json file.
42+
you're writing a jquery.json manifest file.
4343
* The name ends up being part of a URL. Any name with non-url-safe characters will
4444
be rejected. The jQuery Plugins Site is UTF-8.
4545
* The name should be short, but also reasonably descriptive.
@@ -51,7 +51,7 @@ The name is what your thing is called. Some tips:
5151

5252
## <a name="field-version">version</a>
5353

54-
The *most* important things in your jquery.json are the name and version fields.
54+
The *most* important things in your manifest file are the name and version fields.
5555
The name and version together form an identifier that is assumed
5656
to be completely unique. Changes to the plugin should come along with
5757
changes to the version. Version number must be a valid semantic version number
@@ -213,7 +213,7 @@ The following are equivalent:
213213
You may not supply a comparator with a version containing an x. Any
214214
digits after the first "x" are ignored.
215215

216-
## <a href="sample">Sample jquery.json</a>
216+
## <a href="sample">Sample manifest</a>
217217

218218
**color.jquery.json**
219219

@@ -236,10 +236,8 @@ digits after the first "x" are ignored.
236236
"url": "https://github.com/jquery/jquery-color/raw/2.0.0-beta.1/GPL-LICENSE.txt"
237237
}
238238
],
239-
"jquery": {
240-
"dependencies": {
241-
"jquery": "1"
242-
}
239+
"dependencies": {
240+
"jquery": ">=1.6"
243241
},
244242
"description": "The main purpose of this plugin is to animate color properties on elements using jQuery's .animate()",
245243
"keywords": [

grunt.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ grunt.loadNpmTasks( "grunt-wordpress" );
66

77
grunt.initConfig({
88
lint: {
9-
grunt: "grunt.js"
10-
// src: [ "lib/**", "scripts/**" ]
9+
grunt: "grunt.js",
10+
src: [ "lib/**", "scripts/**" ]
11+
},
12+
13+
test: {
14+
files: [ "test/**/*.js" ]
1115
},
1216

1317
wordpress: config.wordpress

lib/hook.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ function processVersions( repo, fn ) {
106106

107107
var group = this.group();
108108
releases.forEach(function( release ) {
109-
for ( file in release.packages ) {
110-
processRelease( repo, release.tag, file, release.packages[ file ], group() );
109+
for ( var file in release.manifests ) {
110+
processRelease( repo, release.tag, file, release.manifests[ file ], group() );
111111
}
112112
});
113113
},
@@ -118,12 +118,12 @@ function processVersions( repo, fn ) {
118118
);
119119
}
120120

121-
function processRelease( repo, tag, file, package, fn ) {
121+
function processRelease( repo, tag, file, manifest, fn ) {
122122
Step(
123123
// find out who owns this plugin
124124
// if there is no owner, then set the user as the owner
125125
function() {
126-
pluginsDb.getOrSetOwner( package.name, repo.userId, repo.id, this );
126+
pluginsDb.getOrSetOwner( manifest.name, repo.userId, repo.id, this );
127127
},
128128

129129
// verify the user is the owner
@@ -136,7 +136,7 @@ function processRelease( repo, tag, file, package, fn ) {
136136
// the plugin is owned by someone else
137137
if ( owner !== repo.userId ) {
138138
// TODO: report error to user
139-
logger.log( repo.userId + " attempted to add " + package.name + " which is owned by " + owner );
139+
logger.log( repo.userId + " attempted to add " + manifest.name + " which is owned by " + owner );
140140
return fn( null, null );
141141
}
142142

@@ -145,7 +145,7 @@ function processRelease( repo, tag, file, package, fn ) {
145145

146146
// track the new release
147147
function( error, owner ) {
148-
pluginsDb.addRelease( repo.id, tag, file, package, this );
148+
pluginsDb.addRelease( repo.id, tag, file, manifest, this );
149149
},
150150

151151
// finished processing release
@@ -155,8 +155,8 @@ function processRelease( repo, tag, file, package, fn ) {
155155
return fn( error );
156156
}
157157

158-
logger.log( "Added " + package.name + " v" + package.version + " to plugins DB" );
159-
fn( null, package );
158+
logger.log( "Added " + manifest.name + " v" + manifest.version + " to plugins DB" );
159+
fn( null, manifest );
160160
}
161161
);
162162
}

lib/pluginsdb.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ var pluginsDb = module.exports = {
8787
db.run( "INSERT OR IGNORE INTO repos( repo, tag ) VALUES( ?, ? )", [ repoId, tag ], fn );
8888
}),
8989

90-
addRelease: auto(function( repoId, tag, file, package, fn ) {
90+
addRelease: auto(function( repoId, tag, file, manifest, fn ) {
9191
var data = JSON.stringify({
9292
repo: repoId,
9393
tag: tag,
9494
file: file,
95-
package: package
95+
manifest: manifest
9696
});
9797

9898
db.run( "INSERT INTO actions( action, data ) VALUES( ?, ? )",

0 commit comments

Comments
 (0)