How to ultra-over-engineer a useless piece of software (or why human interaction is important)
Tags: overengineering, useless, npm, package
Published: 2021-04-07 22:51:22

---
title: How to ultra-over-engineer a useless piece of software (or why human interaction is important)
published: true
description: This is the story of the of the most useless (may be) npm package. I am warning you that this will be a waste of time.
tags: overengineering, useless, npm, package
cover_image: https://pbs.twimg.com/media/CAeRfLyWAAAfpjj?format=png&name=small
---
<sup>(cover image: from [here](https://twitter.com/jerome_etienne/status/578591043093835776/photo/1))</sup>

This is the story of the of the most useless (may be) npm package. I am warning you that this will be a waste of time.

## Why?

Whenever I wanted to setup a new project, I used to always run these commands:

```
npm init -y
```
And,

```
git init .
git add .
git commit -m "Initial commit"
```

So, I thought of automating it.

I thought of writing a tool (FML 🤦‍♂️!) that could execute a series of commands.

ENTER THE `Uninit`

## How does it work?

This will basically read a `json` file that has a `schema` object. This `schema` object should have key-value pairs of schemas.

User can select a `schema` by passing a cli argument (`-l`) that points to the `json` file containing schemas as key-value pairs:  
![Select Schema](https://raw.githubusercontent.com/stagefright5/uninit/master/images/select-schema-no-confirm.png)  

`--skip-confirm=true` option is passed. Otherwise, user has to confirm the execution of each task.   

This is a sample `schema` object. Here, there are `tasks` that will run sequentially, when the schema is run:  
  
![Sample Schema Object](https://raw.githubusercontent.com/stagefright5/uninit/master/images/schema-npm-git-init.png)  

This is how the `task`s are run sequentially:

![Tasks Execution](https://raw.githubusercontent.com/stagefright5/uninit/master/images/running-schema-npm-git-init-no-confirm.png)  

Observe the last task (no. 4). This task's `command` has placeholders
- `${commit_head}` and
- `${commit_body}`

![Tasks Execution](https://raw.githubusercontent.com/stagefright5/uninit/master/images/placeholder-task.png)

So, the tool will 
- Parse the command
- Take the values for each of the placeholder from the user (you can see something like, "Value for placeholder_0" in the image)
- Replace the placeholders with these values
- Execute the replaced command (Here, `git commit -m "This is commit header" -m "This is detailed commit descriptions"`)

## Structure Of Schema (You can skip and go to [PS](#ps))

Each schema has the folowing structure: 

- description(`string`): Describes the schema
- tasks(`Array<{name: string, command: string}>`): `name` property is a unique id for this object task object. 
`command` is the command to execute. `command` can take user inputs.
If there is any placeholder in the string(in this form: `${user_input_1}`), then the tool will parse it and asks the user for input for each of the placeholder.

## PS

You might be thinking,
>"Why The F, would I ever use this instead of a simple shell script! This is a completely useless piece Of Sh*t!"

And, you would be **ABSOLUTELY** right.

This whole exercise made me realize why you should say your "awesome" ideas out loud, preferably, to other human beings.

Anyway,
- Here is the repo: https://github.com/stagefright5/uninit (if you want to explore the code of this amazing software), and
- NPM Link: https://www.npmjs.com/package/uninit