Skip to content

Commit

Permalink
New: patching aurelia.json, updated metadata format, kendoui-bridge c…
Browse files Browse the repository at this point in the history
…onfig

Version bump to 0.0.2
  • Loading branch information
martonsagi committed Oct 25, 2016
1 parent 785bfe8 commit acd06d9
Show file tree
Hide file tree
Showing 11 changed files with 1,432 additions and 111 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules
.idea

61 changes: 53 additions & 8 deletions lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

const fs = require('fs-extra'),
path = require('path'),
npm = require('npm');
npm = require('npm'),
rfc6902 = require('rfc6902');

/**
* NPM api helper
Expand Down Expand Up @@ -77,22 +78,38 @@ exports.PacMan = class {
/**
* Uninstall npm package
*
* @param pkgName string packgae name
* @param pkgName string package name
* @return {Promise}
*/
uninstall(pkgName) {
return NPMLoader('uninstall', pkgName);
}


/**
* Configures package dependencies
* Edits aurelia.json to add/remove pre-configured dependencies for specified package
* Configure package dependencies
* Edit aurelia.json to add/remove pre-configured dependencies for specified package
*
* @void
*/
configure(cliParams, project, deps) {
if (!deps || deps.length === 0) {
if (!deps) {
return;
}

// patch aurelia.json settings with overrides
if (deps && deps.patches && deps.patches.length > 0) {
let result = rfc6902.applyPatch(project, deps.patches),
errors = result.filter(err => err !== null);

if (errors.length > 0) {
console.log(`[ERR] An error occurred while applying custom settings. Exiting...\n`, errors);
return;
}

console.log(`[INFO] Custom project settings has been applied to aurelia.json.`);
}

if (deps.dependencies && deps.dependencies.length === 0) {
console.log(`[INFO] There are no dependencies to configure for ${cliParams.pkg} in aurelia.json. Exiting...`);
return;
}
Expand Down Expand Up @@ -133,7 +150,7 @@ exports.PacMan = class {
}

console.log(`[INFO] Bundle found: ${bundleName}. Configuring new dependencies in aurelia.json...`);
for (let dep of deps) {
for (let dep of deps.dependencies) {
let name = dep.name || dep,
check = bundle.dependencies.find(item => (item.name || item) === name);

Expand Down Expand Up @@ -233,6 +250,7 @@ exports.PacMan = class {
*/
getDependencies(pkgName) {
let t = this;

return new Promise(function (resolve, reject) {
t.exists(pkgName)
.then(function (exists) {
Expand All @@ -245,7 +263,15 @@ exports.PacMan = class {
}
});
} else {
resolve(null);
// when package name contains @version and it has no version-specific metadata,
// we check again with basename (pkg@0.1 => pkg)
let realPkgName = t.getRealPkgName(pkgName);
if (realPkgName !== pkgName) {
t.getDependencies(realPkgName)
.then(data => resolve(data));
} else {
resolve(null);
}
}
})
.catch(function (e) {
Expand All @@ -272,10 +298,29 @@ exports.PacMan = class {
*/
exists(pkgName) {
let t = this;

return new Promise(function (resolve, reject) {
fs.exists(t.getFilename(pkgName), function (exists) {
resolve(exists);
});
});
}

/**
* Package might has a @version tag in its name
*
* @param pkgName string package name
* @return {*}
*/
getRealPkgName(pkgName) {
return pkgName.indexOf('@') !== -1 ? pkgName.split('@')[0] : pkgName;
}

/**
* Remove previously backed up 'aurelia.json.<timestamp>.bak' files
* @todo
*/
cleanup() {
throw new Error('Not implemented yet.');
}
};
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aurelia-cli-pacman",
"version": "0.0.1",
"version": "0.0.2",
"author": "Marton Sagi <hello@martonsagi.me>",
"description": "Extension to provide aurelia-cli with package management capabilities",
"homepage": "https://github.com/martonsagi/aurelia-cli-pacman",
Expand All @@ -23,6 +23,8 @@
"postinstall": "node ./install/post-install.js"
},
"dependencies": {
"fs-extra": "^0.30.0"
"aurelia-cli": "^0.21.0",
"fs-extra": "^0.30.0",
"rfc6902": "^1.2.2"
}
}
125 changes: 65 additions & 60 deletions registry/aurelia-editables.json
Original file line number Diff line number Diff line change
@@ -1,60 +1,65 @@
[
{
"name": "interact",
"path": "../node_modules/interact.js/dist",
"main": "interact"
},
{
"name": "aurelia-interactjs",
"path": "../node_modules/aurelia-interactjs/dist/amd",
"main": "index"
},
"aurelia-http-client",
"underscore",
{
"name": "jquery",
"path": "../node_modules/jquery/dist",
"main": "jquery.min"
},
{
"name": "bootstrap",
"path": "../node_modules/bootstrap/dist",
"main": "js/bootstrap.min",
"deps": ["jquery"],
"exports": "$"
},
{
"name": "i18next",
"path": "../node_modules/i18next/dist/umd",
"main": "i18next"
},
{
"name": "aurelia-i18n",
"path": "../node_modules/aurelia-i18n/dist/amd",
"main": "aurelia-i18n"
},
{
"name": "i18next-xhr-backend",
"path": "../node_modules/i18next-xhr-backend/dist/umd",
"main": "i18nextXHRBackend"
},
{
"name": "aurelia-validation",
"path": "../node_modules/aurelia-validation/dist/amd",
"main": "aurelia-validation"
},
{
"name": "aurelia-ui-virtualization",
"path": "../node_modules/aurelia-ui-virtualization/dist/amd",
"main": "aurelia-ui-virtualization"
},
{
"name": "aurelia-editables",
"path": "../node_modules/aurelia-editables/dist/amd",
"main": "aurelia-editables",
"resources": [
"**/*.html",
"**/*.css"
]
}
]
{
"patches": null,
"dependencies": [
{
"name": "interact",
"path": "../node_modules/interact.js/dist",
"main": "interact"
},
{
"name": "aurelia-interactjs",
"path": "../node_modules/aurelia-interactjs/dist/amd",
"main": "index"
},
"aurelia-http-client",
"underscore",
{
"name": "jquery",
"path": "../node_modules/jquery/dist",
"main": "jquery.min"
},
{
"name": "bootstrap",
"path": "../node_modules/bootstrap/dist",
"main": "js/bootstrap.min",
"deps": [
"jquery"
],
"exports": "$"
},
{
"name": "i18next",
"path": "../node_modules/i18next/dist/umd",
"main": "i18next"
},
{
"name": "aurelia-i18n",
"path": "../node_modules/aurelia-i18n/dist/amd",
"main": "aurelia-i18n"
},
{
"name": "i18next-xhr-backend",
"path": "../node_modules/i18next-xhr-backend/dist/umd",
"main": "i18nextXHRBackend"
},
{
"name": "aurelia-validation",
"path": "../node_modules/aurelia-validation/dist/amd",
"main": "aurelia-validation"
},
{
"name": "aurelia-ui-virtualization",
"path": "../node_modules/aurelia-ui-virtualization/dist/amd",
"main": "aurelia-ui-virtualization"
},
{
"name": "aurelia-editables",
"path": "../node_modules/aurelia-editables/dist/amd",
"main": "aurelia-editables",
"resources": [
"**/*.html",
"**/*.css"
]
}
]
}
27 changes: 15 additions & 12 deletions registry/aurelia-interactjs.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
[
{
"name": "interact",
"path": "../node_modules/interact.js/dist",
"main": "interact"
},
{
"name": "aurelia-interactjs",
"path": "../node_modules/aurelia-interactjs/dist/amd",
"main": "index"
}
]
{
"patches": null,
"dependencies": [
{
"name": "interact",
"path": "../node_modules/interact.js/dist",
"main": "interact"
},
{
"name": "aurelia-interactjs",
"path": "../node_modules/aurelia-interactjs/dist/amd",
"main": "index"
}
]
}
12 changes: 12 additions & 0 deletions registry/aurelia-kendoui-bridge.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"patches": [
{ "op": "replace", "path": "/build/loader/plugins/0/stub", "value": false}
],
"dependencies": [
{
"name": "aurelia-kendoui-bridge",
"path": "../node_modules/aurelia-kendoui-bridge/dist/amd",
"main": "index"
}
]
}
12 changes: 12 additions & 0 deletions registry/aurelia-kendoui-bridge@1.0.0-beta.1.0.17.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"patches": [
{ "op": "replace", "path": "/build/loader/plugins/0/stub", "value": false}
],
"dependencies": [
{
"name": "aurelia-kendoui-bridge",
"path": "../node_modules/aurelia-kendoui-bridge/dist/amd",
"main": "index"
}
]
}
33 changes: 19 additions & 14 deletions registry/bootstrap.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
[
{
"name": "jquery",
"path": "../node_modules/jquery/dist",
"main": "jquery.min"
},
{
"name": "bootstrap",
"path": "../node_modules/bootstrap/dist",
"main": "js/bootstrap.min",
"deps": ["jquery"],
"exports": "$"
}
]
{
"patches": null,
"dependencies": [
{
"name": "jquery",
"path": "../node_modules/jquery/dist",
"main": "jquery.min"
},
{
"name": "bootstrap",
"path": "../node_modules/bootstrap/dist",
"main": "js/bootstrap.min",
"deps": [
"jquery"
],
"exports": "$"
}
]
}
17 changes: 10 additions & 7 deletions registry/jquery.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[
{
"name": "jquery",
"path": "../node_modules/jquery/dist",
"main": "jquery.min"
}
]
{
"patches": null,
"dependencies": [
{
"name": "jquery",
"path": "../node_modules/jquery/dist",
"main": "jquery.min"
}
]
}
11 changes: 11 additions & 0 deletions registry/kendo-ui-core.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"patches": null,
"dependencies": [
"jquery",
{
"name": "kendo-ui-core",
"path": "../node_modules/kendo-ui-core/",
"main": "js/kendo.ui.core"
}
]
}
Loading

0 comments on commit acd06d9

Please sign in to comment.