• Stars
    star
    139
  • Rank 262,954 (Top 6 %)
  • Language
    JavaScript
  • Created over 10 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

.files and environment configuration manager created with node

NPM

Build Status img img img

kody

alt tag

An interactive .files and environment configuration tool created with node

Inspired by Zach Holmans popular dotfiles, stripped down and written in node

  • One command
  • No restrictions on where you run from or store your dotfiles
  • Easy to configure, extend and tweak
  • Interactive CLI that prompts which tasks you want to run
  • Just needs node and your dotfiles!

alt tag

Index

What is kody

kody is more than a dotfiles installer. Out of the box, it can handle symlinking your version controlled files to a desired directory. It will also backup your originals if you wish πŸ‘

But it can do much more! And it's up to you how creative you want to get 🐻

You create some tasks to set up your machine, run kody, and kody will go ahead and run the tasks you tell it to!

What else would I use it for

You can use kody to automate most things.

For example, fed up of installing a bunch of apps when you set up a machine? Create a small task to install homebrew, configure a list of apps you want and tell kody to do it for you! πŸ˜‰

Or how about automating your shell configuration or IDE set up! They can be time consuming πŸ˜…

You can see some examples in the examples section below πŸ‘

Installation

You'll need to install node/npm first as this is a dependency of kody. Then, install kody globally πŸ‘

npm i -g kody

Usage

Installing Dotfiles

Out of the box, kody comes with dotfile installation. kody will symlink your version controlled dotfiles to a directory of your choosing. The default is $HOME.

kody needs to know which files to symlink. So any files or directories you wish to symlink should have the suffix .link.

For example; I want to install a dotfile for a .gitignore file. Rename your version controlled .gitignore to .gitignore.link and then run kody in that directory. The same works for directories if you want to symlink the contents of a directory.

/my/version/controlled/dotfiles/repo/.gitignore.link -> $HOME/.gitignore

kody will also prompt you to see if you'd like to backup your original dotfiles. It will backup the original to the same destination with the .bak suffix.

That's all you need to manage and install your dotfiles πŸ’ͺ

Tasks

Now the fun starts! πŸ˜‰

You can also use kody to automate various defined tasks.

Let's start with the basics.

By default, all tasks live inside a kody.tasks directory. You can configure this (we will get to that). kody will search the directory for all the JavaScript files it can find. You can nest tasks.

Each task file exposes an object that must consist of at least a name and an exec function. The description property is metadata to give a friendly description of tasks. description will be rendered when choosing which tasks to run.

module.exports = {
  name: 'πŸ¦„',
  description: 'A truly magical task',
  exec: (resolve, reject, shell, config, log, ora) => {}
}

The exec function is what gets run by kody. You can do whatever you like inside this function but the arguments passed in are important. This is how kody exposes various things to the user. You are of course free to name the parameters however you wish πŸ˜„

Let's run through them πŸ‘

  • resolve/reject - kody uses Promises so the first two arguments enable you to inform kody of when to move on. If your task is complete, invoke resolve. If your task stumbles, make use of reject πŸ›‘
  • shell - one of the main things when automating set up etc. is running various shell commands. kody exposes the shelljs API to your tasks. We will use this in the Hello World example
  • config - a major thing with set ups is being able to keep everything in one config file. This way you won't have to hard code values into your tasks. kody will search for a .kodyrc file on start and pass that configuration object to your tasks. In here you can define any JSON you want. For example, a list of apps to install, editor plugins to install etc. Define under keys and access them in your tasks πŸ‘Š
  • log - kody exposes a simple color logging utility that uses chalk. It's a function that takes three parameters. The first is the message you want to display. The second and third are the text color and background color respectively. The function expects color represented by a hexidecimal value πŸ‘ You use this log function inside your standard console invocation.
  • ora - kody exposes the ora API so you can fire up a terminal spinner when needed too!

Hello World

For our first task, why not "Hello World!"? πŸ˜…

We will use shelljs to invoke say.

const task = {
  name: 'Hello World πŸ‘‹',
  description: 'Hey from kody 🐻',
  exec: (resolve, reject, shell) => {
    shell.exec('say hello world!')
    resolve()
  }
}
module.exports = task

That's it! Run kody in the parent of your tasks directory and choose the Hello World task. Depending on your OS, you should hear Hello World! πŸŽ‰

.kodyrc file

The .kodyrc file was mentioned briefly above. It's used to define values and configuration for your tasks. It also has two special keys. Both are optional

  • task_directory - this specifies the location of your tasks relative to your current working directory
  • running_order - this specifies a running order for your tasks

An example .kodyrc

{
  "task_directory": "./awesome-tasks",
  "running_order": [
    "b",
    "a",
    "*"
  ],
  "brewInstalls": [
    "google-chrome",
    "visual-studio-code"
  ],
}

In this .kodyrc file we specify that tasks are under ./awesome-tasks. We also state that tasks run in any order but b must run before a. It's important to note that running order entries are task file names and not the name of the task. The extension is not necessary.

Any other keys in the .kodyrc file are user defined and made available in any tasks you write/use. In this example, we have brewInstalls which could be an array of homebrew casks to install.

A real task

For a real task example, let's install Homebrew.

const { info } = console
const HOMEBREW_URL =
  'https://raw.githubusercontent.com/Homebrew/install/master/install'
const task = {
  name: 'Homebrew',
  description: 'Install and set up Homebrew',
  exec: function(resolve, reject, shell, config, log) {
    const { brew_installs: packages } = config
    const brewInstalled = shell.which('brew') !== null
    if (!brewInstalled) {
      try {
        info(log('Installing Homebrew'))
        const result = shell.exec(`ruby -e "$(curl -fsSL ${PROPS.URL})"`)
        if (result.code !== 0) throw new Error(result.stderr)
        else info(log('Homebrew installed'))
      } catch (err) {
        throw new Error(err)
      }
    } else info(log('Homebrew already installed'))
    info(log('Running brew doctor'))
    shell.exec('brew doctor')
    info(
      log(
        `NOTE: Any info from brew doctor may account for any issues with package installs`
      )
    )
    if (packages && packages.length > 0) {
      info(log(`Installing ${packages.join(' ')}`))
      shell.exec(`brew install ${packages.join(' ')}`)
      info(log('Brew packages installed'))
    } else {
      info(log('No brew packages to install'))
    }
    resolve()
  },
}

module.exports = task

It may look like there's a lot going on here. But the majority of this is actually logging to the console πŸ˜…

Tasks that have already been created

  • Set up git
  • Write OSX defaults
  • Install and set up Homebrew
  • Install programs supported by brew cask such as Spotify, Chrome, etc.
  • Set up fish shell
  • Set up oh-my-zsh
  • Install Atom IDE packages
  • Install and set up Visual Studio Code
  • Remove unwanted default system applications

Examples

  • Jhey's .files - My personal kody set up. Sets up IDE, installs programs, configures shell etc.

Development

kody is easy to work on. It uses a self-documented Makefile.

Just run make to see what tasks are available.

First things first is to pull in dependencies with make setup.

Then you'll be wanting to use make develop to start work. Use npm link to get a global instance of what you're working on available in the shell. You can test this by running kody --version.

It's best to create a dummy folder that you can test things out in. This reduces the risk of breaking your $HOME setup.

Enjoy! 😎

Under the hood

kody is written using es6 with babel and is developed using a self-documented Makefile.

Disclaimer

I've only used kody on OSX. I'm not responsible if you bork your machine configuration πŸ˜… However, I'm happy to try and help you out if you get stuck!

Contributing

Any problems or questions, feel free to post an issue or tweet me, @jh3yyy! 🐦


Made with 🐻s by @jh3y 2018

More Repositories

1

whirl

CSS loading animations with minimal effort!
SCSS
1,756
star
2

tyto

manage and organise things
JavaScript
675
star
3

ep

enhance your HTML5 progress bars with minimal effort!
JavaScript
647
star
4

driveway

pure CSS masonry layouts
HTML
632
star
5

vincent-van-git

Use your Github commit history as a canvas!
JavaScript
288
star
6

meanderer

A JavaScript micro-library for responsive CSS motion paths! ✨
JavaScript
223
star
7

sketchbook

The home for all my demo source wherever you may find them! ⚑️
HTML
183
star
8

gulp-boilerplate

a simple gulp boilerplate
JavaScript
146
star
9

doormat

Let's take a scroll!
JavaScript
110
star
10

jh3y

73
star
11

pxl

A React app for drawing pixel art
JavaScript
72
star
12

osaka-card

TypeScript
59
star
13

tips

CSS tooltips!
CSS
47
star
14

jhey.dev

Site source for jhey.dev ✨
JavaScript
47
star
15

a-guide-to-css-animation

Demo code for "A Guide to CSS Animation"
CSS
44
star
16

use-caret-position

A custom React hook for grabbing the caret position in a text input.
JavaScript
37
star
17

parcel-boilerplate

a boilerplate for using Parcel JS 😎
HTML
30
star
18

culr

color search engine
JavaScript
27
star
19

node-cli-boilerplate

a simple boilerplate to get up and running with node cli apps
JavaScript
27
star
20

creatives-directory

A list of creatives to follow on Twitter 🐦
JavaScript
23
star
21

view-transition-sandbox

Sandbox to get creative with the View Transition API
Astro
20
star
22

my-script-kit

JavaScript
20
star
23

move-things-with-css

The accompanying source for "Move Things With CSS"
CSS
20
star
24

focussed-twitter

Let's focus on the tweets! 🐦
JavaScript
17
star
25

subscription-calendar-view-transitions

MPA View Transitions Subscription Calendar
Astro
17
star
26

stationery-cabinet

The repository for the majority of my CodePen creations!
Pug
15
star
27

crayon

a repo for styling CodePen profiles
HTML
14
star
28

deck

Astro
14
star
29

pen-case

A local development boilerplate set up for creating new pens πŸ“
Makefile
12
star
30

sike

a cli app that reminds you to move around every once in a while!
JavaScript
11
star
31

russ

a node scripts runner 🐰
JavaScript
11
star
32

parcel-react-boilerplate

a boilerplate for bundling react applications with Parcel JS
JavaScript
10
star
33

netlify-cms-next-starter

Get up and running with Netlify CMS && Next.js
JavaScript
10
star
34

next-portfolio-starter

A portfolio starting point using Next.js, Netlify CMS, Storybook, and Tailwind
JavaScript
9
star
35

kody_env

My personal settings for kody .files manager
Shell
9
star
36

serverless-og

JavaScript
9
star
37

whac-a-mole-react

JavaScript
9
star
38

dynamic-island

An Astro playground for building a "Dynamic Island" for your site
CSS
9
star
39

round-table

CSS
8
star
40

egghead

a home for my egghead material source πŸ₯š
HTML
7
star
41

campfire

CSS
6
star
42

shooting-stars

HTML5 Canvas play around to create shooting stars effect
JavaScript
6
star
43

houdini-tesla

A CSS Houdini PaintWorklet for Tesla Coils
JavaScript
5
star
44

create-bangle-app

create and develop bangle.js apps from the command line
JavaScript
5
star
45

houdini-noise

CSS Houdini PaintWorklet for background noise
JavaScript
4
star
46

color-image-search-api

JavaScript
4
star
47

astro-mpa-bars

Quick POC for Astro Page Stinger View Transitions
TypeScript
4
star
48

which-key

an app for grabbing JavaScript KeyboardEvent info!
JavaScript
4
star
49

blurbs

Write something about me!
3
star
50

testPlayground

a repo for examples on how to set up mocha
JavaScript
3
star
51

jheymote

Audience remote for Jhey's conference talks
JavaScript
3
star
52

storybook-addon-studybook

Spin your Storybook into a learning aid with trackable progress.
JavaScript
3
star
53

key-book

create frozen enum objects from a string array ❄️
JavaScript
3
star
54

electron-parcel-react-starter

A starter project using Electron, React, and Parcel
JavaScript
3
star
55

border-radius-playground

An interactive visualisation tool for becoming a wizard with border-radius ✨
JavaScript
3
star
56

feedy

an angular app for consuming public photo feeds
JavaScript
3
star
57

inspector-gamut

A POC app for using AI to generate color palettes based on keywords
TypeScript
3
star
58

ng-mega-table

A directive for handling mega data
JavaScript
2
star
59

green-blocks

A Github Activity Visualizer Built with Next.js, React-Three-Fiber, Netlify, Tailwind, and GSAP
JavaScript
2
star
60

react-waves

A React component for making those fancy animated waves!
JavaScript
2
star
61

corvid

interactive command line Github API browser and cloning aid
JavaScript
2
star
62

blokky-road

3D CSS studio built with React on Vite
JavaScript
2
star
63

blink

JavaScript
2
star
64

fusion-hn

Hacker News example app built w/ Fusion JS
JavaScript
2
star
65

html5-boilerplate-jade-less-livereload.docpad

A skeleton for docpad using html5 boilerplate, less and jade.
CoffeeScript
1
star
66

interactive-twitch-overlay

Interactive Twitch Overlays Built with Tailwind && Next.js
JavaScript
1
star
67

sticky

A configurable sticky note component.
JavaScript
1
star
68

nodivember

CSS
1
star
69

blok-party

JavaScript
1
star
70

og-generator

A CLI tool for generating jh3y cover assets.
JavaScript
1
star
71

clinic

Submit your questions and issues for the clinic!
1
star
72

jheytompkins.com

source for
JavaScript
1
star
73

pencil-sharpener

Repo for storing my CodePen profile styling
HTML
1
star
74

next-storyblok-playground

JavaScript
1
star
75

gulp-template-store

a gulp plugin for storing lodash templates in a namespace object
JavaScript
1
star