Skip to content

Commit

Permalink
fix: add missing package, and add install test (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith committed Mar 6, 2019
1 parent e26692b commit 63b89e9
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 2 deletions.
13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"dependencies": {
"@google-cloud/projectify": "^0.3.2",
"@google-cloud/promisify": "^0.4.0",
"@types/duplexify": "^3.6.0",
"arrify": "^1.0.1",
"concat-stream": "^2.0.0",
"extend": "^3.0.1",
Expand All @@ -62,30 +63,38 @@
"@google-cloud/nodejs-repo-tools": "^3.0.0",
"@types/arrify": "^1.0.4",
"@types/async": "^2.0.50",
"@types/execa": "^0.9.0",
"@types/extend": "^3.0.0",
"@types/is": "0.0.21",
"@types/mocha": "^5.2.5",
"@types/mv": "^2.1.0",
"@types/ncp": "^2.0.1",
"@types/proxyquire": "^1.3.28",
"@types/sinon": "^7.0.2",
"@types/through2": "^2.0.34",
"@types/tmp": "0.0.34",
"assert-rejects": "^1.0.0",
"codecov": "^3.0.2",
"eslint": "^5.0.0",
"eslint-config-prettier": "^4.0.0",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-prettier": "^3.0.0",
"execa": "^1.0.0",
"google-proto-files": "^0.18.0",
"gts": "^0.9.0",
"intelli-espower-loader": "^1.0.1",
"jsdoc": "^3.5.5",
"jsdoc-baseline": "git+https://github.com/hegemonic/jsdoc-baseline.git",
"linkinator": "^1.1.2",
"mocha": "^6.0.0",
"mv": "^2.1.1",
"npc": "0.0.1",
"nyc": "^13.0.0",
"power-assert": "^1.5.0",
"prettier": "^1.13.5",
"proxyquire": "^2.0.1",
"sinon": "^7.0.0",
"typescript": "~3.3.0",
"linkinator": "^1.1.2"
"tmp": "0.0.33",
"typescript": "~3.3.0"
}
}
23 changes: 23 additions & 0 deletions system-test/fixtures/sample/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "datastore-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/datastore": "file:./datastore.tgz"
},
"devDependencies": {
"@types/node": "^10.3.0",
"typescript": "^3.0.0",
"gts": "^0.9.0"
}
}
6 changes: 6 additions & 0 deletions system-test/fixtures/sample/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {Datastore} from '@google-cloud/datastore';
async function main() {
const datastore = new Datastore();
console.log(datastore);
}
main();
10 changes: 10 additions & 0 deletions system-test/fixtures/sample/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./node_modules/gts/tsconfig-google.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "build"
},
"include": [
"src/*.ts"
]
}
56 changes: 56 additions & 0 deletions system-test/install.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* 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-datastore-${pkg.version}.tgz`;
await mvp(tarball, `${stagingPath}/datastore.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 63b89e9

Please sign in to comment.