@@ -18,14 +18,10 @@ import { createPrepareResourcesContext } from './prepare-resources/context.mjs';
1818const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
1919const projectRoot = path . resolve ( __dirname , '..' ) ;
2020
21- const main = async ( ) => {
22- const context = createPrepareResourcesContext ( {
23- argv : process . argv ,
24- env : process . env ,
25- projectRoot,
26- } ) ;
21+ const prepareAstrbotVersionSync = async ( { context } ) => {
2722 const {
2823 mode,
24+ projectRoot,
2925 sourceDir,
3026 sourceRepoUrl,
3127 sourceRepoRef,
@@ -35,38 +31,32 @@ const main = async () => {
3531 desktopVersionOverride,
3632 } = context ;
3733 const needsSourceRepo = mode !== 'version' || ! desktopVersionOverride ;
38- await mkdir ( path . join ( projectRoot , 'resources' ) , { recursive : true } ) ;
3934
40- if ( desktopVersionInput && desktopVersionInput !== desktopVersionOverride ) {
41- console . log (
42- `[prepare-resources] Normalized ASTRBOT_DESKTOP_VERSION from ${ desktopVersionInput } to ${ desktopVersionOverride } ` ,
43- ) ;
44- }
35+ ensureStartupShellAssets ( projectRoot ) ;
4536
46- if ( needsSourceRepo ) {
47- ensureSourceRepo ( {
48- sourceDir,
49- sourceRepoUrl,
50- sourceRepoRef,
51- isSourceRepoRefCommitSha,
52- sourceDirOverrideRaw : sourceDirOverrideInput ,
53- } ) ;
54- } else {
37+ if ( ! needsSourceRepo ) {
5538 console . log (
5639 '[prepare-resources] Skip source repo sync in version-only mode because ASTRBOT_DESKTOP_VERSION is set.' ,
5740 ) ;
41+ return desktopVersionOverride ;
5842 }
5943
60- ensureStartupShellAssets ( projectRoot ) ;
44+ ensureSourceRepo ( {
45+ sourceDir,
46+ sourceRepoUrl,
47+ sourceRepoRef,
48+ isSourceRepoRefCommitSha,
49+ sourceDirOverrideRaw : sourceDirOverrideInput ,
50+ } ) ;
51+
6152 const astrbotVersion =
6253 desktopVersionOverride || ( await readAstrbotVersionFromPyproject ( { sourceDir } ) ) ;
63-
6454 await validateAstrbotRuntimeVersion ( {
6555 sourceDir,
6656 expectedVersion : desktopVersionOverride ? undefined : astrbotVersion ,
6757 } ) ;
6858
69- if ( desktopVersionOverride && needsSourceRepo ) {
59+ if ( desktopVersionOverride ) {
7060 const sourceVersion = await readAstrbotVersionFromPyproject ( { sourceDir } ) ;
7161 if ( sourceVersion !== desktopVersionOverride ) {
7262 console . warn (
@@ -75,6 +65,30 @@ const main = async () => {
7565 }
7666 }
7767
68+ return astrbotVersion ;
69+ } ;
70+
71+ const main = async ( ) => {
72+ const context = createPrepareResourcesContext ( {
73+ argv : process . argv ,
74+ env : process . env ,
75+ projectRoot,
76+ } ) ;
77+ const {
78+ mode,
79+ desktopVersionInput,
80+ desktopVersionOverride,
81+ } = context ;
82+ await mkdir ( path . join ( projectRoot , 'resources' ) , { recursive : true } ) ;
83+
84+ if ( desktopVersionInput && desktopVersionInput !== desktopVersionOverride ) {
85+ console . log (
86+ `[prepare-resources] Normalized ASTRBOT_DESKTOP_VERSION from ${ desktopVersionInput } to ${ desktopVersionOverride } ` ,
87+ ) ;
88+ }
89+
90+ const astrbotVersion = await prepareAstrbotVersionSync ( { context } ) ;
91+
7892 await syncDesktopVersionFiles ( { projectRoot, version : astrbotVersion } ) ;
7993 if ( desktopVersionOverride ) {
8094 console . log (
0 commit comments