From d9bb573419fd9c4a8a001cebae8c7e986a915dd8 Mon Sep 17 00:00:00 2001 From: HoldYourWaffle Date: Mon, 6 Nov 2023 05:25:38 +0100 Subject: [PATCH 1/3] Mention `npm link` in development setup docs --- docs/develop.md | 1 + test/README.md | 2 ++ 2 files changed, 3 insertions(+) diff --git a/docs/develop.md b/docs/develop.md index 15ceb593..f152f8be 100644 --- a/docs/develop.md +++ b/docs/develop.md @@ -16,6 +16,7 @@ git clone https://github.com//clasp.git cd clasp ``` - Install dependencies: `npm install` +- Link-install this development version of `clasp`: `npm link` ### After Making a Change diff --git a/test/README.md b/test/README.md index b5439927..73a75185 100644 --- a/test/README.md +++ b/test/README.md @@ -14,6 +14,8 @@ ## How to Run Tests +Make sure you have completed the [development setup](/docs/develop.md#setup). + 1. Log in: `clasp login` 1. Rebuild: `npm run build` 1. Set environmental variables: From 29b925e5d97a0a426d254be7ac0a91344d05c17a Mon Sep 17 00:00:00 2001 From: HoldYourWaffle Date: Mon, 6 Nov 2023 04:43:06 +0100 Subject: [PATCH 2/3] Throw error if SCRIPT/PROJECT_ID is not defined As far as I can tell not-defining these will always lead to trouble later. Is `ClaspError` appropriate here? --- test/constants.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/constants.ts b/test/constants.ts index 1ba740ef..95086a0f 100644 --- a/test/constants.ts +++ b/test/constants.ts @@ -2,6 +2,7 @@ import os from 'os'; import path from 'path'; import {ClaspToken} from '../src/dotfile.js'; +import {ClaspError} from '../src/clasp-error.js'; import {randomString} from './functions.js'; import type {OAuth2ClientOptions} from 'google-auth-library'; @@ -27,9 +28,15 @@ export const TEST_APPSSCRIPT_JSON_WITH_RUN_API = JSON.stringify({ // Travis Env Variables export const IS_PR: boolean = process.env.CI === 'true'; -export const SCRIPT_ID: string = process.env.SCRIPT_ID ?? ''; -export const PROJECT_ID: string = process.env.PROJECT_ID ?? ''; -export const PARENT_ID: string[] = [process.env.PROJECT_ID ?? '']; +if (process.env.SCRIPT_ID === undefined) { + throw new ClaspError('Environment variable SCRIPT_ID is not defined.'); +} +export const SCRIPT_ID: string = process.env.SCRIPT_ID; +if (process.env.PROJECT_ID === undefined) { + throw new ClaspError('Environment variable PROJECT_ID is not defined.'); +} +export const PROJECT_ID: string = process.env.PROJECT_ID; +export const PARENT_ID: string[] = [process.env.PROJECT_ID]; const HOME: string = process.env.HOME ?? ''; // Paths From 0c3081c1796e9b7507191a6248e2750c126b7e8e Mon Sep 17 00:00:00 2001 From: HoldYourWaffle Date: Mon, 6 Nov 2023 03:26:59 +0100 Subject: [PATCH 3/3] Fix CLASP_PATHS.rcGlobal on Windows --- test/constants.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/constants.ts b/test/constants.ts index 95086a0f..3134b172 100644 --- a/test/constants.ts +++ b/test/constants.ts @@ -37,12 +37,11 @@ if (process.env.PROJECT_ID === undefined) { } export const PROJECT_ID: string = process.env.PROJECT_ID; export const PARENT_ID: string[] = [process.env.PROJECT_ID]; -const HOME: string = process.env.HOME ?? ''; // Paths export const CLASP_PATHS = { clientCredsLocal: 'client_credentials.json', - rcGlobal: path.join(HOME, '.clasprc.json'), + rcGlobal: path.join(os.homedir(), '.clasprc.json'), rcLocal: '.clasprc.json', settingsLocal: '.clasp.json', };