CN110647348A - Method and system for solving problem of difficult code maintenance caused by version differentiation - Google Patents

Method and system for solving problem of difficult code maintenance caused by version differentiation Download PDF

Info

Publication number
CN110647348A
CN110647348A CN201910897288.XA CN201910897288A CN110647348A CN 110647348 A CN110647348 A CN 110647348A CN 201910897288 A CN201910897288 A CN 201910897288A CN 110647348 A CN110647348 A CN 110647348A
Authority
CN
China
Prior art keywords
configuration
array
configuration file
module
character string
Prior art date
Legal status (The legal status 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 status listed.)
Granted
Application number
CN201910897288.XA
Other languages
Chinese (zh)
Other versions
CN110647348B (en
Inventor
徐玲
朱文芳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inspur Cisco Networking Technology Co Ltd
Original Assignee
Inspur Cisco Networking Technology Co Ltd
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 Inspur Cisco Networking Technology Co Ltd filed Critical Inspur Cisco Networking Technology Co Ltd
Priority to CN201910897288.XA priority Critical patent/CN110647348B/en
Publication of CN110647348A publication Critical patent/CN110647348A/en
Application granted granted Critical
Publication of CN110647348B publication Critical patent/CN110647348B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method and a system for solving the problem of difficult code maintenance caused by version differentiation, wherein the method comprises the following steps: s1, establishing a global configuration file, and analyzing the global configuration file to generate an excluded array and a required array; s2, traversing the configuration files to generate a modular list array, and setting a flag for each module configuration file to be injected or not; s3, reading the route template configuration file and generating a route configuration character string; s4, outputting the route configuration character string to the path file under the appointed directory; and S5, carrying out dynamic route loading on the page view. The invention solves the problems of difference between versions and disordered development, can pack the required functions according to the version requirements, realizes that a plurality of versions only maintain one set of codes, and makes the project development and maintenance simple and easy.

Description

Method and system for solving problem of difficult code maintenance caused by version differentiation
Technical Field
The invention relates to a method and a system for solving the problem of difficult code maintenance caused by version differentiation, and belongs to the technical field of computers.
Background
In front-end engineering development, when a project has multiple versions, the versions are branched too many, but because the differences between the versions cannot be combined, the project becomes too bulky and difficult to maintain due to a large amount of repeated codes, and the project development is more and more disordered.
Umi are route-based, support promissory routing, and various advanced routing functions, such as a front end framework that supports on-demand loading at the routing level. umi first loads the user's configuration and plug-ins, then generates a routing configuration based on the configuration or directory, and then completely concatenates the JS/CSS source code and HTML based on the routing configuration. User configured parameters and plug-ins affect each link in the process.
Umi, however, cannot type different routing codes depending on the version.
Disclosure of Invention
Aiming at the defects of the method, the invention provides a method and a system for solving the problem of difficult maintenance of codes due to version differentiation, and aims to support the loading on demand of a routing level, combine a plurality of versions into the same project, solve the problems of difference and development disorder among the versions, pack the required functions according to the version requirements, realize that only one set of codes is maintained by the plurality of versions, and make the project development and maintenance simple and easy.
The technical scheme adopted for solving the technical problems is as follows:
on one hand, the method for solving the problem of difficult code maintenance caused by version differentiation provided by the embodiment of the invention comprises the following steps:
s1, establishing a global configuration file, and analyzing the global configuration file to generate an excluded array and a required array;
s2, traversing the configuration files to generate a modular list array, and setting a flag for each module configuration file to be injected or not;
s3, reading the route template configuration file and generating a route configuration character string;
s4, outputting the route configuration character string to the path file under the appointed directory;
and S5, carrying out dynamic route loading on the page view.
In combination with a possible implementation manner of this embodiment, the step S1 specifically includes:
establishing a global version config.yml configuration file in a root directory of the project;
and reading a global version config.yml configuration file through the fs.readfileSync file, and analyzing to generate two arrays of an excluded array excludEModule and a required array requiredModule.
In combination with a possible implementation manner of this embodiment, the global version config.yml configuration file includes version author information of the project, page files that need to be packaged into the project, and files that do not need to be packaged into the project.
In combination with a possible implementation manner of this embodiment, the step S2 specifically includes:
traversing config.yml configuration files in a view folder to generate a modulePathList modular list array;
yml configuration, sets if a single configuration module is injected couldModuleBeInjected injectable flag.
In combination with a possible implementation manner as this embodiment, the setting of the couldModuleBeInjected flag whether a single configuration module is injected is as follows: if the module is in a requiredModule array, setting couldModuleBeInjected as true, storing a path and a component name of the file into an array routerArr, and generating a routerStr character string from the routerArr by using JSON (Java language translation) and a regular expression; if the module is in the excludmemodule array, couldmoduleBeInjected is set to false, and no other operation is performed.
In combination with a possible implementation manner of this embodiment, the step S3 specifically includes:
reading a route template configuration file of _ route.template.js through fs.readFileSync to generate a routeConfig character string; and replacing the specific content in the routerConfig character string into the routersstr character string in batches by using the regular expression.
In combination with a possible implementation manner of this embodiment, the step S4 specifically includes: export the routerConfig character string into the routes.js file under the specified directory through fs.outputfile.
On the other hand, the system for solving the problem of difficult code maintenance caused by version differentiation provided by the embodiment of the present invention includes:
the global configuration module is used for establishing a global configuration file and analyzing the global configuration file to generate an exclusion array and a required array;
the modular list module is used for traversing the configuration files to generate a modular list array and setting a flag for judging whether each module configuration file is injected or not;
the routing configuration reading module is used for reading the routing template configuration file and generating a routing configuration character string;
the path module is used for outputting the routing configuration character string to a path file under the specified directory;
and the view loading module is used for carrying out dynamic route loading on the page view.
In combination with a possible implementation manner as this embodiment, the global configuration file includes version author information of the project, page files that need to be packaged into the project, and files that do not need to be packaged into the project.
The technical scheme of the embodiment of the invention has the following beneficial effects:
the invention supports the loading on demand of the routing level, combines a plurality of versions into the same project, solves the problems of difference between the versions and chaotic development, can pack the required functions according to the version requirements, realizes that a plurality of versions only maintain one set of codes, and makes the project development and maintenance simple and easy.
The invention solves the problem of how to combine routing codes of different versions into a project, not only can specify the page view file output to the routing navigation, but also can independently configure a function entry for each view file, thereby facilitating the maintenance and upgrading of developers.
Description of the drawings:
FIG. 1 is a flow diagram illustrating a method for resolving code difficult to maintain due to version differentiation, according to an example embodiment.
Detailed Description
The invention is further illustrated by the following examples in conjunction with the accompanying drawings:
in order to clearly explain the technical features of the present invention, the following detailed description of the present invention is provided with reference to the accompanying drawings. The following disclosure provides many different embodiments, or examples, for implementing different features of the invention. To simplify the disclosure of the present invention, the components and arrangements of specific examples are described below. Furthermore, the present invention may repeat reference numerals and/or letters in the various examples. This repetition is for the purpose of simplicity and clarity and does not in itself dictate a relationship between the various embodiments and/or configurations discussed. It should be noted that the components illustrated in the figures are not necessarily drawn to scale. Descriptions of well-known components and processing techniques and procedures are omitted so as to not unnecessarily limit the invention.
FIG. 1 is a flow diagram illustrating a method for resolving code difficult to maintain due to version differentiation, according to an example embodiment. As shown in fig. 1, a method for solving the problem of difficult code maintenance due to version differentiation provided by an embodiment of the present invention includes the following steps:
s1, establishing a global configuration file, and analyzing the global configuration file to generate an excluded array and a required array;
s2, traversing the configuration files to generate a modular list array, and setting a flag for each module configuration file to be injected or not;
s3, reading the route template configuration file and generating a route configuration character string;
s4, outputting the route configuration character string to the path file under the appointed directory;
and S5, carrying out dynamic route loading on the page view.
In combination with a possible implementation manner of this embodiment, the step S1 specifically includes:
establishing a global version config.yml configuration file in a root directory of the project;
and reading a global version config.yml configuration file through the fs.readfileSync file, and analyzing to generate two arrays of an excluded array excludEModule and a required array requiredModule.
In combination with a possible implementation manner of this embodiment, the global version config.yml configuration file includes version author information of the project, page files that need to be packaged into the project, and files that do not need to be packaged into the project.
In combination with a possible implementation manner of this embodiment, the step S2 specifically includes:
traversing config.yml configuration files in a view folder to generate a modulePathList modular list array;
yml configuration, sets if a single configuration module is injected couldModuleBeInjected injectable flag.
In combination with a possible implementation manner as this embodiment, the setting of the couldModuleBeInjected flag whether a single configuration module is injected is as follows: if the module is in a requiredModule array, setting couldModuleBeInjected as true, storing a path and a component name of the file into an array routerArr, and generating a routerStr character string from the routerArr by using JSON (Java language translation) and a regular expression; if the module is in the excludmemodule array, couldmoduleBeInjected is set to false, and no other operation is performed.
In combination with a possible implementation manner of this embodiment, the step S3 specifically includes:
reading a route template configuration file of _ route.template.js through fs.readFileSync to generate a routeConfig character string; and replacing the specific content in the routerConfig character string into the routersstr character string in batches by using the regular expression.
In combination with a possible implementation manner of this embodiment, the step S4 specifically includes: export the routerConfig character string into the routes.js file under the specified directory through fs.outputfile.
The system for solving the problem of difficult code maintenance caused by version differentiation provided by the embodiment of the invention comprises the following steps:
the global configuration module is used for establishing a global configuration file and analyzing the global configuration file to generate an exclusion array and a required array;
the modular list module is used for traversing the configuration files to generate a modular list array and setting a flag for judging whether each module configuration file is injected or not;
the routing configuration reading module is used for reading the routing template configuration file and generating a routing configuration character string;
the path module is used for outputting the routing configuration character string to a path file under the specified directory;
and the view loading module is used for carrying out dynamic route loading on the page view.
In combination with a possible implementation manner as this embodiment, the global configuration file includes version author information of the project, page files that need to be packaged into the project, and files that do not need to be packaged into the project.
The system of the invention is realized by the following mechanism:
1. and establishing a global version config.yml configuration file in a root directory of the project, wherein the global version config.yml configuration file is used for setting version author information of the project, page files needing to be packaged into the project and files needing not to be packaged into the project.
2. Reading the yaml file through fs.readFileSync, and analyzing to generate two arrays of excludEModule and requiredModule; yml configuration files under the whole views folder are traversed, and a modulePathList array is generated. Traversing the modulePathList array, reading a single config.yml configuration, setting a mark of whether a single module is injected, namely couldModuleBeInjected, if the module is in a requedModule array, setting the couldModulBeInjected to be true, simultaneously storing a path and a component name of the file in an array routerArr, and then using JSON.stripifify and a regular expression to generate a routerStr character string from the routerArr. If the module is in the excludmemodule array, couldmodulebobjected is set to false, and no other operation is performed.
3. And reading a route template configuration file of _ route.template.js through fs.readFileSync to generate a routeConfig character string. And replacing the specific content in the routerConfig character string into the routersstr character string in batches by using a specific regular expression.
4. And outputting the routerConfig character string to a routes file under a specified directory through fs.outputFile, so as to complete the dynamic route loading function of the page view.
5. And carrying out dynamic route loading on the page view.
The invention can flexibly and independently configure each view template; the routing information is dynamically written into the current js file by adopting io, so that the problem that the require of webpack can only be led into a static path is solved; different view modules can be flexibly configured and combined according to different versions.
The foregoing is only a preferred embodiment of the present invention, and it will be apparent to those skilled in the art that various modifications and improvements can be made without departing from the principle of the present invention, and these modifications and improvements are also considered to be within the scope of the present invention.

Claims (9)

1. A method for solving the problem of difficult code maintenance caused by version differentiation is characterized by comprising the following steps:
s1, establishing a global configuration file, and analyzing the global configuration file to generate an excluded array and a required array;
s2, traversing the configuration files to generate a modular list array, and setting a flag for each module configuration file to be injected or not;
s3, reading the route template configuration file and generating a route configuration character string;
s4, outputting the route configuration character string to the path file under the appointed directory;
and S5, carrying out dynamic route loading on the page view.
2. The method of claim 1, wherein the step S1 is specifically performed by:
establishing a global version config.yml configuration file in a root directory of the project;
and reading a global version config.yml configuration file through the fs.readfileSync file, and analyzing to generate two arrays of an excluded array excludEModule and a required array requiredModule.
3. The method of claim 2, wherein the global version config.yml configuration file comprises version author information of the project, page files that need to be packaged into the project, and files that do not need to be packaged into the project.
4. The method according to claim 2, wherein the step S2 is specifically as follows:
traversing config.yml configuration files in a view folder to generate a modulePathList modular list array;
yml configuration, sets if a single configuration module is injected couldModuleBeInjected injectable flag.
5. The method of claim 4, wherein said setting of the couldmoduleBeInjected injectable flag that is injected by a single configuration module is: if the module is in a requiredModule array, setting couldModuleBeInjected as true, storing a path and a component name of the file into an array routerArr, and generating a routerStr character string from the routerArr by using JSON (Java language translation) and a regular expression; if the module is in the excludmeModule array, couldModuleBeInjected is set to false.
6. The method of claim 5, wherein the step S3 is specifically performed by:
reading a route template configuration file of _ route.template.js through fs.readFileSync to generate a routeConfig character string; and replacing the specific content in the routerConfig character string into the routersstr character string in batches by using the regular expression.
7. The method according to claim 6, wherein the step S4 is specifically as follows: export the routerConfig character string into the routes.js file under the specified directory through fs.outputfile.
8. A system for resolving difficult code maintenance due to version differentiation, comprising:
the global configuration module is used for establishing a global configuration file and analyzing the global configuration file to generate an exclusion array and a required array;
the modular list module is used for traversing the configuration files to generate a modular list array and setting a flag for judging whether each module configuration file is injected or not;
the routing configuration reading module is used for reading the routing template configuration file and generating a routing configuration character string;
the path module is used for outputting the routing configuration character string to a path file under the specified directory;
and the view loading module is used for carrying out dynamic route loading on the page view.
9. The system of claim 8, wherein the global configuration file comprises version author information of the project, page files that need to be packaged into the project, and files that do not need to be packaged into the project.
CN201910897288.XA 2019-09-20 2019-09-20 Method and system for solving problem of difficult code maintenance caused by version differentiation Active CN110647348B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910897288.XA CN110647348B (en) 2019-09-20 2019-09-20 Method and system for solving problem of difficult code maintenance caused by version differentiation

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910897288.XA CN110647348B (en) 2019-09-20 2019-09-20 Method and system for solving problem of difficult code maintenance caused by version differentiation

Publications (2)

Publication Number Publication Date
CN110647348A true CN110647348A (en) 2020-01-03
CN110647348B CN110647348B (en) 2022-11-22

Family

ID=68992450

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910897288.XA Active CN110647348B (en) 2019-09-20 2019-09-20 Method and system for solving problem of difficult code maintenance caused by version differentiation

Country Status (1)

Country Link
CN (1) CN110647348B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114489758A (en) * 2022-02-14 2022-05-13 北京京东振世信息技术有限公司 Page isolation method, page rendering method, device, equipment and computer medium
CN115390879A (en) * 2022-09-14 2022-11-25 安徽长江工业大数据科技股份公司 Method for real-time management of umi project codes through node construction

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030093709A1 (en) * 2001-11-13 2003-05-15 Yukio Ogawa Method and system for supporting network system troubleshooting
CN103399934A (en) * 2013-08-09 2013-11-20 神州数码(中国)有限公司 Form data transmission and storage method
US20150033217A1 (en) * 2013-07-25 2015-01-29 Oracle International Corporation External platform extensions in a multi-tenant environment
CN105511889A (en) * 2016-01-15 2016-04-20 珠海金山网络游戏科技有限公司 General game version incremental updating system and method
CN105574207A (en) * 2016-01-21 2016-05-11 上海谦讯网络科技有限公司 WAP webpage developing method
CN108469952A (en) * 2018-03-16 2018-08-31 祖龙(天津)科技有限公司 A kind of code generating method and kit of management game configuration
CN109491695A (en) * 2018-10-19 2019-03-19 华南理工大学 A kind of increment updating method of integrated Android application
CN110109659A (en) * 2019-04-28 2019-08-09 广东三维家信息科技有限公司 A kind of system that realizing front end applications scaffold and server

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030093709A1 (en) * 2001-11-13 2003-05-15 Yukio Ogawa Method and system for supporting network system troubleshooting
US20150033217A1 (en) * 2013-07-25 2015-01-29 Oracle International Corporation External platform extensions in a multi-tenant environment
CN103399934A (en) * 2013-08-09 2013-11-20 神州数码(中国)有限公司 Form data transmission and storage method
CN105511889A (en) * 2016-01-15 2016-04-20 珠海金山网络游戏科技有限公司 General game version incremental updating system and method
CN105574207A (en) * 2016-01-21 2016-05-11 上海谦讯网络科技有限公司 WAP webpage developing method
CN108469952A (en) * 2018-03-16 2018-08-31 祖龙(天津)科技有限公司 A kind of code generating method and kit of management game configuration
CN109491695A (en) * 2018-10-19 2019-03-19 华南理工大学 A kind of increment updating method of integrated Android application
CN110109659A (en) * 2019-04-28 2019-08-09 广东三维家信息科技有限公司 A kind of system that realizing front end applications scaffold and server

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
SHIM, J等: "Patterns for configuration requirements of Software-as-a-Service", 《PROCEEDINGS OF THE 2011 ACM SYMPOSIUM ON APPLIED COMPUTING 》 *
张新诺 等: "GPFS文件***的安装配置与维护", 《计算机技术与发展》 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114489758A (en) * 2022-02-14 2022-05-13 北京京东振世信息技术有限公司 Page isolation method, page rendering method, device, equipment and computer medium
CN115390879A (en) * 2022-09-14 2022-11-25 安徽长江工业大数据科技股份公司 Method for real-time management of umi project codes through node construction
CN115390879B (en) * 2022-09-14 2023-12-22 安徽长江工业大数据科技股份公司 Method for constructing real-time management umi project code through node

Also Published As

Publication number Publication date
CN110647348B (en) 2022-11-22

Similar Documents

Publication Publication Date Title
CN112988153B (en) Data processing method and frame based on micro front end
CN109933752B (en) Method and device for exporting electronic document
CN106371829B (en) Template framework design method and system based on modularization idea
CN110968325B (en) Applet conversion method and device
US8924944B2 (en) Implementation of distributed methods that support generic functions
CN111443921A (en) Method, system and computer equipment for subpackage deployment of web front-end projects
CN110647348B (en) Method and system for solving problem of difficult code maintenance caused by version differentiation
CN106610853A (en) Application deployment method and device
CN106020823A (en) Front-end Web presentation and data separation as well as page quick response mode
US11328793B2 (en) Accelerating genomic data parsing on field programmable gate arrays
CN113609820A (en) Method, device and equipment for generating word file based on extensible markup language file
US11474796B1 (en) Build system for distributed applications
CN104283947A (en) Java script dynamic consolidated server and work process thereof
CN111966760A (en) Hive data warehouse-based test data generation method and device
CN109828759B (en) Code compiling method, device, computer device and storage medium
CN113900944A (en) Logic verification method and device applied to Flink SQL
CN109062577A (en) A kind of front end script is split and destructing optimization method and system
CN105786529B (en) One type Managed Code calls the Parameters design of the labyrinth of C/C++ style function
CN110941655A (en) Data format conversion method and device
CN107643892B (en) Interface processing method, device, storage medium and processor
CN104462157A (en) Method and device for secondary structuralizing of text data
CN105279032A (en) Method and apparatus for synchronizing interface message and javaBean
CN112925768B (en) HBASE database analysis method and system based on Protobuf protocol
CN109992293B (en) Method and device for assembling Android system component version information
CN107577476A (en) A kind of Android system source code difference analysis method, server and medium based on Module Division

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant