简体   繁体   English

发布Javascript库供客户端使用

[英]Releasing a Javascript library for client use

I have a Javascript library that I wrote for a client. 我有一个我为客户编写的Javascript库。 This is written in typescript using webpack and "compiles" into javascript. 这是使用webpack在typescript中编写的,并且“编译”到javascript中。 I want to give the client access to the distribution files but not the whole source. 我想让客户端访问分发文件,但不是整个源。 Ideally they can install from the command line to make installing updates easy. 理想情况下,他们可以从命令行安装以简化安装更新。

The library provides some javascript functions. 该库提供了一些javascript函数。 The client would install the script in one location on their server. 客户端会将脚本安装在其服务器上的一个位置。 They could then include the javascripts in their web surveys as they need it. 然后,他们可以根据需要在他们的网络调查中包含javascripts。

+project
  +dist
     -main.js
     -vendor.js
     -index.html
     -README.md
     -LICENSE.md
  +src
     -index.js
     -index.html
     ...

My initial thoughts are to give them access to a private git repository that contains only the distribution files. 我最初的想法是让他们访问仅包含分发文件的私有git存储库。 So my project would be a git repository, only I would have access to this repo. 所以我的项目将是一个git存储库,只有我可以访问这个repo。 I would then copy the contents of the dist directory to a release directory. 然后我会将dist目录的内容复制到release目录。 The release directory would be another git repo I could supply to the client. release目录将是我可以提供给客户端的另一个git repo。

I'm not sure this is the best approach. 我不确定这是最好的方法。

It was suggested that GitHub releases may be an option - but I don't use GitHub, I use GitLab and would like to continue to do so. 有人建议GitHub发布可能是一个选项 - 但我不使用GitHub,我使用GitLab并希望继续这样做。

npm also doesn't seem like a good choice. npm也不是一个好选择。 It installs files into the node_modules directory and creates a package.json file. 它将文件安装到node_modules目录中并创建package.json文件。 That's going to be confusing to my client and isn't "clean". 这对我的客户来说会让人感到困惑并且不是“干净”。

It sounds like a second git repository as submodule could work for you. 这听起来像是第二个git存储库,因为子模块可以为你工作。 On your side it would receive the built files, and on the clients side they could consume them. 在你这边它会收到构建的文件,在客户端它们可以使用它们。

I'd suggest making use of tags to indicate significant versions in the submodule 我建议使用标签来指示子模块中的重要版本

By using a separate repository there is no risk of leaking the original files. 通过使用单独的存储库,不存在泄漏原始文件的风险。

Alternatively you could package the files as a zip, and upload somewhere like S3 as part of your ci process, and write a script to give the client that can automatically download the distribution files - but this seems more complex than just using a package manager like npm. 或者,您可以将文件打包为zip文件,然后将其作为ci进程的一部分上传到S3,并编写脚本以便客户端可以自动下载分发文件 - 但这似乎比使用类似于包管理器更复杂NPM。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM