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

build!: drop support for node.js 8.x #1239

Merged
merged 1 commit into from
Apr 12, 2020
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
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
**/node_modules
src/**/doc/*
build/
docs/
protos/
test/fixtures
src/plugins/types
15 changes: 0 additions & 15 deletions .eslintrc.yml

This file was deleted.

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: [8, 10, 12, 13]
node: [10, 12, 13]
# Docker containers to run for database RPC tracing integration tests.
services:
mongo:
Expand Down
9 changes: 6 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
node_modules/*
samples/node_modules/*
src/**/doc/*
**/node_modules
build/
docs/
protos/
test/fixtures
src/plugins/types
8 changes: 0 additions & 8 deletions .prettierrc

This file was deleted.

17 changes: 0 additions & 17 deletions AUTHORS

This file was deleted.

36 changes: 0 additions & 36 deletions appveyor.yml

This file was deleted.

2 changes: 0 additions & 2 deletions codecov.yml

This file was deleted.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
"repository": "googleapis/cloud-trace-nodejs",
"scripts": {
"init-test-fixtures": "npm run script init-test-fixtures",
"test": "npm run script npm-check npm-compile npm-init-test-fixtures npm-unit-test npm-license-check",
"test": "npm run script npm-compile npm-init-test-fixtures npm-unit-test npm-license-check",
"unit-test": "npm run script run-unit-tests",
"non-interference": "npm run script test-non-interference",
"presystem-test": "npm run compile",
"system-test": "c8 mocha build/system-test --timeout 60000",
"check-install": "npm run script check-install",
"get-plugin-types": "npm run script get-plugin-types",
"coverage": "npm run script run-unit-tests-with-coverage report-coverage",
"check": "gts check",
"lint": "gts check",
"clean": "rimraf build/src",
"compile-all": "npm run script compile-auto",
Expand Down Expand Up @@ -51,7 +50,7 @@
"author": "Google Inc.",
"license": "Apache-2.0",
"engines": {
"node": ">=8.10.0"
"node": ">=10"
},
"devDependencies": {
"@compodoc/compodoc": "1.1.11",
Expand Down Expand Up @@ -85,7 +84,7 @@
"gaxios": "^3.0.2",
"glob": "^7.0.3",
"grpc": "1.24.2",
"gts": "^1.0.0",
"gts": "^2.0.0",
"js-green-licenses": "^1.0.0",
"linkinator": "^2.0.0",
"mocha": "^7.0.0",
Expand All @@ -108,6 +107,7 @@
"continuation-local-storage": "^3.2.1",
"extend": "^3.0.2",
"gcp-metadata": "^4.0.0",
"google-auth-library": "^6.0.0",
"hex2dec": "^1.0.1",
"is": "^3.2.0",
"methods": "^1.1.1",
Expand Down
16 changes: 5 additions & 11 deletions samples/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,12 @@ const DISCOVERY_URL = 'https://www.googleapis.com/discovery/v1/apis';
app.get('/', async (req, res) => {
// This outgoing HTTP request should be captured by Trace
try {
const { body } = await got(DISCOVERY_URL, { json: true });
const names = body.items.map((item) => item.name);
res
.status(200)
.send(names.join('\n'))
.end();
}
catch (err) {
const {body} = await got(DISCOVERY_URL, {json: true});
const names = body.items.map(item => item.name);
res.status(200).send(names.join('\n')).end();
} catch (err) {
console.error(err);
res
.status(500)
.end();
res.status(500).end();
}
});

Expand Down
5 changes: 4 additions & 1 deletion samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
"type": "git",
"url": "https://github.com/googleapis/cloud-trace-nodejs.git"
},
"files": [
"*.js"
],
"engines": {
"node": ">=8"
"node": ">=10"
},
"scripts": {
"deploy": "gcloud app deploy",
Expand Down
2 changes: 1 addition & 1 deletion samples/snippets.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
// [START trace_setup_nodejs_explicit]
require('@google-cloud/trace-agent').start({
projectId: 'your-project-id',
keyFilename: '/path/to/key.json'
keyFilename: '/path/to/key.json',
});
// [END trace_setup_nodejs_explicit]
11 changes: 5 additions & 6 deletions samples/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
'use strict';

const execa = require('execa');
const {describe, it} = require('mocha');

describe('trace samples', () => {

it('should run the quickstart', done => {
// select a random port between 49152 and 65535
const PORT = Math.floor((Math.random() * (65535-49152))) + 49152;
const PORT = Math.floor(Math.random() * (65535 - 49152)) + 49152;
const proc = execa('node', ['app.js'], {
env: {
PORT
}
PORT,
},
});
proc.stdout.on('data', message => {
// Listen to stdout and look for messages. If we get a `Press CTRL+...`
Expand All @@ -37,11 +37,10 @@ describe('trace samples', () => {
done();
}, 1000);
}
})
});
proc.stderr.on('data', message => {
// if anything comes through stderr, assume a bug
done(new Error(message.toString('utf8')));
});
});

});
54 changes: 41 additions & 13 deletions scripts/check-install.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
// Copyright 2017 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
//
// http://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 cpy from 'cpy';
import * as path from 'path';
import { globP, spawnP, tmpDirP } from './utils';
import {globP, spawnP, tmpDirP} from './utils';

/**
* Get the major version number of the current Node process.
Expand All @@ -25,31 +39,45 @@ export async function checkInstall() {
// in your current working directory.
const tgz = await globP(`${process.cwd()}/*.tgz`);
if (tgz.length !== 1) {
throw new Error(`Expected 1 tgz file in current directory, but found ${tgz.length}`);
throw new Error(
`Expected 1 tgz file in current directory, but found ${tgz.length}`
);
}
// Initialize a new npm package.json in the temp directory.
await spawnP('npm', ['init', '-y'], {
cwd: installDir
cwd: installDir,
});
// Install the tgz file as a package, along with necessities.
// @types/node version should match the current process version, but clamped
// at >=9 (because of http2 types) and <11 (because Node 11 doesn't yet have
// type definitions).
const nodeTypesVersion = Math.min(Math.max(getNodeMajorVersion(), 9), 10);
await spawnP('npm', ['install', 'typescript', `@types/node@${nodeTypesVersion}`, tgz[0]], {
cwd: installDir
});
await spawnP(
'npm',
['install', 'typescript', `@types/node@${nodeTypesVersion}`, tgz[0]],
{
cwd: installDir,
}
);
// Create an entry point for the package created in the temp directory
// use-module.ts is a fixture that imports the Trace Agent
await cpy('./test/fixtures/use-module.ts', installDir, { rename: 'index.ts' });
await cpy('./test/fixtures/use-module.ts', installDir, {rename: 'index.ts'});
// Compile it
await spawnP(`node_modules${path.sep}.bin${path.sep}tsc`, ['index.ts', '--lib', 'es2015'], {
cwd: installDir
});
await spawnP(
`node_modules${path.sep}.bin${path.sep}tsc`,
['index.ts', '--lib', 'es2015'],
{
cwd: installDir,
}
);
console.log('`npm install` + `tsc` test was successful.');
// Evaluate require('..').start() in Node.
await spawnP(`node`, ['-e', `"require('@google-cloud/trace-agent').start()"`], {
cwd: installDir
});
await spawnP(
'node',
['-e', '"require(\'@google-cloud/trace-agent\').start()"'],
{
cwd: installDir,
}
);
console.log('require + start test was successful.');
}
30 changes: 22 additions & 8 deletions scripts/compile.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
import * as path from 'path';
import { forkP } from './utils';
import * as ts from 'typescript';
// Copyright 2017 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
//
// http://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 {forkP} from './utils';
import * as semver from 'semver';

export interface CompileOptions {
Expand All @@ -9,14 +21,16 @@ export interface CompileOptions {
}

export async function compile(options: CompileOptions) {
let { strict, languageLevel } = options;
let {languageLevel} = options;
if (languageLevel === 'auto') {
languageLevel = semver.satisfies(process.version, '>=7.5') ? 'es2017' : 'es2015';
languageLevel = semver.satisfies(process.version, '>=7.5')
? 'es2017'
: 'es2015';
}
await forkP(`node_modules/typescript/lib/tsc`, [
await forkP('node_modules/typescript/lib/tsc', [
'-p',
strict ? '.' : './tsconfig.full.json',
options.strict ? '.' : './tsconfig.full.json',
'--target',
languageLevel
languageLevel,
]);
}
25 changes: 21 additions & 4 deletions scripts/credentials.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
import { createCipheriv, createDecipheriv, randomBytes } from 'crypto';
import { createReadStream, createWriteStream } from 'fs';
// Copyright 2017 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
//
// http://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 {createCipheriv, createDecipheriv, randomBytes} from 'crypto';
import {createReadStream, createWriteStream} from 'fs';

export interface KeyAndIV {
key: string;
Expand Down Expand Up @@ -28,10 +42,13 @@ export async function encryptCredentials(filename: string): Promise<KeyAndIV> {
.on('error', reject)
.on('finish', resolve);
});
return { key, iv };
return {key, iv};
}

export async function decryptCredentials({ key, iv }: KeyAndIV, filename: string) {
export async function decryptCredentials(
{key, iv}: KeyAndIV,
filename: string
) {
const decipher = createDecipheriv(
'aes-256-cbc',
Buffer.from(key, 'hex'),
Expand Down
Loading