Skip to content

Commit

Permalink
Move LOG to /src/commands.ts (google#155)
Browse files Browse the repository at this point in the history
* Move LOG to /src/commands.ts
* Committing /src/commands.ts and commenting out tests
* Fixing typo in decribe -> describe
  • Loading branch information
campionfellin authored and grant committed Apr 30, 2018
1 parent 22e0925 commit faed059
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 41 deletions.
40 changes: 1 addition & 39 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { google } from 'googleapis';
import * as mkdirp from 'mkdirp';
const open = require('open');
const path = require('path');
import * as pluralize from 'pluralize';
const commander = require('commander');
const readMultipleFiles = require('read-multiple-files');
import * as recursive from 'recursive-readdir';
Expand All @@ -40,7 +39,7 @@ import { DOT, PROJECT_NAME, PROJECT_MANIFEST_BASENAME, ClaspSettings,
saveProjectId, manifestExists } from './src/utils.js';
import { oauth2Client, getAPICredentials,
authorizeWithLocalhost, authorizeWithoutLocalhost } from './src/auth.js';

import { LOG } from './src/commands.js';
// An Apps Script API File
interface AppsScriptFile {
name: string;
Expand All @@ -62,43 +61,6 @@ const script = google.script({
auth: oauth2Client,
});

// Log messages (some logs take required params)
export const LOG = {
AUTH_CODE: 'Enter the code from that page here: ',
AUTH_PAGE_SUCCESSFUL: `Logged in! You may close this page.`, // HTML Redirect Page
AUTH_SUCCESSFUL: `Saved the credentials to ${DOT.RC.PATH}. You may close the page.`,
AUTHORIZE: (authUrl: string) => `🔑 Authorize ${PROJECT_NAME} by visiting this url:\n${authUrl}\n`,
CLONE_SUCCESS: (fileNum: number) => `Cloned ${fileNum} ${pluralize('files', fileNum)}.`,
CLONING: 'Cloning files...',
CREATE_PROJECT_FINISH: (scriptId: string) => `Created new script: ${getScriptURL(scriptId)}`,
CREATE_PROJECT_START: (title: string) => `Creating new script: ${title}...`,
DEPLOYMENT_CREATE: 'Creating deployment...',
DEPLOYMENT_DNE: 'No deployed versions of script.',
DEPLOYMENT_LIST: (scriptId: string) => `Listing deployments for ${scriptId}...`,
DEPLOYMENT_START: (scriptId: string) => `Deploying project ${scriptId}...`,
FILES_TO_PUSH: 'Files to push were:',
FINDING_SCRIPTS: 'Finding your scripts...',
FINDING_SCRIPTS_DNE: 'No script files found.',
OPEN_PROJECT: (scriptId: string) => `Opening script: ${scriptId}`,
PULLING: 'Pulling files...',
STATUS_PUSH: 'The following files will be pushed by clasp push:',
STATUS_IGNORE: 'Untracked files:',
PUSH_SUCCESS: (numFiles: number) => `Pushed ${numFiles} ${pluralize('files', numFiles)}.`,
PUSH_FAILURE: 'Push failed. Errors:',
PUSHING: 'Pushing files...',
REDEPLOY_END: 'Updated deployment.',
REDEPLOY_START: 'Updating deployment...',
RENAME_FILE: (oldName: string, newName: string) => `Renamed file: ${oldName} -> ${newName}`,
UNDEPLOYMENT_FINISH: (deploymentId: string) => `Undeployed ${deploymentId}.`,
UNDEPLOYMENT_START: (deploymentId: string) => `Undeploy ${deploymentId}...`,
UNTITLED_SCRIPT_TITLE: 'Untitled Script',
VERSION_CREATE: 'Creating a new version...',
VERSION_CREATED: (versionNumber: string) => `Created version ${versionNumber}.`,
VERSION_DESCRIPTION: ({ versionNumber, description }: any) => `${versionNumber} - ` +
(description || '(no description)'),
VERSION_NUM: (numVersions: number) => `~ ${numVersions} ${pluralize('Version', numVersions)} ~`,
};

/**
* Requests authorization to manage Apps Script projects.
* @param {boolean} useLocalhost True if a local HTTP server should be run
Expand Down
3 changes: 1 addition & 2 deletions src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import * as http from 'http';
import * as url from 'url';
const open = require('open');
const readline = require('readline');
//Just for now, until it moves into /src/commands.ts
import { LOG } from '../index.js';
import { LOG } from './commands.js';

// API settings
// @see https://developers.google.com/oauthplayground/
Expand Down
39 changes: 39 additions & 0 deletions src/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { DOT, PROJECT_NAME, getScriptURL } from './utils.js';
import * as pluralize from 'pluralize';

// Log messages (some logs take required params)
export const LOG = {
AUTH_CODE: 'Enter the code from that page here: ',
AUTH_PAGE_SUCCESSFUL: `Logged in! You may close this page.`, // HTML Redirect Page
AUTH_SUCCESSFUL: `Saved the credentials to ${DOT.RC.PATH}. You may close the page.`,
AUTHORIZE: (authUrl: string) => `🔑 Authorize ${PROJECT_NAME} by visiting this url:\n${authUrl}\n`,
CLONE_SUCCESS: (fileNum: number) => `Cloned ${fileNum} ${pluralize('files', fileNum)}.`,
CLONING: 'Cloning files...',
CREATE_PROJECT_FINISH: (scriptId: string) => `Created new script: ${getScriptURL(scriptId)}`,
CREATE_PROJECT_START: (title: string) => `Creating new script: ${title}...`,
DEPLOYMENT_CREATE: 'Creating deployment...',
DEPLOYMENT_DNE: 'No deployed versions of script.',
DEPLOYMENT_LIST: (scriptId: string) => `Listing deployments for ${scriptId}...`,
DEPLOYMENT_START: (scriptId: string) => `Deploying project ${scriptId}...`,
FILES_TO_PUSH: 'Files to push were:',
FINDING_SCRIPTS: 'Finding your scripts...',
FINDING_SCRIPTS_DNE: 'No script files found.',
OPEN_PROJECT: (scriptId: string) => `Opening script: ${scriptId}`,
PULLING: 'Pulling files...',
STATUS_PUSH: 'The following files will be pushed by clasp push:',
STATUS_IGNORE: 'Untracked files:',
PUSH_SUCCESS: (numFiles: number) => `Pushed ${numFiles} ${pluralize('files', numFiles)}.`,
PUSH_FAILURE: 'Push failed. Errors:',
PUSHING: 'Pushing files...',
REDEPLOY_END: 'Updated deployment.',
REDEPLOY_START: 'Updating deployment...',
RENAME_FILE: (oldName: string, newName: string) => `Renamed file: ${oldName} -> ${newName}`,
UNDEPLOYMENT_FINISH: (deploymentId: string) => `Undeployed ${deploymentId}.`,
UNDEPLOYMENT_START: (deploymentId: string) => `Undeploy ${deploymentId}...`,
UNTITLED_SCRIPT_TITLE: 'Untitled Script',
VERSION_CREATE: 'Creating a new version...',
VERSION_CREATED: (versionNumber: string) => `Created version ${versionNumber}.`,
VERSION_DESCRIPTION: ({ versionNumber, description }: any) => `${versionNumber} - ` +
(description || '(no description)'),
VERSION_NUM: (numVersions: number) => `~ ${numVersions} ${pluralize('Version', numVersions)} ~`,
};

0 comments on commit faed059

Please sign in to comment.