Skip to content
This repository was archived by the owner on Mar 1, 2020. It is now read-only.

Commit 177fd3e

Browse files
committed
Merge branch 'new-version'
2 parents 9dc841a + 453007e commit 177fd3e

File tree

8 files changed

+422
-273
lines changed

8 files changed

+422
-273
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
*.swo
33
*~
44
*.log
5-
node_modules
5+
node_modules

CONTRIBUTING.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# :eight_spoked_asterisk: :stars: :sparkles: :dizzy: :star2: :star2: :sparkles: :dizzy: :star2: :star2: Contributing :star: :star2: :dizzy: :sparkles: :star: :star2: :dizzy: :sparkles: :stars: :eight_spoked_asterisk:
2+
3+
So, you want to contribute to this project! That's awesome. However, before
4+
doing so, please read the following simple steps how to contribute. This will
5+
make the life easier and will avoid wasting time on things which are not
6+
requested. :sparkles:
7+
8+
## Discuss the changes before doing them
9+
- First of all, open an issue in the repository, using the [bug tracker][1],
10+
describing the contribution you would like to make, the bug you found or any
11+
other ideas you have. This will help us to get you started on the right
12+
foot.
13+
14+
- If it makes sense, add the platform and software information (e.g. operating
15+
system, Node.JS version etc.), screenshots (so we can see what you are
16+
seeing).
17+
18+
- It is recommended to wait for feedback before continuing to next steps.
19+
However, if the issue is clear (e.g. a typo) and the fix is simple, you can
20+
continue and fix it.
21+
22+
## Fixing issues
23+
- Fork the project in your account and create a branch with your fix:
24+
`some-great-feature` or `some-issue-fix`.
25+
26+
- Commit your changes in that branch, writing the code following the
27+
[code style][2]. If the project contains tests (generally, the `test`
28+
directory), you are encouraged to add a test as well. :memo:
29+
30+
- If the project contains a `package.json` or a `bower.json` file add yourself
31+
in the `contributors` array (or `authors` in the case of `bower.json`;
32+
if the array does not exist, create it):
33+
34+
```json
35+
{
36+
"contributors": [
37+
"Your Name <and@email.address> (http://your.website)"
38+
]
39+
}
40+
```
41+
42+
## Creating a pull request
43+
44+
- Open a pull request, and reference the initial issue in the pull request
45+
message (e.g. *fixes #<your-issue-number>*). Write a good description and
46+
title, so everybody will know what is fixed/improved.
47+
48+
- If it makes sense, add screenshots, gifs etc., so it is easier to see what
49+
is going on.
50+
51+
## Wait for feedback
52+
Before accepting your contributions, we will review them. You may get feedback
53+
about what should be fixed in your modified code. If so, just keep committing
54+
in your branch and the pull request will be updated automatically.
55+
56+
## Everyone is happy!
57+
Finally, your contributions will be merged, and everyone will be happy! :smile:
58+
Contributions are more than welcome!
59+
60+
Thanks! :sweat_smile:
61+
62+
[1]: https://github.com/cdnjs/cdnjs-importer/issues
63+
64+
[2]: https://github.com/IonicaBizau/code-style

DOCUMENTATION.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## Documentation
2+
You can see below the API reference of this module.
3+
4+
### `CdnJsImporter(options, callback)`
5+
Creates a new instance of `CdnJsImporter`.
6+
7+
#### Params
8+
- **Object** `options`: An object containing the following fields:
9+
- `libs` (Array): An array of `Lib` items (see the `add` method what they should contain). They will be downloaded in parallel (default: `[]`).
10+
- `debug` (Boolean|Number): A boolean or number value indicating the log level (default: `false`).
11+
- `cdnjs` (String): The absolute path to the local cdnjs repository.
12+
- **Function** `callback`: The callback function.
13+
14+
#### Return
15+
- **CdnJsImporter** The `CdnJsImporter` instance.
16+

LICENSE

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
The MIT License (MIT)
1+
The KINDLY License
2+
Copyright (c) 2015 Ionică Bizău <bizauionica@gmail.com>
23

3-
Copyright (c) 2015 Ionică Bizău
4+
You have the permission to use this software, read its source code, modify and
5+
redistribute it under the following terms:
46

5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
7+
- if you want to use this software or include parts of its code in a
8+
closed-source or commercial project you should kindly ask the
9+
author (via a private message or email) and get a positive answer
10+
- this license should be included in the modified versions of this software
11+
- in case of redistributing modified copies, you are encouraged to clearly
12+
indicate that the copies are based on this work
13+
- if you think that your redistributed copy is awesome, you are encouraged to
14+
show the author of this software what you did and how you helped the others
1115

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
16+
You are free to install and use this software on as many machines as you want,
17+
free of charge, making sure you met the terms above.
1418

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
19+
You are encouraged to kindly support the software and its author by:
20+
21+
- sharing his/her work
22+
- reporting issues/bugs and asking for feature requests
23+
- donating money or any other things that can help the author
24+
- contribute on the software code by fixing bugs and adding features

README.md

Lines changed: 75 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,97 @@
1-
![CDNJS Importer](http://i.imgur.com/OLwedYJ.png)
1+
<!---------------------------------------------------------------------------->
2+
<!-- STOP, LOOK & LISTEN! -->
3+
<!-- ==================== -->
4+
<!-- Do NOT edit this file directly since it's generated from a template -->
5+
<!-- file, using https://github.com/IonicaBizau/node-blah -->
6+
<!-- -->
7+
<!-- If you found a typo in documentation, fix it in the source files -->
8+
<!-- (`lib/*.js`) and make a pull request. -->
9+
<!-- -->
10+
<!-- If you have any other ideas, open an issue. -->
11+
<!-- -->
12+
<!-- Please consider reading the contribution steps (CONTRIBUTING.md). -->
13+
<!-- * * * Thanks! * * * -->
14+
<!---------------------------------------------------------------------------->
15+
16+
![cdnjs-importer](http://i.imgur.com/OLwedYJ.png)
17+
18+
# `$ cdnjs-importer` [![Donate now][donate-now]][paypal-donations]
219

3-
# CDNJS Importer
420
Easy way to import a library into CDNJS.
521

622
## Installation
723

24+
You can install the package globally and use it as command line tool:
25+
826
```sh
9-
$ npm install -g cdnjs-importer
27+
$ npm i -g cdnjs-importer@2.0.0-beta
1028
```
1129

12-
## Usage
13-
14-
Use the `-c` option to specify the path to the CDNJS repository. Default location is `~/cdnjs`.
30+
Then, run `cdnjs-importer --help` and see what the CLI tool can do.
1531

1632
```sh
17-
$ cdnjs-importer -c path/to/cdnjs git@github.com:someone/project.git git@github.com:someone/another-project.git
18-
```
33+
$ cdnjs-importer --help
34+
Usage: cdnjs-importer [options]
1935

20-
## Documentation
21-
Using as module is also possible.
36+
Options:
37+
-g, --git-url <git-url> Your library git url.
38+
-p, --path <path> The path to your cdnjs local repository.
39+
-h, --help Displays this help.
40+
-v, --version Displays version information.
2241

23-
### `CdnJsImporter(options, callback)`
24-
Creates a new instance of `CdnJsImporter`.
42+
Examples:
43+
cdnjs-importer -g git@github.com:IonicaBizau/gh.js.git # adds gh.js to cdnjs
44+
cdnjs-importer -g ... -p path/to/cdnjs
2545

26-
#### Params
27-
- **Object** `options`: An object containing the following fields:
28-
- `libs` (Array): An array of `Lib` items (see the `add` method what they should contain). They will be downloaded in parallel (default: `[]`).
29-
- `debug` (Boolean|Number): A boolean or number value indicating the log level (default: `false`).
30-
- `cdnjs` (String): The absolute path to the local cdnjs repository.
46+
The default cdnjs repository location is in ~/cdnjs
3147

32-
- **Function** `callback`: The callback function.
48+
Documentation can be found at https://github.com/cdnjs/cdnjs-importer
49+
```
3350

34-
#### Return
35-
- **CdnJsImporter** The `CdnJsImporter` instance.
51+
## Example
3652

37-
### `add(lib, callback)`
38-
Adds a new library in the local cdnjs repository.
53+
Here is an example how to use this package as library. To install it locally, as library, you can do that using `npm`:
3954

40-
#### Params
41-
- **Object|String** `lib`: The git url as string or an object containing:
42-
- `git` (String): The `git` url.
43-
- `dir` (String): The directory containing the files which should be imported (default: `"/dist"` or `"/build"` or `"/src"` or `"/"`).
44-
- `map` (Array): The file map used by cdnjs in autoupdate process (default: `[{ basePath: lib.dir , files: ["**/*"] }]`).
45-
- **Function** `callback`: The callback function called with `error` and `data`.
55+
```sh
56+
$ npm i cdnjs-importer
57+
```
4658

47-
#### Return
48-
- **CdnJsImporter** The `CdnJsImporter` instance.
59+
```js
60+
// Dependencies
61+
var CdnJsImporter = require("cdnjs-importer")
62+
, Path = require("path")
63+
;
64+
65+
// Test adding CaiuSS
66+
CdnJsImporter({
67+
cdnjs: Path.resolve(__dirname, "../../cdnjs")
68+
, debug: true
69+
, libs: [
70+
"git@github.com:IonicaBizau/CaiuSS.git"
71+
]
72+
}, function (res) {
73+
console.log(res);
74+
});
75+
76+
```
77+
78+
## Documentation
79+
80+
For full API reference, see the [DOCUMENTATION.md][docs] file.
4981

5082
## How to contribute
51-
1. File an issue in the repository, using the bug tracker, describing the
52-
contribution you'd like to make. This will help us to get you started on the
53-
right foot.
54-
2. Fork the project in your account and create a new branch:
55-
`your-great-feature`.
56-
3. Commit your changes in that branch.
57-
4. Open a pull request, and reference the initial issue in the pull request
58-
message.
83+
Have an idea? Found a bug? See [how to contribute][contributing].
84+
85+
## Press Highlights
86+
None yet. If you wrote or found an article about this project, [add it][contributing] in this section. :memo:
5987

6088
## License
61-
See the [LICENSE](./LICENSE) file.
89+
[KINDLY][license] © [Ionică Bizău][website]–The [LICENSE](/LICENSE) file contains
90+
a copy of the license.
91+
92+
[license]: http://ionicabizau.github.io/kindly-license/?author=Ionic%C4%83%20Biz%C4%83u%20%3Cbizauionica@gmail.com%3E&year=2015
93+
[contributing]: /CONTRIBUTING.md
94+
[website]: http://ionicabizau.net
95+
[docs]: /DOCUMENTATION.md
96+
[paypal-donations]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MG98D7NPFZ3MG
97+
[donate-now]: http://i.imgur.com/6cMbHOC.png

bin/cdnjs-importer

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,64 @@
22

33
// Dependencies
44
var CdnJsImporter = require("../lib")
5-
, Minimist = require("minimist")
65
, Ul = require("ul")
76
, Path = require("path")
87
, Logger = require("bug-killer")
98
, IsThere = require("is-there")
10-
, Fs = require("fs-plus")
9+
, Clp = require("clp")
10+
, Package = require("../package")
11+
, Abs = require("abs")
1112
;
1213

13-
// Parse arguments
14-
var argv = Minimist(process.argv.slice(2));
15-
1614
// Constants
17-
const CDNJS_ROOT = argv.c ? argv.c : Path.join(Ul.USER_DIR, "cdnjs");
15+
const CDNJS_ROOT = Abs("~/cdnjs");
16+
17+
// Parse the command line arguments
18+
var gitUrlOpt = new Clp.Option(["g", "git-url"], "Your library git url.", "git-url")
19+
, pathOpt = new Clp.Option(["p", "path"], "The path to your cdnjs local repository.", "path", CDNJS_ROOT)
20+
, parser = new Clp({
21+
name: "CDNJS Importer"
22+
, version: Package.version
23+
, exe: Package.name
24+
, examples: [
25+
"cdnjs-importer -g git@github.com:IonicaBizau/gh.js.git # adds gh.js to cdnjs"
26+
, "cdnjs-importer -g ... -p path/to/cdnjs"
27+
]
28+
, docs_url: Package.homepage
29+
, notes: "The default cdnjs repository location is in ~/cdnjs"
30+
, process: true
31+
}, [
32+
gitUrlOpt
33+
, pathOpt
34+
])
35+
;
36+
37+
// Invalid git url
38+
if (!gitUrlOpt.value) {
39+
return console.log(parser.displayHelp());
40+
}
41+
42+
// Resolve the path to the cdnjs repo
43+
if (pathOpt.is_provided) {
44+
pathOpt.value = Abs(pathOpt.value);
45+
}
1846

1947
// Check if the repository exists and display friendly messages
20-
if (!IsThere.sync(CDNJS_ROOT)) {
21-
Logger.config.displayDate = false;
22-
Logger.config.logLevel = 4;
23-
Logger.log("Couldn't find the CDNJS repository in this path: " + CDNJS_ROOT, "error");
48+
if (!IsThere(pathOpt.value)) {
49+
Logger.log("Couldn't find the CDNJS repository in this path: " + pathOpt.value, "error");
2450
Logger.log("Use `git clone git@github.com:cdnjs/cdnjs.git ~/cdnjs` to clone it.", "info");
25-
Logger.log("If you already cloned it in another location, please provide the path to that location using `cdnjs-importer -c path/to/cdnjs`", "info");
51+
Logger.log("If you already cloned it in another location, please provide the path to that location using `cdnjs-importer -p path/to/cdnjs`", "info");
2652
return;
2753
}
2854

2955
// Import the repositories
3056
var importer = CdnJsImporter({
31-
cdnjs: Fs.normalize(CDNJS_ROOT)
57+
cdnjs: pathOpt.value
3258
, debug: true
33-
, libs: []
59+
, libs: [
60+
gitUrlOpt.value
61+
]
3462
}, function (err) {
35-
console.log(err);
63+
if (err) { return Logger.log(err, "error"); }
64+
Logger.log("Successfully done. Now you have to push your changes on GitHub and raise a pull request.");
3665
});
37-
38-
function seq(i) {
39-
i = i || 0;
40-
41-
var cLib = argv._[i];
42-
if (!cLib) {
43-
return Logger.log("Done.", "info");
44-
}
45-
46-
importer.add(cLib, function (err) {
47-
seq(i + 1);
48-
});
49-
}
50-
51-
seq();

0 commit comments

Comments
 (0)