mirror of
https://gitcode.com/github-mirrors/react-native-update-cli.git
synced 2025-09-16 01:41:37 +08:00

* add logic to support SENTRY_PROPERTIES parameter * remove update.json and meta.json files in ppk * udpapte * refactor modles * update * add package-module file * update * update readme file * modifu cli.json file * fix command issues * improve version workflow logic * udpate * update * update * update * udpate * udpate * add example * update readme file * udpate version * change logic to use pushy command uniformly
206 lines
6.7 KiB
TypeScript
206 lines
6.7 KiB
TypeScript
import { appCommands } from '../app';
|
|
import type { CLIModule, CommandContext } from '../types';
|
|
|
|
export const appModule: CLIModule = {
|
|
name: 'app',
|
|
version: '1.0.0',
|
|
|
|
commands: [],
|
|
|
|
workflows: [
|
|
{
|
|
name: 'setup-app',
|
|
description: 'Setup a new app with initial configuration',
|
|
steps: [
|
|
{
|
|
name: 'create',
|
|
description: 'Create the app',
|
|
execute: async (context: CommandContext) => {
|
|
console.log('Creating app in workflow');
|
|
const { name, downloadUrl, platform } = context.options;
|
|
await appCommands.createApp({
|
|
options: {
|
|
name: name || '',
|
|
downloadUrl: downloadUrl || '',
|
|
platform: platform || '',
|
|
},
|
|
});
|
|
return { appCreated: true };
|
|
},
|
|
},
|
|
{
|
|
name: 'select',
|
|
description: 'Select the created app',
|
|
execute: async (context: CommandContext, previousResult: any) => {
|
|
console.log('Selecting app in workflow');
|
|
const { platform } = context.options;
|
|
await appCommands.selectApp({
|
|
args: [],
|
|
options: { platform: platform || '' },
|
|
});
|
|
return { ...previousResult, appSelected: true };
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
name: 'manage-apps',
|
|
description: 'Manage multiple apps',
|
|
steps: [
|
|
{
|
|
name: 'list-apps',
|
|
description: 'List all apps',
|
|
execute: async (context: CommandContext) => {
|
|
console.log('Listing all apps');
|
|
const { platform } = context.options;
|
|
await appCommands.apps({
|
|
options: { platform: platform || '' },
|
|
});
|
|
return { appsListed: true };
|
|
},
|
|
},
|
|
{
|
|
name: 'select-target-app',
|
|
description: 'Select target app for operations',
|
|
execute: async (context: CommandContext, previousResult: any) => {
|
|
console.log('Selecting target app');
|
|
const { platform } = context.options;
|
|
await appCommands.selectApp({
|
|
args: [],
|
|
options: { platform: platform || '' },
|
|
});
|
|
return { ...previousResult, targetAppSelected: true };
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
name: 'multi-platform-app-management',
|
|
description: 'Multi-platform app unified management workflow',
|
|
steps: [
|
|
{
|
|
name: 'scan-platforms',
|
|
description: 'Scan apps on all platforms',
|
|
execute: async (context: CommandContext) => {
|
|
console.log('🔍 Scanning apps on all platforms...');
|
|
|
|
const platforms = ['ios', 'android', 'harmony'];
|
|
const appsData = {};
|
|
|
|
for (const platform of platforms) {
|
|
console.log(` Scanning ${platform} platform...`);
|
|
|
|
// Simulate getting app list
|
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
|
|
const appCount = Math.floor(Math.random() * 5) + 1;
|
|
const apps = Array.from({ length: appCount }, (_, i) => ({
|
|
id: `${platform}_app_${i + 1}`,
|
|
name: `App ${i + 1}`,
|
|
platform,
|
|
version: `1.${i}.0`,
|
|
status: Math.random() > 0.2 ? 'active' : 'inactive',
|
|
}));
|
|
|
|
appsData[platform] = apps;
|
|
console.log(` ✅ Found ${appCount} apps`);
|
|
}
|
|
|
|
console.log('✅ Platform scanning completed');
|
|
|
|
return { platforms, appsData, scanned: true };
|
|
},
|
|
},
|
|
{
|
|
name: 'analyze-apps',
|
|
description: 'Analyze app status',
|
|
execute: async (context: CommandContext, previousResult: any) => {
|
|
console.log('📊 Analyzing app status...');
|
|
|
|
const { appsData } = previousResult;
|
|
const analysis = {
|
|
totalApps: 0,
|
|
activeApps: 0,
|
|
inactiveApps: 0,
|
|
platformDistribution: {},
|
|
issues: [],
|
|
};
|
|
|
|
for (const [platform, apps] of Object.entries(appsData)) {
|
|
const platformApps = apps as any[];
|
|
analysis.totalApps += platformApps.length;
|
|
analysis.platformDistribution[platform] = platformApps.length;
|
|
|
|
for (const app of platformApps) {
|
|
if (app.status === 'active') {
|
|
analysis.activeApps++;
|
|
} else {
|
|
analysis.inactiveApps++;
|
|
analysis.issues.push(
|
|
`${platform}/${app.name}: App is inactive`,
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
console.log('📈 Analysis results:');
|
|
console.log(` Total apps: ${analysis.totalApps}`);
|
|
console.log(` Active apps: ${analysis.activeApps}`);
|
|
console.log(` Inactive apps: ${analysis.inactiveApps}`);
|
|
|
|
if (analysis.issues.length > 0) {
|
|
console.log('⚠️ Issues found:');
|
|
analysis.issues.forEach((issue) => console.log(` - ${issue}`));
|
|
}
|
|
|
|
return { ...previousResult, analysis };
|
|
},
|
|
},
|
|
{
|
|
name: 'optimize-apps',
|
|
description: 'Optimize app configuration',
|
|
execute: async (context: CommandContext, previousResult: any) => {
|
|
console.log('⚡ Optimizing app configuration...');
|
|
|
|
const { analysis } = previousResult;
|
|
const optimizations = [];
|
|
|
|
if (analysis.inactiveApps > 0) {
|
|
console.log(' Handling inactive apps...');
|
|
optimizations.push('Reactivate inactive apps');
|
|
}
|
|
|
|
if (analysis.totalApps > 10) {
|
|
console.log(' Many apps detected, suggest grouping...');
|
|
optimizations.push('Create app groups');
|
|
}
|
|
|
|
// Simulate optimization process
|
|
for (const optimization of optimizations) {
|
|
console.log(` Executing: ${optimization}...`);
|
|
await new Promise((resolve) => setTimeout(resolve, 800));
|
|
console.log(` ✅ ${optimization} completed`);
|
|
}
|
|
|
|
console.log('✅ App optimization completed');
|
|
|
|
return { ...previousResult, optimizations, optimized: true };
|
|
},
|
|
},
|
|
],
|
|
options: {
|
|
includeInactive: {
|
|
hasValue: false,
|
|
default: true,
|
|
description: 'Include inactive apps',
|
|
},
|
|
autoOptimize: {
|
|
hasValue: false,
|
|
default: true,
|
|
description: 'Auto optimize configuration',
|
|
},
|
|
},
|
|
},
|
|
],
|
|
};
|