1

My goal

Get json files from CLDR packages. But obviously not all of them (there are some configuration files) - just the real data.

Idea

As I can see, they're configured for bower. There is also a pattern, which describes where to find those json files within a repository:

{
  "name": "cldr-dates-full",
  "version": "29.0.0",
  "dependencies": {
    "cldr-numbers-full": "29.0.0"
  },
  "main": "main/**/*.json",
  "ignore": [
    ".gitattributes",
    "README.md"
  ]
}

Thus - is it possible to easily download bower packages to a .NET application?

Naive approach

Download each repository, find the bower.json file, navigate to the main property, parse the pattern, extract the files. Very ugly.

Any advice would be very welcome. Thanks!

ebvtrnog
  • 4,167
  • 4
  • 31
  • 59

2 Answers2

0

I'm not sure what type of .Net application you are refering to but if you are using the new Asp.Net Core (Asp.Net 5) together with Visual Studio 2015, there are built in tooling to download npm packages, run gulp/grunt and download dependencies from bower.

http://docs.asp.net/en/latest/client-side/bower.html

Edit. After some discussion maybe Edge.js can help you out. It supports combinibg node.js and.Net.

Hypnobrew
  • 1,120
  • 9
  • 23
  • Is this only for downloading packages during build? Or is is possible to pull them at runtime too? – ebvtrnog Apr 11 '16 at 18:37
  • Not exclusive to build rather than development as whole. Not sure why you want to download packages during runtime? – Hypnobrew Apr 11 '16 at 18:39
  • The goal is to provide a functionality of browsing CLDR data by the client. Does the approach make sense? – ebvtrnog Apr 11 '16 at 18:41
  • I get it. Sorry no, the tooling is bound to Visual Studio for fetching libraries used in the application. If you want to display packages during runtime, I guess you have to build this by yourself with for example HttpClient and invoking them manually – Hypnobrew Apr 11 '16 at 18:44
  • So you'd say that my *naive approach* above is the way to go? – ebvtrnog Apr 11 '16 at 18:46
  • Made an update to my answer. Maybe it can get you some boilerplate for your solution. – Hypnobrew Apr 11 '16 at 18:50
0

Bower is a package manager (sort of like NuGet). Just like NuGet, there is a Bower command line utility that can be used to download packages to your local file system. From there, you can add the folders to your project.

# install specific version of a package
$ bower install <package>#<version>

Also, just like NuGet, any packages you have in a local bower.json file...

{
  ... Other stuff omitted for brevity

  "license": "MIT",
  "ignore": [
    "**/.*",
    "node_modules",
    "bower_components",
    "*.json",
    ".git"
  ],
  "dependencies": {
    "jquery": ">= 1.4.2",
  "cldr-segments-modern": ">= 1.0.0"
  }
}

Then you can just use the install command to download them all at once.

$ bower install

Related:

NOTE: If you use Bower frequently from Visual Studio, you might consider How can I add a custom command to Visual Studio?

Community
  • 1
  • 1
NightOwl888
  • 55,572
  • 24
  • 139
  • 212