1- import { hapTasks } from '@ohos/hvigor-ohos-plugin' ;
2- import fs from 'fs' ;
3- import path from 'path' ;
4-
5- export function generatePushyBuildTime ( str ?: string ) {
6- return {
7- pluginId : 'PushyBuildTimePlugin' ,
8- apply ( pluginContext ) {
9- pluginContext . registerTask ( {
10- name : 'pushy_build_time' ,
11- run : ( taskContext ) => {
12- const metaFilePath = path . resolve ( __dirname , 'src/main/resources/rawfile/meta.json' ) ;
13- const dirPath = path . dirname ( metaFilePath ) ;
14- if ( ! fs . existsSync ( dirPath ) ) {
15- fs . mkdirSync ( dirPath , { recursive : true } ) ;
16- }
17- const moduleJsonPath = path . resolve ( __dirname , '../AppScope/app.json5' ) ;
18- let versionName = '' ;
19- if ( fs . existsSync ( moduleJsonPath ) ) {
20- const moduleContent = fs . readFileSync ( moduleJsonPath , 'utf-8' ) ;
21- const versionMatch = moduleContent . match ( / " v e r s i o n N a m e " : \s * " ( [ ^ " ] + ) " / ) ;
22- if ( versionMatch && versionMatch [ 1 ] ) {
23- versionName = versionMatch [ 1 ] ;
24- }
25- }
26- const buildTime = new Date ( ) . toISOString ( ) ;
27- const metaContent = {
28- pushy_build_time : buildTime ,
29- versionName : versionName
30- } ;
31- fs . writeFileSync ( metaFilePath , JSON . stringify ( metaContent , null , 4 ) ) ;
32- console . log ( `Build time written to ${ metaFilePath } ` ) ;
33- } ,
34- dependencies : [ ] ,
35- postDependencies : [ 'default@BuildJS' ]
36- } )
37- }
38- }
39- }
1+ import { hapTasks } from '@ohos/hvigor-ohos-plugin' ;
2+ import { reactNativeUpdatePlugin } from 'pushy/hvigor-plugin' ;
403
414export default {
42- system : hapTasks , /* Built-in plugin of Hvigor. It cannot be modified. */
43- plugins :[ generatePushyBuildTime ( ) ] /* Custom plugin to extend the functionality of Hvigor. */
44- }
5+ system : hapTasks /* Built-in plugin of Hvigor. It cannot be modified. */ ,
6+ plugins : [
7+ reactNativeUpdatePlugin ( ) ,
8+ ] /* Custom plugin to extend the functionality of Hvigor. */ ,
9+ } ;
0 commit comments