Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve the generated sample app #101

Merged
merged 2 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions assets/www-template/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ <h1>Capacitor Test Plugin Project</h1>
<button onclick="testEcho()">Click Me!</button>
</main>

<script src="capacitor.js"></script>
<script src="js/plugin.js"></script>
<script src="js/example.js"></script>
<script src="./js/example.js" type="module"></script>
</body>
</html>
6 changes: 4 additions & 2 deletions assets/www-template/js/example.js.mustache
Original file line number Diff line number Diff line change
@@ -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 })
}
8 changes: 5 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Debug from 'debug';
import { readFileSync, copyFileSync, existsSync, rmSync, writeFileSync } from 'fs';

Check warning on line 2 in src/index.ts

View workflow job for this annotation

GitHub Actions / lint

'copyFileSync' is defined but never used

Check warning on line 2 in src/index.ts

View workflow job for this annotation

GitHub Actions / lint

'copyFileSync' is defined but never used
import kleur from 'kleur';
import { resolve } from 'path';

Expand Down Expand Up @@ -95,9 +95,11 @@
// 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,
Expand Down