how do you get the latest version of Polymer elements using bower? - asp.net

I am experimenting with an asp.net core MVC web app using Polymer, and largely things seem to be going well. I used the now built in bower.json file to specify required packages (eg paper-fab), and they were dutifully installed. Nearly every time I could just use the package name and version from the appropriate Polymer catalogue page (example). But with a couple of the pages (paper-ripple and paper-card) bower can't find the specified version, so I tried the wildcard approach which resolved to a much earlier version. For paper-ripple it didn't seem to cause any problems, but paper-card just doesn't seem to work for me.
Here is my bower.json file:
{
"name": "asp.net",
"private": true,
"dependencies": {
"jquery": "2.2.0",
"jquery-validation": "1.14.0",
"jquery-validation-unobtrusive": "3.2.6",
"polymer": "1.4.0",
"PolymerElements/paper-material": "1.0.6",
"PolymerElements/iron-icons": "1.1.3",
"PolymerElements/iron-image": "1.2.5",
"PolymerElements/paper-button": "1.0.13",
"PolymerElements/paper-icon-button": "1.1.3",
"PolymerElements/app-layout": "0.10.4",
"PolymerElements/paper-header-panel": "1.1.6",
"PolymerElements/paper-toolbar": "1.1.7",
"PolymerElements/paper-drawer-panel": "1.0.10",
"PolymerElements/paper-fab": "1.2.1",
"PolymerElements/paper-item": "1.2.1",
"PolymerElements/paper-listbox": "1.1.2",
"PolymerElements/paper-ripple": "*",
"PolymerElements/paper-card": "*",
"normalize-css": "4.1.1"
},
"resolutions": {
"polymer": "^1.2.1",
"paper-ripple": "^1.0.0",
"font-roboto": "^1.0.1"
}
}
I know I could just download the latest versions from the catalogue, but I'd rather continue using bower if I can.
Of course it's always possible I am doing the cards wrong!
<link rel="import" href="~/lib/bower/paper-card/paper-card.html" />
<paper-material main elevation="0">
#for (int i = 0; i < 10; i++)
{
<paper-card heading="Card #i">
<div class="card-content">Some content #i</div>
</paper-card>
}
</paper-material>
The cards are just being output into the DOM like this (usually when using chrome dev tools I can see all the local DOM inside Polymer elements, but not in this case):
<paper-card heading="Card 0">
<div class="card-content">Some content 0</div>
</paper-card>
EDIT: Potential Workaround
So I have found that rather than directly editing the bower.json file in Visual Studio (which updates all your packages when saving), if I open up cmd in the same directory as the bower.json file and run bower commands from there I can install the versions shown in the Polymer catalog. For example bower install --save PolymerElements/paper-ripple which then updates the bower.json file accordingly. Perhaps this is the best way of doing it rather than relying editing it manually and relying on VS to update the packages?

If you want to install latest version on every bower install command you can add caret(^) to all your bower dependencies. Currently you have hard coded all the versions that needs to be used.
You can check out this answer for more details on bower versions

Related

Did anyone manage to make OpenXml work with dnx core 5?

We have to use DNX core 5 and OpenXml, for XLS export, in our app.
It seems like the OpenXml dependency is not supported, according to the error message I got:
Error NU1002 The dependency DocumentFormat.OpenXml 2.5.0 in project does not support framework DNXCore,Version=v5.0. project.json
Here is the part of the project.json associated with the problem:
"frameworks": {
"dnx451": {
"dependencies": { },
"frameworkAssemblies": {
"WindowsBase": "4.0.0.0"
}
},
"dnxcore50": {
"dependencies": {
}
}},
Adding manually the same frameworkAssemblies element to the "dnxcore50" node does not seem to fix the problem.
Removing the "dnxcore50" node makes the app to compile, but this compromises the benefits of dnx Core 5.0 advantages.
This similar question did not properly answer my question :
Open XML in dnx5.0 / aspnext
Does anyone have a solution ?
Unfortunately there is currently no nuget package for the Open Xml SDK.
However, some people are already working on creating such a package:
https://github.com/OfficeDev/Open-XML-SDK/issues/65
Update 24th May.
The community worked for .NET Standard support 😊.
It should work for .NET Core, if not it will be very soon.
Follow the evolution here:
https://dotnet.myget.org/gallery/open-xml-sdk

Meteor require unpublished npm module

In node, it's easy to do
"dependencies": {
"express": "^4.13.3",
"node-uuid": "^1.4.3",
"PACKAGE_NAME": "git://github.com/USERNAME/REPO_NAME.git#COMMIT_SHA"
}
In meteor I can include an npm module using var uuid = Meteor.npmRequire('node-uuid'); for npm packages that are published, but when pointing my package at github (the same way I would in a node project) I get an error.
How does one doe this with Meteor? When trying to do the same thing in the package.json I get the following error
"must declare exact version of dependency:"
Any help on how to include a package that's not published to Npm?
You need to specify the commit and point to the archive. From https://atmospherejs.com/meteorhacks/npm:
If you need to install an npm module from a specific commit, use the
syntax:
{ "googleapis": "https://github.com/bradvogel/google-api-nodejs-client/archive/d945dabf416d58177b0c14da64e0d6038f0cc47b.tar.gz" }

Trouble updating packages using Bower in ASP .NET vNext

I have started ASP .NET vNext and I was going through several articles about using bower in Visual Studio 2015 for managing client side libraries, it's pretty simple to use but I am having problems in updating the packages...
I am following this
bower.json:
"dependencies": {
"bootstrap": "3.3.2",
"jquery": "1.4.1",
"jquery-validation": "1.11.1",
"jquery-validation-unobtrusive": "3.2.2",
"hammer.js": "2.0.4",
"bootstrap-touch-carousel": "0.8.0",
"jquery-migrate-official": "^1.2.1",
"bootstrap-hover-dropdown": "2.1.3",
"jquery-slimscroll": "1.3.3",
"jquery-cookie": "1.4.1",
"jquery.uniform": "4.3.0",
"blockui": "2.1.2",
"font-awesome": "4.3.0"
},
The intellisense says that the package blockui has the latest stable version 2.1.2 but package manager log says:
bower blockui#2.1.2 ENORESTARGET No tag found that was able to satisfy 2.1.2
bower blockui#2.1.2 not-cached git://github.com/malsup/blockui.git#2.1.2
bower blockui#2.1.2 resolve git://github.com/malsup/blockui.git#2.1.
Questions:
What does this mean? Is the intellisense picking up the wrong latest version?
Is there any better way to update all client side packages like I used to do using nuget package manager ?
update-package
I read that for server-side packages ASP .NET vNext will use nuget packages but when I write any command in my Package Manager Console nothing happens
update-package
install-package entityframework
You can right-click the 'Bower' node under the 'Dependencies' node and choose 'Restore Packages'. I often have to open the 'Task Runner Explorer' from 'View -> Other Windows' and run the 'bower' task from its context menu. This will trigger a bower installation.
gruntfile.js
module.exports = function (grunt) {
grunt.initConfig({
bower: {
install: {
options: {
targetDir: "wwwroot/lib",
layout: "byComponent",
cleanTargetDir: false
}
}
}
});
// This command registers the default task which will install bower packages into wwwroot/lib
grunt.registerTask("default", ["bower:install"]);
// The following line loads the grunt plugins.
// This line needs to be at the end of this this file.
grunt.loadNpmTasks("grunt-bower-task");
};
package.json
{
"version": "0.0.0",
"name": "",
"devDependencies": {
"grunt": "0.4.5",
"grunt-bower-task": "0.4.0"
}
}
The packages should then show up in your wwwroot -> lib directory.
Check out bower's website for more details: http://bower.io/
I just found that for (and for font-awesome package) IntelliSense advices non-existing version. That was 2.1.2, exactly like for your case, that is why I found your question.
I had re-checked real version, corrected it to existing one, and everything started to work.

How to compile .less files on save in Visual Studio 2015 (preview)

Ok, so I've created a new ASP.Net 5/MVC 6 project in Visual Studio 2015 Preview. In keeping with our current method of doing things, for styling I want to use .less files. Creating the files is straightforward, but Web Essentials no longer compiles them.
So my question is this: what precisely do I need to do to get my .css files generated when I save the .less files?
Based on my adventures getting Typescript to work nicely, I will have to use Grunt to accomplish this task, but I am brand-new to Grunt and so I'm not sure how one would do it?
Please help!
With VS 2015 Web Essential is split into multiple extensions you can download
the Web Compiler extension from here and it also has details on how to use it.
It is certainly not elegant as it used to be, but if you are using existing project and want to use a compiler for LESS then this may do the basic job.
So here's how to do it (compile on build and non-elegant compile on save):
Step 1
Open up your package.json file (it's in the root of your project) and add these lines:
"grunt-contrib-less": "^1.0.0",
"less": "^2.1.2"
Obviously you can change the version numbers (you'll get helpful intellisense), these are just the current versions.
Step 2
Right-click on the NPM folder (under Dependencies) and click Restore Packages. This will install less and grunt-contrib-less.
Step 3
Once those packages are restored, go to your gruntfile.js file (again, in the root of the project). Here, you'll need to add the following section to grunt.initConfig
less: {
development: {
options: {
paths: ["importfolder"]
},
files: {
"wwwroot/destinationfolder/destinationfilename.css": "sourcefolder/sourcefile.less"
}
}
}
You'll also need to add this line near the end of gruntfile.js:
grunt.loadNpmTasks("grunt-contrib-less");
Step 4
Then just go to View->Other Windows->Task Runner Explorer in the menu hit the refresh icon/button, then right-click on less under Tasks and go to Bindings and tick After Build.
Hooray, now less files will compile and we (I) learned about grunt, which seems really powerful.
Step 5: Compiling on save
I still haven't got this working to my satisfaction, but here's what I've got so far:
As above, add another NPM package grunt-contrib-watch (add to package.json, then restore packages).
Then add a watch section in gruntfile.js, like this (obviously this can work for other types of files as well):
watch: {
less: {
files: ["sourcefolder/*.less"],
tasks: ["less"],
options: {
livereload: true
}
}
}
So you'll now have something like this in your gruntfile.js:
/// <binding AfterBuild='typescript' />
// This file in the main entry point for defining grunt tasks and using grunt plugins.
// Click here to learn more. http://go.microsoft.com/fwlink/?LinkID=513275&clcid=0x409
module.exports = function (grunt) {
grunt.initConfig({
bower: {
install: {
options: {
targetDir: "wwwroot/lib",
layout: "byComponent",
cleanTargetDir: false
}
}
},
watch: {
less: {
files: ["less/*.less"],
tasks: ["less"],
options: {
livereload: true
}
}
},
less: {
development: {
options: {
paths: ["less"]
},
files: {
"wwwroot/css/style.css": "less/style.less"
}
}
}
});
// This command registers the default task which will install bower packages into wwwroot/lib
grunt.registerTask("default", ["bower:install"]);
// The following line loads the grunt plugins.
// This line needs to be at the end of this this file.
grunt.loadNpmTasks("grunt-bower-task");
grunt.loadNpmTasks("grunt-contrib-less");
grunt.loadNpmTasks("grunt-contrib-watch");
};
One can then simply set this task to run on Project Open (right-click on watch under Tasks in the Task Runner Explorer (it's under View->Other Windows in the top menu) and you're done. I would expect you'd have to close and re-open the project/solution to get this to kick in, otherwise you can manually run the task.
(Note: there is now a new question asked here directly concerning sass. I tried to alter the question and tags in this question to include sass, but someone didn't allow it.)
I would like to add the answer to the same question for sass (.scss). The answer is so related I think these may best be combined as two answers in this same post (if you disagree, please let me know; else, we might add "or sass" in the post title?). As such, see Maverick's answer for some fuller details, here's the nutshell for sass:
(Pre-step for Empty Projects)
If you started with an empty project, first add Grunt and Bower:
Right click solution -> Add -> 'Grunt and Bower to Project' (then wait for a minute for it to all install)
package.json:
"devDependencies": {
"grunt": "^0.4.5",
"grunt-bower-task": "^0.4.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-contrib-sass": "^0.9.2"
}
(FYI: grunt-contrib-sass link)
Then:
Dependencies -> right-click NPM -> Restore Packages.
gruntfile.js
1) Add or make sure these three lines are registered near the bottom (as NPM tasks):
grunt.loadNpmTasks("grunt-bower-task");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-sass");
2) Again in gruntfile.js, add init configurations, something like the following.
{ Caveat: I am no expert on such configurations. I found the sass configuration on an excellent blog post some time ago that I can't locate at this time in order to give credit. The key was I wanted to find all files in the project within a certain folder (plus descendants). The following does that (notice "someSourceFolder/**/*.scss", and see important related note here). }
// ... after bower in grunt.initConfig ...
"default": {
"files": [
{
"expand": true,
"src": [ "someSourceFolder/**/*.scss" ],
"dest": "wwwroot/coolbeans", // or "<%= src %>" for output to the same (source) folder
"ext": ".css"
}
]
},
"watch": {
"sass": {
"files": [ "someSourceFolder/**/*.scss" ],
"tasks": [ "sass" ],
"options": {
"livereload": true
}
}
}
Now follow the instructions for Task Runner Explorer as given in the other answer. Make sure to close and reopen project. It seems you have to run (double click) 'watch' (under 'Tasks') every time the project is started to get the watch watching, but then it works on subsequent saves.

How to get individual ui-utility module using bower.json

I'm trying to include the ui-mask utility in my projects bower.json file so other devs will be able to install it when running bower install.
I can install it manually with bower install angular-ui-utils#bower-mask,
but in my bower.json file I can't figure out the correct name/version. Should be mask-0.1.1
Angular UI-Utils
UI-Util Mask Module
What I want to work in bower.json:
{
"name": "project-name",
"dependencies": {
"jquery": "^2.1.x",
"angular": "~1.3.x",
"angular-route": "~1.3.x",
"angular-touch": "~1.3.x",
"angular-sanitize": "~1.3.x",
"at-table": "1.0.1",
"ngDialog": "0.2.13",
"angular-local-storage" : "0.0.7",
"angular-ui-utils#bower-mask" : "0.1.1" <- This should work
}
}
When using bower install angular-ui-utils#bower-mask you instruct bower to look for angular-ui-utils with a "bower-mask" version.
A version in this case is actually a git tag, branch or commit hash (when bower is using a git resolver).
Since the the angular-ui/ui-utils repository has a bower-mask branch it will be resolved.
If you would like to resolve bower-mask 0.1.1 you will need to find the correct tag in the Github repository. In this case this should be mask-0.1.1, so what you need in bower.json is:
{
"name": "project-name",
"dependencies": {
"angular-ui-utils" : "mask-0.1.1"
}
}
In the bower output you should see:
bower resolve git://github.com/angular-ui/ui-utils.git#mask-0.1.1
bower download https://github.com/angular-ui/ui-utils/archive/mask-0.1.1.tar.gz

Resources