A method and system for constructing RN projects
By using a pre-built environment in RN project construction, the problem of large network overhead and low construction efficiency caused by direct access to the public network is solved, and a more efficient construction process is achieved.
Patent Information
- Application Number
- CN201910417607.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-05-20
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2039-05-20
AI Technical Summary
During the construction of RN project, direct access to the public network to obtain dependent resources leads to large network overhead and long time, which affects the construction efficiency.
Through the pre-built environment, obtain the dependency resources of the RN project to be built from the public network, package and generate the target dependency package, and save it to the first Git repository through the private network, and the offline construction environment obtains the dependency package from the first Git repository for construction.
Reduce dependence on public networks, reduce network overhead, avoid problems such as restriction and failure of public networks, and significantly improve the construction efficiency of RN projects.
Smart Images

Figure CN110162332B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the information technology field of financial technology (Fintech), and in particular to a construction method and system for a RN project. Background Art
[0002] With the development of computer technology, more and more technologies are applied in the financial field, and the traditional financial industry is gradually transforming to Fintech. RN (ReactNative), a mobile cross-platform application development framework launched by Facebook, supports two major mobile platforms, Android and iOS. In the development and construction process of the RN project, the installation of Android dependent resources (such as npm dependencies and gradle dependencies) and iOS dependent resources is involved.
[0003] At present, when building an RN project, it is usually necessary to directly access the public network to obtain dependency resources from the official dependency download platform. However, for project security reasons, most companies will set up internal development networks, and specific access configuration is required to obtain dependency resources through the public network. Therefore, the network overhead of directly accessing the public network to obtain dependency resource packages is large and time-consuming, which in turn affects the construction progress of the RN project and causes low construction efficiency of the RN project. Summary of the invention
[0004] The present invention provides a method and system for constructing an RN project, so as to solve the problem of low construction efficiency of the RN project existing in the prior art.
[0005] In a first aspect, an embodiment of the present invention provides a method for constructing an RN project, including:
[0006] Obtaining dependent resources corresponding to the RN project to be built from the public network through a pre-built environment, packaging the dependent resources to generate a target dependent package, and saving the target dependent package to the first Git repository through a private network based on the pre-built environment, wherein the first Git repository is used to store dependent packages;
[0007] Based on the offline construction environment, the target dependency package is obtained from the first Git repository through the private network, and the RN project to be constructed is constructed based on the target dependency package.
[0008] In an optional implementation, the step of obtaining dependent resources corresponding to the RN project to be built from the public network through the pre-built environment includes:
[0009] Obtaining a template of the RN project to be constructed from the second Git repository through a pre-built environment; wherein the second Git repository stores the template of the RN project to be constructed; the template of the RN project to be constructed includes a dependency configuration file corresponding to the RN project to be constructed, and the dependency configuration file includes an identifier for indicating at least one dependent resource;
[0010] The specific dependent resource for building the RN project to be built is obtained from the public network through the pre-built environment and according to the identifier of the at least one dependent resource.
[0011] In an optional implementation, the dependent resources corresponding to the RN project to be constructed include the specific dependent resources and basic dependent resources, and the basic dependent resources are general dependent resources for constructing RN projects; the method further includes:
[0012] The basic dependent resources are obtained from the public network through the pre-built environment.
[0013] In an optional implementation, the specific dependency resources include npm dependency resources, gradle dependency resources, and iOS dependency resources;
[0014] The step of packaging the dependent resources to generate a target dependent package includes:
[0015] Generate default cache directories corresponding to the npm dependent resources, the gradle dependent resources, the iOS dependent resources, and the basic dependent resources respectively;
[0016] Adjusting the format of the default cache directory corresponding to the gradle dependent resource to obtain an adjusted cache directory corresponding to the gradle dependent resource, wherein the adjusted cache directory is a directory that can be recognized by the offline construction module;
[0017] Based on the default cache directories corresponding to the npm dependent resources, the iOS dependent resources and the basic dependent resources, and the adjusted cache directories, the npm dependent resources, the iOS dependent resources, the basic dependent resources and the gradle dependent resources are packaged to generate a target dependency package.
[0018] In an optional implementation, the target dependency package is a dependency package of the first version, and the method further includes:
[0019] When the pre-built environment detects that the dependency configuration file corresponding to the RN project to be built in the second Git repository is updated, based on the updated dependency configuration file, re-acquire the dependency resources corresponding to the RN project to be built from the public network;
[0020] The re-acquired dependency resources corresponding to the RN project to be built are packaged through the pre-built environment to generate a second version of the target dependency package, and the second version of the target dependency package is saved to the first Git repository.
[0021] In a second aspect, an embodiment of the present invention provides a construction system for an RN project, comprising: a pre-construction module, an offline construction module and a first Git repository; the pre-construction module is connected to a public network and a private network respectively, the offline construction module is connected to the private network, and the first Git repository is connected to the pre-construction module and the offline construction module through the private network;
[0022] The pre-built module is used to obtain the dependency resources corresponding to the RN project to be built from the public network through the pre-built environment, package the dependency resources, generate a target dependency package, and save the target dependency package to the first Git warehouse through the private network based on the pre-built environment, and the first Git warehouse is used to store dependency packages;
[0023] The offline construction module is used to obtain the target dependency package from the first Git repository through the private network based on the offline construction environment, and to build the RN project to be built based on the target dependency package.
[0024] In an optional implementation, the system further includes a second Git repository, wherein the second Git repository is used to store a template of the RN project to be constructed;
[0025] The pre-built module, when obtaining dependent resources corresponding to the RN project to be built from the public network through the pre-built environment, is specifically used to:
[0026] Obtaining a template of the RN project to be constructed from the second Git repository through a pre-built environment; wherein the template of the RN project to be constructed includes a dependency configuration file corresponding to the RN project to be constructed, and the dependency configuration file includes an identifier for indicating at least one dependent resource;
[0027] The specific dependent resource for building the RN project to be built is obtained from the public network through the pre-built environment and according to the identifier of the at least one dependent resource.
[0028] In an optional implementation, the dependency resources corresponding to the RN project to be constructed include the specific dependency resources and basic dependency resources, and the basic dependency resources are general dependency resources for constructing RN projects;
[0029] The pre-built module is further used to obtain the basic dependent resources from the public network through the pre-built environment.
[0030] In an optional implementation, the target dependency package is a dependency package of the first version, and the pre-built module is further used to:
[0031] When it is detected that the dependency configuration file corresponding to the RN project to be built in the second Git repository is updated, based on the updated dependency configuration file, reacquire the dependency resources corresponding to the RN project to be built from the public network;
[0032] The re-acquired dependent resources corresponding to the RN project to be built are packaged to generate a second version of the target dependency package, and the second version of the target dependency package is saved to the first Git repository.
[0033] In a third aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions. When the computer instructions are executed on a computer, the computer executes the above method.
[0034] In an embodiment of the present invention, based on the interaction between the pre-built environment and the public network, the dependency resources of the RN project to be built obtained from the public network are packaged to generate a target dependency package and saved to the first Git repository. Then, when building the RN project, the offline construction environment can directly obtain the target dependency package from the first Git repository at one time, and all the dependency resources required for the RN project to be built can be obtained. In the process of building the RN project based on the target dependency package, there is no need to access the public network, which reduces network overhead and can avoid problems such as public network access restrictions and access failures, thereby effectively improving the construction efficiency of the RN project. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 A schematic diagram of the structure of a system for constructing an RN project provided by an embodiment of the present invention;
[0036] Figure 2 A schematic diagram of the structure of another RN project construction system provided in an embodiment of the present invention;
[0037] Figure 3 A data flow diagram provided for an embodiment of the present invention;
[0038] Figure 4 A flowchart of a method for constructing an RN project provided in an embodiment of the present invention;
[0039] Figure 5 A flowchart of another method for constructing an RN project provided in an embodiment of the present invention;
[0040] Figure 6 A flowchart of a dependency deployment method provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0041] In order to make the purpose, technical solution and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0042] It should be noted that the multiple involved in the present invention refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. In addition, it should be understood that although the terms first, second, etc. may be used to describe each database in the embodiments of the present invention, these databases should not be limited to these terms. These terms are only used to distinguish each database from each other.
[0043] At present, when building RN projects, direct dependency installation is usually adopted, that is, HTTP (Hypertext Transfer Protocol) or HTTPS (Hypertext Transfer Protocol Secure) connection is directly initiated through the network, and the corresponding dependency resources are downloaded from the official dependency download platform, such as the official Maven repository of Google, from the public network. For project security considerations, most companies will set up internal development networks. Accessing the public network to obtain dependency resources often requires specific access configurations, such as configuring a specific external network access whitelist. This configuration is more cumbersome. In addition, the method of directly accessing the public network to obtain dependency resource packages has a large network overhead and takes a long time. Moreover, due to the large number of visits and a wide range of traffic sources, the external official dependency download platform usually configures multiple CDNs (Content Delivery Networks) to provide dependency resources in order to achieve load balancing and improve distribution efficiency. In this case, when accessing the official dependency download platform to obtain dependency resources, the access request will be redirected to a specific CDN node. If the CDN node is not on the external network access whitelist configured in the intranet, the access will fail. Therefore, the direct dependency installation method will be restricted by public network access, which will in turn affect the construction progress of the RN project and cause low construction efficiency of the RN project.
[0044] When building an RN project, another way to install dependencies is usually used, that is, to build a dependency warehouse in the internal development network. For example, several machines or cloud servers in the enterprise's internal network can be used as servers to build a static resource service, that is, the dependency warehouse of the intranet. The dependency image of the official dependency warehouse of the public network is deployed in the dependency warehouse of the intranet for management, and then downloaded and used when the RN project is built. However, the dependency warehouse of the intranet is usually an application dependency warehouse with a unified general specification standard, which is used to manage large and commonly used dependency resources, such as npm dependency resources and gradle dependency resources. However, there is a lack of small special dependency resources required for RN projects, such as iOS dependency resources, and specifically the management of third-party dependency resources of iOS sub-projects. As a result, when building the RN project, it is still necessary to access the public network to download some special dependency resources, such as downloading third-party dependency resources of iOS sub-projects from third-party code libraries on the GitHub website. This method is not completely offline, and there is still network overhead for accessing public network download resources, which will still affect the progress of RN project construction, resulting in low efficiency in building RN projects.
[0045] It can be seen that when constructing an RN project, the above two methods are used to install dependencies, which will affect the progress of the RN project construction, resulting in low construction efficiency of the RN project. These two situations seriously do not meet the needs of financial institutions such as banking institutions and insurance institutions. Based on this, an embodiment of the present invention provides a method and system for constructing an RN project to solve the problem of low construction efficiency of the RN project caused by the direct dependency installation method in the prior art, which can effectively improve the construction efficiency of the RN project. Among them, the method and the system are based on the same inventive concept. Since the principles of solving the problem by the method and the system are similar, the implementation of the system and the method can refer to each other, and the repetitions will not be repeated.
[0046] The distributed version control system (Git) warehouse mentioned below in the embodiments of the present invention can be regarded as a file directory that needs to be version controlled. All files in the directory are version managed through an open source Git. Git can also track and record all updates that occur in the directory. The Git warehouse is mainly used to store files related to project application development and manage file versions. In actual application, such as in collaborative development projects, the Git warehouse can be cloned to the local device, the file directory corresponding to the Git warehouse can be obtained, and the files required for development can be obtained through the file directory, thereby realizing stand-alone development according to different development purposes.
[0047] To facilitate understanding of this embodiment, a construction system of an RN project disclosed in an embodiment of the present invention is first introduced in detail.
[0048] See also Figure 1The construction system 100 of a RN project shown in FIG. 1 includes: a pre-construction module 110, an offline construction module 120, and a first Git repository 130. In the system, the pre-construction module 110, the offline construction module 120, and the first Git repository 130 interact with each other based on a private network. Figure 1 As shown, the pre-built module 110 also interacts with an external public network.
[0049] The pre-construction module 110 obtains the dependent resources corresponding to the RN project to be constructed from the public network by accessing the public network; then the dependent resources corresponding to the RN project to be constructed are saved to the first Git warehouse 130 through the private network, so that the offline construction module 120 can obtain the dependent resources from the first Git warehouse through the private network, and construct the RN project to be constructed according to the dependent resources. In other words, by pre-saving all the dependent resources required for RN construction in a Git warehouse that can only be accessed through a private network, and the Git warehouse supports custom creation and uses a directory structure to save resources / files, compared with the dependent warehouse of the intranet in the prior art, it will not be restricted by the normative standards, and then the RN project is constructed offline through the dependent resources in the Git warehouse, which can improve the construction efficiency of the RN project while ensuring the security of the construction and development of the RN project. That is, the above operations are performed inside financial institutions such as banking institutions and insurance institutions to ensure the security of the construction and development of the RN project while improving the construction efficiency of the RN project.
[0050] In an optional embodiment, the functions of the pre-construction module 110 and the offline construction module 120 can be performed by one or more processors, and the processor can be a general-purpose processor, a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, and can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware processor for execution, or can be executed by a combination of hardware and software modules in the processor.
[0051] In a specific implementation, the above system may also include a communication interface and a memory. The pre-construction module 110 and the offline construction module 120 communicate with other devices through the communication interface. The communication interface may be a network access port of a private network. The aforementioned other devices may be a service machine configured with the first Git repository 130.
[0052] Memory, for storing program instructions. In the embodiment of the present application, the memory can be a non-volatile memory, such as a hard disk (hard disk drive, HDD) or a solid-state drive (solid-state drive, SSD), etc., and can also be a volatile memory (volatile memory), such as a random access memory (random-access memory, RAM). The memory can also be any other medium that can be used to carry or store the desired program code with the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory in the embodiment of the present application can also be a circuit or other arbitrarily capable of realizing a storage function, for storing program instructions and / or data. The specific connection medium between the above-mentioned communication interface, memory and processor is not limited in the embodiment of the present application, such as a bus, and the bus can be divided into an address bus, a data bus, a control bus, etc.
[0053] In an optional implementation, the pre-construction module 110 is connected to the public network and the private network respectively, the offline construction module 120 is connected to the private network, and the first Git repository 130 is connected to the pre-construction module 110 and the offline construction module 120 through the private network.
[0054] The pre-built module 110 is used to obtain the dependency resources corresponding to the RN project to be built from the public network through the pre-built environment, package the dependency resources, generate a target dependency package, and save the target dependency package to the first Git repository 130 through the private network based on the pre-built environment. The first Git repository 130 is used to store dependency packages.
[0055] In specific implementation, when the pre-construction module 110 saves the target dependency package to the first Git repository 130 through the private network based on the pre-construction environment, it is specifically used to:
[0056] The pre-built module 110 submits the target dependency package to the first Git repository 130 through the private network based on the pre-built environment, so that the first Git repository 130 verifies the legitimacy of the target dependency package, and saves the target dependency package after the verification. The legitimacy is used to indicate that the dependency resources in the target dependency package are regular resources obtained from the official dependency platform.
[0057] The offline construction module 120 is used to obtain the target dependency package from the first Git repository 130 through a private network based on the offline construction environment, and to build the RN project to be built based on the target dependency package.
[0058] In an embodiment of the present invention, the pre-construction module 110 interacts with the public network based on the pre-construction environment, packages the dependency resources of the RN project to be constructed obtained from the public network into a target dependency package and saves it to the first Git repository. When the offline construction module 120 constructs the RN project based on the offline construction environment, the target dependency package can be directly obtained from the first Git repository through the private network at one time, that is, all the dependency resources required for the RN project to be constructed can be obtained through the private network, and then in the process of constructing the RN project based on the target dependency package, there is no need to access the public network, which reduces network overhead, can avoid the problems of public network access restrictions and access failures, and thus effectively improve the construction efficiency of the RN project.
[0059] Furthermore, the above system also includes a second Git repository 140, also Figure 1 It is shown that the second Git repository 140 is used to store the template of the RN project to be constructed; wherein the template of the RN project to be constructed is an empty shell RN project, that is, a project scaffold generated according to the RN technical specifications. The empty shell RN project only contains some basic technical components and dependency configuration files corresponding to the RN project to be constructed, and does not involve the application source code for developing the RN project. By constructing an empty shell RN project, the dependency configuration file of the RN project to be constructed is separately loaded into the empty shell RN project. When the dependent resources are subsequently obtained from the public network according to the dependency configuration file, the dependency configuration file of the RN project to be constructed can be directly obtained from the second Git repository, which can avoid source code leakage.
[0060] Based on this, in an optional implementation, the pre-construction module 110, when obtaining dependent resources corresponding to the RN project to be constructed from the public network through the pre-construction environment, is specifically used to:
[0061] A template for the RN project to be built is obtained from the second Git repository through a pre-built environment; wherein the template for the RN project to be built includes a dependency configuration file corresponding to the RN project to be built, and the dependency configuration file includes an identifier for indicating at least one dependent resource; through the pre-built environment and based on the identifier of at least one dependent resource, specific dependent resources for building the RN project to be built are obtained from the public network.
[0062] Among them, the identification of the aforementioned dependent resources can be used to indicate the download specification or download link of the dependent resources. For example, when the dependent resources required for the RN project to be built include npm resources, gradle resources, and iOS resources, the download specifications of npm resources and gradle resources, that is, the dependent package name and version number, are configured in its dependency configuration file, and the download link of iOS dependency is configured to indicate that when the pre-built module 110 obtains resources from the public network according to the dependency configuration file, it automatically obtains the corresponding npm dependent resources from the official dependency platform such as the nodejs official package manager for managing npm resources according to the download specification, such as obtaining gradle dependent resources from Google's maven official warehouse; and obtains the corresponding iOS dependent resources from the third-party code library on the GitHub website according to the download link.
[0063] Specifically, the dependency resources corresponding to the above-mentioned RN project to be built include the aforementioned specific dependency resources and basic dependency resources. The basic dependency resources are general dependency resources used to build RN projects. General dependency resources are determined by the development environment and compilation tools, and are the default dependency resources for development projects and software applications. For example, if an RN project is developed on an Android development platform, the general dependency resources include the Android SDK resources required when compiling the project.
[0064] The pre-construction module 110 is further used to obtain basic dependent resources from the public network through the pre-construction environment.
[0065] Further, in an optional implementation, when the above-mentioned specific dependent resources include npm dependent resources, gradle dependent resources and iOS dependent resources, the pre-building module 110 is specifically used to package the dependent resources and generate the target dependent package when:
[0066] A1, generate the default cache directories corresponding to npm dependency resources, gradle dependency resources, iOS dependency resources and basic dependency resources respectively.
[0067] During specific implementation, the construction tools corresponding to the various types of dependent resources required for the RN project to be built can be pre-configured in the aforementioned pre-built environment. When the dependent resources of the RN project to be built are obtained from the public network based on the pre-built environment, the corresponding types of dependent resources are installed locally in the pre-built environment through the preset construction tools to form a default cache directory. Specifically, in one embodiment, the npm dependent resources will be stored in the node_modules directory under the project directory after installation and can be used directly. The gradle dependent resources will be stored in the .gradle / caches / modules-2 / files-2.1 directory under the user directory, and iOS dependent resources, such as third-party dependent resources of iOS sub-projects, will be saved in the .rncache directory under the user directory.
[0068] A2, adjusting the format of the default cache directory corresponding to the gradle dependency resource to obtain an adjusted cache directory corresponding to the gradle dependency resource, where the adjusted cache directory is a directory that can be recognized by the offline construction module 120.
[0069] Since the gradle dependency resources are installed in the pre-built environment and the directory configuration that forms the local cache is bound to the absolute path related to the machine storing the gradle dependency resources. Since different machines use different formats of the default cache directory, direct copying will cause the offline build module 120 to be unable to recognize it. For example, the default cache directory hierarchy corresponding to the gradle dependency resources is "organization name / package name / version number / hash value / dependency file". Since there are hash values in the default cache directory hierarchy, the offline build module 120 cannot recognize it, so it is necessary to adjust the format of the default cache directory corresponding to the gradle dependency resources. In an optional embodiment, the hash value in the default cache directory corresponding to the gradle dependency resources can be removed to extract a local maven warehouse directory that can be used by the offline build module 120, and the local maven warehouse directory can be recognized by the offline build module 120.
[0070] In the specific implementation, first, the default cache directory corresponding to the aforementioned gradle dependency resource can be traversed using the preset traversal method for querying data (such as depth-first traversal) to obtain all gradle dependencies, and then the directory level of "hash value" in the default cache directory structure is shielded to form a directory structure of "organization name / package name / version number / dependency file", that is, the Maven warehouse directory.
[0071] A3, based on the default cache directories corresponding to npm dependent resources, iOS dependent resources, and basic dependent resources, and the adjusted cache directories, package npm dependent resources, iOS dependent resources, basic dependent resources, and gradle dependent resources to generate a target dependency package.
[0072] During the specific implementation, the npm dependent resources, iOS dependent resources, gradle dependent resources and basic dependent resources are packaged and compressed according to their corresponding cache directories, for example, the cache directory corresponding to the npm dependent resources is the node_modules directory, the cache directory corresponding to the iOS dependent resources is the .rncache directory, the local maven warehouse directory extracted from the default cache directory corresponding to the gradle dependent resources, and the default cache directory corresponding to the basic dependent resources, to generate the target dependency package.
[0073] Furthermore, the system 100 further includes a third Git repository 150, such as Figure 2 As shown, the third Git repository 150 is connected to a private network, and the third Git repository 150 is connected to the offline construction module 120 through the aforementioned private network. The third Git repository is used to store the development files of the RN project to be built; wherein, the development files include source code files, dependency configuration files and dependency installation script files corresponding to the RN project to be built.
[0074] Based on this, in an optional implementation, the offline construction module 120, when obtaining the target dependency package from the first Git repository through a private network based on the offline construction environment, and building the RN project to be built based on the target dependency package, is specifically used to:
[0075] B1, obtain the source code files, dependency configuration files and dependency installation script files corresponding to the RN project to be built from the third Git repository; wherein the dependency configuration file corresponding to the RN project to be built also records the initial path of the dependency configuration path.
[0076] During specific implementation, the third Git repository can be cloned to the offline construction environment through the local Git tool preset in the offline construction environment, that is, the development files of the RN project to be built can be obtained, thereby obtaining the source code files, dependency configuration files and dependency installation script files corresponding to the RN project to be built.
[0077] B2, based on the dependency installation script file corresponding to the RN project to be built, obtain the target dependency package from the aforementioned first Git repository 130.
[0078] B3, unzip the target dependency package to the local project directory preset in the offline build environment, and reset the dependency configuration path in the dependency configuration file corresponding to the RN project to be built according to the local project directory to obtain the reset dependency configuration file.
[0079] In specific implementation, a local project directory can be created in advance in an offline build environment, and the target dependency package can be decompressed by running the corresponding command line tool through the dependency installation script file to obtain various dependency resources configured with a cache directory, such as gradle dependency resources configured with a maven warehouse directory, npm dependency resources configured with a node_modules directory, and iOS dependency resources configured with a .rncache directory. The decompressed dependency resources with their respective originally configured cache directories are copied to the aforementioned local project directory for storage, that is, a layer of the same parent directory is added to the cache directory of each dependency resource in the target dependency package to facilitate unified management. Then, the dependency configuration path is reset according to the local directory, so that the dependency configuration path (dependency resource query path) in the RN project to be built is configured to correspond to the path of the dependency resource in the local project directory of the offline build environment, so that the dependency resources are loaded from the correct location when the RN project to be built is built, avoiding online downloads. The entire build process will no longer involve access to the external network (that is, the aforementioned public network), and dependent resources can be used for a long time after being deployed locally in the offline build environment (or the build machine) without the need for repeated deployment, allowing for complete offline builds at the build machine level.
[0080] B4, build the RN project to be built according to the source code files corresponding to the RN project to be built and the reset dependency configuration files.
[0081] Furthermore, considering that in the actual development process of the RN project, there may be a situation where the project needs to add new dependent resources, and thus the target dependency package in the first Git repository needs to be updated. In order to facilitate the offline construction module 120 to obtain the updated target dependency package, the target dependency package can be optionally version numbered, and multiple versions of the target dependency package can be managed through the second Git repository 130.
[0082] Specifically, the target dependency package in the above system is the dependency package of the first version.
[0083] Based on this, the pre-built module 110 is also used to: when it is monitored that the dependency configuration file corresponding to the RN project to be built in the second Git repository is updated, re-download the dependency resources corresponding to the RN project to be built from the public network based on the updated dependency configuration file; package the re-downloaded dependency resources corresponding to the RN project to be built, generate a second version of the target dependency package, and save the second version of the target dependency package to the first Git repository.
[0084] For ease of implementation, see Figure 3 The embodiment of the present invention is based on Figure 2 Another RN project construction system shown also provides a data flow diagram, which illustrates the process of updating dependent resources. The specific description is as follows:
[0085] The third Git warehouse 150 obtains dependency configuration update information, updates the dependency configuration file of the RN project to be built in the third Git warehouse 150 according to the dependency configuration update information, obtains an updated dependency configuration file, that is, an updated development file, and synchronizes the updated dependency configuration file to the template of the RN project to be built in the second Git warehouse 140 based on the preset update script triggered by the Git hook, so that the dependency configuration file in the template of the RN project to be built is updated. Among them, the Git hook is a script file used to trigger and control the Git workflow, which is usually stored in the hooks subdirectory of the Git directory. The third Git warehouse 150 is connected to the second Git warehouse 140 through a private network. The aforementioned dependency configuration update information includes the identification information of the newly added dependency. In specific implementation, the developer can trigger the offline construction module 120 to transmit the aforementioned dependency configuration update information to the third Git warehouse 150, and further the third Git warehouse 150 completes the synchronization update of the dependency configuration file in the second Git warehouse 140; in addition, in another optional way, the developer can also directly update the dependency configuration file of the RN project to be built in the second Git warehouse 140.
[0086] The pre-built module 110, based on the updated dependency configuration file, re-acquires the dependency resources corresponding to the RN project to be built from the public network; packages the re-acquired dependency resources corresponding to the RN project to be built, generates a second version of the target dependency package, and saves the second version of the target dependency package to the first Git repository 130.
[0087] The offline construction module 120, when obtaining the update instruction, obtains the target dependency package corresponding to the second version number from the first Git repository 130; wherein the update instruction is used to notify the target dependency package in the first Git repository 130 of the version update; and rebuilds the RN project to be built based on the target dependency package corresponding to the second version number. In specific implementation, the aforementioned update instruction can be an instruction triggered by a developer at the offline construction module 120.
[0088] To summarize, the above-mentioned system provided by the embodiment of the present invention is that the pre-built module 110 accesses the public network through the pre-built environment to obtain the dependent resources required for the construction of the RN project, and packages the dependent resources through the private network and hands them over to the first Git repository 130 for storage and management, and then in the offline construction module 120, based on the target dependent package in the first Git repository obtained through the private network through the offline construction environment, completes the construction of the RN project.
[0089] Through the multi-environment (pre-build environment and offline build environment) multi-warehouse (first Git warehouse 130, second Git warehouse 140 and third Git warehouse 150) mechanism, dependent resource acquisition, dependent resource storage, dependent resource deployment and dependent resource update are completed, and the dependent resources are pre-deployed in the offline build environment at one time, and then the RN project is built offline in a private network environment, the build time is greatly shortened, and when the dependency is updated, it can also be synchronized in time, which solves the network limitation problem and completely avoids the network overhead caused by network access, which can effectively improve the construction efficiency of the RN project; and in the above system, only the dependency configuration file in the template of the RN project to be built exists in the pre-build module 110 that can access the public network, and does not involve the privacy and confidentiality content of the actual project, such as the project source code. The key source code files are stored in the third Git warehouse 150 in the private network environment, which can effectively ensure the security of the RN project construction.
[0090] For the construction system of the above RN project, see Figure 4 As shown, an embodiment of the present invention provides a flow chart of a method for constructing an RN project. The method includes:
[0091] Step S401, obtaining dependent resources corresponding to the RN project to be built from the public network through the pre-built environment, packaging the dependent resources, generating a target dependent package, and saving the target dependent package to the first Git repository through the private network based on the pre-built environment, the first Git repository is used to store dependent packages;
[0092] Step S402, based on the offline construction environment, obtain the target dependency package from the first Git repository through the private network, and build the RN project to be built based on the target dependency package.
[0093] In an embodiment of the present invention, a pre-built environment is first interacted with the public network, and the dependency resources of the RN project to be built obtained from the public network are packaged to generate a target dependency package and saved in a first Git repository. Then, based on the offline construction environment, when building the RN project, the target dependency package can be directly obtained from the first Git repository through the private network at one time, and all the dependency resources required for the RN project to be built can be obtained. In the process of building the RN project based on the target dependency package, there is no need to access the public network, which reduces network overhead and can avoid the problems of public network access restrictions and access failures, thereby effectively improving the construction efficiency of the RN project.
[0094] In an optional implementation, the step of obtaining dependent resources corresponding to the RN project to be built from the public network through the pre-built environment includes:
[0095] Obtaining a template of the RN project to be constructed from the second Git repository through a pre-built environment; wherein the second Git repository stores the template of the RN project to be constructed; the template of the RN project to be constructed includes a dependency configuration file corresponding to the RN project to be constructed, and the dependency configuration file includes an identifier for indicating at least one dependent resource;
[0096] By pre-building the environment and according to the identification of at least one dependent resource, specific dependent resources for building the RN project to be built are obtained from the public network.
[0097] In an optional implementation, the dependency resources corresponding to the RN project to be constructed include specific dependency resources and basic dependency resources, and the basic dependency resources are general dependency resources used to construct RN projects; the method also includes: obtaining basic dependency resources from the public network through a pre-built environment.
[0098] In an optional implementation, the aforementioned specific dependency resources include npm dependency resources, gradle dependency resources, and iOS dependency resources; and the step of packaging the dependency resources to generate a target dependency package includes:
[0099] Generate the default cache directories corresponding to npm dependency resources, gradle dependency resources, iOS dependency resources and basic dependency resources respectively;
[0100] The format of the default cache directory corresponding to the gradle dependency resource is adjusted to obtain an adjusted cache directory corresponding to the gradle dependency resource, where the adjusted cache directory is a directory that can be recognized by the offline build environment;
[0101] Based on the default cache directories corresponding to npm dependency resources, iOS dependency resources, and basic dependency resources, as well as the adjusted cache directories, npm dependency resources, iOS dependency resources, basic dependency resources, and gradle dependency resources are packaged to generate the target dependency package.
[0102] In an optional implementation, the target dependency package is a dependency package of the first version, and the method further includes:
[0103] When the pre-built environment detects that the dependency configuration file corresponding to the RN project to be built in the second Git repository is updated, the dependency resources corresponding to the RN project to be built are re-downloaded from the public network based on the updated dependency configuration file;
[0104] The dependent resources corresponding to the re-downloaded RN project to be built are packaged through the pre-built environment to generate the second version of the target dependency package, and the second version of the target dependency package is saved to the first Git repository.
[0105] Further, for the convenience of implementation, take the dependent resources required for building the RN project as npm dependent resources, iOS dependent resources, and gradle dependent resources as an example, see Figure 5 The embodiment of the present invention also provides another method for constructing an RN project, the method comprising:
[0106] (1) Obtaining dependency configuration: Obtain the dependency configuration file of the RN project to be built in the empty shell project repository (that is, the aforementioned second Git repository) through the pre-built environment, and obtain npm dependency resources, iOS dependency resources, and gradle dependency resources from the public network based on the dependency configuration file.
[0107] (2) Dependency extraction and storage: A default cache directory is formed in the pre-built environment, and the default cache directory (.gradle / caches) corresponding to the gradle dependency resources is deeply traversed. After the directory is reorganized into a local Maven warehouse directory (that is, localMaven), the npm dependency resources, iOS dependency resources, and gradle dependency resources are packaged and compressed according to their corresponding cache directories. For example, the cache directory corresponding to the npm dependency resources is the node_modules directory, the cache directory corresponding to the iOS dependency resources is the .rncache directory, the local Maven warehouse directory extracted from the default cache directory corresponding to the gradle dependency resources, and the default cache directory corresponding to the basic dependency resources are generated to generate the target dependency package.
[0108] The target dependency package carrying the cache directory of the above-mentioned dependent resources is submitted to the dependency warehouse (that is, the above-mentioned first Git warehouse) through the pre-built environment, and the dependency warehouse performs legitimacy verification, such as signature verification, and saves it in the dependency warehouse after passing the verification.
[0109] (3) Dependency deployment: Clone the dependency repository storing the target dependency package and the project repository storing the RN project development files to be built (that is, the aforementioned third Git repository) through the offline build environment, and complete the deployment of dependency resources in the offline build environment, so that developers can build the RN project to be built in the offline build environment.
[0110] During specific implementation, the dependency repository is cloned through the offline build environment, and the target dependency package in the dependency repository can be decompressed and deployed to the build machine in the offline build environment. After cloning the project repository through the offline build environment, the dependency configuration path (that is, dependency pointing) is reset according to the directory of various dependency resources on the build machine after decompression (for example, localMaven corresponding to gradle dependency resources, node_modules corresponding to npm dependency resources, and .rncache corresponding to iOS dependency resources). The offline build environment can be a development environment for developers to develop and debug RN projects, or it can be a continuous integration environment for developers to release versions of RN projects. For ease of understanding, see Figure 6 , the embodiment of the present invention takes the development environment as an example and provides a flow chart of a dependent deployment method.
[0111] (4) Dependency update: When dependency configuration update information is obtained through the project repository, the project repository triggers the dependency synchronization update through the Git hook to complete the synchronization update of the dependency configuration file in the empty shell project repository, and then re-executes the above steps based on the new dependency configuration file in the empty shell project repository through the pre-built environment, including dependency configuration acquisition, dependency extraction and storage, and dependency deployment.
[0112] During specific implementation, the new dependency requirements uploaded by developers can be obtained through the offline build environment, and then the dependency configuration update information corresponding to the dependency configuration file in the project repository can be determined.
[0113] Furthermore, an embodiment of the present invention also provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are executed on a computer, the computer executes the above-mentioned RN project construction method.
[0114] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0115] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0116] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0117] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0118] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0119] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A method for constructing an RN project. It is characterized in that include: Obtaining dependent resources corresponding to the RN project to be built from the public network through a pre-built environment, packaging the dependent resources to generate a target dependent package, and saving the target dependent package to a first Git repository through a private network based on the pre-built environment, wherein the first Git repository is used to store dependent packages; Obtain the target dependency package from the first Git repository through the private network based on the offline construction environment, and build the RN project to be built based on the target dependency package; The step of obtaining dependent resources corresponding to the RN project to be built from the public network through the pre-built environment includes: Obtaining a template of the RN project to be constructed from the second Git repository through a pre-built environment; wherein the second Git repository stores the template of the RN project to be constructed; the template of the RN project to be constructed includes a dependency configuration file corresponding to the RN project to be constructed, and the dependency configuration file includes an identifier for indicating at least one dependent resource; obtaining a specific dependent resource for constructing the RN project to be constructed from the public network through the pre-built environment and according to the identifier of the at least one dependent resource; The dependency resources corresponding to the RN project to be built include the specific dependency resources and basic dependency resources; the specific dependency resources include npm dependency resources, gradle dependency resources and iOS dependency resources; The step of packaging the dependent resources to generate a target dependent package includes: generating default cache directories corresponding to the npm dependent resources, the gradle dependent resources, the iOS dependent resources and the basic dependent resources respectively; adjusting the format of the default cache directory corresponding to the gradle dependent resources to obtain an adjusted cache directory corresponding to the gradle dependent resources, wherein the adjusted cache directory is a directory that can be recognized by an offline construction module; based on the default cache directories corresponding to the npm dependent resources, the iOS dependent resources and the basic dependent resources, and the adjusted cache directory, packaging the npm dependent resources, the iOS dependent resources, the basic dependent resources and the gradle dependent resources to generate a target dependent package.
2. The method according to claim 1, It is characterized in that The basic dependency resource is a common dependency resource for building an RN project; the method further includes: The basic dependent resources are obtained from the public network through the pre-built environment.
3. The method according to claim 1, It is characterized in that The target dependency package is a dependency package of the first version, and the method further includes: When the pre-built environment detects that the dependency configuration file corresponding to the RN project to be built in the second Git repository is updated, based on the updated dependency configuration file, re-acquire the dependency resources corresponding to the RN project to be built from the public network; The re-acquired dependency resources corresponding to the RN project to be built are packaged through the pre-built environment to generate a second version of the target dependency package, and the second version of the target dependency package is saved to the first Git repository.
4. A construction system for RN projects, It is characterized in that include: Pre-built modules, offline built modules and first Git repository; The pre-built module is connected to a public network and a private network respectively, the offline built module is connected to the private network, and the first Git repository is connected to the pre-built module and the offline built module through the private network; The pre-built module is used to obtain the dependency resources corresponding to the RN project to be built from the public network through the pre-built environment, package the dependency resources, generate a target dependency package, and save the target dependency package to the first Git warehouse through the private network based on the pre-built environment, and the first Git warehouse is used to store dependency packages; The offline construction module is used to obtain the target dependency package from the first Git repository through the private network based on the offline construction environment, and to build the RN project to be built based on the target dependency package; The system also includes a second Git repository, wherein the second Git repository is used to store templates of the RN project to be constructed; The pre-built module, when obtaining dependent resources corresponding to the RN project to be built from the public network through the pre-built environment, is specifically used to: Obtaining a template of the RN project to be constructed from the second Git repository through a pre-built environment; wherein the template of the RN project to be constructed includes a dependency configuration file corresponding to the RN project to be constructed, and the dependency configuration file includes an identifier for indicating at least one dependent resource; Obtaining, from the public network, through the pre-built environment and according to the identifier of the at least one dependent resource, a specific dependent resource for building the RN project to be built; the dependent resources corresponding to the RN project to be built include the specific dependent resources and basic dependent resources; The pre-built module is specifically used to generate default cache directories corresponding to npm dependent resources, gradle dependent resources, iOS dependent resources and the basic dependent resources respectively; adjust the format of the default cache directory corresponding to the gradle dependent resources to obtain the adjusted cache directory corresponding to the gradle dependent resources, and the adjusted cache directory is a directory that can be recognized by the offline building module; based on the default cache directories corresponding to the npm dependent resources, the iOS dependent resources and the basic dependent resources, and the adjusted cache directory, the npm dependent resources, the iOS dependent resources, the basic dependent resources and the gradle dependent resources are packaged to generate a target dependency package.
5. The system according to claim 4, It is characterized in that The basic dependency resources are common dependency resources used to build RN projects; The pre-built module is further used to obtain the basic dependent resources from the public network through the pre-built environment.
6. The system of claim 4, It is characterized in that The target dependency package is a dependency package of the first version, and the pre-built module is further used for: When it is detected that the dependency configuration file corresponding to the RN project to be built in the second Git repository is updated, based on the updated dependency configuration file, reacquire the dependency resources corresponding to the RN project to be built from the public network; The re-acquired dependent resources corresponding to the RN project to be built are packaged to generate a second version of the target dependency package, and the second version of the target dependency package is saved to the first Git repository.
7. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer instructions, and when the computer instructions are executed on a computer, the computer executes the method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Front-end development engineering system and method
CN106843869A
Code file packaging deployment method, continuous integration server and system
CN109725909A