@vaibhavvenkat/aacod
TypeScript icon, indicating that this package has built-in type declarations

0.6.7 • Public • Published

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();

Why would you ever need this?

Imagine you get a new computer, or set up a new server in the cloud.

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.

Package on npmjs

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

Readme

Keywords

none

Package Sidebar

Install

npm i @vaibhavvenkat/aacod

Weekly Downloads

0

Version

0.6.7

License

MIT

Unpacked Size

55.7 kB

Total Files

10

Last publish

Collaborators

  • vibovenkat