dart-lang / pub

The pub command line tool
https://dart.dev/tools/pub/cmd
BSD 3-Clause "New" or "Revised" License
1.04k stars 228 forks source link

Make pubspec.yaml optional #1718

Closed Meai1 closed 7 years ago

Meai1 commented 7 years ago

Problem: Requirement for project configuration in a special extra file called pubspec.yaml. This requires maintenance of files in a format that is not native to dart, installation of extra plugins for IDE, learning a new format ('yaml'). It makes the development of simple one-off scripts harder, where I now have to constantly keep another file around so that my script can run.

Solution: Move the config in form of a simple map/json into the main.dart file.

// @pubspec

import 'dart:async';

final PUB_SPEC = {
  "name" : "My project",
  "description": "new way to describe project config",
  "environment": {"sdk": '>=1.20.1 <2.0.0'},
  "dependencies": {
    "path": "^1.4.1",
    "petitparser": "^1.6.1",
    "xml": "^2.6.0",
    "barback": "^0.15.2",
    "shelf": "any",
    "shelf_web_socket": "any",
    "shelf_route": "any",
  },
  "transformers": {"dart_server_test": {}}
};
void main() {
    print("No pubspec.yaml necessary!");
}

Pros:

Cons:

nex3 commented 7 years ago

I understand that it produces some amount of overhead, but YAML is a widely-used and well-defined format that's a lot less verbose than manually writing data structures. I don't think this change would ultimately make many peoples' lives that much easier, and it would certainly make plenty of users' lives harder as well.