webpack-require-http webpack encore symfony - require external js - symfony

I tried to add this extension:
https://www.npmjs.com/package/webpack-require-http
to webpack encore:
.addExternals({
'webpack-require-http' :require('webpack-require-http')
})
but I got:
encore dev --watch
Running webpack ...
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration.externals should be one of these:
string | object { <key>: string | object | boolean } | function | RegExp | [string | object { <key>: string | object | boolean } | function | RegExp | [(recursive)]]
-> Specify dependencies that shouldn't be resolved by webpack, but should become dependencies of the resulting bundle. The kind of the dependency depends on `output.libraryTarget`.
Details:
* configuration.externals should be a string.
-> An exact matched dependency becomes external. The same string is used as external dependency.
* configuration.externals['webpack-require-http'] should be a string.
* configuration.externals['webpack-require-http'] should be an object.
* configuration.externals['webpack-require-http'] should be a boolean.
* configuration.externals should be an instance of function
-> `function(context, request, callback(err, result))` The function is called on each dependency.
* configuration.externals should be an instance of RegExp
-> Every matched dependency becomes external.
* configuration.externals should be an array:
[string | object { <key>: string | object | boolean } | function | RegExp | [(recursive)]]
error Command failed with exit code 1.
I want to load the php-generated js to webpack.
In vendor.js add:
require('http://10.2.0.2/vars.js');
This url file is php generated js.

Related

How can I define local dependencies between roles in a collection in ansible?

I have a question about dependencies between roles in a collection.
In general, I am concerned if it is possible to define dependencies between roles in a collection - local dependencies like a relative path.
I would like to implement scenarios:
roleB depends on roleA
default scenario of roleC should use roleA in prepare.yml to set up the environment
or
default scenario of roleC should use roleA in converge.yml
I would like to get these dependencies as local dependencies.
For case 2, I tried to use the requriments.yml file
with the appropriate entry in molecule.yml
---
dependency:
name: galaxy
driver:
name: docker
platforms:
.. ...
provisioner:
name: ansible
# env:
# ANSIBLE_ROLES_PATH: "../../roles"
playbooks:
prepare: prepare.yml
config_options:
defaults:
remote_user: ansible
dependency:
name: galaxy
options:
ignore-certs: True
ignore-errors: True
requirements-file: requirements.yml
verifier:
name: ansible
But unfortunately I can't solve the error:
ERROR [1m[0;34mUsing /etc/ansible/ansible.cfg as config file[1m[0m
Starting galaxy role install process
- downloading role from file://../../tool-box
[1m[0;31m [ERROR]: failed to download the file: <urlopen error [Errno 2] No such file or[1m[0m
[1m[0;31mdirectory: '/../tool-box'>[1m[0m
[1m[1;35m[WARNING]: - tool-box was NOT installed successfully.[1m[0m
[1m[0;31mERROR! - you can use --ignore-errors to skip failed roles and finish processing the list.[1m[0m
Structure of collection with roles:
mynamespace
|
|-- mycollection
|
| --roles
|
| -- roleA --
| |--molecule
| |
| |--default
|
| -- roleB --
| |--molecule
| |
| |--default
|
| -- roleC --
| |--molecule
| |
| |--default
Thank you.
Update:
See request issue in ansible/galaxy:
https://github.com/ansible/galaxy/issues/2719
I added this because I don't think there is such functionality.

Error: Could not find main or io in tokio, invalid return type `impl Future`

I'm on my way of converting to Rust from the ML family, but I'm finding it hard at some strange places I'm not used to having problems.
I'm trying to use hyper for http handling but can't seem to get tokio to work.
I have tried to copy paste this example:
use hyper::{body::HttpBody as _, Client};
use tokio::io::{self, AsyncWriteExt as _};
type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
#[tokio::main]
async fn main() -> Result<()> {
// ...
fetch_url(url).await
}
async fn fetch_url(url: hyper::Uri) -> Result<()> {
// ...
Ok(())
}
Here is my Cargo.toml:
[package]
name = "projectname"
version = "0.1.0"
authors = ["username"]
edition = "2018"
[dependencies]
hyper = "0.14.4"
tokio = "1.2.0"
It is complaining that it can't find the io crate, and that main has an invalid type impl Future, and that it can't find main in tokio:
error[E0433]: failed to resolve: could not find `main` in `tokio`
--> src/main.rs:9:10
|
9 | #[tokio::main]
| ^^^^ could not find `main` in `tokio`
error[E0277]: `main` has invalid return type `impl Future`
--> src/main.rs:10:20
|
10 | async fn main() -> Result<()> {
| ^^^^^^^^^^ `main` can only return types that implement `Termination`
error[E0432]: unresolved import `hyper::Client`
--> src/main.rs:3:34
|
3 | use hyper::{body::HttpBody as _, Client};
| ^^^^^^ no `Client` in the root
error[E0425]: cannot find function `stdout` in module `io`
--> src/main.rs:45:13
|
45 | io::stdout().write_all(&chunk).await?;
| ^^^^^^ not found in `io`
|
error[E0432]: unresolved import `tokio::io::AsyncWriteExt`
--> src/main.rs:4:23
|
4 | use tokio::io::{self, AsyncWriteExt as _};
| -------------^^^^^
| |
| no `AsyncWriteExt` in `io`
| help: a similar name exists in the module: `AsyncWrite`
Is #[tokio::main] and client not in hyper?
The tokio::main macro converts an async main to a regular main that spawns a runtime. However, because the macro is not found is scope, it cannot transform your main function, and the compiler is complaining that your main has an invalid return type of impl Future. To fix this, you have to enable the required features to import the main macro:
tokio = { version = "1.2.0", features = ["rt", "macros"] }
You also have to enable the io-util feature to access io::AsyncWriteExt, and the io-std feature to access io::stdout. To simplify this, tokio provides the full feature flag, which will enable all optional features:
tokio = { version = "1.2.0", features = ["full"] }
You also need hyper's client and http feature flags to resolve the Client import:
hyper = { version = "0.14.4", features = ["client", "http1", "http2"] }

How to remove steps from checkout in Sylius

I'm using sylius/sylius 1.3.9 with symfony/framework-bundle 4.2.4. Regarding the doc to remove states from checkout you have to replace the whole configuration of the Sylius core bundle.
I put my configuration into src/Resources/SyliusCoreBundle/config/app/state_machine/sylius_order_checkout.yml:
winzou_state_machine:
sylius_order_checkout:
class: '%sylius.model.order.class%'
property_path: checkoutState
graph: sylius_order_checkout
state_machine_class: '%sylius.state_machine.class%'
states:
cart: ~
addressed: ~
completed: ~
transitions:
address:
from: [cart, addressed]
to: addressed
complete:
from: [addressed]
to: completed
callbacks:
after:
sylius_process_cart:
on: [address]
do: ['#sylius.order_processing.order_processor', process]
args: [object]
sylius_create_order:
on: [complete]
do: ['#sm.callback.cascade_transition', apply]
args: [object, event, create, sylius_order]
sylius_save_checkout_completion_date:
on: [complete]
do: [object, completeCheckout]
args: [object]
After that I execute:
php bin/console cache:clear -e dev
[...]
php bin/console debug:winzou:state-machine sylius_order_checkout -e dev
+--------------------+
| Configured States: |
+--------------------+
| cart |
| addressed |
| shipping_selected |
| shipping_skipped |
| payment_skipped |
| payment_selected |
| completed |
+--------------------+
[...]
Nothing changed. When I follow the link in the doc it says:
Bundle inheritance was removed in Symfony 4.0 [...]
So is it still possible with Symfony 4.2 to replace a whole configuration file of a bundle like suggested by the docs or is this a regression in Sylius 1.3 and what would be a possible solution if I did nothing wrong?
You can try to create state_machine directory in config/packages, put your YAML file and add this line in configureContainer() method into src/Kernel:
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
{
...
$loader->load($confDir.'/state_machine/*'.self::CONFIG_EXTS, 'glob');
}

Route edit,show and delete not working using laravel 5.7

Page not found all I get when trying to get these pages.
web.php looks like this
Route::resource('admin/roles', 'RoleController');
route:list look like this
| GET|HEAD | admin/roles | index | App\Http\Controllers\RoleController#index
| GET|HEAD | admin/roles/create | create | App\Http\Controllers\RoleController#create
| PUT|PATCH | admin/roles/{} | update | App\Http\Controllers\RoleController#update
| GET|HEAD | admin/roles/{} | show | App\Http\Controllers\RoleController#show
| DELETE | admin/roles/{} | destroy | App\Http\Controllers\RoleController#destroy
| GET|HEAD | admin/roles/{}/edit | edit | App\Http\Controllers\RoleController#edit
Controllerlook like this
public function show($id)
{
$role = Role::find($id);
return view('admin.roles/show')->with('role',$role);
}
public function edit($id)
{
$role = Role::find($id);
return view('admin.roles.edit')->with('role',$role);
}
You should try navigating your browser to admin/roles/1 instead of admin/roles/show/1. The route you've tried doesn't exist so you're correctly getting a 404 error.
Since the create and index page work fine, but not show I think there is something up with the route bindings.
Since the routes in route:list command show admin/roles/{}, it makes me think laravel couldn't figure out the bindings.
My best guess for this it to check the http kernel. You should have the \Illuminate\Routing\Middleware\SubstituteBindings::class middleware either in the $middleware array or inside the web group under the $middlewareGroups array. I suggest putting it in the web middleware group.
eg:
protected $middlewareGroups = [
//
'web' => [
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
//
];
Another suggestion:
Try defining the routes individually instead of using Route::resource()
Route::get('admin/roles', 'RoleController#index');
Route::get('admin/roles/create', 'RoleController#create');
Route::patch('admin/roles/{role}', 'RoleController#update');
Route::get('admin/roles/{role}', 'RoleController#show');
Route::delete('admin/roles/{role}', 'RoleController#delete');
Route::get('admin/roles/{role}/edit', 'RoleController#edit');
Note you may need to add ->name('some-name') to fix the names

How to set version number in sbt when building & publishing akka-http

I'm trying to experiment with a local copy of the akka-http library. I can publish it locally with sbt publishLocal, but I can't figure out how to change the version number. build.sbt contains an organization field but no simple version field - that seems to be generated from somewhere else and I can't figure out where. It's currently at 10.0.5but grepping that string in the source doesn't turn up anything obvious.
Seems like a simple question, but where is version defined? Thanks.
(I'm asking this because sbt docs tell me I should name my local version something like 0.1-SNAPSHOT. I assume there must be a simpler way to do this than by disabling the auto-generation logic and hardcoding it into build.sbt)
It seems that Akka-HTTP generates its version at run-time.
If you look at akka-http/akka-http-core/src/main/resources/reference.conf:
Akka HTTP version, checked against the runtime version of Akka HTTP.
Loaded from generated conf file.
And then look at akka-http/project/Version.scala:
/**
* Generate version.conf and akka/Version.scala files based on the version setting.
*/
object Version {
def versionSettings: Seq[Setting[_]] = inConfig(Compile)(Seq(
resourceGenerators += generateVersion(resourceManaged, _ / "akka-http-version.conf",
"""|akka.http.version = "%s"
|""").taskValue,
sourceGenerators += generateVersion(sourceManaged, _ / "akka" / "http" / "Version.scala",
"""|package akka.http
|
|import com.typesafe.config.Config
|
|object Version {
| val current: String = "%s"
| def check(config: Config): Unit = {
| val configVersion = config.getString("akka.http.version")
| if (configVersion != current) {
| throw new akka.ConfigurationException(
| "Akka JAR version [" + current + "] does not match the provided " +
| "config version [" + configVersion + "]")
| }
| }
|}
|""").taskValue
))
def generateVersion(dir: SettingKey[File], locate: File => File, template: String) = Def.task[Seq[File]] {
val file = locate(dir.value)
val content = template.stripMargin.format(version.value)
if (!file.exists || IO.read(file) != content) IO.write(file, content)
Seq(file)
}
}
I'm assuming after generating the current version you should see a akka-http-version.conf file somewhere in your filesystem.

Resources