tthr 0.3.10 → 0.3.11
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/index.js +17 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -200,10 +200,16 @@ async function deployFunctionsToServer(projectId, token, functionsDir, environme
|
|
|
200
200
|
}
|
|
201
201
|
const files = await fs.readdir(functionsDir);
|
|
202
202
|
const tsFiles = files.filter((f) => f.endsWith(".ts") && !f.startsWith("_"));
|
|
203
|
+
const helperFiles = files.filter((f) => f.endsWith(".ts") && f.startsWith("_"));
|
|
203
204
|
if (tsFiles.length === 0) {
|
|
204
205
|
spinner.info("No function files found");
|
|
205
206
|
return;
|
|
206
207
|
}
|
|
208
|
+
const helperSources = /* @__PURE__ */ new Map();
|
|
209
|
+
for (const hf of helperFiles) {
|
|
210
|
+
const hfPath = path.join(functionsDir, hf);
|
|
211
|
+
helperSources.set(hf, await fs.readFile(hfPath, "utf-8"));
|
|
212
|
+
}
|
|
207
213
|
const functions = [];
|
|
208
214
|
for (const file of tsFiles) {
|
|
209
215
|
const filePath = path.join(functionsDir, file);
|
|
@@ -213,9 +219,19 @@ async function deployFunctionsToServer(projectId, token, functionsDir, environme
|
|
|
213
219
|
if (parsedFunctions.length === 0) continue;
|
|
214
220
|
spinner.text = `Bundling ${file}...`;
|
|
215
221
|
const bundledSource = await bundleFunctionFile(filePath);
|
|
222
|
+
let combinedRawSource = source;
|
|
223
|
+
for (const [helperFile, helperSource] of helperSources) {
|
|
224
|
+
const helperBase = helperFile.replace(".ts", "");
|
|
225
|
+
if (source.includes(`"./${helperBase}"`) || source.includes(`'./${helperBase}'`)) {
|
|
226
|
+
combinedRawSource += `
|
|
227
|
+
|
|
228
|
+
// --- ${helperFile} ---
|
|
229
|
+
${helperSource}`;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
216
232
|
for (const fn of parsedFunctions) {
|
|
217
233
|
fn.source = bundledSource;
|
|
218
|
-
fn.rawSource =
|
|
234
|
+
fn.rawSource = combinedRawSource;
|
|
219
235
|
}
|
|
220
236
|
functions.push(...parsedFunctions);
|
|
221
237
|
}
|