Steps to reproduce:
tns create TestApp && tns build android --path TestApp -> Everything is fine
rm -rf TestApp/platforms/android
tns build android --path TestApp --compileSdk 99 (some invalid sdk version in order to fail build command)
Result: tns-android is found in dependencies of package.json.
This later breaks tns platform add/remove android
The underlying problem is a lot different than we first anticipated, and thus the supposed "fix" cannot handle the inconsistent CLI behavior. I'll look into a more general solution.
The same happens with those steps:
tns create TestApp
tns run android --path TestApp
Ctrl+C
Project is broken and no chance to get in working until you manually delete tns-android from dependencies.
Workaround:
Manually delete tns-android from dependencies in package.json
One idea to handle this is to attach to process exit signals in the block where we install tns-android as dependency, for example here.
The code should be something like:
this.$processService.attachToProcessExitSignals(this, () => {
const packageJsonContent = this.$fs.readJson(pathToPackageJson);
if (packageJsonContent && packageJsonContent.dependencies && packageJsonContent.dependencies["tns-android"] ) {
delete packageJsonContent.dependencies["tns-android"];
this.$fs.writeJson(pathToPackageJson, packageJsonContent);
}
}
This way, in case Ctrl + C is used during installation of the runtime, before exiting the process, CLI will execute the logic in the lambda and will not leave the project in incorrect state.
With latest changes, this issue is no longer valid as runtimes are not added as dependencies of the project anymore (and removed after that). The new behavior will be available in CLI 4.2.0
Most helpful comment
With latest changes, this issue is no longer valid as runtimes are not added as dependencies of the project anymore (and removed after that). The new behavior will be available in CLI 4.2.0