Skip to content

Commit

Permalink
Merge branch 'master' into merged
Browse files Browse the repository at this point in the history
  • Loading branch information
danielzen authored Sep 30, 2024
2 parents 14823ea + d633ca9 commit 4e46d1d
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 27 deletions.
8 changes: 4 additions & 4 deletions docs/config-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ Typescript configuration file | `<rootDir>/tsconfig.json` | Used for user specif

## Environment variables

Environment variables can be set in order to specify the location of the following configutation files:
Environment variables can be set in order to specify the location of the following configuration files:

File | Environment varaiable | Comment
File | Environment variable | Comment
--- | --- | ---
Clasp project file | `clasp_config_project` | The filename must start with a dot '.'
Clasp ignore file | `clasp_config_ignore` |
Google Auth file | `clasp_config_auth` | The filename must start with a dot '.'

## Command line options

Command line options can be used in order to specify the location of the following configutation files:
Command line options can be used in order to specify the location of the following configuration files:

File | Environment varaiable | Comment
File | Environment variable | Comment
--- | --- | ---
Clasp project file | `-P <path>` or `--project <path>` | The filename must start with a dot '.'
Clasp ignore file | `-I <path>` or `--ignore <path>` |
Expand Down
30 changes: 20 additions & 10 deletions docs/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

### Prerequisites

To use `clasp run`, you need to complete 4 steps:
To use `clasp run`, you need to complete 5 steps:

- Set up a **Project ID**.
- Set up a **Project ID** in your `.clasp.json` if missing.
- Create an **OAuth Client ID** (Desktop App). Download as `creds.json`.
- `clasp login --creds creds.json` with this downloaded file.
- Add the following to `appsscript.json`:
Expand All @@ -15,6 +15,7 @@ To use `clasp run`, you need to complete 4 steps:
"access": "ANYONE"
}
```
- Deploy your project as an API Executable if necessary

#### Setup Instructions

Expand All @@ -27,9 +28,10 @@ To use `clasp run`, you need to complete 4 steps:
1. Set the `projectId` to your Apps Script project
- Open `https://console.developers.google.com/apis/credentials/consent?project=[PROJECT_ID]`
- Set `Application name` to `clasp project` and click `save`.
- `clasp open`
- In the menu, click `Resources > Cloud Platform project...`
- Paste `Project number` in `Change Project` and click `Set Project`
- Run `clasp open`
- In the menu, click `⚙️ Project Settings > Google Cloud Platform (GCP) Project`
- If the `Project Number` is missing,
- Click `Change Project`, paste the PROJECT_NUMBER, and click `Set project`
1. Use your own OAuth 2 client. Create one by following these instructions:
- `clasp open --creds`
- Press **Create credentials** > **OAuth client ID**
Expand All @@ -38,11 +40,11 @@ To use `clasp run`, you need to complete 4 steps:
- Download the file (⬇), move it to your directory, and name it `creds.json`. Please keep this file secret!
1. Call `clasp login --creds creds.json`
1. Add the following to `appsscript.json`:
```json
"executionApi": {
"access": "ANYONE"
}
```
```json
"executionApi": {
"access": "ANYONE"
}
```
1. If you use Google Workspace, enable `Apps Script API`
- Open `https://console.cloud.google.com/marketplace/product/google/script.googleapis.com?project=[PROJECT_ID]`
- Press ENABLE button
Expand All @@ -56,6 +58,14 @@ After setup, you can remotely execute Apps Script functions from `clasp`:
- The result is displayed in the output.
- You can also run functions directly. i.e. `clasp run helloWorld`.

If you get an "Script API executable not published/deployed." error, deploy your script as an API Executable:

- Run `clasp open`
- Click `Deploy > New deployment`
- Select type ⚙ > API Executable
- Type a `Description`
- Click `Deploy`

### Run a function that requires scopes

Many Apps Script functions require special OAuth Scopes (Gmail, Drive, etc.).
Expand Down
2 changes: 1 addition & 1 deletion docs/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This quickstart guide describes how to create a TypeScript project from scratch.
- `clasp -v`

1. Install TypeScript definitions for Apps Script in your project's folder.
- `npm i -S @types/google-apps-script`
- `npm i -D @types/google-apps-script`

1. Create a file called `tsconfig.json` to enable TypeScript features:

Expand Down
4 changes: 2 additions & 2 deletions src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ const authorizeWithoutLocalhost = async (
};

/**
* Set OAuth client credentails from rc.
* Set OAuth client credentials from rc.
* Can be global or local.
* Saves new credentials if access token refreshed.
* @param {ClaspToken} rc OAuth client settings from rc file.
Expand Down Expand Up @@ -313,7 +313,7 @@ const setOauthClientCredentials = async (rc: ClaspToken) => {

// /**
// * Compare global OAuth client scopes against manifest and prompt user to
// * authorize if new scopes found (local OAuth credentails only).
// * authorize if new scopes found (local OAuth credentials only).
// * @param {ClaspToken} rc OAuth client settings from rc file.
// */
// // TODO: currently unused. Check relevancy
Expand Down
2 changes: 1 addition & 1 deletion src/commands/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default async (options: CommandOption): Promise<void> => {
try {
projectExist = is.string((await getProjectSettings()).scriptId);
} catch {
process.exitCode = 0; // To reset `exitCode` that was overriden in ClaspError constructor.
process.exitCode = 0; // To reset `exitCode` that was overridden in ClaspError constructor.
projectExist = false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default async (settingKey?: keyof ProjectSettings, settingValue?: string)
}

// We don't use console.log as it automatically adds a new line
// Which interfers with storing the value
// Which interferes with storing the value
process.stdout.write(keyValue);
} else {
throw new ClaspError(ERROR.UNKNOWN_KEY(settingKey));
Expand Down
2 changes: 1 addition & 1 deletion src/conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class Conf {

set projectRootDirectory(path: string | undefined) {
this._root = path;
this._projectConfig = undefined; // Force recalculation of path if root chanaged
this._projectConfig = undefined; // Force recalculation of path if root changed
}

get projectRootDirectory() {
Expand Down
8 changes: 4 additions & 4 deletions src/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ export const splitProjectFiles = (files: ProjectFile[]): [ProjectFile[], Project
];

async function getContentOfProjectFiles(files: ProjectFile[]) {
const transpileOpttions = getTranspileOptions();
const transpileOptions = getTranspileOptions();

const getContent = (file: ProjectFile) => (file.isIgnored ? file : projectFileWithContent(file, transpileOpttions));
const getContent = (file: ProjectFile) => (file.isIgnored ? file : projectFileWithContent(file, transpileOptions));
return Promise.all(files.map(getContent));
}

Expand Down Expand Up @@ -223,7 +223,7 @@ const getTranspileOptions = (): TranspileOptions => {
// * Recursively finds all files that are part of the current project, and those that are ignored
// * by .claspignore and calls the passed callback function with the file lists.
// * @param {string} rootDir The project's root directory
// * @param {FilesCallBack} callback The callback will be called with the following paramters
// * @param {FilesCallBack} callback The callback will be called with the following parameters
// * error: Error if there's an error, otherwise null
// * result: string[][], array of two lists of strings, ie. [validFilePaths,ignoredFilePaths]
// * files?: Array<AppsScriptFile> Array of AppsScriptFile objects used by clasp push
Expand Down Expand Up @@ -328,7 +328,7 @@ export const fetchProject = async (

/**
* Writes files locally to `pwd` with dots converted to subdirectories.
* @param {AppsScriptFile[]} Files to wirte
* @param {AppsScriptFile[]} Files to write
* @param {string?} rootDir The directory to save the project files to. Defaults to `pwd`
*/
export const writeProjectFiles = async (files: AppsScriptFile[], rootDir = '') => {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ program
.action(login);

/**
* Logs out the user by deleteing client credentials.
* Logs out the user by deleting client credentials.
* @name logout
* @example logout
*/
Expand Down
2 changes: 1 addition & 1 deletion src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Forgot ${PROJECT_NAME} commands? Get help:\n ${PROJECT_NAME} --help`,
NO_FUNCTION_NAME: 'N/A',
NO_GCLOUD_PROJECT: () => `No projectId found in your ${config.projectConfig} file.`,
NO_PARENT_ID: () => `No parentId or empty parentId found in your ${config.projectConfig} file.`,
NO_LOCAL_CREDENTIALS: `Requires local crendetials:\n\n ${PROJECT_NAME} login --creds <file.json>`,
NO_LOCAL_CREDENTIALS: `Requires local credentials:\n\n ${PROJECT_NAME} login --creds <file.json>`,
NO_MANIFEST: (filename: string) => `Manifest: ${filename} invalid. \`create\` or \`clone\` a project first.`,
NO_NESTED_PROJECTS: '\nNested clasp projects are not supported.',
NO_VERSIONED_DEPLOYMENTS: 'No versioned deployments found in project.',
Expand Down
2 changes: 1 addition & 1 deletion test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ describe('Test getLocalFileType function from utils', () => {
expect(getLocalFileType('HTML')).to.equal('html');
});

it('should return the specified file extention if the file type is SERVER_JS', () => {
it('should return the specified file extension if the file type is SERVER_JS', () => {
expect(getLocalFileType('SERVER_JS', 'gs')).to.equal('gs');
expect(getLocalFileType('GS', 'js')).to.equal('gs');
expect(getLocalFileType('JS', 'gs')).to.equal('js');
Expand Down

0 comments on commit 4e46d1d

Please sign in to comment.