Skip to content

Commit

Permalink
feat: no need for copy cli script, use web app build dir
Browse files Browse the repository at this point in the history
  • Loading branch information
IT-MikeS committed Aug 19, 2021
1 parent 1e61b7a commit 891f9ec
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"publish:next-prerelease": "env-cmd lerna publish prerelease --preid alpha --dist-tag alpha --pre-dist-tag alpha --conventional-commits --create-release github --force-publish",
"publish:next": "env-cmd lerna publish --preid next --dist-tag next --pre-dist-tag next --conventional-commits --create-release github --force-publish",
"build-all": "lerna run build --stream",
"fmt": "lerna run fmt --stream",
"postinstall": "lerna bootstrap",
"env-cmd": "env-cmd",
"shx": "shx"
Expand Down
17 changes: 15 additions & 2 deletions platform/src/cli-scripts/add.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chalk from 'chalk';
import { existsSync, mkdirSync } from 'fs';
import { copySync } from 'fs-extra';
import { join } from 'path';
import path from 'path';
import { extract } from 'tar';

import {
Expand All @@ -12,10 +12,16 @@ import {
formatHrTime,
} from './common';

const relative = path.relative;
const join = path.join;
const sep = path.sep;
const posixSep = path.posix.sep;

export async function doAdd(): Promise<void> {
const start = process.hrtime();
log(`\n${chalk.bold('Tauri Platform:')} Starting add task 🚀`);
const usersProjectDir = process.env.CAPACITOR_ROOT_DIR;
const builtWebAppDir = process.env.CAPACITOR_WEB_DIR;
const platformNodeModuleTemplateTar = join(
usersProjectDir,
'node_modules',
Expand Down Expand Up @@ -62,11 +68,18 @@ export async function doAdd(): Promise<void> {
log(`\n${chalk.bold('Tauri Platform:')} Setting up Tauri project files 📋`);
writePrettyJSON(join(destDir, 'package.json'), platformPackageJson);

const srcTauriPath = join(destDir, 'src-tauri');
const platformTauriConfigJson = readJSON(
join(destDir, 'src-tauri', 'tauri.conf.json'),
join(srcTauriPath, 'tauri.conf.json'),
);
platformTauriConfigJson.package.productName = appName;
platformTauriConfigJson.tauri.windows[0].title = appName;
platformTauriConfigJson.build.distDir = relative(
srcTauriPath,
builtWebAppDir,
)
.split(sep)
.join(posixSep);
writePrettyJSON(
join(destDir, 'src-tauri', 'tauri.conf.json'),
platformTauriConfigJson,
Expand Down
18 changes: 14 additions & 4 deletions platform/src/cli-scripts/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import chalk from 'chalk';

import { doAdd } from './add';
import { doCopy } from './copy';
import { log } from './common';
import { doOpen } from './open';
// import { doCopy } from './copy';
// import { doUpdate } from './update';

/*
Expand All @@ -13,9 +16,11 @@ async function doAddTask() {
return await doAdd();
}

/*
async function doCopyTask() {
return await doCopy();
}
*/

async function doOpenTask() {
return await doOpen();
Expand All @@ -27,11 +32,16 @@ async function doOpenTask() {
switch (scriptToRun) {
case 'add':
await doAddTask();
await doCopyTask();
// await doCopyTask();
// await doUpdateTask();
break;
case 'copy':
await doCopyTask();
log(
`\n${chalk.bold(
'Tauri Platform:',
)} Copy isn't necessary on the Tauri platform, as it uses your build folder from the web app directly 👍\n`,
);
// await doCopyTask();
break;
case 'run':
case 'open':
Expand All @@ -43,7 +53,7 @@ async function doOpenTask() {
// break;
case 'sync':
throw new Error(`Invalid script chosen: ${scriptToRun}`);
// await doCopyTask();
// await doSyncTask();
// await doUpdateTask();
// break;
default:
Expand Down

0 comments on commit 891f9ec

Please sign in to comment.