Skip to content

Commit

Permalink
fix: do not exclude d.ts files, and add install test (#545)
Browse files Browse the repository at this point in the history
  • Loading branch information
AVaksman authored and callmehiphop committed Sep 25, 2019
1 parent 3acf841 commit 60acdf8
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 1 deletion.
5 changes: 4 additions & 1 deletion package.json
Expand Up @@ -22,7 +22,6 @@
"build/protos",
"build/proto",
"build/src",
"!**/*.d.ts",
"!**/*.map"
],
"main": "build/src/index.js",
Expand Down Expand Up @@ -75,6 +74,8 @@
"@types/is": "0.0.21",
"@types/lodash.snakecase": "^4.1.5",
"@types/mocha": "^5.2.6",
"@types/mv": "^2.1.0",
"@types/ncp": "^2.0.1",
"@types/proxyquire": "^1.3.28",
"@types/pumpify": "^1.4.1",
"@types/sinon": "^7.0.7",
Expand All @@ -92,6 +93,8 @@
"linkinator": "^1.5.0",
"mkdirp": "^0.5.1",
"mocha": "^6.0.0",
"mv": "^2.1.1",
"npc": "0.0.1",
"nyc": "^14.0.0",
"p-queue": "^6.0.2",
"power-assert": "^1.4.4",
Expand Down
23 changes: 23 additions & 0 deletions system-test/fixtures/sample/package.json
@@ -0,0 +1,23 @@
{
"name": "bigtable-sample-fixture",
"description": "An app we're using to test the library.",
"scripts": {
"check": "gts check",
"clean": "gts clean",
"compile": "tsc -p .",
"fix": "gts fix",
"prepare": "npm run compile",
"pretest": "npm run compile",
"posttest": "npm run check",
"start": "node build/src/index.js"
},
"license": "Apache-2.0",
"dependencies": {
"@google-cloud/bigtable": "file:./bigtable.tgz"
},
"devDependencies": {
"@types/node": "^10.3.0",
"typescript": "^3.0.0",
"gts": "^1.0.0"
}
}
22 changes: 22 additions & 0 deletions system-test/fixtures/sample/src/index.ts
@@ -0,0 +1,22 @@
/**
* Copyright 2019 Google LLC. All Rights Reserved.
*
* 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 {Bigtable} from '@google-cloud/bigtable';
async function main() {
const bigtable = new Bigtable();
console.log(bigtable);
}
main();
11 changes: 11 additions & 0 deletions system-test/fixtures/sample/tsconfig.json
@@ -0,0 +1,11 @@
{
"extends": "./node_modules/gts/tsconfig-google.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "build",
"types": ["node"]
},
"include": [
"src/*.ts"
]
}
59 changes: 59 additions & 0 deletions system-test/install.ts
@@ -0,0 +1,59 @@
/**
* Copyright 2019 Google LLC. All Rights Reserved.
*
* 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 execa from 'execa';
import * as mv from 'mv';
import {ncp} from 'ncp';
import * as tmp from 'tmp';
import {promisify} from 'util';

const keep = false;
const mvp = (promisify(mv) as {}) as (...args: string[]) => Promise<void>;
const ncpp = promisify(ncp);
const stagingDir = tmp.dirSync({keep, unsafeCleanup: true});
const stagingPath = stagingDir.name;

const pkg = require('../../package.json');

describe('📦 pack and install', () => {
/**
* Create a staging directory with temp fixtures used to test on a fresh
* application.
*/
it('should be able to use the d.ts', async () => {
await execa('npm', ['pack', '--unsafe-perm']);
const tarball = `google-cloud-bigtable-${pkg.version}.tgz`;
await mvp(tarball, `${stagingPath}/bigtable.tgz`);
await ncpp('system-test/fixtures/sample', `${stagingPath}/`);
await execa('npm', ['install', '--unsafe-perm'], {
cwd: `${stagingPath}/`,
stdio: 'inherit',
});
await execa('node', ['--throw-deprecation', 'build/src/index.js'], {
cwd: `${stagingPath}/`,
stdio: 'inherit',
});
});

/**
* CLEAN UP - remove the staging directory when done.
*/
after('cleanup staging', () => {
if (!keep) {
stagingDir.removeCallback();
}
});
});

0 comments on commit 60acdf8

Please sign in to comment.