Socket
Socket
Sign inDemoInstall

@rushstack/package-deps-hash

Package Overview
Dependencies
Maintainers
0
Versions
391
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rushstack/package-deps-hash - npm Package Compare versions

Comparing version 4.1.68 to 4.2.0

9

CHANGELOG.md
# Change Log - @rushstack/package-deps-hash
This log was last generated on Fri, 13 Sep 2024 00:11:43 GMT and should not be manually modified.
This log was last generated on Sat, 21 Sep 2024 00:10:27 GMT and should not be manually modified.
## 4.2.0
Sat, 21 Sep 2024 00:10:27 GMT
### Minor changes
- Expose `hashFilesAsync` API. This serves a similar role as `getGitHashForFiles` but is asynchronous and allows for the file names to be provided as an async iterable.
## 4.1.68

@@ -6,0 +13,0 @@ Fri, 13 Sep 2024 00:11:43 GMT

@@ -72,2 +72,17 @@ /**

/**
* Uses `git hash-object` to hash the provided files. Unlike `getGitHashForFiles`, this API is asynchronous, and also allows for
* the input file paths to be specified as an async iterable.
*
* @param rootDirectory - The root directory to which paths are specified relative. Must be the root of the Git repository.
* @param filesToHash - The file paths to hash using `git hash-object`
* @param gitPath - The path to the Git executable
* @returns An iterable of [filePath, hash] pairs
*
* @remarks
* The input file paths must be specified relative to the Git repository root, or else be absolute paths.
* @beta
*/
export declare function hashFilesAsync(rootDirectory: string, filesToHash: Iterable<string> | AsyncIterable<string>, gitPath?: string): Promise<Iterable<[string, string]>>;
/**
* Information about the changes to a file.

@@ -74,0 +89,0 @@ * @beta

2

dist/tsdoc-metadata.json

@@ -8,5 +8,5 @@ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.

"packageName": "@microsoft/api-extractor",
"packageVersion": "7.47.8"
"packageVersion": "7.47.9"
}
]
}

@@ -56,2 +56,16 @@ export interface IGitVersion {

/**
* Uses `git hash-object` to hash the provided files. Unlike `getGitHashForFiles`, this API is asynchronous, and also allows for
* the input file paths to be specified as an async iterable.
*
* @param rootDirectory - The root directory to which paths are specified relative. Must be the root of the Git repository.
* @param filesToHash - The file paths to hash using `git hash-object`
* @param gitPath - The path to the Git executable
* @returns An iterable of [filePath, hash] pairs
*
* @remarks
* The input file paths must be specified relative to the Git repository root, or else be absolute paths.
* @beta
*/
export declare function hashFilesAsync(rootDirectory: string, filesToHash: Iterable<string> | AsyncIterable<string>, gitPath?: string): Promise<Iterable<[string, string]>>;
/**
* Gets the object hashes for all files in the Git repo, combining the current commit with working tree state.

@@ -58,0 +72,0 @@ * Uses async operations and runs all primary Git calls in parallel.

"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
var __asyncValues = (this && this.__asyncValues) || function (o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
};
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }

@@ -18,3 +25,3 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {

Object.defineProperty(exports, "__esModule", { value: true });
exports.parseGitVersion = exports.ensureGitMinimumVersion = exports.getRepoChanges = exports.getRepoStateAsync = exports.getRepoRoot = exports.parseGitStatus = exports.parseGitDiffIndex = exports.parseGitHashObject = exports.parseGitLsTree = void 0;
exports.parseGitVersion = exports.ensureGitMinimumVersion = exports.getRepoChanges = exports.getRepoStateAsync = exports.hashFilesAsync = exports.getRepoRoot = exports.parseGitStatus = exports.parseGitDiffIndex = exports.parseGitHashObject = exports.parseGitLsTree = void 0;
const events_1 = require("events");

@@ -240,3 +247,57 @@ const stream_1 = require("stream");

}
function isIterable(value) {
return Symbol.iterator in value;
}
/**
* Uses `git hash-object` to hash the provided files. Unlike `getGitHashForFiles`, this API is asynchronous, and also allows for
* the input file paths to be specified as an async iterable.
*
* @param rootDirectory - The root directory to which paths are specified relative. Must be the root of the Git repository.
* @param filesToHash - The file paths to hash using `git hash-object`
* @param gitPath - The path to the Git executable
* @returns An iterable of [filePath, hash] pairs
*
* @remarks
* The input file paths must be specified relative to the Git repository root, or else be absolute paths.
* @beta
*/
async function hashFilesAsync(rootDirectory, filesToHash, gitPath) {
const hashPaths = [];
const input = stream_1.Readable.from(isIterable(filesToHash)
? (function* () {
for (const file of filesToHash) {
hashPaths.push(file);
yield `${file}\n`;
}
})()
: (function () {
return __asyncGenerator(this, arguments, function* () {
var _a, e_1, _b, _c;
try {
for (var _d = true, filesToHash_1 = __asyncValues(filesToHash), filesToHash_1_1; filesToHash_1_1 = yield __await(filesToHash_1.next()), _a = filesToHash_1_1.done, !_a; _d = true) {
_c = filesToHash_1_1.value;
_d = false;
const file = _c;
hashPaths.push(file);
yield yield __await(`${file}\n`);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (!_d && !_a && (_b = filesToHash_1.return)) yield __await(_b.call(filesToHash_1));
}
finally { if (e_1) throw e_1.error; }
}
});
})(), {
encoding: 'utf-8',
objectMode: false,
autoDestroy: true
});
const hashObjectResult = await spawnGitAsync(gitPath, STANDARD_GIT_OPTIONS.concat(['hash-object', '--stdin-paths']), rootDirectory, input);
return parseGitHashObject(hashObjectResult, hashPaths);
}
exports.hashFilesAsync = hashFilesAsync;
/**
* Gets the object hashes for all files in the Git repo, combining the current commit with working tree state.

@@ -276,3 +337,2 @@ * Uses async operations and runs all primary Git calls in parallel.

]), rootDirectory).then(parseGitStatus);
const hashPaths = [];
function getFilesToHash() {

@@ -282,4 +342,3 @@ return __asyncGenerator(this, arguments, function* getFilesToHash_1() {

for (const file of additionalRelativePathsToHash) {
hashPaths.push(file);
yield yield __await(`${file}\n`);
yield yield __await(file);
}

@@ -290,4 +349,3 @@ }

if (exists) {
hashPaths.push(filePath);
yield yield __await(`${filePath}\n`);
yield yield __await(filePath);
}

@@ -300,14 +358,6 @@ else {

}
const hashObjectPromise = spawnGitAsync(gitPath, STANDARD_GIT_OPTIONS.concat(['hash-object', '--stdin-paths']), rootDirectory, stream_1.Readable.from(getFilesToHash(), {
encoding: 'utf-8',
objectMode: false,
autoDestroy: true
}));
const [{ files, submodules }, hashObject] = await Promise.all([
statePromise,
hashObjectPromise,
locallyModifiedPromise
]);
const hashObjectPromise = hashFilesAsync(rootDirectory, getFilesToHash(), gitPath);
const [{ files, submodules }] = await Promise.all([statePromise, locallyModifiedPromise]);
// The result of "git hash-object" will be a list of file hashes delimited by newlines
for (const [filePath, hash] of parseGitHashObject(hashObject, hashPaths)) {
for (const [filePath, hash] of await hashObjectPromise) {
files.set(filePath, hash);

@@ -314,0 +364,0 @@ }

@@ -13,3 +13,3 @@ /**

export { getPackageDeps, getGitHashForFiles } from './getPackageDeps';
export { type IFileDiffStatus, getRepoChanges, getRepoRoot, getRepoStateAsync, ensureGitMinimumVersion } from './getRepoState';
export { type IFileDiffStatus, getRepoChanges, getRepoRoot, getRepoStateAsync, ensureGitMinimumVersion, hashFilesAsync } from './getRepoState';
//# sourceMappingURL=index.d.ts.map

@@ -5,3 +5,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ensureGitMinimumVersion = exports.getRepoStateAsync = exports.getRepoRoot = exports.getRepoChanges = exports.getGitHashForFiles = exports.getPackageDeps = void 0;
exports.hashFilesAsync = exports.ensureGitMinimumVersion = exports.getRepoStateAsync = exports.getRepoRoot = exports.getRepoChanges = exports.getGitHashForFiles = exports.getPackageDeps = void 0;
/**

@@ -26,2 +26,3 @@ * This package builds a JSON object containing the git hashes of all files used to produce a given NPM package.

Object.defineProperty(exports, "ensureGitMinimumVersion", { enumerable: true, get: function () { return getRepoState_1.ensureGitMinimumVersion; } });
Object.defineProperty(exports, "hashFilesAsync", { enumerable: true, get: function () { return getRepoState_1.hashFilesAsync; } });
//# sourceMappingURL=index.js.map
{
"name": "@rushstack/package-deps-hash",
"version": "4.1.68",
"version": "4.2.0",
"description": "",

@@ -14,4 +14,4 @@ "main": "lib/index.js",

"devDependencies": {
"local-node-rig": "1.0.0",
"@rushstack/heft": "0.67.2"
"@rushstack/heft": "0.67.2",
"local-node-rig": "1.0.0"
},

@@ -18,0 +18,0 @@ "dependencies": {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc