@@ -11,9 +11,7 @@ import chalk from "chalk";
1111
1212
1313const RUNTIME_ZIP_URL = `https://github.com/csg-tokyo/bluescript/releases/download/v${ VM_VERSION } /release-microcontroller-v${ VM_VERSION } .zip` ;
14- const GLOBAL_PACKAGES_ZIP_URL = `https://github.com/csg-tokyo/bluescript/releases/download/v${ VM_VERSION } /release-modules-v${ VM_VERSION } .zip` ;
1514const RUNTIME_DIR = path . join ( GLOBAL_BLUESCRIPT_PATH , 'microcontroller' ) ;
16- const GLOBAL_PACKAGES_DIR = path . join ( GLOBAL_BLUESCRIPT_PATH , 'modules' ) ;
1715
1816const ESP_IDF_VERSION = 'v5.4' ;
1917const ESP_IDF_GIT_REPO = 'https://github.com/espressif/esp-idf.git' ;
@@ -32,58 +30,40 @@ abstract class SetupHandler {
3230 getSetupPlan ( ) : string [ ] {
3331 const plan : string [ ] = [ ] ;
3432 plan . push ( `Download BlueScript runtime from ${ RUNTIME_ZIP_URL } ` ) ;
35- plan . push ( `Download global packages from ${ GLOBAL_PACKAGES_ZIP_URL } ` ) ;
3633 plan . push ( ...this . getBoardSetupPlan ( ) ) ;
3734 return plan ;
3835 }
3936
4037 async setup ( ) : Promise < void > {
38+ this . ensureBlueScriptDir ( ) ;
4139 await this . downloadBlueScriptRuntime ( ) ;
42- await this . downloadGlobalPackages ( ) ;
4340 await this . setupBoard ( ) ;
4441 this . globalConfigHandler . save ( ) ;
4542 }
4643
47- private needToDownloadBlueScriptRuntime ( ) {
48- return ! this . globalConfigHandler . isRuntimeSetup ( ) ;
44+ private ensureBlueScriptDir ( ) {
45+ if ( ! fs . exists ( GLOBAL_BLUESCRIPT_PATH ) ) {
46+ fs . makeDir ( GLOBAL_BLUESCRIPT_PATH ) ;
47+ }
4948 }
5049
51- private needToDownloadGlobalPackages ( ) {
52- return ! this . globalConfigHandler . isGlobalPackagesSetup ( ) ;
50+ private needToDownloadBlueScriptRuntime ( ) {
51+ return ! this . globalConfigHandler . isRuntimeSetup ( ) ;
5352 }
5453
5554 @LogStep ( `Downloading BlueScript runtime...` )
5655 private async downloadBlueScriptRuntime ( ) {
5756 if ( ! this . needToDownloadBlueScriptRuntime ( ) ) {
5857 throw new SkipStep ( 'already downloaded.' , undefined ) ;
5958 }
60-
6159 if ( fs . exists ( RUNTIME_DIR ) ) {
6260 fs . removeDir ( RUNTIME_DIR ) ;
6361 }
64- if ( ! fs . exists ( GLOBAL_BLUESCRIPT_PATH ) ) {
65- fs . makeDir ( GLOBAL_BLUESCRIPT_PATH ) ;
66- }
62+
6763 await fs . downloadAndUnzip ( RUNTIME_ZIP_URL , GLOBAL_BLUESCRIPT_PATH ) ;
6864 this . globalConfigHandler . setRuntimeDir ( RUNTIME_DIR ) ;
6965 }
7066
71- @LogStep ( `Downloading global packages...` )
72- private async downloadGlobalPackages ( ) {
73- if ( ! this . needToDownloadGlobalPackages ( ) ) {
74- throw new SkipStep ( 'already downloaded.' , undefined ) ;
75- }
76-
77- if ( fs . exists ( GLOBAL_PACKAGES_DIR ) ) {
78- fs . removeDir ( GLOBAL_PACKAGES_DIR ) ;
79- }
80- if ( ! fs . exists ( GLOBAL_BLUESCRIPT_PATH ) ) {
81- fs . makeDir ( GLOBAL_BLUESCRIPT_PATH ) ;
82- }
83- await fs . downloadAndUnzip ( GLOBAL_PACKAGES_ZIP_URL , GLOBAL_BLUESCRIPT_PATH ) ;
84- this . globalConfigHandler . setGlobalPackagesDir ( GLOBAL_PACKAGES_DIR ) ;
85- }
86-
8767 abstract needSetup ( ) : boolean ;
8868
8969 abstract getBoardSetupPlan ( ) : string [ ] ;
@@ -210,7 +190,7 @@ export class ESP32SetupHandler extends SetupHandler {
210190 }
211191
212192 fs . makeDir ( ESP_ROOT_DIR ) ;
213- await exec ( `git clone -b ${ ESP_IDF_VERSION } --recursive ${ ESP_IDF_GIT_REPO } ` , { cwd : ESP_ROOT_DIR } ) ;
193+ await exec ( `git clone --depth 1 - b ${ ESP_IDF_VERSION } --recursive ${ ESP_IDF_GIT_REPO } ` , { cwd : ESP_ROOT_DIR } ) ;
214194 }
215195
216196 @LogStep ( 'Running ESP-IDF install script...' )
0 commit comments