mirror of
https://github.com/thomasnordquist/MQTT-Explorer.git
synced 2026-09-14 10:34:36 +00:00
Modify appx after it was packed
This commit is contained in:
@@ -2,21 +2,29 @@ import * as fs from 'fs-extra'
|
||||
import * as path from 'path'
|
||||
import { chdir } from 'process'
|
||||
import { exec } from './util'
|
||||
import * as AdmZip from 'adm-zip'
|
||||
|
||||
export default async function (info: any) {
|
||||
for (const snapFile of info.artifactPaths) {
|
||||
if (/\.snap$/.test(snapFile)) {
|
||||
for (const artifact of info.artifactPaths) {
|
||||
if (/\.snap$/.test(artifact)) {
|
||||
const originalDir = __dirname
|
||||
const dirname = path.dirname(snapFile)
|
||||
const dirname = path.dirname(artifact)
|
||||
chdir(dirname)
|
||||
|
||||
await exec('sudo', ['unsquashfs', snapFile])
|
||||
await fs.remove(snapFile)
|
||||
await exec('sudo', ['unsquashfs', artifact])
|
||||
await fs.remove(artifact)
|
||||
await exec('sudo', ['chmod', '-R', 'g-s', 'squashfs-root'])
|
||||
await exec('sudo', ['snap', 'run', 'snapcraft', 'pack', 'squashfs-root', '--output', snapFile])
|
||||
await exec('sudo', ['snap', 'run', 'snapcraft', 'pack', 'squashfs-root', '--output', artifact])
|
||||
await fs.remove('squashfs-root')
|
||||
|
||||
chdir(originalDir)
|
||||
}
|
||||
|
||||
if (/\.appx$/.test(artifact)) {
|
||||
const zip = new AdmZip(artifact)
|
||||
const data = zip.readAsText('AppxManifest.xml')
|
||||
const newData = data.replace('uap:DefaultTile', 'uap:DefaultTile ShowName="allLogos"')
|
||||
zip.updateFile('AppxManifest.xml', Buffer.from(newData))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
import * as fs from 'fs-extra'
|
||||
import * as path from 'path'
|
||||
import { chdir } from 'process'
|
||||
import { exec } from './util'
|
||||
|
||||
interface AfterPackContext {
|
||||
outDir: string
|
||||
appOutDir: string
|
||||
packager: any// PlatformPackager<any>
|
||||
electronPlatformName: string
|
||||
arch: any//Arch
|
||||
targets: any//Array<Target>
|
||||
}
|
||||
|
||||
export default async function (info: AfterPackContext) {
|
||||
console.log(info)
|
||||
console.log(info.targets)
|
||||
console.log(info.packager)
|
||||
console.log(info.arch)
|
||||
|
||||
addAppNameToTiles(info)
|
||||
}
|
||||
|
||||
export function addAppNameToTiles(info: AfterPackContext) {
|
||||
const manifestPath = path.join(info.appOutDir, 'AppxManifest.xml')
|
||||
const data = fs.readFileSync(manifestPath).toString()
|
||||
const newData = data.replace('uap:DefaultTile', 'uap:DefaultTile ShowName="allLogos"')
|
||||
fs.writeFileSync(manifestPath, newData)
|
||||
}
|
||||
Reference in New Issue
Block a user