@@ -43,67 +43,72 @@ if [ ! -f "package.json" ]; then
43
43
print_warning " package.json not found in current directory"
44
44
fi
45
45
46
- # Extract PHP version from composer.json
47
- print_status " Extracting PHP version from composer.json..."
48
-
49
- # Try to get PHP version from platform config first
50
- PHP_VERSION=$( jq -r ' .["config"]["platform"]["php"] // empty' composer.json 2> /dev/null)
51
-
52
- # If not found in platform config, try require-dev
53
- if [ -z " $PHP_VERSION " ] || [ " $PHP_VERSION " = " null" ]; then
54
- PHP_VERSION=$( jq -r ' .["require-dev"]["php"] // empty' composer.json 2> /dev/null)
55
- fi
56
-
57
- # If still not found, try require
58
- if [ -z " $PHP_VERSION " ] || [ " $PHP_VERSION " = " null" ]; then
59
- PHP_VERSION=$( jq -r ' .["require"]["php"] // empty' composer.json 2> /dev/null)
60
- fi
61
-
62
- # Clean up version string (remove >=, ^, ~, etc.)
63
- PHP_VERSION=$( echo " $PHP_VERSION " | sed ' s/[^0-9.]//g' )
64
-
65
- if [ -z " $PHP_VERSION " ] || [ " $PHP_VERSION " = " null" ]; then
66
- print_error " Could not extract PHP version from composer.json"
67
- print_status " Available PHP-related fields in composer.json:"
68
- jq -r ' paths | select(.[-1] == "php") | join(".")' composer.json 2> /dev/null || print_warning " No PHP version found in composer.json"
69
- exit 1
70
- fi
71
-
72
- print_status " Extracted PHP version: $PHP_VERSION "
73
-
74
- # Extract additional information from composer.json
75
- print_status " Extracting additional information from composer.json..."
76
-
77
- COMPOSER_NAME=$( jq -r ' .name // empty' composer.json 2> /dev/null)
78
- COMPOSER_DESCRIPTION=$( jq -r ' .description // empty' composer.json 2> /dev/null)
79
- COMPOSER_VERSION=$( jq -r ' .version // empty' composer.json 2> /dev/null)
80
- COMPOSER_LICENSE=$( jq -r ' .license // empty' composer.json 2> /dev/null)
81
- COMPOSER_TYPE=$( jq -r ' .type // empty' composer.json 2> /dev/null)
82
-
83
- # Extract Node.js information from package.json if it exists
84
- NODE_VERSION=" "
85
- NPM_VERSION=" "
86
- PACKAGE_NAME=" "
87
- PACKAGE_VERSION=" "
88
- PACKAGE_DESCRIPTION=" "
89
-
90
- if [ -f " package.json" ]; then
91
- print_status " Extracting information from package.json..."
92
-
93
- NODE_VERSION=$( jq -r ' .engines.node // empty' package.json 2> /dev/null)
94
- NPM_VERSION=$( jq -r ' .engines.npm // empty' package.json 2> /dev/null)
95
- PACKAGE_NAME=$( jq -r ' .name // empty' package.json 2> /dev/null)
96
- PACKAGE_VERSION=$( jq -r ' .version // empty' package.json 2> /dev/null)
97
- PACKAGE_DESCRIPTION=$( jq -r ' .description // empty' package.json 2> /dev/null)
98
- fi
99
-
100
- # Extract Composer scripts
101
- COMPOSER_SCRIPTS=$( jq -r ' .scripts | to_entries[] | " - " + .key + ": " + (if (.value|type)=="array" then (.value|join(" && ")) else .value end)' composer.json 2> /dev/null)
102
-
103
- # Extract npm scripts
104
- NPM_SCRIPTS=" "
105
- if [ -f " package.json" ]; then
106
- NPM_SCRIPTS=$( jq -r ' .scripts | to_entries[] | " - " + .key + ": " + .value' package.json 2> /dev/null)
46
+ # Check if running in CI
47
+ if [ " $CI " = " true" ]; then
48
+ print_status " CI environment detected. Skipping jq-dependent logic."
49
+ else
50
+ # Extract PHP version from composer.json
51
+ print_status " Extracting PHP version from composer.json..."
52
+
53
+ # Try to get PHP version from platform config first
54
+ PHP_VERSION=$( jq -r ' .["config"]["platform"]["php"] // empty' composer.json 2> /dev/null)
55
+
56
+ # If not found in platform config, try require-dev
57
+ if [ -z " $PHP_VERSION " ] || [ " $PHP_VERSION " = " null" ]; then
58
+ PHP_VERSION=$( jq -r ' .["require-dev"]["php"] // empty' composer.json 2> /dev/null)
59
+ fi
60
+
61
+ # If still not found, try require
62
+ if [ -z " $PHP_VERSION " ] || [ " $PHP_VERSION " = " null" ]; then
63
+ PHP_VERSION=$( jq -r ' .["require"]["php"] // empty' composer.json 2> /dev/null)
64
+ fi
65
+
66
+ # Clean up version string (remove >=, ^, ~, etc.)
67
+ PHP_VERSION=$( echo " $PHP_VERSION " | sed ' s/[^0-9.]//g' )
68
+
69
+ if [ -z " $PHP_VERSION " ] || [ " $PHP_VERSION " = " null" ]; then
70
+ print_error " Could not extract PHP version from composer.json"
71
+ print_status " Available PHP-related fields in composer.json:"
72
+ jq -r ' paths | select(.[-1] == "php") | join(".")' composer.json 2> /dev/null || print_warning " No PHP version found in composer.json"
73
+ exit 1
74
+ fi
75
+
76
+ print_status " Extracted PHP version: $PHP_VERSION "
77
+
78
+ # Extract additional information from composer.json
79
+ print_status " Extracting additional information from composer.json..."
80
+
81
+ COMPOSER_NAME=$( jq -r ' .name // empty' composer.json 2> /dev/null)
82
+ COMPOSER_DESCRIPTION=$( jq -r ' .description // empty' composer.json 2> /dev/null)
83
+ COMPOSER_VERSION=$( jq -r ' .version // empty' composer.json 2> /dev/null)
84
+ COMPOSER_LICENSE=$( jq -r ' .license // empty' composer.json 2> /dev/null)
85
+ COMPOSER_TYPE=$( jq -r ' .type // empty' composer.json 2> /dev/null)
86
+
87
+ # Extract Node.js information from package.json if it exists
88
+ NODE_VERSION=" "
89
+ NPM_VERSION=" "
90
+ PACKAGE_NAME=" "
91
+ PACKAGE_VERSION=" "
92
+ PACKAGE_DESCRIPTION=" "
93
+
94
+ if [ -f " package.json" ]; then
95
+ print_status " Extracting information from package.json..."
96
+
97
+ NODE_VERSION=$( jq -r ' .engines.node // empty' package.json 2> /dev/null)
98
+ NPM_VERSION=$( jq -r ' .engines.npm // empty' package.json 2> /dev/null)
99
+ PACKAGE_NAME=$( jq -r ' .name // empty' package.json 2> /dev/null)
100
+ PACKAGE_VERSION=$( jq -r ' .version // empty' package.json 2> /dev/null)
101
+ PACKAGE_DESCRIPTION=$( jq -r ' .description // empty' package.json 2> /dev/null)
102
+ fi
103
+
104
+ # Extract Composer scripts
105
+ COMPOSER_SCRIPTS=$( jq -r ' .scripts | to_entries[] | " - " + .key + ": " + (if (.value|type)=="array" then (.value|join(" && ")) else .value end)' composer.json 2> /dev/null)
106
+
107
+ # Extract npm scripts
108
+ NPM_SCRIPTS=" "
109
+ if [ -f " package.json" ]; then
110
+ NPM_SCRIPTS=$( jq -r ' .scripts | to_entries[] | " - " + .key + ": " + .value' package.json 2> /dev/null)
111
+ fi
107
112
fi
108
113
109
114
# Define Cursor rules directory
0 commit comments