AACOD
Write typescript code to automate your environment setup
Get started by running npm install @vaibhavvenkat/aacod
Table of contents
A(utomation) A(s) COD(e)
AACOD is a away Automate having the same environment all within typescript.
Clone git repos, install packages, run scripts, all within a pragmatic way.
It has:
- A way to install homebrew packages
- A way to clone git repos
- A way to run shell scripts
- A way to install npm packages
- A way to run commands in the terminal
// index.ts
import { BrewPackage } from "@vaibhavvenkat/aacod";
const git = new BrewPackage({
name: "git",
silent: false,
cask: false,
upgrade_all: false,
update_homebrew: false,
});
async function main() {
const res = await git.safeInstall();
// ^? { success: boolean, error: BrewError | null }
console.log(res); // { success: true, error: null }
}
main();
Imagine you get a new computer, or set up a new server in the cloud. Why would you ever need this?
You want to have the same environment as your old computer, right?
You could write a huge shell script, but that doesn't ensure safety, and has some limitations, mainly because bash isn't a fully featured language, and you can't really do much about it.
AACOD
is an npm package that has a set of helper classes that allow you to
automate the process of setting up your environment. Since it is written in
typescript, you can use all the features of typescript to make your life easier,
Like arrays, objects, classes, functions, special types, etc.
Keep in mind this is not as fully featured as Ansible, the package expects you write your own typescript code along with the package. The package simply provides classes to run commands.
Example
import { BrewPackage, BrewPackageOptions } from "@vaibhavvenkat/aacod";
// ❌ This is not how it works
async function bad() {
// we don't have an `installNames` function
BrewPackage.installNamesSilently(["git", "node"]); // bad
// as nice as it seems, this is not the intended use case
}
// ✅ This is how it works
const pkgs: Pick<BrewPackageOptions, "name">[] = [
{
name: "git",
},
{
name: "node",
},
];
async function main() {
for (const pkg of pkgs) {
const brewPkg = new BrewPackage({
name: pkg.name,
silent: false,
cask: false,
update_homebrew: false,
upgrade_all: false,
});
const res = await brewPkg.safeInstall();
if (!res.success) {
console.error(res.error);
}
}
}
main();
Getting started
If you are on a brand new computer (on a Unix system), you can run ./setup.sh
to initialize an npm project in your directory and install AACOD
.
To install the package, use your favourite package manager.
npm
npm install @vaibhavvenkat/aacod
yarn
yarn add @vaibhavvenkat/aacod
pnpm
pnpm add @vaibhavvenkat/aacod
Usage Docs
By Vaibhav Venkat