Skip to content

Commit dc938b2

Browse files
committed
Rename deploymentKey to releaseChannelPublicId for clarity
1 parent 1871dec commit dc938b2

38 files changed

+360
-378
lines changed

CodePush.js

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@ import hoistStatics from 'hoist-non-react-statics';
88
let NativeCodePush = require("react-native").NativeModules.CodePush;
99
const PackageMixins = require("./package-mixins")(NativeCodePush);
1010

11-
async function checkForUpdate(deploymentKey = null, handleBinaryVersionMismatchCallback = null) {
11+
async function checkForUpdate(releaseChannelPublicId = null, handleBinaryVersionMismatchCallback = null) {
1212
/*
1313
* Before we ask the server if an update exists, we
1414
* need to retrieve three pieces of information from the
15-
* native side: deployment key, app version (e.g. 1.0.1)
15+
* native side: release channel, app version (e.g. 1.0.1)
1616
* and the hash of the currently running update (if there is one).
1717
* This allows the client to only receive updates which are targetted
18-
* for their specific deployment and version and which are actually
18+
* for their specific release channel and version and which are actually
1919
* different from the CodePush update they have already installed.
2020
*/
2121
const nativeConfig = await getConfiguration();
2222
/*
23-
* If a deployment key was explicitly provided,
23+
* If a release channel was explicitly provided,
2424
* then let's override the one we retrieved
2525
* from the native-side of the app. This allows
2626
* dynamically "redirecting" end-users at different
27-
* deployments (e.g. an early access deployment for insiders).
27+
* release channels (e.g. an early access release channel for insiders).
2828
*/
29-
const config = deploymentKey ? { ...nativeConfig, ...{ deploymentKey } } : nativeConfig;
29+
const config = releaseChannelPublicId ? { ...nativeConfig, ...{ releaseChannelPublicId } } : nativeConfig;
3030
const sdk = getPromisifiedSdk(requestFetchAdapter, config);
3131

3232
// Use dynamically overridden getCurrentPackage() during tests.
@@ -84,7 +84,7 @@ async function checkForUpdate(deploymentKey = null, handleBinaryVersionMismatchC
8484
} else {
8585
const remotePackage = { ...update, ...PackageMixins.remote(sdk.reportStatusDownload) };
8686
remotePackage.failedInstall = await NativeCodePush.isFailedUpdate(remotePackage.packageHash);
87-
remotePackage.deploymentKey = deploymentKey || nativeConfig.deploymentKey;
87+
remotePackage.releaseChannelPublicId = releaseChannelPublicId || nativeConfig.releaseChannelPublicId;
8888
return remotePackage;
8989
}
9090
}
@@ -118,6 +118,9 @@ async function getUpdateMetadata(updateState) {
118118
}
119119

120120
function getPromisifiedSdk(requestFetchAdapter, config) {
121+
// TODO MIGRATION Temporary retro-compat while we still use code-push module
122+
config.deploymentKey = config.releaseChannelPublicId;
123+
121124
// Use dynamically overridden AcquisitionSdk during tests.
122125
const sdk = new module.exports.AcquisitionSdk(requestFetchAdapter, config);
123126
sdk.queryUpdateWithCurrentPackage = (queryPackage) => {
@@ -132,9 +135,9 @@ function getPromisifiedSdk(requestFetchAdapter, config) {
132135
});
133136
};
134137

135-
sdk.reportStatusDeploy = (deployedPackage, status, previousLabelOrAppVersion, previousDeploymentKey) => {
138+
sdk.reportStatusDeploy = (deployedPackage, status, previousLabelOrAppVersion, previousReleaseChannelPublicId) => {
136139
return new Promise((resolve, reject) => {
137-
module.exports.AcquisitionSdk.prototype.reportStatusDeploy.call(sdk, deployedPackage, status, previousLabelOrAppVersion, previousDeploymentKey, (err) => {
140+
module.exports.AcquisitionSdk.prototype.reportStatusDeploy.call(sdk, deployedPackage, status, previousLabelOrAppVersion, previousReleaseChannelPublicId, (err) => {
138141
if (err) {
139142
reject(err);
140143
} else {
@@ -183,17 +186,17 @@ async function notifyApplicationReadyInternal() {
183186
async function tryReportStatus(statusReport, retryOnAppResume) {
184187
const config = await getConfiguration();
185188
const previousLabelOrAppVersion = statusReport.previousLabelOrAppVersion;
186-
const previousDeploymentKey = statusReport.previousDeploymentKey || config.deploymentKey;
189+
const previousReleaseChannelPublicId = statusReport.previousReleaseChannelPublicId || config.releaseChannelPublicId;
187190
try {
188191
if (statusReport.appVersion) {
189192
log(`Reporting binary update (${statusReport.appVersion})`);
190193

191-
if (!config.deploymentKey) {
192-
throw new Error("Deployment key is missed");
194+
if (!config.releaseChannelPublicId) {
195+
throw new Error("Release channel is missing");
193196
}
194197

195198
const sdk = getPromisifiedSdk(requestFetchAdapter, config);
196-
await sdk.reportStatusDeploy(/* deployedPackage */ null, /* status */ null, previousLabelOrAppVersion, previousDeploymentKey);
199+
await sdk.reportStatusDeploy(/* deployedPackage */ null, /* status */ null, previousLabelOrAppVersion, previousReleaseChannelPublicId);
197200
} else {
198201
const label = statusReport.package.label;
199202
if (statusReport.status === "DeploymentSucceeded") {
@@ -203,9 +206,9 @@ async function tryReportStatus(statusReport, retryOnAppResume) {
203206
await NativeCodePush.setLatestRollbackInfo(statusReport.package.packageHash);
204207
}
205208

206-
config.deploymentKey = statusReport.package.deploymentKey;
209+
config.releaseChannelPublicId = statusReport.package.releaseChannelPublicId;
207210
const sdk = getPromisifiedSdk(requestFetchAdapter, config);
208-
await sdk.reportStatusDeploy(statusReport.package, statusReport.status, previousLabelOrAppVersion, previousDeploymentKey);
211+
await sdk.reportStatusDeploy(statusReport.package, statusReport.status, previousLabelOrAppVersion, previousReleaseChannelPublicId);
209212
}
210213

211214
NativeCodePush.recordStatusReported(statusReport);
@@ -363,7 +366,7 @@ const sync = (() => {
363366
async function syncInternal(options = {}, syncStatusChangeCallback, downloadProgressCallback, handleBinaryVersionMismatchCallback) {
364367
let resolvedInstallMode;
365368
const syncOptions = {
366-
deploymentKey: null,
369+
releaseChannelPublicId: null,
367370
ignoreFailedUpdates: true,
368371
rollbackRetryOptions: null,
369372
installMode: CodePush.InstallMode.ON_NEXT_RESTART,
@@ -416,7 +419,7 @@ async function syncInternal(options = {}, syncStatusChangeCallback, downloadProg
416419
await CodePush.notifyApplicationReady();
417420

418421
syncStatusChangeCallback(CodePush.SyncStatus.CHECKING_FOR_UPDATE);
419-
const remotePackage = await checkForUpdate(syncOptions.deploymentKey, handleBinaryVersionMismatchCallback);
422+
const remotePackage = await checkForUpdate(syncOptions.releaseChannelPublicId, handleBinaryVersionMismatchCallback);
420423

421424
const doDownloadAndInstall = async () => {
422425
syncStatusChangeCallback(CodePush.SyncStatus.DOWNLOADING_PACKAGE);
@@ -479,8 +482,8 @@ async function syncInternal(options = {}, syncStatusChangeCallback, downloadProg
479482
}
480483
});
481484
}
482-
483-
// Since the install button should be placed to the
485+
486+
// Since the install button should be placed to the
484487
// right of any other button, add it last
485488
dialogButtons.push({
486489
text: installButtonText,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<resources>
2-
<string moduleConfig="true" name="CodePushDeploymentKey">deployment-key-here</string>
2+
<string moduleConfig="true" name="CodePushReleaseChannelPublicId">release-channel-public-id-here</string>
33
<string name="app_name">CodePushDemoApp</string>
44
</resources>

Examples/CodePushDemoApp/ios/CodePushDemoApp/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
</array>
5252
<key>UIViewControllerBasedStatusBarAppearance</key>
5353
<false/>
54-
<key>CodePushDeploymentKey</key>
55-
<string>deployment-key-here</string>
54+
<key>CodePushReleaseChannelPublicId</key>
55+
<string>release-channel-public-id-here</string>
5656
</dict>
5757
</plist>

Examples/CodePushDemoAppCpp/windows/CodePushDemoAppCpp/App.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ App::App() noexcept
5656
m_host.InstanceSettings().PackageProviders().Append(make<ReactPackageProvider>()); // Includes all modules in this project
5757

5858
InitializeComponent();
59-
59+
6060
Suspending({ this, &App::OnSuspending });
6161

6262
#if defined _DEBUG && !defined DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
@@ -81,7 +81,7 @@ void App::OnLaunched(activation::LaunchActivatedEventArgs const& e)
8181
winrt::Microsoft::CodePush::ReactNative::CodePushConfig::SetHost(Host());
8282
auto configMap{ winrt::single_threaded_map<hstring, hstring>() };
8383
configMap.Insert(L"appVersion", L"1.0.0");
84-
configMap.Insert(L"deploymentKey", L"<app deployment key>");
84+
configMap.Insert(L"releaseChannelPublicId", L"<app release channel public id>");
8585
winrt::Microsoft::CodePush::ReactNative::CodePushConfig::Init(configMap);
8686

8787
Frame rootFrame{ nullptr };

Examples/create-app.js

Lines changed: 26 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ console.log(`App name: ${appName}`);
6161
console.log(`React Native version: ${reactNativeVersion}`);
6262
console.log(`React Native Module for CodePush version: ${reactNativeCodePushVersion} \n`);
6363

64-
let androidStagingDeploymentKey = null;
65-
let iosStagingDeploymentKey = null;
64+
let androidStagingReleaseChannelPublicId = null;
65+
let iosStagingReleaseChannelPublicId = null;
6666

6767

6868

@@ -73,45 +73,47 @@ createCodePushApp(appNameIOS, 'iOS');
7373
generatePlainReactNativeApp(appName, reactNativeVersion);
7474
process.chdir(appName);
7575
installCodePush(reactNativeCodePushVersion);
76-
linkCodePush(androidStagingDeploymentKey, iosStagingDeploymentKey);
76+
linkCodePush();
7777
//GENERATE END
7878

7979

8080

8181
function createCodePushApp(name, os) {
8282
try {
83+
// TODO MIGRATION
8384
console.log(`Creating CodePush app "${name}" to release updates for ${os}...`);
8485
try {
85-
const appResult = execCommand(`appcenter apps create -d ${name} -n ${name} -o ${os} -p React-Native --output json`);
86+
const appResult = execCommand(`appzung applications create -d ${name} -n ${name} -o ${os} -p React-Native --output json`);
8687
const app = JSON.parse(appResult);
8788
owner = app.owner.name;
8889
console.log(`App "${name}" has been created \n`);
8990
} catch (e) {
9091
console.error(`Error: Unable to create CodePush app. Please check that you haven't application with "${name}" name on portal.`,);
9192
console.error("Error: ", e.toString());
9293
}
93-
execCommand(`appcenter codepush deployment add -a ${owner}/${name} Staging`);
94+
execCommand(`appzung releases-channels create`); // TODO MIGRATION
9495
} catch (e) {
9596
console.error("Error", e.toString());
9697
}
9798

9899
try {
99-
const deploymentKeysResult = execCommand(`appcenter codepush deployment list -a ${owner}/${name} -k --output json`);
100-
const deploymentKeys = JSON.parse(deploymentKeysResult);
101-
const stagingDeploymentKey = deploymentKeys[0][1];
102-
console.log(`Deployment key for ${os}: ${stagingDeploymentKey}`);
103-
console.log(`Use "appcenter codepush release-react ${owner}/${name}" command to release updates for ${os} \n`);
100+
// TODO MIGRATION
101+
const releaseChannelPublicIdsResult = execCommand(`appzung release-channels list --output json`);
102+
const releaseChannelPublicIds = JSON.parse(releaseChannelPublicIdsResult);
103+
const stagingReleaseChannelPublicId = releaseChannelPublicIds[0][1];
104+
console.log(`Release channel public ID for ${os}: ${stagingReleaseChannelPublicId}`);
105+
console.log(`Use "appzung releases deploy-react-native" command to release updates for ${os} \n`);
104106

105107
switch (os) {
106108
case 'Android':
107-
androidStagingDeploymentKey = stagingDeploymentKey;
109+
androidStagingReleaseChannelPublicId = stagingReleaseChannelPublicId;
108110
break;
109111
case 'iOS':
110-
iosStagingDeploymentKey = stagingDeploymentKey;
112+
iosStagingReleaseChannelPublicId = stagingReleaseChannelPublicId;
111113
break;
112114
}
113115
} catch (e) {
114-
console.error("Error: Unable to load deployment keys");
116+
console.error("Error: Unable to load release channels");
115117
console.error("Error: ", e.toString());
116118
}
117119

@@ -129,33 +131,16 @@ function installCodePush(reactNativeCodePushVersion) {
129131
console.log(`React Native Module for CodePush has been installed \n`);
130132
}
131133

132-
function linkCodePush(androidStagingDeploymentKey, iosStagingDeploymentKey) {
134+
function linkCodePush() {
133135
console.log(`Linking React Native Module for CodePush...`);
134-
if (isReactNativeVersionLowerThan(60)) {
135-
nexpect.spawn(`react-native link react-native-code-push`)
136-
.wait("What is your CodePush deployment key for Android (hit <ENTER> to ignore)")
137-
.sendline(androidStagingDeploymentKey)
138-
.wait("What is your CodePush deployment key for iOS (hit <ENTER> to ignore)")
139-
.sendline(iosStagingDeploymentKey)
140-
.run(function (err) {
141-
if (!err) {
142-
console.log(`React Native Module for CodePush has been linked \n`);
143-
setupAssets();
144-
}
145-
else {
146-
console.log(err);
147-
}
148-
});
136+
androidSetup();
137+
if (process.platform === 'darwin') {
138+
iosSetup();
149139
} else {
150-
androidSetup();
151-
if (process.platform === 'darwin') {
152-
iosSetup();
153-
} else {
154-
console.log('Your OS is not "Mac OS" so the iOS application will not be configured')
155-
}
156-
setupAssets();
157-
console.log(`React Native Module for CodePush has been linked \n`);
140+
console.log('Your OS is not "Mac OS" so the iOS application will not be configured')
158141
}
142+
setupAssets();
143+
console.log(`React Native Module for CodePush has been linked \n`);
159144
}
160145

161146
function setupAssets() {
@@ -198,15 +183,6 @@ function setupAssets() {
198183

199184
function optimizeToTestInDebugMode() {
200185
const rnXcodeShLocationFolder = 'scripts';
201-
try {
202-
const rnVersions = JSON.parse(execCommand(`npm view react-native versions --json`));
203-
const currentRNversion = JSON.parse(fs.readFileSync('./package.json'))['dependencies']['react-native'];
204-
if (rnVersions.indexOf(currentRNversion) > -1 &&
205-
rnVersions.indexOf(currentRNversion) < rnVersions.indexOf("0.46.0-rc.0")) {
206-
rnXcodeShLocationFolder = 'packager';
207-
}
208-
} catch (e) { }
209-
210186
const rnXcodeShPath = `node_modules/react-native/${rnXcodeShLocationFolder}/react-native-xcode.sh`;
211187
// Replace "if [[ "$PLATFORM_NAME" == *simulator ]]; then" with "if false; then" to force bundling
212188
execCommand(`sed -ie 's/if \\[\\[ "\$PLATFORM_NAME" == \\*simulator \\]\\]; then/if false; then/' ${rnXcodeShPath}`);
@@ -253,8 +229,8 @@ function androidSetup() {
253229

254230
let stringsResourcesContent = fs.readFileSync(stringsResourcesPath, "utf8");
255231
const insertAfterString = "<resources>";
256-
const deploymentKeyString = `\t<string moduleConfig="true" name="CodePushDeploymentKey">${androidStagingDeploymentKey || "deployment-key-here"}</string>`;
257-
stringsResourcesContent = stringsResourcesContent.replace(insertAfterString, `${insertAfterString}\n${deploymentKeyString}`);
232+
const releaseChannelPublicIdString = `\t<string moduleConfig="true" name="CodePushReleaseChannelPublicId">${androidStagingReleaseChannelPublicId || "release-channel-public-id-here"}</string>`;
233+
stringsResourcesContent = stringsResourcesContent.replace(insertAfterString, `${insertAfterString}\n${releaseChannelPublicIdString}`);
258234
fs.writeFileSync(stringsResourcesPath, stringsResourcesContent);
259235

260236
let buildGradleContents = fs.readFileSync(buildGradlePath, "utf8");
@@ -327,9 +303,9 @@ function iosSetup() {
327303

328304
const dictPlistTag = `</dict>\n</plist>`;
329305

330-
const codePushDeploymentKey = iosStagingDeploymentKey || 'deployment-key-here';
306+
const codePushReleaseChannelPublicId = iosStagingReleaseChannelPublicId || 'release-channel-public-id-here';
331307
plistContents = plistContents.replace(dictPlistTag,
332-
`\t<key>CodePushDeploymentKey</key>\n\t<string>${codePushDeploymentKey}</string>${dictPlistTag}`);
308+
`\t<key>CodePushReleaseChannelPublicId</key>\n\t<string>${codePushReleaseChannelPublicId}</string>${dictPlistTag}`);
333309
fs.writeFileSync(plistPath, plistContents);
334310

335311
let appDelegateContents = fs.readFileSync(appDelegatePath, "utf8");

0 commit comments

Comments
 (0)