@ui5/cli 3.0.0-alpha.0 → 3.0.0-alpha.11
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 +102 -1
- 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 +6037 -846
- package/package.json +18 -17
- package/lib/utils/buildHelper.js +0 -216
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
|
|
@@ -9,11 +9,11 @@ function getProjectYamlDocument({project, configFile, configPath}) {
|
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
const projectDocumentIndex = configs.findIndex((config) => {
|
|
12
|
-
return config.metadata && config.metadata.name === project.
|
|
12
|
+
return config.metadata && config.metadata.name === project.getName();
|
|
13
13
|
});
|
|
14
14
|
if (projectDocumentIndex === -1) {
|
|
15
15
|
throw new Error(
|
|
16
|
-
`Could not find project with name ${project.
|
|
16
|
+
`Could not find project with name ${project.getName()} in YAML: ${configPath}`
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -137,13 +137,23 @@ function formatValue(value, indent) {
|
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
module.exports = async function({project, data}) {
|
|
140
|
+
module.exports = async function({project, configPathOverride, data}) {
|
|
141
141
|
const {promisify} = require("util");
|
|
142
142
|
const fs = require("fs");
|
|
143
143
|
const readFile = promisify(fs.readFile);
|
|
144
144
|
const writeFile = promisify(fs.writeFile);
|
|
145
145
|
|
|
146
|
-
|
|
146
|
+
let configPath;
|
|
147
|
+
if (configPathOverride) {
|
|
148
|
+
if (path.isAbsolute(configPathOverride)) {
|
|
149
|
+
configPath = configPathOverride;
|
|
150
|
+
} else {
|
|
151
|
+
configPath = path.join(project.getPath(), configPathOverride);
|
|
152
|
+
}
|
|
153
|
+
} else {
|
|
154
|
+
configPath = path.join(project.getPath(), "ui5.yaml");
|
|
155
|
+
}
|
|
156
|
+
|
|
147
157
|
const configFile = await readFile(configPath, {encoding: "utf8"});
|
|
148
158
|
|
|
149
159
|
let {
|
package/lib/framework/use.js
CHANGED
|
@@ -5,13 +5,10 @@ async function resolveVersion({frameworkName, frameworkVersion}, resolverOptions
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
function getEffectiveFrameworkName({project, frameworkOptions}) {
|
|
8
|
-
if (!project.
|
|
8
|
+
if (!project.getFrameworkName() && !frameworkOptions.name) {
|
|
9
9
|
throw new Error("No framework configuration defined. Make sure to also provide the framework name.");
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
// This should not happen as the configuration should have been validated against the schema
|
|
13
|
-
throw new Error(`Project ${project.metadata.name} does not define a framework name configuration`);
|
|
14
|
-
}
|
|
11
|
+
|
|
15
12
|
if (frameworkOptions.name) {
|
|
16
13
|
if (frameworkOptions.name.toLowerCase() === "openui5") {
|
|
17
14
|
return "OpenUI5";
|
|
@@ -21,17 +18,17 @@ function getEffectiveFrameworkName({project, frameworkOptions}) {
|
|
|
21
18
|
throw new Error("Invalid framework name: " + frameworkOptions.name);
|
|
22
19
|
}
|
|
23
20
|
} else {
|
|
24
|
-
return project.
|
|
21
|
+
return project.getFrameworkName();
|
|
25
22
|
}
|
|
26
23
|
}
|
|
27
24
|
|
|
28
|
-
module.exports = async function({
|
|
29
|
-
const project = await getRootProjectConfiguration(
|
|
25
|
+
module.exports = async function({projectGraphOptions, frameworkOptions}) {
|
|
26
|
+
const project = await getRootProjectConfiguration(projectGraphOptions);
|
|
30
27
|
|
|
31
|
-
if (!isValidSpecVersion(project.
|
|
28
|
+
if (!isValidSpecVersion(project.getSpecVersion())) {
|
|
32
29
|
throw new Error(
|
|
33
30
|
`ui5 use command requires specVersion "2.0" or higher. ` +
|
|
34
|
-
`Project ${project.
|
|
31
|
+
`Project ${project.getName()} uses specVersion "${project.getSpecVersion()}"`
|
|
35
32
|
);
|
|
36
33
|
}
|
|
37
34
|
|
|
@@ -39,13 +36,13 @@ module.exports = async function({normalizerOptions, frameworkOptions}) {
|
|
|
39
36
|
name: getEffectiveFrameworkName({project, frameworkOptions})
|
|
40
37
|
};
|
|
41
38
|
|
|
42
|
-
const frameworkVersion = frameworkOptions.version ||
|
|
39
|
+
const frameworkVersion = frameworkOptions.version || project.getFrameworkVersion();
|
|
43
40
|
if (frameworkVersion) {
|
|
44
41
|
framework.version = await resolveVersion({
|
|
45
42
|
frameworkName: framework.name,
|
|
46
43
|
frameworkVersion
|
|
47
44
|
}, {
|
|
48
|
-
cwd: project.
|
|
45
|
+
cwd: project.getPath()
|
|
49
46
|
});
|
|
50
47
|
}
|
|
51
48
|
|
|
@@ -54,6 +51,7 @@ module.exports = async function({normalizerOptions, frameworkOptions}) {
|
|
|
54
51
|
try {
|
|
55
52
|
await require("./updateYaml")({
|
|
56
53
|
project,
|
|
54
|
+
configPathOverride: projectGraphOptions.config,
|
|
57
55
|
data: {
|
|
58
56
|
framework: framework
|
|
59
57
|
}
|
package/lib/framework/utils.js
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
getRootProjectConfiguration: async function(
|
|
3
|
-
const {
|
|
2
|
+
getRootProjectConfiguration: async function(projectGraphOptions) {
|
|
3
|
+
const {generateProjectGraph} = require("@ui5/project");
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
let graph;
|
|
6
|
+
if (projectGraphOptions.dependencyDefinition) {
|
|
7
|
+
graph = await generateProjectGraph.usingStaticFile({
|
|
8
|
+
filePath: projectGraphOptions.dependencyDefinition,
|
|
9
|
+
resolveFrameworkDependencies: false
|
|
10
|
+
});
|
|
11
|
+
} else {
|
|
12
|
+
graph = await generateProjectGraph.usingNodePackageDependencies({
|
|
13
|
+
rootConfigPath: projectGraphOptions.config,
|
|
14
|
+
resolveFrameworkDependencies: false
|
|
15
|
+
});
|
|
9
16
|
}
|
|
10
17
|
|
|
11
|
-
|
|
12
|
-
tree.dependencies = [];
|
|
13
|
-
|
|
14
|
-
return projectPreprocessor.processTree(tree);
|
|
18
|
+
return graph.getRoot();
|
|
15
19
|
},
|
|
16
20
|
getFrameworkResolver: function(frameworkName) {
|
|
17
21
|
if (frameworkName === "SAPUI5") {
|