28 Commits

Author SHA1 Message Date
Jacob Nguyen
b369fdc196 Merge branch 'main' into experimental-serverless-build 2024-07-27 00:23:04 -05:00
Jacob Nguyen
6db6cf52a7 ea 2024-07-27 00:20:42 -05:00
Jacob Nguyen
7b99f02307 fix regression and clean up publish script 2024-06-13 00:01:12 -05:00
Jacob Nguyen
1990b3e158 add nonpromptable plugins install 2024-05-20 17:08:47 -05:00
Jacob Nguyen
08bb490d26 watch 2024-05-10 17:59:19 -05:00
Jacob Nguyen
4fb85d5f70 fix up typing gen for process env and watch mode 2024-05-10 17:57:03 -05:00
jacob
c69cc52b6f pluginify and simplify 2024-05-09 20:42:42 -05:00
jacob
fa3eb82aea extrapolate into plugin 2024-05-09 20:09:44 -05:00
jacob
21f483fc0f bundle presence and event modules 2024-05-03 16:14:42 -05:00
jacob
dc01c0cf79 fix merge 2024-05-03 15:56:11 -05:00
jacob
186b2fa2e5 b 2024-05-02 17:30:31 -05:00
jacob
8176da7801 out 2024-05-02 17:28:26 -05:00
Jacob Nguyen
4014fea984 prototype 2024-05-02 01:23:09 -05:00
jacob
cc6affb0a1 fix version gen 2024-05-01 17:40:16 -05:00
jacob
3ec56f951c consolidate 2024-05-01 17:25:16 -05:00
jacob
ec44400462 write handler 2024-05-01 17:11:44 -05:00
jacob
26de568c35 prg 2024-04-30 15:04:13 -05:00
Jacob Nguyen
925ff60134 /internal route 2024-04-29 00:08:26 -05:00
Jacob Nguyen
924810e1ac refactor out 2024-04-28 18:45:26 -05:00
jacob
f0fb5ff1b1 step 1 2024-04-28 13:50:56 -05:00
jacob
ca1c6e2869 fmt 2024-04-18 10:22:57 -05:00
Jacob Nguyen
524cf3770a more progress 2024-04-11 22:17:07 -05:00
Jacob Nguyen
e975d85d9b merge n progress 2024-04-11 18:59:05 -05:00
Jacob Nguyen
32628fa64b eol 2024-04-01 10:18:09 -05:00
Jacob Nguyen
1dadf54ad6 add 2024-03-29 00:11:40 -05:00
Jacob Nguyen
2465e8da1d plugin calling 2024-03-28 23:46:37 -05:00
Jacob Nguyen
fcca124c20 s 2024-03-22 02:32:11 -05:00
Jacob Nguyen
c9b2de0621 high hopes 2024-03-22 02:15:27 -05:00
13 changed files with 4180 additions and 4308 deletions

View File

@@ -42,7 +42,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
with:
node-version: 20
node-version: 17
- name: Install Node.js dependencies
run: npm i && npm run build

View File

@@ -2,53 +2,6 @@
All notable changes to this project will be documented in this file.
## [1.3.5](https://github.com/sern-handler/cli/compare/v1.3.4...v1.3.5) (2025-01-29)
### Bug Fixes
* Update Dockerfile.TS.sern ([#149](https://github.com/sern-handler/cli/issues/149)) ([fca3c76](https://github.com/sern-handler/cli/commit/fca3c7601604215af9b6d66a137370064ae656e1))
## [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)
### Bug Fixes
* make tsconfig work with comments/trailing commas ([#142](https://github.com/sern-handler/cli/issues/142)) ([53ca446](https://github.com/sern-handler/cli/commit/53ca446a38076ed7b165dbbb41f346f028b7e394))
## [1.3.1](https://github.com/sern-handler/cli/compare/v1.3.0...v1.3.1) (2024-07-27)
### Miscellaneous Chores
* release 1.3.1 ([2bb169f](https://github.com/sern-handler/cli/commit/2bb169f600172af8c8316b6c9420684a4de34e0d))
## [1.3.0](https://github.com/sern-handler/cli/compare/v1.2.1...v1.3.0) (2024-07-27)
### Features
* plugin, no prompt, bug fixes ([#139](https://github.com/sern-handler/cli/issues/139)) ([20364fa](https://github.com/sern-handler/cli/commit/20364fa20d1f3bf70a1c0cfefbc1d6c9365a4925))
### Bug Fixes
* fix publish command for bun & pnpm ([#137](https://github.com/sern-handler/cli/issues/137)) ([d581142](https://github.com/sern-handler/cli/commit/d581142f082ed888036e58aa33e9d88d84d34c2f))
## [1.2.1](https://github.com/sern-handler/cli/compare/v1.2.0...v1.2.1) (2024-02-08)

View File

@@ -61,23 +61,3 @@ 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
```

8196
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,63 +1,63 @@
{
"name": "@sern/cli",
"version": "1.3.5",
"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.2.1",
"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"
}
}

View File

@@ -10,7 +10,6 @@ import { pathExists, pathExistsSync } from 'find-up';
import { mkdir, writeFile, readFile } from 'fs/promises';
import * as Preprocessor from '../utilities/preprocessor';
import { bold, magentaBright } from 'colorette';
import { parseTsConfig } from '../utilities/parseTsconfig';
const VALID_EXTENSIONS = ['.ts', '.js' ];
@@ -44,11 +43,6 @@ type BuildOptions = {
* default to .env.
*/
env?: string;
/**
* flag: default false
*/
sourcemap?: boolean;
};
const CommandHandlerPlugin = (buildConfig: Partial<BuildOptions>, ambientFilePath: string, sernTsConfigPath: string) => {
@@ -81,7 +75,6 @@ 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');
@@ -91,7 +84,6 @@ 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: []
@@ -111,8 +103,8 @@ export async function build(options: Record<string, any>) {
}
assert(buildConfig.mode === 'development' || buildConfig.mode === 'production', 'Mode is not `production` or `development`');
try {
let config = await parseTsConfig(buildConfig.tsconfig!);
config?.extends && console.warn("Extend the generated tsconfig")
let config = JSON.parse(await readFile(buildConfig.tsconfig!, 'utf8'));
config.extends && console.warn("Extend the generated tsconfig")
} catch(e) {
console.error("no tsconfig / jsconfig found");
console.error(`Please create a ${sernConfig.language === 'javascript' ? 'jsconfig.json' : 'tsconfig.json' }`);
@@ -127,7 +119,6 @@ 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] =
@@ -147,7 +138,6 @@ 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!],
});

View File

@@ -11,7 +11,6 @@ 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 ??= [];
@@ -19,14 +18,13 @@ export async function publish(commandDir: string | undefined, args: Partial<Publ
const isBunOrPnpm = rootPath.pathname.includes('.bun') || rootPath.pathname.includes('.pnpm');
const esmLoader = new URL(`${isBunOrPnpm ? '../../' : '../'}node_modules/@esbuild-kit/esm-loader/dist/index.js`, rootPath);
await import('dotenv/config');
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);
// 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(), '--no-warnings'],
execArgv: ['--loader', esmLoader.toString(), '-r', fileURLToPath(dotenvLocation), '--no-warnings'],
});
// send paths object so we dont have to recalculate it in script
command.send({ config, preloads: args.import, commandDir });

View File

@@ -52,6 +52,15 @@ program //
.option('-y, --yes', "Say yes to all prompts")
.option('-e, --env [path]', "Supply a path to a .env")
.action(async (...args) => importDynamic('command-clear.js').then((m) => m.commandClear(...args))));
program
.command('app')
.description('manage your discord application')
.addCommand(
new Command('update')
.description("Refresh your discord application.")
.option('-W --suppress-warnings', 'suppress experimental warning')
.action(async (...args) => importDynamic('app-update.js').then(m => m.appUpdate(...args))))
program
.command('build')
.description('Build your bot')
@@ -61,7 +70,6 @@ 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)));

View File

@@ -1,7 +1,6 @@
import { findUp } from 'find-up';
import { readFile, rename, writeFile } from 'node:fs/promises';
import { fromCwd } from './fromCwd.js';
import { parseTsConfig } from './parseTsconfig.js';
/**
* It takes a string, finds the package.json file in the directory of the string, and changes the name
@@ -62,12 +61,10 @@ export async function editDirs(
});
if (tsconfig) {
const output = await parseTsConfig(tsconfig);
const output = JSON.parse(await readFile(tsconfig, 'utf8'));
if (!output) throw new Error("Can't read your tsconfig.json.");
if (!output.compilerOptions) throw new Error("Can't find compilerOptions in your tsconfig.json.");
output.compilerOptions.rootDir = srcName;
// This will strip comments/trailing commas from the tsconfig.json file
await writeFile(tsconfig, JSON.stringify(output, null, 2));
}

View File

@@ -1,50 +0,0 @@
import { resolve } from 'node:path';
import { readFile } from 'node:fs/promises';
interface CompilerOptions {
target: string;
module: string;
lib: string[];
allowJs: boolean;
checkJs: boolean;
jsx: string;
declaration: boolean;
sourceMap: boolean;
outDir: string;
rootDir: string;
strict: boolean;
esModuleInterop: boolean;
forceConsistentCasingInFileNames: boolean;
noEmit: boolean;
importHelpers: boolean;
isolatedModules: boolean;
moduleResolution: string;
resolveJsonModule: boolean;
noEmitHelpers: boolean;
}
interface TsConfig {
compilerOptions: CompilerOptions;
files: string[];
include: string[];
exclude: string[];
extends: string;
}
const cleanJson = (json: string) =>
json
.replace(/\/\/.*$/gm, '')
.replace(/\/\*[\s\S]*?\*\//gm, '')
.replace(/,\s*([}\]])/g, '$1');
export const parseTsConfig = async (path: string) => {
const absPath = resolve(path);
const fileContent = await readFile(absPath, 'utf-8');
const cleanContent = cleanJson(fileContent);
try {
return JSON.parse(cleanContent) as Partial<TsConfig>;
} catch (e) {
return null;
}
};

View File

@@ -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: 'node',
moduleResolution: 'node16',
strict: true,
skipLibCheck: true,
target: 'esnext',

View File

@@ -1,7 +1,5 @@
FROM node:latest
RUN npm install -g @sern/cli
WORKDIR /app
COPY package.json ./
@@ -10,6 +8,4 @@ RUN npm install
COPY . .
RUN sern build
CMD node .
CMD node src/index.js

View File

@@ -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 sern build
RUN tsc --build || npx -p typescript tsc --build
CMD node dist/index.js