@mcpher/gas-fakes 2.3.6 → 2.3.7
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/appsscript.json +3 -3
- package/package.json +1 -1
- package/src/cli/setup.js +4 -4
- package/src/cli/utils.js +21 -0
package/appsscript.json
CHANGED
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
"exceptionLogging": "STACKDRIVER",
|
|
4
4
|
"runtimeVersion": "V8",
|
|
5
5
|
"oauthScopes": [
|
|
6
|
+
"openid",
|
|
7
|
+
"https://www.googleapis.com/auth/userinfo.email",
|
|
6
8
|
"https://www.googleapis.com/auth/cloud-platform",
|
|
7
9
|
"https://www.googleapis.com/auth/drive",
|
|
8
10
|
"https://www.googleapis.com/auth/sqlservice",
|
|
9
11
|
"https://www.googleapis.com/auth/script.external_request",
|
|
10
12
|
"https://www.googleapis.com/auth/spreadsheets",
|
|
11
|
-
"https://www.googleapis.com/auth/userinfo.email",
|
|
12
13
|
"https://www.googleapis.com/auth/documents",
|
|
13
14
|
"https://www.googleapis.com/auth/presentations",
|
|
14
15
|
"https://www.googleapis.com/auth/forms",
|
|
15
16
|
"https://mail.google.com/",
|
|
16
|
-
"openid",
|
|
17
17
|
"https://www.googleapis.com/auth/calendar"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
@@ -99,4 +99,4 @@
|
|
|
99
99
|
}
|
|
100
100
|
]
|
|
101
101
|
}
|
|
102
|
-
}
|
|
102
|
+
}
|
package/package.json
CHANGED
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"name": "@mcpher/gas-fakes",
|
|
40
40
|
"author": "bruce mcpherson",
|
|
41
|
-
"version": "2.3.
|
|
41
|
+
"version": "2.3.7",
|
|
42
42
|
"license": "MIT",
|
|
43
43
|
"main": "main.js",
|
|
44
44
|
"description": "An implementation of the Google Workspace Apps Script runtime: Run native App Script Code on Node and Cloud Run",
|
package/src/cli/setup.js
CHANGED
|
@@ -5,7 +5,7 @@ import path from "path";
|
|
|
5
5
|
import os from "os";
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
7
7
|
import { execSync } from "child_process";
|
|
8
|
-
import { checkForGcloudCli, runCommandSync } from "./utils.js";
|
|
8
|
+
import { checkForGcloudCli, runCommandSync, runCommandWithRetrySync } from "./utils.js";
|
|
9
9
|
import { getMsGraphToken, mapGasScopesToMsGraph } from "../support/msgraph/msauth.js";
|
|
10
10
|
|
|
11
11
|
// --- Utility Functions ---
|
|
@@ -794,9 +794,9 @@ export async function authenticateUser(options = {}) {
|
|
|
794
794
|
}
|
|
795
795
|
|
|
796
796
|
console.log("...applying IAM permissions");
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
797
|
+
runCommandWithRetrySync(`gcloud projects add-iam-policy-binding "${projectId}" --member="serviceAccount:${sa_email}" --role="roles/editor" --quiet`, true);
|
|
798
|
+
runCommandWithRetrySync(`gcloud iam service-accounts add-iam-policy-binding "${sa_email}" --member="serviceAccount:${sa_email}" --role="roles/iam.serviceAccountTokenCreator" --quiet`, true);
|
|
799
|
+
runCommandWithRetrySync(`gcloud iam service-accounts add-iam-policy-binding "${sa_email}" --member="user:${current_user}" --role="roles/iam.serviceAccountTokenCreator" --quiet`, true);
|
|
800
800
|
|
|
801
801
|
const saUniqueId = execSync(`gcloud iam service-accounts describe "${sa_email}" --format="value(uniqueId)"`, { shell: true }).toString().trim();
|
|
802
802
|
console.log(`\n\x1b[1;33m*************************************************************************************************`);
|
package/src/cli/utils.js
CHANGED
|
@@ -99,6 +99,27 @@ export function runCommandSync(command, silent = false) {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Helper function to run a shell command sync with retries (useful for GCP eventual consistency).
|
|
104
|
+
*/
|
|
105
|
+
export function runCommandWithRetrySync(command, silent = false, retries = 5, delay = 5000) {
|
|
106
|
+
for (let i = 0; i <= retries; i++) {
|
|
107
|
+
try {
|
|
108
|
+
execSync(command, { stdio: silent ? "ignore" : "inherit", shell: true });
|
|
109
|
+
return;
|
|
110
|
+
} catch (error) {
|
|
111
|
+
if (i < retries) {
|
|
112
|
+
console.log(`...command failed, retrying in ${delay / 1000}s (${i + 1}/${retries})...`);
|
|
113
|
+
const start = Date.now();
|
|
114
|
+
while (Date.now() - start < delay);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
console.error(`\nError executing command after ${retries} retries: ${command}`);
|
|
118
|
+
process.exit(1);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
102
123
|
/**
|
|
103
124
|
* Parses sandbox-related CLI options into a structured config object.
|
|
104
125
|
*/
|