@molecule/api-ai-tools 1.14.9 → 1.14.10
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-command.d.ts","sourceRoot":"","sources":["../src/server-command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,KAAK,sBAAsB,EAAyB,MAAM,oBAAoB,CAAA;AAKvF;;;GAGG;AACH,eAAO,MAAM,YAAY,QAA6C,CAAA;AAEtE;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,QACmP,CAAA;
|
|
1
|
+
{"version":3,"file":"server-command.d.ts","sourceRoot":"","sources":["../src/server-command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,KAAK,sBAAsB,EAAyB,MAAM,oBAAoB,CAAA;AAKvF;;;GAGG;AACH,eAAO,MAAM,YAAY,QAA6C,CAAA;AAEtE;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,QACmP,CAAA;AAmI9Q;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAI5D;AAED,0EAA0E;AAC1E,MAAM,WAAW,gBAAgB;IAC/B,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,GAC5C,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAmBlC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,GAC5C,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAiBxC;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAO5F;AAED;;;GAGG;AACH,eAAO,MAAM,yBAAyB,QAG0B,CAAA"}
|
package/dist/server-command.js
CHANGED
|
@@ -73,6 +73,10 @@ const STARTS_LISTENING = /\b(?:server|app)\.listen\s*\(/;
|
|
|
73
73
|
const NODE_INLINE_FLAG = /^(?:-[A-Za-z]*[ep]|--(?:eval|print)(?:=|$))/;
|
|
74
74
|
/** Python inline programs use -c, including combined interpreter flags. */
|
|
75
75
|
const PYTHON_INLINE_FLAG = /^-[A-Za-z]*c$/;
|
|
76
|
+
/** Node's syntax-only flags, valid only in the interpreter's option prefix. */
|
|
77
|
+
const NODE_CHECK_FLAG = /^(?:-c|--check)$/;
|
|
78
|
+
/** Node flags whose preload/loader code still executes during a syntax check. */
|
|
79
|
+
const NODE_EXECUTION_FLAG = /^(?:-r(?:.|$)|--require(?:=|$)|--import(?:=|$)|--experimental-loader(?:=|$)|--loader(?:=|$))/;
|
|
76
80
|
/**
|
|
77
81
|
* Inline/stdin programs have no server filename to classify. Their source is arbitrary
|
|
78
82
|
* code; the normal bounded command runner, rather than another partial JS/Python
|
|
@@ -94,6 +98,25 @@ function bare(word) {
|
|
|
94
98
|
const match = /^(['"])(.*)\1$/s.exec(word);
|
|
95
99
|
return match?.[2] ?? word;
|
|
96
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Whether Node only checks a script's syntax. The check flag must precede the script and `--`;
|
|
103
|
+
* preloads and loaders still execute under `--check`, so they retain normal classification.
|
|
104
|
+
*/
|
|
105
|
+
function isNodeSyntaxCheck(segment) {
|
|
106
|
+
if (!/^node(?:js)?$/.test(segment.program))
|
|
107
|
+
return false;
|
|
108
|
+
let check = false;
|
|
109
|
+
for (const arg of segment.args) {
|
|
110
|
+
const word = bare(arg);
|
|
111
|
+
if (word === '--' || !word.startsWith('-'))
|
|
112
|
+
return check;
|
|
113
|
+
if (NODE_EXECUTION_FLAG.test(word))
|
|
114
|
+
return false;
|
|
115
|
+
if (NODE_CHECK_FLAG.test(word))
|
|
116
|
+
check = true;
|
|
117
|
+
}
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
97
120
|
/**
|
|
98
121
|
* Whether one parsed statement starts a server: a package manager's serving script, or a program
|
|
99
122
|
* that IS a server, named in command position (so `cat server.ts` is a read, not a launch).
|
|
@@ -114,7 +137,7 @@ function runsServerProgram(segment) {
|
|
|
114
137
|
}
|
|
115
138
|
if (!SERVER_PROGRAMS.has(segment.program))
|
|
116
139
|
return false;
|
|
117
|
-
if (isInlineProgram(segment))
|
|
140
|
+
if (isInlineProgram(segment) || isNodeSyntaxCheck(segment))
|
|
118
141
|
return false;
|
|
119
142
|
return SERVER_PROGRAM.test(segment.text);
|
|
120
143
|
}
|
|
@@ -127,8 +150,8 @@ function runsServerProgram(segment) {
|
|
|
127
150
|
function scriptPath(segment) {
|
|
128
151
|
if (!SCRIPT_RUNNERS.has(segment.program))
|
|
129
152
|
return null;
|
|
130
|
-
//
|
|
131
|
-
if (isInlineProgram(segment))
|
|
153
|
+
// Inline programs and syntax-only checks execute no script source to classify.
|
|
154
|
+
if (isInlineProgram(segment) || isNodeSyntaxCheck(segment))
|
|
132
155
|
return null;
|
|
133
156
|
for (const arg of segment.args) {
|
|
134
157
|
const word = bare(arg);
|