-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yangyuan
committed
Jul 4, 2023
1 parent
addd43d
commit d0a3ede
Showing
96 changed files
with
39,464 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from dart | ||
|
||
WORKDIR /app | ||
COPY . ./ | ||
RUN dart pub get | ||
ENTRYPOINT ["dart", "run", "bin/unpub.dart", "--database", "mongodb://mongo:27017/dart_pub"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import 'dart:io'; | ||
import 'package:path/path.dart' as path; | ||
import 'package:args/args.dart'; | ||
import 'package:mongo_dart/mongo_dart.dart'; | ||
import 'package:unpub/unpub.dart' as unpub; | ||
|
||
main(List<String> args) async { | ||
var parser = ArgParser(); | ||
parser.addOption('host', abbr: 'h', defaultsTo: '0.0.0.0'); | ||
parser.addOption('port', abbr: 'p', defaultsTo: '4000'); | ||
parser.addOption('database', abbr: 'd', defaultsTo: 'mongodb://localhost:27017/dart_pub'); | ||
|
||
var results = parser.parse(args); | ||
|
||
var host = results['host'] as String?; | ||
var port = int.parse(results['port'] as String); | ||
var dbUri = results['database'] as String; | ||
|
||
if (results.rest.isNotEmpty) { | ||
print('Got unexpected arguments: "${results.rest.join(' ')}".\n\nUsage:\n'); | ||
print(parser.usage); | ||
exit(1); | ||
} | ||
|
||
final db = Db(dbUri); | ||
await db.open(); | ||
|
||
var baseDir = path.absolute('unpub-packages'); | ||
|
||
var app = unpub.App( | ||
metaStore: unpub.MongoStore(db), | ||
packageStore: unpub.FileStore(baseDir), | ||
); | ||
|
||
var server = await app.serve(host, port); | ||
print('Serving at http://${server.address.host}:${server.port}'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
version: '3.3' | ||
services: | ||
unpub: | ||
build: ./ | ||
container_name: unpub | ||
restart: always | ||
ports: | ||
- 4000:4000 | ||
volumes: | ||
- ~/.unpub-packages:/app/unpub-packages | ||
depends_on: | ||
- mongo | ||
mongo: | ||
image: mongo:4.2.19 | ||
container_name: unpub_mongo | ||
restart: always | ||
volumes: | ||
- ~/.unpub_mongo:/data/db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import 'package:mongo_dart/mongo_dart.dart'; | ||
import 'package:unpub/unpub.dart' as unpub; | ||
|
||
main(List<String> args) async { | ||
final db = Db('mongodb://localhost:27017/dart_pub'); | ||
await db.open(); // make sure the MongoDB connection opened | ||
|
||
final app = unpub.App( | ||
metaStore: unpub.MongoStore(db), | ||
packageStore: unpub.FileStore('./unpub-packages'), | ||
); | ||
|
||
final server = await app.serve('0.0.0.0', 4000); | ||
print('Serving at http://${server.address.host}:${server.port}'); | ||
} |
Oops, something went wrong.