@google/clasp 2.5.0 → 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 +251 -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 +53 -54
  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 -355
  47. package/build/src/intl.js +34 -0
  48. package/docs/README.md +0 -5
  49. package/docs/config-files.md +0 -1
  50. package/docs/run.md +2 -2
  51. package/package.json +86 -51
  52. package/CHANGELOG.md +0 -79
  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 -37
  59. package/build/src/auth.js +0 -310
  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 -90
  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 -60
  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 -15
  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 -364
  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 -94
  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,55 +0,0 @@
1
- import pMap from 'p-map';
2
- import { loadAPICredentials, script } from '../auth.js';
3
- import { ClaspError } from '../clasp-error.js';
4
- import { ERROR, LOG } from '../messages.js';
5
- import { getProjectSettings, spinner, stopSpinner } from '../utils.js';
6
- /**
7
- * Removes a deployment from the Apps Script project.
8
- * @param deploymentId {string} The deployment's ID
9
- */
10
- export default async (deploymentId, options) => {
11
- await loadAPICredentials();
12
- const { scriptId } = await getProjectSettings();
13
- if (scriptId) {
14
- if (options.all) {
15
- const mapper = async ({ deploymentId }) => deleteDeployment(scriptId, deploymentId);
16
- const deployments = await listDeployments(scriptId);
17
- deployments.shift(); // @HEAD (Read-only deployments) may not be deleted.
18
- await pMap(deployments, mapper);
19
- console.log(LOG.UNDEPLOYMENT_ALL_FINISH);
20
- return;
21
- }
22
- if (!deploymentId) {
23
- const deployments = await listDeployments(scriptId);
24
- // @HEAD (Read-only deployments) may not be deleted.
25
- deployments.shift();
26
- const lastDeployment = deployments.pop();
27
- if (!lastDeployment) {
28
- throw new ClaspError(ERROR.SCRIPT_ID_INCORRECT(scriptId));
29
- }
30
- deploymentId = lastDeployment.deploymentId;
31
- }
32
- await deleteDeployment(scriptId, deploymentId);
33
- }
34
- };
35
- const deleteDeployment = async (scriptId, deploymentId) => {
36
- spinner.start(LOG.UNDEPLOYMENT_START(deploymentId));
37
- const { status } = await script.projects.deployments.delete({ scriptId, deploymentId });
38
- if (status !== 200) {
39
- throw new ClaspError(ERROR.READ_ONLY_DELETE);
40
- }
41
- stopSpinner();
42
- console.log(LOG.UNDEPLOYMENT_FINISH(deploymentId));
43
- };
44
- const listDeployments = async (scriptId) => {
45
- const { data, status, statusText } = await script.projects.deployments.list({ scriptId });
46
- if (status !== 200) {
47
- throw new ClaspError(statusText);
48
- }
49
- const { deployments = [] } = data;
50
- if (deployments.length === 0) {
51
- throw new ClaspError(ERROR.SCRIPT_ID_INCORRECT(scriptId));
52
- }
53
- return deployments;
54
- };
55
- //# sourceMappingURL=undeploy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"undeploy.js","sourceRoot":"","sources":["../../../src/commands/undeploy.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,OAAO,CAAC;AAEzB,OAAO,EAAC,kBAAkB,EAAE,MAAM,EAAC,MAAM,YAAY,CAAC;AACtD,OAAO,EAAC,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAC,KAAK,EAAE,GAAG,EAAC,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAC,kBAAkB,EAAE,OAAO,EAAE,WAAW,EAAC,MAAM,aAAa,CAAC;AAMrE;;;GAGG;AACH,eAAe,KAAK,EAAE,YAAgC,EAAE,OAAsB,EAAiB,EAAE;IAC/F,MAAM,kBAAkB,EAAE,CAAC;IAC3B,MAAM,EAAC,QAAQ,EAAC,GAAG,MAAM,kBAAkB,EAAE,CAAC;IAC9C,IAAI,QAAQ,EAAE;QACZ,IAAI,OAAO,CAAC,GAAG,EAAE;YACf,MAAM,MAAM,GAAG,KAAK,EAAE,EAAC,YAAY,EAA6B,EAAE,EAAE,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAa,CAAC,CAAC;YAE/G,MAAM,WAAW,GA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AE,EAAE;IACjD,MAAM,EAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAC,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,EAAC,QAAQ,EAAC,CAAC,CAAC;IACtF,IAAI,MAAM,KAAK,GAAG,EAAE;QAClB,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC;KAClC;IAED,MAAM,EAAC,WAAW,GAAG,EAAE,EAAC,GAAG,IAAI,CAAC;IAChC,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;QAC5B,MAAM,IAAI,UAAU,CAAC,KAAK,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC;KAC3D;IAED,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC"}
@@ -1,5 +0,0 @@
1
- declare const _default: (description?: string | undefined) => Promise<void>;
2
- /**
3
- * Creates a new version of an Apps Script project.
4
- */
5
- export default _default;
@@ -1,22 +0,0 @@
1
- import { loadAPICredentials, script } from '../auth.js';
2
- import { ClaspError } from '../clasp-error.js';
3
- import { descriptionPrompt } from '../inquirer.js';
4
- import { LOG } from '../messages.js';
5
- import { getProjectSettings, spinner, stopSpinner } from '../utils.js';
6
- /**
7
- * Creates a new version of an Apps Script project.
8
- */
9
- export default async (description) => {
10
- var _a;
11
- await loadAPICredentials();
12
- const { scriptId } = await getProjectSettings();
13
- description = description !== null && description !== void 0 ? description : (await descriptionPrompt()).description;
14
- spinner.start(LOG.VERSION_CREATE);
15
- const { data, status, statusText } = await script.projects.versions.create({ scriptId, requestBody: { description } });
16
- if (status !== 200) {
17
- throw new ClaspError(statusText);
18
- }
19
- stopSpinner();
20
- console.log(LOG.VERSION_CREATED((_a = data.versionNumber) !== null && _a !== void 0 ? _a : -1));
21
- };
22
- //# sourceMappingURL=version.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/commands/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAE,MAAM,EAAC,MAAM,YAAY,CAAC;AACtD,OAAO,EAAC,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAC,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAC,GAAG,EAAC,MAAM,gBAAgB,CAAC;AACnC,OAAO,EAAC,kBAAkB,EAAE,OAAO,EAAE,WAAW,EAAC,MAAM,aAAa,CAAC;AAErE;;GAEG;AACH,eAAe,KAAK,EAAE,WAAoB,EAAiB,EAAE;;IAC3D,MAAM,kBAAkB,EAAE,CAAC;IAE3B,MAAM,EAAC,QAAQ,EAAC,GAAG,MAAM,kBAAkB,EAAE,CAAC;IAC9C,WAAW,GAAG,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,CAAC,MAAM,iBAAiB,EAAE,CAAC,CAAC,WAAW,CAAC;IAErE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAElC,MAAM,EAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAC,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAC,QAAQ,EAAE,WAAW,EAAE,EAAC,WAAW,EAAC,EAAC,CAAC,CAAC;IACjH,IAAI,MAAM,KAAK,GAAG,EAAE;QAClB,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC;KAClC;IAED,WAAW,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,eAAe,CAAC,MAAA,IAAI,CAAC,aAAa,mCAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7D,CAAC,CAAC"}
@@ -1,5 +0,0 @@
1
- declare const _default: () => Promise<void>;
2
- /**
3
- * Lists versions of an Apps Script project.
4
- */
5
- export default _default;
@@ -1,41 +0,0 @@
1
- import { loadAPICredentials, script } from '../auth.js';
2
- import { ClaspError } from '../clasp-error.js';
3
- import { LOG } from '../messages.js';
4
- import { getProjectSettings, spinner, stopSpinner } from '../utils.js';
5
- /**
6
- * Lists versions of an Apps Script project.
7
- */
8
- export default async () => {
9
- await loadAPICredentials();
10
- spinner.start('Grabbing versions…');
11
- const { scriptId } = await getProjectSettings();
12
- const versionList = await getVersionList(scriptId);
13
- stopSpinner();
14
- const count = versionList.length;
15
- if (count === 0) {
16
- throw new ClaspError(LOG.DEPLOYMENT_DNE);
17
- }
18
- console.log(LOG.VERSION_NUM(count));
19
- versionList.reverse();
20
- for (const version of versionList) {
21
- console.log(LOG.VERSION_DESCRIPTION(version));
22
- }
23
- };
24
- const getVersionList = async (scriptId) => {
25
- let maxPages = 5;
26
- let pageToken;
27
- let list = [];
28
- do {
29
- const { data, status, statusText } = await script.projects.versions.list({ scriptId, pageSize: 200, pageToken });
30
- if (status !== 200) {
31
- throw new ClaspError(statusText);
32
- }
33
- const { nextPageToken, versions } = data;
34
- if (versions) {
35
- list = [...list, ...(versions !== null && versions !== void 0 ? versions : [])];
36
- pageToken = nextPageToken !== null && nextPageToken !== void 0 ? nextPageToken : undefined;
37
- }
38
- } while (pageToken && --maxPages);
39
- return list;
40
- };
41
- //# sourceMappingURL=versions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"versions.js","sourceRoot":"","sources":["../../../src/commands/versions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,kBAAkB,EAAE,MAAM,EAAC,MAAM,YAAY,CAAC;AACtD,OAAO,EAAC,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAC,GAAG,EAAC,MAAM,gBAAgB,CAAC;AACnC,OAAO,EAAC,kBAAkB,EAAE,OAAO,EAAE,WAAW,EAAC,MAAM,aAAa,CAAC;AAErE;;GAEG;AACH,eAAe,KAAK,IAAmB,EAAE;IACvC,MAAM,kBAAkB,EAAE,CAAC;IAE3B,OAAO,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;IAEpC,MAAM,EAAC,QAAQ,EAAC,GAAG,MAAM,kBAAkB,EAAE,CA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,SAAS,IAAI,EAAE,QAAQ,EAAE;IAElC,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
@@ -1,40 +0,0 @@
1
- /**
2
- * A Singleton class to hold configuration related objects.
3
- * Use the `get()` method to access the unique singleton instance.
4
- *
5
- * Resolution order for paths is:
6
- * - Explicitly set paths (via CLI option)
7
- * - Env var
8
- * - Well-known location
9
- *
10
- *
11
- */
12
- export declare class Conf {
13
- private _root;
14
- private _projectConfig;
15
- private _ignore;
16
- private _auth;
17
- private _authLocal;
18
- private static _instance;
19
- /**
20
- * Private to prevent direct construction calls with the `new` operator.
21
- */
22
- private constructor();
23
- set projectRootDirectory(path: string | undefined);
24
- get projectRootDirectory(): string | undefined;
25
- set projectConfig(filePath: string | undefined);
26
- get projectConfig(): string | undefined;
27
- set ignore(path: string | undefined);
28
- get ignore(): string | undefined;
29
- set auth(path: string | undefined);
30
- get auth(): string | undefined;
31
- set authLocal(path: string | undefined);
32
- get authLocal(): string | undefined;
33
- private buildPathOrUseEnv;
34
- /**
35
- * The static method that controls the access to the Conf singleton instance.
36
- *
37
- * @returns {Conf}
38
- */
39
- static get(): Conf;
40
- }
package/build/src/conf.js DELETED
@@ -1,100 +0,0 @@
1
- import os from 'os';
2
- import path from 'path';
3
- import { findUpSync } from 'find-up';
4
- import { PROJECT_NAME } from './constants.js';
5
- /**
6
- * Supported environment variables
7
- */
8
- var ENV;
9
- (function (ENV) {
10
- ENV["DOT_CLASP_AUTH"] = "clasp_config_auth";
11
- ENV["DOT_CLASP_IGNORE"] = "clasp_config_ignore";
12
- ENV["DOT_CLASP_PROJECT"] = "clasp_config_project";
13
- // MANIFEST = 'clasp_config_manifest',
14
- // TSCONFIG = 'clasp_config_tsconfig',
15
- })(ENV || (ENV = {}));
16
- /**
17
- * A Singleton class to hold configuration related objects.
18
- * Use the `get()` method to access the unique singleton instance.
19
- *
20
- * Resolution order for paths is:
21
- * - Explicitly set paths (via CLI option)
22
- * - Env var
23
- * - Well-known location
24
- *
25
- *
26
- */
27
- export class Conf {
28
- /**
29
- * Private to prevent direct construction calls with the `new` operator.
30
- */
31
- constructor() { }
32
- set projectRootDirectory(path) {
33
- this._root = path;
34
- this._projectConfig = undefined; // Force recalculation of path if root changed
35
- }
36
- get projectRootDirectory() {
37
- if (this._root === undefined) {
38
- const configPath = findUpSync(`.${PROJECT_NAME}.json`);
39
- this._root = configPath ? path.dirname(configPath) : process.cwd();
40
- }
41
- return this._root;
42
- }
43
- set projectConfig(filePath) {
44
- this._projectConfig = filePath;
45
- if (filePath) {
46
- this._root = path.dirname(filePath); // Root dir must be same dir as config
47
- }
48
- }
49
- get projectConfig() {
50
- if (this._projectConfig === undefined && this.projectRootDirectory) {
51
- this._projectConfig = this.buildPathOrUseEnv(`.${PROJECT_NAME}.json`, this.projectRootDirectory, ENV.DOT_CLASP_PROJECT);
52
- }
53
- return this._projectConfig;
54
- }
55
- set ignore(path) {
56
- this._ignore = path;
57
- }
58
- get ignore() {
59
- if (this._ignore === undefined && this.projectRootDirectory) {
60
- this._ignore = this.buildPathOrUseEnv(`.${PROJECT_NAME}ignore`, this.projectRootDirectory, ENV.DOT_CLASP_IGNORE);
61
- }
62
- return this._ignore;
63
- }
64
- set auth(path) {
65
- this._auth = path;
66
- }
67
- get auth() {
68
- if (this._auth === undefined) {
69
- this._auth = this.buildPathOrUseEnv(`.${PROJECT_NAME}rc.json`, os.homedir(), ENV.DOT_CLASP_AUTH);
70
- }
71
- return this._auth;
72
- }
73
- set authLocal(path) {
74
- this._authLocal = path;
75
- }
76
- get authLocal() {
77
- if (this._authLocal === undefined && this.projectRootDirectory) {
78
- this._authLocal = this.buildPathOrUseEnv(`.${PROJECT_NAME}rc.json`, this.projectRootDirectory, ENV.DOT_CLASP_AUTH);
79
- }
80
- return this._authLocal;
81
- }
82
- buildPathOrUseEnv(filename, root, envName) {
83
- if (envName && process.env[envName] !== undefined) {
84
- return process.env[envName];
85
- }
86
- return path.join(root, filename);
87
- }
88
- /**
89
- * The static method that controls the access to the Conf singleton instance.
90
- *
91
- * @returns {Conf}
92
- */
93
- static get() {
94
- if (!Conf._instance) {
95
- Conf._instance = new Conf();
96
- }
97
- return Conf._instance;
98
- }
99
- }
100
- //# sourceMappingURL=conf.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"conf.js","sourceRoot":"","sources":["../../src/conf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,UAAU,EAAC,MAAM,SAAS,CAAC;AAEnC,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C;;GAEG;AACH,IAAK,GAMJ;AAND,WAAK,GAAG;IACN,2CAAoC,CAAA;IACpC,+CAAwC,CAAA;IACxC,iDAA0C,CAAA;IAC1C,sCAAsC;IACtC,sCAAsC;AACxC,CAAC,EANI,GAAG,KAAH,GAAG,QAMP;AAED;;;;;;;;;;GAUG;AACH,MAAM,OAAO,IAAI;IASf;;OAEG;IACH,gBAAuB,CAAC;IAExB,IAAI,oBAAoB,CAAC,IAAwB;QAC/C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC,8CAA8C;IACjF,CAAC;IAED,IAAI,oBAAoB;QACtB,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE;YAC5B,MAAM,UAAU,GAAG,UAAU,CAAC,IAAI,YAAY,OAAO,CAAC,CAAC;YACvD,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;SACpE;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAI,aAAa,CAAC,QAA4B;QAC5C,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAC;QAC/B,IAAI,QAAQ,EAAE;YACZ,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,SAAS,IAAI,IAAI,CAAC,oBAAoB,EAAE;YAC9D,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,iBAAiB,CACtC,IAAI,YAAY,SAAS,EACzB,IAAI,CAAC,oBAAoB,EACzB,GAAG,CAAC,cAAc,CACnB,CAAC;SACH;QACD,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAEO,iBAAiB,CAAC,QAAgB,EAAE,IAAY,EAAE,OAAgB;QACxE,IAAI,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,SAAS,EAAE;YACjD,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,CAAE,CAAC;SAC9B;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,GAAG;QACR,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;SAC7B;QAED,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF"}
@@ -1,6 +0,0 @@
1
- export declare const FS_OPTIONS: {
2
- encoding: string;
3
- };
4
- export declare const PROJECT_NAME = "clasp";
5
- export declare const PROJECT_MANIFEST_BASENAME = "appsscript";
6
- export declare const PROJECT_MANIFEST_FILENAME: string;
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,MAAM,CAAC,MAAM,UAAU,GAAG,EAAC,QAAQ,EAAE,MAAM,EAAC,CAAC;AAE7C,gBAAgB;AAChB,MAAM,CAAC,MAAM,YAAY,GAAG,OAAO,CAAC;AACpC,MAAM,CAAC,MAAM,yBAAyB,GAAG,YAAY,CAAC;AACtD,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,yBAAyB,OAAO,CAAC"}
@@ -1,50 +0,0 @@
1
- import type { Credentials, OAuth2ClientOptions } from 'google-auth-library';
2
- export type { Dotfile } from 'dotf';
3
- export interface ProjectSettings {
4
- scriptId: string;
5
- rootDir?: string;
6
- projectId?: string;
7
- fileExtension?: string;
8
- filePushOrder?: string[];
9
- parentId?: string[];
10
- }
11
- export declare const DOTFILE: {
12
- /**
13
- * Reads ignore.resolve() to get a glob pattern of ignored paths.
14
- * @return {Promise<string[]>} A list of file glob patterns
15
- */
16
- IGNORE: () => Promise<string[]>;
17
- /**
18
- * Gets the closest DOT.PROJECT.NAME in the parent directory of the directory
19
- * that the command was run in.
20
- * @return {Dotf} A dotf with that dotfile. Null if there is no file
21
- */
22
- PROJECT: () => import("dotf").Dotfile;
23
- AUTH: (local?: boolean | undefined) => import("dotf").Dotfile;
24
- };
25
- /**
26
- * OAuth client settings file.
27
- * Local credentials are saved in ./.clasprc.json
28
- * Global credentials are saved in ~/.clasprc.json
29
- * @example
30
- * {
31
- * "token": {
32
- * "access_token": "",
33
- * "refresh_token": "",
34
- * "scope": "https://www.googleapis.com/auth/script.projects https://.../script.webapp.deploy",
35
- * "token_type": "Bearer",
36
- * "expiry_date": 1539130731398
37
- * },
38
- * "oauth2ClientSettings": {
39
- * "clientId": "",
40
- * "clientSecret": "",
41
- * "redirectUri": "http://localhost"
42
- * },
43
- * "isLocalCreds": false
44
- * }
45
- */
46
- export interface ClaspToken {
47
- token: Credentials;
48
- oauth2ClientSettings: OAuth2ClientOptions;
49
- isLocalCreds: boolean;
50
- }
@@ -1,71 +0,0 @@
1
- /**
2
- * Manages dotfiles. There are 2 types of dotfiles:
3
- *
4
- * Global clasp auth settings:
5
- * - File: ~/.clasp.json
6
- * - Default credentials for clasp projects.
7
- *
8
- * Local clasp auth settings:
9
- * - File: .clasp.json
10
- * - Requires `clasp login --creds creds.json`
11
- *
12
- * This should be the only file that uses DOTFILE.
13
- */
14
- import dotf from 'dotf';
15
- import fs from 'fs-extra';
16
- import path from 'path';
17
- import splitLines from 'split-lines';
18
- import stripBom from 'strip-bom';
19
- import { Conf } from './conf.js';
20
- import { FS_OPTIONS } from './constants.js';
21
- const config = Conf.get();
22
- const defaultClaspignore = `# ignore all files…
23
- **/**
24
-
25
- # except the extensions…
26
- !appsscript.json
27
- !**/*.gs
28
- !**/*.js
29
- !**/*.ts
30
- !**/*.html
31
-
32
- # ignore even valid files if in…
33
- .git/**
34
- node_modules/**
35
- `;
36
- // Methods for retrieving dotfiles.
37
- export const DOTFILE = {
38
- /**
39
- * Reads ignore.resolve() to get a glob pattern of ignored paths.
40
- * @return {Promise<string[]>} A list of file glob patterns
41
- */
42
- IGNORE: async () => {
43
- const ignorePath = config.ignore;
44
- const content = ignorePath && fs.existsSync(ignorePath) ? fs.readFileSync(ignorePath, FS_OPTIONS) : defaultClaspignore;
45
- return splitLines(stripBom(content)).filter((name) => name.length > 0);
46
- },
47
- /**
48
- * Gets the closest DOT.PROJECT.NAME in the parent directory of the directory
49
- * that the command was run in.
50
- * @return {Dotf} A dotf with that dotfile. Null if there is no file
51
- */
52
- PROJECT: () => {
53
- // ! TODO: currently limited if filename doesn't start with a dot '.'
54
- const { dir, base } = path.parse(config.projectConfig);
55
- if (base.startsWith('.')) {
56
- return dotf(dir || '.', base.slice(1));
57
- }
58
- throw new Error('Project file must start with a dot (i.e. .clasp.json)');
59
- },
60
- // Stores {ClaspCredentials}
61
- AUTH: (local) => {
62
- const configPath = local ? config.authLocal : config.auth;
63
- // ! TODO: currently limited if filename doesn't start with a dot '.'
64
- const { dir, base } = path.parse(configPath);
65
- if (base.startsWith('.')) {
66
- return dotf(dir || '.', base.slice(1));
67
- }
68
- throw new Error('Auth file must start with a dot (i.e. .clasp.json)');
69
- },
70
- };
71
- //# sourceMappingURL=dotfile.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dotfile.js","sourceRoot":"","sources":["../../src/dotfile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,M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,KAAe,EAAE,EAAE;QACxB,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;QAC1D,qEAAqE;QACrE,MAAM,EAAC,GAAG,EAAE,IAAI,EAAC,GAAG,IAAI,CAAC,KAAK,CAAC,UAAW,CAAC,CAAC;QAC5C,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YACxB,OAAO,IAAI,CAAC,GAAG,IAAI,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SACxC;QACD,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACxE,CAAC;CACF,CAAC"}
@@ -1,70 +0,0 @@
1
- interface AppsScriptFile {
2
- readonly name: string;
3
- readonly source: string;
4
- readonly type: string;
5
- }
6
- interface ProjectFile {
7
- readonly isIgnored: boolean;
8
- readonly name: string;
9
- readonly source: string;
10
- readonly type: string;
11
- }
12
- /**
13
- * Return an array of `ProjectFile` objects
14
- *
15
- * Recursively finds all files that are part of the current project, including those that are ignored by .claspignore
16
- *
17
- * > Note: content for each file is not returned. Use `getContentOfProjectFiles()` on the resulting array.
18
- *
19
- * @param rootDir the project's `rootDir`
20
- */
21
- export declare const getAllProjectFiles: (rootDir?: string) => Promise<ProjectFile[]>;
22
- export declare const splitProjectFiles: (files: ProjectFile[]) => [ProjectFile[], ProjectFile[]];
23
- export declare const getOrderedProjectFiles: (files: ProjectFile[], filePushOrder: string[] | undefined) => ProjectFile[];
24
- /**
25
- * Gets the local file type from the API FileType.
26
- * @param {string} type The file type returned by Apps Script
27
- * @return {string} The file type
28
- * @see https://developers.google.com/apps-script/api/reference/rest/v1/File#FileType
29
- */
30
- export declare const getLocalFileType: (type: string, fileExtension?: string | undefined) => string;
31
- /**
32
- * Returns true if the user has a clasp project.
33
- * @returns {boolean} If .clasp.json exists.
34
- */
35
- export declare const hasProject: () => boolean;
36
- /**
37
- * @deprecated If the file is valid, add it to our file list.
38
- * We generally want to allow for all file types, including files in node_modules/.
39
- * However, node_modules/@types/ files should be ignored.
40
- */
41
- export declare const isValidFileName: (name: string, type: string, rootDir: string, _normalizedName: string, ignoreMatches: readonly string[]) => boolean;
42
- /**
43
- * Gets the name of the file for Apps Script.
44
- * Formats rootDir/appsscript.json to appsscript.json.
45
- * Preserves subdirectory names in rootDir
46
- * (rootDir/foo/Code.js becomes foo/Code.js)
47
- * @param {string} rootDir The directory to save the project files to.
48
- * @param {string} filePath Path of file that is part of the current project
49
- */
50
- export declare const getAppsScriptFileName: (rootDir: string, filePath: string) => string;
51
- /**
52
- * Fetches the files for a project from the server
53
- * @param {string} scriptId The project script id
54
- * @param {number?} versionNumber The version of files to fetch.
55
- * @returns {AppsScriptFile[]} Fetched files
56
- */
57
- export declare const fetchProject: (scriptId: string, versionNumber?: number | undefined, silent?: boolean) => Promise<AppsScriptFile[]>;
58
- /**
59
- * Writes files locally to `pwd` with dots converted to subdirectories.
60
- * @param {AppsScriptFile[]} Files to write
61
- * @param {string?} rootDir The directory to save the project files to. Defaults to `pwd`
62
- */
63
- export declare const writeProjectFiles: (files: AppsScriptFile[], rootDir?: string) => Promise<void>;
64
- /**
65
- * Pushes project files to script.google.com.
66
- * @param {boolean} silent If true, doesn't console.log any success message.
67
- */
68
- export declare const pushFiles: (silent?: boolean) => Promise<void>;
69
- export declare const logFileList: (files: readonly string[]) => void;
70
- export {};