Skip to content

Commit

Permalink
build!: update library to use Node 12 (#428)
Browse files Browse the repository at this point in the history
* feat!: Update library to use Node 12
* 🦉 Updates from OwlBot post-processor
See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
sofisl and gcf-owl-bot[bot] authored May 10, 2022
1 parent e5667b1 commit 288b662
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 160 deletions.
2 changes: 1 addition & 1 deletion .github/sync-repo-settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ branchProtectionRules:
- "ci/kokoro: System test"
- docs
- lint
- test (10)
- test (12)
- test (14)
- test (16)
- cla/google
- windows
- OwlBot Post Processor
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [10, 12, 14]
node: [12, 14, 16]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand Down
34 changes: 0 additions & 34 deletions .kokoro/continuous/node10/common.cfg

This file was deleted.

4 changes: 0 additions & 4 deletions .kokoro/continuous/node10/docs.cfg

This file was deleted.

9 changes: 0 additions & 9 deletions .kokoro/continuous/node10/test.cfg

This file was deleted.

24 changes: 0 additions & 24 deletions .kokoro/continuous/node8/common.cfg

This file was deleted.

Empty file removed .kokoro/continuous/node8/test.cfg
Empty file.
34 changes: 0 additions & 34 deletions .kokoro/presubmit/node10/common.cfg

This file was deleted.

4 changes: 0 additions & 4 deletions .kokoro/presubmit/node10/docs.cfg

This file was deleted.

4 changes: 0 additions & 4 deletions .kokoro/presubmit/node10/lint.cfg

This file was deleted.

Empty file removed .kokoro/presubmit/node10/test.cfg
Empty file.
24 changes: 0 additions & 24 deletions .kokoro/presubmit/node8/common.cfg

This file was deleted.

Empty file removed .kokoro/presubmit/node8/test.cfg
Empty file.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "./build/src/index.js",
"types": "./build/src/index.d.ts",
"engines": {
"node": ">=10"
"node": ">=12.0.0"
},
"repository": "google/node-gtoken",
"scripts": {
Expand Down Expand Up @@ -51,9 +51,9 @@
"c8": "^7.0.0",
"gts": "^3.0.0",
"linkinator": "^2.0.0",
"mocha": "^8.0.0",
"mocha": "^9.2.2",
"nock": "^13.0.0",
"typescript": "^3.8.3"
"typescript": "^4.6.4"
},
"files": [
"build/src",
Expand Down
2 changes: 1 addition & 1 deletion samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"license": "MIT",
"author": "Google LLC",
"engines": {
"node": ">=8"
"node": ">=12.0.0"
},
"files": [
"*.js",
Expand Down
28 changes: 19 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
/**
* Copyright 2018 Google LLC
*
* Distributed under MIT license.
* See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import * as fs from 'fs';
import {request} from 'gaxios';
import {GaxiosError, request} from 'gaxios';
import * as jws from 'jws';
import * as path from 'path';
import {promisify} from 'util';
Expand Down Expand Up @@ -339,12 +346,15 @@ export class GoogleToken {
} catch (e) {
this.rawToken = undefined;
this.tokenExpires = undefined;
const body = e.response && e.response.data ? e.response.data : {};
const body =
(e as GaxiosError).response && (e as GaxiosError).response?.data
? (e as GaxiosError).response?.data
: {};
if (body.error) {
const desc = body.error_description
? `: ${body.error_description}`
: '';
e.message = `${body.error}${desc}`;
(e as GaxiosError).message = `${body.error}${desc}`;
}
throw e;
}
Expand Down
23 changes: 15 additions & 8 deletions test/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
/**
* Copyright 2018 Google LLC
*
* Distributed under MIT license.
* See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import * as assert from 'assert';
import {describe, it} from 'mocha';
Expand Down Expand Up @@ -246,7 +253,7 @@ describe('.revokeToken()', () => {
} catch (e) {
err = e;
}
assert(err && err.message);
assert(err && (err as Error).message);
});
});

Expand Down Expand Up @@ -603,7 +610,7 @@ describe('.getToken()', () => {
const gtoken = new GoogleToken(TESTDATA_KEYFILEJSON);
await gtoken.getCredentials(KEYFILEJSON);
} catch (err) {
message = err.message;
message = (err as Error).message;
}
assert.strictEqual(message, 'use key rather than keyFile.');
});
Expand Down

0 comments on commit 288b662

Please sign in to comment.