Skip to content

Static Files Block - Embed files into project (such as a Go executable project)

License

Notifications You must be signed in to change notification settings

ddosakura/sblock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sblock - Static Files Block

Embed files into project (such as a Go executable project).

This package was inspired by the statik and the need like #56.

The package includes:

  • sblocker: the cli of code generater
  • sbi: the interface
  • plugins: the plugin to generate code
  • libs: the library to use the code block

If you use golang - origin/zip/default, the code generated is compatible with statik

Usage

Install the command line tool first.

go get -v -u github.com/ddosakura/sblock/sblocker

See the help

sblocker -h

Official plugin and library (lang/algorithm)

  • golang

    • origin - Do not use compression to shrink the files.
    • zip/default
  • js

    • origin
    • zip/default
  • The Catalog of Libs

How to implement Plugin

The plugin needs:

  • Compression algorithm by golang
  • The Code and Example pattern which will be generated

The library needs:

  • Decompression algorithm by your language
  • A FileSystem Abstraction System for you language like afero to save your files

First, you should implement the interface:

// github.com/ddosakura/sblock/sbi/interface.go
type Plugin interface {
    ...
}

Warning:

  • If you not only have SourceFile and ExampleFile, you should deal the force flag

Then you need to provide a library to use the code generated.

Warning:
Rather than providing a library that uses sblock, I prefer to support it directly in a virtual file system.
On this point, you can track the development of aferox

TODO

  • split library and plugin
  • custom parameters for plugin
  • the description for custom parameters
  • add official nodejs/js plugin
    • sblock4js
    • sblock4koa
    • sblock-web-driver
      • custom param no-dump raw-name
    • print the explain to use yarn/npm
  • overwrite should not delete the target folder
    • the type Plugin interface need ForceOverwrite param
  • the template to develop sblock-plugin

About

Static Files Block - Embed files into project (such as a Go executable project)

Resources

License

Stars

Watchers

Forks

Packages

No packages published