@ui5/cli 3.0.0-alpha.7 → 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.
@@ -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.normalizerOptions
9
+ * @param {object} parameters.projectGraphOptions
10
10
  * @param {object} parameters.libraries
11
11
  */
12
- module.exports = async function({normalizerOptions, libraries}) {
13
- const project = await getRootProjectConfiguration({normalizerOptions});
12
+ module.exports = async function({projectGraphOptions, libraries}) {
13
+ const project = await getRootProjectConfiguration(projectGraphOptions);
14
14
 
15
- if (!isValidSpecVersion(project.specVersion)) {
15
+ if (!isValidSpecVersion(project.getSpecVersion())) {
16
16
  throw new Error(
17
17
  `ui5 remove command requires specVersion "2.0" or higher. ` +
18
- `Project ${project.metadata.name} uses specVersion "${project.specVersion}"`
18
+ `Project ${project.getName()} uses specVersion "${project.getSpecVersion()}"`
19
19
  );
20
20
  }
21
21
 
22
- if (!project.framework) {
22
+ if (!project.getFrameworkName()) {
23
23
  throw new Error(
24
- `Project ${project.metadata.name} is missing a framework configuration. ` +
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.framework.version) {
28
+ if (!project.getFrameworkVersion()) {
29
29
  throw new Error(
30
- `Project ${project.metadata.name} does not define a framework version configuration. ` +
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.framework.libraries) {
35
+ if (!project.getFrameworkDependencies().length) {
36
36
  throw new Error(
37
- `Project ${project.metadata.name} does not define framework libraries.`
37
+ `Project ${project.getName()} does not define framework libraries.`
38
38
  );
39
39
  }
40
40
 
41
- const allLibraries = [...project.framework.libraries];
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.metadata.name} because it is not present.`
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.metadata.name;
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.metadata.name} in YAML: ${configPath}`
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
- const configPath = project.configPath || path.join(project.path, "ui5.yaml");
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 {
@@ -5,13 +5,10 @@ async function resolveVersion({frameworkName, frameworkVersion}, resolverOptions
5
5
  }
6
6
 
7
7
  function getEffectiveFrameworkName({project, frameworkOptions}) {
8
- if (!project.framework && !frameworkOptions.name) {
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
- if (project.framework && !project.framework.name) {
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.framework.name;
21
+ return project.getFrameworkName();
25
22
  }
26
23
  }
27
24
 
28
- module.exports = async function({normalizerOptions, frameworkOptions}) {
29
- const project = await getRootProjectConfiguration({normalizerOptions});
25
+ module.exports = async function({projectGraphOptions, frameworkOptions}) {
26
+ const project = await getRootProjectConfiguration(projectGraphOptions);
30
27
 
31
- if (!isValidSpecVersion(project.specVersion)) {
28
+ if (!isValidSpecVersion(project.getSpecVersion())) {
32
29
  throw new Error(
33
30
  `ui5 use command requires specVersion "2.0" or higher. ` +
34
- `Project ${project.metadata.name} uses specVersion "${project.specVersion}"`
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 || (project.framework && project.framework.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.path
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
  }
@@ -1,17 +1,21 @@
1
1
  module.exports = {
2
- getRootProjectConfiguration: async function({normalizerOptions}) {
3
- const {normalizer, projectPreprocessor} = require("@ui5/project");
2
+ getRootProjectConfiguration: async function(projectGraphOptions) {
3
+ const {generateProjectGraph} = require("@ui5/project");
4
4
 
5
- const tree = await normalizer.generateDependencyTree(normalizerOptions);
6
-
7
- if (normalizerOptions.configPath) {
8
- tree.configPath = normalizerOptions.configPath;
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
- // Prevent dependencies from being processed
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") {