@mcpher/gas-fakes 1.2.11 → 1.2.12
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/gas-fakes.js +19 -6
- package/main.js +6 -0
- package/package.json +1 -1
- package/src/index.js +1 -0
package/gas-fakes.js
CHANGED
|
@@ -12,13 +12,19 @@ import { Command } from "commander";
|
|
|
12
12
|
import dotenv from "dotenv";
|
|
13
13
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
14
14
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
15
|
-
import { z
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
|
|
17
|
+
// sync the version with gas fakes code since they share a package.json
|
|
18
|
+
import { createRequire } from 'node:module';
|
|
19
|
+
const require = createRequire(import.meta.url);
|
|
20
|
+
const pjson = require('./package.json');
|
|
21
|
+
const VERSION = pjson.version;
|
|
16
22
|
|
|
17
23
|
// -----------------------------------------------------------------------------
|
|
18
24
|
// CONSTANTS & UTILITIES
|
|
19
25
|
// -----------------------------------------------------------------------------
|
|
20
26
|
|
|
21
|
-
const
|
|
27
|
+
const CLI_VERSION = "0.0.7";
|
|
22
28
|
const MCP_VERSION = "0.0.3";
|
|
23
29
|
const execAsync = promisify(exec);
|
|
24
30
|
|
|
@@ -155,7 +161,7 @@ function generateExecutionScript({ scriptText, useSandbox, sandboxConfig }) {
|
|
|
155
161
|
' await import("./main.js"); // This will trigger the fxInit call',
|
|
156
162
|
gasScript,
|
|
157
163
|
"}",
|
|
158
|
-
"runGas();",
|
|
164
|
+
"return runGas();",
|
|
159
165
|
].join("\n");
|
|
160
166
|
|
|
161
167
|
return { mainScript, gasScript };
|
|
@@ -201,12 +207,17 @@ async function executeGasScript(options) {
|
|
|
201
207
|
configurable: true,
|
|
202
208
|
});
|
|
203
209
|
|
|
210
|
+
let res;
|
|
204
211
|
if (args) {
|
|
205
212
|
const gasFunction = new Function("args", mainScript);
|
|
206
|
-
await gasFunction(args);
|
|
213
|
+
res = await gasFunction(args);
|
|
207
214
|
} else {
|
|
208
215
|
const gasFunction = new Function(mainScript);
|
|
209
|
-
await gasFunction();
|
|
216
|
+
res = await gasFunction();
|
|
217
|
+
}
|
|
218
|
+
if (res) {
|
|
219
|
+
const output = typeof res == "string" ? res : JSON.stringify(res);
|
|
220
|
+
console.log(output); // Returned value from Google Apps Script.
|
|
210
221
|
}
|
|
211
222
|
}
|
|
212
223
|
|
|
@@ -475,7 +486,9 @@ async function main() {
|
|
|
475
486
|
let args = null;
|
|
476
487
|
if (options.args) {
|
|
477
488
|
try {
|
|
478
|
-
args = JSON.parse(
|
|
489
|
+
args = JSON.parse(
|
|
490
|
+
options.args.replace(/\n/g, "\\n").replace(/\r/g, "\\r")
|
|
491
|
+
);
|
|
479
492
|
} catch (err) {
|
|
480
493
|
console.error("Error: Invalid JSON provided to --args option.");
|
|
481
494
|
process.exit(1);
|
package/main.js
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
// testing locally
|
|
2
|
+
// sync the version with gas fakes code since they share a package.json
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
const require = createRequire(import.meta.url);
|
|
5
|
+
const pjson = require('./package.json');
|
|
6
|
+
const VERSION = pjson.version;
|
|
7
|
+
console.log (`...gas-fakes version ${VERSION}`)
|
|
2
8
|
import './src/index.js'
|
package/package.json
CHANGED
package/src/index.js
CHANGED