Permalink
Browse files

protect private repo. docs on package

  • Loading branch information...
1 parent a4a2297 commit d04d96cb6b720d0f5f6dfa039190ff4886272db0 Hsiaoming Yang committed Mar 17, 2013
Showing with 52 additions and 1 deletion.
  1. +43 −1 docs/en/package.md
  2. +9 −0 lib/sdk/yuan.js
View
@@ -9,7 +9,7 @@ spm follows the [Common Module Definition](https://github.com/spmjs/specificatio
CMD [packaging draft](https://github.com/spmjs/specification/blob/master/draft/package.md) add an additional namespace, which is `family`. spm add another namespace, which is `spm`.
-A full example of `package.json`:
+Here is an example of `package.json`:
```json
{
@@ -48,8 +48,50 @@ A full example of `package.json`:
}
```
+## family
+
+This is the account name on http://spmjs.org.
+
+## name
+
+This is your package's name.
+
+## version
+
+The version of your package. We only accept version like this:
+
+```
+1.0.0
+```
+
+The regexp is `\d+\.\d+\.\d+`.
+
+## description
+
+Put a description in it. It's a string. This helps people discover your package, as it's listed in `spm search`.
+
+
+## keywords
+
+Put keywords in it. It's an array of strings. This helps people discover your package as it's listed in `spm search`.
+
+## homepage
+
+The url to the project homepage.
+
+## repository
+
+The repository of your project.
+
+## private
+
+If you set `"private": true` in your package.json, then spm will refuse to publish it to https://spmjs.org.
+
+This is a way to prevent accidental publication of private repositories. But you can publish to other source center.
+
## spm.alias
+Alias.
## spm.output
View
@@ -149,6 +149,10 @@ Yuan.prototype.register = function(data, callback) {
};
Yuan.prototype.publish = function(pkg, callback) {
+ if (pkg.private && this.server === 'https://spmjs.org') {
+ log.error('exit', 'this is a private repo');
+ process.exit(3);
+ }
var auth = spmrc.get(this.authKey);
var req = {};
req.urlpath = util.format(
@@ -259,6 +263,11 @@ Yuan.prototype.search = function(data, callback) {
};
Yuan.prototype.upload = function(data, callback) {
+ if (pkg.private && this.server === 'https://spmjs.org') {
+ log.error('exit', 'this is a private repo');
+ process.exit(3);
+ }
+
var auth = spmrc.get(this.authKey);
if (!auth) {
callback('login is required.');

0 comments on commit d04d96c

Please sign in to comment.