@jcassidyav/nativescript-native-add
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -52,2 +52,11 @@ "use strict"; | ||
} | ||
getAndroidSourcePathBase(projectData) { | ||
if (this.isPlugin(projectData)) { | ||
return path.join("platforms", "android", "java"); | ||
} | ||
else { | ||
const resources = this.$projectData.getAppResourcesDirectoryPath(); | ||
return path.join(resources, 'Android', 'src', 'main', 'java'); | ||
} | ||
} | ||
} | ||
@@ -111,10 +120,6 @@ exports.NativeAddCommand = NativeAddCommand; | ||
doJavaKotlin(className, extension) { | ||
if (extension == 'kotlin' && !this.checkAndUpdateGradleProperties()) { | ||
return; | ||
} | ||
const resources = this.$projectData.getAppResourcesDirectoryPath(); | ||
const fileExt = extension == 'java' ? extension : 'kt'; | ||
const packageName = this.getPackageName(className); | ||
const classSimpleName = this.getClassSimpleName(className); | ||
const packagePath = path.join(resources, 'Android', 'src', 'main', 'java', ...packageName.split('.')); | ||
const packagePath = path.join(this.getAndroidSourcePathBase(this.$projectData), ...packageName.split('.')); | ||
const filePath = path.join(packagePath, `${classSimpleName}.${fileExt}`); | ||
@@ -125,2 +130,5 @@ if (fs.existsSync(filePath)) { | ||
} | ||
if (extension == 'kotlin' && !this.isPlugin(this.$projectData) && !this.checkAndUpdateGradleProperties()) { | ||
return; | ||
} | ||
const fileContent = extension == 'java' ? this.generateJavaClassContent(packageName, classSimpleName) : this.generateKotlinClassContent(packageName, classSimpleName); | ||
@@ -127,0 +135,0 @@ fs.mkdirSync(packagePath, { recursive: true }); |
{ | ||
"name": "@jcassidyav/nativescript-native-add", | ||
"preferGlobal": true, | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"author": "jcassidyav", | ||
@@ -25,3 +25,3 @@ "description": "Extension to allow adding of some native files in a Nativescript Project", | ||
"devDependencies": { | ||
"nativescript": "^8.5.3" | ||
"nativescript": "^8.6.5" | ||
}, | ||
@@ -28,0 +28,0 @@ "analyze": true, |
@@ -9,1 +9,9 @@ # nativescript-native-add | ||
Installs to `~/.local/share/.nativescript-cli/extensions` | ||
## Provided commands | ||
```shell | ||
ns native add swift SomeClass | ||
ns native add objective-c SomeOtherClass | ||
ns native add java some.thing.SomeClass | ||
ns native add kotlin some.thing.SomeOtherClass | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
21261
316
17
0