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

Cleanup before next pr #621

Merged
merged 17 commits into from
May 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 0 additions & 101 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"chalk": "^2.4.1",
"cli-spinner": "^0.2.8",
"commander": "^2.15.1",
"connect": "^3.6.6",
"del": "^4.1.1",
"dotf": "^1.2.0",
"ellipsize": "^0.1.0",
Expand All @@ -64,14 +63,12 @@
"split-lines": "^2.0.0",
"string.prototype.padend": "^3.0.0",
"ts2gas": "^3.4.4",
"ucfirst": "^1.0.0",
"url": "^0.11.0",
"watch": "^1.0.2"
},
"devDependencies": {
"@types/chai": "^4.1.3",
"@types/cli-spinner": "^0.2.0",
"@types/connect": "^3.4.32",
"@types/events": "^3.0.0",
"@types/find-parent-dir": "^0.3.0",
"@types/fs-extra": "^7.0.0",
Expand All @@ -86,7 +83,6 @@
"axios": "^0.18.0",
"chai": "^4.1.2",
"coveralls": "^3.0.1",
"fs-copy-file-sync": "^1.1.1",
"fs-extra": "^8.0.1",
"mocha": "^6.1.4",
"nyc": "^14.1.0",
Expand Down
6 changes: 3 additions & 3 deletions src/apiutils.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as fuzzy from 'fuzzy';
import { script_v1 } from 'googleapis';
import * as inquirer from 'inquirer';
import { Answers, Question, prompt } from 'inquirer';
import { loadAPICredentials, serviceUsage } from './auth';
import { enableOrDisableAdvanceServiceInManifest } from './manifest';
import { ERROR, getProjectId, logError, spinner } from './utils';

// setup inquirer
import * as inquirer from 'inquirer';
import { prompt, Question, Answers } from 'inquirer';
inquirer.registerPrompt('autocomplete', require('inquirer-autocomplete-prompt'));

/**
Expand Down Expand Up @@ -111,4 +111,4 @@ export async function enableAppsScriptAPI(){
const projectId = await getProjectIdWithErrors();
const name = `projects/${projectId}/services/script.googleapis.com`;
await serviceUsage.services.enable({ name });
}
}
4 changes: 2 additions & 2 deletions src/auth.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import * as http from 'http';
import { AddressInfo } from 'net';
import * as readline from 'readline';
import * as url from 'url';
/**
* Authentication with Google's APIs.
*/
import { Credentials, GenerateAuthUrlOpts, OAuth2Client, OAuth2ClientOptions } from 'google-auth-library';
import { google, script_v1 } from 'googleapis';
import { prompt } from 'inquirer';
import * as open from 'open';
import { ClaspToken, DOTFILE } from './dotfile';
import { readManifest } from './manifest';
import { ClaspCredentials, ERROR, LOG, checkIfOnline, getOAuthSettings, logError } from './utils';
import * as open from 'open';
import * as readline from 'readline';

// Auth is complicated. Consider yourself warned.
// tslint:disable:max-line-length
Expand Down
40 changes: 15 additions & 25 deletions src/commands/apis.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
import * as open from 'open';
const padEnd = require('string.prototype.padend');

import { GaxiosResponse } from 'gaxios';
import { serviceusage_v1} from 'googleapis';
import { serviceusage_v1 } from 'googleapis';
import * as open from 'open';
import { PUBLIC_ADVANCED_SERVICES } from '../apis';
import {
enableOrDisableAPI,
} from '../apiutils';
import {
discovery,
loadAPICredentials,
serviceUsage,
} from '../auth';
import { enableOrDisableAPI } from '../apiutils';
import { discovery, loadAPICredentials, serviceUsage } from '../auth';
import { URL } from '../urls';
import {
ERROR,
checkIfOnline,
getProjectId,
logError,
} from '../utils';
import { ERROR, checkIfOnline, getProjectId, logError } from '../utils';
const padEnd = require('string.prototype.padend');

/**
* Acts as a router to apis subcommands
Expand Down Expand Up @@ -53,8 +41,9 @@ export default async (options: { open?: string }) => {
console.log('\n# Currently enabled APIs:');
const projectId = await getProjectId(); // will prompt user to set up if required
const MAX_PAGE_SIZE = 200; // This is the max page size according to the docs.
const list: GaxiosResponse<serviceusage_v1.Schema$ListServicesResponse> =
await serviceUsage.services.list({
const list: GaxiosResponse<
serviceusage_v1.Schema$ListServicesResponse
> = await serviceUsage.services.list({
parent: `projects/${projectId}`,
filter: 'state:ENABLED',
pageSize: MAX_PAGE_SIZE,
Expand All @@ -65,10 +54,11 @@ export default async (options: { open?: string }) => {
}

// Filter out the disabled ones. Print the enabled ones.
const enabledAPIs = serviceList.filter((service:
serviceusage_v1.Schema$GoogleApiServiceusageV1Service) => {
return service.state === 'ENABLED';
});
const enabledAPIs = serviceList.filter(
(service: serviceusage_v1.Schema$GoogleApiServiceusageV1Service) => {
return service.state === 'ENABLED';
},
);
for (const enabledAPI of enabledAPIs) {
if (enabledAPI.config && enabledAPI.config.documentation) {
const name = enabledAPI.config.name || 'Unknown name.';
Expand All @@ -92,7 +82,7 @@ export default async (options: { open?: string }) => {
// Merge discovery data with public services data.
const publicServices = [];
for (const publicServiceId of PUBLIC_ADVANCED_SERVICE_IDS) {
const service = services.find((s) => s.name === publicServiceId);
const service = services.find(s => s.name === publicServiceId);
// for some reason 'youtubePartner' is not in the api list.
if (service && service.id && service.description) {
publicServices.push(service);
Expand Down
Loading