mirror of
https://github.com/tauri-apps/tauri-action.git
synced 2026-01-31 00:35:20 +01:00
fix: add proper args parsing (#1195)
This commit is contained in:
4
dist/index.js
vendored
4
dist/index.js
vendored
File diff suppressed because one or more lines are too long
24
pnpm-lock.yaml
generated
24
pnpm-lock.yaml
generated
@@ -1935,9 +1935,9 @@ snapshots:
|
||||
- encoding
|
||||
- mocha
|
||||
|
||||
'@covector/assemble@0.12.0':
|
||||
'@covector/assemble@0.12.0(mocha@10.4.0)':
|
||||
dependencies:
|
||||
'@covector/command': 0.8.0
|
||||
'@covector/command': 0.8.0(mocha@10.4.0)
|
||||
'@covector/files': 0.8.0
|
||||
effection: 2.0.8(mocha@10.4.0)
|
||||
js-yaml: 4.1.0
|
||||
@@ -1948,9 +1948,10 @@ snapshots:
|
||||
unified: 9.2.2
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
- mocha
|
||||
- supports-color
|
||||
|
||||
'@covector/changelog@0.12.0':
|
||||
'@covector/changelog@0.12.0(mocha@10.4.0)':
|
||||
dependencies:
|
||||
'@covector/files': 0.8.0
|
||||
effection: 2.0.8(mocha@10.4.0)
|
||||
@@ -1960,14 +1961,16 @@ snapshots:
|
||||
unified: 9.2.2
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
- mocha
|
||||
- supports-color
|
||||
|
||||
'@covector/command@0.8.0':
|
||||
'@covector/command@0.8.0(mocha@10.4.0)':
|
||||
dependencies:
|
||||
'@effection/process': 2.1.4
|
||||
'@effection/process': 2.1.4(mocha@10.4.0)
|
||||
effection: 2.0.8(mocha@10.4.0)
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
- mocha
|
||||
|
||||
'@covector/files@0.8.0':
|
||||
dependencies:
|
||||
@@ -2014,10 +2017,8 @@ snapshots:
|
||||
dependencies:
|
||||
effection: 2.0.8(mocha@10.4.0)
|
||||
mocha: 10.4.0
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
|
||||
'@effection/process@2.1.4':
|
||||
'@effection/process@2.1.4(mocha@10.4.0)':
|
||||
dependencies:
|
||||
cross-spawn: 7.0.6
|
||||
ctrlc-windows: 2.2.0
|
||||
@@ -2025,6 +2026,7 @@ snapshots:
|
||||
shellwords: 0.1.1
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
- mocha
|
||||
|
||||
'@effection/stream@2.0.6':
|
||||
dependencies:
|
||||
@@ -2537,9 +2539,9 @@ snapshots:
|
||||
dependencies:
|
||||
'@clack/prompts': 0.7.0
|
||||
'@covector/apply': 0.10.0(mocha@10.4.0)
|
||||
'@covector/assemble': 0.12.0
|
||||
'@covector/changelog': 0.12.0
|
||||
'@covector/command': 0.8.0
|
||||
'@covector/assemble': 0.12.0(mocha@10.4.0)
|
||||
'@covector/changelog': 0.12.0(mocha@10.4.0)
|
||||
'@covector/command': 0.8.0(mocha@10.4.0)
|
||||
'@covector/files': 0.8.0
|
||||
effection: 2.0.8(mocha@10.4.0)
|
||||
globby: 11.1.0
|
||||
|
||||
26
src/build.ts
26
src/build.ts
@@ -20,26 +20,10 @@ export async function buildProject(
|
||||
): Promise<Artifact[]> {
|
||||
const runner = await getRunner(root, buildOpts.tauriScript);
|
||||
|
||||
const tauriArgs = buildOpts.args ?? [];
|
||||
|
||||
const debug =
|
||||
[...tauriArgs].findIndex((e) => e === '-d' || e === '--debug') >= 0;
|
||||
|
||||
const targetArgIdx = [...tauriArgs].findIndex(
|
||||
(e) => e === '-t' || e === '--target',
|
||||
);
|
||||
const targetPath =
|
||||
targetArgIdx >= 0 ? [...tauriArgs][targetArgIdx + 1] : undefined;
|
||||
|
||||
const configArgIdx = [...tauriArgs].findIndex(
|
||||
(e) => e === '-c' || e === '--config',
|
||||
);
|
||||
const configArg =
|
||||
configArgIdx >= 0 ? [...tauriArgs][configArgIdx + 1] : undefined;
|
||||
|
||||
const profileArgIdx = [...tauriArgs].findIndex((e) => e === '--profile');
|
||||
const profile =
|
||||
profileArgIdx >= 0 ? [...tauriArgs][profileArgIdx + 1] : undefined;
|
||||
const debug = buildOpts.parsedArgs['debug'] as boolean;
|
||||
const targetPath = buildOpts.parsedArgs['target'] as string | undefined;
|
||||
const configArg = buildOpts.parsedArgs['config'] as string | undefined;
|
||||
const profile = buildOpts.parsedRunnerArgs['profile'] as string | undefined;
|
||||
|
||||
const targetInfo = getTargetInfo(targetPath);
|
||||
|
||||
@@ -61,7 +45,7 @@ export async function buildProject(
|
||||
|
||||
await runner.execTauriCommand(
|
||||
['build'],
|
||||
[...tauriArgs],
|
||||
buildOpts.rawArgs || [],
|
||||
root,
|
||||
targetInfo.platform === 'macos'
|
||||
? {
|
||||
|
||||
42
src/index.ts
42
src/index.ts
@@ -13,6 +13,7 @@ import { execCommand, getInfo, getTargetInfo } from './utils';
|
||||
|
||||
import type { Artifact, BuildOptions } from './types';
|
||||
import { uploadWorkflowArtifacts } from './upload-workflow-artifacts';
|
||||
import { parseArgs } from 'node:util';
|
||||
|
||||
async function run(): Promise<void> {
|
||||
try {
|
||||
@@ -23,8 +24,26 @@ async function run(): Promise<void> {
|
||||
const includeUpdaterJson = core.getBooleanInput('includeUpdaterJson');
|
||||
const retryAttempts = parseInt(core.getInput('retryAttempts') || '0', 10);
|
||||
const tauriScript = core.getInput('tauriScript');
|
||||
const args = stringArgv(core.getInput('args'));
|
||||
const releaseAssetNamePattern = core.getInput('releaseAssetNamePattern');
|
||||
const rawArgs = stringArgv(core.getInput('args'));
|
||||
const parsedArgs = parseArgs({
|
||||
args: rawArgs,
|
||||
strict: false,
|
||||
options: {
|
||||
target: { type: 'string', short: 't' },
|
||||
config: {
|
||||
type: 'string',
|
||||
short: 'c',
|
||||
},
|
||||
debug: { type: 'boolean', short: 'd' },
|
||||
},
|
||||
});
|
||||
const parsedRunnerArgs = parseArgs({
|
||||
args: parsedArgs.positionals,
|
||||
strict: false,
|
||||
options: { profile: { type: 'string' } },
|
||||
});
|
||||
|
||||
const uploadPlainBinary = core.getBooleanInput('uploadPlainBinary');
|
||||
|
||||
let tagName = core.getInput('tagName').replace('refs/tags/', '');
|
||||
@@ -48,7 +67,7 @@ async function run(): Promise<void> {
|
||||
const workflowArtifactsNamePattern =
|
||||
core.getInput('workflowArtifactsNamePattern') ||
|
||||
'[platform]-[arch]-[bundle]';
|
||||
const uplodaUpdaterSignatures = core.getBooleanInput(
|
||||
const uploadUpdaterSignatures = core.getBooleanInput(
|
||||
'uploadUpdaterSignatures',
|
||||
);
|
||||
|
||||
@@ -59,20 +78,13 @@ async function run(): Promise<void> {
|
||||
|
||||
const buildOptions: BuildOptions = {
|
||||
tauriScript,
|
||||
args,
|
||||
rawArgs,
|
||||
parsedArgs: parsedArgs.values,
|
||||
parsedRunnerArgs: parsedRunnerArgs.values,
|
||||
};
|
||||
|
||||
const targetArgIdx = [...args].findIndex(
|
||||
(e) => e === '-t' || e === '--target',
|
||||
);
|
||||
const targetPath =
|
||||
targetArgIdx >= 0 ? [...args][targetArgIdx + 1] : undefined;
|
||||
|
||||
const configArgIdx = [...args].findIndex(
|
||||
(e) => e === '-c' || e === '--config',
|
||||
);
|
||||
const configArg =
|
||||
configArgIdx >= 0 ? [...args][configArgIdx + 1] : undefined;
|
||||
const targetPath = buildOptions.parsedArgs['target'] as string | undefined;
|
||||
const configArg = buildOptions.parsedArgs['config'] as string | undefined;
|
||||
|
||||
const artifacts: Artifact[] = [];
|
||||
|
||||
@@ -192,7 +204,7 @@ async function run(): Promise<void> {
|
||||
githubBaseUrl,
|
||||
isGitea,
|
||||
releaseAssetNamePattern,
|
||||
uplodaUpdaterSignatures,
|
||||
uploadUpdaterSignatures,
|
||||
);
|
||||
|
||||
if (includeUpdaterJson) {
|
||||
|
||||
14
src/types.d.ts
vendored
14
src/types.d.ts
vendored
@@ -33,9 +33,21 @@ export interface Artifact {
|
||||
|
||||
export interface BuildOptions {
|
||||
tauriScript: string | null;
|
||||
args: string[] | null;
|
||||
rawArgs: string[] | null;
|
||||
parsedArgs: ParsedArgs;
|
||||
parsedRunnerArgs: ParsedRunnerArgs;
|
||||
}
|
||||
|
||||
type ParsedArgs = {
|
||||
debug?: string | boolean;
|
||||
config?: string | boolean;
|
||||
target?: string | boolean;
|
||||
};
|
||||
|
||||
type ParsedRunnerArgs = {
|
||||
profile?: string | boolean;
|
||||
};
|
||||
|
||||
export interface CargoManifestBin {
|
||||
name: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user