20 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
18 changed files with 2573 additions and 528 deletions

View File

@@ -12,10 +12,10 @@ jobs:
steps: steps:
- name: Checkout Project - name: Checkout Project
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3 uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
- name: Use Node.js - name: Use Node.js
uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # tag=v3 uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with: with:
node-version: 17 node-version: 17
registry-url: 'https://registry.npmjs.org/' registry-url: 'https://registry.npmjs.org/'

View File

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

View File

@@ -15,10 +15,10 @@ jobs:
steps: steps:
- name: Check out Git repository - name: Check out Git repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3 uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
- name: Set up Node.js - name: Set up Node.js
uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # tag=v3 uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with: with:
node-version: 17 node-version: 17
registry-url: 'https://registry.npmjs.org' registry-url: 'https://registry.npmjs.org'

View File

@@ -17,10 +17,10 @@ jobs:
steps: steps:
- name: Check out Git repository - name: Check out Git repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3 uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
- name: Set up Node.js - name: Set up Node.js
uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # tag=v3 uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with: with:
node-version: 17 node-version: 17
@@ -37,10 +37,10 @@ jobs:
steps: steps:
- name: Check out Git repository - name: Check out Git repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3 uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
- name: Set up Node.js - name: Set up Node.js
uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # tag=v3 uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with: with:
node-version: 17 node-version: 17

View File

@@ -14,16 +14,16 @@ jobs:
steps: steps:
- name: Check out Git repository - name: Check out Git repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3 uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
- name: Set up Node.js - name: Set up Node.js
uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # tag=v3 uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with: with:
node-version: 17 node-version: 17
registry-url: 'https://registry.npmjs.org' registry-url: 'https://registry.npmjs.org'
- name: Install Node.js dependencies - name: Install Node.js dependencies
run: npm i run: npm i && npm run build
- name: Link Project - name: Link Project
run: npm link run: npm link

View File

@@ -12,15 +12,15 @@ jobs:
with: with:
release-type: node release-type: node
bump-patch-for-minor-pre-major: true bump-patch-for-minor-pre-major: true
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3 - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
if: ${{ steps.release.outputs.release_created }} if: ${{ steps.release.outputs.release_created }}
- uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # tag=v3 - uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with: with:
node-version: 17 node-version: 17
registry-url: 'https://registry.npmjs.org' registry-url: 'https://registry.npmjs.org'
if: ${{ steps.release.outputs.release_created }} if: ${{ steps.release.outputs.release_created }}
- run: npm i - run: npm i && npm run build
if: ${{ steps.release.outputs.release_created }} if: ${{ steps.release.outputs.release_created }}
- run: npm link - run: npm link
if: ${{ steps.release.outputs.release_created }} if: ${{ steps.release.outputs.release_created }}

View File

@@ -16,7 +16,7 @@ npm install -g @sern/cli@latest
``` ```
```sh ```sh
yarn add -g @sern/cli@latest yarn global add @sern/cli@latest
``` ```
```sh ```sh

2867
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -11,7 +11,7 @@
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"format": "prettier --check .", "format": "prettier --check .",
"fix": "prettier --write .", "fix": "prettier --write .",
"build": "tsc", "build": "tsup",
"watch": "tsc --watch" "watch": "tsc --watch"
}, },
"repository": { "repository": {
@@ -30,7 +30,7 @@
"bugs": { "bugs": {
"url": "https://github.com/sern-handler/cli/issues" "url": "https://github.com/sern-handler/cli/issues"
}, },
"homepage": "https://sern-handler.js.org", "homepage": "https://sern.dev",
"dependencies": { "dependencies": {
"colorette": "^2.0.16", "colorette": "^2.0.16",
"commander": "^9.3.0", "commander": "^9.3.0",
@@ -41,10 +41,12 @@
"undici": "^5.6.1" "undici": "^5.6.1"
}, },
"devDependencies": { "devDependencies": {
"@favware/npm-deprecate": "1.0.5", "@favware/npm-deprecate": "1.0.7",
"@types/prompts": "2.0.14", "@types/prompts": "2.4.3",
"prettier": "2.7.1", "esbuild-plugin-version-injector": "^1.0.3",
"typescript": "4.7.4" "prettier": "2.8.4",
"tsup": "^6.6.3",
"typescript": "4.9.5"
}, },
"engines": { "engines": {
"node": ">= 16.10.x" "node": ">= 16.10.x"

View File

@@ -1,7 +1,6 @@
import { cyanBright, green, magentaBright } from 'colorette'; import { cyanBright, green, magentaBright } from 'colorette';
export function help() { export const help = `
return `
___ ___ _ __ _ __ ___ ___ _ __ _ __
/ __|/ _ \\ '__| '_ \\ / __|/ _ \\ '__| '_ \\
\\__ \\ __/ | | | | | \\__ \\ __/ | | | | |
@@ -13,6 +12,5 @@ export function help() {
)} for an interactive setup to your new bot project! )} for an interactive setup to your new bot project!
${green( ${green(
`If you have any ideas, suggestions, bug reports, kindly join our support server: https://discord.gg/xzK5fUKT4r` `If you have any ideas, suggestions, bug reports, kindly join our support server: https://sern.dev/discord`
)}`; )}`;
}

View File

@@ -1,4 +1,4 @@
import { greenBright, redBright } from 'colorette'; import { greenBright, redBright, underline } from 'colorette';
import { execa } from 'execa'; import { execa } from 'execa';
import { findUp } from 'find-up'; import { findUp } from 'find-up';
import ora from 'ora'; import ora from 'ora';
@@ -98,19 +98,19 @@ async function git(data: Data) {
spinner: 'aesthetic', spinner: 'aesthetic',
}).start(); }).start();
const exe = await execa('git', ['init', data.name]); try {
await execa('git', ['init', data.name]);
await wait(300); 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!'); 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. */ /** Wait for a specified number of milliseconds, then return a promise that resolves to undefined. */

View File

@@ -1,14 +1,32 @@
import { greenBright } from 'colorette'; import { greenBright } from 'colorette';
import fs from 'fs'; import fs from 'fs';
import prompt from 'prompts'; import prompt from 'prompts';
import { fetch } from 'undici'; import { fetch, type Response } from 'undici';
import { pluginsQ } from '../prompts/plugin.js'; import { pluginsQ } from '../prompts/plugin.js';
import { fromCwd } from '../utilities/fromCwd.js'; import { fromCwd } from '../utilities/fromCwd.js';
/** /**
* Installs plugins to project * Installs plugins to project
*/ */
export async function plugins() {
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; const e: string[] = (await prompt([await pluginsQ()])).list;
if (!e) process.exit(1); if (!e) process.exit(1);
@@ -23,6 +41,15 @@ export async function plugins() {
); );
} }
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) { async function download(url: string) {
const data = await fetch(url, { method: 'GET' }) const data = await fetch(url, { method: 'GET' })
.then((res) => res.text()) .then((res) => res.text())
@@ -30,7 +57,7 @@ async function download(url: string) {
if (!data) throw new Error('Download failed! Kindly contact developers'); if (!data) throw new Error('Download failed! Kindly contact developers');
const dir = `${fromCwd('/src/plugins')}`; const dir = fromCwd('/src/plugins');
const filedir = `${process.cwd()}/src/plugins/${url.split('/').pop()}`; const filedir = `${process.cwd()}/src/plugins/${url.split('/').pop()}`;
if (!fs.existsSync(dir)) { if (!fs.existsSync(dir)) {
@@ -38,3 +65,9 @@ async function download(url: string) {
} }
fs.writeFileSync(filedir, data); fs.writeFileSync(filedir, data);
} }
interface PluginOptions {
name?: string[];
save: boolean
}

View File

@@ -6,13 +6,14 @@ import { init } from './commands/init.js';
import { Command } from 'commander'; import { Command } from 'commander';
import { plugins } from './commands/plugins.js'; import { plugins } from './commands/plugins.js';
import { version } from './utilities/version.js';
export const program = new Command(); export const program = new Command();
const version: string = '[VI]{{inject}}[/VI]';
program program
.name('sern') .name('sern')
.description(help()) .description(help)
.version(version()) .version(`sern CLI v${version}`)
.exitOverride(() => process.exit(0)); .exitOverride(() => process.exit(0));
program program
@@ -22,12 +23,13 @@ program
.option('-s, --sync', 'Syncs the project and generates sern.config.json') .option('-s, --sync', 'Syncs the project and generates sern.config.json')
.action(init); .action(init);
program const pluginCommand = program.command(plugins.name)
.command(plugins.name) pluginCommand
.description( .description(
'Install plugins from https://github.com/sern-handler/awesome-plugins' 'Get plugins from https://github.com/sern-handler/awesome-plugins'
) )
.option('-n --name', 'Name of plugin') .option('-n --name <string...>', 'Name(s) of plugin to install')
.option('-S --save', 'Save and keep plugins updated')
.action(plugins); .action(plugins);
program program

View File

@@ -41,3 +41,5 @@ interface Data {
name: string; name: string;
download_url: string; download_url: string;
} }

View File

@@ -36,6 +36,7 @@ export async function installDeps(choice: PackageManagerChoice, name: string) {
const result = await execa(choice, ['install'], { const result = await execa(choice, ['install'], {
cwd: process.cwd() + '/' + name, cwd: process.cwd() + '/' + name,
}).catch(() => null); }).catch(() => null);
if (!result || result?.failed) { if (!result || result?.failed) {
spin.fail(`${redBright('Failed')} to install dependencies!`); spin.fail(`${redBright('Failed')} to install dependencies!`);
process.exit(1); process.exit(1);
@@ -48,12 +49,21 @@ export async function installDeps(choice: PackageManagerChoice, name: string) {
* @param name - The name of the project * @param name - The name of the project
*/ */
export async function cloneRepo(lang: string, name: string) { export async function cloneRepo(lang: string, name: string) {
try {
await execa('git', [ await execa('git', [
'clone', 'clone',
`https://github.com/sern-handler/templates.git`, `https://github.com/sern-handler/templates.git`,
]); ]);
copyRecursiveSync(`templates/templates/${lang}`, name); copyRecursiveSync(`templates/templates/${lang}`, name);
fs.rmSync(`templates/`, { recursive: true, force: true }); 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);
}
} }
/** /**

View File

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

View File

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

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,
}
)