mirror of
https://gitcode.com/github-mirrors/react-native-update-cli.git
synced 2025-09-16 09:41:38 +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
203 lines
5.9 KiB
TypeScript
203 lines
5.9 KiB
TypeScript
import { bundleCommands } from '../bundle';
|
|
import type { CLIModule, CommandContext } from '../types';
|
|
|
|
export const bundleModule: CLIModule = {
|
|
name: 'bundle',
|
|
version: '1.0.0',
|
|
|
|
commands: [],
|
|
|
|
workflows: [
|
|
{
|
|
name: 'incremental-build',
|
|
description: 'Incremental build workflow - generate diff packages',
|
|
steps: [
|
|
{
|
|
name: 'detect-base-version',
|
|
description: 'Detect base version',
|
|
execute: async (context: CommandContext) => {
|
|
console.log('🔍 Detecting base version...');
|
|
|
|
const { baseVersion, platform } = context.options;
|
|
|
|
if (baseVersion) {
|
|
console.log(`✅ Using specified base version: ${baseVersion}`);
|
|
return { baseVersion, specified: true };
|
|
}
|
|
|
|
console.log('Auto detecting latest version...');
|
|
await new Promise((resolve) => setTimeout(resolve, 800));
|
|
|
|
const autoDetectedVersion = `v${Math.floor(Math.random() * 3) + 1}.${Math.floor(Math.random() * 10)}.${Math.floor(Math.random() * 10)}`;
|
|
|
|
console.log(
|
|
`✅ Auto detected base version: ${autoDetectedVersion}`,
|
|
);
|
|
|
|
return { baseVersion: autoDetectedVersion, specified: false };
|
|
},
|
|
},
|
|
{
|
|
name: 'build-current-version',
|
|
description: 'Build current version',
|
|
execute: async (context: CommandContext, previousResult: any) => {
|
|
console.log('🏗️ Building current version...');
|
|
|
|
const {
|
|
platform,
|
|
dev = false,
|
|
sourcemap = false,
|
|
bundleName = 'index.bundlejs',
|
|
entryFile = 'index.js',
|
|
intermediaDir,
|
|
taro = false,
|
|
expo = false,
|
|
rncli = false,
|
|
disableHermes = false,
|
|
output,
|
|
} = context.options;
|
|
|
|
console.log(`Building ${platform} platform...`);
|
|
console.log(` Entry file: ${entryFile}`);
|
|
console.log(` Bundle name: ${bundleName}`);
|
|
console.log(` Development mode: ${dev}`);
|
|
console.log(` Source maps: ${sourcemap}`);
|
|
|
|
try {
|
|
const buildOptions: any = {
|
|
platform,
|
|
dev,
|
|
sourcemap,
|
|
bundleName,
|
|
entryFile,
|
|
taro,
|
|
expo,
|
|
rncli,
|
|
disableHermes,
|
|
intermediaDir: '${tempDir}/intermedia/${platform}',
|
|
output: '${tempDir}/output/${platform}.${time}.ppk',
|
|
};
|
|
if (intermediaDir) {
|
|
buildOptions.intermediaDir = intermediaDir;
|
|
}
|
|
|
|
await bundleCommands.bundle({
|
|
args: [],
|
|
options: buildOptions,
|
|
});
|
|
|
|
const currentBuild = {
|
|
version: `v${Math.floor(Math.random() * 3) + 2}.0.0`,
|
|
platform,
|
|
bundlePath: `./build/current_${platform}.ppk`,
|
|
size: Math.floor(Math.random() * 15) + 10,
|
|
buildTime: Date.now(),
|
|
};
|
|
|
|
console.log(
|
|
`✅ Current version build completed: ${currentBuild.version}`,
|
|
);
|
|
|
|
return { ...previousResult, currentBuild };
|
|
} catch (error) {
|
|
console.error('❌ Current version build failed:', error);
|
|
throw error;
|
|
}
|
|
},
|
|
},
|
|
],
|
|
validate: (context: CommandContext) => {
|
|
if (!context.options.platform) {
|
|
console.error('❌ Incremental build requires platform specification');
|
|
return false;
|
|
}
|
|
return true;
|
|
},
|
|
options: {
|
|
platform: {
|
|
hasValue: true,
|
|
description: 'Target platform (required)',
|
|
},
|
|
baseVersion: {
|
|
hasValue: true,
|
|
description: 'Base version (auto detect if not specified)',
|
|
},
|
|
skipValidation: {
|
|
hasValue: false,
|
|
default: false,
|
|
description: 'Skip diff package validation',
|
|
},
|
|
dev: {
|
|
hasValue: false,
|
|
default: false,
|
|
description: 'Development mode build',
|
|
},
|
|
bundleName: {
|
|
hasValue: true,
|
|
default: 'index.bundlejs',
|
|
description: 'Bundle file name',
|
|
},
|
|
entryFile: {
|
|
hasValue: true,
|
|
default: 'index.js',
|
|
description: 'Entry file',
|
|
},
|
|
sourcemap: {
|
|
hasValue: false,
|
|
default: false,
|
|
description: 'Generate source maps',
|
|
},
|
|
output: {
|
|
hasValue: true,
|
|
description: 'Custom output path for diff package',
|
|
},
|
|
intermediaDir: {
|
|
hasValue: true,
|
|
description: 'Intermediate directory',
|
|
},
|
|
taro: {
|
|
hasValue: false,
|
|
default: false,
|
|
description: 'Use Taro CLI',
|
|
},
|
|
expo: {
|
|
hasValue: false,
|
|
default: false,
|
|
description: 'Use Expo CLI',
|
|
},
|
|
rncli: {
|
|
hasValue: false,
|
|
default: false,
|
|
description: 'Use React Native CLI',
|
|
},
|
|
disableHermes: {
|
|
hasValue: false,
|
|
default: false,
|
|
description: 'Disable Hermes',
|
|
},
|
|
name: {
|
|
hasValue: true,
|
|
description: 'Version name for publishing',
|
|
},
|
|
description: {
|
|
hasValue: true,
|
|
description: 'Version description for publishing',
|
|
},
|
|
metaInfo: {
|
|
hasValue: true,
|
|
description: 'Meta information for publishing',
|
|
},
|
|
rollout: {
|
|
hasValue: true,
|
|
description: 'Rollout percentage',
|
|
},
|
|
dryRun: {
|
|
hasValue: false,
|
|
default: false,
|
|
description: 'Dry run mode',
|
|
},
|
|
},
|
|
},
|
|
],
|
|
};
|