@param string $packagePath
@param array $map
@param bool $isSymlink
@param bool $isRelative

@throws IOException

@api
181487
public function publish(string $packagePath, array $map, bool $isSymlink, bool $isRelative)
    {
        $packagePath = (string)realpath($packagePath);
        \assert('is_dir($packagePath) && is_readable($packagePath)');
        foreach ($map as $from => $to) {
            $origin = realpath(rtrim($packagePath, '/') . '/' . ltrim($from, '/'));
            \assert('is_dir($origin) && is_readable($origin)');
            $this->filesystem->remove($to);
            $this->filesystem->mkdir(\dirname($to));
            if ($isSymlink) {
                $from = $isRelative
                    ? $this->filesystem->makePathRelative($origin, \dirname($to))
                    : $origin;
                $this->publishSymlink($origin, $from, $to);
            } else {
                $this->io->write(sprintf('Installing assets %s as <comment>hard copies</comment>.', $origin));
                $this->filesystem->mirror($origin, $to);
            }
        }
    }
1312506
private void addFileIfNotMapped(String filePath) throws DuplicateBundlePathException {

		for (JoinableResourceBundle bundle : currentBundles) {
			List<BundlePath> items = bundle.getItemPathList();
			List<BundlePath> itemsDebug = bundle.getItemDebugPathList();
			Set<String> licenses = bundle.getLicensesPathList();

			for (BundlePath path : items) {
				if (path.getPath().equals(filePath)) {
					return;
				}
			}
			for (BundlePath path : itemsDebug) {
				if (path.getPath().equals(filePath)) {
					return;
				}
			}

			if (licenses.contains(filePath))
				return;
			else if (filePath.equals(bundle.getId())) {
				Marker fatal = MarkerFactory.getMarker("FATAL");
				LOGGER.error(fatal, "Duplicate bundle id resulted from orphan mapping of:" + filePath);
				throw new DuplicateBundlePathException(filePath);
			}
		}

		if (!filePath.startsWith(JawrConstant.WEB_INF_DIR_PREFIX)
				&& !filePath.startsWith(JawrConstant.META_INF_DIR_PREFIX)) {

			if (LOGGER.isDebugEnabled())
				LOGGER.debug("Adding orphan resource: " + filePath);

			// If we got here, the resource belongs to no other bundle.
			bundleMapping.add(filePath);
		}
	}
904975
private void scanPlatformPath(PackageSymbol p) throws IOException {
        fillIn(p, PLATFORM_CLASS_PATH,
               list(PLATFORM_CLASS_PATH,
                    p,
                    p.fullname.toString(),
                    allowSigFiles ? EnumSet.of(JavaFileObject.Kind.CLASS,
                                               JavaFileObject.Kind.OTHER)
                                  : EnumSet.of(JavaFileObject.Kind.CLASS)));
    }
183748
@Override
	public BundlePathMapping build(List<String> strPathMappings) {

		BundlePathMapping bundlePathMapping = new BundlePathMapping(bundle);
		for (JoinableResourceBundle child : ((CompositeResourceBundle) bundle).getChildBundles()) {
			if (!child.getInclusionPattern().isIncludeOnlyOnDebug()) {
				bundlePathMapping.getItemPathList().addAll(child.getItemPathList());
				addFilePathMapping(bundlePathMapping, child.getItemPathList());
			}

			if (!child.getInclusionPattern().isExcludeOnDebug()) {
				bundlePathMapping.getItemDebugPathList().addAll(child.getItemDebugPathList());
				addFilePathMapping(bundlePathMapping, child.getItemDebugPathList());
			}
			bundlePathMapping.getLicensesPathList().addAll(child.getLicensesPathList());
			addFilePathMapping(bundlePathMapping, child.getLicensesPathList());
		}
		return bundlePathMapping;
	}
673396
private function getRequired(PackageInterface $package, bool $isRoot)
    {
        $required = [];

        if ($this->requireDependencies) {
            $required = $package->getRequires();
        }
        if (($isRoot || !$this->requireDependencyFilter) && $this->requireDevDependencies) {
            $required = array_merge($required, $package->getDevRequires());
        }

        return $required;
    }
1274100
protected function getPackageDataKey(PackageInterface $package, $key, $defaultValue = null)
    {
        if (!isset($this->packagesData)) {
            $this->initializePackageData();
        }

        $packageKey = $package->getPrettyName() . '/' . $package->getPrettyVersion();
        if (!isset($this->packagesData[$packageKey]) || !isset($this->packagesData[$packageKey][$key])) {
            return $defaultValue;
        }

        return $this->packagesData[$packageKey][$key];
    }
883192
public function publishPackage($package, $packagePath = null)
    {
        $source = $this->getSource($package, $packagePath ?: $this->packagePath);

        return $this->publish($package, $source);
    }
858410
public function bundleCommand(string $packageKey, string $serverScript = null, string $clientScript = null)
    {
        $start = microtime(true);
        $filePathResolver = new FilePathResolver();
        /** @var Package $package */
        $package = $this->packageManager->getPackage($packageKey);
        if ($serverScript !== null) {
            $serverScript = $filePathResolver->resolveFilePath($serverScript);
        } else {
            $serverScript = str_replace('@packageResourcesPath', rtrim($package->getResourcesPath(), '/'), $this->reactServerFilePattern);
        }

        if ($clientScript !== null) {
            $clientScript = $filePathResolver->resolveFilePath($clientScript);
        } else {
            $clientScript = str_replace('@packageResourcesPath', rtrim($package->getResourcesPath(), '/'), $this->reactClientFilePattern);
        }

        $identifier = md5($serverScript);

        $request = new ActionRequest(Request::createFromEnvironment());
        $uriBuilder = new UriBuilder();
        $uriBuilder->setRequest($request);

        $controllerContext = new ControllerContext($request, new Response(), new Arguments(), $uriBuilder);

        $unit = new Unit($controllerContext);

        $unit->work(function (App $app) use ($clientScript, $serverScript, $identifier) {
            $this->outputLine();
            $this->output('Transpiling... ');

            $transpiler = new Transpiler($app);
            $transpiler->transpile($identifier, $serverScript, $clientScript)->done(function () use ($app) {
                $this->outputLine('<success>done</success>');
                $app->end();
            });
        });

        $bundler = new Bundler($controllerContext);
        $this->output('Bundling module... ');
        $bundler->bundle($identifier);
        $this->outputLine('<success>done</success>');

        $this->outputLine();
        $elapsed = round(microtime(true) - $start, 2);
        $this->outputLine('Bundled <success>%s</success> in <success>%s seconds</success>.', [$package->getPackageKey(), $elapsed]);
        $this->outputLine();
    }
550022
private void applyRelativePath(RelationQueryNode node) {
       if (tmpRelPath != null)
       {
          // try {
          QPath relPath = tmpRelPath;
          for (int i = 0; i < relPath.getEntries().length; i++)
          {
             node.addPathElement(relPath.getEntries()[i]);
          }
          tmpRelPath = null;
       }
    }
37698
public function publishPackage($package, $packagePath = null)
	{
		list($vendor, $name) = explode('/', $package);

		// First we will figure out the source of the package's configuration location
		// which we do by convention. Once we have that we will move the files over
		// to the "main" configuration directory for this particular application.
		$path = $packagePath ?: $this->packagePath;

		$source = $this->getSource($package, $name, $path);

		return $this->publish($package, $source);
	}
1019773
public function ensureSymlinkExists($sourcePath, $symlinkPath)
    {
        if (!is_link($symlinkPath)) {
            $this->ensureDirectoryExists(dirname($symlinkPath));

            return symlink($sourcePath, $symlinkPath);
        }

        return false;
    }
797496
private function initComposerJson($path, $repositoryUrl, $packageName)
    {
        $json = [];
        $composerJson = $path.'/composer.json';
        if (file_exists($composerJson)) {
            $json = json_decode(file_get_contents($composerJson), true);
        }

        if (!isset($json['name'])) {
            $json['name'] = $packageName;
        }

        if (!isset($json['version'])) {
            $json['version'] = '0.0.1';
        }

        if (!isset($json['repositories'])) {
            $json['repositories'] = [['type' => 'git', 'url' => $repositoryUrl]];
        } else {
            $hasRepositoryUrl = false;
            foreach ($json['repositories'] as $item) {
                if ($item['type'] == 'git') {
                    $hasRepositoryUrl = true;
                    break;
                }
            }
            if (!$hasRepositoryUrl) {
                $json['repositories'][] = ['type' => 'git', 'url' => $repositoryUrl];
            }
        }

        $size = file_put_contents(
            $composerJson,
            json_encode(
                $json,
                JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
            )
        );

        if (!$size) {
            $this->error("Error to write file '{$composerJson}'.");
        }
    }
381303
@Override
	public Links findLinksWithRel(LinkRelation relation, InputStream representation) {

		Assert.notNull(relation, "LinkRelation must not be null!");

		try {

			Object parseResult = getExpression(relation).read(representation);
			return createLinksFrom(parseResult, relation);

		} catch (IOException o_O) {
			throw new RuntimeException(o_O);
		} catch (PathNotFoundException o_O) {
			return Links.NONE;
		}
	}
651138
protected function getSource($packagePath)
    {
        $sources = [
            "{$packagePath}/resources/database/migrations",
            "{$packagePath}/resources/migrations",
            "{$packagePath}/migrations",
        ];

        // iterate through all possible locations
        foreach ($sources as $source) {
            if ($this->files->isDirectory($source)) {
                $paths = [];

                // get all files of the current directory
                $files = $this->getSourceFiles($source);

                // iterate through all files
                foreach ($files as $file) {
                    // if the destination doesn't exist we can add the file to the queue
                    if (!class_exists($this->getClassFromFile($file))) {
                        $paths[$file] = $this->getDestinationPath('migrations', [
                            date('Y_m_d_His', time()), $this->getFileName($file),
                        ]);
                    }
                }

                return $paths;
            }
        }

        throw new InvalidArgumentException('Migrations not found.');
    }
1275292
private function getPackageByName(iterable $packages, string $name): ?PackageInterface
    {
        foreach ($packages as $package) {
            if ($package->getName() === $name) {
                return $package;
            }
        }

        return null;
    }
1277200
private function getPrimaryNamespace(PackageInterface $package)
    {
        $primaryNs = null;

        foreach ($package->getAutoload() as $type => $pathMap) {
            if ($type !== 'psr-4') {
                continue;
            }

            if (count($pathMap) === 1) {
                $primaryNs = key($pathMap);
                break;
            }

            $matches = preg_grep('#^(\./)?src/?$#', $pathMap);
            if ($matches) {
                $primaryNs = key($matches);
                break;
            }

            if (false !== ($key = array_search('', $pathMap, true))
                || false !== ($key = array_search('.', $pathMap, true))
            ) {
                $primaryNs = $key;
            }

            break;
        }

        if (!$primaryNs) {
            throw new RuntimeException(sprintf("Unable to get primary namespace for package %s.", $package->getName()));
        }

        return $primaryNs;
    }
1075203
public static function isAsset(PackageInterface $package, array $configPackages = array())
    {
        $projectConfig = self::getProjectActivation($package, $configPackages);
        $enabled = false !== $projectConfig;

        return $enabled && (static::hasExtraActivation($package)
            || static::hasPluginDependency($package->getRequires())
            || static::hasPluginDependency($package->getDevRequires())
            || true === $projectConfig);
    }