mirror of
https://github.com/sern-handler/cli
synced 2026-06-06 17:36:53 +00:00
Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ba16b494c | ||
|
|
d35cb828fb | ||
|
|
ae3725587d | ||
|
|
885045a041 | ||
|
|
54a3e6e42c | ||
|
|
eb85a7a8f2 | ||
|
|
e86e3a7e67 | ||
|
|
e3a7d1a28c | ||
|
|
82dd9e7141 | ||
|
|
055da6c24d | ||
|
|
3bd262739f | ||
|
|
805543e1a3 | ||
|
|
7e65f3e5c3 | ||
|
|
93e17be8c7 | ||
|
|
514a56fde4 | ||
|
|
895a48910e | ||
|
|
7cf62c0308 | ||
|
|
3eb63835d9 | ||
|
|
e78cb552da | ||
|
|
f650171030 | ||
|
|
b2e6236dde | ||
|
|
09a9b68b65 | ||
|
|
67a0efd1c2 | ||
|
|
310c82f24e | ||
|
|
b1a8683373 |
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
@@ -1,2 +1 @@
|
||||
* @Allyedge
|
||||
* @EvolutionX-10
|
||||
35
.github/workflows/codeql-analysis-go.yml
vendored
35
.github/workflows/codeql-analysis-go.yml
vendored
@@ -1,35 +0,0 @@
|
||||
name: "CodeQL Go"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
schedule:
|
||||
- cron: "40 13 * * 2"
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: ["go"]
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
65
.github/workflows/codeql-analysis.yml
vendored
Normal file
65
.github/workflows/codeql-analysis.yml
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
# 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"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ main ]
|
||||
schedule:
|
||||
- cron: '40 13 * * 2'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'javascript' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
||||
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
40
.github/workflows/continuous-delivery.yml
vendored
Normal file
40
.github/workflows/continuous-delivery.yml
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
name: Continuous Delivery
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
Build:
|
||||
name: Building
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # tag=v3
|
||||
with:
|
||||
node-version: 17
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Install Node.js dependencies
|
||||
run: npm i
|
||||
|
||||
- name: Link Project
|
||||
run: npm link
|
||||
|
||||
- name: Test Sern
|
||||
run: sern
|
||||
|
||||
Publish:
|
||||
name: Publishing to npm
|
||||
runs-on: ubuntu-latest
|
||||
needs: [Build]
|
||||
steps:
|
||||
- name: Publish to npm
|
||||
run: npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
54
.github/workflows/continuous-integration.yml
vendored
Normal file
54
.github/workflows/continuous-integration.yml
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
name: Continuous Integration
|
||||
|
||||
on:
|
||||
# Trigger the workflow on push or pull request,
|
||||
# but only for the main branch
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request_target:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
Lint:
|
||||
name: Linting
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # tag=v3
|
||||
with:
|
||||
node-version: 17
|
||||
|
||||
# Prettier must be in `package.json`
|
||||
- name: Install Node.js dependencies
|
||||
run: npm i
|
||||
|
||||
- name: Run Prettier
|
||||
run: npm run format
|
||||
|
||||
Test:
|
||||
name: Testing
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # tag=v3
|
||||
with:
|
||||
node-version: 17
|
||||
|
||||
- name: Install Node.js dependencies
|
||||
run: npm i
|
||||
|
||||
- name: Link Project
|
||||
run: npm link
|
||||
|
||||
- name: Test Sern
|
||||
run: sern
|
||||
35
.github/workflows/release.yml
vendored
35
.github/workflows/release.yml
vendored
@@ -1,35 +0,0 @@
|
||||
name: goreleaser
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "*"
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
issues: write
|
||||
|
||||
jobs:
|
||||
goreleaser:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
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
|
||||
with:
|
||||
version: latest
|
||||
args: release --rm-dist
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
118
.gitignore
vendored
118
.gitignore
vendored
@@ -1 +1,117 @@
|
||||
node_modules
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Editor Files
|
||||
.vscode
|
||||
.idea
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
.env.development.local
|
||||
.env.development
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and *not* Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Extras
|
||||
.vscode/
|
||||
|
||||
# Yarn files
|
||||
.yarn/install-state.gz
|
||||
.yarn/build-state.yml
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
builds:
|
||||
- binary: sern
|
||||
goos:
|
||||
- windows
|
||||
- darwin
|
||||
- linux
|
||||
goarch:
|
||||
- amd64
|
||||
main: ./cmd
|
||||
2
.prettierignore
Normal file
2
.prettierignore
Normal file
@@ -0,0 +1,2 @@
|
||||
.github/
|
||||
CHANGELOG.md
|
||||
5
.prettierrc
Normal file
5
.prettierrc
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"tabWidth": 4,
|
||||
"useTabs": true,
|
||||
"singleQuote": true
|
||||
}
|
||||
65
CHANGELOG.md
65
CHANGELOG.md
@@ -2,22 +2,57 @@
|
||||
|
||||
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.
|
||||
|
||||
## 0.1.1 (2022-06-02)
|
||||
## [0.2.0](https://github.com/sern-handler/cli/compare/v0.1.3...v0.2.0) (2022-06-22)
|
||||
|
||||
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)
|
||||
|
||||
This is the CLI's initial release.
|
||||
|
||||
### Features
|
||||
|
||||
- `init` command
|
||||
- `help` command
|
||||
- `version` command
|
||||
* add `sern.config.json` ([#38](https://github.com/sern-handler/cli/issues/38)) ([3eb6383](https://github.com/sern-handler/cli/commit/3eb63835d9f6ff3f3426e017ea87344c00bb13a4))
|
||||
* add basic type checking ([eb85a7a](https://github.com/sern-handler/cli/commit/eb85a7a8f2f6252f719fd396d42cded2d9eb0918))
|
||||
* add commander and start plugins installer ([#36](https://github.com/sern-handler/cli/issues/36)) ([b2e6236](https://github.com/sern-handler/cli/commit/b2e6236dde6f4848dde6fc23a6222415824bb294))
|
||||
* enable extra command & jsdockerfile ([#43](https://github.com/sern-handler/cli/issues/43)) ([7cf62c0](https://github.com/sern-handler/cli/commit/7cf62c03083b8ebbb8a6a63fd8efe592344d5230))
|
||||
* plugin command!!! ([#45](https://github.com/sern-handler/cli/issues/45)) ([895a489](https://github.com/sern-handler/cli/commit/895a48910e32813f8aa25f57302a4123fc631c2c))
|
||||
|
||||
### [0.1.3](https://github.com/sern-handler/cli/compare/v0.1.2...v0.1.3) (2022-06-10)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add default settings for the -y flag ([#19](https://github.com/sern-handler/cli/issues/19)) ([e5f607e](https://github.com/sern-handler/cli/commit/e5f607e99875e105cbb148cab3ed1bbc3771ae35))
|
||||
* Added version command & created readme ([#25](https://github.com/sern-handler/cli/issues/25)) ([7535a5e](https://github.com/sern-handler/cli/commit/7535a5e0267c9e682b7bc8470206c0597f5ba9a1))
|
||||
* create typescript dockerfile and the extra command ([#28](https://github.com/sern-handler/cli/issues/28)) ([b1a8683](https://github.com/sern-handler/cli/commit/b1a86833734258e0a22da18c2c780133c199d5cd))
|
||||
* now edits the directories as per user's choice ([fec1c8e](https://github.com/sern-handler/cli/commit/fec1c8e24c5ca7752f9e74b0fc3a32716bb42299))
|
||||
* **skip:** option to skip package manager selection ([#20](https://github.com/sern-handler/cli/issues/20)) ([7b1d535](https://github.com/sern-handler/cli/commit/7b1d53520f0aa35e48b72d61d2f1a85ffdfdfec8))
|
||||
* using degit to clone the templates ([ddb0285](https://github.com/sern-handler/cli/commit/ddb02850f2096d8c9ec36e766ea74e10d2efce3f))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix degit erroring when there's no cache ([fc01554](https://github.com/sern-handler/cli/commit/fc01554fae2726f4ebd39a66ef1cb634a421dd9f))
|
||||
* **install.js:** fix mistyped. cached -> cache ([fa68936](https://github.com/sern-handler/cli/commit/fa689360ce054c63dab77e8b8f0b794b3b8736e4))
|
||||
* no more crashing cli if yarn isnt present ([#24](https://github.com/sern-handler/cli/issues/24)) ([88893a3](https://github.com/sern-handler/cli/commit/88893a35cd1144867713de32c5bf52c2dc702450))
|
||||
* no more error when selecting js ([cc410bd](https://github.com/sern-handler/cli/commit/cc410bd370a751833dbc5fc04030bfa53a6c1fd2))
|
||||
|
||||
### [0.1.1](https://github.com/sern-handler/cli/compare/v0.1.0...v0.1.1) (2022-05-09)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* added help command ([ca23d17](https://github.com/sern-handler/cli/commit/ca23d17670663b62e23849e2350deef208bfc100))
|
||||
* cli is now functional ([5021d28](https://github.com/sern-handler/cli/commit/5021d28bca6ebe1cb4a548f5e595b1220f222c98))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* prettier things ([1265224](https://github.com/sern-handler/cli/commit/1265224bb9f93cb104915be50c1c2ea1e3924955))
|
||||
* removed useless line ([f268b1c](https://github.com/sern-handler/cli/commit/f268b1c62fd4d5823d483a33cfef2e2d7f7b127c))
|
||||
|
||||
## 0.1.0 (2022-04-21)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* added actions and formatting stuff ([b302a8b](https://github.com/sern-handler/cli/commit/b302a8b362257fb2cea72b7e1fc66bea351c511f))
|
||||
* bump all files to GitHub 🎉 ([01b39ad](https://github.com/sern-handler/cli/commit/01b39ad9b78f0a67e23ba66c10262082675eeed5))
|
||||
* more questions, better handling, better ui ([f931802](https://github.com/sern-handler/cli/commit/f9318024bb4c62cee1a7ddfc6af4117c22ca6020))
|
||||
* refactored code and added custom handling of commands ([0e97b7d](https://github.com/sern-handler/cli/commit/0e97b7db8afed7f625eeb0a43aa992441ab49b39))
|
||||
|
||||
25
README.md
25
README.md
@@ -1,8 +1,5 @@
|
||||
# Sern CLI
|
||||
|
||||
[](https://github.com/sern-handler/cli)
|
||||
[](https://github.com/sern-handler/cli)
|
||||
|
||||
Our CLI allows you to setup and manage Discord bot projects without writing a single line of code!
|
||||
|
||||
😁 **User Friendly** <br>
|
||||
@@ -10,10 +7,6 @@ Our CLI allows you to setup and manage Discord bot projects without writing a si
|
||||
🌱 **Efficient** <br>
|
||||
💪 **Powerful** <br>
|
||||
|
||||
## License
|
||||
|
||||
[](https://github.com/sern-handler/cli)
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
@@ -36,22 +29,8 @@ When you install the CLI, you can use our commands with **sern** prefix.
|
||||
|
||||
## Setting Up Your Project
|
||||
|
||||
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
|
||||
```
|
||||
#### TODO
|
||||
|
||||
## Stats
|
||||
|
||||

|
||||

|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"github.com/sern-handler/cli/pkg/initialize"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var initCmd = &cobra.Command{
|
||||
Use: "init",
|
||||
Short: "Initialize a new Sern project.",
|
||||
Long: `Initialize a new Sern project, either with a JavaScript or a TypeScript template.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
initialize.Initialize()
|
||||
},
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "sern",
|
||||
Short: "A powerful CLI tool for Sern.",
|
||||
Version: "0.1.0",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("Sern CLI")
|
||||
},
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
rootCmd.Flags().BoolP("help", "h", false, "Help for the Sern CLI.")
|
||||
rootCmd.Flags().BoolP("version", "v", false, "The version of the Sern CLI.")
|
||||
rootCmd.SetVersionTemplate("Sern CLI - Version {{.Version}}\n")
|
||||
rootCmd.AddCommand(initCmd)
|
||||
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package main
|
||||
|
||||
import "github.com/sern-handler/cli/cmd/cli"
|
||||
|
||||
func main() {
|
||||
cli.Execute()
|
||||
}
|
||||
99
dumpfiles.js
Normal file
99
dumpfiles.js
Normal file
@@ -0,0 +1,99 @@
|
||||
//! Message for Sern CLI developers. Please ignore this file.
|
||||
|
||||
const SpinnerName = [
|
||||
'dots',
|
||||
'dots2',
|
||||
'dots3',
|
||||
'dots4',
|
||||
'dots5',
|
||||
'dots6',
|
||||
'dots7',
|
||||
'dots8',
|
||||
'dots9',
|
||||
'dots10',
|
||||
'dots11',
|
||||
'dots12',
|
||||
'dots8Bit',
|
||||
'line',
|
||||
'line2',
|
||||
'pipe',
|
||||
'simpleDots',
|
||||
'simpleDotsScrolling',
|
||||
'star',
|
||||
'star2',
|
||||
'flip',
|
||||
'hamburger',
|
||||
'growVertical',
|
||||
'growHorizontal',
|
||||
'balloon',
|
||||
'balloon2',
|
||||
'noise',
|
||||
'bounce',
|
||||
'boxBounce',
|
||||
'boxBounce2',
|
||||
'triangle',
|
||||
'arc',
|
||||
'circle',
|
||||
'squareCorners',
|
||||
'circleQuarters',
|
||||
'circleHalves',
|
||||
'squish',
|
||||
'toggle',
|
||||
'toggle2',
|
||||
'toggle3',
|
||||
'toggle4',
|
||||
'toggle5',
|
||||
'toggle6',
|
||||
'toggle7',
|
||||
'toggle8',
|
||||
'toggle9',
|
||||
'toggle10',
|
||||
'toggle11',
|
||||
'toggle12',
|
||||
'toggle13',
|
||||
'arrow',
|
||||
'arrow2',
|
||||
'arrow3',
|
||||
'bouncingBar',
|
||||
'bouncingBall',
|
||||
'smiley',
|
||||
'monkey',
|
||||
'hearts',
|
||||
'clock',
|
||||
'earth',
|
||||
'material',
|
||||
'moon',
|
||||
'runner',
|
||||
'pong',
|
||||
'shark',
|
||||
'dqpb',
|
||||
'weather',
|
||||
'christmas',
|
||||
'grenade',
|
||||
'point',
|
||||
'layer',
|
||||
'betaWave',
|
||||
'fingerDance',
|
||||
'fistBump',
|
||||
'soccerHeader',
|
||||
'mindblown',
|
||||
'speaker',
|
||||
'orangePulse',
|
||||
'bluePulse',
|
||||
'orangeBluePulse',
|
||||
'timeTravel',
|
||||
'aesthetic',
|
||||
];
|
||||
|
||||
// const p = new Promise((resolve) => {
|
||||
// SpinnerName.forEach((spin, i, ar) => {
|
||||
// setTimeout(() => {
|
||||
// spinner.spinner = spin;
|
||||
// spinner.text = `Initializing... ${spin}`;
|
||||
// if (i === ar.length - 1) {
|
||||
// resolve();
|
||||
// }
|
||||
// }, i * 1000);
|
||||
// });
|
||||
// });
|
||||
// p.then(() => spinner.succeed('Finished!'));
|
||||
38
go.mod
38
go.mod
@@ -1,38 +0,0 @@
|
||||
module github.com/sern-handler/cli
|
||||
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/AlecAivazis/survey/v2 v2.3.4
|
||||
github.com/go-git/go-git/v5 v5.4.2
|
||||
github.com/gookit/color v1.5.0
|
||||
github.com/spf13/cobra v1.4.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/Microsoft/go-winio v0.4.16 // indirect
|
||||
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 // indirect
|
||||
github.com/acomagu/bufpipe v1.0.3 // indirect
|
||||
github.com/emirpasic/gods v1.12.0 // indirect
|
||||
github.com/go-git/gcfg v1.5.0 // indirect
|
||||
github.com/go-git/go-billy/v5 v5.3.1 // indirect
|
||||
github.com/imdario/mergo v0.3.12 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
|
||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
|
||||
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect
|
||||
github.com/mattn/go-colorable v0.1.2 // indirect
|
||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/sergi/go-diff v1.1.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/xanzy/ssh-agent v0.3.0 // indirect
|
||||
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
|
||||
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b // indirect
|
||||
golang.org/x/net v0.0.0-20210326060303-6b1517762897 // indirect
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
|
||||
golang.org/x/term v0.0.0-20210503060354-a79de5458b56 // indirect
|
||||
golang.org/x/text v0.3.3 // indirect
|
||||
gopkg.in/warnings.v0 v0.1.2 // indirect
|
||||
)
|
||||
136
go.sum
136
go.sum
@@ -1,136 +0,0 @@
|
||||
github.com/AlecAivazis/survey/v2 v2.3.4 h1:pchTU9rsLUSvWEl2Aq9Pv3k0IE2fkqtGxazskAMd9Ng=
|
||||
github.com/AlecAivazis/survey/v2 v2.3.4/go.mod h1:hrV6Y/kQCLhIZXGcriDCUBtB3wnN7156gMXJ3+b23xM=
|
||||
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
|
||||
github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk=
|
||||
github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0=
|
||||
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63nhn5WAunQHLTznkw5W8b1Xc0dNjp83s=
|
||||
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w=
|
||||
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 h1:YoJbenK9C67SkzkDfmQuVln04ygHj3vjZfd9FL+GmQQ=
|
||||
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=
|
||||
github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk=
|
||||
github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4=
|
||||
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=
|
||||
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
|
||||
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
|
||||
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI=
|
||||
github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
|
||||
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
|
||||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
|
||||
github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
|
||||
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
|
||||
github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4=
|
||||
github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E=
|
||||
github.com/go-git/go-billy/v5 v5.2.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
|
||||
github.com/go-git/go-billy/v5 v5.3.1 h1:CPiOUAzKtMRvolEKw+bG1PLRpT7D3LIs3/3ey4Aiu34=
|
||||
github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
|
||||
github.com/go-git/go-git-fixtures/v4 v4.2.1 h1:n9gGL1Ct/yIw+nfsfr8s4+sbhT+Ncu2SubfXjIWgci8=
|
||||
github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0=
|
||||
github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4=
|
||||
github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc=
|
||||
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/gookit/color v1.5.0 h1:1Opow3+BWDwqor78DcJkJCIwnkviFi+rrOANki9BUFw=
|
||||
github.com/gookit/color v1.5.0/go.mod h1:43aQb+Zerm/BWh2GnrgOQm7ffz7tvQXEKV6BFMl7wAo=
|
||||
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec h1:qv2VnGeEQHchGaZ/u7lxST/RaJw+cv273q79D81Xbog=
|
||||
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68=
|
||||
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
|
||||
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
|
||||
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
|
||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
|
||||
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
|
||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
|
||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
|
||||
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck=
|
||||
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A=
|
||||
github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA=
|
||||
github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU=
|
||||
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
|
||||
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
|
||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
|
||||
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
||||
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
||||
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=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI=
|
||||
github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0=
|
||||
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8=
|
||||
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=
|
||||
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b h1:7mWr3k41Qtv8XlltBkDkl8LoP3mpSgBW8BUoxtEdbXg=
|
||||
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210326060303-6b1517762897 h1:KrsHThm5nFk34YtATK1LsThyGhGbGe1olrte/HInHvs=
|
||||
golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210503060354-a79de5458b56 h1:b8jxX3zqjpqb2LklXPzKSGJhzyxCOZSz8ncv8Nv+y7w=
|
||||
golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY=
|
||||
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
|
||||
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
7260
package-lock.json
generated
7260
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
89
package.json
89
package.json
@@ -1,37 +1,56 @@
|
||||
{
|
||||
"name": "@sern/cli",
|
||||
"version": "0.1.1",
|
||||
"description": "Our CLI allows you to setup and manage Discord bot projects without writing a single line of code!",
|
||||
"scripts": {
|
||||
"postinstall": "go-npm install",
|
||||
"preuninstall": "go-npm uninstall"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sern-handler/cli.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"@gzuidhof/go-npm": "^0.1.13"
|
||||
},
|
||||
"keywords": [
|
||||
"sern",
|
||||
"cli",
|
||||
"discord",
|
||||
"bot",
|
||||
"discord.js"
|
||||
],
|
||||
"contributors": [
|
||||
"Allyedge",
|
||||
"EvolutionX-10"
|
||||
],
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/sern-handler/cli/issues"
|
||||
},
|
||||
"homepage": "https://github.com/sern-handler/cli#readme",
|
||||
"goBinary": {
|
||||
"name": "sern",
|
||||
"path": "./bin",
|
||||
"url": "https://github.com/sern-handler/cli/releases/download/v{{version}}/cli_{{version}}_{{platform}}_{{arch}}.tar.gz"
|
||||
}
|
||||
"name": "@sern/cli",
|
||||
"version": "0.2.0",
|
||||
"description": "A CLI for @sern/handler",
|
||||
"exports": "./src/index.js",
|
||||
"bin": {
|
||||
"sern": "./src/index.js"
|
||||
},
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"release": "standard-version",
|
||||
"preview": "standard-version --dry-run",
|
||||
"push": "git push --follow-tags",
|
||||
"format": "prettier --check .",
|
||||
"fix": "prettier --write ."
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sern-handler/cli.git"
|
||||
},
|
||||
"keywords": [
|
||||
"cli",
|
||||
"discord",
|
||||
"discord.js",
|
||||
"sern",
|
||||
"sern-handler"
|
||||
],
|
||||
"author": "EvolutionX",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/sern-handler/cli/issues"
|
||||
},
|
||||
"homepage": "https://github.com/sern-handler/cli#readme",
|
||||
"dependencies": {
|
||||
"axios": "^0.27.2",
|
||||
"colorette": "^2.0.16",
|
||||
"commander": "^9.3.0",
|
||||
"execa": "^6.1.0",
|
||||
"find-up": "6.3.0",
|
||||
"ora": "^6.1.0",
|
||||
"prompts": "2.4.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/prompts": "^2.0.14",
|
||||
"cz-conventional-changelog": "3.0.1",
|
||||
"eslint": "8.18.0",
|
||||
"prettier": "2.7.1",
|
||||
"standard-version": "9.5.0"
|
||||
},
|
||||
"config": {
|
||||
"commitizen": {
|
||||
"path": "./node_modules/cz-conventional-changelog"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
package initialize
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"github.com/gookit/color"
|
||||
"github.com/sern-handler/cli/pkg/util"
|
||||
)
|
||||
|
||||
func installDependencies(name string, packageManager string) error {
|
||||
err := os.Chdir(name)
|
||||
|
||||
if err != nil {
|
||||
color.Error.Prompt("Couldn't change to the project's directory.")
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
packageManagers := util.CheckPackageManagers()
|
||||
|
||||
if packageManager == "npm" && packageManagers.NPM {
|
||||
err := exec.Command("npm", "install").Run()
|
||||
|
||||
if err != nil {
|
||||
color.Error.Prompt("Couldn't install the dependencies.")
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
color.Info.Prompt("Successfully installed the dependencies.")
|
||||
}
|
||||
|
||||
if packageManager == "yarn" && packageManagers.Yarn {
|
||||
err := exec.Command("yarn", "install").Run()
|
||||
|
||||
if err != nil {
|
||||
color.Error.Prompt("Couldn't install the dependencies.")
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
color.Info.Prompt("Successfully installed the dependencies.")
|
||||
}
|
||||
|
||||
if packageManager == "skip" {
|
||||
color.Warn.Prompt("Skipping the installation of the dependencies.")
|
||||
}
|
||||
|
||||
if !packageManagers.NPM && !packageManagers.Yarn {
|
||||
color.Error.Prompt("Couldn't find any package managers.")
|
||||
|
||||
return errors.New("couldn't find any package managers")
|
||||
}
|
||||
|
||||
err = os.Chdir("..")
|
||||
|
||||
if err != nil {
|
||||
color.Error.Prompt("Couldn't change to the starting directory.")
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
package initialize
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/AlecAivazis/survey/v2"
|
||||
"github.com/gookit/color"
|
||||
)
|
||||
|
||||
func Initialize() {
|
||||
answers := struct {
|
||||
Name string
|
||||
Language string
|
||||
Main string
|
||||
Commands string
|
||||
Package string
|
||||
}{}
|
||||
|
||||
err := survey.Ask(questions, &answers)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("Project initialization failed, exiting.")
|
||||
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
color.Info.Prompt("Initializing the project...")
|
||||
|
||||
err = cloneRepository(answers.Name, answers.Language)
|
||||
|
||||
if err != nil {
|
||||
color.Error.Prompt("Couldn't generate the project from the templates, exiting.")
|
||||
|
||||
err = os.RemoveAll("templates")
|
||||
|
||||
if err != nil {
|
||||
color.Error.Prompt("Couldn't remove the templates folder.")
|
||||
}
|
||||
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
err = os.RemoveAll("templates")
|
||||
|
||||
if err != nil {
|
||||
color.Error.Prompt("Couldn't remove the templates folder.")
|
||||
}
|
||||
|
||||
color.Info.Prompt("Successfully generated the project from the templates.")
|
||||
|
||||
color.Info.Prompt("Renaming the project's folders...")
|
||||
|
||||
err = renameFolders(answers.Name, answers.Main, answers.Commands)
|
||||
|
||||
if err != nil {
|
||||
color.Error.Prompt("Couldn't rename the folders, exiting.")
|
||||
color.Warn.Prompt("The project was generated, but the folders weren't renamed.\n\nYou can still use the project, but you will have to rename the folders manually.")
|
||||
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
color.Info.Prompt("Successfully renamed the project's folders.")
|
||||
|
||||
color.Info.Prompt("Installing the dependencies...")
|
||||
|
||||
err = installDependencies(answers.Name, answers.Package)
|
||||
|
||||
if err != nil {
|
||||
color.Error.Prompt("Couldn't install the dependencies, exiting.")
|
||||
color.Warn.Prompt("The project was generated, but the dependencies weren't installed.\n\nYou can still use the project, but you will have to install the dependencies manually.")
|
||||
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
err = renamePackageJson(answers.Name)
|
||||
|
||||
if err != nil {
|
||||
color.Error.Prompt("Couldn't rename the package.json file, exiting.")
|
||||
color.Warn.Prompt("The project was generated, but the package.json file wasn't updated.\n\nYou can still use the project, but you will have to update the package.json file manually.")
|
||||
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
color.Success.Prompt("Project successfully initialized.")
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package initialize
|
||||
|
||||
type PackageJSON struct {
|
||||
Name string `json:"name"`
|
||||
Version string `json:"version"`
|
||||
Description string `json:"description"`
|
||||
Main string `json:"main"`
|
||||
Scripts map[string]string `json:"scripts"`
|
||||
Keywords []string `json:"keywords"`
|
||||
Author string `json:"author"`
|
||||
License string `json:"license"`
|
||||
Dependencies map[string]string `json:"dependencies"`
|
||||
DevDependencies map[string]string `json:"devDependencies"`
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package initialize
|
||||
|
||||
import "github.com/AlecAivazis/survey/v2"
|
||||
|
||||
var questions = []*survey.Question{
|
||||
{
|
||||
Name: "name",
|
||||
Prompt: &survey.Input{
|
||||
Message: "What is your project's name?",
|
||||
},
|
||||
Validate: survey.Required,
|
||||
},
|
||||
{
|
||||
Name: "language",
|
||||
Prompt: &survey.Select{
|
||||
Message: "What language do you want to use?",
|
||||
Options: []string{"JavaScript", "TypeScript"},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "main",
|
||||
Prompt: &survey.Input{
|
||||
Message: "What is your project's main directory?",
|
||||
Default: "src",
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "commands",
|
||||
Prompt: &survey.Input{
|
||||
Message: "What is your project's command directory?",
|
||||
Default: "commands",
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "package",
|
||||
Prompt: &survey.Select{
|
||||
Message: "What package manager do you want to use?",
|
||||
Options: []string{"npm", "yarn", "skip"},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package initialize
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/gookit/color"
|
||||
)
|
||||
|
||||
func renameFolders(name string, main string, commands string) error {
|
||||
if main != "src" {
|
||||
err := os.Rename(name+"/src", name+"/"+main)
|
||||
|
||||
if err != nil {
|
||||
color.Warn.Prompt("Couldn't rename the main folder.")
|
||||
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if commands != "commands" {
|
||||
err := os.Rename(name+"/"+main+"/commands", name+"/"+main+"/"+commands)
|
||||
|
||||
if err != nil {
|
||||
color.Warn.Prompt("Couldn't rename the commands folder.")
|
||||
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func renamePackageJson(name string) error {
|
||||
file, err := ioutil.ReadFile(name + "/package.json")
|
||||
|
||||
if err != nil {
|
||||
color.Warn.Prompt("Couldn't read the package.json file.")
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
var packageJSON PackageJSON
|
||||
|
||||
err = json.Unmarshal(file, &packageJSON)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
|
||||
color.Warn.Prompt("Couldn't unmarshal the package.json file.")
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
packageJSON.Name = name
|
||||
|
||||
file, err = json.MarshalIndent(packageJSON, "", " ")
|
||||
|
||||
if err != nil {
|
||||
color.Warn.Prompt("Couldn't marshal the package.json file.")
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(name+"/package.json", file, 0644)
|
||||
|
||||
if err != nil {
|
||||
color.Warn.Prompt("Couldn't write the package.json file.")
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package initialize
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/gookit/color"
|
||||
)
|
||||
|
||||
func cloneRepository(name string, language string) error {
|
||||
_, err := git.PlainClone("templates", false, &git.CloneOptions{
|
||||
URL: "https://github.com/sern-handler/templates",
|
||||
Progress: os.Stdout,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
color.Error.Prompt("Couldn't install the template.")
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
err = os.Rename("templates/templates/"+strings.ToLower(language), name)
|
||||
|
||||
if err != nil {
|
||||
color.Error.Prompt("Couldn't rename the template to the project's name.")
|
||||
color.Warn.Prompt("The project was generated, but it wasn't renamed.\n\nYou can still use the project, but you will have to rename it manually.")
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
err = os.RemoveAll("templates")
|
||||
|
||||
if err != nil {
|
||||
color.Error.Prompt("Couldn't remove the templates folder.")
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package util
|
||||
|
||||
import "os/exec"
|
||||
|
||||
type PackageManagers struct {
|
||||
NPM bool
|
||||
Yarn bool
|
||||
}
|
||||
|
||||
func CheckPackageManagers() PackageManagers {
|
||||
packageManagers := PackageManagers{
|
||||
NPM: false,
|
||||
Yarn: false,
|
||||
}
|
||||
|
||||
_, err := exec.LookPath("npm")
|
||||
|
||||
if err == nil {
|
||||
packageManagers.NPM = true
|
||||
}
|
||||
|
||||
_, err = exec.LookPath("yarn")
|
||||
|
||||
if err == nil {
|
||||
packageManagers.Yarn = true
|
||||
}
|
||||
|
||||
return packageManagers
|
||||
}
|
||||
17
renovate.json
Normal file
17
renovate.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": ["config:base"],
|
||||
"major": {
|
||||
"dependencyDashboardApproval": true
|
||||
},
|
||||
"schedule": ["every weekend"],
|
||||
"lockFileMaintenance": {
|
||||
"enabled": true
|
||||
},
|
||||
"packageRules": [
|
||||
{
|
||||
"matchUpdateTypes": ["minor", "patch"],
|
||||
"matchCurrentVersion": "!/^0/"
|
||||
}
|
||||
]
|
||||
}
|
||||
12
src/commands/extra.js
Normal file
12
src/commands/extra.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import prompts from 'prompts';
|
||||
import { extraPrompt } from '../prompts/extra.js';
|
||||
import { create } from '../utilities/create.js';
|
||||
const { prompt } = prompts;
|
||||
|
||||
export async function extra() {
|
||||
const extra = await prompt([extraPrompt]);
|
||||
|
||||
if (Object.keys(extra).length < 1) process.exit(1);
|
||||
const lang = extra.extra.includes('typescript') ? 'TS' : 'JS';
|
||||
await create(extra.extra.split('-')[0], lang, process.cwd(), true);
|
||||
}
|
||||
12
src/commands/help.js
Normal file
12
src/commands/help.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import { cyanBright, yellowBright, green } from 'colorette';
|
||||
|
||||
export function help() {
|
||||
let guide = 'Welcome to Sern!\n';
|
||||
guide += `If you're new to ${cyanBright('Sern')}, run ${yellowBright(
|
||||
'sern init'
|
||||
)} for an interactive setup to your new bot project!\n\n`;
|
||||
guide += `${green(
|
||||
`If you have any ideas, suggestions, bug reports, kindly join our support server: https://discord.gg/xzK5fUKT4r`
|
||||
)}`;
|
||||
return guide;
|
||||
}
|
||||
132
src/commands/init.js
Normal file
132
src/commands/init.js
Normal file
@@ -0,0 +1,132 @@
|
||||
import prompts from 'prompts';
|
||||
import ora from 'ora';
|
||||
import { greenBright, redBright, yellowBright } from 'colorette';
|
||||
import { execa } from 'execa';
|
||||
import { findUp } from 'find-up';
|
||||
import {
|
||||
cmds_dir,
|
||||
lang,
|
||||
main_dir,
|
||||
gitInit,
|
||||
which_manager,
|
||||
skip_install_dep,
|
||||
name,
|
||||
} from '../prompts/init.js';
|
||||
|
||||
import { npm } from '../utilities/npm.js';
|
||||
import { cloneRepo, installDeps } from '../utilities/install.js';
|
||||
import { editDirs, editMain } from '../utilities/edits.js';
|
||||
import { writeFile } from 'fs/promises';
|
||||
const { prompt } = prompts;
|
||||
|
||||
export async function init(flags) {
|
||||
// * Check if node version is valid
|
||||
const node = await execa('node', ['--version']);
|
||||
if (/v1(([0-6]\.[2-9])|([0-5]\.[0-9]))/gm.test(node.stdout)) {
|
||||
console.log(
|
||||
yellowBright(
|
||||
`\nYou are using Node ${node.stdout}\nPlease upgrade to Node 16.10.x or higher!\n`
|
||||
)
|
||||
);
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
let data;
|
||||
let git_init;
|
||||
let pm;
|
||||
|
||||
if (flags.y) {
|
||||
const projectName = await prompt([name]);
|
||||
git_init = true;
|
||||
pm = 'npm';
|
||||
data = {
|
||||
name: projectName.name,
|
||||
lang: 'typescript',
|
||||
main_dir: 'src',
|
||||
cmds_dir: 'commands',
|
||||
};
|
||||
} else {
|
||||
data = await prompt([name, lang, main_dir, cmds_dir]);
|
||||
git_init = (await prompt([gitInit])).gitinit;
|
||||
pm = await npm();
|
||||
}
|
||||
|
||||
const config = {
|
||||
language: data.lang,
|
||||
paths: {
|
||||
base: data.main_dir,
|
||||
commands: data.cmds_dir,
|
||||
},
|
||||
};
|
||||
const file = JSON.stringify(config, null, 2);
|
||||
|
||||
if (Object.keys(data).length < 4) process.exit(1);
|
||||
|
||||
await cloneRepo(data.lang, data.name);
|
||||
|
||||
const pkg = await findUp('package.json', {
|
||||
cwd: process.cwd() + '/' + data.name,
|
||||
});
|
||||
|
||||
if (!pkg) throw new Error('No package.json found! Clone Failed');
|
||||
|
||||
if (pkg) {
|
||||
await writeFile(pkg.replace('package.json', 'sern.config.json'), file);
|
||||
}
|
||||
|
||||
git_init ? await git(data) : console.log(`Skipping git init...\n`);
|
||||
|
||||
let choice;
|
||||
|
||||
if (pm === 'both') {
|
||||
const chosen = await prompt([which_manager]);
|
||||
choice = chosen.manager;
|
||||
} else {
|
||||
const chosen = await prompt([skip_install_dep]);
|
||||
choice = chosen.skip_install_dep ? pm : 'skip';
|
||||
}
|
||||
|
||||
await installDeps(choice, data.name);
|
||||
await editMain(data.name);
|
||||
await editDirs(data.main_dir, data.cmds_dir, data.name, data.lang);
|
||||
|
||||
console.log(`${greenBright('Success, project was initialised!')}`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* It initializes git
|
||||
* @param data - The data object that contains the name of the project.
|
||||
*/
|
||||
async function git(data) {
|
||||
const spin = ora({
|
||||
text: 'Initializing git...',
|
||||
spinner: 'aesthetic',
|
||||
}).start();
|
||||
|
||||
const exe = await execa('git', ['init', data.name]);
|
||||
|
||||
await wait(300);
|
||||
|
||||
if (!exe || exe?.failed) {
|
||||
spin.fail(
|
||||
`${redBright('Failed')} to initialize git!` +
|
||||
'\nMaybe you should run git init?'
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
spin.succeed('Git initialized!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for a specified number of milliseconds, then return a promise that resolves to undefined.
|
||||
* @param {number} ms - The number of milliseconds to wait.
|
||||
* @returns A function that takes a single argument, ms, and returns a promise that resolves after ms
|
||||
* milliseconds.
|
||||
*/
|
||||
async function wait(ms) {
|
||||
const wait = (await import('util')).promisify(setTimeout);
|
||||
return wait(ms);
|
||||
}
|
||||
44
src/commands/plugins.js
Normal file
44
src/commands/plugins.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import { pluginsQ } from '../prompts/plugin.js';
|
||||
import prompts from 'prompts';
|
||||
import axios from 'axios';
|
||||
import fs from 'fs';
|
||||
import { greenBright } from 'colorette';
|
||||
const { prompt } = prompts;
|
||||
|
||||
/**
|
||||
* Installs plugins to project
|
||||
*/
|
||||
export async function plugins() {
|
||||
/**
|
||||
* @type {string[]}
|
||||
*/
|
||||
const e = (await prompt([await pluginsQ()])).list;
|
||||
if (!e) process.exit(1);
|
||||
|
||||
for await (const url of e) {
|
||||
await download(url);
|
||||
}
|
||||
const pluginNames = e.map((e) => e.split('/').pop());
|
||||
console.log(
|
||||
`Successfully downloaded plugin(s):\n${greenBright(
|
||||
pluginNames.join('\n')
|
||||
)}`
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} url
|
||||
* @returns File
|
||||
*/
|
||||
async function download(url) {
|
||||
const res = await axios.default.get(url);
|
||||
const data = res.data;
|
||||
const dir = `${process.cwd()}/src/plugins`;
|
||||
const filedir = `${process.cwd()}/src/plugins/${url.split('/').pop()}`;
|
||||
if (!fs.existsSync(dir)) {
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
}
|
||||
const file = fs.writeFileSync(filedir, data);
|
||||
|
||||
return file;
|
||||
}
|
||||
37
src/index.js
Normal file
37
src/index.js
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { init } from './commands/init.js';
|
||||
import { help } from './commands/help.js';
|
||||
import { extra } from './commands/extra.js';
|
||||
|
||||
import { Command } from 'commander';
|
||||
import { version } from './utilities/version.js';
|
||||
import { plugins } from './commands/plugins.js';
|
||||
export const program = new Command();
|
||||
|
||||
program
|
||||
.name('sern')
|
||||
.description(help())
|
||||
.version(version())
|
||||
.exitOverride(() => process.exit(0));
|
||||
|
||||
program
|
||||
.command(init.name)
|
||||
.description('Quickest way to scaffold a new project')
|
||||
.option('-y', 'Finishes setup as default')
|
||||
.action(init);
|
||||
|
||||
program
|
||||
.command(plugins.name)
|
||||
.description(
|
||||
'Install plugins from https://github.com/sern-handler/awesome-plugins'
|
||||
)
|
||||
.option('-n --name', 'Name of plugin')
|
||||
.action(plugins);
|
||||
|
||||
program
|
||||
.command(extra.name)
|
||||
.description('Easy way to add extra things in your sern project')
|
||||
.action(extra);
|
||||
|
||||
program.parse();
|
||||
18
src/prompts/extra.js
Normal file
18
src/prompts/extra.js
Normal file
@@ -0,0 +1,18 @@
|
||||
export const extraPrompt = {
|
||||
message: 'What extra feature do you want to add?',
|
||||
name: 'extra',
|
||||
type: 'select',
|
||||
choices: [
|
||||
{
|
||||
title: 'Dockerfile (TypeScript)',
|
||||
description: 'Dockerfile for TypeScript',
|
||||
value: 'Dockerfile-typescript',
|
||||
selected: true,
|
||||
},
|
||||
{
|
||||
title: 'Dockerfile (JavaScript)',
|
||||
description: 'Dockerfile for JavaScript',
|
||||
value: 'Dockerfile-javascript',
|
||||
},
|
||||
],
|
||||
};
|
||||
96
src/prompts/init.js
Normal file
96
src/prompts/init.js
Normal file
@@ -0,0 +1,96 @@
|
||||
import { blueBright } from 'colorette';
|
||||
|
||||
export const lang = {
|
||||
message: 'What language do you want the project to be in?',
|
||||
name: 'lang',
|
||||
type: 'select',
|
||||
choices: [
|
||||
{
|
||||
title: 'JavaScript',
|
||||
description: 'JS',
|
||||
value: 'javascript',
|
||||
},
|
||||
{
|
||||
title: 'TypeScript',
|
||||
description: 'TS - (Recommended)',
|
||||
value: 'typescript',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const main_dir = {
|
||||
message: 'What is the main directory of your project?',
|
||||
name: 'main_dir',
|
||||
type: 'text',
|
||||
initial: 'src',
|
||||
};
|
||||
|
||||
export const cmds_dir = {
|
||||
message: 'What is the directory of your commands?',
|
||||
name: 'cmds_dir',
|
||||
type: 'text',
|
||||
initial: 'commands',
|
||||
validate: (/** @type {string} */ dir) =>
|
||||
dir === 'src' ? 'You can not use src as a directory' : true,
|
||||
};
|
||||
|
||||
/**
|
||||
* @type {import('prompts').PromptObject}
|
||||
*/
|
||||
export const npmInit = {
|
||||
name: 'npm_init',
|
||||
type: 'confirm',
|
||||
message: `Do you want ${blueBright('me')} to initialize npm?`,
|
||||
initial: true,
|
||||
};
|
||||
|
||||
export const gitInit = {
|
||||
name: 'gitinit',
|
||||
type: 'confirm',
|
||||
message: `Do you want to ${blueBright('me')} to initialize git?`,
|
||||
initial: true,
|
||||
};
|
||||
|
||||
export const which_manager = {
|
||||
message: `Which manager do you want to use?`,
|
||||
name: 'manager',
|
||||
type: 'select',
|
||||
choices: [
|
||||
{
|
||||
title: 'NPM',
|
||||
description: 'Default Package Manager',
|
||||
selected: true,
|
||||
value: 'npm',
|
||||
},
|
||||
{
|
||||
title: 'Yarn',
|
||||
description: 'Yarn Package Manager',
|
||||
value: 'yarn',
|
||||
},
|
||||
{
|
||||
title: 'Skip',
|
||||
description: 'Skip selection',
|
||||
value: 'skip',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const skip_install_dep = {
|
||||
name: 'skip_install_dep',
|
||||
type: 'confirm',
|
||||
message: `Do you want ${blueBright('me')} to install dependencies?`,
|
||||
initial: false,
|
||||
};
|
||||
|
||||
/**
|
||||
* @type {import('prompts').PromptObject}
|
||||
*/
|
||||
export const name = {
|
||||
message: 'What is your project name?',
|
||||
name: 'name',
|
||||
type: 'text',
|
||||
validate: (/**@type {string}*/ name) =>
|
||||
name.match('^(?:@[a-z0-9-*~][a-z0-9-*._~]*/)?[a-z0-9-~][a-z0-9-._~]*$')
|
||||
? true
|
||||
: 'Invalid name',
|
||||
};
|
||||
24
src/prompts/plugin.js
Normal file
24
src/prompts/plugin.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import axios from 'axios';
|
||||
import { getLang } from '../utilities/getLang.js';
|
||||
async function gimmechoices() {
|
||||
const lang =
|
||||
(await getLang()) === 'typescript' ? 'TypeScript' : 'JavaScript';
|
||||
const link = `https://api.github.com/repos/sern-handler/awesome-plugins/contents/${lang}`;
|
||||
|
||||
const data = (await axios.get(link)).data;
|
||||
const choices = data.map((e) => ({
|
||||
title: e.name,
|
||||
value: e.download_url,
|
||||
}));
|
||||
return choices;
|
||||
}
|
||||
|
||||
export async function pluginsQ() {
|
||||
return {
|
||||
name: 'list',
|
||||
type: 'autocompleteMultiselect',
|
||||
message: 'What plugins do you want to install?',
|
||||
choices: await gimmechoices(),
|
||||
min: 1,
|
||||
};
|
||||
}
|
||||
11
src/templates/extra/Dockerfile.JS.sern
Normal file
11
src/templates/extra/Dockerfile.JS.sern
Normal file
@@ -0,0 +1,11 @@
|
||||
FROM node:latest
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json ./
|
||||
|
||||
RUN npm install
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN node src/index.js
|
||||
13
src/templates/extra/Dockerfile.TS.sern
Normal file
13
src/templates/extra/Dockerfile.TS.sern
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
|
||||
54
src/utilities/create.js
Normal file
54
src/utilities/create.js
Normal file
@@ -0,0 +1,54 @@
|
||||
import { URL, fileURLToPath } from 'url';
|
||||
import { resolve, dirname } from 'node:path';
|
||||
import { readFile, mkdir, writeFile } from 'fs/promises';
|
||||
const root = new URL('../', import.meta.url);
|
||||
|
||||
const templates = new URL('./templates/', root);
|
||||
const extraURL = new URL('./extra/', templates);
|
||||
const extraFolder = fileURLToPath(extraURL);
|
||||
|
||||
/**
|
||||
* It creates a file with the name `name.lang.sern` in the `location` directory
|
||||
* @param {string} name - The name of the file.
|
||||
* @param {string} lang - The language you want to use.
|
||||
* @param {string} location - The location of the file to be created.
|
||||
* @param {boolean} no_ext - If true, the file will be created without an extension.
|
||||
* @returns File
|
||||
*/
|
||||
export async function create(name, lang, location, no_ext) {
|
||||
const file = `${name}.${lang}.sern`;
|
||||
|
||||
const target = no_ext
|
||||
? `${location}/${name}`
|
||||
: `${location}/${name}.${lang}`;
|
||||
|
||||
return createFile(file, target);
|
||||
}
|
||||
|
||||
/**
|
||||
* It reads a file from a template folder, and writes it to a target folder
|
||||
* @param {string} template - The name of the file to be created.
|
||||
* @param {string} target - The location of the file to be created.
|
||||
*/
|
||||
async function createFile(template, target) {
|
||||
const location = `${extraFolder}${template}`;
|
||||
|
||||
const file = await readFile(location, 'utf8');
|
||||
|
||||
await writeFileRecursive(target, file);
|
||||
}
|
||||
|
||||
/**
|
||||
* It creates a directory recursively, then writes a file to it
|
||||
* @param {string} target - The path to the file you want to write to.
|
||||
* @param {string} data - The data to write to the file.
|
||||
* @returns A promise that resolves to the result of the writeFile function.
|
||||
*/
|
||||
async function writeFileRecursive(target, data) {
|
||||
const resolvedTarget = resolve(target);
|
||||
const dir = dirname(resolvedTarget);
|
||||
|
||||
await mkdir(dir, { recursive: true });
|
||||
|
||||
return writeFile(resolvedTarget, data);
|
||||
}
|
||||
84
src/utilities/edits.js
Normal file
84
src/utilities/edits.js
Normal file
@@ -0,0 +1,84 @@
|
||||
import { readFile, rename, writeFile } from 'node:fs/promises';
|
||||
import { findUp } from 'find-up';
|
||||
|
||||
/**
|
||||
* It takes a string, finds the package.json file in the directory of the string, and changes the name
|
||||
* of the package.json file to the string.
|
||||
* @param {string} name - The name of the project.
|
||||
* @returns A promise.
|
||||
*/
|
||||
export async function editMain(name) {
|
||||
const pjLocation = await findUp('package.json', {
|
||||
cwd: process.cwd() + '/' + name,
|
||||
});
|
||||
|
||||
const output = JSON.parse(await readFile(pjLocation, 'utf8'));
|
||||
if (!output) throw new Error("Can't read your package.json.");
|
||||
|
||||
output.name = name;
|
||||
|
||||
return writeFile(pjLocation, JSON.stringify(output, null, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* It renames the `src` and `commands` directories, and edits the `index.ts` file to reflect the
|
||||
* changes
|
||||
* @param {string} srcName - The name of the folder that will contain your main files.
|
||||
* @param {string} cmds_dirName - The name of the directory where your commands will be stored.
|
||||
* @param {string} name - The name of the folder you want to edit.
|
||||
* @param {'javascript' | 'typescript'} lang - The language you want to use.
|
||||
* @returns void
|
||||
*/
|
||||
export async function editDirs(
|
||||
srcName,
|
||||
cmds_dirName,
|
||||
name,
|
||||
lang = 'typescript'
|
||||
) {
|
||||
const path = await findUp('src', {
|
||||
cwd: process.cwd() + '/' + name,
|
||||
type: 'directory',
|
||||
});
|
||||
|
||||
const ext = lang === 'typescript' ? 'ts' : 'js';
|
||||
|
||||
const newMainDir = path?.replace('src', srcName);
|
||||
await rename(path, newMainDir);
|
||||
|
||||
const cmdsPath = await findUp('commands', {
|
||||
cwd: process.cwd() + '/' + name + '/' + srcName,
|
||||
type: 'directory',
|
||||
});
|
||||
|
||||
const index = await findUp(`index.${ext}`, {
|
||||
cwd: process.cwd() + '/' + name + '/' + srcName,
|
||||
});
|
||||
|
||||
const newCmdsPath = cmdsPath?.replace('commands', cmds_dirName);
|
||||
await rename(cmdsPath, newCmdsPath);
|
||||
|
||||
const tsconfig = await findUp('tsconfig.json', {
|
||||
cwd: process.cwd() + '/' + name,
|
||||
});
|
||||
|
||||
if (tsconfig) {
|
||||
const output = JSON.parse(await readFile(tsconfig, 'utf8'));
|
||||
if (!output) throw new Error("Can't read your tsconfig.json.");
|
||||
output.compilerOptions.rootDir = srcName;
|
||||
|
||||
writeFile(tsconfig, JSON.stringify(output, null, 2));
|
||||
}
|
||||
|
||||
const output = await readFile(index, 'utf8');
|
||||
|
||||
const oldfold = ext === 'ts' ? 'dist' : 'src';
|
||||
const newfold = ext === 'ts' ? 'dist' : srcName;
|
||||
|
||||
const regex = new RegExp(`commands: '${oldfold}/commands'`);
|
||||
const edit = output.replace(
|
||||
regex,
|
||||
`commands: '${newfold}/${cmds_dirName}'`
|
||||
);
|
||||
|
||||
return writeFile(index, edit);
|
||||
}
|
||||
18
src/utilities/getLang.js
Normal file
18
src/utilities/getLang.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import { findUp } from 'find-up';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
|
||||
/**
|
||||
* It finds the sern.config.json file, reads it, and returns the language property
|
||||
* @returns {Promise<string>} The language of the project.
|
||||
*/
|
||||
export async function getLang() {
|
||||
const sernLocation = await findUp('sern.config.json');
|
||||
|
||||
if (!sernLocation) throw new Error("Can't find sern.config.json");
|
||||
|
||||
const output = JSON.parse(await readFile(sernLocation, 'utf8'));
|
||||
|
||||
if (!output) throw new Error("Can't read your sern.config.json.");
|
||||
|
||||
return output.language;
|
||||
}
|
||||
89
src/utilities/install.js
Normal file
89
src/utilities/install.js
Normal file
@@ -0,0 +1,89 @@
|
||||
import { execa } from 'execa';
|
||||
import { redBright } from 'colorette';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { readFile } from 'fs/promises';
|
||||
import { findUp } from 'find-up';
|
||||
import ora from 'ora';
|
||||
|
||||
/**
|
||||
* It installs dependencies from a package.json file
|
||||
* @param {'skip' | 'npm' | 'yarn'} choice - The package manager to use.
|
||||
* @param {string} name - The name of the project
|
||||
* @returns a promise.
|
||||
*/
|
||||
export async function installDeps(choice, name) {
|
||||
const pkg = await findUp('package.json', {
|
||||
cwd: process.cwd() + '/' + name,
|
||||
});
|
||||
if (!pkg) throw new Error('No package.json found!');
|
||||
|
||||
const output = JSON.parse(await readFile(pkg, 'utf8'));
|
||||
if (!output) throw new Error("Can't read file.");
|
||||
|
||||
const deps = output.dependencies;
|
||||
if (!deps) throw new Error("Can't find dependencies.");
|
||||
|
||||
if (choice === 'skip') {
|
||||
return console.log('Dependency installation skipped...');
|
||||
}
|
||||
|
||||
const spin = ora({
|
||||
text: `Installing dependencies...`,
|
||||
spinner: 'aesthetic',
|
||||
}).start();
|
||||
|
||||
const result = await execa(choice, ['install'], {
|
||||
cwd: process.cwd() + '/' + name,
|
||||
}).catch(() => null);
|
||||
if (!result || result?.failed) {
|
||||
spin.fail(`${redBright('Failed')} to install dependencies!`);
|
||||
process.exit(1);
|
||||
} else spin.succeed(`Dependencies installed!`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the repo, copy the files from the repo to the new project directory, and delete the repo
|
||||
* @param {string} lang - The language of the template
|
||||
* @param {string} name - The name of the project
|
||||
*/
|
||||
export async function cloneRepo(lang, name) {
|
||||
await execa('git', [
|
||||
'clone',
|
||||
`https://github.com/sern-handler/templates.git`,
|
||||
]);
|
||||
copyRecursiveSync(`templates/templates/${lang}`, name);
|
||||
fs.rmSync(`templates/`, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
/**
|
||||
* If the source is a directory, create the destination directory and then recursively copy the
|
||||
* contents of the source directory to the destination directory. If the source is not a directory,
|
||||
* copy the source file to the destination file
|
||||
* @param {string} src - The source path.
|
||||
* @param {string} dest - The destination folder where the files will be copied to.
|
||||
*/
|
||||
export function copyRecursiveSync(src, dest) {
|
||||
const exists = fs.existsSync(src);
|
||||
|
||||
const stats = exists && fs.statSync(src);
|
||||
|
||||
const isDirectory = exists && stats.isDirectory();
|
||||
if (isDirectory) {
|
||||
fs.mkdirSync(dest);
|
||||
|
||||
fs.readdirSync(src).forEach(function (childItemName) {
|
||||
copyRecursiveSync(
|
||||
path.join(src, childItemName),
|
||||
path.join(dest, childItemName)
|
||||
);
|
||||
});
|
||||
} else {
|
||||
fs.copyFileSync(src, dest);
|
||||
}
|
||||
}
|
||||
|
||||
// async function wait(ms) {
|
||||
// const wait = (await import('util')).promisify(setTimeout);
|
||||
// return wait(ms);
|
||||
// }
|
||||
25
src/utilities/npm.js
Normal file
25
src/utilities/npm.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import { execa } from 'execa';
|
||||
|
||||
/**
|
||||
* It checks if you have npm or yarn installed, and returns a string based on the result
|
||||
* @returns A promise that resolves to a string.
|
||||
*/
|
||||
export async function npm() {
|
||||
const npm = await execa('npm', ['-v']).catch(() => null);
|
||||
const npm_version = npm?.stdout;
|
||||
|
||||
const yarn = await execa('yarn', ['-v']).catch(() => null);
|
||||
const yarn_version = yarn?.stdout;
|
||||
|
||||
if (npm_version && !yarn_version) {
|
||||
return 'npm';
|
||||
}
|
||||
|
||||
if (!npm_version && yarn_version) {
|
||||
return 'yarn';
|
||||
}
|
||||
|
||||
if (npm_version && yarn_version) {
|
||||
return 'both';
|
||||
}
|
||||
}
|
||||
7
src/utilities/version.js
Normal file
7
src/utilities/version.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import { createRequire } from 'module';
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
export function version() {
|
||||
const { version: v } = require('../../package.json');
|
||||
return `SernHandler CLI v${v}`;
|
||||
}
|
||||
17
tsconfig.json
Normal file
17
tsconfig.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"lib": ["es2017", "dom"],
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
"noEmit": true,
|
||||
"strict": false,
|
||||
"noImplicitThis": true,
|
||||
"alwaysStrict": true,
|
||||
"esModuleInterop": true,
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
"include": ["test", "src"]
|
||||
}
|
||||
Reference in New Issue
Block a user