Example #1
0
// GetEngineVersion 获取引擎版本
func (v *Version) GetEngineVersion() string {
	// 遍历所有文件,查看是否有 project.manifest 文件
	for _, item := range v.items {
		// 如果等于指定文件名
		if strings.EqualFold("project.manifest", fp.Base(item.name)) {
			filename := v.Path + "/" + item.name
			f, _ := ioutil.ReadFile(filename)
			mf := manifest.NewManifest()
			mf.Unmarshal(f)
			return mf.GetEngineVersion()
		}
	}
	return ""
}
Example #2
0
// Publish 发布资源
func (c *Channel) Publish(host, engine string) {
	if len(c.versions) <= 1 {
		fmt.Println("没有要发布的资源")
		return
	}
	channelpath := c.pubpath + "/" + c.name
	util.CheckOrCreateDir(channelpath)

	// 设置源版本
	vsrc := c.versions[0]

	mf := manifest.NewManifest()
	// 基本设置
	mf.SetURL(host + "/" + c.name)
	mf.SetVersion(vsrc.Name)
	mf.SetEngineVersion(engine)

	// 变化从 1 索引开始,0 对比 1
	for i := 1; i < len(c.versions); i++ {
		// 目标版本
		vtar := c.versions[i]
		chg := NewChange(c.name, vsrc, vtar)
		zipfile := chg.ArchiveZip(c.pubpath)

		mf.AddGroupVersion(vtar.Name)
		md5, _ := util.GetFileMD5(channelpath + "/" + zipfile)
		mf.AddAsset(zipfile, md5)

		vsrc = vtar
	}

	path := c.pubpath + "/" + c.name + "/"
	con, _ := mf.MarshalMini()
	_ = ioutil.WriteFile(path+"version.manifest", con, 0644)
	// fmt.Println(string(con))
	con, _ = mf.Marshal()
	_ = ioutil.WriteFile(path+"project.manifest", con, 0644)
}