Skip to content

Commit

Permalink
feat: add args option, closes #131 (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored May 13, 2021
1 parent 0e9704e commit f564b01
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 23 deletions.
6 changes: 6 additions & 0 deletions .changes/args.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@tauri-apps/action-core": patch
"action": patch
---

Adds `args` option to pass arguments to the tauri command.
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ inputs:
description: 'the package.json script to run to build the Tauri app'
preferGlobal:
description: 'set this to true to use a globally installed tauri instead'
args:
description: 'arguments for the tauri command'
outputs:
releaseId:
description: 'The ID of the created release'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition = "2018"
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = [ "derive" ] }
tauri = { version = "1.0.0-beta-rc.2", features =["api-all"]}
tauri = { version = "1.0.0-beta-rc.2", features = ["api-all", "updater"] }

[build-dependencies]
tauri-build = "1.0.0-beta-rc.0"
Expand Down
6 changes: 3 additions & 3 deletions packages/action/dist/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/action/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@actions/core": "1.2.7",
"@actions/github": "4.0.0",
"@tauri-apps/action-core": "0.1.1",
"string-argv": "0.3.1",
"tslib": "2.2.0"
},
"devDependencies": {
Expand Down
5 changes: 4 additions & 1 deletion packages/action/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import uploadReleaseAssets from './upload-release-assets'
import createRelease from './create-release'
import { getPackageJson, buildProject, execCommand } from '@tauri-apps/action-core'
import type { BuildOptions } from '@tauri-apps/action-core'
import stringArgv from 'string-argv'

async function run(): Promise<void> {
try {
Expand All @@ -22,6 +23,7 @@ async function run(): Promise<void> {
const iconPath = core.getInput('iconPath')
const includeDebug = core.getInput('includeDebug') === 'true'
const npmScript = core.getInput('npmScript')
const args = stringArgv(core.getInput('args'))

let tagName = core.getInput('tagName').replace('refs/tags/', '')
let releaseName = core.getInput('releaseName').replace('refs/tags/', '')
Expand All @@ -40,7 +42,8 @@ async function run(): Promise<void> {
configPath: existsSync(configPath) ? configPath : null,
distPath,
iconPath,
npmScript
npmScript,
args
}
const artifacts = await buildProject(preferGlobal, projectPath, false, options)
if (includeDebug) {
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ export async function run(): Promise<void> {
const iconPath = argv['icon-path']
const includeDebug = argv['include-debug']
const npmScript = argv['npm-script']
const args = argv._

const options: BuildOptions = {
configPath: existsSync(configPath) ? configPath : null,
distPath,
iconPath,
npmScript
npmScript,
args
}
const artifacts = await buildProject(preferGlobal, projectPath, false, options)
if (includeDebug) {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"url": "git+https://github.com/tauri-apps/tauri-action.git"
},
"dependencies": {
"@tauri-apps/action-core": "0.1.0",
"@tauri-apps/action-core": "0.1.1",
"minimist": "1.2.5",
"tslib": "2.2.0"
},
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export default {
entryFileNames: "[name].js",
exports: "named",
},
plugins: [typescript()],
plugins: [typescript({
allowSyntheticDefaultImports: true
})],
external: [
...Object.keys(pkg.dependencies || {}),
"path",
Expand Down
11 changes: 6 additions & 5 deletions packages/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { platform } from 'os'
import { readFileSync, existsSync, copyFileSync, writeFileSync } from 'fs'
import execa from 'execa'
import toml from '@iarna/toml'
import { parse as parseToml } from '@iarna/toml'
import { join } from 'path'

export function getPackageJson(root: string): any {
Expand Down Expand Up @@ -68,6 +68,7 @@ export interface BuildOptions {
distPath: string | null
iconPath: string | null
npmScript: string | null
args: string[] | null
}

export interface Runner {
Expand All @@ -79,7 +80,7 @@ export async function buildProject(
preferGlobal: boolean,
root: string,
debug: boolean,
{ configPath, distPath, iconPath, npmScript }: BuildOptions
{ configPath, distPath, iconPath, npmScript, args }: BuildOptions
): Promise<string[]> {
return new Promise<Runner>((resolve, reject) => {
if (preferGlobal) {
Expand Down Expand Up @@ -118,7 +119,7 @@ export async function buildProject(
}
if (!(name && version)) {
const manifestPath = join(root, 'src-tauri/Cargo.toml')
const cargoManifest = (toml.parse(
const cargoManifest = (parseToml(
readFileSync(manifestPath).toString()
) as any) as CargoManifest
name = name || cargoManifest.package.name
Expand Down Expand Up @@ -191,7 +192,7 @@ export async function buildProject(
writeFileSync(tauriConfPath, JSON.stringify(tauriConf))
}

const args = debug ? ['--debug'] : []
const tauriArgs = debug ? ['--debug', ...(args ?? [])] : (args ?? [])
let buildCommand
let buildArgs: string[] = []

Expand All @@ -209,7 +210,7 @@ export async function buildProject(

return execCommand(
buildCommand,
[...buildArgs, ...args],
[...buildArgs, ...tauriArgs],
{ cwd: root }
)
.then(() => {
Expand Down
4 changes: 3 additions & 1 deletion packages/core/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export default {
entryFileNames: "[name].js",
exports: "named",
},
plugins: [typescript()],
plugins: [typescript({
tsconfig: './tsconfig.json'
})],
external: [
...Object.keys(pkg.dependencies || {}),
"path",
Expand Down
3 changes: 2 additions & 1 deletion packages/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "."
"rootDir": ".",
"allowSyntheticDefaultImports": true
},
"include": ["index.ts"]
}
13 changes: 5 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,6 @@
estree-walker "^1.0.1"
picomatch "^2.2.2"

"@tauri-apps/[email protected]":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/action-core/-/action-core-0.1.0.tgz#dec84eb4d6eb4e37c6772fa5edac5457331c7a10"
integrity sha512-apyQvpGejwqra2oWRhOHlC8wFS1MzqXKaDkwqutEmQ2G4COg2d1sON/UKYamlTTw33E8gsoz8HMhph8XXVkJsA==
dependencies:
"@iarna/toml" "2.2.5"
execa "5.0.0"

"@tauri-apps/toml@^2.2.4":
version "2.2.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/toml/-/toml-2.2.4.tgz#2b4f637aded7fc3a7302724605682c8fa3ac7505"
Expand Down Expand Up @@ -1605,6 +1597,11 @@ spdx-license-ids@^3.0.0:
resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.7.tgz#e9c18a410e5ed7e12442a549fbd8afa767038d65"
integrity sha512-U+MTEOO0AiDzxwFvoa4JVnMV6mZlJKk2sBLt90s7G0Gd0Mlknc7kxEn3nuDPNZRta7O2uy8oLcZLVT+4sqNZHQ==

[email protected]:
version "0.3.1"
resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.3.1.tgz#95e2fbec0427ae19184935f816d74aaa4c5c19da"
integrity sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg==

string-width@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3"
Expand Down

0 comments on commit f564b01

Please sign in to comment.