mirror of
https://gitlab.com/vyla-entertainment/home.git
synced 2026-11-13 21:57:21 -05:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dfb0893316 | |||
| 08c70a2c6d | |||
| 1092d359ab | |||
| dcba2a2438 | |||
| 8f99096bfb |
@@ -20,11 +20,13 @@ const REPO_CONFIG = {
|
||||
};
|
||||
|
||||
function clonePrivateRepo(repoConfig, targetDir) {
|
||||
const repoUrl = `https://gitlab.com/${GITLAB_GROUP}/${repoConfig.name}.git`;
|
||||
const token = process.env.GITLAB_TOKEN || process.env.VYLA_GITLAB_TOKEN;
|
||||
const auth = token ? `oauth2:${token}@` : '';
|
||||
const repoUrl = `https://${auth}gitlab.com/${GITLAB_GROUP}/${repoConfig.name}.git`;
|
||||
|
||||
try {
|
||||
if (fs.existsSync(targetDir)) {
|
||||
fs.rmSync(targetDir, { recursive: true, force: true });
|
||||
fs.rmSync(targetDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
||||
}
|
||||
|
||||
execSync(`git clone --depth 1 --branch ${repoConfig.branch} ${repoUrl} ${targetDir}`, {
|
||||
@@ -332,6 +334,9 @@ async function build() {
|
||||
}
|
||||
|
||||
const zipPath = path.join(__dirname, 'update-payload.zip');
|
||||
if (fs.existsSync(zipPath)) {
|
||||
fs.rmSync(zipPath, { force: true });
|
||||
}
|
||||
zip.writeZip(zipPath);
|
||||
|
||||
const checksum = validatePayload(zipPath);
|
||||
|
||||
12
main.js
12
main.js
@@ -243,6 +243,18 @@ async function start() {
|
||||
sendToTauri('status', { message: 'Loading credentials...' });
|
||||
serviceManager.credentialManager.loadCredentials();
|
||||
|
||||
sendToTauri('status', { message: 'Installing the Vyla SDK to latest version...' });
|
||||
try {
|
||||
require('child_process').execSync('npm install @vyla-entertainment/sdk@latest --no-save --no-audit --no-fund', {
|
||||
cwd: APPDATA_DIR,
|
||||
stdio: 'ignore',
|
||||
windowsHide: true
|
||||
});
|
||||
debugLog("Vyla SDK updated to latest successfully.");
|
||||
} catch (e) {
|
||||
debugLog(`Failed to install Vyla SDK: ${e.message}`);
|
||||
}
|
||||
|
||||
sendToTauri('status', { message: 'Starting backend services...' });
|
||||
await serviceManager.startServices([
|
||||
{ name: 'auth-proxy', relativeDir: 'auth-proxy' },
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vyla-home",
|
||||
"version": "1.1.1",
|
||||
"version": "1.1.5",
|
||||
"description": "Vyla Home Desktop App Launcher",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
@@ -14,7 +14,7 @@
|
||||
"@tauri-apps/api": "^2.0.0",
|
||||
"@tauri-apps/plugin-shell": "^2.0.0",
|
||||
"@tauri-apps/plugin-process": "^2.0.0",
|
||||
"@vyla-entertainment/sdk": "^1.10.0",
|
||||
"@vyla-entertainment/sdk": "^1.11.0",
|
||||
"adm-zip": "^0.6.0",
|
||||
"express": "^4.19.2"
|
||||
},
|
||||
|
||||
139
release.js
139
release.js
@@ -78,42 +78,38 @@ function uploadFileToGitLabPackage(filePath, packageName, version, fileName) {
|
||||
}
|
||||
|
||||
function createGitLabRelease(tag, releaseLinks) {
|
||||
const sendRequest = (method, path) => {
|
||||
const sendRequest = (method, path, data = null) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let currentRef = 'main';
|
||||
try {
|
||||
currentRef = execSync('git rev-parse HEAD').toString().trim();
|
||||
} catch (e) { }
|
||||
|
||||
const postData = JSON.stringify({
|
||||
name: `Vyla Home Release ${tag}`,
|
||||
tag_name: tag,
|
||||
ref: currentRef,
|
||||
description: `Automated local release ${tag}`,
|
||||
assets: {
|
||||
links: releaseLinks
|
||||
}
|
||||
});
|
||||
|
||||
const req = https.request({
|
||||
const options = {
|
||||
hostname: 'gitlab.com',
|
||||
port: 443,
|
||||
path: path,
|
||||
method: method,
|
||||
headers: {
|
||||
'PRIVATE-TOKEN': TOKEN,
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Length': Buffer.byteLength(postData)
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}, (res) => {
|
||||
};
|
||||
let postData = '';
|
||||
if (data) {
|
||||
postData = JSON.stringify(data);
|
||||
options.headers['Content-Length'] = Buffer.byteLength(postData);
|
||||
}
|
||||
|
||||
const req = https.request(options, (res) => {
|
||||
let body = '';
|
||||
res.on('data', chunk => body += chunk);
|
||||
res.on('end', () => {
|
||||
if (res.statusCode === 200 || res.statusCode === 201) {
|
||||
resolve(JSON.parse(body));
|
||||
if (res.statusCode >= 200 && res.statusCode < 300) {
|
||||
try {
|
||||
resolve(body ? JSON.parse(body) : {});
|
||||
} catch (e) {
|
||||
resolve({});
|
||||
}
|
||||
} else if (res.statusCode === 409 && method === 'POST') {
|
||||
console.log(`Release ${tag} already exists, updating assets...`);
|
||||
sendRequest('PUT', `/api/v4/projects/${PROJECT_ID}/releases/${encodeURIComponent(tag)}`)
|
||||
console.log(`Release ${tag} already exists, deleting and recreating...`);
|
||||
sendRequest('DELETE', `/api/v4/projects/${PROJECT_ID}/releases/${encodeURIComponent(tag)}`)
|
||||
.then(() => sendRequest('POST', `/api/v4/projects/${PROJECT_ID}/releases`, data))
|
||||
.then(resolve)
|
||||
.catch(reject);
|
||||
} else {
|
||||
@@ -123,12 +119,27 @@ function createGitLabRelease(tag, releaseLinks) {
|
||||
});
|
||||
|
||||
req.on('error', reject);
|
||||
req.write(postData);
|
||||
if (data) req.write(postData);
|
||||
req.end();
|
||||
});
|
||||
};
|
||||
|
||||
return sendRequest('POST', `/api/v4/projects/${PROJECT_ID}/releases`);
|
||||
let currentRef = 'main';
|
||||
try {
|
||||
currentRef = execSync('git rev-parse HEAD').toString().trim();
|
||||
} catch (e) { }
|
||||
|
||||
const releaseData = {
|
||||
name: `Vyla Home Release ${tag}`,
|
||||
tag_name: tag,
|
||||
ref: currentRef,
|
||||
description: `Automated local release ${tag}`,
|
||||
assets: {
|
||||
links: releaseLinks
|
||||
}
|
||||
};
|
||||
|
||||
return sendRequest('POST', `/api/v4/projects/${PROJECT_ID}/releases`, releaseData);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
@@ -156,15 +167,23 @@ async function main() {
|
||||
console.log('Ensuring bundled Node.js runtime...');
|
||||
await ensureBundledNode();
|
||||
|
||||
await ensureWebView2Loader();
|
||||
|
||||
const bundleDir = path.join(__dirname, 'src-tauri', 'target', 'release', 'bundle');
|
||||
if (fs.existsSync(bundleDir)) {
|
||||
fs.rmSync(bundleDir, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
console.log('Compiling Windows Tauri installer locally...');
|
||||
execSync('npm run build', {
|
||||
stdio: 'inherit',
|
||||
env: Object.assign({}, process.env, { WEBVIEW2_STATIC_LIB: '1' })
|
||||
stdio: 'inherit'
|
||||
});
|
||||
|
||||
const nsisDir = path.join(__dirname, 'src-tauri/target/release/bundle/nsis');
|
||||
if (fs.existsSync(nsisDir)) {
|
||||
const files = fs.readdirSync(nsisDir).filter(f => f.endsWith('.exe'));
|
||||
const targetVersion = version.startsWith('v') ? version.substring(1) : version;
|
||||
const files = fs.readdirSync(nsisDir).filter(f => f.endsWith('.exe') && f.includes(targetVersion));
|
||||
|
||||
if (files.length > 0) {
|
||||
const originalName = files[0];
|
||||
installerPath = path.join(nsisDir, originalName);
|
||||
@@ -174,11 +193,13 @@ async function main() {
|
||||
}
|
||||
|
||||
console.log('[2/4] Uploading artifacts to GitLab Package Registry...');
|
||||
const timestamp = Date.now();
|
||||
|
||||
console.log('Uploading update-payload.zip...');
|
||||
const payloadUrl = await uploadFileToGitLabPackage(payloadPath, 'vyla-home', version, 'update-payload.zip');
|
||||
const payloadUrl = await uploadFileToGitLabPackage(payloadPath, 'vyla-home', version, `update-payload-${timestamp}.zip`);
|
||||
|
||||
console.log('Uploading manifest.json...');
|
||||
const manifestUrl = await uploadFileToGitLabPackage(manifestPath, 'vyla-home', version, 'manifest.json');
|
||||
const manifestUrl = await uploadFileToGitLabPackage(manifestPath, 'vyla-home', version, `manifest-${timestamp}.json`);
|
||||
|
||||
const releaseLinks = [
|
||||
{ name: 'update-payload.zip', url: payloadUrl, link_type: 'other' },
|
||||
@@ -187,7 +208,8 @@ async function main() {
|
||||
|
||||
if (installerPath && installerUploadName) {
|
||||
console.log(`Uploading installer ${installerUploadName}...`);
|
||||
const installerUrl = await uploadFileToGitLabPackage(installerPath, 'vyla-home', version, installerUploadName);
|
||||
const installerUnique = installerUploadName.replace('.exe', `-${timestamp}.exe`);
|
||||
const installerUrl = await uploadFileToGitLabPackage(installerPath, 'vyla-home', version, installerUnique);
|
||||
releaseLinks.push({ name: installerUploadName, url: installerUrl, link_type: 'package' });
|
||||
}
|
||||
|
||||
@@ -238,6 +260,59 @@ function ensureBundledNode() {
|
||||
});
|
||||
}
|
||||
|
||||
function ensureWebView2Loader() {
|
||||
const releaseDir = path.join(__dirname, 'src-tauri', 'target', 'release');
|
||||
const rootDllPath = path.join(__dirname, 'src-tauri', 'WebView2Loader.dll');
|
||||
fs.mkdirSync(releaseDir, { recursive: true });
|
||||
|
||||
const targetDllPath = path.join(releaseDir, 'WebView2Loader.dll');
|
||||
|
||||
if (fs.existsSync(rootDllPath) && fs.existsSync(targetDllPath)) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const AdmZip = require('adm-zip');
|
||||
const tempNupkg = path.join(__dirname, 'temp-wv2.zip');
|
||||
const nupkgUrl = 'https://www.nuget.org/api/v2/package/Microsoft.Web.WebView2/1.0.2903.40';
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const fileStream = fs.createWriteStream(tempNupkg);
|
||||
const request = (url) => {
|
||||
https.get(url, (res) => {
|
||||
if (res.statusCode === 301 || res.statusCode === 302) {
|
||||
return request(res.headers.location);
|
||||
}
|
||||
res.pipe(fileStream);
|
||||
fileStream.on('finish', () => {
|
||||
fileStream.close();
|
||||
try {
|
||||
const zip = new AdmZip(tempNupkg);
|
||||
const zipEntries = zip.getEntries();
|
||||
const dllEntry = zipEntries.find(e =>
|
||||
e.entryName.includes('x64/WebView2Loader.dll') ||
|
||||
e.entryName.includes('x64\\WebView2Loader.dll')
|
||||
);
|
||||
if (dllEntry) {
|
||||
const buffer = dllEntry.getData();
|
||||
fs.writeFileSync(targetDllPath, buffer);
|
||||
fs.writeFileSync(rootDllPath, buffer);
|
||||
}
|
||||
try { fs.unlinkSync(tempNupkg); } catch (_) { }
|
||||
resolve();
|
||||
} catch (e) {
|
||||
try { fs.unlinkSync(tempNupkg); } catch (_) { }
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
}).on('error', (err) => {
|
||||
try { fs.unlinkSync(tempNupkg); } catch (_) { }
|
||||
reject(err);
|
||||
});
|
||||
};
|
||||
request(nupkgUrl);
|
||||
});
|
||||
}
|
||||
|
||||
main().catch(err => {
|
||||
console.error('Release failed:', err.message);
|
||||
process.exit(1);
|
||||
|
||||
2
src-tauri/Cargo.lock
generated
2
src-tauri/Cargo.lock
generated
@@ -4222,7 +4222,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "vyla-home"
|
||||
version = "1.1.1"
|
||||
version = "1.1.5"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "vyla-home"
|
||||
version = "1.1.1"
|
||||
version = "1.1.5"
|
||||
description = "Vyla Home Desktop App Launcher"
|
||||
edition = "2021"
|
||||
|
||||
|
||||
BIN
src-tauri/WebView2Loader.dll
Normal file
BIN
src-tauri/WebView2Loader.dll
Normal file
Binary file not shown.
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "Vyla Home",
|
||||
"version": "1.1.1",
|
||||
"version": "1.1.5",
|
||||
"identifier": "com.vyla.home",
|
||||
"build": {
|
||||
"frontendDist": "../ui"
|
||||
@@ -28,6 +28,7 @@
|
||||
}
|
||||
},
|
||||
"resources": [
|
||||
"WebView2Loader.dll",
|
||||
"../bin/*",
|
||||
"../main.js",
|
||||
"../service-manager.js",
|
||||
|
||||
Reference in New Issue
Block a user