MCPcopy Create free account
hub / github.com/reactnativecn/react-native-update / reactNativeUpdatePlugin

Function reactNativeUpdatePlugin

harmony/hvigor-plugin.ts:4–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2import path from 'path';
3
4export function reactNativeUpdatePlugin() {
5 return {
6 pluginId: 'reactNativeUpdatePlugin',
7 apply() {
8 const cwd = process.cwd();
9 const metaFilePath = path.resolve(
10 cwd,
11 'entry/src/main/resources/rawfile/meta.json',
12 );
13 fs.mkdirSync(path.dirname(metaFilePath), { recursive: true });
14
15 const moduleJsonPath = path.resolve(cwd, 'AppScope/app.json5');
16 let versionName = '';
17 if (fs.existsSync(moduleJsonPath)) {
18 const content = fs.readFileSync(moduleJsonPath, 'utf-8');
19 const match = content.match(
20 /(?:"versionName"|versionName):\s*["']([^"']+)["']/,
21 );
22 versionName = match?.[1] || '';
23 }
24
25 const metaContent = {
26 pushy_build_time: String(Date.now()),
27 versionName,
28 };
29
30 fs.writeFileSync(metaFilePath, JSON.stringify(metaContent, null, 2));
31 console.log(`Build time written to ${metaFilePath}`);
32 },
33 };
34}

Callers 1

hvigorfile.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected