Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Check composer.json for module type #32

Conversation

GuySartorelli
Copy link
Member

Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly fine

This will be wrong on silverstripe-config which lacks a type

In case you want to double check stuff I wrote a quite script and ran this on sink

<?php

$types = [];
$unknowns = [];
$minks = [];
$composerPlugins = [];
foreach (['silverstripe', 'cwp'] as $vendor) {
    $d = __DIR__ . "/vendor/$vendor";
    // loop subdirs in $d using scandir
    foreach (scandir($d) as $subdir) {
        // loop files in $subdir
        if ($subdir == '.' || $subdir == '..') {
            continue;
        }
        foreach (scandir("$d/$subdir") as $file) {
            if ($file !== 'composer.json') {
                continue;
            }
            $json = json_decode(file_get_contents("$d/$subdir/$file"), true);
            if (!isset($json['type'])) {
                $unknowns[] = "$d/$subdir/$file";
                continue;
            }
            $type = $json['type'];
            if ($type === 'behat-extension') {
                $behats[] = "$d/$subdir/$file";
            } else if ($type === 'mink-driver') {
                $minks[] = "$d/$subdir/$file";
            } else if ($type === 'composer-plugin') {
                $composerPlugins[] = "$d/$subdir/$file";
            } else {
                $types[$type] ??= 0;
                $types[$type]++;
            }
        }
    }
}

echo "UNKNOWNS\n";
print_r($unknowns);

echo "BEHATS\n";
print_r($behats);

echo "MINKS\n";
print_r($minks);

echo "TYPES\n";
print_r($types);

@GuySartorelli GuySartorelli force-pushed the pulls/main/dynamically-check-module-type branch from 2204867 to 5d59def Compare January 29, 2024 21:18
@GuySartorelli
Copy link
Member Author

Ahh yup fair point. config isn't a Silverstripe CMS module technically, but I'm okay with pretending it is for the purposes of this tool, since we tend to treat it as though it is one.
Done

@emteknetnz emteknetnz merged commit c1e0340 into silverstripe:main Jan 30, 2024
1 check passed
@emteknetnz emteknetnz deleted the pulls/main/dynamically-check-module-type branch January 30, 2024 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants