@google/clasp 2.4.2 → 3.0.0-alpha1

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.
Files changed (149) hide show
  1. package/README.md +253 -196
  2. package/build/src/auth/auth.js +176 -0
  3. package/build/src/auth/auth_code_flow.js +36 -0
  4. package/build/src/auth/credential_store.js +1 -0
  5. package/build/src/auth/file_credential_store.js +82 -0
  6. package/build/src/auth/localhost_auth_code_flow.js +62 -0
  7. package/build/src/auth/serverless_auth_code_flow.js +32 -0
  8. package/build/src/commands/clone-script.js +71 -0
  9. package/build/src/commands/create-deployment.js +33 -0
  10. package/build/src/commands/create-script.js +75 -0
  11. package/build/src/commands/create-version.js +31 -0
  12. package/build/src/commands/delete-deployment.js +71 -0
  13. package/build/src/commands/disable-api.js +19 -0
  14. package/build/src/commands/enable-api.js +31 -0
  15. package/build/src/commands/list-apis.js +23 -0
  16. package/build/src/commands/list-deployments.js +30 -0
  17. package/build/src/commands/list-scripts.js +28 -0
  18. package/build/src/commands/list-versions.js +29 -0
  19. package/build/src/commands/login.js +54 -53
  20. package/build/src/commands/logout.js +15 -15
  21. package/build/src/commands/open-apis.js +11 -0
  22. package/build/src/commands/open-container.js +15 -0
  23. package/build/src/commands/open-credentials.js +11 -0
  24. package/build/src/commands/open-logs.js +11 -0
  25. package/build/src/commands/open-script.js +18 -0
  26. package/build/src/commands/open-webapp.js +56 -0
  27. package/build/src/commands/program.js +108 -0
  28. package/build/src/commands/pull.js +19 -18
  29. package/build/src/commands/push.js +64 -74
  30. package/build/src/commands/run-function.js +61 -0
  31. package/build/src/commands/setup-logs.js +12 -0
  32. package/build/src/commands/show-authorized-user.js +18 -0
  33. package/build/src/commands/show-file-status.js +34 -0
  34. package/build/src/commands/tail-logs.js +92 -0
  35. package/build/src/commands/utils.js +82 -0
  36. package/build/src/constants.js +0 -3
  37. package/build/src/{apis.js → core/apis.js} +90 -92
  38. package/build/src/core/clasp.js +171 -0
  39. package/build/src/core/files.js +359 -0
  40. package/build/src/core/functions.js +51 -0
  41. package/build/src/core/logs.js +41 -0
  42. package/build/src/core/manifest.js +1 -0
  43. package/build/src/core/project.js +313 -0
  44. package/build/src/core/services.js +179 -0
  45. package/build/src/core/utils.js +121 -0
  46. package/build/src/index.js +16 -354
  47. package/build/src/intl.js +34 -0
  48. package/docs/README.md +1 -4
  49. package/docs/config-files.md +4 -5
  50. package/docs/run.md +26 -7
  51. package/package.json +87 -51
  52. package/CHANGELOG.md +0 -66
  53. package/build/src/apis.d.ts +0 -34
  54. package/build/src/apis.js.map +0 -1
  55. package/build/src/apiutils.d.ts +0 -16
  56. package/build/src/apiutils.js +0 -81
  57. package/build/src/apiutils.js.map +0 -1
  58. package/build/src/auth.d.ts +0 -34
  59. package/build/src/auth.js +0 -295
  60. package/build/src/auth.js.map +0 -1
  61. package/build/src/clasp-error.d.ts +0 -3
  62. package/build/src/clasp-error.js +0 -10
  63. package/build/src/clasp-error.js.map +0 -1
  64. package/build/src/commands/apis.d.ts +0 -10
  65. package/build/src/commands/apis.js +0 -91
  66. package/build/src/commands/apis.js.map +0 -1
  67. package/build/src/commands/clone.d.ts +0 -13
  68. package/build/src/commands/clone.js +0 -59
  69. package/build/src/commands/clone.js.map +0 -1
  70. package/build/src/commands/create.d.ts +0 -16
  71. package/build/src/commands/create.js +0 -81
  72. package/build/src/commands/create.js.map +0 -1
  73. package/build/src/commands/default.d.ts +0 -8
  74. package/build/src/commands/default.js +0 -10
  75. package/build/src/commands/default.js.map +0 -1
  76. package/build/src/commands/deploy.d.ts +0 -13
  77. package/build/src/commands/deploy.js +0 -51
  78. package/build/src/commands/deploy.js.map +0 -1
  79. package/build/src/commands/deployments.d.ts +0 -5
  80. package/build/src/commands/deployments.js +0 -29
  81. package/build/src/commands/deployments.js.map +0 -1
  82. package/build/src/commands/list.d.ts +0 -9
  83. package/build/src/commands/list.js +0 -34
  84. package/build/src/commands/list.js.map +0 -1
  85. package/build/src/commands/login.d.ts +0 -14
  86. package/build/src/commands/login.js.map +0 -1
  87. package/build/src/commands/logout.d.ts +0 -5
  88. package/build/src/commands/logout.js.map +0 -1
  89. package/build/src/commands/logs.d.ts +0 -17
  90. package/build/src/commands/logs.js +0 -181
  91. package/build/src/commands/logs.js.map +0 -1
  92. package/build/src/commands/open.d.ts +0 -15
  93. package/build/src/commands/open.js +0 -89
  94. package/build/src/commands/open.js.map +0 -1
  95. package/build/src/commands/pull.d.ts +0 -10
  96. package/build/src/commands/pull.js.map +0 -1
  97. package/build/src/commands/push.d.ts +0 -11
  98. package/build/src/commands/push.js.map +0 -1
  99. package/build/src/commands/run.d.ts +0 -14
  100. package/build/src/commands/run.js +0 -130
  101. package/build/src/commands/run.js.map +0 -1
  102. package/build/src/commands/setting.d.ts +0 -8
  103. package/build/src/commands/setting.js +0 -53
  104. package/build/src/commands/setting.js.map +0 -1
  105. package/build/src/commands/status.d.ts +0 -9
  106. package/build/src/commands/status.js +0 -25
  107. package/build/src/commands/status.js.map +0 -1
  108. package/build/src/commands/undeploy.d.ts +0 -9
  109. package/build/src/commands/undeploy.js +0 -55
  110. package/build/src/commands/undeploy.js.map +0 -1
  111. package/build/src/commands/version.d.ts +0 -5
  112. package/build/src/commands/version.js +0 -22
  113. package/build/src/commands/version.js.map +0 -1
  114. package/build/src/commands/versions.d.ts +0 -5
  115. package/build/src/commands/versions.js +0 -41
  116. package/build/src/commands/versions.js.map +0 -1
  117. package/build/src/conf.d.ts +0 -40
  118. package/build/src/conf.js +0 -100
  119. package/build/src/conf.js.map +0 -1
  120. package/build/src/constants.d.ts +0 -6
  121. package/build/src/constants.js.map +0 -1
  122. package/build/src/dotfile.d.ts +0 -50
  123. package/build/src/dotfile.js +0 -71
  124. package/build/src/dotfile.js.map +0 -1
  125. package/build/src/files.d.ts +0 -70
  126. package/build/src/files.js +0 -318
  127. package/build/src/files.js.map +0 -1
  128. package/build/src/index.d.ts +0 -18
  129. package/build/src/index.js.map +0 -1
  130. package/build/src/inquirer.d.ts +0 -82
  131. package/build/src/inquirer.js +0 -111
  132. package/build/src/inquirer.js.map +0 -1
  133. package/build/src/manifest.d.ts +0 -123
  134. package/build/src/manifest.js +0 -142
  135. package/build/src/manifest.js.map +0 -1
  136. package/build/src/messages.d.ts +0 -110
  137. package/build/src/messages.js +0 -161
  138. package/build/src/messages.js.map +0 -1
  139. package/build/src/urls.d.ts +0 -21
  140. package/build/src/urls.js +0 -33
  141. package/build/src/urls.js.map +0 -1
  142. package/build/src/utils.d.ts +0 -102
  143. package/build/src/utils.js +0 -232
  144. package/build/src/utils.js.map +0 -1
  145. package/docs/develop.md +0 -81
  146. package/docs/esmodules.md +0 -81
  147. package/docs/running-locally.md +0 -31
  148. package/docs/settings.md +0 -56
  149. package/docs/typescript.md +0 -354
@@ -18,364 +18,26 @@
18
18
  /**
19
19
  * clasp - The Apps Script CLI
20
20
  */
21
- import { program } from 'commander';
21
+ import Debug from 'debug';
22
22
  import loudRejection from 'loud-rejection';
23
- import { dirname } from 'path';
24
- import { readPackageUpSync } from 'read-pkg-up';
25
- import { fileURLToPath } from 'url';
26
- import fs from 'fs-extra';
27
- import { ClaspError } from './clasp-error.js';
28
- import apis from './commands/apis.js';
29
- import clone from './commands/clone.js';
30
- import create from './commands/create.js';
31
- import defaultCmd from './commands/default.js';
32
- import deploy from './commands/deploy.js';
33
- import deployments from './commands/deployments.js';
34
- import list from './commands/list.js';
35
- import login from './commands/login.js';
36
- import logout from './commands/logout.js';
37
- import logs from './commands/logs.js';
38
- import openCmd from './commands/open.js';
39
- import pull from './commands/pull.js';
40
- import push from './commands/push.js';
41
- import run from './commands/run.js';
42
- import setting from './commands/setting.js';
43
- import status from './commands/status.js';
44
- import undeploy from './commands/undeploy.js';
45
- import version from './commands/version.js';
46
- import versions from './commands/versions.js';
47
- import { Conf } from './conf.js';
48
- import { PROJECT_NAME } from './constants.js';
49
- import { spinner, stopSpinner } from './utils.js';
50
- const __dirname = dirname(fileURLToPath(import.meta.url));
51
- // instantiate the config singleton (and loads environment variables as a side effect)
52
- const config = Conf.get();
23
+ import { makeProgram } from './commands/program.js';
24
+ const debug = Debug('clasp:cli');
53
25
  // Ensure any unhandled exception won't go unnoticed
54
26
  loudRejection();
55
- const manifest = readPackageUpSync({ cwd: __dirname });
56
- // CLI
57
- /**
58
- * Set global CLI configurations
59
- */
60
- program.storeOptionsAsProperties(false);
61
- /**
62
- * Displays clasp version
63
- */
64
- program.version(manifest ? manifest.packageJson.version : 'unknown', '-v, --version', 'output the current version');
65
- program.name(PROJECT_NAME).usage('<command> [options]').description(`${PROJECT_NAME} - The Apps Script CLI`);
66
- /**
67
- * Path to an auth file, or to a folder with a '.clasprc.json' file.
68
- */
69
- program
70
- .option('-A, --auth <file>', "path to an auth file or a folder with a '.clasprc.json' file.")
71
- .on('option:auth', (auth) => {
72
- config.auth = auth;
73
- });
74
- /**
75
- * Path to an ignore file, or to a folder with a '.claspignore'.
76
- */
77
- program
78
- .option('-I, --ignore <file>', "path to an ignore file or a folder with a '.claspignore' file.")
79
- .on('option:ignore', (ignore) => {
80
- config.ignore = ignore;
81
- });
82
- /**
83
- * Path to a project file, or to a folder with a '.clasp.json'.
84
- */
85
- program
86
- .option('-P, --project <file>', "path to a project file or to a folder with a '.clasp.json' file.")
87
- .on('option:project', (path) => {
88
- const stats = fs.lstatSync(path);
89
- if (stats.isDirectory()) {
90
- config.projectRootDirectory = path;
27
+ const program = makeProgram();
28
+ try {
29
+ debug('Running clasp with args: %s', process.argv.join(' '));
30
+ // User input is provided from the process' arguments
31
+ await program.parseAsync(process.argv);
32
+ }
33
+ catch (error) {
34
+ debug('Error: %O', error);
35
+ if (error instanceof Error) {
36
+ process.exitCode = 1;
37
+ console.error(error.message);
91
38
  }
92
39
  else {
93
- config.projectConfig = path;
40
+ process.exitCode = 1;
41
+ console.error('Unknown error', error);
94
42
  }
95
- });
96
- /**
97
- * Logs the user in. Saves the client credentials to an rc file.
98
- * @name login
99
- * @param {string?} [--no-localhost] Do not run a local server, manually enter code instead.
100
- * @param {string?} [--creds] Relative path to credentials (from GCP).
101
- * @example login (uses default clasp credentials)
102
- * @example login --creds credentials.json (uses your credentials file).
103
- * @see test
104
- */
105
- program
106
- .command('login')
107
- .description('Log in to script.google.com')
108
- .option('--no-localhost', 'Do not run a local server, manually enter code instead')
109
- .option('--creds <file>', 'Relative path to credentials (from GCP).')
110
- .option('--status', 'Print who is logged in')
111
- .action(login);
112
- /**
113
- * Logs out the user by deleteing client credentials.
114
- * @name logout
115
- * @example logout
116
- */
117
- program.command('logout').description('Log out').action(logout);
118
- /**
119
- * Creates a new script project.
120
- * @name create
121
- * @param {string?} [--title] An optional project title.
122
- * @param {string?} [--parentId] An optional project parent Id. The Drive ID of a parent file
123
- * that the created script project is bound to. This is usually the ID of a
124
- * Google Doc, Google Sheet, Google Form, or Google Slides file. If not set, a
125
- * standalone script project is created.
126
- * https://drive.google.com/open?id=<ID>
127
- * @param {string?} [--rootDir] Local root directory that store your project files.
128
- * @example create
129
- * @example create "My Script"
130
- * @example create "My Script" "1D_Gxyv*****************************NXO7o"
131
- * @see https://developers.google.com/apps-script/api/reference/rest/v1/projects/create
132
- */
133
- program
134
- .command('create')
135
- .description('Create a script')
136
- .option('--type <type>', 'Creates a new Apps Script project attached to a new Document, Spreadsheet, Presentation, Form, or as a standalone script, web app, or API.')
137
- .option('--title <title>', 'The project title.')
138
- .option('--parentId <id>', 'A project parent Id.')
139
- .option('--rootDir <rootDir>', 'Local root directory in which clasp will store your project files.')
140
- .action(create);
141
- /**
142
- * Fetches a project and saves the script id locally.
143
- * @param {string?} [scriptId] The script ID to clone.
144
- * @param {string?} [versionNumber] The version of the script to clone.
145
- * @param {string?} [--rootDir] Local root directory that store your project files.
146
- */
147
- program
148
- .command('clone [scriptId] [versionNumber]')
149
- .description('Clone a project')
150
- .option('--rootDir <rootDir>', 'Local root directory in which clasp will store your project files.')
151
- .action(clone);
152
- /**
153
- * Fetches a project from either a provided or saved script id.
154
- * Updates local files with Apps Script project.
155
- * @name pull
156
- * @example pull
157
- */
158
- program
159
- .command('pull')
160
- .description('Fetch a remote project')
161
- .option('--versionNumber <version>', 'The version number of the project to retrieve.')
162
- .action(pull);
163
- /**
164
- * Force writes all local files to the script management server.
165
- * @name push
166
- * @desc Ignores files:
167
- * - That start with a .
168
- * - That don't have an accepted file extension
169
- * - That are ignored (filename matches a glob pattern in the ignore file)
170
- * @example push
171
- * @example push --force
172
- * @example push --watch
173
- */
174
- program
175
- .command('push')
176
- .description('Update the remote project')
177
- .option('-f, --force', 'Forcibly overwrites the remote manifest.')
178
- .option('-w, --watch', 'Watches for local file changes. Pushes when a non-ignored file changes.')
179
- .action(push);
180
- /**
181
- * Lists files that will be written to the server on `push`.
182
- * @name status
183
- * @desc Ignores files:
184
- * - That start with a .
185
- * - That don't have an accepted file extension
186
- * - That are ignored (filename matches a glob pattern in the ignore file)
187
- * @example status
188
- */
189
- program
190
- .command('status')
191
- .description('Lists files that will be pushed by clasp')
192
- .option('--json', 'Show status in JSON form')
193
- .action(status);
194
- /**
195
- * Opens the `clasp` project on script.google.com. Provide a `scriptId` to open a different script.
196
- * @name open
197
- * @param {string?} [scriptId] The optional script project to open.
198
- * @example open
199
- * @example open [scriptId]
200
- */
201
- program
202
- .command('open [scriptId]')
203
- .description('Open a script')
204
- .option('--webapp', 'Open web application in the browser')
205
- .option('--creds', 'Open the URL to create credentials')
206
- .option('--addon', 'List parent IDs and open the URL of the first one')
207
- .option('--deploymentId <id>', 'Use custom deployment ID with webapp')
208
- .action(openCmd);
209
- /**
210
- * List deployments of a script
211
- * @name deployments
212
- * @example deployments
213
- */
214
- program.command('deployments').description('List deployment ids of a script').action(deployments);
215
- /**
216
- * Creates a version and deploys a script.
217
- * The response gives the version of the deployment.
218
- * @name deploy
219
- * @example deploy (create new deployment and new version)
220
- * @example deploy --versionNumber 4 (create new deployment)
221
- * @example deploy --description "Updates sidebar logo." (deploy with description)
222
- * @example deploy --deploymentId 123 (create new version)
223
- * @example deploy -V 7 -d "Updates sidebar logo." -i 456
224
- */
225
- program
226
- .command('deploy')
227
- .description('Deploy a project')
228
- .option('-V, --versionNumber <version>', 'The project version') // We can't use `version` in subcommand
229
- .option('-d, --description <description>', 'The deployment description')
230
- .option('-i, --deploymentId <id>', 'The deployment ID to redeploy')
231
- .action(deploy);
232
- /**
233
- * Undeploys a deployment of a script.
234
- * @name undeploy
235
- * @param {string?} [deploymentId] The deployment ID.
236
- * @param {boolean?} all Setup StackDriver logs.
237
- * @example "undeploy" (undeploy the last deployment.)
238
- * @example "undeploy 123"
239
- * @example "undeploy --all"
240
- */
241
- program
242
- .command('undeploy [deploymentId]')
243
- .description('Undeploy a deployment of a project')
244
- .option('-a, --all', 'Undeploy all deployments')
245
- .action(undeploy);
246
- /**
247
- * Creates an immutable version of the script.
248
- * @name version
249
- * @param {string?} description The description of the script version.
250
- * @example version
251
- * @example version "Bump the version."
252
- */
253
- program.command('version [description]').description('Creates an immutable version of the script').action(version);
254
- /**
255
- * List versions of a script.
256
- * @name versions
257
- * @example versions
258
- */
259
- program.command('versions').description('List versions of a script').action(versions);
260
- /**
261
- * Lists your most recent 10 Apps Script projects.
262
- * @name list
263
- * @example list # helloworld1 - xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...
264
- * @todo Add --all flag to list all projects.
265
- */
266
- program
267
- .command('list')
268
- .description('List App Scripts projects')
269
- .option('--noShorten', 'Do not shorten long names', false)
270
- .action(list);
271
- /**
272
- * Prints StackDriver logs.
273
- * @name logs
274
- * @param {boolean?} json Output logs in json format.
275
- * @param {boolean?} open Open StackDriver logs in a browser.
276
- * @param {boolean?} setup Setup StackDriver logs.
277
- */
278
- program
279
- .command('logs')
280
- .description('Shows the StackDriver logs')
281
- .option('--json', 'Show logs in JSON form')
282
- .option('--open', 'Open the StackDriver logs in the browser')
283
- .option('--setup', 'Setup StackDriver logs')
284
- .option('--watch', 'Watch and print new logs')
285
- .option('--simplified', 'Hide timestamps with logs')
286
- .action(logs);
287
- /**
288
- * Remotely executes an Apps Script function.
289
- * This function runs your script in the cloud. You must supply
290
- * the functionName params. For now, it can
291
- * only run functions that do not require other authorization.
292
- * @name run
293
- * @param {string} functionName The function in the script that you want to run.
294
- * @param {boolean?} nondev Run script function in non-devMode.
295
- * @example run 'sendEmail'
296
- * @see https://developers.google.com/apps-script/api/reference/rest/v1/scripts/run
297
- * @requires `clasp login --creds` to be run beforehand.
298
- */
299
- program
300
- .command('run [functionName]')
301
- .description('Run a function in your Apps Scripts project')
302
- .option('--nondev', 'Run script function in non-devMode')
303
- .option('-p, --params [StringArray]', 'Add parameters required for the function as a JSON String Array')
304
- .action(run);
305
- /**
306
- * List, enable, or disable APIs for your project.
307
- * Currently, only list is supported.
308
- * @name apis
309
- * @example apis list
310
- * @example apis enable drive
311
- */
312
- program
313
- .command('apis')
314
- .description(`List, enable, or disable APIs
315
- list
316
- enable <api>
317
- disable <api>`)
318
- .option('--open', 'Open the API Console in the browser')
319
- .action(apis);
320
- /**
321
- * Update .clasp.json settings file.
322
- * If `newValue` is omitted, it returns the current setting value
323
- * If `settingKey` is omitted, it returns all keys in .clasp.json
324
- * @name setting
325
- * @param {string?} settingKey They key in .clasp.json you want to change
326
- * @param {string?} newValue The new value for the setting
327
- * @example setting
328
- * @example setting scriptId
329
- * @example setting scriptId new-id
330
- */
331
- program
332
- .command('setting [settingKey] [newValue]')
333
- .alias('settings')
334
- .description('Update <settingKey> in .clasp.json')
335
- .action(setting);
336
- /**
337
- * All other commands are given a help message.
338
- * @example random
339
- */
340
- program.command('*', { isDefault: true }).description('Any other command is not supported').action(defaultCmd);
341
- /**
342
- * @internal
343
- * Displays clasp paths
344
- */
345
- program
346
- .command('paths')
347
- .description('List current config files path')
348
- .action(() => {
349
- console.log('project', config.projectConfig);
350
- console.log('ignore', config.ignore);
351
- console.log('auth', config.auth);
352
- });
353
- const [_bin, _sourcePath, ...args] = process.argv;
354
- // Defaults to help if commands are not provided
355
- if (args.length === 0) {
356
- program.outputHelp();
357
43
  }
358
- (async () => {
359
- try {
360
- // User input is provided from the process' arguments
361
- await program.parseAsync(process.argv);
362
- stopSpinner();
363
- }
364
- catch (error) {
365
- spinner.stop();
366
- if (error instanceof ClaspError) {
367
- // ClaspError handles process.exitCode
368
- console.error(error.message);
369
- }
370
- else if (error instanceof Error) {
371
- process.exitCode = 1;
372
- console.error(error.message);
373
- }
374
- else {
375
- process.exitCode = 1;
376
- console.error('Unknown error', error);
377
- }
378
- }
379
- spinner.clear();
380
- })();
381
- //# sourceMappingURL=index.js.map
@@ -0,0 +1,34 @@
1
+ import { createIntl, createIntlCache } from '@formatjs/intl';
2
+ import Debug from 'debug';
3
+ const debug = Debug('clasp:intl');
4
+ function isDefined(item) {
5
+ return item !== null && item !== undefined;
6
+ }
7
+ function getLocale() {
8
+ const envLocales = [process.env.LC_ALL, process.env.LC_CTYPE, process.env.LANG].filter(isDefined);
9
+ for (const envLocale of envLocales) {
10
+ try {
11
+ // Attempt to normalize the locale string (e.g., "en_US" to "en-US")
12
+ const normalizedLocale = new Intl.Locale(envLocale).toString();
13
+ return normalizedLocale;
14
+ }
15
+ catch (_error) {
16
+ // Ignore invalid locale strings and try the next one
17
+ debug('Invalid locale string: %s', envLocale);
18
+ }
19
+ }
20
+ return 'en';
21
+ }
22
+ function loadMessages(_locale) {
23
+ // TODO - L10N not implemented yet.
24
+ return {};
25
+ }
26
+ const cache = createIntlCache();
27
+ const locale = getLocale();
28
+ debug('Using locale: %s', locale);
29
+ export const intl = createIntl({
30
+ // Locale of the application
31
+ locale,
32
+ defaultLocale: 'en',
33
+ messages: loadMessages(locale),
34
+ }, cache);
package/docs/README.md CHANGED
@@ -2,8 +2,5 @@
2
2
 
3
3
  This folder contains advanced guides for `clasp`.
4
4
 
5
- - [Develop clasp](/docs/develop.md): Build, Run, and Test the CLI.
5
+ - [Configuration](/docs/config-files.md): Learn about the configuration files used by clasp.
6
6
  - [Run](/docs/run.md): Execute Apps Script remotely with `clasp run`.
7
- - [Running locally](/docs/running-locally.md): Install and use clasp as a local dependency.
8
- - [Settings](/docs/settings.md): Set up JSON autocompletion and `.gs` syntax highlighting.
9
- - [TypeScript](/docs/typescript.md): Learn how to develop Apps Script in TypeScript.
@@ -12,9 +12,9 @@ Typescript configuration file | `<rootDir>/tsconfig.json` | Used for user specif
12
12
 
13
13
  ## Environment variables
14
14
 
15
- Environment variables can be set in order to specify the location of the following configutation files:
15
+ Environment variables can be set in order to specify the location of the following configuration files:
16
16
 
17
- File | Environment varaiable | Comment
17
+ File | Environment variable | Comment
18
18
  --- | --- | ---
19
19
  Clasp project file | `clasp_config_project` | The filename must start with a dot '.'
20
20
  Clasp ignore file | `clasp_config_ignore` |
@@ -22,9 +22,9 @@ Google Auth file | `clasp_config_auth` | The filename must start with a dot '.'
22
22
 
23
23
  ## Command line options
24
24
 
25
- Command line options can be used in order to specify the location of the following configutation files:
25
+ Command line options can be used in order to specify the location of the following configuration files:
26
26
 
27
- File | Environment varaiable | Comment
27
+ File | Environment variable | Comment
28
28
  --- | --- | ---
29
29
  Clasp project file | `-P <path>` or `--project <path>` | The filename must start with a dot '.'
30
30
  Clasp ignore file | `-I <path>` or `--ignore <path>` |
@@ -53,4 +53,3 @@ list | | | Read |
53
53
  logs | ??? | | Read | ???
54
54
  run | Read | | Read | ???
55
55
  apis | ??? | | Read | ???
56
- setting | Read | | ??? | ???
package/docs/run.md CHANGED
@@ -4,9 +4,9 @@
4
4
 
5
5
  ### Prerequisites
6
6
 
7
- To use `clasp run`, you need to complete 4 steps:
7
+ To use `clasp run`, you need to complete 5 steps:
8
8
 
9
- - Set up a **Project ID**.
9
+ - Set up the **Project ID** in your `.clasp.json` if missing.
10
10
  - Create an **OAuth Client ID** (Other). Download as `creds.json`.
11
11
  - `clasp login --creds creds.json` with this downloaded file.
12
12
  - Add the following to `appsscript.json`:
@@ -15,6 +15,7 @@ To use `clasp run`, you need to complete 4 steps:
15
15
  "access": "ANYONE"
16
16
  }
17
17
  ```
18
+ - Deploy your project as an API Executable if necessary
18
19
 
19
20
  #### Setup Instructions
20
21
 
@@ -27,16 +28,26 @@ To use `clasp run`, you need to complete 4 steps:
27
28
  1. Set the `projectId` to your Apps Script project
28
29
  - Open `https://console.developers.google.com/apis/credentials/consent?project=[PROJECT_ID]`
29
30
  - Set `Application name` to `clasp project` and click `save`.
30
- - `clasp open`
31
- - In the menu, click `Resources > Cloud Platform project...`
32
- - Paste `Project number` in `Change Project` and click `Set Project`
31
+ - Run `clasp open`
32
+ - In the menu, click `⚙️ Project Settings > Google Cloud Platform (GCP) Project`
33
+ - If the `Project Number` is missing,
34
+ - Click `Change Project`, paste the PROJECT_NUMBER, and click `Set project`
33
35
  1. Use your own OAuth 2 client. Create one by following these instructions:
34
36
  - `clasp open --creds`
35
37
  - Press **Create credentials** > **OAuth client ID**
36
38
  - Application type: **Desktop App**
37
39
  - **Create** > **OK**
38
40
  - Download the file (⬇), move it to your directory, and name it `creds.json`. Please keep this file secret!
39
- 1. Call `clasp login --creds creds.json`
41
+ 1. Call `clasp login --user <name> --creds creds.json`
42
+ 1. Add the following to `appsscript.json`:
43
+ ```json
44
+ "executionApi": {
45
+ "access": "ANYONE"
46
+ }
47
+ ```
48
+ 1. If you use Google Workspace, enable `Apps Script API`
49
+ - Open `https://console.cloud.google.com/marketplace/product/google/script.googleapis.com?project=[PROJECT_ID]`
50
+ - Press ENABLE button
40
51
 
41
52
  ### Run a function
42
53
 
@@ -47,6 +58,14 @@ After setup, you can remotely execute Apps Script functions from `clasp`:
47
58
  - The result is displayed in the output.
48
59
  - You can also run functions directly. i.e. `clasp run helloWorld`.
49
60
 
61
+ If you get an "Script API executable not published/deployed." error, deploy your script as an API Executable:
62
+
63
+ - Run `clasp open`
64
+ - Click `Deploy > New deployment`
65
+ - Select type ⚙ > API Executable
66
+ - Type a `Description`
67
+ - Click `Deploy`
68
+
50
69
  ### Run a function that requires scopes
51
70
 
52
71
  Many Apps Script functions require special OAuth Scopes (Gmail, Drive, etc.).
@@ -57,4 +76,4 @@ To run functions that use these scopes, you must add the scopes to your Apps Scr
57
76
  - `File > Project Properties > Scopes`
58
77
  - Add these scopes to your `appsscript.json`.
59
78
  - Log in again: `clasp login --creds creds.json`. This will add these scopes to your credentials.
60
- - `clasp run sendMail`
79
+ - `clasp run --user <name> sendMail`