Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single-file packages #103

Closed
carlor opened this issue Aug 17, 2013 · 6 comments
Closed

Single-file packages #103

carlor opened this issue Aug 17, 2013 · 6 comments

Comments

@carlor
Copy link
Contributor

carlor commented Aug 17, 2013

(Note: I'd post it to the newsgroup, but issue #8 prevents me)

Problem

When dealing with large libraries including multiple files, sub-packages, and so on, dub is well-designed and easy to use. There is one target audience, however, where the user interface could be simpler: packages with only a single file.

The current choice offered is either to make one repository for every single-file package (e.g. my own embd), or to lump together several often unrelated packages into one repo (e.g. the great arsd). The former option is clunky, and the latter requires users to download and compile several modules they won't need. Another option is needed.

Solution

An SFP is a folder named example with a single file inside named example.d (not including .git, etc). Somewhere in the file will be a comment like so:

/+
dub:
 {
     ...what would be in package.json...
 }
+/

This file could be automatically generated by:

$ dub init --sfp example
    create folder example
    create file example/example.d

Questions

Here's some additional ideas:

  • Requiring that the packages be sfp/[name] in the repository?
  • Adding support for gist and dpaste?
  • An option to generate a symlink in the parent folder: example.d -> example/example.d

School's about to start, so I'll be slow, but I'm willing to work on it.

Thoughts?
NMS

@s-ludwig
Copy link
Member

Forgot to mention: I've made a basic comment on the forum. I'll try and sit down to properly think about it in the coming days. The spam detection situation has been improved and there are at least much less false positives.

@MartinNowak
Copy link
Member

An SFP is a folder named example with a single file inside named example.d (not including .git, etc). Somewhere in the file will be a comment like so

You should be really able to just run dub example.d or dub build example. Putting the configuration in a comment or in a string makes sense. It should not require any config though, i.e. the only mandatory config name should be deduced from the filename.

#!/usr/bin/env dub
/* PACKAGE_CFG
{
    "dependencies" : {
        "vibe-d": ">=0.7.11"
    }
}
*/
import vibe.d;

void handleRequest(HTTPServerRequest req,
                   HTTPServerResponse res)
{
    res.writeBody("Hello, World!", "text/plain");
}

shared static this()
{
    auto settings = new HTTPServerSettings;
    settings.port = 8080;

    listenHTTP(settings, &handleRequest);
}

@MrSmith33
Copy link
Contributor

It's nice-to-have feature. I really like it!

@MartinNowak
Copy link
Member

Anyone working on this?

@s-ludwig
Copy link
Member

Not aware of anyone.

BTW, considering the pending SDL format implementation, it would be good to encode the format in the comment, for example /* dub.json: ....

@Abscissa
Copy link
Contributor

or to lump together several often unrelated packages into one repo (e.g. the great arsd)[...]requires users to download and compile several modules they won't need.

I know I keep harping on it, but this option would not be a problem if dub packages had the ability to tell dub "Don't compile any of my files that aren't actually imported, rdmd-style". For MANY packages, the extra build time involved would be trivial. Larger packages that have longer compile times would NOT be under any obligation to to actually use this option and could freely stick with the current "all files" behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants