-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9af5c20
Showing
15 changed files
with
727 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# EditorConfig is awesome: http://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
# Unix-style newlines with a newline ending every file | ||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
|
||
# 2 space indentation | ||
[**.*] | ||
indent_style = space | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Marton Sagi, contributors | ||
|
||
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: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#**Experimental:** this project is a work in progress. | ||
|
||
# aurelia-cli-pacman | ||
|
||
> Aurelia-cli-pacman is a simple package management helper for projects using [aurelia-cli](http://github.com/aurelia/cli). It supports npm package installation/removal, and configuration of pre-defined bundle dependencies in `aurelia.json`. This project's main goal is to enhance the package/plugin configuration process while using `aurelia-cli` for development. | ||
## 1. Installation | ||
|
||
Since it's an extension to aurelia-cli, it cannot be used with JSPM or WebPack. | ||
|
||
``` | ||
npm install aurelia-cli-pacman --save | ||
``` | ||
|
||
### 1.1 `pacman` helper task for aurelia-cli | ||
|
||
Since aurelia-cli is still in alpha stage and `install` command is not yet implemented, I've created this custom cli task to enhance configuration of plugin dependencies in `aurelia.json`. It adds a pre-configured set of dependencies to `aurelia.json`, if there's any. | ||
A post-install npm script takes care of placing this new `pacman.ts|js` task into `aurelia_project/tasks` folder. | ||
|
||
## 2. Usage | ||
|
||
| Parameters | Description | | ||
| ------------------- | ----------- | | ||
| --install, i <bundle-file.js> | Install npm package and sets bundle dependencies. Calls `npm install --save` | | ||
| --uninstall, u <bundle-file.js> | Uninstall npm package and removes bundle dependencies. Calls `npm uninstall --save` | | ||
| --bundle, b <bundle-file.js> | Set bundle section to be modified | | ||
| --force, f | Overwrite previously set dependencies (applies only to dependencies of specified package! It won't delete the whole bundle setting.) | | ||
|
||
Run `au pacman` helper: | ||
|
||
``` | ||
au pacman --install <package name> [--bunde <custom-bundle-filename>] [--force] | ||
au pacman i aurelia-validation --bunde plugin-bundle.js --force | ||
au pacman u aurelia-validation | ||
``` | ||
|
||
**Note:** tested on Windows platform only. | ||
|
||
### 2.1 Pre-defined bundle dependencies | ||
|
||
There is a small dependency collection for several basic aurelia plugins and other npm packages in `./registry` folder. | ||
|
||
## 3. Dependencies | ||
|
||
* aurelia-cli | ||
* fs-extra | ||
|
||
|
||
## 4. Platform Support | ||
|
||
This extension can be used with **NodeJS** only. It's executed within `aurelia-cli` infrastructure. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"use strict"; | ||
|
||
exports.PacMan = require('./lib/common').PacMan; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* Mini cli helper for package management | ||
* - Installs/Uninstalls npm packages | ||
* - Configures bundle correctly | ||
* | ||
* It's pure ES6 to support Babel/Typescript projects as well | ||
* | ||
* Usage: | ||
* au pacman --install/i <package-name> [--bundle <custom-bundle-filename.js>] [--force] | ||
* au pacman --uninstall/u <package-name> [--bundle <custom-bundle-filename.js>] | ||
*/ | ||
|
||
import * as fs from 'fs-extra'; | ||
import {CLIOptions} from 'aurelia-cli'; | ||
import {PacMan} from 'aurelia-cli-pacman'; | ||
|
||
/** | ||
* Reads aurelia.json | ||
* | ||
* Using this, because default import statement would | ||
* add a "default" member to the original object | ||
* causing problems at saving | ||
* | ||
* @return {Promise|Promise<any>} | ||
*/ | ||
let getProject = () => { | ||
return new Promise((resolve, reject) => { | ||
let path = 'aurelia_project/aurelia.json'; | ||
fs.readJson(path, (err, content) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(content); | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
/** | ||
* Execute | ||
*/ | ||
export default () => { | ||
// package manager | ||
let pacMan = new PacMan(CLIOptions); | ||
|
||
// collect given parameters | ||
let cliParams = pacMan.getCliParams(); | ||
|
||
if (!cliParams.action) { | ||
console.log(`Invalid or no action given. Please use one of these:\n`); | ||
for (let action of allowedActions) { | ||
console.log(` au pacman --${action.join('/')} <package name>`); | ||
} | ||
return; | ||
} | ||
|
||
let tasks = [getProject(), pacMan.getDependencies(cliParams.pkg)]; | ||
|
||
return Promise | ||
.all(tasks) | ||
.then(result => { | ||
return pacMan[cliParams.action](cliParams.pkg) | ||
.then(ok => pacMan.configure(cliParams, ...result)); | ||
}) | ||
.catch(err => { throw new Error(err); }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "pacman", | ||
"description": "cli extension for package management. It helps you to install/uninstall packages and to configure bundle dependencies.", | ||
"flags": [ | ||
{ | ||
"name": "install", | ||
"description": "Installs npm package and sets bundle dependencies", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "uninstall", | ||
"description": "Uninstalls npm package and removes bundle dependencies", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "bundle", | ||
"description": "Sets bundle section to be modified", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "force", | ||
"description": "Overwrite previously set dependencies. This applies only to dependencies of the given package!", | ||
"type": "boolean" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"use strict"; | ||
|
||
try { | ||
let fs = require('fs-extra'), | ||
path = require('path'), | ||
projectFolder = '../../aurelia_project/', | ||
projectFile = 'aurelia.json', | ||
installName = 'pacman'; | ||
|
||
// fs-extra is installed as devDependency for CLI projects | ||
// if it isn't there, it's probably not CLI | ||
if (fs) { | ||
// check again if it's an aurelia-cli project for sure | ||
fs.exists(projectFolder, function (exists) { | ||
if (exists === true) { | ||
fs.readJson(projectFolder + projectFile, function (err, project) { | ||
if (err) { | ||
return console.log('Could not install ' + projectFile, err); | ||
} else { | ||
// determinate transpiler to set correct file extension | ||
let filename = installName + project.transpiler.fileExtension, | ||
source = './install/' + installName, | ||
dest = projectFolder + 'tasks/'; | ||
|
||
fs.copy(source + '.js', dest + filename, function (err) { | ||
if (err) { | ||
return console.log('Could not install ' + filename, err); | ||
} else { | ||
fs.copy(source + '.json', dest + installName + '.json', function (err) { | ||
if (err) { | ||
return console.log('Could not install ' + dest + installName + '.json', err); | ||
} else { | ||
return console.log(dest + filename + ' has been installed.'); | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
} catch (e) { | ||
console.log('aurelia-interactjs: post installation step skipped.\n', e); | ||
} |
Oops, something went wrong.