Skip to content

Commit

Permalink
fix: Change msi naming scheme for recent Tauri upgrades (#227)
Browse files Browse the repository at this point in the history
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
  • Loading branch information
jdukewich and lucasfernog authored Feb 20, 2022
1 parent 4917e78 commit 4d70258
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 15 deletions.
6 changes: 6 additions & 0 deletions .changes/tauri-lang-support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@tauri-apps/action-core": minor
"action": minor
---

Update to Tauri release candidate.
6 changes: 3 additions & 3 deletions packages/action/dist/index.js

Large diffs are not rendered by default.

55 changes: 43 additions & 12 deletions packages/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,22 @@ interface TauriConfig {
productName?: string
version?: string
}
tauri?: {
bundle?: {
windows?: {
wix?: {
language?: string | string[] | { [language: string]: unknown }
}
}
}
}
}

interface Application {
runner: Runner
name: string
version: string
wixLanguage: string | string[] | { [language: string]: unknown }
}

export interface BuildOptions {
Expand All @@ -126,12 +136,14 @@ export interface Runner {
interface Info {
name: string
version: string
wixLanguage: string | string[] | { [language: string]: unknown }
}
export function getInfo(root: string): Info {
const configPath = join(root, 'src-tauri/tauri.conf.json')
if (existsSync(configPath)) {
let name
let version
let wixLanguage: string | string[] | { [language: string]: unknown } = 'en-US'
const config = JSON.parse(
readFileSync(configPath).toString()
) as TauriConfig
Expand All @@ -147,6 +159,9 @@ export function getInfo(root: string): Info {
name = name || cargoManifest.package.name
version = version || cargoManifest.package.version
}
if (config.tauri?.bundle?.windows?.wix?.language) {
wixLanguage = config.tauri.bundle.windows.wix.language
}

if (!(name && version)) {
console.error('Could not determine package name and version')
Expand All @@ -156,6 +171,7 @@ export function getInfo(root: string): Info {
return {
name,
version,
wixLanguage,
}
} else {
const packageJson = getPackageJson(root)
Expand All @@ -165,7 +181,8 @@ export function getInfo(root: string): Info {
const version = packageJson ? packageJson.version : '0.1.0'
return {
name: appName,
version
version,
wixLanguage: 'en-US',
}
}
}
Expand Down Expand Up @@ -200,6 +217,7 @@ export async function buildProject(
runner,
name: info.name,
version: info.version,
wixLanguage: info.wixLanguage
}
} else {
const packageJson = getPackageJson(root)
Expand Down Expand Up @@ -230,6 +248,7 @@ export async function buildProject(
runner,
name: info.name,
version: info.version,
wixLanguage: info.wixLanguage,
}
if (iconPath) {
return execCommand(runner.runnerCommand, [...runner.runnerArgs, 'icon', join(root, iconPath)], {
Expand Down Expand Up @@ -309,20 +328,32 @@ export async function buildProject(
)
]
} else if (platform() === 'win32') {
return [
join(
// If multiple Wix languages are specified, multiple installers (.msi) will be made
// The .zip and .sig are only generated for the first specified language
let langs
if (typeof app.wixLanguage === "string") {
langs = [app.wixLanguage]
} else if (Array.isArray(app.wixLanguage)) {
langs = app.wixLanguage
} else {
langs = Object.keys(app.wixLanguage)
}
const artifacts: string[] = []
langs.forEach(lang => {
artifacts.push(join(
artifactsPath,
`bundle/msi/${fileAppName}_${app.version}_${process.arch}.msi`
),
join(
`bundle/msi/${fileAppName}_${app.version}_${process.arch}_${lang}.msi`
))
artifacts.push(join(
artifactsPath,
`bundle/msi/${fileAppName}_${app.version}_${process.arch}.msi.zip`
),
join(
`bundle/msi/${fileAppName}_${app.version}_${process.arch}_${lang}.msi.zip`
))
artifacts.push(join(
artifactsPath,
`bundle/msi/${fileAppName}_${app.version}_${process.arch}.msi.zip.sig`
)
]
`bundle/msi/${fileAppName}_${app.version}_${process.arch}_${lang}.msi.zip.sig`
))
})
return artifacts
} else {
const arch =
process.arch === 'x64'
Expand Down

0 comments on commit 4d70258

Please sign in to comment.