MCPcopy Create free account
hub / github.com/msgbyte/tailchat / createUpdateZipAndDeploy

Function createUpdateZipAndDeploy

client/desktop-old/scripts/update.ts:43–95  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

41}
42
43async function createUpdateZipAndDeploy() {
44 const asarPath = getAsarFilePath();
45 if (!(await fs.pathExists(asarPath))) {
46 throw new Error('asar 文件不存在');
47 }
48 const updateDir = path.resolve(outputDir, './update');
49 const outputPath = path.resolve(updateDir, './tmp.zip');
50 await fs.ensureDir(updateDir);
51 await fs.emptyDir(updateDir);
52
53 console.log('开始创建更新包');
54 createZip(asarPath, outputPath);
55
56 const buffer = await fs.readFile(outputPath);
57 const sha256 = hash(buffer);
58 const hashName = sha256.slice(7, 12);
59 await fs.move(outputPath, path.resolve(updateDir, `${hashName}.zip`));
60
61 console.log('正在输出更新文件...');
62 await fs.outputJSON(path.resolve(updateDir, 'manifest.json'), {
63 active: true,
64 version,
65 from: '0.0.0',
66 name: `${hashName}.zip`,
67 hash: sha256,
68 date: new Date().valueOf(),
69 size: buffer.byteLength,
70 });
71
72 console.log('正在部署到远程...');
73 // 部署到github pages
74 await new Promise<void>((resolve, reject) => {
75 ghpages.publish(
76 updateDir,
77 {
78 repo: 'git@github.com:msgbyte/tailchat-archive.git',
79 branch: 'gh-pages',
80 dest: './desktop/update',
81 push: true,
82 history: false,
83 },
84 (err) => {
85 if (err) {
86 reject(err);
87 } else {
88 resolve();
89 }
90 }
91 );
92 });
93
94 console.log('完成');
95}
96
97// async function
98

Callers 1

update.tsFile · 0.85

Calls 6

getAsarFilePathFunction · 0.85
createZipFunction · 0.85
hashFunction · 0.85
rejectFunction · 0.85
readFileMethod · 0.80
logMethod · 0.65

Tested by

no test coverage detected