From 66ef0725aedfadacc8f82b8fb2ad0909e7f50ed2 Mon Sep 17 00:00:00 2001
From: wilsonatb <55840381+wilsonatb@users.noreply.github.com>
Date: Tue, 7 Apr 2026 12:07:00 -0400
Subject: [PATCH] fix: resolve plugin directory structure inconsistency
Updates PluginCreateCommand to generate nested directories (resources/android/src and resources/ios/Sources). Updates corresponding tests to reflect the new paths. This aligns the creation command with the expectations of PluginValidateCommand.
---
src/Commands/PluginCreateCommand.php | 20 ++++++++++----------
tests/Feature/Plugins/PluginCommandsTest.php | 2 +-
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/Commands/PluginCreateCommand.php b/src/Commands/PluginCreateCommand.php
index d07d220..9b084e8 100644
--- a/src/Commands/PluginCreateCommand.php
+++ b/src/Commands/PluginCreateCommand.php
@@ -162,8 +162,8 @@ protected function createPluginStructure(): void
'/src/Facades',
'/src/Events',
'/src/Commands',
- '/resources/android',
- '/resources/ios',
+ '/resources/android/src',
+ '/resources/ios/Sources',
'/resources/js',
'/tests',
];
@@ -536,7 +536,7 @@ class GetStatus(private val context: Context) : BridgeFunction {
}
KOTLIN;
- $this->files->put($path."/resources/android/{$namespace}Functions.kt", $content);
+ $this->files->put($path."/resources/android/src/{$namespace}Functions.kt", $content);
}
protected function createSwiftFunctions(string $path): void
@@ -573,7 +573,7 @@ class GetStatus: BridgeFunction {
}
SWIFT;
- $this->files->put($path."/resources/ios/{$namespace}Functions.swift", $content);
+ $this->files->put($path."/resources/ios/Sources/{$namespace}Functions.swift", $content);
}
protected function createJavaScript(string $path): void
@@ -986,7 +986,7 @@ protected function createTests(string $path): void
describe('Native Code', function () {
it('has Android Kotlin file', function () {
- \$kotlinFile = \$this->pluginPath . '/resources/android/{$namespace}Functions.kt';
+ \$kotlinFile = \$this->pluginPath . '/resources/android/src/{$namespace}Functions.kt';
expect(file_exists(\$kotlinFile))->toBeTrue();
@@ -997,7 +997,7 @@ protected function createTests(string $path): void
});
it('has iOS Swift file', function () {
- \$swiftFile = \$this->pluginPath . '/resources/ios/{$namespace}Functions.swift';
+ \$swiftFile = \$this->pluginPath . '/resources/ios/Sources/{$namespace}Functions.swift';
expect(file_exists(\$swiftFile))->toBeTrue();
@@ -1009,8 +1009,8 @@ protected function createTests(string $path): void
it('has matching bridge function classes in native code', function () {
\$manifest = json_decode(file_get_contents(\$this->manifestPath), true);
- \$kotlinFile = \$this->pluginPath . '/resources/android/{$namespace}Functions.kt';
- \$swiftFile = \$this->pluginPath . '/resources/ios/{$namespace}Functions.swift';
+ \$kotlinFile = \$this->pluginPath . '/resources/android/src/{$namespace}Functions.kt';
+ \$swiftFile = \$this->pluginPath . '/resources/ios/Sources/{$namespace}Functions.swift';
\$kotlinContent = file_get_contents(\$kotlinFile);
\$swiftContent = file_get_contents(\$swiftFile);
@@ -1171,8 +1171,8 @@ protected function displayNextSteps(): void
$this->components->twoColumnDetail('Next steps', '');
$this->components->bulletList([
'Implement native functions in:',
- " resources/android/{$this->pluginData['namespace']}Functions.kt",
- " resources/ios/{$this->pluginData['namespace']}Functions.swift",
+ " resources/android/src/{$this->pluginData['namespace']}Functions.kt",
+ " resources/ios/Sources/{$this->pluginData['namespace']}Functions.swift",
'Edit nativephp.json to add permissions and dependencies',
'Customize the copy_assets hook in:',
' src/Commands/CopyAssetsCommand.php',
diff --git a/tests/Feature/Plugins/PluginCommandsTest.php b/tests/Feature/Plugins/PluginCommandsTest.php
index af6405a..875ae51 100644
--- a/tests/Feature/Plugins/PluginCommandsTest.php
+++ b/tests/Feature/Plugins/PluginCommandsTest.php
@@ -211,7 +211,7 @@ public function plugin_create_generates_swift_example(): void
->assertSuccessful();
// Find Swift files
- $swiftFiles = glob($this->testPluginPath.'/resources/ios/*.swift');
+ $swiftFiles = glob($this->testPluginPath.'/resources/ios/Sources/*.swift');
$this->assertNotEmpty($swiftFiles, 'Should have generated at least one Swift file');