Skip to content

Commit c376458

Browse files
author
Fatme
authored
Merge pull request #3916 from NativeScript/fatme/msv-preview-app
feat: pass msvKey and msvEnv to preview-sdk in order to respect different min supported versions of preview app
2 parents 077131b + 8d41215 commit c376458

8 files changed

+53
-11
lines changed

config/config.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"ANDROID_DEBUG_UI_MAC": "Google Chrome",
66
"USE_POD_SANDBOX": false,
77
"DISABLE_HOOKS": false,
8-
"UPLOAD_PLAYGROUND_FILES_ENDPOINT": "https://play.nativescript.org/api/files" ,
9-
"SHORTEN_URL_ENDPOINT": "https://play.nativescript.org/api/shortenurl?longUrl=%s"
8+
"UPLOAD_PLAYGROUND_FILES_ENDPOINT": "https://play.nativescript.org/api/files",
9+
"SHORTEN_URL_ENDPOINT": "https://play.nativescript.org/api/shortenurl?longUrl=%s",
10+
"PREVIEW_APP_ENVIRONMENT": "live"
1011
}

lib/config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export class Configuration extends ConfigBase implements IConfiguration { // Use
1010
USE_POD_SANDBOX: boolean = false;
1111
UPLOAD_PLAYGROUND_FILES_ENDPOINT: string = null;
1212
SHORTEN_URL_ENDPOINT: string = null;
13+
PREVIEW_APP_ENVIRONMENT: string = null;
1314

1415
/*don't require logger and everything that has logger as dependency in config.js due to cyclic dependency*/
1516
constructor(protected $fs: IFileSystem) {

lib/declarations.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ interface IConfiguration extends Config.IConfig {
384384
USE_POD_SANDBOX: boolean;
385385
UPLOAD_PLAYGROUND_FILES_ENDPOINT: string;
386386
SHORTEN_URL_ENDPOINT: string;
387+
PREVIEW_APP_ENVIRONMENT: string;
387388
}
388389

389390
interface IApplicationPackage {

lib/services/livesync/livesync-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
327327
let deviceDescriptorsForInitialSync: ILiveSyncDeviceInfo[] = [];
328328

329329
if (liveSyncData.syncToPreviewApp) {
330-
this.$previewAppLiveSyncService.initialize({
330+
await this.$previewAppLiveSyncService.initialize({
331331
appFilesUpdaterOptions: {
332332
bundle: liveSyncData.bundle,
333333
release: liveSyncData.release,

lib/services/livesync/playground/preview-app-livesync-service.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ export class PreviewAppLiveSyncService implements IPreviewAppLiveSyncService {
2020
private $projectFilesManager: IProjectFilesManager,
2121
private $projectFilesProvider: IProjectFilesProvider) { }
2222

23-
public initialize(data: IPreviewAppLiveSyncData) {
24-
this.$previewSdkService.initialize(async (device: Device) => {
23+
public async initialize(data: IPreviewAppLiveSyncData): Promise<void> {
24+
await this.$previewSdkService.initialize(async (device: Device) => {
2525
if (!device) {
2626
this.$errors.failWithoutHelp("Sending initial preview files without a specified device is not supported.");
2727
}

lib/services/livesync/playground/preview-sdk-service.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ export class PreviewSdkService implements IPreviewSdkService {
1717
return `nsplay://boot?instanceId=${this.instanceId}&pKey=${PubnubKeys.PUBLISH_KEY}&sKey=${PubnubKeys.SUBSCRIBE_KEY}&template=play-ng&hmr=${hmrValue}`;
1818
}
1919

20-
public initialize(getInitialFiles: (device: Device) => Promise<FilesPayload>): void {
20+
public async initialize(getInitialFiles: (device: Device) => Promise<FilesPayload>): Promise<void> {
2121
const initConfig = this.getInitConfig(getInitialFiles);
2222
this.messagingService = new MessagingService();
23-
this.instanceId = this.messagingService.initialize(initConfig);
23+
this.instanceId = await this.messagingService.initialize(initConfig);
2424
}
2525

2626
public applyChanges(filesPayload: FilesPayload): Promise<void> {
@@ -43,6 +43,8 @@ export class PreviewSdkService implements IPreviewSdkService {
4343
return {
4444
pubnubPublishKey: PubnubKeys.PUBLISH_KEY,
4545
pubnubSubscribeKey: PubnubKeys.SUBSCRIBE_KEY,
46+
msvKey: "cli",
47+
msvEnv: this.$config.PREVIEW_APP_ENVIRONMENT,
4648
callbacks: this.getCallbacks(),
4749
getInitialFiles
4850
};

npm-shrinkwrap.json

+40-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"mkdirp": "0.5.1",
5757
"mute-stream": "0.0.5",
5858
"nativescript-doctor": "1.3.0",
59-
"nativescript-preview-sdk": "0.2.9",
59+
"nativescript-preview-sdk": "0.2.11",
6060
"open": "0.0.5",
6161
"ora": "2.0.0",
6262
"osenv": "0.1.3",

0 commit comments

Comments
 (0)