I have created a package in which I placed less files and then add these files in package file but I didn't find these files in resource in browser.
My package structure is:
package -> client -> autocomplet -> autocomplet.import.less, autocomplet.js, autocomplet.html
And in package.js file:
Package.onUse(function(api) {
api.use('templating', 'client');
api.versionsFrom('1.1.0.2');
api.addFiles('./client/autocomplete/autocomplete.html');
api.addFiles('./client/autocomplete/autocomplete.js');
api.addFiles('./client/autocomplete/autocomplete.css');
});
Kyll's comment pointed out one of the issues. You need to both use less to import the less files, and also add the files themselves. Also note that ./ is not necessary because the paths are already relative to the location of package.js. Something like the following:
Package.onUse(function(api) {
api.versionsFrom('1.1.0.2');
api.use('templating', 'client');
api.use('less');
api.addFiles('client/autocomplete/autocomplete.html');
api.addFiles('client/autocomplete/autocomplete.js');
api.addFiles('client/autocomplete/autocomplete.import.less');
});
P.S. Have you checked out the autocomplete package? (Disclaimer: I wrote this package.)
Related
I need to include a file when I build a package, but the file itself is not required at all at runtime.
I have been told to look at how to do it using a do_ function, but have been unable to find a suitable function in any documentation. I would assume this could be done trivially, but simply specifying which file to add.
Again, I'm not looking for a way to add the files to the final image. This is just for building.
Here is full documentation about tasks. They all start with do_, so you were advised to extend one of them. Also (as written in docs) packages may have additional tasks, that come from classes - files .bbclass, that are applied to your package's recipe with inherit keyword. To get full list of exactly your package tasks use command
bitbake -c listtasks <your package name>
Actually this way you just call task do_listtasks of your package, do_listtasks is also... a task)
So.. first you need to understand to what task you need to append your file. Tasks have pretty straightforward names, so to use your file during compilation, you need task do_compile, and so on.
Now, it is not clear, how you are going to actually add your file to the build, but looks like also somehow by recipe of your package. That means you should place your file in folder files (there are options about this folder naming) next by your recipe, than add file to variable SRC_URI like this:
SRC_URI = " \
.....
file://your-file-in-folder-files.ext \
.....
"
By doing this, you tell bitbake to append this file to WORKDIR during do_unpack task. More on this here, especially in 3.3.5.
Now to actually your question)) Suppose you need to use your file during do_compile task, but before the actual compilation actions. Than in your recipe extend do_compile like this:
do_compile_prepend() {
cp ${WORKDIR}/your-file-in-folder-files.ext ${S}/some/subpath/inside/sources
}
Similarly to do something with your file after some actual task actions, create function with _append suffix. For example, do_configure_append or do_compile_append.
Here WORKDIR is some folder under Yocto build directory, where all your package stuff, needed for build your package, is placed, S is a special folder with downloaded and unpacked source code under WORKDIR and do_compile_prepend (and others) is just a bash-script.
Also consider folder D (it is also locates under WORKDIR). It contains files, that actually shall go into resulting image during image creating. So if somehow your file finds the way to the resulting image, remove it directly from D like this:
do_install_append() {
rm -f ${D}/path/to/your/file/in/resulting/rootfs/your-file-in-folder-files.ext
}
Well... this is more overview, than a exact answer, but hope this helps!
I'm trying to setup the testthat unit test framework and having some trouble to get the source file location right.
My package folder structure is like below:
.\R\abc.R
.\R\def.R
.\tests\testthat\test_01.R
In my test case file test_01.R, I need to import abc.R. I managed to get this working by specifying a relative path like below:
'../../R/abc.R'
Now the abc.R file can be sourced successfully from my test cases. However, it failed at the step where abc.R tries to source def.R. I think this is because the working directory is set to ./tests/testthat by testthat.
The fix I can think of is to add a relative path '../../R/' to def.R, but this looks to me like a terrible solution as it will break when I run abc.R directly. And also there are a lot more files like abc.R and def.R in my package.
Is there a more graceful way to handle this?
Sorry if this is a straightforward question as I'm still new to R.
Inside ./tests/ there should be a file named testthat.R
Within this file you can add 3 lines:
library(testthat)
library(yourLibraryName)
test_check("yourLibraryName")
Of course replace "yourLibraryName" with the name of your package.
Then all the functions exported by your package will be loaded and tests will be able to use them.
I would like to know how to get two packages to compile the same file extension.
I am writing a package that compiles .jsx by looking for certain strings and replacing them. Inside this plugin, I am using isobuild:compiler-plugin#1.0.0:
Plugin.registerCompiler({
extensions: ['jsx']
}, function () {
...
});
The problem is that I cannot use this with mdg's jsx package because that package is also trying to compile .jsx.
Meteor gives me:
While determining active plugins:
error: conflict: two packages included in the app (jsx and my-plugin) are both trying to handle *.jsx
Ideally, I would like jsx plugin to compile the .jsx files first, and then my plugin to compile them again. Any suggestions on how to achieve this? Or can someone point me to any other directions?
consider the following app structure:
app.html
app.coffee
app.styl ## global styles, e.g. primary = #222
packages/
FirstPackage/
package.styl ## package styles, e.g. background: primary
SecondPackage/
package.styl
ThirdPackage/
package.styl
how can the packages use the styles defined app.styl?
This is possible with the meteor stylus package:
When adding the file to share in package.js (package name: project:name), mark it as 'importabe' by adding {isImport: true}:
api.addFiles('file.styl', 'client', {isImport: true});
Then import that file into stylus files of other packages:
#import '{project:name}/file.styl'
More info: https://atmospherejs.com/meteor/stylus#cross-packages-imports
take a look here: http://s-grid.meteor.com/#stylusconfiguration This is hard with Meteor for now. But you can add more paths to Stylus build plugin. Here you will find how to do this with package which provide stylus build plugin with config .json file for it: http://s-grid.meteor.com/#additionalincludepaths
I'm developing R packages for my company of not so tech savy employees.
To facilitate the life of the users I'm thinking of having a set of scripts at a global location that can get sourced at startup in order to update and load relevant packages.
My idea is to have a script for each custom package that only gets sourced if that particalar package is installed. For this to work I need to modify the .First() function when the user installs the different packages, such that after packages A is installed:
.First() <- function(){
source('script_to_package_A')
}
and if package B is then installed:
.First() <- function(){
source('script_to_package_A')
source('script_to_package_B')
}
Thus i am interested to add a line inside the .Rprofile file if .First() is already defined and the line is not in there already or, if no .Rprofile exists, create it.
What would be the best way to achieve this?
best wishes
Thomas
EDIT: Just to clarify - what I am looking for is a safe way to modify the .First() function that gets called during startup. That means that if a user already has defined a .First() function the additions will just be appended instead of replacing the old .First(). Preferably this addition to first will happen when a specific package is installed but this is not necessary. I'm fairly confident in what to add to the .First() function so this is not in question.
I suspect that the easiest way to get what you want is to have a single package installed on all machines. If you can alter the .First function on everyones machine, then you can install a package.
Your .First function would be:
.First() <- function(){
library(mypkg)
run_mypkg_fun()
##Could also check for package updates
##update.packages("mypkg"...)
}
The function run_mypkg_fun can do all the checks you want, including:
installing packages
running different functions conditional on what's installed.