mirror of
https://github.com/tauri-apps/tauri-action.git
synced 2026-01-31 00:35:20 +01:00
fix!: remove broken configPath option (#428)
* fix!: remove broken `configPath` option * try to read --config arg as json string first * resolve config flag relative to projectPath * better --config error message * typo
This commit is contained in:
5
.changes/breaking-remove-configpath.md
Normal file
5
.changes/breaking-remove-configpath.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'action': minor
|
||||
---
|
||||
|
||||
**Breaking change**: Remove broken `configPath` argument in favor of `--config` flag.
|
||||
15
README.md
15
README.md
@@ -191,13 +191,12 @@ jobs:
|
||||
|
||||
These inputs are _typically_ only used if your GitHub repo does not contain an existing Tauri project and you want the action to initialize it for you.
|
||||
|
||||
| Name | Required | Description | Type | Default |
|
||||
| ------------------ | :------------------------------: | ------------------------------------------------------------------------------------------- | ------ | --------------- |
|
||||
| `projectPath` | false | The path to the root of the tauri project relative to the current working directory | string | . |
|
||||
| `configPath` | false | Path to the tauri.conf.json file if you want a configuration different from the default one | string | tauri.conf.json |
|
||||
| `distPath` | false | Path to the distributable folder with your index.html and JS/CSS | string | |
|
||||
| `iconPath` | false | path to the PNG icon to use as app icon, relative to the projectPath | string | |
|
||||
| `bundleIdentifier` | yes, if not changed via --config | the bundle identifier to inject when initializing the Tauri app | string | |
|
||||
| Name | Required | Description | Type | Default |
|
||||
| ------------------ | :--------------------------: | ----------------------------------------------------------------------------------- | ------ | ------- |
|
||||
| `projectPath` | false | The path to the root of the tauri project relative to the current working directory | string | . |
|
||||
| `distPath` | false | Path to the distributable folder with your index.html and JS/CSS | string | |
|
||||
| `iconPath` | false | path to the PNG icon to use as app icon, relative to the projectPath | string | |
|
||||
| `bundleIdentifier` | yes, if not set via --config | the bundle identifier to inject when initializing the Tauri app | string | |
|
||||
|
||||
### Build Options
|
||||
|
||||
@@ -205,6 +204,7 @@ These inputs allow you to change how your Tauri project will be build.
|
||||
|
||||
| Name | Required | Description | Type | Default |
|
||||
| -------------------- | :------: | ------------------------------------------------------------------------------------------------- | ------ | --------------------------- |
|
||||
| `projectPath` | false | The path to the root of the tauri project relative to the current working directory | string | . |
|
||||
| `includeDebug` | false | whether to include a debug build or not | bool | false |
|
||||
| `includeRelease` | false | whether to include a release build or not | bool | true |
|
||||
| `includeUpdaterJson` | false | whether to upload a JSON file for the updater or not (only relevant if the updater is configured) | bool | true |
|
||||
@@ -246,4 +246,5 @@ These inputs allow you to modify the GitHub release.
|
||||
- If you want to add additional arguments to the build command, you can use the `args` option. For example, if you're setting a specific target for your build, you can specify `args: --target your-target-arch`.
|
||||
- When your Tauri app is not in the root of the repo, use the `projectPath` input.
|
||||
- Usually it will work without it, but the action will install and use a global `@tauri-apps/cli` installation instead of your project's CLI which can cause issues if you also configured `tauriScript` or if you have multiple `tauri.conf.json` files in your repo.
|
||||
- Additionally, relative paths provided via the `--config` flag will be resolved relative to the `projectPath` to match Tauri's behavior.
|
||||
- If you create the release yourself and provide a `releaseId` but do not set `tagName`, the download url for updater bundles in `latest.json` will point to `releases/latest/download/<bundle>` which can cause issues if your repo contains releases that do not include updater bundles.
|
||||
|
||||
@@ -23,9 +23,6 @@ inputs:
|
||||
projectPath:
|
||||
description: 'path to the root of the project that will be built'
|
||||
default: '.'
|
||||
configPath:
|
||||
description: 'path to the tauri.conf.json file if you want a configuration different from the default one'
|
||||
default: 'tauri.conf.json'
|
||||
distPath:
|
||||
description: 'path to the distributable folder with your index.html and JS/CSS'
|
||||
iconPath:
|
||||
|
||||
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
15
src/build.ts
15
src/build.ts
@@ -33,12 +33,12 @@ export async function buildProject(
|
||||
const configArgIdx = [...tauriArgs].findIndex(
|
||||
(e) => e === '-c' || e === '--config'
|
||||
);
|
||||
const configArgPath =
|
||||
const configArg =
|
||||
configArgIdx >= 0 ? [...tauriArgs][configArgIdx + 1] : undefined;
|
||||
|
||||
const targetInfo = getTargetInfo(targetPath);
|
||||
|
||||
const info = getInfo(root, buildOpts.configPath, targetInfo, configArgPath);
|
||||
const info = getInfo(root, targetInfo, configArg);
|
||||
|
||||
const app = info.tauriPath
|
||||
? {
|
||||
@@ -50,17 +50,6 @@ export async function buildProject(
|
||||
}
|
||||
: await initProject(root, runner, info, buildOpts);
|
||||
|
||||
const tauriConfPath = join(app.tauriPath, 'tauri.conf.json');
|
||||
if (buildOpts.configPath) {
|
||||
copyFileSync(buildOpts.configPath, tauriConfPath);
|
||||
}
|
||||
|
||||
if (buildOpts.distPath) {
|
||||
const tauriConf = JSON.parse(readFileSync(tauriConfPath).toString());
|
||||
tauriConf.build.distDir = buildOpts.distPath;
|
||||
writeFileSync(tauriConfPath, JSON.stringify(tauriConf));
|
||||
}
|
||||
|
||||
let buildCommand;
|
||||
if (hasDependency('vue-cli-plugin-tauri', root)) {
|
||||
buildCommand = 'tauri:build';
|
||||
|
||||
@@ -82,18 +82,34 @@ export function mergePlatformConfig(
|
||||
}
|
||||
|
||||
/// This modifies baseConfig in-place!
|
||||
export function mergeUserConfig(baseConfig: TauriConfig, configPath: string) {
|
||||
const config = readCustomConfig(configPath);
|
||||
export function mergeUserConfig(
|
||||
root: string,
|
||||
baseConfig: TauriConfig,
|
||||
mergeConfig: string
|
||||
) {
|
||||
let config = _tryParseJsonConfig(mergeConfig);
|
||||
|
||||
if (!config) {
|
||||
const configPath = path.isAbsolute(mergeConfig)
|
||||
? mergeConfig
|
||||
: path.join(root, mergeConfig);
|
||||
|
||||
config = readCustomConfig(configPath);
|
||||
}
|
||||
|
||||
if (config) {
|
||||
merge(baseConfig, config);
|
||||
} else {
|
||||
console.error(`Couldn't read --config: ${mergeConfig}`);
|
||||
}
|
||||
}
|
||||
|
||||
export function getConfig(tauriDir: string, customPath?: string): TauriConfig {
|
||||
if (customPath) {
|
||||
export function getConfig(
|
||||
tauriDir: string /* customPath?: string */
|
||||
): TauriConfig {
|
||||
/* if (customPath) {
|
||||
return readCustomConfig(customPath);
|
||||
}
|
||||
} */
|
||||
|
||||
if (existsSync(join(tauriDir, 'tauri.conf.json'))) {
|
||||
const contents = readFileSync(join(tauriDir, 'tauri.conf.json')).toString();
|
||||
|
||||
@@ -19,10 +19,6 @@ async function run(): Promise<void> {
|
||||
process.cwd(),
|
||||
core.getInput('projectPath') || process.argv[2]
|
||||
);
|
||||
const configPath = join(
|
||||
projectPath,
|
||||
core.getInput('configPath') || 'tauri.conf.json'
|
||||
);
|
||||
const distPath = core.getInput('distPath');
|
||||
const iconPath = core.getInput('iconPath');
|
||||
const includeRelease = core.getBooleanInput('includeRelease');
|
||||
@@ -49,7 +45,6 @@ async function run(): Promise<void> {
|
||||
}
|
||||
|
||||
const options: BuildOptions = {
|
||||
configPath: existsSync(configPath) ? configPath : undefined,
|
||||
distPath,
|
||||
iconPath,
|
||||
tauriScript,
|
||||
@@ -66,11 +61,11 @@ async function run(): Promise<void> {
|
||||
const configArgIdx = [...args].findIndex(
|
||||
(e) => e === '-c' || e === '--config'
|
||||
);
|
||||
const configArgPath =
|
||||
const configArg =
|
||||
configArgIdx >= 0 ? [...args][configArgIdx + 1] : undefined;
|
||||
|
||||
const targetInfo = getTargetInfo(targetPath);
|
||||
const info = getInfo(projectPath, undefined, targetInfo, configArgPath);
|
||||
const info = getInfo(projectPath, targetInfo, configArg);
|
||||
|
||||
const artifacts: Artifact[] = [];
|
||||
if (includeRelease) {
|
||||
|
||||
1
src/types.d.ts
vendored
1
src/types.d.ts
vendored
@@ -14,7 +14,6 @@ export interface Artifact {
|
||||
}
|
||||
|
||||
export interface BuildOptions {
|
||||
configPath?: string;
|
||||
distPath: string | null;
|
||||
iconPath: string | null;
|
||||
tauriScript: string | null;
|
||||
|
||||
@@ -153,7 +153,6 @@ export function execCommand(
|
||||
|
||||
export function getInfo(
|
||||
root: string,
|
||||
inConfigPath?: string,
|
||||
targetInfo?: TargetInfo,
|
||||
configFlag?: string
|
||||
): Info {
|
||||
@@ -164,12 +163,12 @@ export function getInfo(
|
||||
let wixLanguage: string | string[] | { [language: string]: unknown } =
|
||||
'en-US';
|
||||
|
||||
const config = getConfig(tauriDir, inConfigPath);
|
||||
const config = getConfig(tauriDir);
|
||||
if (targetInfo) {
|
||||
mergePlatformConfig(config, tauriDir, targetInfo.platform);
|
||||
}
|
||||
if (configFlag) {
|
||||
mergeUserConfig(config, configFlag);
|
||||
mergeUserConfig(root, config, configFlag);
|
||||
}
|
||||
|
||||
if (config.package) {
|
||||
|
||||
Reference in New Issue
Block a user