lt-script 1.0.5 → 1.0.6

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/cli/ltc.js CHANGED
@@ -2,13 +2,17 @@
2
2
  import { compile } from '../index.js';
3
3
  import * as fs from 'fs';
4
4
  import * as path from 'path';
5
- import { getAllFiles, ensureDirectoryExistence, style } from './utils.js';
5
+ import { getAllFiles, ensureDirectoryExistence, style, getPackageVersion } from './utils.js';
6
6
  const args = process.argv.slice(2);
7
7
  const command = args[0];
8
8
  if (!command) {
9
9
  printUsage();
10
10
  process.exit(1);
11
11
  }
12
+ if (command === '-v' || command === '--version') {
13
+ console.log(`v${getPackageVersion()}`);
14
+ process.exit(0);
15
+ }
12
16
  switch (command) {
13
17
  case 'watch':
14
18
  handleWatch(args.slice(1));
@@ -23,7 +27,7 @@ switch (command) {
23
27
  }
24
28
  function printUsage() {
25
29
  console.log(`
26
- ${style.bold('LT Language Compiler')} ${style.gray('(v1.0.0)')}
30
+ ${style.bold('LT Language Compiler')} ${style.gray(`(v${getPackageVersion()})`)}
27
31
  ${style.gray('----------------------------------------')}
28
32
 
29
33
  ${style.bold('Usage:')}
@@ -1,5 +1,6 @@
1
1
  export declare function getAllFiles(dir: string, extension: string, fileList?: string[]): string[];
2
2
  export declare function ensureDirectoryExistence(filePath: string): void;
3
+ export declare function getPackageVersion(): string;
3
4
  export declare const colors: {
4
5
  reset: string;
5
6
  bright: string;
package/dist/cli/utils.js CHANGED
@@ -24,6 +24,27 @@ export function ensureDirectoryExistence(filePath) {
24
24
  ensureDirectoryExistence(dirname);
25
25
  fs.mkdirSync(dirname);
26
26
  }
27
+ export function getPackageVersion() {
28
+ try {
29
+ const __dirname = path.dirname(new URL(import.meta.url).pathname);
30
+ // Navigate up from dist/cli/utils.js to package.json
31
+ // dist/cli -> dist -> root
32
+ const packageJsonPath = path.resolve(__dirname, '../../package.json');
33
+ // Handle Windows path issues with URL pathname usually having leading slash
34
+ const adjustedPath = process.platform === 'win32' && packageJsonPath.startsWith('\\')
35
+ ? packageJsonPath.substring(1)
36
+ : packageJsonPath;
37
+ if (fs.existsSync(adjustedPath)) {
38
+ const content = fs.readFileSync(adjustedPath, 'utf-8');
39
+ const pkg = JSON.parse(content);
40
+ return pkg.version || '1.0.0';
41
+ }
42
+ }
43
+ catch (e) {
44
+ // Fallback or dev environment handling
45
+ }
46
+ return '1.0.5'; // Fallback to current known version
47
+ }
27
48
  export const colors = {
28
49
  reset: "\x1b[0m",
29
50
  bright: "\x1b[1m",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lt-script",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "type": "module",
5
5
  "description": "LT Language Compiler for FiveM",
6
6
  "main": "dist/index.js",