mirror of
https://github.com/sern-handler/cli
synced 2026-06-06 01:16:53 +00:00
Compare commits
7 Commits
v1.3.2
...
jacoobes-p
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
898cae0f12 | ||
|
|
7f4203370c | ||
|
|
23d70c6e03 | ||
|
|
90fae47ff4 | ||
|
|
9d2c7979dd | ||
|
|
9c2d6d7389 | ||
|
|
24e97a3695 |
2
.github/workflows/continuous-integration.yml
vendored
2
.github/workflows/continuous-integration.yml
vendored
@@ -42,7 +42,7 @@ jobs:
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
|
||||
with:
|
||||
node-version: 17
|
||||
node-version: 20
|
||||
|
||||
- name: Install Node.js dependencies
|
||||
run: npm i && npm run build
|
||||
|
||||
14
CHANGELOG.md
14
CHANGELOG.md
@@ -2,6 +2,20 @@
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [1.3.4](https://github.com/sern-handler/cli/compare/v1.3.3...v1.3.4) (2025-01-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* tsconfig generator ([#145](https://github.com/sern-handler/cli/issues/145)) ([23d70c6](https://github.com/sern-handler/cli/commit/23d70c6e03860d1a69e3bffedd6910aba82071ab))
|
||||
|
||||
## [1.3.3](https://github.com/sern-handler/cli/compare/v1.3.2...v1.3.3) (2024-08-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* bunpnpminstall ([9c2d6d7](https://github.com/sern-handler/cli/commit/9c2d6d7389c41a071ab86570cebf987b02bbf450))
|
||||
|
||||
## [1.3.2](https://github.com/sern-handler/cli/compare/v1.3.1...v1.3.2) (2024-07-31)
|
||||
|
||||
|
||||
|
||||
20
README.md
20
README.md
@@ -61,3 +61,23 @@ Run `npm create @sern/bot` for an interactive setup on a brand new project using
|
||||
|
||||
sern runs on your plugins. Contribute to our [repository](https://github.com/sern-handler/awesome-plugins) and then install the plugins via our cli! <br>
|
||||
Run `sern plugins` to see all installable plugins.
|
||||
|
||||
|
||||
## Development
|
||||
|
||||
```sh
|
||||
git clone https://github.com/sern-handler/cli.git
|
||||
```
|
||||
## insall i
|
||||
```sh
|
||||
npm i
|
||||
```
|
||||
## build it
|
||||
```sh
|
||||
npm run build
|
||||
```
|
||||
## make it usable globally
|
||||
- if sern is installed globally already, you may need to uninstall it.
|
||||
```sh
|
||||
npm link
|
||||
```
|
||||
|
||||
8200
package-lock.json
generated
8200
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
122
package.json
122
package.json
@@ -1,63 +1,63 @@
|
||||
{
|
||||
"name": "@sern/cli",
|
||||
"version": "1.3.2",
|
||||
"description": "Official CLI for @sern/handler",
|
||||
"exports": "./dist/index.js",
|
||||
"bin": {
|
||||
"sern": "./dist/index.js"
|
||||
},
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"format": "prettier --check .",
|
||||
"fix": "prettier --write .",
|
||||
"build": "tsup",
|
||||
"watch": "tsup --watch"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sern-handler/cli.git"
|
||||
},
|
||||
"keywords": [
|
||||
"cli",
|
||||
"discord",
|
||||
"discord.js",
|
||||
"sern",
|
||||
"sern-handler"
|
||||
],
|
||||
"author": "EvolutionX",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/sern-handler/cli/issues"
|
||||
},
|
||||
"homepage": "https://sern.dev",
|
||||
"dependencies": {
|
||||
"@esbuild-kit/cjs-loader": "^2.4.2",
|
||||
"@esbuild-kit/esm-loader": "^2.5.5",
|
||||
"colorette": "2.0.20",
|
||||
"commander": "11.0.0",
|
||||
"dotenv": "^16.3.1",
|
||||
"esbuild": "^0.19.1",
|
||||
"execa": "7.2.0",
|
||||
"find-up": "6.3.0",
|
||||
"glob": "^10.3.3",
|
||||
"ora": "6.3.1",
|
||||
"prompts": "2.4.2",
|
||||
"undici": "5.23.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/parser": "^7.22.5",
|
||||
"@favware/npm-deprecate": "1.0.7",
|
||||
"@types/prompts": "2.4.4",
|
||||
"prettier": "2.8.8",
|
||||
"tsup": "^6.7.0",
|
||||
"typescript": "5.2.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18.16.x"
|
||||
},
|
||||
"publishConfig": {
|
||||
"registry": "https://registry.npmjs.org/",
|
||||
"access": "public"
|
||||
}
|
||||
"name": "@sern/cli",
|
||||
"version": "1.3.4",
|
||||
"description": "Official CLI for @sern/handler",
|
||||
"exports": "./dist/index.js",
|
||||
"bin": {
|
||||
"sern": "./dist/index.js"
|
||||
},
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"format": "prettier --check .",
|
||||
"fix": "prettier --write .",
|
||||
"build": "tsup",
|
||||
"watch": "tsup --watch"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sern-handler/cli.git"
|
||||
},
|
||||
"keywords": [
|
||||
"cli",
|
||||
"discord",
|
||||
"discord.js",
|
||||
"sern",
|
||||
"sern-handler"
|
||||
],
|
||||
"author": "EvolutionX",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/sern-handler/cli/issues"
|
||||
},
|
||||
"homepage": "https://sern.dev",
|
||||
"dependencies": {
|
||||
"@esbuild-kit/cjs-loader": "^2.4.2",
|
||||
"@esbuild-kit/esm-loader": "^2.5.5",
|
||||
"colorette": "2.0.20",
|
||||
"commander": "11.0.0",
|
||||
"dotenv": "^16.3.1",
|
||||
"esbuild": "^0.19.1",
|
||||
"execa": "7.2.0",
|
||||
"find-up": "6.3.0",
|
||||
"glob": "^10.3.3",
|
||||
"ora": "6.3.1",
|
||||
"prompts": "2.4.2",
|
||||
"undici": "5.23.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/parser": "^7.22.5",
|
||||
"@favware/npm-deprecate": "1.0.7",
|
||||
"@types/prompts": "2.4.4",
|
||||
"prettier": "2.8.8",
|
||||
"tsup": "^6.7.0",
|
||||
"typescript": "5.2.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18.16.x"
|
||||
},
|
||||
"publishConfig": {
|
||||
"registry": "https://registry.npmjs.org/",
|
||||
"access": "public"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,11 @@ type BuildOptions = {
|
||||
* default to .env.
|
||||
*/
|
||||
env?: string;
|
||||
/**
|
||||
* flag: default false
|
||||
*/
|
||||
sourcemap?: boolean;
|
||||
|
||||
};
|
||||
|
||||
const CommandHandlerPlugin = (buildConfig: Partial<BuildOptions>, ambientFilePath: string, sernTsConfigPath: string) => {
|
||||
@@ -76,6 +81,7 @@ export async function build(options: Record<string, any>) {
|
||||
if (!options.supressWarnings) {
|
||||
console.info(`${magentaBright('EXPERIMENTAL')}: This API has not been stabilized. add -W or --suppress-warnings flag to suppress`);
|
||||
}
|
||||
console.log(options)
|
||||
const sernConfig = await getConfig();
|
||||
let buildConfig: BuildOptions;
|
||||
const buildConfigPath = p.resolve(options.project ?? 'sern.build.js');
|
||||
@@ -85,6 +91,7 @@ export async function build(options: Record<string, any>) {
|
||||
format: options.format ?? 'esm',
|
||||
mode: options.mode ?? 'development',
|
||||
dropLabels: [],
|
||||
sourcemap: options.sourceMaps,
|
||||
tsconfig: resolveBuildConfig(options.tsconfig, sernConfig.language),
|
||||
env: options.env ?? '.env',
|
||||
include: []
|
||||
@@ -120,6 +127,7 @@ export async function build(options: Record<string, any>) {
|
||||
console.log(' ', magentaBright('mode'), buildConfig.mode);
|
||||
console.log(' ', magentaBright('tsconfig'), buildConfig.tsconfig);
|
||||
console.log(' ', magentaBright('env'), buildConfig.env);
|
||||
console.log(' ', magentaBright('sourceMaps'), buildConfig.sourcemap);
|
||||
|
||||
const sernDir = p.resolve('.sern'),
|
||||
[ambientFilePath, sernTsConfigPath, genDir] =
|
||||
@@ -139,6 +147,7 @@ export async function build(options: Record<string, any>) {
|
||||
const ctx = await esbuild.context({
|
||||
entryPoints,
|
||||
plugins: [CommandHandlerPlugin(buildConfig, ambientFilePath, sernTsConfigPath)],
|
||||
sourcemap: buildConfig.sourcemap,
|
||||
...defaultEsbuild(buildConfig.format!, buildConfig.tsconfig),
|
||||
dropLabels: [buildConfig.mode === 'production' ? '__DEV__' : '__PROD__', ...buildConfig.dropLabels!],
|
||||
});
|
||||
|
||||
@@ -11,6 +11,7 @@ export async function publish(commandDir: string | undefined, args: Partial<Publ
|
||||
// pass in args into the command.
|
||||
const rootPath = new URL('../', import.meta.url),
|
||||
publishScript = new URL('../dist/create-publish.js', rootPath);
|
||||
|
||||
// assign args.import to empty array if non existent
|
||||
args.import ??= [];
|
||||
|
||||
@@ -18,13 +19,14 @@ export async function publish(commandDir: string | undefined, args: Partial<Publ
|
||||
|
||||
const isBunOrPnpm = rootPath.pathname.includes('.bun') || rootPath.pathname.includes('.pnpm');
|
||||
|
||||
const dotenvLocation = new URL(`${isBunOrPnpm ? '../../' : '../'}node_modules/dotenv/config.js`, rootPath),
|
||||
esmLoader = new URL(`${isBunOrPnpm ? '../../' : '../'}node_modules/@esbuild-kit/esm-loader/dist/index.js`, rootPath);
|
||||
const esmLoader = new URL(`${isBunOrPnpm ? '../../' : '../'}node_modules/@esbuild-kit/esm-loader/dist/index.js`, rootPath);
|
||||
|
||||
await import('dotenv/config');
|
||||
|
||||
// We dynamically load the create-publish script in a child process so that we can pass the special
|
||||
// loader flag to require typescript files
|
||||
const command = fork(fileURLToPath(publishScript), [], {
|
||||
execArgv: ['--loader', esmLoader.toString(), '-r', fileURLToPath(dotenvLocation), '--no-warnings'],
|
||||
execArgv: ['--loader', esmLoader.toString(), '--no-warnings'],
|
||||
});
|
||||
// send paths object so we dont have to recalculate it in script
|
||||
command.send({ config, preloads: args.import, commandDir });
|
||||
|
||||
@@ -61,6 +61,7 @@ program
|
||||
.option('-W --suppress-warnings', 'suppress experimental warning')
|
||||
.option('-p --project [filePath]', 'build with the provided sern.build file')
|
||||
.option('-e --env', 'path to .env file')
|
||||
.option('--source-maps', 'Whether to add source-maps to configuration', false)
|
||||
.option('--tsconfig [filePath]', 'Use this tsconfig')
|
||||
.action(async (...args) => importDynamic('build.js').then((m) => m.build(...args)));
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ const writeTsConfig = async (format: 'cjs' | 'esm', configPath: string, fw: File
|
||||
compilerOptions: {
|
||||
//module determines top level await. CJS doesn't have that abliity afaik
|
||||
module: format === 'cjs' ? 'node' : 'esnext',
|
||||
moduleResolution: 'node16',
|
||||
moduleResolution: 'node',
|
||||
strict: true,
|
||||
skipLibCheck: true,
|
||||
target: 'esnext',
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
FROM node:latest
|
||||
|
||||
RUN npm install -g @sern/cli typescript@latest
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json ./
|
||||
|
||||
RUN npm install
|
||||
|
||||
RUN npm install -D typescript
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN tsc --build || npx -p typescript tsc --build
|
||||
RUN sern build
|
||||
|
||||
CMD node dist/index.js
|
||||
|
||||
Reference in New Issue
Block a user