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

Commit

Permalink
Merge branch 'new-version'
Browse files Browse the repository at this point in the history
  • Loading branch information
IonicaBizau committed Oct 5, 2015
2 parents 9dc841a + 453007e commit 177fd3e
Show file tree
Hide file tree
Showing 8 changed files with 422 additions and 273 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
*.swo
*~
*.log
node_modules
node_modules
64 changes: 64 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# :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:

So, you want to contribute to this project! That's awesome. However, before
doing so, please read the following simple steps how to contribute. This will
make the life easier and will avoid wasting time on things which are not
requested. :sparkles:

## Discuss the changes before doing them
- First of all, open an issue in the repository, using the [bug tracker][1],
describing the contribution you would like to make, the bug you found or any
other ideas you have. This will help us to get you started on the right
foot.

- If it makes sense, add the platform and software information (e.g. operating
system, Node.JS version etc.), screenshots (so we can see what you are
seeing).

- It is recommended to wait for feedback before continuing to next steps.
However, if the issue is clear (e.g. a typo) and the fix is simple, you can
continue and fix it.

## Fixing issues
- Fork the project in your account and create a branch with your fix:
`some-great-feature` or `some-issue-fix`.

- Commit your changes in that branch, writing the code following the
[code style][2]. If the project contains tests (generally, the `test`
directory), you are encouraged to add a test as well. :memo:

- If the project contains a `package.json` or a `bower.json` file add yourself
in the `contributors` array (or `authors` in the case of `bower.json`;
if the array does not exist, create it):

```json
{
"contributors": [
"Your Name <and@email.address> (http://your.website)"
]
}
```

## Creating a pull request

- Open a pull request, and reference the initial issue in the pull request
message (e.g. *fixes #<your-issue-number>*). Write a good description and
title, so everybody will know what is fixed/improved.

- If it makes sense, add screenshots, gifs etc., so it is easier to see what
is going on.

## Wait for feedback
Before accepting your contributions, we will review them. You may get feedback
about what should be fixed in your modified code. If so, just keep committing
in your branch and the pull request will be updated automatically.

## Everyone is happy!
Finally, your contributions will be merged, and everyone will be happy! :smile:
Contributions are more than welcome!

Thanks! :sweat_smile:

[1]: https://github.com/cdnjs/cdnjs-importer/issues

[2]: https://github.com/IonicaBizau/code-style
16 changes: 16 additions & 0 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## Documentation
You can see below the API reference of this module.

### `CdnJsImporter(options, callback)`
Creates a new instance of `CdnJsImporter`.

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

#### Return
- **CdnJsImporter** The `CdnJsImporter` instance.

37 changes: 20 additions & 17 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
The MIT License (MIT)
The KINDLY License
Copyright (c) 2015 Ionică Bizău <bizauionica@gmail.com>

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

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

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

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
You are encouraged to kindly support the software and its author by:

- sharing his/her work
- reporting issues/bugs and asking for feature requests
- donating money or any other things that can help the author
- contribute on the software code by fixing bugs and adding features
114 changes: 75 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,97 @@
![CDNJS Importer](http://i.imgur.com/OLwedYJ.png)
<!---------------------------------------------------------------------------->
<!-- STOP, LOOK & LISTEN! -->
<!-- ==================== -->
<!-- Do NOT edit this file directly since it's generated from a template -->
<!-- file, using https://github.com/IonicaBizau/node-blah -->
<!-- -->
<!-- If you found a typo in documentation, fix it in the source files -->
<!-- (`lib/*.js`) and make a pull request. -->
<!-- -->
<!-- If you have any other ideas, open an issue. -->
<!-- -->
<!-- Please consider reading the contribution steps (CONTRIBUTING.md). -->
<!-- * * * Thanks! * * * -->
<!---------------------------------------------------------------------------->

![cdnjs-importer](http://i.imgur.com/OLwedYJ.png)

# `$ cdnjs-importer` [![Donate now][donate-now]][paypal-donations]

# CDNJS Importer
Easy way to import a library into CDNJS.

## Installation

You can install the package globally and use it as command line tool:

```sh
$ npm install -g cdnjs-importer
$ npm i -g cdnjs-importer@2.0.0-beta
```

## Usage

Use the `-c` option to specify the path to the CDNJS repository. Default location is `~/cdnjs`.
Then, run `cdnjs-importer --help` and see what the CLI tool can do.

```sh
$ cdnjs-importer -c path/to/cdnjs git@github.com:someone/project.git git@github.com:someone/another-project.git
```
$ cdnjs-importer --help
Usage: cdnjs-importer [options]

## Documentation
Using as module is also possible.
Options:
-g, --git-url <git-url> Your library git url.
-p, --path <path> The path to your cdnjs local repository.
-h, --help Displays this help.
-v, --version Displays version information.

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

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

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

#### Return
- **CdnJsImporter** The `CdnJsImporter` instance.
## Example

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

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

#### Return
- **CdnJsImporter** The `CdnJsImporter` instance.
```js
// Dependencies
var CdnJsImporter = require("cdnjs-importer")
, Path = require("path")
;

// Test adding CaiuSS
CdnJsImporter({
cdnjs: Path.resolve(__dirname, "../../cdnjs")
, debug: true
, libs: [
"git@github.com:IonicaBizau/CaiuSS.git"
]
}, function (res) {
console.log(res);
});

```

## Documentation

For full API reference, see the [DOCUMENTATION.md][docs] file.

## How to contribute
1. File an issue in the repository, using the bug tracker, describing the
contribution you'd like to make. This will help us to get you started on the
right foot.
2. Fork the project in your account and create a new branch:
`your-great-feature`.
3. Commit your changes in that branch.
4. Open a pull request, and reference the initial issue in the pull request
message.
Have an idea? Found a bug? See [how to contribute][contributing].

## Press Highlights
None yet. If you wrote or found an article about this project, [add it][contributing] in this section. :memo:

## License
See the [LICENSE](./LICENSE) file.
[KINDLY][license] © [Ionică Bizău][website]–The [LICENSE](/LICENSE) file contains
a copy of the license.

[license]: http://ionicabizau.github.io/kindly-license/?author=Ionic%C4%83%20Biz%C4%83u%20%3Cbizauionica@gmail.com%3E&year=2015
[contributing]: /CONTRIBUTING.md
[website]: http://ionicabizau.net
[docs]: /DOCUMENTATION.md
[paypal-donations]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MG98D7NPFZ3MG
[donate-now]: http://i.imgur.com/6cMbHOC.png
72 changes: 43 additions & 29 deletions bin/cdnjs-importer
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,64 @@

// Dependencies
var CdnJsImporter = require("../lib")
, Minimist = require("minimist")
, Ul = require("ul")
, Path = require("path")
, Logger = require("bug-killer")
, IsThere = require("is-there")
, Fs = require("fs-plus")
, Clp = require("clp")
, Package = require("../package")
, Abs = require("abs")
;

// Parse arguments
var argv = Minimist(process.argv.slice(2));

// Constants
const CDNJS_ROOT = argv.c ? argv.c : Path.join(Ul.USER_DIR, "cdnjs");
const CDNJS_ROOT = Abs("~/cdnjs");

// Parse the command line arguments
var gitUrlOpt = new Clp.Option(["g", "git-url"], "Your library git url.", "git-url")
, pathOpt = new Clp.Option(["p", "path"], "The path to your cdnjs local repository.", "path", CDNJS_ROOT)
, parser = new Clp({
name: "CDNJS Importer"
, version: Package.version
, exe: Package.name
, examples: [
"cdnjs-importer -g git@github.com:IonicaBizau/gh.js.git # adds gh.js to cdnjs"
, "cdnjs-importer -g ... -p path/to/cdnjs"
]
, docs_url: Package.homepage
, notes: "The default cdnjs repository location is in ~/cdnjs"
, process: true
}, [
gitUrlOpt
, pathOpt
])
;

// Invalid git url
if (!gitUrlOpt.value) {
return console.log(parser.displayHelp());
}

// Resolve the path to the cdnjs repo
if (pathOpt.is_provided) {
pathOpt.value = Abs(pathOpt.value);
}

// Check if the repository exists and display friendly messages
if (!IsThere.sync(CDNJS_ROOT)) {
Logger.config.displayDate = false;
Logger.config.logLevel = 4;
Logger.log("Couldn't find the CDNJS repository in this path: " + CDNJS_ROOT, "error");
if (!IsThere(pathOpt.value)) {
Logger.log("Couldn't find the CDNJS repository in this path: " + pathOpt.value, "error");
Logger.log("Use `git clone git@github.com:cdnjs/cdnjs.git ~/cdnjs` to clone it.", "info");
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");
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");
return;
}

// Import the repositories
var importer = CdnJsImporter({
cdnjs: Fs.normalize(CDNJS_ROOT)
cdnjs: pathOpt.value
, debug: true
, libs: []
, libs: [
gitUrlOpt.value
]
}, function (err) {
console.log(err);
if (err) { return Logger.log(err, "error"); }
Logger.log("Successfully done. Now you have to push your changes on GitHub and raise a pull request.");
});

function seq(i) {
i = i || 0;

var cLib = argv._[i];
if (!cLib) {
return Logger.log("Done.", "info");
}

importer.add(cLib, function (err) {
seq(i + 1);
});
}

seq();
Loading

0 comments on commit 177fd3e

Please sign in to comment.