12 Commits

Author SHA1 Message Date
Allyedge
48990d5732 v0.1.2 changelog 2022-06-06 10:50:23 +02:00
Allyedge
d60da9fd3b v0.1.2 2022-06-06 10:43:47 +02:00
Allyedge
9cead56a35 feat: add extra command 2022-06-06 10:43:23 +02:00
Allyedge
e9560e8874 refactor: revert back to v0.1.1 2022-06-06 10:20:38 +02:00
EvolutionX
336d31a16d ci: update import gpg version 2022-06-05 10:26:29 +05:30
EvolutionX
dbe56fa8d9 ci: final edit release.yml 2022-06-05 10:21:12 +05:30
EvolutionX
5bc0ac68bd ci: update .goreleaser.yml 2022-06-05 10:11:57 +05:30
EvolutionX
c43f6c5a31 fix(ci): updated configuration of go releaser 2022-06-05 09:02:06 +05:30
EvolutionX
c648e0560b chore: release 0.1.2 2022-06-04 23:41:50 +05:30
EvolutionX
b9286cb45a ci: signing builds 2022-06-04 23:36:15 +05:30
Allyedge
5d7dd98c45 feat: update CLI version command 2022-06-03 13:57:49 +02:00
Evo
60aa5263a3 docs(changelog): remove standard-version 2022-06-03 10:14:19 +05:30
13 changed files with 167 additions and 38 deletions

View File

@@ -18,13 +18,14 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Fetch all tags
run: git fetch --force --tags
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
id: go
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2

View File

@@ -1,6 +1,14 @@
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
All notable changes to this project will be documented in this file.
## 0.1.2 (2022-06-04)
The `extra` command was added. It basically helps developers to add things like Dockerfile to their projects with ease.
### Features
- `extra` command
## 0.1.1 (2022-06-02)

View File

@@ -2,10 +2,12 @@
[![Go](https://img.shields.io/badge/go-%2300ADD8.svg?style=for-the-badge&logo=go&logoColor=white)](https://github.com/sern-handler/cli)
[![Build](https://img.shields.io/github/workflow/status/sern-handler/cli/goreleaser?style=for-the-badge)](https://github.com/sern-handler/cli)
[![NPM](https://img.shields.io/npm/dt/@sern/cli?style=for-the-badge)](https://npmjs.com/@sern/cli)
Our CLI allows you to setup and manage Discord bot projects without writing a single line of code!
😁 **User Friendly** <br>
🔥 **Fast** <br>
💦 **Simple** <br>
🌱 **Efficient** <br>
💪 **Powerful** <br>

15
cmd/cli/extra.go Normal file
View File

@@ -0,0 +1,15 @@
package cli
import (
"github.com/sern-handler/cli/pkg/extra"
"github.com/spf13/cobra"
)
var extraCmd = &cobra.Command{
Use: "extra",
Short: "Add extra tools to your Sern project.",
Long: `Add extra tools to your Sern project to help you with the setup and development.`,
Run: func(cmd *cobra.Command, args []string) {
extra.Execute()
},
}

View File

@@ -10,9 +10,9 @@ import (
var rootCmd = &cobra.Command{
Use: "sern",
Short: "A powerful CLI tool for Sern.",
Version: "0.1.0",
Version: "0.1.2",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Sern CLI")
cmd.Help()
},
}
@@ -21,6 +21,7 @@ func Execute() {
rootCmd.Flags().BoolP("version", "v", false, "The version of the Sern CLI.")
rootCmd.SetVersionTemplate("Sern CLI - Version {{.Version}}\n")
rootCmd.AddCommand(initCmd)
rootCmd.AddCommand(extraCmd)
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)

32
package-lock.json generated
View File

@@ -1,32 +0,0 @@
{
"name": "@sern/cli",
"version": "0.1.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@sern/cli",
"version": "0.1.0",
"hasInstallScript": true,
"license": "MIT",
"dependencies": {
"@gzuidhof/go-npm": "^0.1.13"
}
},
"node_modules/@gzuidhof/go-npm": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/@gzuidhof/go-npm/-/go-npm-0.1.13.tgz",
"integrity": "sha512-45nOc+/Elll2f1xrFQU7rrpcpl1AIPgi3x04sGizbUUdtyreM8v2QFcpr5gACfYxt9P9wXPShIMXjve1C406Rg==",
"bin": {
"go-npm": "bin/index.js"
}
}
},
"dependencies": {
"@gzuidhof/go-npm": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/@gzuidhof/go-npm/-/go-npm-0.1.13.tgz",
"integrity": "sha512-45nOc+/Elll2f1xrFQU7rrpcpl1AIPgi3x04sGizbUUdtyreM8v2QFcpr5gACfYxt9P9wXPShIMXjve1C406Rg=="
}
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@sern/cli",
"version": "0.1.1",
"version": "0.1.2",
"description": "Our CLI allows you to setup and manage Discord bot projects without writing a single line of code!",
"scripts": {
"postinstall": "go-npm install",

34
pkg/extra/docker.go Normal file
View File

@@ -0,0 +1,34 @@
package extra
import (
"os"
"github.com/gookit/color"
"github.com/sern-handler/cli/pkg/util"
)
func addDockerfile() error {
var dockerfile string
_, err := os.Stat("tsconfig.json")
if err != nil {
dockerfile = "Dockerfile.js"
} else {
dockerfile = "Dockerfile.ts"
}
color.Info.Prompt("Adding Dockerfile...")
err = util.CopyFile("templates/extra/"+dockerfile, "Dockerfile")
if err != nil {
color.Error.Prompt("Couldn't add the Dockerfile, exiting.")
return err
}
color.Info.Prompt("Successfully added the Dockerfile.")
return nil
}

33
pkg/extra/extra.go Normal file
View File

@@ -0,0 +1,33 @@
package extra
import (
"os"
"github.com/AlecAivazis/survey/v2"
"github.com/gookit/color"
)
func Execute() {
answers := struct {
Extra string
}{}
err := survey.Ask(questions, &answers)
if err != nil {
color.Error.Prompt("Adding extras failed, exiting.")
os.Exit(1)
}
switch answers.Extra {
case "Dockerfile":
err = addDockerfile()
if err != nil {
color.Error.Prompt("Adding the Dockerfile failed, exiting.")
os.Exit(1)
}
}
}

13
pkg/extra/questions.go Normal file
View File

@@ -0,0 +1,13 @@
package extra
import "github.com/AlecAivazis/survey/v2"
var questions = []*survey.Question{
{
Name: "extra",
Prompt: &survey.Select{
Message: "What extra do you want to add?",
Options: []string{"Dockerfile"},
},
},
}

View File

@@ -1,6 +1,10 @@
package util
import "os/exec"
import (
"io"
"os"
"os/exec"
)
type PackageManagers struct {
NPM bool
@@ -27,3 +31,29 @@ func CheckPackageManagers() PackageManagers {
return packageManagers
}
func CopyFile(src, dst string) error {
in, err := os.Open(src)
if err != nil {
return err
}
defer in.Close()
out, err := os.Create(dst)
if err != nil {
return err
}
defer out.Close()
_, err = io.Copy(out, in)
if err != nil {
return err
}
return out.Close()
}

View File

@@ -0,0 +1,11 @@
FROM node:latest
WORKDIR /app
COPY package.json ./
RUN npm install
COPY . .
RUN node src/index.js

View File

@@ -0,0 +1,13 @@
FROM node:latest
WORKDIR /app
COPY package.json ./
RUN npm install
COPY . .
RUN tsc --build
RUN node dist/index.js