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

@arshaw/monorepo-tool

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arshaw/monorepo-tool - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

2

dist/src/git/GitRepo.js

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

const exec_1 = require("../util/exec");
const log_1 = require("../util/log");
class GitRepo {

@@ -52,2 +53,3 @@ constructor(rootDir) {

];
log_1.log(cmd);
return this.exec(cmd).then((output) => {

@@ -54,0 +56,0 @@ return Boolean(output.trim());

3

dist/src/npm/AbstractNpmClient.js

@@ -17,5 +17,2 @@ "use strict";

}
buildRunCmd(npmArgs) {
return [this.baseCmd, 'run', ...npmArgs];
}
buildPublishCmd(npmArgs) {

@@ -22,0 +19,0 @@ return [this.baseCmd, 'publish', ...npmArgs];

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const shell_quote_1 = require("shell-quote");
const errors_1 = require("../errors");

@@ -21,4 +20,4 @@ const arg_parse_1 = require("../util/arg-parse");

}
buildExecCmd(npmArgs) {
return ['npx', '-c', shell_quote_1.quote(npmArgs)];
buildExecCmd(cmdStr) {
return ['npx', '-c', cmdStr];
}

@@ -25,0 +24,0 @@ queryAddConfig(args, rootDir) {

@@ -22,4 +22,6 @@ "use strict";

}
buildExecCmd(otherArgs) {
return otherArgs; // execute directly because no npx equiv
buildExecCmd(cmdStr) {
// pipe directly to bash! no npx equiv! TODO: x-platform compat?
// TODO: use spawn() with shell:true arg?
return ['eval', cmdStr];
}

@@ -26,0 +28,0 @@ buildAddCmd(pkgArgs, otherArgs) {

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

const async_1 = require("../util/async");
const log_1 = require("../util/log");
function changedPkgsSincePoint(// TODO: rename from "point"

@@ -30,2 +31,3 @@ monoRepo, subjectPkgs, versionish, gitDiffArgs) {

let pkgGitRepo = yield PkgGitRepo_1.buildPkgGitRepo(monoRepo.rootDir, subjectPkgs);
log_1.log('versionish', versionish, commitHash);
return getChangedRepoPkgs(pkgGitRepo, commitHash, gitDiffArgs);

@@ -38,6 +40,11 @@ });

let ownPromises = pkgGitRepo.pkgs.map((pkg) => {
let ignoresFromRepoRoot = pkg.ignoreFiles.map((ignoreFile) => path_1.join(pkg.relDir, ignoreFile));
return pkgGitRepo.hasChangesSince(commitHash, [pkg.relDir], ignoresFromRepoRoot, otherGitArgs)
let includesAbs = [pkg.dir];
let ignoresAbs = pkg.ignoreFiles.map((ignoreFile) => path_1.join(pkg.dir, ignoreFile));
// need to relativize to subrepo root
let includes = includesAbs.map((path) => path_1.relative(pkgGitRepo.rootDir, path) || '.');
let ignores = ignoresAbs.map((path) => path_1.relative(pkgGitRepo.rootDir, path) || '.');
return pkgGitRepo.hasChangesSince(commitHash, includes, ignores, otherGitArgs)
.then((bool) => bool ? [pkg] : []);
});
log_1.log('looking at', pkgGitRepo.rootDir, commitHash);
let subPromises = pkgGitRepo.submodules.map((submodule) => {

@@ -44,0 +51,0 @@ return pkgGitRepo.getSubmoduleCommit(commitHash, submodule.rootDir).then((subCommit) => {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const shell_quote_1 = require("shell-quote");
const exec_1 = require("../util/exec");
const pretty_task_1 = require("../util/pretty-task");
function runScriptInPkgs(monoRepo, pkgs, isParallel, npmRunTimeArgs) {
let npmRunArgs = monoRepo.getCmdNpmArgs('run');
return execCmdsInPkgs(pkgs.map((pkg) => monoRepo.npmClient.buildRunCmd(npmRunArgs.concat(pkg.npmClientArgs, npmRunTimeArgs))), pkgs, isParallel);
const log_1 = require("../util/log");
function runScriptInPkgs(monoRepo, pkgs, isParallel, runArgs) {
// let npmRunArgs = monoRepo.getCmdNpmArgs('run') // TODO: somehow pass these in
let scriptName = runArgs[0]; // TODO: handle other runArgs
let tasks = [];
for (let pkg of pkgs) {
let cmd = pkg.buildScriptCmd(monoRepo.npmClient, scriptName);
if (cmd) {
tasks.push({
label: pkg.readableId() + ' (script(run): ' + scriptName + ')',
func() {
return isParallel
? exec_1.execBuffered(cmd, pkg.dir)
: exec_1.execLive(cmd, pkg.dir);
}
});
}
}
return isParallel ? pretty_task_1.runPrettyParallel(tasks) : pretty_task_1.runPrettySerial(tasks);
}
exports.runScriptInPkgs = runScriptInPkgs;
function execInPkgs(monoRepo, pkgs, isParallel, npmRunTimeArgs) {
let npmExecArgs = monoRepo.getCmdNpmArgs('exec');
return execCmdsInPkgs(pkgs.map((pkg) => monoRepo.npmClient.buildExecCmd(npmExecArgs.concat(pkg.npmClientArgs, npmRunTimeArgs))), pkgs, isParallel);
}
exports.execInPkgs = execInPkgs;
function execCmdsInPkgs(cmds, pkgs, isParallel) {
let tasks = pkgs.map((pkg, i) => ({
label: pkg.readableId(),
function execInPkgs(monoRepo, pkgs, isParallel, cmd) {
// let npmExecArgs = monoRepo.getCmdNpmArgs('exec') // dont want in exec command
// nor pkg.npmClientArgs
log_1.log('execInPkgs', cmd);
let tasks = pkgs.map((pkg) => ({
label: pkg.readableId() + '(exec: ' + cmd.join(' ') + ')',
func() {
let filteredCmd = monoRepo.npmClient.buildExecCmd(shell_quote_1.quote(cmd)); // with correct path and whatnot
return isParallel
? exec_1.execBuffered(cmds[i], pkg.dir)
: exec_1.execLive(cmds[i], pkg.dir);
? exec_1.execBuffered(filteredCmd, pkg.dir)
: exec_1.execLive(filteredCmd, pkg.dir);
}

@@ -26,1 +42,2 @@ }));

}
exports.execInPkgs = execInPkgs;

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

runScript(npmClient, scriptName, buffer = false) {
if (this.hasScript(scriptName)) {
let cmd = npmClient.buildRunCmd([scriptName].concat(this.npmClientArgs));
let cmd = this.buildScriptCmd(npmClient, scriptName);
if (cmd) {
log_1.log('runcmd', cmd, buffer, this.dir);
if (buffer) {

@@ -70,2 +71,9 @@ return exec_1.execBuffered(cmd, this.dir);

}
buildScriptCmd(npmClient, scriptName) {
let scriptCmdStr = (this.jsonData.scripts || {})[scriptName];
if (scriptCmdStr) {
return npmClient.buildExecCmd(scriptCmdStr);
}
return null;
}
readableId() {

@@ -72,0 +80,0 @@ return this.jsonData.name || 'root'; // assuming root is a bad idea

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

return __awaiter(this, void 0, void 0, function* () {
log_1.log('Running preversion hooks...');
yield preVersionHook();

@@ -96,2 +97,3 @@ modUndos = yield modifyFiles(modMap);

}
log_1.log('Running version hooks...');
yield versionHook();

@@ -105,5 +107,9 @@ if (pkgGitRepo) {

yield async_1.allSettledVoid(committedRepos.map((repo) => {
return repo.createTag(versionConfig.gitTagPrefix + newVersion, message, versionConfig.gitTagSign);
return repo.createTag(versionConfig.gitTagPrefix + newVersion, message, versionConfig.gitTagSign).catch((err) => {
console.error('Repo with problem making tag: ' + repo.rootDir);
throw err;
});
}));
}
log_1.log('Running postversion hooks...');
yield postVersionHook();

@@ -339,9 +345,13 @@ });

}
// TODO: use EXEC utils somehow. not DRY like this
let tasks = pkgsWithScripts.map((pkg) => ({
label: pkg.readableId(),
label: pkg.readableId() + ' (script(bump): ' + scriptName + ')',
func() {
return pkg.runScript(npmClient, scriptName, true); // bufferOutput=true
return pkg.runScript(npmClient, scriptName, false); // bufferOutput=false
}
}));
return pretty_task_1.runPrettyParallel(tasks).catch(() => {
// better to do serial in case there are interactive command prompts
// TODO: make a setting to toggle this?
// TODO: if change, will need to switch bufferOutput above
return pretty_task_1.runPrettySerial(tasks).catch(() => {
throw new errors_1.FailedNpmScript(scriptName);

@@ -348,0 +358,0 @@ });

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

cwd,
stdio: ['ignore', 1, 2] // TODO: will accept input?
stdio: [0, 1, 2]
});

@@ -26,0 +26,0 @@ child.on('error', (error) => {

{
"name": "@arshaw/monorepo-tool",
"version": "0.0.1",
"version": "0.0.2",
"license": "MIT",

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

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