@@ -5,6 +5,7 @@ import meow from "meow";
5
5
import { dirname } from "node:path" ;
6
6
import { readPackageUpSync } from "read-pkg-up" ;
7
7
import { fileURLToPath } from "node:url" ;
8
+ import { parse } from "semver" ;
8
9
import gltf from "./src/index.js" ;
9
10
10
11
const __filename = fileURLToPath ( import . meta. url ) ;
@@ -75,11 +76,27 @@ const cli = meow(
75
76
} ,
76
77
) ;
77
78
78
- console . log ( "dirname" , __dirname ) ;
79
- console . log ( "process. cwd" , process . cwd ( ) ) ;
80
-
79
+ const { packageJson : cwdPackageJson } = readPackageUpSync ( {
80
+ cwd : process . cwd ( ) ,
81
+ } ) ;
81
82
const { packageJson } = readPackageUpSync ( { cwd : __dirname } ) ;
82
83
84
+ let ngVer ;
85
+
86
+ if ( cwdPackageJson . dependencies [ "@angular/core" ] ) {
87
+ const parsed = parse ( cwdPackageJson . dependencies [ "@angular/core" ] ) ;
88
+ ngVer = parsed . major ;
89
+
90
+ if ( ngVer < 18 ) {
91
+ console . error ( "Angular version must be >= 18" ) ;
92
+ process . exit ( 1 ) ;
93
+ }
94
+
95
+ console . log ( "Detected Angular version: " , parsed . version ) ;
96
+ } else {
97
+ console . warn ( "Executing outside of Angular workspace" ) ;
98
+ }
99
+
83
100
if ( cli . input . length === 0 ) {
84
101
console . log ( cli . help ) ;
85
102
} else {
@@ -106,6 +123,7 @@ if (cli.input.length === 0) {
106
123
showLog,
107
124
timeout : 0 ,
108
125
delay : 1 ,
126
+ ngVer,
109
127
header : `Auto-generated by: https://github.com/angular-threejs/gltf
110
128
Command: npx angular-three-gltf@${ packageJson . version } ${ process . argv . slice ( 2 ) . join ( " " ) } ` ,
111
129
} ;
0 commit comments