preface
The company adopts UNI-App development for all small program projects. Build package should be made before release, and then open the production environment project in the wechat developer tool before uploading.
This version has to be operated in wechat developer tools every time, and it is necessary to bear the slow loading of wechat developer tools.
An overview of the
Miniprogram-ci is a compilation module of small program/small game project code extracted from wechat developer tools.
Developers do not need to open the small program developer tool, and independently use miniprogram-CI to upload and preview the small program code.
Miniprogram-ci currently offers the following capabilities:
- Upload code, corresponding to the small program developer tool upload
- Preview code, corresponding to the applets developer tool preview
- build
npm
, corresponding to the applets developer tools: menu-Tools-Buildnpm
- Upload cloud development cloud function code, corresponding to the applets developer tool upload cloud function capability
- Upload cloud managed code, corresponding to the applets developer tools upload cloud hosting capabilities
- Upload cloud storage/statically managed files, corresponding to the applets developer tool – Cloud development – Cloud storage and statically managed file management
- Proxy, configuration
miniprogram-ci
Network request proxy- Supports obtaining the latest uploaded version
sourceMap
- support
node
Script invocation and command line invocation
The preparatory work
-
Go to “wechat public Platform – development – Development Settings” to download the code to upload the key, and configure the IP whitelist.
Developers can choose to enable the IP address whitelist. Only IP addresses in the whitelist can be invoked. Turn it off and all IP addresses can be called.
-
Place the downloaded secret key in the project root directory
Install miniprogram – ci
npm install miniprogram-ci --save
Copy the code
Writing upload scripts
// miniprogram-pro-upload.js const dayjs = require('dayjs'); const ci = require('miniprogram-ci'); (async () => {const project = new ci.project ({appId: 'miniProgram', // appId type: 'miniProgram', projectPath: 'dist/build/mp-weixin', // package path privateKeyPath: 'pro.key', // key path}); Const uploadResult = await ci.upload({project, version: '1.5.6', // version desc: Format ('YYYY-MM-DD HH: MM :ss')} ', // Custom remarks Setting: {ES6: true,}, onProgressUpdate: console.log,}); console.log(uploadResult); }) ();Copy the code
The script uses dayJS in addition to note the code upload time, which can be modified
npm install dayjs
Copy the code
Upload experience version
node ./miniprogram-pro-upload.js
Copy the code
If the following information is displayed after the upload is complete, the upload is successful
Setting experience version
Select the version submitted by CI Robot 1 in “wechat Public Platform – Management – Version Management” or “Small Program Assistant – Audit Management – Development version” and set it as the experience version
This step only needs to be performed once. If the CI robot is replaced later, select the corresponding development version and set it as the experience version
The resources
Wechat official documents/development assistance/CI