Bower + Rails and files in public folder - ruby-on-rails

I read a lot of articles how to integrate Rails and Bower. But what I need now basically, is little bit more complicated scenario. I have bower component with the following directory structure:
xx.js
xx.css
vendor
|- dir1
|---vendor-file-1.js
|---vendor-file-2.js
|- dir2
|- vendor-file.js
|- vendor-file.cab
|- vendor-file.jar
Basically, xx.js and xx.css is the component itself. But this component is usable only when vendor files are attached to the page with script tags. These vendor javascript files are using cab and jar files. I don't want to modify vendor files, and the path to cab and jar files is hardcoded in vendor-file.js (loaded from the same directory).
So I plan to use my component the standard bower-rails way. And I plan to attach vendor files to the page (when it's required) with script tags.
So, for this reason I need to put all of the vendor files into ./public folder.
I can try to configure it with .bowerrc and directory parameter. But in this case I don't know what to do with other components. Is there any way to configure bower to have "directory" parameter for each bower component and not for all of them?
Or any other ideas how to deal with cab and jar file if something is loading them from the same directory?

Related

Accessing assets in an Electron/Svelte project?

I've used Electron and Electron-Builder for a long time and am now learning Svelte and trying to use it in my projects. I've got the simple 'hello world' project up and running using this tutorial but I am confused about how to reference packaged assets– for example images or json files in an included 'assets' folder. An image of my directory structure is below.
If I console.log( __dirname); in my Svelte component I get /Users/UserName/electron_workspace/electron-app-svelte/public – which I understand is the compiled component context - but my 'assets' folder is in the 'src' directory.
Do I put my 'assets' folder in the 'public' directory rather than 'src'? (And I guess 'git-ignore' the 'build' folder?)
It looks like the simple (and obvious, I guess) answer is to store project assets in the 'public' directory of the project, per this 2021 article: Directory and files structure of Svelte projects
public folder
This folder holds the production ready files. So, if
your project has images, videos, other multimedia, svg etc. then they
all will be stored in this folder. When you run npm run build, Svelte
will compile your files, optimize them and store in build folder
within public folder. This build folder can be deployed to server.
I've always stored production assets in the project 'src' directory since that is what gets versioned/stored in git compared to the compiled 'dist' (build) directory which does not. I guess I will need to 'git-ignore' the 'build' directory.

How to specify `node_modules` from parent folder in `serverless.yml`?

In serverless.yml file, how can I include the modules from parent folder?
package:
include:
- ../node_modules/**
but the packaged zip file doesn't include the dependencies from parent node_modules folder. I have tried the plugin: https://www.npmjs.com/package/serverless-plugin-include-dependencies but it still doesn't work. None of dependencies from parent folder is packaged.
How can I change the dependencies folder directory when packaging my application? I also want to apply excluding devDependencies logic for the parent folder.
I'd suggest to package your functions individually in some side script & then run the serverless deploy.
Then you can easily fine-tune your packaging process and include the node_modules from your parent, excluding the dev dependencies.
package:
individually: true
functions:
sample:
package:
artifact: ../functions/sample/deploy/sample.zip
Another small benefit on this is, if you only want to update some function you can explicitly just repackage that one and run the serverless deploy much faster.

How I can register subdirectory of my vcs root as a bower module?

I have this project structure:
- .git
- test
--- unit
--- e2e
- sources
--- lib
--- js
I have this project structure. This is some library, that I want to share with other peoples. I want to register my code as bower module, so people can easy use my library.
Actually, bower module is only /sources/* contents. I don't want test directory to be published in bower module contents. I want only /sources/* contents to be published.
Note, I know that I can ignore some directories like test/ directory. After this when I do bower install moduleName I will got this structure:
- sources
--- lib
--- js
This is not what I want. I want to get sources contents.
Also, I tried to put bower.json into sources directory. After that:
I have problems with bower version <ver> (no tags are created)
I resolve full project structure, but only only contents of the dir with bower.json file
How to register bower module, so only contents of some subdirectory will be published?

bin subdirectories have no generated packages directories

I am using Dart 1.3.6 SDK and generated a typical command line application with a bin directory. The bin directory automatically gets its packages directory. However, none of the subdirectories of the bin directory gets any packages directory. As such I cannot import packages such as http that I am trying to use.
According to Dart's literature I think bin, test, web and example directories should all generate packages in there sub-directories. Yes?
I got the info that pub get should create these directories. I just created the symlinks manually when they were missing.
https://code.google.com/p/dart/issues/detail?id=16947
So far "entry points" in sub directories are not supported:
See also:
https://code.google.com/p/dart/issues/detail?id=18589
https://code.google.com/p/dart/issues/detail?id=17596

What relevance do folders have in a dart project?

When I create a sub folder in a Dart Project in Dart Editor, immediately a package subfolder is created inside this sub folder. I have not read anywhere that sub folders have a special meaning for the project structure, but it appears they do. Anybody knows more?
The package subfolder holds symlinks to your Pub packages. You can read more about Pub and Pub packages at http://pub.dartlang.org/doc/.
When you start a non-web project, the editor will automatically create package directories in your bin/ and test/ directories (but not in your lib/ directory). If you create a web project, a package directory is also created in the web/ folder.
If you add a Pub dependency in the pubspec.yaml file and run pub install, your will see that the package folders will contain symlinks to the Pub package you just installed. If you are using Dart Editor, pub install will automatically run once you modify your pubspec,yaml file.
If you create a subfolder inside any directory that contains one of these auto-generated package folders, the subfolder will get its own package directory. This way, you will have access to your Pub packages no matter how deeply you nest your code in a directory.
Shailen's answer is correct. I wanted to add a bit more, as the title of this question is "What relevance to folders have in a Dart project?"
Dart is designed to be very web friendly. Because there is no load path or classpath on the web, Dart apps must run without requiring an installation or pre-configuration of a local environment.
The only way you can link one file to another in Dart is via a URI. These URIs can be file URIs, and they can be relative. That means file A.dart can point to file B.dart via an absolute or relative path.
So, to answer you question, there is nothing special about a folder layout for Dart applications. The app will run as long as your Dart file can reference its dependencies via the same kind of linking rules that exist on the web (think <a href="" or <link src="").
However, pub (the Dart dependency manager) does make a few assumptions about package and application layout. If certain conventions are followed, pub can manage symlinks for you so that it's easier to reference 3rd party dependencies. Do you need to use pub? Nope, you can manually copy files around or manually manage symlinks. But pub certainly does make it easier to use packages, given the constraints of Dart's design (no load path, no classpath).

Resources