Skip to content

Commit f8c0ddd

Browse files
committed
Updated package.json. Moved docs, demo, dependencies under jquery hash. Removed files field. Fixes jquery-archive#26 - (Forward) compatibility with npm.
1 parent ae096b1 commit f8c0ddd

File tree

2 files changed

+28
-48
lines changed

2 files changed

+28
-48
lines changed

docs/package.md

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,16 @@ file. It must be actual JSON, not just a JavaScript object literal.
1515
* <a href="#field-title">title</a>
1616
* <a href="#field-author">author</a>
1717
* <a href="#field-licenses">licenses</a>
18-
* <a href="#field-dependencies">dependencies</a>
18+
* <a href="#field-jquery-dependencies">jquery.dependencies</a>
1919

2020
## Optional Fields
2121

2222
* <a href="#field-description">description</a>
2323
* <a href="#field-keywords">keywords</a>
2424
* <a href="#field-homepage">homepage</a>
25-
* <a href="#field-docs">docs</a>
26-
* <a href="#field-demo">demo</a>
25+
* <a href="#field-jquery-docs">jquery.docs</a>
26+
* <a href="#field-jquery-demo">jquery.demo</a>
2727
* <a href="#field-maintainers">maintainers</a>
28-
* <a href="#field-files">files</a>
2928

3029
## <a name="field-name">name</a>
3130

@@ -84,7 +83,7 @@ a url property linking to the actual text and an optional "type" property specif
8483
}
8584
]
8685

87-
## <a name="field-dependencies">dependencies</a>
86+
## <a name="field-jquery-dependencies">jquery.dependencies</a>
8887

8988
Dependencies are specified with a simple hash of package name to version
9089
range. The version range is EITHER a string which has one or more
@@ -114,11 +113,11 @@ discover your plugin as it's listed on the jQuery Plugins Site.
114113

115114
The url to the plugin homepage.
116115

117-
## <a name="field-docs">docs</a>
116+
## <a name="field-jquery-docs">jquery.docs</a>
118117

119118
The url to the plugin documentation.
120119

121-
## <a name="field-demo">demo</a>
120+
## <a name="field-jquery-demo">jquery.demo</a>
122121

123122
The url to the plugin demo or demos.
124123

@@ -128,14 +127,6 @@ An array of people.
128127

129128
See [People Fields](#people-fields).
130129

131-
## <a name="field-files">files</a>
132-
133-
The "files" field is an array of files that make up your plugin. This should
134-
be a file path relative to the root of your plugin folder.
135-
136-
If you name a folder in the array, then it will also include the files
137-
inside that folder.
138-
139130
# <a name="people-fields">People Fields</a>
140131

141132
A "person" is an object with a "name" field and optionally "url" and
@@ -236,8 +227,10 @@ digits after the first "x" are ignored.
236227
"url": "GPL-LICENSE.txt"
237228
}
238229
],
239-
"dependencies": {
240-
"jquery": "1"
230+
"jquery": {
231+
"dependencies": {
232+
"jquery": "1"
233+
}
241234
},
242235
"description": "The main purpose of this plugin is to animate color properties on elements using jQuery's .animate()",
243236
"keywords": [
@@ -252,9 +245,6 @@ digits after the first "x" are ignored.
252245
"name": "Corey Frang",
253246
"url": "https://github.com/gnarf37"
254247
}
255-
],
256-
"files": [
257-
"jquery.color.js"
258248
]
259249
}
260250
```

src/service.js

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,15 @@ extend( Repo.prototype, {
127127
});
128128
}
129129

130-
if ( !package.dependencies ) {
131-
errors.push( "Missing required field: dependencies." );
130+
if ( !package.jquery || !package.jquery.dependencies ) {
131+
errors.push( "Missing required field: jquery.dependencies." );
132132
} else {
133-
if ( !package.dependencies.jquery ) {
133+
if ( !package.jquery.dependencies.jquery ) {
134134
errors.push( "Missing required dependency: jquery." );
135135
}
136-
Object.keys( package.dependencies ).forEach(function( dependency ) {
136+
Object.keys( package.jquery.dependencies ).forEach(function( dependency ) {
137137
// TODO: validate name
138-
if ( !semver.validRange( package.dependencies[ dependency ] ) ) {
138+
if ( !semver.validRange( package.jquery.dependencies[ dependency ] ) ) {
139139
errors.push( "Invalid version range for dependency: " + dependency + "." );
140140
}
141141
});
@@ -168,19 +168,21 @@ extend( Repo.prototype, {
168168
}
169169
}
170170

171-
if ( "docs" in package ) {
172-
if ( typeof package.docs !== "string" ) {
173-
errors.push( "Invalid data type for docs; must be a string." );
174-
} else if ( !isUrl( package.docs ) ) {
175-
errors.push( "Invalid value for docs." );
171+
if ( package.jquery ) {
172+
if ( "docs" in package ) {
173+
if ( typeof package.jquery.docs !== "string" ) {
174+
errors.push( "Invalid data type for jquery.docs; must be a string." );
175+
} else if ( !isUrl( package.jquery.docs ) ) {
176+
errors.push( "Invalid value for jquery.docs." );
177+
}
176178
}
177-
}
178179

179-
if ( "demo" in package ) {
180-
if ( typeof package.demo !== "string" ) {
181-
errors.push( "Invalid data type for demo; must be a string." );
182-
} else if ( !isUrl( package.demo ) ) {
183-
errors.push( "Invalid value for demo." );
180+
if ( "demo" in package ) {
181+
if ( typeof package.jquery.demo !== "string" ) {
182+
errors.push( "Invalid data type for jquery.demo; must be a string." );
183+
} else if ( !isUrl( package.jquery.demo ) ) {
184+
errors.push( "Invalid value for jquery.demo." );
185+
}
184186
}
185187
}
186188

@@ -208,18 +210,6 @@ extend( Repo.prototype, {
208210
}
209211
}
210212

211-
if ( "files" in package ) {
212-
if ( !Array.isArray( package.files ) ) {
213-
errors.push( "Invalid data type for files; must be an array." );
214-
} else {
215-
package.files.forEach(function( file, i ) {
216-
if ( typeof file !== "string" ) {
217-
errors.push( "Invalid data type for files[" + i + "]; must be a string." );
218-
}
219-
});
220-
}
221-
}
222-
223213
return errors;
224214
}
225215
});

0 commit comments

Comments
 (0)