外观
stackhub
原文: https://finproducts.atlassian.net/wiki/spaces/JIDD3/pages/34794012678/FIN+5.3.1+stackhub 中文整理基于 FIN 5.3.1
导读: 此库提供 Fantom API,以便与 https://stackhub.org 进行接口连接。
以下为 API 参考,保留英文以便对照源码;目录已列出(英文标题便于检索);概述已尽量中译。
目录(导读)
- classes
- docs
- Overview
- Publishing
- Slot Details
- make
- password
- releaseStatus
- run
- username
- call
- download
- liveUri
- log
- packageRead
- ping
- publish
- publishPod
- socketConfig
- uri
- err
- extToFault
- file
- id
- isValid
- licensee
- list
- mod
- org
- product
- prop
- props
- vendor
API 正文(英文)
Overview
This library provides the Fantom APIs to interface to https://stackhub.org.
Publishing
To publish a Fantom pod to StackHub you will need to first register your package name on https://stackhub.org. Your package name must match the name of your pod. Package names must be approved, so follow good naming conventions such as prefixing your pod with a project or organization name. Also make sure your package is tagged with fanPod and any other other tags which are appropriate.
In your pods build's script add this target:
@Target { help = "Publish to stackhub.org " }
Void publish() { stackhub::PublishTask(this).run }That will add a new build target which you can run from the command line like this:
build.fan publishThe task will prompt you for your StackHub username and password, and then publish your pod using its current version. You will need to make sure that you give each version published a unique version number. You can hardcode the username and/or password in your build script, or you could get them from environment variables like this:
@Target { help = "Publish to stackhub.org " }
Void publish()
{
task := stackhub::PublishTask(this)
// hardcode username/password
task.username = "wizard@acme.com"
task.password = "secret"
// get username/password from ENV variables
// task.username = Env.cur.vars["STACKHUB_USERNAME"]
// task.password = Env.cur.vars["STACKHUB_PASSWORD"]
task.run
}If your pod defines a pod.fandoc file, then it is automatically converted to a markdown file called readme.md file and your pod is rewritten before publishing. It will then become the documentation show on your package's StackHub page.
PublishTask
class PublishTask : Task
Build task to publish BuildPod's pod file to stackhub.
Constructors
| make |
Fields
| password | Preconfigured stackhub password (prompt if null) |
| releaseStatus | Set to one of alpha, beta, or released. |
| username | Preconfigured stackhub username (prompt if null) |
Methods
| run |
Slot Details
make
new make(BuildPod script)
password
Str? password
Preconfigured stackhub password (prompt if null)
releaseStatus
Str releaseStatus := "released"
Set to one of alpha, beta, or released. Packages will default to released if this is an invalid string.
run
virtual override Void run()
username
Str? username
Preconfigured stackhub username (prompt if null)
StackHubClient
class StackHubClient : Obj
StackHubClient provides an interface to http://stackhub.org
Constructors
| make | Construct with given credentials and log |
Fields
| liveUri | |
| log | Logging |
| password | Password to use or null for anonymous public access |
| socketConfig | Socket option |
| uri | Site URI |
| username | Username to use or null for anonymous public access |
Methods
| call | Make Haystack op call |
| download | Download a package version to a local file |
| packageRead | Perform package read using given search string. |
| ping | Ping the client to ensure connectity and return about dict |
| publish | Publish a local file to StackHub. |
| publishPod | Publish a pod file. |
Slot Details
call
Grid call(Str op, Grid req := Etc.makeEmptyGrid())
Make Haystack op call
download
Void download(Str name, Version version, File dest)
Download a package version to a local file
liveUri
const static Uri liveUri := `https://nosni.stackhub.org`
log
const Log log := Log.get("stackhub")
Logging
make
new make(|This|? f := null)
Construct with given credentials and log
packageRead
Grid packageRead(Str search := "", Str filter := "fanPod")
Perform package read using given search string. By default we filter to include only fantom pods.
password
const Str? password
Password to use or null for anonymous public access
ping
Dict ping()
Ping the client to ensure connectity and return about dict
publish
Grid publish(Dict meta, File file)
Publish a local file to StackHub. This is low-level method to publish any file; use publishPod if the file is a Fantom pod.
publishPod
Grid publishPod(File podFile, Dict meta := Etc.emptyDict())
Publish a pod file. The pod's meta is automatically extracted to populate the package meta and merged into the given meta.
socketConfig
SocketConfig socketConfig := SocketConfig.cur().setTimeouts(30sec)
Socket option
uri
const Uri uri := liveUri
Site URI
username
const Str? username
Username to use or null for anonymous public access
StackHubLic
const class StackHubLic : Obj
StackHubLic provides an API to work with a digitally signed license issued by http://stackhub.org
Methods
| err | Reason entire license file is invalid |
| extToFault | Put the given extension into license fault |
| file | Backing file on file system |
| id | Unique identifier for this license file |
| isValid | Is entire license file valid. |
| licensee | Who owns this licensee |
| list | List licenses installed in the given system |
| mod | Last modified time of license |
| org | Org responsible for this license |
| product | Product identifier and display name |
| prop | Get a property by name or raise NameErr if checked |
| props | Name/value props |
| vendor | Product vendor identifier and display name |
Slot Details
err
Str? err()
Reason entire license file is invalid
extToFault
static Void extToFault(Ext ext, Str msg)
Put the given extension into license fault
file
File file()
Backing file on file system
id
Str id()
Unique identifier for this license file
isValid
Bool isValid()
Is entire license file valid.
licensee
Str licensee()
Who owns this licensee
list
static StackHubLic[] list(Sys sys)
List licenses installed in the given system
mod
DateTime mod()
Last modified time of license
org
Ref org()
Org responsible for this license
product
Ref product()
Product identifier and display name
prop
Str? prop(Str name, Bool checked := true)
Get a property by name or raise NameErr if checked
props
Str:Str props()
Name/value props
vendor
Ref vendor()
Product vendor identifier and display name