nehemiah
v1.0.8
Published
A library for managing repositories
Downloads
14
Maintainers
Readme
About
Basically monorepos without the monorepo. Nehemiah synchronizes directories and executes tasks within them, based on code you write using a simple API.
Features include:
- Scan repo for files
- Test if file exists --> find out what type of project it is, or if a certain dependency/config file is used
- Copy file --> add file to repo if it doesn't exist, overwrite file, e.g.
tslint.json
- Delete file --> remove unwanted files for cleanup, e.g. logfiles
- Merge file fragments --> insert partials into
README.md
- Edit json file --> update
package.json
with standardized values - Edit line-based file --> update
.gitignore
- Run shell commands in directory -->
yarn install
,git fetch
,yarn upgrade
,sort-package-json
- Get warned if something deviates from expectations --> no tests in
package.json
, missing license
Install
yarn add nehemiah
Example
import Nehemiah from "nehemiah"
const projects = ["a", "b", "c"]
interface Package {
author: string
keywords: string[]
}
async function updateProject(dir: string) {
const n = new Nehemiah(dir)
const updatePackage = () => n.modify("package.json")
.asJson<Package>(p => {
p.author = "Esra"
if (!Array.isArray(p.keywords) || p.keywords.length < 3) {
n.warn("Not enough keywords")
}
})
const shouldHaveLicense = async () => {
if (!await n.exists("license*")) {
n.warn("Missing license")
}
}
const deleteLogs = async () => n.delete("*.log")
const updateEditorConfig = async () =>
n.copy(__dirname, "templates/.editorconfig").to(".editorconfig")
const updateMinorPatch = async () =>
n.run("yarn upgrade --mutext file")
const gitFetchPrune = () => n.run("git fetch --prune")
await Promise.all([
updatePackage,
shouldHaveLicense,
deleteLogs,
updateEditorConfig,
updateMinorPatch,
gitFetchPrune,
])
}
(async () => {
for (const dir of projects) {
await updateProject(dir)
}
})()