Comments (5)
@MGatner Here is my publisher for example for Alpine.js
<?php
namespace App\Publishers;
use CodeIgniter\Publisher\Publisher;
class AlpinePublisher extends Publisher
{
/**
* Tell Publisher where to get the files.
* Since we will use Composer to download
* them we point to the "vendor" directory.
*
* @var string
*/
protected $source = \ROOTPATH . 'node_modules/alpinejs';
/**
* FCPATH is always the default destination,
* but we may want them to go in a sub-folder
* to keep things organized.
*
* @var string
*/
protected $destination = \FCPATH . 'vendor/alpinejs';
/**
* Use the "publish" method to indicate that this
* class is ready to be discovered and automated.
*
* @return boolean
*/
public function publish(): bool
{
return $this
// Add all the files relative to $source
->addPath('dist')
// Indicate we only want the minimized versions
->retainPattern('*.min.*')
// Merge-and-replace to retain the original directory structure
->merge(true);
}
}
Problem no.1
I must specify \ROOTPATH
& \FCPATH
. Is default ok ? Docs are say that it's default.
Problem no.2
What is expected ? Publisher will create directories vendor & alpinejs ?
Error
CodeIgniter v4.1.8 Command Line Tool - Server Time: 2022-02-22 18:15:26 UTC+01:00
[CodeIgniter\Files\Exceptions\FileException]
__construct expects a valid directory.
at SYSTEMPATH/Files/FileCollection.php:50
Backtrace:
1 SYSTEMPATH/Files/FileCollection.php:50
CodeIgniter\Files\Exceptions\FileException::forExpectedDirectory('__construct')
2 SYSTEMPATH/Publisher/Publisher.php:160
CodeIgniter\Files\FileCollection::resolveDirectory('/app/public/vendor/alpinejs')
3 SYSTEMPATH/Publisher/Publisher.php:119
CodeIgniter\Publisher\Publisher()->__construct()
4 SYSTEMPATH/Commands/Utilities/Publish.php:77
CodeIgniter\Publisher\Publisher::discover('Publishers')
5 SYSTEMPATH/CLI/Commands.php:63
CodeIgniter\Commands\Utilities\Publish()->run([])
6 SYSTEMPATH/CLI/CommandRunner.php:70
CodeIgniter\CLI\Commands()->run('publish', [])
7 SYSTEMPATH/CLI/CommandRunner.php:56
CodeIgniter\CLI\CommandRunner()->index([])
8 SYSTEMPATH/CodeIgniter.php:823
CodeIgniter\CLI\CommandRunner()->_remap('index', 'publish')
9 SYSTEMPATH/CodeIgniter.php:412
CodeIgniter\CodeIgniter()->runController(Object(CodeIgniter\CLI\CommandRunner))
10 SYSTEMPATH/CodeIgniter.php:320
CodeIgniter\CodeIgniter()->handleRequest(null, Object(Config\Cache), false)
11 SYSTEMPATH/CLI/Console.php:48
CodeIgniter\CodeIgniter()->run()
12 ROOTPATH/spark:63
CodeIgniter\CLI\Console()->run()
exit status 9
Problem no.3
If I create folders manually then
CodeIgniter v4.1.8 Command Line Tool - Server Time: 2022-02-22 18:19:42 UTC+01:00
App\Publishers\AlpinePublisher failed to publish to /app/public/vendor/alpinejs/!
/app/node_modules/alpinejs/dist/cdn.min.js
/app/node_modules/alpinejs/dist/cdn.min.js fails the following restriction for /app/public/: #\.(?css|js|map|htm?|xml|json|webmanifest|tff|eot|woff?|gif|jpe?g|tiff?|png|webp|bmp|ico|svg)$#i
from codeigniter4-assets.
It looks like you are having some issues with Publisher that aren't related to this library. As far as I can tell you have everything configured correctly, but the framework's security restrictions are triggering when you try to publish to the public path. But if you look at the error it essentially says "your .js file does not meet the restrictions: a bunch of extensions, including .js"
Try adding your own Publisher Config in app/Config and change FCPATH to allow everything, see if that works for starters.
As follow-up you will need to take this issue to the framework for troubleshooting, unless you discover something else that points to this library.
from codeigniter4-assets.
@MGatner If I edit Publisher conf like:
public $restrictions = [
ROOTPATH => '*',
FCPATH => '*',
];
It's trying to publish to /app/public/alpinejs/
what is wrong. I don't understand why is there /app/
in front of.
But cdn.min.js
is in place.
CodeIgniter v4.1.8 Command Line Tool - Server Time: 2022-02-23 20:13:08 UTC+01:00
App\Publishers\AlpinePublisher published 1 file(s) to /app/public/alpinejs/.
from codeigniter4-assets.
@MGatner Ok I spent few hours to get it working.
Here is my final Publisher
<?php
namespace App\Publishers;
use CodeIgniter\Publisher\Publisher;
class AlpineJSPublisher extends Publisher
{
/**
* Tell Publisher where to get the files.
* Since we will use Composer to download
* them we point to the "vendor" directory.
*
* @var string
*/
protected $source = \ROOTPATH . '/node_modules';
/**
* FCPATH is always the default destination,
* but we may want them to go in a sub-folder
* to keep things organized.
*
* @var string
*/
protected $destination = \FCPATH . '/assets/vendor';
/**
* Use the "publish" method to indicate that this
* class is ready to be discovered and automated.
*
* @return boolean
*/
public function publish(): bool
{
return $this
->addPath('alpinejs')
->retainPattern('*.min.*')
->merge(true);
}
}
I must specify ROOTPATH
& FCPATH
because of erro in file SYSTEMPATH/Files/FileCollection.php:50
.
I tried to achieve to auto creation of folders with assets. If I specify in protected $source = \ROOTPATH . '/node_modules/alpinejs';
then it won't work. So I tried to put folders directly to addPath
and it works!
Something must be wrong with this filter #\.(?css|js|map|htm?|xml|json|webmanifest|tff|eot|woff?|gif|jpe?g|tiff?|png|webp|bmp|ico|svg)$#
because with that it wont work. I'm not so happy to don't use any filter now, but at least I can publish my assets and use them with your assets library.
from codeigniter4-assets.
Glad you got it fixed! If you have a version of your code/repo that you believe is "bugged" then submit it as a bug report to the CodeIgniter repo.
from codeigniter4-assets.
Related Issues (20)
- Feature: After filter HOT 1
- Set the order for assets HOT 2
- Feature: Manifest URLs HOT 3
- Feature: Asset Groups HOT 1
- Discussion: Route integration HOT 3
- Discussion: Patches HOT 1
- disable dynamic parameter .js?v=1599757859 HOT 7
- Bug: Duplicate manifest publishing
- vendor js loaded after route assets HOT 4
- AssetsTestTrait::$published
- JS and CSS HTTPS HOT 3
- Feature: Toolbar Collector
- Issue: Outputted URIs contain \ backslash on Windows HOT 3
- {locale} support HOT 4
- Fix: Filters Registrar HOT 2
- In readme small fix word HOT 2
- Configure routes dynamically HOT 6
- config Assets.php for jquery e other HOT 4
- loading single js per page HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from codeigniter4-assets.