mirror of
https://github.com/sern-handler/cli
synced 2026-06-27 02:02:20 +00:00
Compare commits
28 Commits
v1.3.2
...
experiment
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b369fdc196 | ||
|
|
6db6cf52a7 | ||
|
|
7b99f02307 | ||
|
|
1990b3e158 | ||
|
|
08bb490d26 | ||
|
|
4fb85d5f70 | ||
|
|
c69cc52b6f | ||
|
|
fa3eb82aea | ||
|
|
21f483fc0f | ||
|
|
dc01c0cf79 | ||
|
|
186b2fa2e5 | ||
|
|
8176da7801 | ||
|
|
4014fea984 | ||
|
|
cc6affb0a1 | ||
|
|
3ec56f951c | ||
|
|
ec44400462 | ||
|
|
26de568c35 | ||
|
|
925ff60134 | ||
|
|
924810e1ac | ||
|
|
f0fb5ff1b1 | ||
|
|
ca1c6e2869 | ||
|
|
524cf3770a | ||
|
|
e975d85d9b | ||
|
|
32628fa64b | ||
|
|
1dadf54ad6 | ||
|
|
2465e8da1d | ||
|
|
fcca124c20 | ||
|
|
c9b2de0621 |
26
CHANGELOG.md
26
CHANGELOG.md
@@ -2,32 +2,6 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
## [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)
|
## [1.2.1](https://github.com/sern-handler/cli/compare/v1.2.0...v1.2.1) (2024-02-08)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@sern/cli",
|
"name": "@sern/cli",
|
||||||
"version": "1.3.2",
|
"version": "1.2.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@sern/cli",
|
"name": "@sern/cli",
|
||||||
"version": "1.3.2",
|
"version": "1.2.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@esbuild-kit/cjs-loader": "^2.4.2",
|
"@esbuild-kit/cjs-loader": "^2.4.2",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sern/cli",
|
"name": "@sern/cli",
|
||||||
"version": "1.3.2",
|
"version": "1.2.1",
|
||||||
"description": "Official CLI for @sern/handler",
|
"description": "Official CLI for @sern/handler",
|
||||||
"exports": "./dist/index.js",
|
"exports": "./dist/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import { pathExists, pathExistsSync } from 'find-up';
|
|||||||
import { mkdir, writeFile, readFile } from 'fs/promises';
|
import { mkdir, writeFile, readFile } from 'fs/promises';
|
||||||
import * as Preprocessor from '../utilities/preprocessor';
|
import * as Preprocessor from '../utilities/preprocessor';
|
||||||
import { bold, magentaBright } from 'colorette';
|
import { bold, magentaBright } from 'colorette';
|
||||||
import { parseTsConfig } from '../utilities/parseTsconfig';
|
|
||||||
|
|
||||||
const VALID_EXTENSIONS = ['.ts', '.js' ];
|
const VALID_EXTENSIONS = ['.ts', '.js' ];
|
||||||
|
|
||||||
@@ -104,8 +103,8 @@ export async function build(options: Record<string, any>) {
|
|||||||
}
|
}
|
||||||
assert(buildConfig.mode === 'development' || buildConfig.mode === 'production', 'Mode is not `production` or `development`');
|
assert(buildConfig.mode === 'development' || buildConfig.mode === 'production', 'Mode is not `production` or `development`');
|
||||||
try {
|
try {
|
||||||
let config = await parseTsConfig(buildConfig.tsconfig!);
|
let config = JSON.parse(await readFile(buildConfig.tsconfig!, 'utf8'));
|
||||||
config?.extends && console.warn("Extend the generated tsconfig")
|
config.extends && console.warn("Extend the generated tsconfig")
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.error("no tsconfig / jsconfig found");
|
console.error("no tsconfig / jsconfig found");
|
||||||
console.error(`Please create a ${sernConfig.language === 'javascript' ? 'jsconfig.json' : 'tsconfig.json' }`);
|
console.error(`Please create a ${sernConfig.language === 'javascript' ? 'jsconfig.json' : 'tsconfig.json' }`);
|
||||||
|
|||||||
@@ -52,6 +52,15 @@ program //
|
|||||||
.option('-y, --yes', "Say yes to all prompts")
|
.option('-y, --yes', "Say yes to all prompts")
|
||||||
.option('-e, --env [path]', "Supply a path to a .env")
|
.option('-e, --env [path]', "Supply a path to a .env")
|
||||||
.action(async (...args) => importDynamic('command-clear.js').then((m) => m.commandClear(...args))));
|
.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
|
program
|
||||||
.command('build')
|
.command('build')
|
||||||
.description('Build your bot')
|
.description('Build your bot')
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { findUp } from 'find-up';
|
import { findUp } from 'find-up';
|
||||||
import { readFile, rename, writeFile } from 'node:fs/promises';
|
import { readFile, rename, writeFile } from 'node:fs/promises';
|
||||||
import { fromCwd } from './fromCwd.js';
|
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
|
* 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) {
|
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) 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;
|
output.compilerOptions.rootDir = srcName;
|
||||||
|
|
||||||
// This will strip comments/trailing commas from the tsconfig.json file
|
|
||||||
await writeFile(tsconfig, JSON.stringify(output, null, 2));
|
await writeFile(tsconfig, JSON.stringify(output, null, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user