Skip to content

Commit

Permalink
chore: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
technikhil314 committed Mar 23, 2022
1 parent bd92a38 commit 94e5831
Show file tree
Hide file tree
Showing 13 changed files with 221 additions and 99 deletions.
35 changes: 0 additions & 35 deletions .github/workflows/publish_npm.yml

This file was deleted.

29 changes: 14 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,26 @@ on:
- "*"

jobs:
changelog:
release:
runs-on: ubuntu-latest
name: create release on tag
name: create release and publish brew formula

steps:
- uses: actions/checkout@v2

# This action generates changelog which then the release action consumes
- name: Conventional Changelog Action
id: changelog
uses: TriPSs/conventional-changelog-action@v3
- name: Set up Go 1.18
uses: actions/setup-go@v2
with:
github-token: ${{ secrets.github_token }}
skip-commit: 'true'
go-version: 1.18
id: go

- name: Create Release
uses: actions/create-release@v1
if: ${{ steps.changelog.outputs.skipped == 'false' }}
- name: Install goreleaser
env:
GO111MODULE: on
run: go install github.com/goreleaser/goreleaser@latest

- name: Release using goreleaser
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
with:
tag_name: ${{ steps.changelog.outputs.tag }}
release_name: ${{ steps.changelog.outputs.tag }}
body: ${{ steps.changelog.outputs.clean_changelog }}
run: |
goreleaser release --rm-dist
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,5 @@ dist

# TernJS port file
.tern-port

dist/
47 changes: 47 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
- go mod tidy
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
binary: mono
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
brews:
- name: mono-cli
tap:
owner: technikhil314
name: homebrew-mono-cli
branch: main
download_strategy: CurlDownloadStrategy
commit_author:
name: goreleaser
email: goreleaser@technikhil314.com
commit_msg_template: "Brew formula update for {{ .ProjectName }} version {{ .Tag }}"
folder: Formula
homepage: "https://technikhil314.netlify.app/docs/mono-cli/introduction"
description: "Opinionated command line tool for managing all your project tasks."
license: "MIT"
install: |
bin.install "mono"
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Nikhil Mehta
Copyright (c) 2022-present Nikhil Mehta

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
54 changes: 40 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,50 @@
# 1command
# mono-cli

Project based aliases for streamline your build and development flow.

# Problem

Right now when you are about run/build a new project you have to do the following
Right now to run new project you have to do the following

1. Look for what command starts the dev env
2. Look for what command build the project
3. and so for install dependancies, clean project and many other tasks
1. read the docs just to find what should you run to get your development environment up
2. But over the years dues tools like npm,yarn,maven,gradle the commands have some de-facto standard viz
1. with `npm` you will run `npm start` or `npm run dev`
2. with `maven` you will run `maven start`
3. and so on
3. yet every time you have to read throgh docs to find what command to run which is not good DX

# Solution

1. This cli tries to abstract away the actual commands as these commands are very tightly coupled with the framework or tech stack you are choosing.

# How does it work

1. It tries to detect multiple deciding factors like runtime, package manager, framework, bundler, linter, test runner, test framework
2. Then it runs the default commands for each of mentioned factor like `npm install` or `webpack serve` etc

# Advantages of using mono-cli

1. imagine you have to jump between multiple projects like nextjs, create-react-app, remix.run etc.
2. When you jump from nextjs to create-react-app the command change from `npm run dev` to `npm start`
3. And you have to either recall that or check in the docs
4. With mono-cli you have to remember just the verbs like install, buils, clean, start etc and prefix them with `mono-cli` and you have one command doing same job across projects.
5. mono-cli internally detects things like what runtime, package manager, dev start commands to run and runs those commands on your behalf.
6. See the [usage](#usage) section below to see the commands and their defaults

# installation

# Usage

1. Add this code to your favourite shell init script
2. install 1command using `npm install 1command`
3. and then run following commands for each described task

| command | Purpose | Supports |
| ------- | ---------------------------------- | ---------------------------- |
| install | install dependancies | npm, yarn, pnpn, lerna |
| build | build your project | webpack, vite and frameworks |
| clean | cleans your build directory | webpack, vite and frameworks |
| start | start your development environment | webpack, vite and frameworks |
2. and then run following commands for each described task

| command | Purpose | Supports | Depends on | Default |
| ------------ | ---------------------------------- | ---------------------------- | ------------------------------------------------------ | ------------------------------------------- |
| mono install | install dependancies | npm, yarn, pnpn, lerna | lock files or monorepo config files | if no lock file found then defaults to pnpm |
| mono build | build your project | webpack, vite and frameworks | framework or bundler <br/> config file in project root | defaults to `npm run build` |
| mono clean | cleans your build directory | webpack, vite and frameworks | framework or bundler <br/> config file in project root | defaults to `npm run clean` |
| mono start | start your development environment | webpack, vite and frameworks | framework or bundler <br/> config file in project root | defaults to `npm run start` |

# License

MIT
2 changes: 0 additions & 2 deletions bin/index.js

This file was deleted.

40 changes: 40 additions & 0 deletions cmd/install.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
*/
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

// installCmd represents the install command
var installCmd = &cobra.Command{
Use: "install",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("install called")
},
}

func init() {
rootCmd.AddCommand(installCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// installCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// installCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
47 changes: 47 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
*/
package cmd

import (
"os"

"github.com/spf13/cobra"
)

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "mono",
Short: "A brief description of your application",
Long: `A longer description that spans multiple lines and likely contains
examples and usage of using your application. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
// Uncomment the following line if your bare application
// has an action associated with it:
// Run: func(cmd *cobra.Command, args []string) { },
}

// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}
}

func init() {
// Here you will define your flags and configuration settings.
// Cobra supports persistent flags, which, if defined here,
// will be global for your application.

// rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.mono-cli.yaml)")

// Cobra also supports local flags, which will only run
// when this action is called directly.
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
9 changes: 9 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module github.com/technikhil314/mono-cli

go 1.18

require (
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/spf13/cobra v1.4.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
)
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.4.0 h1:y+wJpx64xcgO1V+RcnwW0LEHxTKRi2ZDPSBjWnrg88Q=
github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
11 changes: 11 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
*/
package main

import "github.com/technikhil314/mono-cli/cmd"

func main() {
cmd.Execute()
}
32 changes: 0 additions & 32 deletions package.json

This file was deleted.

0 comments on commit 94e5831

Please sign in to comment.