npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

layacmd

v2.1.23

Published

layaair toolkit

Downloads

84

Readme

@ -1,271 +0,0 @@

layacmd

[TOC]

layacmdlayaair的命令行工具,可以使用layacmd不打开IDE的情况下对layaair项目进行编译发布等操作。它包含以下功能,这些功能都对应一个子命令。

| 功能 | 子命令 | | -------------- | --------------- | | 编译 | compile | | 发布 | publish | | 导出UI | ui | | 资源版本控制 | resourceVersion | | 使用guetzli压缩jpg | guetzli | | 打开静态文件服务器 | open |

安装

$ npm install layacmd -g

CLI

layacmd的命令类似git命令,它的形式是:

$ layacmd [command] [args]

比如编译项目:

$ layacmd compile

或者查看帮助信息:

$ layacmd --help

不仅layacmd本身,所有的子命令都有版本信息和帮助信息,查看子命令帮助信息:

$ layacmd command -h

layacmd的大部分子命令都需要当前工作目录下包含layaair项目,少数命令可以手动指定输入目录,如guetzlatlas命令则是即可以直接$ layacmd atlas,也可以指定输入目录。

编译

$ layacmd compile -h

  Usage: layacmd-compile [options]

  Options:

    -h, --help     output usage information
    -V, --version  output the version number

如果当前目录有layaair项目,该命令会生成编译后的JavaScript文件。编译只有ActionScriptTypeScript项目需要,如果是JavaScript,则什么也不做。

使用

$ layacmd copmile

发布

$ layacmd publish -h

  Usage: layacmd-publish [options]

  Options:

    -V, --version                   output the version number
    -o --compressOptions <options>  压缩选项。留空不处理,'c'表示压缩,'cc'表示压缩并合并
    -n --versionName <name>         version name
    --noCompile                     不重新编译项目
    --noUi                          不重新生成UI代码文件
    --noAtlas                       不重新生成图集
    -h, --help                      output usage information

如果当前目录有layaair项目,该命令会生成发布后的JavaScript文件,发布的文件夹在release下面。

使用

$ layacmd publish -o cc # 指定了压缩选项为合并并压缩

导出UI

$ layacmd ui -h

  Usage: layacmd-ui [options]

  Options:

    -V, --version     output the version number
    -c --clear        clear will delete old ui code file.
    -a --atlas        generate atlas
    -d --code         generate ui code files
    -m --mode <mode>  'normal'或者'release',指定'release'会生成除未使用资源外的UI代码文件
    -h, --help        output usage information

如果当前目录有layaair项目,该命令为UI页面导出与UI相关的文件。

使用

$ layacmd ui -c -m release # 导出前清理,并且把mode设置为release
$ layacmd ui -d # 导出UI代码文件
$ layacmd ui -a # 导出图集文件

资源版本控制

资源版本控制用于为资源生成版本。版本号默认从数字1000开始递增,如果传入--versionName参数,则使用用户指定的版本名称。下次建立建立版本时如果没有再次指定--name,版本号为1002,因为每次生成版本,资源版本控制内部版本计数器都会递增。

在建立版本时,相对于上次版本建立,修改了的文件或者新增的文件会被记录在新版本中。如果没有新增文件或者没有修改文件,不会有新版本生成。

在最终使用资源时,不允许使用上层相对路径,即路径中包含“..”。

$ layacmd resourceVersion -h

  Usage: layacmd-resourceVersion [options]

  Options:

    -h, --help                       output usage information
    -V, --version                    output the version number
    -i --input <input>               资源目录
    -o --output <output>             导出目录
    -n --versionName <version name>  版本名称,默认是从1000开始递增的数字

该命令不需要当前目录包含layaair项目,取而代之的是,你需要指定输入目录。

使用

$ layacmd resourceVersion -i input_dir -o output_dir -n 1.1.0
# 指定了输入目录、输出目录和版本名称

生成的文件

1000

resources...

1001

resources...

1002

resources...

.record

manifest.json

资源版本

名为100010011002的文件夹是默认资源版本名称,里面保存的是对应版本被修改了的资源。根据从manifest.json中得到的每个资源的最新版本号,从这些文件夹读取manifest.json对应的版本资源。

.record记录文件

.recordUnix-like系统中是隐藏文件。这个文件保存最近的版本建立信息,资源版本控制由此来判定建立新版本时哪些文件被修改。这个文件不能被删除,如果这个文件丢失,之前建立的版本就会丢失,相当于重新开始建立版本。

manifest.json资源清单

用户根据manifest.json获取最新的资源。该文件包含资源键值对:

{
    "res1": "1000",
    "res2": "1000",
    "res3": "1002",
    "sub\\res3": "1000",
    "sub\\res4": "1000"
}

用户从该映射中获取资源对应的版本号后,使用资源根目录/版本号/相对文件路径得到资源的url,加载并使用。

资源版本切换

由于manifest.json保存各版本的文件版本号。所以只需要保留历史manifest.json即可使用对应版本的资源。

guetzli

guetzligoogle的开源jpeg编码器。关于它的介绍、注意事项等参见官方https://github.com/google/guetzli。

guetzli的压缩过程很慢,而且占用资源大,所以可能要等待些时间。

最好在资源版本控制生成的文件夹中使用guetzli压缩,这可以保证不会重复压缩一张图。

$ layacmd guetzli -h

  Usage: layacmd-guetzli [options]

  Options:

    -h, --help              output usage information
    -V, --version           output the version number
    -i --input <input>      resource directory.
    -q --quality <quality>  quality, more than 84.

该命令不需要当前目录包含layaair项目,取而代之的是,你需要指定输入目录。压缩成功后,源文件会被修改。压缩失败则源文件保持不变。

使用

$ layacmd guetzli -i input_dir -q 95
# 指定了压缩率95

打开静态文件服务器

$ layacmd open -h

  Usage: layacmd-open [port] [args]

  Options:

    -h, --help     output usage information
    -V, --version  output the version number
    -p <port>      resource directory.
    -s             don't open browser

该命令需要在与layaair项目拥有同样结构的目录中使用。对于ActionScript项目,它会在*./bin/h5*开启静态文件服务器;对于JavaScriptTypeScript项目,它会在**./bin**开启静态文件服务器;