Comparing version 0.3.1 to 0.4.0
47
index.js
@@ -5,2 +5,3 @@ 'use strict'; | ||
const path = require('path'); | ||
const { promisify } = require('util'); | ||
const branchName = require('branch-name'); | ||
@@ -10,31 +11,20 @@ const buildVersion = require('build-version'); | ||
const realpath = (filePath) => { | ||
return new Promise((resolve, reject) => { | ||
fs.realpath(filePath, (err, resolvedPath) => { | ||
if (err) { | ||
reject(err); | ||
return; | ||
} | ||
resolve(resolvedPath); | ||
}); | ||
}); | ||
}; | ||
const realpath = promisify(fs.realpath); | ||
const buildData = (option) => { | ||
const buildData = async (option) => { | ||
const config = Object.assign({}, option); | ||
const { cwd } = config; | ||
return Promise.all([ | ||
const [branch, version] = await Promise.all([ | ||
config.branch || branchName.assumeMaster({ cwd }), | ||
config.version || buildVersion({ cwd }) | ||
]) | ||
.then((data) => { | ||
return { | ||
branch : data[0], | ||
version : data[1] | ||
}; | ||
}); | ||
]); | ||
return { | ||
branch, | ||
version | ||
}; | ||
}; | ||
buildData.latest = (option) => { | ||
buildData.latest = async (option) => { | ||
const config = Object.assign({}, option); | ||
@@ -44,6 +34,6 @@ const { branch, version, cwd } = config; | ||
if (branch && version) { | ||
return Promise.resolve({ | ||
return { | ||
branch, | ||
version | ||
}); | ||
}; | ||
} | ||
@@ -58,10 +48,9 @@ | ||
return realpath(path.join(cwd || '', linkPath)).then((resolvedPath) => { | ||
return { | ||
branch : branch || path.basename(path.join(resolvedPath, '..')), | ||
version : version || path.basename(resolvedPath) | ||
}; | ||
}); | ||
const resolvedPath = await realpath(path.join(cwd || '', linkPath)); | ||
return { | ||
branch : branch || path.basename(path.join(resolvedPath, '..')), | ||
version : version || path.basename(resolvedPath) | ||
}; | ||
}; | ||
module.exports = buildData; |
127
package.json
{ | ||
"name": "build-data", | ||
"version": "0.3.1", | ||
"description": "Get metadata for your build.", | ||
"homepage": "https://github.com/sholladay/build-data", | ||
"main": "index.js", | ||
"author": { | ||
"name": "Seth Holladay", | ||
"url": "http://seth-holladay.com", | ||
"email": "me@seth-holladay.com" | ||
}, | ||
"scripts": { | ||
"test": "xo" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:sholladay/build-data.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/sholladay/build-data/issues", | ||
"email": "me@seth-holladay.com" | ||
}, | ||
"engines": { | ||
"node": ">=6" | ||
}, | ||
"license": "MPL-2.0", | ||
"files": [ | ||
"index.js" | ||
], | ||
"dependencies": { | ||
"branch-name": "^0.1.4", | ||
"build-path": "^0.1.0", | ||
"build-version": "^0.2.0" | ||
}, | ||
"devDependencies": { | ||
"eslint-config-tidy": "^0.3.0", | ||
"xo": "^0.16.0" | ||
}, | ||
"keywords": [ | ||
"package", | ||
"tooling", | ||
"build", | ||
"builds", | ||
"compile", | ||
"current", | ||
"latest", | ||
"head", | ||
"commit", | ||
"commits", | ||
"rev", | ||
"hash", | ||
"version", | ||
"versions", | ||
"git", | ||
"branch", | ||
"name", | ||
"meta", | ||
"data", | ||
"metadata", | ||
"info" | ||
], | ||
"xo": { | ||
"extend": "tidy" | ||
} | ||
"name": "build-data", | ||
"version": "0.4.0", | ||
"description": "Get metadata for your build", | ||
"homepage": "https://github.com/sholladay/build-data", | ||
"main": "index.js", | ||
"author": { | ||
"name": "Seth Holladay", | ||
"url": "https://seth-holladay.com", | ||
"email": "me@seth-holladay.com" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:sholladay/build-data.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/sholladay/build-data/issues", | ||
"email": "me@seth-holladay.com" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
}, | ||
"license": "MPL-2.0", | ||
"files": [ | ||
"index.js" | ||
], | ||
"dependencies": { | ||
"branch-name": "^1.0.0", | ||
"build-path": "^1.0.0", | ||
"build-version": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^0.22.0", | ||
"eslint-config-tidy": "^0.5.0", | ||
"xo": "^0.18.2" | ||
}, | ||
"keywords": [ | ||
"package", | ||
"tooling", | ||
"build", | ||
"builds", | ||
"compile", | ||
"current", | ||
"latest", | ||
"head", | ||
"commit", | ||
"commits", | ||
"rev", | ||
"hash", | ||
"version", | ||
"versions", | ||
"git", | ||
"branch", | ||
"name", | ||
"meta", | ||
"data", | ||
"metadata", | ||
"info" | ||
], | ||
"xo": { | ||
"extend": "tidy" | ||
} | ||
} |
@@ -1,4 +0,4 @@ | ||
# build-data [![Build status for build-data on Circle CI.](https://img.shields.io/circleci/project/sholladay/build-data/master.svg "Circle Build Status")](https://circleci.com/gh/sholladay/build-data "Build Data Builds") | ||
# build-data [![Build status for build-data](https://img.shields.io/circleci/project/sholladay/build-data/master.svg "Build Status")](https://circleci.com/gh/sholladay/build-data "Builds") | ||
> Get metadata for your build. | ||
> Get metadata for your build | ||
@@ -86,26 +86,15 @@ ## Why? | ||
### buildDir.link(option) | ||
Takes `cwd`, `branch`, and `version` on the option object. | ||
Within the `cwd`, writes a symlink at `latest-build` pointing to `build/<branch>/latest` and from there to `<version>`. | ||
### buildDir.prepare(option) | ||
Returns a promise for an object with these fields: | ||
- `path` is a newly created temporary directory for you to write the build to. | ||
- `finalize()` moves `path` to its final location and runs `buildDir.link()` on it. | ||
## Related | ||
- [build-version](https://github.com/sholladay/build-version) - Get a version for your build. | ||
- [build-dir](https://github.com/sholladay/build-dir) - Get a place to put your build. | ||
- [build-path](https://github.com/sholladay/build-path) - Get a path for the given build. | ||
- [build-keys](https://github.com/sholladay/build-keys) - Get the paths of files from your build. | ||
- [build-files](https://github.com/sholladay/build-files) - Read the files from your build. | ||
- [delivr](https://github.com/sholladay/delivr) - Build your code and ship it to S3 | ||
- [build-files](https://github.com/sholladay/build-files) - Read the files from your build | ||
- [build-keys](https://github.com/sholladay/build-keys) - Get the paths of files from your build | ||
- [build-dir](https://github.com/sholladay/build-dir) - Get a place to put your build | ||
- [build-path](https://github.com/sholladay/build-path) - Get a path for the given build | ||
- [build-version](https://github.com/sholladay/build-version) - Get a version for your build | ||
- [branch-name](https://github.com/sholladay/branch-name) - Get the current branch name | ||
## Contributing | ||
See our [contributing guidelines](https://github.com/sholladay/build-data/blob/master/CONTRIBUTING.md "The guidelines for participating in this project.") for more details. | ||
See our [contributing guidelines](https://github.com/sholladay/build-data/blob/master/CONTRIBUTING.md "Guidelines for participating in this project") for more details. | ||
@@ -116,8 +105,8 @@ 1. [Fork it](https://github.com/sholladay/build-data/fork). | ||
4. Push to the branch: `git push origin my-new-feature` | ||
5. [Submit a pull request](https://github.com/sholladay/build-data/compare "Submit code to this project for review."). | ||
5. [Submit a pull request](https://github.com/sholladay/build-data/compare "Submit code to this project for review"). | ||
## License | ||
[MPL-2.0](https://github.com/sholladay/build-data/blob/master/LICENSE "The license for build-data.") © [Seth Holladay](http://seth-holladay.com "Author of build-data.") | ||
[MPL-2.0](https://github.com/sholladay/build-data/blob/master/LICENSE "License for build-data") © [Seth Holladay](https://seth-holladay.com "Author of build-data") | ||
Go make something, dang it. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21791
3
42
111
+ Addedbranch-name@1.0.0(transitive)
+ Addedbuild-path@1.0.0(transitive)
+ Addedbuild-version@1.0.0(transitive)
+ Addedfind-up@2.1.0(transitive)
+ Addedload-json-file@2.0.0(transitive)
+ Addedlocate-path@2.0.0(transitive)
+ Addedmkdirtemp@1.1.0(transitive)
+ Addedp-limit@1.3.0(transitive)
+ Addedp-locate@2.0.0(transitive)
+ Addedp-try@1.0.0(transitive)
+ Addedpath-exists@3.0.0(transitive)
+ Addedpath-type@2.0.0(transitive)
+ Addedread-pkg@2.0.0(transitive)
+ Addedread-pkg-up@2.0.0(transitive)
+ Addedstrip-bom@3.0.0(transitive)
- Removedbranch-name@0.1.7(transitive)
- Removedbuild-path@0.1.1(transitive)
- Removedbuild-version@0.2.2(transitive)
- Removedfind-up@1.1.2(transitive)
- Removedis-utf8@0.2.1(transitive)
- Removedload-json-file@1.1.0(transitive)
- Removedpath-exists@2.1.0(transitive)
- Removedpath-type@1.1.0(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
- Removedread-pkg@1.1.0(transitive)
- Removedread-pkg-up@1.0.1(transitive)
- Removedstrip-bom@2.0.0(transitive)
Updatedbranch-name@^1.0.0
Updatedbuild-path@^1.0.0
Updatedbuild-version@^1.0.0