From 2073aa9abcdaee04834b972bbafb455260a67e99 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 24 Jul 2018 15:19:57 +0200 Subject: Test installation on latest version, not the packed one --- packages/monorepo-scripts/src/test_installation.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'packages/monorepo-scripts/src/test_installation.ts') diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index 668d4ef1d..52868483f 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -16,16 +16,14 @@ import { utils } from './utils/utils'; pkg => !pkg.packageJson.private && !_.isUndefined(pkg.packageJson.main) && pkg.packageJson.main.endsWith('.js'), ); for (const installablePackage of installablePackages) { - const packagePath = installablePackage.location; const packageName = installablePackage.packageJson.name; + const packageVersion = installablePackage.packageJson.version; 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 }); + let result = await execAsync('yarn init --yes', { cwd: testDirectory }); + utils.log(`Installing ${packageName}@${packageVersion}`); + result = await execAsync(`yarn add ${packageName}@${packageVersion}`, { cwd: testDirectory }); const indexFilePath = path.join(testDirectory, 'index.ts'); fs.writeFileSync(indexFilePath, `import * as Package from '${packageName}';\n`); const tsConfig = { -- cgit v1.2.3 From 24aa5cd1bf38197a72be32a53f2e4a7c9aaf58ef Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 24 Jul 2018 16:08:07 +0200 Subject: Make the test:installation work with the local npm registry --- packages/monorepo-scripts/src/test_installation.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'packages/monorepo-scripts/src/test_installation.ts') diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index 52868483f..a9610e5ee 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -10,20 +10,27 @@ import { utils } from './utils/utils'; (async () => { const monorepoRootPath = path.join(__dirname, '../../..'); - const packages = utils.getPackages(monorepoRootPath); + const packages = utils.getTopologicallySortedPackages(monorepoRootPath); const installablePackages = _.filter( packages, pkg => !pkg.packageJson.private && !_.isUndefined(pkg.packageJson.main) && pkg.packageJson.main.endsWith('.js'), ); + utils.log('Testing packages:'); + _.map(installablePackages, pkg => utils.log(`* ${pkg.packageJson.name}`)); for (const installablePackage of installablePackages) { + const changelogPath = path.join(installablePackage.location, 'CHANGELOG.json'); + const lastChangelogVersion = JSON.parse(fs.readFileSync(changelogPath).toString())[0].version; const packageName = installablePackage.packageJson.name; - const packageVersion = installablePackage.packageJson.version; utils.log(`Testing ${packageName}`); const testDirectory = path.join(monorepoRootPath, '../test-env'); fs.mkdirSync(testDirectory); - let result = await execAsync('yarn init --yes', { cwd: testDirectory }); - utils.log(`Installing ${packageName}@${packageVersion}`); - result = await execAsync(`yarn add ${packageName}@${packageVersion}`, { cwd: testDirectory }); + await execAsync('yarn init --yes', { cwd: testDirectory }); + const npmrcFilePath = path.join(testDirectory, '.npmrc'); + fs.writeFileSync(npmrcFilePath, `registry=http://localhost:4873`); + utils.log(`Installing ${packageName}@${lastChangelogVersion}`); + await execAsync(`npm install --save ${packageName}@${lastChangelogVersion} --registry=http://localhost:4873`, { + cwd: testDirectory, + }); const indexFilePath = path.join(testDirectory, 'index.ts'); fs.writeFileSync(indexFilePath, `import * as Package from '${packageName}';\n`); const tsConfig = { -- cgit v1.2.3 From e320f343f8d18a301bc1d74dcb2816e3d1e3be6f Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 26 Jul 2018 14:14:14 +0200 Subject: Add support for testing installations post-publish as well --- packages/monorepo-scripts/src/test_installation.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'packages/monorepo-scripts/src/test_installation.ts') diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index a9610e5ee..12c0e7603 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -9,6 +9,8 @@ import * as rimraf from 'rimraf'; import { utils } from './utils/utils'; (async () => { + const IS_LOCAL_PUBLISH = process.env.IS_LOCAL_PUBLISH === 'true'; + const registry = IS_LOCAL_PUBLISH ? 'http://localhost:4873' : 'https://registry.npmjs.org'; const monorepoRootPath = path.join(__dirname, '../../..'); const packages = utils.getTopologicallySortedPackages(monorepoRootPath); const installablePackages = _.filter( @@ -26,9 +28,9 @@ import { utils } from './utils/utils'; fs.mkdirSync(testDirectory); await execAsync('yarn init --yes', { cwd: testDirectory }); const npmrcFilePath = path.join(testDirectory, '.npmrc'); - fs.writeFileSync(npmrcFilePath, `registry=http://localhost:4873`); + fs.writeFileSync(npmrcFilePath, `registry=${registry}`); utils.log(`Installing ${packageName}@${lastChangelogVersion}`); - await execAsync(`npm install --save ${packageName}@${lastChangelogVersion} --registry=http://localhost:4873`, { + await execAsync(`npm install --save ${packageName}@${lastChangelogVersion} --registry=${registry}`, { cwd: testDirectory, }); const indexFilePath = path.join(testDirectory, 'index.ts'); -- cgit v1.2.3 From d3be4f2852ca5bb35e50d27403715354b7485c4b Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 26 Jul 2018 14:22:51 +0200 Subject: Add ending slash --- packages/monorepo-scripts/src/test_installation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/monorepo-scripts/src/test_installation.ts') diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index 12c0e7603..55ff12083 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -10,7 +10,7 @@ import { utils } from './utils/utils'; (async () => { const IS_LOCAL_PUBLISH = process.env.IS_LOCAL_PUBLISH === 'true'; - const registry = IS_LOCAL_PUBLISH ? 'http://localhost:4873' : 'https://registry.npmjs.org'; + const registry = IS_LOCAL_PUBLISH ? 'http://localhost:4873/' : 'https://registry.npmjs.org/'; const monorepoRootPath = path.join(__dirname, '../../..'); const packages = utils.getTopologicallySortedPackages(monorepoRootPath); const installablePackages = _.filter( -- cgit v1.2.3 From 9947e643d0b201a0dad122fbe1a6f4a226469944 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 26 Jul 2018 14:23:07 +0200 Subject: Print version that will be tested --- packages/monorepo-scripts/src/test_installation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/monorepo-scripts/src/test_installation.ts') diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index 55ff12083..1d9e3569d 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -23,7 +23,7 @@ import { utils } from './utils/utils'; const changelogPath = path.join(installablePackage.location, 'CHANGELOG.json'); const lastChangelogVersion = JSON.parse(fs.readFileSync(changelogPath).toString())[0].version; const packageName = installablePackage.packageJson.name; - utils.log(`Testing ${packageName}`); + utils.log(`Testing ${packageName}@${lastChangelogVersion}`); const testDirectory = path.join(monorepoRootPath, '../test-env'); fs.mkdirSync(testDirectory); await execAsync('yarn init --yes', { cwd: testDirectory }); -- cgit v1.2.3 From af4071e119b4cb651ae311ea1200fdd76f8123e7 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 26 Jul 2018 14:23:45 +0200 Subject: Delete any remenants of test-env dir before creating a new one --- packages/monorepo-scripts/src/test_installation.ts | 1 + 1 file changed, 1 insertion(+) (limited to 'packages/monorepo-scripts/src/test_installation.ts') diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index 1d9e3569d..b10db5a06 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -25,6 +25,7 @@ import { utils } from './utils/utils'; const packageName = installablePackage.packageJson.name; utils.log(`Testing ${packageName}@${lastChangelogVersion}`); const testDirectory = path.join(monorepoRootPath, '../test-env'); + rimraf.sync(testDirectory); fs.mkdirSync(testDirectory); await execAsync('yarn init --yes', { cwd: testDirectory }); const npmrcFilePath = path.join(testDirectory, '.npmrc'); -- cgit v1.2.3 From e3cfa6363daf8b46b231fb38fc1bf6c8e13db17b Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 26 Jul 2018 15:32:30 +0200 Subject: Change test:installation so it also causes run-time errors to appear --- packages/monorepo-scripts/src/test_installation.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'packages/monorepo-scripts/src/test_installation.ts') diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index b10db5a06..4c92d0aa2 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -13,11 +13,14 @@ import { utils } from './utils/utils'; const registry = IS_LOCAL_PUBLISH ? 'http://localhost:4873/' : 'https://registry.npmjs.org/'; const monorepoRootPath = path.join(__dirname, '../../..'); const packages = utils.getTopologicallySortedPackages(monorepoRootPath); - const installablePackages = _.filter( + const preInstallablePackages = _.filter( packages, pkg => !pkg.packageJson.private && !_.isUndefined(pkg.packageJson.main) && pkg.packageJson.main.endsWith('.js'), ); utils.log('Testing packages:'); + const installablePackages = _.filter(preInstallablePackages, pkg => { + return pkg.packageJson.name === '0x.js'; + }); _.map(installablePackages, pkg => utils.log(`* ${pkg.packageJson.name}`)); for (const installablePackage of installablePackages) { const changelogPath = path.join(installablePackage.location, 'CHANGELOG.json'); @@ -35,7 +38,7 @@ import { utils } from './utils/utils'; cwd: testDirectory, }); const indexFilePath = path.join(testDirectory, 'index.ts'); - fs.writeFileSync(indexFilePath, `import * as Package from '${packageName}';\n`); + fs.writeFileSync(indexFilePath, `import * as Package from '${packageName}';\nconsole.log(Package);\n`); const tsConfig = { compilerOptions: { typeRoots: ['node_modules/@0xproject/typescript-typings/types', 'node_modules/@types'], @@ -55,7 +58,11 @@ import { utils } from './utils/utils'; const tscBinaryPath = path.join(monorepoRootPath, './node_modules/typescript/bin/tsc'); await execAsync(tscBinaryPath, { cwd: testDirectory }); utils.log(`Successfully compiled with ${packageName} as a dependency`); - rimraf.sync(testDirectory); + const transpiledIndexFilePath = path.join(testDirectory, 'index.js'); + utils.log(`Running test script with ${packageName} imported`); + await execAsync(`node ${transpiledIndexFilePath}`); + utils.log(`Successfilly ran test script with ${packageName} imported`); + // rimraf.sync(testDirectory); } })().catch(err => { utils.log(err.stderr); -- cgit v1.2.3 From 735bc2f1789384c33c38db011148e5a98e7ba74e Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 26 Jul 2018 15:32:53 +0200 Subject: Re-enable deleted the dir after test runs --- packages/monorepo-scripts/src/test_installation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/monorepo-scripts/src/test_installation.ts') diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index 4c92d0aa2..d1f5ce655 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -62,7 +62,7 @@ import { utils } from './utils/utils'; utils.log(`Running test script with ${packageName} imported`); await execAsync(`node ${transpiledIndexFilePath}`); utils.log(`Successfilly ran test script with ${packageName} imported`); - // rimraf.sync(testDirectory); + rimraf.sync(testDirectory); } })().catch(err => { utils.log(err.stderr); -- cgit v1.2.3 From a90f434df5718f45b8eb367a8fabde97ee3d0513 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 26 Jul 2018 15:58:35 +0200 Subject: Split running packages that cannot be run in a node.js script --- packages/monorepo-scripts/src/test_installation.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'packages/monorepo-scripts/src/test_installation.ts') diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index d1f5ce655..bbaf9b056 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -8,6 +8,14 @@ import * as rimraf from 'rimraf'; import { utils } from './utils/utils'; +// Packages might not be runnable if they are command-line tools or only run in browsers. +const UNRUNNABLE_PACKAGES = [ + '@0xproject/abi-gen', + '@0xproject/sra-report', + '@0xproject/react-shared', + '@0xproject/react-docs', +]; + (async () => { const IS_LOCAL_PUBLISH = process.env.IS_LOCAL_PUBLISH === 'true'; const registry = IS_LOCAL_PUBLISH ? 'http://localhost:4873/' : 'https://registry.npmjs.org/'; @@ -19,7 +27,7 @@ import { utils } from './utils/utils'; ); utils.log('Testing packages:'); const installablePackages = _.filter(preInstallablePackages, pkg => { - return pkg.packageJson.name === '0x.js'; + return !_.includes(UNRUNNABLE_PACKAGES, pkg.packageJson.name); }); _.map(installablePackages, pkg => utils.log(`* ${pkg.packageJson.name}`)); for (const installablePackage of installablePackages) { -- cgit v1.2.3 From 0187e0c47df98bac67da135b55e2630e25ffd513 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 26 Jul 2018 16:20:20 +0200 Subject: Still test unrunnable packages for compilation issues --- packages/monorepo-scripts/src/test_installation.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'packages/monorepo-scripts/src/test_installation.ts') diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index bbaf9b056..a8ddf0c58 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -21,14 +21,11 @@ const UNRUNNABLE_PACKAGES = [ const registry = IS_LOCAL_PUBLISH ? 'http://localhost:4873/' : 'https://registry.npmjs.org/'; const monorepoRootPath = path.join(__dirname, '../../..'); const packages = utils.getTopologicallySortedPackages(monorepoRootPath); - const preInstallablePackages = _.filter( + const installablePackages = _.filter( packages, pkg => !pkg.packageJson.private && !_.isUndefined(pkg.packageJson.main) && pkg.packageJson.main.endsWith('.js'), ); utils.log('Testing packages:'); - const installablePackages = _.filter(preInstallablePackages, pkg => { - return !_.includes(UNRUNNABLE_PACKAGES, pkg.packageJson.name); - }); _.map(installablePackages, pkg => utils.log(`* ${pkg.packageJson.name}`)); for (const installablePackage of installablePackages) { const changelogPath = path.join(installablePackage.location, 'CHANGELOG.json'); @@ -66,10 +63,13 @@ const UNRUNNABLE_PACKAGES = [ const tscBinaryPath = path.join(monorepoRootPath, './node_modules/typescript/bin/tsc'); await execAsync(tscBinaryPath, { cwd: testDirectory }); utils.log(`Successfully compiled with ${packageName} as a dependency`); - const transpiledIndexFilePath = path.join(testDirectory, 'index.js'); - utils.log(`Running test script with ${packageName} imported`); - await execAsync(`node ${transpiledIndexFilePath}`); - utils.log(`Successfilly ran test script with ${packageName} imported`); + const isUnrunnablePkg = _.includes(UNRUNNABLE_PACKAGES, packageName); + if (!isUnrunnablePkg) { + const transpiledIndexFilePath = path.join(testDirectory, 'index.js'); + utils.log(`Running test script with ${packageName} imported`); + await execAsync(`node ${transpiledIndexFilePath}`); + utils.log(`Successfilly ran test script with ${packageName} imported`); + } rimraf.sync(testDirectory); } })().catch(err => { -- cgit v1.2.3