Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

workspace-tools

Package Overview
Dependencies
Maintainers
2
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

workspace-tools - npm Package Compare versions

Comparing version 0.15.1 to 0.16.0

lib/__tests__/getDefaultRemote.test.d.ts

17

CHANGELOG.json

@@ -5,3 +5,18 @@ {

{
"date": "Wed, 19 May 2021 21:05:04 GMT",
"date": "Tue, 25 May 2021 21:47:22 GMT",
"tag": "workspace-tools_v0.16.0",
"version": "0.16.0",
"comments": {
"minor": [
{
"comment": "Fix #24: Add support for different upstream branches",
"author": "dannyvv@microsoft.com",
"commit": "83546ce7c0ff54f588ad1fca54f2620d8f071708",
"package": "workspace-tools"
}
]
}
},
{
"date": "Wed, 19 May 2021 21:05:10 GMT",
"tag": "workspace-tools_v0.15.1",

@@ -8,0 +23,0 @@ "version": "0.15.1",

# Change Log - workspace-tools
This log was last generated on Wed, 19 May 2021 21:05:04 GMT and should not be manually modified.
This log was last generated on Tue, 25 May 2021 21:47:22 GMT and should not be manually modified.
<!-- Start content -->
## 0.16.0
Tue, 25 May 2021 21:47:22 GMT
### Minor changes
- Fix #24: Add support for different upstream branches (dannyvv@microsoft.com)
## 0.15.1
Wed, 19 May 2021 21:05:04 GMT
Wed, 19 May 2021 21:05:10 GMT

@@ -11,0 +19,0 @@ ### Patches

31

lib/__tests__/getChangedPackages.test.js

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

// act
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "master");
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main");
// assert

@@ -32,3 +32,3 @@ expect(changedPkgs).toContain("package-a");

// act
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "master");
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main");
// assert

@@ -43,3 +43,3 @@ expect(changedPkgs).toEqual(["package-a"]);

// act
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "master");
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main");
// assert

@@ -54,3 +54,3 @@ expect(changedPkgs).toContain("package-a");

// act
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "master");
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main");
// assert

@@ -66,3 +66,3 @@ expect(changedPkgs).toEqual(["package-a"]);

// act
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "master");
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main");
// assert

@@ -78,3 +78,3 @@ expect(changedPkgs).toContain("package-a");

// act
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "master");
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main");
// assert

@@ -91,3 +91,3 @@ expect(changedPkgs).toEqual(["package-a"]);

// act
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "master");
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main");
// assert

@@ -104,6 +104,19 @@ expect(changedPkgs).toContain("package-a");

// act
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "master");
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main");
// assert
expect(changedPkgs).toEqual(["package-a"]);
});
it("can detect changes inside a file that has been committed in a different branch using default remote", () => {
// arrange
const root = setupFixture_1.setupFixture("monorepo");
setupFixture_1.setupLocalRemote(root, "origin", "basic");
const newFile = path_1.default.join(root, "packages/package-a/footest.txt");
fs_1.default.writeFileSync(newFile, "hello foo test");
git_1.git(["checkout", "-b", "newbranch"], { cwd: root });
git_1.stageAndCommit(["add", newFile], "test commit", root);
// act
const changedPkgs = getChangedPackages_1.getChangedPackages(root, undefined);
// assert
expect(changedPkgs).toContain("package-a");
});
it("can ignore glob patterns in detecting changes", () => {

@@ -116,3 +129,3 @@ // arrange

// act
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "master", ["packages/package-a/*"]);
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main", ["packages/package-a/*"]);
// assert

@@ -119,0 +132,0 @@ expect(changedPkgs).toEqual([]);

@@ -65,4 +65,5 @@ declare type ProcessOutput = {

export declare function getDefaultRemoteBranch(branch: string | undefined, cwd: string): string;
export declare function getDefaultBranch(cwd: string): string;
export declare function getDefaultRemote(cwd: string): string;
export declare function listAllTrackedFiles(patterns: string[], cwd: string): string[];
export {};

@@ -368,7 +368,17 @@ "use strict";

}
function getDefaultRemoteBranch(branch = "master", cwd) {
function getDefaultRemoteBranch(branch, cwd) {
const defaultRemote = getDefaultRemote(cwd);
branch = branch || getDefaultBranch(cwd);
return `${defaultRemote}/${branch}`;
}
exports.getDefaultRemoteBranch = getDefaultRemoteBranch;
function getDefaultBranch(cwd) {
const result = git(["config", "init.defaultBranch"], { cwd });
if (!result.success) {
// Default to the legacy 'master' for backwards compat and old git clients
return "master";
}
return result.stdout.trim();
}
exports.getDefaultBranch = getDefaultBranch;
function getDefaultRemote(cwd) {

@@ -375,0 +385,0 @@ let packageJson;

@@ -7,1 +7,2 @@ /**

export declare function cleanupFixtures(): void;
export declare function setupLocalRemote(cwd: string, remoteName: string, fixtureName: string): void;

@@ -9,2 +9,3 @@ "use strict";

const fs_extra_1 = __importDefault(require("fs-extra"));
const fs_extra_2 = __importDefault(require("fs-extra"));
const tmp_1 = __importDefault(require("tmp"));

@@ -38,2 +39,8 @@ const git_1 = require("../git");

git_1.init(cwd, "test@test.email", "test user");
// Make the 'main' branch the default in the test repo
// ensure that the configuration for this repo does not collide
// with any global configuration the user had made, so we have
// a 'fixed' value for our tests, regardless of user configuration
git_1.gitFailFast(['symbolic-ref', 'HEAD', 'refs/heads/main'], { cwd });
git_1.gitFailFast(['config', 'init.defaultBranch', 'main'], { cwd });
git_1.stageAndCommit(["."], "test", cwd);

@@ -50,1 +57,14 @@ return cwd;

exports.cleanupFixtures = cleanupFixtures;
function setupLocalRemote(cwd, remoteName, fixtureName) {
// Create a seperate repo and configure it as a remote
const remoteCwd = setupFixture(fixtureName);
const remoteUrl = remoteCwd.replace(/\\/g, "/");
git_1.gitFailFast(["remote", "add", remoteName, remoteUrl], { cwd });
// Configure url in package.json
const pkgJsonPath = path_1.default.join(cwd, "package.json");
const pkgJson = fs_extra_2.default.readJSONSync(pkgJsonPath);
fs_extra_2.default.writeJSONSync(pkgJsonPath, Object.assign(Object.assign({}, pkgJson), { repository: {
url: remoteUrl
} }));
}
exports.setupLocalRemote = setupLocalRemote;

@@ -18,2 +18,2 @@ /**

*/
export declare function getChangedPackages(cwd: string, target?: string, ignoreGlobs?: string[]): string[];
export declare function getChangedPackages(cwd: string, target: string | undefined, ignoreGlobs?: string[]): string[];

@@ -27,4 +27,5 @@ "use strict";

*/
function getChangedPackages(cwd, target = "origin/master", ignoreGlobs = []) {
function getChangedPackages(cwd, target, ignoreGlobs = []) {
const workspaceInfo = getWorkspaces_1.getWorkspaces(cwd);
target = target || git_1.getDefaultRemoteBranch(undefined, cwd);
let changes = [

@@ -31,0 +32,0 @@ ...new Set([

{
"name": "workspace-tools",
"version": "0.15.1",
"version": "0.16.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "repository": {

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