@@ -42,59 +42,64 @@ export async function loadProjects() {
4242}
4343
4444async function loadManifest ( projectPath : string ) {
45- const manifestPath = join ( projectPath , 'manifest.json' )
46- let manifest = await readJSON ( manifestPath ) . catch ( ( ) => ( {
47- header : { } ,
48- metadata : { } ,
49- } ) )
50- let {
51- header : { version, name, description } ,
52- metadata : { author } = {
53- author : 'Unknown' ,
54- } ,
55- } = manifest
45+ let langDescription : string
46+ try {
47+ const langFile = (
48+ await fs . readFile ( join ( projectPath , 'texts/en_US.lang' ) )
49+ ) . toString ( 'utf-8' )
50+ const lines = langFile . split ( '\n' )
5651
57- if ( description === 'pack.description' ) {
58- try {
59- const langFile = (
60- await fs . readFile ( join ( projectPath , 'texts/en_US.lang' ) )
61- ) . toString ( 'utf-8' )
62- const lines = langFile . split ( '\n' )
52+ for ( let line of lines ) {
53+ const [ key , value ] = line . split ( '=' )
54+ if ( key . trim ( ) === 'pack.description' )
55+ langDescription = value . trim ( )
56+ }
57+ } catch { }
58+ try {
59+ const manifestPath = join ( projectPath , 'manifest.json' )
60+ let manifest = await readJSON ( manifestPath )
61+ let {
62+ header : { version, name, description } ,
63+ metadata : { author } = {
64+ author : 'Unknown' ,
65+ } ,
66+ } = manifest
6367
64- for ( let line of lines ) {
65- const [ key , value ] = line . split ( '=' )
66- if ( key . trim ( ) === 'pack.description' )
67- description = value . trim ( )
68- }
69- } catch { }
70- }
68+ if ( description === 'pack.description' ) description = langDescription
7169
72- const appVersion = APP_VERSION . replace ( 'v' , '' )
73- const generatedWithBridge : string [ ] | undefined =
74- manifest ?. metadata ?. generated_with ?. bridge
75- if ( generatedWithBridge ) {
76- if ( ! generatedWithBridge . includes ( appVersion ) )
77- generatedWithBridge . push ( appVersion )
78- } else {
79- manifest = {
80- ...( manifest ?? { } ) ,
81- metadata : {
82- ...( manifest ?. metadata ?? { } ) ,
83- generated_with : {
84- ...( manifest ?. metadata ?. generated_with ?? { } ) ,
85- bridge : [ appVersion ] ,
70+ const appVersion = APP_VERSION . replace ( 'v' , '' )
71+ const generatedWithBridge : string [ ] | undefined =
72+ manifest ?. metadata ?. generated_with ?. bridge
73+ if ( generatedWithBridge ) {
74+ if ( ! generatedWithBridge . includes ( appVersion ) )
75+ generatedWithBridge . push ( appVersion )
76+ } else {
77+ manifest = {
78+ ...( manifest ?? { } ) ,
79+ metadata : {
80+ ...( manifest ?. metadata ?? { } ) ,
81+ generated_with : {
82+ ...( manifest ?. metadata ?. generated_with ?? { } ) ,
83+ bridge : generatedWithBridge ?? [ appVersion ] ,
84+ } ,
8685 } ,
87- } ,
86+ }
8887 }
89- }
9088
91- await writeJSON ( manifestPath , manifest , true )
92-
93- return {
94- version,
95- name,
96- author,
97- description,
89+ await writeJSON ( manifestPath , manifest , true )
90+ return {
91+ version,
92+ name,
93+ author,
94+ description,
95+ }
96+ } catch {
97+ return {
98+ version : undefined ,
99+ name : undefined ,
100+ author : undefined ,
101+ description : undefined ,
102+ }
98103 }
99104}
100105
0 commit comments