CN110647348B - 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 PDFInfo
- Publication number
- CN110647348B CN110647348B CN201910897288.XA CN201910897288A CN110647348B CN 110647348 B CN110647348 B CN 110647348B CN 201910897288 A CN201910897288 A CN 201910897288A CN 110647348 B CN110647348 B CN 110647348B
- Authority
- CN
- China
- Prior art keywords
- configuration
- array
- module
- file
- 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.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 21
- 230000004069 differentiation Effects 0.000 title claims abstract description 14
- 238000012423 maintenance Methods 0.000 title claims abstract description 13
- 230000007717 exclusion Effects 0.000 claims abstract description 7
- 238000003491 array Methods 0.000 claims description 5
- 230000008569 process Effects 0.000 claims description 4
- 238000011161 development Methods 0.000 abstract description 6
- 230000006870 function Effects 0.000 abstract description 6
- 206010012559 Developmental delay Diseases 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000013519 translation Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/71—Version 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 maintenance of codes due to version differentiation, wherein the method comprises the following steps: s1, establishing a global configuration file, and analyzing the global configuration file to generate an exclusion array and a required array; s2, traversing the configuration files to generate a modular list array, and setting a flag for whether each module configuration file is injected or not; s3, reading a routing template configuration file and generating a routing configuration character string; s4, outputting the routing configuration character string to a path file under the specified 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
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, but because the differences among the versions cannot be combined, a large amount of repeated codes causes the project to be bloated and difficult to maintain, and the project development is more and more disordered.
Umi is route-based, supports promissory routing, and various advanced routing functions, such as supporting on-demand front-end frameworks 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 with the HTML based on the routing configuration. User configured parameters and plug-ins affect each link in the process.
However, the Umi cannot print out different routing codes according to versions.
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 exclusion array and a required array;
s2, traversing the configuration files to generate a modular list array, and setting a flag of whether to be injected into each module configuration file;
s3, reading a route template configuration file and generating a route configuration character string;
s4, outputting the routing configuration character string to a path file under the specified 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, set couldmoduleBeInjected inject flag if single configuration module is injected.
In combination as a possible implementation manner of this embodiment, the process of setting the couldmodulebeijected injectable 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 as 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, and generating 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 as a possible implementation manner of this embodiment, the step S4 specifically includes: output putfile output the routerConfig string into routes.
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 route level loading according to the needs, combines a plurality of versions into the same project, solves the problems of difference between the versions and development disorder, can pack the required functions according to the version requirements, realizes that only one set of codes are maintained for a plurality of versions, and makes the project development and maintenance simple and easy.
The invention solves the problem of how to combine the routing codes of different versions into a project, not only can specify the page view file output to the routing navigation, but also can configure the function entry for each view file independently, thereby being convenient for the developer to maintain and upgrade.
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 following figures:
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. Moreover, the present disclosure 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 exclusion array and a required array;
s2, traversing the configuration files to generate a modular list array, and setting a flag for whether each module configuration file is injected or not;
s3, reading a routing template configuration file and generating a routing configuration character string;
s4, outputting the routing configuration character string to a path file under the specified 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 as 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 as 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 maintenance of codes 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 route configuration reading module is used for reading the route template configuration file and generating a route 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 of 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 which do not need 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. And traversing the modulePathList array, reading a single config.yml configuration, setting a mark (couldModuleBeInjected) indicating whether a single module is injected, setting the couldModuleBeInjected as true if the module is in a requiredModule array, storing a path and a component name of the file in an array routerArr, and generating a routerStr character string by the routerArr by using JSON. 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 (6)
1. A method for solving the problem of difficult maintenance of codes due to version differentiation is characterized by comprising the following steps:
s1, establishing a global configuration file, and analyzing the global configuration file to generate an exclusion array and a required array;
s2, traversing the configuration files to generate a modular list array, and setting a flag for whether each module configuration file is injected or not;
s3, reading a route template configuration file and generating a route configuration character string;
s4, outputting the routing configuration character string to a path file under the specified directory;
s5, carrying out dynamic route loading on the page view;
the step S2 specifically comprises the following steps:
yml configuration files in the view folders are traversed, and a modulePathList modular list array is generated;
traversing the modulePathList modular list array, reading a single config.yml configuration, and setting a couldModuleBeInjected injectable mark which is injected by the single configuration module;
the process of setting the couldModuleBeInjected injectable 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 script) and a regular expression; if the module is in the excludmeModule array, then couldModuleBeInjected is set to false;
the step S3 specifically comprises the following steps:
reading a route template configuration file of _ route.template.js through fs.readFileSync, and generating a routeConfig character string; and replacing the specific content in the routerConfig character string into a routerStr character string in batches by using the regular expression.
2. The method according to claim 1, wherein the step S1 is specifically as follows:
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 S4 is specifically as follows: export the routerConfig character string into the routes.js file under the specified directory through fs.outputfile.
5. A system for resolving code difficult to maintain 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 route configuration reading module is used for reading the route template configuration file and generating a route configuration character string;
the path module is used for outputting the routing configuration character string to a path file under the specified directory;
the view loading module is used for carrying out dynamic route loading on the page view;
the modular list module is specifically configured to:
traversing config.yml configuration files in a view folder to generate a modulePathList modular list array;
traversing the modulePathList modular list array, reading a single config.yml configuration, and setting a couldModuleBeInjected injectable mark which is injected by the single configuration module;
the process of setting the couldModuleBeInjected injectable 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 script) and a regular expression; if the module is within the excludmemodule array, then couldmoduleBeInjected is set to false;
the route configuration reading module is specifically configured to:
reading a route template configuration file of _ route.template.js through fs.readFileSync, and generating 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.
6. The system for resolving code difficult to maintain due to version differentiation as claimed in claim 5, wherein said global configuration module is specifically configured to:
establishing a global version config.yml configuration file in a root directory of the project;
reading a global version config.yml configuration file through an fs.readFileSync file, and analyzing to generate two arrays of an excluded array excludEModule and a required array requiredModule;
yml configuration files include version author information for the project, page files that need to be packaged into the project, and which files do not need to be packaged into the project.
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 CN110647348A (en) | 2020-01-03 |
CN110647348B true 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) |
Families Citing this family (2)
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 |
CN115390879B (en) * | 2022-09-14 | 2023-12-22 | 安徽长江工业大数据科技股份公司 | Method for constructing real-time management umi project code through node |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
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 |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP3876692B2 (en) * | 2001-11-13 | 2007-02-07 | 株式会社日立製作所 | Network system failure analysis support method and method |
US9294482B2 (en) * | 2013-07-25 | 2016-03-22 | Oracle International Corporation | External platform extensions in a multi-tenant environment |
-
2019
- 2019-09-20 CN CN201910897288.XA patent/CN110647348B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
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)
Title |
---|
GPFS文件***的安装配置与维护;张新诺 等;《计算机技术与发展》;20180620;第28卷(第05期);174-178 * |
Patterns for configuration requirements of Software-as-a-Service;Shim, J等;《Proceedings of the 2011 ACM Symposium on Applied Computing 》;20110331;155-161 * |
Also Published As
Publication number | Publication date |
---|---|
CN110647348A (en) | 2020-01-03 |
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 | |
CN110647348B (en) | Method and system for solving problem of difficult code maintenance caused by version differentiation | |
US8924944B2 (en) | Implementation of distributed methods that support generic functions | |
CN106610853A (en) | Application deployment method and device | |
CN106020823A (en) | Front-end Web presentation and data separation as well as page quick response mode | |
US20150278073A1 (en) | Logging code generation and distribution | |
CN103838573A (en) | Application program generation method and device | |
CN103412754A (en) | Dynamic language code execution method and device | |
CN106547782A (en) | The acquisition methods and device of log information | |
CN113760729A (en) | Code detection method and device | |
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 | |
US20140201709A1 (en) | JavaScript™ Deployment Build Tool for software code that uses an object literal to define meta data and system code. | |
CN105786529B (en) | One type Managed Code calls the Parameters design of the labyrinth of C/C++ style function | |
CN109062577A (en) | A kind of front end script is split and destructing optimization method and system | |
CN107643892B (en) | Interface processing method, device, storage medium and processor | |
CN108170436B (en) | PHP and HTM L code hybrid development method and system | |
CN105279032A (en) | Method and apparatus for synchronizing interface message and javaBean | |
CN112596734B (en) | Static library generation method and device | |
CN109992293B (en) | Method and device for assembling Android system component version information | |
CN111966337B (en) | Front-end multi-project display method, system, equipment and storage medium based on Vue | |
CN107577476A (en) | A kind of Android system source code difference analysis method, server and medium based on Module Division | |
CN113392311A (en) | Field searching method, field searching device, electronic equipment and storage medium |
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 |