From 4865d72f3528a8a5a2bd06f9954641340e3afe83 Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Thu, 16 May 2024 20:08:22 +0200 Subject: [PATCH 1/2] feat: improve the generated sample app --- assets/www-template/index.html | 4 +--- assets/www-template/js/example.js.mustache | 6 ++++-- src/index.ts | 8 +++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/assets/www-template/index.html b/assets/www-template/index.html index 8363012..db77f34 100644 --- a/assets/www-template/index.html +++ b/assets/www-template/index.html @@ -21,8 +21,6 @@

Capacitor Test Plugin Project

- - - + diff --git a/assets/www-template/js/example.js.mustache b/assets/www-template/js/example.js.mustache index f611264..3e47faf 100644 --- a/assets/www-template/js/example.js.mustache +++ b/assets/www-template/js/example.js.mustache @@ -1,4 +1,6 @@ -const testEcho = () => { +import { {{ CLASS }} } from '{{ PACKAGE_NAME }}'; + +window.testEcho = () => { const inputValue = document.getElementById("echoInput").value; - capacitor{{ CLASS }}.{{ CLASS }}.echo({ value: inputValue }) + {{ CLASS }}.echo({ value: inputValue }) } diff --git a/src/index.ts b/src/index.ts index 051fcb8..f8401d6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -95,9 +95,11 @@ export const run = async (): Promise => { // Use www template await extractTemplate(wwwDir, details, 'WWW_TEMPLATE'); - // Copy over built plugin and capacitor runtime - const builtPluginFile = resolve(details.dir, 'dist', 'plugin.js'); - copyFileSync(builtPluginFile, resolve(wwwDir, 'js', 'plugin.js')); + await runSubprocess('npm', ['run', 'build'], { + cwd: resolve(opts.cwd, 'example'), + stdio: opts.stdio, + }); + await runSubprocess('npx', ['cap', 'copy'], { cwd: resolve(opts.cwd, 'example'), stdio: opts.stdio, From 9e3ab6c7676fc51372a6ea8a469f666f5ee4f55a Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Thu, 16 May 2024 20:11:30 +0200 Subject: [PATCH 2/2] fmt --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index f8401d6..f418b3c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -99,7 +99,7 @@ export const run = async (): Promise => { cwd: resolve(opts.cwd, 'example'), stdio: opts.stdio, }); - + await runSubprocess('npx', ['cap', 'copy'], { cwd: resolve(opts.cwd, 'example'), stdio: opts.stdio,