I started by reviewing the Api notes and comparing them:
https://developer.holochain.org/api/
What I have done so far:
Preparation:
Downloaded and installed 0.0.2, and then updated the bash_profile following this link:
https://developer.holochain.org/start.html
JSON PARSE/Stringify update
Updated all of the tests to remove any JSON.parse and JSON.stringify calls as they are no longer needed, for example replacing this:
JSON.stringify({})
with this:
{}
Derive function update
Updated all derive functions in zome definition files ( lib.rs ) to include Debug and DefaultJSON, like this:
#[derive(Serialize, Deserialize, Debug, DefaultJson)]
Json String update
Did a global find and replace for all zome files on the JsonString
changing the serde_json call to look like this :
replacing
-> serde_json::Value
with
-> JsonString
so it looks like this:
fn handle_create_action(action: Action, user_address: HashString) ->
JsonString { ...
Current errors
I am running to these errors:
error: cannot find derive macro DefaultJson in this scope
error[E0412]: cannot find type JsonString in this scope
how can we import these into the lib.rs files?
Update
This is by no means a comprehensive answer, but here are some of the additional steps I have found with help.
You will also need to edit the cargo.toml file of each zome, the dependencies part, to look like this:
serde = "1.0"
serde_json = "1.0"
serde_derive = "1.0"
hdk = { git = "https://github.com/holochain/holochain-rust", branch = "master" }
holochain_core_types = { git = "https://github.com/holochain/holochain-rust", branch = "master" }
holochain_core_types_derive = { git = "https://github.com/holochain/holochain-rust", branch = "master" }
holochain_wasm_utils = { git = "https://github.com/holochain/holochain-rust", branch = "master" }
This was found with the specification app which is already up to date with the release that happened last night, at this page:
https://github.com/holochain/dev-camp-tests-rust/blob/master/zomes/people/code/Cargo.toml
Each zome needed this as a replacement for everything above the #derive function:
#![feature(try_from)]
#[macro_use]
extern crate hdk;
extern crate serde;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate serde_json;
extern crate holochain_core_types;
#[macro_use]
extern crate holochain_core_types_derive;
use hdk::{
holochain_core_types::{
dna::zome::entry_types::Sharing,
hash::HashString,
json::JsonString,
entry::Entry,
entry::entry_type::EntryType,
error::HolochainError,
cas::content::Address,
},
};
This resolved the initial errors on compile, and showed me the next layer of changes needed via terminal feedback when I ran hc test to compile, build and test the app... this is what I am seeing now..
Error 1
error[E0061]: this function takes 1 parameter but 2 parameters were supplied
--> src/lib.rs:56:11
|
56 | match hdk::commit_entry("metric", json!(metric)) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 1 parameter
Error 2
error[E0308]: mismatched types
--> src/lib.rs:60:24
|
60 | return json!({"link error": link_result.err().unwrap()});
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `holochain_core_types::json::JsonString`, found enum `serde_json::Value`
I will attempt to resolve this one by replacing the serde_json calls in the zome code with JsonString...
Error 3
error[E0609]: no field `links` on type `hdk::holochain_wasm_utils::api_serialization::get_links::GetLinksResult`
--> src/lib.rs:82:18
|
82 | .links
| ^^^^^ unknown field
Error 4
error[E0599]: no method named `to_json` found for type `hdk::error::ZomeApiError` in the current scope
--> src/lib.rs:97:32
|
97 | "error": hdk_error.to_json()
| ^^^^^^^
Update 2
#connorturlands answer got me through most of those errors, and now there appears to be just one more.
^^^^^^^^
|
= note: #[warn(unused_imports)] on by default
error[E0063]: missing fields `active`, `date_time`, `description` and 12 other fields in initializer of `Metric`
--> src/lib.rs:48:68
|
48 | let metric_entry = Entry::new(EntryType::App("metric".into()), Metric{
| ^^^^^^ missing `active`, `date_time`, `description` and 12 other fields
error: aborting due to previous error
For more information about this error, try `rustc --explain E0063`.
error: Could not compile `metrics`.
Which is in response to this zome definition:
fn handle_create_metric(metric: Metric, user_address: HashString) -> JsonString {
let metric_entry = Entry::new(EntryType::App("metric".into()), Metric{
// => Here is where the error triggers... it wants me to define 'title, time, etc' but as a core function, I don't see the point, those will be inputted.. not sure how to address this
});
match hdk::commit_entry(&metric_entry) {
Ok(metric_address) => {
match hdk::link_entries(
&user_address,
&metric_address,
"metric_by_user"
) {
Ok(link_address) => metric_address.into(),
Err(e) => e.into(),
}
}
Err(hdk_error) => hdk_error.into(),
}
}
For error 1, just check this example, and copy it:
https://developer.holochain.org/api/0.0.2/hdk/api/fn.commit_entry.html
For error 2, just do
link_result.into()
which converts it into a JsonString
For error 3, use
.addresses()
instead of .links, this can be seen here: https://developer.holochain.org/api/0.0.2/holochain_wasm_utils/api_serialization/get_links/struct.GetLinksResult.html
And for error 4 just do
hdk_error.into()
and remove it from the json! wrapping that it looks like you're attempting :)
In general, if you see a reference to something relating to the hdk, use the search feature of the API ref to find out more about it, its very good
Migrating from 0.0.1 to 0.0.2 was exactly what I did recently for the todo-list example. I just created a branch for the old version so you can compare the two
https://github.com/willemolding/holochain-rust-todo
https://github.com/willemolding/holochain-rust-todo/tree/working-on-v0.0.1
From memory some of the gotchas are:
commit_entry now takes a single reference to an Entry object
Links must be included as part of the define_zome! or they cannot be created
move from serde_json Value to JsonString
Need to include holochain_core_types_derive = { git = "https://github.com/holochain/holochain-rust" , tag = "holochain-cmd-v0.0.2" } in the cargo.toml
Responses from get_entry are generic entry types and can be converted into a local type, say ListEntry, as ListEntry::try_from(entry.value())
There are a whole lot more so its probably best to check out the repo.
My Seedjob creates a job, which needs to fulfill some fileOperation tasks - so I am using the fileOperations plugin, which are doing what they should, except this:
fileZipOperation('target/unpacked')
I am getting this exception, when my seed job in Jenkins runs (it failes then):
No signature of method:
javaposse.jobdsl.dsl.helpers.step.StepContext.fileZipOperation() is
applicable for argument types: (java.lang.String)
When I configure a job 'by hand' and set up fileZipOperation,
it needs one string parameter folderPath - and it works. Zip is created just fine.
I even looked into the sourceCodes in GitHub, but I can't see the problem. Any help - thank you in advance?
You can use the Dynamic DSL to configure file operations:
job('example') {
steps {
fileOperationsBuilder {
fileOperations {
fileZipOperation {
folderPath('test')
}
}
}
}
}
My question is very related to How to access list of Jenkins job parameters from within a JobDSL script?
With the diference: How can I access one specific parameter within the DSL script?
I tried to figure it out from the answers in the mentioned question but couldn't figure it out.
Let's say the parameter is named REPOSITORY_NAME.
I tried to use the code from the accepted answer and do something like
import hudson.model.*
Build build = Executor.currentExecutor().currentExecutable
ParametersAction parametersAction = build.getAction(ParametersAction)
def newname = parametersAction.parameters['REPOSITORY_NAME'].ParameterValue
println newname
but I only got
ERROR: (script, line 5) Exception evaluating property 'REPOSITORY_NAME' for java.util.Collections$UnmodifiableRandomAccessList, Reason: groovy.lang.MissingPropertyException: No such property: REPOSITORY_NAME for class: hudson.model.StringParameterValue
I also tried
def newname = parametersAction.parameters.getParameter('REPOSITORY_NAME').ParameterValue
instead but it gave me
ERROR: (script, line 5) No signature of method: java.util.Collections$UnmodifiableRandomAccessList.getParameter() is applicable for argument types: (java.lang.String) values: [REPOSITORY_NAME]
What do I have to change to make this work?
Okey just figured it out now using the second answer on the mentioned question and if-else like
def reponame = ''
binding.variables.each {
println "${it.key} = ${it.value}"
if(it.key == 'REPOSITORY_NAME'){
reponame = it.value
}
}
probably not the most eficient way but it works.
I am writing a custom grails script. I want custom help, options etc.
According to doc (
http://grails.github.io/grails-doc/latest/guide/commandLine.html#creatingCustomScripts), I just need to do:
description( "Generates a controller that performs CRUD operations and the associated views" ) {
usage "grails generate-all [DOMAIN CLASS]"
flag name:'force', description:"Whether to overwrite existing files"
argument name:'Domain Class', description:'The name of the domain class'
}
However when I add that to my script, I get:
Warning: Error caching created help for /server/scripts/ExecuteDBScript.groovy: No signature of method: ExecuteDBScript.description() is applicable for argument types: (java.lang.String, ExecuteDBScript$_run_closure1) values: [Generates a controller that performs CRUD operations and the associated views, ...]
My script looks like:
includeTargets << grailsScript("_GrailsInit")
description( "Generates a controller that performs CRUD operations and the associated views" ) {
usage "grails generate-all [DOMAIN CLASS]"
flag name:'force', description:"Whether to overwrite existing files"
argument name:'Domain Class', description:'The name of the domain class'
}
/**
* Script to execute the DB script.
*
*/
target(main: "This script executes DB Script") {
...
}
Any ideas?
Documentation is poor, but I found this solution:
includeTargets << grailsScript("_GrailsBootstrap")
USAGE = """
grails script-name [PARAM]
where
PARAM = Description
"""
target (default: "command description") {
//...
}
Your link (http://grails.github.io/grails-doc/latest/guide/commandLine.html#creatingCustomScripts) refers to the latest version of grails, a non-stable version (3.0.0.M2).
Probably you are using the latest stable version, 2.4.4, so the correct docs are here: http://grails.github.io/grails-doc/2.4.4/ref/Command%20Line/create-script.html
I just started to use jslint with backbone. At the beginning of project I create object:
App = {
Models: {},
Views: {},
Controller: {}
}
and get error:" 'App' was used before it was defined."
Then later I use it as:
App.Models.Task = Backbone.Model.extend({})
and at this point jslint can't pass me through. it says
unexpected 'App'. App.Models.Task = Backbone.Model.extend({}) // Line 17, Pos 1
#8 Stopping. (7% scanned).
I've read that probably jslint sees it as critical error because it stopped but it is not an error. what should I do?
It should be var App (or window.App, depending on your goals; but, in my opinion, even global variables are better defined as local ones first, then exported into outer space within a single statement). Otherwise JSLint (quite rightly) thinks that you just forgot to define this variable in some other place OR made a typo in its name.