Skip to content
This repository was archived by the owner on Nov 9, 2023. It is now read-only.

Commit d286db8

Browse files
authored
Merge pull request #49 from tauri-apps/feat/rc
2 parents bdab351 + f36a319 commit d286db8

File tree

4 files changed

+189
-1333
lines changed

4 files changed

+189
-1333
lines changed

generator/index.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
const { init } = require('@tauri-apps/cli/dist/api/cli')
1+
const cli = require('@tauri-apps/cli')
22

33
module.exports = async (api, options) => {
4-
init({
5-
directory: api.resolve('.'),
6-
appName: options.appName,
7-
windowTitle: options.windowTitle,
8-
distDir: 'Set automatically by Vue CLI plugin',
9-
devPath: 'Set automatically by Vue CLI plugin'
10-
})
4+
cli.run([
5+
'init',
6+
'--directory', api.resolve('.'),
7+
'--app-name', options.appName,
8+
'--window-title', options.windowTitle,
9+
'--dist-dir', 'Set automatically by Vue CLI plugin',
10+
'--dev-path', 'Set automatically by Vue CLI plugin'
11+
])
1112

1213
api.extendPackage({
1314
scripts: {

index.js

Lines changed: 53 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
module.exports = (api, options) => {
22
// If plugin options are provided in vue.config.js, those will be used. Otherwise it is empty object
33
const pluginOptions =
4-
options.pluginOptions && options.pluginOptions.tauri
5-
? options.pluginOptions.tauri
6-
: {}
4+
options.pluginOptions && options.pluginOptions.tauri ?
5+
options.pluginOptions.tauri :
6+
{}
77

88
api.chainWebpack((cfg) => {
99
if (process.env.TAURI_SERVE || process.env.TAURI_BUILD) {
@@ -14,11 +14,11 @@ module.exports = (api, options) => {
1414
return args
1515
})
1616
} else {
17-
cfg.plugin('define').use(DefinePlugin, [
18-
{
19-
'process.env': { IS_TAURI: true }
17+
cfg.plugin('define').use(DefinePlugin, [{
18+
'process.env': {
19+
IS_TAURI: true
2020
}
21-
])
21+
}])
2222
}
2323

2424
// Apply custom config from user
@@ -29,47 +29,51 @@ module.exports = (api, options) => {
2929
})
3030

3131
api.registerCommand(
32-
'tauri:serve',
33-
{
34-
// TODO: fill in meta
35-
description: 'todo',
36-
usage: 'todo'
32+
'tauri:serve', {
33+
description: 'Starts Tauri in development mode',
34+
usage: 'vue-cli-service tauri:serve'
3735
},
3836
async () => {
39-
const { dev } = require('@tauri-apps/cli/dist/api/cli')
37+
const cli = require('@tauri-apps/cli')
4038

4139
// Use custom config for webpack
4240
process.env.TAURI_SERVE = true
4341

4442
const server = await api.service.run('serve')
45-
46-
return dev({
47-
config: {
48-
build: {
49-
devPath: server.url
50-
}
43+
const config = {
44+
build: {
45+
devPath: server.url
5146
}
52-
})
47+
}
48+
49+
cli.run(['dev', '--config', JSON.stringify(config)])
5350
}
5451
)
5552

5653
api.registerCommand(
57-
'tauri:build',
58-
{
59-
// TODO: fill in meta
60-
description: 'todo',
61-
usage: 'todo'
54+
'tauri:build', {
55+
description: 'Builds the Tauri application',
56+
usage: 'vue-cli-service tauri:build [options]',
57+
options: {
58+
'--skip-bundle': 'skip bundling the frontend application',
59+
'--verbose': 'enables verbose logging',
60+
'--debug': 'build with the debug flag',
61+
'--target': 'target triple to build against. It must be one of the values outputted by `$rustc --print target-list` or `universal-apple-darwin` for an universal macOS application. note that compiling an universal macOS application requires both `aarch64-apple-darwin` and `x86_64-apple-darwin` targets to be installed',
62+
'--bundle': 'set which applications bundle to package, e.g. "appimage,deb" or "app,dmg". Defaults to all bundles for the current platform',
63+
}
6264
},
6365
async (args) => {
64-
const { build } = require('@tauri-apps/cli/dist/api/cli')
65-
const { error } = require('@vue/cli-shared-utils')
66+
const cli = require('@tauri-apps/cli')
67+
const {
68+
error
69+
} = require('@vue/cli-shared-utils')
6670

6771
// Use custom config for webpack
6872
process.env.TAURI_BUILD = true
6973
// Set publicPath so that scripts are properly imported
7074
options.publicPath = ''
7175

72-
if (!args.skipBundle) {
76+
if (!args['skip-bundle']) {
7377
try {
7478
await api.service.run('build', {
7579
dest: 'src-tauri/target/webpack_dist'
@@ -82,17 +86,27 @@ module.exports = (api, options) => {
8286
}
8387
}
8488

85-
build({
86-
config: {
87-
build: {
88-
distDir: './target/webpack_dist'
89-
}
90-
},
91-
verbose: args.v || args.verbose || false,
92-
debug: args.d || args.debug || false,
93-
target: args.t || args.target || false,
94-
bundle: args.b || args.bundle || false
95-
})
89+
const config = {
90+
build: {
91+
distDir: './target/webpack_dist'
92+
}
93+
}
94+
const cliArgs = ['build', '--config', JSON.stringify(config)]
95+
if (args.v || args.verbose) {
96+
cliArgs.push('--verbose')
97+
}
98+
if (args.d || args.debug) {
99+
cliArgs.push('--debug')
100+
}
101+
if (args.t || args.target) {
102+
cliArgs.push('--target')
103+
cliArgs.push(args.t)
104+
}
105+
if (args.b || args.bundle) {
106+
cliArgs.push('--bundle')
107+
cliArgs.push(args.b)
108+
}
109+
cli.run(cliArgs)
96110
}
97111
)
98112
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-cli-plugin-tauri",
3-
"version": "1.0.0-beta.6",
3+
"version": "1.0.0-rc.0",
44
"description": "A Vue CLI plugin for rigging Tauri",
55
"main": "index.js",
66
"author": "Noah Klayman <noahklayman@gmail.com>",
@@ -11,7 +11,7 @@
1111
"pretest": "rimraf __tests__/temp_projects/*"
1212
},
1313
"dependencies": {
14-
"@tauri-apps/cli": "1.0.0-beta.6",
14+
"@tauri-apps/cli": "1.0.0-rc.1",
1515
"@vue/cli-shared-utils": "^4.1.1"
1616
},
1717
"devDependencies": {

0 commit comments

Comments
 (0)