builder-support
Advanced tools
Comparing version 0.4.1 to 0.5.0
@@ -11,3 +11,3 @@ #!/usr/bin/env node | ||
// builder-support <action> | ||
var actionFlag = process.argv[2]; | ||
var actionFlag = process.argv[2]; // eslint-disable-line no-magic-numbers | ||
var action = ACTIONS[actionFlag]; | ||
@@ -14,0 +14,0 @@ |
History | ||
======= | ||
## 0.5.0 | ||
* Add extra `package.json` mutations for `../ARCHETYPE-dev` scenario. | ||
* Update Travis to Nodes 4, 6, 8. And use yarn. | ||
* Upgrade all dependencies. | ||
## 0.4.1 | ||
@@ -5,0 +11,0 @@ |
@@ -21,2 +21,6 @@ "use strict"; | ||
var INDENT = 2; | ||
var LOCAL_DEV_PATH = path.resolve("dev"); | ||
// Allow "not found", otherwise pass through errors. | ||
@@ -26,3 +30,3 @@ var allowNotFound = function (callback) { | ||
if (err && err.code === "ENOENT") { | ||
return callback(null, null); | ||
return void callback(null, null); | ||
} | ||
@@ -37,7 +41,8 @@ | ||
* | ||
* @param {Object} source Source JSON object | ||
* @param {Object} target Target JSON object | ||
* @returns {Object} Updated JSON object | ||
* @param {Object} source Source JSON object | ||
* @param {Object} target Target JSON object | ||
* @param {Boolean} isExternal Is external (`../NAME-dev`) dev package. | ||
* @returns {Object} Updated JSON object | ||
*/ | ||
var updatePkg = function (source, target) { | ||
var updatePkg = function (source, target, isExternal) { | ||
// Clone source | ||
@@ -53,6 +58,39 @@ var pkg = JSON.parse(JSON.stringify(source)); | ||
// Update with "development" names | ||
var nameRe = new RegExp("(^|.*\/)(" + source.name + ")(\/.*|$)"); | ||
// Update with internal "development" names | ||
pkg.name += "-dev"; | ||
pkg.description += " (Development)"; | ||
// Update external fields to add `-dev` if applicable and present. | ||
if (isExternal) { | ||
[ | ||
"repository.url", | ||
"bugs.url", | ||
"homepage" | ||
].forEach(function (paths) { | ||
// Traverse the package structure. | ||
var parts = paths.split("."); | ||
var pkgPart = pkg; | ||
parts.forEach(function (part, i) { | ||
if (pkgPart && pkgPart[part]) { | ||
if (i + 1 === parts.length) { | ||
// Done! Update part if present. | ||
if (nameRe.test(pkgPart[part])) { | ||
pkgPart[part] = pkgPart[part].replace(nameRe, "$1" + pkg.name + "$3"); | ||
} | ||
return; | ||
} | ||
// Increment | ||
pkgPart = pkgPart[part]; | ||
return; | ||
} | ||
// Failed. | ||
pkgPart = null; | ||
}); | ||
}); | ||
} | ||
// Copy back in dependencies from dev package | ||
@@ -76,13 +114,12 @@ pkg.dependencies = (target || {}).dependencies || {}; | ||
findDevPath: ["readProdPackage", function (cb, results) { | ||
findDevPath: ["readProdPackage", function (results, cb) { | ||
var pkg = results.readProdPackage; | ||
var localDevPath = path.resolve("dev"); | ||
var externalDevPath = path.resolve("../" + pkg.name + "-dev"); | ||
fs.stat(localDevPath, function (localErr) { | ||
fs.stat(LOCAL_DEV_PATH, function (localErr) { | ||
if (localErr && localErr.code === "ENOENT") { | ||
return fs.stat(externalDevPath, function (externalErr) { | ||
return void fs.stat(externalDevPath, function (externalErr) { | ||
if (externalErr) { | ||
return cb(new Error("Could not find dev directories in: " + [ | ||
localDevPath, | ||
return void cb(new Error("Could not find dev directories in: " + [ | ||
LOCAL_DEV_PATH, | ||
externalDevPath | ||
@@ -94,7 +131,7 @@ ].join(", "))); | ||
} | ||
cb(localErr, localDevPath); | ||
cb(localErr, LOCAL_DEV_PATH); | ||
}); | ||
}], | ||
readDevPackage: ["findDevPath", function (cb, results) { | ||
readDevPackage: ["findDevPath", function (results, cb) { | ||
var pkgPath = path.join(results.findDevPath, "package.json"); | ||
@@ -108,5 +145,10 @@ fs.readJson(pkgPath, allowNotFound(cb)); | ||
"readProdPackage", | ||
function (cb, results) { | ||
function (results, cb) { | ||
var isExternal = results.findDevPath !== LOCAL_DEV_PATH; | ||
try { | ||
return cb(null, updatePkg(results.readProdPackage, results.readDevPackage)); | ||
return cb(null, updatePkg( | ||
results.readProdPackage, | ||
results.readDevPackage, | ||
isExternal | ||
)); | ||
} catch (err) { | ||
@@ -118,9 +160,9 @@ return cb(err); | ||
writeDevPackage: ["findDevPath", "updateDevPackage", function (cb, results) { | ||
writeDevPackage: ["findDevPath", "updateDevPackage", function (results, cb) { | ||
var pkgPath = path.join(results.findDevPath, "package.json"); | ||
fs.writeFile(pkgPath, JSON.stringify(results.updateDevPackage, null, 2) + "\n", cb); | ||
fs.writeFile(pkgPath, JSON.stringify(results.updateDevPackage, null, INDENT) + "\n", cb); | ||
}], | ||
// Copy all remaining files straight up. | ||
copyFiles: ["findDevPath", function (cb, results) { | ||
copyFiles: ["findDevPath", function (results, cb) { | ||
async.map(FILES, function (fileName, mapCb) { | ||
@@ -127,0 +169,0 @@ fs.copy( |
{ | ||
"name": "builder-support", | ||
"version": "0.4.1", | ||
"version": "0.5.0", | ||
"description": "Builder support libraries", | ||
@@ -19,4 +19,4 @@ "repository": { | ||
"scripts": { | ||
"builder:lint-server": "eslint --color -c .eslintrc-server lib bin", | ||
"builder:lint-server-test": "eslint --color -c .eslintrc-server-test test", | ||
"builder:lint-server": "eslint lib bin", | ||
"builder:lint-server-test": "eslint test", | ||
"builder:lint": "npm run builder:lint-server && npm run builder:lint-server-test", | ||
@@ -29,16 +29,17 @@ "builder:test": "mocha --opts test/server/mocha.opts test/server/spec", | ||
"dependencies": { | ||
"async": "^1.5.0", | ||
"fs-extra": "^0.30.0" | ||
"async": "^2.5.0", | ||
"fs-extra": "^4.0.2" | ||
}, | ||
"devDependencies": { | ||
"chai": "^3.4.1", | ||
"chai": "^4.1.2", | ||
"coveralls": "^2.11.6", | ||
"eslint": "^1.10.1", | ||
"eslint-config-defaults": "^7.0.1", | ||
"eslint-plugin-filenames": "^0.1.2", | ||
"eslint": "^4.7.2", | ||
"eslint-config-formidable": "^3.0.0", | ||
"eslint-plugin-filenames": "^1.1.0", | ||
"eslint-plugin-import": "^2.2.0", | ||
"istanbul": "^0.4.2", | ||
"mocha": "^2.3.4", | ||
"mock-fs": "3.10.0", | ||
"sinon": "^1.17.2" | ||
"mocha": "^3.5.3", | ||
"mock-fs": "4.4.1", | ||
"sinon": "^3.3.0" | ||
} | ||
} |
@@ -28,3 +28,3 @@ "use strict"; | ||
.to.have.property("message").and | ||
.to.contain("package.json"); | ||
.to.contain("package.json"); // eslint-disable-line indent | ||
@@ -50,3 +50,3 @@ done(); | ||
.to.have.property("message").and | ||
.to.contain("name"); | ||
.to.contain("name"); // eslint-disable-line indent | ||
@@ -72,3 +72,3 @@ done(); | ||
.to.have.property("message").and | ||
.to.contain("Could not find dev directories"); | ||
.to.contain("Could not find dev directories"); // eslint-disable-line indent | ||
@@ -90,3 +90,3 @@ done(); | ||
.to.have.property("message").and | ||
.to.contain("Unexpected token"); | ||
.to.contain("Unexpected token"); // eslint-disable-line indent | ||
@@ -113,3 +113,3 @@ done(); | ||
genDev(function (err) { | ||
if (err) { return done(err); } | ||
if (err) { return void done(err); } | ||
@@ -153,3 +153,3 @@ // NOTE: Sync methods are OK here because mocked and in-memory. | ||
genDev(function (err) { | ||
if (err) { return done(err); } | ||
if (err) { return void done(err); } | ||
@@ -192,3 +192,3 @@ // NOTE: Sync methods are OK here because mocked and in-memory. | ||
genDev(function (err) { | ||
if (err) { return done(err); } | ||
if (err) { return void done(err); } | ||
@@ -215,2 +215,10 @@ // NOTE: Sync methods are OK here because mocked and in-memory. | ||
description: "foo desc", | ||
repository: { | ||
type: "git", | ||
url: "https://github.com/FormidableLabs/no-match.git" | ||
}, | ||
bugs: { | ||
url: "https://github.com/FormidableLabs/foo/issues" | ||
}, | ||
homepage: "https://github.com/FormidableLabs/foo", | ||
dependencies: {}, | ||
@@ -233,3 +241,3 @@ peerDependencies: {} | ||
genDev(function (err) { | ||
if (err) { return done(err); } | ||
if (err) { return void done(err); } | ||
@@ -240,2 +248,8 @@ // NOTE: Sync methods are OK here because mocked and in-memory. | ||
expect(devPkg).to.have.property("description", "foo desc (Development)"); | ||
expect(devPkg).to.have.nested.property("repository.url", | ||
"https://github.com/FormidableLabs/no-match.git"); | ||
expect(devPkg).to.have.nested.property("bugs.url", | ||
"https://github.com/FormidableLabs/foo-dev/issues"); | ||
expect(devPkg).to.have.nested.property("homepage", | ||
"https://github.com/FormidableLabs/foo-dev"); | ||
expect(devPkg).to.have.property("dependencies").to.eql({ | ||
@@ -270,3 +284,3 @@ "foo": "^1.0.0" | ||
genDev(function (err) { | ||
if (err) { return done(err); } | ||
if (err) { return void done(err); } | ||
@@ -273,0 +287,0 @@ // NOTE: Sync methods are OK here because mocked and in-memory. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
87731
17
442
10
+ Addedasync@2.6.4(transitive)
+ Addedfs-extra@4.0.3(transitive)
+ Addedjsonfile@4.0.0(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addeduniversalify@0.1.2(transitive)
- Removedasync@1.5.2(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedfs-extra@0.30.0(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedglob@7.2.3(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedjsonfile@2.4.0(transitive)
- Removedklaw@1.3.1(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedonce@1.4.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedrimraf@2.7.1(transitive)
- Removedwrappy@1.0.2(transitive)
Updatedasync@^2.5.0
Updatedfs-extra@^4.0.2