CN107357558A - Build the method and device of code - Google Patents

Build the method and device of code Download PDF

Info

Publication number
CN107357558A
CN107357558A CN201610305986.2A CN201610305986A CN107357558A CN 107357558 A CN107357558 A CN 107357558A CN 201610305986 A CN201610305986 A CN 201610305986A CN 107357558 A CN107357558 A CN 107357558A
Authority
CN
China
Prior art keywords
target
code
environment parameter
environment
parameter
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
CN201610305986.2A
Other languages
Chinese (zh)
Other versions
CN107357558B (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.)
Advanced New Technologies Co Ltd
Advantageous New Technologies Co Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201610305986.2A priority Critical patent/CN107357558B/en
Publication of CN107357558A publication Critical patent/CN107357558A/en
Application granted granted Critical
Publication of CN107357558B publication Critical patent/CN107357558B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The present invention disclose a kind of method and device for building code, is related to Internet technical field, can build it is a kind of can both avoid enterprises information from leaking outside, go for various environment again and invade the code of source code degree minimum.The method of the present invention mainly includes:Receive the structure order for indicating structure object code;Ordered according to structure and determine target environment parameter;Obtaining includes the source code of ambient parameter mark corresponding to the configuration file and configuration file prestored, configuration file includes configuration information corresponding to ambient parameter mark corresponding at least one ambient parameter, ambient parameter and ambient parameter mark;According to the matching result of target environment parameter and ambient parameter, configuration information corresponding to ambient parameter mark corresponding to target environment parameter and ambient parameter mark is determined;According to configuration information corresponding to ambient parameter mark corresponding to target environment parameter and ambient parameter mark, source code is pre-processed, obtains object code.

Description

Method and device for constructing codes
Technical Field
The invention relates to the technical field of internet, in particular to a method and a device for constructing codes.
Background
In practical application, a code developed by a developer needs to be sequentially operated in different environments, and can be on-line for a user to use after each environment is operated. For example, a piece of code often needs to run first in a development environment, then in a test environment, and finally in an online production environment.
The change of the environment also relates to the change of the code layer, for example, the website address needing to be accessed is different under different environments. There are mainly two ways of constructing code in the prior art: (1) when changing from one environment to another, developers temporarily modify codes, which not only involves a large number of and many modifications of codes, but also may forget to modify some codes during the entire process of changing the development environment to the online production environment, so that only some functions that may appear in the development or test environment appear online, and further, online faults occur. (2) The method comprises the steps of storing codes required in various environments in the current environment, and acquiring the codes required to be executed from the codes in all environments according to a domain name, Cookie and the like when the codes are required to be executed. Although in the process of changing the environment, the developer does not need to temporarily modify the codes, since the codes in all environments are stored in the current environment, after the codes are on line, the user can check the codes in various environments, so that risks of leakage of information inside the enterprise may occur, for example, a domain name used inside the enterprise leaks out, and further, losses are caused to the enterprise.
Therefore, how to minimally invade the source code on the basis of avoiding the leakage of the internal information of the enterprise, so that the obtained code is suitable for various environments is urgent to be solved.
Disclosure of Invention
In view of this, the present invention provides a method and an apparatus for constructing a code, which can construct a code that can avoid leakage of information inside an enterprise, and is applicable to various environments with minimal intrusion into a source code.
In one aspect, the present invention provides a method of constructing code, the method comprising:
receiving a build command indicating to build the object code;
determining a target environment parameter according to the construction command;
acquiring a pre-stored configuration file and a source code which is corresponding to the configuration file and comprises an environment parameter identifier, wherein the configuration file comprises at least one environment parameter, the environment parameter identifier corresponding to the environment parameter and configuration information corresponding to the environment parameter identifier;
determining an environmental parameter identifier corresponding to the target environmental parameter and configuration information corresponding to the environmental parameter identifier according to the matching result of the target environmental parameter and the environmental parameter;
and preprocessing the source code according to the environment parameter identification corresponding to the target environment parameter and the configuration information corresponding to the environment parameter identification to obtain a target code, wherein the preprocessing comprises converting the source code comprising the environment parameter identification into a code comprising the configuration information and matched with the target environment parameter.
In another aspect, the present invention provides an apparatus for constructing code, the apparatus comprising:
a receiving unit that receives a build command for instructing to build an object code;
the determining unit is used for determining target environment parameters according to the construction command received by the receiving unit;
the device comprises an acquisition unit, a storage unit and a processing unit, wherein the acquisition unit is used for acquiring a pre-stored configuration file and a source code which corresponds to the configuration file and comprises an environment parameter identifier, and the configuration file comprises at least one environment parameter, an environment parameter identifier corresponding to the environment parameter and configuration information corresponding to the environment parameter identifier;
the determining unit is used for determining an environmental parameter identifier corresponding to the target environmental parameter and configuration information corresponding to the environmental parameter identifier according to the target environmental parameter and the matching result of the environmental parameter;
and the processing unit is used for preprocessing the source code according to the environment parameter identifier corresponding to the target environment parameter and the configuration information corresponding to the environment parameter identifier, which are determined by the determining unit, so as to obtain the target code, wherein the preprocessing comprises the step of converting the source code comprising the environment parameter identifier into a code which is matched with the target environment parameter and comprises the configuration information.
By the technical scheme, after receiving the configuration file which is sent by the terminal and contains various environmental parameters, the environmental parameter identification corresponding to each environmental parameter and the configuration information corresponding to the environmental parameter identification, and the source code corresponding to the configuration file, when the code suitable for a certain environment needs to be constructed, the user can send the construction command based on the server, after the server receives the construction command, the target environmental parameter can be determined according to the construction command, then the environmental parameter identification corresponding to the target environmental parameter and the configuration information corresponding to the environmental parameter identification are obtained from the configuration file, and finally the source code containing the environmental parameter identification is converted into the target code which is matched with the target environmental parameter and contains the configuration information according to the environmental parameter identification and the configuration information corresponding to the environmental parameter identification, the target code is deployed to the server corresponding to the environment for execution, so that the codes stored in the servers of various environments only contain the codes suitable for the current environment, and no codes in other environments exist, and the phenomenon that the internal information of the enterprise is leaked due to the fact that the codes in other environments are displayed to the user is avoided. In addition, since the source code written by the developer using the environment parameter identification can be applied to various environments, there is no phenomenon of modifying the source code, thereby realizing the function of minimally intruding the source code.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
FIG. 1 is a flow chart illustrating a method of building code according to an embodiment of the present invention;
FIG. 2 is a flow chart illustrating another method of building code provided by an embodiment of the present invention;
FIG. 3 is a block diagram illustrating an apparatus for constructing code according to an embodiment of the present invention;
fig. 4 is a block diagram illustrating another apparatus for constructing code according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
An embodiment of the present invention provides a method for constructing a code, where the method is mainly applied to a server side, and as shown in fig. 1, the method mainly includes:
101. a build command is received that indicates to build the object code.
Wherein the build command is used to instruct to build the target code matching the target environment. After the developer develops the source code, the developer needs to run the source code in the development environment, the test environment and the online production environment in sequence, so that when the source code needs to be run in a certain environment, the developer can issue a construction command based on a server (for clarity, hereinafter referred to as a code construction server, namely a server provided with a code construction tool) so as to construct a code suitable for the environment based on the source code developed by each developer.
It should be noted that the code building server may be a server dedicated to building the object code, or may be a server having both a function of building the object code and a function of running the object code, that is, a server corresponding to the target environment.
102. And determining the target environment parameters according to the construction command.
The construction command may or may not carry target environment parameters for describing the target environment. When the construction command carries the target environment parameter, the code construction server can directly extract the target environment parameter from the construction command, and when the construction command does not carry the target environment parameter, the target environment parameter can be obtained in other modes, such as an IP network segment of the server corresponding to the target environment.
103. And acquiring a pre-stored configuration file and a source code which corresponds to the configuration file and comprises an environment parameter identifier.
The configuration file comprises at least one environment parameter, an environment parameter identifier corresponding to the environment parameter and configuration information corresponding to the environment parameter identifier. The environment parameters in the configuration file mainly include environment parameters (e.g., "default") for describing a development environment, environment parameters (e.g., "test") for describing a test environment, environment parameters (e.g., "prod") for describing an on-line production environment, and environment parameters for describing other environments. In addition, the environment parameter identifiers in the configuration information corresponding to different environment parameters are often the same, and the configuration information marked by the same environment parameter identifier is often different.
In practical applications, when an application program or a website is developed, the developed application program or website often needs to be divided into a plurality of functional modules, and the functional modules are developed by different developers respectively. After each developer writes the configuration file for which the developer is responsible and the source code corresponding to the configuration file and including the environment parameter identifier, the configuration file and the source code can be sent to the code construction server, so that the code construction server stores the configuration file and the source code to the local, and the target code can be obtained according to the construction instruction after the construction instruction is received subsequently. The configuration files written by each developer may be the same or different.
104. And determining an environmental parameter identifier corresponding to the target environmental parameter and configuration information corresponding to the environmental parameter identifier according to the matching result of the target environmental parameter and the environmental parameter.
After the code building server obtains the pre-stored configuration file, the target environment parameters can be respectively matched with the environment parameters in the configuration file, the environment parameters identical to the target environment parameters are obtained, and then the environment parameter identifications corresponding to the target environment parameters and the configuration information corresponding to each environment parameter identification are obtained from the configuration file.
After the code building server receives the building command and determines the target environment parameter, the environment parameter identifier corresponding to the target environment and the configuration information corresponding to the environment parameter identifier may be obtained from the configuration file sent by each terminal (computer used by the developer), so as to obtain the target code based on step 105 in the following.
105. And preprocessing the source code according to the environment parameter identification corresponding to the target environment parameter and the configuration information corresponding to the environment parameter identification to obtain the target code.
Wherein the preprocessing comprises converting the source code comprising the environment parameter identification into code comprising the configuration information matching the target environment parameter. After the environment parameter identifier corresponding to the target environment parameter and the configuration information corresponding to the environment parameter identifier are respectively obtained from each configuration file, the source code corresponding to each configuration file can be respectively preprocessed, and the code containing the configuration information and matched with the target environment parameter is obtained, so that the target codes under different functional modules are obtained.
It should be noted that, when the server in the target environment executes the target code, the target code under each functional module needs to be loaded first, and then each section of the target code needs to be executed in sequence according to the predetermined sequence, so that when there are many functional modules, it takes much loading time. Therefore, in order to reduce the subsequent loading time, after the code construction server obtains the object codes under each functional module, the object codes can be spliced according to a preset sequence, and the spliced codes are stored in one file, so that the file can be subsequently deployed to the server under the target environment to be executed only by loading once.
The method for constructing a code provided by the embodiment of the invention can receive a configuration file which is sent by a terminal and contains various environmental parameters, environmental parameter identifications corresponding to each environmental parameter and configuration information corresponding to the environmental parameter identifications, and a source code corresponding to the configuration file, when a code suitable for a certain environment needs to be constructed, a user can send a construction command based on a server, after the server receives the construction command, the target environmental parameter can be determined according to the construction command, then the environmental parameter identifications corresponding to the target environmental parameter and the configuration information corresponding to the environmental parameter identifications are obtained from the configuration file, and finally the source code containing the environmental parameter identifications is converted into the target code which is matched with the target environmental parameter and contains the configuration information according to the environmental parameter identifications and the configuration information corresponding to the environmental parameter identifications, the target code is deployed to the server corresponding to the environment for execution, so that the codes stored in the servers of various environments only contain the codes suitable for the current environment, and no codes in other environments exist, and the phenomenon that the internal information of the enterprise is leaked due to the fact that the codes in other environments are displayed to the user is avoided. In addition, since the source code written by the developer using the environment parameter identification can be applied to various environments, there is no phenomenon of modifying the source code, thereby realizing the function of minimally intruding the source code.
Further, according to the above method embodiment, another embodiment of the present invention further provides a method for constructing a code, as shown in fig. 2, the method mainly includes:
201. a build command is received that indicates to build the object code.
202. And determining the target environment parameters according to the construction command.
In step 102 of the above embodiment, the construction command may or may not carry the target environment parameter. Therefore, after receiving the build command, the specific implementation manner of the code build server determining the target environment parameter may be: judging whether the construction command carries an environmental parameter; if the construction command carries the environmental parameters, determining the environmental parameters carried in the construction command as target environmental parameters; if the construction command does not carry the environmental parameters, basic information of a server corresponding to the target environment is obtained, and the target environmental parameters are determined according to the basic information, wherein the basic information comprises an IP (Internet Protocol) address.
Specifically, the code building server may locally store the IP addresses (or IP network segments) of servers corresponding to each environment in the system and the corresponding relationship between other basic information and the environment parameters. When the target environment parameter does not exist in the construction command, the basic information of the server corresponding to the target environment can be acquired from the construction command, or the basic information of the current server is directly detected (the code construction server at this time is the server corresponding to the target environment), and then the target environment parameter is determined according to the corresponding relation between the basic information and the environment parameter.
203. And acquiring a pre-stored configuration file and a source code which corresponds to the configuration file and comprises an environment parameter identifier.
204. And determining an environmental parameter identifier corresponding to the target environmental parameter and configuration information corresponding to the environmental parameter identifier according to the matching result of the target environmental parameter and the environmental parameter.
Further, in practical applications, a developer may forget to set a certain environmental parameter, an environmental parameter identifier corresponding to the environmental parameter, and configuration information corresponding to the environmental parameter identifier in a configuration file, so that the configuration file lacks information. Based on the above problems, the embodiments of the present invention mainly provide the following two solutions:
the method comprises the following steps: and if the target environment parameter does not exist in the configuration file, acquiring an environment parameter identifier corresponding to the target environment parameter and configuration information corresponding to the environment parameter identifier from the default configuration file.
The default configuration file is a configuration file which is stored in the code building server locally and agreed by a developer before writing the source code, and when the subsequent developer writes the source code, the developer can write the source code directly according to the default configuration file or modify the default configuration file according to the requirement and then write the source code.
Since the default configuration file is generally the same as the configuration file sent by each terminal, when the configuration file sent by a certain terminal does not have the target environment parameter and the environment parameter identifier and the configuration information corresponding to the target environment parameter (for example, the developer mistakenly deletes the target environment parameter, the environment parameter identifier corresponding to the target environment parameter and the configuration information corresponding to the environment parameter identifier), the environment parameter identifier and the configuration information corresponding to the environment parameter identifier, which are recorded in the default configuration file and correspond to the target environment parameter, can be directly determined as the environment parameter identifier and the configuration information to be used.
However, when writing the source code, the user may not write based on the environment parameter identifier and the configuration information corresponding to the target environment parameter in the default configuration file, so that the environment parameter identifier and the configuration information obtained directly based on the default configuration file may be wrong, which may cause that obtaining the target code based on the environment parameter identifier and the corresponding configuration information is wrong, and further when the target environment is an online test environment, a risk of system failure may occur. Therefore, to avoid the above problem, the following method may be adopted:
the second method comprises the following steps: and if the target environment parameters do not exist in the configuration file, determining a preset warning code for indicating that the system is in a repair state as a target code.
205. And preprocessing the source code according to the environment parameter identification corresponding to the target environment parameter and the configuration information corresponding to the environment parameter identification to obtain the target code.
The specific implementation manner of preprocessing the source code may be: replacing the environment parameter identification corresponding to the target environment parameter recorded in the source code with the configuration information corresponding to the environment parameter identification; and determining other environment parameters recorded in the source code according to the target environment parameters, and deleting codes corresponding to the other environment parameters.
For example, if the target environment parameter is "test", that is, the test environment, the environment parameter identifier corresponding to the target environment parameter and the configuration information corresponding to the environment parameter identifier are { "DATAHOST": http:///×. the "configuration": true };
part of the source code is:
after the source code is preprocessed based on the environment parameter identifier corresponding to the target environment parameter and the configuration information corresponding to the environment parameter identifier, the obtained target code is:
in addition, the codes corresponding to other environment parameters may be deleted first, and then the replacement processing of the environment parameter identifier and the configuration information corresponding to the environment parameter identifier may be performed based on the remaining codes.
206. And after the target codes corresponding to the source codes are obtained, carrying out duplication elimination processing on the obtained target codes according to a preset duplication elimination rule to obtain final target codes.
In practical applications, a phenomenon that functional modules developed by two developers are duplicated may be caused for some reasons, so that each target code obtained by the code building server is duplicated, and a situation that the same function is executed twice subsequently occurs. In order to solve the above problems, in this step, after the target codes corresponding to the source codes sent by each terminal are obtained, the duplication elimination processing is performed on each target code according to a preset duplication elimination rule, and then the code after duplication elimination is deployed on the server corresponding to the target environment.
According to a preset deduplication rule, a specific implementation manner of performing deduplication processing on each obtained target code may be: carrying out duplicate removal processing on object codes with the same file names; or, carrying out duplication elimination processing on object codes with the same code content; or, the object codes with the same hash value are subjected to deduplication processing. The last two implementation modes can perform deduplication processing on files with different file names and the same file content, and the third mode is higher in efficiency than the second mode.
Further, in practical applications, when a developer refers to a source code of a page developed by another developer for page layout, a situation of reference misordering may occur, for example, a description of a sequence of red, orange, yellow and green is wrongly referred to as red, yellow, green and orange, so that a phenomenon that different layouts exist on the same page may occur. In order to avoid the above problems, the embodiments of the present invention provide the following improvements: detecting whether CSS (Cascading Style Sheets) used for describing different target codes of the same page are the same; if not, displaying error prompt information. Because the running sequence of the target code is a development environment, a test environment and an on-line production environment, when error prompt information is displayed in the process of running the target code in the development environment, developers can immediately modify the error prompt information, and therefore the risk of page disorder on line is avoided.
Further, according to the above method embodiment, another embodiment of the present invention further provides an apparatus for constructing a code, as shown in fig. 3, the apparatus mainly includes: a receiving unit 31, a determining unit 32, an obtaining unit 33 and a processing unit 34. Wherein,
a receiving unit 31 that receives a build command for instructing to build the object code;
a determination unit 32 that determines a target environmental parameter from the build command received by the reception unit 31;
the acquiring unit 33 acquires a pre-stored configuration file and a source code corresponding to the configuration file and including an environment parameter identifier, where the configuration file includes at least one environment parameter, a corresponding environment parameter identifier corresponding to the environment parameter, and configuration information corresponding to the environment parameter identifier;
a determining unit 32, configured to determine configuration information corresponding to the target environment parameter according to the target environment parameter and the matching result of the environment parameter;
and the processing unit 34 is configured to perform preprocessing on the source code according to the environment parameter identifier corresponding to the target environment parameter determined by the determining unit 32 and the configuration information corresponding to the environment parameter identifier, so as to obtain the target code, where the preprocessing includes converting the source code including the environment parameter identifier into a code including the configuration information, which is matched with the target environment parameter.
The device for constructing a code provided by the embodiment of the invention can receive a configuration file which is sent by a terminal and contains various environmental parameters, environmental parameter identifications corresponding to each environmental parameter and configuration information corresponding to the environmental parameter identifications, and a source code corresponding to the configuration file, when a code suitable for a certain environment needs to be constructed, a user can send a construction command based on a server, after the server receives the construction command, the target environmental parameter can be determined according to the construction command, then the environmental parameter identifications corresponding to the target environmental parameter and the configuration information corresponding to the environmental parameter identifications are obtained from the configuration file, and finally the source code containing the environmental parameter identifications is converted into the target code which is matched with the target environmental parameter and contains the configuration information according to the environmental parameter identifications and the configuration information corresponding to the environmental parameter identifications, the target code is deployed to the server corresponding to the environment for execution, so that the codes stored in the servers of various environments only contain the codes suitable for the current environment, and no codes in other environments exist, and the phenomenon that the internal information of the enterprise is leaked due to the fact that the codes in other environments are displayed to the user is avoided. In addition, since the source code written by the developer using the environment parameter identification can be applied to various environments, there is no phenomenon of modifying the source code, thereby realizing the function of minimally intruding the source code.
Further, as shown in fig. 4, the processing unit 34 includes:
the replacing module 341 replaces the environment parameter identifier corresponding to the target environment parameter recorded in the source code with the configuration information of the environment parameter identifier mark;
the determining module 342 determines that other environment parameters are recorded in the source code according to the target environment parameters;
the deleting module 343 deletes the codes corresponding to the other environment parameters determined by the determining module 342.
Further, as shown in fig. 4, the determination unit 32 includes:
the judging module 321 judges whether the construction command carries an environmental parameter;
a first determining module 322, configured to determine the environmental parameter carried in the construction command as the target environmental parameter when the judgment result of the judging module 321 is that the construction command carries the environmental parameter;
an obtaining module 323, configured to obtain basic information of the server corresponding to the target environment when the determination result of the determining module 321 is that the construction command does not carry the environment parameter;
the second determining module 324 determines the target environment parameter according to the basic information acquired by the acquiring module 323, where the basic information includes an internet protocol IP address.
Further, the obtaining unit 33 obtains, when there is no target environment parameter in the configuration file, an environment parameter identifier corresponding to the target environment parameter and configuration information corresponding to the environment parameter identifier from the default configuration file.
Further, the determining unit 32 determines a preset warning code indicating that the system is in a repair state as the target code when the target environment parameter is not in the configuration file.
Further, as shown in fig. 4, the apparatus further includes:
and the duplicate removal unit 35, after obtaining the object codes corresponding to the source codes, performs duplicate removal processing on the obtained object codes according to a preset duplicate removal rule to obtain final object codes.
Further, as shown in fig. 4, the deduplication unit 35 includes:
the first duplication removal module 351 is used for carrying out duplication removal processing on the object codes with the same file names;
the second deduplication module 352 performs deduplication processing on target codes with the same code content;
the third deduplication module 353 performs deduplication processing on object codes with the same hash value.
Further, as shown in fig. 4, the apparatus further includes:
the detecting unit 36 detects whether the cascading style sheets CSS for describing different target codes of the same page are the same;
and a display unit 37 for displaying error prompt information when the detection results of the detection units 36 are different.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
It will be appreciated that the relevant features of the method and apparatus described above are referred to one another. In addition, "first", "second", and the like in the above embodiments are for distinguishing the embodiments, and do not represent merits of the embodiments.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
The algorithms and displays presented herein are not inherently related to any particular computer, virtual machine, or other apparatus. Various general purpose systems may also be used with the teachings herein. The required structure for constructing such a system will be apparent from the description above. Moreover, the present invention is not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the present invention as described herein, and any descriptions of specific languages are provided above to disclose the best mode of the invention.
In the description provided herein, numerous specific details are set forth. It is understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: that the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.
The various component embodiments of the invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that a microprocessor or Digital Signal Processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components of the method and apparatus for constructing code in accordance with embodiments of the present invention. The present invention may also be embodied as apparatus or device programs (e.g., computer programs and computer program products) for performing a portion or all of the methods described herein. Such programs implementing the present invention may be stored on computer-readable media or may be in the form of one or more signals. Such a signal may be downloaded from an internet website or provided on a carrier signal or in any other form.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The usage of the words first, second and third, etcetera do not indicate any ordering. These words may be interpreted as names.

Claims (16)

1. A method of constructing code, the method comprising:
receiving a build command indicating to build the object code;
determining a target environment parameter according to the construction command;
acquiring a pre-stored configuration file and a source code which is corresponding to the configuration file and comprises an environment parameter identifier, wherein the configuration file comprises at least one environment parameter, the environment parameter identifier corresponding to the environment parameter and configuration information corresponding to the environment parameter identifier;
determining an environmental parameter identifier corresponding to the target environmental parameter and configuration information corresponding to the environmental parameter identifier according to the matching result of the target environmental parameter and the environmental parameter;
and preprocessing the source code according to the environment parameter identification corresponding to the target environment parameter and the configuration information corresponding to the environment parameter identification to obtain a target code, wherein the preprocessing comprises converting the source code comprising the environment parameter identification into a code comprising the configuration information and matched with the target environment parameter.
2. The method of claim 1, wherein preprocessing the source code according to an environment parameter identifier corresponding to the target environment parameter and configuration information corresponding to the environment parameter identifier, and obtaining the target code comprises:
replacing the environment parameter identification corresponding to the target environment parameter recorded in the source code with the configuration information corresponding to the environment parameter identification;
and determining other environment parameters recorded in the source code according to the target environment parameters, and deleting codes corresponding to the other environment parameters.
3. The method of claim 1, wherein determining a target environmental parameter from the build command comprises:
judging whether the construction command carries an environmental parameter;
if the construction command carries the environmental parameters, determining the environmental parameters carried in the construction command as target environmental parameters;
if the construction command does not carry the environmental parameters, acquiring basic information of a server corresponding to the target environment, and determining the target environmental parameters according to the basic information, wherein the basic information comprises an Internet Protocol (IP) address.
4. The method of claim 1, further comprising:
and if the target environment parameter does not exist in the configuration file, acquiring an environment parameter identifier corresponding to the target environment parameter and configuration information corresponding to the environment parameter identifier from a default configuration file.
5. The method of claim 1, further comprising:
and if the target environment parameters are not in the configuration file, determining a preset warning code for indicating that the system is in a repair state as a target code.
6. The method of claim 1, wherein after obtaining the object code corresponding to each source code, the method further comprises:
and according to a preset duplication elimination rule, carrying out duplication elimination processing on each obtained object code to obtain a final object code.
7. The method of claim 6, wherein performing deduplication processing on each obtained object code according to a preset deduplication rule comprises:
carrying out duplicate removal processing on object codes with the same file names;
or, carrying out duplication elimination processing on object codes with the same code content;
or, the object codes with the same hash value are subjected to deduplication processing.
8. The method according to any one of claims 1 to 7, further comprising:
detecting whether CSSs of different target codes for describing the same page are the same;
if not, displaying error prompt information.
9. An apparatus for constructing code, the apparatus comprising:
a receiving unit that receives a build command for instructing to build an object code;
the determining unit is used for determining target environment parameters according to the construction command received by the receiving unit;
the device comprises an acquisition unit, a storage unit and a processing unit, wherein the acquisition unit is used for acquiring a pre-stored configuration file and a source code which corresponds to the configuration file and comprises an environment parameter identifier, and the configuration file comprises at least one environment parameter, an environment parameter identifier corresponding to the environment parameter and configuration information corresponding to the environment parameter identifier;
the determining unit is used for determining an environmental parameter identifier corresponding to the target environmental parameter and configuration information corresponding to the environmental parameter identifier according to the target environmental parameter and the matching result of the environmental parameter;
and the processing unit is used for preprocessing the source code according to the environment parameter identifier corresponding to the target environment parameter and the configuration information corresponding to the environment parameter identifier, which are determined by the determining unit, so as to obtain the target code, wherein the preprocessing comprises the step of converting the source code comprising the environment parameter identifier into a code which is matched with the target environment parameter and comprises the configuration information.
10. The apparatus of claim 9, wherein the processing unit comprises:
the replacing module is used for replacing the environment parameter identification corresponding to the target environment parameter recorded in the source code with the configuration information corresponding to the environment parameter identification;
the determining module is used for determining other environment parameters recorded in the source code according to the target environment parameters;
and the deleting module deletes the codes corresponding to the other environment parameters determined by the determining module.
11. The apparatus of claim 9, wherein the determining unit comprises:
the judging module is used for judging whether the construction command carries an environmental parameter;
the first determining module is used for determining the environmental parameters carried in the construction command as target environmental parameters when the judgment result of the judging module is that the construction command carries the environmental parameters;
the acquisition module is used for acquiring the basic information of the server corresponding to the target environment when the judgment result of the judgment module is that the construction command does not carry the environmental parameters;
and the second determining module is used for determining the target environment parameters according to the basic information acquired by the acquiring module, wherein the basic information comprises an Internet Protocol (IP) address.
12. The apparatus according to claim 9, wherein the obtaining unit obtains, when the target environment parameter is not in the configuration file, an environment parameter identifier corresponding to the target environment parameter and configuration information corresponding to the environment parameter identifier from a default configuration file.
13. The apparatus of claim 9, wherein the determining unit determines a preset warning code indicating that the system is in a repair state as the target code when the target environment parameter is not in the configuration file.
14. The apparatus of claim 9, further comprising:
and the duplication removing unit is used for performing duplication removing processing on each obtained target code according to a preset duplication removing rule after the target code corresponding to each source code is obtained, so as to obtain the final target code.
15. The apparatus of claim 14, wherein the deduplication unit comprises:
the first duplication removal module is used for carrying out duplication removal processing on the object codes with the same file names;
the second duplication removal module is used for carrying out duplication removal processing on the target codes with the same code content;
and the third duplication removal module is used for carrying out duplication removal processing on the target codes with the same hash value.
16. The apparatus of any one of claims 9 to 15, further comprising:
the detection unit is used for detecting whether the CSSs of the cascading style sheets for describing different target codes of the same page are the same;
and the display unit displays error prompt information when the detection results of the detection units are different.
CN201610305986.2A 2016-05-10 2016-05-10 Method and device for constructing codes Active CN107357558B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610305986.2A CN107357558B (en) 2016-05-10 2016-05-10 Method and device for constructing codes

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610305986.2A CN107357558B (en) 2016-05-10 2016-05-10 Method and device for constructing codes

Publications (2)

Publication Number Publication Date
CN107357558A true CN107357558A (en) 2017-11-17
CN107357558B CN107357558B (en) 2020-07-24

Family

ID=60272000

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610305986.2A Active CN107357558B (en) 2016-05-10 2016-05-10 Method and device for constructing codes

Country Status (1)

Country Link
CN (1) CN107357558B (en)

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108664270A (en) * 2018-05-09 2018-10-16 平安普惠企业管理有限公司 Environment dynamic switching method, device, computer equipment and storage medium
CN110275699A (en) * 2018-03-15 2019-09-24 拉扎斯网络科技(上海)有限公司 Code construction method, Serverless platform and object storage platform
CN110389755A (en) * 2019-07-24 2019-10-29 网易(杭州)网络有限公司 Code process method and device, electronic equipment and computer readable storage medium
CN110858143A (en) * 2018-08-22 2020-03-03 广州虎牙信息科技有限公司 Installation package generation method, device, equipment and storage medium
CN111026403A (en) * 2019-12-10 2020-04-17 北京锐安科技有限公司 Packing deployment method and device, computer equipment and storage medium
CN111443923A (en) * 2020-03-26 2020-07-24 北京房天下嘉居网络技术有限公司 Service publishing method and device
CN112596782A (en) * 2020-12-26 2021-04-02 中国农业银行股份有限公司 Production program package generation method and related equipment
CN112732361A (en) * 2021-01-18 2021-04-30 龙芯中科技术股份有限公司 Function implementation method, device and equipment
CN112965767A (en) * 2021-03-08 2021-06-15 北京金山云网络技术有限公司 Job processing method and apparatus, electronic device, and storage medium
CN115269562A (en) * 2022-09-26 2022-11-01 北京奥星贝斯科技有限公司 Database management method and device, storage medium and electronic equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100325607A1 (en) * 2009-06-17 2010-12-23 Microsoft Corporation Generating Code Meeting Approved Patterns
CN102135904A (en) * 2011-03-11 2011-07-27 华为技术有限公司 Multi-core target system oriented mapping method and device
GB2510866A (en) * 2013-02-15 2014-08-20 Geeks Ltd Computer code editor
CN104536744A (en) * 2014-12-19 2015-04-22 微梦创科网络科技(中国)有限公司 Method and server for automatically building and deploying codes
CN104572644A (en) * 2013-10-10 2015-04-29 北京大学 Database updating device and database updating method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100325607A1 (en) * 2009-06-17 2010-12-23 Microsoft Corporation Generating Code Meeting Approved Patterns
CN102135904A (en) * 2011-03-11 2011-07-27 华为技术有限公司 Multi-core target system oriented mapping method and device
GB2510866A (en) * 2013-02-15 2014-08-20 Geeks Ltd Computer code editor
CN104572644A (en) * 2013-10-10 2015-04-29 北京大学 Database updating device and database updating method
CN104536744A (en) * 2014-12-19 2015-04-22 微梦创科网络科技(中国)有限公司 Method and server for automatically building and deploying codes

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110275699A (en) * 2018-03-15 2019-09-24 拉扎斯网络科技(上海)有限公司 Code construction method, Serverless platform and object storage platform
CN108664270A (en) * 2018-05-09 2018-10-16 平安普惠企业管理有限公司 Environment dynamic switching method, device, computer equipment and storage medium
CN110858143A (en) * 2018-08-22 2020-03-03 广州虎牙信息科技有限公司 Installation package generation method, device, equipment and storage medium
CN110858143B (en) * 2018-08-22 2023-07-28 广州虎牙信息科技有限公司 Installation package generation method, device, equipment and storage medium
CN110389755A (en) * 2019-07-24 2019-10-29 网易(杭州)网络有限公司 Code process method and device, electronic equipment and computer readable storage medium
CN111026403A (en) * 2019-12-10 2020-04-17 北京锐安科技有限公司 Packing deployment method and device, computer equipment and storage medium
CN111443923A (en) * 2020-03-26 2020-07-24 北京房天下嘉居网络技术有限公司 Service publishing method and device
CN112596782A (en) * 2020-12-26 2021-04-02 中国农业银行股份有限公司 Production program package generation method and related equipment
CN112732361A (en) * 2021-01-18 2021-04-30 龙芯中科技术股份有限公司 Function implementation method, device and equipment
CN112732361B (en) * 2021-01-18 2023-05-16 龙芯中科技术股份有限公司 Function realization method, device and equipment
CN112965767A (en) * 2021-03-08 2021-06-15 北京金山云网络技术有限公司 Job processing method and apparatus, electronic device, and storage medium
CN115269562A (en) * 2022-09-26 2022-11-01 北京奥星贝斯科技有限公司 Database management method and device, storage medium and electronic equipment

Also Published As

Publication number Publication date
CN107357558B (en) 2020-07-24

Similar Documents

Publication Publication Date Title
CN107357558B (en) Method and device for constructing codes
US9852049B2 (en) Screenshot validation testing
US9535781B2 (en) System file repair method and apparatus
CN107133165B (en) Browser compatibility detection method and device
US10049031B2 (en) Correlation of violating change sets in regression testing of computer software
CN106776334B (en) Comment-based test case generation method and device
US20100218049A1 (en) Method of Creating Signatures for Classifying Program Failures
CN105631341B (en) Blind detection method and device for vulnerability
CN111198809A (en) Interface automation test method and device
CN107632901A (en) A kind of self-repair method and device of application program operation exception
CN109144874B (en) Method and device for monitoring test environment
CN107784230B (en) The restorative procedure and device of page loophole
CN110287696A (en) A kind of detection method, device and the equipment of the shell process that rebounds
WO2015131643A1 (en) Software detection method and device
CN109213505A (en) Server hard disc firmware method for refreshing and device
CN113360379B (en) Program test environment creation method and program test environment creation apparatus
CN110737573B (en) Method and device for automatically testing user interface UI
CN104809053A (en) Control style testing method and device
JP5967225B2 (en) Data update omission inspection device, data update omission inspection method, data update omission inspection program
CN103095698B (en) The restorative procedure of client software, device and communication system
CN105700917A (en) Method and apparatus for synchronizing DLL and database
CN111538994A (en) System security detection and repair method, device, storage medium and terminal
CN110737577B (en) Test defect data storage method and device
US20140281719A1 (en) Explaining excluding a test from a test suite
WO2017054731A1 (en) Method and device for processing hijacked browser

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
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20200921

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee after: Innovative advanced technology Co.,Ltd.

Address before: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee before: Advanced innovation technology Co.,Ltd.

Effective date of registration: 20200921

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee after: Advanced innovation technology Co.,Ltd.

Address before: A four-storey 847 mailbox in Grand Cayman Capital Building, British Cayman Islands

Patentee before: Alibaba Group Holding Ltd.