@covector/assemble
Advanced tools
Comparing version 0.1.0 to 0.2.0
# Changelog | ||
## [0.2.0] | ||
- Note in sub-bullets when a bump was due to a dependency (and that helps note where there summary text is from as well.) | ||
- [de3248d](https://www.github.com/jbolda/covector/commit/de3248dfd70146392ff65e7065c2125daf527728) feat: dep bump note in changelog ([#87](https://www.github.com/jbolda/covector/pull/87)) on 2020-07-10 | ||
- Pull and set git meta information on change files as an array of commits. This can then be piped into changelogs. | ||
- Bumped due to a bump in covector. | ||
- [cc19486](https://www.github.com/jbolda/covector/commit/cc19486f86b78aec2c719e5dd17a2d72cbc8d450) feat: new command package and piped git info ([#78](https://www.github.com/jbolda/covector/pull/78)) on 2020-07-09 | ||
- [de3248d](https://www.github.com/jbolda/covector/commit/de3248dfd70146392ff65e7065c2125daf527728) feat: dep bump note in changelog ([#87](https://www.github.com/jbolda/covector/pull/87)) on 2020-07-10 | ||
- Allow complex commands specified as an object. This let's one specify a dryRunCommand that is executed in --dry-run mode instead (so no accidental publishes!) or to set pipe to true that the output is returned from the main covector function. The pipe likely won't be used directly, but can be consumed within the action to create a Github Release, etc. | ||
- Bumped due to a bump in covector. | ||
- [3ca050c](https://www.github.com/jbolda/covector/commit/3ca050c2c51821d229209e18391535c266b6b200) feat: advanced commands ([#71](https://www.github.com/jbolda/covector/pull/71)) on 2020-07-06 | ||
- Version commands used to only run on changes, but ignore parents. Reconfigure that we resolve the parents and run commands on both direct changes and changes through a dependency. | ||
- Bumped due to a bump in covector. | ||
- [3ca050c](https://www.github.com/jbolda/covector/commit/3ca050c2c51821d229209e18391535c266b6b200) feat: advanced commands ([#71](https://www.github.com/jbolda/covector/pull/71)) on 2020-07-06 | ||
- Add config option to specify an asset that is uploaded on publish to the Github Release. | ||
- [3f6e0b3](https://www.github.com/jbolda/covector/commit/3f6e0b335e88ebd07186ebeec57d4f438a274e1f) feat: add config option to specify assets to upload at publish ([#86](https://www.github.com/jbolda/covector/pull/86)) on 2020-07-10 | ||
## [0.1.0] | ||
@@ -4,0 +21,0 @@ |
117
index.js
@@ -8,2 +8,3 @@ const unified = require("unified"); | ||
const { readPkgFile } = require("@covector/files"); | ||
const { runCommand } = require("@covector/command"); | ||
const path = require("path"); | ||
@@ -13,4 +14,4 @@ | ||
const parseChange = (testText) => { | ||
const parsed = processor.parse(testText); | ||
const parseChange = function* ({ cwd, vfile }) { | ||
const parsed = processor.parse(vfile.contents); | ||
const processed = processor.runSync(parsed); | ||
@@ -29,2 +30,30 @@ let changeset = {}; | ||
}, ""); | ||
if (cwd) { | ||
try { | ||
let gitInfo = yield runCommand({ | ||
cwd, | ||
pkgPath: "", | ||
command: `git log --reverse --format="%h %H %as %s" ${vfile.data.filename}`, | ||
log: false, | ||
}); | ||
const commits = gitInfo.split(/\n/).map((commit) => { | ||
const [hashShort, hashLong, date, ...rest] = commit.split(" "); | ||
return { | ||
hashShort, | ||
hashLong, | ||
date, | ||
commitSubject: rest.join(" "), | ||
}; | ||
}); | ||
changeset.meta = { | ||
...vfile.data, | ||
commits, | ||
}; | ||
} catch (e) { | ||
changeset.meta = { | ||
...vfile.data, | ||
}; | ||
} | ||
} | ||
return changeset; | ||
@@ -69,6 +98,14 @@ }; | ||
module.exports.assemble = (texts) => { | ||
module.exports.assemble = function* ({ cwd, vfiles }) { | ||
let plan = {}; | ||
plan.changes = texts.map((text) => parseChange(text)); | ||
plan.releases = mergeReleases(plan.changes); | ||
let changes = yield function* () { | ||
let allVfiles = vfiles.map((vfile) => parseChange({ cwd, vfile })); | ||
let yieldedV = []; | ||
for (let v of allVfiles) { | ||
yieldedV = [...yieldedV, yield v]; | ||
} | ||
return yieldedV; | ||
}; | ||
plan.changes = changes; | ||
plan.releases = mergeReleases(changes); | ||
return plan; | ||
@@ -92,2 +129,3 @@ }; | ||
let getPublishedVersion; | ||
let assets; | ||
if (command === "publish") { | ||
@@ -98,2 +136,3 @@ getPublishedVersion = mergeCommand({ | ||
}); | ||
assets = mergeCommand({ ...commandItems, command: "assets" }); | ||
} | ||
@@ -112,2 +151,3 @@ | ||
...(!getPublishedVersion ? {} : { getPublishedVersion }), | ||
...(!assets ? {} : { assets }), | ||
manager: config.packages[pkg].manager, | ||
@@ -134,3 +174,3 @@ dependencies: config.packages[pkg].dependencies, | ||
const extraPublishParams = | ||
let extraPublishParams = | ||
command == "version" | ||
@@ -150,9 +190,2 @@ ? {} | ||
}), | ||
...(!pkgCommands[pkg].getPublishedVersion | ||
? {} | ||
: { | ||
getPublishedVersion: template( | ||
pkgCommands[pkg].getPublishedVersion | ||
)(pipeToTemplate), | ||
}), | ||
}; | ||
@@ -168,2 +201,25 @@ | ||
if (command !== "version") { | ||
// add these after that they can use pkgFile | ||
extraPublishParams = { | ||
...extraPublishParams, | ||
...(!pkgCommands[pkg].getPublishedVersion | ||
? {} | ||
: { | ||
getPublishedVersion: template( | ||
pkgCommands[pkg].getPublishedVersion | ||
)(pipeToTemplate), | ||
}), | ||
...(!pkgCommands[pkg].assets | ||
? {} | ||
: { | ||
assets: templateCommands( | ||
pkgCommands[pkg].assets, | ||
pipeToTemplate, | ||
["path", "name"] | ||
), | ||
}), | ||
}; | ||
} | ||
if (dryRun) { | ||
@@ -177,2 +233,3 @@ pipeOutput[pkg] = {}; | ||
pkg, | ||
...(!pkgs[pkg].parents ? {} : { parents: pkgs[pkg].parents }), | ||
...extraPublishParams, | ||
@@ -183,10 +240,17 @@ path: pkgCommands[pkg].path, | ||
dependencies: pkgCommands[pkg].dependencies, | ||
precommand: templateCommands(pkgCommands[pkg].precommand, pipeToTemplate), | ||
command: templateCommands(pkgCommands[pkg].command, pipeToTemplate), | ||
precommand: templateCommands( | ||
pkgCommands[pkg].precommand, | ||
pipeToTemplate, | ||
["command", "dryRunCommand"] | ||
), | ||
command: templateCommands(pkgCommands[pkg].command, pipeToTemplate, [ | ||
"command", | ||
"dryRunCommand", | ||
]), | ||
postcommand: templateCommands( | ||
pkgCommands[pkg].postcommand, | ||
pipeToTemplate | ||
pipeToTemplate, | ||
["command", "dryRunCommand"] | ||
), | ||
}; | ||
return merged; | ||
@@ -224,6 +288,21 @@ }); | ||
const templateCommands = (command, pipe) => { | ||
const templateCommands = (command, pipe, complexCommands) => { | ||
if (!command) return null; | ||
const commands = !Array.isArray(command) ? [command] : command; | ||
return commands.map((c) => template(c)(pipe)); | ||
return commands.map((c) => { | ||
if (typeof c === "object") { | ||
return { | ||
...c, | ||
...complexCommands.reduce((templated, complex) => { | ||
templated[complex] = | ||
typeof c[complex] === "string" | ||
? template(c[complex])(pipe) | ||
: c[complex]; | ||
return templated; | ||
}, {}), | ||
}; | ||
} else { | ||
return template(c)(pipe); | ||
} | ||
}); | ||
}; |
{ | ||
"name": "@covector/assemble", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "files": [ |
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
11568
271