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

@chensi-thunder/fe-generate-jar

v1.0.8

Published

使用 JDK 把前端包生成 jar 包

Downloads

29

Readme

README

一、应用

  • 默认使用插件中的内置模版,如[1、配置](### 1、配置)
  • 可以在项目中的package.json自定义配置,但 description 中的描述必须有 "custom-jar-tmpl",通过添加此字段判定使用自定义模版来打 jar 包
  • 主文件内顶部必须有 #!/usr/bin/env node 以便于可以用命令执行

1、配置

(1)项目配置

  1. 修改package.json 文件

    • package.json 文件中的 scripts 中虚添加 "jar": "fe-generate-jar"

    • 添加后即可使用在项目中使用 npm run jaryarn|pnpm jar命令执行打jar包命令了

    "scripts": {
      "jar": "fe-generate-jar"
    }
  2. 默认使用插件中的模版配置

    内置模版会与项目中package.json文件进行合并

    模版配置如下:

    {
      "jarSettings": {
        "name": "csa-",
        "folder": "static",
        "time": {
          "type": "date",
          "format": "yyyyMMdd"
        }
      }
    }
  3. 使用自定义模版

  • 在项目中的package.json自定义配置,但 description 中的描述必须有 "custom-jar-tmpl"

  • 在项目中的package.json按以下模版进行配置

    {
      "jarSettings": {
        "name": "csa-",
        "folder": "static",
        "time": {
          "type": "date",
          "format": "yyyyMMdd"
        }
      }
    }

二、相关知识

1、jar

(1)jar命令参数:

jar命令格式:jar {c t x u f }[ v m e 0 M i ][-C 目录]文件名…

其中{ctxu}这四个参数必须选选其一。[v f m e 0 M i ]是可选参数,文件名也是必须的。

-c 创建一个jar包 -t 显示jar中的内容列表 -x 解压jar包 -u 添加文件到jar包中 -f 指定jar包的文件名 -v 生成详细的报造,并输出至标准设备 -m 指定manifest.mf文件.(manifest.mf文件中可以对jar包及其中的内容作一些一设置) -0 产生jar包时不对其中的内容进行压缩处理 -M 不产生所有文件的清单文件(Manifest.mf)。这个参数与忽略掉-m参数的设置 -i 为指定的jar文件创建索引文件 -C 表示转到相应的目录下执行jar命令,相当于cd到那个目录,然后不带-C执行jar命令

(2)jar使用范例:

1)创建jar包
#利用test目录生成hello.jar包,如hello.jar存在,则覆盖
jar cf hello.jar hello
2)创建并显示打包过程
#利用hello目录创建hello.jar包,并显示创建过程
jar cvf hello.jar hello
E:\>jar cvf hello.jar hello

标明清单(manifest) 增加:hello/(读入= 0) (写出= 0)(存储了 0%) 增加:hello/TestServlet2.class(读入= 1497) (写出= 818)(压缩了 45%) 增加:hello/HelloServlet.class(读入= 1344) (写出= 736)(压缩了 45%) 增加:hello/TestServlet1.class(读入= 2037) (写出= 1118)(压缩了 45%)

3)显示jar包:

jar tvf hello.jar 查看hello.jar包的内容 指定的jar包必须真实存在,否则会发生FileNoutFoundException。

4)解压jar包:
#解压hello.jar至当前目录
jar xvf hello.jar
5)jar中添加文件:
jar uf hello.jar HelloWorld.java

将HelloWorld.java添加到hello.jar包中

6)创建不压缩内容jar包:
#利用当前目录中所有的.class文件生成一个不压缩jar包
jar cvf0 hello.jar *.class
7)创建带manifest.mf文件的jar包:
#创建的jar包多了一个META-INF目录,META-INF止录下多了一个manifest.mf文件,至于manifest.mf的作用,后面会提到.
jar cvfm hello.jar manifest.mf hello
8)忽略manifest.mf文件:
#生成的jar包中不包括META-INF目录及manifest.mf文件
jar cvfM hello.jar hello
9)加-C应用:
#表示在切换到hello目录下然后再执行jar命令
jar cvfm hello.jar mymanifest.mf -C hello/
10)-i为jar文件生成索引列表:

当一个jar包中的内容很好的时候,你可以给它生成一个索引文件,这样看起来很省事。

#执行完这条命令后,它会在hello.jar包的META-INF文件夹下生成一个名为INDEX.LIST的索引文件,它会生成一个列表,最上边为jar包名。
jar i hello.jar
11)导出解压列表:
如果你想查看解压一个jar的详细过程,而这个jar包又很大,屏幕信息会一闪而过,这时你可以把列表输出到一个文件中,慢慢欣赏!
jar tvf hello.jar >hello.txt 
12)jar -cvf hello.jar hello/*

例如原目录结构如下: hello |—com |—org

你本想只把com目录和org目录打包,而这时jar命令会连同hello目洋也一块打包进。这点大家要注意。jar命令生成的压缩文件会包含它后边出的目录。我们应该进入到hello目录再执行jar命令。

注意:manifest.mf这个文件名,用户可以任指定,但jar命令只认识Manifest.mf,它会对用户指定的文件名进行相应在的转换,这不需用户担心。

2、shelljs

3、chalk

由于最新版本不支持require引用了,因此,需要特定版本【4.0.0】

4、inquirer

由于最新版本不支持require引用了,因此,需要特定版本【7.1.0】