@covector/command
Advanced tools
Comparing version 0.3.0 to 0.3.1
# Changelog | ||
## \[0.3.1] | ||
- Add missing dependencies that likely worked due to hoisting. | ||
- [60e8fc7](https://www.github.com/jbolda/covector/commit/60e8fc79cef13f2a2b442d772db0d9b8b9695ceb) chore: bump devDeps and fix tsconfig/rollup issues ([#165](https://www.github.com/jbolda/covector/pull/165)) on 2021-03-24 | ||
- Pull the most recent changelog into the chain of output. This opens up piping it into the Github Release. | ||
- [66539a8](https://www.github.com/jbolda/covector/commit/66539a800365ccfb28f95291b066e77114863382) fix: GitHub release pipe ([#164](https://www.github.com/jbolda/covector/pull/164)) on 2021-03-24 | ||
- Split up config merge function into two functions, one for version and one for publish, et al. This makes the types easier to reason about. | ||
- [66539a8](https://www.github.com/jbolda/covector/commit/66539a800365ccfb28f95291b066e77114863382) fix: GitHub release pipe ([#164](https://www.github.com/jbolda/covector/pull/164)) on 2021-03-24 | ||
## \[0.3.0] | ||
@@ -4,0 +13,0 @@ |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.raceTime = exports.sh = exports.runCommand = exports.confirmCommandsToRun = exports.attemptCommands = void 0; | ||
const tslib_1 = require("tslib"); | ||
const effection_1 = require("effection"); | ||
const node_1 = require("@effection/node"); | ||
const execa_1 = tslib_1.__importDefault(require("execa")); | ||
const strip_ansi_1 = tslib_1.__importDefault(require("strip-ansi")); | ||
const path_1 = tslib_1.__importDefault(require("path")); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var effection = require('effection'); | ||
var node = require('@effection/node'); | ||
var execa = require('execa'); | ||
var stripAnsi = require('strip-ansi'); | ||
var path = require('path'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var execa__default = /*#__PURE__*/_interopDefaultLegacy(execa); | ||
var stripAnsi__default = /*#__PURE__*/_interopDefaultLegacy(stripAnsi); | ||
var path__default = /*#__PURE__*/_interopDefaultLegacy(path); | ||
const attemptCommands = function* ({ cwd, commands, command, commandPrefix = "", pkgCommandsRan, dryRun, }) { | ||
let _pkgCommandsRan = Object.assign({}, pkgCommandsRan); | ||
for (let pkg of commands) { | ||
//@ts-ignore | ||
if (!pkg[`${commandPrefix}command`]) | ||
continue; | ||
//@ts-ignore | ||
const c = pkg[`${commandPrefix}command`]; | ||
@@ -52,3 +60,4 @@ const pubCommands = typeof c === "string" || typeof c === "function" || !Array.isArray(c) | ||
try { | ||
yield runningCommand.command(pkg); | ||
const pipeToFunction = Object.assign(Object.assign({}, pkg), { pkgCommandsRan: _pkgCommandsRan }); | ||
yield runningCommand.command(pipeToFunction); | ||
if (typeof pubCommand === "object" && pubCommand.pipe) { | ||
@@ -63,8 +72,7 @@ console.warn(`We cannot pipe the function command in ${pkg.pkg}`); | ||
else { | ||
//@ts-ignore TODO generator error | ||
const ranCommand = yield exports.runCommand({ | ||
const ranCommand = yield runCommand({ | ||
command: runningCommand.command, | ||
cwd, | ||
pkg: pkg.pkg, | ||
pkgPath: runningCommand.runFromRoot === true ? "" : pkg.path, | ||
pkgPath: runningCommand.runFromRoot === true ? "" : pkg.path || "", | ||
log: `${pkg.pkg} [${commandPrefix}${command}${runningCommand.runFromRoot === true ? " run from the cwd" : ""}]: ${runningCommand.command}`, | ||
@@ -87,3 +95,2 @@ }); | ||
}; | ||
exports.attemptCommands = attemptCommands; | ||
const confirmCommandsToRun = function* ({ cwd, commands, command, }) { | ||
@@ -93,13 +100,13 @@ let subPublishCommand = command.slice(7, 999); | ||
for (let pkg of commands) { | ||
//@ts-ignore | ||
const getPublishedVersion = pkg[`getPublishedVersion${subPublishCommand}`]; | ||
if (!!getPublishedVersion) { | ||
//@ts-ignore TODO generator error | ||
const version = yield exports.runCommand({ | ||
const version = yield runCommand({ | ||
command: getPublishedVersion, | ||
cwd, | ||
pkg: pkg.pkg, | ||
pkgPath: pkg.path, | ||
log: `Checking if ${pkg.pkg}@${pkg.pkgFile.version} is already published with: ${getPublishedVersion}`, | ||
pkgPath: pkg.path || "", | ||
log: `Checking if ${pkg.pkg}${!pkg.pkgFile ? "" : `@${pkg.pkgFile.version}`} is already published with: ${getPublishedVersion}`, | ||
}); | ||
if (pkg.pkgFile.version === version) { | ||
if (pkg.pkgFile && pkg.pkgFile.version === version) { | ||
console.log(`${pkg.pkg}@${pkg.pkgFile.version} is already published. Skipping.`); | ||
@@ -114,10 +121,9 @@ // early return if published already | ||
}; | ||
exports.confirmCommandsToRun = confirmCommandsToRun; | ||
const runCommand = function* ({ pkg = "package", command, cwd, pkgPath, log = `running command for ${pkg}`, }) { | ||
if (log !== false) | ||
console.log(log); | ||
exports.raceTime(); | ||
raceTime(); | ||
//@ts-ignore TODO generator error | ||
const child = yield exports.sh(command, { | ||
cwd: path_1.default.join(cwd, pkgPath), | ||
const child = yield sh(command, { | ||
cwd: path__default['default'].join(cwd, pkgPath), | ||
encoding: "utf8", | ||
@@ -127,3 +133,2 @@ }, log); | ||
}; | ||
exports.runCommand = runCommand; | ||
const sh = function* (command, options, log) { | ||
@@ -133,3 +138,3 @@ if (command.includes("|")) { | ||
//@ts-ignore | ||
const child = yield execa_1.default.command(command, Object.assign(Object.assign({}, options), { shell: true, all: true, timeout: 1200000 })); | ||
const child = yield execa__default['default'].command(command, Object.assign(Object.assign({}, options), { shell: true, all: true, timeout: 1200000 })); | ||
const out = child.stdout; | ||
@@ -147,7 +152,7 @@ if (log !== false) { | ||
// @ts-ignore | ||
let child = yield node_1.exec(command, options); | ||
let child = yield node.exec(command, options); | ||
if (log !== false) { | ||
// @ts-ignore | ||
yield effection_1.spawn(child.stdout.subscribe().forEach(function* (datum) { | ||
const out = strip_ansi_1.default(datum.toString().trim()); | ||
yield effection.spawn(child.stdout.subscribe().forEach(function* (datum) { | ||
const out = stripAnsi__default['default'](datum.toString().trim()); | ||
if (out !== "") | ||
@@ -157,4 +162,4 @@ console.log(out); | ||
// @ts-ignore | ||
yield effection_1.spawn(child.stderr.subscribe().forEach(function* (datum) { | ||
const out = strip_ansi_1.default(datum.toString().trim()); | ||
yield effection.spawn(child.stderr.subscribe().forEach(function* (datum) { | ||
const out = stripAnsi__default['default'](datum.toString().trim()); | ||
if (out !== "") | ||
@@ -165,3 +170,3 @@ console.error(out); | ||
const out = yield child.expect(); | ||
const stripped = strip_ansi_1.default( | ||
const stripped = stripAnsi__default['default']( | ||
//@ts-ignore | ||
@@ -172,9 +177,13 @@ Buffer.concat(out.tail).toString().trim()); | ||
}; | ||
exports.sh = sh; | ||
const raceTime = function ({ t = 1200000, msg = `timeout out waiting ${t / 1000}s for command`, } = {}) { | ||
return effection_1.spawn(function* () { | ||
yield effection_1.timeout(t); | ||
return effection.spawn(function* () { | ||
yield effection.timeout(t); | ||
throw new Error(msg); | ||
}); | ||
}; | ||
exports.attemptCommands = attemptCommands; | ||
exports.confirmCommandsToRun = confirmCommandsToRun; | ||
exports.raceTime = raceTime; | ||
exports.runCommand = runCommand; | ||
exports.sh = sh; |
{ | ||
"name": "@covector/command", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"license": "Apache-2.0", | ||
@@ -20,2 +20,3 @@ "homepage": "https://github.com/jbolda/covector#readme", | ||
"dependencies": { | ||
"@effection/node": "^1.0.1", | ||
"effection": "^1.0.0", | ||
@@ -26,4 +27,5 @@ "execa": "^5.0.0", | ||
"devDependencies": { | ||
"@covector/assemble": "0.6.0", | ||
"@rollup/plugin-typescript": "^8.2.0", | ||
"rollup": "^2.41.4", | ||
"rollup": "^2.42.4", | ||
"tslib": "^2.1.0", | ||
@@ -30,0 +32,0 @@ "typescript": "^4.2.3" |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
13996
172
0
4
5
+ Added@effection/node@^1.0.1
+ Added@effection/channel@1.0.0(transitive)
+ Added@effection/events@1.0.0(transitive)
+ Added@effection/node@1.0.2(transitive)
+ Added@effection/subscription@1.0.0(transitive)
+ Addedctrlc-windows@2.1.0(transitive)
+ Addedshellwords@0.1.1(transitive)