Skip to content

Commit aefdd28

Browse files
committed
Fail CI on PRs with empty initialized packages
1 parent ea53ee5 commit aefdd28

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

bin/lint-packages.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ const findCommands = (folder: string, scope: string): string[] => {
102102
} catch (e) {
103103
if (e instanceof Error && e.message.includes('no such file or directory')) {
104104
const alternateFile = path.join('packages/base/src/commands', scope, 'cli.ts')
105-
console.log(chalk.yellow(`Could not find commands in ${chalk.bold(folder)}, this means it's being migrated...`))
106-
console.log(chalk.yellow(`Reading imports in ${chalk.bold(alternateFile)} instead.\n`))
105+
console.log(chalk.yellow(`Could not find commands in ${chalk.bold(folder)}. A migration may be in progress...`))
106+
console.log(chalk.yellow(`Trying to read imports in ${chalk.bold(alternateFile)} instead.\n`))
107107

108108
const content = fs.readFileSync(alternateFile, 'utf8')
109109

@@ -218,10 +218,19 @@ const pluginPackages = fs
218218
.readdirSync('packages')
219219
.filter((dir) => dir.startsWith('plugin-'))
220220
.map((dir) => {
221+
let loadedPackage: Package
221222
try {
222-
const {folder, packageJson} = loadPackage(dir)
223+
loadedPackage = loadPackage(dir)
224+
} catch {
225+
console.log(chalk.yellow(`Could not load ${chalk.bold(dir)} package. Skipping it...\n`))
226+
227+
return undefined
228+
}
229+
230+
const {folder, packageJson} = loadedPackage
231+
const scope = dir.replace('plugin-', '')
223232

224-
const scope = dir.replace('plugin-', '')
233+
try {
225234
const commands = findCommands(folder, scope)
226235

227236
return {
@@ -231,9 +240,11 @@ const pluginPackages = fs
231240
commands,
232241
}
233242
} catch {
234-
console.log(chalk.yellow(`Could not load ${chalk.bold(dir)} package. Skipping it...\n`))
235-
236-
return undefined
243+
console.log(chalk.bold.red(`Invalid state for ${folder}.`))
244+
console.log(
245+
`Did you recently run ${chalk.bold(`bin/init-package.sh ${scope}`)}? Please either run ${chalk.bold(`bin/migrate.sh ${scope}`)} and finish the migration, or complete the structure of the plugin before merging your PR.`
246+
)
247+
process.exit(1)
237248
}
238249
})
239250
.filter((p): p is PluginPackage => p !== undefined)

0 commit comments

Comments
 (0)