1 | #!/usr/bin/env node
|
2 |
|
3 |
|
4 |
|
5 | var pkg = require("../package.json");
|
6 | var semver;
|
7 | try {
|
8 | semver = require("semver");
|
9 | } catch (err) {
|
10 |
|
11 | if (err.name !== "SyntaxError") {
|
12 | throw err;
|
13 | }
|
14 | }
|
15 | var nodeVersion = process.version;
|
16 |
|
17 | if (pkg.engines && pkg.engines.node && (!semver || !semver.satisfies(nodeVersion, pkg.engines.node))) {
|
18 | console.log("==================== UNSUPPORTED NODE.JS VERSION ====================");
|
19 | console.log("You are using an unsupported version of Node.js");
|
20 | console.log("Detected version " + nodeVersion + " but " + pkg.name + " requires " + pkg.engines.node);
|
21 | console.log("");
|
22 | console.log("=> Please upgrade to a supported version of Node.js to use this tool");
|
23 | console.log("=====================================================================");
|
24 | process.exit(1);
|
25 | } else {
|
26 |
|
27 | setTimeout(() => {
|
28 | if (!process.env.UI5_CLI_NO_LOCAL) {
|
29 | const importLocal = require("import-local");
|
30 |
|
31 |
|
32 | if (importLocal(__filename)) {
|
33 | if (process.argv.includes("--verbose")) {
|
34 | console.info(`INFO: This project contains an individual ${pkg.name} installation which ` +
|
35 | "will be used over the global one.");
|
36 | console.info("See https://github.com/SAP/ui5-cli#local-vs-global-installation for details.");
|
37 | console.info("");
|
38 | } else {
|
39 | console.info(`INFO: Using local ${pkg.name} installation`);
|
40 | console.info("");
|
41 | }
|
42 | return;
|
43 | }
|
44 | }
|
45 |
|
46 | const updateNotifier = require("update-notifier");
|
47 | updateNotifier({
|
48 | pkg,
|
49 | updateCheckInterval: 1000 * 60 * 60 * 24,
|
50 | shouldNotifyInNpmScript: true
|
51 | }).notify();
|
52 |
|
53 | const NO_UPDATE_NOTIFIER = "--no-update-notifier";
|
54 | if (process.argv.includes(NO_UPDATE_NOTIFIER)) {
|
55 | process.argv = process.argv.filter((v) => v !== NO_UPDATE_NOTIFIER);
|
56 | }
|
57 |
|
58 | const cli = require("yargs");
|
59 |
|
60 | cli.parserConfiguration({
|
61 | "parse-numbers": false
|
62 | });
|
63 |
|
64 |
|
65 |
|
66 |
|
67 | const version = `${pkg.version} (from ${__filename})`;
|
68 | require("../lib/cli/version").set(version);
|
69 | cli.version(version);
|
70 |
|
71 |
|
72 | cli.scriptName("ui5");
|
73 |
|
74 |
|
75 | cli.commandDir("../lib/cli/commands");
|
76 |
|
77 |
|
78 | cli.wrap(cli.terminalWidth());
|
79 |
|
80 |
|
81 |
|
82 | cli.argv;
|
83 | }, 0);
|
84 | }
|