Skip to content

Commit

Permalink
Small things (#690)
Browse files Browse the repository at this point in the history
* 2.1.0

* Low impact changes (#619)

* dependencies clean-up

* types for child_process' spawnSync

* types for child_process' spawnSync + options fix

* linting

* Relative rootdir (#620)

* relative rootDir support

* relative rootDir support (untrackedFiles behavior changed)

* relative rootDir doc changes

* Cleanup before next pr (#621)

* prettier + sort imports

* splitLines types

* unused package 'connect'

* ucfirst, isOnline types

* ellipsize types

* redundant package 'fs-copy-file-sync'

* removing extra line

* // TODO

* packages dependencies update

* comment fix

* fixes

* nicer ellipsize typing

* better?

* Refactor `inquirer` package (#622)

* regroup `inquirer` into a single file

* fix typo

* linting

* switch to `find-up`

* switch to `find-up` & `strip-bom`

* dependencies update

* findUp implementation fix

* enum accessor fix

* fs-extra & typescript dependency fix

* linting

* dependencies clean-up (again)

* non any cast

* import cleanup & TODO resolve

* prettier

* ch-ch-changes
  • Loading branch information
PopGoesTheWza authored and grant committed Aug 22, 2019
1 parent 732c987 commit af6c74a
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 27 deletions.
3 changes: 1 addition & 2 deletions src/apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +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 {
interface AdvancedService {
userSymbol: string;
serviceId: string;
version: string;
Expand Down
3 changes: 1 addition & 2 deletions src/apiutils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,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() {
async function getProjectIdWithErrors() {
const projectId = await getProjectId(); // will prompt user to set up if required
if (!projectId) logError(null, ERROR.NO_GCLOUD_PROJECT);
return projectId;
Expand Down
1 change: 0 additions & 1 deletion src/auth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import http from 'http';
// TODO: AddressInfo is not defined in @types/node version 8 => check if any impact
import { AddressInfo } from 'net';
import readline from 'readline';
import url from 'url';
Expand Down
1 change: 0 additions & 1 deletion src/commands/clone.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { async } from 'rxjs/internal/scheduler/async';
import { drive, loadAPICredentials } from '../auth';
import { fetchProject, hasProject, writeProjectFiles } from '../files';
import { ScriptIdPrompt, scriptIdPrompt } from '../inquirer';
Expand Down
1 change: 0 additions & 1 deletion src/commands/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { authorize, getLoggedInEmail } from '../auth';
import { FS_OPTIONS } from '../files';
import { readManifest } from '../manifest';
import { ERROR, LOG, checkIfOnline, hasOauthClientSettings, safeIsOnline } from '../utils';
import { google } from 'googleapis';

/**
* Logs the user in. Saves the client credentials to an either local or global rc file.
Expand Down
9 changes: 3 additions & 6 deletions src/commands/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ const logEntryCache: { [key: string]: boolean } = {};
* Prints log entries
* @param entries {any[]} StackDriver log entries.
*/
// TODO: unnecessary export
export function printLogs(
function printLogs(
entries: logging_v2.Schema$LogEntry[] = [],
formatJson: boolean,
simplified: boolean,
Expand Down Expand Up @@ -127,8 +126,7 @@ export function printLogs(
}
}

// TODO: unnecessary export
export async function setupLogs(): Promise<string> {
async function setupLogs(): Promise<string> {
let projectId: string;
return new Promise<string>((resolve, reject) => {
getProjectSettings().then(projectSettings => {
Expand Down Expand Up @@ -163,8 +161,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(
async function fetchAndPrintLogs(
formatJson: boolean,
simplified: boolean,
projectId?: string,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/openCmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import open from 'open';
import { loadAPICredentials, script } from '../auth';
import { deploymentIdPrompt } from '../inquirer';
import { URL } from '../urls';
import { ERROR, LOG, checkIfOnline, getProjectSettings, getWebApplicationURL, logError } from '../utils';
import { ERROR, LOG, getProjectSettings, getWebApplicationURL, logError } from '../utils';

interface EllipizeOptions {
ellipse?: string;
Expand Down
1 change: 1 addition & 0 deletions src/dotfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export interface ProjectSettings {
fileExtension?: string;
filePushOrder?: string[];
}

// Dotfile names
export const DOT = {
/**
Expand Down
4 changes: 1 addition & 3 deletions src/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import fs from 'fs-extra';
import mkdirp from 'mkdirp';
import multimatch from 'multimatch';
import recursive from 'recursive-readdir';
import { async } from 'rxjs/internal/scheduler/async';
import ts2gas from 'ts2gas';
import ts from 'typescript';
import { loadAPICredentials, script } from './auth';
Expand Down Expand Up @@ -56,8 +55,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 {
function getTranspileOptions(): ts.TranspileOptions {
const projectPath = findUp.sync(DOT.PROJECT.PATH);
const tsconfigPath = path.join(projectPath ? path.dirname(projectPath) : DOT.PROJECT.DIR, 'tsconfig.json');
if(fs.existsSync(tsconfigPath)) {
Expand Down
2 changes: 1 addition & 1 deletion src/inquirer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { script_v1 } from 'googleapis';
import { Question, prompt, registerPrompt } from 'inquirer';
import { prompt, registerPrompt } from 'inquirer';
import { SCRIPT_TYPES } from './apis';
import { LOG } from './utils';

Expand Down
9 changes: 5 additions & 4 deletions src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import { ERROR, PROJECT_MANIFEST_FILENAME, getProjectSettings, getValidJSON, log

/**
* Checks if the rootDir appears to be a valid project.
*
* @param {string} rootDir dir to check.
*
* @return {boolean} True if valid project, false otherwise
*/
export const manifestExists = (rootDir: string = DOT.PROJECT.DIR): boolean =>
Expand All @@ -34,8 +37,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) {
async function writeManifest(manifest: Manifest) {
let { rootDir } = await getProjectSettings();
if (typeof rootDir === 'undefined') rootDir = DOT.PROJECT.DIR;
const manifestFilePath = path.join(rootDir, PROJECT_MANIFEST_FILENAME);
Expand Down Expand Up @@ -346,8 +348,7 @@ interface Gmail {
sheets: Sheets;
}

// TODO: unnecessary export
export interface Manifest {
interface Manifest {
timeZone?: string;
oauthScopes?: string[];
dependencies?: Dependencies;
Expand Down
11 changes: 6 additions & 5 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ Forgot ${PROJECT_NAME} commands? Get help:\n ${PROJECT_NAME} --help`,
DEPLOYMENT_COUNT: `Unable to deploy; Scripts may only have up to 20 versioned deployments at a time.`,
DRIVE: `Something went wrong with the Google Drive API`,
EXECUTE_ENTITY_NOT_FOUND: `Script API executable not published/deployed.`,
// FOLDER_EXISTS: `Project file already exists.`, // TEMP!
FOLDER_EXISTS: `Project file (${DOT.PROJECT.PATH}) already exists.`,
FS_DIR_WRITE: 'Could not create directory.',
FS_FILE_WRITE: 'Could not write file.',
Expand Down Expand Up @@ -179,7 +178,8 @@ Cloned ${fileNum} ${pluralize('files', fileNum)}.`,
? `Local credentials saved to: ${DOT.RC.LOCAL_DIR}${DOT.RC.ABSOLUTE_LOCAL_PATH}.\n` +
`*Be sure to never commit this file!* It's basically a password.`
: `Default credentials saved to: ${DOT.RC.PATH} (${DOT.RC.ABSOLUTE_PATH}).`,
SCRIPT_LINK: (scriptId: string) => `https://script.google.com/d/${scriptId}/edit`,
SCRIPT_LINK: (scriptId: string) => `https://script.google.com/d/${scriptId}/edit`,
// TODO: `SCRIPT_RUN` is never used
SCRIPT_RUN: (functionName: string) => `Executing: ${functionName}`,
STACKDRIVER_SETUP: 'Setting up StackDriver Logging.',
STATUS_IGNORE: 'Ignored files:',
Expand All @@ -192,6 +192,7 @@ SCRIPT_LINK: (scriptId: string) => `https://script.google.com/d/${scriptId}/edit
VERSION_DESCRIPTION: ({ versionNumber, description }: script_v1.Schema$Version) =>
`${versionNumber} - ` + (description || '(no description)'),
VERSION_NUM: (numVersions: number) => `~ ${numVersions} ${pluralize('Version', numVersions)} ~`,
// TODO: `SETUP_LOCAL_OAUTH` is never used
SETUP_LOCAL_OAUTH: (projectId: string) => `1. Create a client ID and secret:
Open this link: ${chalk.blue(URL.CREDS(projectId))}
Click ${chalk.cyan('Create credentials')}, then select ${chalk.yellow('OAuth client ID')}.
Expand Down Expand Up @@ -257,9 +258,9 @@ export function getWebApplicationURL(deployment: script_v1.Schema$Deployment) {
const entryPoints = deployment.entryPoints || [];
const webEntryPoint = entryPoints.find((entryPoint: script_v1.Schema$EntryPoint) =>
entryPoint.entryPointType === 'WEB_APP');
if (webEntryPoint) return webEntryPoint.webApp && webEntryPoint.webApp.url;
logError(null, ERROR.NO_WEBAPP(deployment.deploymentId || ''));
}
if (webEntryPoint) return webEntryPoint.webApp && webEntryPoint.webApp.url;
logError(null, ERROR.NO_WEBAPP(deployment.deploymentId || ''));
}

/**
* Gets default project name.
Expand Down

0 comments on commit af6c74a

Please sign in to comment.