Skip to content

feat: pass msvKey and msvEnv to preview-sdk in order to respect different min supported versions of preview app #3916

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 2 commits into from
Sep 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ANDROID_DEBUG_UI_MAC": "Google Chrome",
"USE_POD_SANDBOX": false,
"DISABLE_HOOKS": false,
"UPLOAD_PLAYGROUND_FILES_ENDPOINT": "https://play.nativescript.org/api/files" ,
"SHORTEN_URL_ENDPOINT": "https://play.nativescript.org/api/shortenurl?longUrl=%s"
"UPLOAD_PLAYGROUND_FILES_ENDPOINT": "https://play.nativescript.org/api/files",
"SHORTEN_URL_ENDPOINT": "https://play.nativescript.org/api/shortenurl?longUrl=%s",
"PREVIEW_APP_ENVIRONMENT": "live"
}
1 change: 1 addition & 0 deletions lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export class Configuration extends ConfigBase implements IConfiguration { // Use
USE_POD_SANDBOX: boolean = false;
UPLOAD_PLAYGROUND_FILES_ENDPOINT: string = null;
SHORTEN_URL_ENDPOINT: string = null;
PREVIEW_APP_ENVIRONMENT: string = null;

/*don't require logger and everything that has logger as dependency in config.js due to cyclic dependency*/
constructor(protected $fs: IFileSystem) {
Expand Down
1 change: 1 addition & 0 deletions lib/declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ interface IConfiguration extends Config.IConfig {
USE_POD_SANDBOX: boolean;
UPLOAD_PLAYGROUND_FILES_ENDPOINT: string;
SHORTEN_URL_ENDPOINT: string;
PREVIEW_APP_ENVIRONMENT: string;
}

interface IApplicationPackage {
Expand Down
2 changes: 1 addition & 1 deletion lib/services/livesync/livesync-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
let deviceDescriptorsForInitialSync: ILiveSyncDeviceInfo[] = [];

if (liveSyncData.syncToPreviewApp) {
this.$previewAppLiveSyncService.initialize({
await this.$previewAppLiveSyncService.initialize({
appFilesUpdaterOptions: {
bundle: liveSyncData.bundle,
release: liveSyncData.release,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export class PreviewAppLiveSyncService implements IPreviewAppLiveSyncService {
private $projectFilesManager: IProjectFilesManager,
private $projectFilesProvider: IProjectFilesProvider) { }

public initialize(data: IPreviewAppLiveSyncData) {
this.$previewSdkService.initialize(async (device: Device) => {
public async initialize(data: IPreviewAppLiveSyncData): Promise<void> {
await this.$previewSdkService.initialize(async (device: Device) => {
if (!device) {
this.$errors.failWithoutHelp("Sending initial preview files without a specified device is not supported.");
}
Expand Down
6 changes: 4 additions & 2 deletions lib/services/livesync/playground/preview-sdk-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ export class PreviewSdkService implements IPreviewSdkService {
return `nsplay://boot?instanceId=${this.instanceId}&pKey=${PubnubKeys.PUBLISH_KEY}&sKey=${PubnubKeys.SUBSCRIBE_KEY}&template=play-ng&hmr=${hmrValue}`;
}

public initialize(getInitialFiles: (device: Device) => Promise<FilesPayload>): void {
public async initialize(getInitialFiles: (device: Device) => Promise<FilesPayload>): Promise<void> {
const initConfig = this.getInitConfig(getInitialFiles);
this.messagingService = new MessagingService();
this.instanceId = this.messagingService.initialize(initConfig);
this.instanceId = await this.messagingService.initialize(initConfig);
}

public applyChanges(filesPayload: FilesPayload): Promise<void> {
Expand All @@ -43,6 +43,8 @@ export class PreviewSdkService implements IPreviewSdkService {
return {
pubnubPublishKey: PubnubKeys.PUBLISH_KEY,
pubnubSubscribeKey: PubnubKeys.SUBSCRIBE_KEY,
msvKey: "cli",
msvEnv: this.$config.PREVIEW_APP_ENVIRONMENT,
callbacks: this.getCallbacks(),
getInitialFiles
};
Expand Down
43 changes: 40 additions & 3 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"mkdirp": "0.5.1",
"mute-stream": "0.0.5",
"nativescript-doctor": "1.3.0",
"nativescript-preview-sdk": "0.2.9",
"nativescript-preview-sdk": "0.2.11",
"open": "0.0.5",
"ora": "2.0.0",
"osenv": "0.1.3",
Expand Down