@ui5/cli 3.1.2 → 3.2.0

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 CHANGED
@@ -2,7 +2,27 @@
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.1.2...HEAD).
5
+ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-cli/compare/v3.2.0...HEAD).
6
+
7
+ <a name="v3.2.0"></a>
8
+ ## [v3.2.0] - 2023-06-06
9
+ ### Dependency Updates
10
+ - Bump [@ui5](https://github.com/ui5)/project from 3.3.1 to 3.3.2 [`a508e96`](https://github.com/SAP/ui5-cli/commit/a508e966fb15de82c64754171fbd2202af3128e3)
11
+ - Bump [@ui5](https://github.com/ui5)/server from 3.1.2 to 3.1.3 [`888fc0c`](https://github.com/SAP/ui5-cli/commit/888fc0cf918994cab1e3c84beac757e609a61566)
12
+ - Bump [@ui5](https://github.com/ui5)/builder from 3.0.4 to 3.0.5 [`1155cfc`](https://github.com/SAP/ui5-cli/commit/1155cfccb57f7d588063999719d1a0814fd7e939)
13
+
14
+ ### Features
15
+ - **SNAPSHOT Consumption:** Add cache-mode parameter ([#633](https://github.com/SAP/ui5-cli/issues/633)) [`61d0865`](https://github.com/SAP/ui5-cli/commit/61d0865416eaee9bfc08195f636c60ad4f64e13f)
16
+ - **ui5 tree:** Add 'level' and 'flat' parameters ([#635](https://github.com/SAP/ui5-cli/issues/635)) [`284d9ea`](https://github.com/SAP/ui5-cli/commit/284d9ea9f75967257859b7763e7b9a09a3b219cf)
17
+
18
+
19
+ <a name="v3.1.3"></a>
20
+ ## [v3.1.3] - 2023-05-23
21
+ ### Dependency Updates
22
+ - Bump [@ui5](https://github.com/ui5)/project from 3.3.0 to 3.3.1 [`dbe7657`](https://github.com/SAP/ui5-cli/commit/dbe765789c2998e71dbc2acfe18029400c144159)
23
+ - Bump [@ui5](https://github.com/ui5)/builder from 3.0.3 to 3.0.4 [`44a7b21`](https://github.com/SAP/ui5-cli/commit/44a7b21618fe2892d6f99d5e97779a43cda24b8d)
24
+ - Bump [@ui5](https://github.com/ui5)/fs from 3.0.3 to 3.0.4 [`9ed9ce2`](https://github.com/SAP/ui5-cli/commit/9ed9ce206ac22dbe396d10a9ae5f8ff1345c28be)
25
+
6
26
 
7
27
  <a name="v3.1.2"></a>
8
28
  ## [v3.1.2] - 2023-05-05
@@ -1031,6 +1051,8 @@ Only Node.js v10 or higher is supported.
1031
1051
 
1032
1052
  <a name="v0.0.1"></a>
1033
1053
  ## v0.0.1 - 2018-06-06
1054
+ [v3.2.0]: https://github.com/SAP/ui5-cli/compare/v3.1.3...v3.2.0
1055
+ [v3.1.3]: https://github.com/SAP/ui5-cli/compare/v3.1.2...v3.1.3
1034
1056
  [v3.1.2]: https://github.com/SAP/ui5-cli/compare/v3.1.1...v3.1.2
1035
1057
  [v3.1.1]: https://github.com/SAP/ui5-cli/compare/v3.1.0...v3.1.1
1036
1058
  [v3.1.0]: https://github.com/SAP/ui5-cli/compare/v3.0.7...v3.1.0
package/lib/cli/base.js CHANGED
@@ -52,7 +52,7 @@ export default function(cli) {
52
52
  "config", "dependency-definition", "workspace-config", "workspace", "log-level",
53
53
 
54
54
  // tree.js, build.js & serve.js
55
- "framework-version",
55
+ "framework-version", "cache-mode",
56
56
 
57
57
  // build.js
58
58
  "dest",
@@ -101,6 +101,15 @@ build.builder = function(cli) {
101
101
  describe: "Overrides the framework version defined by the project",
102
102
  type: "string"
103
103
  })
104
+ .option("cache-mode", {
105
+ describe:
106
+ "Cache mode to use when consuming SNAPSHOT versions of a framework: 'Default', 'Force', or 'Off'. " +
107
+ "The 'Default' behavior is to invalidate the cache after 9 hours. 'Force' uses the cache only and " +
108
+ "does not create any requests. 'Off' invalidates any existing cache and updates from the repository",
109
+ type: "string",
110
+ default: "Default",
111
+ choices: ["Default", "Force", "Off"]
112
+ })
104
113
  .option("experimental-css-variables", {
105
114
  describe:
106
115
  "Generate CSS variables (css-variables.css, css-variables.source.less)" +
@@ -129,12 +138,14 @@ async function handleBuild(argv) {
129
138
  graph = await graphFromStaticFile({
130
139
  filePath: argv.dependencyDefinition,
131
140
  rootConfigPath: argv.config,
132
- versionOverride: argv.frameworkVersion
141
+ versionOverride: argv.frameworkVersion,
142
+ cacheMode: argv.cacheMode,
133
143
  });
134
144
  } else {
135
145
  graph = await graphFromPackageDependencies({
136
146
  rootConfigPath: argv.config,
137
147
  versionOverride: argv.frameworkVersion,
148
+ cacheMode: argv.cacheMode,
138
149
  workspaceConfigPath: argv.workspaceConfig,
139
150
  workspaceName: argv.workspace === false ? null : argv.workspace,
140
151
  });
@@ -65,11 +65,20 @@ serve.builder = function(cli) {
65
65
  describe: "Overrides the framework version defined by the project",
66
66
  type: "string"
67
67
  })
68
+ .option("cache-mode", {
69
+ describe:
70
+ "Cache mode to use when consuming SNAPSHOT versions of a framework: 'Default', 'Force', or 'Off'. " +
71
+ "The 'Default' behavior is to invalidate the cache after 9 hours. 'Force' uses the cache only and " +
72
+ "does not create any requests. 'Off' invalidates any existing cache and updates from the repository",
73
+ type: "string",
74
+ default: "Default",
75
+ choices: ["Default", "Force", "Off"]
76
+ })
68
77
  .example("ui5 serve", "Start a web server for the current project")
69
78
  .example("ui5 serve --h2", "Enable the HTTP/2 protocol for the web server (requires SSL certificate)")
70
79
  .example("ui5 serve --config /path/to/ui5.yaml", "Use the project configuration from a custom path")
71
- .example("ui5 serve --translator static:/path/to/projectDependencies.yaml",
72
- "Use a \"static\" translator with translator parameters.")
80
+ .example("ui5 serve --dependency-definition /path/to/projectDependencies.yaml",
81
+ "Use a static dependency definition file")
73
82
  .example("ui5 serve --port 1337 --open tests/QUnit.html",
74
83
  "Listen to port 1337 and launch default browser with http://localhost:1337/test/QUnit.html");
75
84
  };
@@ -83,12 +92,14 @@ serve.handler = async function(argv) {
83
92
  if (argv.dependencyDefinition) {
84
93
  graph = await graphFromStaticFile({
85
94
  filePath: argv.dependencyDefinition,
86
- versionOverride: argv.frameworkVersion
95
+ versionOverride: argv.frameworkVersion,
96
+ cacheMode: argv.cacheMode,
87
97
  });
88
98
  } else {
89
99
  graph = await graphFromPackageDependencies({
90
100
  rootConfigPath: argv.config,
91
101
  versionOverride: argv.frameworkVersion,
102
+ cacheMode: argv.cacheMode,
92
103
  workspaceConfigPath: argv.workspaceConfig,
93
104
  workspaceName: argv.workspace === false ? null : argv.workspace,
94
105
  });
@@ -4,6 +4,7 @@ import chalk from "chalk";
4
4
 
5
5
  const tree = {
6
6
  command: "tree",
7
+ aliases: ["ls", "list"],
7
8
  describe:
8
9
  "Outputs the dependency tree of the current project to stdout. " +
9
10
  "It takes all relevant parameters of ui5 build into account.",
@@ -12,10 +13,28 @@ const tree = {
12
13
 
13
14
  tree.builder = function(cli) {
14
15
  return cli
16
+ .option("flat", {
17
+ describe: "Output a flat list of all dependencies instead of a tree hierarchy",
18
+ type: "boolean",
19
+ default: false
20
+ })
21
+ .option("level", {
22
+ describe: "Limit the number of levels shown in the tree hierarchy",
23
+ type: "number"
24
+ })
15
25
  .option("framework-version", {
16
26
  describe:
17
27
  "Overrides the framework version defined by the project",
18
28
  type: "string"
29
+ })
30
+ .option("cache-mode", {
31
+ describe:
32
+ "Cache mode to use when consuming SNAPSHOT versions of a framework: 'Default', 'Force', or 'Off'. " +
33
+ "The 'Default' behavior is to invalidate the cache after 9 hours. 'Force' uses the cache only and " +
34
+ "does not create any requests. 'Off' invalidates any existing cache and updates from the repository",
35
+ type: "string",
36
+ default: "Default",
37
+ choices: ["Default", "Force", "Off"]
19
38
  });
20
39
  };
21
40
 
@@ -30,12 +49,14 @@ tree.handler = async function(argv) {
30
49
  if (argv.dependencyDefinition) {
31
50
  graph = await graphFromStaticFile({
32
51
  filePath: argv.dependencyDefinition,
33
- versionOverride: argv.frameworkVersion
52
+ versionOverride: argv.frameworkVersion,
53
+ cacheMode: argv.cacheMode,
34
54
  });
35
55
  } else {
36
56
  graph = await graphFromPackageDependencies({
37
57
  rootConfigPath: argv.config,
38
58
  versionOverride: argv.frameworkVersion,
59
+ cacheMode: argv.cacheMode,
39
60
  workspaceConfigPath: argv.workspaceConfig,
40
61
  workspaceName: argv.workspace === false ? null : argv.workspace,
41
62
  });
@@ -45,18 +66,31 @@ tree.handler = async function(argv) {
45
66
  elapsedTime = await getElapsedTime(startTime);
46
67
  }
47
68
 
48
- const projects = Object.create(null);
69
+ let requestedLevels;
70
+ if (argv.level !== undefined && isNaN(argv.level)) {
71
+ throw new Error(`The provided 'level' option is not a number`);
72
+ } else if (argv.level !== undefined) {
73
+ requestedLevels = argv.level;
74
+ } else {
75
+ requestedLevels = Infinity;
76
+ }
77
+
78
+ const projects = new Map();
49
79
  const indentWidth = 4;
50
80
  await graph.traverseBreadthFirst(async ({project, dependencies}) => {
51
- projects[project.getName()] = {
52
- render: function(indentation, connectorIndices, lastChild) {
53
- let baseString = " ".repeat(indentation * indentWidth);
81
+ projects.set(project.getName(), {
82
+ render: function(level, connectorIndices, lastChild, renderDeps = true) {
83
+ let baseString = " ".repeat(level * indentWidth);
54
84
  connectorIndices.forEach((idx) => {
55
85
  baseString = `${baseString.slice(0, idx)}│${baseString.slice(idx + 1)}`;
56
86
  });
57
87
  const connectorString = lastChild ? "╰─" : "├─";
88
+ let name = chalk.bold(project.getName());
89
+ if (project.isFrameworkProject()) {
90
+ name = chalk.blue(name);
91
+ }
58
92
  console.log(
59
- `${baseString}${connectorString} ${chalk.bold(project.getName())} ` +
93
+ `${baseString}${connectorString} ${name} ` +
60
94
  `${project.getNamespace() ? chalk.inverse(project.getNamespace()) + " " : ""}` +
61
95
  chalk.dim(`(${project.getVersion()}, ${project.getType()}) `) +
62
96
  chalk.dim.italic(`${project.getRootPath()}`)
@@ -65,18 +99,39 @@ tree.handler = async function(argv) {
65
99
  const lastIdx = dependencies.length - 1;
66
100
  const newConnectorIndices = [...connectorIndices];
67
101
  if (!lastChild) {
68
- newConnectorIndices.push(indentation * indentWidth);
102
+ newConnectorIndices.push(level * indentWidth);
103
+ }
104
+
105
+ if (level >= requestedLevels) {
106
+ const msg = chalk.dim.italic(`Dependencies below Level ${level} are hidden`);
107
+ let nextBaseString = " ".repeat((level + 1) * indentWidth);
108
+ newConnectorIndices.forEach((idx) => {
109
+ nextBaseString = `${nextBaseString.slice(0, idx)}│${nextBaseString.slice(idx + 1)}`;
110
+ });
111
+ console.log(`${nextBaseString}╰─ ${msg}`);
112
+ return;
113
+ }
114
+ if (renderDeps) {
115
+ dependencies.forEach((dep, i) => {
116
+ projects.get(dep).render(level + 1, newConnectorIndices, i === lastIdx);
117
+ });
69
118
  }
70
- dependencies.forEach((dep, i) => {
71
- projects[dep].render(indentation + 1, newConnectorIndices, i === lastIdx);
72
- });
73
119
  }
74
- };
120
+ });
75
121
  });
76
122
 
77
- const projectKeys = Object.keys(projects);
78
- console.log(chalk.bold.underline(`Dependencies (${projectKeys.length}):`));
79
- projects[projectKeys[0]].render(0, [], true);
123
+ console.log(chalk.bold.underline(`Dependencies (${projects.size}):`));
124
+ if (argv.flat) {
125
+ // Iterate over list of projects, rendering each individually
126
+ // We need to transform the map into an array in order to know the index
127
+ // for determining whether we are rendering the last entry (lastChild param)
128
+ Array.from(projects.values()).forEach(({render: renderProject}, idx, arr) => {
129
+ renderProject(0, [], idx == arr.length -1, false);
130
+ });
131
+ } else {
132
+ // Recursively render the tree, starting with the first entry of the map
133
+ projects.values().next().value.render(0, [], true);
134
+ }
80
135
  console.log("");
81
136
 
82
137
  const extensionNames = graph.getExtensionNames();