Add a path repository for the asset to the application's composer.json file.

@return void
438126
protected function addAssetRepositoryToRootComposer()
    {
        $composer = json_decode(file_get_contents(base_path('composer.json')), true);

        $composer['repositories'][] = [
            'type' => 'path',
            'url' => './'.$this->relativeAssetPath(),
        ];

        file_put_contents(
            base_path('composer.json'),
            json_encode($composer, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
        );
    }
761474
protected function installFromFile()
    {
        if (!file_exists($path = base_path('components.json'))) {
            $this->error("File 'components.json' does not exist in your project root.");

            return;
        }

        $components = Json::make($path);

        $dependencies = $components->get('require', []);

        foreach ($dependencies as $component) {
            $component = collect($component);

            $this->install(
                $component->get('name'),
                $component->get('version'),
                $component->get('type')
            );
        }
    }
907273
def add_path(self, path):
        
        abspath = os.path.abspath(path)
        self.children.append(_build_project_tree(abspath, self.followsymlinks, self.file_filter))
345113
private function resolveAutomaticallyIgnoredPaths()
    {
        foreach ($this->paths as $path) {
            if (is_array($path)) {
                $path = $path['home'];
            }
            if (!Str::endsWith($path, $this->normalizePath('_template/'))) {
                $ignoredPath = $this->normalizePath(realpath($path.'/composer.json'));

                if (!in_array($ignoredPath, $this->automaticallyResolvedIgnoredPaths)) {
                    $this->automaticallyResolvedIgnoredPaths[] = $ignoredPath;
                }
            }
        }

        // Add the '_newup' directory.
        $this->automaticallyResolvedIgnoredPaths[] = $this->normalizePath('_newup\*');
    }
1357160
private function updateDistBundles()
    {
        $fs = $this->app['filesystem']->getFilesystem('root');
        $files = [
            '.bolt.yml',
            'composer.json',
            'composer.lock',
            'src/Site/CustomisationExtension.php',
        ];
        foreach ($files as $file) {
            $dist = $fs->getFile($file . '.dist');
            if (!$fs->has($file) && $dist->exists()) {
                $dist->rename($file);
            }
        }
    }
251948
protected function setupAssets()
    {
        if ($this->app instanceof LumenApplication) {
            $this->app->configure('hashid'); // @codeCoverageIgnore
        }

        $this->mergeConfigFrom($config = __DIR__.'/../config/hashid.php', 'hashid');

        if ($this->app->runningInConsole()) {
            $this->publishes([$config => base_path('config/hashid.php')], 'hashid');
        }
    }
647636
protected function bindPathsInContainer()
    {
        $this->instance('path.base',   $this->basePath());
        $this->instance('path.app',    $this->basePath('app'));
        $this->instance('path.config', $this->basePath('app/config'));
        $this->instance('path.theme',  $this->basePath('app/theme'));
        $this->instance('path.temp',   $this->basePath('app/temp'));
        $this->instance('path.lang',   $this->basePath('app/trans/langs'));
        $this->instance('path.jargon', $this->basePath('app/trans/jargons'));
    }
458393
protected function registerAssetPublishCommand(): void
    {
        $this->app->singleton('command.asset.publish', function (Application $app) {
            return new AssetPublishCommand($app->make('asset.publisher'));
        });
    }
245938
protected function registerAssetDispatcher()
    {
        $this->app->singleton('assets.dispatcher', function ($app)
        {
            $dispatcher = new AssetDispatcher($app);

            // Register the route for assets from main assets folder.
            $dispatcher->route('assets/(.*)', function (Request $request, $path) use ($dispatcher)
            {
                $basePath = $this->app['config']->get('routing.assets.path', base_path('assets'));

                $path = $basePath .DS .str_replace('/', DS, $path);

                return $dispatcher->serve($path, $request);
            });

            // Register the route for assets from Packages, Modules and Themes.
            $dispatcher->route('packages/([^/]+)/([^/]+)/(.*)', function (Request $request, $vendor, $package, $path) use ($dispatcher)
            {
                $namespace = $vendor .'/' .$package;

                if (is_null($packagePath = $dispatcher->getPackagePath($namespace))) {
                    return new Response('File Not Found', 404);
                }

                $path = $packagePath .str_replace('/', DS, $path);

                return $dispatcher->serve($path, $request);
            });

            // Register the route for assets from Vendor.
            $dispatcher->route('vendor/(.*)', function (Request $request, $path) use ($dispatcher)
            {
                $paths = $dispatcher->getVendorPaths();

                if (! Str::startsWith($path, $paths)) {
                    return new Response('File Not Found', 404);
                }

                $path = BASEPATH .'vendor' .DS .str_replace('/', DS, $path);

                return $dispatcher->serve($path, $request);
            });

            return $dispatcher;
        });
    }
74564
protected function updateComposerJson($path)
    {
        $helpers = 'shared/Support/helpers.php';

        //
        $composerJson = getenv('COMPOSER') ?: 'composer.json';

        $path = base_path($composerJson);

        // Get the composer.json contents in a decoded form.
        $config = json_decode(file_get_contents($path), true);

        if (! is_array($config)) {
            return;
        }

        // Update the composer.json
        else if (! in_array($helpers, $files = Arr::get($config, "autoload.files", array()))) {
            array_push($files, $helpers);

            Arr::set($config, "autoload.files", $files);

            $output = json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . "\n";

            file_put_contents($path, $output);
        }
    }
1029999
public function compile()
    {
        $compiledAssets = dirname(dirname(__DIR__)) . '/.build';

        $this->compileUi($compiledAssets);

        $finder = new Finder();
        $finder->files()
            ->ignoreVCS(true)
            ->name('*.php')
            ->name('*.yml')
            ->notName('UiTask.php')
            ->in(dirname(dirname(__DIR__)) . '/src');
        foreach ($finder as $file) {
            $this->addFile($file);
        }

        $finder = new Finder();
        $finder
            ->files()
            ->ignoreVCS(true)
            ->name('*.css')
            ->name('*.js')
            ->name('*.map')
            ->name('*.png')
            ->name('*.svg')
            ->name('*.html')
            ->name('*.otf')
            ->name('*.eot')
            ->name('*.ttf')
            ->name('*.woff')
            ->name('*.woff2')
            ->name('*.json')
            ->in($compiledAssets);
        foreach ($finder as $file) {
            /** @var SplFileInfo $file */
            $this->addFile($file, false, str_replace($compiledAssets, 'assets', $file->getRealPath()));
        }
    }
1156223
protected function initializeAssetsVendorDir()
    {
        $path = $this->getRootPackageAssetsPath() . '/' . (
            $this->assets_vendor_dir ? str_replace($this->getRootPackageAssetsPath(), '', $this->assets_vendor_dir) : ''
        );
        $this->filesystem->ensureDirectoryExists($path);
        $this->assets_vendor_dir = realpath($path);
        return $this;
    }
296157
public function dispatchAssets()
    {
        $this->app['asset.factory']->add('fielder-vendors', [
            'path' => FIELDER_URI.'public/js/vendors.js',
        ])->area('admin');

        $this->app['asset.factory']->add('fielder', [
            'path' => FIELDER_URI.'public/js/fielder.js',
            'dependences' => ['fielder-vendors'],
        ])->area('admin');

        $this->app['asset.factory']->add('fielder-style', [
            'path' => FIELDER_URI.'public/css/fielder.css',
        ])->area('admin');
    }
1289133
private function setup()
    {
        if ($this->started) {
            return;
        }

        if ($this->app['extend.writeable']) {
            // Do required JSON update/set up
            try {
                $this->updateJson();
            } catch (ParseException $e) {
                $this->app['logger.flash']->danger(Trans::__('Error reading extensions/composer.json file: %ERROR%', ['%ERROR%' => $e->getMessage()]));
                $this->started = false;

                return;
            }
        }

        $this->started = true;
    }
998449
public function set_assets_path($path, $fs_dir = null)
    {
        if (empty($path)) {
            return;
        }

        $path = rtrim($path, '/') . '/';

        // handle relative assets path
        if (!preg_match('|^https?://|', $path) && $path[0] != '/') {
            // save the path to search for asset files later
            $this->assets_dir = $path;

            $base = preg_replace('/[?#&].*$/', '', $_SERVER['REQUEST_URI']);
            $base = rtrim($base, '/');

            // remove url token if exists
            if ($len = intval($this->config->get('use_secure_urls'))) {
                $_base  = explode('/', $base);
                $last   = count($_base) - 1;
                $length = $len > 1 ? $len : 16; // as in rcube::get_secure_url_token()

                // we can't use real token here because it
                // does not exists in unauthenticated state,
                // hope this will not produce false-positive matches
                if ($last > -1 && preg_match('/^[a-f0-9]{' . $length . '}$/', $_base[$last])) {
                    $path = '../' . $path;
                }
            }
        }

        // set filesystem path for assets
        if ($fs_dir) {
            if ($fs_dir[0] != '/') {
                $fs_dir = realpath(RCUBE_INSTALL_PATH . $fs_dir);
            }
            // ensure the path ends with a slash
            $this->assets_dir = rtrim($fs_dir, '/') . '/';
        }

        $this->assets_path = $path;
        $this->set_env('assets_path', $path);
    }
230636
public function addAsset($type, $assetName, $fileName, $dependencies = array())
    {
        if (!isset($this->assets[$type]) || !is_array($this->assets[$type])) {
            $this->assets[$type] = array();
        }
        
        $asset = new Asset(
            $type,
            $assetName,
            $this->buildSourceFilePath($fileName),
            $dependencies
        );
        
        $this->assets[$type][$assetName] = $asset;
        $this->saveAssets();
    }
277032
public static function add_to_repo($repository_path, $files = null)
    {
        $repo = new pakeMercurial($repository_path);
        $repo->add($files);

        return $repo;
    }