public function addPackage(array $packageNames, $areDevPackages = false)
    {
        $fs = new Filesystem();
        $file = $this->embeddedComposer->getExternalComposerFilename();

        if ($fs->exists($file) === false) {
            $fs->dumpFile($file, "{\n}\n");
        }

        if (filesize($file) === 0) {
            $fs->dumpFile($file, "{\n}\n");
        }

        $json = new JsonFile($file);

        $requirements = $this->formatPackageNames($packageNames);
        $versionParser = new VersionParser();

        foreach ($requirements as $constraint) {
            $versionParser->parseConstraints($constraint);
        }

        $composerDefinition = $json->read();

        $requireKey = $areDevPackages ? 'require-dev' : 'require';

        foreach ($requirements as $package => $version) {
            $composerDefinition[$requireKey][$package] = $version;
        }

        $json->write($composerDefinition);

        return $composerDefinition[$requireKey];
    }