Skip to content

Commit 60acdf8

Browse files
AVaksmancallmehiphop
authored andcommitted
fix: do not exclude d.ts files, and add install test (#545)
1 parent 3acf841 commit 60acdf8

File tree

5 files changed

+119
-1
lines changed

5 files changed

+119
-1
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"build/protos",
2323
"build/proto",
2424
"build/src",
25-
"!**/*.d.ts",
2625
"!**/*.map"
2726
],
2827
"main": "build/src/index.js",
@@ -75,6 +74,8 @@
7574
"@types/is": "0.0.21",
7675
"@types/lodash.snakecase": "^4.1.5",
7776
"@types/mocha": "^5.2.6",
77+
"@types/mv": "^2.1.0",
78+
"@types/ncp": "^2.0.1",
7879
"@types/proxyquire": "^1.3.28",
7980
"@types/pumpify": "^1.4.1",
8081
"@types/sinon": "^7.0.7",
@@ -92,6 +93,8 @@
9293
"linkinator": "^1.5.0",
9394
"mkdirp": "^0.5.1",
9495
"mocha": "^6.0.0",
96+
"mv": "^2.1.1",
97+
"npc": "0.0.1",
9598
"nyc": "^14.0.0",
9699
"p-queue": "^6.0.2",
97100
"power-assert": "^1.4.4",
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "bigtable-sample-fixture",
3+
"description": "An app we're using to test the library.",
4+
"scripts": {
5+
"check": "gts check",
6+
"clean": "gts clean",
7+
"compile": "tsc -p .",
8+
"fix": "gts fix",
9+
"prepare": "npm run compile",
10+
"pretest": "npm run compile",
11+
"posttest": "npm run check",
12+
"start": "node build/src/index.js"
13+
},
14+
"license": "Apache-2.0",
15+
"dependencies": {
16+
"@google-cloud/bigtable": "file:./bigtable.tgz"
17+
},
18+
"devDependencies": {
19+
"@types/node": "^10.3.0",
20+
"typescript": "^3.0.0",
21+
"gts": "^1.0.0"
22+
}
23+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Copyright 2019 Google LLC. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import {Bigtable} from '@google-cloud/bigtable';
18+
async function main() {
19+
const bigtable = new Bigtable();
20+
console.log(bigtable);
21+
}
22+
main();
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": "./node_modules/gts/tsconfig-google.json",
3+
"compilerOptions": {
4+
"rootDir": ".",
5+
"outDir": "build",
6+
"types": ["node"]
7+
},
8+
"include": [
9+
"src/*.ts"
10+
]
11+
}

system-test/install.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* Copyright 2019 Google LLC. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import * as execa from 'execa';
18+
import * as mv from 'mv';
19+
import {ncp} from 'ncp';
20+
import * as tmp from 'tmp';
21+
import {promisify} from 'util';
22+
23+
const keep = false;
24+
const mvp = (promisify(mv) as {}) as (...args: string[]) => Promise<void>;
25+
const ncpp = promisify(ncp);
26+
const stagingDir = tmp.dirSync({keep, unsafeCleanup: true});
27+
const stagingPath = stagingDir.name;
28+
29+
const pkg = require('../../package.json');
30+
31+
describe('📦 pack and install', () => {
32+
/**
33+
* Create a staging directory with temp fixtures used to test on a fresh
34+
* application.
35+
*/
36+
it('should be able to use the d.ts', async () => {
37+
await execa('npm', ['pack', '--unsafe-perm']);
38+
const tarball = `google-cloud-bigtable-${pkg.version}.tgz`;
39+
await mvp(tarball, `${stagingPath}/bigtable.tgz`);
40+
await ncpp('system-test/fixtures/sample', `${stagingPath}/`);
41+
await execa('npm', ['install', '--unsafe-perm'], {
42+
cwd: `${stagingPath}/`,
43+
stdio: 'inherit',
44+
});
45+
await execa('node', ['--throw-deprecation', 'build/src/index.js'], {
46+
cwd: `${stagingPath}/`,
47+
stdio: 'inherit',
48+
});
49+
});
50+
51+
/**
52+
* CLEAN UP - remove the staging directory when done.
53+
*/
54+
after('cleanup staging', () => {
55+
if (!keep) {
56+
stagingDir.removeCallback();
57+
}
58+
});
59+
});

0 commit comments

Comments
 (0)