Skip to content

Commit a899190

Browse files
committed
docs(resources-update-command): add documentation for the new resources-update command
1 parent be6d70c commit a899190

File tree

5 files changed

+36
-8
lines changed

5 files changed

+36
-8
lines changed

docs/man_pages/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Command | Description
2626
[platform list](project/configuration/platform.html) | Lists all platforms that the project currently targets.
2727
[platform&nbsp;remove&nbsp;`<Platform>`](project/configuration/platform-remove.html) | Removes the selected platform from the platforms that the project currently targets. This operation deletes all platform-specific files and subdirectories from your project.
2828
[platform update `<Platform>`](project/configuration/platform-update.html) | Updates the NativeScript runtime for the specified platform.
29+
[resources-update](project/configuration/resources-update.html) | Updates the App_Resources/<platform>'s internal folder structure to conform to that of an Android project.
2930
[prepare `<Platform>`](project/configuration/prepare.html) | Copies relevant content from the app directory to the subdirectory for the selected target platform to let you build the project.
3031
[build `<Platform>`](project/testing/build.html) | Builds the project for the selected target platform and produces an application package or an emulator package.
3132
[deploy `<Platform>`](project/testing/deploy.html) | Deploys the project to a connected physical or virtual device.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
resources-update
2+
==========
3+
4+
Usage | Synopsis
5+
------|-------
6+
`$ tns resources-update` | Defaults to executing `$ tns resources-update android`. Updates the App_Resources/Android's folder structure.
7+
`$ tns resources-update android` | Updates the App_Resources/Android's folder structure.
8+
9+
Updates the App_Resources/<platform>'s internal folder structure to conform to that of an Android project. Android resource files and directories will be located at the following paths:
10+
- `drawable-*`, `values`, `raw`, etc. can be found at `App_Resources/Android/src/main/res`
11+
- `AndroidManifest.xml` can be found at `App_Resources/Android/src/main/AndroidManifest.xml`
12+
- Java source files can be dropped in at `App_Resources/Android/src/main/java` after creating the proper package subdirectory structure
13+
- Additional arbitrary assets can be dropped in at `App_Resources/Android/src/main/assets`
14+
15+
### Command Limitations
16+
17+
* The command works only for the directory structure under `App_Resources/Android`. Running `$ tns resources-update ios` will have no effect.
18+
19+
### Related Commands
20+
21+
Command | Description
22+
----------|----------
23+
[install](install.html) | Installs all platforms and dependencies described in the `package.json` file in the current directory.
24+
[platform add](platform-add.html) | Configures the current project to target the selected platform.
25+
[platform remove](platform-remove.html) | Removes the selected platform from the platforms that the project currently targets.
26+
[platform](platform.html) | Lists all platforms that the project currently targets.
27+
[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.

docs/man_pages/project/configuration/update.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ Command | Description
1717
[platform remove](platform-remove.html) | Removes the selected platform from the platforms that the project currently targets.
1818
[platform](platform.html) | Lists all platforms that the project currently targets.
1919
[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.
20-
[platform update](platform-update.html) | Updates the NativeScript runtime for the specified platform.
20+
[platform update](platform-update.html) | Updates the NativeScript runtime for the specified platform.
21+
[resources-update android](resources-update.html) | Updates the App_Resources/Android directory to the new v4.0 directory structure

lib/commands/resources-update.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export class ResourcesUpdateCommand implements ICommand {
1313

1414
public async canExecute(args: string[]): Promise<boolean> {
1515
if (!args || args.length === 0) {
16-
this.$errors.failWithoutHelp("No platform specified. Please specify a platform to update. Valid platforms are: 'android'");
16+
// Command defaults to migrating the Android App_Resources, unless explicitly specified
17+
args = ["android"];
1718
}
1819

1920
for (const platform of args) {

lib/services/project-v4-migration-service.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ export class ProjectV4MigrationService implements IProjectV4MigrationService {
66
private static ANDROID_DIR_TEMP = "Android-Updated";
77
private static ANDROID_DIR_OLD = "Android-Pre-v4";
88

9-
constructor(
10-
private $fs: IFileSystem,
9+
constructor(private $fs: IFileSystem,
1110
private $logger: ILogger,
12-
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants
13-
) { }
11+
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants) { }
1412

1513
canMigrate(platformString: string): boolean {
1614
if (platformString.toLowerCase() === this.$devicePlatformsConstants.iOS.toLowerCase()) {
@@ -50,12 +48,12 @@ export class ProjectV4MigrationService implements IProjectV4MigrationService {
5048
shell.cp("-Rf", dir, appResourcesMainSourceSetResourcesDestination);
5149
});
5250

53-
// move the pre-v4 app_resources in ANDROID_DIR_OLD
51+
// rename the pre-v4 app_resources to ANDROID_DIR_OLD
5452
shell.mv(originalAppResources, path.join(appResourcesDir, ProjectV4MigrationService.ANDROID_DIR_OLD));
5553
// move the new, updated app_resources to App_Resources/Android, as the de facto resources
5654
shell.mv(appResourcesDestination, originalAppResources)
5755

58-
this.$logger.out(`Successfully updated your project's App_Resources/Android directory structure. The previous version of App_Resources/Android has been renamed to App_Resources/${ProjectV4MigrationService.ANDROID_DIR_OLD}`);
56+
this.$logger.out(`Successfully updated your project's App_Resources/Android directory structure.\nThe previous version of App_Resources/Android has been renamed to App_Resources/${ProjectV4MigrationService.ANDROID_DIR_OLD}`);
5957
}
6058

6159
}

0 commit comments

Comments
 (0)