@@ -37,22 +37,22 @@ func (f *migrateFlow) run() error {
3737 }
3838
3939 f .printHeader ()
40- printMigrateTimeline (f .dryRun (), f .shouldPublish (), false , false , false , false , false , false , false )
40+ printMigrateTimeline (f .dryRun (), f .shouldPublish (), f . shouldPushAssets (), f . shouldPublish (), false , false , false , false , false , false , false )
4141
4242 if err := f .authenticate (); err != nil {
4343 return err
4444 }
45- printMigrateTimeline (f .dryRun (), f .shouldPublish (), true , false , false , false , false , false , false )
45+ printMigrateTimeline (f .dryRun (), f .shouldPublish (), f . shouldPushAssets (), f . shouldPublish (), true , false , false , false , false , false , false )
4646
4747 if err := f .loadPages (); err != nil {
4848 return err
4949 }
50- printMigrateTimeline (f .dryRun (), f .shouldPublish (), true , true , false , false , false , false , false )
50+ printMigrateTimeline (f .dryRun (), f .shouldPublish (), f . shouldPushAssets (), f . shouldPublish (), true , true , false , false , false , false , false )
5151
5252 if err := f .loadGlobalCode (); err != nil {
5353 return err
5454 }
55- printMigrateTimeline (f .dryRun (), f .shouldPublish (), true , true , true , false , false , false , false )
55+ printMigrateTimeline (f .dryRun (), f .shouldPublish (), f . shouldPushAssets (), f . shouldPublish (), true , true , true , false , false , false , false )
5656
5757 if err := f .planMigration (); err != nil {
5858 return err
@@ -66,14 +66,14 @@ func (f *migrateFlow) run() error {
6666
6767 if f .dryRun () {
6868 utils .CPrint ("Dry run mode: no files or Webflow code were changed" , "yellow" )
69- printMigrateTimeline (true , f .shouldPublish (), true , true , true , false , false , false , false )
69+ printMigrateTimeline (true , f .shouldPublish (), f . shouldPushAssets (), f . shouldPublish (), true , true , true , false , false , false , false )
7070 return nil
7171 }
7272
7373 if err := f .writeFiles (); err != nil {
7474 return err
7575 }
76- printMigrateTimeline (false , f .shouldPublish (), true , true , true , true , false , false , false )
76+ printMigrateTimeline (false , f .shouldPublish (), f . shouldPushAssets (), f . shouldPublish (), true , true , true , true , false , false , false )
7777
7878 if ! f .shouldPublish () {
7979 f .printSuccess ()
@@ -83,12 +83,14 @@ func (f *migrateFlow) run() error {
8383 if err := f .buildAssets (); err != nil {
8484 return err
8585 }
86- printMigrateTimeline (false , true , true , true , true , true , true , false , false )
86+ printMigrateTimeline (false , f . shouldPublish (), f . shouldPushAssets (), f . shouldPublish () , true , true , true , true , true , false , false )
8787
88- if err := f .pushGit (); err != nil {
89- return err
88+ if f .shouldPushAssets () {
89+ if err := f .pushGit (); err != nil {
90+ return err
91+ }
9092 }
91- printMigrateTimeline (false , true , true , true , true , true , true , true , false )
93+ printMigrateTimeline (false , f . shouldPublish (), f . shouldPushAssets (), f . shouldPublish (), true , true , true , true , true , f . shouldPushAssets () , false )
9294
9395 if err := f .publish (); err != nil {
9496 return err
@@ -106,7 +108,7 @@ func (f *migrateFlow) loadConfig() error {
106108 if cfg .AppName == "" {
107109 return fmt .Errorf ("missing appName configuration in wfkit.json" )
108110 }
109- if f .shouldPublish () {
111+ if f .shouldPublish () && f . delivery () == "cdn" {
110112 if err := cfg .ValidatePublish (); err != nil {
111113 return err
112114 }
@@ -116,6 +118,7 @@ func (f *migrateFlow) loadConfig() error {
116118 f .pagesDir = resolveStringFlag (f .cliContext , "pages-dir" , "src/pages" )
117119 f .args = map [string ]interface {}{
118120 "env" : "prod" ,
121+ "delivery" : resolveDeliveryModeFlag (f .cliContext , cfg .DeliveryMode ),
119122 "asset-branch" : resolveAssetBranchFlag (f .cliContext , cfg .AssetBranch ),
120123 "build-dir" : resolveStringFlag (f .cliContext , "build-dir" , cfg .BuildDir ),
121124 "custom-commit" : f .cliContext .String ("custom-commit" ),
@@ -189,6 +192,20 @@ func (f *migrateFlow) writeFiles() error {
189192
190193func (f * migrateFlow ) buildAssets () error {
191194 utils .CPrint ("Building migrated pages..." , "cyan" )
195+ if f .delivery () == "inline" {
196+ if err := build .RunProjectBuild (f .args ["build-dir" ].(string ), f .config .PackageManager ); err != nil {
197+ return fmt .Errorf ("build failed after migration: %w" , err )
198+ }
199+ inlineBundles , err := build .BuildInlineBundles (f .args ["build-dir" ].(string ), f .config .PackageManager )
200+ if err != nil {
201+ return fmt .Errorf ("inline bundle build failed after migration: %w" , err )
202+ }
203+ f .args ["inline-global" ] = inlineBundles .Global
204+ f .args ["inline-pages" ] = inlineBundles .Pages
205+ utils .CPrint ("Build successful, inline bundles are ready for Webflow" , "green" )
206+ return nil
207+ }
208+
192209 scriptURL , err := build .DoBuild (f .args , f .config .GitHubUser , f .config .RepositoryName , f .config .PackageManager )
193210 if err != nil {
194211 return fmt .Errorf ("build failed after migration: %w" , err )
@@ -243,15 +260,16 @@ func (f *migrateFlow) publish() error {
243260func (f * migrateFlow ) printSuccess () {
244261 if f .shouldPublish () {
245262 printMigrationPublishResult (f .result )
246- printMigrateTimeline (false , true , true , true , true , true , true , true , f .result .Published )
263+ printMigrateTimeline (false , f . shouldPublish (), f . shouldPushAssets (), f . shouldPublish (), true , true , true , true , true , f . shouldPushAssets () , f .result .Published )
247264
248265 notifySuccess (f .args ["notify" ].(bool ), "wfkit migrate completed" , "Webflow code migration finished successfully." )
249266
250267 utils .PrintSuccessScreen (
251268 "Migration completed" ,
252- "Legacy Webflow code has been moved into local files and published via jsDelivr ." ,
269+ "Legacy Webflow code has been moved into local files and published back to Webflow ." ,
253270 []utils.SummaryMetric {
254271 {Label : "Pages updated" , Value : fmt .Sprintf ("%d" , f .result .UpdatedPages ), Tone : "success" },
272+ {Label : "Delivery" , Value : f .delivery (), Tone : "info" },
255273 {Label : "Published" , Value : map [bool ]string {true : "yes" , false : "no" }[f .result .Published ], Tone : "info" },
256274 },
257275 "git status" ,
@@ -260,7 +278,7 @@ func (f *migrateFlow) printSuccess() {
260278 return
261279 }
262280
263- printMigrateTimeline (false , false , true , true , true , true , false , false , false )
281+ printMigrateTimeline (false , false , false , false , true , true , true , true , false , false , false )
264282 notifySuccess (f .args ["notify" ].(bool ), "wfkit migrate completed" , "Webflow code migration files were written locally." )
265283 utils .PrintSuccessScreen (
266284 "Migration completed" ,
@@ -281,3 +299,11 @@ func (f *migrateFlow) dryRun() bool {
281299func (f * migrateFlow ) shouldPublish () bool {
282300 return f .cliContext .Bool ("publish" )
283301}
302+
303+ func (f * migrateFlow ) delivery () string {
304+ return f .args ["delivery" ].(string )
305+ }
306+
307+ func (f * migrateFlow ) shouldPushAssets () bool {
308+ return f .shouldPublish () && f .delivery () == "cdn"
309+ }
0 commit comments