🔧 Global formatting and update formatting

This commit is contained in:
Tw93
2025-08-05 19:53:58 +08:00
parent 467123068a
commit 7c2c68f3a6
47 changed files with 824 additions and 653 deletions

View File

@@ -1,7 +1,7 @@
import fs from 'fs';
export default async function combineFiles(files: string[], output: string) {
const contents = files.map(file => {
const contents = files.map((file) => {
const fileContent = fs.readFileSync(file);
if (file.endsWith('.css')) {
return (
@@ -11,7 +11,11 @@ export default async function combineFiles(files: string[], output: string) {
);
}
return "window.addEventListener('DOMContentLoaded', (_event) => { " + fileContent + ' });';
return (
"window.addEventListener('DOMContentLoaded', (_event) => { " +
fileContent +
' });'
);
});
fs.writeFileSync(output, contents.join('\n'));
return files;

11
bin/utils/info.ts vendored
View File

@@ -5,11 +5,18 @@ import chalk from 'chalk';
// Generates an identifier based on the given URL.
export function getIdentifier(url: string) {
const postFixHash = crypto.createHash('md5').update(url).digest('hex').substring(0, 6);
const postFixHash = crypto
.createHash('md5')
.update(url)
.digest('hex')
.substring(0, 6);
return `com.pake.${postFixHash}`;
}
export async function promptText(message: string, initial?: string): Promise<string> {
export async function promptText(
message: string,
initial?: string,
): Promise<string> {
const response = await prompts({
type: 'text',
name: 'content',

4
bin/utils/ip.ts vendored
View File

@@ -13,13 +13,13 @@ const ping = async (host: string) => {
// Prevent timeouts from affecting user experience.
const requestPromise = new Promise<number>((resolve, reject) => {
const req = http.get(`http://${ip.address}`, res => {
const req = http.get(`http://${ip.address}`, (res) => {
const delay = new Date().getTime() - start.getTime();
res.resume();
resolve(delay);
});
req.on('error', err => {
req.on('error', (err) => {
reject(err);
});
});

6
bin/utils/shell.ts vendored
View File

@@ -5,10 +5,12 @@ export async function shellExec(command: string) {
try {
const { exitCode } = await execa(command, {
cwd: npmDirectory,
stdio: 'inherit'
stdio: 'inherit',
});
return exitCode;
} catch (error) {
throw new Error(`Error occurred while executing command "${command}". Exit code: ${error.exitCode}`);
throw new Error(
`Error occurred while executing command "${command}". Exit code: ${error.exitCode}`,
);
}
}