Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Example 1
Fig. 1 is a flowchart of a program code management method according to a first embodiment of the present invention, where the method may be implemented by a program code management device, and the program code management device may be implemented in hardware and/or software and may be configured in a terminal integrated with a set operating environment. As shown in fig. 1, the method includes:
S101, acquiring a construction script configured under a code management directory, wherein the code management directory is created in advance under the set running environment through a set command, and a plurality of management subdirectories are also created in advance in the code management directory.
The method comprises the steps of setting an operation environment, wherein the operation environment is a basis for realizing automatic management of applet codes, and the capability of automatically executing scripts or instructions can be provided for a terminal. For example, the setting execution environment may be a node. Js execution environment, and the terminal may be enabled to execute a script written in JavaScript. Accordingly, the build script may be a program written using JavaScript, including specific logic, that may be used to instruct code management operations, defining rules or procedures for the code management operations. The set command may be an instruction in the node. Js runtime environment that can initiate creation of a code management directory.
The code management directory may be a root directory created in the set-up running environment with all applets and code in the items. It should be noted that, when developing, each applet may correspond to a program item, and each program item includes a code corresponding to the applet. The code management directory can centralize and structure the codes originally scattered in different program items, thereby providing a unified path and data source for subsequent automatic management operations.
Further, the code management directory further includes a plurality of management subdirectories, and the management subdirectories can divide the code management directory according to different dimensions. For example, codes having the same function or the same code among the respective applets in the code management directory may be stored as common function codes in a common code sub-directory, and differentiated configuration parameters among the respective applets in the code management directory may be stored in a configuration sub-directory.
By way of example, taking setting the running environment as the node.js running environment as an example, the present embodiment may configure a package.json file by a command line running npm init command on a terminal configured with the node.js running environment, thereby creating the code management directory projectMini. Further, a plurality of management subdirectories may be created in the code management directory projectMini in different dimensions, and build scripts capable of defining code management operation rules may be configured.
Preferably, the management subdirectory may include a public page directory for recording public pages, a public interface directory for recording public function interfaces, a program item directory for recording program items, and a public configuration file for configuring attribute information and differentiation parameters of the program items.
It will be appreciated that under the code management directory projectMini, a public page directory commonPage may be created, respectively, which may be used to record public page codes (e.g., program codes of login pages), a public interface directory commonApi may be used to record public function interface codes (e.g., program codes of payment interfaces), a program item directory miniprogram may be used to record paths of program items corresponding to respective applets, and a public configuration file appconfig. Js may be used to record global parameters of different applets, such as program item names of applets, app ids of applets, applet names, applet logo, default sharing graphs, etc.
In the prior art, when development and maintenance are performed on the applet, code development or modification is required in the program item corresponding to the applet. Since the code is completely independent between program items of each applet, the same or similar functions (such as login, payment, etc.) need to be repeatedly developed in different applets, resulting in code redundancy. Meanwhile, when the function of the applet is updated or repaired, each applet item needs to be modified respectively, so that the maintenance efficiency is low and the inconsistency problem is easy to occur.
The embodiment can divide codes originally scattered in different program items into a public page directory for recording public pages, a public interface directory for recording public function interfaces, a program item directory for recording program items and a public configuration file for configuring attribute information and differential parameters of the program items in a concentrated manner, so that the public function codes of the applets are separated from specific configuration of the applets, and when the public functions (such as login functions) of the applets are developed, repeated development can be avoided only once, and code redundancy is reduced.
S102, analyzing the construction script to generate a code management instruction, and determining a management object corresponding to the code management instruction from each management subdirectory.
The code management instruction may be an instruction that parses the management requirement of the construction script, and the generated instruction containing the complete management operation semantics may be used to instruct how to execute the management operation specifically. For example, the management operations performed may be to synchronize common function code to all applets or specified applets, or to synchronize code of one applet to other applets (either in full or in a particular file or folder).
The management object may be a program code or a program item to be involved in performing the management operation. For example, when the management operation is to synchronize the common function code to all the applets or the specified applets, then the common function code recorded in the common code management sub-directory, and the program code or program items of all the applets or the specified applets, may be taken as management objects.
For example, the obtained build script may be parsed, and specific code management instructions may be generated through a parsing process. Meanwhile, according to the logic of the code management instruction, the management object which needs to be processed in the code management operation can be identified and determined from each management subdirectory under the code management directory. These management objects may be the source of code management operations, and may also be the target of code management operations.
S103, running the code management instruction, and executing code management logic on the management object by calling a setting function module in the setting running environment.
The setting function module may be a function provided by the setting operation environment (such as node. Js operation environment) and used for executing a management operation. For example, the setting function module may be a delete and copy function of fs, fsExtra files/folders in the node. Js operating environment.
The code management logic may be to implement automated management operations on code in a set-up runtime environment. It should be noted that the code management instruction may be instruction information of how to execute the management operation at this time. And code management logic may be an implementation of how management operations are performed this time.
Illustratively, the specific code management logic may be executed for the determined management object by executing the generated code management instructions to execute the set function module provided by the call set execution environment (e.g., to invoke the delete and copy functions of fs, fsExtra files/folders in the node. Js execution environment). For example, a code management instruction may be executed to synchronize common function code under a code management directory into program items of all applets by invoking delete and copy functions of fs, fsExtra files/folders in the node. Js operating environment.
According to the technical scheme, the construction script configured under the code management catalog is obtained, the code management catalog is created in advance under the set running environment through the set command, the code management catalog is also created with the plurality of management subdirectories in advance, then the construction script is analyzed to generate the code management instruction, the management object corresponding to the code management instruction is determined from the management subdirectories, finally the code management instruction is operated, the code management logic is executed for the management object through calling the set function module under the set running environment, the problem that the prior art lacks of a management framework capable of uniformly carrying out centralized scheduling on a plurality of small program codes and the problem that the management on the codes of the plurality of small programs under the same main body cannot be automated is solved, and the centralized scheduling and automatic management on the plurality of small program codes are realized.
Example two
Fig. 2 is a flowchart of a program code management method according to a second embodiment of the present invention. The present embodiment may further improve the above embodiment in the case where the build script is configured as the first synchronization script having the common code synchronization requirement. As shown in fig. 2, the method includes:
S201, acquiring a construction script configured under a code management directory, wherein the code management directory is created in advance under the set running environment through a set command, and a plurality of management subdirectories are also created in advance in the code management directory. The management subdirectory comprises a public page directory for recording public pages, a public interface directory for recording public function interfaces, a program item directory for recording program items, and a public configuration file for configuring attribute information and differentiation parameters of the program items.
S202, if the construction script is configured to be a first synchronization script with a public code synchronization requirement, generating a public code synchronization instruction corresponding to the public code synchronization requirement and taking the public code synchronization instruction as a code management instruction;
wherein the common code synchronization requirement may be to synchronize the common function code into all applets or specified applets. The first synchronization script may be a build script corresponding to configuration requirements for synchronizing common function code into all applets or specified applets.
The common code synchronization instruction may be an instruction that instructs to synchronize a common function code into all applets or specified applets. For example, the common code synchronization instruction may be a npm command in the node. Js execution environment that instructs all files under the common page directory commonPage and common interface directory commonApi to be copied to all applets in the common configuration file appconfig.
For example, when the parsing of the build script determines that the management requirement of the build script is to synchronize the common function code, a common code synchronization instruction corresponding to the configuration requirement of the common function code synchronization may be generated as the code management instruction. The code management instructions may specifically indicate whether the common code synchronization requirement requires that the common code be synchronized to all applets or that the common code be synchronized to a specified applet.
Step S203 is performed when the common function code needs to be synchronized to all the applets, and step S204 is performed when the common function code needs to be synchronized to a specified applet.
And S203, when the common code synchronization requirement is unified management and multi-terminal synchronization of the common function codes, taking the common page directory and the common interface directory as source management objects, and taking program items corresponding to the program item names contained in the common configuration file as target management objects.
Where unified management and multiterminal synchronization of common function code may be understood as requiring synchronization of common function code to all applets.
The source management object may be a management subdirectory that provides the original code content in a code management operation, storing source code that needs to be synchronized, replicated or processed. The target management object may be an object that receives source code in a code management operation. In the applet item directory miniprogram, a program item corresponding to all applets in the common configuration file appconfig. Js of the code management directory projectMini may be used as a target management object when it is necessary to synchronize a common function code to all applets.
For example, when determining the common code synchronization requirement to synchronize the common function code to all applets, the common page directory and the common interface directory in the code management directory may be used as source management objects, and program items corresponding to program item names of all applets contained in the common configuration file may be used as target management objects.
S204, when the common code synchronization requirement is that the common function module is synchronized to the designated program item according to the configuration, the common page directory and the common interface directory are used as source management objects, and the designated program item is used as target management objects.
Where synchronizing common function modules to specified program items by configuration is understood to mean that common function code needs to be synchronized to specified applets. At this time, the main body required to provide the source code for the code synchronization can still be the public page directory and the public interface directory, and the execution object of the code synchronization can be the program item corresponding to the specified applet.
For example, when the common code synchronization requirement is determined to be that the common function code needs to be synchronized into a specified applet, a common page directory and a common interface directory in a code management directory may be taken as source management objects, and program items of the specified program may be taken as target management objects.
It should be noted that the specified program item may be indicated by a corresponding parameter in the code management instruction. For example, the item name of the specified program item is added to the code management instruction so that the system can recognize the specified program item as a target management object.
And S205, triggering the code management instruction to execute through a npm command in the set running environment, calling a first functional module with a file copying function, and copying all files recorded under the public page directory and the public interface directory to each program item contained in the public configuration file or to the appointed program item.
The npm command may be a management operation instruction in the node. Js operating environment. For example, a code management operation may be triggered by taking npm command as a code management instruction. For example, the common function code may be indicated to be synchronized to all applets by npm run build-common run commands, while the common function code may also be indicated to be synchronized to program item project1 by npm run build-common project1 run commands.
The first function module may be a pre-established module having a file copy function. For example, the first functional module may be implemented by means of the delete and copy functions of fs, fsExtra files/folders in the node. Js operating environment.
By way of example, a npm run build-common run command may indicate that common function code needs to be synchronized to all applets.
On this basis, by firstly acquiring global configuration items (including applet appId, applet name appName, applet item directory name projectDir, default sharing map, default sharing title defaultShare, and top navigation bar mark navbarLogo) of all applets in a public configuration file appConfig. js in a code management directory projectMini, copying all code files under a public page item commonPage in the code management directory projectMini to all applets through a first functional module, and enabling a path after copying to be projectMini/miniprogram/applets/pages/commonPage, the synchronization of public page codes to program items of different applets is realized, and meanwhile, copying all code files under a public interface directory commonApi in a code management directory projectMini to all applets, and enabling a path after copying to be projectMini/miniprogram/applets/api/commonApi, so that the synchronization of public api codes to program items of different applets is realized.
Or may indicate via npm run build-common project1 run command that common function code needs to be synchronized onto specified program item project 1.
On this basis, the synchronization of the common page code into a specific applet item can be realized by firstly acquiring the global configuration item (including applet appId, applet name appName, applet item directory name projectDir, default sharing map, default sharing title defaultShare, top navigation bar flag navbarLogo) of the program item project1 of the specific applet in the common configuration file appConfig. js in the code management directory projectMini, copying all code files under the common page item commonPage in the code management directory projectMini into the program item project1 of the specific applet through the first functional module, and the path after copying can be projectMini/miniprogram/project 1/pages/commonPage, wherein all code files under the common interface directory commonApi in the code management directory projectMini are copied into the program item project1 of the specific applet, and the path after copying is projectMini/miniprogram/project 1/api/commonApi.
According to the technical scheme, when the construction script is determined to be configured as the first synchronization script with the public code synchronization requirement, the public page directory and the public interface directory are taken as source management objects, meanwhile, program items corresponding to the names of all program items contained in the public configuration file or designated program items are taken as target management objects, further, a command npm under a set running environment triggers code management instruction execution, a first function module with a file copying function is called to copy all files recorded in the public page directory and the public interface directory to all program items contained in the public configuration file or to the designated program items, unified management and multi-terminal synchronization of the public function codes are achieved, repeated development is avoided, automatic synchronization of the public function codes to the designated small program items according to configuration is supported, and the flexibility of code synchronization is improved.
Example III
Fig. 3 is a flowchart of a program code management method according to a third embodiment of the present invention. The present embodiment may further improve the above embodiment in the case that the build script is configured as a second synchronization script having a code synchronization requirement between program items. As shown in fig. 3, the method includes:
S301, acquiring a construction script configured under a code management catalog, wherein the code management catalog is created in advance under the set running environment through a set command, and a plurality of management subdirectories are also created in advance, and the management subdirectories comprise a public page catalog for recording public pages, a public interface catalog for recording public function interfaces, a program item catalog for recording program items and a public configuration file for configuring attribute information and differentiation parameters of the program items.
S302, if the construction script is configured as a second synchronization script with the inter-program-item code synchronization requirement, generating an inter-program-item code synchronization instruction corresponding to the inter-program-item code synchronization requirement and taking the inter-program-item code synchronization instruction as a code management instruction.
The code synchronization requirement between program items can be to synchronize the code in the program item of one source applet to the program item of other target applets, or to synchronize configuration related differentiation parameters. It will be appreciated that during code synchronization between program items, a certain full amount of functional code in the program items of the source applet may be synchronized into the program items of other target applets, or a specific file or folder portion in the program items of the source applet may be synchronized into the program items of other target applets. The synchronization configuration related differencing parameter may be to synchronize the global configuration in the common configuration file into a specified applet.
The second synchronization script may be a build script corresponding to code synchronization requirements configuration requirements among the program items.
For example, when parsing the build script determines that the management requirement of the build script is to synchronize the code in the program item of one source applet to the program item of another target applet, or that a synchronization configuration related differentiation parameter is required, an inter-project code synchronization instruction corresponding to the inter-program code synchronization requirement may be generated as the code management instruction. The code management instructions may specifically denote synchronizing a function code or part of a file/folder in a program item of one source applet to all other target applets or other part specific target applets, or synchronizing a global configuration in a common configuration file to a designated applet.
Step S303 may be performed when the code management instruction indicates that a certain function code in the program item of one source applet needs to be synchronized into all other target applets or other part-specific target applets, step S304 may be performed when the code management instruction indicates that a part of files/folders in the program item of one source applet needs to be synchronized into all other target applets or other part-specific target applets, and step S305 may be performed when the code management instruction indicates that a global configuration in a common configuration file needs to be synchronized into a specific applet.
S303, when the code synchronization requirement among the program items is that any function module of the program items is modified, and the modified content is synchronized to other program items with the function module, taking a first designated item in the program item catalog as a source management object, taking a program item corresponding to each program item name contained in the common configuration file as a target management object, or taking a second designated item in the program item catalog as a target management object.
After any functional module of a program item is modified, synchronizing the modified content to other program items with the functional module can be understood as synchronizing a functional code in a program item of a source applet to all other target applets or other part specific target applets. It should be noted that, based on the function module that sends the modification, it may be determined to synchronize specifically to all other target applets or to synchronize to other specific target applets. For example, for a functional module included in each applet, if the functional module sends a modification, it may be synchronized to all other target applets. And for the functional module contained in only part of the applet, if the functional module sends a modification, the functional module can be synchronized to other designated part of the object applet. In addition, the code synchronization object applet can be determined by receiving a user's parameter configuration of the code management instructions.
The first specified item in the program item catalog may be a program item corresponding to an applet that the functional module has modified. The second specified item in the program item catalog may be a program item corresponding to another specific applet containing the same functional module.
For example, when it is determined that it is necessary to synchronize a function code in a program item of one source applet to all other target applets or other part-specific target applets, a first designated item corresponding to the source applet modified by the function module in the program item directory miniprogram may be taken as a source management object, and a program item corresponding to the program item names of all applets included in the common configuration file may be taken as a target management object, or a program item corresponding to other specific applets including the same function module in the program item directory miniprogram may be taken as a target management object.
S304, setting a folder under a first designated item in the program item catalog as a source management object, and taking a program item corresponding to each program item name contained in the common configuration file as a target management object or taking a third designated item from the program item catalog as a target management object when the code synchronization requirement among the program items is single file or folder selective synchronization among the program items.
The selective synchronization of individual files or folders among program items may be understood as requiring the synchronization of a portion of the files/folders in a program item of a source applet to all other target applets or other portion-specific target applets, or the need to synchronize configuration-related differencing parameters. Step S304 may be a process of determining a source management object and a target management object on the premise that a single file or folder is selectively synchronized among program items as part of the files/folders in the program items of one source applet needs to be synchronized to all other target applets or other part of specific target applets.
The settings folder may be a modified portion of the folder under the program item corresponding to the source applet that the functional module has been modified. Accordingly, the third specified item in the program item catalog may be a program item having the same folder as the source applet.
For example, when it is determined that it is necessary to synchronize a part of the files/folders in the program items of one source applet to all other target applets or other part-specific target applets, the part of the folders in the program item directory miniprogram that are modified under the first designated item corresponding to the source applet modified by the function module may be taken as the source management object, and the program items corresponding to the program item names of all applets contained in the common configuration file may be taken as the target management object, or the third designated item having the same folder as the source applet in the program item directory miniprogram may be taken as the target management object.
S305, when the code synchronization requirement among the program items is that a single file or folder is selectively synchronized among the program items, the common configuration file is taken as a source management object, and a fourth designated item in the program item catalog is taken as a target management object.
It should be noted that, step S305 may be a process of determining the source management object and the target management object on the premise that a single file or folder is selectively synchronized between program items to require synchronization configuration related differentiation parameters.
The fourth specified item in the program item catalog may refer to a program item of an applet that needs to configure the relevant differentiation parameters.
For example, when determining that the synchronization configuration related differential parameters are required, the common configuration file may be used as a source management object, and the fourth specified item corresponding to the applet requiring the configuration related differential parameters may be used as a target management object.
S306, triggering the code management instruction to execute through npm commands in the set running environment, calling a second functional module with file deleting, reading, copying and regular expression text replacing functions, determining to-be-synchronized content from the source management object, and copying the to-be-synchronized code into the target management object, wherein the to-be-synchronized content is a code file, a specific folder or a configuration file content which participates in adding and deleting.
The npm command may be a management operation instruction in the node. Js operating environment. For example, a code management operation may be triggered by taking npm command as a code management instruction. For example, applet project1 may be copied to all applets in a common configuration file appConfig. js through npm run build project1, applet project1 may be copied to applet project2 through npm run build project1 project2, specific folders in applet project1 may be copied to all applets in appConfig. js through npm run build project all pages/logins, specific files in applet project1 may be copied to applet project2 through npm run build project project2 api/index. Js, and global configuration in appConfig. js may be synchronized to applet project1 through npm run build project1 onlyResetConfig.
The second functional module may be a pre-established module with file deletion, reading, copying, and regular expression text replacement functions. For example, the second functional module may be implemented using delete, copy, read functions of fs and fsExtra modules in the node. Js execution environment, and regular expression text replacement functions. Optionally, the application object replaced by the regular expression text is a differential configuration item, wherein the differential configuration item comprises an item base identifier, an interface display text and a global variable, and the global variable comprises an application name, a default sharing title, a default sharing picture and a navigation bar.
Illustratively, when executing the npm run build project1 command, applet project1 can be copied into all other applet items registered in the common configuration file, appconfig.
For example, global configuration items of all target applets in the common configuration file acconfig. js in the code management directory projectMini are acquired first, then the common configuration file acconfig. js in the code management directory projectMini is copied to the static/js directory of all target applets, and the path after copying is projectMini/miniprogram/target applet/static/js/appConfig. js. Thereafter, all files under program item project1 of the source applet can be copied to all target applets (except the source applet) for synchronization of the source applet code into different target applet items.
At this time, the program codes of the source applet and the target applet are identical, so that global configurations such as logo, name, default sharing map, default title, navbarLogo, etc. of each applet are independent.
The global configuration of logo, name, default sharing graph, default title, navbarLogo and the like of the source applet can be replaced by the global configuration item of the target applet in the program item of the target applet respectively by using a regular expression text replacement function.
For example, in order to make global configurations such as logo, name, default sharing map, default title, navbarLogo of each applet independent, the method can be used for respectively reading projectMini/miniprogram/target applet/project. Config. Json file, then using regular expression text replacement to replace appId with target applet appId and save file, this step can solve the configuration of different target applet appId and save file, respectively reading projectMini/miniprogram/target applet/app.json file stream, then using regular expression text replacement to replace navigationBarTitleText with corresponding target applet appName in projectMini/appConfig.js, and using save file, this step can solve the differentiation of different target applet top titles navigationBarTitleText, respectively reading projectMini/miniprogram/target applet/app.js file stream, then using regular expression text replacement to replace appName, defaultShareTitle, defaultShareImg, navbarLogo with corresponding target applet in projectMini/appfig.js, and save file, this step can solve the configuration of different target applet in projectMini/appConfig.js, and save file, this step can solve the difference of different target applet top titles (6735), default title (default title), and other than the whole title.
It will be appreciated that when executing the npm run build project project2 command, the complete code library of applet project1 can be copied exactly into the specified project2 item and ensure that project2 remains in its independent personalized configuration.
The specific implementation process includes the steps of firstly analyzing command line parameters, identifying a source item as project1, and identifying a target item as project2. And then reading the public configuration file appconfig. Js to acquire the specific configuration information of the two items. The method comprises the steps of executing core synchronization operation, copying a public configuration file to a designated position of project2 to serve as a runtime reference, copying all code files in the project1 catalog to the project2 catalog completely to cover existing codes of the project2, finally carrying out key differential configuration processing, reading the configuration file of the project2, accurately replacing the fields such as appId, application names, navigation bar titles and sharing information in the configuration file by using a regular expression, and recovering the configuration file to be a configuration value unique to the project2. The whole process ensures that the project2 completely maintains the identity and personalized characteristics of the project1 while obtaining the latest code of the project, and realizes accurate directional code synchronization.
When executing npm run build project1 all pages/login commands, the specific login page folder in applet project1 can be copied exactly into all other applet items registered in the common configuration file appconfig.
The specific implementation process includes the steps of firstly analyzing command line parameters, identifying that a source item is project1, identifying that a target range is all items, and logging in a page folder with synchronous content of pages/logins. The common configuration file appconfig. Js is then read, a list of all applet items registered therein (e.g. project2, project3, etc.) is obtained, and the source item project1 itself is automatically excluded. And performing special file-level synchronization operation on each target item, namely copying the public configuration file to each target item for standby, accurately copying all files (including page logic, templates, styles and configuration files) under the project 1/pages/logins directory to the corresponding pages/logins paths of each target item, and finally performing necessary differential configuration processing on each target item to ensure that the login page can operate correctly in each item and keep the individual identity. The whole process realizes the accurate synchronization of specific functional modules among multiple items, and avoids unnecessary full code replication.
When executing npm run build project1 project2 API/index. Js commands, the specific API interface file in applet project1 can be copied exactly to the corresponding location of applet project 2.
The specific implementation process includes the steps of firstly analyzing command line parameters, and identifying a specific file of which a source item is project1, a target item is project2 and a synchronous object is api/index. And then reading the public configuration file appconfig. Js to acquire detailed configuration information of the two items. Then, the accurate file-level synchronization operation is performed, namely, the common configuration file is copied to the project2 for standby, one file, namely, the project1/api/index. Js, is accurately copied to the corresponding path of the project2/api/index. Js, and because of single file synchronization, the differentiated configuration replacement of all the projects is not usually performed, but the core identity of the project2 after the file is copied is ensured to be unchanged. The whole process realizes accurate code sharing of the API interface level, ensures that project2 obtains the latest realization of specific interface functions in project1, and simultaneously reduces the interference to other codes of the project2 to the greatest extent.
When executing npm run build project1 onlyResetConfig command, the global configuration parameters for project1 in the common configuration file appconfig. Js can be updated synchronously into the configuration file of the project1 item itself without any copying operation of the code file.
A specific implementation may be to first parse the command line parameters, identify the target item as project1, and confirm that this is a special configuration reset operation. And then reading a public configuration file appConfig.js, and extracting personalized configuration parameters corresponding to the project1 from the public configuration file appConfig.js, wherein the personalized configuration parameters comprise appId, application names, default sharing information, navigation bar logo and the like. And then, performing accurate configuration updating operation, namely copying the public configuration file into a static resource catalog of the project1 for standby, sequentially reading key configuration files of the project1, accurately positioning and replacing specific fields in the key configuration files by using a regular expression, namely updating appId in project. Config. Json to be a correct value, updating a navigation bar title in app. Json to be an application name of the project1, and updating global variables (such as an application name, a sharing title, a sharing picture, a navigation bar logo and the like) in app. Json to be configuration values unique to the project 1. The whole process only involves synchronous updating of configuration parameters, does not change any functional code, and ensures that the identity and personalized configuration of project1 are consistent with the central configuration library all the time while keeping the code unchanged.
According to the technical scheme, under the condition that the construction script is configured to be a second synchronization script with the code synchronization requirement among program items, the corresponding source management object and target management object are determined, the execution of the code management instruction is triggered through npm commands in the set running environment, a second functional module with file deletion, reading, copying and regular expression text replacement functions is called, the content to be synchronized is determined from the source management object, the code to be synchronized is copied to the target management object, the capability of modifying and synchronously updating all the applets at one place can be realized for the code with the same function, the global configuration independence of each applet is kept, and the selective synchronization of a single file or folder among a plurality of applets is realized.
Example IV
Fig. 4 is a schematic structural diagram of a program code management apparatus according to a fourth embodiment of the present invention. The program code management means may be arranged on a terminal integrated with the set operating environment. As shown in fig. 4, the apparatus includes:
An obtaining module 41, configured to obtain a build script configured under a code management directory, where the code management directory is created in advance under the set running environment by a set command, and where the code management directory is also created in advance with a plurality of management subdirectories;
The parsing model 42 may be configured to parse the build script to generate a code management instruction, and determine a management object corresponding to the code management instruction from each of the management subdirectories;
the management module 43 may be configured to execute the code management instruction, and execute code management logic for the management object by calling a setting function module in the setting execution environment.
According to the technical scheme, the construction script configured under the code management catalog is obtained, the code management catalog is created in advance under the set running environment through the set command, the code management catalog is also created with the plurality of management subdirectories in advance, then the construction script is analyzed to generate the code management instruction, the management object corresponding to the code management instruction is determined from the management subdirectories, finally the code management instruction is operated, the code management logic is executed for the management object through calling the set function module under the set running environment, the problem that the prior art lacks of a management framework capable of uniformly carrying out centralized scheduling on a plurality of small program codes and the problem that the management on the codes of the plurality of small programs under the same main body cannot be automated is solved, and the centralized scheduling and automatic management on the plurality of small program codes are realized.
Alternatively, the management subdirectory may include a public page directory for recording public pages, a public interface directory for recording public function interfaces, a program item directory for recording program items, and a public configuration file for configuring attribute information and differentiation parameters of the program items.
Optionally, the parsing model 42 may be specifically configured to generate, when the construction script is configured as a first synchronization script having a common code synchronization requirement, a common code synchronization instruction corresponding to the common code synchronization requirement and serve as a code management instruction;
When the public code synchronization requirement is unified management and multi-terminal synchronization of the public function codes, the public page directory and the public interface directory are used as source management objects, and program items corresponding to the names of all program items contained in the public configuration file are used as target management objects;
and when the common code synchronization requirement is that the common function module is synchronized to the appointed program item according to the configuration, the common page directory and the common interface directory are used as source management objects, and the appointed program item is used as target management objects.
Optionally, when the construction script is a first synchronization script and the common code synchronization instruction is a code management instruction, the management module 43 may specifically be configured to trigger the execution of the code management instruction by using a npm command in the set operating environment, call a first function module with a file copy function, copy all files recorded in the common page directory and the common interface directory to each program item included in the common configuration file, or copy all files recorded in the common page directory and the common interface directory to the designated program item.
Optionally, the parsing model 42 may be further specifically configured to generate, when the construction script is configured as a second synchronization script having a requirement for synchronization of codes between program items, an inter-item code synchronization instruction corresponding to the requirement for synchronization of codes between program items, and use the generated inter-item code synchronization instruction as a code management instruction;
When the code synchronization requirement among the program items is that any functional module of the program items is modified, synchronizing the modified content to other program items with the functional module, taking a first designated item in the program item catalog as a source management object, taking a program item corresponding to each program item name contained in the public configuration file as a target management object, or taking a second designated item in the program item catalog as a target management object;
setting a folder under a first designated item in the program item catalog as a source management object, and setting a program item corresponding to each program item name contained in the common configuration file as a target management object, or setting a fourth designated item from the program item catalog as a target management object when the code synchronization requirement among program items is single file or folder selective synchronization among program items;
Or when the code synchronization requirement between program items is that a single file or folder is selectively synchronized between the program items, the common configuration file is taken as a source management object, and a fifth designated item in the program item catalog is taken as a target management object.
Optionally, when the construction script is a second synchronization script and the inter-project code synchronization instruction is a code management instruction, the management module 43 may be specifically configured to trigger execution of the code management instruction by using a npm command in the set operating environment, call a second function module with functions of file deletion, reading, copying, and regular expression text replacement, determine content to be synchronized from the source management object, and copy the code to be synchronized into the target management object, where the content to be synchronized is a code file, a specific folder, or a configuration file content that participates in deletion and modification.
Optionally, the application object replaced by the regular expression text is a differential configuration item, wherein the differential configuration item comprises an item base identifier, an interface display text and a global variable, and the global variable comprises an application name, a default sharing title, a default sharing picture and a navigation bar.
The program code management device provided by the embodiment of the invention can execute the program code management method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
Example five
Fig. 5 shows a schematic diagram of an electronic device 50 that may be used to implement an embodiment of the invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. Electronic equipment may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 5, the electronic device 50 includes at least one processor 51, and a memory, such as a Read Only Memory (ROM) 52, a Random Access Memory (RAM) 53, etc., communicatively connected to the at least one processor 51, in which the memory stores a computer program executable by the at least one processor, and the processor 51 may perform various appropriate actions and processes according to the computer program stored in the Read Only Memory (ROM) 52 or the computer program loaded from the storage unit 58 into the Random Access Memory (RAM) 53. In the RAM 53, various programs and data required for the operation of the electronic device 50 can also be stored. The processor 51, the ROM52 and the RAM 53 are connected to each other via a bus 54. An input/output (I/O) interface 55 is also connected to bus 54.
Various components in the electronic device 50 are connected to the I/O interface 55, including an input unit 56 such as a keyboard, mouse, etc., an output unit 57 such as various types of displays, speakers, etc., a storage unit 58 such as a magnetic disk, optical disk, etc., and a communication unit 59 such as a network card, modem, wireless communication transceiver, etc. The communication unit 59 allows the electronic device 50 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunications networks.
The processor 51 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 51 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, digital Signal Processors (DSPs), and any suitable processor, controller, microcontroller, etc. The processor 51 performs the various methods and processes described above, such as program code management methods.
In some embodiments, the program code management method may be implemented as a computer program tangibly embodied on a computer-readable storage medium, such as the storage unit 58. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 50 via the ROM 52 and/or the communication unit 59. When a computer program is loaded into RAM 53 and executed by processor 51, one or more steps of the program code management method described above may be performed. Alternatively, in other embodiments, the processor 51 may be configured to perform the program code management method in any other suitable way (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include being implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be a special or general purpose programmable processor, operable to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for carrying out methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be implemented. The computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user, for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback), and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a Local Area Network (LAN), a Wide Area Network (WAN), a blockchain network, and the Internet.
The computing system may include clients and servers. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service are overcome.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present invention may be performed in parallel, sequentially, or in a different order, so long as the desired results of the technical solution of the present invention are achieved, and the present invention is not limited herein.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.