I'm new at FAKE and I'm trying to use fake as continuous delivery, but I'm faced with a problem with deploying my .nupkg files. Here is the code of my DeployPackage target
Target "DeployPackages" (fun _ ->
deployProjects
|> Seq.iter (fun projName ->
deploymentMachines
|> Seq.iter (fun machineUrl ->
let package = Directory.GetFiles(deployDir, projName + "*.nupkg").FirstOrDefault()
if package = String.Empty
then failwith "No packages was found. You should get green build before deployment."
else
package |> deployToMachine(machineUrl)
)
)
)
and in TeamCity build log I see error:
"Finished Target: CreateDeploymentPackage
Starting Target: DeployPackages (==> CreateDeploymentPackage, CreateDeploymentPackage)
Target: DeployPackages
..\Build\output\deploy\MySitev2.65.nupkg"
AND then the next error message "Newtonsoft.Json.JsonSerializationException:
No union type found with the name 'Message'. Path 'case', line 2, position 20.
at Newtonsoft.Json.Converters.DiscriminatedUnionConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
[15:35:09][Step 2/2] at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
[15:35:09][Step 2/2] at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at Fake.FakeDeployAgentHelper.processResponse(Byte[] response) in D:\code\fake\src\app\Fake.Deploy.Lib\FakeDeployAgentHelper.fs:line 120"
Whats wrong with my target?
Related
I'm working on a command line tool written in Scala which is executed as:
sbt "run --customerAccount 1234567"
Now, I wish to make this flexible to accept "--CUSTOMERACCOUNT" or --cUsToMerAccount or --customerACCOUNT ...you get the drift
Here's what the code looks like:
lazy val OptionsParser: OptionParser[Args] = new scopt.OptionParser[Args]("scopt") {
head(
"XML Generator",
"Creates XML for testing"
)
help("help").text(s"Prints this usage message. $envUsage")
opt[String]('c', "customerAccount")
.text("Required: Please provide customer account number as -c 12334 or --customerAccount 12334")
.required()
.action { (cust, args) =>
assert(cust.nonEmpty, "cust is REQUIRED!!")
args.copy(cust = cust)
}
}
I assume the opt[String]('c', "customerAccount") does the pattern matching from the command line and will match with "customerAccount" - how do I get this to match with "--CUSTOMERACCOUNT" or --cUsToMerAccount or --customerACCOUNT? What exactly does the args.copy (cust = cust) do?
I apologize if the questions seem too basic. I'm incredibly new to Scala, have worked in Java and Python earlier so sometimes I find the syntax a little hard to understand as well.
You'd normally be parsing the args with code like:
OptionsParser.parse(args, Args())
So if you want case-insensitivity, probably the easiest way is to canonicalize the case of args with something like
val canonicalized = args.map(_.toLowerCase)
OptionsParser.parse(canonicalized, Args())
Or, if you for instance wanted to only canonicalize args starting with -- and before a bare --:
val canonicalized =
args.foldLeft(false -> List.empty[String]) { (state, arg) =>
val (afterDashes, result) = state
if (afterDashes) true -> (arg :: result) // pass through unchanged
else {
if (arg == "==") true -> (arg :: result) // move to afterDash state & pass through
else {
if (arg.startsWith("--")) false -> (arg.toLowerCase :: result)
else false -> (arg :: result) // pass through unchanged
}
}
}
._2 // Extract the result
.reverse // Reverse it back into the original order (if building up a sequence, your first choice should be to build a list in reversed order and reverse at the end)
OptionsParser.parse(canonicalized, Args())
Re the second question, since Args is (almost certainly) a case class, it has a copy method which constructs a new object with (most likely, depending on usage) different values for its fields. So
args.copy(cust = cust)
creates a new Args object, where:
the value of the cust field in that object is the value of the cust variable in that block (this is basically a somewhat clever hack that works with named method arguments)
every other field's value is taken from args
Please Note: I could not a find a solution that could work here, so I used ports for the same.
I need to use Browser.Events.onKeyDown for which I have also written a decoder, I need to create some shortcuts for my web app thus I need to prevent default behavior of Meta key (on Mac) and Ctrl key (on other Os)
In my Subscription method I am using the following.
But there is no exposed way of using prevent Default.
let
decoder : Decode.Decoder Msg
decoder =
keyDecoder
|> Decode.andThen
(\( keyCode, ctrlKey ) ->
case keyCode of
39 ->
Decode.succeed <| ShortCutNext
37 ->
Decode.succeed <| ShortCutPrevious
_ ->
Decode.fail ""
)
in
Sub.batch
[ Browser.Events.onKeyDown decoder]
keyDecoder : Decode.Decoder ( Int, Bool )
keyDecoder =
Decode.map2 (\a -> \b -> ( a, b ))
(Decode.field "keyCode" Decode.int)
(Decode.field "metaKey" Decode.bool)
Note: The event is on the page itself and not on any element such as textarea thus Html.Events.custom "keydown" options decoder is not applicable.
I am trying to get the x and y coordinates of the mouse during a mouse-wheel-move event in the Elm 0.19 programming language.
I attempt it with this package. See under "Advanced Usage":
https://package.elm-lang.org/packages/mpizenberg/elm-pointer-events/3.1.0/Html-Events-Extra-Wheel
The package itself did not describe a clear example so I looked for an example in a similar package.
See the example under "advanced usage" in this page:
https://package.elm-lang.org/packages/mpizenberg/elm-pointer-events/3.1.0/Html-Events-Extra-Mouse
This example is very similar to what I need, but I can also not get this to work. Get exactly the same problem.
Here is my code adapted from the example to fit with mouse wheel:
module WheelDecoder exposing(..)
import Html exposing (div, text)
import Html.Events.Extra.Wheel as Wheel
import Json.Decode as Decode
type alias WheelEventWithOffsetXY =
{ wheelEvent : Wheel.Event
, offsetXY : {x: Float, y: Float}
}
decodeWeelWithOffsetXY : Decode.Decoder WheelEventWithOffsetXY
decodeWeelWithOffsetXY =
Decode.map2 WheelEventWithOffsetXY
Wheel.eventDecoder
offsetXYDecoder
offsetXYDecoder : Decode.Decoder {x: Float, y: Float}
offsetXYDecoder =
Decode.map2 (\a b -> {x=a,y=b})
(Decode.field "offsetY" Decode.float)
(Decode.field "offsetY" Decode.float)
type Msg
= WheelOffsetXY {x: Float, y: Float}
view =
div
[ (onWheelOffsetXY (\wheelEvent -> WheelOffsetXY (wheelEvent.offsetXY))) ]
[ (text "mousewheel here") ]
onWheelOffsetXY : (WheelEventWithOffsetXY -> msg) -> Html.Attribute msg
onWheelOffsetXY tag =
let
options = { stopPropagation = True, preventDefault = True }
func = Decode.map tag decodeWeelWithOffsetXY
attribute = Wheel.onWithOptions options func
in
attribute
When I try to compile with "elm make" I get the following error:
-- TYPE MISMATCH -------------------------------------- src/Map/WheelDecoder.elm
The 2nd argument to `onWithOptions` is not what I expect:
39| attribute = Wheel.onWithOptions options func
^^^^
This `func` value is a:
Decode.Decoder msg
But `onWithOptions` needs the 2nd argument to be:
Wheel.Event -> msg
Hint: I always figure out the argument types from left to right. If an argument
is acceptable, I assume it is “correct” and move on. So the problem may actually
be in one of the previous arguments!
This error message makes sense as I can see there is a type mismatch, but I have no clue about how to solve it.
It seems like Wheel.eventDecoder was meant to work with Html.Events.on or Html.Events.onWithOptions rather than Wheel.onWithOptions. These were removed in 0.19 in favor of Html.Events.custom, however, which is slightly different. Replacing onWheelOffsetXY with this seems to work:
onWheelOffsetXY : (WheelEventWithOffsetXY -> msg) -> Html.Attribute msg
onWheelOffsetXY tag =
let
options message =
{ message = message
, stopPropagation = True
, preventDefault = True
}
decoder =
decodeWeelWithOffsetXY
|> Decode.map tag
|> Decode.map options
in
Html.Events.custom "wheel" decoder
PS: There's a typo in decodeWeelWithOffsetXY, btw. I've left the typo in place.
PPS: Also, you're looking at outdated documentation. Here's the documentation for the latest version.
[error] Unexpected Exception: [Exception... "The URI scheme corresponds to an unknown protocol handler"
nsresult: "0x804b0012 (NS_ERROR_UNKNOWN_PROTOCOL)"
location: "JS frame :: chrome://selenium-ide/content/tools.js ->
file:///D:/SeleniumTestCases/UserExtensions/include.js?1426324803395 :: IDEIncludeCommand.prototype.getIncludeDocumentBySynchronRequest :: line 82" data: no]. toString -> function toString() { [native code] },
message -> , result -> 2152398866, name -> NS_ERROR_UNKNOWN_PROTOCOL,
filename -> chrome://selenium-ide/content/tools.js ->
file:///D:/SeleniumTestCases/UserExtensions/include.js?1426324803395,
lineNumber -> 82, columnNumber -> 0, inner -> null, data -> null,
stack -> IDEIncludeCommand.prototype.getIncludeDocumentBySynchronRequest#chrome://selenium-ide/content/tools.js
-> file:///D:/SeleniumTestCases/UserExtensions/include.js?1426324803395:82:4
xmlTestData.prototype.load#chrome://selenium-ide/content/tools.js ->
file:///D:/SeleniumTestCases/UserExtensions/datadriven.js?1426324803392:54:21
Selenium.prototype.doLoadTestData#chrome://selenium-ide/content/tools.js
-> file:///D:/SeleniumTestCases/UserExtensions/datadriven.js?1426324803392:103:4
fnBind/retval#chrome://selenium-ide/content/selenium-core/scripts/htmlutils.js:60:11
ActionHandler.prototype.execute#chrome://selenium-ide/content/selenium-core/scripts/selenium-commandhandlers.js:314:27
._executeCurrentCommand#chrome://selenium-ide/content/selenium-runner.js:306:18
TestLoop.prototype.resume#chrome://selenium-ide/content/selenium-core/scripts/selenium-executionloop.js:78:12
fnBind/retval#chrome://selenium-ide/content/selenium-core/scripts/htmlutils.js:60:11
, location -> JS frame :: chrome://selenium-ide/content/tools.js ->
file:///D:/SeleniumTestCases/UserExtensions/include.js?1426324803395
:: IDEIncludeCommand.prototype.getIncludeDocumentBySynchronRequest ::
line 82
I included all js file in user-extension.js text box
like D:\SeleniumTestCases\UserExtensions\user-extension.js, D:\SeleniumTestCases\UserExtensions\sideflow.js,D:\SeleniumTestCases\UserExtensions\datadriven.js, D:\SeleniumTestCases\UserExtensions\include.js
I referred my test case by How can I read variables from data pool with selenium IDE
sounds like improper xml file attempting to be loaded.
What is the selenium code causing this? how is the url written?
I get an error which I can't resolve.
The snap application compiles without a problem and everything seems to be ok.
But when I render the relevant page in a browser I get this error:
A web handler threw an exception. Details:
expected ("code" :: Integer) in [ _id: 50b56f19208c2e9a09dccc2b, id: 1.0, code: "hdg435", name: "froggy"]
The code value is just a rendom string I picked for testing. I am not sure why an integer is expected?
These are the relevant parts of an example snap application.
getData :: IO [Document]
getData = do
pipe <- runIOE $ connect $ host "127.0.0.1"
let run act = access pipe master "test" act
result <- run (find (select [] "pcs") >>= rest)
close pipe
return $ either (const []) id result
mkSplice :: Document -> Splice AppHandler
mkSplice d = runChildrenWithText [dtp "id" d
,dtp "code" d
,dtp "name" d
]
dtp :: Text -> Document -> (Text,Text)
dtp tag d = (tag, T.pack $ show $ at tag d)
recSplice :: Splice AppHandler
recSplice = mapSplices mkSplice =<< liftIO getData
table :: Handler App App ()
table = heistLocal (bindSplice "rec" recSplice) $ render "table"
The relevant Heist template part of table.tpl is here:
<table>
<tbody>
<rec>
<tr><td><id/></td><td><code/></td><td><name/></td></tr>
</rec>
</tbody>
</table>
Please let me know what other parts of code need to be posted.
When I compile your dtp function I get:
import Data.Bson
import Data.Text (Text)
import qualified Data.Text as T
dtp :: Text -> Document -> (Text,Text)
dtp tag d = (tag, T.pack $ show $ at tag d)
Ambiguous type variable `a0' in the constraints:
(Show a0)
[...]
which makes perfect sense. It seems like in your case it's defaulting to Integer when you really want String. You can try adding a signature or better yet, just:
dtp tag d = (tag, at tag d)
If you want this to work for other types, you'll have to work harder.
UPDATE
Here's a GHCi session that illustrates the problem and how GHCi seems to default the Show instance to Integer:
Prelude Data.Bson> show $ at "hello" ["hello" =: "world"]
"*** Exception: expected ("hello" :: Integer) in [ hello: "world"]