WO2018176812A1 - 静态资源发布方法及装置 - Google Patents

静态资源发布方法及装置 Download PDF

Info

Publication number
WO2018176812A1
WO2018176812A1 PCT/CN2017/107047 CN2017107047W WO2018176812A1 WO 2018176812 A1 WO2018176812 A1 WO 2018176812A1 CN 2017107047 W CN2017107047 W CN 2017107047W WO 2018176812 A1 WO2018176812 A1 WO 2018176812A1
Authority
WO
WIPO (PCT)
Prior art keywords
resource
lightweight
file
static
static resource
Prior art date
Application number
PCT/CN2017/107047
Other languages
English (en)
French (fr)
Inventor
黄警
郑彪
陈少杰
张文明
Original Assignee
武汉斗鱼网络科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 武汉斗鱼网络科技有限公司 filed Critical 武汉斗鱼网络科技有限公司
Publication of WO2018176812A1 publication Critical patent/WO2018176812A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking

Definitions

  • the present invention relates to the field of Internet technologies, and in particular, to a static resource publishing method and apparatus.
  • the static resource can be simply understood as a file that directly sends the corresponding file to the client is a static resource.
  • the static resource includes the css, js and other files of the website itself, and includes resources such as pictures in the website content.
  • how to accurately and effectively publish static resources is a technical problem that need to be considered by those skilled in the art.
  • the present invention has been made in order to provide a static resource issuing method and apparatus that overcomes the above problems or at least partially solves the above problems.
  • a method for publishing a static resource includes: obtaining a static resource to be published by a website, and obtaining a current resource dependency table according to a reference relationship between the static resources, and a file version control system Obtaining the last released resource dependency table; comparing the current resource dependency table with the last released resource dependency table to determine a variable lightweight static resource; and the lightweight static resource Copying to the file version control system, the lightweight version of the static resource is uploaded to the resource publishing server by the file version control system.
  • the method further includes: recording a resource address of the lightweight static resource, generating a lightweight publishing resource list; and acquiring, according to the resource address recorded by the lightweight publishing resource list
  • the file of the lightweight static resource is copied to the release directory.
  • the copying the lightweight static resource to the file version control system includes: obtaining a file of the lightweight static resource from the publishing directory, and copying the file of the lightweight static resource Go to the file version control system.
  • the method before the copying the lightweight static resource to the file version control system, the method further includes: detecting the correctness of the lightweight static resource; and determining the correctness of the lightweight static resource specifically includes: verifying the lightness And verifying the correctness of the resource list, verifying the correctness of the file of the lightweight static resource, and/or verifying whether the file of the lightweight static resource in the publishing directory is compiled correctly.
  • the comparing the current resource dependency relationship table with the last released resource dependency relationship table, and determining the changed lightweight static resource including: reading the current resource dependency relationship table a static resource file, converting the file into a JSON array, and looping out the checksum attribute of the resource object from the JSON array; determining whether the checksum attribute exists in the last published resource dependency In the relational table, if it already exists, it indicates that the static resource has not changed. If it does not exist, it determines that the static resource has changed.
  • a static resource issuance device including: an obtaining unit, configured to acquire a static resource to be published by a website, and obtain a current resource dependency table according to a reference relationship between the static resources, And obtaining, from the file version control system, the last released resource dependency table; the comparison unit is configured to compare the current resource dependency table with the last released resource dependency table to determine that a change occurs a lightweight static resource; a publishing unit, configured to copy the lightweight static resource to the file version control system, and upload the lightweight static resource to the resource publishing server by the file version control system.
  • the method further includes: a lightweight processing unit, configured to record a resource address of the lightweight static resource, generate a lightweight publishing resource list; and acquire the light according to the resource address recorded by the lightweight publishing resource list
  • a lightweight processing unit configured to record a resource address of the lightweight static resource, generate a lightweight publishing resource list; and acquire the light according to the resource address recorded by the lightweight publishing resource list
  • the files of the static resources are copied to the release directory.
  • the issuing unit is specifically configured to: obtain a file of the lightweight static resource from the publishing directory, and copy the file of the lightweight static resource into the file version control system.
  • the method further includes: a detecting unit, configured to detect the correctness of the lightweight static resource; specifically: verifying the correctness of the lightweight publishing resource list, verifying the correctness of the file of the lightweight static resource, and/ Or, verify that the file of the lightweight static resource in the release directory is compiled correctly.
  • a detecting unit configured to detect the correctness of the lightweight static resource; specifically: verifying the correctness of the lightweight publishing resource list, verifying the correctness of the file of the lightweight static resource, and/ Or, verify that the file of the lightweight static resource in the release directory is compiled correctly.
  • the comparison unit is specifically configured to: read the static in the current resource dependency table a file of the state resource, converting the file into a JSON array, and cyclically reading the checksum attribute of the resource object from the JSON array; determining whether the checksum attribute exists in the last published resource dependency In the table, if it already exists, it indicates that the static resource has not changed. If it does not exist, it is determined that the static resource has changed.
  • the current resource dependency relationship table is compared with the last released resource dependency relationship table, and the lightweight static resource that is changed is determined, and only the lightweight static resource is copied. Go to the file version control system and upload the lightweight static resources to the resource publishing server by the file version control system.
  • SVN is a version management tool that facilitates teamwork and service stability. Use SVN to manage the version, which is in line with the publishing process of the front end of the current website. When publishing, you can submit the resource dependency table and the compiled file at the same time. It also plays a big role in exception handling. When a problem needs to be rolled back, the resource dependency table and the compiled file can be rolled back to the previous version at the same time to avoid the problem of rollback out of sync. Moreover, the SVN service is stable, avoiding the problem that the release code and the resource dependency table are not synchronized due to network reasons, and the full-release file is changed to a lightweight release to improve the publishing efficiency.
  • FIG. 1 is a flowchart of a static resource publishing method according to an embodiment of the present invention
  • FIG. 2 is a schematic structural diagram of a static resource issuing apparatus according to an embodiment of the present invention.
  • the scheme for releasing static resources is generally based on the management of resource dependency tables. Most of the development teams need corresponding file servers, and this is additionally equipped with one server. If the development client implements the release of static resources, it may be impossible to effectively synchronize the resource dependency table due to the instability of the client network, resulting in incorrect publishing.
  • the present invention mainly carries out two innovative means.
  • a typical application scenario of the solution of the present invention is: the link of the code in the website development to the online environment. The main application is on the publisher's local machine and follows the code release process.
  • FIG. 1 a flow chart of a static resource issuance method according to an embodiment of the present invention is shown.
  • the method at least includes steps S101-S103.
  • steps S102-1 and/or S102-2 may also be included.
  • S101 Obtain a static resource to be published by the website, obtain a current resource dependency table according to a reference relationship between the static resources, and obtain a resource dependency table that is last released from the file version control system.
  • Static resources include but are not limited to HTML files, JS files, CSS files, RES files, image files, and the like. Static resources of the above type can be obtained from a static database, and there is no restriction on the manner of obtaining.
  • the HTML file references JS/CSS/RES
  • the JS file references CSS/RES
  • the resource dependency table is used to record the interdependence between the template file and the static resource file, and the MD5 value of the static resource file, and recursively find the dependent resource by using the template file as an entry, and will depend on the MD5 value of the resource, corresponding to the file name. Generate a resource dependency table.
  • MD5 is a hash function widely used in the field of computer security to provide message integrity protection.
  • a typical application is to generate a message-digest for a piece of information (Message-Digest) to prevent tampering.
  • MD5 treats the entire file as a large text message. Through its irreversible string transformation algorithm, the unique MD5 of the file is generated. Summary of information.
  • the resource dependency table of the last release is also obtained from the file version control system, and the purpose is to compare the two resource dependency tables in the subsequent steps.
  • the "file version control system” is a file management system adopted by the present invention in the front-end development client.
  • SVN Subversion
  • SVN is a typical file version control system and is a free and open source version control system.
  • Subversion management files and directories can go beyond time and space.
  • Subversion stores the file in a central repository, which is much like a normal file server. The difference is that it can record every file and directory modification, so that you can restore the data to the previous version. And you can view the details of the changes to the data.
  • the advantage of adopting the SVN system is that the resource dependency table and the SVN version are effectively consistent, completely eliminating the problem of version inconsistency.
  • the specific comparison process for determining the changed lightweight static resource may include: reading a file of the static resource in the current resource dependency table, converting the file into a JSON array, and cyclically reading out from the JSON array.
  • the checksum attribute of the resource object ; whether the checksum attribute exists in the last released resource dependency table. If it exists, it indicates that the static resource has not changed. If it does not exist, it determines that the static resource has changed.
  • the so-called "lightweight static resource” is a static resource that is determined by comparing the current resource dependency table with the last released resource dependency table.
  • the advantage of this kind of determining lightweight static resources is obvious. Since only the lightweight static resources need to be published later, instead of all the static resources of the current resource dependency table, the number of published files can be reduced and the publishing efficiency can be improved.
  • Node.js is a JavaScript runtime environment based on the Chrome V8 engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js's package manager, npm, is the world's largest open source library ecosystem. At the same time, the efficient operating system API interface is improved, and the scripting tool can be written by using javascript to complete the project construction process.
  • analyze the resource dependency table for example, use Node's FS module to read the file into memory for analysis, convert to a JSON array, and loop out the resource object ⁇ "filepath": “base.css”, “chksum” : “aa”, “timestamp”: “”, “deps”: [], “consumers”: [] ⁇ .
  • find() method of the lodash module to determine whether the chksum attribute (checksum attribute) of the current resource object is in the resource dependency table of the previous version. If it exists, it indicates that the resource has not changed, and this time does not need to be released; If it does not exist, it is considered as the object of this change.
  • the advantage of comparing two resource dependency tables is that the resource dependency table of the entire project can be efficiently generated to ensure effective updating of resource files.
  • the method further includes: step S102-1: recording a resource address of the lightweight static resource, generating a lightweight publishing resource list; and publishing the resource list according to the lightweight Record the resource address, get the file of the lightweight static resource and copy it to the release directory.
  • the method before copying the lightweight static resource to the file version control system, the method further includes the step S102-2: detecting the correctness of the lightweight static resource.
  • the step S102-2, "Detecting the correctness of the lightweight static resource” may specifically include: verifying the correctness of the lightweight published resource list, and verifying Verify the correctness of the file for the lightweight static resource, and/or verify that the file for the lightweight static resource in the published directory is compiled correctly.
  • the loop distributes the resource list JSON array lightly, and extracts the resource object ⁇ "filepath”: “base.css”, “chksum”: “aa”, “timestamp”: “”, “deps”: [] , “consumers”: [] ⁇ , according to the filepath field to determine whether the file exists in the distribution directory. If there is an error, give specific information and exit the release process.
  • the compiled file contains the "?_md5_" tag. If it exists, the compilation is incorrect, the specific prompt information is given, which file fails to be compiled, and the release process is exited.
  • S103 Copy the lightweight static resource to the file version control system, and upload the lightweight static resource to the resource publishing server by the file version control system.
  • the specific process of copying the lightweight static resource to the file version control system includes: obtaining a file of the lightweight static resource from the release directory, and copying the file of the lightweight static resource to the file In the version control system.
  • calling the fs.copySync() method of the fs-extra module will copy the files in the distribution directory. Go to the SVN directory.
  • the developer used to manually copy files, which wasted a lot of time and was easy to make mistakes. Now it is automatically copied to the target directory to improve the efficiency and stability of the release.
  • you can submit it to SVN and upload it to the server.
  • the final confirmation can be made through the SVN log, and if the information is correct, the file is uploaded to the publishing server.
  • the advantage of this implementation is that the first can guarantee the simultaneous submission of the SVN file and the resource dependency table to ensure the uniformity of the file; the second can use the SVN code check to verify the correctness of the file.
  • the current resource dependency relationship table is compared with the last released resource dependency relationship table, and the lightweight static resource that is changed is determined, and only the lightweight static resource is copied. Go to the file version control system and upload the lightweight static resources to the resource publishing server by the file version control system.
  • SVN is a version management tool that facilitates teamwork and service stability. Use SVN to manage the version, which is in line with the publishing process of the front end of the current website. When publishing, you can submit the resource dependency table and the compiled file at the same time. It also plays a big role in exception handling. When a problem needs to be rolled back, the resource dependency table and the compiled file can be rolled back to the previous version at the same time to avoid the problem of rollback out of sync. Moreover, the SVN service is stable, avoiding the problem that the release code and the resource dependency table are not synchronized due to network reasons, and the full-release file is changed to a lightweight release to improve the publishing efficiency.
  • the embodiment of the present invention further provides a static resource issuing device.
  • the device includes:
  • the obtaining unit 201 is configured to obtain a static resource to be advertised by the website, obtain a current resource dependency relationship table according to a reference relationship between the static resources, and obtain a resource dependency relationship table that is last released from the file version control system;
  • the matching unit 202 is configured to use the current resource dependency table and the last released resource
  • the dependency table is compared to determine the lightweight static resource that has changed
  • the issuing unit 203 is configured to copy the lightweight static resource to the file version control system, and the file version control system uploads the lightweight static resource to the resource publishing server.
  • the device further includes: a lightweight processing unit 204, configured to record a resource address of the lightweight static resource, generate a lightweight publishing resource list; and acquire, according to the resource address recorded by the lightweight publishing resource list
  • the file of the lightweight static resource is copied to the release directory.
  • the issuing unit 203 is specifically configured to: obtain a file of the lightweight static resource from the publishing directory, and copy the file of the lightweight static resource into the file version control system.
  • the device further includes a detecting unit 205, configured to detect the correctness of the lightweight static resource; specifically: verifying the correctness of the lightweight publishing resource list, and verifying the correctness of the file of the lightweight static resource, And/or verifying that the file of the lightweight static resource in the release directory is compiled correctly.
  • a detecting unit 205 configured to detect the correctness of the lightweight static resource; specifically: verifying the correctness of the lightweight publishing resource list, and verifying the correctness of the file of the lightweight static resource, And/or verifying that the file of the lightweight static resource in the release directory is compiled correctly.
  • the comparing unit 202 is specifically configured to: read a file of the static resource in the current resource dependency table, convert the file into a JSON array, and cyclically read the resource object from the JSON array. a checksum attribute; determining whether the checksum attribute exists in the last released resource dependency table, if it already exists, indicating that the static resource has not changed, and if not, determining that the static resource has changed .
  • the various component embodiments of the present invention may be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof.
  • a microprocessor or digital signal processor may be used in practice to implement some or all of the functionality of some or all of the components of the user morphing control system in accordance with embodiments of the present invention.
  • the invention may also be embodied as a device or device for performing some or all of the methods described herein.
  • Programs for example, computer programs and computer program products).
  • Such a program implementing the invention may be stored on a computer readable medium or may be in the form of one or more signals. Such signals may be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.

Abstract

本发明公开了一种静态资源发布方法及装置,其中的方法包括:获取网站待发布的静态资源,并根据各静态资源之间的引用关系,得到当前资源依赖关系表,以及,从文件版本控制系统获取上一次发布的资源依赖关系表;将所述当前资源依赖关系表和所述上一次发布的资源依赖关系表进行比对,确定出发生变动的轻量静态资源;将所述轻量静态资源拷贝到所述文件版本控制系统,由所述文件版本控制系统将所述轻量静态资源上传至资源发布服务器。本发明可提高静态资源发布的准确性和效率。

Description

静态资源发布方法及装置 技术领域
本发明涉及互联网技术领域,具体涉及一种静态资源发布方法及装置。
背景技术
网站前端开发中,涉及动态资源及静态资源的发布和加载。其中,静态资源可以简单理解为,直接把相应文件发送到客户端的文件都是静态资源,例如,静态资源包括网站本身的css,js等文件,还包括网站内容中的图片等资源。在网站开发中,如何准确有效的进行静态资源发布,是本领域技术人员需要考虑的一个技术问题。
发明内容
鉴于上述问题,提出了本发明以便提供一种克服上述问题或者至少部分地解决上述问题的一种静态资源发布方法及装置。
依据本发明的一个方面,提供一种静态资源发布方法,包括:获取网站待发布的静态资源,并根据各静态资源之间的引用关系,得到当前资源依赖关系表,以及,从文件版本控制系统获取上一次发布的资源依赖关系表;将所述当前资源依赖关系表和所述上一次发布的资源依赖关系表进行比对,确定出发生变动的轻量静态资源;将所述轻量静态资源拷贝到所述文件版本控制系统,由所述文件版本控制系统将所述轻量静态资源上传至资源发布服务器。
优选的,在确定出发生变动的轻量静态资源之后,还包括:记录所述轻量静态资源的资源地址,生成轻量发布资源列表;根据所述轻量发布资源列表记录的资源地址,获取所述轻量静态资源的文件并拷贝到发布目录中。
优选的,所述将所述轻量静态资源拷贝到所述文件版本控制系统,包括:从所述发布目录获取到所述轻量静态资源的文件,并将所述轻量静态资源的文件拷贝到所述文件版本控制系统中。
优选的,在将所述轻量静态资源拷贝到所述文件版本控制系统之前,还包括:检测轻量静态资源的正确性;所述检测轻量静态资源的正确性具体包括:验证所述轻量发布资源列表的正确性,验证所述轻量静态资源的文件的正确性,和/或,验证所述发布目录中的所述轻量静态资源的文件是否编译正确。
优选的,所述将所述当前资源依赖关系表和所述上一次发布的资源依赖关系表进行比对,确定出发生变动的轻量静态资源,包括:读取所述当前资源依赖关系表中的静态资源的文件,将所述文件转换为JSON数组,并循环从JSON数组中读取出资源对象的校验和属性;判断所述校验和属性是否存在于所述上一次发布的资源依赖关系表中,如果已存在,则表明静态资源未发生变动,如果不存在,则确定静态资源发生了变动。
依据本发明的另一方面,还提供一种静态资源发布装置,包括:获取单元,用于获取网站待发布的静态资源,并根据各静态资源之间的引用关系,得到当前资源依赖关系表,以及,从文件版本控制系统获取上一次发布的资源依赖关系表;比对单元,用于将所述当前资源依赖关系表和所述上一次发布的资源依赖关系表进行比对,确定出发生变动的轻量静态资源;发布单元,用于将所述轻量静态资源拷贝到所述文件版本控制系统,由所述文件版本控制系统将所述轻量静态资源上传至资源发布服务器。
优选的,还包括:轻量处理单元,用于记录所述轻量静态资源的资源地址,生成轻量发布资源列表;以及,根据所述轻量发布资源列表记录的资源地址,获取所述轻量静态资源的文件并拷贝到发布目录中。
优选的,所述发布单元具体用于:从所述发布目录获取到所述轻量静态资源的文件,并将所述轻量静态资源的文件拷贝到所述文件版本控制系统中。
优选的,还包括:检测单元,用于检测轻量静态资源的正确性;具体包括:验证所述轻量发布资源列表的正确性,验证所述轻量静态资源的文件的正确性,和/或,验证所述发布目录中的所述轻量静态资源的文件是否编译正确。
优选的,所述比对单元具体用于:读取所述当前资源依赖关系表中的静 态资源的文件,将所述文件转换为JSON数组,并循环从JSON数组中读取出资源对象的校验和属性;判断所述校验和属性是否存在于所述上一次发布的资源依赖关系表中,如果已存在,则表明静态资源未发生变动,如果不存在,则确定静态资源发生了变动。
可见,本发明实施例提供的静态资源发布方法中,将当前资源依赖关系表和上一次发布的资源依赖关系表进行比对,确定出发生变动的轻量静态资源,仅将轻量静态资源拷贝到文件版本控制系统,并由文件版本控制系统将轻量静态资源上传至资源发布服务器。
本发明方案至少存在两方面的技术效果:
(1)提供完整的轻量资源发布流程
根据资源关系依赖表生成轻量资源发布列表,保证轻量文件的完整性,提交文件前自动执行测试用例,保证文件内容无误,自动将文件拷贝到SVN目录,减少手工操作。
(2)使用文件版本控制系统(例如SVN)进行资源依赖关系文件管理
SVN是一个方便团队协作、服务稳定的版本管理工具。使用SVN来管理版本,契合当前网站前端的发布流程,发布时可同时提交资源依赖关系表和编译文件。在异常处理上也有很大的作用,遇到问题需要回滚代码时,资源依赖关系表和编译文件可以同时回滚到上个版本,避免出现回滚不同步的问题。而且,SVN服务稳定,避免因为网络原因造成发布代码和资源依赖关系表不同步的问题,将每次全量发布文件改为轻量发布,提升发布效率。
上述说明仅是本发明技术方案的概述,为了能够更清楚了解本发明的技术手段,而可依照说明书的内容予以实施,并且为了让本发明的上述和其它目的、特征和优点能够更明显易懂,以下特举本发明的具体实施方式。
附图说明
通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本发明的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中:
图1示出了根据本发明的一个实施例提供的静态资源发布方法流程图;
图2示出了根据本发明一个实施例提供的静态资源发布装置结构示意图。
具体实施方式
下面将参照附图更详细地描述本公开的示例性实施例。虽然附图中显示了本公开的示例性实施例,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。
目前发布静态资源的方案,一般是基于资源依赖关系表的管理,大多需要开发团队具有对应的文件服务器,这就额外配备一台服务器。而如果在开发客户端实现静态资源的发布,则有可能由于客户端网络不稳定而导致不能有效同步资源依赖关系表,导致发布有误。
针对上述问题,本发明方案主要进行了两种创新手段。第一,使用SVN管理资源依赖关系表,这样可以保证每次要发布的代码和资源依赖关系表都能完全一致,并且可以在提交代码时进行有效校验。第二,实现轻量发布的完整解决方案,从更新SVN代码到编译代码,最后提交到SVN整个发布流程有效的整合到一起,解决从发布所有文件到只发布轻量的(有变动的)文件。本发明方案的一个典型应用场景是:网站开发中代码发布到线上环境的环节。主要应用在发布人员的本地机器上,跟随代码发布流程实施。
参见图1,示出了根据本发明的一个实施例提供的静态资源发布方法流程图。该方法至少包括步骤S101-S103,在一个优选实现方式中,还可以包括步骤S102-1和/或S102-2。
S101:获取网站待发布的静态资源,并根据各静态资源之间的引用关系,得到当前资源依赖关系表,以及,从文件版本控制系统获取上一次发布的资源依赖关系表。
静态资源包括但不限于HTML文件、JS文件、CSS文件、RES文件、图片文件等。可以从静态数据库中获取上述类型的静态资源,对于获取方式不作限制。
在获取到静态资源之后,执行前端资源编译流程,以HTML文件为起点分析资源依赖引用关系,例如,HTML文件引用JS/CSS/RES,JS文件引用CSS/RES,CSS引用RES,生成本次待发布资源依赖关系表。
资源依赖关系表,用于记录模版文件和静态资源文件之间的互相依赖关系,以及静态资源文件的MD5值,以模版文件为入口递归查找依赖资源,并将依赖资源的MD5值,对应文件名生成资源依赖关系表。其中,MD5为计算机安全领域广泛使用的一种散列函数,用以提供消息的完整性保护。典型应用是对一段信息(Message)产生信息摘要(Message-Digest),以防止被篡改,MD5将整个文件当作一个大文本信息,通过其不可逆的字符串变换算法,产生了这个文件唯一的MD5信息摘要。
在得到当前资源依赖关系表之后,还需要从文件版本控制系统中获取上一次发布的资源依赖关系表,目的在于后续步骤中对两个资源依赖关系表进行比对。
“文件版本控制系统”是本发明在前端开发客户端中采用的一个文件管理系统,例如,SVN(Subversion)作为一个典型的文件版本控制系统,是一个自由开源的版本控制系统。在Subversion管理下,文件和目录可以超越时空。Subversion将文件存放在中心版本库里,这个版本库很像一个普通的文件服务器,不同的是,它可以记录每一次文件和目录的修改情况,这样就可以借此将数据恢复到以前的版本,并可以查看数据的更改细节。
采用SVN系统的好处是,资源依赖关系表和SVN版本有效的保持一致,完全杜绝版本不一致的问题。
S102:将当前资源依赖关系表和上一次发布的资源依赖关系表进行比对,确定出发生变动的轻量静态资源。
具体的,确定出发生变动的轻量静态资源的具体比对过程可以包括:读取当前资源依赖关系表中的静态资源的文件,将文件转换为JSON数组,并循环从JSON数组中读取出资源对象的校验和属性;判断校验和属性是否存在于上一次发布的资源依赖关系表中,如果已存在,则表明静态资源未发生变动,如果不存在,则确定静态资源发生了变动。
可见,所谓“轻量静态资源”,即是通过将当前资源依赖关系表和上一次发布的资源依赖关系表进行比对确定出的发生变动的静态资源。这种确定轻量静态资源的优点是显而易见的,由于后续只需发布轻量静态资源,而不是将当前资源依赖关系表的所有静态资源都发布,由此可减少发布文件数量,提高发布效率。
下面以Node为例进行说明。
Node.js是一个基于Chrome V8引擎的JavaScript运行环境。Node.js使用了一个事件驱动、非阻塞式I/O的模型,使其轻量又高效。Node.js的包管理器npm,是全球最大的开源库生态系统。同时提高了高效的操作系统API接口,可以利用javascript编写脚本工具,完成项目的构建流程。
具体的,分析本次资源依赖关系表,例如,使用Node的FS模块读取文件到内存中进行分析,转成JSON数组,循环取出资源对象{″filepath″:″base.css″,″chksum″:″aa″,″timestamp″:″″,″deps″:[],″consumers″:[]}。使用lodash模块的find()方法判断当前资源对象的chksum属性(校验和属性)是否在上一个版本的资源依赖关系表中,如果已存在,则表明资源未有变动,本次不需要发布;如果不存在,则视为本次变更的对象。
将两个资源依赖关系表进行比对的优点在于,可有效的生成整个项目的资源依赖关系表,保证资源文件的有效更新。
在一个优选实现方式中,在确定出发生变动的轻量静态资源之后,还包括步骤S102-1:记录轻量静态资源的资源地址,生成轻量发布资源列表;以及,根据轻量发布资源列表记录的资源地址,获取轻量静态资源的文件并拷贝到发布目录中。
例如,分析轻量发布资源列表JSON数组,使用forEach方法,循环JSON数组取出列表中的文件地址,使用FS模块将对应文件拷贝至发布目录,得到本次需要发布的所有轻量静态资源。
在另一个优选实现方式中,在将轻量静态资源拷贝到文件版本控制系统之前,还包括步骤S102-2:检测轻量静态资源的正确性。具体的,步骤S102-2“检测轻量静态资源的正确性”具体可包括:验证轻量发布资源列表的正确性,验 证轻量静态资源的文件的正确性,和/或,验证发布目录中的轻量静态资源的文件是否编译正确。
下面对这三个验证过程具体举例说明。
(1)轻量发布资源列表正确性验证
可使用与发布时相反的搜索匹配方法,以上次发布的资源依赖关系表为起点进行分析,例如,使用forEach循环上次依赖关系表数组,取出资源对象{″filepath″:″base.css″,″chksum″:″aa″,″timestamp″:″″,″deps″:[],″consumers″:[]}。再循环本次依赖关系表,比较同一个资源对象的chksum属性是否发生改变,如果改变则加入资源列表。循环结束后生成轻量资源列表,与之前生成的资源列表进行对比,判断数组的大小和内容是否一致,以此来校验轻量发布资源列表是否正确。如果有错误,则给出具体提示信息,并退出发布流程。
(2)轻量静态资源的文件的正确性验证
通过该验证可确保轻量文件都已经正确拷贝到发布目录。例如,使用forEach方法,循环轻量发布资源列表JSON数组,取出资源对象{″filepath″:″base.css″,″chksum″:″aa″,″timestamp″:″″,″deps″:[],″consumers″:[]},根据filepath字段判断发布目录中是否存在该文件。如果有错误,则给出具体提示信息,并退出发布流程。
(3)验证发布目录中的文件是否编译正确
例如,检测编译过后的文件是否包含“?_md5_”标记,如果存在,则编译有误,给出具体提示信息,提示哪个文件编译失败,并退出发布流程。
S103:将轻量静态资源拷贝到文件版本控制系统,由文件版本控制系统将轻量静态资源上传至资源发布服务器。
在与步骤S102-1对应的方式中,将轻量静态资源拷贝到文件版本控制系统的具体过程包括:从发布目录获取到轻量静态资源的文件,并将轻量静态资源的文件拷贝到文件版本控制系统中。
例如,调用fs-extra模块的fs.copySync()方法,将发布目录里的文件拷贝 至SVN目录。相较于现有方案,以前是开发人员手动拷贝文件,浪费了大量的时间并且容易出错,现在改为自动拷贝文件到目标目录,提升发布的效率和稳定性。例如,发布时可先提交到SVN,再上传至服务器。在提交代码时,可通过SVN日志可以进行最终确认,如果信息无误,则上传文件至发布服务器。这样实施的优点是,第一可保证同时提交SVN文件和资源依赖关系表,保证文件统一性;第二可以利用SVN的代码检查进行文件正确性校验。
可见,本发明实施例提供的静态资源发布方法中,将当前资源依赖关系表和上一次发布的资源依赖关系表进行比对,确定出发生变动的轻量静态资源,仅将轻量静态资源拷贝到文件版本控制系统,并由文件版本控制系统将轻量静态资源上传至资源发布服务器。
本发明方案至少存在两方面的技术效果:
(1)提供完整的轻量资源发布流程
根据资源关系依赖表生成轻量资源发布列表,保证轻量文件的完整性,提交文件前自动执行测试用例,保证文件内容无误,自动将文件拷贝到SVN目录,减少手工操作。
(2)使用文件版本控制系统(例如SVN)进行资源依赖关系文件管理
SVN是一个方便团队协作、服务稳定的版本管理工具。使用SVN来管理版本,契合当前网站前端的发布流程,发布时可同时提交资源依赖关系表和编译文件。在异常处理上也有很大的作用,遇到问题需要回滚代码时,资源依赖关系表和编译文件可以同时回滚到上个版本,避免出现回滚不同步的问题。而且,SVN服务稳定,避免因为网络原因造成发布代码和资源依赖关系表不同步的问题,将每次全量发布文件改为轻量发布,提升发布效率。
与上述方法相对应,本发明实施例还提供一种静态资源发布装置,参见图2,该装置包括:
获取单元201,用于获取网站待发布的静态资源,并根据各静态资源之间的引用关系,得到当前资源依赖关系表,以及,从文件版本控制系统获取上一次发布的资源依赖关系表;
比对单元202,用于将所述当前资源依赖关系表和所述上一次发布的资源 依赖关系表进行比对,确定出发生变动的轻量静态资源;
发布单元203,用于将所述轻量静态资源拷贝到所述文件版本控制系统,由所述文件版本控制系统将所述轻量静态资源上传至资源发布服务器。
优选的,该装置还包括:轻量处理单元204,用于记录所述轻量静态资源的资源地址,生成轻量发布资源列表;以及,根据所述轻量发布资源列表记录的资源地址,获取所述轻量静态资源的文件并拷贝到发布目录中。
优选的,所述发布单元203具体用于:从所述发布目录获取到所述轻量静态资源的文件,并将所述轻量静态资源的文件拷贝到所述文件版本控制系统中。
优选的,该装置还包括检测单元205,用于检测轻量静态资源的正确性;具体包括:验证所述轻量发布资源列表的正确性,验证所述轻量静态资源的文件的正确性,和/或,验证所述发布目录中的所述轻量静态资源的文件是否编译正确。
优选的,所述比对单元202具体用于:读取所述当前资源依赖关系表中的静态资源的文件,将所述文件转换为JSON数组,并循环从JSON数组中读取出资源对象的校验和属性;判断所述校验和属性是否存在于所述上一次发布的资源依赖关系表中,如果已存在,则表明静态资源未发生变动,如果不存在,则确定静态资源发生了变动。
在此提供的算法和显示不与任何特定计算机、虚拟系统或者其它设备固有相关。各种通用系统也可以与基于在此的示教一起使用。根据上面的描述,构造这类系统所要求的结构是显而易见的。此外,本发明也不针对任何特定编程语言。应当明白,可以利用各种编程语言实现在此描述的本发明的内容,并且上面对特定语言所做的描述是为了披露本发明的最佳实施方式。
本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解,可以在实践中使用微处理器或者数字信号处理器(DSP)来实现根据本发明实施例的用户变身控制的系统中的一些或者全部部件的一些或者全部功能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的设备或者装 置程序(例如,计算机程序和计算机程序产品)。这样的实现本发明的程序可以存储在计算机可读介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站上下载得到,或者在载体信号上提供,或者以任何其他形式提供。
应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。单词“包含”不排除存在未列在权利要求中的元件或步骤。位于元件之前的单词“一”或“一个”不排除存在多个这样的元件。本发明可以借助于包括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。单词第一、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。

Claims (10)

  1. 一种静态资源发布方法,其特征在于,包括:
    获取网站待发布的静态资源,并根据各静态资源之间的引用关系,得到当前资源依赖关系表,以及,从文件版本控制系统获取上一次发布的资源依赖关系表;
    将所述当前资源依赖关系表和所述上一次发布的资源依赖关系表进行比对,确定出发生变动的轻量静态资源;
    将所述轻量静态资源拷贝到所述文件版本控制系统,由所述文件版本控制系统将所述轻量静态资源上传至资源发布服务器。
  2. 如权利要求1所述的方法,其特征在于,在确定出发生变动的轻量静态资源之后,还包括:
    记录所述轻量静态资源的资源地址,生成轻量发布资源列表;
    根据所述轻量发布资源列表记录的资源地址,获取所述轻量静态资源的文件并拷贝到发布目录中。
  3. 如权利要求2所述的方法,其特征在于,所述将所述轻量静态资源拷贝到所述文件版本控制系统,包括:
    从所述发布目录获取到所述轻量静态资源的文件,并将所述轻量静态资源的文件拷贝到所述文件版本控制系统中。
  4. 如权利要求2所述的方法,其特征在于,在将所述轻量静态资源拷贝到所述文件版本控制系统之前,还包括:检测轻量静态资源的正确性;
    所述检测轻量静态资源的正确性具体包括:验证所述轻量发布资源列表的正确性,验证所述轻量静态资源的文件的正确性,和/或,验证所述发布目录中的所述轻量静态资源的文件是否编译正确。
  5. 如权利要求1-4任一项所述的方法,其特征在于,所述将所述当前资源依赖关系表和所述上一次发布的资源依赖关系表进行比对,确定出发生变动的轻量静态资源,包括:
    读取所述当前资源依赖关系表中的静态资源的文件,将所述文件转换为 JSON数组,并循环从JSON数组中读取出资源对象的校验和属性;
    判断所述校验和属性是否存在于所述上一次发布的资源依赖关系表中,如果已存在,则表明静态资源未发生变动,如果不存在,则确定静态资源发生了变动。
  6. 一种静态资源发布装置,其特征在于,包括:
    获取单元,用于获取网站待发布的静态资源,并根据各静态资源之间的引用关系,得到当前资源依赖关系表,以及,从文件版本控制系统获取上一次发布的资源依赖关系表;
    比对单元,用于将所述当前资源依赖关系表和所述上一次发布的资源依赖关系表进行比对,确定出发生变动的轻量静态资源;
    发布单元,用于将所述轻量静态资源拷贝到所述文件版本控制系统,由所述文件版本控制系统将所述轻量静态资源上传至资源发布服务器。
  7. 如权利要求6所述的装置,其特征在于,还包括:
    轻量处理单元,用于记录所述轻量静态资源的资源地址,生成轻量发布资源列表;以及,根据所述轻量发布资源列表记录的资源地址,获取所述轻量静态资源的文件并拷贝到发布目录中。
  8. 如权利要求7所述的装置,其特征在于,所述发布单元具体用于:从所述发布目录获取到所述轻量静态资源的文件,并将所述轻量静态资源的文件拷贝到所述文件版本控制系统中。
  9. 如权利要求7所述的装置,其特征在于,还包括:检测单元,用于检测轻量静态资源的正确性;具体包括:验证所述轻量发布资源列表的正确性,验证所述轻量静态资源的文件的正确性,和/或,验证所述发布目录中的所述轻量静态资源的文件是否编译正确。
  10. 如权利要求6-9任一项所述的装置,其特征在于,所述比对单元具体用于:读取所述当前资源依赖关系表中的静态资源的文件,将所述文件转换为JSON数组,并循环从JSON数组中读取出资源对象的校验和属性;判断所述校验和属性是否存在于所述上一次发布的资源依赖关系表中,如果已存在,则 表明静态资源未发生变动,如果不存在,则确定静态资源发生了变动。
PCT/CN2017/107047 2017-03-31 2017-10-20 静态资源发布方法及装置 WO2018176812A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710205021.0 2017-03-31
CN201710205021.0A CN107169000B (zh) 2017-03-31 2017-03-31 静态资源发布方法及装置

Publications (1)

Publication Number Publication Date
WO2018176812A1 true WO2018176812A1 (zh) 2018-10-04

Family

ID=59849030

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/107047 WO2018176812A1 (zh) 2017-03-31 2017-10-20 静态资源发布方法及装置

Country Status (2)

Country Link
CN (1) CN107169000B (zh)
WO (1) WO2018176812A1 (zh)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107169000B (zh) * 2017-03-31 2018-08-10 武汉斗鱼网络科技有限公司 静态资源发布方法及装置
CN107645422A (zh) * 2017-11-17 2018-01-30 武汉楚鼎信息技术有限公司 一种网站静态资源更新方法及系统装置
CN108347479B (zh) * 2018-01-26 2020-12-18 政采云有限公司 基于内容分发网络的多仓库静态资源上传方法和系统
CN108984337B (zh) * 2018-05-29 2021-04-16 杭州网易再顾科技有限公司 一种数据同步异常的修复方法、修复装置、介质和计算设备
CN112637074B (zh) * 2019-10-08 2023-04-28 中国移动通信集团浙江有限公司 web静态资源协调方法、装置及分发系统
CN113326456B (zh) * 2021-07-08 2022-01-21 北京达佳互联信息技术有限公司 网页资源获取方法、装置、设备、系统及存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102081633A (zh) * 2009-11-27 2011-06-01 阿里巴巴集团控股有限公司 一种JavaScript文件的管理方法、装置和系统
CN102105848A (zh) * 2008-06-30 2011-06-22 诺基亚公司 用于管理硬件资源的资源管理器
CN106294597A (zh) * 2016-07-28 2017-01-04 百度在线网络技术(北京)有限公司 用于对网页的静态资源进行分组的方法和装置
CN107169000A (zh) * 2017-03-31 2017-09-15 武汉斗鱼网络科技有限公司 静态资源发布方法及装置

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1549178A (zh) * 2003-05-16 2004-11-24 �Ҵ���˾ 分配和更新杂散资源的方法和系统
CN102902558B (zh) * 2012-09-11 2016-05-11 新浪网技术(中国)有限公司 项目脚本文件更新系统和方法、脚本文件合并方法和装置
CN106293675B (zh) * 2015-06-08 2020-12-25 腾讯科技(深圳)有限公司 系统静态资源加载方法及装置
CN105511889B (zh) * 2016-01-15 2020-01-07 珠海金山网络游戏科技有限公司 一种通用的游戏版本增量更新系统和方法
CN106020798A (zh) * 2016-05-11 2016-10-12 乐视控股(北京)有限公司 网页版本发布方法、装置及系统

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102105848A (zh) * 2008-06-30 2011-06-22 诺基亚公司 用于管理硬件资源的资源管理器
CN102081633A (zh) * 2009-11-27 2011-06-01 阿里巴巴集团控股有限公司 一种JavaScript文件的管理方法、装置和系统
CN106294597A (zh) * 2016-07-28 2017-01-04 百度在线网络技术(北京)有限公司 用于对网页的静态资源进行分组的方法和装置
CN107169000A (zh) * 2017-03-31 2017-09-15 武汉斗鱼网络科技有限公司 静态资源发布方法及装置

Also Published As

Publication number Publication date
CN107169000B (zh) 2018-08-10
CN107169000A (zh) 2017-09-15

Similar Documents

Publication Publication Date Title
WO2018176812A1 (zh) 静态资源发布方法及装置
JP7361165B2 (ja) 分散型台帳を用いて公共のソフトウェアコンポーネント・エコシステムを管理するためのシステムおよび方法
US10515005B1 (en) Systems and methods for testing source code
US8151247B2 (en) Test data management
US8577833B2 (en) Automated data analysis and transformation
US10740093B2 (en) Advanced packaging techniques for improving work flows
US20190197130A1 (en) Ensuring consistency in distributed incremental content publishing
US20180137032A1 (en) Systems and methods for testing source code
US10979440B1 (en) Preventing serverless application package tampering
JP2020532213A (ja) 分散型台帳を用いるデジタルアセット・トレーサビリティおよび保証
US20140114913A1 (en) Single-Database Multiple-Tenant Software System Upgrade
CN108897571B (zh) 程序打包部署方法、装置、系统、电子设备及存储介质
US20130198134A1 (en) Online verification of a standby database in log shipping physical replication environments
US20120266131A1 (en) Automatic program generation device, method, and computer program
US20150143327A1 (en) Project management tool
WO2016138859A1 (zh) 数据同步方法和集群节点
US9378260B2 (en) Methods and apparatus for synchronizing closed heterogenous systems
WO2019037418A1 (zh) 代码管理方法、装置、计算机设备和计算机可读存储介质
US20090288071A1 (en) Techniques for delivering third party updates
CN108959086B (zh) 程序包测试部署方法、装置、系统、电子设备及存储介质
Felício et al. Rapitest: Continuous black-box testing of restful web apis
US11099837B2 (en) Providing build avoidance without requiring local source code
US9442719B2 (en) Regression alerts
US9015116B2 (en) Consistent replication of transactional updates
US20160103815A1 (en) Generating mobile web browser views for applications

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17902830

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17902830

Country of ref document: EP

Kind code of ref document: A1