0.6.7 • Published 10 months ago

@vaibhavvenkat/aacod v0.6.7

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

Table of contents

  • About AACOD
    • Methodology of AACOD
  • Getting started
  • Usage

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

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

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

By Vaibhav Venkat

0.6.7

10 months ago

0.6.6

10 months ago

0.6.5

10 months ago

0.6.4

10 months ago

0.6.3

10 months ago

0.6.2

10 months ago

0.6.1

10 months ago

0.6.0

10 months ago

0.5.5

10 months ago

0.5.4

10 months ago

0.5.3

10 months ago

0.5.2

10 months ago

0.5.1

10 months ago

0.5.0

10 months ago

0.4.2

10 months ago

0.4.1

10 months ago

0.4.0

10 months ago

0.3.0

10 months ago

0.2.1

10 months ago

0.2.0

10 months ago

0.1.1

10 months ago

0.0.5

10 months ago

0.0.4

10 months ago

0.0.2

10 months ago