Make the test:installation work with the local npm registry

This commit is contained in:
Leonid Logvinov
2018-07-24 16:08:07 +02:00
parent f699da90ba
commit 24aa5cd1bf
2 changed files with 13 additions and 5 deletions

View File

@@ -42,6 +42,7 @@
"typescript": "2.7.1"
},
"dependencies": {
"@lerna/batch-packages": "^3.0.0-beta.18",
"@types/depcheck": "^0.6.0",
"async-child-process": "^1.1.1",
"chalk": "^2.3.0",

View File

@@ -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 = {