Skip to content

Commit 2fec565

Browse files
authored
Merge pull request #2364 from NativeScript/plamen5kov/respect_shelljserrors
Plamen5kov/respect shelljserrors
2 parents 07f204a + ae2ea99 commit 2fec565

8 files changed

+12
-24
lines changed

lib/nativescript-cli.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as fiber from "fibers";
33
import Future = require("fibers/future");
44
import * as shelljs from "shelljs";
55
shelljs.config.silent = true;
6+
shelljs.config.fatal = true;
67
import {installUncaughtExceptionListener} from "./common/errors";
78
installUncaughtExceptionListener(process.exit);
89

lib/services/android-project-service.ts

+5-13
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
1212
private static VALUES_DIRNAME = "values";
1313
private static VALUES_VERSION_DIRNAME_PREFIX = AndroidProjectService.VALUES_DIRNAME + "-v";
1414
private static ANDROID_PLATFORM_NAME = "android";
15-
private static MIN_RUNTIME_VERSION_WITH_GRADLE = "1.3.0";
15+
private static MIN_RUNTIME_VERSION_WITH_GRADLE = "1.5.0";
1616
private static REQUIRED_DEV_DEPENDENCIES = [
1717
{ name: "babel-traverse", version: "^6.4.5" },
1818
{ name: "babel-types", version: "^6.4.5" },
@@ -118,10 +118,8 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
118118
}
119119
this.copy(this.platformData.projectRoot, frameworkDir, "build.gradle settings.gradle gradle.properties build-tools", "-Rf");
120120

121-
if (this.useGradleWrapper(frameworkDir)) {
122-
this.copy(this.platformData.projectRoot, frameworkDir, "gradle", "-R");
123-
this.copy(this.platformData.projectRoot, frameworkDir, "gradlew gradlew.bat", "-f");
124-
}
121+
this.copy(this.platformData.projectRoot, frameworkDir, "gradle", "-R");
122+
this.copy(this.platformData.projectRoot, frameworkDir, "gradlew gradlew.bat", "-f");
125123

126124
this.cleanResValues(targetSdkVersion, frameworkVersion);
127125

@@ -158,11 +156,6 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
158156
}).future<any>()();
159157
}
160158

161-
private useGradleWrapper(frameworkDir: string): boolean {
162-
let gradlew = path.join(frameworkDir, "gradlew");
163-
return this.$fs.exists(gradlew);
164-
}
165-
166159
private cleanResValues(targetSdkVersion: number, frameworkVersion: string): void {
167160
let resDestinationDir = this.getAppResourcesDestinationDirectoryPath(frameworkVersion);
168161
let directoriesInResFolder = this.$fs.readDirectory(resDestinationDir);
@@ -228,7 +221,6 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
228221

229222
public updatePlatform(currentVersion: string, newVersion: string, canUpdate: boolean, addPlatform?: Function, removePlatforms?: (platforms: string[]) => IFuture<void>): IFuture<boolean> {
230223
return (() => {
231-
// TODO: plamen5kov: drop support for project older than 1.3.0(MIN_RUNTIME_VERSION_WITH_GRADLE)
232224
if (semver.eq(newVersion, AndroidProjectService.MIN_RUNTIME_VERSION_WITH_GRADLE)) {
233225
let platformLowercase = this.platformData.normalizedPlatformName.toLowerCase();
234226
removePlatforms([platformLowercase.split("@")[0]]).wait();
@@ -249,7 +241,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
249241
buildOptions.unshift("--debug");
250242
}
251243
buildOptions.unshift("buildapk");
252-
let gradleBin = this.useGradleWrapper(projectRoot) ? path.join(projectRoot, "gradlew") : "gradle";
244+
let gradleBin = path.join(projectRoot, "gradlew");
253245
if (this.$hostInfo.isWindows) {
254246
gradleBin += ".bat"; // cmd command line parsing rules are weird. Avoid issues with quotes. See https://github.com/apache/cordova-android/blob/master/bin/templates/cordova/lib/builders/GradleBuilder.js for another approach
255247
}
@@ -399,7 +391,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
399391
buildOptions.unshift("clean");
400392

401393
let projectRoot = this.platformData.projectRoot;
402-
let gradleBin = this.useGradleWrapper(projectRoot) ? path.join(projectRoot, "gradlew") : "gradle";
394+
let gradleBin = path.join(projectRoot, "gradlew");
403395
if (this.$hostInfo.isWindows) {
404396
gradleBin += ".bat";
405397
}

lib/services/ios-project-service.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,9 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
119119
}
120120
}).future<void>()();
121121
}
122-
122+
//TODO: plamen5kov: revisit this method, might have unnecessary/obsolete logic
123123
public interpolateData(): IFuture<void> {
124124
return (() => {
125-
let infoPlistFilePath = path.join(this.platformData.projectRoot, IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER, `${IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER}-Info.plist`);
126-
this.interpolateConfigurationFile(infoPlistFilePath).wait();
127-
128125
let projectRootFilePath = path.join(this.platformData.projectRoot, IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER);
129126
// Starting with NativeScript for iOS 1.6.0, the project Info.plist file resides not in the platform project,
130127
// but in the hello-world app template as a platform specific resource.
@@ -156,9 +153,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
156153
}
157154

158155
public interpolateConfigurationFile(configurationFilePath?: string): IFuture<void> {
159-
return (() => {
160-
shell.sed('-i', "__CFBUNDLEIDENTIFIER__", this.$projectData.projectId, configurationFilePath || this.platformData.configurationFilePath);
161-
}).future<void>()();
156+
return Future.fromResult();
162157
}
163158

164159
public afterCreateProject(projectRoot: string): void {

lib/services/project-service.ts

-2
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ export class ProjectService implements IProjectService {
158158
this.$fs.createDirectory(appDestinationPath);
159159

160160
shelljs.cp('-R', path.join(appSourcePath, "*"), appDestinationPath);
161-
// Copy hidden files.
162-
shelljs.cp('-R', path.join(appSourcePath, ".*"), appDestinationPath);
163161

164162
this.$fs.createDirectory(path.join(projectDir, "platforms"));
165163

test/debug.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe("Debugger tests", () => {
8686
let androidProjectService: IPlatformProjectService = testInjector.resolve("androidProjectService");
8787
let spawnFromEventCount = childProcess.spawnFromEventCount;
8888
androidProjectService.beforePrepareAllPlugins().wait();
89-
assert.isTrue(childProcess.lastCommand === "gradle");
89+
assert.isTrue(childProcess.lastCommand.indexOf("gradle") !== -1);
9090
assert.isTrue(childProcess.lastCommandArgs[0] === "clean");
9191
assert.isTrue(spawnFromEventCount === 0);
9292
assert.isTrue(spawnFromEventCount + 1 === childProcess.spawnFromEventCount);

test/npm-support.ts

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ function setupProject(dependencies?: any): IFuture<any> {
124124
let appResourcesFolderPath = path.join(appFolderPath, "App_Resources");
125125
fs.createDirectory(appResourcesFolderPath);
126126
fs.createDirectory(path.join(appResourcesFolderPath, "Android"));
127+
fs.createDirectory(path.join(appResourcesFolderPath, "Android", "mockdir"));
127128
fs.createDirectory(path.join(appFolderPath, "tns_modules"));
128129

129130
// Creates platforms/android folder

test/test-bootstrap.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as shelljs from "shelljs";
22
shelljs.config.silent = true;
3+
shelljs.config.fatal = true;
34
global._ = require("lodash");
45
global.$injector = require("../lib/common/yok").injector;
56

0 commit comments

Comments
 (0)