mirror of
https://github.com/sern-handler/cli
synced 2026-06-06 09:26:52 +00:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48990d5732 | ||
|
|
d60da9fd3b | ||
|
|
9cead56a35 | ||
|
|
e9560e8874 | ||
|
|
336d31a16d | ||
|
|
dbe56fa8d9 | ||
|
|
5bc0ac68bd | ||
|
|
c43f6c5a31 | ||
|
|
c648e0560b | ||
|
|
b9286cb45a | ||
|
|
5d7dd98c45 | ||
|
|
60aa5263a3 | ||
|
|
a74657d2b1 | ||
|
|
b92bf721c8 | ||
|
|
5864b9f023 |
4
.github/CODEOWNERS
vendored
4
.github/CODEOWNERS
vendored
@@ -1,2 +1,2 @@
|
||||
* @EvolutionX-10
|
||||
* @Allyedge
|
||||
* @Allyedge
|
||||
* @EvolutionX-10
|
||||
36
.github/workflows/codeql-analysis-go.yml
vendored
36
.github/workflows/codeql-analysis-go.yml
vendored
@@ -1,24 +1,12 @@
|
||||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL Go"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ go-rewrite ]
|
||||
branches: [main]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ main ]
|
||||
branches: [main]
|
||||
schedule:
|
||||
- cron: '40 13 * * 2'
|
||||
- cron: "40 13 * * 2"
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
@@ -32,16 +20,16 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'go' ]
|
||||
language: ["go"]
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
|
||||
7
.github/workflows/release.yml
vendored
7
.github/workflows/release.yml
vendored
@@ -7,8 +7,8 @@ on:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
# packages: write
|
||||
# issues: write
|
||||
packages: write
|
||||
issues: write
|
||||
|
||||
jobs:
|
||||
goreleaser:
|
||||
@@ -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
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
.github/
|
||||
20
CHANGELOG.md
20
CHANGELOG.md
@@ -1,6 +1,24 @@
|
||||
# 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)
|
||||
|
||||
The `go-npm` package was replaced by one of its forks, `@gzuidhof/go-npm`.
|
||||
|
||||
`@gzuidhof/go-npm` has updated dependencies, and it uses `esbuild`, which is great.
|
||||
|
||||
### Changes
|
||||
|
||||
- Replace `go-npm` with `@gzuidhof/go-npm`.
|
||||
|
||||
## 0.1.0 (2022-06-02)
|
||||
|
||||
|
||||
25
README.md
25
README.md
@@ -1,12 +1,21 @@
|
||||
# Sern CLI
|
||||
|
||||
[](https://github.com/sern-handler/cli)
|
||||
[](https://github.com/sern-handler/cli)
|
||||
[](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>
|
||||
|
||||
## License
|
||||
|
||||
[](https://github.com/sern-handler/cli)
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
@@ -29,7 +38,21 @@ When you install the CLI, you can use our commands with **sern** prefix.
|
||||
|
||||
## Setting Up Your Project
|
||||
|
||||
#### TODO
|
||||
To create a new project, you can simply run the following command:
|
||||
|
||||
```sh
|
||||
sern init
|
||||
```
|
||||
|
||||
The `init` command will ask you some questions and at the end it will generate a new project.
|
||||
|
||||
## Help
|
||||
|
||||
If you need help, you can always run the following command:
|
||||
|
||||
```sh
|
||||
sern help
|
||||
```
|
||||
|
||||
## Stats
|
||||
|
||||
|
||||
15
cmd/cli/extra.go
Normal file
15
cmd/cli/extra.go
Normal 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()
|
||||
},
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
1089
package-lock.json
generated
1089
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
14
package.json
14
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@sern/cli",
|
||||
"version": "0.1.0",
|
||||
"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",
|
||||
@@ -10,6 +10,9 @@
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sern-handler/cli.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"@gzuidhof/go-npm": "^0.1.13"
|
||||
},
|
||||
"keywords": [
|
||||
"sern",
|
||||
"cli",
|
||||
@@ -18,17 +21,14 @@
|
||||
"discord.js"
|
||||
],
|
||||
"contributors": [
|
||||
"EvolutionX-10",
|
||||
"Allyedge"
|
||||
"Allyedge",
|
||||
"EvolutionX-10"
|
||||
],
|
||||
"license": "ISC",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/sern-handler/cli/issues"
|
||||
},
|
||||
"homepage": "https://github.com/sern-handler/cli#readme",
|
||||
"dependencies": {
|
||||
"go-npm": "^0.1.9"
|
||||
},
|
||||
"goBinary": {
|
||||
"name": "sern",
|
||||
"path": "./bin",
|
||||
|
||||
34
pkg/extra/docker.go
Normal file
34
pkg/extra/docker.go
Normal 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
33
pkg/extra/extra.go
Normal 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
13
pkg/extra/questions.go
Normal 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"},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
11
templates/extra/Dockerfile.js
Normal file
11
templates/extra/Dockerfile.js
Normal file
@@ -0,0 +1,11 @@
|
||||
FROM node:latest
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json ./
|
||||
|
||||
RUN npm install
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN node src/index.js
|
||||
13
templates/extra/Dockerfile.ts
Normal file
13
templates/extra/Dockerfile.ts
Normal 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
|
||||
Reference in New Issue
Block a user