mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-10-20 13:02:58 +08:00
chore: 同步 template 对 script/ 的修改
This commit is contained in:
parent
26a3daac68
commit
228557b866
@ -13,6 +13,8 @@ import { RequiredData, RequiredIconsData, ResourceType } from './types';
|
|||||||
import { splitResource, SplittedResource } from './build-resource';
|
import { splitResource, SplittedResource } from './build-resource';
|
||||||
import { formatSize } from './utils';
|
import { formatSize } from './utils';
|
||||||
|
|
||||||
|
const DEBUG_REPLAY = false;
|
||||||
|
|
||||||
const ansi = {
|
const ansi = {
|
||||||
clear: '\x1b[2J\x1b[0f'
|
clear: '\x1b[2J\x1b[0f'
|
||||||
};
|
};
|
||||||
@ -92,7 +94,8 @@ async function buildData(outDir: string, entry: string) {
|
|||||||
name: 'ProcessData',
|
name: 'ProcessData',
|
||||||
fileName: 'data',
|
fileName: 'data',
|
||||||
formats: ['iife']
|
formats: ['iife']
|
||||||
}
|
},
|
||||||
|
minify: !DEBUG_REPLAY
|
||||||
}
|
}
|
||||||
} satisfies UserConfig);
|
} satisfies UserConfig);
|
||||||
|
|
||||||
@ -648,7 +651,7 @@ async function buildGame() {
|
|||||||
`⚠️ 压缩包大于 100M,可能导致发塔困难,请考虑降低塔的大小\r\n`
|
`⚠️ 压缩包大于 100M,可能导致发塔困难,请考虑降低塔的大小\r\n`
|
||||||
);
|
);
|
||||||
const suggections: string[] = [];
|
const suggections: string[] = [];
|
||||||
if (dataObject.main.bgms.some(v => !v.endsWith('opuw'))) {
|
if (dataObject.main.bgms.some(v => !v.endsWith('opus'))) {
|
||||||
suggections.push(`将 BGM 和音效换用 opus 格式`);
|
suggections.push(`将 BGM 和音效换用 opus 格式`);
|
||||||
}
|
}
|
||||||
if (dataObject.main.images.some(v => !v.endsWith('webp'))) {
|
if (dataObject.main.images.some(v => !v.endsWith('webp'))) {
|
||||||
|
@ -166,20 +166,20 @@ export async function splitResource(
|
|||||||
while (index < files.length) {
|
while (index < files.length) {
|
||||||
let total = 0;
|
let total = 0;
|
||||||
const start = index;
|
const start = index;
|
||||||
for (let i = index; i < files.length; i++) {
|
let i = index;
|
||||||
|
for (; i < files.length; i++) {
|
||||||
const file = files[i];
|
const file = files[i];
|
||||||
if (file.exceed) {
|
if (file.exceed) {
|
||||||
if (i === index) i = index + 1;
|
if (i === index) i = index + 1;
|
||||||
index = i;
|
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
total += file.stats.size;
|
total += file.stats.size;
|
||||||
}
|
}
|
||||||
if (total > limit) {
|
if (total > limit) {
|
||||||
index = i;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
index = i;
|
||||||
const toZip = files.slice(start, index);
|
const toZip = files.slice(start, index);
|
||||||
result.push(await compressFiles(toZip));
|
result.push(await compressFiles(toZip));
|
||||||
}
|
}
|
||||||
|
55
script/pack-template.ts
Normal file
55
script/pack-template.ts
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/* eslint-disable no-console */
|
||||||
|
import { copy, emptyDir, ensureDir } from 'fs-extra';
|
||||||
|
import { writeFile } from 'fs/promises';
|
||||||
|
import { resolve } from 'path';
|
||||||
|
|
||||||
|
const base = resolve(process.cwd());
|
||||||
|
const template = resolve(base, 'template');
|
||||||
|
|
||||||
|
const serve = `在 2.B 样板中,不再使用先前的启动服务,而使用一个单独的软件。
|
||||||
|
你可以加造塔群 959329661 后,在群文件 - 启动服务 中获取,文件夹中会有一个专门的安装教程。`;
|
||||||
|
|
||||||
|
async function packTemplate() {
|
||||||
|
await ensureDir(template);
|
||||||
|
await emptyDir(template);
|
||||||
|
|
||||||
|
// 复制必要文件
|
||||||
|
const toCopy = [
|
||||||
|
'.vscode',
|
||||||
|
'packages',
|
||||||
|
'packages-user',
|
||||||
|
'public',
|
||||||
|
'script',
|
||||||
|
'src',
|
||||||
|
'.gitignore',
|
||||||
|
'.madgerc',
|
||||||
|
'.prettierignore',
|
||||||
|
'.prettierrc',
|
||||||
|
'eslint.config.js',
|
||||||
|
'index.html',
|
||||||
|
'LICENSE',
|
||||||
|
'package.json',
|
||||||
|
'pnpm-lock.yaml',
|
||||||
|
'pnpm-workspace.yaml',
|
||||||
|
'README.md',
|
||||||
|
'tsconfig.json',
|
||||||
|
'tsconfig.node.json',
|
||||||
|
'vite.config.ts'
|
||||||
|
];
|
||||||
|
|
||||||
|
await Promise.all(
|
||||||
|
toCopy.map(v =>
|
||||||
|
copy(resolve(base, v), resolve(template, v), {
|
||||||
|
filter: src => !src.includes('node_modules')
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
await writeFile(resolve(template, '启动服务呢?.txt'), serve, 'utf-8');
|
||||||
|
|
||||||
|
console.log(`样板打包完成`);
|
||||||
|
}
|
||||||
|
|
||||||
|
(() => {
|
||||||
|
packTemplate();
|
||||||
|
})();
|
Loading…
Reference in New Issue
Block a user