Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update comments and remove no-any rule #629

Merged
merged 9 commits into from
May 22, 2019
1 change: 1 addition & 0 deletions src/apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export enum SCRIPT_TYPES {

// Also see:
// https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/appsscript.json
// TODO: unnecessary export
export interface AdvancedService {
userSymbol: string;
serviceId: string;
Expand Down
1 change: 1 addition & 0 deletions src/apiutils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export async function getFunctionNames(script: script_v1.Script, scriptId: strin
/**
* Gets the project ID from the manifest. If there is no project ID, it returns an error.
*/
// TODO: unnecessary export
export async function getProjectIdWithErrors() {
const projectId = await getProjectId(); // will prompt user to set up if required
if (!projectId) throw logError(null, ERROR.NO_GCLOUD_PROJECT);
Expand Down
1 change: 1 addition & 0 deletions src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ async function setOauthClientCredentials(rc: ClaspToken) {
* authorize if new scopes found (local OAuth credentails only).
* @param {ClaspToken} rc OAuth client settings from rc file.
*/
// TODO: currently unused. Check relevancy
export async function checkOauthScopes(rc: ClaspToken) {
try {
await checkIfOnline();
Expand Down
10 changes: 6 additions & 4 deletions src/commands/logs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import chalk from 'chalk';
import { GaxiosResponse } from 'gaxios';
import { logging_v2 } from 'googleapis';
import * as open from 'open';
import { loadAPICredentials, logger } from './../auth';
Expand Down Expand Up @@ -59,6 +60,7 @@ export default async (cmd: { json: boolean; open: boolean; setup: boolean; watch
* Prints log entries
* @param entries {any[]} StackDriver log entries.
*/
// TODO: unnecessary export
export function printLogs(entries: logging_v2.Schema$LogEntry[] = [], formatJson: boolean) {
/**
* This object holds all log IDs that have been printed to the user.
Expand Down Expand Up @@ -104,8 +106,7 @@ export function printLogs(entries: logging_v2.Schema$LogEntry[] = [], formatJson
payloadData = padEnd(payloadData, 20);
}
}
// tslint:disable-next-line:no-any
const coloredStringMap: any = {
const coloredStringMap: { [key: string]: string } = {
ERROR: chalk.red(severity),
INFO: chalk.cyan(severity),
DEBUG: chalk.green(severity), // includes timeEnd
Expand All @@ -122,6 +123,7 @@ export function printLogs(entries: logging_v2.Schema$LogEntry[] = [], formatJson
}
}

// TODO: unnecessary export
export async function setupLogs(): Promise<string> {
let projectId: string;
const promise = new Promise<string>((resolve, reject) => {
Expand Down Expand Up @@ -161,6 +163,7 @@ export async function setupLogs(): Promise<string> {
* Fetches the logs and prints the to the user.
* @param startDate {Date?} Get logs from this date to now.
*/
// TODO: unnecessary export
export async function fetchAndPrintLogs(formatJson: boolean, projectId?: string, startDate?: Date) {
const oauthSettings = await loadAPICredentials();
spinner.setSpinnerTitle(`${oauthSettings.isLocalCreds ? LOG.LOCAL_CREDS : ''}${LOG.GRAB_LOGS}`).start();
Expand Down Expand Up @@ -192,8 +195,7 @@ export async function fetchAndPrintLogs(formatJson: boolean, projectId?: string,
console.log(filter);
}
// Parse response and print logs or print error message.
// tslint:disable-next-line:no-any
const parseResponse = (response: any) => {
const parseResponse = (response: GaxiosResponse<logging_v2.Schema$ListLogEntriesResponse>) => {
if (logs.status !== 200) {
switch (logs.status) {
case 401:
Expand Down
1 change: 1 addition & 0 deletions src/commands/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default async (cmd: { watch: boolean; force: boolean }) => {
/**
* @see https://www.npmjs.com/package/watch
*/
// TODO check alternative https://github.com/paulmillr/chokidar
watchTree(rootDir || '.', async (f, curr, prev) => {
// The first watch doesn't give a string for some reason.
if (typeof f === 'string') {
Expand Down
1 change: 1 addition & 0 deletions src/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export function hasProject(): boolean {
* Returns in tsconfig.json.
* @returns {ts.TranspileOptions} if tsconfig.json not exists, return undefined.
*/
// TODO: unnecessary export
export function getTranspileOptions(): ts.TranspileOptions {
const projectPath = findUp.sync(DOT.PROJECT.PATH);
const tsconfigPath = path.join(projectPath ? path.dirname(projectPath) : DOT.PROJECT.DIR, 'tsconfig.json');
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env node

/**
* @license
* Copyright Google Inc.
Expand Down
3 changes: 3 additions & 0 deletions src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export async function readManifest(): Promise<Manifest> {
* Writes the appsscript.json manifest file.
* @param {Manifest} manifest The new manifest to write.
*/
// TODO: unnecessary export
export async function writeManifest(manifest: Manifest) {
let { rootDir } = await getProjectSettings();
if (typeof rootDir === 'undefined') rootDir = DOT.PROJECT.DIR;
Expand Down Expand Up @@ -99,6 +100,7 @@ export async function addScopeToManifest(scopes: string[]) {
* Enables the Execution API in the Manifest.
* The Execution API requires the manifest to have the "executionApi.access" field set.
*/
// TODO: currently unused. Check relevancy
export async function enableExecutionAPI() {
console.log('Writing manifest');
const manifest = await readManifest();
Expand Down Expand Up @@ -344,6 +346,7 @@ interface Gmail {
sheets: Sheets;
}

// TODO: unnecessary export
export interface Manifest {
timeZone?: string;
oauthScopes?: string[];
Expand Down
5 changes: 3 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const hasOauthClientSettings = (local = false): boolean =>
/**
* Gets the OAuth client settings from rc file.
* @param {boolean} local If true, gets the local OAuth settings. Global otherwise.
* Should be used instead of `DOTFILE.RC?().read()`
* ! Should be used instead of `DOTFILE.RC?().read()`
* @returns {Promise<ClaspToken>} A promise to get the rc file as object.
*/
export function getOAuthSettings(local: boolean): Promise<ClaspToken> {
Expand Down Expand Up @@ -264,7 +264,7 @@ export function getDefaultProjectName(): string {

/**
* Gets the project settings from the project dotfile. Logs errors.
* Should be used instead of `DOTFILE.PROJECT().read()`
* ! Should be used instead of `DOTFILE.PROJECT().read()`
* @param {boolean} failSilently Don't err when dot file DNE.
* @return {Promise<ProjectSettings>} A promise to get the project dotfile as object.
*/
Expand Down Expand Up @@ -335,6 +335,7 @@ export async function saveProject(
append = true): Promise<ProjectSettings> {
if (append) {
const projectSettings: ProjectSettings = await DOTFILE.PROJECT().read();
// TODO: const projectSettings: ProjectSettings = await getProjectSettings();
newProjectSettings = { ...projectSettings, ...newProjectSettings };
}
return DOTFILE.PROJECT().write(newProjectSettings);
Expand Down