Skip to content

chore: merge release in master #4949

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 24 commits into from
Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0b1e750
feat: support accounts with two-factor authentication on publish
Fatme Jul 25, 2019
802e8e6
feat: add apple-login command
Fatme Jul 25, 2019
e8106ec
fix: missing --template arg
rynop Jul 25, 2019
a106c8d
Merge pull request #4901 from rynop/patch-2
rosen-vladimirov Jul 26, 2019
a6e17e5
test: fix unit tests
Fatme Jul 25, 2019
9ca5ba5
docs: add help for new options and command
Fatme Jul 26, 2019
b63f34e
fix: fix PR comments
Fatme Jul 30, 2019
cc664a5
fix: hardcode karma-webpack to 3.0.5
Fatme Jul 30, 2019
40de21d
Merge pull request #4903 from NativeScript/fatme/2fa
Fatme Jul 30, 2019
87f2b1f
fix: fix appstore list command for accounts with 2fa
Fatme Jul 30, 2019
56c8376
Merge pull request #4912 from NativeScript/fatme/karam-3.0.5
Jul 30, 2019
5ebd184
Merge pull request #4915 from NativeScript/fatme/fix-appstore-list
Jul 30, 2019
2dfbeaa
fix: re-implement lost improvements for faster LiveSync and avoid get…
DimitarTachev Jul 31, 2019
1e2109f
fix: avoid 30 seconds delay on each LiveSync
DimitarTachev Jul 31, 2019
196cd3c
chore: bump version
DimitarTachev Jul 31, 2019
e3bacd5
Merge pull request #4917 from NativeScript/tachev/fix-fast-livesync
Aug 1, 2019
45f3284
update changelog
miroslavaivanova Aug 6, 2019
71be391
Merge pull request #4929 from NativeScript/miroslavaivanova-patch-2
miroslavaivanova Aug 6, 2019
ffa256d
fix: include all chunkFiles in fallbackFiles in order to avoid wrong …
DimitarTachev Aug 1, 2019
50588b1
chore: bump version to 6.0.4
rosen-vladimirov Aug 13, 2019
49fdfdd
Merge pull request #4946 from NativeScript/vladimirov/bump-version-604
rosen-vladimirov Aug 13, 2019
8bc8868
Merge pull request #4925 from NativeScript/tachev/fix-lazy-chunks-hmr
rosen-vladimirov Aug 14, 2019
eead2d2
chore: merge release in master
rosen-vladimirov Aug 14, 2019
4d3419e
chore: replace failWithoutHelp with fail
rosen-vladimirov Aug 14, 2019
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
NativeScript CLI Changelog
================

6.0.3 (2019, August 05)
==
* [Fixed #4914](https://github.com/NativeScript/nativescript-cli/issues/4914): livesync not working with command tns test android
* [Fixed #4746](https://github.com/NativeScript/nativescript-cli/issues/4746): Unable to work with `[email protected]` on test command
* [Fixed #4586](https://github.com/NativeScript/nativescript-cli/issues/4586): publish ios fails because of hsa2

6.0.2 (2019, July 22)
==
* [Fixed #4885](https://github.com/NativeScript/nativescript-cli/issues/4885): `migrate` and `update` commands are failing where everything is up-to-date
Expand Down
3 changes: 2 additions & 1 deletion config/test-dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
},
{
"name": "karma-webpack",
"excludedPeerDependencies": ["webpack"]
"excludedPeerDependencies": ["webpack"],
"version": "3.0.5"
},
{
"name": "mocha",
Expand Down
20 changes: 10 additions & 10 deletions docs/man_pages/project/creation/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ Below you can see a list of the recommended NativeScript starting templates and
Template | Command
---------|----------
`JavaScript - Hello World`, `--js`, `--javascript` | tns create --template tns-template-hello-world
`JavaScript - SideDrawer` | tns create tns-template-drawer-navigation
`JavaScript - Tabs` | tns create tns-template-tab-navigation
`TypeScript - Hello World`, `--ts`, `--tsc`, `--typescript` | tns create tns-template-hello-world-ts
`TypeScript - SideDrawer` | tns create tns-template-drawer-navigation-ts
`TypeScript - Tabs` | tns create tns-template-tab-navigation-ts
`Angular - Hello World`, `--ng`, `--angular` | tns create tns-template-hello-world-ng
`Angular - SideDrawer` | tns create tns-template-drawer-navigation-ng
`Angular - Tabs` | tns create tns-template-tab-navigation-ng
`Vue.js - Blank`, `--vue`, `--vuejs` | tns create tns-template-blank-vue
`Vue.js - SideDrawer`, | tns create tns-template-drawer-navigation-vue
`JavaScript - SideDrawer` | tns create --template tns-template-drawer-navigation
`JavaScript - Tabs` | tns create --template tns-template-tab-navigation
`TypeScript - Hello World`, `--ts`, `--tsc`, `--typescript` | tns create --template tns-template-hello-world-ts
`TypeScript - SideDrawer` | tns create --template tns-template-drawer-navigation-ts
`TypeScript - Tabs` | tns create --template tns-template-tab-navigation-ts
`Angular - Hello World`, `--ng`, `--angular` | tns create --template tns-template-hello-world-ng
`Angular - SideDrawer` | tns create --template tns-template-drawer-navigation-ng
`Angular - Tabs` | tns create --template tns-template-tab-navigation-ng
`Vue.js - Blank`, `--vue`, `--vuejs` | tns create --template tns-template-blank-vue
`Vue.js - SideDrawer`, | tns create --template tns-template-drawer-navigation-vue

### Related Commands

Expand Down
35 changes: 35 additions & 0 deletions docs/man_pages/publishing/apple-login.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<% if (isJekyll) { %>---
title: tns apple-login
position: 5
---<% } %>

# tns apple-login

### Description

Uses the provided Apple credentials to obtain Apple session which can be used when publishing to Apple AppStore.

### Commands

Usage | Synopsis
---|---
General | `$ tns apple-login [<Apple ID>] [<Password>]`

### Arguments

* `<Apple ID>` and `<Password>` are your credentials for logging into iTunes Connect.

<% if(isHtml) { %>s

### Related Commands

Command | Description
----------|----------
[appstore](appstore.html) | Lists applications registered in iTunes Connect.
[appstore upload](appstore-upload.html) | Uploads project to iTunes Connect.
[build](../project/testing/build.html) | Builds the project for the selected target platform and produces an application package that you can manually deploy on device or in the native emulator.
[build ios](../project/testing/build-ios.html) | Builds the project for iOS and produces an APP or IPA that you can manually deploy in the iOS Simulator or on device, respectively.
[deploy](../project/testing/deploy.html) | Builds and deploys the project to a connected physical or virtual device.
[run](../project/testing/run.html) | Runs your project on a connected device or in the native emulator for the selected platform.
[run ios](../project/testing/run-ios.html) | Runs your project on a connected iOS device or in the iOS Simulator, if configured.
<% } %>
3 changes: 3 additions & 0 deletions docs/man_pages/publishing/appstore-upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ position: 1
### Description

Uploads project to iTunes Connect. The command either issues a production build and uploads it to iTunes Connect, or uses an already built package to upload.
The user will be prompted interactively for verification code when two-factor authentication enabled account is used. As on non-interactive console (CI), you will not be prompt for verification code. In this case, you need to generate a login session for your apple's account in advance using `tns apple-login` command. The generated value must be provided via the `--appleSessionBase64` option and is only valid for up to a month. Meaning you'll need to create a new session every month.

<% if(isConsole && (isLinux || isWindows)) { %>WARNING: You can run this command only on macOS systems. To view the complete help for this command, run `$ tns help appstore upload`<% } %>
<% if((isConsole && isMacOS) || isHtml) { %>
Expand All @@ -22,6 +23,8 @@ Upload package | `$ tns appstore upload [<Apple ID> [<Password>]] --ipa <Ipa Fil
### Options

* `--ipa` - If set, will use provided .ipa file instead of building the project.
* `--appleApplicationSpecificPassword` - Specifies the password for accessing the information you store in iTunes Transporter application.
* `--appleSessionBase64` - The session that will be used instead of triggering a new login each time NativeScript CLI communicates with Apple's APIs.

### Arguments

Expand Down
5 changes: 4 additions & 1 deletion docs/man_pages/publishing/publish-ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ position: 3
### Description

Uploads project to iTunes Connect. The command either issues a production build and uploads it to iTunes Connect, or uses an already built package to upload.
The user will be prompted interactively for verification code when two-factor authentication enabled account is used. As on non-interactive console (CI), you will not be prompt for verification code. In this case, you need to generate a login session for your apple's account in advance using `tns apple-login` command. The generated value must be provided via the `--appleSessionBase64` option and is only valid for up to a month. Meaning you'll need to create a new session every month.

<% if(isConsole && (isLinux || isWindows)) { %>WARNING: You can run this command only on macOS systems. To view the complete help for this command, run `$ tns help publish ios`<% } %>

Expand All @@ -24,7 +25,9 @@ Upload package | `$ tns publish ios [<Apple ID> [<Password>]] --ipa <Ipa File Pa

* `--ipa` - If set, will use provided .ipa file instead of building the project.
* `--team-id` - Specified the team id for which Xcode will try to find distribution certificate and provisioning profile when exporting for AppStore submission.

* `--appleApplicationSpecificPassword` - Specifies the password for accessing the information you store in iTunes Transporter application.
* `--appleSessionBase64` - The session that will be used instead of triggering a new login each time NativeScript CLI communicates with Apple's APIs.

### Arguments

* `<Apple ID>` and `<Password>` are your credentials for logging into iTunes Connect.
Expand Down
1 change: 1 addition & 0 deletions lib/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ $injector.requireCommand("dev-generate-help", "./commands/generate-help");
$injector.requireCommand("appstore|*list", "./commands/appstore-list");
$injector.requireCommand("appstore|upload", "./commands/appstore-upload");
$injector.requireCommand("publish|ios", "./commands/appstore-upload");
$injector.requireCommand("apple-login", "./commands/apple-login");
$injector.require("itmsTransporterService", "./services/itmstransporter-service");

$injector.requireCommand("setup|*", "./commands/setup");
Expand Down
34 changes: 34 additions & 0 deletions lib/commands/apple-login.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { StringCommandParameter } from "../common/command-params";

export class AppleLogin implements ICommand {
public allowedParameters: ICommandParameter[] = [new StringCommandParameter(this.$injector), new StringCommandParameter(this.$injector)];

constructor(
private $applePortalSessionService: IApplePortalSessionService,
private $errors: IErrors,
private $injector: IInjector,
private $logger: ILogger,
private $prompter: IPrompter
) { }

public async execute(args: string[]): Promise<void> {
let username = args[0];
if (!username) {
username = await this.$prompter.getString("Apple ID", { allowEmpty: false });
}

let password = args[1];
if (!password) {
password = await this.$prompter.getPassword("Apple ID password");
}

const user = await this.$applePortalSessionService.createUserSession({ username, password });
if (!user.areCredentialsValid) {
this.$errors.fail(`Invalid username and password combination. Used '${username}' as the username.`);
}

const output = Buffer.from(user.userSessionCookie).toString("base64");
this.$logger.info(output);
}
}
$injector.registerCommand("apple-login", AppleLogin);
13 changes: 11 additions & 2 deletions lib/commands/appstore-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ export class ListiOSApps implements ICommand {

constructor(private $injector: IInjector,
private $applePortalApplicationService: IApplePortalApplicationService,
private $applePortalSessionService: IApplePortalSessionService,
private $logger: ILogger,
private $projectData: IProjectData,
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
private $platformValidationService: IPlatformValidationService,
private $errors: IErrors,
private $prompter: IPrompter) {
private $prompter: IPrompter,
private $options: IOptions) {
this.$projectData.initializeProjectData();
}

Expand All @@ -31,7 +33,14 @@ export class ListiOSApps implements ICommand {
password = await this.$prompter.getPassword("Apple ID password");
}

const applications = await this.$applePortalApplicationService.getApplications({ username, password });
const user = await this.$applePortalSessionService.createUserSession({ username, password }, {
sessionBase64: this.$options.appleSessionBase64,
});
if (!user.areCredentialsValid) {
this.$errors.fail(`Invalid username and password combination. Used '${username}' as the username.`);
}

const applications = await this.$applePortalApplicationService.getApplications(user);

if (!applications || !applications.length) {
this.$logger.info("Seems you don't have any applications yet.");
Expand Down
16 changes: 14 additions & 2 deletions lib/commands/appstore-upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export class PublishIOS implements ICommand {
new StringCommandParameter(this.$injector), new StringCommandParameter(this.$injector)];

constructor(
private $applePortalSessionService: IApplePortalSessionService,
private $injector: IInjector,
private $itmsTransporterService: IITMSTransporterService,
private $logger: ILogger,
Expand Down Expand Up @@ -38,6 +39,16 @@ export class PublishIOS implements ICommand {
password = await this.$prompter.getPassword("Apple ID password");
}

const user = await this.$applePortalSessionService.createUserSession({ username, password }, {
applicationSpecificPassword: this.$options.appleApplicationSpecificPassword,
sessionBase64: this.$options.appleSessionBase64,
requireInteractiveConsole: true,
requireApplicationSpecificPassword: true
});
if (!user.areCredentialsValid) {
this.$errors.fail(`Invalid username and password combination. Used '${username}' as the username.`);
}

if (!mobileProvisionIdentifier && !ipaFilePath) {
this.$logger.warn("No mobile provision identifier set. A default mobile provision will be used. You can set one in app/App_Resources/iOS/build.xcconfig");
}
Expand Down Expand Up @@ -69,8 +80,9 @@ export class PublishIOS implements ICommand {
}

await this.$itmsTransporterService.upload({
username,
password,
credentials: { username, password },
user,
applicationSpecificPassword: this.$options.appleApplicationSpecificPassword,
ipaFilePath,
shouldExtractIpa: !!this.$options.ipa,
verboseLogging: this.$logger.getLevel() === "TRACE"
Expand Down
11 changes: 11 additions & 0 deletions lib/commands/test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
abstract class TestCommandBase {
public allowedParameters: ICommandParameter[] = [];
public dashedOptions = {
hmr: { type: OptionType.Boolean, default: false, hasSensitiveValue: false },
};

protected abstract platform: string;
protected abstract $projectData: IProjectData;
protected abstract $testExecutionService: ITestExecutionService;
Expand Down Expand Up @@ -50,6 +54,13 @@ abstract class TestCommandBase {

async canExecute(args: string[]): Promise<boolean> {
if (!this.$options.force) {
if (this.$options.hmr) {
// With HMR we are not restarting after LiveSync which is causing a 30 seconds app start on Android
// because the Runtime does not watch for the `/data/local/tmp<appId>-livesync-in-progress` file deletion.
// The App is closing itself after each test execution and the bug will be reproducible on each LiveSync.
this.$errors.fail("The `--hmr` option is not supported for this command.");
}

await this.$migrateController.validate({ projectDir: this.$projectData.projectDir, platforms: [this.platform] });
}

Expand Down
1 change: 1 addition & 0 deletions lib/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export class HttpStatusCodes {
static NOT_MODIFIED = 304;
static PAYMENT_REQUIRED = 402;
static PROXY_AUTHENTICATION_REQUIRED = 407;
static CONFLICTING_RESOURCE = 409;
}

export const HttpProtocolToPort: IDictionary<number> = {
Expand Down
4 changes: 3 additions & 1 deletion lib/common/http-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ private defaultUserAgent: string;
this.$logger.error(`You can run ${EOL}\t${clientNameLowerCase} proxy set <url> <username> <password>.${EOL}In order to supply ${clientNameLowerCase} with the credentials needed.`);
return "Your proxy requires authentication.";
} else if (statusCode === HttpStatusCodes.PAYMENT_REQUIRED) {
return util.format("Your subscription has expired.");
return "Your subscription has expired.";
} else if (statusCode === HttpStatusCodes.CONFLICTING_RESOURCE) {
return "The request conflicts with the current state of the server.";
} else {
this.$logger.trace("Request was unsuccessful. Server returned: ", body);
try {
Expand Down
51 changes: 36 additions & 15 deletions lib/controllers/run-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { HmrConstants, DeviceDiscoveryEventNames } from "../common/constants";
import { PREPARE_READY_EVENT_NAME, TrackActionNames, DEBUGGER_DETACHED_EVENT_NAME, RunOnDeviceEvents, USER_INTERACTION_NEEDED_EVENT_NAME } from "../constants";
import { cache, performanceLog } from "../common/decorators";
import { EventEmitter } from "events";
import * as util from "util";

export class RunController extends EventEmitter implements IRunController {
private prepareReadyEventHandler: any = null;
Expand Down Expand Up @@ -270,7 +271,7 @@ export class RunController extends EventEmitter implements IRunController {
}

private async syncInitialDataOnDevices(projectData: IProjectData, liveSyncInfo: ILiveSyncInfo, deviceDescriptors: ILiveSyncDeviceDescriptor[]): Promise<void> {
const rebuiltInformation: IDictionary<{ packageFilePath: string, platform: string, isEmulator: boolean }> = { };
const rebuiltInformation: IDictionary<{ packageFilePath: string, platform: string, isEmulator: boolean }> = {};

const deviceAction = async (device: Mobile.IDevice) => {
const deviceDescriptor = _.find(deviceDescriptors, dd => dd.identifier === device.deviceInfo.identifier);
Expand Down Expand Up @@ -333,15 +334,16 @@ export class RunController extends EventEmitter implements IRunController {
error: err,
});

await this.stop({ projectDir: projectData.projectDir, deviceIdentifiers: [device.deviceInfo.identifier], stopOptions: { shouldAwaitAllActions: false }});
await this.stop({ projectDir: projectData.projectDir, deviceIdentifiers: [device.deviceInfo.identifier], stopOptions: { shouldAwaitAllActions: false } });
}
};

await this.addActionToChain(projectData.projectDir, () => this.$devicesService.execute(deviceAction, (device: Mobile.IDevice) => _.some(deviceDescriptors, deviceDescriptor => deviceDescriptor.identifier === device.deviceInfo.identifier)));
}

private async syncChangedDataOnDevices(data: IFilesChangeEventData, projectData: IProjectData, liveSyncInfo: ILiveSyncInfo): Promise<void> {
const rebuiltInformation: IDictionary<{ packageFilePath: string, platform: string, isEmulator: boolean }> = { };
const successfullySyncedMessageFormat = `Successfully synced application %s on device %s.`;
const rebuiltInformation: IDictionary<{ packageFilePath: string, platform: string, isEmulator: boolean }> = {};

const deviceAction = async (device: Mobile.IDevice) => {
const deviceDescriptors = this.$liveSyncProcessDataService.getDeviceDescriptors(projectData.projectDir);
Expand Down Expand Up @@ -380,28 +382,47 @@ export class RunController extends EventEmitter implements IRunController {
await this.$deviceInstallAppService.installOnDevice(device, deviceDescriptor.buildData, rebuiltInformation[platformData.platformNameLowerCase].packageFilePath);
await platformLiveSyncService.syncAfterInstall(device, watchInfo);
await this.refreshApplication(projectData, { deviceAppData, modifiedFilesData: [], isFullSync: false, useHotModuleReload: liveSyncInfo.useHotModuleReload }, data, deviceDescriptor);
this.$logger.info(util.format(successfullySyncedMessageFormat, deviceAppData.appIdentifier, device.deviceInfo.identifier));
} else {
const isInHMRMode = liveSyncInfo.useHotModuleReload && data.hmrData && data.hmrData.hash;
if (isInHMRMode) {
this.$hmrStatusService.watchHmrStatus(device.deviceInfo.identifier, data.hmrData.hash);
}

let liveSyncResultInfo = await platformLiveSyncService.liveSyncWatchAction(device, watchInfo);
await this.refreshApplication(projectData, liveSyncResultInfo, data, deviceDescriptor);

if (!liveSyncResultInfo.didRecover && isInHMRMode) {
const status = await this.$hmrStatusService.getHmrStatus(device.deviceInfo.identifier, data.hmrData.hash);
if (status === HmrConstants.HMR_ERROR_STATUS) {
watchInfo.filesToSync = data.hmrData.fallbackFiles;
liveSyncResultInfo = await platformLiveSyncService.liveSyncWatchAction(device, watchInfo);
// We want to force a restart of the application.
liveSyncResultInfo.isFullSync = true;
await this.refreshApplication(projectData, liveSyncResultInfo, data, deviceDescriptor);
const watchAction = async (): Promise<void> => {
let liveSyncResultInfo = await platformLiveSyncService.liveSyncWatchAction(device, watchInfo);
await this.refreshApplication(projectData, liveSyncResultInfo, data, deviceDescriptor);

if (!liveSyncResultInfo.didRecover && isInHMRMode) {
const status = await this.$hmrStatusService.getHmrStatus(device.deviceInfo.identifier, data.hmrData.hash);
if (status === HmrConstants.HMR_ERROR_STATUS) {
watchInfo.filesToSync = data.hmrData.fallbackFiles;
liveSyncResultInfo = await platformLiveSyncService.liveSyncWatchAction(device, watchInfo);
// We want to force a restart of the application.
liveSyncResultInfo.isFullSync = true;
await this.refreshApplication(projectData, liveSyncResultInfo, data, deviceDescriptor);
}
}

this.$logger.info(util.format(successfullySyncedMessageFormat, deviceAppData.appIdentifier, device.deviceInfo.identifier));
};

if (liveSyncInfo.useHotModuleReload) {
try {
this.$logger.trace("Try executing watch action without any preparation of files.");
await watchAction();
this.$logger.trace("Successfully executed watch action without any preparation of files.");
return;
} catch (err) {
this.$logger.trace(`Error while trying to execute fast sync. Now we'll check the state of the app and we'll try to resurrect from the error. The error is: ${err}`);
}
}

await this.$deviceInstallAppService.installOnDeviceIfNeeded(device, deviceDescriptor.buildData);
watchInfo.connectTimeout = null;
await watchAction();
}

this.$logger.info(`Successfully synced application ${deviceAppData.appIdentifier} on device ${device.deviceInfo.identifier}.`);
} catch (err) {
this.$logger.warn(`Unable to apply changes for device: ${device.deviceInfo.identifier}. Error is: ${err && err.message}.`);

Expand Down
Loading