| 7 | const deployDir = path.resolve(__dirname, '../release/deploy'); |
| 8 | |
| 9 | async function deployToGithubPages() { |
| 10 | if (!(await fs.pathExists(outputDir))) { |
| 11 | throw new Error('outputDir does not exist'); |
| 12 | } |
| 13 | |
| 14 | await fs.ensureDir(deployDir); |
| 15 | await fs.emptyDir(deployDir); |
| 16 | |
| 17 | console.log('Selecting file...'); |
| 18 | const fileList = await fg(['*.zip', '*.exe'], { |
| 19 | cwd: outputDir, |
| 20 | }); |
| 21 | console.log(fileList.map((f) => `- ${f}`).join('\n')); |
| 22 | await Promise.all( |
| 23 | fileList.map((f) => |
| 24 | fs.copyFile(path.resolve(outputDir, f), path.resolve(deployDir, f)) |
| 25 | ) |
| 26 | ); |
| 27 | |
| 28 | console.log('Deploying to remote...'); |
| 29 | // 部署到github pages |
| 30 | await new Promise<void>((resolve, reject) => { |
| 31 | ghpages.publish( |
| 32 | deployDir, |
| 33 | { |
| 34 | repo: 'git@github.com:msgbyte/tailchat-archive.git', |
| 35 | branch: 'gh-pages', |
| 36 | dest: './desktop/app', |
| 37 | push: true, |
| 38 | history: false, |
| 39 | }, |
| 40 | (err) => { |
| 41 | if (err) { |
| 42 | reject(err); |
| 43 | } else { |
| 44 | resolve(); |
| 45 | } |
| 46 | } |
| 47 | ); |
| 48 | }); |
| 49 | |
| 50 | console.log('Completed!'); |
| 51 | } |
| 52 | |
| 53 | deployToGithubPages(); |