• Stars
    star
    435
  • Rank 100,085 (Top 2 %)
  • Language
    Dart
  • License
    MIT License
  • Created over 5 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Self-hosted private Dart Pub server for Enterprise

Unpub

pub

Unpub is a self-hosted private Dart Pub server for Enterprise, with a simple web interface to search and view packages information.

Screenshots

Screenshot

Usage

Command Line

pub global activate unpub
unpub --database mongodb://localhost:27017/dart_pub # Replace this with production database uri

Unpub use mongodb as meta information store and file system as package(tarball) store by default.

Dart API is also available for further customization.

Dart API

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}');
}

Options

Option Description Default
metaStore (Required) Meta information store -
packageStore (Required) Package(tarball) store -
upstream Upstream url https://pub.dev
googleapisProxy Http(s) proxy to call googleapis (to get uploader email) -
uploadValidator See Package validator -

Usage behind reverse-proxy

Using unpub behind reverse proxy(nginx or another), ensure you have necessary headers

proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

# Workaround for: 
# Asynchronous error HttpException: 
# Trying to set 'Transfer-Encoding: Chunked' on HTTP 1.0 headers
proxy_http_version 1.1;

Package validator

Naming conflicts is a common issue for private registry. A reasonable solution is to add prefix to reduce conflict probability.

With uploadValidator you could check if uploaded package is valid.

var app = unpub.App(
  // ...
  uploadValidator: (Map<String, dynamic> pubspec, String uploaderEmail) {
    // Only allow packages with some specified prefixes to be uploaded
    var prefix = 'my_awesome_prefix_';
    var name = pubspec['name'] as String;
    if (!name.startsWith(prefix)) {
      throw 'Package name should starts with $prefix';
    }

    // Also, you can check if uploader email is valid
    if (!uploaderEmail.endsWith('@your-company.com')) {
      throw 'Uploader email invalid';
    }
  }
);

Customize meta and package store

Unpub is designed to be extensible. It is quite easy to customize your own meta store and package store.

import 'package:unpub/unpub.dart' as unpub;

class MyAwesomeMetaStore extends unpub.MetaStore {
  // Implement methods of MetaStore abstract class
  // ...
}

class MyAwesomePackageStore extends unpub.PackageStore {
  // Implement methods of PackageStore abstract class
  // ...
}

// Then use it
var app = unpub.App(
  metaStore: MyAwesomeMetaStore(),
  packageStore: MyAwesomePackageStore(),
);

Available Package Stores

  1. unpub_aws: AWS S3 package store, maintained by @CleanCode.

Badges

URL Badge
/badge/v/{package_name} badge example badge example
/badge/d/{package_name} badge example

Alternatives

  • pub-dev: Source code of pub.dev, which should be deployed at Google Cloud Platform.
  • pub_server: An alpha version of pub server provided by Dart team.

Credits

License

MIT

More Repositories

1

hashmd

Hackable Markdown Editor and Viewer (WIP)
TypeScript
4,343
star
2

git-touch

An open-source app for GitHub, GitLab, Bitbucket, Gitea, and Gitee(码云), built with Flutter
Dart
1,560
star
3

debugtron

Debug in-production Electron based app
TypeScript
1,359
star
4

octohint

The missing IntelliSense hint for GitHub and GitLab
TypeScript
962
star
5

console-importer

Easily import JS and CSS resources from Chrome console.
TypeScript
857
star
6

vite-plugin-svgr

Vite plugin to transform SVGs into React components
TypeScript
540
star
7

chrome-ui

Chrome browser UI built with web technologies
JavaScript
237
star
8

json-viewer

Port of Firefox's JSON Viewer for Chromium-based Browsers
JavaScript
221
star
9

npmview

A web application to view npm package files
TypeScript
130
star
10

http-indicator

Indicator for HTTP/2, QUIC and HTTP/3
TypeScript
101
star
11

tiza

Console styling for browsers
TypeScript
86
star
12

system-monitor

A browser extension to monitor system status like CPU and memory
TypeScript
81
star
13

flutter-vector-icons

Customizable Icons for Flutter. Port of react-native-vector-icons
Dart
78
star
14

friendly-error

Show uncaught errors friendly in Node.js.
JavaScript
73
star
15

lottiefy

Render Lottie to any engine
JavaScript
62
star
16

octoview

The missing preview feature for GitHub
TypeScript
53
star
17

nanoid-dart

Dart implementation of ai/nanoid
Dart
48
star
18

tampery

A programmable tool to tamper browser requests
TypeScript
33
star
19

cnode-pwa

Progressive Web App for CNode community
TypeScript
32
star
20

echojs-reader

Open source EchoJS reader built with React Native
ReScript
24
star
21

nn

A full featured, cross platform, zero dependencies Node.js version manager
JavaScript
20
star
22

memcached-cli

A simple memcached CLI tool with SASL support
JavaScript
16
star
23

promisify-all

Promisify all Node.js builtin async methods
JavaScript
14
star
24

ant-design-mobile-flutter

Flutter implementation of Ant Design Mobile
Dart
14
star
25

cnode-weapp

WeChat APP for CNode community.
JavaScript
12
star
26

memory-monitor

Moved to https://github.com/pd4d10/system-monitor
JavaScript
11
star
27

moment

Dart
10
star
28

dart-hn

Hacker News PWA built with AngularDart
Dart
9
star
29

flutterdoc

Generate gallery for your Flutter widgets with one command
Dart
9
star
30

userscript-meta

Parse and stringify Userscript metadata.
JavaScript
7
star
31

electron-update-notification

Update notifier for open source Electron apps
TypeScript
5
star
32

devtron-next

Deprecated, see https://github.com/electron-userland/devtron/pull/221
TypeScript
3
star
33

gulp-userscript

Generate Userscript metadata.
JavaScript
3
star
34

nes

WIP
Dart
3
star
35

pd4d10

2
star
36

graphyne

TypeScript
2
star
37

unplugin-properties

TypeScript
2
star
38

airplay

Airplay
JavaScript
1
star
39

qrcode-helper

A Chrome extension to generate and read QRCode
TypeScript
1
star
40

express-server-timing

[DEPRECATED] Add server timing header for express
JavaScript
1
star
41

prettier-plugin-thrift

Prettier Thrift Plugin
TypeScript
1
star
42

device-art

Wrap app screenshots in device artwork
JavaScript
1
star
43

rescript-webext

ReScript bindings for Web Extensions
ReScript
1
star
44

teambition-enhancer

Copy Teambition task link URL
JavaScript
1
star
45

uppjs

Unity PlayerPrefs parser and dumper in JavaScript
TypeScript
1
star