Giter Site home page Giter Site logo

vpm's Introduction

vpm

(Available Chinese README version) | (Available Portuguese README version)

vpm(0.0.2) is a package manager for V, written on V.

  • The package is now downloaded to the ~/.vmodules directory.

Requirements

  • V compiler >=v0.1.23.
  • Install git, because the package is currently downloaded via git clone.

Building

$ git clone https://github.com/yue-best-practices/vpm
$ cd vpm
$ v -prod .

CLI Usage

Command Params Description
-v/version Show vpm version
init <project-name> Initialize project (create the vpm.json file)
get <git-url> <pkg-name> Fetch package from the git repo (add dependency to the vpm.json.
install Install the package from the vpm.json file.
-h/help Show help information.
clean Delete the vpm.json file.
ls Show installed packages list
rm <package-name>... Remove packages in the vpm.json file by name

Packages

For an overview of all the available and supported packages, you can look at VPM Repository.

Example

Here is an example of using the vargs package.

  • Make project directory test
$ mkdir test
$ cd test
  • Init vpm.json
$ vpm init
  • Write example code
$ vim main.v
import vargs
import os

fn main() {
    _args := vargs.parse(os.args, 1)
    println(_args.str())
    println(_args.command)
    println(_args.unknown[0])
}
  • Install args package
$ vpm get https://github.com/nedpals/v-args vargs
  • Build
$ v -prod main.v
  • Run
$ ./main hello world
{ command: hello, options: {}, unknown: ["world"] }
hello
world

vpm's People

Contributors

bowero avatar chronosxyz avatar smartyue avatar vbrazo avatar waozi-dev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vpm's Issues

网站上没法提交 module

你好,
我开发了一个 web 框架,想发布到 vpm 上。
我在 https://vpm.best 上先点 Submit a module。
然后点 Log in via GitHub。
跳转授权都正常的,但是最后 redirect 回 https://vpm.best/new 并没有登录上,页面依旧是没登陆的样子。

我要提交的 module 叫 valval,是一个 web 开发框架。
官网地址是 https://valval.cool/
github 地址是 https://github.com/taojy123/valval

希望能吸纳我这项目进 vpm
谢谢!

Feature: Install modules in project folder

Since V 0.1.12, V searches for modules in the current directory before looking in VROOT/vlib.

Due to this feature, I suggest to only install packages in the project directory rather then gobaly (atleast without a --global or -g flag [like npm i -g]).

Compile time example:

$ ls
app.v
modulea/
moduleb/

$ cat modulea/module.v
module modulea

pub fn hello() {
print('Hello ')
}

$ cat moduleb/module.v
module moduleb

pub fn world() {
println('world!')
}

$ cat app.v
module main
import modulea
import moduleb

fn main() {
modulea.hello()
moduleb.world()
}

$ v run app.v
============ running app ============
Hello world!

Installation not working on Mac

When I run

v -prod .

I get:

./array.v:8:14: warning: use `x := []Type{}` instead of `x := []Type`
    6 | // []string 去重
    7 | fn string_array_distinct(arr []string)[]string{
    8 |     mut res:=[]string
      |              ~~~~~~~~
    9 |     for v in arr{
   10 |         if !v in res{
./command.v:115:15: warning: use `x := []Type{}` instead of `x := []Type`
  113 |         return 
  114 |     }
  115 |     mut pkgs:=[]PkgInfo
      |               ~~~~~~~~~
  116 |     mut rm_names:=[]string
  117 |     for p in store.packages{
./command.v:116:19: warning: use `x := []Type{}` instead of `x := []Type`
  114 |     }
  115 |     mut pkgs:=[]PkgInfo
  116 |     mut rm_names:=[]string
      |                   ~~~~~~~~
  117 |     for p in store.packages{
  118 |         if !p.name in names{
./util.v:124:31: warning: `fn f(x, y Type)` syntax has been deprecated and will soon be removed. Use `fn f(x Type, y Type)` instead. You can run `v fmt -w "./util.v"` to automatically fix your code.
  122 | 
  123 | // 通过git下载包
  124 | fn fetch_pkg_from_git(lib_name,git_url string)PkgInfo{
      |                               ^
  125 |     pkg_info:=PkgInfo{name:lib_name,repo:git_url}
  126 |     lib_path:=get_vlib_path()+'/$lib_name'
./vpm.v:3:5: warning: const names cannot contain uppercase letters, use snake_case instead
    1 | module main
    2 | const (
    3 |     PKG_NAME = 'vpm.json'
      |     ~~~~~~~~
    4 |     VERSION = '0.0.2'
    5 |     VROOT = get_v_root_path()
./vpm.v:4:5: warning: const names cannot contain uppercase letters, use snake_case instead
    2 | const (
    3 |     PKG_NAME = 'vpm.json'
    4 |     VERSION = '0.0.2'
      |     ~~~~~~~
    5 |     VROOT = get_v_root_path()
    6 | )
./vpm.v:5:5: warning: const names cannot contain uppercase letters, use snake_case instead
    3 |     PKG_NAME = 'vpm.json'
    4 |     VERSION = '0.0.2'
    5 |     VROOT = get_v_root_path()
      |     ~~~~~
    6 | )
    7 |
./array.v:10:12: error: ! operator can only be used with bool types
    8 |     mut res:=[]string
    9 |     for v in arr{
   10 |         if !v in res{
      |            ^
   11 |             res<<v
   12 |         }
./command.v:118:12: error: ! operator can only be used with bool types
  116 |     mut rm_names:=[]string
  117 |     for p in store.packages{
  118 |         if !p.name in names{
      |            ^
  119 |             pkgs<<p
  120 |         }else{
./util.v:31:8: error: os.rm() returns an option, so it should have either an `or {}` block, or `?` at the end
   29 | // 删除包管理文件
   30 | fn rm_store_path(){
   31 |     os.rm(get_store_path())
      |        ~~~~~~~~~~~~~~~~~~~~
   32 | }
   33 |
./util.v:41:15: error: unknown function: os.filename
   39 | // 获取项目默认名称(当前所在目录名称)
   40 | fn get_default_project_name()string{
   41 |     return os.filename(os.getwd())
      |               ~~~~~~~~~~~~~~~~~~~~
   42 | }
   43 |
./util.v:62:18: error: unknown function: os.filename
   60 | // 从git url 上获取 lib 名称
   61 | fn get_lib_name(git_url string)string{
   62 |     mut name:=os.filename(git_url)
      |                  ~~~~~~~~~~~~~~~~~
   63 |     if name.ends_with('.git'){
   64 |         name=name.replace('.git','')
./util.v:63:13: error: non-bool type `void` used as if condition
   61 | fn get_lib_name(git_url string)string{
   62 |     mut name:=os.filename(git_url)
   63 |     if name.ends_with('.git'){
      |             ~~~~~~~~~~~~~~~~~
   64 |         name=name.replace('.git','')
   65 |     }
./util.v:64:13: error: assignment mismatch: 1 variable(s) but `replace()` returns 0 value(s)
   62 |     mut name:=os.filename(git_url)
   63 |     if name.ends_with('.git'){
   64 |         name=name.replace('.git','')
      |             ^
   65 |     }
   66 |     return name
./util.v:66:12: error: cannot use `void` as type `string` in return argument
   64 |         name=name.replace('.git','')
   65 |     }
   66 |     return name
      |            ~~~~
   67 | }
   68 | // 检测是否是git url
./util.v:80:16: error: cannot use `string` as `[]byte` in argument 1 to `os.File.write`
   78 |         return 
   79 |     }
   80 |     file.write(content)
      |                ~~~~~~~
   81 |     file.close()
   82 | }
./util.v:134:17: error: function `os.exec` has been deprecated; use os.execute or os.execute_or_panic instead
  132 |     // clone lib
  133 |     println('fetching "$lib_name" from "$git_url" ...')
  134 |     git_res:=os.exec('git clone $git_url $lib_path') or {
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  135 |         println('fetch failed')
  136 |         return PkgInfo{name:'',repo:''}

Add a license

From the GitHub FAQs:

You're under no obligation to choose a license. However, without a license, the default copyright laws apply, meaning that you retain all rights to your source code and no one may reproduce, distribute, or create derivative works from your work. If you're creating an open source project, we strongly encourage you to include an open source license.

Please add a license so others can use / contribute.

Error on compile: ./command.v:99:25: function `right` is private

When I try to compile vpm, I get this error:

[bowero]% v -prod .
failed to create /tmp/v/vpm.tmp.c
./command.v:99:25: function `right` is private
   97| 
   98| fn cmd_rm(args []string){
   99|     mut names:=args.right(2)
                               ^
  100|     if names.len==0{
  101|         println('nothing to remove')

Make vpm.json visible like package.json

For me it makes more sense to be able to see the vpm.json file (like the package.json of NPM).

The current name is .vpm.json which makes it invisiable when using default settings on most file managers.

It makes no sense to not be able to see your package list/project file, does it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.