Skip to content

Fix appid inconsistent #450

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

Merged
merged 1 commit into from
May 4, 2015
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
2 changes: 1 addition & 1 deletion lib/common
6 changes: 3 additions & 3 deletions lib/project-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ export class ProjectData implements IProjectData {
// If no project found, projectDir should be null
if(projectDir) {
this.projectDir = projectDir;
this.projectName = path.basename(projectDir);
this.projectName = this.$projectHelper.sanitizeName(path.basename(projectDir));
this.platformsDir = path.join(projectDir, "platforms");
this.projectFilePath = path.join(projectDir, this.$staticConfig.PROJECT_FILE_NAME);

if (this.$fs.exists(this.projectFilePath).wait()) {
try {
var fileContent = this.$fs.readJson(this.projectFilePath).wait();
this.projectId = fileContent.id;
var fileContent = this.$fs.readJson(this.projectFilePath).wait();
this.projectId = fileContent.id;
} catch (err) {
this.$errors.fail({formatStr: "The project file %s is corrupted." + os.EOL +
"Consider restoring an earlier version from your source control or backup." + os.EOL +
Expand Down
9 changes: 2 additions & 7 deletions lib/services/android-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,6 @@ class AndroidProjectService implements IPlatformProjectService {
return this.$fs.exists(path.join(projectRoot, "assets", constants.APP_FOLDER_NAME));
}

private generateBuildFile(projDir: string, targetSdk: string): void {
this.$logger.info("Generate build.xml for %s", projDir);
var cmd = util.format("android update project -p %s --target %s --subprojects", projDir, targetSdk);
this.$childProcess.exec(cmd).wait();
}

private parseProjectProperties(projDir: string, destDir: string): void {
var projProp = path.join(projDir, "project.properties");

Expand All @@ -188,7 +182,8 @@ class AndroidProjectService implements IPlatformProjectService {
var targetDir = path.join(destDir, path.basename(projDir));
// TODO: parametrize targetSdk
var targetSdk = "android-17";
this.generateBuildFile(targetDir, targetSdk);
this.$logger.info("Generate build.xml for %s", targetDir);
this.runAndroidUpdate(targetDir, targetSdk).wait();
}

private getProjectReferences(projDir: string): ILibRef[]{
Expand Down
4 changes: 3 additions & 1 deletion lib/services/project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import shell = require("shelljs");
import util = require("util");

export class ProjectService implements IProjectService {
private static DEFAULT_APP_IDENTIFIER_PREFIX = "org.nativescript";

constructor(private $errors: IErrors,
private $fs: IFileSystem,
private $logger: ILogger,
Expand All @@ -25,7 +27,7 @@ export class ProjectService implements IProjectService {
}
this.$projectNameValidator.validate(projectName);

var projectId = options.appid || this.$projectHelper.generateDefaultAppId(projectName, "org.nativescript");
var projectId = options.appid || this.$projectHelper.generateDefaultAppId(projectName, ProjectService.DEFAULT_APP_IDENTIFIER_PREFIX);

var projectDir = path.join(path.resolve(options.path || "."), projectName);
this.$fs.createDirectory(projectDir).wait();
Expand Down
4 changes: 4 additions & 0 deletions test/stubs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,10 @@ export class ProjectHelperStub implements IProjectHelper {
generateDefaultAppId(appName: string, baseAppId: string): string {
return "org.nativescript";
}

sanitizeName(appName: string): string {
return "";
}
}

export class ProjectTemplatesService implements IProjectTemplatesService {
Expand Down