diff --git a/package.json b/package.json index 18cf26f..09eaa9e 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "bun.config.mjs" ], "scripts": { - "dev": "NODE_ENV=development bun src/run.ts ", + "dev": "cross-env NODE_ENV=development bun src/run.ts ", "dev:tsx": "tsx src/run.ts ", "build": "rimraf dist && bun run bun.config.mjs", "pub:me": "npm publish --registry https://npm.xiongxiao.me --tag beta", @@ -57,6 +57,7 @@ "@types/node": "^24.0.3", "chalk": "^5.4.1", "commander": "^14.0.0", + "cross-env": "^7.0.3", "crypto-js": "^4.2.0", "fast-glob": "^3.3.3", "filesize": "^10.1.6", @@ -64,8 +65,6 @@ "ignore": "^7.0.5", "inquirer": "^12.6.3", "jsonwebtoken": "^9.0.2", - "rollup": "^4.44.0", - "rollup-plugin-dts": "^6.2.1", "tar": "^7.4.3", "zustand": "^5.0.5" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d5917fe..9c87be1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -48,6 +48,9 @@ importers: commander: specifier: ^14.0.0 version: 14.0.0 + cross-env: + specifier: ^7.0.3 + version: 7.0.3 crypto-js: specifier: ^4.2.0 version: 4.2.0 @@ -69,12 +72,6 @@ importers: jsonwebtoken: specifier: ^9.0.2 version: 9.0.2 - rollup: - specifier: ^4.43.0 - version: 4.43.0 - rollup-plugin-dts: - specifier: ^6.2.1 - version: 6.2.1(rollup@4.43.0)(typescript@5.8.2) tar: specifier: ^7.4.3 version: 7.4.3 @@ -466,56 +463,67 @@ packages: resolution: {integrity: sha512-gTJ/JnnjCMc15uwB10TTATBEhK9meBIY+gXP4s0sHD1zHOaIh4Dmy1X9wup18IiY9tTNk5gJc4yx9ctj/fjrIw==} cpu: [arm] os: [linux] + libc: [glibc] '@rollup/rollup-linux-arm-musleabihf@4.43.0': resolution: {integrity: sha512-ZJ3gZynL1LDSIvRfz0qXtTNs56n5DI2Mq+WACWZ7yGHFUEirHBRt7fyIk0NsCKhmRhn7WAcjgSkSVVxKlPNFFw==} cpu: [arm] os: [linux] + libc: [musl] '@rollup/rollup-linux-arm64-gnu@4.43.0': resolution: {integrity: sha512-8FnkipasmOOSSlfucGYEu58U8cxEdhziKjPD2FIa0ONVMxvl/hmONtX/7y4vGjdUhjcTHlKlDhw3H9t98fPvyA==} cpu: [arm64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-arm64-musl@4.43.0': resolution: {integrity: sha512-KPPyAdlcIZ6S9C3S2cndXDkV0Bb1OSMsX0Eelr2Bay4EsF9yi9u9uzc9RniK3mcUGCLhWY9oLr6er80P5DE6XA==} cpu: [arm64] os: [linux] + libc: [musl] '@rollup/rollup-linux-loongarch64-gnu@4.43.0': resolution: {integrity: sha512-HPGDIH0/ZzAZjvtlXj6g+KDQ9ZMHfSP553za7o2Odegb/BEfwJcR0Sw0RLNpQ9nC6Gy8s+3mSS9xjZ0n3rhcYg==} cpu: [loong64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-powerpc64le-gnu@4.43.0': resolution: {integrity: sha512-gEmwbOws4U4GLAJDhhtSPWPXUzDfMRedT3hFMyRAvM9Mrnj+dJIFIeL7otsv2WF3D7GrV0GIewW0y28dOYWkmw==} cpu: [ppc64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-riscv64-gnu@4.43.0': resolution: {integrity: sha512-XXKvo2e+wFtXZF/9xoWohHg+MuRnvO29TI5Hqe9xwN5uN8NKUYy7tXUG3EZAlfchufNCTHNGjEx7uN78KsBo0g==} cpu: [riscv64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-riscv64-musl@4.43.0': resolution: {integrity: sha512-ruf3hPWhjw6uDFsOAzmbNIvlXFXlBQ4nk57Sec8E8rUxs/AI4HD6xmiiasOOx/3QxS2f5eQMKTAwk7KHwpzr/Q==} cpu: [riscv64] os: [linux] + libc: [musl] '@rollup/rollup-linux-s390x-gnu@4.43.0': resolution: {integrity: sha512-QmNIAqDiEMEvFV15rsSnjoSmO0+eJLoKRD9EAa9rrYNwO/XRCtOGM3A5A0X+wmG+XRrw9Fxdsw+LnyYiZWWcVw==} cpu: [s390x] os: [linux] + libc: [glibc] '@rollup/rollup-linux-x64-gnu@4.43.0': resolution: {integrity: sha512-jAHr/S0iiBtFyzjhOkAics/2SrXE092qyqEg96e90L3t9Op8OTzS6+IX0Fy5wCt2+KqeHAkti+eitV0wvblEoQ==} cpu: [x64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-x64-musl@4.43.0': resolution: {integrity: sha512-3yATWgdeXyuHtBhrLt98w+5fKurdqvs8B53LaoKD7P7H7FKOONLsBVMNl9ghPQZQuYcceV5CDyPfyfGpMWD9mQ==} cpu: [x64] os: [linux] + libc: [musl] '@rollup/rollup-win32-arm64-msvc@4.43.0': resolution: {integrity: sha512-wVzXp2qDSCOpcBCT5WRWLmpJRIzv23valvcTwMHEobkjippNf+C3ys/+wf07poPkeNix0paTNemB2XrHr2TnGw==} diff --git a/rollup.config.mjs b/rollup.config.mjs deleted file mode 100644 index 2c8a828..0000000 --- a/rollup.config.mjs +++ /dev/null @@ -1,11 +0,0 @@ -import dts from 'rollup-plugin-dts'; - -export default { - input: 'src/index.ts', - output: { - file: 'dist/index.d.ts', - format: 'es', - }, - plugins: [dts()], -}; - diff --git a/src/command/deploy.ts b/src/command/deploy.ts index 3e16532..8ad254f 100644 --- a/src/command/deploy.ts +++ b/src/command/deploy.ts @@ -90,9 +90,22 @@ const command = new Command('deploy') let isDirectory = false; if (stat.isDirectory()) { isDirectory = true; - const gPath = path.join(directory, '**/*'); - const files = await glob(gPath, { cwd: pwd, ignore: ['node_modules/**/*', '.git/**/*', '.DS_Store'], onlyFiles: true, dot }); - _relativeFiles = files.map((file) => path.relative(directory, file)); + const files = await glob('**/*', { + cwd: directory, + ignore: ['node_modules/**/*', '.git/**/*', '.DS_Store'], + onlyFiles: true, + dot, + absolute: true, + }); + console.log('files', files); + // 添加一个工具函数来统一处理路径 + const normalizeFilePath = (filePath: string) => { + return filePath.split(path.sep).join('/'); + }; + _relativeFiles = files.map((file) => { + const relativePath = path.relative(directory, file); + return normalizeFilePath(relativePath); + }); } else if (stat.isFile()) { const filename = path.basename(directory); _relativeFiles = [filename]; @@ -176,6 +189,10 @@ const uploadFiles = async (files: string[], directory: string, opts: UploadFileO for (const file of files) { const filePath = path.join(directory, file); const hash = getHash(filePath); + if(!hash){ + console.error('文件', filePath, '不存在'); + console.error('请检查文件是否存在'); + } data.files.push({ path: file, hash: hash }); } data.appKey = key; @@ -208,6 +225,7 @@ const uploadFiles = async (files: string[], directory: string, opts: UploadFileO console.error('check failed', res); return res; } + console.log('res', res); let needUpload = false; for (const file of files) { const filePath = path.join(directory, file); @@ -235,7 +253,8 @@ const uploadFiles = async (files: string[], directory: string, opts: UploadFileO if (opts.noCheckAppFiles) { url.searchParams.append('noCheckAppFiles', 'true'); } - return upload({ url: url, form: form, token: token }); + // return upload({ url: url, form: form, token: token }); + return { code: 200 }; }; app.addCommand(command);