@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
@@ -1 +0,0 @@
1
- {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/messages.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAC,yBAAyB,EAAE,YAAY,EAAC,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAC,GAAG,EAAC,MAAM,WAAW,CAAC;AAE9B,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;AAE1B,iDAAiD;AACjD,MAAM,YAAY,GAAG,IAAI,GAAG,CAAiB;IAC3C,CAAC,MAAM,EAAE,YAAY,CAAC;IACtB,CAAC,OAAO,EAAE,aAAa,CAAC;IACxB,CAAC,QAAQ,EAAE,cAAc,CAAC;IAC1B,CAAC,QAAQ,EAAE,cAAc,CAAC;CAC3B,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,eAAe,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAEjE;;;;GAIG;AACH,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC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AAiD;IACjD,qCAAqC;IACrC,6GAA6G;IAE7G,yDAAyD;IACzD,sDAAsD;CACvD,CAAC"}
@@ -1,21 +0,0 @@
1
- /**
2
- * Extracts scriptId from URL if given in URL form.
3
- * @param scriptId {string} either a scriptId or URL containing the scriptId
4
- * @example
5
- * extractScriptId(
6
- * 'https://script.google.com/a/DOMAIN/d/1Ng7bNZ1K95wNi2H7IUwZzM68FL6ffxQhyc_ByV42zpS6qAFX8pFsWu2I/edit'
7
- * )
8
- * returns '1Ng7bNZ1K95wNi2H7IUwZzM68FL6ffxQhyc_ByV42zpS6qAFX8pFsWu2I'
9
- * @example
10
- * extractScriptId('1Ng7bNZ1K95wNi2H7IUwZzM68FL6ffxQhyc_ByV42zpS6qAFX8pFsWu2I')
11
- * returns '1Ng7bNZ1K95wNi2H7IUwZzM68FL6ffxQhyc_ByV42zpS6qAFX8pFsWu2I'
12
- */
13
- export declare const extractScriptId: (scriptId: string) => string;
14
- export declare const URL: {
15
- APIS: (projectId: string) => string;
16
- CREDS: (projectId: string) => string;
17
- LOGS: (projectId: string) => string;
18
- SCRIPT_API_USER: string;
19
- SCRIPT: (scriptId: string) => string;
20
- DRIVE: (driveId: string) => string;
21
- };
package/build/src/urls.js DELETED
@@ -1,33 +0,0 @@
1
- import { SCRIPT_ID_LENGTH } from './apis.js';
2
- /**
3
- * Extracts scriptId from URL if given in URL form.
4
- * @param scriptId {string} either a scriptId or URL containing the scriptId
5
- * @example
6
- * extractScriptId(
7
- * 'https://script.google.com/a/DOMAIN/d/1Ng7bNZ1K95wNi2H7IUwZzM68FL6ffxQhyc_ByV42zpS6qAFX8pFsWu2I/edit'
8
- * )
9
- * returns '1Ng7bNZ1K95wNi2H7IUwZzM68FL6ffxQhyc_ByV42zpS6qAFX8pFsWu2I'
10
- * @example
11
- * extractScriptId('1Ng7bNZ1K95wNi2H7IUwZzM68FL6ffxQhyc_ByV42zpS6qAFX8pFsWu2I')
12
- * returns '1Ng7bNZ1K95wNi2H7IUwZzM68FL6ffxQhyc_ByV42zpS6qAFX8pFsWu2I'
13
- */
14
- export const extractScriptId = (scriptId) => {
15
- if (scriptId.length !== SCRIPT_ID_LENGTH) {
16
- const ids = scriptId.split('/').filter(s => s.length === SCRIPT_ID_LENGTH);
17
- if (ids.length > 0) {
18
- return ids[0];
19
- }
20
- }
21
- return scriptId;
22
- };
23
- // Helpers to get Apps Script project URLs
24
- export const URL = {
25
- APIS: (projectId) => `https://console.developers.google.com/apis/dashboard?project=${projectId}`,
26
- CREDS: (projectId) => `https://console.developers.google.com/apis/credentials?project=${projectId}`,
27
- LOGS: (projectId) => `https://console.cloud.google.com/logs/viewer?project=${projectId}&resource=app_script_function`,
28
- SCRIPT_API_USER: 'https://script.google.com/home/usersettings',
29
- // It is too expensive to get the script URL from the Drive API. (Async/not offline)
30
- SCRIPT: (scriptId) => `https://script.google.com/d/${scriptId}/edit`,
31
- DRIVE: (driveId) => `https://drive.google.com/open?id=${driveId}`,
32
- };
33
- //# sourceMappingURL=urls.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"urls.js","sourceRoot":"","sources":["../../src/urls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,WAAW,CAAC;AAE3C;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAAgB,EAAE,EAAE;IAClD,IAAI,QAAQ,CAAC,MAAM,KAAK,gBAAgB,EAAE;QACxC,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,gBAAgB,CAAC,CAAC;QAC3E,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE;YAClB,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC;SACf;KACF;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF,0CAA0C;AAC1C,MAAM,CAAC,MAAM,GAAG,GAAG;IACjB,IAAI,EAAE,CAAC,SAAiB,EAAE,EAAE,CAAC,gEAAgE,SAAS,EAAE;IACxG,KAAK,EAAE,CAAC,SAAiB,EAAE,EAAE,CAAC,kEAAkE,SAAS,EAAE;IAC3G,IAAI,EAAE,CAAC,SAAiB,EAAE,EAAE,CAC1B,wDAAwD,SAAS,+BAA+B;IAClG,eAAe,EAAE,6CAA6C;IAC9D,oFAAoF;IACpF,MAAM,EAAE,CAAC,QAAgB,EAAE,EAAE,CAAC,+BAA+B,QAAQ,OAAO;IAC5E,KAAK,EAAE,CAAC,OAAe,EAAE,EAAE,CAAC,oCAAoC,OAAO,EAAE;CAC1E,CAAC"}
@@ -1,102 +0,0 @@
1
- import { script_v1 as scriptV1 } from 'googleapis';
2
- import type { ClaspToken, ProjectSettings } from './dotfile';
3
- /**
4
- * The installed credentials. This is a file downloaded from console.developers.google.com
5
- * Credentials > OAuth 2.0 client IDs > Type:Other > Download
6
- * Usually called: creds.json
7
- * @see https://console.developers.google.com/apis/credentials
8
- */
9
- interface ClaspCredentialsInstalled {
10
- client_id: string;
11
- project_id: string;
12
- auth_uri: string;
13
- token_uri: string;
14
- auth_provider_x509_cert_url: string;
15
- client_secret: string;
16
- redirect_uris: string[];
17
- }
18
- export interface ClaspCredentials {
19
- installed: ClaspCredentialsInstalled;
20
- }
21
- /**
22
- * Checks if OAuth client settings rc file exists.
23
- * @param {boolean} local check ./clasprc.json instead of ~/.clasprc.json
24
- * @return {boolean}
25
- */
26
- export declare const hasOauthClientSettings: (local?: boolean) => boolean;
27
- /**
28
- * Gets the OAuth client settings from rc file.
29
- * @param {boolean} local If true, gets the local OAuth settings. Global otherwise.
30
- * ! Should be used instead of `DOTFILE.RC?().read()`
31
- * @returns {Promise<ClaspToken>} A promise to get the rc file as object.
32
- */
33
- export declare const getOAuthSettings: (local: boolean) => Promise<ClaspToken>;
34
- export declare const spinner: import("ora").Ora;
35
- /** Stops the spinner if it is spinning */
36
- export declare const stopSpinner: () => void;
37
- export declare const getErrorMessage: (value: any) => any;
38
- /**
39
- * Gets the web application URL from a deployment.
40
- *
41
- * It is too expensive to get the web application URL from the Drive API. (Async/not offline)
42
- * @param {any} value The deployment
43
- * @return {string} The URL of the web application in the online script editor.
44
- */
45
- export declare const getWebApplicationURL: (value: Readonly<scriptV1.Schema$Deployment>) => string | null | undefined;
46
- /**
47
- * Gets default project name.
48
- * @return {string} default project name.
49
- */
50
- export declare const getDefaultProjectName: () => string;
51
- /**
52
- * Gets the project settings from the project dotfile.
53
- *
54
- * Logs errors.
55
- *
56
- * ! Should be used instead of `DOTFILE.PROJECT().read()`
57
- * @return {Promise<ProjectSettings>} A promise to get the project dotfile as object.
58
- */
59
- export declare const getProjectSettings: () => Promise<ProjectSettings>;
60
- /**
61
- * Gets the Google Drive API FileType.
62
- *
63
- * Assumes the path is valid.
64
- * @param {string} value The file path
65
- * @return {string} The API's FileType enum (uppercase), null if not valid.
66
- */
67
- export declare const getApiFileType: (value: string) => string;
68
- /**
69
- * Checks if the network is available. Gracefully exits if not.
70
- */
71
- export declare const safeIsOnline: () => Promise<boolean>;
72
- /**
73
- * Checks if the network is available. Gracefully exits if not.
74
- */
75
- export declare const checkIfOnlineOrDie: () => Promise<boolean>;
76
- /**
77
- * Saves the project settings in the project dotfile.
78
- * @param {ProjectSettings} projectSettings The project settings
79
- * @param {boolean} append Appends the settings if true.
80
- */
81
- export declare const saveProject: (projectSettings: ProjectSettings, append?: boolean) => Promise<ProjectSettings>;
82
- /**
83
- * Gets the script's Cloud Platform Project Id from project settings file or prompt for one.
84
- * @returns {Promise<string>} A promise to get the projectId string.
85
- */
86
- export declare const getProjectId: (promptUser?: boolean) => Promise<string>;
87
- /**
88
- * Validates input string is a well-formed project id.
89
- * @param {string} value The project id.
90
- * @returns {boolean} Is the project id valid
91
- */
92
- export declare const isValidProjectId: (value: string) => boolean;
93
- /**
94
- * Parses input string into a valid JSON object or throws a `ClaspError` error.
95
- * @param value JSON string.
96
- */
97
- export declare const parseJsonOrDie: <T>(value: string) => T;
98
- /**
99
- * Pads input string to given length and truncate with ellipsis if necessary
100
- */
101
- export declare const ellipsize: (value: string, length: number) => string;
102
- export {};
@@ -1,232 +0,0 @@
1
- import cliTruncate from 'cli-truncate';
2
- import fs from 'fs-extra';
3
- import isReachable from 'is-reachable';
4
- import logSymbols from 'log-symbols';
5
- import ora from 'ora';
6
- import path from 'path';
7
- import pMap from 'p-map';
8
- import { ClaspError } from './clasp-error.js';
9
- import { Conf } from './conf.js';
10
- import { DOTFILE } from './dotfile.js';
11
- import { projectIdPrompt } from './inquirer.js';
12
- import { ERROR, LOG } from './messages.js';
13
- const config = Conf.get();
14
- /**
15
- * Returns input string with uppercased first character
16
- */
17
- const capitalize = (value) => value && value[0].toUpperCase() + value.slice(1);
18
- /**
19
- * Checks if OAuth client settings rc file exists.
20
- * @param {boolean} local check ./clasprc.json instead of ~/.clasprc.json
21
- * @return {boolean}
22
- */
23
- export const hasOauthClientSettings = (local = false) => {
24
- if (local) {
25
- return config.authLocal !== undefined && fs.existsSync(config.authLocal);
26
- }
27
- return config.auth !== undefined && fs.existsSync(config.auth);
28
- };
29
- /**
30
- * Gets the OAuth client settings from rc file.
31
- * @param {boolean} local If true, gets the local OAuth settings. Global otherwise.
32
- * ! Should be used instead of `DOTFILE.RC?().read()`
33
- * @returns {Promise<ClaspToken>} A promise to get the rc file as object.
34
- */
35
- export const getOAuthSettings = async (local) => {
36
- var _a;
37
- try {
38
- const result = DOTFILE.AUTH(local).read();
39
- return await result;
40
- }
41
- catch (error) {
42
- throw new ClaspError((_a = getErrorMessage(error)) !== null && _a !== void 0 ? _a : ERROR.NO_CREDENTIALS(local));
43
- }
44
- };
45
- export const spinner = ora(); // new Spinner();
46
- /** Stops the spinner if it is spinning */
47
- export const stopSpinner = () => {
48
- if (spinner.isSpinning) {
49
- spinner.stop();
50
- }
51
- };
52
- export const getErrorMessage = (value) => {
53
- // Errors are weird. The API returns interesting error structures.
54
- // TODO(timmerman) This will need to be standardized. Waiting for the API to
55
- // change error model. Don't review this method now.
56
- if (value && typeof value.error === 'string') {
57
- return JSON.parse(value.error).error;
58
- }
59
- if ((value === null || value === void 0 ? void 0 : value.statusCode) === 401 || ((value === null || value === void 0 ? void 0 : value.error) && value.error.error && value.error.error.code === 401)) {
60
- // TODO check if local creds exist:
61
- // localOathSettingsExist() ? ERROR.UNAUTHENTICATED : ERROR.UNAUTHENTICATED_LOCAL
62
- return ERROR.UNAUTHENTICATED;
63
- }
64
- if (value && ((value.error && value.error.code === 403) || value.code === 403)) {
65
- // TODO check if local creds exist:
66
- // localOathSettingsExist() ? ERROR.PERMISSION_DENIED : ERROR.PERMISSION_DENIED_LOCAL
67
- return ERROR.PERMISSION_DENIED;
68
- }
69
- if (value && value.code === 429) {
70
- return ERROR.RATE_LIMIT;
71
- }
72
- if (value === null || value === void 0 ? void 0 : value.error) {
73
- return `~~ API ERROR (${value.statusCode || value.error.code})=\n${value.error}`;
74
- }
75
- return undefined;
76
- };
77
- /**
78
- * Gets the web application URL from a deployment.
79
- *
80
- * It is too expensive to get the web application URL from the Drive API. (Async/not offline)
81
- * @param {any} value The deployment
82
- * @return {string} The URL of the web application in the online script editor.
83
- */
84
- export const getWebApplicationURL = (value) => {
85
- var _a, _b;
86
- const { entryPoints = [] } = value;
87
- const entryPoint = entryPoints.find((entryPoint) => entryPoint.entryPointType === 'WEB_APP');
88
- if (entryPoint) {
89
- return (_a = entryPoint.webApp) === null || _a === void 0 ? void 0 : _a.url;
90
- }
91
- throw new ClaspError(ERROR.NO_WEBAPP((_b = value.deploymentId) !== null && _b !== void 0 ? _b : ''));
92
- };
93
- /**
94
- * Gets default project name.
95
- * @return {string} default project name.
96
- */
97
- export const getDefaultProjectName = () => capitalize(path.basename(config.projectRootDirectory));
98
- /**
99
- * Gets the project settings from the project dotfile.
100
- *
101
- * Logs errors.
102
- *
103
- * ! Should be used instead of `DOTFILE.PROJECT().read()`
104
- * @return {Promise<ProjectSettings>} A promise to get the project dotfile as object.
105
- */
106
- export const getProjectSettings = async () => {
107
- const dotfile = DOTFILE.PROJECT();
108
- try {
109
- if (await dotfile.exists()) {
110
- // Found a dotfile, but does it have the settings, or is it corrupted?
111
- try {
112
- const settings = await dotfile.read();
113
- // Settings must have the script ID. Otherwise we err.
114
- if (settings.scriptId) {
115
- return settings;
116
- }
117
- }
118
- catch (error) {
119
- throw new ClaspError(ERROR.SETTINGS_DNE()); // Never found a dotfile
120
- }
121
- }
122
- throw new ClaspError(ERROR.SETTINGS_DNE()); // Never found a dotfile
123
- }
124
- catch (error) {
125
- if (error instanceof ClaspError) {
126
- throw error;
127
- }
128
- throw new ClaspError(getErrorMessage(error));
129
- }
130
- };
131
- /**
132
- * Gets the Google Drive API FileType.
133
- *
134
- * Assumes the path is valid.
135
- * @param {string} value The file path
136
- * @return {string} The API's FileType enum (uppercase), null if not valid.
137
- */
138
- export const getApiFileType = (value) => {
139
- const extension = value.slice(value.lastIndexOf('.') + 1).toUpperCase();
140
- return ['GS', 'JS'].includes(extension) ? 'SERVER_JS' : extension;
141
- };
142
- const mapper = async (url) => {
143
- const wasReached = await isReachable(url, { timeout: 25000 });
144
- if (!wasReached) {
145
- console.log(url, logSymbols.error);
146
- }
147
- return wasReached;
148
- };
149
- /**
150
- * Checks if the network is available. Gracefully exits if not.
151
- */
152
- // If using a proxy, return true since `isOnline` doesn't work.
153
- // @see https://github.com/googleapis/google-api-nodejs-client#using-a-proxy
154
- export const safeIsOnline = async () => {
155
- if (process.env.HTTP_PROXY || process.env.HTTPS_PROXY) {
156
- return true;
157
- }
158
- const urls = [
159
- // 'www.googleapis.com',
160
- 'script.google.com',
161
- 'console.developers.google.com',
162
- 'console.cloud.google.com',
163
- 'drive.google.com',
164
- ];
165
- const result = await pMap(urls, mapper, { stopOnError: false });
166
- return result.every(wasReached => wasReached);
167
- };
168
- /**
169
- * Checks if the network is available. Gracefully exits if not.
170
- */
171
- export const checkIfOnlineOrDie = async () => {
172
- if (await safeIsOnline()) {
173
- return true;
174
- }
175
- throw new ClaspError(ERROR.OFFLINE);
176
- };
177
- /**
178
- * Saves the project settings in the project dotfile.
179
- * @param {ProjectSettings} projectSettings The project settings
180
- * @param {boolean} append Appends the settings if true.
181
- */
182
- export const saveProject = async (projectSettings, append = true) => DOTFILE.PROJECT().write(append ? { ...(await getProjectSettings()), ...projectSettings } : projectSettings);
183
- /**
184
- * Gets the script's Cloud Platform Project Id from project settings file or prompt for one.
185
- * @returns {Promise<string>} A promise to get the projectId string.
186
- */
187
- export const getProjectId = async (promptUser = true) => {
188
- var _a;
189
- try {
190
- const projectSettings = await getProjectSettings();
191
- if (!projectSettings.projectId) {
192
- if (!promptUser) {
193
- throw new ClaspError('Project ID not found.');
194
- }
195
- console.log(`${LOG.OPEN_LINK(LOG.SCRIPT_LINK(projectSettings.scriptId))}\n`);
196
- console.log(`${LOG.GET_PROJECT_ID_INSTRUCTIONS}\n`);
197
- projectSettings.projectId = (await projectIdPrompt()).projectId;
198
- await DOTFILE.PROJECT().write(projectSettings);
199
- }
200
- return (_a = projectSettings.projectId) !== null && _a !== void 0 ? _a : '';
201
- }
202
- catch (error) {
203
- if (error instanceof ClaspError) {
204
- throw error;
205
- }
206
- // TODO: better error handling
207
- throw new ClaspError(error.message);
208
- }
209
- };
210
- /**
211
- * Validates input string is a well-formed project id.
212
- * @param {string} value The project id.
213
- * @returns {boolean} Is the project id valid
214
- */
215
- export const isValidProjectId = (value) => /^[a-z][-\da-z]{5,29}$/.test(value);
216
- /**
217
- * Parses input string into a valid JSON object or throws a `ClaspError` error.
218
- * @param value JSON string.
219
- */
220
- export const parseJsonOrDie = (value) => {
221
- try {
222
- return JSON.parse(value);
223
- }
224
- catch {
225
- throw new ClaspError(ERROR.INVALID_JSON);
226
- }
227
- };
228
- /**
229
- * Pads input string to given length and truncate with ellipsis if necessary
230
- */
231
- export const ellipsize = (value, length) => cliTruncate(value, length, { preferTruncationOnSpace: true }).padEnd(length);
232
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
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,CAAC"}
package/docs/develop.md DELETED
@@ -1,81 +0,0 @@
1
- ## Develop clasp
2
-
3
- You can develop and test `clasp` on your computer by following these steps.
4
-
5
- > Note: `clasp` uses TypeScript to provide autocompletion and linting when developing. Use an IDE like **Visual Studio Code** for TypeScript autocompletion.
6
-
7
- ### Setup
8
-
9
- - Install `tsc`: `npm install -g typescript`
10
- - Remove your local version of `clasp`: `npm uninstall -g @google/clasp`
11
- - This will prevent errors when updating `node_modules`.
12
- - [Fork](https://help.github.com/en/github/getting-started-with-github/fork-a-repo) the `clasp` repository
13
- - Clone it to your device
14
- ```
15
- git clone https://github.com/<your-github-username>/clasp.git
16
- cd clasp
17
- ```
18
- - Install dependencies: `npm install`
19
-
20
- ### After Making a Change
21
-
22
- ```sh
23
- npm run build
24
- clasp <command>
25
- ```
26
-
27
- #### Build Errors?
28
-
29
- If you're seeing build errors, try deleting the local `node_modules` and re-building `clasp` from scratch:
30
-
31
- ```sh
32
- rm package-lock.json
33
- rm -rf node_modules/
34
- npm run build-fresh
35
- ```
36
-
37
- This is what @grant's terminal looks like:
38
-
39
- ```sh
40
- sudo npm run build-fresh
41
- Password:
42
-
43
- > @google/clasp@1.5.3 build-fresh ~/Documents/github/google/clasp
44
- > npm cache clean --force && npm i && npm run build
45
-
46
- npm WARN using --force I sure hope you know what you are doing.
47
- up to date in 2.464s
48
-
49
- > @google/clasp@1.5.3 build ~/Documents/github/google/clasp
50
- > tsc --project tsconfig.json && npm i -g --loglevel=error
51
-
52
- /usr/local/bin/clasp -> /usr/local/lib/node_modules/@google/clasp/src/index.js
53
- + @google/clasp@1.5.3
54
- updated 1 package in 2.768s
55
- ```
56
-
57
- After seeing that message, you're ready to test out `clasp`!
58
-
59
- ### Run Tests
60
-
61
- `clasp` has some unit tests that help detect errors. Build and run tests with these commands:
62
-
63
- ```sh
64
- npm run build;
65
- npm run test
66
- ```
67
-
68
- See [/test/](/test/) for more information.
69
-
70
- ### Lint
71
-
72
- - Use `npm run lint` to find common style errors. TravisCI will autodetect these errors too.
73
- - Download [sort-imports](https://marketplace.visualstudio.com/items?itemName=amatiasq.sort-imports) for VSC to automatically sort imports.
74
- - Use `npm run prettier` to make the code pretty.
75
-
76
- ### Publishing `clasp` to npm (admin)
77
-
78
- 1. Build `index.js` locally. `.gitignore`/`.npmignore` will hide js/ts files appropriately.
79
- 1. Bump version: `npm version [major|minor|patch] -m "Bump version to %s"`
80
- 1. Push to GitHub: `git push --tags`
81
- 1. Publish with: `npm run publish`
package/docs/esmodules.md DELETED
@@ -1,81 +0,0 @@
1
- # ES Modules
2
-
3
- Currently, Google Apps Script does **not** support ES modules. Hence the typical `export`/`import` pattern cannot be used and will fail.
4
-
5
- One way of handling this is to use [rollup.js](https://rollupjs.org/) to bundle your project into one single JavaScript file.
6
-
7
- The trick here is to make sure not to export any functions in your entry point code, e.g. `index.ts`, _and_ to prevent any generation of export statement in the final bundle (see the custom rollup plugin in the `rollup.config.js` below).
8
-
9
- ```js
10
- import { babel } from "@rollup/plugin-babel";
11
- import { nodeResolve } from "@rollup/plugin-node-resolve";
12
-
13
- const extensions = [".ts", ".js"];
14
-
15
- const preventTreeShakingPlugin = () => {
16
- return {
17
- name: 'no-treeshaking',
18
- resolveId(id, importer) {
19
- if (!importer) {
20
- // let's not theeshake entry points, as we're not exporting anything in Apps Script files
21
- return {id, moduleSideEffects: "no-treeshake" }
22
- }
23
- return null;
24
- }
25
- }
26
- }
27
-
28
- export default {
29
- input: "./src/index.ts",
30
- output: {
31
- dir: "build",
32
- format: "esm",
33
- },
34
- plugins: [
35
- preventTreeShakingPlugin(),
36
- nodeResolve({
37
- extensions,
38
- }),
39
- babel({ extensions, babelHelpers: "runtime" }),
40
- ],
41
- };
42
- ```
43
-
44
- In order to use [babel](https://babeljs.io/) to transpile the code, be sure to add a `babel.config.js` to the project:
45
-
46
- ```js
47
- module.exports = {
48
- presets: [
49
- [
50
- // ES features necessary for user's Node version
51
- require("@babel/preset-env").default,
52
- {
53
- targets: {
54
- node: "current",
55
- },
56
- },
57
- ],
58
- [require("@babel/preset-typescript").default],
59
- ],
60
- };
61
- ```
62
-
63
- In the above example, the resulting bundle created by transpiling the entry point, i.e. `./src/index.ts`, will end up as `./build/index.js`. To make sure Clasp picks the right files to push, a `.claspignore`-file must be added to the project:
64
-
65
- ```ignore
66
- # ignore all files…
67
- **/**
68
-
69
- # except the extensions…
70
- !appsscript.json
71
- # and our transpiled code
72
- !build/*.js
73
-
74
- # ignore even valid files if in…
75
- .git/**
76
- node_modules/**
77
- ```
78
-
79
- Now you can push using your normal `clasp push`-command!
80
-
81
- This should be enough to start developing a project using ES Modules. A complete example repo can be cloned from [atti187/esmodules](https://github.com/atti187/esmodules).
@@ -1,31 +0,0 @@
1
- # Using clasp as a local dependency
2
-
3
- Typically `clasp` is installed as a global package for convenience when using the command line.
4
-
5
- Still there may be occasions when you want a project to use a specific version of `clasp` (i.e. to prevent potential breaking changes in future version)
6
-
7
- This can be achieved by simply adding clasp as a local dependency and a fixed version
8
-
9
- ```sh
10
- npm install --save-exact @google/clasp
11
- ```
12
-
13
- Optionally, you can specify an older version.
14
-
15
- ```sh
16
- npm install --save-exact @google/clasp@1.7.0
17
- ```
18
-
19
- After this, any npm scripts using `clasp` will use the **local** version
20
-
21
- ```json
22
- "scripts": {
23
- "push-project1": "cd src/GasProject1 && clasp push",
24
- },
25
- ```
26
-
27
- From the command line, within your project, use the `npx` tool in order to use the **local** version of `clasp` rather than any global one.
28
-
29
- ```sh
30
- npx clasp --version
31
- ```
package/docs/settings.md DELETED
@@ -1,56 +0,0 @@
1
- # Settings
2
-
3
- These 1-time-setup settings can enhance your Google Apps Script developer experience. (1 min)
4
-
5
- ## `appsscript.json` and `.clasp.json` Autocompletion
6
-
7
- ![autocompletion](https://user-images.githubusercontent.com/744973/44441171-2b8f2b00-a580-11e8-9470-4a846066de8e.gif)
8
-
9
- You can get autocompletion for `appsscript.json` and `.clasp.json` in VSCode by following these steps:
10
-
11
- 1. Open VSCode settings.
12
-
13
- > **Code** > **Preferences** > **Settings**
14
-
15
- 1. Add these `"json.schemas"` in the **User Settings** file:
16
-
17
- ```js
18
- {
19
- "json.schemas": [{
20
- "fileMatch": [
21
- "appsscript.json"
22
- ],
23
- "url": "http://json.schemastore.org/appsscript"
24
- }, {
25
- "fileMatch": [
26
- ".clasp.json"
27
- ],
28
- "url": "http://json.schemastore.org/clasp"
29
- }]
30
- }
31
- ```
32
-
33
- 1. After adding this, upon editing these files:
34
-
35
- - `appsscript.json` – Apps Script manifest
36
- - `.clasp.json` – Clasp Project settings
37
-
38
- ### Other IDEs
39
-
40
- - [IntelliJ instructions](https://www.jetbrains.com/help/idea/settings-languages-json-schema.html)
41
- - [Sublime instructions](https://packagecontrol.io/packages/Schema%20Validator)
42
-
43
- ## `.gs` Syntax highlighting
44
-
45
- You can also add `gs` color coding if you prefer not to use `js` or `ts` via this property in the same settings file:
46
-
47
- ```js
48
- "files.associations": {
49
- "*.gs": "javascript"
50
- },
51
- ```
52
-
53
- ## Missing Schema?
54
-
55
- File a Pull Request in this repo:
56
- https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/appsscript.json