From c81ac5ee2a8d95de48b1d38c4c0bde629d6891b0 Mon Sep 17 00:00:00 2001 From: Noah Klayman Date: Mon, 25 Jan 2021 15:45:34 -0800 Subject: [PATCH 1/5] feat: add support for building with vue cli --- README.md | 4 ++++ src/main.ts | 18 +++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3818c2aa76..615f40d1bc 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,8 @@ jobs: sudo apt-get update sudo apt-get install -y webkit2gtk-4.0 - name: install app dependencies and build it + # If using the Vue CLI plugin, tauri:build will be run automatically by tauri-action + # and you can remove `&& yarn build` from this command run: yarn && yarn build - uses: tauri-apps/tauri-action@v0 env: @@ -149,6 +151,8 @@ jobs: sudo apt-get update sudo apt-get install -y webkit2gtk-4.0 - name: install app dependencies and build it + # If using the Vue CLI plugin, tauri:build will be run automatically by tauri-action + # and you can remove `&& yarn build` from this command run: yarn && yarn build - uses: tauri-apps/tauri-action@v0 env: diff --git a/src/main.ts b/src/main.ts index d840063089..b56b11d4ac 100644 --- a/src/main.ts +++ b/src/main.ts @@ -17,12 +17,13 @@ function getPackageJson(root: string): any { return null } -function hasTauriDependency(root: string): boolean { +function hasDependency(dependencyName: string, root: string): boolean { const packageJson = getPackageJson(root) return ( packageJson && - ((packageJson.dependencies && packageJson.dependencies.tauri) || - (packageJson.devDependencies && packageJson.devDependencies.tauri)) + ((packageJson.dependencies && packageJson.dependencies[dependencyName]) || + (packageJson.devDependencies && + packageJson.devDependencies[dependencyName])) ) } @@ -73,9 +74,9 @@ async function buildProject( {configPath, distPath, iconPath, npmScript}: BuildOptions ): Promise { return new Promise(resolve => { - if (core.getInput('preferGlobal') === "true") { + if (core.getInput('preferGlobal') === 'true') { resolve('tauri') - } else if (hasTauriDependency(root)) { + } else if (hasDependency('tauri', root)) { if (npmScript) { resolve(usesYarn(root) ? `yarn ${npmScript}` : `npm run ${npmScript}`) } else { @@ -145,8 +146,11 @@ async function buildProject( } const args = debug ? ['--debug'] : [] + const buildCommand = hasDependency('vue-cli-plugin-tauri', root) + ? (usesYarn(root) ? 'yarn' : 'npm run') + ' tauri:build' + : `${app.runner} build` return execCommand( - `${app.runner} build` + (args.length ? ` ${args.join(' ')}` : ''), + buildCommand + (args.length ? ` ${args.join(' ')}` : ''), {cwd: root} ) .then(() => { @@ -298,4 +302,4 @@ async function run(): Promise { } } -run() \ No newline at end of file +run() From 84b0de24b014f85ea905c91f02ebbdba9ab0d3c8 Mon Sep 17 00:00:00 2001 From: Noah Klayman Date: Tue, 26 Jan 2021 21:02:20 -0800 Subject: [PATCH 2/5] fix: don't install tauri.js if using vue cli plugin --- src/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index b56b11d4ac..101c931b77 100644 --- a/src/main.ts +++ b/src/main.ts @@ -76,7 +76,7 @@ async function buildProject( return new Promise(resolve => { if (core.getInput('preferGlobal') === 'true') { resolve('tauri') - } else if (hasDependency('tauri', root)) { + } else if (hasDependency('tauri', root) || hasDependency('vue-cli-plugin-tauri', root)) { if (npmScript) { resolve(usesYarn(root) ? `yarn ${npmScript}` : `npm run ${npmScript}`) } else { From 03604947dbfc6a54d5f2ea36e645d190e865ff2f Mon Sep 17 00:00:00 2001 From: Noah Klayman Date: Fri, 29 Jan 2021 14:54:11 -0800 Subject: [PATCH 3/5] actually build the project --- dist/index.js | 16 ++++++++++------ dist/main.js | 16 ++++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/dist/index.js b/dist/index.js index 19b14fbb63..0d6d780c9c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -10664,11 +10664,12 @@ function getPackageJson(root) { } return null; } -function hasTauriDependency(root) { +function hasDependency(dependencyName, root) { const packageJson = getPackageJson(root); return (packageJson && - ((packageJson.dependencies && packageJson.dependencies.tauri) || - (packageJson.devDependencies && packageJson.devDependencies.tauri))); + ((packageJson.dependencies && packageJson.dependencies[dependencyName]) || + (packageJson.devDependencies && + packageJson.devDependencies[dependencyName]))); } function usesYarn(root) { return fs_1.existsSync(path_1.join(root, 'yarn.lock')); @@ -10687,10 +10688,10 @@ function execCommand(command, { cwd }) { function buildProject(root, debug, { configPath, distPath, iconPath, npmScript }) { return __awaiter(this, void 0, void 0, function* () { return new Promise(resolve => { - if (core.getInput('preferGlobal') === "true") { + if (core.getInput('preferGlobal') === 'true') { resolve('tauri'); } - else if (hasTauriDependency(root)) { + else if (hasDependency('tauri', root) || hasDependency('vue-cli-plugin-tauri', root)) { if (npmScript) { resolve(usesYarn(root) ? `yarn ${npmScript}` : `npm run ${npmScript}`); } @@ -10750,7 +10751,10 @@ function buildProject(root, debug, { configPath, distPath, iconPath, npmScript } fs_1.writeFileSync(tauriConfPath, JSON.stringify(tauriConf)); } const args = debug ? ['--debug'] : []; - return execCommand(`${app.runner} build` + (args.length ? ` ${args.join(' ')}` : ''), { cwd: root }) + const buildCommand = hasDependency('vue-cli-plugin-tauri', root) + ? (usesYarn(root) ? 'yarn' : 'npm run') + ' tauri:build' + : `${app.runner} build`; + return execCommand(buildCommand + (args.length ? ` ${args.join(' ')}` : ''), { cwd: root }) .then(() => { const appName = app.name; const artifactsPath = path_1.join(root, `src-tauri/target/${debug ? 'debug' : 'release'}`); diff --git a/dist/main.js b/dist/main.js index 85dc8eec8d..1a49563f9c 100644 --- a/dist/main.js +++ b/dist/main.js @@ -48,11 +48,12 @@ function getPackageJson(root) { } return null; } -function hasTauriDependency(root) { +function hasDependency(dependencyName, root) { const packageJson = getPackageJson(root); return (packageJson && - ((packageJson.dependencies && packageJson.dependencies.tauri) || - (packageJson.devDependencies && packageJson.devDependencies.tauri))); + ((packageJson.dependencies && packageJson.dependencies[dependencyName]) || + (packageJson.devDependencies && + packageJson.devDependencies[dependencyName]))); } function usesYarn(root) { return fs_1.existsSync(path_1.join(root, 'yarn.lock')); @@ -71,10 +72,10 @@ function execCommand(command, { cwd }) { function buildProject(root, debug, { configPath, distPath, iconPath, npmScript }) { return __awaiter(this, void 0, void 0, function* () { return new Promise(resolve => { - if (core.getInput('preferGlobal') === "true") { + if (core.getInput('preferGlobal') === 'true') { resolve('tauri'); } - else if (hasTauriDependency(root)) { + else if (hasDependency('tauri', root) || hasDependency('vue-cli-plugin-tauri', root)) { if (npmScript) { resolve(usesYarn(root) ? `yarn ${npmScript}` : `npm run ${npmScript}`); } @@ -134,7 +135,10 @@ function buildProject(root, debug, { configPath, distPath, iconPath, npmScript } fs_1.writeFileSync(tauriConfPath, JSON.stringify(tauriConf)); } const args = debug ? ['--debug'] : []; - return execCommand(`${app.runner} build` + (args.length ? ` ${args.join(' ')}` : ''), { cwd: root }) + const buildCommand = hasDependency('vue-cli-plugin-tauri', root) + ? (usesYarn(root) ? 'yarn' : 'npm run') + ' tauri:build' + : `${app.runner} build`; + return execCommand(buildCommand + (args.length ? ` ${args.join(' ')}` : ''), { cwd: root }) .then(() => { const appName = app.name; const artifactsPath = path_1.join(root, `src-tauri/target/${debug ? 'debug' : 'release'}`); From 1ce56aaef45d9619080438047a98de40c1b46308 Mon Sep 17 00:00:00 2001 From: Noah Klayman Date: Sat, 30 Jan 2021 10:35:19 -0800 Subject: [PATCH 4/5] chore(package): add changefile --- .changes/vue-cli-support.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/vue-cli-support.md diff --git a/.changes/vue-cli-support.md b/.changes/vue-cli-support.md new file mode 100644 index 0000000000..9b0ecc6811 --- /dev/null +++ b/.changes/vue-cli-support.md @@ -0,0 +1,5 @@ +--- +"tauri-action": minor +--- + +If vue-cli-plugin-tauri is detected, the tauri:build command will be used. \ No newline at end of file From 5142752eba5b050c3005dfffbc664a4d47d2e1a3 Mon Sep 17 00:00:00 2001 From: Noah Klayman Date: Sat, 30 Jan 2021 10:47:49 -0800 Subject: [PATCH 5/5] chore(package): fix .changes file --- .changes/vue-cli-support.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changes/vue-cli-support.md b/.changes/vue-cli-support.md index 9b0ecc6811..387984f070 100644 --- a/.changes/vue-cli-support.md +++ b/.changes/vue-cli-support.md @@ -1,5 +1,5 @@ --- -"tauri-action": minor +"action": minor --- If vue-cli-plugin-tauri is detected, the tauri:build command will be used. \ No newline at end of file