@mcpher/gas-fakes 1.2.7 → 1.2.8
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/README.md +2 -1
- package/gas-fakes.js +19 -10
- package/package.json +1 -44
- package/src/support/sxauth.js +8 -11
- package/src/support/syncit.js +2 -1
package/README.md
CHANGED
|
@@ -169,4 +169,5 @@ As I mentioned earlier, to take this further, I'm going to need a lot of help to
|
|
|
169
169
|
- [named range identity](named-range-identity.md)
|
|
170
170
|
- [adc and restricted scopes](https://ramblings.mcpher.com/how-to-allow-access-to-sensitive-scopes-with-application-default-credentials/)
|
|
171
171
|
- [push test pull](pull-test-push.md)
|
|
172
|
-
- [gas fakes cli](gas-fakes-cli.md)
|
|
172
|
+
- [gas fakes cli](gas-fakes-cli.md)
|
|
173
|
+
- [sharing cache and properties between gas-fakes and live apps script](https://ramblings.mcpher.com/sharing-cache-and-properties-between-gas-fakes-and-live-apps-script/)
|
package/gas-fakes.js
CHANGED
|
@@ -27,11 +27,13 @@ program
|
|
|
27
27
|
)
|
|
28
28
|
.option(
|
|
29
29
|
"-e, --env <path>",
|
|
30
|
-
"provide path to your .env file for special options."
|
|
30
|
+
"provide path to your .env file for special options.",
|
|
31
|
+
"./.env"
|
|
31
32
|
)
|
|
32
33
|
.option(
|
|
33
34
|
"-g, --gfsettings <path>",
|
|
34
|
-
"provide path to your gasfakes.json file for script options."
|
|
35
|
+
"provide path to your gasfakes.json file for script options.",
|
|
36
|
+
"./gasfakes.json"
|
|
35
37
|
)
|
|
36
38
|
.option(
|
|
37
39
|
"-s, --script <string>",
|
|
@@ -63,12 +65,22 @@ program
|
|
|
63
65
|
);
|
|
64
66
|
process.exit();
|
|
65
67
|
}
|
|
66
|
-
|
|
67
|
-
obj.gfSettings = path.resolve(gfsettings);
|
|
68
|
-
}
|
|
68
|
+
|
|
69
69
|
if (env) {
|
|
70
|
-
|
|
70
|
+
const envPath = path.resolve(process.cwd(), env)
|
|
71
|
+
console.log ('...using env file in', envPath)
|
|
72
|
+
dotenv.config({ path: envPath, quiet: true});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// note this must come after any env file fiddling.
|
|
76
|
+
if (gfsettings) {
|
|
77
|
+
const gfPath = path.resolve(process.cwd(), gfsettings )
|
|
78
|
+
console.log ('...using gasfakes settings file in', gfPath)
|
|
79
|
+
obj.gfSettings = gfPath;
|
|
80
|
+
// override whatever is in env
|
|
81
|
+
process.env.GF_SETTINGS_PATH = gfPath
|
|
71
82
|
}
|
|
83
|
+
|
|
72
84
|
if (filename) {
|
|
73
85
|
obj.filename = filename;
|
|
74
86
|
}
|
|
@@ -177,10 +189,6 @@ function __getImportScript(o) {
|
|
|
177
189
|
}
|
|
178
190
|
const importScriptAr = [
|
|
179
191
|
`async function runGas() {`,
|
|
180
|
-
// Pass the settings path to the init function if it's provided
|
|
181
|
-
gfSettings
|
|
182
|
-
? `const settingsPath = "${gfSettings}";`
|
|
183
|
-
: `const settingsPath = undefined;`,
|
|
184
192
|
`await import("./main.js");`, // This will trigger the fxInit call
|
|
185
193
|
...gasScriptAr,
|
|
186
194
|
`};`,
|
|
@@ -194,6 +202,7 @@ function __getImportScript(o) {
|
|
|
194
202
|
}
|
|
195
203
|
|
|
196
204
|
async function loadScript(o) {
|
|
205
|
+
|
|
197
206
|
const { filename, script, display } = o;
|
|
198
207
|
|
|
199
208
|
const scriptText = filename ? fs.readFileSync(filename, "utf8") : script;
|
package/package.json
CHANGED
|
@@ -28,54 +28,11 @@
|
|
|
28
28
|
},
|
|
29
29
|
"type": "module",
|
|
30
30
|
"scripts": {
|
|
31
|
-
"test": "node --env-file=./.env ./test/test.js",
|
|
32
|
-
"testdrive": "node --env-file=./.env ./test/testdrive.js execute",
|
|
33
|
-
"testsheetsdatavalidations": "node --env-file=./.env ./test/testsheetsdatavalidations.js execute",
|
|
34
|
-
"testsheetspermissions": "node --env-file=./.env ./test/testsheetspermissions.js execute",
|
|
35
|
-
"testsheetsvalues": "node --env-file=./.env ./test/testsheetsvalues.js execute",
|
|
36
|
-
"testsheets": "node --env-file=./.env ./test/testsheets.js execute",
|
|
37
|
-
"testfetch": "node --env-file=./.env ./test/testfetch.js execute",
|
|
38
|
-
"testsession": "node --env-file=./.env ./test/testsession.js execute",
|
|
39
|
-
"testutilities": "node --env-file=./.env ./test/testutilities.js execute",
|
|
40
|
-
"teststores": "node --env-file=./.env ./test/teststores.js execute",
|
|
41
|
-
"testscriptapp": "node --env-file=./.env ./test/testscriptapp.js execute",
|
|
42
|
-
"testfiddler": "node --env-file=./.env ./test/testfiddler.js execute",
|
|
43
|
-
"testenums": "node --env-file=./.env ./test/testenums.js execute",
|
|
44
|
-
"testsheetssets": "node --env-file=./.env ./test/testsheetssets.js execute",
|
|
45
|
-
"testsheetsvui": "node --env-file=./.env ./test/testsheetsvui.js execute",
|
|
46
|
-
"testsheetsdeveloper": "node --env-file=./.env ./test/testsheetsdeveloper.js execute",
|
|
47
|
-
"testsheetsexotics": "node --env-file=./.env ./test/testsheetsexotics.js execute",
|
|
48
|
-
"testsheetsdata": "node --env-file=./.env ./test/testsheetsdata.js execute",
|
|
49
|
-
"testdocsadv": "node --env-file=./.env ./test/testdocsadv.js execute",
|
|
50
|
-
"testslidesadv": "node --env-file=./.env ./test/testslidesadv.js execute",
|
|
51
|
-
"testform": "node --env-file=./.env ./test/testform.js execute",
|
|
52
|
-
"testformsadv": "node --env-file=./.env ./test/testformsadv.js execute",
|
|
53
|
-
"testdocs": "node --env-file=./.env ./test/testdocs.js execute",
|
|
54
|
-
"testslides": "node --env-file=./.env ./test/testslides.js execute",
|
|
55
|
-
"testdocsnext": "node --env-file=./.env ./test/testdocsnext.js execute",
|
|
56
|
-
"testsheetstext": "node --env-file=./.env ./test/testsheetstext.js execute",
|
|
57
|
-
"testsheetsrange": "node --env-file=./.env ./test/testsheetsrange.js execute",
|
|
58
|
-
"testdocslistitems": "node --env-file=./.env ./test/testdocslistitems.js execute",
|
|
59
|
-
"testdocsall": "node --env-file=./.env ./test/testdocsall.js",
|
|
60
|
-
"testdocsheaders": "node --env-file=./.env ./test/testdocsheaders.js execute",
|
|
61
|
-
"testdocsfooters": "node --env-file=./.env ./test/testdocsfooters.js execute",
|
|
62
|
-
"testdocsfootnotes": "node --env-file=./.env ./test/testdocsfootnotes.js execute",
|
|
63
|
-
"testdocsimages": "node --env-file=./.env ./test/testdocsimages.js execute",
|
|
64
|
-
"testdocsstyles": "node --env-file=./.env ./test/testdocsstyles.js execute",
|
|
65
|
-
"testsandbox": "node --trace-warnings ./test/testsandbox.js execute",
|
|
66
|
-
"testgmail": "node --env-file=./.env ./test/testgmail.js execute",
|
|
67
|
-
"testlogger": "node --env-file=./.env ./test/testlogger.js execute",
|
|
68
|
-
"testchat": "node --env-file=./.env ./test/testchat.js execute",
|
|
69
|
-
"testpeople": "node --env-file=./.env ./test/testpeople.js execute",
|
|
70
|
-
"testtasks": "node --env-file=./.env ./test/testtasks.js execute",
|
|
71
|
-
"testcalendar": "node --env-file=./.env ./test/testcalendar.js execute",
|
|
72
|
-
"testworkspaceevents": "node --env-file=./.env ./test/testworkspaceevents.js execute",
|
|
73
|
-
"testmimetype": "node --env-file=./.env ./test/testmimetype.js execute",
|
|
74
31
|
"pub": "npm publish --access public"
|
|
75
32
|
},
|
|
76
33
|
"name": "@mcpher/gas-fakes",
|
|
77
34
|
"author": "bruce mcpherson",
|
|
78
|
-
"version": "1.2.
|
|
35
|
+
"version": "1.2.8",
|
|
79
36
|
"license": "MIT",
|
|
80
37
|
"main": "main.js",
|
|
81
38
|
"description": "A proof of concept implementation of Apps Script Environment on Node",
|
package/src/support/sxauth.js
CHANGED
|
@@ -20,13 +20,12 @@ import path from 'path'
|
|
|
20
20
|
* @param {string} p.authPath import the auth code
|
|
21
21
|
* @param {string} p.claspPath where to find the clasp file by default
|
|
22
22
|
* @param {string} p.settingsPath where to find the settings file
|
|
23
|
-
* @param {string} p.mainDir the directory the main app is running from
|
|
24
23
|
* @param {string} p.cachePath the cache files
|
|
25
24
|
* @param {string} p.propertiesPath the properties file location
|
|
26
25
|
* @param {string} p.fakeId a fake script id to use if one isnt in the settings
|
|
27
26
|
* @return {object} the finalized vesions of all the above
|
|
28
27
|
*/
|
|
29
|
-
export const sxInit = async ({ manifestPath, claspPath, settingsPath,
|
|
28
|
+
export const sxInit = async ({ manifestPath, claspPath, settingsPath, cachePath, propertiesPath, fakeId }) => {
|
|
30
29
|
|
|
31
30
|
|
|
32
31
|
|
|
@@ -47,13 +46,11 @@ export const sxInit = async ({ manifestPath, claspPath, settingsPath, mainDir, c
|
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
// files are relative to this main path
|
|
49
|
+
const settingsDir = path.dirname(settingsPath)
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
const settingsDir = path.dirname(settingsFile)
|
|
53
|
-
|
|
54
|
-
// syncLog (JSON.stringify({mainDir,settingsPath,settingsDir,settingsFile}))
|
|
51
|
+
// syncLog (JSON.stringify({settingsPath,settingsDir,settingsPath}))
|
|
55
52
|
// get the setting file if it exists
|
|
56
|
-
const _settings = await getIfExists(
|
|
53
|
+
const _settings = await getIfExists(settingsPath)
|
|
57
54
|
const settings = { ..._settings }
|
|
58
55
|
|
|
59
56
|
// the content of the settings file take precedence over whatever is passed as the default
|
|
@@ -61,8 +58,8 @@ export const sxInit = async ({ manifestPath, claspPath, settingsPath, mainDir, c
|
|
|
61
58
|
settings.manifest = settings.manifest || manifestPath
|
|
62
59
|
settings.clasp = settings.clasp || claspPath
|
|
63
60
|
const [manifest, clasp] = await Promise.all([
|
|
64
|
-
getIfExists(path.resolve(
|
|
65
|
-
getIfExists(path.resolve(
|
|
61
|
+
getIfExists(path.resolve(settingsDir, settings.manifest)),
|
|
62
|
+
getIfExists(path.resolve(settingsDir, settings.clasp))
|
|
66
63
|
])
|
|
67
64
|
|
|
68
65
|
/// if we dont have a scriptId we need to check in clasp or make a fakeone
|
|
@@ -82,8 +79,8 @@ export const sxInit = async ({ manifestPath, claspPath, settingsPath, mainDir, c
|
|
|
82
79
|
const strSet = JSON.stringify(settings, null, 2)
|
|
83
80
|
if (JSON.stringify(_settings, null, 2) !== strSet) {
|
|
84
81
|
await mkdir(settingsDir, { recursive: true })
|
|
85
|
-
syncLog(`...writing to ${
|
|
86
|
-
writeFile(
|
|
82
|
+
syncLog(`...writing to ${settingsPath}`);
|
|
83
|
+
writeFile(settingsPath, strSet, { flag: 'w' })
|
|
87
84
|
}
|
|
88
85
|
|
|
89
86
|
// get the required scopes and set them
|
package/src/support/syncit.js
CHANGED
|
@@ -262,10 +262,11 @@ const fxUnzipper = ({ blob }) => {
|
|
|
262
262
|
const fxInit = ({
|
|
263
263
|
manifestPath = manifestDefaultPath,
|
|
264
264
|
claspPath = claspDefaultPath,
|
|
265
|
-
settingsPath =
|
|
265
|
+
settingsPath = settingsDefaultPath,
|
|
266
266
|
cachePath = cacheDefaultPath,
|
|
267
267
|
propertiesPath = propertiesDefaultPath,
|
|
268
268
|
} = {}) => {
|
|
269
|
+
|
|
269
270
|
// this is the path of the runing main process
|
|
270
271
|
const mainDir = path.dirname(process.argv[1]);
|
|
271
272
|
|