Where is the "Hello world" going to be printed after following shadow-cljs documentation to watch the app? - printing

I am following shadow-cljs Quick Start documentation on a minimal example of a project. Here is the link.
I have this shadow-cljs.edn file:
;; shadow-cljs configuration
{:source-paths
["src/dev"
"src/main"
"src/test"]
:dev-http {8080 "public"}
:dependencies
[]
:builds
{:frontend
{:target :browser
:modules {:main {:init-fn acme.frontend.app/init}}
}}}
In /Users/pedro/projects/acme-app/src/main/acme/frontend/app.cljs, I also have:
(ns acme.frontend.app)
(defn init []
(println "Hello World"))
I can build and watch it with the command:
$ npx shadow-cljs watch frontend
shadow-cljs - config: /Users/pedro/projects/acme-app/shadow-cljs.edn
shadow-cljs - HTTP server available at http://localhost:8080
shadow-cljs - server version: 2.20.2 running at http://localhost:9630
shadow-cljs - nREPL server started on port 61214
shadow-cljs - watching build :frontend
[:frontend] Configuring build.
[:frontend] Compiling ...
[:frontend] Build completed. (127 files, 0 compiled, 0 warnings, 6.97s)
Since the init function is a "Hellow World" function I was expecting to see it in some place. But, I can't find anywhere "showing" the Hello World to see it worked out.
Where is the "Hello World" supposed to "appear"? Is it supposed only to be available in the REPL inside the IDE as a function to be invoked by the programmer?
The "hello world" is not printed on the terminal (see above the message retrieved), is not displayed on the UI on localhost:8080 (that would probably need a tweak in HTML - see pic below), and does not appear on the browser console (that would probably need js/console.log).
These are the failed attempts to invoke the functions in the REPL after executing npx shadow-cljs node-repl:
cljs.user=> (acme.frontend.app/init)
------ WARNING - :undeclared-var -----------------------------------------------
Resource: <eval>:1:2
Use of undeclared Var acme.frontend.app/init
--------------------------------------------------------------------------------
cljs.user=> (main.acme.frontend.app/init)
------ WARNING - :undeclared-ns ------------------------------------------------
Resource: <eval>:1:2
No such namespace: main.acme.frontend.app, could not locate main/acme/frontend/app.cljs, main/acme/frontend/app.cljc, or JavaScript source providing "main.acme.frontend.app"
--------------------------------------------------------------------------------
This is the image on localhost:8080:

You appear to have skipped the creation of the public/index.html, as mentioned in the Quick Start. The build is using :target :browser, so it is meant to be loaded in the Browser. The HTML will do that. When loaded you'll see the println in the Browser Console.
For the REPL the code always needs to be loaded before if can be used. So, you need a (require '[acme.frontend.app :as x]) before running (x/init).

Related

getting this error while trying to run cube js

I'm getting this error while trying to run cube js with the default command in the getting started docs. I've started this in a folder and running it in docker.
Warning. There is no cube.js file. Continue with environment variables
πŸ”₯ Cube Store (0.28.31) is assigned to 3030 port.
Warning. Option apiSecret is required in dev mode. Cube.js has generated it as e3b8c5a35fe378f4d481ada777e5f3c4
πŸ”“ Authentication checks are disabled in developer mode. Please use NODE_ENV=production to enable it.
πŸ¦… Dev environment available at http://localhost:4000
πŸš€ Cube.js server (0.28.31) is listening on 4000
2021-09-03 15:06:01,512 INFO [cubestore::http::status] <pid:17> Serving status probes at 0.0.0.0:3031
2021-09-03 15:06:01,515 INFO [cubestore::metastore] <pid:17> Using existing metastore in /cube/conf/.cubestore/data/metastore
thread '
main
' panicked at '
called `Result::unwrap()` on an `Err` value: Error { message: "IO error: While fsync: a directory: Invalid argument" }
', /project/cubestore/src/metastore/mod.rs:1542:40
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Cube Store Start Error: undefined
I guess it’s corrupted metastore due to it was incorrectly shutdown for you locally. Could you please try to drop the .cubestore directory?

Error when running near indexer localnet, fail to generate config.json

So I'm trying to run the indexer on localnet following the official tutorial https://docs.near.org/docs/tutorials/near-indexer
However when I run cargo run -- init to generate the localnet json config I get this error
Finished dev [unoptimized + debuginfo] target(s) in 17.62s
Running `target/debug/example-indexer init`
thread 'main' panicked at 'Failed to deserialize config: Error("expected value", line: 1, column: 1)', /home/francois/.cargo/git/checkouts/nearcore-5bf7818cf2261fd0/a44be20/nearcore/src/config.rs:499:39
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
At some point it seems the json is not created or not created properly I guess, the function crashing in config.rf line 499 is
impl From<&str> for Config {
fn from(content: &str) -> Self {
serde_json::from_str(content).expect("Failed to deserialize config")
}
}
It's quite difficult to debug since cargo run -- init is using some inner near function (also I'm new to rust).
the config.json file is created but it seems the permission are not set properly by the script, the content of config.json is
"<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Access Denied</Message> ... "
If anyone from the community has encountered this problem or has a hint it would be great!! thanks a lot !
In the tutorial you referenced, it mentions a similar error, and suggests the following:
Open your config.json located in the .near folder in the root of your home directory. ( ~/.near/config.json )
In this file, locate: "tracked_shards": [] and change the value to [0].
Save the file and try running your indexer again.
So I had the wrong config with download_config: false,
It should be download_config: false, for the localnet use

SilverStripe running tests using Behat throwing "No behat.yml found for module silverstripe/framework" error

I am working on a SilverStripe project. I am trying to write Behavioural Tests using Behat for my projects. But I am getting an error when I run the tests. Following is what I have done so far.
First I install the module using composer
composer require --dev silverstripe/behat-extension
I have the behat.yml file right under the project root folder with the following definition
default:
suites: []
extensions:
SilverStripe\BehatExtension\MinkExtension:
default_session: facebook_web_driver
javascript_session: facebook_web_driver
facebook_web_driver:
browser: chrome
wd_host: "http://127.0.0.1:9515"
browser_name: chrome
SilverStripe\BehatExtension\Extension:
bootstrap_file: vendor/silverstripe/cms/tests/behat/serve-bootstrap.php
screenshot_path: %paths.base%/artifacts/screenshots
retry_seconds: 4 # default is 2
Then I tried to run the tests executing the following command.
vendor/bin/behat #framework
Then I get the following error.
In ModuleSuiteLocator.php line 166:
No behat.yml found for module silverstripe/framework
behat [-s|--suite SUITE] [-f|--format FORMAT] [-o|--out OUT] [--format-settings FORMAT-SETTINGS] [--init] [--namespace NAMESPACE] [--lang LANG] [--name NAME] [--tags TAGS] [--role ROLE] [--story-syntax] [-d|--definitions DEFINITIONS] [--snippets-for [SNIPPETS-FOR]] [--snippets-type SNIPPETS-TYPE] [--append-snippets] [--no-snippets] [--strict] [--order ORDER] [--rerun] [--stop-on-failure] [--dry-run] [--] [<module> [<paths>]]
There is not behat.yml in the vendor/silverstripe/framework folder. Actually, it is supposed to come with the framework. But it is not there. How can I solve the error?
For all SilverStripe modules the tests and associated configuration are not shipped with distributable packages (e.g. tags).
If you want to use them, you'll need to install the "dev" version. E.g. 4.5.x-dev instead of ~4.5.0.

symfony/yaml backed symfony/config not parsing environment variables

I have recreated a simple example in this tiny github repo. I am attempting to use symfony/dependency-injection to configure monolog/monolog to write logs to php://stderr. I am using a yaml file called services.yml to configure dependency injection.
This all works fine if my yml file looks like this:
parameters:
log.file: 'php://stderr'
log.level: 'DEBUG'
services:
stream_handler:
class: \Monolog\Handler\StreamHandler
arguments:
- '%log.file%'
- '%log.level%'
log:
class: \Monolog\Logger
arguments: [ 'default', ['#stream_handler'] ]
However, my goal is to read the path of the log files and the log level from environment variables, $APP_LOG and LOG_LEVEL respectively. According to The symphony documentations on external paramaters the correct way to do that in the services.yml file is like this:
parameters:
log.file: '%env(APP_LOG)%'
log.level: '%env(LOGGING_LEVEL)%'
In my sample app I verified PHP can read these environment variables with the following:
echo "Hello World!\n\n";
echo 'APP_LOG=' . (getenv('APP_LOG') ?? '__NULL__') . "\n";
echo 'LOG_LEVEL=' . (getenv('LOG_LEVEL') ?? '__NULL__') . "\n";
Which writes the following to the browser when I use my original services.yml with hard coded values.:
Hello World!
APP_LOG=php://stderr
LOG_LEVEL=debug
However, if I use the %env(VAR_NAME)% syntax in services.yml, I get the following error:
Fatal error: Uncaught UnexpectedValueException: The stream or file "env_PATH_a61e1e48db268605210ee2286597d6fb" could not be opened: failed to open stream: Permission denied in /var/www/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107 Stack trace: #0 /var/www/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\StreamHandler->write(Array) #1 /var/www/vendor/monolog/monolog/src/Monolog/Logger.php(337): Monolog\Handler\AbstractProcessingHandler->handle(Array) #2 /var/www/vendor/monolog/monolog/src/Monolog/Logger.php(532): Monolog\Logger->addRecord(100, 'Initialized dep...', Array) #3 /var/www/html/index.php(17): Monolog\Logger->debug('Initialized dep...') #4 {main} thrown in /var/www/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107
What am I doing wrong?
Ok you need a few things here. First of all you need version 3.3 of Symfony, which is still in beta. 3.2 was the released version when I encountered this. Second you need to "compile" the environment variables.
Edit your composer.json with the following values and run composer update. You might need to update other dependencies. You can substitute ^3.3 with dev-master.
"symfony/config": "^3.3",
"symfony/console": "^3.3",
"symfony/dependency-injection": "^3.3",
"symfony/yaml": "^3.3",
You will likely have to do this for symfony/__WHATEVER__ if you have other symfony components.
Now in you're code after you load your yaml configuration into your dependency container you compile it.
So after you're lines here (perhaps in bin/console):
$container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . DIRECTORY_SEPARATOR . '..'));
$loader->load('services.yml');
Do this:
$container->compile(true);
Your IDE's intellisense might tell you compile takes no parameters. That's ok. That's because compile() grabs its args indirectly via func_get_arg().
public function compile(/*$resolveEnvPlaceholders = false*/)
{
if (1 <= func_num_args()) {
$resolveEnvPlaceholders = func_get_arg(0);
} else {
. . .
}
References
Github issue where this was discussed
Pull request to add compile(true)
Using this command after loading your services.yaml file should help.
$containerBuilder->compile(true);
given your files gets also validated by the checks for proper configurations which this method also does. The parameter is $resolveEnvPlaceholders which makes environmental variables accessible to the yaml services configuration.

How to press keys on Android application in Appium via Robot Framework?

my Robot Framework script is shown below. When I use the "Input Text" keyword, the previous letters are erased and only the last letter is shown. How can I simulate a manual key press using Appium via Robot Framework?
*** Settings ***
Library AppiumLibrary
Test Setup Setup application
Test Teardown Teardown application
*** Variables ***
${BROWSER_NAME} mobileOS
${PLATFORM} Android
${USER} XXXXXXX
${PASSWORD} XXXXXXX
${deviceName} XXXXXXX
${AUTOMATIONNAME} Appium
${HOST} https://XXXX.perfectomobile.com/nexperience/perfectomobile/wd/hub
${ANDROID_APP} PUBLIC:XXXX\\XXXXXXXXXXX_X_X_XX.apk
${ANDROID_APP_PACKAGE} XXX.XXX
${APP_ACTIVITY} XXX.XXX.XXX
*** Test Cases ***
Test Case 01: Open application and then close it
Log Source
Wait until page contains element xpath=//*[#resource-id='email'] timeout=60
Input Text xpath=//*[#resource-id='email'] Hello
Capture Page Screenshot
*** Keywords ***
Setup application
Open Application ${HOST}
... browserName=${BROWSER_NAME}
... platform=${PLATFORM}
... user=${USER}
... password=${PASSWORD}
... deviceName=${DEVICENAME}
... automationName=${AUTOMATION_NAME}
... app=${ANDROID_APP}
... appPackage=${ANDROID_APP_PACKAGE}
... appActivity=${APP_ACTIVITY}
Teardown application
Log Source
Close Application
You can use the selenium library built-in keyword Press Key along with the corresponding ASCII code of the certain key you want to press.
For more information visit: https://serhatbolsu.github.io/robotframework-appiumlibrary/AppiumLibrary.html#Press%20Keycode
Example:
press keycode 66

Resources