11// Build
22
33const baseMiddleware = require ( "../middlewares/base.js" ) ;
4- const buildHelper = require ( "../../utils/buildHelper" ) ;
54
65const build = {
76 command : "build" ,
@@ -12,11 +11,6 @@ const build = {
1211
1312build . builder = function ( cli ) {
1413 return cli
15- . command ( "dev" , "Dev build: Skips non-essential and time-intensive tasks during build" , {
16- handler : handleBuild ,
17- builder : noop ,
18- middlewares : [ baseMiddleware ]
19- } )
2014 . command ( "jsdoc" , "Build JSDoc resources" , {
2115 handler : handleBuild ,
2216 builder : noop ,
@@ -29,46 +23,46 @@ build.builder = function(cli) {
2923 } )
3024 . command ( "self-contained" ,
3125 "Build project and create self-contained bundle. " +
32- "Recommended to be used in conjunction with --all " , {
26+ "Recommended to be used in conjunction with --include-dependencies " , {
3327 handler : handleBuild ,
3428 builder : noop ,
3529 middlewares : [ baseMiddleware ]
3630 } )
37- . option ( "all" , {
38- describe : "Include all project dependencies into build process " ,
39- alias : "a" ,
31+ . option ( "include- all-dependencies " , {
32+ describe : "Include all dependencies in the build result " ,
33+ alias : [ "all" , "a" ] ,
4034 default : false ,
4135 type : "boolean"
4236 } )
4337 . option ( "include-dependency" , {
44- describe : "A list of dependencies to be included into the build process . You can use the asterisk '*' as" +
45- " an alias for including all dependencies into the build process . The listed dependencies cannot be" +
38+ describe : "A list of dependencies to be included in the build result . You can use the asterisk '*' as" +
39+ " an alias for including all dependencies in the build result . The listed dependencies cannot be" +
4640 " overruled by dependencies defined in 'exclude-dependency'." ,
4741 type : "array"
4842 } )
4943 . option ( "include-dependency-regexp" , {
50- describe : "A list of regular expressions defining dependencies to be included into the build process ." +
44+ describe : "A list of regular expressions defining dependencies to be included in the build result ." +
5145 " This list is prioritized like 'include-dependency'." ,
5246 type : "array"
5347 } )
5448 . option ( "include-dependency-tree" , {
55- describe : "A list of dependencies to be included into the build process . Transitive dependencies are" +
49+ describe : "A list of dependencies to be included in the build result . Transitive dependencies are" +
5650 " implicitly included and do not need to be part of this list. These dependencies overrule" +
5751 " the selection of 'exclude-dependency-tree' but can be overruled by 'exclude-dependency'." ,
5852 type : "array"
5953 } )
6054 . option ( "exclude-dependency" , {
61- describe : "A list of dependencies to be excluded from the build process . The listed dependencies can" +
55+ describe : "A list of dependencies to be excluded from the build result . The listed dependencies can" +
6256 " be overruled by dependencies defined in 'include-dependency'." ,
6357 type : "array"
6458 } )
6559 . option ( "exclude-dependency-regexp" , {
66- describe : "A list of regular expressions defining dependencies to be excluded from the build process ." +
60+ describe : "A list of regular expressions defining dependencies to be excluded from the build result ." +
6761 " This list is prioritized like 'exclude-dependency'." ,
6862 type : "array"
6963 } )
7064 . option ( "exclude-dependency-tree" , {
71- describe : "A list of dependencies to be excluded from the build process . Transitive dependencies are" +
65+ describe : "A list of dependencies to be excluded from the build result . Transitive dependencies are" +
7266 " implicitly included and do not need to be part of this list." ,
7367 type : "array"
7468 } )
@@ -82,18 +76,19 @@ build.builder = function(cli) {
8276 default : false ,
8377 type : "boolean"
8478 } )
85- . option ( "dev-exclude-project " , {
86- describe :
87- "A list of specific projects to be excluded from dev mode " +
88- "(dev mode must be active for this to be effective)" ,
89- type : "array "
79+ . option ( "create-build-manifest " , {
80+ describe : "Store build metadata in a '.ui5' directory in the build destination, " +
81+ "allowing reuse of the build result in other builds" ,
82+ default : false ,
83+ type : "boolean "
9084 } )
9185 . option ( "include-task" , {
92- describe : "A list of specific tasks to be included to the default/dev set" ,
86+ describe : "A list of tasks to be added to the default execution set. " +
87+ "This option takes precedence over any excludes." ,
9388 type : "array"
9489 } )
9590 . option ( "exclude-task" , {
96- describe : "A list of specific tasks to be excluded from default/dev set" ,
91+ describe : "A list of tasks to be excluded from the default task execution set" ,
9792 type : "array"
9893 } )
9994 . option ( "framework-version" , {
@@ -108,6 +103,8 @@ build.builder = function(cli) {
108103 type : "boolean"
109104 } )
110105 . example ( "ui5 build" , "Preload build for project without dependencies" )
106+
107+ // TODO 3.0: Update examples
111108 . example ( "ui5 build self-contained --all" , "Self-contained build for project including dependencies" )
112109 . example ( "ui5 build --all --exclude-task=* --include-task=createDebugFiles generateAppPreload" ,
113110 "Build project and dependencies but only apply the createDebugFiles- and generateAppPreload tasks" )
@@ -120,56 +117,49 @@ build.builder = function(cli) {
120117 . example ( "ui5 build dev" ,
121118 "Build project and dependencies in dev mode. Only a set of essential tasks is executed." )
122119 . example ( "ui5 build --experimental-css-variables" ,
123- "Preload build for project without dependencies but with CSS variable artefacts " ) ;
120+ "Preload build for project without dependencies but with CSS variable artifacts " ) ;
124121} ;
125122
126123async function handleBuild ( argv ) {
127- const normalizer = require ( "@ui5/project" ) . normalizer ;
128- const builder = require ( "@ui5/builder" ) . builder ;
129124 const logger = require ( "@ui5/logger" ) ;
125+ const { generateProjectGraph, builder} = require ( "@ui5/project" ) ;
130126
131127 const command = argv . _ [ argv . _ . length - 1 ] ;
132128 logger . setShowProgress ( true ) ;
133129
134- const normalizerOptions = {
135- translatorName : argv . translator ,
136- configPath : argv . config
137- } ;
138-
139- if ( argv . frameworkVersion ) {
140- normalizerOptions . frameworkOptions = {
130+ let graph ;
131+ if ( argv . dependencyDefinition ) {
132+ graph = await generateProjectGraph . usingStaticFile ( {
133+ filePath : argv . dependencyDefinition ,
134+ rootConfigPath : argv . config ,
141135 versionOverride : argv . frameworkVersion
142- } ;
136+ } ) ;
137+ } else {
138+ graph = await generateProjectGraph . usingNodePackageDependencies ( {
139+ rootConfigPath : argv . config ,
140+ versionOverride : argv . frameworkVersion
141+ } ) ;
143142 }
144-
145- const tree = await normalizer . generateProjectTree ( normalizerOptions ) ;
146- const buildSettings = ( tree . builder && tree . builder . settings ) || { } ;
147-
148- const { includedDependencies, excludedDependencies} = buildHelper . createDependencyLists ( {
149- tree : tree ,
150- includeDependency : argv [ "include-dependency" ] ,
151- includeDependencyRegExp : argv [ "include-dependency-regexp" ] ,
152- includeDependencyTree : argv [ "include-dependency-tree" ] ,
153- excludeDependency : argv [ "exclude-dependency" ] ,
154- excludeDependencyRegExp : argv [ "exclude-dependency-regexp" ] ,
155- excludeDependencyTree : argv [ "exclude-dependency-tree" ] ,
156- defaultIncludeDependency : buildSettings . includeDependency ,
157- defaultIncludeDependencyRegExp : buildSettings . includeDependencyRegExp ,
158- defaultIncludeDependencyTree : buildSettings . includeDependencyTree
159- } ) ;
160- const buildAll = buildHelper . alignWithBuilderApi ( argv . all , includedDependencies , excludedDependencies ) ;
161-
162- await builder . build ( {
163- tree : tree ,
143+ const buildSettings = graph . getRoot ( ) . getBuilderSettings ( ) || { } ;
144+ await builder ( {
145+ graph,
164146 destPath : argv . dest ,
165147 cleanDest : argv [ "clean-dest" ] ,
166- buildDependencies : buildAll ,
167- includedDependencies : includedDependencies ,
168- excludedDependencies : excludedDependencies ,
169- dev : command === "dev" ,
148+ createBuildManifest : argv [ "create-build-manifest" ] ,
149+ complexDependencyIncludes : {
150+ includeAllDependencies : argv [ "include-all-dependencies" ] ,
151+ includeDependency : argv [ "include-dependency" ] ,
152+ includeDependencyRegExp : argv [ "include-dependency-regexp" ] ,
153+ includeDependencyTree : argv [ "include-dependency-tree" ] ,
154+ excludeDependency : argv [ "exclude-dependency" ] ,
155+ excludeDependencyRegExp : argv [ "exclude-dependency-regexp" ] ,
156+ excludeDependencyTree : argv [ "exclude-dependency-tree" ] ,
157+ defaultIncludeDependency : buildSettings . includeDependency ,
158+ defaultIncludeDependencyRegExp : buildSettings . includeDependencyRegExp ,
159+ defaultIncludeDependencyTree : buildSettings . includeDependencyTree
160+ } ,
170161 selfContained : command === "self-contained" ,
171162 jsdoc : command === "jsdoc" ,
172- devExcludeProject : argv [ "dev-exclude-project" ] ,
173163 includedTasks : argv [ "include-task" ] ,
174164 excludedTasks : argv [ "exclude-task" ] ,
175165 cssVariables : argv [ "experimental-css-variables" ]
0 commit comments