mirror of
https://github.com/sern-handler/cli
synced 2026-06-06 09:26:52 +00:00
Compare commits
84 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ebc688022e | ||
|
|
810763837c | ||
|
|
fa331ae0c0 | ||
|
|
6c034a568f | ||
|
|
9158e66bb4 | ||
|
|
af593bf84a | ||
|
|
f84e7ac8f5 | ||
|
|
08b8a13d16 | ||
|
|
c4f8e45bdc | ||
|
|
83e841a341 | ||
|
|
ab2f8016b6 | ||
|
|
93ef62bc9d | ||
|
|
e454ddaaab | ||
|
|
e3ee6d5428 | ||
|
|
02eec5f926 | ||
|
|
aa1e11b24a | ||
|
|
39817e6b4f | ||
|
|
a0d5890ea7 | ||
|
|
2fa5a360ef | ||
|
|
1e07b5f1c8 | ||
|
|
c312ca794c | ||
|
|
eee3bb8db6 | ||
|
|
d9ea304fa6 | ||
|
|
52725ea7f6 | ||
|
|
b24a053d1c | ||
|
|
419b7bce22 | ||
|
|
5a24ae4819 | ||
|
|
8f6b1c690f | ||
|
|
46ec745b88 | ||
|
|
6472683c19 | ||
|
|
2b260eb1bc | ||
|
|
428b87ee1f | ||
|
|
493189772f | ||
|
|
dff1481e19 | ||
|
|
9264dde532 | ||
|
|
ffc1e6f3eb | ||
|
|
95c20a3edf | ||
|
|
c351bd5c0b | ||
|
|
f218e6524b | ||
|
|
afd0b46ffc | ||
|
|
c730986264 | ||
|
|
03dddd4384 | ||
|
|
177766e357 | ||
|
|
7cbde33af2 | ||
|
|
58922bf69e | ||
|
|
92b713e476 | ||
|
|
94757d67cb | ||
|
|
6253571095 | ||
|
|
c4c9b11bc2 | ||
|
|
e06ae29fa1 | ||
|
|
d455a9ef30 | ||
|
|
9bd2b0f38b | ||
|
|
330b2ee92d | ||
|
|
8c45327094 | ||
|
|
361e6451a7 | ||
|
|
81eabff53e | ||
|
|
d78c20a491 | ||
|
|
a97bfdf9ee | ||
|
|
7276c2cb21 | ||
|
|
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 |
28
.github/workflows/auto-deprecate.yml
vendored
Normal file
28
.github/workflows/auto-deprecate.yml
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
name: NPM Auto Deprecate
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
auto-deprecate:
|
||||
name: NPM Auto Deprecate
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Project
|
||||
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
|
||||
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # tag=v3
|
||||
with:
|
||||
node-version: 17
|
||||
registry-url: 'https://registry.npmjs.org/'
|
||||
|
||||
- name: Install Node.js dependencies
|
||||
run: npm i
|
||||
- name: Deprecate versions
|
||||
run: npx npm-deprecate --name "*dev*" --package "@sern/cli" --message "This is a deprecated version of @sern/cli@dev. Please use the latest dev version."
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
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:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'src/**'
|
||||
- 'package.json'
|
||||
|
||||
jobs:
|
||||
Publish:
|
||||
name: Publishing Dev
|
||||
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@2fddd8803e2f5c9604345a0b591c3020ee971a93 # 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
|
||||
|
||||
- name: Publish to npm
|
||||
run: |
|
||||
npm version premajor --preid "dev.$(git rev-parse --verify --short HEAD)" --git-tag-version=false
|
||||
npm publish --tag dev
|
||||
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@2fddd8803e2f5c9604345a0b591c3020ee971a93 # 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@2fddd8803e2f5c9604345a0b591c3020ee971a93 # 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
|
||||
32
.github/workflows/linter.yml
vendored
32
.github/workflows/linter.yml
vendored
@@ -1,32 +0,0 @@
|
||||
name: Lint
|
||||
|
||||
on:
|
||||
# Trigger the workflow on push or pull request,
|
||||
# but only for the main branch
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request_target:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
run-linters:
|
||||
name: Run linters
|
||||
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@56337c425554a6be30cdef71bf441f15be286854 # tag=v3
|
||||
with:
|
||||
node-version: 17
|
||||
|
||||
# ESLint and Prettier must be in `package.json`
|
||||
- name: Install Node.js dependencies
|
||||
run: npm i
|
||||
|
||||
- name: Run Prettier
|
||||
run: npm run format
|
||||
33
.github/workflows/publish.yml
vendored
Normal file
33
.github/workflows/publish.yml
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
name: Publish
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
Publish:
|
||||
name: Publishing
|
||||
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@2fddd8803e2f5c9604345a0b591c3020ee971a93 # 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
|
||||
|
||||
- name: Publish to npm
|
||||
run: npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
32
.github/workflows/release-please.yml
vendored
Normal file
32
.github/workflows/release-please.yml
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
Release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: google-github-actions/release-please-action@v3
|
||||
id: release
|
||||
with:
|
||||
release-type: node
|
||||
bump-patch-for-minor-pre-major: true
|
||||
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
|
||||
if: ${{ steps.release.outputs.release_created }}
|
||||
- uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # tag=v3
|
||||
with:
|
||||
node-version: 17
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
if: ${{ steps.release.outputs.release_created }}
|
||||
- run: npm i
|
||||
if: ${{ steps.release.outputs.release_created }}
|
||||
- run: npm link
|
||||
if: ${{ steps.release.outputs.release_created }}
|
||||
- run: sern
|
||||
if: ${{ steps.release.outputs.release_created }}
|
||||
- run: npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
if: ${{ steps.release.outputs.release_created }}
|
||||
6
.npmignore
Normal file
6
.npmignore
Normal file
@@ -0,0 +1,6 @@
|
||||
renovate.json
|
||||
tsconfig.json
|
||||
.prettierignore
|
||||
.prettierrc
|
||||
.gitattributes
|
||||
.github/
|
||||
97
CHANGELOG.md
97
CHANGELOG.md
@@ -1,6 +1,101 @@
|
||||
# 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.4.2](https://github.com/sern-handler/cli/compare/v0.4.1...v0.4.2) (2022-07-28)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* switch to undici ([#58](https://github.com/sern-handler/cli/issues/58)) ([c4f8e45](https://github.com/sern-handler/cli/commit/c4f8e45bdc0af5a3bbd394d2b9f852f4a946114c))
|
||||
|
||||
## [0.4.1](https://github.com/sern-handler/cli/compare/v0.4.0...v0.4.1) (2022-07-07)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* 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))
|
||||
* 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 actions and formatting stuff ([b302a8b](https://github.com/sern-handler/cli/commit/b302a8b362257fb2cea72b7e1fc66bea351c511f))
|
||||
* added help command ([ca23d17](https://github.com/sern-handler/cli/commit/ca23d17670663b62e23849e2350deef208bfc100))
|
||||
* Added version command & created readme ([#25](https://github.com/sern-handler/cli/issues/25)) ([7535a5e](https://github.com/sern-handler/cli/commit/7535a5e0267c9e682b7bc8470206c0597f5ba9a1))
|
||||
* bump all files to GitHub 🎉 ([01b39ad](https://github.com/sern-handler/cli/commit/01b39ad9b78f0a67e23ba66c10262082675eeed5))
|
||||
* cli is now functional ([65f38f3](https://github.com/sern-handler/cli/commit/65f38f3eb2b4e8e2bd136b9bd8f37f1966be1661))
|
||||
* cli is now functional ([5021d28](https://github.com/sern-handler/cli/commit/5021d28bca6ebe1cb4a548f5e595b1220f222c98))
|
||||
* 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))
|
||||
* enable extra command & jsdockerfile ([#43](https://github.com/sern-handler/cli/issues/43)) ([7cf62c0](https://github.com/sern-handler/cli/commit/7cf62c03083b8ebbb8a6a63fd8efe592344d5230))
|
||||
* **init:** add --sync flag ([#53](https://github.com/sern-handler/cli/issues/53)) ([b24a053](https://github.com/sern-handler/cli/commit/b24a053d1cb8c00d49a96b6d536dd17205b9fa0e))
|
||||
* making sern help message look better, adding ascii art ([#50](https://github.com/sern-handler/cli/issues/50)) ([9bd2b0f](https://github.com/sern-handler/cli/commit/9bd2b0f38be835a31fceeabdf60487a1424cdf7e))
|
||||
* more questions, better handling, better ui ([f931802](https://github.com/sern-handler/cli/commit/f9318024bb4c62cee1a7ddfc6af4117c22ca6020))
|
||||
* now edits the directories as per user's choice ([fec1c8e](https://github.com/sern-handler/cli/commit/fec1c8e24c5ca7752f9e74b0fc3a32716bb42299))
|
||||
* plugin command!!! ([#45](https://github.com/sern-handler/cli/issues/45)) ([895a489](https://github.com/sern-handler/cli/commit/895a48910e32813f8aa25f57302a4123fc631c2c))
|
||||
* rebase changes ([cae3c59](https://github.com/sern-handler/cli/commit/cae3c597c3da6aa836fb9c70b8555814e8fc5db0))
|
||||
* refactored code and added custom handling of commands ([0e97b7d](https://github.com/sern-handler/cli/commit/0e97b7db8afed7f625eeb0a43aa992441ab49b39))
|
||||
* **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
|
||||
|
||||
* avoid crashing of cli when no plugin found ([#47](https://github.com/sern-handler/cli/issues/47)) ([8c45327](https://github.com/sern-handler/cli/commit/8c45327094b2560f7b5c813a1c1925920bd46038))
|
||||
* 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))
|
||||
* prettier things ([1265224](https://github.com/sern-handler/cli/commit/1265224bb9f93cb104915be50c1c2ea1e3924955))
|
||||
* removed useless line ([f268b1c](https://github.com/sern-handler/cli/commit/f268b1c62fd4d5823d483a33cfef2e2d7f7b127c))
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* **init.js:** string.match -> regex.test for node version ([f760dbc](https://github.com/sern-handler/cli/commit/f760dbc6e39e098496f25a5c4ee90855a2bb3bd5))
|
||||
|
||||
### [0.2.2](https://github.com/sern-handler/cli/compare/v0.2.1...v0.2.2) (2022-07-05)
|
||||
|
||||
### [0.2.1](https://github.com/sern-handler/cli/compare/v0.2.0...v0.2.1) (2022-07-05)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* making sern help message look better, adding ascii art ([#50](https://github.com/sern-handler/cli/issues/50)) ([9bd2b0f](https://github.com/sern-handler/cli/commit/9bd2b0f38be835a31fceeabdf60487a1424cdf7e))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* avoid crashing of cli when no plugin found ([#47](https://github.com/sern-handler/cli/issues/47)) ([8c45327](https://github.com/sern-handler/cli/commit/8c45327094b2560f7b5c813a1c1925920bd46038))
|
||||
|
||||
## [0.2.0](https://github.com/sern-handler/cli/compare/v0.1.3...v0.2.0) (2022-06-22)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* 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)
|
||||
|
||||
|
||||
30
README.md
30
README.md
@@ -1,4 +1,4 @@
|
||||
# Sern CLI
|
||||
# sern CLI
|
||||
|
||||
Our CLI allows you to setup and manage Discord bot projects without writing a single line of code!
|
||||
|
||||
@@ -25,12 +25,32 @@ pnpm add -g @sern/cli@latest
|
||||
|
||||
When you install the CLI, you can use our commands with **sern** prefix.
|
||||
|
||||
`sern <command> (opt)<flag>`
|
||||
```
|
||||
Usage: sern [options] [command]
|
||||
|
||||
Welcome to sern!
|
||||
If you're new to sern, run sern init for an interactive setup to your new bot project!
|
||||
|
||||
If you have any ideas, suggestions, bug reports, kindly join our support server: https://discord.gg/xzK5fUKT4r
|
||||
|
||||
Options:
|
||||
-V, --version output the version number
|
||||
-h, --help display help for command
|
||||
|
||||
Commands:
|
||||
init [options] Quickest way to scaffold a new project
|
||||
plugins [options] Install plugins from https://github.com/sern-handler/awesome-plugins
|
||||
extra Easy way to add extra things in your sern project
|
||||
help [command] display help for command
|
||||
|
||||
```
|
||||
|
||||
## Setting Up Your Project
|
||||
|
||||
#### TODO
|
||||
Run `sern init (-y)` for an interactive setup on a brand new project using our framework. <br>
|
||||
Adding the `-y` flag sets up project as default. ( **Note** : the default initiates a typescript project)
|
||||
|
||||
## Stats
|
||||
## Installing Plugins
|
||||
|
||||

|
||||
sern runs on your plugins. Contribute to the [repository](https://github.com/sern-handler/awesome-plugins) and then install the plugins via our cli! <br>
|
||||
Run `sern plugins` to see all installable options
|
||||
|
||||
99
dumpfiles.js
99
dumpfiles.js
@@ -1,99 +0,0 @@
|
||||
//! 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!'));
|
||||
7573
package-lock.json
generated
7573
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
26
package.json
26
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@sern/cli",
|
||||
"version": "0.1.1",
|
||||
"version": "0.4.2",
|
||||
"description": "A CLI for @sern/handler",
|
||||
"exports": "./src/index.js",
|
||||
"bin": {
|
||||
@@ -9,9 +9,6 @@
|
||||
"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 ."
|
||||
},
|
||||
@@ -31,24 +28,23 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/sern-handler/cli/issues"
|
||||
},
|
||||
"homepage": "https://github.com/sern-handler/cli#readme",
|
||||
"homepage": "https://sern-handler.js.org",
|
||||
"dependencies": {
|
||||
"colorette": "^2.0.16",
|
||||
"degit": "^2.8.4",
|
||||
"commander": "^9.3.0",
|
||||
"execa": "^6.1.0",
|
||||
"find-up": "6.3.0",
|
||||
"ora": "^6.1.0",
|
||||
"prompts": "2.4.2"
|
||||
"prompts": "2.4.2",
|
||||
"undici": "^5.6.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"cz-conventional-changelog": "3.3.0",
|
||||
"eslint": "8.15.0",
|
||||
"prettier": "2.6.2",
|
||||
"standard-version": "9.5.0"
|
||||
"@favware/npm-deprecate": "1.0.4",
|
||||
"@types/prompts": "2.0.14",
|
||||
"prettier": "2.7.1"
|
||||
},
|
||||
"config": {
|
||||
"commitizen": {
|
||||
"path": "./node_modules/cz-conventional-changelog"
|
||||
}
|
||||
"publishConfig": {
|
||||
"registry": "https://registry.npmjs.org/",
|
||||
"access": "public"
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1,6 +1,19 @@
|
||||
import { version } from '../utilities/version.js';
|
||||
import { cyanBright, green, yellowBright } from 'colorette';
|
||||
|
||||
export function help({ flags }) {
|
||||
if (flags?.includes('v') || flags?.includes('version')) return version();
|
||||
console.log('This is the Sern CLI help section.\n\n' + 'Fill me up later!');
|
||||
export function help() {
|
||||
return `
|
||||
___ ___ _ __ _ __
|
||||
/ __|/ _ \\ '__| '_ \\
|
||||
\\__ \\ __/ | | | | |
|
||||
|___/\\___|_| |_| |_|
|
||||
|
||||
Welcome!
|
||||
If you're new to ${cyanBright('sern')}, run ${yellowBright(
|
||||
'sern init'
|
||||
)} for an interactive setup to your new bot project!
|
||||
|
||||
${green(
|
||||
`If you have any ideas, suggestions, bug reports, kindly join our support server: https://discord.gg/xzK5fUKT4r`
|
||||
)}
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import prompts from 'prompts';
|
||||
import ora from 'ora';
|
||||
import { redBright, yellowBright } from 'colorette';
|
||||
import { greenBright, redBright, yellowBright } from 'colorette';
|
||||
import { execa } from 'execa';
|
||||
import { findUp } from 'find-up';
|
||||
import {
|
||||
cmds_dir,
|
||||
default_prefix,
|
||||
lang,
|
||||
main_dir,
|
||||
gitInit,
|
||||
@@ -12,18 +12,27 @@ import {
|
||||
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 }) {
|
||||
/**
|
||||
* @param {{ y: string; sync: string; }} flags
|
||||
*/
|
||||
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)) {
|
||||
const { version } = process;
|
||||
const [major, minor] = version.split('.');
|
||||
const majorNum = parseInt(major.slice(1));
|
||||
const minorNum = parseInt(minor);
|
||||
|
||||
if (majorNum < 16 || (majorNum === 16 && minorNum < 10)) {
|
||||
console.log(
|
||||
yellowBright(
|
||||
`\nYou are using Node ${node.stdout}\nPlease upgrade to Node 16.10.x or higher!\n`
|
||||
`\nYou are using Node ${version}\nPlease upgrade to Node 16.10.x or higher!\n`
|
||||
)
|
||||
);
|
||||
|
||||
@@ -34,7 +43,7 @@ export async function init({ flags }) {
|
||||
let git_init;
|
||||
let pm;
|
||||
|
||||
if (flags?.includes('y')) {
|
||||
if (flags.y) {
|
||||
const projectName = await prompt([name]);
|
||||
git_init = true;
|
||||
pm = 'npm';
|
||||
@@ -43,21 +52,51 @@ export async function init({ flags }) {
|
||||
lang: 'typescript',
|
||||
main_dir: 'src',
|
||||
cmds_dir: 'commands',
|
||||
default_prefix: '!',
|
||||
};
|
||||
} else if (flags.sync) {
|
||||
data = await prompt([lang, main_dir, cmds_dir]);
|
||||
} else {
|
||||
data = await prompt([name, lang, main_dir, cmds_dir, default_prefix]);
|
||||
data = await prompt([name, lang, main_dir, cmds_dir]);
|
||||
git_init = (await prompt([gitInit])).gitinit;
|
||||
pm = await npm();
|
||||
}
|
||||
|
||||
if (Object.keys(data).length < 5) process.exit(1);
|
||||
const config = {
|
||||
language: data.lang,
|
||||
paths: {
|
||||
base: data.main_dir,
|
||||
commands: data.cmds_dir,
|
||||
},
|
||||
};
|
||||
|
||||
await cloneRepo(data.lang, data.name);
|
||||
const file = JSON.stringify(config, null, 2);
|
||||
|
||||
const requiredData = flags.sync !== undefined ? 3 : 4;
|
||||
const receivedData = Object.keys(data).length;
|
||||
const incompleteDataCondition = receivedData < requiredData;
|
||||
|
||||
if (incompleteDataCondition) process.exit(1);
|
||||
|
||||
if (!flags.sync) 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!');
|
||||
|
||||
if (pkg) {
|
||||
await writeFile(pkg.replace('package.json', 'sern.config.json'), file);
|
||||
}
|
||||
|
||||
if (flags.sync) {
|
||||
console.log('Project was successfully synced!');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
git_init ? await git(data) : console.log(`Skipping git init...\n`);
|
||||
|
||||
let choice = '';
|
||||
let choice;
|
||||
|
||||
if (pm === 'both') {
|
||||
const chosen = await prompt([which_manager]);
|
||||
@@ -69,7 +108,10 @@ export async function init({ flags }) {
|
||||
|
||||
await installDeps(choice, data.name);
|
||||
await editMain(data.name);
|
||||
await editDirs(data.main_dir, data.cmds_dir, data.name);
|
||||
await editDirs(data.main_dir, data.cmds_dir, data.name, data.lang);
|
||||
|
||||
console.log(`${greenBright('Success, project was initialised!')}`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
48
src/commands/plugins.js
Normal file
48
src/commands/plugins.js
Normal file
@@ -0,0 +1,48 @@
|
||||
import { pluginsQ } from '../prompts/plugin.js';
|
||||
import prompts from 'prompts';
|
||||
import { fetch } from 'undici';
|
||||
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 data = await fetch(url, { method: 'GET' })
|
||||
.then((res) => res.text())
|
||||
.catch(() => null);
|
||||
|
||||
if (!data) throw new Error('Download failed! Kindly contact developers');
|
||||
|
||||
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;
|
||||
}
|
||||
46
src/index.js
46
src/index.js
@@ -2,27 +2,37 @@
|
||||
|
||||
import { init } from './commands/init.js';
|
||||
import { help } from './commands/help.js';
|
||||
import { extra } from './commands/extra.js';
|
||||
|
||||
const regex = /(?<=--|-)\w+/gm;
|
||||
const rawArgs = process.argv.slice(2);
|
||||
const flags = rawArgs.join(' ').match(regex);
|
||||
import { Command } from 'commander';
|
||||
import { version } from './utilities/version.js';
|
||||
import { plugins } from './commands/plugins.js';
|
||||
export const program = new Command();
|
||||
|
||||
const args = rawArgs
|
||||
.join(' ')
|
||||
.trim()
|
||||
.split(/ +/)
|
||||
.filter((e) => !/(--|-)\w+/gm.test(e));
|
||||
program
|
||||
.name('sern')
|
||||
.description(help())
|
||||
.version(version())
|
||||
.exitOverride(() => process.exit(0));
|
||||
|
||||
const cmdName = args[0] || '';
|
||||
program
|
||||
.command(init.name)
|
||||
.description('Quickest way to scaffold a new project')
|
||||
.option('-y', 'Finishes setup as default')
|
||||
.option('-s, --sync', 'Syncs the project and generates sern.config.json')
|
||||
.action(init);
|
||||
|
||||
const commands = new Map([
|
||||
['help', help],
|
||||
['', help],
|
||||
['init', init],
|
||||
]);
|
||||
program
|
||||
.command(plugins.name)
|
||||
.description(
|
||||
'Install plugins from https://github.com/sern-handler/awesome-plugins'
|
||||
)
|
||||
.option('-n --name', 'Name of plugin')
|
||||
.action(plugins);
|
||||
|
||||
const found = commands.get(cmdName);
|
||||
program
|
||||
.command(extra.name)
|
||||
.description('Easy way to add extra things in your sern project')
|
||||
.action(extra);
|
||||
|
||||
if (found) {
|
||||
await found({ args, flags });
|
||||
} else console.log('Unknown Command');
|
||||
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',
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -9,25 +9,15 @@ export const lang = {
|
||||
title: 'JavaScript',
|
||||
description: 'JS',
|
||||
value: 'javascript',
|
||||
disabled: true,
|
||||
},
|
||||
{
|
||||
title: 'TypeScript',
|
||||
description: 'TS',
|
||||
description: 'TS - (Recommended)',
|
||||
value: 'typescript',
|
||||
selected: true,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const default_prefix = {
|
||||
message:
|
||||
'What is the default prefix for your bot? Type "none" if it is completely Application-Command based',
|
||||
name: 'prefix',
|
||||
type: 'text',
|
||||
initial: '!',
|
||||
};
|
||||
|
||||
export const main_dir = {
|
||||
message: 'What is the main directory of your project?',
|
||||
name: 'main_dir',
|
||||
@@ -40,7 +30,7 @@ export const cmds_dir = {
|
||||
name: 'cmds_dir',
|
||||
type: 'text',
|
||||
initial: 'commands',
|
||||
validate: (dir) =>
|
||||
validate: (/** @type {string} */ dir) =>
|
||||
dir === 'src' ? 'You can not use src as a directory' : true,
|
||||
};
|
||||
|
||||
@@ -99,7 +89,7 @@ export const name = {
|
||||
message: 'What is your project name?',
|
||||
name: 'name',
|
||||
type: 'text',
|
||||
validate: (name) =>
|
||||
validate: (/**@type {string}*/ name) =>
|
||||
name.match('^(?:@[a-z0-9-*~][a-z0-9-*._~]*/)?[a-z0-9-~][a-z0-9-._~]*$')
|
||||
? true
|
||||
: 'Invalid name',
|
||||
|
||||
32
src/prompts/plugin.js
Normal file
32
src/prompts/plugin.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import { fetch } from 'undici';
|
||||
import { getLang } from '../utilities/getLang.js';
|
||||
async function gimmechoices() {
|
||||
const lang =
|
||||
(await getLang().catch(() => null)) === 'typescript'
|
||||
? 'TypeScript'
|
||||
: 'JavaScript';
|
||||
const link = `https://api.github.com/repos/sern-handler/awesome-plugins/contents/${lang}`;
|
||||
|
||||
const resp = await fetch(link).catch(() => null);
|
||||
|
||||
if (!resp) return { title: 'No plugins found!', value: '', disabled: true };
|
||||
|
||||
const data = await resp.json();
|
||||
const choices = data.map(
|
||||
(/** @type {{ name: string; download_url: string; }} */ 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);
|
||||
}
|
||||
@@ -20,6 +20,15 @@ export async function editMain(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,
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -1,17 +1,15 @@
|
||||
import { execa } from 'execa';
|
||||
import { redBright } from 'colorette';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import { readFile } from 'fs/promises';
|
||||
import { findUp } from 'find-up';
|
||||
import ora from 'ora';
|
||||
import degit from 'degit';
|
||||
|
||||
/**
|
||||
* It installs dependencies from a package.json file
|
||||
* @param choice - The package manager to use.
|
||||
* @param name - The name of the project
|
||||
* @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) {
|
||||
@@ -27,7 +25,7 @@ export async function installDeps(choice, name) {
|
||||
if (!deps) throw new Error("Can't find dependencies.");
|
||||
|
||||
if (choice === 'skip') {
|
||||
return console.log('Skipped.');
|
||||
return console.log('Dependency installation skipped...');
|
||||
}
|
||||
|
||||
const spin = ora({
|
||||
@@ -40,7 +38,7 @@ export async function installDeps(choice, name) {
|
||||
}).catch(() => null);
|
||||
if (!result || result?.failed) {
|
||||
spin.fail(`${redBright('Failed')} to install dependencies!`);
|
||||
return process.exit(1);
|
||||
process.exit(1);
|
||||
} else spin.succeed(`Dependencies installed!`);
|
||||
}
|
||||
|
||||
@@ -50,18 +48,12 @@ export async function installDeps(choice, name) {
|
||||
* @param {string} name - The name of the project
|
||||
*/
|
||||
export async function cloneRepo(lang, name) {
|
||||
const isCached = fs.existsSync(
|
||||
path.join(os.homedir(), '.degit/github/sern-handler/templates')
|
||||
);
|
||||
const emitter = degit('sern-handler/templates/templates', {
|
||||
cache: isCached,
|
||||
force: true,
|
||||
});
|
||||
|
||||
await emitter.clone('templates');
|
||||
|
||||
copyRecursiveSync(`templates/${lang}`, name);
|
||||
fs.rmSync('templates', { recursive: true, force: true });
|
||||
await execa('git', [
|
||||
'clone',
|
||||
`https://github.com/sern-handler/templates.git`,
|
||||
]);
|
||||
copyRecursiveSync(`templates/templates/${lang}`, name);
|
||||
fs.rmSync(`templates/`, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +63,7 @@ export async function cloneRepo(lang, name) {
|
||||
* @param {string} src - The source path.
|
||||
* @param {string} dest - The destination folder where the files will be copied to.
|
||||
*/
|
||||
function copyRecursiveSync(src, dest) {
|
||||
export function copyRecursiveSync(src, dest) {
|
||||
const exists = fs.existsSync(src);
|
||||
|
||||
const stats = exists && fs.statSync(src);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createRequire } from 'module';
|
||||
const require = createRequire(import.meta.url);
|
||||
const { version: v } = require('../../package.json');
|
||||
|
||||
export function version() {
|
||||
console.log(`SernHandler CLI v${v}`);
|
||||
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