@openedx/frontend-base 1.0.0-alpha.16 → 1.0.0-alpha.17
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/dist/tools/cli/openedx.js +25 -6
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const child_process_1 = require("child_process");
|
|
8
9
|
const fs_1 = require("fs");
|
|
9
10
|
const path_1 = __importDefault(require("path"));
|
|
10
11
|
const types_1 = require("../types");
|
|
@@ -15,13 +16,31 @@ const printUsage_1 = __importDefault(require("./utils/printUsage"));
|
|
|
15
16
|
const commandName = process.argv[2];
|
|
16
17
|
// remove 'openedx' from process.argv to allow subcommands to read options properly
|
|
17
18
|
process.argv.splice(1, 1);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
function getVersion() {
|
|
20
|
+
// Read the version from package.json. The compiled CLI lives at
|
|
21
|
+
// dist/tools/cli/openedx.js, so the package root is always three levels up.
|
|
22
|
+
const pkgJsonPath = path_1.default.resolve(__dirname, '../../../package.json');
|
|
23
|
+
if (!(0, fs_1.existsSync)(pkgJsonPath)) {
|
|
24
|
+
return '(unknown)';
|
|
25
|
+
}
|
|
26
|
+
const { version: pkgVersion } = require(pkgJsonPath);
|
|
27
|
+
if (!pkgVersion) {
|
|
28
|
+
return '(unknown)';
|
|
29
|
+
}
|
|
30
|
+
if (!/^0\.0\.0-.+$/.test(pkgVersion)) {
|
|
31
|
+
return pkgVersion;
|
|
32
|
+
}
|
|
33
|
+
// Placeholder version found — likely a local git checkout. Append the
|
|
34
|
+
// git hash so the exact checkout is identifiable.
|
|
35
|
+
try {
|
|
36
|
+
const hash = (0, child_process_1.execSync)('git rev-parse --short HEAD', { encoding: 'utf-8' }).trim();
|
|
37
|
+
return `${pkgVersion} (${hash})`;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return pkgVersion;
|
|
41
|
+
}
|
|
24
42
|
}
|
|
43
|
+
const version = getVersion();
|
|
25
44
|
(0, prettyPrintTitle_1.default)(`Open edX CLI v${version}`);
|
|
26
45
|
switch (commandName) {
|
|
27
46
|
case types_1.CommandTypes.LINT:
|