Skip to content

Commit 012a406

Browse files
FatmeFatme
Fatme
authored and
Fatme
committed
Merge pull request #613 from NativeScript/fatme/merge-release-1.1.2-into-master
Merge release 1.1.2 into master
2 parents 74a647e + 0b638e7 commit 012a406

39 files changed

+794
-154
lines changed

CHANGELOG.md

+17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
NativeScript CLI Changelog
22
================
33

4+
1.1.2 (2015, July 2)
5+
==
6+
7+
### New
8+
9+
* [Implemented #600](https://github.com/NativeScript/nativescript-cli/issues/600): Added the `$ tns init` command. You can use it to initialize a NativeScript project for development. The command recreates or updates the `package.json` file of the project. You can then run `$ tns install` to install the platforms and dependencies described in the `package.json` file.
10+
* [Implemented #587](https://github.com/NativeScript/nativescript-cli/issues/587): Added the `$ tns install` command. You can use it to quickly install all platforms and dependencies described in a `package.json` file.
11+
12+
### Fixed
13+
14+
* [Fixed #606](https://github.com/NativeScript/nativescript-cli/issues/606): The NativeScript CLI lets you run `<Platform>`-based commands on operating systems which do not support development for this platform. For example, you can run `$ tns build ios` on a Windows system.
15+
* [Fixed #601](https://github.com/NativeScript/nativescript-cli/issues/601): The NativeScript CLI does not treat the dependencies of devDependencies as devDependencies.
16+
* [Fixed #599](https://github.com/NativeScript/nativescript-cli/issues/599): The NativeScript CLI always creates a `tmp` directory in the current directory when you run any command and modifies the `package.json` file for the project.
17+
* [Fixed #584](https://github.com/NativeScript/nativescript-cli/issues/584): The NativeScript CLI references the files in the project with their absolute paths instead of their relative paths. This might cause the project to stop working when transfered to another location and might cause issues with your application packages.
18+
* [Fixed #578](https://github.com/NativeScript/nativescript-cli/issues/578): Platform-specific files in NativeScript plugins are not processed correctly. The NativeScript CLI copies them to the correct platform-specific directory but does not rename them correctly.
19+
* [Fixed #520](https://github.com/NativeScript/nativescript-cli/issues/520): iOS resources from the `App_Resources` folder are not included in the native Xcode project and are not accessible in the application package.
20+
421
1.1.1 (2015, June 17)
522
==
623

bin/nativescript.js

100644100755
File mode changed.

docs/man_pages/index.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ Command | Description
2828
[emulate `<Platform>`](project/testing/emulate.html) | Deploys the project in the native emulator for the selected target platform.
2929
[run `<Platform>`](project/testing/run.html) | Runs your project on a connected device or in the native emulator, if configured.
3030
[debug `<Platform>`](project/testing/debug.html) | Debugs your project on a connected device.
31-
[plugin](plugin.html) | Lists all installed plugins for your project or lets you manage the plugins for your project.
31+
[install](project/configuration/install.html) | Installs all platforms and dependencies described in the `package.json` file in the current directory.
32+
[plugin](lib-management/plugin.html) | Lets you manage the plugins for your project.
3233

3334
## Device Commands
3435
Command | Description
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
install
2+
==========
3+
4+
Usage | Synopsis
5+
---|---
6+
General | `$ tns install [--path]`
7+
8+
Installs all platforms and dependencies described in the `package.json` file in the current directory.
9+
10+
<% if(isHtml) { %>
11+
The `package.json` file must be a valid `package.json` describing the configuration of a NativeScript project. If missing or corrupted, you can recreate the file by running `$ tns init` in the directory of a NativeScript project.
12+
<% } %>
13+
14+
### Options
15+
* `--path` - Specifies the directory which contains the `package.json` file, if different from the current directory.
16+
17+
<% if(isHtml) { %>
18+
### Related Commands
19+
20+
Command | Description
21+
----------|----------
22+
[platform add](platform-add.html) | Configures the current project to target the selected platform.
23+
[platform remove](platform-remove.html) | Removes the selected platform from the platforms that the project currently targets.
24+
[platform update](platform-update.html) | Updates the NativeScript runtime for the specified platform.
25+
[platform](platform.html) | Lists all platforms that the project currently targets.
26+
[prepare](prepare.html) | Copies common and relevant platform-specific content from the app directory to the subdirectory for the selected target platform in the platforms directory.
27+
<% } %>

docs/man_pages/project/configuration/platform-add.md

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ To list only experimental versions for iOS, run `$ npm view tns-ios dist-tags`
3232

3333
Command | Description
3434
----------|----------
35+
[install](install.html) | Installs all platforms and dependencies described in the `package.json` file in the current directory.
3536
[platform remove](platform-remove.html) | Removes the selected platform from the platforms that the project currently targets.
3637
[platform update](platform-update.html) | Updates the NativeScript runtime for the specified platform.
3738
[platform](platform.html) | Lists all platforms that the project currently targets.

docs/man_pages/project/configuration/platform-remove.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Removes the selected platform from the platforms that the project currently targ
2424

2525
Command | Description
2626
----------|----------
27+
[install](install.html) | Installs all platforms and dependencies described in the `package.json` file in the current directory.
2728
[platform add](platform-add.html) | Configures the current project to target the selected platform.
2829
[platform update](platform-update.html) | Updates the NativeScript runtime for the specified platform.
2930
[platform](platform.html) | Lists all platforms that the project currently targets.

docs/man_pages/project/configuration/platform-update.md

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ To list only experimental versions for ios, run `$ npm view tns-ios dist-tags`
2929

3030
Command | Description
3131
----------|----------
32+
[install](install.html) | Installs all platforms and dependencies described in the `package.json` file in the current directory.
3233
[platform add](platform-add.html) | Configures the current project to target the selected platform.
3334
[platform remove](platform-remove.html) | Removes the selected platform from the platforms that the project currently targets.
3435
[platform](platform.html) | Lists all platforms that the project currently targets.

docs/man_pages/project/configuration/platform.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Lists all platforms that the project currently targets. You can build and deploy
1212

1313
Command | Description
1414
----------|----------
15+
[install](install.html) | Installs all platforms and dependencies described in the `package.json` file in the current directory.
1516
[platform add](platform-add.html) | Configures the current project to target the selected platform.
1617
[platform remove](platform-remove.html) | Removes the selected platform from the platforms that the project currently targets.
1718
[platform update](platform-update.html) | Updates the NativeScript runtime for the specified platform.

docs/man_pages/project/configuration/prepare.md

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ in the `platforms` directory. This lets you build the project with the SDK for t
2323

2424
Command | Description
2525
----------|----------
26+
[install](install.html) | Installs all platforms and dependencies described in the `package.json` file in the current directory.
2627
[platform add](platform-add.html) | Configures the current project to target the selected platform.
2728
[platform remove](platform-remove.html) | Removes the selected platform from the platforms that the project currently targets.
2829
[platform update](platform-update.html) | Updates the NativeScript runtime for the specified platform.

docs/man_pages/project/creation/create.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,13 @@ Creates a new project for native development with NativeScript from the default
1616
* `<App Name>` is the name of project. The specified name must meet the requirements of all platforms that you want to target. <% if(isConsole) { %>For more information about the `<App Name>` requirements, run `$ tns help create`<% } %><% if(isHtml) { %>For projects that target Android, you can use uppercase or lowercase letters, numbers, and underscores. The name must start with a letter.
1717
For projects that target iOS, you can use uppercase or lowercase letters, numbers, and hyphens.<% } %>
1818
* `<App ID>` is the application identifier for your project. It must be a domain name in reverse and must meet the requirements of all platforms that you want to target. If not specified, the application identifier is set to `org.nativescript.<App name>` <% if(isConsole) { %>For more information about the `<App ID>` requirements, run `$ tns help create`<% } %><% if(isHtml) { %>For projects that target Android, you can use uppercase or lowercase letters, numbers, and underscores in the strings of the reversed domain name, separated by a dot. Strings must be separated by a dot and must start with a letter. For example: `com.nativescript.My_Andro1d_App`
19-
For projects that target iOS, you can use uppercase or lowercase letters, numbers, and hyphens in the strings of the reversed domain name. Strings must be separated by a dot. For example: `com.nativescript.My-i0s-App`.<% } %>
19+
For projects that target iOS, you can use uppercase or lowercase letters, numbers, and hyphens in the strings of the reversed domain name. Strings must be separated by a dot. For example: `com.nativescript.My-i0s-App`.<% } %>
20+
21+
<% if(isHtml) { %>
22+
### Related Commands
23+
24+
Command | Description
25+
----------|----------
26+
[init](init.html) | Initializes a project for development. The command prompts you to provide your project configuration interactively and uses the information to create a new package.json file or update the existing one.
27+
[install](install.html) | Installs all platforms and dependencies described in the `package.json` file in the current directory.
28+
<% } %>
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
init
2+
==========
3+
4+
Usage | Synopsis
5+
---|---
6+
General | `$ tns init [--path <Directory>] [--force]`
7+
8+
Initializes a project for development. The command prompts you to provide your project configuration interactively and uses the information to create a new `package.json` file or update the existing one.
9+
10+
### Options
11+
* `--path` - Specifies the directory where you want to initialize the project, if different from the current directory. The directory must be empty.
12+
* `--force` - If set, applies the default project configuration and does not show the interactive prompt. The default project configuration targets the latest official runtimes and sets `org.nativescript.<folder_name>` for application identifier.
13+
14+
<% if(isHtml) { %>
15+
### Related Commands
16+
17+
Command | Description
18+
----------|----------
19+
[create](create.html) | Creates a new project for native development with NativeScript from the default template or from an existing NativeScript project.
20+
[install](install.html) | Installs all platforms and dependencies described in the `package.json` file in the current directory.
21+
<% } %>

lib/bootstrap.ts

+6
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,9 @@ $injector.requireCommand("plugin|add", "./commands/plugin/add-plugin");
6161
$injector.requireCommand("plugin|remove", "./commands/plugin/remove-plugin");
6262

6363
$injector.require("doctorService", "./services/doctor-service");
64+
$injector.requireCommand("install", "./commands/install");
65+
66+
$injector.require("initService", "./services/init-service");
67+
$injector.requireCommand("init", "./commands/init");
68+
69+
$injector.require("projectFilesManager", "./services/project-files-manager");

lib/commands/init.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
///<reference path="../.d.ts"/>
2+
"use strict";
3+
4+
import Future = require("fibers/future");
5+
6+
export class InitCommand implements ICommand {
7+
constructor(private $initService: IInitService) { }
8+
9+
public allowedParameters: ICommandParameter[] = [];
10+
public enableHooks = false;
11+
12+
public execute(args: string[]): IFuture<void> {
13+
return this.$initService.initialize();
14+
}
15+
}
16+
$injector.registerCommand("init", InitCommand);

lib/commands/install.ts

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
///<reference path="../.d.ts"/>
2+
"use strict";
3+
4+
export class InstallCommand implements ICommand {
5+
private _projectData: any;
6+
7+
constructor(private $platformsData: IPlatformsData,
8+
private $platformService: IPlatformService,
9+
private $projectData: IProjectData,
10+
private $projectDataService: IProjectDataService,
11+
private $pluginsService: IPluginsService,
12+
private $logger: ILogger) { }
13+
14+
public enableHooks = false;
15+
16+
public allowedParameters: ICommandParameter[] = [];
17+
18+
public execute(args: string[]): IFuture<void> {
19+
return (() => {
20+
let error: string = "";
21+
22+
this.$pluginsService.ensureAllDependenciesAreInstalled().wait();
23+
24+
this.$projectDataService.initialize(this.$projectData.projectDir);
25+
_.each(this.$platformsData.platformsNames, platform => {
26+
let platformData = this.$platformsData.getPlatformData(platform);
27+
let frameworkPackageData = this.$projectDataService.getValue(platformData.frameworkPackageName).wait();
28+
if(frameworkPackageData && frameworkPackageData.version) {
29+
try {
30+
this.$platformService.addPlatforms([`${platform}@${frameworkPackageData.version}`]).wait();
31+
} catch(err) {
32+
error += err;
33+
}
34+
}
35+
});
36+
37+
if(error) {
38+
this.$logger.error(error);
39+
}
40+
41+
}).future<void>()();
42+
}
43+
}
44+
$injector.registerCommand("install", InstallCommand);

lib/commands/prepare.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ export class PrepareCommand implements ICommand {
66
private $platformCommandParameter: ICommandParameter) { }
77

88
execute(args: string[]): IFuture<void> {
9-
return (() => {
10-
this.$platformService.preparePlatform(args[0]).wait();
11-
}).future<void>()();
9+
return this.$platformService.preparePlatform(args[0]);
1210
}
1311

1412
allowedParameters = [this.$platformCommandParameter];

lib/commands/run.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class RunAndroidCommand extends RunCommandBase implements ICommand {
2828
private $platformsData: IPlatformsData) {
2929
super($platformService);
3030
}
31-
31+
3232
public allowedParameters: ICommandParameter[] = [];
3333

3434
public execute(args: string[]): IFuture<void> {

lib/config.ts

+4
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,9 @@ export class StaticConfig extends staticConfigBaseLibPath.StaticConfigBase imple
5757
public get HTML_CLI_HELPERS_DIR(): string {
5858
return path.join(__dirname, "../docs/helpers");
5959
}
60+
61+
public get pathToPackageJson(): string {
62+
return path.join(__dirname, "..", "package.json");
63+
}
6064
}
6165
$injector.register("staticConfig", StaticConfig);

lib/constants.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export var NATIVESCRIPT_KEY_NAME = "nativescript";
77
export var NODE_MODULES_FOLDER_NAME = "node_modules";
88
export var PACKAGE_JSON_FILE_NAME = "package.json";
99
export var NODE_MODULE_CACHE_PATH_KEY_NAME = "node-modules-cache-path";
10+
export var DEFAULT_APP_IDENTIFIER_PREFIX = "org.nativescript";
1011

1112
export class ReleaseType {
1213
static MAJOR = "major";

lib/declarations.ts

+10
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ interface IOpener {
5050

5151
interface IOptions extends ICommonOptions {
5252
frameworkPath: string;
53+
frameworkName: string;
54+
frameworkVersion: string;
5355
copyFrom: string;
5456
linkTo: string;
5557
release: boolean;
@@ -64,3 +66,11 @@ interface IOptions extends ICommonOptions {
6466
keyStoreAliasPassword: string;
6567
sdk: string;
6668
}
69+
70+
interface IProjectFilesManager {
71+
processPlatformSpecificFiles(directoryPath: string, platform: string, excludedDirs?: string[]): IFuture<void>;
72+
}
73+
74+
interface IInitService {
75+
initialize(): IFuture<void>;
76+
}

lib/definitions/project.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ interface IPlatformProjectService {
2727
interpolateData(projectRoot: string): IFuture<void>;
2828
afterCreateProject(projectRoot: string): IFuture<void>;
2929
buildProject(projectRoot: string): IFuture<void>;
30+
prepareProject(): IFuture<void>;
31+
prepareAppResources(appResourcesDirectoryPath: string): IFuture<void>;
3032
isPlatformPrepared(projectRoot: string): IFuture<boolean>;
3133
addLibrary(platformData: IPlatformData, libraryPath: string): IFuture<void>;
3234
canUpdatePlatform(currentVersion: string, newVersion: string): IFuture<boolean>;

lib/options.ts

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export class Options extends commonOptionsLibPath.OptionsBase {
1313
$hostInfo: IHostInfo) {
1414
super({
1515
frameworkPath: { type: OptionType.String },
16+
frameworkName: { type: OptionType.String },
17+
frameworkVersion: { type: OptionType.String },
1618
copyFrom: { type: OptionType.String },
1719
linkTo: { type: OptionType.String },
1820
release: { type: OptionType.Boolean },

lib/services/android-project-service.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class AndroidProjectService implements IPlatformProjectService {
5151
frameworkFilesExtensions: [".jar", ".dat", ".so"],
5252
configurationFileName: "AndroidManifest.xml",
5353
configurationFilePath: path.join(this.$projectData.platformsDir, "android", "AndroidManifest.xml"),
54-
mergeXmlConfig: [{ "nodename": "manifest", "attrname": "*" }]
54+
mergeXmlConfig: [{ "nodename": "manifest", "attrname": "*" }, { "application": "manifest", "attrname": "*" }]
5555
};
5656
}
5757

@@ -181,6 +181,16 @@ class AndroidProjectService implements IPlatformProjectService {
181181
public isPlatformPrepared(projectRoot: string): IFuture<boolean> {
182182
return this.$fs.exists(path.join(projectRoot, "assets", constants.APP_FOLDER_NAME));
183183
}
184+
185+
public prepareAppResources(appResourcesDirectoryPath: string): IFuture<void> {
186+
return (() => {
187+
let resourcesDirPath = path.join(appResourcesDirectoryPath, this.platformData.normalizedPlatformName);
188+
let resourcesDirs = this.$fs.readDirectory(resourcesDirPath).wait();
189+
_.each(resourcesDirs, resourceDir => {
190+
this.$fs.deleteDirectory(path.join(this.platformData.appResourcesDestinationDirectoryPath, resourceDir)).wait();
191+
});
192+
}).future<void>()();
193+
}
184194

185195
private parseProjectProperties(projDir: string, destDir: string): void {
186196
let projProp = path.join(projDir, "project.properties");
@@ -273,6 +283,10 @@ class AndroidProjectService implements IPlatformProjectService {
273283
public getFrameworkFilesExtensions(): string[] {
274284
return [".jar", ".dat"];
275285
}
286+
287+
public prepareProject(): IFuture<void> {
288+
return (() => { }).future<void>()();
289+
}
276290

277291
private copy(projectRoot: string, frameworkDir: string, files: string, cpArg: string): IFuture<void> {
278292
return (() => {

0 commit comments

Comments
 (0)