@@ -20,6 +20,7 @@ const { HelixProject } = require('@adobe/helix-simulator');
2020const GitUtils = require ( './git-utils.js' ) ;
2121const BuildCommand = require ( './build.cmd' ) ;
2222const pkgJson = require ( '../package.json' ) ;
23+ const HelixPages = require ( './helix-pages.js' ) ;
2324
2425const HELIX_CONFIG = 'helix-config.yaml' ;
2526
@@ -31,6 +32,7 @@ class UpCommand extends BuildCommand {
3132 this . _saveConfig = false ;
3233 this . _overrideHost = null ;
3334 this . _localRepos = [ ] ;
35+ this . _helixPagesRepo = '' ;
3436 }
3537
3638 withHttpPort ( p ) {
@@ -62,6 +64,11 @@ class UpCommand extends BuildCommand {
6264 return this ;
6365 }
6466
67+ withHelixPagesRepo ( url ) {
68+ this . _helixPagesRepo = url ;
69+ return this ;
70+ }
71+
6572 get project ( ) {
6673 return this . _project ;
6774 }
@@ -162,19 +169,58 @@ class UpCommand extends BuildCommand {
162169 } ;
163170 } ) ) ;
164171
165- // start debugger (#178)
166- // https://nodejs.org/en/docs/guides/debugging-getting-started/#enable-inspector
167- if ( process . platform !== 'win32' ) {
168- process . kill ( process . pid , 'SIGUSR1' ) ;
169- }
170-
171172 this . _project = new HelixProject ( )
172173 . withCwd ( this . directory )
173174 . withBuildDir ( this . _target )
174175 . withHelixConfig ( this . config )
175- . withDisplayVersion ( pkgJson . version )
176176 . withRuntimeModulePaths ( module . paths ) ;
177177
178+ // special handling for helix pages project
179+ const pages = new HelixPages ( this . _logger ) . withDirectory ( this . directory ) ;
180+ if ( await pages . isPagesProject ( ) ) {
181+ this . log . info ( ' __ __ ___ ___ ' ) ;
182+ this . log . info ( ' / // /__ / (_)_ __ / _ \\___ ____ ____ ___' ) ;
183+ this . log . info ( ' / _ / -_) / /\\ \\ // ___/ _ `/ _ `/ -_|_-<' ) ;
184+ this . log . info ( ' /_//_/\\__/_/_//_\\_\\/_/ \\_,_/\\_, /\\__/___/' ) ;
185+ this . log . info ( ` /___/ v${ pkgJson . version } ` ) ;
186+ this . log . info ( '' ) ;
187+
188+ if ( this . _helixPagesRepo ) {
189+ pages . withRepo ( this . _helixPagesRepo ) ;
190+ }
191+
192+ await pages . init ( ) ;
193+
194+ // use bundled helix-pages sources
195+ this . withFiles ( [ `${ pages . srcDirectory } /**/*.htl` , `${ pages . srcDirectory } /**/*.js` ] ) ;
196+ this . _project . withSourceDir ( pages . srcDirectory ) ;
197+
198+ // use bundled helix-pages htdocs
199+ if ( ! await fse . pathExists ( path . join ( this . directory , 'htdocs' ) ) ) {
200+ this . config . strains . get ( 'default' ) . static . url = pages . staticURL ;
201+ localRepos . push ( {
202+ repoPath : pages . checkoutDirectory ,
203+ gitUrl : pages . staticURL ,
204+ } ) ;
205+ this . config . strains . get ( 'default' ) . static . url = pages . staticURL ;
206+ }
207+
208+ // pretend to have config file to suppress message below
209+ hasConfigFile = true ;
210+ } else {
211+ this . log . info ( ' __ __ ___ ' ) ;
212+ this . log . info ( ' / // /__ / (_)_ __ ' ) ;
213+ this . log . info ( ' / _ / -_) / /\\ \\ / ' ) ;
214+ this . log . info ( ` /_//_/\\__/_/_//_\\_\\ v${ pkgJson . version } ` ) ;
215+ this . log . info ( ' ' ) ;
216+ }
217+
218+ // start debugger (#178)
219+ // https://nodejs.org/en/docs/guides/debugging-getting-started/#enable-inspector
220+ if ( process . platform !== 'win32' ) {
221+ process . kill ( process . pid , 'SIGUSR1' ) ;
222+ }
223+
178224 if ( this . _httpPort >= 0 ) {
179225 this . _project . withHttpPort ( this . _httpPort ) ;
180226 }
0 commit comments