98 Commits

Author SHA1 Message Date
jacoobes
088c3eb6ac fix: homepage 2023-03-31 13:08:35 -05:00
jacoobes
68c096e689 chore: use constant instead of function 2023-03-31 12:57:07 -05:00
jacoobes
34bf4d004c merge corectly 2023-03-31 12:40:46 -05:00
jacoobes
309bf5224a merge 2023-03-31 12:40:04 -05:00
jacoobes
4382ce6d5e Merge branch 'main' into plugin-version-management 2023-03-31 12:39:03 -05:00
Jacob Nguyen
58fa3253f6 feat: version injector (#90) 2023-03-21 18:47:40 +05:30
renovate[bot]
1421136181 chore(deps): lock file maintenance (#71)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-11 23:33:28 -06:00
renovate[bot]
f29c7881fe chore(deps): update actions/setup-node digest to 64ed1c7 (#81)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com>
2023-03-11 23:29:39 -06:00
renovate[bot]
0d37da5689 chore(deps): update actions/checkout digest to ac59398 (#86)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-11 23:28:27 -06:00
renovate[bot]
504d36729e chore(deps): update dependency @favware/npm-deprecate to v1.0.7 (#88)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-11 23:26:34 -06:00
renovate[bot]
e391fddf20 chore(deps): update dependency @types/prompts to v2.4.3 (#83)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-11 23:23:16 -06:00
renovate[bot]
e5d6de4841 chore(deps): update dependency prettier to v2.8.4 (#87)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-11 23:19:00 -06:00
renovate[bot]
fc47847eeb chore(deps): update dependency typescript to v4.9.5 (#78)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-11 23:13:48 -06:00
jacoobes
731017f637 feat: add more methods 2023-02-16 12:07:16 -06:00
Jacob Nguyen
a3f5f1bf52 chore: update discord link (#89) 2023-02-16 11:46:11 -06:00
Jacob Nguyen
386b30aedd chore: update discord link 2023-02-16 11:43:11 -06:00
Duro
f2531a6f9b docs: fix yarn installation step in readme (#84) 2022-10-11 16:59:23 +05:30
69287ab1bd fix: git not installed errors during init (#79)
Co-authored-by: EvolutionX <evolutionx9777@gmail.com>
2022-09-22 12:38:49 +05:30
Evo
aa398a871c chore: i hate you github 2022-09-16 12:16:22 +05:30
Evo
0855abfea3 chore: ffs github 2022-09-16 12:13:07 +05:30
github-actions[bot]
6212fb3588 chore(main): release 0.5.0 (#77)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-09-16 12:10:23 +05:30
EvolutionX
2018c4381e chore: release 0.5.0
Release-As: 0.5.0
2022-09-16 12:06:24 +05:30
EvolutionX
5b0214a073 chore: for real.
permalink: http://whatthecommit.com/2466dab665a386b7b29018ac71f45033
2022-09-16 12:00:57 +05:30
Jacob Nguyen
6e6ed3136d docs(readme): add banner (#75) 2022-09-16 06:10:42 +05:30
EvolutionX
c302e1e4be chore: cmon github bruh 2022-09-13 10:31:15 +05:30
EvolutionX
e60fb42e3e chore: cmon github 2022-09-13 10:29:22 +05:30
EvolutionX
5e48f27584 chore: update help 2022-09-13 10:26:50 +05:30
EvolutionX
276b9656b8 ci: update to auto deprecate 2022-09-13 10:22:43 +05:30
EvolutionX
75dff367f5 ci: update testing 2.0 2022-09-13 10:10:24 +05:30
EvolutionX
90429523c3 ci: update testing 2022-09-13 10:06:46 +05:30
Tofix.js
bed31c1f49 feat!: re-write to TypeScript
Co-authored-by: Evo <85353424+EvolutionX-10@users.noreply.github.com>
2022-09-13 10:05:02 +05:30
Jacob Nguyen
9271da3076 feat: adds the esm template option + refactors (#73)
* feat: inline gimmeChoices returned value

* feat: add esm option

* feat: add config support for javascript-esm

* feat: add fromCwd.js util

* feat: transform repetitive paths to fromCwd

* feat: remove conditional branch in favor of transform

* refactor: extract condition into function

* style: prettier
2022-08-13 23:15:44 +05:30
Jacob Nguyen
2009d1fdca feat: add engine for node version & remove manual version check (#72)
cheers
2022-08-12 12:01:35 +05:30
Evo
f9aa2c3d20 chore: oops 2022-08-12 11:01:25 +05:30
Evo
3fa93bd903 ci: update again 2022-08-12 11:01:02 +05:30
Evo
e7c50c4d32 ci: update publish.yml 2022-08-12 10:53:09 +05:30
Evo
b1190efee3 chore: update description 2022-08-07 23:24:22 +05:30
renovate[bot]
55b1fff28e chore(deps): lock file maintenance (#69)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-08-01 08:51:46 +05:30
renovate[bot]
7bcbf55fb5 chore(deps): update dependency @favware/npm-deprecate to v1.0.5 (#68)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-07-31 10:32:16 +05:30
github-actions[bot]
ebc688022e chore(main): release 0.4.2 (#66)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-07-28 12:33:13 +05:30
renovate[bot]
810763837c chore(deps): lock file maintenance (#65)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-07-25 13:26:49 +05:30
renovate[bot]
fa331ae0c0 chore(deps): lock file maintenance (#64)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-07-25 08:37:41 +05:30
Evo
6c034a568f refactor(init): improve node version check (#63) 2022-07-22 19:22:54 +05:30
EvolutionX
9158e66bb4 chore(init): update naming of variable 2022-07-21 23:15:27 +05:30
renovate[bot]
af593bf84a chore(deps): update actions/setup-node digest to 2fddd88 (#60)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-07-18 09:39:56 +05:30
renovate[bot]
f84e7ac8f5 chore(deps): lock file maintenance (#61)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-07-18 09:24:27 +05:30
renovate[bot]
08b8a13d16 chore(deps): lock file maintenance (#59) 2022-07-11 15:28:32 +05:30
Evo
c4f8e45bdc feat: switch to undici (#58) 2022-07-10 11:09:22 +05:30
EvolutionX
83e841a341 chore: update scripts 2022-07-07 23:05:47 +05:30
EvolutionX
ab2f8016b6 chore: remove standard-version 2022-07-07 23:05:00 +05:30
github-actions[bot]
93ef62bc9d chore(main): release 0.4.1 (#57)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-07-07 22:49:09 +05:30
EvolutionX
e454ddaaab chore: stuff 2022-07-07 22:45:42 +05:30
EvolutionX
e3ee6d5428 chore: stuff 2022-07-07 22:43:39 +05:30
EvolutionX
02eec5f926 chore: stuff 2022-07-07 22:39:04 +05:30
EvolutionX
aa1e11b24a chore: stuff 2022-07-07 22:37:36 +05:30
EvolutionX
39817e6b4f chore: stuff 2022-07-07 22:36:06 +05:30
github-actions[bot]
a0d5890ea7 chore(main): release 0.4.0 (#56)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-07-07 22:34:55 +05:30
EvolutionX
2fa5a360ef chore: fix workflow 2022-07-07 22:33:24 +05:30
EvolutionX
1e07b5f1c8 chore: revert versions 2022-07-07 22:29:55 +05:30
EvolutionX
c312ca794c ci: update workflows 2022-07-07 22:24:45 +05:30
EvolutionX
eee3bb8db6 docs(changelog): update changelog 2022-07-07 22:04:43 +05:30
github-actions[bot]
d9ea304fa6 chore(main): release 0.3.0 (#55)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-07-07 21:53:27 +05:30
EvolutionX
52725ea7f6 ci: remove sign off 2022-07-07 21:50:26 +05:30
Evo
b24a053d1c feat(init): add --sync flag (#53) 2022-07-07 10:52:49 -05:00
EvolutionX
419b7bce22 chore: add .gitattributes to npmignore 2022-07-07 21:13:08 +05:30
EvolutionX
5a24ae4819 ci: new workflow release 2022-07-07 21:12:08 +05:30
EvolutionX
8f6b1c690f ci: rename release to publish 2022-07-07 21:03:26 +05:30
xxDeveloper
46ec745b88 docs(README): Remove stats (#52) 2022-07-07 20:26:46 +05:30
Evo
6472683c19 chore: add website as homepage 2022-07-06 09:14:15 +05:30
EvolutionX
2b260eb1bc chore(release): 0.2.2 2022-07-05 18:56:15 +05:30
EvolutionX
428b87ee1f chore(release): 0.2.1 2022-07-05 18:52:58 +05:30
renovate[bot]
493189772f chore(deps): lock file maintenance (#46)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-07-05 18:50:47 +05:30
renovate[bot]
dff1481e19 chore(deps): update dependency eslint to v8.19.0 (#51)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-07-05 13:18:29 +00:00
renovate[bot]
9264dde532 chore(deps): pin dependencies (#48)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-07-05 18:47:18 +05:30
renovate[bot]
ffc1e6f3eb chore(deps): update dependency cz-conventional-changelog to v3.3.0 (#41)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-07-05 18:44:50 +05:30
EvolutionX
95c20a3edf chore: update name and add npmignore 2022-07-03 09:36:31 +05:30
EvolutionX
c351bd5c0b chore: no 2022-06-29 13:12:58 +05:30
EvolutionX
f218e6524b ci: deprecations should now work 2022-06-29 13:10:10 +05:30
EvolutionX
afd0b46ffc ci: final final final update 2022-06-29 12:56:25 +05:30
EvolutionX
c730986264 ci: final final update 2022-06-29 12:52:30 +05:30
EvolutionX
03dddd4384 ci: final update 2022-06-29 12:49:16 +05:30
EvolutionX
177766e357 ci: update cd 2022-06-29 12:45:40 +05:30
EvolutionX
7cbde33af2 ci: update cd 2022-06-29 12:36:15 +05:30
EvolutionX
58922bf69e ci: update cd 2022-06-29 12:32:14 +05:30
EvolutionX
92b713e476 ci: update workflows 2022-06-29 12:24:27 +05:30
EvolutionX
94757d67cb chore(release): 0.2.1 2022-06-29 12:23:47 +05:30
EvolutionX
6253571095 ci: update stuff 2022-06-29 11:59:57 +05:30
EvolutionX
c4c9b11bc2 ci: npm version stuff 2022-06-29 11:50:10 +05:30
EvolutionX
e06ae29fa1 ci: update workflows 2022-06-29 11:32:25 +05:30
EvolutionX
d455a9ef30 ci: update delivery workflow 2022-06-29 11:14:55 +05:30
Jacob Nguyen
9bd2b0f38b feat: making sern help message look better, adding ascii art (#50) 2022-06-29 10:17:07 +05:30
Jacob Nguyen
330b2ee92d docs: add better instructions for readme (#49) 2022-06-28 23:05:45 +05:30
Evo
8c45327094 fix: avoid crashing of cli when no plugin found (#47) 2022-06-22 11:53:42 -05:00
EvolutionX
361e6451a7 ci: damn it 2022-06-22 13:02:44 +05:30
EvolutionX
81eabff53e ci: finally done 2022-06-22 12:58:06 +05:30
EvolutionX
d78c20a491 ci: testing npm 3x 2022-06-22 12:49:07 +05:30
EvolutionX
a97bfdf9ee ci: testing npm 2x 2022-06-22 12:42:03 +05:30
EvolutionX
7276c2cb21 ci: testing npm 2022-06-22 12:40:17 +05:30
38 changed files with 3870 additions and 6012 deletions

32
.github/workflows/auto-deprecate.yml vendored Normal file
View File

@@ -0,0 +1,32 @@
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@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
- name: Use Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
node-version: 17
registry-url: 'https://registry.npmjs.org/'
- name: Install Node.js dependencies
run: npm i
- name: Deprecate dev 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 }}
- name: Deprecate pr versions
run: npx npm-deprecate --name "*pr*" --package "@sern/cli" --message "This is a deprecated version of @sern/cli. Please use the latest version."
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

View File

@@ -38,7 +38,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL

View File

@@ -1,26 +1,30 @@
name: Continuous Delivery
on:
release:
types: [published]
push:
branches:
- main
paths:
- 'src/**'
- 'package.json'
jobs:
Build:
name: Building
Publish:
name: Publishing Dev
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
- name: Set up Node.js
uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # tag=v3
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
node-version: 17
registry-url: 'https://registry.npmjs.org'
- name: Install Node.js dependencies
run: npm i
run: npm i && npm run build
- name: Link Project
run: npm link
@@ -28,13 +32,9 @@ jobs:
- name: Test Sern
run: sern
Publish:
name: Publishing to npm
runs-on: ubuntu-latest
needs: [Build]
steps:
- name: Publish to npm
run: npm publish
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 }}

View File

@@ -17,10 +17,10 @@ jobs:
steps:
- name: Check out Git repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
- name: Set up Node.js
uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # tag=v3
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
node-version: 17
@@ -37,18 +37,18 @@ jobs:
steps:
- name: Check out Git repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
- name: Set up Node.js
uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # tag=v3
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
node-version: 17
- name: Install Node.js dependencies
run: npm i
run: npm i && npm run build
- name: Link Project
run: npm link
- name: Test Sern
- name: Test sern
run: sern

40
.github/workflows/publish.yml vendored Normal file
View File

@@ -0,0 +1,40 @@
name: Publish
on:
workflow_dispatch:
inputs:
prNumber:
description: The number of the PR that is being deployed
required: true
jobs:
Publish:
name: Publishing
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
- name: Set up Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
node-version: 17
registry-url: 'https://registry.npmjs.org'
- name: Install Node.js dependencies
run: npm i && npm run build
- name: Link Project
run: npm link
- name: Test sern
run: sern
- name: Publish to npm
run: |
TAG=$(echo 'pr-${{ github.event.inputs.prNumber }}')
npm version premajor --preid "${TAG}.$(git rev-parse --verify --short HEAD)" --git-tag-version=false
npm publish --tag ${TAG}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

32
.github/workflows/release-please.yml vendored Normal file
View 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@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
if: ${{ steps.release.outputs.release_created }}
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
node-version: 17
registry-url: 'https://registry.npmjs.org'
if: ${{ steps.release.outputs.release_created }}
- run: npm i && npm run build
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
View File

@@ -0,0 +1,6 @@
renovate.json
tsconfig.json
.prettierignore
.prettierrc
.gitattributes
.github/

View File

@@ -1,2 +1,3 @@
.github/
CHANGELOG.md
CHANGELOG.md
dist/

View File

@@ -1,6 +1,88 @@
# 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.5.0](https://github.com/sern-handler/cli/compare/v0.4.2...v0.5.0) (2022-09-16)
### ⚠ BREAKING CHANGES
* re-write to TypeScript
### Features
* add engine for node version & remove manual version check ([#72](https://github.com/sern-handler/cli/issues/72)) ([2009d1f](https://github.com/sern-handler/cli/commit/2009d1fdca9a383d219304fd3cb48a622355b7dc))
* adds the esm template option + refactors ([#73](https://github.com/sern-handler/cli/issues/73)) ([9271da3](https://github.com/sern-handler/cli/commit/9271da30764f86225385e8ae6448b99d66687294))
* re-write to TypeScript ([bed31c1](https://github.com/sern-handler/cli/commit/bed31c1f4995bbf7d8d0a483f562788172e29919))
### Miscellaneous Chores
* release 0.5.0 ([2018c43](https://github.com/sern-handler/cli/commit/2018c4381e665b9b0c5e70a203aa0dfd9fdd3cef))
## [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)

View File

@@ -1,6 +1,8 @@
# Sern CLI
<div align="center">
<img src="https://raw.githubusercontent.com/sern-handler/.github/main/cli.png" width="900px">
</div>
Our CLI allows you to setup and manage Discord bot projects without writing a single line of code!
# Features
😁 **User Friendly** <br>
💦 **Simple** <br>
@@ -14,7 +16,7 @@ npm install -g @sern/cli@latest
```
```sh
yarn add -g @sern/cli@latest
yarn global add @sern/cli@latest
```
```sh
@@ -25,12 +27,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
![Alt](https://repobeats.axiom.co/api/embed/5eb8cf0f79fecee29cc81cd2eca5f6321981304e.svg 'Feel free to contribute')
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

View File

@@ -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!'));

8696
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,19 +1,18 @@
{
"name": "@sern/cli",
"version": "0.2.0",
"description": "A CLI for @sern/handler",
"exports": "./src/index.js",
"version": "0.5.0",
"description": "Official CLI for @sern/handler",
"exports": "./dist/index.js",
"bin": {
"sern": "./src/index.js"
"sern": "./dist/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 ."
"fix": "prettier --write .",
"build": "tsup",
"watch": "tsc --watch"
},
"repository": {
"type": "git",
@@ -31,26 +30,29 @@
"bugs": {
"url": "https://github.com/sern-handler/cli/issues"
},
"homepage": "https://github.com/sern-handler/cli#readme",
"homepage": "https://sern.dev",
"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"
"prompts": "2.4.2",
"undici": "^5.6.1"
},
"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"
"@favware/npm-deprecate": "1.0.7",
"@types/prompts": "2.4.3",
"esbuild-plugin-version-injector": "^1.0.3",
"prettier": "2.8.4",
"tsup": "^6.6.3",
"typescript": "4.9.5"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
"engines": {
"node": ">= 16.10.x"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
}
}

View File

@@ -1,7 +1,6 @@
import prompts from 'prompts';
import prompt 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]);

View File

@@ -1,12 +0,0 @@
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;
}

16
src/commands/help.ts Normal file
View File

@@ -0,0 +1,16 @@
import { cyanBright, green, magentaBright } from 'colorette';
export const help = `
___ ___ _ __ _ __
/ __|/ _ \\ '__| '_ \\
\\__ \\ __/ | | | | |
|___/\\___|_| |_| |_|
Welcome!
If you're new to ${cyanBright('sern')}, run ${magentaBright(
'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://sern.dev/discord`
)}`;

View File

@@ -1,132 +0,0 @@
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);
}

136
src/commands/init.ts Normal file
View File

@@ -0,0 +1,136 @@
import { greenBright, redBright, underline } from 'colorette';
import { execa } from 'execa';
import { findUp } from 'find-up';
import ora from 'ora';
import prompt from 'prompts';
import {
cmds_dir,
gitInit,
lang,
main_dir,
name,
skip_install_dep,
which_manager,
} from '../prompts/init.js';
import { writeFile } from 'fs/promises';
import { editDirs, editMain } from '../utilities/edits.js';
import { cloneRepo, installDeps } from '../utilities/install.js';
import { npm } from '../utilities/npm.js';
import type { PackageManagerChoice } from '../utilities/types.js';
export async function init(flags: Flags) {
let data: PromptData;
let git_init = true; // the default;
let pm = flags.sync ? undefined : flags.y ? 'npm' : await npm();
if (flags.y) {
const projectName = await prompt([name]);
git_init = true;
data = {
name: projectName.name,
lang: 'typescript',
main_dir: 'src',
cmds_dir: 'commands',
};
} else if (flags.sync) {
data = (await prompt([lang, main_dir, cmds_dir])) as PromptData;
} else {
data = (await prompt([name, lang, main_dir, cmds_dir])) as PromptData;
git_init = (await prompt([gitInit])).gitinit;
}
const language = data.lang === 'javascript-esm' ? 'javascript' : data.lang;
const config = {
language,
paths: {
base: data.main_dir,
commands: data.cmds_dir,
},
};
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!');
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: PackageManagerChoice;
if (pm === 'both') {
choice = (await prompt([which_manager])).manager;
} else {
choice = (
(await prompt([skip_install_dep])).skip_install_dep ? pm : 'skip'
) as PackageManagerChoice;
}
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 */
async function git(data: Data) {
const spin = ora({
text: 'Initializing git...',
spinner: 'aesthetic',
}).start();
try {
await execa('git', ['init', data.name]);
await wait(300);
spin.succeed('Git initialized!');
} catch (error) {
spin.fail(
`${redBright(
'Failed'
)} to initialize git!\nTry to install it at ${underline(
'https://git-scm.com'
)}\nSkipping for now.`
);
}
}
/** Wait for a specified number of milliseconds, then return a promise that resolves to undefined. */
async function wait(ms: number) {
const wait = (await import('util')).promisify(setTimeout);
return wait(ms);
}
interface Data {
name: string;
}
interface Flags {
y: boolean;
sync: boolean;
}
interface PromptData {
name: string;
lang: 'typescript' | 'javascript' | 'javascript-esm';
main_dir: string;
cmds_dir: string;
}

View File

@@ -1,44 +0,0 @@
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;
}

73
src/commands/plugins.ts Normal file
View File

@@ -0,0 +1,73 @@
import { greenBright } from 'colorette';
import fs from 'fs';
import prompt from 'prompts';
import { fetch, type Response } from 'undici';
import { pluginsQ } from '../prompts/plugin.js';
import { fromCwd } from '../utilities/fromCwd.js';
/**
* Installs plugins to project
*/
function dispatchSave() {
}
function dispatchInstall() {
}
export async function plugins(options: PluginOptions) {
if(options.save) {
dispatchSave()
}
//Download instead based on names given. Must be a full filename ie: (publish)
if(options.name) {
const pluginSource = await downloa();
}
const e: string[] = (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')
)}`
);
}
async function downloa(url: string | URL) {
const formatText = (res: Response) => res.text()
return fetch(url, { method: 'GET' })
.then(formatText)
.catch(() => {
throw Error('Download failed! Kindly contact developers')
})
}
async function download(url: string) {
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 = fromCwd('/src/plugins');
const filedir = `${process.cwd()}/src/plugins/${url.split('/').pop()}`;
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, { recursive: true });
}
fs.writeFileSync(filedir, data);
}
interface PluginOptions {
name?: string[];
save: boolean
}

View File

@@ -1,34 +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 { help } from './commands/help.js';
import { init } from './commands/init.js';
import { Command } from 'commander';
import { version } from './utilities/version.js';
import { plugins } from './commands/plugins.js';
export const program = new Command();
const version: string = '[VI]{{inject}}[/VI]';
program
.name('sern')
.description(help())
.version(version())
.description(help)
.version(`sern CLI v${version}`)
.exitOverride(() => process.exit(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);
program
.command(plugins.name)
.description(
'Install plugins from https://github.com/sern-handler/awesome-plugins'
)
.option('-n --name', 'Name of plugin')
.action(plugins);
const pluginCommand = program.command(plugins.name)
pluginCommand
.description(
'Get plugins from https://github.com/sern-handler/awesome-plugins'
)
.option('-n --name <string...>', 'Name(s) of plugin to install')
.option('-S --save', 'Save and keep plugins updated')
.action(plugins);
program
.command(extra.name)
.description('Easy way to add extra things in your sern project')

View File

@@ -1,4 +1,6 @@
export const extraPrompt = {
import type { PromptObject } from 'prompts';
export const extraPrompt: PromptObject = {
message: 'What extra feature do you want to add?',
name: 'extra',
type: 'select',

View File

@@ -1,6 +1,7 @@
import { blueBright } from 'colorette';
import type { PromptObject } from 'prompts';
export const lang = {
export const lang: PromptObject = {
message: 'What language do you want the project to be in?',
name: 'lang',
type: 'select',
@@ -10,6 +11,11 @@ export const lang = {
description: 'JS',
value: 'javascript',
},
{
title: 'JavaScript (ESM)',
description: 'JS',
value: 'javascript-esm',
},
{
title: 'TypeScript',
description: 'TS - (Recommended)',
@@ -18,40 +24,37 @@ export const lang = {
],
};
export const main_dir = {
export const main_dir: PromptObject = {
message: 'What is the main directory of your project?',
name: 'main_dir',
type: 'text',
initial: 'src',
};
export const cmds_dir = {
export const cmds_dir: PromptObject = {
message: 'What is the directory of your commands?',
name: 'cmds_dir',
type: 'text',
initial: 'commands',
validate: (/** @type {string} */ dir) =>
validate: (dir: string) =>
dir === 'src' ? 'You can not use src as a directory' : true,
};
/**
* @type {import('prompts').PromptObject}
*/
export const npmInit = {
export const npmInit: PromptObject = {
name: 'npm_init',
type: 'confirm',
message: `Do you want ${blueBright('me')} to initialize npm?`,
initial: true,
};
export const gitInit = {
export const gitInit: PromptObject = {
name: 'gitinit',
type: 'confirm',
message: `Do you want to ${blueBright('me')} to initialize git?`,
initial: true,
};
export const which_manager = {
export const which_manager: PromptObject = {
message: `Which manager do you want to use?`,
name: 'manager',
type: 'select',
@@ -75,21 +78,18 @@ export const which_manager = {
],
};
export const skip_install_dep = {
export const skip_install_dep: PromptObject = {
name: 'skip_install_dep',
type: 'confirm',
message: `Do you want ${blueBright('me')} to install dependencies?`,
initial: false,
};
/**
* @type {import('prompts').PromptObject}
*/
export const name = {
export const name: PromptObject = {
message: 'What is your project name?',
name: 'name',
type: 'text',
validate: (/**@type {string}*/ name) =>
validate: (name: string) =>
name.match('^(?:@[a-z0-9-*~][a-z0-9-*._~]*/)?[a-z0-9-~][a-z0-9-._~]*$')
? true
: 'Invalid name',

View File

@@ -1,24 +0,0 @@
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,
};
}

45
src/prompts/plugin.ts Normal file
View File

@@ -0,0 +1,45 @@
import type { Choice, PromptObject } from 'prompts';
import { fetch } from 'undici';
import { getLang } from '../utilities/getLang.js';
function upperCase(string: string | null) {
if (string === null) {
console.error('Lang property not found!');
process.exit(0);
}
return string === 'typescript' ? 'TypeScript' : 'JavaScript';
}
async function gimmechoices(): Promise<Choice[]> {
const lang = upperCase(await getLang().catch(() => null));
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()) as Data[];
const choices = data.map((e) => ({
title: e.name,
value: e.download_url,
}));
return choices;
}
export async function pluginsQ(): Promise<PromptObject> {
return {
name: 'list',
type: 'autocompleteMultiselect',
message: 'What plugins do you want to install?',
choices: await gimmechoices(),
min: 1,
};
}
interface Data {
name: string;
download_url: string;
}

View File

@@ -1,7 +1,7 @@
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);
import { mkdir, readFile, writeFile } from 'fs/promises';
import { dirname, resolve } from 'node:path';
import { fileURLToPath, URL } from 'url';
const root = new URL('../../', import.meta.url);
const templates = new URL('./templates/', root);
const extraURL = new URL('./extra/', templates);
@@ -9,13 +9,17 @@ 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
* @param name - The name of the file.
* @param lang - The language you want to use.
* @param location - The location of the file to be created.
* @param no_ext - If true, the file will be created without an extension.
*/
export async function create(name, lang, location, no_ext) {
export async function create(
name: string,
lang: string,
location: string,
no_ext: boolean
) {
const file = `${name}.${lang}.sern`;
const target = no_ext
@@ -27,10 +31,10 @@ export async function create(name, lang, location, no_ext) {
/**
* 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.
* @param template - The name of the file to be created.
* @param target - The location of the file to be created.
*/
async function createFile(template, target) {
async function createFile(template: string, target: string) {
const location = `${extraFolder}${template}`;
const file = await readFile(location, 'utf8');
@@ -40,11 +44,11 @@ async function createFile(template, target) {
/**
* 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.
* @param target - The path to the file you want to write to.
* @param 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) {
async function writeFileRecursive(target: string, data: string) {
const resolvedTarget = resolve(target);
const dir = dirname(resolvedTarget);

View File

@@ -1,16 +1,16 @@
import { readFile, rename, writeFile } from 'node:fs/promises';
import { findUp } from 'find-up';
import { readFile, rename, writeFile } from 'node:fs/promises';
import { fromCwd } from './fromCwd.js';
/**
* 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.
* @param name - The name of the project.
*/
export async function editMain(name) {
const pjLocation = await findUp('package.json', {
cwd: process.cwd() + '/' + name,
});
export async function editMain(name: string) {
const pjLocation = (await findUp('package.json', {
cwd: fromCwd('/' + name),
})) as string;
const output = JSON.parse(await readFile(pjLocation, 'utf8'));
if (!output) throw new Error("Can't read your package.json.");
@@ -23,36 +23,35 @@ export async function editMain(name) {
/**
* 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
* @param srcName - The name of the folder that will contain your main files.
* @param cmds_dirName - The name of the directory where your commands will be stored.
* @param name - The name of the folder you want to edit.
* @param lang - The language you want to use.
*/
export async function editDirs(
srcName,
cmds_dirName,
name,
lang = 'typescript'
srcName: string,
cmds_dirName: string,
name: string,
lang: 'javascript' | 'typescript' | 'javascript-esm' = 'typescript'
) {
const path = await findUp('src', {
cwd: process.cwd() + '/' + name,
const path = (await findUp('src', {
cwd: fromCwd(name),
type: 'directory',
});
})) as string;
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,
const cmdsPath = (await findUp('commands', {
cwd: fromCwd(name, srcName),
type: 'directory',
});
})) as string;
const index = await findUp(`index.${ext}`, {
cwd: process.cwd() + '/' + name + '/' + srcName,
});
const index = (await findUp(`index.${ext}`, {
cwd: fromCwd(name, srcName),
})) as string;
const newCmdsPath = cmdsPath?.replace('commands', cmds_dirName);
await rename(cmdsPath, newCmdsPath);
@@ -66,7 +65,7 @@ export async function editDirs(
if (!output) throw new Error("Can't read your tsconfig.json.");
output.compilerOptions.rootDir = srcName;
writeFile(tsconfig, JSON.stringify(output, null, 2));
await writeFile(tsconfig, JSON.stringify(output, null, 2));
}
const output = await readFile(index, 'utf8');

5
src/utilities/fromCwd.ts Normal file
View File

@@ -0,0 +1,5 @@
import path from 'path';
export function fromCwd(...dir: string[]) {
return path.join(...[process.cwd(), ...dir]);
}

View File

@@ -3,9 +3,9 @@ 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.
* @returns The language of the project.
*/
export async function getLang() {
export async function getLang(): Promise<'typescript' | 'javascript'> {
const sernLocation = await findUp('sern.config.json');
if (!sernLocation) throw new Error("Can't find sern.config.json");

View File

@@ -1,18 +1,18 @@
import { execa } from 'execa';
import { redBright } from 'colorette';
import fs from 'fs';
import path from 'path';
import { readFile } from 'fs/promises';
import { execa } from 'execa';
import { findUp } from 'find-up';
import fs from 'fs';
import { readFile } from 'fs/promises';
import ora from 'ora';
import path from 'path';
import type { PackageManagerChoice } from './types';
/**
* 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.
* @param choice - The package manager to use.
* @param name - The name of the project
*/
export async function installDeps(choice, name) {
export async function installDeps(choice: PackageManagerChoice, name: string) {
const pkg = await findUp('package.json', {
cwd: process.cwd() + '/' + name,
});
@@ -36,6 +36,7 @@ export async function installDeps(choice, name) {
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);
@@ -44,29 +45,38 @@ export async function installDeps(choice, name) {
/**
* 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
* @param lang - The language of the template
* @param 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 });
export async function cloneRepo(lang: string, name: string) {
try {
await execa('git', [
'clone',
`https://github.com/sern-handler/templates.git`,
]);
copyRecursiveSync(`templates/templates/${lang}`, name);
fs.rmSync(`templates/`, { recursive: true, force: true });
} catch (error) {
console.log(
`${redBright(
'✖ Failed'
)} to clone github templates repo. Install git and try again!`
);
process.exit(1);
}
}
/**
* 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.
* @param src - The source path.
* @param dest - The destination folder where the files will be copied to.
*/
export function copyRecursiveSync(src, dest) {
export function copyRecursiveSync(src: string, dest: string) {
const exists = fs.existsSync(src);
const stats = exists && fs.statSync(src);
const stats = (exists && fs.statSync(src)) as fs.Stats;
const isDirectory = exists && stats.isDirectory();
if (isDirectory) {
@@ -82,8 +92,3 @@ export function copyRecursiveSync(src, dest) {
fs.copyFileSync(src, dest);
}
}
// async function wait(ms) {
// const wait = (await import('util')).promisify(setTimeout);
// return wait(ms);
// }

10
src/utilities/types.ts Normal file
View File

@@ -0,0 +1,10 @@
export type PackageManagerChoice = 'skip' | 'npm' | 'yarn';
export interface Config {
language: string;
paths : {
base: string;
commands: string;
}
}

View File

@@ -1,7 +0,0 @@
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
export function version() {
const { version: v } = require('../../package.json');
return `SernHandler CLI v${v}`;
}

6
src/utilities/version.ts Normal file
View File

@@ -0,0 +1,6 @@
import { requiree } from "..";
export function version() {
const { version: v } = requiree('../../package.json');
return `@sern/cli v${v}`;
}

View File

@@ -1,17 +1,18 @@
{
"compilerOptions": {
"target": "ES2022",
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "NodeNext",
"lib": ["es2017", "dom"],
"allowJs": true,
"checkJs": true,
"noEmit": true,
"strict": false,
"noImplicitThis": true,
"alwaysStrict": true,
"moduleResolution": "Node",
"outDir": "dist",
"rootDir": "src",
"declaration": true,
"declarationMap": true,
"strict": true,
"esModuleInterop": true,
"resolveJsonModule": true
},
"include": ["test", "src"]
"noImplicitAny": true,
"strictNullChecks": true,
"importsNotUsedAsValues": "error",
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
}
}

19
tsup.config.ts Normal file
View File

@@ -0,0 +1,19 @@
import { defineConfig } from 'tsup'
import { esbuildPluginVersionInjector } from 'esbuild-plugin-version-injector';
const shared = {
entry: ['src/index.ts'],
platform: 'node',
clean: true,
sourcemap: true,
};
export default defineConfig(
{
format: 'esm',
target: 'node16',
tsconfig: './tsconfig.json',
outDir: './dist',
treeshake: true,
esbuildPlugins: [esbuildPluginVersionInjector()],
...shared,
}
)