@ui5/cli 3.0.0-alpha.1 → 3.0.0-alpha.12
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 +926 -0
- package/lib/cli/commands/add.js +4 -4
- package/lib/cli/commands/base.js +9 -5
- package/lib/cli/commands/build.js +61 -61
- 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 +1133 -8627
- package/package.json +11 -10
- package/lib/utils/buildHelper.js +0 -216
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,25 +76,35 @@ 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", {
|
|
100
95
|
describe: "Overrides the framework version defined by the project",
|
|
101
96
|
type: "string"
|
|
102
97
|
})
|
|
98
|
+
.option("experimental-css-variables", {
|
|
99
|
+
describe:
|
|
100
|
+
"Generate CSS variables (css-variables.css, css-variables.source.less)" +
|
|
101
|
+
" and skeleton (library-skeleton(-RTL).css) for all themes",
|
|
102
|
+
default: false,
|
|
103
|
+
type: "boolean"
|
|
104
|
+
})
|
|
103
105
|
.example("ui5 build", "Preload build for project without dependencies")
|
|
106
|
+
|
|
107
|
+
// TODO 3.0: Update examples
|
|
104
108
|
.example("ui5 build self-contained --all", "Self-contained build for project including dependencies")
|
|
105
109
|
.example("ui5 build --all --exclude-task=* --include-task=createDebugFiles generateAppPreload",
|
|
106
110
|
"Build project and dependencies but only apply the createDebugFiles- and generateAppPreload tasks")
|
|
@@ -111,58 +115,54 @@ build.builder = function(cli) {
|
|
|
111
115
|
"Build project and dependencies in dev mode, except \"sap.ui.core\" and \"sap.m\" " +
|
|
112
116
|
"(useful in combination with --include-task)")
|
|
113
117
|
.example("ui5 build dev",
|
|
114
|
-
"Build project and dependencies in dev mode. Only a set of essential tasks is executed.")
|
|
118
|
+
"Build project and dependencies in dev mode. Only a set of essential tasks is executed.")
|
|
119
|
+
.example("ui5 build --experimental-css-variables",
|
|
120
|
+
"Preload build for project without dependencies but with CSS variable artifacts");
|
|
115
121
|
};
|
|
116
122
|
|
|
117
123
|
async function handleBuild(argv) {
|
|
118
|
-
const normalizer = require("@ui5/project").normalizer;
|
|
119
|
-
const builder = require("@ui5/builder").builder;
|
|
120
124
|
const logger = require("@ui5/logger");
|
|
125
|
+
const {generateProjectGraph} = require("@ui5/project");
|
|
121
126
|
|
|
122
127
|
const command = argv._[argv._.length - 1];
|
|
123
128
|
logger.setShowProgress(true);
|
|
124
129
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
let graph;
|
|
131
|
+
if (argv.dependencyDefinition) {
|
|
132
|
+
graph = await generateProjectGraph.usingStaticFile({
|
|
133
|
+
filePath: argv.dependencyDefinition,
|
|
134
|
+
rootConfigPath: argv.config,
|
|
135
|
+
versionOverride: argv.frameworkVersion
|
|
136
|
+
});
|
|
137
|
+
} else {
|
|
138
|
+
graph = await generateProjectGraph.usingNodePackageDependencies({
|
|
139
|
+
rootConfigPath: argv.config,
|
|
132
140
|
versionOverride: argv.frameworkVersion
|
|
133
|
-
};
|
|
141
|
+
});
|
|
134
142
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const {includedDependencies, excludedDependencies} = buildHelper.createDependencyLists({
|
|
140
|
-
tree: tree,
|
|
141
|
-
includeDependency: argv["include-dependency"],
|
|
142
|
-
includeDependencyRegExp: argv["include-dependency-regexp"],
|
|
143
|
-
includeDependencyTree: argv["include-dependency-tree"],
|
|
144
|
-
excludeDependency: argv["exclude-dependency"],
|
|
145
|
-
excludeDependencyRegExp: argv["exclude-dependency-regexp"],
|
|
146
|
-
excludeDependencyTree: argv["exclude-dependency-tree"],
|
|
147
|
-
defaultIncludeDependency: buildSettings.includeDependency,
|
|
148
|
-
defaultIncludeDependencyRegExp: buildSettings.includeDependencyRegExp,
|
|
149
|
-
defaultIncludeDependencyTree: buildSettings.includeDependencyTree
|
|
150
|
-
});
|
|
151
|
-
const buildAll = buildHelper.alignWithBuilderApi(argv.all, includedDependencies, excludedDependencies);
|
|
152
|
-
|
|
153
|
-
await builder.build({
|
|
154
|
-
tree: tree,
|
|
143
|
+
const buildSettings = graph.getRoot().getBuilderSettings() || {};
|
|
144
|
+
await graph.build({
|
|
145
|
+
graph,
|
|
155
146
|
destPath: argv.dest,
|
|
156
147
|
cleanDest: argv["clean-dest"],
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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
|
+
},
|
|
161
161
|
selfContained: command === "self-contained",
|
|
162
162
|
jsdoc: command === "jsdoc",
|
|
163
|
-
devExcludeProject: argv["dev-exclude-project"],
|
|
164
163
|
includedTasks: argv["include-task"],
|
|
165
|
-
excludedTasks: argv["exclude-task"]
|
|
164
|
+
excludedTasks: argv["exclude-task"],
|
|
165
|
+
cssVariables: argv["experimental-css-variables"]
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
168
|
|
|
@@ -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
|
package/lib/framework/remove.js
CHANGED
|
@@ -6,39 +6,39 @@ const log = require("@ui5/logger").getLogger("cli:framework:remove");
|
|
|
6
6
|
* Removes the given set of libraries from the framework libraries section in the ui5.yaml
|
|
7
7
|
*
|
|
8
8
|
* @param {object} parameters Parameters
|
|
9
|
-
* @param {object} parameters.
|
|
9
|
+
* @param {object} parameters.projectGraphOptions
|
|
10
10
|
* @param {object} parameters.libraries
|
|
11
11
|
*/
|
|
12
|
-
module.exports = async function({
|
|
13
|
-
const project = await getRootProjectConfiguration(
|
|
12
|
+
module.exports = async function({projectGraphOptions, libraries}) {
|
|
13
|
+
const project = await getRootProjectConfiguration(projectGraphOptions);
|
|
14
14
|
|
|
15
|
-
if (!isValidSpecVersion(project.
|
|
15
|
+
if (!isValidSpecVersion(project.getSpecVersion())) {
|
|
16
16
|
throw new Error(
|
|
17
17
|
`ui5 remove command requires specVersion "2.0" or higher. ` +
|
|
18
|
-
`Project ${project.
|
|
18
|
+
`Project ${project.getName()} uses specVersion "${project.getSpecVersion()}"`
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
if (!project.
|
|
22
|
+
if (!project.getFrameworkName()) {
|
|
23
23
|
throw new Error(
|
|
24
|
-
`Project ${project.
|
|
24
|
+
`Project ${project.getName()} is missing a framework configuration. ` +
|
|
25
25
|
`Please use "ui5 use" to configure a framework and version.`
|
|
26
26
|
);
|
|
27
27
|
}
|
|
28
|
-
if (!project.
|
|
28
|
+
if (!project.getFrameworkVersion()) {
|
|
29
29
|
throw new Error(
|
|
30
|
-
`Project ${project.
|
|
30
|
+
`Project ${project.getName()} does not define a framework version configuration. ` +
|
|
31
31
|
`Please use "ui5 use" to configure a version.`
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
if (!project.
|
|
35
|
+
if (!project.getFrameworkDependencies().length) {
|
|
36
36
|
throw new Error(
|
|
37
|
-
`Project ${project.
|
|
37
|
+
`Project ${project.getName()} does not define framework libraries.`
|
|
38
38
|
);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
const allLibraries = [...project.
|
|
41
|
+
const allLibraries = [...project.getFrameworkDependencies()];
|
|
42
42
|
|
|
43
43
|
libraries.forEach((library) => {
|
|
44
44
|
const iIndexToRemove = allLibraries.findIndex(($) => $.name === library.name);
|
|
@@ -46,7 +46,7 @@ module.exports = async function({normalizerOptions, libraries}) {
|
|
|
46
46
|
// do not fail here just log, because the framework library is not present afterwards
|
|
47
47
|
log.warn(
|
|
48
48
|
`Failed to remove framework library ${library.name} from project ` +
|
|
49
|
-
`${project.
|
|
49
|
+
`${project.getName()} because it is not present.`
|
|
50
50
|
);
|
|
51
51
|
} else {
|
|
52
52
|
allLibraries.splice(iIndexToRemove, 1);
|
|
@@ -63,6 +63,7 @@ module.exports = async function({normalizerOptions, libraries}) {
|
|
|
63
63
|
try {
|
|
64
64
|
await require("./updateYaml")({
|
|
65
65
|
project,
|
|
66
|
+
configPathOverride: projectGraphOptions.config,
|
|
66
67
|
data: {
|
|
67
68
|
framework: {
|
|
68
69
|
libraries: allLibraries
|