Socket
Socket
Sign inDemoInstall

@lerna/describe-ref

Package Overview
Dependencies
2
Maintainers
2
Versions
61
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.16.5 to 4.0.0

31

CHANGELOG.md

@@ -6,2 +6,33 @@ # Change Log

# [4.0.0](https://github.com/lerna/lerna/compare/v3.22.1...v4.0.0) (2021-02-10)
### Code Refactoring
* **describe-ref:** Add JSDoc types, remove test-only export ([e5cf30c](https://github.com/lerna/lerna/commit/e5cf30cb66f9b85f13afb475ea0c9e59c8fabba3))
### Features
* Drop support for Node v6.x & v8.x ([ff4bb4d](https://github.com/lerna/lerna/commit/ff4bb4da215555e3bb136f5af09b5cbc631e57bb))
* Expose named export ([c1303f1](https://github.com/lerna/lerna/commit/c1303f13adc4cf15f96ff25889b52149f8224c0e))
* Remove default export ([e2f1ec3](https://github.com/lerna/lerna/commit/e2f1ec3dd049d2a89880029908a2aa7c66f15082))
### BREAKING CHANGES
* The default export has been removed, please use a named export instead.
* **describe-ref:** The test-only 'parse()' export has been removed.
* Node v6.x & v8.x are no longer supported. Please upgrade to the latest LTS release.
Here's the gnarly one-liner I used to make these changes:
```
npx lerna exec --concurrency 1 --stream -- 'json -I -f package.json -e '"'"'this.engines=this.engines||{};this.engines.node=">= 10.18.0"'"'"
```
(requires `npm i -g json` beforehand)
## [3.16.5](https://github.com/lerna/lerna/compare/v3.16.4...v3.16.5) (2019-10-07)

@@ -8,0 +39,0 @@

59

lib/describe-ref.js

@@ -6,6 +6,32 @@ "use strict";

module.exports = describeRef;
module.exports.parse = parse;
module.exports.sync = sync;
module.exports.describeRef = describeRef;
module.exports.describeRefSync = describeRefSync;
/**
* @typedef {object} DescribeRefOptions
* @property {string} [cwd] Defaults to `process.cwd()`
* @property {string} [match] Glob passed to `--match` flag
*/
/**
* @typedef {object} DescribeRefFallbackResult When annotated release tags are missing
* @property {boolean} isDirty
* @property {string} refCount
* @property {string} sha
*/
/**
* @typedef {object} DescribeRefDetailedResult When annotated release tags are present
* @property {string} lastTagName
* @property {string} lastVersion
* @property {boolean} isDirty
* @property {string} refCount
* @property {string} sha
*/
/**
* Build `git describe` args.
* @param {DescribeRefOptions} options
* @param {boolean} [includeMergedTags]
*/
function getArgs(options, includeMergedTags) {

@@ -30,3 +56,3 @@ let args = [

// we want to consider all tags, also from merged branches
args = args.filter(arg => arg !== "--first-parent");
args = args.filter((arg) => arg !== "--first-parent");
}

@@ -37,2 +63,7 @@

/**
* @param {DescribeRefOptions} [options]
* @param {boolean} [includeMergedTags]
* @returns {Promise<DescribeRefFallbackResult|DescribeRefDetailedResult>}
*/
function describeRef(options = {}, includeMergedTags) {

@@ -42,3 +73,3 @@ const promise = childProcess.exec("git", getArgs(options, includeMergedTags), options);

return promise.then(({ stdout }) => {
const result = parse(stdout, options);
const result = parse(stdout, options.cwd);

@@ -52,5 +83,9 @@ log.verbose("git-describe", "%j => %j", options && options.match, stdout);

function sync(options = {}, includeMergedTags) {
/**
* @param {DescribeRefOptions} [options]
* @param {boolean} [includeMergedTags]
*/
function describeRefSync(options = {}, includeMergedTags) {
const stdout = childProcess.execSync("git", getArgs(options, includeMergedTags), options);
const result = parse(stdout, options);
const result = parse(stdout, options.cwd);

@@ -63,3 +98,9 @@ // only called by collect-updates with no matcher

function parse(stdout, options = {}) {
/**
* Parse git output and return relevant metadata.
* @param {string} stdout Result of `git describe`
* @param {string} [cwd] Defaults to `process.cwd()`
* @returns {DescribeRefFallbackResult|DescribeRefDetailedResult}
*/
function parse(stdout, cwd) {
const minimalShaRegex = /^([0-9a-f]{7,40})(-dirty)?$/;

@@ -72,3 +113,3 @@ // when git describe fails to locate tags, it returns only the minimal sha

// count number of commits since beginning of time
const refCount = childProcess.execSync("git", ["rev-list", "--count", sha], options);
const refCount = childProcess.execSync("git", ["rev-list", "--count", sha], { cwd });

@@ -75,0 +116,0 @@ return { refCount, sha, isDirty: Boolean(isDirty) };

8

package.json
{
"name": "@lerna/describe-ref",
"version": "3.16.5",
"version": "4.0.0",
"description": "Parse git describe output for lerna-related tags",

@@ -19,3 +19,3 @@ "keywords": [

"engines": {
"node": ">= 6.9.0"
"node": ">= 10.18.0"
},

@@ -34,6 +34,6 @@ "publishConfig": {

"dependencies": {
"@lerna/child-process": "3.16.5",
"@lerna/child-process": "4.0.0",
"npmlog": "^4.1.2"
},
"gitHead": "f0574092a2db90142b3a27ec1a4941cddbdcdf62"
"gitHead": "4582c476e07dddddd6b2e3ab6e7f52c1f9eed59a"
}

@@ -8,3 +8,3 @@ # `@lerna/describe-ref`

```js
const describe = require("@lerna/describe-ref");
const { describe } = require("@lerna/describe-ref");

@@ -11,0 +11,0 @@ (async () => {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc