@enactprotocol/shared 1.0.13 → 1.0.14

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.
@@ -1,11 +1,32 @@
1
1
  // src/utils/version.ts
2
2
  import pc from "picocolors";
3
+ import { readFileSync } from "fs";
4
+ import { join, dirname } from "path";
5
+ import { fileURLToPath } from "url";
3
6
  /**
4
7
  * Displays the CLI version with nice formatting
5
8
  */
6
9
  export function showVersion() {
7
- // Bun automatically sets npm_package_version when running scripts via package.json
8
- const version = process.env.npm_package_version || "0.0.1-dev";
10
+ let version = "0.0.1-dev";
11
+ try {
12
+ // Try to get version from environment first (for npm scripts)
13
+ if (process.env.npm_package_version) {
14
+ version = process.env.npm_package_version;
15
+ }
16
+ else {
17
+ // When running as installed binary, read from package.json
18
+ // Go up from shared/dist/utils/version.js to find package.json
19
+ const currentFile = typeof __filename !== 'undefined' ? __filename : fileURLToPath(import.meta.url);
20
+ const sharedDir = dirname(dirname(dirname(currentFile)));
21
+ const packageJsonPath = join(sharedDir, 'package.json');
22
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
23
+ version = packageJson.version;
24
+ }
25
+ }
26
+ catch (error) {
27
+ // Fall back to default version if anything fails
28
+ version = "1.0.14";
29
+ }
9
30
  const versionText = `v${version}`;
10
31
  console.error(`
11
32
  ${pc.bold("Enact CLI")} ${pc.cyan(versionText)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enactprotocol/shared",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "Shared utilities and core functionality for Enact Protocol",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,12 +1,33 @@
1
1
  // src/utils/version.ts
2
2
  import pc from "picocolors";
3
+ import { readFileSync } from "fs";
4
+ import { join, dirname } from "path";
5
+ import { fileURLToPath } from "url";
3
6
 
4
7
  /**
5
8
  * Displays the CLI version with nice formatting
6
9
  */
7
10
  export function showVersion(): void {
8
- // Bun automatically sets npm_package_version when running scripts via package.json
9
- const version = process.env.npm_package_version || "0.0.1-dev";
11
+ let version = "0.0.1-dev";
12
+
13
+ try {
14
+ // Try to get version from environment first (for npm scripts)
15
+ if (process.env.npm_package_version) {
16
+ version = process.env.npm_package_version;
17
+ } else {
18
+ // When running as installed binary, read from package.json
19
+ // Go up from shared/dist/utils/version.js to find package.json
20
+ const currentFile = typeof __filename !== 'undefined' ? __filename : fileURLToPath(import.meta.url);
21
+ const sharedDir = dirname(dirname(dirname(currentFile)));
22
+ const packageJsonPath = join(sharedDir, 'package.json');
23
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
24
+ version = packageJson.version;
25
+ }
26
+ } catch (error) {
27
+ // Fall back to default version if anything fails
28
+ version = "1.0.14";
29
+ }
30
+
10
31
  const versionText = `v${version}`;
11
32
 
12
33
  console.error(`