|
| 1 | +/* eslint-disable no-console */ |
| 2 | +import * as fs from 'fs'; |
| 3 | +import * as glob from 'glob'; |
| 4 | +import * as path from 'path'; |
| 5 | + |
| 6 | +const testRecipePaths = glob.sync('test-applications/*/test-recipe.json', { |
| 7 | + cwd: __dirname, |
| 8 | + absolute: true, |
| 9 | +}); |
| 10 | + |
| 11 | +testRecipePaths.forEach(testRecipePath => { |
| 12 | + const testAppPath = path.dirname(testRecipePath); |
| 13 | + const npmrcPath = path.resolve(testAppPath, '.npmrc'); |
| 14 | + |
| 15 | + if (!fs.existsSync(npmrcPath)) { |
| 16 | + console.log( |
| 17 | + `No .npmrc found in test application "${testAppPath}". Please add a .npmrc to this test application that uses the fake test registry. (More info in packages/e2e-tests/README.md)`, |
| 18 | + ); |
| 19 | + process.exit(1); |
| 20 | + } |
| 21 | + |
| 22 | + const npmrcContents = fs.readFileSync(npmrcPath, 'utf-8'); |
| 23 | + if (!npmrcContents.includes('http://localhost:4873')) { |
| 24 | + console.log( |
| 25 | + `.npmrc in test application "${testAppPath} doesn't contain a reference to the fake test registry at "http://localhost:4873". Please add a .npmrc to this test application that uses the fake test registry. (More info in packages/e2e-tests/README.md)`, |
| 26 | + ); |
| 27 | + process.exit(1); |
| 28 | + } |
| 29 | + |
| 30 | + const gitignorePath = path.resolve(testAppPath, '.gitignore'); |
| 31 | + |
| 32 | + if (!fs.existsSync(gitignorePath)) { |
| 33 | + console.log( |
| 34 | + `No .gitignore found in test application "${testAppPath}". Please add a .gitignore to this test application that ignores any kind of lockfiles. (More info in packages/e2e-tests/README.md)`, |
| 35 | + ); |
| 36 | + process.exit(1); |
| 37 | + } |
| 38 | + |
| 39 | + const gitignoreContents = fs.readFileSync(gitignorePath, 'utf-8'); |
| 40 | + if (!gitignoreContents.includes('lock')) { |
| 41 | + console.log( |
| 42 | + `.gitignore in test application "${testAppPath} doesn't contain an entry for a lockfile. Please add a .gitignore to this test application that ignores any kind of lockfiles. (More info in packages/e2e-tests/README.md)`, |
| 43 | + ); |
| 44 | + process.exit(1); |
| 45 | + } |
| 46 | +}); |
0 commit comments