You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 20, 2025. It is now read-only.
UPDATE: Over the next few months, we will be working on a new version of CodePush that will address some of the most common performance issues our customers are facing. This updated version will allow a better experience, our team to better support CodePush moving forward and have a faster development cycle for new features.
1
+
UPDATE: Over the next few months, we will be working on a new version of CodePush that will address some of the most common performance issues our customers are facing. This updated version will allow a better experience, our team to better support CodePush moving forward and have a faster development cycle for new features.
2
2
We are prioritizing this work because we believe this to be the most valuable thing we can do for our CodePush customers in the long run. Starting June 11th 2019, support will slow down, bug fixes will be limited to critical bugs, and new feature development will pause until we finish this core update.
#### [Sign up With App Center](https://appcenter.ms/signup?utm_source=CodePush&utm_medium=Azure) to use CodePush
9
9
10
10
# CodePush
11
11
12
-
[CodePush](https://microsoft.github.io/code-push) is a cloud service that enables Cordova and React Native developers to deploy mobile app updates directly to their users' devices. It works by acting as a central repository that developers can publish updates to (JS, HTML, CSS and images), and that apps can query for updates from (using provided client SDKs for [Cordova](https://github.com/Microsoft/cordova-plugin-code-push) and [React Native](https://github.com/Microsoft/react-native-code-push)). This allows you to have a more deterministic and direct engagement model with your userbase, when addressing bugs and/or adding small features that don't require you to re-build a binary and re-distribute it through the respective app stores.
12
+
[CodePush](https://microsoft.github.io/code-push) is a cloud service that enables Cordova and React Native developers to deploy mobile app updates directly to their users' devices. It works by acting as a central repository that developers can publish updates to (JS, HTML, CSS and images), and that apps can query for updates from (using provided client SDK for [Cordova](https://github.com/Microsoft/cordova-plugin-code-push) and [React Native](https://github.com/Microsoft/react-native-code-push)). This allows you to have a more deterministic and direct engagement model with your userbase, when addressing bugs and/or adding small features that don't require you to re-build a binary and re-distribute it through the respective app stores.
13
13
14
-
This repo includes the [management CLI](https://github.com/Microsoft/code-push/tree/master/cli) and [Node.js management SDK](https://github.com/Microsoft/code-push/tree/master/sdk), which allows you to manage and automate the needs of your Cordova and React Native apps. To get started using CodePush, refer to our [documentation](https://docs.microsoft.com/en-us/appcenter/distribution/codepush/), otherwise, read the following steps if you'd like to build/contribute to the project from source.
14
+
To get started using CodePush, refer to our [documentation](https://docs.microsoft.com/en-us/appcenter/distribution/codepush/), otherwise, read the following steps if you'd like to build/contribute to the project from source.
15
+
16
+
*NOTE: If you need information about [code-push management CLI](https://github.com/microsoft/code-push/tree/v3.0.1/cli), you can find it in v3.0.1.*
* Clone the Repository: `git clone https://github.com/Microsoft/code-push.git`
22
23
23
24
### Building
24
25
25
-
* Run `npm install` from the root of the repository.
26
-
* Run `gulp install` to install the NPM dependencies of each module within the project.
27
-
* Run `gulp link` to link CLI and SDK for local development. It is advisable to do this step if you are making changes to the SDK and want the CLI to pick those changes.
28
-
* Run `gulp build` to build all of the modules. To build just one of the modules (e.g. cli or sdk), run `gulp build-cli` or `gulp build-sdk`.
26
+
* Run `npm run setup` to install the NPM dependencies of management SDK.
27
+
* Run `npm run build` to build the management SDK for testing.
28
+
* Run `npm run build:release` to build the release version of management SDK.
29
29
30
30
### Running Tests
31
31
32
-
To run all tests, run `gulp test` script from the root of the project.
33
-
34
-
To test just one of the projects (e.g. cli or sdk), run `gulp test-cli` or `gulp test-sdk`
32
+
* To run tests, run `npm run test` from the root of the project.
33
+
* You can use debug mode for tests with `.vscode/launch.json` file.
35
34
36
35
### Coding Conventions
37
36
@@ -40,3 +39,114 @@ To test just one of the projects (e.g. cli or sdk), run `gulp test-cli` or `gulp
40
39
* Use `camelCase` for local variables and imported modules, `PascalCase` for types, and `dash-case` for file names
41
40
42
41
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
42
+
43
+
# CodePush Management SDK (Node.js)
44
+
45
+
A JavaScript library for programmatically managing your CodePush account (e.g. creating apps, promoting releases), which allows authoring Node.js-based build and/or deployment scripts, without needing to shell out to the [App Center CLI](https://github.com/microsoft/appcenter-cli).
46
+
47
+
## Getting Started
48
+
49
+
1. Create a token to authenticate with the CodePush server using the following [App Center CLI](https://github.com/microsoft/appcenter-cli) command:
Please copy your `API Token` and keep it secret. You won't be able to see it again.
56
+
57
+
2. Install the management SDK by running `npm install code-push --save`
58
+
59
+
3. Import it using one of the following statement: (using ES6 syntax as applicable):
60
+
* On commonjs environments:
61
+
62
+
```javascript
63
+
const CodePush = require("code-push");
64
+
```
65
+
66
+
* Using ES6 syntax with tsconfig.json:
67
+
68
+
```javascript
69
+
import CodePush from "code-push";
70
+
```
71
+
72
+
4. Create an instance of the `CodePush` class, passing it the `API Token` you created or retrieved in step #1:
73
+
74
+
```javascript
75
+
const codePush = new CodePush("YOUR_API_TOKEN");
76
+
```
77
+
78
+
5. Begin automating the management of your account! For more details on what you can do with this `codePush` object, refer to the API reference section below.
79
+
80
+
## API Reference
81
+
82
+
The `code-push` module exports a single class (typically referred to as `CodePush`), which represents a proxy to the CodePush account management REST API. This class has a single constructor for authenticating with the CodePush service, and a collection of instance methods that correspond to the commands in the [App Center CLI](https://github.com/microsoft/appcenter-cli), which allow you to programmatically control every aspect of your CodePush account.
83
+
84
+
### Constructors
85
+
86
+
* __CodePush(accessKey: string)__ - Creates a new instance of the CodePush management SDK, using the specified access key to authenticated with the server.
87
+
88
+
### Methods
89
+
90
+
*Note: `access key` here refers to an AppCenter API Token.*
91
+
92
+
* __addAccessKey(description: string): Promise<AccessKey>__ - Creates a new access key with the specified description (e.g. "VSTS CI").
93
+
94
+
* __addApp(name: string, os: string, platform: string, manuallyProvisionDeployments: boolean = false): Promise<App>__ - Creates a new CodePush app with the specified name, os, and platform. If the default deployments of "Staging" and "Production" are not desired, pass a value of true for the manuallyProvisionDeployments parameter.
95
+
96
+
* __addCollaborator(appName: string, email: string): Promise<void>__ - Adds the specified CodePush user as a collaborator to the specified CodePush app.
97
+
98
+
* __addDeployment(appName: string, deploymentName: string): Promise<Deployment>__ - Creates a new deployment with the specified name, and associated with the specified app.
99
+
100
+
* __clearDeploymentHistory(appName: string, deploymentName: string): Promise<void>__ - Clears the release history associated with the specified app deployment.
101
+
102
+
* __getAccessKey(accessKey: string): Promise<AccessKey>__ - Retrieves the metadata about the specific access key.
103
+
104
+
* __getAccessKeys(): Promise<AccessKey[]>__ - Retrieves the list of access keys associated with your CodePush account.
105
+
106
+
* __getApp(appName: string): Promise<App>__ - Retrieves the metadata about the specified app.
107
+
108
+
* __getApps(): Promise<App[]>__ - Retrieves the list of apps associated with your CodePush account.
109
+
110
+
* __getCollaborators(appName: string): Promise<CollaboratorMap>__ - Retrieves the list of collaborators associated with the specified app.
111
+
112
+
* __getDeployment(appName: string, deploymentName: string): Promise<Deployment>__ - Retrieves the metadata for the specified app deployment.
113
+
114
+
* __getDeploymentHistory(appName: string, deploymentName: string): Promise<Package[]>__ - Retrieves the list of releases that have been made to the specified app deployment.
115
+
116
+
* __getDeploymentMetrics(appName: string, deploymentName: string): Promise<DeploymentMetrics>__ - Retrieves the installation metrics for the specified app deployment.
117
+
118
+
* __getDeployments(appName: string): Promise<Deployment[]>__ - Retrieves the list of deployments associated with the specified app.
119
+
120
+
* __patchRelease(appName: string, deploymentName: string, label: string, updateMetadata: PackageInfo): Promise<void>__ - Updates the specified release's metadata with the given information.
121
+
122
+
* __promote(appName: string, sourceDeploymentName: string, destinationDeploymentName: string, updateMetadata: PackageInfo): Promise<Package>__ - Promotes the latest release from one deployment to another for the specified app and updates the release with the given metadata.
123
+
124
+
* __release(appName: string, deploymentName: string, updateContentsPath: string, targetBinaryVersion: string, updateMetadata: PackageInfo): Promise<Package>__ - Releases a new update to the specified deployment with the given metadata.
125
+
126
+
* __removeAccessKey(accessKey: string): Promise<void>__ - Removes the specified access key from your CodePush account.
127
+
128
+
* __removeApp(appName: string): Promise<void>__ - Deletes the specified CodePush app from your account.
129
+
130
+
* __removeCollaborator(appName: string, email: string): Promise<void>__ - Removes the specified account as a collaborator from the specified app.
131
+
132
+
* __removeDeployment(appName: string, deploymentName: string): Promise<void>__ - Removes the specified deployment from the specified app.
* __renameDeployment(appName: string, oldDeploymentName: string, newDeploymentName: string): Promise<void>__ - Renames an existing deployment within the specified app.
137
+
138
+
* __rollback(appName: string, deploymentName: string, targetRelease?: string): Promise<void>__ - Rolls back the latest release within the specified deployment. Optionally allows you to target a specific release in the deployment's history, as opposed to rolling to the previous release.
139
+
140
+
* __transferApp(appName: string, email: string): Promise<void>__ - Transfers the ownership of the specified app to the specified account.
141
+
142
+
### Error Handling
143
+
144
+
When an error occurs in any of the methods, the promise will be rejected with a CodePushError object with the following properties:
145
+
146
+
* __message__: A user-friendly message that describes the error.
147
+
* __statusCode__: An HTTP response code that identifies the category of error:
148
+
* __CodePush.ERROR_GATEWAY_TIMEOUT__: A network error prevented you from connecting to the CodePush server.
149
+
* __CodePush.ERROR_INTERNAL_SERVER__: An error occurred internally on the CodePush server.
150
+
* __CodePush.ERROR_NOT_FOUND__: The resource you are attempting to retrieve does not exist.
151
+
* __CodePush.ERROR_CONFLICT__: The resource you are attempting to create already exists.
152
+
* __CodePush.ERROR_UNAUTHORIZED__: The access key you configured is invalid or expired.
0 commit comments