aboutsummaryrefslogtreecommitdiffstats
path: root/packages/monorepo-scripts/src/test_installation.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-03-28 02:16:13 +0800
committerFabio Berger <me@fabioberger.com>2018-03-28 02:16:13 +0800
commit005376276098a4e6cb832eaf5b5dbc07118e1f50 (patch)
tree543a431a5fd2a17f3b3582cfb0910f8c85357ac1 /packages/monorepo-scripts/src/test_installation.ts
parenteb89ef79eba3d044e10b8e52e20927bb88241ac2 (diff)
parent066d13f5b7260d28b13195c4f9aed48b4ae96cc3 (diff)
downloaddexon-sol-tools-005376276098a4e6cb832eaf5b5dbc07118e1f50.tar
dexon-sol-tools-005376276098a4e6cb832eaf5b5dbc07118e1f50.tar.gz
dexon-sol-tools-005376276098a4e6cb832eaf5b5dbc07118e1f50.tar.bz2
dexon-sol-tools-005376276098a4e6cb832eaf5b5dbc07118e1f50.tar.lz
dexon-sol-tools-005376276098a4e6cb832eaf5b5dbc07118e1f50.tar.xz
dexon-sol-tools-005376276098a4e6cb832eaf5b5dbc07118e1f50.tar.zst
dexon-sol-tools-005376276098a4e6cb832eaf5b5dbc07118e1f50.zip
merge developmentx
Diffstat (limited to 'packages/monorepo-scripts/src/test_installation.ts')
-rw-r--r--packages/monorepo-scripts/src/test_installation.ts58
1 files changed, 58 insertions, 0 deletions
diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts
new file mode 100644
index 000000000..195b64b2a
--- /dev/null
+++ b/packages/monorepo-scripts/src/test_installation.ts
@@ -0,0 +1,58 @@
+#!/usr/bin/env node
+
+import * as fs from 'fs';
+import lernaGetPackages = require('lerna-get-packages');
+import * as _ from 'lodash';
+import * as path from 'path';
+import { exec as execAsync } from 'promisify-child-process';
+import * as rimraf from 'rimraf';
+
+import { utils } from './utils';
+
+(async () => {
+ const monorepoRootPath = path.join(__dirname, '../../..');
+ const lernaPackages = lernaGetPackages(monorepoRootPath);
+ const installablePackages = _.filter(
+ lernaPackages,
+ lernaPackage =>
+ !lernaPackage.package.private &&
+ !_.isUndefined(lernaPackage.package.main) &&
+ lernaPackage.package.main.endsWith('.js'),
+ );
+ for (const installableLernaPackage of installablePackages) {
+ const packagePath = installableLernaPackage.location;
+ const packageName = installableLernaPackage.package.name;
+ utils.log(`Testing ${packageName}`);
+ let result = await execAsync('npm pack', { cwd: packagePath });
+ const packedPackageFileName = result.stdout.trim();
+ const testDirectory = path.join(monorepoRootPath, '../test-env');
+ fs.mkdirSync(testDirectory);
+ result = await execAsync('yarn init --yes', { cwd: testDirectory });
+ utils.log(`Installing ${packedPackageFileName}`);
+ result = await execAsync(`yarn add ${packagePath}/${packedPackageFileName}`, { cwd: testDirectory });
+ const indexFilePath = path.join(testDirectory, 'index.ts');
+ fs.writeFileSync(indexFilePath, `import * as Package from '${packageName}'`);
+ const tsConfig = {
+ compilerOptions: {
+ typeRoots: ['node_modules/@0xproject/typescript-typings/types', 'node_modules/@types'],
+ module: 'commonjs',
+ target: 'es5',
+ lib: ['es2017', 'dom'],
+ declaration: true,
+ noImplicitReturns: true,
+ pretty: true,
+ strict: true,
+ },
+ include: ['index.ts'],
+ };
+ const tsconfigFilePath = path.join(testDirectory, 'tsconfig.json');
+ fs.writeFileSync(tsconfigFilePath, JSON.stringify(tsConfig, null, 4));
+ utils.log(`Compiling ${packageName}`);
+ await execAsync('../node_modules/typescript/bin/tsc', { cwd: testDirectory });
+ utils.log(`Successfully compiled with ${packageName} as a dependency`);
+ rimraf.sync(testDirectory);
+ }
+})().catch(err => {
+ utils.log(err.stdout);
+ process.exit(1);
+});