diff --git a/scripts/api-changelog.js b/scripts/api-changelog.js deleted file mode 100644 index 15670e5..0000000 --- a/scripts/api-changelog.js +++ /dev/null @@ -1,221 +0,0 @@ -import fs from 'node:fs' -import path from 'node:path' -import { execSync } from 'node:child_process' -import { fileURLToPath } from 'node:url' - -// Recreate __dirname -const __filename = fileURLToPath(import.meta.url) -const __dirname = path.dirname(__filename) - -// Define paths -const rustFilesPath = path.join(__dirname, '..', 'src-tauri') - -function getApiDefinitions() { - // Get a list of all Rust files - const rustFiles = findRustFiles(rustFilesPath) - - // Extract API functions and structs from Rust files - const apiDefinitions = { - commands: [], - structs: [], - } - - rustFiles.forEach((filePath) => { - const content = fs.readFileSync(filePath, 'utf8') - - // Find Tauri commands (API endpoints) - const commandRegex = /#\[tauri::command\]\s+(?:pub\s+)?(?:async\s+)?fn\s+([a-zA-Z0-9_]+)/g - let match - while ((match = commandRegex.exec(content)) !== null) { - apiDefinitions.commands.push({ - name: match[1], - file: path.relative(rustFilesPath, filePath), - }) - } - - // Find structs that are likely part of the API - const structRegex = /#\[derive\(.*Serialize.*\)\]\s+(?:pub\s+)?struct\s+([a-zA-Z0-9_]+)/g - while ((match = structRegex.exec(content)) !== null) { - apiDefinitions.structs.push({ - name: match[1], - file: path.relative(rustFilesPath, filePath), - }) - } - }) - - return apiDefinitions -} - -function findRustFiles(dir) { - let results = [] - const list = fs.readdirSync(dir) - - list.forEach((file) => { - const filePath = path.join(dir, file) - const stat = fs.statSync(filePath) - - if (stat && stat.isDirectory() && file !== 'target') { - // Recursively search subdirectories, but skip the 'target' directory - results = results.concat(findRustFiles(filePath)) - } else if (path.extname(file) === '.rs') { - // Add Rust files to the results - results.push(filePath) - } - }) - - return results -} - -function compareApiDefinitions(oldApi, newApi) { - const changes = { - commands: { - added: [], - removed: [], - }, - structs: { - added: [], - removed: [], - }, - } - - // Find added and removed commands - const oldCommandNames = oldApi.commands.map((cmd) => cmd.name) - const newCommandNames = newApi.commands.map((cmd) => cmd.name) - - changes.commands.added = newApi.commands.filter((cmd) => !oldCommandNames.includes(cmd.name)) - changes.commands.removed = oldApi.commands.filter((cmd) => !newCommandNames.includes(cmd.name)) - - // Find added and removed structs - const oldStructNames = oldApi.structs.map((struct) => struct.name) - const newStructNames = newApi.structs.map((struct) => struct.name) - - changes.structs.added = newApi.structs.filter((struct) => !oldStructNames.includes(struct.name)) - changes.structs.removed = oldApi.structs.filter((struct) => !newStructNames.includes(struct.name)) - - return changes -} - -function updateChangelog(changes) { - const changelogPath = path.join(__dirname, '..', 'CHANGELOG.md') - let changelog = '' - - // Create changelog if it doesn't exist - if (fs.existsSync(changelogPath)) { - changelog = fs.readFileSync(changelogPath, 'utf8') - } else { - changelog = - '# Changelog\n\nAll notable changes to this project will be documented in this file.\n\n' - } - - // Get the current version and date - const packageJsonPath = path.join(__dirname, '..', 'package.json') - const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')) - const version = packageJson.version - const date = new Date().toISOString().split('T')[0] - - // Create the new changelog entry - let newEntry = `## [${version}] - ${date}\n\n` - - if ( - changes.commands.added.length > 0 || - changes.commands.removed.length > 0 || - changes.structs.added.length > 0 || - changes.structs.removed.length > 0 - ) { - newEntry += '### API Changes\n\n' - - if (changes.commands.added.length > 0) { - newEntry += '#### New Commands\n\n' - changes.commands.added.forEach((cmd) => { - newEntry += `- \`${cmd.name}\` in \`${cmd.file}\`\n` - }) - newEntry += '\n' - } - - if (changes.commands.removed.length > 0) { - newEntry += '#### Removed Commands\n\n' - changes.commands.removed.forEach((cmd) => { - newEntry += `- \`${cmd.name}\` (was in \`${cmd.file}\`)\n` - }) - newEntry += '\n' - } - - if (changes.structs.added.length > 0) { - newEntry += '#### New Structures\n\n' - changes.structs.added.forEach((struct) => { - newEntry += `- \`${struct.name}\` in \`${struct.file}\`\n` - }) - newEntry += '\n' - } - - if (changes.structs.removed.length > 0) { - newEntry += '#### Removed Structures\n\n' - changes.structs.removed.forEach((struct) => { - newEntry += `- \`${struct.name}\` (was in \`${struct.file}\`)\n` - }) - newEntry += '\n' - } - } else { - newEntry += 'No API changes in this release.\n\n' - } - - // Add git commit information since last release - try { - // Get the latest tag - const latestTag = execSync('git describe --tags --abbrev=0', { encoding: 'utf8' }).trim() - - // Get commits since the latest tag - const commits = execSync(`git log ${latestTag}..HEAD --pretty=format:"%h %s (%an)"`, { - encoding: 'utf8', - }).trim() - - if (commits) { - newEntry += '### Other Changes\n\n' - - // Split commits by line and add them to the changelog - commits.split('\n').forEach((commit) => { - newEntry += `- ${commit}\n` - }) - - newEntry += '\n' - } - } catch (error) { - // If there are no tags or other git issues, just continue without commit info - console.warn('Could not get git commit information:', error.message) - } - - // Add the new entry to the changelog - if (changelog.includes('## [')) { - // Insert new entry after the first heading - changelog = changelog.replace('# Changelog\n\n', `# Changelog\n\n${newEntry}`) - } else { - // Append to the end if no existing versions - changelog += newEntry - } - - // Write the updated changelog - fs.writeFileSync(changelogPath, changelog) - console.log(`Updated CHANGELOG.md with API changes for version ${version}`) -} - -// Main execution -try { - // Check if we have a saved API definition - const apiCachePath = path.join(__dirname, '.api-cache.json') - let oldApi = { commands: [], structs: [] } - let newApi = getApiDefinitions() - - if (fs.existsSync(apiCachePath)) { - oldApi = JSON.parse(fs.readFileSync(apiCachePath, 'utf8')) - } - - // Compare and update the changelog - const changes = compareApiDefinitions(oldApi, newApi) - updateChangelog(changes) - - // Save the new API definition for next time - fs.writeFileSync(apiCachePath, JSON.stringify(newApi, null, 2)) -} catch (error) { - console.error('Error updating API changelog:', error) - process.exit(1) -} diff --git a/scripts/generate-updater-json.js b/scripts/generate-updater-json.js deleted file mode 100644 index 5e9f388..0000000 --- a/scripts/generate-updater-json.js +++ /dev/null @@ -1,57 +0,0 @@ -import fs from 'node:fs' -import path from 'node:path' -import { fileURLToPath } from 'node:url' - -const __filename = fileURLToPath(import.meta.url) -const __dirname = path.dirname(__filename) - -const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8')) -const version = packageJson.version -const pubDate = new Date().toISOString() - -const baseUrl = 'https://github.com/novattz/rust-gui-dev/releases/download' -const releaseTag = `v${version}` -const releaseUrl = `${baseUrl}/${releaseTag}` - -function findSigFile(dir, baseName) { - const files = fs.readdirSync(dir) - const sigFile = files.find((f) => f.startsWith(baseName) && f.endsWith('.sig')) - return sigFile ? fs.readFileSync(path.join(dir, sigFile), 'utf8').trim() : null -} - -function addPlatform(platformKey, folder, baseName, ext) { - const dir = path.join('src-tauri', 'target', 'release', 'bundle', folder) - const fileName = `${baseName}${ext}` - const filePath = path.join(dir, fileName) - - if (fs.existsSync(filePath)) { - const signature = findSigFile(dir, baseName) - if (!signature) { - console.warn(`⚠️ Signature not found for ${fileName}`) - return - } - - updaterJson.platforms[platformKey] = { - url: `${releaseUrl}/${fileName}`, - signature, - } - } else { - console.warn(`⚠️ File not found: ${filePath}`) - } -} - -const updaterJson = { - version, - notes: `Release version ${version}`, - pub_date: pubDate, - platforms: {}, -} - -addPlatform('linux-x86_64', 'appimage', `Creamlinux_${version}_amd64`, '.AppImage') -addPlatform('linux-deb', 'deb', `Creamlinux_${version}_amd64`, '.deb') -addPlatform('linux-rpm', 'rpm', `Creamlinux-${version}-1.x86_64`, '.rpm') - -// Optional: Windows/macOS can still be supported later - -fs.writeFileSync('latest.json', JSON.stringify(updaterJson, null, 2)) -console.log('✅ Created latest.json updater file') diff --git a/scripts/sync-version.js b/scripts/sync-version.js deleted file mode 100644 index ad8ac94..0000000 --- a/scripts/sync-version.js +++ /dev/null @@ -1,35 +0,0 @@ -import fs from 'node:fs' -import path from 'node:path' -import { execSync } from 'node:child_process' -import { fileURLToPath } from 'node:url' - -// Recreate __dirname -const __filename = fileURLToPath(import.meta.url) -const __dirname = path.dirname(__filename) - -// Read current version from package.json -const packageJsonPath = path.join(__dirname, '..', 'package.json') -const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')) -const version = packageJson.version - -console.log(`Current version: ${version}`) - -// Update Cargo.toml -const cargoTomlPath = path.join(__dirname, '..', 'src-tauri', 'Cargo.toml') -let cargoToml = fs.readFileSync(cargoTomlPath, 'utf8') - -// Replace the version in Cargo.toml -cargoToml = cargoToml.replace(/version\s*=\s*"[^"]+"/m, `version = "${version}"`) -fs.writeFileSync(cargoTomlPath, cargoToml) -console.log(`Updated Cargo.toml version to ${version}`) - -// Update tauri.conf.json -const tauriConfigPath = path.join(__dirname, '..', 'src-tauri', 'tauri.conf.json') -const tauriConfig = JSON.parse(fs.readFileSync(tauriConfigPath, 'utf8')) - -// Set the version in tauri.conf.json -tauriConfig.version = version -fs.writeFileSync(tauriConfigPath, JSON.stringify(tauriConfig, null, 2)) -console.log(`Updated tauri.conf.json version to ${version}`) - -console.log('Version synchronization completed!') diff --git a/scripts/update-tauri-config.js b/scripts/update-tauri-config.js deleted file mode 100644 index 6107670..0000000 --- a/scripts/update-tauri-config.js +++ /dev/null @@ -1,42 +0,0 @@ -import fs from 'node:fs' -import path from 'node:path' - -// Path to your tauri.conf.json file -const tauriConfigPath = path.join(__dirname, '..', 'src-tauri', 'tauri.conf.json') - -// Read the current config -const rawConfig = fs.readFileSync(tauriConfigPath, 'utf8') -const config = JSON.parse(rawConfig) - -// Add or update the updater configuration -if (!config.plugins) { - config.plugins = {} -} - -// Get the public key from environment variable -const pubkey = process.env.TAURI_PUBLIC_KEY || '' - -if (!pubkey) { - console.warn( - 'Warning: TAURI_PUBLIC_KEY environment variable is not set. Updater will not work correctly!' - ) -} - -// Configure the updater plugin -config.plugins.updater = { - pubkey, - endpoints: ['https://github.com/tickbase/creamlinux/releases/latest/download/latest.json'], -} - -// Configure bundle settings for updater artifacts -if (!config.bundle) { - config.bundle = {} -} - -// Set createUpdaterArtifacts to true -config.bundle.createUpdaterArtifacts = true - -// Write the updated config back to the file -fs.writeFileSync(tauriConfigPath, JSON.stringify(config, null, 2)) - -console.log('Tauri config updated with updater configuration')