1
1
// Build
2
2
3
3
const baseMiddleware = require ( "../middlewares/base.js" ) ;
4
- const buildHelper = require ( "../../utils/buildHelper" ) ;
5
4
6
5
const build = {
7
6
command : "build" ,
@@ -12,11 +11,6 @@ const build = {
12
11
13
12
build . builder = function ( cli ) {
14
13
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
- } )
20
14
. command ( "jsdoc" , "Build JSDoc resources" , {
21
15
handler : handleBuild ,
22
16
builder : noop ,
@@ -29,46 +23,46 @@ build.builder = function(cli) {
29
23
} )
30
24
. command ( "self-contained" ,
31
25
"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 " , {
33
27
handler : handleBuild ,
34
28
builder : noop ,
35
29
middlewares : [ baseMiddleware ]
36
30
} )
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" ] ,
40
34
default : false ,
41
35
type : "boolean"
42
36
} )
43
37
. 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" +
46
40
" overruled by dependencies defined in 'exclude-dependency'." ,
47
41
type : "array"
48
42
} )
49
43
. 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 ." +
51
45
" This list is prioritized like 'include-dependency'." ,
52
46
type : "array"
53
47
} )
54
48
. 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" +
56
50
" implicitly included and do not need to be part of this list. These dependencies overrule" +
57
51
" the selection of 'exclude-dependency-tree' but can be overruled by 'exclude-dependency'." ,
58
52
type : "array"
59
53
} )
60
54
. 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" +
62
56
" be overruled by dependencies defined in 'include-dependency'." ,
63
57
type : "array"
64
58
} )
65
59
. 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 ." +
67
61
" This list is prioritized like 'exclude-dependency'." ,
68
62
type : "array"
69
63
} )
70
64
. 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" +
72
66
" implicitly included and do not need to be part of this list." ,
73
67
type : "array"
74
68
} )
@@ -82,18 +76,19 @@ build.builder = function(cli) {
82
76
default : false ,
83
77
type : "boolean"
84
78
} )
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 "
90
84
} )
91
85
. 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." ,
93
88
type : "array"
94
89
} )
95
90
. 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" ,
97
92
type : "array"
98
93
} )
99
94
. option ( "framework-version" , {
@@ -108,6 +103,8 @@ build.builder = function(cli) {
108
103
type : "boolean"
109
104
} )
110
105
. example ( "ui5 build" , "Preload build for project without dependencies" )
106
+
107
+ // TODO 3.0: Update examples
111
108
. example ( "ui5 build self-contained --all" , "Self-contained build for project including dependencies" )
112
109
. example ( "ui5 build --all --exclude-task=* --include-task=createDebugFiles generateAppPreload" ,
113
110
"Build project and dependencies but only apply the createDebugFiles- and generateAppPreload tasks" )
@@ -120,56 +117,49 @@ build.builder = function(cli) {
120
117
. example ( "ui5 build dev" ,
121
118
"Build project and dependencies in dev mode. Only a set of essential tasks is executed." )
122
119
. 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 " ) ;
124
121
} ;
125
122
126
123
async function handleBuild ( argv ) {
127
- const normalizer = require ( "@ui5/project" ) . normalizer ;
128
- const builder = require ( "@ui5/builder" ) . builder ;
129
124
const logger = require ( "@ui5/logger" ) ;
125
+ const { generateProjectGraph, builder} = require ( "@ui5/project" ) ;
130
126
131
127
const command = argv . _ [ argv . _ . length - 1 ] ;
132
128
logger . setShowProgress ( true ) ;
133
129
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 ,
141
135
versionOverride : argv . frameworkVersion
142
- } ;
136
+ } ) ;
137
+ } else {
138
+ graph = await generateProjectGraph . usingNodePackageDependencies ( {
139
+ rootConfigPath : argv . config ,
140
+ versionOverride : argv . frameworkVersion
141
+ } ) ;
143
142
}
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,
164
146
destPath : argv . dest ,
165
147
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
+ } ,
170
161
selfContained : command === "self-contained" ,
171
162
jsdoc : command === "jsdoc" ,
172
- devExcludeProject : argv [ "dev-exclude-project" ] ,
173
163
includedTasks : argv [ "include-task" ] ,
174
164
excludedTasks : argv [ "exclude-task" ] ,
175
165
cssVariables : argv [ "experimental-css-variables" ]
0 commit comments