@ui5/cli 3.0.0-alpha.9 → 3.0.0-beta.2
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/.reuse/dep5 +1 -1
- package/CHANGELOG.md +82 -1
- package/CONTRIBUTING.md +1 -1
- package/README.md +4 -4
- package/bin/ui5.cjs +104 -0
- package/jsdoc.json +4 -2
- package/lib/cli/base.js +78 -0
- package/lib/cli/cli.js +74 -0
- package/lib/cli/commands/add.js +5 -3
- package/lib/cli/commands/build.js +6 -8
- package/lib/cli/commands/init.js +11 -11
- package/lib/cli/commands/remove.js +7 -3
- package/lib/cli/commands/serve.js +15 -14
- package/lib/cli/commands/tree.js +12 -11
- package/lib/cli/commands/use.js +6 -3
- package/lib/cli/commands/versions.js +20 -17
- package/lib/cli/middlewares/base.js +4 -4
- package/lib/cli/middlewares/logger.js +5 -6
- package/lib/cli/version.js +7 -9
- package/lib/framework/add.js +7 -6
- package/lib/framework/remove.js +9 -7
- package/lib/framework/updateYaml.js +9 -11
- package/lib/framework/use.js +7 -6
- package/lib/framework/utils.js +27 -29
- package/lib/init/init.js +11 -10
- package/lib/utils/fsHelper.js +4 -12
- package/npm-shrinkwrap.json +4204 -3693
- package/package.json +40 -30
- package/bin/ui5.js +0 -98
- package/index.js +0 -7
- package/lib/cli/commands/base.js +0 -76
package/.reuse/dep5
CHANGED
|
@@ -25,5 +25,5 @@ Disclaimer: The code in this project may include calls to APIs (“API Calls”)
|
|
|
25
25
|
parties the right to use of access any SAP External Product, through API Calls.
|
|
26
26
|
|
|
27
27
|
Files: *
|
|
28
|
-
Copyright: 2018-
|
|
28
|
+
Copyright: 2018-2022 SAP SE or an SAP affiliate company and UI5 Tooling contributors
|
|
29
29
|
License: Apache-2.0
|
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,80 @@
|
|
|
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-
|
|
5
|
+
A list of unreleased changes can be found [here](https://github.com/SAP/ui5-cli/compare/v3.0.0-beta.2...HEAD).
|
|
6
|
+
|
|
7
|
+
<a name="v3.0.0-beta.2"></a>
|
|
8
|
+
## [v3.0.0-beta.2] - 2022-11-29
|
|
9
|
+
### Dependency Updates
|
|
10
|
+
- Bump [@ui5](https://github.com/ui5)/server from 3.0.0-beta.1 to 3.0.0-beta.2 [`8bbfcf9`](https://github.com/SAP/ui5-cli/commit/8bbfcf9e51036c7c9b60e29f53b011a60063c2ea)
|
|
11
|
+
- Bump [@ui5](https://github.com/ui5)/builder from 3.0.0-beta.1 to 3.0.0-beta.2 [`3b241bc`](https://github.com/SAP/ui5-cli/commit/3b241bca435e107772473fab226b652ab3abbe69)
|
|
12
|
+
- Bump [@ui5](https://github.com/ui5)/project from 3.0.0-beta.2 to 3.0.0-beta.3 [`1654cbc`](https://github.com/SAP/ui5-cli/commit/1654cbc91d6c0483144afbe600738a6bee5b4b66)
|
|
13
|
+
- Bump [@ui5](https://github.com/ui5)/project from 3.0.0-beta.1 to 3.0.0-beta.2 [`677dc78`](https://github.com/SAP/ui5-cli/commit/677dc7856363051db7a4b0b2feb312a98cec943a)
|
|
14
|
+
- Bump [@ui5](https://github.com/ui5)/fs from 3.0.0-beta.2 to 3.0.0-beta.3 [`6f59a7e`](https://github.com/SAP/ui5-cli/commit/6f59a7ed1124dc7e55cbbc42bfe2262103f78ef9)
|
|
15
|
+
- Bump [@ui5](https://github.com/ui5)/logger from 3.0.1-beta.0 to 3.0.1-beta.1 [`1532039`](https://github.com/SAP/ui5-cli/commit/15320397fae3ccba9a702bbb6d920367c67c738a)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
<a name="v3.0.0-beta.1"></a>
|
|
19
|
+
## [v3.0.0-beta.1] - 2022-11-07
|
|
20
|
+
### Dependency Updates
|
|
21
|
+
- Bump [@ui5](https://github.com/ui5)/project from 3.0.0-alpha.10 to 3.0.0-beta.1 [`086384e`](https://github.com/SAP/ui5-cli/commit/086384e36302868a284b6fc2493a796501571657)
|
|
22
|
+
- Bump [@ui5](https://github.com/ui5)/server from 3.0.0-alpha.4 to 3.0.0-beta.1 [`58924a4`](https://github.com/SAP/ui5-cli/commit/58924a407dbbf299ade3244210ac66325b52146d)
|
|
23
|
+
- Bump [@ui5](https://github.com/ui5)/builder from 3.0.0-alpha.12 to 3.0.0-beta.1 [`bc16621`](https://github.com/SAP/ui5-cli/commit/bc16621c2eefa5275f42eea96a0aca97f86fa96d)
|
|
24
|
+
- Bump [@ui5](https://github.com/ui5)/fs from 3.0.0-beta.1 to 3.0.0-beta.2 [`8b14c28`](https://github.com/SAP/ui5-cli/commit/8b14c28bd79080429ab49e1e35ef29cab7390b17)
|
|
25
|
+
- Bump [@ui5](https://github.com/ui5)/logger from 3.0.0-beta.1 to 3.0.1-beta.0 [`cfacb3a`](https://github.com/SAP/ui5-cli/commit/cfacb3adf9ab63609eb7ba733e0adb3da352a256)
|
|
26
|
+
- Bump [@ui5](https://github.com/ui5)/fs from 3.0.0-alpha.7 to 3.0.0-beta.1 [`c6fd11c`](https://github.com/SAP/ui5-cli/commit/c6fd11c7dfa56c4066fa94659f81919a069871db)
|
|
27
|
+
- Bump [@ui5](https://github.com/ui5)/logger from 3.0.1-alpha.3 to 3.0.0-beta.1 [`2eba585`](https://github.com/SAP/ui5-cli/commit/2eba58578fd509743a5ab5b39238b9801377b323)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
<a name="v3.0.0-alpha.15"></a>
|
|
31
|
+
## [v3.0.0-alpha.15] - 2022-10-25
|
|
32
|
+
### Breaking Changes
|
|
33
|
+
- Transform to native ESM ([#529](https://github.com/SAP/ui5-cli/issues/529)) [`8e15daf`](https://github.com/SAP/ui5-cli/commit/8e15daf0e949becbd49d60fc1532642aae7f733e)
|
|
34
|
+
|
|
35
|
+
### BREAKING CHANGE
|
|
36
|
+
|
|
37
|
+
This package has been transformed to native ESM. Therefore it no longer provides a CommonJS export.
|
|
38
|
+
If your project uses CommonJS, it needs to be converted to ESM or use a dynamic import.
|
|
39
|
+
|
|
40
|
+
For more information see also:
|
|
41
|
+
- https://sap.github.io/ui5-tooling/updates/migrate-v3/
|
|
42
|
+
- https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
<a name="v3.0.0-alpha.14"></a>
|
|
46
|
+
## [v3.0.0-alpha.14] - 2022-10-20
|
|
47
|
+
### Dependency Updates
|
|
48
|
+
- Bump [@ui5](https://github.com/ui5)/builder from 3.0.0-alpha.10 to 3.0.0-alpha.11 [`b73f97f`](https://github.com/SAP/ui5-cli/commit/b73f97f7bc7e54747062640dd6db751e125ea9c9)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
<a name="v3.0.0-alpha.13"></a>
|
|
52
|
+
## [v3.0.0-alpha.13] - 2022-08-10
|
|
53
|
+
### Dependency Updates
|
|
54
|
+
- Bump [@ui5](https://github.com/ui5)/project from 3.0.0-alpha.8 to 3.0.0-alpha.9 [`3c2b9dc`](https://github.com/SAP/ui5-cli/commit/3c2b9dc8bc4b1c82f8969d491af7f5bc3025a3ac)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
<a name="v3.0.0-alpha.12"></a>
|
|
58
|
+
## [v3.0.0-alpha.12] - 2022-08-09
|
|
59
|
+
### Dependency Updates
|
|
60
|
+
- Bump [@ui5](https://github.com/ui5)/project from 3.0.0-alpha.7 to 3.0.0-alpha.8 [`0e1049e`](https://github.com/SAP/ui5-cli/commit/0e1049e12f929881ce160c756e011e41bf41af95)
|
|
61
|
+
- Bump [@ui5](https://github.com/ui5)/builder from 3.0.0-alpha.9 to 3.0.0-alpha.10 [`ae07c21`](https://github.com/SAP/ui5-cli/commit/ae07c21dffdaf6c2fd176807c441e914306d4f30)
|
|
62
|
+
- Bump [@ui5](https://github.com/ui5)/fs from 3.0.0-alpha.5 to 3.0.0-alpha.6 [`4a2c667`](https://github.com/SAP/ui5-cli/commit/4a2c6675b038e30f31c78e84140833837f87e18f)
|
|
63
|
+
- Bump [@ui5](https://github.com/ui5)/logger from 3.0.1-alpha.1 to 3.0.1-alpha.2 [`60f4129`](https://github.com/SAP/ui5-cli/commit/60f4129f4a312b22c562e55920d1204e14f3b4f0)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
<a name="v3.0.0-alpha.11"></a>
|
|
67
|
+
## [v3.0.0-alpha.11] - 2022-07-27
|
|
68
|
+
### Dependency Updates
|
|
69
|
+
- Bump [@ui5](https://github.com/ui5)/project from 3.0.0-alpha.6 to 3.0.0-alpha.7 [`cac5ae4`](https://github.com/SAP/ui5-cli/commit/cac5ae40a4dbb879e6cd982776ace26340ee8f60)
|
|
70
|
+
- Bump [@ui5](https://github.com/ui5)/server from 3.0.0-alpha.2 to 3.0.0-alpha.3 [`95fd053`](https://github.com/SAP/ui5-cli/commit/95fd0538f7ad23be18a7dd10cc49b37af554eb65)
|
|
71
|
+
- Bump [@ui5](https://github.com/ui5)/builder from 3.0.0-alpha.8 to 3.0.0-alpha.9 [`4363588`](https://github.com/SAP/ui5-cli/commit/4363588b138812797ed8c53c18771284b1c38b7a)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
<a name="v3.0.0-alpha.10"></a>
|
|
75
|
+
## [v3.0.0-alpha.10] - 2022-07-26
|
|
76
|
+
### Dependency Updates
|
|
77
|
+
- Bump [@ui5](https://github.com/ui5)/project from 3.0.0-alpha.4 to 3.0.0-alpha.5 [`8d43873`](https://github.com/SAP/ui5-cli/commit/8d438736375debb54853b61b01696e6fbf3cbbc2)
|
|
78
|
+
|
|
6
79
|
|
|
7
80
|
<a name="v3.0.0-alpha.9"></a>
|
|
8
81
|
## [v3.0.0-alpha.9] - 2022-07-15
|
|
@@ -790,6 +863,14 @@ Only Node.js v10 or higher is supported.
|
|
|
790
863
|
<a name="v0.0.1"></a>
|
|
791
864
|
## v0.0.1 - 2018-06-06
|
|
792
865
|
|
|
866
|
+
[v3.0.0-beta.2]: https://github.com/SAP/ui5-cli/compare/v3.0.0-beta.1...v3.0.0-beta.2
|
|
867
|
+
[v3.0.0-beta.1]: https://github.com/SAP/ui5-cli/compare/v3.0.0-alpha.15...v3.0.0-beta.1
|
|
868
|
+
[v3.0.0-alpha.15]: https://github.com/SAP/ui5-cli/compare/v3.0.0-alpha.14...v3.0.0-alpha.15
|
|
869
|
+
[v3.0.0-alpha.14]: https://github.com/SAP/ui5-cli/compare/v3.0.0-alpha.13...v3.0.0-alpha.14
|
|
870
|
+
[v3.0.0-alpha.13]: https://github.com/SAP/ui5-cli/compare/v3.0.0-alpha.12...v3.0.0-alpha.13
|
|
871
|
+
[v3.0.0-alpha.12]: https://github.com/SAP/ui5-cli/compare/v3.0.0-alpha.11...v3.0.0-alpha.12
|
|
872
|
+
[v3.0.0-alpha.11]: https://github.com/SAP/ui5-cli/compare/v3.0.0-alpha.10...v3.0.0-alpha.11
|
|
873
|
+
[v3.0.0-alpha.10]: https://github.com/SAP/ui5-cli/compare/v3.0.0-alpha.9...v3.0.0-alpha.10
|
|
793
874
|
[v3.0.0-alpha.9]: https://github.com/SAP/ui5-cli/compare/v3.0.0-alpha.8...v3.0.0-alpha.9
|
|
794
875
|
[v3.0.0-alpha.8]: https://github.com/SAP/ui5-cli/compare/v3.0.0-alpha.7...v3.0.0-alpha.8
|
|
795
876
|
[v3.0.0-alpha.7]: https://github.com/SAP/ui5-cli/compare/v3.0.0-alpha.6...v3.0.0-alpha.7
|
package/CONTRIBUTING.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
# Contributing to the UI5 Tooling
|
|
2
2
|
|
|
3
|
-
See CONTRIBUTING.md in the [SAP/ui5-tooling](https://github.com/SAP/ui5-tooling/blob/
|
|
3
|
+
See CONTRIBUTING.md in the [SAP/ui5-tooling](https://github.com/SAP/ui5-tooling/blob/main/CONTRIBUTING.md) repository.
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-

|
|
2
2
|
|
|
3
3
|
# ui5-cli
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
> Part of the [UI5 Tooling](https://github.com/SAP/ui5-tooling)
|
|
7
7
|
|
|
8
8
|
[](https://api.reuse.software/info/github.com/SAP/ui5-cli)
|
|
9
|
-
[](https://dev.azure.com/sap/opensource/_build/latest?definitionId=33&branchName=main)
|
|
10
10
|
[](https://www.npmjs.com/package/@ui5/cli)
|
|
11
11
|
[](https://coveralls.io/github/SAP/ui5-cli)
|
|
12
12
|
|
|
@@ -15,11 +15,11 @@ Can be found here: [sap.github.io/ui5-tooling](https://sap.github.io/ui5-tooling
|
|
|
15
15
|
|
|
16
16
|
## Contributing
|
|
17
17
|
|
|
18
|
-
Please check our [Contribution Guidelines](https://github.com/SAP/ui5-tooling/blob/
|
|
18
|
+
Please check our [Contribution Guidelines](https://github.com/SAP/ui5-tooling/blob/main/CONTRIBUTING.md).
|
|
19
19
|
|
|
20
20
|
## Support
|
|
21
21
|
|
|
22
|
-
Please follow our [Contribution Guidelines](https://github.com/SAP/ui5-tooling/blob/
|
|
22
|
+
Please follow our [Contribution Guidelines](https://github.com/SAP/ui5-tooling/blob/main/CONTRIBUTING.md#report-an-issue) on how to report an issue.
|
|
23
23
|
|
|
24
24
|
Please report issues in the main [UI5 Tooling](https://github.com/SAP/ui5-tooling) repository.
|
|
25
25
|
|
package/bin/ui5.cjs
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// NOTE: This file should be compatible to as many Node.js versions as possible
|
|
4
|
+
// so that the message for unsupported Node.js versions can be displayed.
|
|
5
|
+
|
|
6
|
+
const path = require("path");
|
|
7
|
+
|
|
8
|
+
const ui5 = {
|
|
9
|
+
|
|
10
|
+
getPackageJson() {
|
|
11
|
+
return require("../package.json");
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
checkRequirements({pkg, nodeVersion}) {
|
|
15
|
+
let semver;
|
|
16
|
+
try {
|
|
17
|
+
semver = require("semver");
|
|
18
|
+
} catch (err) {
|
|
19
|
+
// SyntaxError indicates an outdated Node.js version
|
|
20
|
+
if (err.name !== "SyntaxError") {
|
|
21
|
+
throw err;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (
|
|
25
|
+
pkg.engines && pkg.engines.node &&
|
|
26
|
+
(!semver || !semver.satisfies(nodeVersion, pkg.engines.node, {includePrerelease: true}))
|
|
27
|
+
) {
|
|
28
|
+
console.log("==================== UNSUPPORTED NODE.JS VERSION ====================");
|
|
29
|
+
console.log("You are using an unsupported version of Node.js");
|
|
30
|
+
console.log("Detected version " + nodeVersion + " but " + pkg.name + " requires " + pkg.engines.node);
|
|
31
|
+
console.log("");
|
|
32
|
+
console.log("=> Please upgrade to a supported version of Node.js to use this tool");
|
|
33
|
+
console.log("=====================================================================");
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (semver && semver.prerelease(nodeVersion)) {
|
|
38
|
+
console.log("====================== UNSTABLE NODE.JS VERSION =====================");
|
|
39
|
+
console.log("You are using an unstable version of Node.js");
|
|
40
|
+
console.log("Detected Node.js version " + nodeVersion);
|
|
41
|
+
console.log("");
|
|
42
|
+
console.log("=> Please note that an unstable version might cause unexpected");
|
|
43
|
+
console.log(" behavior. For productive use please consider using a stable");
|
|
44
|
+
console.log(" version of Node.js! For the release policy of Node.js, see");
|
|
45
|
+
console.log(" https://nodejs.org/en/about/releases");
|
|
46
|
+
console.log("=====================================================================");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return true;
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
async invokeLocalInstallation(pkg) {
|
|
53
|
+
if (process.env.UI5_CLI_NO_LOCAL) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
// Prefer a local installation of @ui5/cli.
|
|
57
|
+
// This will invoke the local CLI, so no further action required
|
|
58
|
+
// NOTE: Using ui5.js, NOT ui5.cjs to also support CLI versions < v3.
|
|
59
|
+
// Starting with v3, both extensions can be used (see package.json "exports").
|
|
60
|
+
const {default: importLocal} = await import("import-local");
|
|
61
|
+
const ui5Local = importLocal(path.join(__dirname, "ui5.js"));
|
|
62
|
+
if (!ui5Local || ui5Local === module.exports) {
|
|
63
|
+
// Either no local installation found or this script is the local installation
|
|
64
|
+
// (invocation within ui5-cli repo)
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
if (process.argv.includes("--verbose")) {
|
|
68
|
+
console.info(`INFO: This project contains an individual ${pkg.name} installation which ` +
|
|
69
|
+
"will be used over the global one.");
|
|
70
|
+
console.info("See https://github.com/SAP/ui5-cli#local-vs-global-installation for details.");
|
|
71
|
+
console.info("");
|
|
72
|
+
} else {
|
|
73
|
+
console.info(`INFO: Using local ${pkg.name} installation`);
|
|
74
|
+
console.info("");
|
|
75
|
+
}
|
|
76
|
+
return true;
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
async invokeCLI(pkg) {
|
|
80
|
+
const {default: cli} = await import("../lib/cli/cli.js");
|
|
81
|
+
await cli(pkg);
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
async main() {
|
|
85
|
+
const pkg = ui5.getPackageJson();
|
|
86
|
+
if (!ui5.checkRequirements({pkg, nodeVersion: process.version})) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const localInstallationInvoked = await ui5.invokeLocalInstallation(pkg);
|
|
90
|
+
if (!localInstallationInvoked) {
|
|
91
|
+
await ui5.invokeCLI(pkg);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
module.exports = ui5;
|
|
97
|
+
|
|
98
|
+
if (process.env.NODE_ENV !== "test" || process.env.UI5_CLI_TEST_BIN_RUN_MAIN !== "false") {
|
|
99
|
+
ui5.main().catch((err) => {
|
|
100
|
+
console.log("Fatal Error: Unable to initialize UI5 CLI");
|
|
101
|
+
console.log(err);
|
|
102
|
+
process.exit(1);
|
|
103
|
+
});
|
|
104
|
+
}
|
package/jsdoc.json
CHANGED
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
"allowUnknownTags": false
|
|
4
4
|
},
|
|
5
5
|
"source": {
|
|
6
|
-
"include": ["README.md"
|
|
6
|
+
"include": ["README.md"],
|
|
7
7
|
"includePattern": ".+\\.js$",
|
|
8
8
|
"excludePattern": "(node_modules(\\\\|/))"
|
|
9
9
|
},
|
|
10
|
-
"plugins": [
|
|
10
|
+
"plugins": [
|
|
11
|
+
"jsdoc-plugin.cjs"
|
|
12
|
+
],
|
|
11
13
|
"opts": {
|
|
12
14
|
"template": "node_modules/docdash/",
|
|
13
15
|
"encoding": "utf8",
|
package/lib/cli/base.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import logger from "@ui5/logger";
|
|
3
|
+
|
|
4
|
+
export default function(cli) {
|
|
5
|
+
cli.usage("Usage: ui5 <command> [options]")
|
|
6
|
+
.demandCommand(1, "Command required! Please have a look at the help documentation above.")
|
|
7
|
+
.option("config", {
|
|
8
|
+
describe: "Path to project configuration file in YAML format",
|
|
9
|
+
type: "string"
|
|
10
|
+
})
|
|
11
|
+
.option("dependency-definition", {
|
|
12
|
+
describe: "Path to a YAML file containing the project's dependency tree. " +
|
|
13
|
+
"This option will disable resolution of node package dependencies.",
|
|
14
|
+
type: "string"
|
|
15
|
+
})
|
|
16
|
+
.option("verbose", {
|
|
17
|
+
describe: "Enable verbose logging.",
|
|
18
|
+
type: "boolean"
|
|
19
|
+
})
|
|
20
|
+
.option("loglevel", {
|
|
21
|
+
alias: "log-level",
|
|
22
|
+
describe: "Set the logging level (error|warn|info|verbose|silly).",
|
|
23
|
+
default: "info",
|
|
24
|
+
type: "string"
|
|
25
|
+
})
|
|
26
|
+
.option("x-perf", {
|
|
27
|
+
describe: "Outputs performance measurements",
|
|
28
|
+
default: false,
|
|
29
|
+
type: "boolean"
|
|
30
|
+
})
|
|
31
|
+
.showHelpOnFail(true)
|
|
32
|
+
.strict(true)
|
|
33
|
+
.alias("help", "h")
|
|
34
|
+
.alias("version", "v")
|
|
35
|
+
.example("ui5 <command> --translator static:/path/to/projectDependencies.yaml",
|
|
36
|
+
"Execute command using a \"static\" translator with translator parameters")
|
|
37
|
+
.example("ui5 <command> --config /path/to/ui5.yaml",
|
|
38
|
+
"Execute command using a project configuration from custom path")
|
|
39
|
+
.fail(function(msg, err, yargs) {
|
|
40
|
+
if (err) {
|
|
41
|
+
// Exception
|
|
42
|
+
if (logger.isLevelEnabled("error")) {
|
|
43
|
+
console.log("");
|
|
44
|
+
console.log(chalk.bold.red("⚠️ Process Failed With Error"));
|
|
45
|
+
|
|
46
|
+
console.log("");
|
|
47
|
+
console.log(chalk.underline("Error Message:"));
|
|
48
|
+
console.log(err.message);
|
|
49
|
+
|
|
50
|
+
// Unexpected errors should always be logged with stack trace
|
|
51
|
+
const unexpectedErrors = ["SyntaxError", "ReferenceError", "TypeError"];
|
|
52
|
+
if (unexpectedErrors.includes(err.name) || logger.isLevelEnabled("verbose")) {
|
|
53
|
+
console.log("");
|
|
54
|
+
console.log(chalk.underline("Stack Trace:"));
|
|
55
|
+
console.log(err.stack);
|
|
56
|
+
console.log("");
|
|
57
|
+
console.log(
|
|
58
|
+
chalk.dim(
|
|
59
|
+
`If you think this is an issue of the UI5 Tooling, you might report it using the ` +
|
|
60
|
+
`following URL: `) +
|
|
61
|
+
chalk.dim.bold.underline(`https://github.com/SAP/ui5-tooling/issues/new/choose`));
|
|
62
|
+
} else {
|
|
63
|
+
console.log("");
|
|
64
|
+
console.log(chalk.dim(
|
|
65
|
+
`For details, execute the same command again with an additional '--verbose' parameter`));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
// Yargs error
|
|
70
|
+
console.log(chalk.bold.yellow("Command Failed:"));
|
|
71
|
+
console.log(`${msg}`);
|
|
72
|
+
console.log("");
|
|
73
|
+
console.log(chalk.dim(`See 'ui5 --help' or 'ui5 build --help' for help`));
|
|
74
|
+
}
|
|
75
|
+
process.exit(1);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
package/lib/cli/cli.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import yargs from "yargs";
|
|
2
|
+
import {hideBin} from "yargs/helpers";
|
|
3
|
+
import {setVersion} from "./version.js";
|
|
4
|
+
import base from "./base.js";
|
|
5
|
+
import {fileURLToPath} from "node:url";
|
|
6
|
+
import {readdir} from "node:fs/promises";
|
|
7
|
+
|
|
8
|
+
async function getCommands() {
|
|
9
|
+
return (await readdir(new URL("./commands", import.meta.url), {withFileTypes: true}))
|
|
10
|
+
.filter((e) => !e.isDirectory() && e.name.endsWith(".js"))
|
|
11
|
+
.map((e) => new URL(`./commands/${e.name}`, import.meta.url));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default async (pkg) => {
|
|
15
|
+
// Only import update-notifier when it's not disabled
|
|
16
|
+
// See https://github.com/yeoman/update-notifier/blob/3046d0f61a57f8270291b6ab271f8a12df8421a6/update-notifier.js#L57-L60
|
|
17
|
+
// The "is-ci" check is not executed, but will be checked by update-notifier itself then
|
|
18
|
+
const NO_UPDATE_NOTIFIER = "--no-update-notifier";
|
|
19
|
+
const disableUpdateNotifier =
|
|
20
|
+
"NO_UPDATE_NOTIFIER" in process.env ||
|
|
21
|
+
process.env.NODE_ENV === "test" ||
|
|
22
|
+
process.argv.includes(NO_UPDATE_NOTIFIER);
|
|
23
|
+
|
|
24
|
+
if (!disableUpdateNotifier) {
|
|
25
|
+
const {default: updateNotifier} = await import("update-notifier");
|
|
26
|
+
updateNotifier({
|
|
27
|
+
pkg,
|
|
28
|
+
updateCheckInterval: 86400000, // 1 day
|
|
29
|
+
shouldNotifyInNpmScript: true
|
|
30
|
+
}).notify();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Remove --no-update-notifier from argv as it's not known to yargs, but we still want to support using it
|
|
34
|
+
if (process.argv.includes(NO_UPDATE_NOTIFIER)) {
|
|
35
|
+
process.argv = process.argv.filter((v) => v !== NO_UPDATE_NOTIFIER);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const cli = yargs(hideBin(process.argv));
|
|
39
|
+
cli.parserConfiguration({
|
|
40
|
+
"parse-numbers": false
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Explicitly set CLI version as the yargs default might
|
|
44
|
+
// be wrong in case a local CLI installation is used
|
|
45
|
+
// Also add CLI location
|
|
46
|
+
const ui5JsPath = fileURLToPath(new URL("../../bin/ui5.cjs", import.meta.url));
|
|
47
|
+
const pkgVersion = `${pkg.version} (from ${ui5JsPath})`;
|
|
48
|
+
|
|
49
|
+
setVersion(pkgVersion);
|
|
50
|
+
cli.version(pkgVersion);
|
|
51
|
+
|
|
52
|
+
// Explicitly set script name to prevent windows from displaying "ui5.js"
|
|
53
|
+
cli.scriptName("ui5");
|
|
54
|
+
|
|
55
|
+
// Setup general options and error handling
|
|
56
|
+
base(cli);
|
|
57
|
+
|
|
58
|
+
// CLI modules
|
|
59
|
+
// YError: loading a directory of commands is not supported yet for ESM
|
|
60
|
+
// cli.commandDir("../lib/cli/commands");
|
|
61
|
+
// See https://github.com/yargs/yargs/issues/2152
|
|
62
|
+
const commandModules = await getCommands();
|
|
63
|
+
for (const modulePath of commandModules) {
|
|
64
|
+
const {default: command} = await import(modulePath);
|
|
65
|
+
cli.command(command);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Format terminal output to full available width
|
|
69
|
+
cli.wrap(cli.terminalWidth());
|
|
70
|
+
|
|
71
|
+
// yargs registers a get method on the argv property.
|
|
72
|
+
// The property needs to be accessed to initialize everything.
|
|
73
|
+
cli.argv;
|
|
74
|
+
};
|
package/lib/cli/commands/add.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// Add
|
|
2
|
+
import base from "../middlewares/base.js";
|
|
2
3
|
const addCommand = {
|
|
3
4
|
command: "add [--development] [--optional] <framework-libraries..>",
|
|
4
5
|
describe: "Add SAPUI5/OpenUI5 framework libraries to the project configuration.",
|
|
5
|
-
middlewares: [
|
|
6
|
+
middlewares: [base]
|
|
6
7
|
};
|
|
7
8
|
|
|
8
9
|
addCommand.builder = function(cli) {
|
|
@@ -56,7 +57,8 @@ addCommand.handler = async function(argv) {
|
|
|
56
57
|
return library;
|
|
57
58
|
});
|
|
58
59
|
|
|
59
|
-
const {
|
|
60
|
+
const {default: add} = await import("../../framework/add.js");
|
|
61
|
+
const {yamlUpdated} = await add({
|
|
60
62
|
projectGraphOptions,
|
|
61
63
|
libraries
|
|
62
64
|
});
|
|
@@ -85,4 +87,4 @@ addCommand.handler = async function(argv) {
|
|
|
85
87
|
}
|
|
86
88
|
};
|
|
87
89
|
|
|
88
|
-
|
|
90
|
+
export default addCommand;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const baseMiddleware = require("../middlewares/base.js");
|
|
1
|
+
import baseMiddleware from "../middlewares/base.js";
|
|
4
2
|
|
|
5
3
|
const build = {
|
|
6
4
|
command: "build",
|
|
@@ -121,21 +119,21 @@ build.builder = function(cli) {
|
|
|
121
119
|
};
|
|
122
120
|
|
|
123
121
|
async function handleBuild(argv) {
|
|
124
|
-
const logger =
|
|
125
|
-
const {
|
|
122
|
+
const {default: logger} = await import("@ui5/logger");
|
|
123
|
+
const {graphFromStaticFile, graphFromPackageDependencies} = await import("@ui5/project/graph");
|
|
126
124
|
|
|
127
125
|
const command = argv._[argv._.length - 1];
|
|
128
126
|
logger.setShowProgress(true);
|
|
129
127
|
|
|
130
128
|
let graph;
|
|
131
129
|
if (argv.dependencyDefinition) {
|
|
132
|
-
graph = await
|
|
130
|
+
graph = await graphFromStaticFile({
|
|
133
131
|
filePath: argv.dependencyDefinition,
|
|
134
132
|
rootConfigPath: argv.config,
|
|
135
133
|
versionOverride: argv.frameworkVersion
|
|
136
134
|
});
|
|
137
135
|
} else {
|
|
138
|
-
graph = await
|
|
136
|
+
graph = await graphFromPackageDependencies({
|
|
139
137
|
rootConfigPath: argv.config,
|
|
140
138
|
versionOverride: argv.frameworkVersion
|
|
141
139
|
});
|
|
@@ -168,4 +166,4 @@ async function handleBuild(argv) {
|
|
|
168
166
|
|
|
169
167
|
function noop() {}
|
|
170
168
|
|
|
171
|
-
|
|
169
|
+
export default build;
|
package/lib/cli/commands/init.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
// Init
|
|
2
|
+
import baseMiddleware from "../middlewares/base.js";
|
|
3
|
+
|
|
2
4
|
const initCommand = {
|
|
3
5
|
command: "init",
|
|
4
6
|
describe: "Initialize the UI5 Tooling configuration for an application or library project.",
|
|
5
|
-
middlewares: [
|
|
7
|
+
middlewares: [baseMiddleware]
|
|
6
8
|
};
|
|
7
9
|
|
|
8
10
|
initCommand.handler = async function() {
|
|
9
|
-
const
|
|
10
|
-
const init =
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const jsYaml = require("js-yaml");
|
|
15
|
-
const writeFile = promisify(fs.writeFile);
|
|
11
|
+
const {exists} = await import("../../utils/fsHelper.js");
|
|
12
|
+
const {default: init} = await import("../../init/init.js");
|
|
13
|
+
const {default: path} = await import("node:path");
|
|
14
|
+
const {writeFile} = await import("node:fs/promises");
|
|
15
|
+
const {default: jsYaml} = await import("js-yaml");
|
|
16
16
|
|
|
17
17
|
const yamlPath = path.resolve("./ui5.yaml");
|
|
18
|
-
if (await
|
|
18
|
+
if (await exists(yamlPath)) {
|
|
19
19
|
throw new Error("Initialization not possible: ui5.yaml already exists");
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
const projectConfig = await init
|
|
22
|
+
const projectConfig = await init();
|
|
23
23
|
const yaml = jsYaml.dump(projectConfig);
|
|
24
24
|
|
|
25
25
|
await writeFile(yamlPath, yaml);
|
|
@@ -27,4 +27,4 @@ initCommand.handler = async function() {
|
|
|
27
27
|
console.log(yaml);
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
export default initCommand;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// Remove
|
|
2
|
+
import baseMiddleware from "../middlewares/base.js";
|
|
3
|
+
|
|
2
4
|
const removeCommand = {
|
|
3
5
|
command: "remove <framework-libraries..>",
|
|
4
6
|
describe: "Remove SAPUI5/OpenUI5 framework libraries from the project configuration.",
|
|
5
|
-
middlewares: [
|
|
7
|
+
middlewares: [baseMiddleware]
|
|
6
8
|
};
|
|
7
9
|
|
|
8
10
|
removeCommand.builder = function(cli) {
|
|
@@ -37,7 +39,9 @@ removeCommand.handler = async function(argv) {
|
|
|
37
39
|
return library;
|
|
38
40
|
});
|
|
39
41
|
|
|
40
|
-
const {
|
|
42
|
+
const {default: remove} = await import("../../framework/remove.js");
|
|
43
|
+
|
|
44
|
+
const {yamlUpdated} = await remove({
|
|
41
45
|
projectGraphOptions,
|
|
42
46
|
libraries
|
|
43
47
|
});
|
|
@@ -62,4 +66,4 @@ removeCommand.handler = async function(argv) {
|
|
|
62
66
|
}
|
|
63
67
|
};
|
|
64
68
|
|
|
65
|
-
|
|
69
|
+
export default removeCommand;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import baseMiddleware from "../middlewares/base.js";
|
|
3
5
|
|
|
4
6
|
// Serve
|
|
5
7
|
const serve = {
|
|
6
8
|
command: "serve",
|
|
7
9
|
describe: "Start a web server for the current project",
|
|
8
|
-
middlewares: [
|
|
10
|
+
middlewares: [baseMiddleware]
|
|
9
11
|
};
|
|
10
12
|
|
|
11
13
|
serve.builder = function(cli) {
|
|
@@ -73,18 +75,18 @@ serve.builder = function(cli) {
|
|
|
73
75
|
};
|
|
74
76
|
|
|
75
77
|
serve.handler = async function(argv) {
|
|
76
|
-
const {
|
|
77
|
-
const
|
|
78
|
-
const
|
|
78
|
+
const {graphFromStaticFile, graphFromPackageDependencies} = await import("@ui5/project/graph");
|
|
79
|
+
const {serve: serverServe} = await import("@ui5/server");
|
|
80
|
+
const {getSslCertificate} = await import("@ui5/server/internal/sslUtil");
|
|
79
81
|
|
|
80
82
|
let graph;
|
|
81
83
|
if (argv.dependencyDefinition) {
|
|
82
|
-
graph = await
|
|
84
|
+
graph = await graphFromStaticFile({
|
|
83
85
|
filePath: argv.dependencyDefinition,
|
|
84
86
|
versionOverride: argv.frameworkVersion
|
|
85
87
|
});
|
|
86
88
|
} else {
|
|
87
|
-
graph = await
|
|
89
|
+
graph = await graphFromPackageDependencies({
|
|
88
90
|
rootConfigPath: argv.config,
|
|
89
91
|
versionOverride: argv.frameworkVersion
|
|
90
92
|
});
|
|
@@ -124,17 +126,16 @@ serve.handler = async function(argv) {
|
|
|
124
126
|
};
|
|
125
127
|
|
|
126
128
|
if (serverConfig.h2) {
|
|
127
|
-
const {key, cert} = await
|
|
129
|
+
const {key, cert} = await getSslCertificate(serverConfig.key, serverConfig.cert);
|
|
128
130
|
serverConfig.key = key;
|
|
129
131
|
serverConfig.cert = cert;
|
|
130
132
|
}
|
|
131
133
|
|
|
132
|
-
const {h2, port: actualPort} = await
|
|
134
|
+
const {h2, port: actualPort} = await serverServe(graph, serverConfig);
|
|
133
135
|
|
|
134
136
|
const protocol = h2 ? "https" : "http";
|
|
135
137
|
let browserUrl = protocol + "://localhost:" + actualPort;
|
|
136
138
|
if (argv.acceptRemoteConnections) {
|
|
137
|
-
const chalk = require("chalk");
|
|
138
139
|
console.log("");
|
|
139
140
|
console.log(chalk.bold("⚠️ This server is accepting connections from all hosts on your network"));
|
|
140
141
|
console.log(chalk.dim.underline("Please Note:"));
|
|
@@ -158,9 +159,9 @@ serve.handler = async function(argv) {
|
|
|
158
159
|
}
|
|
159
160
|
browserUrl += relPath;
|
|
160
161
|
}
|
|
161
|
-
const open =
|
|
162
|
-
open(browserUrl
|
|
162
|
+
const {default: open} = await import("open");
|
|
163
|
+
open(browserUrl);
|
|
163
164
|
}
|
|
164
165
|
};
|
|
165
166
|
|
|
166
|
-
|
|
167
|
+
export default serve;
|