Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b5d9e1e
Merge remote-tracking branch 'origin/release' into HEAD
Feb 10, 2016
45e950d
Merge remote-tracking branch 'origin/release' into HEAD
Feb 11, 2016
e2a4388
Merge remote-tracking branch 'origin/release' into HEAD
Feb 12, 2016
ff18217
Remove rimraf as dependency
teobugslayer Feb 15, 2016
3e3706a
Merge pull request #1479 from NativeScript/remove-rimraf
teobugslayer Feb 15, 2016
0c2d486
Change docs to recommend production branch
teobugslayer Feb 15, 2016
34efe39
Do not install the CLI
teobugslayer Feb 15, 2016
b83c44c
Merge pull request #1487 from NativeScript/dont-install-tns
teobugslayer Feb 15, 2016
e677c2c
Update node-winreg dependency
teobugslayer Feb 16, 2016
4532593
Merge branch 'release' into vladimirov/merge-rel-master
rosen-vladimirov Feb 16, 2016
1f37944
Update to latest common lib
rosen-vladimirov Feb 16, 2016
80f400d
Merge pull request #1489 from NativeScript/update-winreg
teobugslayer Feb 16, 2016
8a1820a
Merge pull request #1491 from NativeScript/vladimirov/merge-rel-master
rosen-vladimirov Feb 16, 2016
467f4e7
Set version to 1.7.0
rosen-vladimirov Feb 16, 2016
75fcdc4
Merge pull request #1492 from NativeScript/vladimirov/update-version
rosen-vladimirov Feb 16, 2016
e840f7a
Merge remote-tracking branch 'origin/release' into HEAD
Feb 17, 2016
1af4441
Merge branch 'release' into vladimirov/merge-rel-master
rosen-vladimirov Feb 18, 2016
e9da5ab
Update to latest common lib
rosen-vladimirov Feb 18, 2016
27f38b2
Merge pull request #1509 from NativeScript/vladimirov/merge-rel-master
rosen-vladimirov Feb 19, 2016
3ae1b30
Merge remote-tracking branch 'origin/release' into HEAD
Feb 19, 2016
de3b2e0
Introduce `grunt rebuild`
Mitko-Kerezov Feb 22, 2016
a08d207
Merge pull request #1527 from NativeScript/kerezov/grunt-rebuild
Mitko-Kerezov Feb 22, 2016
f220d3b
Allow build.xcconfig in app/App_Resources/iOS/build.xcconfig
PanayotCankov Feb 26, 2016
3e3aa3d
Merge pull request #1547 from NativeScript/cankov/app-resources-xcconfig
PanayotCankov Feb 26, 2016
da63313
Merge branch 'release' into vladimirov/merge-rel-master
rosen-vladimirov Feb 29, 2016
9481127
Update to latest common lib
rosen-vladimirov Feb 29, 2016
ea53638
Merge pull request #1553 from NativeScript/vladimirov/merge-rel-master
rosen-vladimirov Feb 29, 2016
ec05674
Delete /data/local/tmp/<app-identifier> file if exists on Android device
nadyaA Mar 2, 2016
59a2a42
Merge pull request #1560 from NativeScript/natanasova/android-livesyn…
nadyaA Mar 2, 2016
d5bd3ad
Add support for custom platform templates
rosen-vladimirov Feb 20, 2016
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
1 change: 1 addition & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,6 @@ module.exports = function(grunt) {
]);
grunt.registerTask("lint", ["tslint:build"]);
grunt.registerTask("all", ["clean", "test", "lint"]);
grunt.registerTask("rebuild", ["clean", "ts:devlib"]);
grunt.registerTask("default", "ts:devlib");
};
2 changes: 1 addition & 1 deletion lib/common
1 change: 1 addition & 0 deletions lib/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ interface IOptions extends ICommonOptions {
port: Number;
copyTo: string;
baseConfig: string;
platformTemplate: string;
}

interface IInitService {
Expand Down
2 changes: 1 addition & 1 deletion lib/definitions/project.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ interface IBuildConfig {
interface IPlatformProjectService {
platformData: IPlatformData;
validate(): IFuture<void>;
createProject(frameworkDir: string, frameworkVersion: string): IFuture<void>;
createProject(frameworkDir: string, frameworkVersion: string, pathToTemplate?: string): IFuture<void>;
interpolateData(): IFuture<void>;
interpolateConfigurationFile(configurationFilePath?: string): IFuture<void>;
afterCreateProject(projectRoot: string): IFuture<void>;
Expand Down
1 change: 1 addition & 0 deletions lib/nativescript-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as fiber from "fibers";
import Future = require("fibers/future");
import * as shelljs from "shelljs";
shelljs.config.silent = true;
shelljs.config.fatal = true;
import {installUncaughtExceptionListener} from "./common/errors";
installUncaughtExceptionListener(process.exit);

Expand Down
3 changes: 2 additions & 1 deletion lib/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export class Options extends commonOptionsLibPath.OptionsBase {
compileSdk: {type: OptionType.Number },
port: { type: OptionType.Number },
copyTo: { type: OptionType.String },
baseConfig: { type: OptionType.String }
baseConfig: { type: OptionType.String },
platformTemplate: { type: OptionType.String }
},
path.join($hostInfo.isWindows ? process.env.AppData : path.join(osenv.home(), ".local/share"), ".nativescript-cli"),
$errors, $staticConfig);
Expand Down
10 changes: 8 additions & 2 deletions lib/services/android-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
}).future<void>()();
}

public createProject(frameworkDir: string, frameworkVersion: string): IFuture<void> {
public createProject(frameworkDir: string, frameworkVersion: string, pathToTemplate?: string): IFuture<void> {
return (() => {
if(semver.lt(frameworkVersion, AndroidProjectService.MIN_RUNTIME_VERSION_WITH_GRADLE)) {
this.$errors.failWithoutHelp(`The NativeScript CLI requires Android runtime ${AndroidProjectService.MIN_RUNTIME_VERSION_WITH_GRADLE} or later to work properly.`);
Expand All @@ -111,7 +111,13 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
}

// These files and directories should not be symlinked as CLI is modifying them and we'll change the original values as well.
this.copy(this.platformData.projectRoot, frameworkDir, "src", "-R");
if(pathToTemplate) {
let mainPath = path.join(this.platformData.projectRoot, "src", "main");
this.$fs.createDirectory(mainPath).wait();
shell.cp("-R", path.join(path.resolve(pathToTemplate), "*"), mainPath);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we care that shell.cp can fail? We need to call shell.error to check for failures.

} else {
this.copy(this.platformData.projectRoot, frameworkDir, "src", "-R");
}
this.copy(this.platformData.projectRoot, frameworkDir, "build.gradle settings.gradle gradle.properties", "-f");

if (this.useGradleWrapper(frameworkDir)) {
Expand Down
22 changes: 16 additions & 6 deletions lib/services/ios-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,16 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
}).future<void>()();
}

public createProject(frameworkDir: string, frameworkVersion: string): IFuture<void> {
public createProject(frameworkDir: string, frameworkVersion: string, pathToTemplate?: string): IFuture<void> {
return (() => {
this.$fs.ensureDirectoryExists(path.join(this.platformData.projectRoot, IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER)).wait();
if(this.$options.symlink) {
if(pathToTemplate) {
// Copy everything except the template from the runtime
this.$fs.readDirectory(frameworkDir).wait()
.filter(dirName => dirName.indexOf(IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER) === -1)
.forEach(dirName => shell.cp("-R", path.join(frameworkDir, dirName), this.platformData.projectRoot));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we care that shell.cp can fail? We need to call shell.error to check for failures.

shell.cp("-rf", path.join(pathToTemplate, "*"), this.platformData.projectRoot);
} else if(this.$options.symlink) {
let xcodeProjectName = util.format("%s.xcodeproj", IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER);

shell.cp("-R", path.join(frameworkDir, IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER, "*"), path.join(this.platformData.projectRoot, IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER));
Expand All @@ -118,7 +124,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
_.each(frameworkFiles, (file: string) => {
this.$fs.symlink(path.join(frameworkDir, file), path.join(this.platformData.projectRoot, file)).wait();
});

} else {
shell.cp("-R", path.join(frameworkDir, "*"), this.platformData.projectRoot);
}
Expand Down Expand Up @@ -393,6 +398,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
public processConfigurationFilesFromAppResources(): IFuture<void> {
return (() => {
this.mergeInfoPlists().wait();
this.mergeProjectXcconfigFiles().wait();
_(this.getAllInstalledPlugins().wait())
.map(pluginData => this.$pluginVariablesService.interpolatePluginVariables(pluginData, this.platformData.configurationFilePath).wait())
.value();
Expand Down Expand Up @@ -565,8 +571,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ

this.executePodInstall().wait();
}

this.regeneratePluginsXcconfigFile().wait();
}).future<void>()();
}

Expand Down Expand Up @@ -778,7 +782,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
}).future<void>()();
}

private regeneratePluginsXcconfigFile(): IFuture<void> {
private mergeProjectXcconfigFiles(): IFuture<void> {
return (() => {
this.$fs.deleteFile(this.pluginsDebugXcconfigFilePath).wait();
this.$fs.deleteFile(this.pluginsReleaseXcconfigFilePath).wait();
Expand All @@ -793,6 +797,12 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
}
}

let appResourcesXcconfigPath = path.join(this.$projectData.projectDir, constants.APP_FOLDER_NAME, constants.APP_RESOURCES_FOLDER_NAME, this.platformData.normalizedPlatformName, "build.xcconfig");
if (this.$fs.exists(appResourcesXcconfigPath).wait()) {
this.mergeXcconfigFiles(appResourcesXcconfigPath, this.pluginsDebugXcconfigFilePath).wait();
this.mergeXcconfigFiles(appResourcesXcconfigPath, this.pluginsReleaseXcconfigFilePath).wait();
}

let podFolder = path.join(this.platformData.projectRoot, "Pods/Target Support Files/Pods/");
if (this.$fs.exists(podFolder).wait()) {
this.mergeXcconfigFiles(path.join(this.platformData.projectRoot, "Pods/Target Support Files/Pods/Pods.debug.xcconfig"), this.pluginsDebugXcconfigFilePath).wait();
Expand Down
13 changes: 12 additions & 1 deletion lib/services/livesync/android-livesync-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,18 @@ class AndroidLiveSyncService extends liveSyncServiceBaseLib.LiveSyncServiceBase<

public beforeLiveSyncAction(deviceAppData: Mobile.IDeviceAppData): IFuture<void> {
return (() => {
let deviceRootPath = this.getDeviceRootPath(deviceAppData.appIdentifier);
let deviceRootPath = this.getDeviceRootPath(deviceAppData.appIdentifier),
deviceRootDir = path.dirname(deviceRootPath),
deviceRootBasename = path.basename(deviceRootPath),
listResult = this.device.adb.executeShellCommand(["ls", "-l", deviceRootDir]).wait(),
regex = new RegExp(`^-.*${deviceRootBasename}$`, "m"),
matchingFile = (listResult || "").match(regex);

// Check if there is already a file with deviceRootBasename. If so, delete it as it breaks LiveSyncing.
if(matchingFile && matchingFile[0] && _.startsWith(matchingFile[0], '-')){
this.device.adb.executeShellCommand(["rm", "-f", deviceRootPath]).wait();
}

this.device.adb.executeShellCommand(["rm", "-rf", this.$mobileHelper.buildDevicePath(deviceRootPath, "fullsync"),
this.$mobileHelper.buildDevicePath(deviceRootPath, "sync"),
this.$mobileHelper.buildDevicePath(deviceRootPath, "removedsync")]).wait();
Expand Down
44 changes: 40 additions & 4 deletions lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import * as helpers from "../common/helpers";
import * as semver from "semver";
import * as minimatch from "minimatch";
import Future = require("fibers/future");
import * as temp from "temp";
temp.track();
let clui = require("clui");

export class PlatformService implements IPlatformService {
Expand All @@ -29,7 +31,8 @@ export class PlatformService implements IPlatformService {
private $projectFilesManager: IProjectFilesManager,
private $mobileHelper: Mobile.IMobileHelper,
private $hostInfo: IHostInfo,
private $xmlValidator: IXmlValidator) { }
private $xmlValidator: IXmlValidator,
private $npm: INodePackageManager) { }

public addPlatforms(platforms: string[]): IFuture<void> {
return (() => {
Expand Down Expand Up @@ -114,7 +117,13 @@ export class PlatformService implements IPlatformService {
}

let sourceFrameworkDir = isFrameworkPathDirectory && this.$options.symlink ? path.join(this.$options.frameworkPath, "framework") : frameworkDir;
platformData.platformProjectService.createProject(path.resolve(sourceFrameworkDir), installedVersion).wait();
this.$projectDataService.initialize(this.$projectData.projectDir);
let customTemplateOptions = this.getPathToPlatformTemplate(this.$options.platformTemplate, platformData.frameworkPackageName).wait();
let pathToTemplate: string;
if(customTemplateOptions) {
pathToTemplate = customTemplateOptions.pathToTemplate;
}
platformData.platformProjectService.createProject(path.resolve(sourceFrameworkDir), installedVersion, pathToTemplate).wait();

if(isFrameworkPathDirectory || isFrameworkPathNotSymlinkedFile) {
// Need to remove unneeded node_modules folder
Expand All @@ -132,12 +141,39 @@ export class PlatformService implements IPlatformService {
this.$fs.copyFile(newConfigFile, platformData.configurationFilePath).wait();
}

this.$projectDataService.initialize(this.$projectData.projectDir);
this.$projectDataService.setValue(platformData.frameworkPackageName, {version: installedVersion}).wait();
let frameworkPackageNameData: any = {version: installedVersion};
if(customTemplateOptions) {
frameworkPackageNameData.template = customTemplateOptions.selectedTemplate;
}
this.$projectDataService.setValue(platformData.frameworkPackageName, frameworkPackageNameData).wait();

}).future<void>()();
}

private getPathToPlatformTemplate(selectedTemplate: string, frameworkPackageName: string): IFuture<any> {
return (() => {
if(!selectedTemplate) {
// read data from package.json's nativescript key
// check the nativescript.tns-<platform>.template value
let nativescriptPlatformData = this.$projectDataService.getValue(frameworkPackageName).wait();
selectedTemplate = nativescriptPlatformData && nativescriptPlatformData.template;
}

if(selectedTemplate) {
let tempDir = temp.mkdirSync("platform-template");
try {
let pathToTemplate = this.$npm.install(selectedTemplate, tempDir, {"ignore-scripts": true, "production": true}).wait()[0][1];
return { selectedTemplate, pathToTemplate };
} catch(err) {
this.$logger.trace("Error while trying to install specified template: ", err);
this.$errors.failWithoutHelp(`Unable to install platform template ${selectedTemplate}. Make sure the specified value is valid.`);
}
}

return null;
}).future<any>()();
}

public getInstalledPlatforms(): IFuture<string[]> {
return(() => {
if(!this.$fs.exists(this.$projectData.platformsDir).wait()) {
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nativescript",
"preferGlobal": true,
"version": "1.6.1",
"version": "1.7.0",
"author": "Telerik <support@telerik.com>",
"description": "Command-line interface for building NativeScript projects",
"bin": {
Expand Down Expand Up @@ -65,15 +65,14 @@
"properties-parser": "0.2.3",
"ref": "https://github.com/icenium/ref/tarball/v1.1.3.1",
"ref-struct": "https://github.com/telerik/ref-struct/tarball/v1.0.2.1",
"rimraf": "2.4.2",
"semver": "5.0.1",
"shelljs": "0.5.3",
"tabtab": "https://github.com/Icenium/node-tabtab/tarball/master",
"temp": "0.8.3",
"through2": "2.0.0",
"utf-8-validate": "https://github.com/telerik/utf-8-validate/tarball/v1.0.1.1",
"vinyl-filter-since": "2.0.2",
"winreg": "0.0.12",
"winreg": "0.0.17",
"ws": "0.7.1",
"xcode": "https://github.com/NativeScript/node-xcode/archive/1.4.0.tar.gz",
"xmldom": "0.1.21",
Expand Down
13 changes: 0 additions & 13 deletions setup/native-script.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ write-host "To ensure consistent environment, this script will re-install all Na
write-host -BackgroundColor Black -ForegroundColor Yellow "Installing Google Chrome (required to debug NativeScript apps)"
cinst googlechrome --force --yes

write-host -BackgroundColor Black -ForegroundColor Yellow "Installing node.js"
cinst nodejs.install -version 4.3.0 --force --yes

write-host -BackgroundColor Black -ForegroundColor Yellow "Installing Java Development Kit"
cinst jdk8 --force --yes

Expand All @@ -47,16 +44,6 @@ if (!$env:JAVA_HOME) {
$env:JAVA_HOME = $javaHome;
}

# install NativeScript CLI
write-host -BackgroundColor Black -ForegroundColor Yellow "Installing NativeScript CLI"

$oldPathUser = [Environment]::GetEnvironmentVariable("PATH", "User")
$pathMachine = [Environment]::GetEnvironmentVariable("PATH", "Machine")
$myPath = [Environment]::GetEnvironmentVariable("PATH")
[Environment]::SetEnvironmentVariable("PATH", "$myPath;$oldPathUser;$pathMachine;$env:ProgramFiles\nodejs")

npm install -g nativescript

write-host -BackgroundColor Black -ForegroundColor Yellow "This script has modified your environment. You need to log off and log back on for the changes to take effect."
Write-Host "Press any key to continue..."
[void][System.Console]::ReadKey($true)
6 changes: 0 additions & 6 deletions setup/native-script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,4 @@
puts "Configuring your system for Android development... This might take some time, please, be patient."
system "echo yes | /usr/local/opt/android-sdk/tools/android update sdk --filter tools,platform-tools,android-23,build-tools-23.0.2,extra-android-m2repository --all --no-ui"

puts "Installing Node.js 4"
system('brew install homebrew/versions/node4-lts')

puts "Installing NativeScript CLI..."
system "/usr/local/bin/npm install -g nativescript"

puts "The ANDROID_HOME and JAVA_HOME environment variables have been added to your .profile. Restart the terminal to use them."
1 change: 1 addition & 0 deletions test/platform-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ function createTestInjector() {
testInjector.register("mobilePlatformsCapabilities", MobilePlatformsCapabilities);
testInjector.register("devicePlatformsConstants", DevicePlatformsConstants);
testInjector.register("xmlValidator", XmlValidator);
testInjector.register("npm", {});

return testInjector;
}
Expand Down
1 change: 1 addition & 0 deletions test/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function createTestInjector() {
testInjector.register("mobilePlatformsCapabilities", MobilePlatformsCapabilities);
testInjector.register("devicePlatformsConstants", DevicePlatformsConstants);
testInjector.register("xmlValidator", XmlValidator);
testInjector.register("npm", {});

return testInjector;
}
Expand Down