@param IncomingPackage $package

@return void
192143
private function deferExecution(IncomingPackage $package): void
    {
        /** @psalm-suppress MixedTypeCoercion Incorrect amphp types */
        Loop::defer(
            function() use ($package): void
            {
                $this->processor->handle($package)->onResolve(
                    function(?\Throwable $throwable) use ($package): void
                    {
                        $this->currentTasksInProgressCount--;

                        if (null !== $throwable)
                        {
                            $this->logger->critical($throwable->getMessage(), [
                                'packageId'      => $package->id(),
                                'traceId'        => $package->traceId(),
                                'throwablePoint' => \sprintf('%s:%d', $throwable->getFile(), $throwable->getLine()),
                            ]);
                        }
                    }
                );
            }
        );
    }
1352166
public function publishPackage($package)
    {
        $source = $this->getSource($package);

        return $this->publish($package, $source);
    }
792427
public function addPackageUsage(PackageInterface $package)
    {
        $usageData = $this->getPackageUsage($package);
        $packageName = $this->composer->getPackage()->getName();

        if (!in_array($packageName, $usageData)) {
            $usageData[] = $packageName;
        }

        $this->updatePackageUsageFile($package, $usageData);
    }
186432
public function isPackageInstalled(PackageInterface $package)
    {
        return $this->filesystem->exists($this->config->getInstallDir() . '/' . $package->getName() . '/.bower.json');
    }
275675
private function isInstalledGlobally($package)
    {
        if (!isset($this->globalList)) {
            $this->globalList = $this->shell->execute(
                ['npm', 'ls', '--global', '--no-progress', '--depth=0']
            );
        }

        return $this->globalList && strpos($this->globalList, $package . '@') !== false;
    }
620060
private function packageRegistered($package)
    {
        $package_registered = array_key_exists($package, $this->packages);

        if ($package_registered) {
            $this->updateLog("info", "Package {$package} is registered");
        } else {
            $this->updateLog("info", "Package {$package} is not registered");
        }

        return $package_registered;
    }
1266253
protected function handlePackage($package) {
		if ($package instanceof Package) {
			return $package;
		}
		
		$package = new Package($package, $this->basePath, $this->baseUrl, $this->metadataManager);
		
		if ($this->hashAppend) {
			$package->setHashAppend(true);
		}
		
		return $package;
	}
1074920
public function addPackage($name, AbstractPackage $package)
    {
        $this->container->get('package.resolver')->addPackage($name, $package);

        return $this;
    }
607164
public function setCurrentPackage($package)
    {
        if (!$package instanceof AbstractPackage) {
            $package = $this->packageResolver->getPackage($package);
        }

        $this->packageResolver->setCurrentPackage($package);

        return $this;
    }
385585
public static function registerPackage(PackageInterface $package, $target, AssetsInstallerInterface $installer = null)
    {
        $_this = self::getInstance($installer);
        $_this->addPackage($package, $target);
    }
288230
protected function addPackage(ComposerPackage $package)
    {
        $plugin = $this->rep->find($package->getName());

        // create new plugin if not exists
        if (!$plugin) {
            $plugin = new Plugin();
            $plugin->setName($package->getName());
        }

        list($vendor, $package) = explode('/', $plugin->getName());

        try {
            $data = $this->client->getPlugin($vendor, $package);
            $plugin->setTitle($data['title'])->setDescription($data['description']);
            if ($data['logo']) {
                $this->downloader->entity($data['logo'], $plugin, true);
            }
        } catch (\Exception $e) {
            // is not a critical error
        }

        $this->em->persist($plugin);
        $this->em->flush();
    }
924004
public function install($package)
    {
        if (! is_null($package)) {
            $package = '"'.$package.'"';
        }
        $process = $this->getProcess();
        $process->setCommandLine(trim($this->findComposer().' require '.$package));
        $process->run($this->output);
    }
315149
static function package($package) {
        if(!isset(self::$packages[$package])) {
            self::$packages[$package] = new Package($package);
        }
        
        return self::$packages[$package];
    }
26154
public function installMissingPackageTranslations(Package $package)
    {
        // Get the list of languages that users may need for the user interface.
        $wanted = Localization::getAvailableInterfaceLanguages();
        // Get the list of languages that users may need for the site locales.
        $siteService = $this->app->make(SiteService::class);
        $site = $siteService->getSite();
        if ($site) {
            foreach ($site->getLocales() as $locale) {
                $wanted[] = $locale->getLocale();
            }
        }
        $wanted = array_unique($wanted);
        $wanted = array_filter($wanted, function ($localeID) {
            return $localeID !== Localization::BASE_LOCALE;
        });
        $already = array_keys($this->localFactory->getAvailablePackageStats($package));
        $missing = array_diff($wanted, $already);
        $result = [];
        if (count($missing) > 0) {
            $available = $this->remoteProvider->getAvailablePackageStats($package->getPackageHandle(), $package->getPackageVersion());
            $toDownload = array_intersect($missing, array_keys($available));
            foreach ($missing as $missingID) {
                if (!in_array($missingID, $toDownload, true)) {
                    $result[$missingID] = false;
                } else {
                    try {
                        $this->installPackageTranslations($package, $missingID);
                        $result[$missingID] = true;
                    } catch (Exception $x) {
                        $result[$missingID] = $x;
                    }
                }
            }
        }

        return $result;
    }
697654
final protected function define(PackageDefinition $package)
    {
        $package->name('content');

        $package->metadata([
            'icon' => 'cubes',
        ]);

        $contentDefinition = new ContentPackageDefinition($this->getIocContainer()->get(ContentConfig::class), $package, $this->getIocContainer());

        $this->defineContent($contentDefinition);
    }
1218339
public function updateEntry($package)
	{
		$this->verifyCommand($package);

		$lines = file($this->less);

		// Set the new colors
		$lines[0] = '@bg:                ' . $package['bg'] . ";\n";
		$lines[1] = '@gray:              ' . $package['gray'] . ";\n";
		$lines[2] = '@brand-primary:     ' . $package['primary'] . ";\n";
		$lines[3] = '@brand-info:        ' . $package['info'] . ";\n";
		$lines[4] = '@brand-success:     ' . $package['success'] . ";\n";
		$lines[5] = '@brand-warning:     ' . $package['warning'] . ";\n";
		$lines[6] = '@brand-danger:      ' . $package['danger'] . ";\n";
		$lines[7] = '@menuColor:         ' . $package['menu'] . ";\n";

		$this->file->delete($this->less);
		$this->file->put($this->less, implode($lines));
	}
631328
protected function define(PackageDefinition $package)
    {
        $package->name('analytics');

        $package->metadata([
            'icon' => 'globe'
        ]);

        $package->dashboard()
            ->widgets(['config.*']);

        $package->modules([
            'config' => AnalyticsConfigModule::class
        ]);
    }