@ui5/cli 3.0.0-alpha.5 → 3.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -1
- package/lib/cli/commands/add.js +4 -4
- package/lib/cli/commands/base.js +9 -5
- package/lib/cli/commands/build.js +52 -62
- package/lib/cli/commands/remove.js +4 -4
- package/lib/cli/commands/serve.js +16 -14
- package/lib/cli/commands/tree.js +80 -45
- package/lib/cli/commands/use.js +4 -4
- package/lib/framework/add.js +27 -20
- package/lib/framework/remove.js +14 -13
- package/lib/framework/updateYaml.js +14 -4
- package/lib/framework/use.js +10 -12
- package/lib/framework/utils.js +14 -10
- package/npm-shrinkwrap.json +572 -733
- package/package.json +7 -7
- package/lib/utils/buildHelper.js +0 -216
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,33 @@
|
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
4
4
|
|
|
5
|
-
A list of unreleased changes can be found [here](https://github.com/SAP/ui5-cli/compare/v3.0.0-alpha.
|
|
5
|
+
A list of unreleased changes can be found [here](https://github.com/SAP/ui5-cli/compare/v3.0.0-alpha.8...HEAD).
|
|
6
|
+
|
|
7
|
+
<a name="v3.0.0-alpha.8"></a>
|
|
8
|
+
## [v3.0.0-alpha.8] - 2022-06-14
|
|
9
|
+
### Breaking Changes
|
|
10
|
+
- Adapt to Project Graph APIs ([#413](https://github.com/SAP/ui5-cli/issues/413)) [`945b82b`](https://github.com/SAP/ui5-cli/commit/945b82bc775dc0a711529057908e9f36d8fadb62)
|
|
11
|
+
|
|
12
|
+
### Dependency Updates
|
|
13
|
+
- Bump [@ui5](https://github.com/ui5)/server from 3.0.0-alpha.1 to 3.0.0-alpha.2 [`5b959b3`](https://github.com/SAP/ui5-cli/commit/5b959b3903b93b0c7c693f2785d26532c8e78d53)
|
|
14
|
+
- Bump [@ui5](https://github.com/ui5)/project from 3.0.0-alpha.2 to 3.0.0-alpha.3 [`780b1c1`](https://github.com/SAP/ui5-cli/commit/780b1c17b9a6b23397b74ef52fbe707aabf21edb)
|
|
15
|
+
- Bump [@ui5](https://github.com/ui5)/builder from 3.0.0-alpha.6 to 3.0.0-alpha.7 [`37a7062`](https://github.com/SAP/ui5-cli/commit/37a7062521e08085560ea96a27d15e5f4c5d5574)
|
|
16
|
+
- Bump [@ui5](https://github.com/ui5)/fs from 3.0.0-alpha.3 to 3.0.0-alpha.4 [`ae07607`](https://github.com/SAP/ui5-cli/commit/ae076071ccf4dd9d6a58933d7d6aa0a1fdb9d283)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
<a name="v3.0.0-alpha.7"></a>
|
|
20
|
+
## [v3.0.0-alpha.7] - 2022-04-26
|
|
21
|
+
### Dependency Updates
|
|
22
|
+
- Bump [@ui5](https://github.com/ui5)/project from 3.0.0-alpha.1 to 3.0.0-alpha.2 [`aac8f7f`](https://github.com/SAP/ui5-cli/commit/aac8f7f5f204660010c42ed428542e01a988d5c6)
|
|
23
|
+
- Bump [@ui5](https://github.com/ui5)/builder from 3.0.0-alpha.5 to 3.0.0-alpha.6 [`027e4df`](https://github.com/SAP/ui5-cli/commit/027e4dfba2bbbb9bcf209d82d85ecff7a2acb6a9)
|
|
24
|
+
- Bump [@ui5](https://github.com/ui5)/fs from 3.0.0-alpha.2 to 3.0.0-alpha.3 [`1f43c4e`](https://github.com/SAP/ui5-cli/commit/1f43c4ed2699e66b0d6c50ca3738a6f61c060734)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
<a name="v3.0.0-alpha.6"></a>
|
|
28
|
+
## [v3.0.0-alpha.6] - 2022-04-14
|
|
29
|
+
### Dependency Updates
|
|
30
|
+
- Bump [@ui5](https://github.com/ui5)/builder from 3.0.0-alpha.4 to 3.0.0-alpha.5 [`87c4136`](https://github.com/SAP/ui5-cli/commit/87c413627696365eb94de9fccdd7798a05543933)
|
|
31
|
+
|
|
6
32
|
|
|
7
33
|
<a name="v3.0.0-alpha.5"></a>
|
|
8
34
|
## [v3.0.0-alpha.5] - 2022-04-05
|
|
@@ -757,6 +783,9 @@ Only Node.js v10 or higher is supported.
|
|
|
757
783
|
<a name="v0.0.1"></a>
|
|
758
784
|
## v0.0.1 - 2018-06-06
|
|
759
785
|
|
|
786
|
+
[v3.0.0-alpha.8]: https://github.com/SAP/ui5-cli/compare/v3.0.0-alpha.7...v3.0.0-alpha.8
|
|
787
|
+
[v3.0.0-alpha.7]: https://github.com/SAP/ui5-cli/compare/v3.0.0-alpha.6...v3.0.0-alpha.7
|
|
788
|
+
[v3.0.0-alpha.6]: https://github.com/SAP/ui5-cli/compare/v3.0.0-alpha.5...v3.0.0-alpha.6
|
|
760
789
|
[v3.0.0-alpha.5]: https://github.com/SAP/ui5-cli/compare/v3.0.0-alpha.4...v3.0.0-alpha.5
|
|
761
790
|
[v3.0.0-alpha.4]: https://github.com/SAP/ui5-cli/compare/v3.0.0-alpha.3...v3.0.0-alpha.4
|
|
762
791
|
[v3.0.0-alpha.3]: https://github.com/SAP/ui5-cli/compare/v3.0.0-alpha.2...v3.0.0-alpha.3
|
package/lib/cli/commands/add.js
CHANGED
|
@@ -41,9 +41,9 @@ addCommand.handler = async function(argv) {
|
|
|
41
41
|
throw new Error("Options 'development' and 'optional' cannot be combined");
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
const projectGraphOptions = {
|
|
45
|
+
dependencyDefinition: argv.dependencyDefinition,
|
|
46
|
+
config: argv.config
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
const libraries = libraryNames.map((name) => {
|
|
@@ -57,7 +57,7 @@ addCommand.handler = async function(argv) {
|
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
const {yamlUpdated} = await require("../../framework/add")({
|
|
60
|
-
|
|
60
|
+
projectGraphOptions,
|
|
61
61
|
libraries
|
|
62
62
|
});
|
|
63
63
|
|
package/lib/cli/commands/base.js
CHANGED
|
@@ -3,13 +3,12 @@ const cli = require("yargs");
|
|
|
3
3
|
cli.usage("Usage: ui5 <command> [options]")
|
|
4
4
|
.demandCommand(1, "Command required! Please have a look at the help documentation above.")
|
|
5
5
|
.option("config", {
|
|
6
|
-
describe: "Path to configuration file",
|
|
6
|
+
describe: "Path to project configuration file in YAML format",
|
|
7
7
|
type: "string"
|
|
8
8
|
})
|
|
9
|
-
.option("
|
|
10
|
-
describe: "
|
|
11
|
-
|
|
12
|
-
default: "npm",
|
|
9
|
+
.option("dependency-definition", {
|
|
10
|
+
describe: "Path to a YAML file containing the project's dependency tree. " +
|
|
11
|
+
"This option will disable resolution of node package dependencies.",
|
|
13
12
|
type: "string"
|
|
14
13
|
})
|
|
15
14
|
.option("verbose", {
|
|
@@ -22,6 +21,11 @@ cli.usage("Usage: ui5 <command> [options]")
|
|
|
22
21
|
default: "info",
|
|
23
22
|
type: "string"
|
|
24
23
|
})
|
|
24
|
+
.option("x-perf", {
|
|
25
|
+
describe: "Outputs performance measurements",
|
|
26
|
+
default: false,
|
|
27
|
+
type: "boolean"
|
|
28
|
+
})
|
|
25
29
|
.showHelpOnFail(true)
|
|
26
30
|
.strict(true)
|
|
27
31
|
.alias("help", "h")
|
|
@@ -1,7 +1,6 @@
|
|
|
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 --
|
|
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
|
|
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
|
|
45
|
-
" an alias for including all dependencies
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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("
|
|
86
|
-
describe:
|
|
87
|
-
"
|
|
88
|
-
|
|
89
|
-
type: "
|
|
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
|
|
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
|
|
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", {
|
|
@@ -102,12 +97,14 @@ build.builder = function(cli) {
|
|
|
102
97
|
})
|
|
103
98
|
.option("experimental-css-variables", {
|
|
104
99
|
describe:
|
|
105
|
-
"
|
|
106
|
-
"and
|
|
100
|
+
"Generate CSS variables (css-variables.css, css-variables.source.less)" +
|
|
101
|
+
" and skeleton (library-skeleton(-RTL).css) for all themes",
|
|
107
102
|
default: false,
|
|
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
|
|
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
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
-
|
|
146
|
-
|
|
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
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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"]
|
|
@@ -27,9 +27,9 @@ removeCommand.handler = async function(argv) {
|
|
|
27
27
|
return libraryNames.indexOf(libraryName) === index;
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
const projectGraphOptions = {
|
|
31
|
+
dependencyDefinition: argv.dependencyDefinition,
|
|
32
|
+
config: argv.config
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
const libraries = libraryNames.map((name) => {
|
|
@@ -38,7 +38,7 @@ removeCommand.handler = async function(argv) {
|
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
const {yamlUpdated} = await require("../../framework/remove")({
|
|
41
|
-
|
|
41
|
+
projectGraphOptions,
|
|
42
42
|
libraries
|
|
43
43
|
});
|
|
44
44
|
|
|
@@ -73,30 +73,32 @@ serve.builder = function(cli) {
|
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
serve.handler = async function(argv) {
|
|
76
|
-
const
|
|
76
|
+
const {generateProjectGraph} = require("@ui5/project");
|
|
77
77
|
const ui5Server = require("@ui5/server");
|
|
78
78
|
const server = ui5Server.server;
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
80
|
+
let graph;
|
|
81
|
+
if (argv.dependencyDefinition) {
|
|
82
|
+
graph = await generateProjectGraph.usingStaticFile({
|
|
83
|
+
filePath: argv.dependencyDefinition,
|
|
84
|
+
versionOverride: argv.frameworkVersion
|
|
85
|
+
});
|
|
86
|
+
} else {
|
|
87
|
+
graph = await generateProjectGraph.usingNodePackageDependencies({
|
|
88
|
+
rootConfigPath: argv.config,
|
|
87
89
|
versionOverride: argv.frameworkVersion
|
|
88
|
-
};
|
|
90
|
+
});
|
|
89
91
|
}
|
|
90
92
|
|
|
91
|
-
const tree = await normalizer.generateProjectTree(normalizerOptions);
|
|
92
93
|
let port = argv.port;
|
|
93
94
|
let changePortIfInUse = false;
|
|
94
95
|
|
|
95
|
-
if (!port &&
|
|
96
|
+
if (!port && graph.getRoot().getServerSettings()) {
|
|
97
|
+
const serverSettings = graph.getRoot().getServerSettings();
|
|
96
98
|
if (argv.h2) {
|
|
97
|
-
port =
|
|
99
|
+
port = serverSettings.httpsPort;
|
|
98
100
|
} else {
|
|
99
|
-
port =
|
|
101
|
+
port = serverSettings.httpPort;
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
104
|
|
|
@@ -127,7 +129,7 @@ serve.handler = async function(argv) {
|
|
|
127
129
|
serverConfig.cert = cert;
|
|
128
130
|
}
|
|
129
131
|
|
|
130
|
-
const {h2, port: actualPort} = await server.serve(
|
|
132
|
+
const {h2, port: actualPort} = await server.serve(graph, serverConfig);
|
|
131
133
|
|
|
132
134
|
const protocol = h2 ? "https" : "http";
|
|
133
135
|
let browserUrl = protocol + "://localhost:" + actualPort;
|
package/lib/cli/commands/tree.js
CHANGED
|
@@ -9,63 +9,98 @@ const tree = {
|
|
|
9
9
|
|
|
10
10
|
tree.builder = function(cli) {
|
|
11
11
|
return cli
|
|
12
|
-
.option("full", {
|
|
13
|
-
describe: "Include more information (currently the project configuration)",
|
|
14
|
-
default: false,
|
|
15
|
-
type: "boolean"
|
|
16
|
-
})
|
|
17
|
-
.option("json", {
|
|
18
|
-
describe: "Output tree as formatted JSON string",
|
|
19
|
-
default: false,
|
|
20
|
-
type: "boolean"
|
|
21
|
-
})
|
|
22
|
-
.option("dedupe", {
|
|
23
|
-
describe: "Remove duplicate projects from project tree",
|
|
24
|
-
default: false,
|
|
25
|
-
type: "boolean"
|
|
26
|
-
})
|
|
27
12
|
.option("framework-version", {
|
|
28
13
|
describe:
|
|
29
|
-
"Overrides the framework version defined by the project
|
|
14
|
+
"Overrides the framework version defined by the project",
|
|
30
15
|
type: "string"
|
|
31
|
-
})
|
|
32
|
-
if (argv.frameworkVersion && !argv.full) {
|
|
33
|
-
throw new Error(`"framework-version" can only be used in combination with option "--full"`);
|
|
34
|
-
} else {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
})
|
|
38
|
-
.example("ui5 tree > tree.txt", "Pipes the dependency tree into a new file \"tree.txt\"")
|
|
39
|
-
.example("ui5 tree --json > tree.json", "Pipes the dependency tree into a new file \"tree.json\"");
|
|
16
|
+
});
|
|
40
17
|
};
|
|
41
18
|
|
|
42
19
|
tree.handler = async function(argv) {
|
|
43
|
-
const
|
|
44
|
-
const treeify = require("treeify");
|
|
45
|
-
|
|
46
|
-
const options = {
|
|
47
|
-
translatorName: argv.translator,
|
|
48
|
-
translatorOptions: {
|
|
49
|
-
includeDeduped: !argv.dedupe
|
|
50
|
-
},
|
|
51
|
-
configPath: argv.config
|
|
52
|
-
};
|
|
20
|
+
const chalk = require("chalk");
|
|
53
21
|
|
|
54
|
-
|
|
55
|
-
|
|
22
|
+
let startTime;
|
|
23
|
+
let elapsedTime;
|
|
24
|
+
if (argv.xPerf) {
|
|
25
|
+
startTime = process.hrtime();
|
|
26
|
+
}
|
|
27
|
+
const {generateProjectGraph} = require("@ui5/project");
|
|
28
|
+
let graph;
|
|
29
|
+
if (argv.dependencyDefinition) {
|
|
30
|
+
graph = await generateProjectGraph.usingStaticFile({
|
|
31
|
+
filePath: argv.dependencyDefinition,
|
|
56
32
|
versionOverride: argv.frameworkVersion
|
|
57
|
-
};
|
|
33
|
+
});
|
|
34
|
+
} else {
|
|
35
|
+
graph = await generateProjectGraph.usingNodePackageDependencies({
|
|
36
|
+
rootConfigPath: argv.config,
|
|
37
|
+
versionOverride: argv.frameworkVersion
|
|
38
|
+
});
|
|
58
39
|
}
|
|
59
40
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
projectTree = await normalizer.generateProjectTree(options);
|
|
63
|
-
} else {
|
|
64
|
-
projectTree = await normalizer.generateDependencyTree(options);
|
|
41
|
+
if (argv.xPerf) {
|
|
42
|
+
elapsedTime = getElapsedTime(startTime);
|
|
65
43
|
}
|
|
66
44
|
|
|
67
|
-
const
|
|
68
|
-
|
|
45
|
+
const projects = {};
|
|
46
|
+
const indentWidth = 4;
|
|
47
|
+
await graph.traverseBreadthFirst(async ({project, getDependencies}) => {
|
|
48
|
+
const deps = getDependencies().map((dep) => {
|
|
49
|
+
return dep.getName();
|
|
50
|
+
});
|
|
51
|
+
projects[project.getName()] = {
|
|
52
|
+
render: function(indentation, connectorIndices, lastChild) {
|
|
53
|
+
let baseString = " ".repeat(indentation * indentWidth);
|
|
54
|
+
connectorIndices.forEach((idx) => {
|
|
55
|
+
baseString = `${baseString.slice(0, idx)}│${baseString.slice(idx + 1)}`;
|
|
56
|
+
});
|
|
57
|
+
const connectorString = lastChild ? "╰─" : "├─";
|
|
58
|
+
console.log(
|
|
59
|
+
`${baseString}${connectorString} ${chalk.bold(project.getName())} ` +
|
|
60
|
+
`${project.getNamespace ? chalk.inverse(project.getNamespace()) + " " : ""}` +
|
|
61
|
+
chalk.dim(`(${project.getVersion()}, ${project.getType()}) `) +
|
|
62
|
+
chalk.dim.italic(`${project.getPath()}`)
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const lastIdx = deps.length -1;
|
|
66
|
+
const newConnectorIndices = [...connectorIndices];
|
|
67
|
+
if (!lastChild) {
|
|
68
|
+
newConnectorIndices.push(indentation * indentWidth);
|
|
69
|
+
}
|
|
70
|
+
deps.forEach((dep, i) => {
|
|
71
|
+
projects[dep].render(indentation + 1, newConnectorIndices, i === lastIdx);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const projectKeys = Object.keys(projects);
|
|
78
|
+
console.log(chalk.bold.underline(`Dependencies (${projectKeys.length}):`));
|
|
79
|
+
projects[projectKeys[0]].render(0, [], true);
|
|
80
|
+
console.log("");
|
|
81
|
+
|
|
82
|
+
const extensions = graph.getAllExtensions();
|
|
83
|
+
console.log(chalk.bold.underline(`Extensions (${extensions.length}):`));
|
|
84
|
+
if (extensions.length) {
|
|
85
|
+
extensions.forEach((extension) => {
|
|
86
|
+
console.log(
|
|
87
|
+
`├─ ${extension.getName()} ` +
|
|
88
|
+
chalk.dim(`(${extension.getVersion()}, ${extension.getType()}) `) +
|
|
89
|
+
chalk.dim.italic(`${extension.getPath()}`));
|
|
90
|
+
});
|
|
91
|
+
} else {
|
|
92
|
+
console.log(chalk.italic(`None`));
|
|
93
|
+
}
|
|
94
|
+
if (argv.xPerf) {
|
|
95
|
+
console.log("");
|
|
96
|
+
console.log(chalk.blue(
|
|
97
|
+
`Dependency graph generation took ${chalk.bold(elapsedTime)}`));
|
|
98
|
+
}
|
|
69
99
|
};
|
|
70
100
|
|
|
101
|
+
function getElapsedTime(startTime) {
|
|
102
|
+
const timeDiff = process.hrtime(startTime);
|
|
103
|
+
const prettyHrtime = require("pretty-hrtime");
|
|
104
|
+
return prettyHrtime(timeDiff);
|
|
105
|
+
}
|
|
71
106
|
module.exports = tree;
|
package/lib/cli/commands/use.js
CHANGED
|
@@ -55,13 +55,13 @@ function parseFrameworkInfo(frameworkInfo) {
|
|
|
55
55
|
useCommand.handler = async function(argv) {
|
|
56
56
|
const frameworkOptions = parseFrameworkInfo(argv["framework-info"]);
|
|
57
57
|
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
const projectGraphOptions = {
|
|
59
|
+
dependencyDefinition: argv.dependencyDefinition,
|
|
60
|
+
config: argv.config
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
const {usedFramework, usedVersion, yamlUpdated} = await require("../../framework/use")({
|
|
64
|
-
|
|
64
|
+
projectGraphOptions,
|
|
65
65
|
frameworkOptions
|
|
66
66
|
});
|
|
67
67
|
|
package/lib/framework/add.js
CHANGED
|
@@ -1,33 +1,40 @@
|
|
|
1
1
|
const {getRootProjectConfiguration, getFrameworkResolver, isValidSpecVersion} = require("./utils");
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Adds the given set of libraries to the framework libraries section in the ui5.yaml
|
|
5
|
+
*
|
|
6
|
+
* @param {object} parameters Parameters
|
|
7
|
+
* @param {object} parameters.projectGraphOptions
|
|
8
|
+
* @param {object} parameters.libraries
|
|
9
|
+
*/
|
|
10
|
+
module.exports = async function({projectGraphOptions, libraries}) {
|
|
11
|
+
const project = await getRootProjectConfiguration(projectGraphOptions);
|
|
5
12
|
|
|
6
|
-
if (!isValidSpecVersion(project.
|
|
13
|
+
if (!isValidSpecVersion(project.getSpecVersion())) {
|
|
7
14
|
throw new Error(
|
|
8
15
|
`ui5 add command requires specVersion "2.0" or higher. ` +
|
|
9
|
-
`Project ${project.
|
|
16
|
+
`Project ${project.getName()} uses specVersion "${project.getSpecVersion()}"`
|
|
10
17
|
);
|
|
11
18
|
}
|
|
12
19
|
|
|
13
|
-
if (!project.
|
|
20
|
+
if (!project.getFrameworkName()) {
|
|
14
21
|
throw new Error(
|
|
15
|
-
`Project ${project.
|
|
22
|
+
`Project ${project.getName()} is missing a framework configuration. ` +
|
|
16
23
|
`Please use "ui5 use" to configure a framework and version.`
|
|
17
24
|
);
|
|
18
25
|
}
|
|
19
|
-
if (!project.
|
|
26
|
+
if (!project.getFrameworkVersion()) {
|
|
20
27
|
throw new Error(
|
|
21
|
-
`Project ${project.
|
|
28
|
+
`Project ${project.getName()} does not define a framework version configuration. ` +
|
|
22
29
|
`Please use "ui5 use" to configure a version.`
|
|
23
30
|
);
|
|
24
31
|
}
|
|
25
32
|
|
|
26
|
-
const Resolver = getFrameworkResolver(project.
|
|
33
|
+
const Resolver = getFrameworkResolver(project.getFrameworkName());
|
|
27
34
|
|
|
28
35
|
const resolver = new Resolver({
|
|
29
|
-
cwd: project.
|
|
30
|
-
version: project.
|
|
36
|
+
cwd: project.getPath(),
|
|
37
|
+
version: project.getFrameworkVersion()
|
|
31
38
|
});
|
|
32
39
|
|
|
33
40
|
// Get metadata of all libraries to verify that they can be installed
|
|
@@ -35,21 +42,20 @@ module.exports = async function({normalizerOptions, libraries}) {
|
|
|
35
42
|
try {
|
|
36
43
|
await resolver.getLibraryMetadata(name);
|
|
37
44
|
} catch (err) {
|
|
38
|
-
throw new Error(`Failed to find ${project.
|
|
45
|
+
throw new Error(`Failed to find ${project.getFrameworkName()} framework library ${name}: ` + err.message);
|
|
39
46
|
}
|
|
40
47
|
}));
|
|
41
48
|
|
|
42
49
|
// Shallow copy of given libraries to not modify the input parameter when pushing other libraries
|
|
43
50
|
const allLibraries = [...libraries];
|
|
44
51
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
52
|
+
project.getFrameworkDependencies().forEach((library) => {
|
|
53
|
+
// Don't add libraries twice!
|
|
54
|
+
if (allLibraries.findIndex(($) => $.name === library.name) === -1) {
|
|
55
|
+
allLibraries.push(library);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
53
59
|
allLibraries.sort((a, b) => {
|
|
54
60
|
return a.name.localeCompare(b.name);
|
|
55
61
|
});
|
|
@@ -59,6 +65,7 @@ module.exports = async function({normalizerOptions, libraries}) {
|
|
|
59
65
|
try {
|
|
60
66
|
await require("./updateYaml")({
|
|
61
67
|
project,
|
|
68
|
+
configPathOverride: projectGraphOptions.config,
|
|
62
69
|
data: {
|
|
63
70
|
framework: {
|
|
64
71
|
libraries: allLibraries
|