Skip to content

Instantly share code, notes, and snippets.

@lymanlai
Created April 29, 2020 08:23
Show Gist options
  • Save lymanlai/e57b5cb62ef17ca391318fa837da97b9 to your computer and use it in GitHub Desktop.
Save lymanlai/e57b5cb62ef17ca391318fa837da97b9 to your computer and use it in GitHub Desktop.
setup dart private mirror
  1. put credentials.json into the pub cache folder to make a fake credentials for prevent pub command to promot to google oauth
  2. dart main.dart
  3. pub publish
{"accessToken":"fake","refreshToken":"fake","tokenEndpoint":"https://accounts.google.com/o/oauth2/token","scopes":["openid","https://www.googleapis.com/auth/userinfo.email"],"expiration":2588150347472}
import 'package:unpub/unpub.dart' as unpub;
main(List<String> args) async {
var basedir = './data'; // Base directory to save pacakges
var db = 'mongodb://user:pwd@ip:port/dart_pub?authSource=admin'; // MongoDB uri
var metaStore = unpub.MongoStore(db);
await metaStore.db.open();
var packageStore = unpub.FileStore(basedir);
var app = unpub.App(
metaStore: metaStore,
packageStore: packageStore,
upstream: 'https://pub.flutter-io.cn',
overrideUploaderEmail: 'lyman.lai@yaha.me'
);
var server = await app.serve('0.0.0.0', 4000);
print('Serving at http://${server.address.host}:${server.port}');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment