Skip to content

Commit

Permalink
build: keep deleted APIs in place (#2264)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith authored Jul 9, 2020
1 parent 0afc83d commit d74bb34
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 19 deletions.
3 changes: 2 additions & 1 deletion ignore.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"ignore": [
"apigee:v1"
"apigee:v1",
"youtube:v3"
]
}
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
"@types/prettier": "^2.0.0",
"@types/proxyquire": "^1.3.28",
"@types/qs": "^6.5.3",
"@types/rimraf": "^3.0.0",
"@types/sinon": "^9.0.0",
"@types/tmp": "^0.2.0",
"@types/url-template": "^2.0.28",
Expand All @@ -84,7 +83,6 @@
"p-queue": "^6.0.0",
"prettier": "^2.0.5",
"proxyquire": "^2.1.3",
"rimraf": "^3.0.0",
"server-destroy": "^1.0.1",
"sinon": "^9.0.2",
"tmp": "^0.2.0",
Expand Down
12 changes: 6 additions & 6 deletions src/generator/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import * as util from 'util';
import Q from 'p-queue';
import * as prettier from 'prettier';
import * as minimist from 'yargs-parser';
import * as rimraf from 'rimraf';
import {DISCOVERY_URL} from './download';
import {downloadDiscoveryDocs, ChangeSet} from './download';
import * as filters from './filters';
Expand Down Expand Up @@ -176,9 +175,13 @@ export class Generator {
const files: string[] = await readDir(path.join(apisPath, file));
for (const version of files) {
const parts = path.parse(version);
if (!version.endsWith('.d.ts') && parts.ext === '.ts') {
if (
!version.endsWith('.d.ts') &&
parts.ext === '.ts' &&
version !== 'index.ts'
) {
apis[file][version] = parts.name;
const desc = metadata.filter(x => x.name === file)[0].description;
const desc = metadata.find(x => x.name === file)?.description;
// generate the index.ts
const apiIdxPath = path.join(apisPath, file, 'index.ts');
const apiIndexData = {name: file, api: apis[file]};
Expand Down Expand Up @@ -282,9 +285,6 @@ async function main() {
console.log('Generated API for ' + url);
});
} else {
console.log('Removing old APIs...');
const apiPath = path.join(__dirname, '../../../src/apis');
await util.promisify(rimraf)(apiPath);
console.log('Generating APIs...');
await gen.generateAllAPIs(discoveryUrl || DISCOVERY_URL, useCache);
console.log('Finished generating APIs!');
Expand Down
8 changes: 0 additions & 8 deletions src/generator/synth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import * as execa from 'execa';
import * as path from 'path';
import * as fs from 'fs';
import * as gaxios from 'gaxios';
import * as rimraf from 'rimraf';
import * as util from 'util';
import * as minimist from 'yargs-parser';
import {Generator} from './generator';
import {DISCOVERY_URL, ChangeSet} from './download';
Expand All @@ -33,10 +31,6 @@ export interface Changelog {
semverity: Semverity;
}

export const gfs = {
rimraf: util.promisify(rimraf),
};

export interface SynthOptions {
useCache?: boolean;
}
Expand All @@ -46,8 +40,6 @@ export async function synth(options: SynthOptions = {}) {
let changeSets: ChangeSet[] = [];
if (!options.useCache) {
console.log('Removing old APIs...');
const apiPath = path.join(__dirname, '../../../src/apis');
await gfs.rimraf(apiPath);
changeSets = await gen.generateAllAPIs(DISCOVERY_URL, false);
}
const statusResult = await execa('git', ['status', '--porcelain']);
Expand Down
2 changes: 0 additions & 2 deletions test/test.synth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ describe(__filename, () => {
modified: src/apis/blogger/v1.ts
`;
process.env.GITHUB_TOKEN = '12345';
sandbox.stub(synth.gfs, 'rimraf').resolves();
const scope = nock('https://api.github.com')
.post('/repos/googleapis/google-api-nodejs-client/pulls')
.reply(200);
Expand All @@ -84,7 +83,6 @@ describe(__filename, () => {

it('should throw if no token is provided', async () => {
process.env.GITHUB_TOKEN = '';
sandbox.stub(synth.gfs, 'rimraf').resolves();
await assert.rejects(synth.synth, /please include a GITHUB_TOKEN/);
});

Expand Down

0 comments on commit d74bb34

Please sign in to comment.