@openedx/frontend-base 1.0.0-alpha.16 → 1.0.0-alpha.18

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/README.md CHANGED
@@ -78,7 +78,7 @@ This watches for changes in `frontend-base` and rebuilds the packaged tarball on
78
78
  ```sh
79
79
  nvm use
80
80
  npm ci
81
- npm run pack:watch
81
+ npm run watch:pack
82
82
  ```
83
83
 
84
84
  #### In the consuming application
File without changes
@@ -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
- let version;
19
- if ((0, fs_1.existsSync)(path_1.default.resolve(__dirname, '../../package.json'))) {
20
- version = require('../../package.json').version;
21
- }
22
- else if ((0, fs_1.existsSync)(path_1.default.resolve(__dirname, '../../../package.json'))) {
23
- version = require('../../../package.json').version;
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:
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openedx/frontend-base",
3
- "version": "1.0.0-alpha.16",
3
+ "version": "1.0.0-alpha.18",
4
4
  "description": "Build tools, setup and config for frontend apps",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -25,13 +25,14 @@
25
25
  "clean": "make clean",
26
26
  "dev": "npm run build && node ./dist/tools/cli/openedx.js dev:shell",
27
27
  "docs": "jsdoc -c jsdoc.json",
28
- "docs:watch": "nodemon -w runtime -w docs/template -w README.md -e js,jsx,ts,tsx --exec npm run docs",
29
28
  "lint": "eslint .; npm run lint:tools; npm --prefix ./test-site run lint",
30
29
  "lint:tools": "cd ./tools && eslint . && cd ..",
31
30
  "pack": "mkdir -p pack && npm pack --silent --pack-destination pack >/dev/null && mv \"$(ls -t pack/*.tgz | head -n 1)\" pack/openedx-frontend-base.tgz",
32
- "pack:watch": "nodemon --config nodemon.pack.json",
33
31
  "prepack": "npm run build",
34
- "test": "jest"
32
+ "test": "jest",
33
+ "watch:build": "nodemon --exec 'npm run build'",
34
+ "watch:docs": "nodemon --watch docs/template --watch README.md --exec npm run docs",
35
+ "watch:pack": "nodemon --exec 'npm run pack'"
35
36
  },
36
37
  "repository": {
37
38
  "type": "git",