mirror of
https://gitcode.com/github-mirrors/react-native-update-cli.git
synced 2025-12-16 10:22:34 +08:00
Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e4b50b5e46 | ||
|
|
eb1468099b | ||
|
|
7259efbd7d | ||
|
|
cf679715a5 | ||
|
|
ebd6d36b30 | ||
|
|
818907f811 | ||
|
|
6751daf8e0 | ||
|
|
b973ace443 | ||
|
|
e81744b52a | ||
|
|
89da1e5238 | ||
|
|
603e2adf47 | ||
|
|
317975cdba | ||
|
|
f8edbb8083 | ||
|
|
15c8052459 | ||
|
|
c633af549d | ||
|
|
78159f362b | ||
|
|
b76440d018 | ||
|
|
e3c951bc1b | ||
|
|
f6ed8872bd | ||
|
|
fd46bafb98 | ||
|
|
917f99f2ab | ||
|
|
ac13464d4d | ||
|
|
f82bab887a | ||
|
|
07ff19fbe5 | ||
|
|
a4467717bc | ||
|
|
cd890347d1 | ||
|
|
e6de3eeef3 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -105,3 +105,6 @@ dist
|
|||||||
|
|
||||||
lib/
|
lib/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
# react-native-update
|
||||||
|
.update
|
||||||
|
.pushy
|
||||||
1
.swcrc
1
.swcrc
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"jsc": {
|
"jsc": {
|
||||||
|
"baseUrl": "./src",
|
||||||
"loose": true,
|
"loose": true,
|
||||||
"target": "es2018",
|
"target": "es2018",
|
||||||
"parser": {
|
"parser": {
|
||||||
|
|||||||
109
README.md
109
README.md
@@ -49,14 +49,14 @@ const provider = moduleManager.getProvider();
|
|||||||
const bundleResult = await provider.bundle({
|
const bundleResult = await provider.bundle({
|
||||||
platform: 'ios',
|
platform: 'ios',
|
||||||
dev: false,
|
dev: false,
|
||||||
sourcemap: true
|
sourcemap: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Publish version
|
// Publish version
|
||||||
const publishResult = await provider.publish({
|
const publishResult = await provider.publish({
|
||||||
name: 'v1.2.3',
|
name: 'v1.2.3',
|
||||||
description: 'Bug fixes and improvements',
|
description: 'Bug fixes and improvements',
|
||||||
rollout: 100
|
rollout: 100,
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -65,7 +65,11 @@ const publishResult = await provider.publish({
|
|||||||
### 1. Define Module
|
### 1. Define Module
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import type { CLIModule, CommandDefinition, CustomWorkflow } from 'react-native-update-cli';
|
import type {
|
||||||
|
CLIModule,
|
||||||
|
CommandDefinition,
|
||||||
|
CustomWorkflow,
|
||||||
|
} from 'react-native-update-cli';
|
||||||
|
|
||||||
export const myCustomModule: CLIModule = {
|
export const myCustomModule: CLIModule = {
|
||||||
name: 'my-custom',
|
name: 'my-custom',
|
||||||
@@ -79,13 +83,13 @@ export const myCustomModule: CLIModule = {
|
|||||||
console.log('Executing custom command...');
|
console.log('Executing custom command...');
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
data: { message: 'Custom command executed' }
|
data: { message: 'Custom command executed' },
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
param: { hasValue: true, description: 'Custom parameter' }
|
param: { hasValue: true, description: 'Custom parameter' },
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
workflows: [
|
workflows: [
|
||||||
@@ -99,7 +103,7 @@ export const myCustomModule: CLIModule = {
|
|||||||
execute: async (context, previousResult) => {
|
execute: async (context, previousResult) => {
|
||||||
console.log('Executing step 1...');
|
console.log('Executing step 1...');
|
||||||
return { step1Completed: true };
|
return { step1Completed: true };
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'step2',
|
name: 'step2',
|
||||||
@@ -107,10 +111,10 @@ export const myCustomModule: CLIModule = {
|
|||||||
execute: async (context, previousResult) => {
|
execute: async (context, previousResult) => {
|
||||||
console.log('Executing step 2...');
|
console.log('Executing step 2...');
|
||||||
return { ...previousResult, step2Completed: true };
|
return { ...previousResult, step2Completed: true };
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
init: (provider) => {
|
init: (provider) => {
|
||||||
@@ -119,7 +123,7 @@ export const myCustomModule: CLIModule = {
|
|||||||
|
|
||||||
cleanup: () => {
|
cleanup: () => {
|
||||||
console.log('Custom module cleanup');
|
console.log('Custom module cleanup');
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -135,13 +139,13 @@ moduleManager.registerModule(myCustomModule);
|
|||||||
// Execute custom command
|
// Execute custom command
|
||||||
const result = await moduleManager.executeCommand('custom-command', {
|
const result = await moduleManager.executeCommand('custom-command', {
|
||||||
args: [],
|
args: [],
|
||||||
options: { param: 'value' }
|
options: { param: 'value' },
|
||||||
});
|
});
|
||||||
|
|
||||||
// Execute custom workflow
|
// Execute custom workflow
|
||||||
const workflowResult = await moduleManager.executeWorkflow('my-workflow', {
|
const workflowResult = await moduleManager.executeWorkflow('my-workflow', {
|
||||||
args: [],
|
args: [],
|
||||||
options: {}
|
options: {},
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -191,6 +195,7 @@ Each workflow step contains:
|
|||||||
## 📋 Built-in Modules
|
## 📋 Built-in Modules
|
||||||
|
|
||||||
### Bundle Module (`bundle`)
|
### Bundle Module (`bundle`)
|
||||||
|
|
||||||
- `bundle`: Bundle JavaScript code and optionally publish
|
- `bundle`: Bundle JavaScript code and optionally publish
|
||||||
- `diff`: Generate differences between two PPK files
|
- `diff`: Generate differences between two PPK files
|
||||||
- `hdiff`: Generate hdiff between two PPK files
|
- `hdiff`: Generate hdiff between two PPK files
|
||||||
@@ -201,27 +206,31 @@ Each workflow step contains:
|
|||||||
- `hdiffFromIpa`: Generate hdiff from IPA files
|
- `hdiffFromIpa`: Generate hdiff from IPA files
|
||||||
|
|
||||||
### Version Module (`version`)
|
### Version Module (`version`)
|
||||||
|
|
||||||
- `publish`: Publish new version
|
- `publish`: Publish new version
|
||||||
- `versions`: List all versions
|
- `versions`: List all versions
|
||||||
- `update`: Update version information
|
- `update`: Update version information
|
||||||
- `updateVersionInfo`: Update version metadata
|
- `updateVersionInfo`: Update version metadata
|
||||||
|
|
||||||
### App Module (`app`)
|
### App Module (`app`)
|
||||||
|
|
||||||
- `createApp`: Create new application
|
- `createApp`: Create new application
|
||||||
- `apps`: List all applications
|
- `apps`: List all applications
|
||||||
- `selectApp`: Select application
|
- `selectApp`: Select application
|
||||||
- `deleteApp`: Delete application
|
- `deleteApp`: Delete application
|
||||||
|
|
||||||
### Package Module (`package`)
|
### Package Module (`package`)
|
||||||
- `uploadIpa`: Upload IPA files
|
|
||||||
- `uploadApk`: Upload APK files
|
- `uploadIpa`: Upload IPA files (supports `--version` to override extracted version)
|
||||||
- `uploadApp`: Upload APP files
|
- `uploadApk`: Upload APK files (supports `--version` to override extracted version)
|
||||||
|
- `uploadApp`: Upload APP files (supports `--version` to override extracted version)
|
||||||
- `parseApp`: Parse APP file information
|
- `parseApp`: Parse APP file information
|
||||||
- `parseIpa`: Parse IPA file information
|
- `parseIpa`: Parse IPA file information
|
||||||
- `parseApk`: Parse APK file information
|
- `parseApk`: Parse APK file information
|
||||||
- `packages`: List packages
|
- `packages`: List packages
|
||||||
|
|
||||||
### User Module (`user`)
|
### User Module (`user`)
|
||||||
|
|
||||||
- `login`: Login
|
- `login`: Login
|
||||||
- `logout`: Logout
|
- `logout`: Logout
|
||||||
- `me`: Show user information
|
- `me`: Show user information
|
||||||
@@ -242,14 +251,20 @@ interface CLIProvider {
|
|||||||
upload(options: UploadOptions): Promise<CommandResult>;
|
upload(options: UploadOptions): Promise<CommandResult>;
|
||||||
|
|
||||||
// Application management
|
// Application management
|
||||||
getSelectedApp(platform?: Platform): Promise<{ appId: string; platform: Platform }>;
|
getSelectedApp(
|
||||||
|
platform?: Platform,
|
||||||
|
): Promise<{ appId: string; platform: Platform }>;
|
||||||
listApps(platform?: Platform): Promise<CommandResult>;
|
listApps(platform?: Platform): Promise<CommandResult>;
|
||||||
createApp(name: string, platform: Platform): Promise<CommandResult>;
|
createApp(name: string, platform: Platform): Promise<CommandResult>;
|
||||||
|
|
||||||
// Version management
|
// Version management
|
||||||
listVersions(appId: string): Promise<CommandResult>;
|
listVersions(appId: string): Promise<CommandResult>;
|
||||||
getVersion(appId: string, versionId: string): Promise<CommandResult>;
|
getVersion(appId: string, versionId: string): Promise<CommandResult>;
|
||||||
updateVersion(appId: string, versionId: string, updates: Partial<Version>): Promise<CommandResult>;
|
updateVersion(
|
||||||
|
appId: string,
|
||||||
|
versionId: string,
|
||||||
|
updates: Partial<Version>,
|
||||||
|
): Promise<CommandResult>;
|
||||||
|
|
||||||
// Package management
|
// Package management
|
||||||
listPackages(appId: string, platform?: Platform): Promise<CommandResult>;
|
listPackages(appId: string, platform?: Platform): Promise<CommandResult>;
|
||||||
@@ -263,7 +278,10 @@ interface CLIProvider {
|
|||||||
|
|
||||||
// Workflows
|
// Workflows
|
||||||
registerWorkflow(workflow: CustomWorkflow): void;
|
registerWorkflow(workflow: CustomWorkflow): void;
|
||||||
executeWorkflow(workflowName: string, context: CommandContext): Promise<CommandResult>;
|
executeWorkflow(
|
||||||
|
workflowName: string,
|
||||||
|
context: CommandContext,
|
||||||
|
): Promise<CommandResult>;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -276,8 +294,8 @@ const bundleResult = await moduleManager.executeCommand('custom-bundle', {
|
|||||||
options: {
|
options: {
|
||||||
platform: 'android',
|
platform: 'android',
|
||||||
validate: true,
|
validate: true,
|
||||||
optimize: true
|
optimize: true,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Generate diff file
|
// Generate diff file
|
||||||
@@ -286,8 +304,8 @@ const diffResult = await moduleManager.executeCommand('diff', {
|
|||||||
options: {
|
options: {
|
||||||
origin: './build/v1.0.0.ppk',
|
origin: './build/v1.0.0.ppk',
|
||||||
next: './build/v1.1.0.ppk',
|
next: './build/v1.1.0.ppk',
|
||||||
output: './build/diff.patch'
|
output: './build/diff.patch',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Generate diff from APK files
|
// Generate diff from APK files
|
||||||
@@ -296,8 +314,8 @@ const apkDiffResult = await moduleManager.executeCommand('diffFromApk', {
|
|||||||
options: {
|
options: {
|
||||||
origin: './build/app-v1.0.0.apk',
|
origin: './build/app-v1.0.0.apk',
|
||||||
next: './build/app-v1.1.0.apk',
|
next: './build/app-v1.1.0.apk',
|
||||||
output: './build/apk-diff.patch'
|
output: './build/apk-diff.patch',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -349,29 +367,31 @@ Provider provides a concise programming interface suitable for integrating React
|
|||||||
### 📋 Core API Methods
|
### 📋 Core API Methods
|
||||||
|
|
||||||
#### Core Business Functions
|
#### Core Business Functions
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
// Bundle application
|
// Bundle application
|
||||||
await provider.bundle({
|
await provider.bundle({
|
||||||
platform: 'ios',
|
platform: 'ios',
|
||||||
dev: false,
|
dev: false,
|
||||||
sourcemap: true
|
sourcemap: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Publish version
|
// Publish version
|
||||||
await provider.publish({
|
await provider.publish({
|
||||||
name: 'v1.0.0',
|
name: 'v1.0.0',
|
||||||
description: 'Bug fixes',
|
description: 'Bug fixes',
|
||||||
rollout: 100
|
rollout: 100,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Upload file
|
// Upload file
|
||||||
await provider.upload({
|
await provider.upload({
|
||||||
filePath: 'app.ipa',
|
filePath: 'app.ipa',
|
||||||
platform: 'ios'
|
platform: 'ios',
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Application Management
|
#### Application Management
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
// Create application
|
// Create application
|
||||||
await provider.createApp('MyApp', 'ios');
|
await provider.createApp('MyApp', 'ios');
|
||||||
@@ -384,6 +404,7 @@ const { appId, platform } = await provider.getSelectedApp('ios');
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### Version Management
|
#### Version Management
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
// List versions
|
// List versions
|
||||||
await provider.listVersions('app123');
|
await provider.listVersions('app123');
|
||||||
@@ -391,11 +412,12 @@ await provider.listVersions('app123');
|
|||||||
// Update version
|
// Update version
|
||||||
await provider.updateVersion('app123', 'version456', {
|
await provider.updateVersion('app123', 'version456', {
|
||||||
name: 'v1.1.0',
|
name: 'v1.1.0',
|
||||||
description: 'New features'
|
description: 'New features',
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Utility Functions
|
#### Utility Functions
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
// Get platform
|
// Get platform
|
||||||
const platform = await provider.getPlatform('ios');
|
const platform = await provider.getPlatform('ios');
|
||||||
@@ -407,6 +429,7 @@ const session = await provider.loadSession();
|
|||||||
### 🎯 Use Cases
|
### 🎯 Use Cases
|
||||||
|
|
||||||
#### 1. Automated Build Scripts
|
#### 1. Automated Build Scripts
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { moduleManager } from 'react-native-update-cli';
|
import { moduleManager } from 'react-native-update-cli';
|
||||||
|
|
||||||
@@ -417,7 +440,7 @@ async function buildAndPublish() {
|
|||||||
const bundleResult = await provider.bundle({
|
const bundleResult = await provider.bundle({
|
||||||
platform: 'ios',
|
platform: 'ios',
|
||||||
dev: false,
|
dev: false,
|
||||||
sourcemap: true
|
sourcemap: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!bundleResult.success) {
|
if (!bundleResult.success) {
|
||||||
@@ -428,7 +451,7 @@ async function buildAndPublish() {
|
|||||||
const publishResult = await provider.publish({
|
const publishResult = await provider.publish({
|
||||||
name: 'v1.2.3',
|
name: 'v1.2.3',
|
||||||
description: 'Bug fixes and performance improvements',
|
description: 'Bug fixes and performance improvements',
|
||||||
rollout: 100
|
rollout: 100,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!publishResult.success) {
|
if (!publishResult.success) {
|
||||||
@@ -440,6 +463,7 @@ async function buildAndPublish() {
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### 2. CI/CD Integration
|
#### 2. CI/CD Integration
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
async function ciBuild() {
|
async function ciBuild() {
|
||||||
const provider = moduleManager.getProvider();
|
const provider = moduleManager.getProvider();
|
||||||
@@ -447,7 +471,7 @@ async function ciBuild() {
|
|||||||
const result = await provider.bundle({
|
const result = await provider.bundle({
|
||||||
platform: process.env.PLATFORM as 'ios' | 'android',
|
platform: process.env.PLATFORM as 'ios' | 'android',
|
||||||
dev: process.env.NODE_ENV !== 'production',
|
dev: process.env.NODE_ENV !== 'production',
|
||||||
sourcemap: process.env.NODE_ENV === 'production'
|
sourcemap: process.env.NODE_ENV === 'production',
|
||||||
});
|
});
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -455,6 +479,7 @@ async function ciBuild() {
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### 3. Application Management Service
|
#### 3. Application Management Service
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class AppManagementService {
|
class AppManagementService {
|
||||||
private provider = moduleManager.getProvider();
|
private provider = moduleManager.getProvider();
|
||||||
@@ -488,6 +513,7 @@ class AppManagementService {
|
|||||||
### 🔧 Advanced Features
|
### 🔧 Advanced Features
|
||||||
|
|
||||||
#### Custom Workflows
|
#### Custom Workflows
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
// Register custom workflow
|
// Register custom workflow
|
||||||
provider.registerWorkflow({
|
provider.registerWorkflow({
|
||||||
@@ -498,7 +524,7 @@ provider.registerWorkflow({
|
|||||||
name: 'bundle',
|
name: 'bundle',
|
||||||
execute: async () => {
|
execute: async () => {
|
||||||
return await provider.bundle({ platform: 'ios', dev: false });
|
return await provider.bundle({ platform: 'ios', dev: false });
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'publish',
|
name: 'publish',
|
||||||
@@ -507,9 +533,9 @@ provider.registerWorkflow({
|
|||||||
throw new Error('Bundle failed, cannot publish');
|
throw new Error('Bundle failed, cannot publish');
|
||||||
}
|
}
|
||||||
return await provider.publish({ name: 'auto-release', rollout: 50 });
|
return await provider.publish({ name: 'auto-release', rollout: 50 });
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
// Execute workflow
|
// Execute workflow
|
||||||
@@ -535,7 +561,7 @@ class ReactNativeUpdateService {
|
|||||||
const bundleResult = await this.provider.bundle({
|
const bundleResult = await this.provider.bundle({
|
||||||
platform,
|
platform,
|
||||||
dev: false,
|
dev: false,
|
||||||
sourcemap: true
|
sourcemap: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!bundleResult.success) {
|
if (!bundleResult.success) {
|
||||||
@@ -546,7 +572,7 @@ class ReactNativeUpdateService {
|
|||||||
const publishResult = await this.provider.publish({
|
const publishResult = await this.provider.publish({
|
||||||
name: version,
|
name: version,
|
||||||
description: `Release ${version}`,
|
description: `Release ${version}`,
|
||||||
rollout: 100
|
rollout: 100,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!publishResult.success) {
|
if (!publishResult.success) {
|
||||||
@@ -554,11 +580,10 @@ class ReactNativeUpdateService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return { success: true, data: publishResult.data };
|
return { success: true, data: publishResult.data };
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
error: error instanceof Error ? error.message : 'Unknown error'
|
error: error instanceof Error ? error.message : 'Unknown error',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
167
README.zh-CN.md
167
README.zh-CN.md
@@ -1,15 +1,15 @@
|
|||||||
# React Native Update CLI
|
# React Native Update CLI
|
||||||
|
|
||||||
这是一个统一的React Native Update CLI,同时支持传统命令和模块化架构以及自定义发布流程。
|
这是一个统一的 React Native Update CLI,同时支持传统命令和模块化架构以及自定义发布流程。
|
||||||
|
|
||||||
## 🚀 特性
|
## 🚀 特性
|
||||||
|
|
||||||
- **统一CLI**: 使用单个`pushy`命令提供所有功能
|
- **统一 CLI**: 使用单个`pushy`命令提供所有功能
|
||||||
- **向后兼容**: 所有现有命令都能正常工作
|
- **向后兼容**: 所有现有命令都能正常工作
|
||||||
- **模块化架构**: 将CLI功能拆分为独立的模块
|
- **模块化架构**: 将 CLI 功能拆分为独立的模块
|
||||||
- **自定义工作流**: 支持创建自定义的发布流程
|
- **自定义工作流**: 支持创建自定义的发布流程
|
||||||
- **可扩展性**: 用户可以导入和注册自定义模块
|
- **可扩展性**: 用户可以导入和注册自定义模块
|
||||||
- **类型安全**: 完整的TypeScript类型支持
|
- **类型安全**: 完整的 TypeScript 类型支持
|
||||||
|
|
||||||
## 📦 安装
|
## 📦 安装
|
||||||
|
|
||||||
@@ -47,14 +47,14 @@ const provider = moduleManager.getProvider();
|
|||||||
const bundleResult = await provider.bundle({
|
const bundleResult = await provider.bundle({
|
||||||
platform: 'ios',
|
platform: 'ios',
|
||||||
dev: false,
|
dev: false,
|
||||||
sourcemap: true
|
sourcemap: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 发布版本
|
// 发布版本
|
||||||
const publishResult = await provider.publish({
|
const publishResult = await provider.publish({
|
||||||
name: 'v1.2.3',
|
name: 'v1.2.3',
|
||||||
description: 'Bug fixes and improvements',
|
description: 'Bug fixes and improvements',
|
||||||
rollout: 100
|
rollout: 100,
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -63,7 +63,11 @@ const publishResult = await provider.publish({
|
|||||||
### 1. 定义模块
|
### 1. 定义模块
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import type { CLIModule, CommandDefinition, CustomWorkflow } from 'react-native-update-cli';
|
import type {
|
||||||
|
CLIModule,
|
||||||
|
CommandDefinition,
|
||||||
|
CustomWorkflow,
|
||||||
|
} from 'react-native-update-cli';
|
||||||
|
|
||||||
export const myCustomModule: CLIModule = {
|
export const myCustomModule: CLIModule = {
|
||||||
name: 'my-custom',
|
name: 'my-custom',
|
||||||
@@ -77,13 +81,13 @@ export const myCustomModule: CLIModule = {
|
|||||||
console.log('Executing custom command...');
|
console.log('Executing custom command...');
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
data: { message: 'Custom command executed' }
|
data: { message: 'Custom command executed' },
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
param: { hasValue: true, description: 'Custom parameter' }
|
param: { hasValue: true, description: 'Custom parameter' },
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
workflows: [
|
workflows: [
|
||||||
@@ -97,7 +101,7 @@ export const myCustomModule: CLIModule = {
|
|||||||
execute: async (context, previousResult) => {
|
execute: async (context, previousResult) => {
|
||||||
console.log('Executing step 1...');
|
console.log('Executing step 1...');
|
||||||
return { step1Completed: true };
|
return { step1Completed: true };
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'step2',
|
name: 'step2',
|
||||||
@@ -105,10 +109,10 @@ export const myCustomModule: CLIModule = {
|
|||||||
execute: async (context, previousResult) => {
|
execute: async (context, previousResult) => {
|
||||||
console.log('Executing step 2...');
|
console.log('Executing step 2...');
|
||||||
return { ...previousResult, step2Completed: true };
|
return { ...previousResult, step2Completed: true };
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
init: (provider) => {
|
init: (provider) => {
|
||||||
@@ -117,7 +121,7 @@ export const myCustomModule: CLIModule = {
|
|||||||
|
|
||||||
cleanup: () => {
|
cleanup: () => {
|
||||||
console.log('Custom module cleanup');
|
console.log('Custom module cleanup');
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -133,13 +137,13 @@ moduleManager.registerModule(myCustomModule);
|
|||||||
// 执行自定义命令
|
// 执行自定义命令
|
||||||
const result = await moduleManager.executeCommand('custom-command', {
|
const result = await moduleManager.executeCommand('custom-command', {
|
||||||
args: [],
|
args: [],
|
||||||
options: { param: 'value' }
|
options: { param: 'value' },
|
||||||
});
|
});
|
||||||
|
|
||||||
// 执行自定义工作流
|
// 执行自定义工作流
|
||||||
const workflowResult = await moduleManager.executeWorkflow('my-workflow', {
|
const workflowResult = await moduleManager.executeWorkflow('my-workflow', {
|
||||||
args: [],
|
args: [],
|
||||||
options: {}
|
options: {},
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -188,43 +192,48 @@ const workflowResult = await moduleManager.executeWorkflow('my-workflow', {
|
|||||||
|
|
||||||
## 📋 内置模块
|
## 📋 内置模块
|
||||||
|
|
||||||
### Bundle模块 (`bundle`)
|
### Bundle 模块 (`bundle`)
|
||||||
- `bundle`: 打包JavaScript代码并可选发布
|
|
||||||
- `diff`: 生成两个PPK文件之间的差异
|
- `bundle`: 打包 JavaScript 代码并可选发布
|
||||||
- `hdiff`: 生成两个PPK文件之间的hdiff
|
- `diff`: 生成两个 PPK 文件之间的差异
|
||||||
- `diffFromApk`: 从APK文件生成差异
|
- `hdiff`: 生成两个 PPK 文件之间的 hdiff
|
||||||
- `hdiffFromApk`: 从APK文件生成hdiff
|
- `diffFromApk`: 从 APK 文件生成差异
|
||||||
- `hdiffFromApp`: 从APP文件生成hdiff
|
- `hdiffFromApk`: 从 APK 文件生成 hdiff
|
||||||
- `diffFromIpa`: 从IPA文件生成差异
|
- `hdiffFromApp`: 从 APP 文件生成 hdiff
|
||||||
- `hdiffFromIpa`: 从IPA文件生成hdiff
|
- `diffFromIpa`: 从 IPA 文件生成差异
|
||||||
|
- `hdiffFromIpa`: 从 IPA 文件生成 hdiff
|
||||||
|
|
||||||
|
### Version 模块 (`version`)
|
||||||
|
|
||||||
### Version模块 (`version`)
|
|
||||||
- `publish`: 发布新版本
|
- `publish`: 发布新版本
|
||||||
- `versions`: 列出所有版本
|
- `versions`: 列出所有版本
|
||||||
- `update`: 更新版本信息
|
- `update`: 更新版本信息
|
||||||
- `updateVersionInfo`: 更新版本元数据
|
- `updateVersionInfo`: 更新版本元数据
|
||||||
|
|
||||||
### App模块 (`app`)
|
### App 模块 (`app`)
|
||||||
|
|
||||||
- `createApp`: 创建新应用
|
- `createApp`: 创建新应用
|
||||||
- `apps`: 列出所有应用
|
- `apps`: 列出所有应用
|
||||||
- `selectApp`: 选择应用
|
- `selectApp`: 选择应用
|
||||||
- `deleteApp`: 删除应用
|
- `deleteApp`: 删除应用
|
||||||
|
|
||||||
### Package模块 (`package`)
|
### Package 模块 (`package`)
|
||||||
- `uploadIpa`: 上传IPA文件
|
|
||||||
- `uploadApk`: 上传APK文件
|
- `uploadIpa`: 上传 IPA 文件(支持 `--version` 参数覆盖提取的版本)
|
||||||
- `uploadApp`: 上传APP文件
|
- `uploadApk`: 上传 APK 文件(支持 `--version` 参数覆盖提取的版本)
|
||||||
- `parseApp`: 解析APP文件信息
|
- `uploadApp`: 上传 APP 文件(支持 `--version` 参数覆盖提取的版本)
|
||||||
- `parseIpa`: 解析IPA文件信息
|
- `parseApp`: 解析 APP 文件信息
|
||||||
- `parseApk`: 解析APK文件信息
|
- `parseIpa`: 解析 IPA 文件信息
|
||||||
|
- `parseApk`: 解析 APK 文件信息
|
||||||
- `packages`: 列出包
|
- `packages`: 列出包
|
||||||
|
|
||||||
### User模块 (`user`)
|
### User 模块 (`user`)
|
||||||
|
|
||||||
- `login`: 登录
|
- `login`: 登录
|
||||||
- `logout`: 登出
|
- `logout`: 登出
|
||||||
- `me`: 显示用户信息
|
- `me`: 显示用户信息
|
||||||
|
|
||||||
## 🛠️ CLI提供者API
|
## 🛠️ CLI 提供者 API
|
||||||
|
|
||||||
### 核心功能
|
### 核心功能
|
||||||
|
|
||||||
@@ -240,14 +249,20 @@ interface CLIProvider {
|
|||||||
upload(options: UploadOptions): Promise<CommandResult>;
|
upload(options: UploadOptions): Promise<CommandResult>;
|
||||||
|
|
||||||
// 应用管理
|
// 应用管理
|
||||||
getSelectedApp(platform?: Platform): Promise<{ appId: string; platform: Platform }>;
|
getSelectedApp(
|
||||||
|
platform?: Platform,
|
||||||
|
): Promise<{ appId: string; platform: Platform }>;
|
||||||
listApps(platform?: Platform): Promise<CommandResult>;
|
listApps(platform?: Platform): Promise<CommandResult>;
|
||||||
createApp(name: string, platform: Platform): Promise<CommandResult>;
|
createApp(name: string, platform: Platform): Promise<CommandResult>;
|
||||||
|
|
||||||
// 版本管理
|
// 版本管理
|
||||||
listVersions(appId: string): Promise<CommandResult>;
|
listVersions(appId: string): Promise<CommandResult>;
|
||||||
getVersion(appId: string, versionId: string): Promise<CommandResult>;
|
getVersion(appId: string, versionId: string): Promise<CommandResult>;
|
||||||
updateVersion(appId: string, versionId: string, updates: Partial<Version>): Promise<CommandResult>;
|
updateVersion(
|
||||||
|
appId: string,
|
||||||
|
versionId: string,
|
||||||
|
updates: Partial<Version>,
|
||||||
|
): Promise<CommandResult>;
|
||||||
|
|
||||||
// 包管理
|
// 包管理
|
||||||
listPackages(appId: string, platform?: Platform): Promise<CommandResult>;
|
listPackages(appId: string, platform?: Platform): Promise<CommandResult>;
|
||||||
@@ -261,7 +276,10 @@ interface CLIProvider {
|
|||||||
|
|
||||||
// 工作流
|
// 工作流
|
||||||
registerWorkflow(workflow: CustomWorkflow): void;
|
registerWorkflow(workflow: CustomWorkflow): void;
|
||||||
executeWorkflow(workflowName: string, context: CommandContext): Promise<CommandResult>;
|
executeWorkflow(
|
||||||
|
workflowName: string,
|
||||||
|
context: CommandContext,
|
||||||
|
): Promise<CommandResult>;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -274,8 +292,8 @@ const bundleResult = await moduleManager.executeCommand('custom-bundle', {
|
|||||||
options: {
|
options: {
|
||||||
platform: 'android',
|
platform: 'android',
|
||||||
validate: true,
|
validate: true,
|
||||||
optimize: true
|
optimize: true,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// 生成差异文件
|
// 生成差异文件
|
||||||
@@ -284,8 +302,8 @@ const diffResult = await moduleManager.executeCommand('diff', {
|
|||||||
options: {
|
options: {
|
||||||
origin: './build/v1.0.0.ppk',
|
origin: './build/v1.0.0.ppk',
|
||||||
next: './build/v1.1.0.ppk',
|
next: './build/v1.1.0.ppk',
|
||||||
output: './build/diff.patch'
|
output: './build/diff.patch',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// 从APK文件生成差异
|
// 从APK文件生成差异
|
||||||
@@ -294,8 +312,8 @@ const apkDiffResult = await moduleManager.executeCommand('diffFromApk', {
|
|||||||
options: {
|
options: {
|
||||||
origin: './build/app-v1.0.0.apk',
|
origin: './build/app-v1.0.0.apk',
|
||||||
next: './build/app-v1.1.0.apk',
|
next: './build/app-v1.1.0.apk',
|
||||||
output: './build/apk-diff.patch'
|
output: './build/apk-diff.patch',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -330,46 +348,48 @@ export NO_INTERACTIVE=true
|
|||||||
|
|
||||||
## 🚨 注意事项
|
## 🚨 注意事项
|
||||||
|
|
||||||
1. **向后兼容**: 新的模块化CLI保持与现有CLI的兼容性
|
1. **向后兼容**: 新的模块化 CLI 保持与现有 CLI 的兼容性
|
||||||
2. **类型安全**: 所有API都有完整的TypeScript类型定义
|
2. **类型安全**: 所有 API 都有完整的 TypeScript 类型定义
|
||||||
3. **错误处理**: 所有操作都返回标准化的结果格式
|
3. **错误处理**: 所有操作都返回标准化的结果格式
|
||||||
4. **资源清理**: 模块支持清理函数来释放资源
|
4. **资源清理**: 模块支持清理函数来释放资源
|
||||||
5. **模块分离**: 功能按逻辑分离到不同模块中,便于维护和扩展
|
5. **模块分离**: 功能按逻辑分离到不同模块中,便于维护和扩展
|
||||||
|
|
||||||
## 🤝 贡献
|
## 🤝 贡献
|
||||||
|
|
||||||
欢迎提交Issue和Pull Request来改进这个项目!
|
欢迎提交 Issue 和 Pull Request 来改进这个项目!
|
||||||
|
|
||||||
## 🚀 Provider API 使用指南
|
## 🚀 Provider API 使用指南
|
||||||
|
|
||||||
Provider提供了简洁的编程接口,适合在应用程序中集成React Native Update CLI功能。
|
Provider 提供了简洁的编程接口,适合在应用程序中集成 React Native Update CLI 功能。
|
||||||
|
|
||||||
### 📋 核心API方法
|
### 📋 核心 API 方法
|
||||||
|
|
||||||
#### 核心业务功能
|
#### 核心业务功能
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
// 打包应用
|
// 打包应用
|
||||||
await provider.bundle({
|
await provider.bundle({
|
||||||
platform: 'ios',
|
platform: 'ios',
|
||||||
dev: false,
|
dev: false,
|
||||||
sourcemap: true
|
sourcemap: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 发布版本
|
// 发布版本
|
||||||
await provider.publish({
|
await provider.publish({
|
||||||
name: 'v1.0.0',
|
name: 'v1.0.0',
|
||||||
description: 'Bug fixes',
|
description: 'Bug fixes',
|
||||||
rollout: 100
|
rollout: 100,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 上传文件
|
// 上传文件
|
||||||
await provider.upload({
|
await provider.upload({
|
||||||
filePath: 'app.ipa',
|
filePath: 'app.ipa',
|
||||||
platform: 'ios'
|
platform: 'ios',
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 应用管理
|
#### 应用管理
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
// 创建应用
|
// 创建应用
|
||||||
await provider.createApp('MyApp', 'ios');
|
await provider.createApp('MyApp', 'ios');
|
||||||
@@ -382,6 +402,7 @@ const { appId, platform } = await provider.getSelectedApp('ios');
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### 版本管理
|
#### 版本管理
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
// 列出版本
|
// 列出版本
|
||||||
await provider.listVersions('app123');
|
await provider.listVersions('app123');
|
||||||
@@ -389,11 +410,12 @@ await provider.listVersions('app123');
|
|||||||
// 更新版本
|
// 更新版本
|
||||||
await provider.updateVersion('app123', 'version456', {
|
await provider.updateVersion('app123', 'version456', {
|
||||||
name: 'v1.1.0',
|
name: 'v1.1.0',
|
||||||
description: 'New features'
|
description: 'New features',
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 工具函数
|
#### 工具函数
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
// 获取平台
|
// 获取平台
|
||||||
const platform = await provider.getPlatform('ios');
|
const platform = await provider.getPlatform('ios');
|
||||||
@@ -405,6 +427,7 @@ const session = await provider.loadSession();
|
|||||||
### 🎯 使用场景
|
### 🎯 使用场景
|
||||||
|
|
||||||
#### 1. 自动化构建脚本
|
#### 1. 自动化构建脚本
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { moduleManager } from 'react-native-update-cli';
|
import { moduleManager } from 'react-native-update-cli';
|
||||||
|
|
||||||
@@ -415,7 +438,7 @@ async function buildAndPublish() {
|
|||||||
const bundleResult = await provider.bundle({
|
const bundleResult = await provider.bundle({
|
||||||
platform: 'ios',
|
platform: 'ios',
|
||||||
dev: false,
|
dev: false,
|
||||||
sourcemap: true
|
sourcemap: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!bundleResult.success) {
|
if (!bundleResult.success) {
|
||||||
@@ -426,7 +449,7 @@ async function buildAndPublish() {
|
|||||||
const publishResult = await provider.publish({
|
const publishResult = await provider.publish({
|
||||||
name: 'v1.2.3',
|
name: 'v1.2.3',
|
||||||
description: 'Bug fixes and performance improvements',
|
description: 'Bug fixes and performance improvements',
|
||||||
rollout: 100
|
rollout: 100,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!publishResult.success) {
|
if (!publishResult.success) {
|
||||||
@@ -437,7 +460,8 @@ async function buildAndPublish() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 2. CI/CD集成
|
#### 2. CI/CD 集成
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
async function ciBuild() {
|
async function ciBuild() {
|
||||||
const provider = moduleManager.getProvider();
|
const provider = moduleManager.getProvider();
|
||||||
@@ -445,7 +469,7 @@ async function ciBuild() {
|
|||||||
const result = await provider.bundle({
|
const result = await provider.bundle({
|
||||||
platform: process.env.PLATFORM as 'ios' | 'android',
|
platform: process.env.PLATFORM as 'ios' | 'android',
|
||||||
dev: process.env.NODE_ENV !== 'production',
|
dev: process.env.NODE_ENV !== 'production',
|
||||||
sourcemap: process.env.NODE_ENV === 'production'
|
sourcemap: process.env.NODE_ENV === 'production',
|
||||||
});
|
});
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -453,6 +477,7 @@ async function ciBuild() {
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### 3. 应用管理服务
|
#### 3. 应用管理服务
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class AppManagementService {
|
class AppManagementService {
|
||||||
private provider = moduleManager.getProvider();
|
private provider = moduleManager.getProvider();
|
||||||
@@ -478,14 +503,15 @@ class AppManagementService {
|
|||||||
|
|
||||||
### ⚠️ 注意事项
|
### ⚠️ 注意事项
|
||||||
|
|
||||||
1. **错误处理**: 所有Provider方法都返回`CommandResult`,需要检查`success`字段
|
1. **错误处理**: 所有 Provider 方法都返回`CommandResult`,需要检查`success`字段
|
||||||
2. **类型安全**: Provider提供完整的TypeScript类型支持
|
2. **类型安全**: Provider 提供完整的 TypeScript 类型支持
|
||||||
3. **会话管理**: 使用前确保已登录,可通过`loadSession()`检查
|
3. **会话管理**: 使用前确保已登录,可通过`loadSession()`检查
|
||||||
4. **平台支持**: 支持`'ios' | 'android' | 'harmony'`三个平台
|
4. **平台支持**: 支持`'ios' | 'android' | 'harmony'`三个平台
|
||||||
|
|
||||||
### 🔧 高级功能
|
### 🔧 高级功能
|
||||||
|
|
||||||
#### 自定义工作流
|
#### 自定义工作流
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
// 注册自定义工作流
|
// 注册自定义工作流
|
||||||
provider.registerWorkflow({
|
provider.registerWorkflow({
|
||||||
@@ -496,7 +522,7 @@ provider.registerWorkflow({
|
|||||||
name: 'bundle',
|
name: 'bundle',
|
||||||
execute: async () => {
|
execute: async () => {
|
||||||
return await provider.bundle({ platform: 'ios', dev: false });
|
return await provider.bundle({ platform: 'ios', dev: false });
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'publish',
|
name: 'publish',
|
||||||
@@ -505,9 +531,9 @@ provider.registerWorkflow({
|
|||||||
throw new Error('打包失败,无法发布');
|
throw new Error('打包失败,无法发布');
|
||||||
}
|
}
|
||||||
return await provider.publish({ name: 'auto-release', rollout: 50 });
|
return await provider.publish({ name: 'auto-release', rollout: 50 });
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
// 执行工作流
|
// 执行工作流
|
||||||
@@ -533,7 +559,7 @@ class ReactNativeUpdateService {
|
|||||||
const bundleResult = await this.provider.bundle({
|
const bundleResult = await this.provider.bundle({
|
||||||
platform,
|
platform,
|
||||||
dev: false,
|
dev: false,
|
||||||
sourcemap: true
|
sourcemap: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!bundleResult.success) {
|
if (!bundleResult.success) {
|
||||||
@@ -544,7 +570,7 @@ class ReactNativeUpdateService {
|
|||||||
const publishResult = await this.provider.publish({
|
const publishResult = await this.provider.publish({
|
||||||
name: version,
|
name: version,
|
||||||
description: `Release ${version}`,
|
description: `Release ${version}`,
|
||||||
rollout: 100
|
rollout: 100,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!publishResult.success) {
|
if (!publishResult.success) {
|
||||||
@@ -552,11 +578,10 @@ class ReactNativeUpdateService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return { success: true, data: publishResult.data };
|
return { success: true, data: publishResult.data };
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
error: error instanceof Error ? error.message : 'Unknown error'
|
error: error instanceof Error ? error.message : 'Unknown error',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
26
bun.lock
26
bun.lock
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
|
"configVersion": 0,
|
||||||
"workspaces": {
|
"workspaces": {
|
||||||
"": {
|
"": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -23,6 +24,7 @@
|
|||||||
"plist": "^3.1.0",
|
"plist": "^3.1.0",
|
||||||
"progress": "^2.0.3",
|
"progress": "^2.0.3",
|
||||||
"properties": "^1.2.1",
|
"properties": "^1.2.1",
|
||||||
|
"protobufjs": "^7.5.4",
|
||||||
"read": "^4.1.0",
|
"read": "^4.1.0",
|
||||||
"registry-auth-token": "^5.1.0",
|
"registry-auth-token": "^5.1.0",
|
||||||
"semver": "^7.7.2",
|
"semver": "^7.7.2",
|
||||||
@@ -121,6 +123,26 @@
|
|||||||
|
|
||||||
"@pnpm/npm-conf": ["@pnpm/npm-conf@2.3.1", "", { "dependencies": { "@pnpm/config.env-replace": "^1.1.0", "@pnpm/network.ca-file": "^1.0.1", "config-chain": "^1.1.11" } }, "sha512-c83qWb22rNRuB0UaVCI0uRPNRr8Z0FWnEIvT47jiHAmOIUHbBOg5XvV7pM5x+rKn9HRpjxquDbXYSXr3fAKFcw=="],
|
"@pnpm/npm-conf": ["@pnpm/npm-conf@2.3.1", "", { "dependencies": { "@pnpm/config.env-replace": "^1.1.0", "@pnpm/network.ca-file": "^1.0.1", "config-chain": "^1.1.11" } }, "sha512-c83qWb22rNRuB0UaVCI0uRPNRr8Z0FWnEIvT47jiHAmOIUHbBOg5XvV7pM5x+rKn9HRpjxquDbXYSXr3fAKFcw=="],
|
||||||
|
|
||||||
|
"@protobufjs/aspromise": ["@protobufjs/aspromise@1.1.2", "", {}, "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ=="],
|
||||||
|
|
||||||
|
"@protobufjs/base64": ["@protobufjs/base64@1.1.2", "", {}, "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg=="],
|
||||||
|
|
||||||
|
"@protobufjs/codegen": ["@protobufjs/codegen@2.0.4", "", {}, "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg=="],
|
||||||
|
|
||||||
|
"@protobufjs/eventemitter": ["@protobufjs/eventemitter@1.1.0", "", {}, "sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q=="],
|
||||||
|
|
||||||
|
"@protobufjs/fetch": ["@protobufjs/fetch@1.1.0", "", { "dependencies": { "@protobufjs/aspromise": "^1.1.1", "@protobufjs/inquire": "^1.1.0" } }, "sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ=="],
|
||||||
|
|
||||||
|
"@protobufjs/float": ["@protobufjs/float@1.0.2", "", {}, "sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ=="],
|
||||||
|
|
||||||
|
"@protobufjs/inquire": ["@protobufjs/inquire@1.1.0", "", {}, "sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q=="],
|
||||||
|
|
||||||
|
"@protobufjs/path": ["@protobufjs/path@1.1.2", "", {}, "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA=="],
|
||||||
|
|
||||||
|
"@protobufjs/pool": ["@protobufjs/pool@1.1.0", "", {}, "sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw=="],
|
||||||
|
|
||||||
|
"@protobufjs/utf8": ["@protobufjs/utf8@1.1.0", "", {}, "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw=="],
|
||||||
|
|
||||||
"@sec-ant/readable-stream": ["@sec-ant/readable-stream@0.4.1", "", {}, "sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg=="],
|
"@sec-ant/readable-stream": ["@sec-ant/readable-stream@0.4.1", "", {}, "sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg=="],
|
||||||
|
|
||||||
"@sindresorhus/is": ["@sindresorhus/is@5.6.0", "", {}, "sha512-TV7t8GKYaJWsn00tFDqBw8+Uqmr8A0fRU1tvTQhyZzGv0sJCGRQL3JGMI3ucuKo3XIZdUP+Lx7/gh2t3lewy7g=="],
|
"@sindresorhus/is": ["@sindresorhus/is@5.6.0", "", {}, "sha512-TV7t8GKYaJWsn00tFDqBw8+Uqmr8A0fRU1tvTQhyZzGv0sJCGRQL3JGMI3ucuKo3XIZdUP+Lx7/gh2t3lewy7g=="],
|
||||||
@@ -589,6 +611,8 @@
|
|||||||
|
|
||||||
"proto-list": ["proto-list@1.2.4", "", {}, "sha512-vtK/94akxsTMhe0/cbfpR+syPuszcuwhqVjJq26CuNDgFGj682oRBXOP5MJpv2r7JtE8MsiepGIqvvOTBwn2vA=="],
|
"proto-list": ["proto-list@1.2.4", "", {}, "sha512-vtK/94akxsTMhe0/cbfpR+syPuszcuwhqVjJq26CuNDgFGj682oRBXOP5MJpv2r7JtE8MsiepGIqvvOTBwn2vA=="],
|
||||||
|
|
||||||
|
"protobufjs": ["protobufjs@7.5.4", "", { "dependencies": { "@protobufjs/aspromise": "^1.1.2", "@protobufjs/base64": "^1.1.2", "@protobufjs/codegen": "^2.0.4", "@protobufjs/eventemitter": "^1.1.0", "@protobufjs/fetch": "^1.1.0", "@protobufjs/float": "^1.0.2", "@protobufjs/inquire": "^1.1.0", "@protobufjs/path": "^1.1.2", "@protobufjs/pool": "^1.1.0", "@protobufjs/utf8": "^1.1.0", "@types/node": ">=13.7.0", "long": "^5.0.0" } }, "sha512-CvexbZtbov6jW2eXAvLukXjXUW1TzFaivC46BpWc/3BpcCysb5Vffu+B3XHMm8lVEuy2Mm4XGex8hBSg1yapPg=="],
|
||||||
|
|
||||||
"queue-microtask": ["queue-microtask@1.2.3", "", {}, "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A=="],
|
"queue-microtask": ["queue-microtask@1.2.3", "", {}, "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A=="],
|
||||||
|
|
||||||
"queue-tick": ["queue-tick@1.0.1", "", {}, "sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag=="],
|
"queue-tick": ["queue-tick@1.0.1", "", {}, "sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag=="],
|
||||||
@@ -827,6 +851,8 @@
|
|||||||
|
|
||||||
"object.assign/has-symbols": ["has-symbols@1.0.3", "", {}, "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A=="],
|
"object.assign/has-symbols": ["has-symbols@1.0.3", "", {}, "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A=="],
|
||||||
|
|
||||||
|
"protobufjs/long": ["long@5.3.2", "", {}, "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA=="],
|
||||||
|
|
||||||
"safe-array-concat/get-intrinsic": ["get-intrinsic@1.2.4", "", { "dependencies": { "es-errors": "^1.3.0", "function-bind": "^1.1.2", "has-proto": "^1.0.1", "has-symbols": "^1.0.3", "hasown": "^2.0.0" } }, "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ=="],
|
"safe-array-concat/get-intrinsic": ["get-intrinsic@1.2.4", "", { "dependencies": { "es-errors": "^1.3.0", "function-bind": "^1.1.2", "has-proto": "^1.0.1", "has-symbols": "^1.0.3", "hasown": "^2.0.0" } }, "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ=="],
|
||||||
|
|
||||||
"safe-array-concat/has-symbols": ["has-symbols@1.0.3", "", {}, "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A=="],
|
"safe-array-concat/has-symbols": ["has-symbols@1.0.3", "", {}, "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A=="],
|
||||||
|
|||||||
66
cli.json
66
cli.json
@@ -31,12 +31,31 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"uploadIpa": {},
|
"uploadIpa": {
|
||||||
"uploadApk": {},
|
"options": {
|
||||||
"uploadApp": {},
|
"version": {
|
||||||
|
"hasValue": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"uploadApk": {
|
||||||
|
"options": {
|
||||||
|
"version": {
|
||||||
|
"hasValue": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"uploadApp": {
|
||||||
|
"options": {
|
||||||
|
"version": {
|
||||||
|
"hasValue": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"parseApp": {},
|
"parseApp": {},
|
||||||
"parseIpa": {},
|
"parseIpa": {},
|
||||||
"parseApk": {},
|
"parseApk": {},
|
||||||
|
"parseAab": {},
|
||||||
"packages": {
|
"packages": {
|
||||||
"options": {
|
"options": {
|
||||||
"platform": {
|
"platform": {
|
||||||
@@ -44,6 +63,19 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"deletePackage": {
|
||||||
|
"options": {
|
||||||
|
"appId": {
|
||||||
|
"hasValue": true
|
||||||
|
},
|
||||||
|
"packageVersion": {
|
||||||
|
"hasValue": true
|
||||||
|
},
|
||||||
|
"packageId": {
|
||||||
|
"hasValue": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"publish": {
|
"publish": {
|
||||||
"options": {
|
"options": {
|
||||||
"platform": {
|
"platform": {
|
||||||
@@ -141,6 +173,19 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"deleteVersion": {
|
||||||
|
"options": {
|
||||||
|
"platform": {
|
||||||
|
"hasValue": true
|
||||||
|
},
|
||||||
|
"versionId": {
|
||||||
|
"hasValue": true
|
||||||
|
},
|
||||||
|
"appId": {
|
||||||
|
"hasValue": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"build": {
|
"build": {
|
||||||
"description": "Bundle javascript and copy assets."
|
"description": "Bundle javascript and copy assets."
|
||||||
},
|
},
|
||||||
@@ -182,7 +227,7 @@
|
|||||||
"rncli": {
|
"rncli": {
|
||||||
"default": false
|
"default": false
|
||||||
},
|
},
|
||||||
"disableHermes": {
|
"hermes": {
|
||||||
"default": false
|
"default": false
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
@@ -268,15 +313,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"hdiffFromPPK": {
|
|
||||||
"description": "Create hdiff patch from a Prepare package(.ppk)",
|
|
||||||
"options": {
|
|
||||||
"output": {
|
|
||||||
"default": "${tempDir}/output/hdiff-${time}.ppk-patch",
|
|
||||||
"hasValue": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"hdiffFromApp": {
|
"hdiffFromApp": {
|
||||||
"description": "Create hdiff patch from a Harmony package(.app)",
|
"description": "Create hdiff patch from a Harmony package(.app)",
|
||||||
"options": {
|
"options": {
|
||||||
@@ -312,6 +348,10 @@
|
|||||||
"hasValue": true
|
"hasValue": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"install": {
|
||||||
|
"description": "Install optional dependencies to the CLI",
|
||||||
|
"options": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"globalOptions": {
|
"globalOptions": {
|
||||||
|
|||||||
53
example/USAGE_CUSTOM_VERSION.md
Normal file
53
example/USAGE_CUSTOM_VERSION.md
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
# Custom Version Parameter Usage
|
||||||
|
|
||||||
|
This document demonstrates how to use the `--version` parameter with upload commands to override the version extracted from APK/IPA/APP files.
|
||||||
|
|
||||||
|
## Commands Supporting Custom Version
|
||||||
|
|
||||||
|
- `uploadApk --version <version>`
|
||||||
|
- `uploadIpa --version <version>`
|
||||||
|
- `uploadApp --version <version>`
|
||||||
|
|
||||||
|
## Usage Examples
|
||||||
|
|
||||||
|
### Upload APK with Custom Version
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Upload APK and override version to "1.2.3-custom"
|
||||||
|
cresc uploadApk app-release.apk --version "1.2.3-custom"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Upload IPA with Custom Version
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Upload IPA and override version to "2.0.0-beta"
|
||||||
|
cresc uploadIpa MyApp.ipa --version "2.0.0-beta"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Upload APP with Custom Version
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Upload APP and override version to "3.1.0-harmony"
|
||||||
|
cresc uploadApp MyApp.app --version "3.1.0-harmony"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Behavior
|
||||||
|
|
||||||
|
1. **Without `--version`**: The command uses the version extracted from the package file (APK/IPA/APP)
|
||||||
|
2. **With `--version`**: The command uses the provided custom version instead of the extracted version
|
||||||
|
3. **Console Output**: When using a custom version, the CLI will display "Using custom version: <version>" message
|
||||||
|
|
||||||
|
## Use Cases
|
||||||
|
|
||||||
|
- **Testing**: Upload test builds with specific version identifiers
|
||||||
|
- **Hotfixes**: Override version numbers for emergency releases
|
||||||
|
- **Version Alignment**: Ensure consistent versioning across different platforms
|
||||||
|
- **Manual Override**: When the extracted version is incorrect or inappropriate
|
||||||
|
|
||||||
|
## Example Output
|
||||||
|
|
||||||
|
```
|
||||||
|
$ cresc uploadApk app-release.apk --version "1.2.3-hotfix"
|
||||||
|
Using custom version: 1.2.3-hotfix
|
||||||
|
Successfully uploaded APK native package (id: 12345, version: 1.2.3-hotfix, buildTime: 2024-01-15T10:30:00Z)
|
||||||
|
```
|
||||||
22
package.json
22
package.json
@@ -1,17 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "react-native-update-cli",
|
"name": "react-native-update-cli",
|
||||||
"version": "2.0.0",
|
"version": "2.5.0",
|
||||||
"description": "command line tool for react-native-update (remote updates for react native)",
|
"description": "command line tool for react-native-update (remote updates for react native)",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
"pushy": "lib/index.js",
|
"pushy": "lib/index.js",
|
||||||
"cresc": "lib/index.js"
|
"cresc": "lib/index.js"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": ["lib", "src", "proto", "cli.json"],
|
||||||
"lib",
|
|
||||||
"src",
|
|
||||||
"cli.json"
|
|
||||||
],
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "swc src -d lib --strip-leading-paths",
|
"build": "swc src -d lib --strip-leading-paths",
|
||||||
"prepublishOnly": "npm run build && chmod +x lib/index.js",
|
"prepublishOnly": "npm run build && chmod +x lib/index.js",
|
||||||
@@ -21,13 +17,7 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/reactnativecn/react-native-update-cli.git"
|
"url": "git+https://github.com/reactnativecn/react-native-update-cli.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": ["react-native", "ios", "android", "harmony", "update"],
|
||||||
"react-native",
|
|
||||||
"ios",
|
|
||||||
"android",
|
|
||||||
"harmony",
|
|
||||||
"update"
|
|
||||||
],
|
|
||||||
"author": "reactnativecn",
|
"author": "reactnativecn",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
@@ -55,6 +45,7 @@
|
|||||||
"plist": "^3.1.0",
|
"plist": "^3.1.0",
|
||||||
"progress": "^2.0.3",
|
"progress": "^2.0.3",
|
||||||
"properties": "^1.2.1",
|
"properties": "^1.2.1",
|
||||||
|
"protobufjs": "^7.5.4",
|
||||||
"read": "^4.1.0",
|
"read": "^4.1.0",
|
||||||
"registry-auth-token": "^5.1.0",
|
"registry-auth-token": "^5.1.0",
|
||||||
"semver": "^7.7.2",
|
"semver": "^7.7.2",
|
||||||
@@ -81,8 +72,5 @@
|
|||||||
"@types/yazl": "^2.4.6",
|
"@types/yazl": "^2.4.6",
|
||||||
"typescript": "^5.8.3"
|
"typescript": "^5.8.3"
|
||||||
},
|
},
|
||||||
"trustedDependencies": [
|
"trustedDependencies": ["@biomejs/biome", "@swc/core"]
|
||||||
"@biomejs/biome",
|
|
||||||
"@swc/core"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
183
proto/Configuration.proto
Normal file
183
proto/Configuration.proto
Normal file
@@ -0,0 +1,183 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package aapt.pb;
|
||||||
|
|
||||||
|
option java_package = "com.android.aapt";
|
||||||
|
|
||||||
|
message Configuration {
|
||||||
|
enum LayoutDirection {
|
||||||
|
LAYOUT_DIRECTION_UNSET = 0;
|
||||||
|
LAYOUT_DIRECTION_LTR = 1;
|
||||||
|
LAYOUT_DIRECTION_RTL = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ScreenLayoutSize {
|
||||||
|
SCREEN_LAYOUT_SIZE_UNSET = 0;
|
||||||
|
SCREEN_LAYOUT_SIZE_SMALL = 1;
|
||||||
|
SCREEN_LAYOUT_SIZE_NORMAL = 2;
|
||||||
|
SCREEN_LAYOUT_SIZE_LARGE = 3;
|
||||||
|
SCREEN_LAYOUT_SIZE_XLARGE = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ScreenLayoutLong {
|
||||||
|
SCREEN_LAYOUT_LONG_UNSET = 0;
|
||||||
|
SCREEN_LAYOUT_LONG_LONG = 1;
|
||||||
|
SCREEN_LAYOUT_LONG_NOTLONG = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ScreenRound {
|
||||||
|
SCREEN_ROUND_UNSET = 0;
|
||||||
|
SCREEN_ROUND_ROUND = 1;
|
||||||
|
SCREEN_ROUND_NOTROUND = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum WideColorGamut {
|
||||||
|
WIDE_COLOR_GAMUT_UNSET = 0;
|
||||||
|
WIDE_COLOR_GAMUT_WIDECG = 1;
|
||||||
|
WIDE_COLOR_GAMUT_NOWIDECG = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Hdr {
|
||||||
|
HDR_UNSET = 0;
|
||||||
|
HDR_HIGHDR = 1;
|
||||||
|
HDR_LOWDR = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Orientation {
|
||||||
|
ORIENTATION_UNSET = 0;
|
||||||
|
ORIENTATION_PORT = 1;
|
||||||
|
ORIENTATION_LAND = 2;
|
||||||
|
ORIENTATION_SQUARE = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum UiModeType {
|
||||||
|
UI_MODE_TYPE_UNSET = 0;
|
||||||
|
UI_MODE_TYPE_NORMAL = 1;
|
||||||
|
UI_MODE_TYPE_DESK = 2;
|
||||||
|
UI_MODE_TYPE_CAR = 3;
|
||||||
|
UI_MODE_TYPE_TELEVISION = 4;
|
||||||
|
UI_MODE_TYPE_APPLIANCE = 5;
|
||||||
|
UI_MODE_TYPE_WATCH = 6;
|
||||||
|
UI_MODE_TYPE_VR_HEADSET = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum UiModeNight {
|
||||||
|
UI_MODE_NIGHT_UNSET = 0;
|
||||||
|
UI_MODE_NIGHT_NIGHT = 1;
|
||||||
|
UI_MODE_NIGHT_NOTNIGHT = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Touchscreen {
|
||||||
|
TOUCHSCREEN_UNSET = 0;
|
||||||
|
TOUCHSCREEN_NOTOUCH = 1;
|
||||||
|
TOUCHSCREEN_STYLUS = 2;
|
||||||
|
TOUCHSCREEN_FINGER = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum KeysHidden {
|
||||||
|
KEYS_HIDDEN_UNSET = 0;
|
||||||
|
KEYS_HIDDEN_KEYSEXPOSED = 1;
|
||||||
|
KEYS_HIDDEN_KEYSHIDDEN = 2;
|
||||||
|
KEYS_HIDDEN_KEYSSOFT = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Keyboard {
|
||||||
|
KEYBOARD_UNSET = 0;
|
||||||
|
KEYBOARD_NOKEYS = 1;
|
||||||
|
KEYBOARD_QWERTY = 2;
|
||||||
|
KEYBOARD_12KEY = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum NavHidden {
|
||||||
|
NAV_HIDDEN_UNSET = 0;
|
||||||
|
NAV_HIDDEN_NAVEXPOSED = 1;
|
||||||
|
NAV_HIDDEN_NAVHIDDEN = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Navigation {
|
||||||
|
NAVIGATION_UNSET = 0;
|
||||||
|
NAVIGATION_NONAV = 1;
|
||||||
|
NAVIGATION_DPAD = 2;
|
||||||
|
NAVIGATION_TRACKBALL = 3;
|
||||||
|
NAVIGATION_WHEEL = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum GrammaticalGender {
|
||||||
|
GRAMMATICAL_GENDER_UNSET = 0;
|
||||||
|
GRAMMATICAL_GENDER_NEUTER = 1;
|
||||||
|
GRAMMATICAL_GENDER_FEMININE = 2;
|
||||||
|
GRAMMATICAL_GENDER_MASCULINE = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mobile country code.
|
||||||
|
uint32 mcc = 1;
|
||||||
|
|
||||||
|
// Mobile network code.
|
||||||
|
uint32 mnc = 2;
|
||||||
|
|
||||||
|
// Locale.
|
||||||
|
string locale = 3;
|
||||||
|
|
||||||
|
// Layout direction.
|
||||||
|
LayoutDirection layout_direction = 4;
|
||||||
|
|
||||||
|
// Screen width in dp.
|
||||||
|
uint32 screen_width = 5;
|
||||||
|
|
||||||
|
// Screen height in dp.
|
||||||
|
uint32 screen_height = 6;
|
||||||
|
|
||||||
|
// Smallest screen width in dp.
|
||||||
|
uint32 smallest_screen_width = 7;
|
||||||
|
|
||||||
|
// Screen layout size.
|
||||||
|
ScreenLayoutSize screen_layout_size = 8;
|
||||||
|
|
||||||
|
// Screen layout long.
|
||||||
|
ScreenLayoutLong screen_layout_long = 9;
|
||||||
|
|
||||||
|
// Screen round.
|
||||||
|
ScreenRound screen_round = 10;
|
||||||
|
|
||||||
|
// Wide color gamut.
|
||||||
|
WideColorGamut wide_color_gamut = 11;
|
||||||
|
|
||||||
|
// HDR.
|
||||||
|
Hdr hdr = 12;
|
||||||
|
|
||||||
|
// Orientation.
|
||||||
|
Orientation orientation = 13;
|
||||||
|
|
||||||
|
// UI mode type.
|
||||||
|
UiModeType ui_mode_type = 14;
|
||||||
|
|
||||||
|
// UI mode night.
|
||||||
|
UiModeNight ui_mode_night = 15;
|
||||||
|
|
||||||
|
// Density in dpi.
|
||||||
|
uint32 density = 16;
|
||||||
|
|
||||||
|
// Touchscreen.
|
||||||
|
Touchscreen touchscreen = 17;
|
||||||
|
|
||||||
|
// Keys hidden.
|
||||||
|
KeysHidden keys_hidden = 18;
|
||||||
|
|
||||||
|
// Keyboard.
|
||||||
|
Keyboard keyboard = 19;
|
||||||
|
|
||||||
|
// Nav hidden.
|
||||||
|
NavHidden nav_hidden = 20;
|
||||||
|
|
||||||
|
// Navigation.
|
||||||
|
Navigation navigation = 21;
|
||||||
|
|
||||||
|
// SDK version.
|
||||||
|
uint32 sdk_version = 22;
|
||||||
|
|
||||||
|
// Product.
|
||||||
|
string product = 23;
|
||||||
|
|
||||||
|
// Grammatical gender.
|
||||||
|
GrammaticalGender grammatical_gender = 24;
|
||||||
|
}
|
||||||
569
proto/Resources.proto
Normal file
569
proto/Resources.proto
Normal file
@@ -0,0 +1,569 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package aapt.pb;
|
||||||
|
|
||||||
|
option java_package = "com.android.aapt";
|
||||||
|
|
||||||
|
import "Configuration.proto";
|
||||||
|
|
||||||
|
// A string pool that wraps the binary form of the C++ class android::ResStringPool.
|
||||||
|
message StringPool {
|
||||||
|
bytes data = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The position of a declared entity in a file.
|
||||||
|
message SourcePosition {
|
||||||
|
uint32 line_number = 1;
|
||||||
|
uint32 column_number = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Developer friendly source file information for an entity in the resource table.
|
||||||
|
message Source {
|
||||||
|
// The index of the string path within the source StringPool.
|
||||||
|
uint32 path_idx = 1;
|
||||||
|
|
||||||
|
SourcePosition position = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Top level message representing a resource table.
|
||||||
|
message ResourceTable {
|
||||||
|
// The string pool containing source paths referenced by Source messages.
|
||||||
|
StringPool source_pool = 1;
|
||||||
|
|
||||||
|
// The packages declared in this resource table.
|
||||||
|
repeated Package package = 2;
|
||||||
|
|
||||||
|
// The overlayable declarations in this resource table.
|
||||||
|
repeated Overlayable overlayable = 3;
|
||||||
|
|
||||||
|
// The tool fingerprints of the tools that built this resource table.
|
||||||
|
repeated ToolFingerprint tool_fingerprint = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A package declaration.
|
||||||
|
message Package {
|
||||||
|
// The package ID of this package.
|
||||||
|
// This is the first byte of a resource ID (0xPPTTEEEE).
|
||||||
|
// This is optional, and if not set, the package ID is assigned by the runtime.
|
||||||
|
// For the framework, this is 0x01. For the application, this is 0x7f.
|
||||||
|
uint32 package_id = 1;
|
||||||
|
|
||||||
|
// The Java compatible package name.
|
||||||
|
string package_name = 2;
|
||||||
|
|
||||||
|
// The types declared in this package.
|
||||||
|
repeated Type type = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A set of resources grouped under a common type (string, layout, xml, etc).
|
||||||
|
// This maps to the second byte of a resource ID (0xPPTTEEEE).
|
||||||
|
message Type {
|
||||||
|
// The type ID of this type.
|
||||||
|
// This is optional, and if not set, the type ID is assigned by the runtime.
|
||||||
|
uint32 type_id = 1;
|
||||||
|
|
||||||
|
// The name of this type.
|
||||||
|
string name = 2;
|
||||||
|
|
||||||
|
// The entries declared in this type.
|
||||||
|
repeated Entry entry = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A resource entry declaration.
|
||||||
|
// This maps to the last two bytes of a resource ID (0xPPTTEEEE).
|
||||||
|
message Entry {
|
||||||
|
// The entry ID of this entry.
|
||||||
|
// This is optional, and if not set, the entry ID is assigned by the runtime.
|
||||||
|
uint32 entry_id = 1;
|
||||||
|
|
||||||
|
// The name of this entry.
|
||||||
|
string name = 2;
|
||||||
|
|
||||||
|
// The visibility of this entry.
|
||||||
|
Visibility visibility = 3;
|
||||||
|
|
||||||
|
// The allow-new state of this entry.
|
||||||
|
AllowNew allow_new = 4;
|
||||||
|
|
||||||
|
// The overlayable state of this entry.
|
||||||
|
OverlayableItem overlayable_item = 5;
|
||||||
|
|
||||||
|
// The set of values defined for this entry, each with a different configuration.
|
||||||
|
repeated ConfigValue config_value = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The visibility of a resource entry.
|
||||||
|
message Visibility {
|
||||||
|
enum Level {
|
||||||
|
UNKNOWN = 0;
|
||||||
|
PRIVATE = 1;
|
||||||
|
PUBLIC = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The visibility level.
|
||||||
|
Level level = 1;
|
||||||
|
|
||||||
|
// The source of the visibility declaration.
|
||||||
|
Source source = 2;
|
||||||
|
|
||||||
|
// The comment associated with the visibility declaration.
|
||||||
|
string comment = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The allow-new state of a resource entry.
|
||||||
|
message AllowNew {
|
||||||
|
// The source of the allow-new declaration.
|
||||||
|
Source source = 1;
|
||||||
|
|
||||||
|
// The comment associated with the allow-new declaration.
|
||||||
|
string comment = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The overlayable state of a resource entry.
|
||||||
|
message OverlayableItem {
|
||||||
|
enum Policy {
|
||||||
|
NONE = 0;
|
||||||
|
PUBLIC = 1;
|
||||||
|
SYSTEM = 2;
|
||||||
|
VENDOR = 3;
|
||||||
|
PRODUCT = 4;
|
||||||
|
SIGNATURE = 5;
|
||||||
|
ODM = 6;
|
||||||
|
OEM = 7;
|
||||||
|
ACTOR = 8;
|
||||||
|
CONFIG_SIGNATURE = 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The source of the overlayable declaration.
|
||||||
|
Source source = 1;
|
||||||
|
|
||||||
|
// The comment associated with the overlayable declaration.
|
||||||
|
string comment = 2;
|
||||||
|
|
||||||
|
// The policy of the overlayable declaration.
|
||||||
|
repeated Policy policy = 3;
|
||||||
|
|
||||||
|
// The index of the overlayable declaration in the overlayable list.
|
||||||
|
uint32 overlayable_idx = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A value defined for a resource entry with a specific configuration.
|
||||||
|
message ConfigValue {
|
||||||
|
// The configuration for which this value is defined.
|
||||||
|
Configuration config = 1;
|
||||||
|
|
||||||
|
// The value of the resource.
|
||||||
|
Value value = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A generic value of a resource.
|
||||||
|
message Value {
|
||||||
|
// The source of the value declaration.
|
||||||
|
Source source = 1;
|
||||||
|
|
||||||
|
// The comment associated with the value declaration.
|
||||||
|
string comment = 2;
|
||||||
|
|
||||||
|
// The value is a weak reference to another resource.
|
||||||
|
bool weak = 3;
|
||||||
|
|
||||||
|
// The value is a raw string.
|
||||||
|
Item item = 4;
|
||||||
|
|
||||||
|
// The value is a compound value.
|
||||||
|
CompoundValue compound_value = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A value that is a single item.
|
||||||
|
message Item {
|
||||||
|
// The value is a reference to another resource.
|
||||||
|
Reference ref = 1;
|
||||||
|
|
||||||
|
// The value is a string.
|
||||||
|
String str = 2;
|
||||||
|
|
||||||
|
// The value is a raw string.
|
||||||
|
RawString raw_str = 3;
|
||||||
|
|
||||||
|
// The value is a styled string.
|
||||||
|
StyledString styled_str = 4;
|
||||||
|
|
||||||
|
// The value is a file.
|
||||||
|
File file = 5;
|
||||||
|
|
||||||
|
// The value is an integer.
|
||||||
|
Id id = 6;
|
||||||
|
|
||||||
|
// The value is a primitive.
|
||||||
|
Primitive prim = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A value that is a compound value.
|
||||||
|
message CompoundValue {
|
||||||
|
// The value is an attribute.
|
||||||
|
Attribute attr = 1;
|
||||||
|
|
||||||
|
// The value is a style.
|
||||||
|
Style style = 2;
|
||||||
|
|
||||||
|
// The value is a styleable.
|
||||||
|
Styleable styleable = 3;
|
||||||
|
|
||||||
|
// The value is an array.
|
||||||
|
Array array = 4;
|
||||||
|
|
||||||
|
// The value is a plural.
|
||||||
|
Plural plural = 5;
|
||||||
|
|
||||||
|
// The value is a macro.
|
||||||
|
MacroBody macro = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A reference to another resource.
|
||||||
|
message Reference {
|
||||||
|
enum Type {
|
||||||
|
REFERENCE = 0;
|
||||||
|
ATTRIBUTE = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The type of reference.
|
||||||
|
Type type = 1;
|
||||||
|
|
||||||
|
// The resource ID being referenced.
|
||||||
|
uint32 id = 2;
|
||||||
|
|
||||||
|
// The name of the resource being referenced.
|
||||||
|
string name = 3;
|
||||||
|
|
||||||
|
// The private state of the reference.
|
||||||
|
bool private = 4;
|
||||||
|
|
||||||
|
// The dynamic reference state of the reference.
|
||||||
|
bool is_dynamic = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A string value.
|
||||||
|
message String {
|
||||||
|
// The string value.
|
||||||
|
string value = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A raw string value.
|
||||||
|
message RawString {
|
||||||
|
// The raw string value.
|
||||||
|
string value = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A styled string value.
|
||||||
|
message StyledString {
|
||||||
|
// The raw string value.
|
||||||
|
string value = 1;
|
||||||
|
|
||||||
|
// The spans of the styled string.
|
||||||
|
repeated Span span = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A span of a styled string.
|
||||||
|
message Span {
|
||||||
|
// The tag of the span.
|
||||||
|
string tag = 1;
|
||||||
|
|
||||||
|
// The first character index of the span.
|
||||||
|
uint32 first_char = 2;
|
||||||
|
|
||||||
|
// The last character index of the span.
|
||||||
|
uint32 last_char = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A file value.
|
||||||
|
message File {
|
||||||
|
// The path to the file.
|
||||||
|
string path = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// An ID value.
|
||||||
|
message Id {
|
||||||
|
}
|
||||||
|
|
||||||
|
// A primitive value.
|
||||||
|
message Primitive {
|
||||||
|
// The null value.
|
||||||
|
message NullType {}
|
||||||
|
// The empty value.
|
||||||
|
message EmptyType {}
|
||||||
|
|
||||||
|
oneof oneof_value {
|
||||||
|
NullType null_value = 1;
|
||||||
|
EmptyType empty_value = 2;
|
||||||
|
float float_value = 3;
|
||||||
|
uint32 dimension_value = 4;
|
||||||
|
uint32 fraction_value = 5;
|
||||||
|
int32 int_decimal_value = 6;
|
||||||
|
uint32 int_hexadecimal_value = 7;
|
||||||
|
bool boolean_value = 8;
|
||||||
|
uint32 color_argb8_value = 9;
|
||||||
|
uint32 color_rgb8_value = 10;
|
||||||
|
uint32 color_argb4_value = 11;
|
||||||
|
uint32 color_rgb4_value = 12;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// An attribute value.
|
||||||
|
message Attribute {
|
||||||
|
enum FormatFlags {
|
||||||
|
NONE = 0x0;
|
||||||
|
REFERENCE = 0x1;
|
||||||
|
STRING = 0x2;
|
||||||
|
INTEGER = 0x4;
|
||||||
|
BOOLEAN = 0x8;
|
||||||
|
COLOR = 0x10;
|
||||||
|
FLOAT = 0x20;
|
||||||
|
DIMENSION = 0x40;
|
||||||
|
FRACTION = 0x80;
|
||||||
|
ENUM = 0x10000;
|
||||||
|
FLAGS = 0x20000;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The format flags of the attribute.
|
||||||
|
uint32 format_flags = 1;
|
||||||
|
|
||||||
|
// The minimum value of the attribute.
|
||||||
|
int32 min_int = 2;
|
||||||
|
|
||||||
|
// The maximum value of the attribute.
|
||||||
|
int32 max_int = 3;
|
||||||
|
|
||||||
|
// The symbols of the attribute.
|
||||||
|
repeated Symbol symbol = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A symbol of an attribute.
|
||||||
|
message Symbol {
|
||||||
|
// The source of the symbol declaration.
|
||||||
|
Source source = 1;
|
||||||
|
|
||||||
|
// The comment associated with the symbol declaration.
|
||||||
|
string comment = 2;
|
||||||
|
|
||||||
|
// The name of the symbol.
|
||||||
|
Reference name = 3;
|
||||||
|
|
||||||
|
// The value of the symbol.
|
||||||
|
uint32 value = 4;
|
||||||
|
|
||||||
|
// The type of the symbol.
|
||||||
|
uint32 type = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A style value.
|
||||||
|
message Style {
|
||||||
|
// The parent of the style.
|
||||||
|
Reference parent = 1;
|
||||||
|
|
||||||
|
// The source of the parent declaration.
|
||||||
|
Source parent_source = 2;
|
||||||
|
|
||||||
|
// The entries of the style.
|
||||||
|
repeated Entry entry = 3;
|
||||||
|
|
||||||
|
// An entry of a style.
|
||||||
|
message Entry {
|
||||||
|
// The source of the entry declaration.
|
||||||
|
Source source = 1;
|
||||||
|
|
||||||
|
// The comment associated with the entry declaration.
|
||||||
|
string comment = 2;
|
||||||
|
|
||||||
|
// The key of the entry.
|
||||||
|
Reference key = 3;
|
||||||
|
|
||||||
|
// The item of the entry.
|
||||||
|
Item item = 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// A styleable value.
|
||||||
|
message Styleable {
|
||||||
|
// The entries of the styleable.
|
||||||
|
repeated Entry entry = 1;
|
||||||
|
|
||||||
|
// An entry of a styleable.
|
||||||
|
message Entry {
|
||||||
|
// The source of the entry declaration.
|
||||||
|
Source source = 1;
|
||||||
|
|
||||||
|
// The comment associated with the entry declaration.
|
||||||
|
string comment = 2;
|
||||||
|
|
||||||
|
// The attribute of the entry.
|
||||||
|
Reference attr = 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// An array value.
|
||||||
|
message Array {
|
||||||
|
// The elements of the array.
|
||||||
|
repeated Element element = 1;
|
||||||
|
|
||||||
|
// An element of an array.
|
||||||
|
message Element {
|
||||||
|
// The source of the element declaration.
|
||||||
|
Source source = 1;
|
||||||
|
|
||||||
|
// The comment associated with the element declaration.
|
||||||
|
string comment = 2;
|
||||||
|
|
||||||
|
// The item of the element.
|
||||||
|
Item item = 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// A plural value.
|
||||||
|
message Plural {
|
||||||
|
enum Arity {
|
||||||
|
ZERO = 0;
|
||||||
|
ONE = 1;
|
||||||
|
TWO = 2;
|
||||||
|
FEW = 3;
|
||||||
|
MANY = 4;
|
||||||
|
OTHER = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The entries of the plural.
|
||||||
|
repeated Entry entry = 1;
|
||||||
|
|
||||||
|
// An entry of a plural.
|
||||||
|
message Entry {
|
||||||
|
// The source of the entry declaration.
|
||||||
|
Source source = 1;
|
||||||
|
|
||||||
|
// The comment associated with the entry declaration.
|
||||||
|
string comment = 2;
|
||||||
|
|
||||||
|
// The arity of the entry.
|
||||||
|
Arity arity = 3;
|
||||||
|
|
||||||
|
// The item of the entry.
|
||||||
|
Item item = 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// A macro body value.
|
||||||
|
message MacroBody {
|
||||||
|
// The raw string value.
|
||||||
|
string raw_string = 1;
|
||||||
|
|
||||||
|
// The style string value.
|
||||||
|
StyleString style_string = 2;
|
||||||
|
|
||||||
|
// The untranslatable sections of the macro.
|
||||||
|
repeated UntranslatableSection untranslatable_section = 3;
|
||||||
|
|
||||||
|
// The namespace declarations of the macro.
|
||||||
|
repeated NamespaceDeclaration namespace_declaration = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message StyleString {
|
||||||
|
string str = 1;
|
||||||
|
repeated Span spans = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message UntranslatableSection {
|
||||||
|
uint64 start_index = 1;
|
||||||
|
uint64 end_index = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message NamespaceDeclaration {
|
||||||
|
string prefix = 1;
|
||||||
|
string uri = 2;
|
||||||
|
Source source = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// An overlayable declaration.
|
||||||
|
message Overlayable {
|
||||||
|
// The name of the overlayable.
|
||||||
|
string name = 1;
|
||||||
|
|
||||||
|
// The source of the overlayable declaration.
|
||||||
|
Source source = 2;
|
||||||
|
|
||||||
|
// The actor of the overlayable declaration.
|
||||||
|
string actor = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A tool fingerprint.
|
||||||
|
message ToolFingerprint {
|
||||||
|
// The tool name.
|
||||||
|
string tool = 1;
|
||||||
|
|
||||||
|
// The version of the tool.
|
||||||
|
string version = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A dynamic reference table.
|
||||||
|
message DynamicRefTable {
|
||||||
|
// The package ID to package name mapping.
|
||||||
|
repeated PackageId packageName = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message PackageId {
|
||||||
|
uint32 id = 1;
|
||||||
|
string name = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A generic XML node.
|
||||||
|
message XmlNode {
|
||||||
|
// The element node.
|
||||||
|
XmlElement element = 1;
|
||||||
|
|
||||||
|
// The text node.
|
||||||
|
string text = 2;
|
||||||
|
|
||||||
|
// The source of the node.
|
||||||
|
SourcePosition source = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message XmlNamespace {
|
||||||
|
string prefix = 1;
|
||||||
|
string uri = 2;
|
||||||
|
SourcePosition source = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// An XML element.
|
||||||
|
message XmlElement {
|
||||||
|
// The namespace declarations of the element.
|
||||||
|
repeated XmlNamespace namespace_declaration = 1;
|
||||||
|
|
||||||
|
// The namespace URI of the element.
|
||||||
|
string namespace_uri = 2;
|
||||||
|
|
||||||
|
// The name of the element.
|
||||||
|
string name = 3;
|
||||||
|
|
||||||
|
// The attributes of the element.
|
||||||
|
repeated XmlAttribute attribute = 4;
|
||||||
|
|
||||||
|
// The children of the element.
|
||||||
|
repeated XmlNode child = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
// An XML attribute.
|
||||||
|
message XmlAttribute {
|
||||||
|
// The namespace URI of the attribute.
|
||||||
|
string namespace_uri = 1;
|
||||||
|
|
||||||
|
// The name of the attribute.
|
||||||
|
string name = 2;
|
||||||
|
|
||||||
|
// The value of the attribute.
|
||||||
|
string value = 3;
|
||||||
|
|
||||||
|
// The source of the attribute.
|
||||||
|
SourcePosition source = 4;
|
||||||
|
|
||||||
|
// The resource ID of the attribute.
|
||||||
|
uint32 resource_id = 5;
|
||||||
|
|
||||||
|
// The compiled item of the attribute.
|
||||||
|
Item compiled_item = 6;
|
||||||
|
}
|
||||||
13
src/api.ts
13
src/api.ts
@@ -10,18 +10,16 @@ import packageJson from '../package.json';
|
|||||||
import type { Package, Session } from './types';
|
import type { Package, Session } from './types';
|
||||||
import {
|
import {
|
||||||
credentialFile,
|
credentialFile,
|
||||||
defaultEndpoint,
|
|
||||||
pricingPageUrl,
|
pricingPageUrl,
|
||||||
} from './utils/constants';
|
} from './utils/constants';
|
||||||
import { t } from './utils/i18n';
|
import { t } from './utils/i18n';
|
||||||
|
import { getBaseUrl } from 'utils/http-helper';
|
||||||
|
|
||||||
const tcpPing = util.promisify(tcpp.ping);
|
const tcpPing = util.promisify(tcpp.ping);
|
||||||
|
|
||||||
let session: Session | undefined;
|
let session: Session | undefined;
|
||||||
let savedSession: Session | undefined;
|
let savedSession: Session | undefined;
|
||||||
|
|
||||||
const host =
|
|
||||||
process.env.PUSHY_REGISTRY || process.env.RNU_API || defaultEndpoint;
|
|
||||||
|
|
||||||
const userAgent = `react-native-update-cli/${packageJson.version}`;
|
const userAgent = `react-native-update-cli/${packageJson.version}`;
|
||||||
|
|
||||||
@@ -64,7 +62,9 @@ export const closeSession = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
async function query(url: string, options: fetch.RequestInit) {
|
async function query(url: string, options: fetch.RequestInit) {
|
||||||
const resp = await fetch(url, options);
|
const baseUrl = await getBaseUrl;
|
||||||
|
const fullUrl = `${baseUrl}${url}`;
|
||||||
|
const resp = await fetch(fullUrl, options);
|
||||||
const text = await resp.text();
|
const text = await resp.text();
|
||||||
let json: any;
|
let json: any;
|
||||||
try {
|
try {
|
||||||
@@ -83,7 +83,7 @@ async function query(url: string, options: fetch.RequestInit) {
|
|||||||
|
|
||||||
function queryWithoutBody(method: string) {
|
function queryWithoutBody(method: string) {
|
||||||
return (api: string) =>
|
return (api: string) =>
|
||||||
query(host + api, {
|
query(api, {
|
||||||
method,
|
method,
|
||||||
headers: {
|
headers: {
|
||||||
'User-Agent': userAgent,
|
'User-Agent': userAgent,
|
||||||
@@ -94,7 +94,7 @@ function queryWithoutBody(method: string) {
|
|||||||
|
|
||||||
function queryWithBody(method: string) {
|
function queryWithBody(method: string) {
|
||||||
return (api: string, body?: Record<string, any>) =>
|
return (api: string, body?: Record<string, any>) =>
|
||||||
query(host + api, {
|
query(api, {
|
||||||
method,
|
method,
|
||||||
headers: {
|
headers: {
|
||||||
'User-Agent': userAgent,
|
'User-Agent': userAgent,
|
||||||
@@ -116,6 +116,7 @@ export async function uploadFile(fn: string, key?: string) {
|
|||||||
});
|
});
|
||||||
let realUrl = url;
|
let realUrl = url;
|
||||||
if (backupUrl) {
|
if (backupUrl) {
|
||||||
|
// @ts-ignore
|
||||||
if (global.USE_ACC_OSS) {
|
if (global.USE_ACC_OSS) {
|
||||||
realUrl = backupUrl;
|
realUrl = backupUrl;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
236
src/bundle.ts
236
src/bundle.ts
@@ -16,7 +16,7 @@ import os from 'os';
|
|||||||
const properties = require('properties');
|
const properties = require('properties');
|
||||||
import { addGitIgnore } from './utils/add-gitignore';
|
import { addGitIgnore } from './utils/add-gitignore';
|
||||||
import { checkLockFiles } from './utils/check-lockfile';
|
import { checkLockFiles } from './utils/check-lockfile';
|
||||||
import { tempDir } from './utils/constants';
|
import { isPPKBundleFileName, scriptName, tempDir } from './utils/constants';
|
||||||
import { depVersions } from './utils/dep-versions';
|
import { depVersions } from './utils/dep-versions';
|
||||||
import { t } from './utils/i18n';
|
import { t } from './utils/i18n';
|
||||||
import { versionCommands } from './versions';
|
import { versionCommands } from './versions';
|
||||||
@@ -42,7 +42,7 @@ async function runReactNativeBundleCommand({
|
|||||||
platform,
|
platform,
|
||||||
sourcemapOutput,
|
sourcemapOutput,
|
||||||
config,
|
config,
|
||||||
disableHermes,
|
forceHermes,
|
||||||
cli,
|
cli,
|
||||||
}: {
|
}: {
|
||||||
bundleName: string;
|
bundleName: string;
|
||||||
@@ -52,7 +52,7 @@ async function runReactNativeBundleCommand({
|
|||||||
platform: string;
|
platform: string;
|
||||||
sourcemapOutput: string;
|
sourcemapOutput: string;
|
||||||
config?: string;
|
config?: string;
|
||||||
disableHermes?: boolean;
|
forceHermes?: boolean;
|
||||||
cli: {
|
cli: {
|
||||||
taro?: boolean;
|
taro?: boolean;
|
||||||
expo?: boolean;
|
expo?: boolean;
|
||||||
@@ -75,27 +75,40 @@ async function runReactNativeBundleCommand({
|
|||||||
const envArgs = process.env.PUSHY_ENV_ARGS;
|
const envArgs = process.env.PUSHY_ENV_ARGS;
|
||||||
|
|
||||||
if (envArgs) {
|
if (envArgs) {
|
||||||
Array.prototype.push.apply(
|
reactNativeBundleArgs.push(...envArgs.trim().split(/\s+/));
|
||||||
reactNativeBundleArgs,
|
|
||||||
envArgs.trim().split(/\s+/),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.emptyDirSync(outputFolder);
|
fs.emptyDirSync(outputFolder);
|
||||||
|
|
||||||
let cliPath: string | undefined;
|
let cliPath = '';
|
||||||
let usingExpo = false;
|
let usingExpo = false;
|
||||||
|
|
||||||
const getExpoCli = () => {
|
const getExpoCli = () => {
|
||||||
try {
|
try {
|
||||||
|
const searchPaths = [process.cwd()];
|
||||||
|
|
||||||
|
// 尝试添加 expo 包的路径作为额外的搜索路径
|
||||||
|
try {
|
||||||
|
const expoPath = require.resolve('expo/package.json', {
|
||||||
|
paths: [process.cwd()],
|
||||||
|
});
|
||||||
|
// 获取 expo 包的目录路径
|
||||||
|
const expoDir = expoPath.replace(/\/package\.json$/, '');
|
||||||
|
searchPaths.push(expoDir);
|
||||||
|
} catch {
|
||||||
|
// expo 包不存在,忽略
|
||||||
|
}
|
||||||
|
|
||||||
|
// 尝试从搜索路径中解析 @expo/cli
|
||||||
cliPath = require.resolve('@expo/cli', {
|
cliPath = require.resolve('@expo/cli', {
|
||||||
paths: [process.cwd()],
|
paths: searchPaths,
|
||||||
});
|
});
|
||||||
|
|
||||||
const expoCliVersion = JSON.parse(
|
const expoCliVersion = JSON.parse(
|
||||||
fs
|
fs
|
||||||
.readFileSync(
|
.readFileSync(
|
||||||
require.resolve('@expo/cli/package.json', {
|
require.resolve('@expo/cli/package.json', {
|
||||||
paths: [process.cwd()],
|
paths: searchPaths,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.toString(),
|
.toString(),
|
||||||
@@ -104,7 +117,7 @@ async function runReactNativeBundleCommand({
|
|||||||
if (satisfies(expoCliVersion, '>= 0.10.17')) {
|
if (satisfies(expoCliVersion, '>= 0.10.17')) {
|
||||||
usingExpo = true;
|
usingExpo = true;
|
||||||
} else {
|
} else {
|
||||||
cliPath = undefined;
|
cliPath = '';
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
};
|
};
|
||||||
@@ -167,48 +180,38 @@ async function runReactNativeBundleCommand({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (platform === 'harmony') {
|
if (platform === 'harmony') {
|
||||||
Array.prototype.push.apply(reactNativeBundleArgs, [
|
bundleName = 'bundle.harmony.js';
|
||||||
cliPath,
|
if (forceHermes === undefined) {
|
||||||
bundleCommand,
|
// enable hermes by default for harmony
|
||||||
'--dev',
|
forceHermes = true;
|
||||||
dev,
|
|
||||||
'--entry-file',
|
|
||||||
entryFile,
|
|
||||||
]);
|
|
||||||
|
|
||||||
if (sourcemapOutput) {
|
|
||||||
reactNativeBundleArgs.push('--sourcemap-output', sourcemapOutput);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (config) {
|
reactNativeBundleArgs.push(
|
||||||
reactNativeBundleArgs.push('--config', config);
|
cliPath,
|
||||||
}
|
bundleCommand,
|
||||||
|
'--assets-dest',
|
||||||
|
outputFolder,
|
||||||
|
'--bundle-output',
|
||||||
|
path.join(outputFolder, bundleName),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (platform !== 'harmony') {
|
||||||
|
reactNativeBundleArgs.push('--platform', platform, '--reset-cache');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cli.taro) {
|
||||||
|
reactNativeBundleArgs.push('--type', 'rn');
|
||||||
} else {
|
} else {
|
||||||
Array.prototype.push.apply(reactNativeBundleArgs, [
|
reactNativeBundleArgs.push('--dev', dev, '--entry-file', entryFile);
|
||||||
cliPath,
|
}
|
||||||
bundleCommand,
|
|
||||||
'--assets-dest',
|
|
||||||
outputFolder,
|
|
||||||
'--bundle-output',
|
|
||||||
path.join(outputFolder, bundleName),
|
|
||||||
'--platform',
|
|
||||||
platform,
|
|
||||||
'--reset-cache',
|
|
||||||
]);
|
|
||||||
|
|
||||||
if (cli.taro) {
|
if (sourcemapOutput) {
|
||||||
reactNativeBundleArgs.push(...['--type', 'rn']);
|
reactNativeBundleArgs.push('--sourcemap-output', sourcemapOutput);
|
||||||
} else {
|
}
|
||||||
reactNativeBundleArgs.push(...['--dev', dev, '--entry-file', entryFile]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sourcemapOutput) {
|
if (config) {
|
||||||
reactNativeBundleArgs.push('--sourcemap-output', sourcemapOutput);
|
reactNativeBundleArgs.push('--config', config);
|
||||||
}
|
|
||||||
|
|
||||||
if (config) {
|
|
||||||
reactNativeBundleArgs.push('--config', config);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const reactNativeBundleProcess = spawn('node', reactNativeBundleArgs);
|
const reactNativeBundleProcess = spawn('node', reactNativeBundleArgs);
|
||||||
@@ -231,9 +234,9 @@ async function runReactNativeBundleCommand({
|
|||||||
} else {
|
} else {
|
||||||
let hermesEnabled: boolean | undefined = false;
|
let hermesEnabled: boolean | undefined = false;
|
||||||
|
|
||||||
if (disableHermes) {
|
if (forceHermes) {
|
||||||
hermesEnabled = false;
|
hermesEnabled = true;
|
||||||
console.log(t('hermesDisabled'));
|
console.log(t('forceHermes'));
|
||||||
} else if (platform === 'android') {
|
} else if (platform === 'android') {
|
||||||
const gradlePropeties = await new Promise<{
|
const gradlePropeties = await new Promise<{
|
||||||
hermesEnabled?: boolean;
|
hermesEnabled?: boolean;
|
||||||
@@ -260,8 +263,6 @@ async function runReactNativeBundleCommand({
|
|||||||
fs.existsSync('ios/Pods/hermes-engine')
|
fs.existsSync('ios/Pods/hermes-engine')
|
||||||
) {
|
) {
|
||||||
hermesEnabled = true;
|
hermesEnabled = true;
|
||||||
} else if (platform === 'harmony') {
|
|
||||||
await copyHarmonyBundle(outputFolder);
|
|
||||||
}
|
}
|
||||||
if (hermesEnabled) {
|
if (hermesEnabled) {
|
||||||
await compileHermesByteCode(
|
await compileHermesByteCode(
|
||||||
@@ -271,45 +272,25 @@ async function runReactNativeBundleCommand({
|
|||||||
!isSentry,
|
!isSentry,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (platform === 'harmony') {
|
||||||
|
const harmonyRawAssetsPath =
|
||||||
|
'harmony/entry/src/main/resources/rawfile/assets';
|
||||||
|
// copy all files in outputFolder to harmonyRawPath
|
||||||
|
// assets should be in rawfile/assets
|
||||||
|
fs.ensureDirSync(harmonyRawAssetsPath);
|
||||||
|
fs.copySync(outputFolder, harmonyRawAssetsPath, { overwrite: true });
|
||||||
|
fs.moveSync(
|
||||||
|
`${harmonyRawAssetsPath}/bundle.harmony.js`,
|
||||||
|
`${harmonyRawAssetsPath}/../bundle.harmony.js`,
|
||||||
|
{ overwrite: true },
|
||||||
|
);
|
||||||
|
}
|
||||||
resolve(null);
|
resolve(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function copyHarmonyBundle(outputFolder: string) {
|
|
||||||
const harmonyRawPath = 'harmony/entry/src/main/resources/rawfile';
|
|
||||||
try {
|
|
||||||
await fs.ensureDir(harmonyRawPath);
|
|
||||||
try {
|
|
||||||
await fs.access(harmonyRawPath, fs.constants.W_OK);
|
|
||||||
} catch (error) {
|
|
||||||
await fs.chmod(harmonyRawPath, 0o755);
|
|
||||||
}
|
|
||||||
await fs.remove(path.join(harmonyRawPath, 'update.json'));
|
|
||||||
await fs.copy('update.json', path.join(harmonyRawPath, 'update.json'));
|
|
||||||
await fs.ensureDir(outputFolder);
|
|
||||||
|
|
||||||
const files = await fs.readdir(harmonyRawPath);
|
|
||||||
for (const file of files) {
|
|
||||||
if (file !== 'update.json' && file !== 'meta.json') {
|
|
||||||
const sourcePath = path.join(harmonyRawPath, file);
|
|
||||||
const destPath = path.join(outputFolder, file);
|
|
||||||
const stat = await fs.stat(sourcePath);
|
|
||||||
|
|
||||||
if (stat.isFile()) {
|
|
||||||
await fs.copy(sourcePath, destPath);
|
|
||||||
} else if (stat.isDirectory()) {
|
|
||||||
await fs.copy(sourcePath, destPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error: any) {
|
|
||||||
console.error(t('copyHarmonyBundleError', { error }));
|
|
||||||
throw new Error(t('copyFileFailed', { error: error.message }));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getHermesOSBin() {
|
function getHermesOSBin() {
|
||||||
if (os.platform() === 'win32') return 'win64-bin';
|
if (os.platform() === 'win32') return 'win64-bin';
|
||||||
if (os.platform() === 'darwin') return 'osx-bin';
|
if (os.platform() === 'darwin') return 'osx-bin';
|
||||||
@@ -498,7 +479,12 @@ async function uploadSourcemapForSentry(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ignorePackingFileNames = ['.', '..', 'index.bundlejs.map'];
|
const ignorePackingFileNames = [
|
||||||
|
'.',
|
||||||
|
'..',
|
||||||
|
'index.bundlejs.map',
|
||||||
|
'bundle.harmony.js.map',
|
||||||
|
];
|
||||||
const ignorePackingExtensions = ['DS_Store', 'txt.map'];
|
const ignorePackingExtensions = ['DS_Store', 'txt.map'];
|
||||||
async function pack(dir: string, output: string) {
|
async function pack(dir: string, output: string) {
|
||||||
console.log(t('packing'));
|
console.log(t('packing'));
|
||||||
@@ -580,10 +566,7 @@ async function diffFromPPK(origin: string, next: string, output: string) {
|
|||||||
// isFile
|
// isFile
|
||||||
originMap[entry.crc32] = entry.fileName;
|
originMap[entry.crc32] = entry.fileName;
|
||||||
|
|
||||||
if (
|
if (isPPKBundleFileName(entry.fileName)) {
|
||||||
entry.fileName === 'index.bundlejs' ||
|
|
||||||
entry.fileName === 'bundle.harmony.js'
|
|
||||||
) {
|
|
||||||
// This is source.
|
// This is source.
|
||||||
return readEntry(entry, zipFile).then((v) => (originSource = v));
|
return readEntry(entry, zipFile).then((v) => (originSource = v));
|
||||||
}
|
}
|
||||||
@@ -591,9 +574,7 @@ async function diffFromPPK(origin: string, next: string, output: string) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!originSource) {
|
if (!originSource) {
|
||||||
throw new Error(
|
throw new Error(t('bundleFileNotFound'));
|
||||||
'Bundle file not found! Please use default bundle file name and path.',
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const copies = {};
|
const copies = {};
|
||||||
@@ -633,23 +614,13 @@ async function diffFromPPK(origin: string, next: string, output: string) {
|
|||||||
if (!originEntries[entry.fileName]) {
|
if (!originEntries[entry.fileName]) {
|
||||||
addEntry(entry.fileName);
|
addEntry(entry.fileName);
|
||||||
}
|
}
|
||||||
} else if (entry.fileName === 'index.bundlejs') {
|
} else if (isPPKBundleFileName(entry.fileName)) {
|
||||||
//console.log('Found bundle');
|
//console.log('Found bundle');
|
||||||
return readEntry(entry, nextZipfile).then((newSource) => {
|
return readEntry(entry, nextZipfile).then((newSource) => {
|
||||||
//console.log('Begin diff');
|
//console.log('Begin diff');
|
||||||
zipfile.addBuffer(
|
zipfile.addBuffer(
|
||||||
diff(originSource, newSource),
|
diff(originSource, newSource),
|
||||||
'index.bundlejs.patch',
|
`${entry.fileName}.patch`,
|
||||||
);
|
|
||||||
//console.log('End diff');
|
|
||||||
});
|
|
||||||
} else if (entry.fileName === 'bundle.harmony.js') {
|
|
||||||
//console.log('Found bundle');
|
|
||||||
return readEntry(entry, nextZipfile).then((newSource) => {
|
|
||||||
//console.log('Begin diff');
|
|
||||||
zipfile.addBuffer(
|
|
||||||
diff(originSource, newSource),
|
|
||||||
'bundle.harmony.js.patch',
|
|
||||||
);
|
);
|
||||||
//console.log('End diff');
|
//console.log('End diff');
|
||||||
});
|
});
|
||||||
@@ -741,9 +712,7 @@ async function diffFromPackage(
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!originSource) {
|
if (!originSource) {
|
||||||
throw new Error(
|
throw new Error(t('bundleFileNotFound'));
|
||||||
'Bundle file not found! Please use default bundle file name and path.',
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const copies = {};
|
const copies = {};
|
||||||
@@ -763,23 +732,13 @@ async function diffFromPackage(
|
|||||||
if (/\/$/.test(entry.fileName)) {
|
if (/\/$/.test(entry.fileName)) {
|
||||||
// Directory
|
// Directory
|
||||||
zipfile.addEmptyDirectory(entry.fileName);
|
zipfile.addEmptyDirectory(entry.fileName);
|
||||||
} else if (entry.fileName === 'index.bundlejs') {
|
} else if (isPPKBundleFileName(entry.fileName)) {
|
||||||
//console.log('Found bundle');
|
//console.log('Found bundle');
|
||||||
return readEntry(entry, nextZipfile).then((newSource) => {
|
return readEntry(entry, nextZipfile).then((newSource) => {
|
||||||
//console.log('Begin diff');
|
//console.log('Begin diff');
|
||||||
zipfile.addBuffer(
|
zipfile.addBuffer(
|
||||||
diff(originSource, newSource),
|
diff(originSource, newSource),
|
||||||
'index.bundlejs.patch',
|
`${entry.fileName}.patch`,
|
||||||
);
|
|
||||||
//console.log('End diff');
|
|
||||||
});
|
|
||||||
} else if (entry.fileName === 'bundle.harmony.js') {
|
|
||||||
//console.log('Found bundle');
|
|
||||||
return readEntry(entry, nextZipfile).then((newSource) => {
|
|
||||||
//console.log('Begin diff');
|
|
||||||
zipfile.addBuffer(
|
|
||||||
diff(originSource, newSource),
|
|
||||||
'bundle.harmony.js.patch',
|
|
||||||
);
|
);
|
||||||
//console.log('End diff');
|
//console.log('End diff');
|
||||||
});
|
});
|
||||||
@@ -892,24 +851,21 @@ function diffArgsCheck(args: string[], options: any, diffFn: string) {
|
|||||||
|
|
||||||
if (diffFn.startsWith('hdiff')) {
|
if (diffFn.startsWith('hdiff')) {
|
||||||
if (!hdiff) {
|
if (!hdiff) {
|
||||||
console.error(
|
console.error(t('nodeHdiffpatchRequired', { scriptName }));
|
||||||
`This function needs "node-hdiffpatch".
|
|
||||||
Please run "npm i node-hdiffpatch" to install`,
|
|
||||||
);
|
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
diff = hdiff;
|
diff = hdiff;
|
||||||
} else {
|
} else {
|
||||||
if (!bsdiff) {
|
if (!bsdiff) {
|
||||||
console.error(
|
console.error(t('nodeBsdiffRequired', { scriptName }));
|
||||||
`This function needs "node-bsdiff".
|
|
||||||
Please run "npm i node-bsdiff" to install`,
|
|
||||||
);
|
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
diff = bsdiff;
|
diff = bsdiff;
|
||||||
}
|
}
|
||||||
const { output } = options;
|
const { output } = translateOptions({
|
||||||
|
...options,
|
||||||
|
tempDir,
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
origin,
|
origin,
|
||||||
@@ -932,7 +888,7 @@ export const bundleCommands = {
|
|||||||
taro,
|
taro,
|
||||||
expo,
|
expo,
|
||||||
rncli,
|
rncli,
|
||||||
disableHermes,
|
hermes,
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
metaInfo,
|
metaInfo,
|
||||||
@@ -973,7 +929,7 @@ export const bundleCommands = {
|
|||||||
outputFolder: intermediaDir,
|
outputFolder: intermediaDir,
|
||||||
platform,
|
platform,
|
||||||
sourcemapOutput: sourcemap || sourcemapPlugin ? sourcemapOutput : '',
|
sourcemapOutput: sourcemap || sourcemapPlugin ? sourcemapOutput : '',
|
||||||
disableHermes: !!disableHermes,
|
forceHermes: hermes as unknown as boolean,
|
||||||
cli: {
|
cli: {
|
||||||
taro: !!taro,
|
taro: !!taro,
|
||||||
expo: !!expo,
|
expo: !!expo,
|
||||||
@@ -1040,14 +996,14 @@ export const bundleCommands = {
|
|||||||
const { origin, next, realOutput } = diffArgsCheck(args, options, 'diff');
|
const { origin, next, realOutput } = diffArgsCheck(args, options, 'diff');
|
||||||
|
|
||||||
await diffFromPPK(origin, next, realOutput);
|
await diffFromPPK(origin, next, realOutput);
|
||||||
console.log(`${realOutput} generated.`);
|
console.log(t('diffPackageGenerated', { output: realOutput }));
|
||||||
},
|
},
|
||||||
|
|
||||||
async hdiff({ args, options }) {
|
async hdiff({ args, options }) {
|
||||||
const { origin, next, realOutput } = diffArgsCheck(args, options, 'hdiff');
|
const { origin, next, realOutput } = diffArgsCheck(args, options, 'hdiff');
|
||||||
|
|
||||||
await diffFromPPK(origin, next, realOutput);
|
await diffFromPPK(origin, next, realOutput);
|
||||||
console.log(`${realOutput} generated.`);
|
console.log(t('diffPackageGenerated', { output: realOutput }));
|
||||||
},
|
},
|
||||||
|
|
||||||
async diffFromApk({ args, options }) {
|
async diffFromApk({ args, options }) {
|
||||||
@@ -1063,7 +1019,7 @@ export const bundleCommands = {
|
|||||||
realOutput,
|
realOutput,
|
||||||
'assets/index.android.bundle',
|
'assets/index.android.bundle',
|
||||||
);
|
);
|
||||||
console.log(`${realOutput} generated.`);
|
console.log(t('diffPackageGenerated', { output: realOutput }));
|
||||||
},
|
},
|
||||||
|
|
||||||
async hdiffFromApk({ args, options }) {
|
async hdiffFromApk({ args, options }) {
|
||||||
@@ -1079,7 +1035,7 @@ export const bundleCommands = {
|
|||||||
realOutput,
|
realOutput,
|
||||||
'assets/index.android.bundle',
|
'assets/index.android.bundle',
|
||||||
);
|
);
|
||||||
console.log(`${realOutput} generated.`);
|
console.log(t('diffPackageGenerated', { output: realOutput }));
|
||||||
},
|
},
|
||||||
|
|
||||||
async diffFromApp({ args, options }) {
|
async diffFromApp({ args, options }) {
|
||||||
@@ -1094,7 +1050,7 @@ export const bundleCommands = {
|
|||||||
realOutput,
|
realOutput,
|
||||||
'resources/rawfile/bundle.harmony.js',
|
'resources/rawfile/bundle.harmony.js',
|
||||||
);
|
);
|
||||||
console.log(`${realOutput} generated.`);
|
console.log(t('diffPackageGenerated', { output: realOutput }));
|
||||||
},
|
},
|
||||||
|
|
||||||
async hdiffFromApp({ args, options }) {
|
async hdiffFromApp({ args, options }) {
|
||||||
@@ -1109,7 +1065,7 @@ export const bundleCommands = {
|
|||||||
realOutput,
|
realOutput,
|
||||||
'resources/rawfile/bundle.harmony.js',
|
'resources/rawfile/bundle.harmony.js',
|
||||||
);
|
);
|
||||||
console.log(`${realOutput} generated.`);
|
console.log(t('diffPackageGenerated', { output: realOutput }));
|
||||||
},
|
},
|
||||||
|
|
||||||
async diffFromIpa({ args, options }) {
|
async diffFromIpa({ args, options }) {
|
||||||
@@ -1124,7 +1080,7 @@ export const bundleCommands = {
|
|||||||
return m?.[1];
|
return m?.[1];
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(`${realOutput} generated.`);
|
console.log(t('diffPackageGenerated', { output: realOutput }));
|
||||||
},
|
},
|
||||||
|
|
||||||
async hdiffFromIpa({ args, options }) {
|
async hdiffFromIpa({ args, options }) {
|
||||||
@@ -1139,6 +1095,6 @@ export const bundleCommands = {
|
|||||||
return m?.[1];
|
return m?.[1];
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(`${realOutput} generated.`);
|
console.log(t('diffPackageGenerated', { output: realOutput }));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import { loadSession } from './api';
|
import { loadSession } from './api';
|
||||||
import { appCommands } from './app';
|
import { appCommands } from './app';
|
||||||
import { bundleCommands } from './bundle';
|
import { bundleCommands } from './bundle';
|
||||||
|
import { installCommands } from './install';
|
||||||
import { moduleManager } from './module-manager';
|
import { moduleManager } from './module-manager';
|
||||||
import { builtinModules } from './modules';
|
import { builtinModules } from './modules';
|
||||||
import { packageCommands } from './package';
|
import { packageCommands } from './package';
|
||||||
@@ -33,6 +34,7 @@ function printUsage() {
|
|||||||
...appCommands,
|
...appCommands,
|
||||||
...packageCommands,
|
...packageCommands,
|
||||||
...versionCommands,
|
...versionCommands,
|
||||||
|
...installCommands,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const [name, handler] of Object.entries(legacyCommands)) {
|
for (const [name, handler] of Object.entries(legacyCommands)) {
|
||||||
@@ -76,6 +78,7 @@ const legacyCommands = {
|
|||||||
...appCommands,
|
...appCommands,
|
||||||
...packageCommands,
|
...packageCommands,
|
||||||
...versionCommands,
|
...versionCommands,
|
||||||
|
...installCommands,
|
||||||
help: printUsage,
|
help: printUsage,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
19
src/install.ts
Normal file
19
src/install.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import { spawnSync } from 'child_process';
|
||||||
|
import path from 'path';
|
||||||
|
import type { CommandContext } from './types';
|
||||||
|
|
||||||
|
export const installCommands = {
|
||||||
|
install: async ({ args }: CommandContext) => {
|
||||||
|
if (args.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const cliDir = path.resolve(__dirname, '..');
|
||||||
|
|
||||||
|
spawnSync('npm', ['install', ...args], {
|
||||||
|
cwd: cliDir,
|
||||||
|
stdio: 'inherit',
|
||||||
|
shell: true,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -49,7 +49,7 @@ export default {
|
|||||||
fileGenerated: '{{- file}} generated.',
|
fileGenerated: '{{- file}} generated.',
|
||||||
fileSizeExceeded:
|
fileSizeExceeded:
|
||||||
'This file size is {{fileSize}} , exceeding the current quota {{maxSize}} . You may consider upgrading to a higher plan to increase this quota. Details can be found at: {{- pricingPageUrl}}',
|
'This file size is {{fileSize}} , exceeding the current quota {{maxSize}} . You may consider upgrading to a higher plan to increase this quota. Details can be found at: {{- pricingPageUrl}}',
|
||||||
hermesDisabled: 'Hermes disabled',
|
forceHermes: 'Forcing Hermes enabled for this build',
|
||||||
hermesEnabledCompiling: 'Hermes enabled, now compiling to hermes bytecode:\n',
|
hermesEnabledCompiling: 'Hermes enabled, now compiling to hermes bytecode:\n',
|
||||||
ipaUploadSuccess:
|
ipaUploadSuccess:
|
||||||
'Successfully uploaded IPA native package (id: {{id}}, version: {{version}}, buildTime: {{buildTime}})',
|
'Successfully uploaded IPA native package (id: {{id}}, version: {{version}}, buildTime: {{buildTime}})',
|
||||||
@@ -115,6 +115,7 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
|
|||||||
uploadingSourcemap: 'Uploading sourcemap',
|
uploadingSourcemap: 'Uploading sourcemap',
|
||||||
usageDiff: 'Usage: cresc {{command}} <origin> <next>',
|
usageDiff: 'Usage: cresc {{command}} <origin> <next>',
|
||||||
usageParseApk: 'Usage: cresc parseApk <apk file>',
|
usageParseApk: 'Usage: cresc parseApk <apk file>',
|
||||||
|
usageParseAab: 'Usage: cresc parseAab <aab file>',
|
||||||
usageParseApp: 'Usage: cresc parseApp <app file>',
|
usageParseApp: 'Usage: cresc parseApp <app file>',
|
||||||
usageParseIpa: 'Usage: cresc parseIpa <ipa file>',
|
usageParseIpa: 'Usage: cresc parseIpa <ipa file>',
|
||||||
usageUnderDevelopment: 'Usage is under development now.',
|
usageUnderDevelopment: 'Usage is under development now.',
|
||||||
@@ -130,4 +131,20 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
|
|||||||
updateNativePackageQuestion: 'Bind to native package now?(Y/N)',
|
updateNativePackageQuestion: 'Bind to native package now?(Y/N)',
|
||||||
unnamed: '(Unnamed)',
|
unnamed: '(Unnamed)',
|
||||||
dryRun: 'Below is the dry-run result, no actual operation will be performed:',
|
dryRun: 'Below is the dry-run result, no actual operation will be performed:',
|
||||||
|
usingCustomVersion: 'Using custom version: {{version}}',
|
||||||
|
confirmDeletePackage:
|
||||||
|
'Confirm delete native package {{packageId}}? This operation cannot be undone (Y/N):',
|
||||||
|
deletePackageSuccess: 'Native package {{packageId}} deleted successfully',
|
||||||
|
deletePackageError:
|
||||||
|
'Failed to delete native package {{packageId}}: {{error}}',
|
||||||
|
usageDeletePackage: 'Usage: cresc deletePackage [packageId] --appId [appId]',
|
||||||
|
deleteVersionSuccess: 'Version {{versionId}} deleted successfully',
|
||||||
|
deleteVersionError: 'Failed to delete version {{versionId}}: {{error}}',
|
||||||
|
bundleFileNotFound:
|
||||||
|
'Bundle file not found! Please use default bundle file name and path.',
|
||||||
|
diffPackageGenerated: '{{- output}} generated.',
|
||||||
|
nodeBsdiffRequired:
|
||||||
|
'This function needs "node-bsdiff". Please run "{{scriptName}} install node-bsdiff" to install',
|
||||||
|
nodeHdiffpatchRequired:
|
||||||
|
'This function needs "node-hdiffpatch". Please run "{{scriptName}} install node-hdiffpatch" to install',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export default {
|
|||||||
fileGenerated: '已生成 {{- file}}',
|
fileGenerated: '已生成 {{- file}}',
|
||||||
fileSizeExceeded:
|
fileSizeExceeded:
|
||||||
'此文件大小 {{fileSize}} , 超出当前额度 {{maxSize}} 。您可以考虑升级付费业务以提升此额度。详情请访问: {{- pricingPageUrl}}',
|
'此文件大小 {{fileSize}} , 超出当前额度 {{maxSize}} 。您可以考虑升级付费业务以提升此额度。详情请访问: {{- pricingPageUrl}}',
|
||||||
hermesDisabled: 'Hermes 已禁用',
|
forceHermes: '强制启用 Hermes 编译',
|
||||||
hermesEnabledCompiling: 'Hermes 已启用,正在编译为 hermes 字节码:\n',
|
hermesEnabledCompiling: 'Hermes 已启用,正在编译为 hermes 字节码:\n',
|
||||||
ipaUploadSuccess:
|
ipaUploadSuccess:
|
||||||
'已成功上传ipa原生包(id: {{id}}, version: {{version}}, buildTime: {{buildTime}})',
|
'已成功上传ipa原生包(id: {{id}}, version: {{version}}, buildTime: {{buildTime}})',
|
||||||
@@ -109,6 +109,7 @@ export default {
|
|||||||
uploadingSourcemap: '正在上传 sourcemap',
|
uploadingSourcemap: '正在上传 sourcemap',
|
||||||
usageDiff: '用法:pushy {{command}} <origin> <next>',
|
usageDiff: '用法:pushy {{command}} <origin> <next>',
|
||||||
usageParseApk: '使用方法: pushy parseApk apk后缀文件',
|
usageParseApk: '使用方法: pushy parseApk apk后缀文件',
|
||||||
|
usageParseAab: '使用方法: pushy parseAab aab后缀文件',
|
||||||
usageParseApp: '使用方法: pushy parseApp app后缀文件',
|
usageParseApp: '使用方法: pushy parseApp app后缀文件',
|
||||||
usageParseIpa: '使用方法: pushy parseIpa ipa后缀文件',
|
usageParseIpa: '使用方法: pushy parseIpa ipa后缀文件',
|
||||||
usageUploadApk: '使用方法: pushy uploadApk apk后缀文件',
|
usageUploadApk: '使用方法: pushy uploadApk apk后缀文件',
|
||||||
@@ -123,4 +124,18 @@ export default {
|
|||||||
updateNativePackageQuestion: '是否现在将此热更应用到原生包上?(Y/N)',
|
updateNativePackageQuestion: '是否现在将此热更应用到原生包上?(Y/N)',
|
||||||
unnamed: '(未命名)',
|
unnamed: '(未命名)',
|
||||||
dryRun: '以下是 dry-run 模拟运行结果,不会实际执行任何操作:',
|
dryRun: '以下是 dry-run 模拟运行结果,不会实际执行任何操作:',
|
||||||
|
usingCustomVersion: '使用自定义版本:{{version}}',
|
||||||
|
confirmDeletePackage: '确认删除原生包 {{packageId}}? 此操作不可撤销 (Y/N):',
|
||||||
|
deletePackageSuccess: '原生包 {{packageId}} 删除成功',
|
||||||
|
deletePackageError: '删除原生包 {{packageId}} 失败: {{error}}',
|
||||||
|
usageDeletePackage:
|
||||||
|
'使用方法: pushy deletePackage [packageId] --appId [appId]',
|
||||||
|
deleteVersionSuccess: '热更包 {{versionId}} 删除成功',
|
||||||
|
deleteVersionError: '删除热更包 {{versionId}} 失败: {{error}}',
|
||||||
|
bundleFileNotFound: '未找到 bundle 文件!请使用默认的 bundle 文件名和路径。',
|
||||||
|
diffPackageGenerated: '{{- output}} 已生成。',
|
||||||
|
nodeBsdiffRequired:
|
||||||
|
'此功能需要 "node-bsdiff"。请运行 "{{scriptName}} install node-bsdiff" 来安装',
|
||||||
|
nodeHdiffpatchRequired:
|
||||||
|
'此功能需要 "node-hdiffpatch"。请运行 "{{scriptName}} install node-hdiffpatch" 来安装',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -39,9 +39,9 @@ export class ModuleManager {
|
|||||||
module.init(this.provider);
|
module.init(this.provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(
|
// console.log(
|
||||||
`Module '${module.name}' (v${module.version}) registered successfully`,
|
// `Module '${module.name}' (v${module.version}) registered successfully`,
|
||||||
);
|
// );
|
||||||
}
|
}
|
||||||
|
|
||||||
unregisterModule(moduleName: string): void {
|
unregisterModule(moduleName: string): void {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export const bundleModule: CLIModule = {
|
|||||||
taro = false,
|
taro = false,
|
||||||
expo = false,
|
expo = false,
|
||||||
rncli = false,
|
rncli = false,
|
||||||
disableHermes = false,
|
hermes = false,
|
||||||
output,
|
output,
|
||||||
} = context.options;
|
} = context.options;
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ export const bundleModule: CLIModule = {
|
|||||||
taro,
|
taro,
|
||||||
expo,
|
expo,
|
||||||
rncli,
|
rncli,
|
||||||
disableHermes,
|
hermes,
|
||||||
intermediaDir: '${tempDir}/intermedia/${platform}',
|
intermediaDir: '${tempDir}/intermedia/${platform}',
|
||||||
output: '${tempDir}/output/${platform}.${time}.ppk',
|
output: '${tempDir}/output/${platform}.${time}.ppk',
|
||||||
};
|
};
|
||||||
@@ -170,10 +170,10 @@ export const bundleModule: CLIModule = {
|
|||||||
default: false,
|
default: false,
|
||||||
description: 'Use React Native CLI',
|
description: 'Use React Native CLI',
|
||||||
},
|
},
|
||||||
disableHermes: {
|
hermes: {
|
||||||
hasValue: false,
|
hasValue: false,
|
||||||
default: false,
|
default: false,
|
||||||
description: 'Disable Hermes',
|
description: 'Force enable Hermes',
|
||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
hasValue: true,
|
hasValue: true,
|
||||||
|
|||||||
133
src/package.ts
133
src/package.ts
@@ -1,4 +1,4 @@
|
|||||||
import { get, getAllPackages, post, uploadFile } from './api';
|
import { get, getAllPackages, post, uploadFile, doDelete } from './api';
|
||||||
import { question, saveToLocal } from './utils';
|
import { question, saveToLocal } from './utils';
|
||||||
import { t } from './utils/i18n';
|
import { t } from './utils/i18n';
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@ import { getPlatform, getSelectedApp } from './app';
|
|||||||
|
|
||||||
import Table from 'tty-table';
|
import Table from 'tty-table';
|
||||||
import type { Platform } from './types';
|
import type { Platform } from './types';
|
||||||
import { getApkInfo, getAppInfo, getIpaInfo } from './utils';
|
import { getApkInfo, getAppInfo, getIpaInfo, getAabInfo } from './utils';
|
||||||
import { depVersions } from './utils/dep-versions';
|
import { depVersions } from './utils/dep-versions';
|
||||||
import { getCommitInfo } from './utils/git';
|
import { getCommitInfo } from './utils/git';
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ export async function listPackage(appId: string) {
|
|||||||
const versionObj = version as any;
|
const versionObj = version as any;
|
||||||
versionInfo = t('boundTo', {
|
versionInfo = t('boundTo', {
|
||||||
name: versionObj.name || version,
|
name: versionObj.name || version,
|
||||||
id: versionObj.id || version
|
id: versionObj.id || version,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let output = pkg.name;
|
let output = pkg.name;
|
||||||
@@ -57,16 +57,19 @@ export async function choosePackage(appId: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const packageCommands = {
|
export const packageCommands = {
|
||||||
uploadIpa: async ({ args }: { args: string[] }) => {
|
uploadIpa: async ({
|
||||||
|
args,
|
||||||
|
options,
|
||||||
|
}: {
|
||||||
|
args: string[];
|
||||||
|
options: Record<string, any>;
|
||||||
|
}) => {
|
||||||
const fn = args[0];
|
const fn = args[0];
|
||||||
if (!fn || !fn.endsWith('.ipa')) {
|
if (!fn || !fn.endsWith('.ipa')) {
|
||||||
throw new Error(t('usageUploadIpa'));
|
throw new Error(t('usageUploadIpa'));
|
||||||
}
|
}
|
||||||
const ipaInfo = await getIpaInfo(fn);
|
const ipaInfo = await getIpaInfo(fn);
|
||||||
const {
|
const { versionName: extractedVersionName, buildTime } = ipaInfo;
|
||||||
versionName,
|
|
||||||
buildTime,
|
|
||||||
} = ipaInfo;
|
|
||||||
const appIdInPkg = (ipaInfo as any).appId;
|
const appIdInPkg = (ipaInfo as any).appId;
|
||||||
const appKeyInPkg = (ipaInfo as any).appKey;
|
const appKeyInPkg = (ipaInfo as any).appKey;
|
||||||
const { appId, appKey } = await getSelectedApp('ios');
|
const { appId, appKey } = await getSelectedApp('ios');
|
||||||
@@ -79,6 +82,12 @@ export const packageCommands = {
|
|||||||
throw new Error(t('appKeyMismatchIpa', { appKeyInPkg, appKey }));
|
throw new Error(t('appKeyMismatchIpa', { appKeyInPkg, appKey }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use custom version if provided, otherwise use extracted version
|
||||||
|
const versionName = options.version || extractedVersionName;
|
||||||
|
if (options.version) {
|
||||||
|
console.log(t('usingCustomVersion', { version: versionName }));
|
||||||
|
}
|
||||||
|
|
||||||
const { hash } = await uploadFile(fn);
|
const { hash } = await uploadFile(fn);
|
||||||
|
|
||||||
const { id } = await post(`/app/${appId}/package/create`, {
|
const { id } = await post(`/app/${appId}/package/create`, {
|
||||||
@@ -89,20 +98,21 @@ export const packageCommands = {
|
|||||||
commit: await getCommitInfo(),
|
commit: await getCommitInfo(),
|
||||||
});
|
});
|
||||||
saveToLocal(fn, `${appId}/package/${id}.ipa`);
|
saveToLocal(fn, `${appId}/package/${id}.ipa`);
|
||||||
console.log(
|
console.log(t('ipaUploadSuccess', { id, version: versionName, buildTime }));
|
||||||
t('ipaUploadSuccess', { id, version: versionName, buildTime }),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
uploadApk: async ({ args }: { args: string[] }) => {
|
uploadApk: async ({
|
||||||
|
args,
|
||||||
|
options,
|
||||||
|
}: {
|
||||||
|
args: string[];
|
||||||
|
options: Record<string, any>;
|
||||||
|
}) => {
|
||||||
const fn = args[0];
|
const fn = args[0];
|
||||||
if (!fn || !fn.endsWith('.apk')) {
|
if (!fn || !fn.endsWith('.apk')) {
|
||||||
throw new Error(t('usageUploadApk'));
|
throw new Error(t('usageUploadApk'));
|
||||||
}
|
}
|
||||||
const apkInfo = await getApkInfo(fn);
|
const apkInfo = await getApkInfo(fn);
|
||||||
const {
|
const { versionName: extractedVersionName, buildTime } = apkInfo;
|
||||||
versionName,
|
|
||||||
buildTime,
|
|
||||||
} = apkInfo;
|
|
||||||
const appIdInPkg = (apkInfo as any).appId;
|
const appIdInPkg = (apkInfo as any).appId;
|
||||||
const appKeyInPkg = (apkInfo as any).appKey;
|
const appKeyInPkg = (apkInfo as any).appKey;
|
||||||
const { appId, appKey } = await getSelectedApp('android');
|
const { appId, appKey } = await getSelectedApp('android');
|
||||||
@@ -115,6 +125,12 @@ export const packageCommands = {
|
|||||||
throw new Error(t('appKeyMismatchApk', { appKeyInPkg, appKey }));
|
throw new Error(t('appKeyMismatchApk', { appKeyInPkg, appKey }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use custom version if provided, otherwise use extracted version
|
||||||
|
const versionName = options.version || extractedVersionName;
|
||||||
|
if (options.version) {
|
||||||
|
console.log(t('usingCustomVersion', { version: versionName }));
|
||||||
|
}
|
||||||
|
|
||||||
const { hash } = await uploadFile(fn);
|
const { hash } = await uploadFile(fn);
|
||||||
|
|
||||||
const { id } = await post(`/app/${appId}/package/create`, {
|
const { id } = await post(`/app/${appId}/package/create`, {
|
||||||
@@ -125,20 +141,21 @@ export const packageCommands = {
|
|||||||
commit: await getCommitInfo(),
|
commit: await getCommitInfo(),
|
||||||
});
|
});
|
||||||
saveToLocal(fn, `${appId}/package/${id}.apk`);
|
saveToLocal(fn, `${appId}/package/${id}.apk`);
|
||||||
console.log(
|
console.log(t('apkUploadSuccess', { id, version: versionName, buildTime }));
|
||||||
t('apkUploadSuccess', { id, version: versionName, buildTime }),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
uploadApp: async ({ args }: { args: string[] }) => {
|
uploadApp: async ({
|
||||||
|
args,
|
||||||
|
options,
|
||||||
|
}: {
|
||||||
|
args: string[];
|
||||||
|
options: Record<string, any>;
|
||||||
|
}) => {
|
||||||
const fn = args[0];
|
const fn = args[0];
|
||||||
if (!fn || !fn.endsWith('.app')) {
|
if (!fn || !fn.endsWith('.app')) {
|
||||||
throw new Error(t('usageUploadApp'));
|
throw new Error(t('usageUploadApp'));
|
||||||
}
|
}
|
||||||
const appInfo = await getAppInfo(fn);
|
const appInfo = await getAppInfo(fn);
|
||||||
const {
|
const { versionName: extractedVersionName, buildTime } = appInfo;
|
||||||
versionName,
|
|
||||||
buildTime,
|
|
||||||
} = appInfo;
|
|
||||||
const appIdInPkg = (appInfo as any).appId;
|
const appIdInPkg = (appInfo as any).appId;
|
||||||
const appKeyInPkg = (appInfo as any).appKey;
|
const appKeyInPkg = (appInfo as any).appKey;
|
||||||
const { appId, appKey } = await getSelectedApp('harmony');
|
const { appId, appKey } = await getSelectedApp('harmony');
|
||||||
@@ -151,6 +168,12 @@ export const packageCommands = {
|
|||||||
throw new Error(t('appKeyMismatchApp', { appKeyInPkg, appKey }));
|
throw new Error(t('appKeyMismatchApp', { appKeyInPkg, appKey }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use custom version if provided, otherwise use extracted version
|
||||||
|
const versionName = options.version || extractedVersionName;
|
||||||
|
if (options.version) {
|
||||||
|
console.log(t('usingCustomVersion', { version: versionName }));
|
||||||
|
}
|
||||||
|
|
||||||
const { hash } = await uploadFile(fn);
|
const { hash } = await uploadFile(fn);
|
||||||
|
|
||||||
const { id } = await post(`/app/${appId}/package/create`, {
|
const { id } = await post(`/app/${appId}/package/create`, {
|
||||||
@@ -161,9 +184,7 @@ export const packageCommands = {
|
|||||||
commit: await getCommitInfo(),
|
commit: await getCommitInfo(),
|
||||||
});
|
});
|
||||||
saveToLocal(fn, `${appId}/package/${id}.app`);
|
saveToLocal(fn, `${appId}/package/${id}.app`);
|
||||||
console.log(
|
console.log(t('appUploadSuccess', { id, version: versionName, buildTime }));
|
||||||
t('appUploadSuccess', { id, version: versionName, buildTime }),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
parseApp: async ({ args }: { args: string[] }) => {
|
parseApp: async ({ args }: { args: string[] }) => {
|
||||||
const fn = args[0];
|
const fn = args[0];
|
||||||
@@ -186,9 +207,67 @@ export const packageCommands = {
|
|||||||
}
|
}
|
||||||
console.log(await getApkInfo(fn));
|
console.log(await getApkInfo(fn));
|
||||||
},
|
},
|
||||||
|
parseAab: async ({ args }: { args: string[] }) => {
|
||||||
|
const fn = args[0];
|
||||||
|
if (!fn || !fn.endsWith('.aab')) {
|
||||||
|
throw new Error(t('usageParseAab'));
|
||||||
|
}
|
||||||
|
console.log(await getAabInfo(fn));
|
||||||
|
},
|
||||||
packages: async ({ options }: { options: { platform: Platform } }) => {
|
packages: async ({ options }: { options: { platform: Platform } }) => {
|
||||||
const platform = await getPlatform(options.platform);
|
const platform = await getPlatform(options.platform);
|
||||||
const { appId } = await getSelectedApp(platform);
|
const { appId } = await getSelectedApp(platform);
|
||||||
await listPackage(appId);
|
await listPackage(appId);
|
||||||
},
|
},
|
||||||
|
deletePackage: async ({
|
||||||
|
args,
|
||||||
|
options,
|
||||||
|
}: {
|
||||||
|
args: string[];
|
||||||
|
options: { appId?: string; packageId?: string; packageVersion?: string };
|
||||||
|
}) => {
|
||||||
|
let { appId, packageId, packageVersion } = options;
|
||||||
|
|
||||||
|
if (!appId) {
|
||||||
|
const platform = await getPlatform();
|
||||||
|
appId = (await getSelectedApp(platform)).appId as string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no packageId provided as argument, let user choose from list
|
||||||
|
if (!packageId) {
|
||||||
|
const allPkgs = await getAllPackages(appId);
|
||||||
|
if (!allPkgs) {
|
||||||
|
throw new Error(t('noPackagesFound', { appId }));
|
||||||
|
}
|
||||||
|
const selectedPackage = allPkgs.find(
|
||||||
|
(pkg) => pkg.name === packageVersion,
|
||||||
|
);
|
||||||
|
if (!selectedPackage) {
|
||||||
|
throw new Error(t('packageNotFound', { packageVersion }));
|
||||||
|
}
|
||||||
|
packageId = selectedPackage.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Confirm deletion
|
||||||
|
// const confirmDelete = await question(
|
||||||
|
// t('confirmDeletePackage', { packageId }),
|
||||||
|
// );
|
||||||
|
|
||||||
|
// if (
|
||||||
|
// confirmDelete.toLowerCase() !== 'y' &&
|
||||||
|
// confirmDelete.toLowerCase() !== 'yes'
|
||||||
|
// ) {
|
||||||
|
// console.log(t('cancelled'));
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
try {
|
||||||
|
await doDelete(`/app/${appId}/package/${packageId}`);
|
||||||
|
console.log(t('deletePackageSuccess', { packageId }));
|
||||||
|
} catch (error: any) {
|
||||||
|
throw new Error(
|
||||||
|
t('deletePackageError', { packageId, error: error.message }),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export class CLIProviderImpl implements CLIProvider {
|
|||||||
taro: options.taro || false,
|
taro: options.taro || false,
|
||||||
expo: options.expo || false,
|
expo: options.expo || false,
|
||||||
rncli: options.rncli || false,
|
rncli: options.rncli || false,
|
||||||
disableHermes: options.disableHermes || false,
|
hermes: options.hermes || false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ export class CLIProviderImpl implements CLIProvider {
|
|||||||
|
|
||||||
const context: CommandContext = {
|
const context: CommandContext = {
|
||||||
args: [filePath],
|
args: [filePath],
|
||||||
options: { platform, appId },
|
options: { platform, appId, version: options.version },
|
||||||
};
|
};
|
||||||
|
|
||||||
const { packageCommands } = await import('./package');
|
const { packageCommands } = await import('./package');
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ export interface BundleOptions {
|
|||||||
taro?: boolean;
|
taro?: boolean;
|
||||||
expo?: boolean;
|
expo?: boolean;
|
||||||
rncli?: boolean;
|
rncli?: boolean;
|
||||||
disableHermes?: boolean;
|
hermes?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PublishOptions {
|
export interface PublishOptions {
|
||||||
@@ -85,6 +85,7 @@ export interface UploadOptions {
|
|||||||
platform?: Platform;
|
platform?: Platform;
|
||||||
filePath: string;
|
filePath: string;
|
||||||
appId?: string;
|
appId?: string;
|
||||||
|
version?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WorkflowStep {
|
export interface WorkflowStep {
|
||||||
|
|||||||
326
src/utils/app-info-parser/aab.js
Normal file
326
src/utils/app-info-parser/aab.js
Normal file
@@ -0,0 +1,326 @@
|
|||||||
|
const Zip = require('./zip');
|
||||||
|
const yazl = require('yazl');
|
||||||
|
const fs = require('fs-extra');
|
||||||
|
const path = require('path');
|
||||||
|
const { open: openZipFile } = require('yauzl');
|
||||||
|
const os = require('os');
|
||||||
|
|
||||||
|
class AabParser extends Zip {
|
||||||
|
/**
|
||||||
|
* parser for parsing .aab file
|
||||||
|
* @param {String | File | Blob} file // file's path in Node, instance of File or Blob in Browser
|
||||||
|
*/
|
||||||
|
constructor(file) {
|
||||||
|
super(file);
|
||||||
|
if (!(this instanceof AabParser)) {
|
||||||
|
return new AabParser(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从 AAB 提取通用 APK
|
||||||
|
* 这个方法会合并 base/ 和所有 split/ 目录的内容
|
||||||
|
*
|
||||||
|
* @param {String} outputPath - 输出 APK 文件路径
|
||||||
|
* @param {Object} options - 选项
|
||||||
|
* @param {Boolean} options.includeAllSplits - 是否包含所有 split APK(默认 false,只提取 base)
|
||||||
|
* @param {Array<String>} options.splits - 指定要包含的 split APK 名称(如果指定,则只包含这些)
|
||||||
|
* @returns {Promise<String>} 返回输出文件路径
|
||||||
|
*/
|
||||||
|
async extractApk(outputPath, options = {}) {
|
||||||
|
const { includeAllSplits = false, splits = null } = options;
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (typeof this.file !== 'string') {
|
||||||
|
return reject(
|
||||||
|
new Error('AAB file path must be a string in Node.js environment'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
openZipFile(this.file, { lazyEntries: true }, async (err, zipfile) => {
|
||||||
|
if (err) {
|
||||||
|
return reject(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 1. 收集所有条目及其数据
|
||||||
|
const baseEntries = [];
|
||||||
|
const splitEntries = [];
|
||||||
|
const metaInfEntries = [];
|
||||||
|
let pendingReads = 0;
|
||||||
|
let hasError = false;
|
||||||
|
|
||||||
|
const processEntry = (entry, fileName) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
zipfile.openReadStream(entry, (err, readStream) => {
|
||||||
|
if (err) {
|
||||||
|
return reject(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
const chunks = [];
|
||||||
|
readStream.on('data', (chunk) => chunks.push(chunk));
|
||||||
|
readStream.on('end', () => {
|
||||||
|
const buffer = Buffer.concat(chunks);
|
||||||
|
resolve(buffer);
|
||||||
|
});
|
||||||
|
readStream.on('error', reject);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
zipfile.on('entry', async (entry) => {
|
||||||
|
const fileName = entry.fileName;
|
||||||
|
|
||||||
|
// 跳过目录
|
||||||
|
if (fileName.endsWith('/')) {
|
||||||
|
zipfile.readEntry();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pendingReads++;
|
||||||
|
try {
|
||||||
|
const buffer = await processEntry(entry, fileName);
|
||||||
|
|
||||||
|
if (fileName.startsWith('base/')) {
|
||||||
|
// 将 base/manifest/AndroidManifest.xml 转换为 androidmanifest.xml(APK 中通常是小写)
|
||||||
|
// 将 base/resources.arsc 转换为 resources.arsc
|
||||||
|
let apkPath = fileName.replace(/^base\//, '');
|
||||||
|
if (apkPath === 'manifest/AndroidManifest.xml') {
|
||||||
|
apkPath = 'androidmanifest.xml';
|
||||||
|
}
|
||||||
|
|
||||||
|
baseEntries.push({
|
||||||
|
buffer,
|
||||||
|
zipPath: fileName,
|
||||||
|
apkPath,
|
||||||
|
});
|
||||||
|
} else if (fileName.startsWith('split/')) {
|
||||||
|
splitEntries.push({
|
||||||
|
buffer,
|
||||||
|
zipPath: fileName,
|
||||||
|
});
|
||||||
|
} else if (fileName.startsWith('META-INF/')) {
|
||||||
|
metaInfEntries.push({
|
||||||
|
buffer,
|
||||||
|
zipPath: fileName,
|
||||||
|
apkPath: fileName,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// BundleConfig.pb 和其他文件不需要包含在 APK 中
|
||||||
|
|
||||||
|
pendingReads--;
|
||||||
|
zipfile.readEntry();
|
||||||
|
} catch (error) {
|
||||||
|
pendingReads--;
|
||||||
|
if (!hasError) {
|
||||||
|
hasError = true;
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
zipfile.readEntry();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
zipfile.on('end', async () => {
|
||||||
|
// 等待所有读取完成
|
||||||
|
while (pendingReads > 0) {
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasError) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 2. 创建新的 APK 文件
|
||||||
|
const zipFile = new yazl.ZipFile();
|
||||||
|
|
||||||
|
// 3. 添加 base 目录的所有文件
|
||||||
|
for (const { buffer, apkPath } of baseEntries) {
|
||||||
|
zipFile.addBuffer(buffer, apkPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 添加 split APK 的内容(如果需要)
|
||||||
|
if (includeAllSplits || splits) {
|
||||||
|
const splitsToInclude = splits
|
||||||
|
? splitEntries.filter((se) =>
|
||||||
|
splits.some((s) => se.zipPath.includes(s)),
|
||||||
|
)
|
||||||
|
: splitEntries;
|
||||||
|
|
||||||
|
await this.mergeSplitApksFromBuffers(zipFile, splitsToInclude);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. 添加 META-INF(签名信息,虽然可能无效,但保留结构)
|
||||||
|
for (const { buffer, apkPath } of metaInfEntries) {
|
||||||
|
zipFile.addBuffer(buffer, apkPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6. 写入文件
|
||||||
|
zipFile.outputStream
|
||||||
|
.pipe(fs.createWriteStream(outputPath))
|
||||||
|
.on('close', () => {
|
||||||
|
resolve(outputPath);
|
||||||
|
})
|
||||||
|
.on('error', (err) => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
|
||||||
|
zipFile.end();
|
||||||
|
} catch (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
zipfile.on('error', reject);
|
||||||
|
zipfile.readEntry();
|
||||||
|
} catch (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 合并 split APK 的内容(从已读取的 buffer)
|
||||||
|
*/
|
||||||
|
async mergeSplitApksFromBuffers(zipFile, splitEntries) {
|
||||||
|
for (const { buffer: splitBuffer } of splitEntries) {
|
||||||
|
if (splitBuffer) {
|
||||||
|
// 创建一个临时的 ZIP 文件来读取 split APK
|
||||||
|
const tempSplitPath = path.join(
|
||||||
|
os.tmpdir(),
|
||||||
|
`split_${Date.now()}_${Math.random().toString(36).substr(2, 9)}.apk`,
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await fs.writeFile(tempSplitPath, splitBuffer);
|
||||||
|
|
||||||
|
await new Promise((resolve, reject) => {
|
||||||
|
openZipFile(
|
||||||
|
tempSplitPath,
|
||||||
|
{ lazyEntries: true },
|
||||||
|
async (err, splitZipfile) => {
|
||||||
|
if (err) {
|
||||||
|
return reject(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
splitZipfile.on('entry', (splitEntry) => {
|
||||||
|
// 跳过 META-INF,因为签名信息不需要合并
|
||||||
|
if (splitEntry.fileName.startsWith('META-INF/')) {
|
||||||
|
splitZipfile.readEntry();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
splitZipfile.openReadStream(splitEntry, (err, readStream) => {
|
||||||
|
if (err) {
|
||||||
|
splitZipfile.readEntry();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const chunks = [];
|
||||||
|
readStream.on('data', (chunk) => chunks.push(chunk));
|
||||||
|
readStream.on('end', () => {
|
||||||
|
const buffer = Buffer.concat(chunks);
|
||||||
|
// 注意:如果文件已存在(在 base 中),split 中的会覆盖 base 中的
|
||||||
|
zipFile.addBuffer(buffer, splitEntry.fileName);
|
||||||
|
splitZipfile.readEntry();
|
||||||
|
});
|
||||||
|
readStream.on('error', () => {
|
||||||
|
splitZipfile.readEntry();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
splitZipfile.on('end', resolve);
|
||||||
|
splitZipfile.on('error', reject);
|
||||||
|
splitZipfile.readEntry();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
// 清理临时文件
|
||||||
|
await fs.remove(tempSplitPath).catch(() => {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析 AAB 文件信息(类似 APK parser 的 parse 方法)
|
||||||
|
* 注意:AAB 中的 AndroidManifest.xml 在 base/manifest/AndroidManifest.xml
|
||||||
|
*/
|
||||||
|
async parse() {
|
||||||
|
// 尝试从 base/manifest/AndroidManifest.xml 读取 manifest
|
||||||
|
// 但 AAB 中的 manifest 可能是二进制格式,需要特殊处理
|
||||||
|
const manifestPath = 'base/manifest/AndroidManifest.xml';
|
||||||
|
const ResourceName = /^base\/resources\.arsc$/;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const manifestBuffer = await this.getEntry(
|
||||||
|
new RegExp(`^${manifestPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}$`),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!manifestBuffer) {
|
||||||
|
throw new Error(
|
||||||
|
"AndroidManifest.xml can't be found in AAB base/manifest/",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
let apkInfo = this._parseManifest(manifestBuffer);
|
||||||
|
|
||||||
|
// 尝试解析 resources.arsc
|
||||||
|
try {
|
||||||
|
const resourceBuffer = await this.getEntry(ResourceName);
|
||||||
|
if (resourceBuffer) {
|
||||||
|
const resourceMap = this._parseResourceMap(resourceBuffer);
|
||||||
|
const { mapInfoResource } = require('./utils');
|
||||||
|
apkInfo = mapInfoResource(apkInfo, resourceMap);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// resources.arsc 解析失败不影响基本信息
|
||||||
|
console.warn('[Warning] Failed to parse resources.arsc:', e.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return apkInfo;
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error(`Failed to parse AAB: ${error.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse manifest
|
||||||
|
* @param {Buffer} buffer // manifest file's buffer
|
||||||
|
*/
|
||||||
|
_parseManifest(buffer) {
|
||||||
|
try {
|
||||||
|
const ManifestXmlParser = require('./xml-parser/manifest');
|
||||||
|
const parser = new ManifestXmlParser(buffer, {
|
||||||
|
ignore: [
|
||||||
|
'application.activity',
|
||||||
|
'application.service',
|
||||||
|
'application.receiver',
|
||||||
|
'application.provider',
|
||||||
|
'permission-group',
|
||||||
|
],
|
||||||
|
});
|
||||||
|
return parser.parse();
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error('Parse AndroidManifest.xml error: ' + e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse resourceMap
|
||||||
|
* @param {Buffer} buffer // resourceMap file's buffer
|
||||||
|
*/
|
||||||
|
_parseResourceMap(buffer) {
|
||||||
|
try {
|
||||||
|
const ResourceFinder = require('./resource-finder');
|
||||||
|
return new ResourceFinder().processResourceTable(buffer);
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error('Parser resources.arsc error: ' + e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = AabParser;
|
||||||
@@ -81,7 +81,7 @@ class ApkParser extends Zip {
|
|||||||
});
|
});
|
||||||
return parser.parse();
|
return parser.parse();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error('Parse AndroidManifest.xml error: ', e);
|
throw new Error('Parse AndroidManifest.xml error: ' + (e.message || e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
const ApkParser = require('./apk');
|
const ApkParser = require('./apk');
|
||||||
const IpaParser = require('./ipa');
|
const IpaParser = require('./ipa');
|
||||||
const AppParser = require('./app');
|
const AppParser = require('./app');
|
||||||
const supportFileTypes = ['ipa', 'apk', 'app'];
|
const AabParser = require('./aab');
|
||||||
|
const supportFileTypes = ['ipa', 'apk', 'app', 'aab'];
|
||||||
|
|
||||||
class AppInfoParser {
|
class AppInfoParser {
|
||||||
file: string | File;
|
file: string | File;
|
||||||
@@ -20,7 +21,7 @@ class AppInfoParser {
|
|||||||
const fileType = splits[splits.length - 1].toLowerCase();
|
const fileType = splits[splits.length - 1].toLowerCase();
|
||||||
if (!supportFileTypes.includes(fileType)) {
|
if (!supportFileTypes.includes(fileType)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Unsupported file type, only support .ipa or .apk or .app file.',
|
'Unsupported file type, only support .ipa, .apk, .app, or .aab file.',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
this.file = file;
|
this.file = file;
|
||||||
@@ -35,6 +36,9 @@ class AppInfoParser {
|
|||||||
case 'app':
|
case 'app':
|
||||||
this.parser = new AppParser(this.file);
|
this.parser = new AppParser(this.file);
|
||||||
break;
|
break;
|
||||||
|
case 'aab':
|
||||||
|
this.parser = new AabParser(this.file);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parse() {
|
parse() {
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
const scriptName = path.basename(process.argv[1]) as 'cresc' | 'pushy';
|
export const scriptName = path.basename(process.argv[1]) as 'cresc' | 'pushy';
|
||||||
export const IS_CRESC = scriptName === 'cresc';
|
export const IS_CRESC = scriptName === 'cresc';
|
||||||
|
|
||||||
|
export const ppkBundleFileNames = ['index.bundlejs', 'bundle.harmony.js'];
|
||||||
|
export const isPPKBundleFileName = (fileName: string) =>
|
||||||
|
ppkBundleFileNames.includes(fileName);
|
||||||
|
|
||||||
export const credentialFile = IS_CRESC ? '.cresc.token' : '.update';
|
export const credentialFile = IS_CRESC ? '.cresc.token' : '.update';
|
||||||
export const updateJson = IS_CRESC ? 'cresc.config.json' : 'update.json';
|
export const updateJson = IS_CRESC ? 'cresc.config.json' : 'update.json';
|
||||||
export const tempDir = IS_CRESC ? '.cresc.temp' : '.pushy';
|
export const tempDir = IS_CRESC ? '.cresc.temp' : '.pushy';
|
||||||
@@ -10,6 +14,6 @@ export const pricingPageUrl = IS_CRESC
|
|||||||
? 'https://cresc.dev/pricing'
|
? 'https://cresc.dev/pricing'
|
||||||
: 'https://pushy.reactnative.cn/pricing.html';
|
: 'https://pushy.reactnative.cn/pricing.html';
|
||||||
|
|
||||||
export const defaultEndpoint = IS_CRESC
|
export const defaultEndpoints = IS_CRESC
|
||||||
? 'https://api.cresc.dev'
|
? ['https://api.cresc.dev', 'https://api.cresc.app']
|
||||||
: 'https://update.reactnative.cn/api';
|
: ['https://update.reactnative.cn/api', 'https://update.react-native.cn/api'];
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
const currentPackage = require(`${process.cwd()}/package.json`);
|
let currentPackage = null;
|
||||||
|
try {
|
||||||
|
currentPackage = require(`${process.cwd()}/package.json`);
|
||||||
|
} catch (e) {
|
||||||
|
// console.warn('No package.json file were found');
|
||||||
|
}
|
||||||
|
|
||||||
const _depVersions: Record<string, string> = {};
|
const _depVersions: Record<string, string> = {};
|
||||||
|
|
||||||
@@ -24,12 +29,9 @@ if (currentPackage) {
|
|||||||
|
|
||||||
export const depVersions = Object.keys(_depVersions)
|
export const depVersions = Object.keys(_depVersions)
|
||||||
.sort() // Sort the keys alphabetically
|
.sort() // Sort the keys alphabetically
|
||||||
.reduce(
|
.reduce((obj, key) => {
|
||||||
(obj, key) => {
|
obj[key] = _depVersions[key]; // Rebuild the object with sorted keys
|
||||||
obj[key] = _depVersions[key]; // Rebuild the object with sorted keys
|
return obj;
|
||||||
return obj;
|
}, {} as Record<string, string>);
|
||||||
},
|
|
||||||
{} as Record<string, string>,
|
|
||||||
);
|
|
||||||
|
|
||||||
// console.log({ depVersions });
|
// console.log({ depVersions });
|
||||||
|
|||||||
84
src/utils/http-helper.ts
Normal file
84
src/utils/http-helper.ts
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
import { defaultEndpoints } from './constants';
|
||||||
|
import fetch from 'node-fetch';
|
||||||
|
|
||||||
|
// const baseUrl = `http://localhost:9000`;
|
||||||
|
// let baseUrl = SERVER.main[0];
|
||||||
|
// const baseUrl = `https://p.reactnative.cn/api`;
|
||||||
|
|
||||||
|
export function promiseAny<T>(promises: Promise<T>[]) {
|
||||||
|
return new Promise<T>((resolve, reject) => {
|
||||||
|
let count = 0;
|
||||||
|
|
||||||
|
for (const promise of promises) {
|
||||||
|
Promise.resolve(promise)
|
||||||
|
.then(resolve)
|
||||||
|
.catch(() => {
|
||||||
|
count++;
|
||||||
|
if (count === promises.length) {
|
||||||
|
reject(new Error('All promises were rejected'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ping = async (url: string) => {
|
||||||
|
let pingFinished = false;
|
||||||
|
return Promise.race([
|
||||||
|
fetch(url, {
|
||||||
|
method: 'HEAD',
|
||||||
|
})
|
||||||
|
.then(({ status, statusText }) => {
|
||||||
|
pingFinished = true;
|
||||||
|
if (status === 200) {
|
||||||
|
// console.log('ping success', url);
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
// console.log('ping failed', url, status, statusText);
|
||||||
|
throw new Error('ping failed');
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
pingFinished = true;
|
||||||
|
// console.log('ping error', url, e);
|
||||||
|
throw new Error('ping error');
|
||||||
|
}),
|
||||||
|
new Promise((_, reject) =>
|
||||||
|
setTimeout(() => {
|
||||||
|
reject(new Error('ping timeout'));
|
||||||
|
if (!pingFinished) {
|
||||||
|
// console.log('ping timeout', url);
|
||||||
|
}
|
||||||
|
}, 2000),
|
||||||
|
),
|
||||||
|
]) as Promise<string | null>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const testUrls = async (urls?: string[]) => {
|
||||||
|
if (!urls?.length) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const ret = await promiseAny(urls.map(ping));
|
||||||
|
if (ret) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
// console.log('all ping failed, use first url:', urls[0]);
|
||||||
|
return urls[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getBaseUrl = (async () => {
|
||||||
|
const testEndpoint = process.env.PUSHY_REGISTRY || process.env.RNU_API;
|
||||||
|
if (testEndpoint) {
|
||||||
|
return testEndpoint;
|
||||||
|
}
|
||||||
|
return testUrls(defaultEndpoints.map((url) => `${url}/status`)).then(
|
||||||
|
(ret) => {
|
||||||
|
let baseUrl = defaultEndpoints[0];
|
||||||
|
if (ret) {
|
||||||
|
// remove /status
|
||||||
|
baseUrl = ret.replace('/status', '');
|
||||||
|
}
|
||||||
|
// console.log('baseUrl', baseUrl);
|
||||||
|
return baseUrl;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
})();
|
||||||
@@ -149,6 +149,160 @@ export async function getIpaInfo(fn: string) {
|
|||||||
return { versionName, buildTime, ...appCredential };
|
return { versionName, buildTime, ...appCredential };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getAabInfo(fn: string) {
|
||||||
|
const protobuf = require('protobufjs');
|
||||||
|
const root = await protobuf.load(
|
||||||
|
path.join(__dirname, '../../proto/Resources.proto'),
|
||||||
|
);
|
||||||
|
const XmlNode = root.lookupType('aapt.pb.XmlNode');
|
||||||
|
|
||||||
|
const buffer = await readZipEntry(fn, 'base/manifest/AndroidManifest.xml');
|
||||||
|
|
||||||
|
const message = XmlNode.decode(buffer);
|
||||||
|
const object = XmlNode.toObject(message, {
|
||||||
|
enums: String,
|
||||||
|
longs: String,
|
||||||
|
bytes: String,
|
||||||
|
defaults: true,
|
||||||
|
arrays: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const manifestElement = object.element;
|
||||||
|
if (manifestElement.name !== 'manifest') {
|
||||||
|
throw new Error('Invalid manifest');
|
||||||
|
}
|
||||||
|
|
||||||
|
let versionName = '';
|
||||||
|
for (const attr of manifestElement.attribute) {
|
||||||
|
if (attr.name === 'versionName') {
|
||||||
|
versionName = attr.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let buildTime = 0;
|
||||||
|
const appCredential = {};
|
||||||
|
|
||||||
|
// Find application node
|
||||||
|
const applicationNode = manifestElement.child.find(
|
||||||
|
(c: any) => c.element && c.element.name === 'application',
|
||||||
|
);
|
||||||
|
if (applicationNode) {
|
||||||
|
const metaDataNodes = applicationNode.element.child.filter(
|
||||||
|
(c: any) => c.element && c.element.name === 'meta-data',
|
||||||
|
);
|
||||||
|
for (const meta of metaDataNodes) {
|
||||||
|
let name = '';
|
||||||
|
let value = '';
|
||||||
|
let resourceId = 0;
|
||||||
|
|
||||||
|
for (const attr of meta.element.attribute) {
|
||||||
|
if (attr.name === 'name') {
|
||||||
|
name = attr.value;
|
||||||
|
}
|
||||||
|
if (attr.name === 'value') {
|
||||||
|
value = attr.value;
|
||||||
|
if (attr.compiledItem?.ref?.id) {
|
||||||
|
resourceId = attr.compiledItem.ref.id;
|
||||||
|
} else if (attr.compiledItem?.prim?.intDecimalValue) {
|
||||||
|
value = attr.compiledItem.prim.intDecimalValue.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name === 'pushy_build_time') {
|
||||||
|
if (resourceId > 0) {
|
||||||
|
const resolvedValue = await resolveResource(fn, resourceId, root);
|
||||||
|
if (resolvedValue) {
|
||||||
|
value = resolvedValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buildTime = Number(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buildTime === 0) {
|
||||||
|
throw new Error(t('buildTimeNotFound'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return { versionName, buildTime, ...appCredential };
|
||||||
|
}
|
||||||
|
|
||||||
|
async function readZipEntry(fn: string, entryName: string): Promise<Buffer> {
|
||||||
|
const yauzl = require('yauzl');
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
yauzl.open(fn, { lazyEntries: true }, (err: any, zipfile: any) => {
|
||||||
|
if (err) return reject(err);
|
||||||
|
let found = false;
|
||||||
|
zipfile.readEntry();
|
||||||
|
zipfile.on('entry', (entry: any) => {
|
||||||
|
if (entry.fileName === entryName) {
|
||||||
|
found = true;
|
||||||
|
zipfile.openReadStream(entry, (err: any, readStream: any) => {
|
||||||
|
if (err) return reject(err);
|
||||||
|
const chunks: any[] = [];
|
||||||
|
readStream.on('data', (chunk: any) => chunks.push(chunk));
|
||||||
|
readStream.on('end', () => resolve(Buffer.concat(chunks)));
|
||||||
|
readStream.on('error', reject);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
zipfile.readEntry();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
zipfile.on('end', () => {
|
||||||
|
if (!found) reject(new Error(`${entryName} not found in AAB`));
|
||||||
|
});
|
||||||
|
zipfile.on('error', reject);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function resolveResource(
|
||||||
|
fn: string,
|
||||||
|
resourceId: number,
|
||||||
|
root: any,
|
||||||
|
): Promise<string | null> {
|
||||||
|
const pkgId = (resourceId >> 24) & 0xff;
|
||||||
|
const typeId = (resourceId >> 16) & 0xff;
|
||||||
|
const entryId = resourceId & 0xffff;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const buffer = await readZipEntry(fn, 'base/resources.pb');
|
||||||
|
const ResourceTable = root.lookupType('aapt.pb.ResourceTable');
|
||||||
|
const message = ResourceTable.decode(buffer);
|
||||||
|
const object = ResourceTable.toObject(message, {
|
||||||
|
enums: String,
|
||||||
|
longs: String,
|
||||||
|
bytes: String,
|
||||||
|
defaults: true,
|
||||||
|
arrays: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Find package
|
||||||
|
const pkg = object.package.find((p: any) => p.packageId === pkgId);
|
||||||
|
if (!pkg) return null;
|
||||||
|
|
||||||
|
// Find type
|
||||||
|
const type = pkg.type.find((t: any) => t.typeId === typeId);
|
||||||
|
if (!type) return null;
|
||||||
|
|
||||||
|
// Find entry
|
||||||
|
const entry = type.entry.find((e: any) => e.entryId === entryId);
|
||||||
|
if (!entry) return null;
|
||||||
|
|
||||||
|
// Get value from configValue
|
||||||
|
if (entry.configValue && entry.configValue.length > 0) {
|
||||||
|
const val = entry.configValue[0].value;
|
||||||
|
if (val.item?.str) {
|
||||||
|
return val.item.str.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('Failed to resolve resource:', e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const localDir = path.resolve(os.homedir(), tempDir);
|
const localDir = path.resolve(os.homedir(), tempDir);
|
||||||
fs.ensureDirSync(localDir);
|
fs.ensureDirSync(localDir);
|
||||||
export function saveToLocal(originPath: string, destName: string) {
|
export function saveToLocal(originPath: string, destName: string) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { get, getAllPackages, post, put, uploadFile } from './api';
|
import { get, getAllPackages, post, put, uploadFile, doDelete } from './api';
|
||||||
import { question, saveToLocal } from './utils';
|
import { question, saveToLocal } from './utils';
|
||||||
import { t } from './utils/i18n';
|
import { t } from './utils/i18n';
|
||||||
|
|
||||||
@@ -122,17 +122,6 @@ export const bindVersionToPackages = async ({
|
|||||||
console.log(chalk.yellow(t('dryRun')));
|
console.log(chalk.yellow(t('dryRun')));
|
||||||
}
|
}
|
||||||
if (rollout !== undefined) {
|
if (rollout !== undefined) {
|
||||||
const rolloutConfig: Record<string, number> = {};
|
|
||||||
for (const pkg of pkgs) {
|
|
||||||
rolloutConfig[pkg.name] = rollout;
|
|
||||||
}
|
|
||||||
if (!dryRun) {
|
|
||||||
await put(`/app/${appId}/version/${versionId}`, {
|
|
||||||
config: {
|
|
||||||
rollout: rolloutConfig,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
console.log(
|
console.log(
|
||||||
`${t('rolloutConfigSet', {
|
`${t('rolloutConfigSet', {
|
||||||
versions: pkgs.map((pkg: Package) => pkg.name).join(', '),
|
versions: pkgs.map((pkg: Package) => pkg.name).join(', '),
|
||||||
@@ -142,8 +131,10 @@ export const bindVersionToPackages = async ({
|
|||||||
}
|
}
|
||||||
for (const pkg of pkgs) {
|
for (const pkg of pkgs) {
|
||||||
if (!dryRun) {
|
if (!dryRun) {
|
||||||
await put(`/app/${appId}/package/${pkg.id}`, {
|
await post(`/app/${appId}/binding`, {
|
||||||
versionId,
|
versionId,
|
||||||
|
rollout,
|
||||||
|
packageId: pkg.id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.log(
|
console.log(
|
||||||
@@ -352,4 +343,29 @@ export const versionCommands = {
|
|||||||
await put(`/app/${appId}/version/${versionId}`, updateParams);
|
await put(`/app/${appId}/version/${versionId}`, updateParams);
|
||||||
console.log(t('operationSuccess'));
|
console.log(t('operationSuccess'));
|
||||||
},
|
},
|
||||||
|
deleteVersion: async ({
|
||||||
|
options,
|
||||||
|
}: {
|
||||||
|
options: VersionCommandOptions;
|
||||||
|
}) => {
|
||||||
|
let appId = options.appId;
|
||||||
|
if (!appId) {
|
||||||
|
const platform = await getPlatform(options.platform);
|
||||||
|
appId = (await getSelectedApp(platform)).appId;
|
||||||
|
}
|
||||||
|
|
||||||
|
let versionId = options.versionId;
|
||||||
|
if (!versionId) {
|
||||||
|
versionId = (await chooseVersion(appId as string)).id;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await doDelete(`/app/${appId}/version/${versionId}`);
|
||||||
|
console.log(t('deleteVersionSuccess', { versionId }));
|
||||||
|
} catch (error: any) {
|
||||||
|
throw new Error(
|
||||||
|
t('deleteVersionError', { versionId, error: error.message }),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
"target": "ESNext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
|
"target": "ESNext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
|
||||||
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
|
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
|
||||||
"lib": [
|
"lib": [
|
||||||
"ESNext"
|
"ESNext",
|
||||||
|
"DOM"
|
||||||
] /* Specify library files to be included in the compilation. */,
|
] /* Specify library files to be included in the compilation. */,
|
||||||
"allowJs": true /* Allow javascript files to be compiled. */,
|
"allowJs": true /* Allow javascript files to be compiled. */,
|
||||||
// "checkJs": true /* Report errors in .js files. */,
|
// "checkJs": true /* Report errors in .js files. */,
|
||||||
|
|||||||
Reference in New Issue
Block a user