bin subdirectories have no generated packages directories - dart

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

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.

Prevent TFS of detecting packages contents in different folders

I've used .tfignore and Nuget.config solution to prevent tfs of detecting changes in packages folder, at the moment it is not detecting the packages folder changes anymore but whenever I add a new package or update the existing one it will detect the changes in possibly Scripts or Content folders. The problem is I cannot explicitly ignore the Scripts and Content folders because there are some custom scripts that have to be checked-in, what I would prefer is just somehow to ignore the scripts caused by package change?
You can ignore the specify files or include specify files in Scripts and Content folders. For example:
#Ignore .cpp files in the ProjA sub-folder and all its subfolders
ProjA\xxx.cpp
# Do not ignore .dll files in this folder nor in any of its sub-folders
!xxx.dll

Is there a way to disable all those symlinks to the packages directory?

I am using the Dart Eclipse plugin following this guide:
http://blog.dartwatch.com/2013/01/integrating-dart-into-eclipse-and-your.html
( without the Maven integration )
If I use the pubspec.yaml file, my project gets spammed with these packages symlinks.
( I am using the "Package Explorer" view from Eclipse )
I would like some control over where these files get created.
I would argue the web root directory and maybe a scripts directory should be enough.
Currently, no, there is no way to control which directories get "packages" directories and which don't. Pub will place "packages" directories in "bin", "example", "test", "tool", and "web", and any subdirectory of those.
Those are all of the directories where a package may be expected to have a Dart entrypoint. Since an entrypoint needs a "packages" directory next to it to be able to use "package:" imports, pub will place one there.
It won't place "packages" directories anywhere else.
I would argue the web root directory and maybe a scripts directory should be enough.
"tool" is pub's convention for a "scripts" directory.
I found the code that generates these directories in dart-sdk\util\pub\entrypoint.dart.
There is a method called: _linkSecondaryPackageDir.
If I add: if (path.basename(dir) != 'web') return;
The packages folder only gets created in the root folder and the web folder, just like I want.
I will test if this breaks anything and report back.

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