@ui5/cli 3.0.0-alpha.14 → 3.0.0-alpha.15
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 +17 -1
- package/bin/ui5.js +18 -54
- package/jsdoc.json +4 -2
- package/lib/cli/base.js +78 -0
- package/lib/cli/cli.js +64 -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 +14 -13
- package/lib/cli/commands/tree.js +11 -10
- 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 +5 -4
- package/lib/framework/remove.js +7 -5
- package/lib/framework/updateYaml.js +9 -11
- package/lib/framework/use.js +5 -4
- package/lib/framework/utils.js +34 -29
- package/lib/init/init.js +11 -10
- package/lib/utils/fsHelper.js +4 -12
- package/npm-shrinkwrap.json +1510 -944
- package/package.json +26 -19
- package/index.js +0 -7
- package/lib/cli/commands/base.js +0 -76
|
@@ -1,23 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
import {getVersion} from "../version.js";
|
|
1
3
|
/**
|
|
2
4
|
* Logger middleware used as one of default middlewares by tooling
|
|
3
5
|
*
|
|
4
6
|
* @param {object} argv logger arguments
|
|
5
7
|
* @returns {object} logger instance or null
|
|
6
8
|
*/
|
|
7
|
-
function
|
|
9
|
+
export async function initLogger(argv) {
|
|
8
10
|
if (!argv.verbose && !argv.loglevel) return null;
|
|
9
11
|
|
|
10
|
-
const logger =
|
|
12
|
+
const {default: logger} = await import("@ui5/logger");
|
|
11
13
|
if (argv.loglevel) {
|
|
12
14
|
logger.setLevel(argv.loglevel);
|
|
13
15
|
}
|
|
14
16
|
if (argv.verbose) {
|
|
15
17
|
logger.setLevel("verbose");
|
|
16
|
-
|
|
17
|
-
logger.getLogger("cli:middlewares:base").verbose(`using @ui5/cli version ${version}`);
|
|
18
|
+
logger.getLogger("cli:middlewares:base").verbose(`using @ui5/cli version ${getVersion()}`);
|
|
18
19
|
logger.getLogger("cli:middlewares:base").verbose(`using node version ${process.version}`);
|
|
19
20
|
}
|
|
20
21
|
return logger;
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
-
module.exports = {init};
|
package/lib/cli/version.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
let version;
|
|
2
2
|
|
|
3
|
-
// This module holds the CLI's version information (set via
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
};
|
|
3
|
+
// This module holds the CLI's version information (set via cli.js) for later retrieval (e.g. from middlewares/logger)
|
|
4
|
+
export function setVersion(v) {
|
|
5
|
+
version = v;
|
|
6
|
+
}
|
|
7
|
+
export function getVersion() {
|
|
8
|
+
return version;
|
|
9
|
+
}
|
package/lib/framework/add.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import {getRootProjectConfiguration, getFrameworkResolver, isValidSpecVersion} from "./utils.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Adds the given set of libraries to the framework libraries section in the ui5.yaml
|
|
@@ -7,7 +7,7 @@ const {getRootProjectConfiguration, getFrameworkResolver, isValidSpecVersion} =
|
|
|
7
7
|
* @param {object} parameters.projectGraphOptions
|
|
8
8
|
* @param {object} parameters.libraries
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
export default async function({projectGraphOptions, libraries}) {
|
|
11
11
|
const project = await getRootProjectConfiguration(projectGraphOptions);
|
|
12
12
|
|
|
13
13
|
if (!isValidSpecVersion(project.getSpecVersion())) {
|
|
@@ -63,7 +63,8 @@ module.exports = async function({projectGraphOptions, libraries}) {
|
|
|
63
63
|
// Try to update YAML file but still return with name and resolved version in case it failed
|
|
64
64
|
let yamlUpdated = false;
|
|
65
65
|
try {
|
|
66
|
-
await
|
|
66
|
+
const {default: updateYaml} = await import("./updateYaml.js");
|
|
67
|
+
await updateYaml({
|
|
67
68
|
project,
|
|
68
69
|
configPathOverride: projectGraphOptions.config,
|
|
69
70
|
data: {
|
|
@@ -81,4 +82,4 @@ module.exports = async function({projectGraphOptions, libraries}) {
|
|
|
81
82
|
return {
|
|
82
83
|
yamlUpdated
|
|
83
84
|
};
|
|
84
|
-
}
|
|
85
|
+
}
|
package/lib/framework/remove.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import {getRootProjectConfiguration, isValidSpecVersion} from "./utils.js";
|
|
2
|
+
import logger from "@ui5/logger";
|
|
3
3
|
|
|
4
|
+
const log = logger.getLogger("cli:framework:remove");
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Removes the given set of libraries from the framework libraries section in the ui5.yaml
|
|
@@ -9,7 +10,7 @@ const log = require("@ui5/logger").getLogger("cli:framework:remove");
|
|
|
9
10
|
* @param {object} parameters.projectGraphOptions
|
|
10
11
|
* @param {object} parameters.libraries
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
|
+
export default async function({projectGraphOptions, libraries}) {
|
|
13
14
|
const project = await getRootProjectConfiguration(projectGraphOptions);
|
|
14
15
|
|
|
15
16
|
if (!isValidSpecVersion(project.getSpecVersion())) {
|
|
@@ -61,7 +62,8 @@ module.exports = async function({projectGraphOptions, libraries}) {
|
|
|
61
62
|
// Try to update YAML file but still return with name and resolved version in case it failed
|
|
62
63
|
let yamlUpdated = false;
|
|
63
64
|
try {
|
|
64
|
-
await
|
|
65
|
+
const {default: updateYaml} = await import("./updateYaml.js");
|
|
66
|
+
await updateYaml({
|
|
65
67
|
project,
|
|
66
68
|
configPathOverride: projectGraphOptions.config,
|
|
67
69
|
data: {
|
|
@@ -79,4 +81,4 @@ module.exports = async function({projectGraphOptions, libraries}) {
|
|
|
79
81
|
return {
|
|
80
82
|
yamlUpdated
|
|
81
83
|
};
|
|
82
|
-
}
|
|
84
|
+
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import {readFile, writeFile} from "node:fs/promises";
|
|
3
|
+
import {loadAll, dump} from "js-yaml";
|
|
4
|
+
import {fromYaml, getPosition, getValue} from "data-with-position";
|
|
5
|
+
import logger from "@ui5/logger";
|
|
6
|
+
|
|
7
|
+
const log = logger.getLogger("cli:framework:updateYaml");
|
|
5
8
|
|
|
6
9
|
function getProjectYamlDocument({project, configFile, configPath}) {
|
|
7
10
|
const configs = loadAll(configFile, undefined, {
|
|
@@ -137,12 +140,7 @@ function formatValue(value, indent) {
|
|
|
137
140
|
}
|
|
138
141
|
}
|
|
139
142
|
|
|
140
|
-
|
|
141
|
-
const {promisify} = require("util");
|
|
142
|
-
const fs = require("fs");
|
|
143
|
-
const readFile = promisify(fs.readFile);
|
|
144
|
-
const writeFile = promisify(fs.writeFile);
|
|
145
|
-
|
|
143
|
+
export default async function({project, configPathOverride, data}) {
|
|
146
144
|
let configPath;
|
|
147
145
|
if (configPathOverride) {
|
|
148
146
|
if (path.isAbsolute(configPathOverride)) {
|
|
@@ -274,4 +272,4 @@ module.exports = async function({project, configPathOverride, data}) {
|
|
|
274
272
|
}
|
|
275
273
|
|
|
276
274
|
await writeFile(configPath, adoptedYaml);
|
|
277
|
-
}
|
|
275
|
+
}
|
package/lib/framework/use.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import {getRootProjectConfiguration, getFrameworkResolver, isValidSpecVersion} from "./utils.js";
|
|
2
2
|
|
|
3
3
|
async function resolveVersion({frameworkName, frameworkVersion}, resolverOptions) {
|
|
4
4
|
return await getFrameworkResolver(frameworkName).resolveVersion(frameworkVersion, resolverOptions);
|
|
@@ -22,7 +22,7 @@ function getEffectiveFrameworkName({project, frameworkOptions}) {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
export default async function({projectGraphOptions, frameworkOptions}) {
|
|
26
26
|
const project = await getRootProjectConfiguration(projectGraphOptions);
|
|
27
27
|
|
|
28
28
|
if (!isValidSpecVersion(project.getSpecVersion())) {
|
|
@@ -49,7 +49,8 @@ module.exports = async function({projectGraphOptions, frameworkOptions}) {
|
|
|
49
49
|
// Try to update YAML file but still return with name and resolved version in case it failed
|
|
50
50
|
let yamlUpdated = false;
|
|
51
51
|
try {
|
|
52
|
-
await
|
|
52
|
+
const {default: updateYaml} = await import("./updateYaml.js");
|
|
53
|
+
await updateYaml({
|
|
53
54
|
project,
|
|
54
55
|
configPathOverride: projectGraphOptions.config,
|
|
55
56
|
data: {
|
|
@@ -67,4 +68,4 @@ module.exports = async function({projectGraphOptions, frameworkOptions}) {
|
|
|
67
68
|
usedFramework: framework.name,
|
|
68
69
|
usedVersion: framework.version || null
|
|
69
70
|
};
|
|
70
|
-
}
|
|
71
|
+
}
|
package/lib/framework/utils.js
CHANGED
|
@@ -1,32 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {graphFromStaticFile, graphFromPackageDependencies} from "@ui5/project/graph";
|
|
2
|
+
import Sapui5Resolver from "@ui5/project/ui5Framework/Sapui5Resolver";
|
|
3
|
+
import Openui5Resolver from "@ui5/project/ui5Framework/Openui5Resolver";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
5
|
+
export async function getRootProjectConfiguration(projectGraphOptions) {
|
|
6
|
+
let graph;
|
|
7
|
+
if (projectGraphOptions.dependencyDefinition) {
|
|
8
|
+
graph = await graphFromStaticFile({
|
|
9
|
+
filePath: projectGraphOptions.dependencyDefinition,
|
|
10
|
+
resolveFrameworkDependencies: false
|
|
11
|
+
});
|
|
12
|
+
} else {
|
|
13
|
+
graph = await graphFromPackageDependencies({
|
|
14
|
+
rootConfigPath: projectGraphOptions.config,
|
|
15
|
+
resolveFrameworkDependencies: false
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return graph.getRoot();
|
|
20
|
+
}
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
} else {
|
|
26
|
-
throw new Error("Invalid framework.name: " + frameworkName);
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
isValidSpecVersion: function(specVersion) {
|
|
30
|
-
return specVersion && (specVersion !== "0.1" && specVersion !== "1.0" && specVersion !== "1.1");
|
|
22
|
+
export function getFrameworkResolver(frameworkName) {
|
|
23
|
+
if (frameworkName === "SAPUI5") {
|
|
24
|
+
return Sapui5Resolver;
|
|
25
|
+
} else if (frameworkName === "OpenUI5") {
|
|
26
|
+
return Openui5Resolver;
|
|
27
|
+
} else {
|
|
28
|
+
throw new Error("Invalid framework.name: " + frameworkName);
|
|
31
29
|
}
|
|
32
|
-
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function isValidSpecVersion(specVersion) {
|
|
33
|
+
// Only checks for a string and versions that are not supported
|
|
34
|
+
// The CLI relies on the @ui5/project to correctly verify the version
|
|
35
|
+
return typeof specVersion === "string" && specVersion !== "" &&
|
|
36
|
+
specVersion !== "0.1" && specVersion !== "1.0" && specVersion !== "1.1";
|
|
37
|
+
}
|
package/lib/init/init.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const readFile = promisify(fs.readFile);
|
|
5
|
-
const fsHelper = require("../utils/fsHelper");
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import {readFile} from "node:fs/promises";
|
|
3
|
+
import {pathsExist} from "../utils/fsHelper.js";
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
6
|
* Reads the package.json file and returns its content
|
|
@@ -54,13 +52,18 @@ function getProjectType(hasWebapp, hasSrc, hasTest) {
|
|
|
54
52
|
throw new Error(message);
|
|
55
53
|
}
|
|
56
54
|
|
|
55
|
+
/**
|
|
56
|
+
* @module @ui5/cli/init
|
|
57
|
+
*/
|
|
58
|
+
|
|
57
59
|
/**
|
|
58
60
|
* Initiates the projects <b>ui5.yaml</b> configuration file.
|
|
59
61
|
*
|
|
60
62
|
* Checks the package.json and tries to determine the project type. If the <b>ui5.yaml</b> file does not exist,
|
|
61
63
|
* it is created with the basic project configuration.
|
|
62
64
|
*
|
|
63
|
-
* @
|
|
65
|
+
* @function default
|
|
66
|
+
* @static
|
|
64
67
|
* @param {string} cwd Current working directory
|
|
65
68
|
* @returns {Promise} Promise resolving with the project configuration object
|
|
66
69
|
*/
|
|
@@ -87,12 +90,10 @@ async function init({cwd = "./"} = {}) {
|
|
|
87
90
|
throw new Error("Initialization not possible: Missing 'name' in package.json");
|
|
88
91
|
}
|
|
89
92
|
|
|
90
|
-
const [hasWebapp, hasSrc, hasTest] = await
|
|
93
|
+
const [hasWebapp, hasSrc, hasTest] = await pathsExist(["webapp", "src", "test"], cwd);
|
|
91
94
|
projectConfig.type = getProjectType(hasWebapp, hasSrc, hasTest);
|
|
92
95
|
|
|
93
96
|
return projectConfig;
|
|
94
97
|
}
|
|
95
98
|
|
|
96
|
-
|
|
97
|
-
init: init
|
|
98
|
-
};
|
|
99
|
+
export default init;
|
package/lib/utils/fsHelper.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const stat = promisify(fs.stat);
|
|
4
|
-
const path = require("path");
|
|
1
|
+
import {stat} from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
5
|
* Checks if a file or path exists
|
|
@@ -10,7 +8,7 @@ const path = require("path");
|
|
|
10
8
|
* @param {string} filePath Path to check
|
|
11
9
|
* @returns {Promise} Promise resolving with true if the file or path exists
|
|
12
10
|
*/
|
|
13
|
-
async function exists(filePath) {
|
|
11
|
+
export async function exists(filePath) {
|
|
14
12
|
try {
|
|
15
13
|
await stat(filePath);
|
|
16
14
|
return true;
|
|
@@ -32,12 +30,6 @@ async function exists(filePath) {
|
|
|
32
30
|
* @param {string} cwd Current working directory
|
|
33
31
|
* @returns {Promise} Resolving with an array of booleans for each path
|
|
34
32
|
*/
|
|
35
|
-
async function pathsExist(paths, cwd) {
|
|
33
|
+
export async function pathsExist(paths, cwd) {
|
|
36
34
|
return await Promise.all(paths.map((p) => exists(path.join(cwd, p))));
|
|
37
35
|
}
|
|
38
|
-
|
|
39
|
-
module.exports = {
|
|
40
|
-
exists,
|
|
41
|
-
pathsExist
|
|
42
|
-
};
|
|
43
|
-
|