Application environment switching method, device, computer system and readable storage medium
By creating environment configuration files and configuring cache directories, the problem of long resource preparation time during the integrated development environment switching process is solved, and fast and efficient environment switching is achieved.
Patent Information
- Application Number
- CN202110005148.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-04
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2041-01-04
Smart Images

Figure CN113760384B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and more specifically, to an application environment switching method, an application environment switching device, a computer system, and a computer-readable storage medium. Background Art
[0002] In order to adapt to the development needs of the computer age, more and more projects and tasks need to be completed through intelligent applications or software. The generation and normal operation of these applications or software, in addition to the need for programmers, are inevitably inseparable from the technical support provided by programming environments and integrated development environments.
[0003] In the process of realizing the concept of the present disclosure, the inventors found that there are at least the following problems in the related technology. When it is necessary to switch the current integrated development environment, it is often necessary to temporarily prepare a series of resources related to the target environment, which results in a long unnecessary time. Summary of the invention
[0004] In view of this, the present disclosure provides an application environment switching method, an application environment switching device, a computer system, and a computer-readable storage medium.
[0005] One aspect of the present disclosure provides an application environment switching method, including: creating an environment configuration file, wherein the environment configuration file includes a version number, a branch type and a warehouse address of a target application environment, and a warehouse corresponding to the warehouse address stores a local cache code for implementing the target application environment corresponding to the version number or the branch type; according to the version number or the branch type, obtaining a cache directory corresponding to the local cache code from the warehouse corresponding to the warehouse address; and configuring the cache directory as a global environment variable to implement switching from an initial application environment to the target application environment.
[0006] Another aspect of the present disclosure provides an application environment switching device, including: a first creation module, used to create an environment configuration file, wherein the environment configuration file includes a version number, a branch type and a warehouse address of a target application environment, and a warehouse corresponding to the warehouse address stores a local cache code for implementing the target application environment corresponding to the version number or the branch type; an acquisition module, used to acquire a cache directory corresponding to the local cache code from the warehouse corresponding to the warehouse address according to the version number or the branch type; and a switching module, used to configure the cache directory as a global environment variable to implement switching from an initial application environment to the target application environment.
[0007] Another aspect of the present disclosure provides a computer system, including: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the application environment switching method as described above.
[0008] Another aspect of the present disclosure provides a computer-readable storage medium having computer-executable instructions stored thereon, wherein the instructions are used to implement the application environment switching method as described above when executed.
[0009] Another aspect of the present disclosure provides a computer program, which includes computer executable instructions, and when the instructions are executed, are used to implement the application environment switching method as described above.
[0010] According to an embodiment of the present disclosure, by creating an environment configuration file, wherein the environment configuration file includes a version number, a branch type and a warehouse address of a target application environment, a local cache code for implementing a target application environment corresponding to the version number or the branch type is stored in a warehouse corresponding to the warehouse address; a cache directory corresponding to the local cache code is obtained from the warehouse corresponding to the warehouse address according to the version number or the branch type; and the cache directory is configured as a global environment variable to implement a technical means of switching from an initial application environment to a target application environment. Since the local cache code for implementing the target application environment corresponding to the version number or the branch type is directly stored under the warehouse address, the technical problem of consuming a long unnecessary time when the environment needs to be temporarily switched is at least partially overcome, thereby achieving the technical effect of saving switching time when an environment switch is required in any situation. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The above and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:
[0012] Figure 1 An exemplary system architecture to which the application environment switching method can be applied according to an embodiment of the present disclosure is schematically shown;
[0013] Figure 2 A simplified flowchart of the application environment switching method according to an embodiment of the present disclosure is schematically shown;
[0014] Figure 3 A flowchart of operations performed before creating an environment configuration file according to an embodiment of the present disclosure is schematically shown;
[0015] Figure 4 Schematically shows a flow chart of creating an environment configuration file according to an embodiment of the present disclosure;
[0016] Figure 5 Schematically shows a flowchart of executing configuration parsing logic according to an embodiment of the present disclosure
[0017] Figure 6 A block diagram schematically shows an application environment switching device according to an embodiment of the present disclosure; and
[0018] Figure 7 A block diagram of a computer system suitable for implementing the application environment switching method described above according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0019] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0020] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0021] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.
[0022] In the case of using expressions such as "at least one of A, B, and C, etc.", it should generally be interpreted in accordance with the meaning of the expression generally understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.). In the case of using expressions such as "at least one of A, B, or C, etc.", it should generally be interpreted in accordance with the meaning of the expression generally understood by those skilled in the art (for example, "a system having at least one of A, B, or C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0023] In the field of integrated development, Flutter is increasingly favored by developers due to its cross-platform nature, excellent rendering and execution speed. Especially when developing mobile pages, Flutter technology will be taken into consideration.
[0024] Before developing Flutter, you need to configure the environment. The Flutter environment includes the following parts: Flutter git repository, Flutter-related tool script code, Flutter built-in components, the version number of the dependent development language Dart SDK, and Pub tool. Among them, Dart SDK, as the development language package required for developing Flutter applications, is used to compile and run Flutter applications, compile the first part of the Flutter tool script code to generate snapshot (command line tool); Pub tool is used to package and publish Flutter applications; configure global environment variables according to the local git repository path for use in subsequent Flutter development.
[0025] Different flutter projects may require different flutter version development environments, and you often face the problem of frequent switching of flutter environments. For example, when developing a flutter app for the desktop (macOS, Windows, etc.), you need to switch the channel (branch) to the master branch, and when developing an app for the mobile phone, you often need to switch the channel to the stable branch for development. There are even more extreme scenarios. Even if they are all on the same channel, different versions of flutter may cause the same code repository to fail to compile on some machines or have inconsistent effects. Therefore, when developing different projects, you need to switch the local flutter environment to the required flutter version number or branch. The switching process is generally achieved by using commands such as flutter channel xx branch or flutter version yy version provided by flutter.
[0026] However, in the process of implementing the concept of the present disclosure, the inventor found that in the process of executing the environment switch through the above-mentioned flutter channel xx branch or flutter version yy version command, since the switch to the xx branch or yy version is implemented using the git command, it is necessary to first determine whether the Dark SDK that the current flutter depends on is consistent with the locally cached version. In the case of inconsistency, it is necessary to temporarily download the dependent Dark SDK (usually about 200M), and then use the downloaded Dark SDK to compile the flutter source code, and it is necessary to download flutter, iOS, Android, and desktop related resources. Even in the case of consistent judgment, it is still necessary to go through other processes besides downloading. Therefore, when executing the environment switch through the two commands of flutter channel xx branch or flutter version yy version, each switch needs to go through multiple processes such as downloading and compiling. It may take 20 to 30 minutes to switch once depending on the current network environment and machine performance. If multiple projects that depend on different flutter versions are maintained at the same time, then switching the flutter version will be a very high-frequency operation, and the time consumed in this case is obviously very huge.
[0027] The embodiments of the present disclosure provide an application environment switching method, an application environment switching device, a computer system, and a computer-readable storage medium. The method includes creating an environment configuration file, wherein the environment configuration file includes the version number, branch type, and warehouse address of the target application environment, and the warehouse corresponding to the warehouse address stores local cache code for implementing the target application environment corresponding to the version number or branch type; according to the version number or branch type, obtaining a cache directory corresponding to the local cache code from the warehouse corresponding to the warehouse address; and configuring the cache directory as a global environment variable to implement the switch from the initial application environment to the target application environment.
[0028] Figure 1 The exemplary system architecture 100 to which the application environment switching method according to an embodiment of the present disclosure can be applied is schematically shown. It should be noted that: Figure 1 What is shown is merely an example of a system architecture to which the embodiments of the present disclosure can be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but it does not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios.
[0029] like Figure 1As shown, the system architecture 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links, etc.
[0030] The user can use the terminal devices 101, 102, 103 to interact with the server 105 through the network 104 to receive or send data, etc. Various communication client applications can be installed on the terminal devices 101, 102, 103, for example, integrated environment applications for Java development such as Eclipse, MyEclipse, AIDE, or mobile UI frameworks such as flutter or other programming or client applications.
[0031] The terminal devices 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing or software applications, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0032] The server 105 may be a server that provides various services, such as a background management server that provides support for requests sent by users using the terminal devices 101, 102, and 103. The background management server may analyze and process the received user requests and other data, and feed back the processing results (such as web pages, information, instructions, or data obtained or generated according to the user requests) to the terminal device.
[0033] It should be noted that the application environment switching method provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the application environment switching device provided in the embodiment of the present disclosure can generally be set in the server 105. The application environment switching method provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105. Correspondingly, the application environment switching device provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105. Alternatively, the application environment switching method provided in the embodiment of the present disclosure can also be executed by the terminal devices 101, 102, or 103, or can also be executed by other terminal devices different from the terminal devices 101, 102, or 103. Correspondingly, the application environment switching device provided in the embodiment of the present disclosure may also be set in the terminal device 101 , 102 , or 103 , or in other terminal devices different from the terminal device 101 , 102 , or 103 .
[0034] For example, the initial application environment is originally stored in any one of the terminal devices 101, 102, or 103 (for example, the terminal device 101, but not limited thereto), or is stored on an external storage device and can be imported into the terminal device 101. Then, the terminal device 101 can locally execute the application environment switching method provided by the embodiment of the present disclosure, or send the relevant configuration information of the initial application environment to other terminal devices, servers, or server clusters, and the other terminal devices, servers, or server clusters that receive the relevant configuration information of the initial application environment execute the application environment switching method provided by the embodiment of the present disclosure.
[0035] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0036] Figure 2 A simplified flowchart of the application environment switching method according to an embodiment of the present disclosure is schematically shown.
[0037] like Figure 2 As shown, the method includes operations S201 to S203.
[0038] In operation S201, an environment configuration file is created, wherein the environment configuration file includes a version number, a branch type, and a warehouse address of a target application environment, and a local cache code for implementing the target application environment corresponding to the aforementioned version number or branch type is stored in a warehouse corresponding to the warehouse address.
[0039] According to an embodiment of the present disclosure, the above-mentioned creation environment configuration file can be, for example, manually created, or can be an instruction with a one-click creation of a default configuration file function input in a command line tool, and then the creation of the above-mentioned environment configuration file is implemented according to the instruction. The above-mentioned environment configuration file can, for example, have a valid version number or branch type, and a warehouse address, and the warehouse address corresponds to the warehouse that stores the downloaded local cache code for implementing the target application environment. The target application environment can, for example, be a specific application environment that needs to switch the current application environment (for example, it can be called the initial application environment) to a corresponding version or branch that is more suitable for the development of a certain project in order to support a certain project, or it can be other application environments that are different from the version or branch of the current application environment. The local cache code is, for example, code that has been downloaded and stored in the warehouse.
[0040] In operation S202, according to the version number or branch type, a cache directory corresponding to the local cache code is obtained from the warehouse corresponding to the warehouse address.
[0041] According to an embodiment of the present disclosure, the switching of the application environment may include, for example, switching the version or branch of the initial application environment. When the version needs to be switched, the cache directory where the local cache code for the target application environment corresponding to the target version number is obtained from the warehouse; when the branch needs to be switched, the cache directory where the local cache code for the target application environment corresponding to the target branch is obtained from the warehouse. The target version number and the target branch correspond to the version number and the branch type in the above-mentioned environment configuration file, respectively.
[0042] In operation S203, the cache directory is configured as a global environment variable to implement switching from the initial application environment to the target application environment.
[0043] According to an embodiment of the present disclosure, the content stored in the cache directory may be, for example, the required code of the target application environment corresponding to the target version number or the required code of the target application environment corresponding to the target branch. As a variable that provides basic environment support for the operation of the system, the cache directory is directly configured as a global environment variable, that is, the environment that represents the current operation of the system is the environment provided by the code stored in the cache directory, that is, the application environment realizes the switch from the initial application environment to the target application environment corresponding to the version number or branch type in the environment configuration file.
[0044] Through the above-mentioned embodiments of the present disclosure, the idea of exchanging space for time is adopted, and the codes used to implement the target application environment are cached locally without the need for repeated downloading, thereby reducing the time consumed in the download and compilation process, thereby reducing the switching time of the application environment and improving the switching efficiency.
[0045] According to a specific embodiment of the present disclosure, the above-mentioned application environment may be, for example, a flutter environment, and branches corresponding to the flutter environment may include, for example, master (main branch), stable (stable branch), and other branches.
[0046] Based on the above specific embodiments, Figure 3 to Figure 5 ,right Figure 2 The method shown is further explained.
[0047] According to an embodiment of the present disclosure, before the above-mentioned operation S201, it also includes: executing an operation command; judging whether the warehouse corresponding to the initial application environment contains an environment configuration file according to the operation command; and creating an environment configuration file if the warehouse corresponding to the initial application environment does not contain an environment configuration file.
[0048] According to an embodiment of the present disclosure, the above-mentioned operation command may be, for example, flutterw, and the above-mentioned determining whether the warehouse corresponding to the initial application environment contains an environment configuration file according to the operation command includes two specific implementation modes, implementation mode 1 and implementation mode 2.
[0049] Implementation method 1: When it is not necessary to execute an actual project but it is necessary to switch the application environment, it is possible to directly determine whether the warehouse corresponding to the initial application environment contains the above environment configuration file. If it does, the switch from the initial application environment to the target application environment can be implemented based on the environment configuration file combined with the above operations S202 to S203; if it does not contain, all the above operations S201 to S203 are executed to implement the switch from the initial application environment to the target application environment.
[0050] Implementation method 2: When an actual project needs to be executed and the application environment in which the project is located (i.e., the initial application environment) is incompatible with the application environment on which the project depends (i.e., the target application environment) and the application environment needs to be switched, it can be determined whether the project directory (also known as the git repository) of the project contains an environment configuration file. If it is contained, the switch from the initial application environment to the target application environment can be achieved based on the environment configuration file combined with the above operations S202 to S203; if it is not contained, an environment configuration file for the project is constructed according to the flutter version or branch that the project depends on, and the environment configuration file is placed in the project directory of the project as a separate file of the project.
[0051] Figure 3 The flowchart of the execution operation before creating an environment configuration file according to an embodiment of the present disclosure is schematically shown.
[0052] According to the embodiments of the present disclosure, taking the above-mentioned embodiment 2 as an example, and referring to Figure 3 As shown, before the above-mentioned creation of the environment configuration file (ie, execution of operation S201), operations S301 to S304 are also included.
[0053] In operation S301 , a flutterw command is executed.
[0054] In operation S302, it is determined whether there is a configuration file in the project directory.
[0055] According to an embodiment of the present disclosure, the configuration file may be, for example, a flutter environment configuration file.
[0056] In operation S303, the user is prompted that the configuration file is not found and is requested to create a configuration file.
[0057] According to an embodiment of the present disclosure, the creation of the configuration file may be implemented, for example, by inputting an instruction with a one-click creation function of a default configuration file in a command line tool, and the one-click creation instruction may be defined, for example, as flutterwinit. Accordingly, in this operation, for example, the creation of the configuration file may be implemented by prompting the user to use flutterw init to initialize the configuration file.
[0058] In operation S304, the configuration parsing logic is executed.
[0059] It should be noted that the above operation S303 is effective only when the judgment result of the above operation S302 is no. When the judgment result of the above operation S302 is yes, the subsequent operation S304 is executed.
[0060] Through the above-mentioned embodiments of the present disclosure, a configuration file that matches the target application environment it depends on can be created for each project. The configuration file can be stored in the warehouse corresponding to the initial application environment, or in the project directory of the actual project. The difference is that the former may not depend on the project, that is, the application environment can be switched without executing the project, while the latter tends to switch the environment during the project implementation. Among them, the latter greatly reduces the time spent on flutter environment switching by setting an independent flutter environment sandbox (i.e., environment configuration file) for the specified flutter business project through the idea of exchanging space for time. At the same time, it is also convenient for all personnel involved in the project to synchronize to the file when pulling the project without repeated configuration.
[0061] Figure 4 The flowchart of creating an environment configuration file according to an embodiment of the present disclosure is schematically shown.
[0062] Figure 5 The flowchart of executing configuration parsing logic according to an embodiment of the present disclosure is schematically shown.
[0063] It should be noted in advance that the above-mentioned creation of the environment configuration file can be implemented, for example, by combining the above-mentioned execution configuration parsing logic; or the above-mentioned creation of the environment configuration file can also only represent the creation of the environment configuration file, and the above-mentioned execution configuration parsing logic can also only represent the parsing of the created environment configuration file. In different embodiments, the two can be implemented in combination or independently.
[0064] like Figure 4 As shown, the process includes operations S401 to S408.
[0065] In operation S401, an initial configuration file is created, wherein the initial configuration file includes configuration items for characterizing a version number, a branch type, and a warehouse address of a target application environment, respectively, and each configuration item corresponds to configuration information.
[0066] According to an embodiment of the present disclosure, the initial configuration file may be created by the user directly at any time, or may be created when the result of the judgment in the above operation S302 is no.
[0067] According to an embodiment of the present disclosure, taking the creation of an initial configuration file by the above-mentioned flutterw init command as an example, the command line tool parses and performs corresponding logical operations after receiving the flutterw init instruction, and the logical operation may include, for example: using the touch command of the shell to create an initial configuration file, and using the echo command to append the above-mentioned configuration items and configuration information to the configuration file, thereby completing the creation of the above-mentioned initial configuration file.
[0068] According to an embodiment of the present disclosure, taking a specific project as an example, the process of creating the initial configuration file may include: abstracting the flutter environment information on which the project depends as an initial configuration file, and constructing the initial configuration file by separating each configuration item with a line break, and separating the configuration item key and the configuration information value with a colon. For example, in the flutter environment information on which a project depends, the flutter version number (version) is: v1.12.13+hotfix.9, the flutter branch (channel) type is: master, and the flutter warehouse address (repo) is: https: / / github.com / flutter / flutter.git, then the configuration file for the project created based on the flutter environment information is as follows:
[0069] version: v1.12.13+hotfix.9
[0070] channel:master
[0071] repo: https: / / github.com / flutter / flutter.git
[0072] According to an embodiment of the present disclosure, since it cannot be guaranteed that the configuration information (including configuration information such as version number, branch type, warehouse address, etc.) in the initial configuration file created by the above-mentioned one-key creation instruction is completely valid, in order to obtain an environment configuration file with valid configuration information, on the basis of operation S401, for example, the following operations S402 to S406 may also be included, and an environment configuration file with valid content may be obtained by combining the invalidity judgment process.
[0073] In operation S402, configuration information corresponding to each configuration item in the initial configuration file is read.
[0074] According to an embodiment of the present disclosure, this operation may correspond to, for example, Figure 5 Operation S501 in the example: read the configuration information, and obtain the three configuration items of version, channel, and repo.
[0075] According to an embodiment of the present disclosure, the above-mentioned reading of configuration information may, for example, include: respectively reading the configuration items (version, channel, and repo) and corresponding configuration information (flutter version, flutter warehouse branch, and flutter warehouse address) in the above-mentioned initial configuration file, and the reading method may, for example, use the cat command of the shell to realize the reading of the above-mentioned initial configuration file.
[0076] In operation S403, when the configuration information corresponding to the warehouse address is empty or invalid, the configuration information corresponding to the warehouse address is modified to a valid warehouse address.
[0077] According to an embodiment of the present disclosure, this operation may correspond to, for example, Figure 5 Operations S502 to S503 in the process: in operation S502, determine whether the repo is valid; in operation S503, prompt the user that the repo is invalid and ask the user to fill in a correct value; wherein, operation S503 is effective when the determination result of operation S502 is no.
[0078] According to an embodiment of the present disclosure, the above operation S502 is invalid when the repo is empty or not a git repository, and the operation can be implemented using the git ls-remote command, for example. If the judgment result of the above operation S502 is yes, the subsequent operation S504 is continued.
[0079] In operation S404, when the configuration information corresponding to the branch type is empty or invalid, the configuration information corresponding to the branch type is modified to a valid branch.
[0080] According to an embodiment of the present disclosure, this operation may correspond to, for example, Figure 5Operations S504 to S505 in the process: in operation S504, determine whether the channel is valid; in operation S505, prompt the user that the channel is invalid and ask the user to fill in a correct value; operation S505 is effective when the determination result of operation S504 is no.
[0081] According to an embodiment of the present disclosure, the above operation S504 is invalid when the channel is empty or the flutter repository does not have the branch. This operation can be implemented using, for example, the git ls-remote --heads$channel --verify refs / heads / $channel command. If the judgment result of the above operation S504 is yes, continue to perform the subsequent operation S506.
[0082] In operation S405, when the configuration information corresponding to the version number is not empty and invalid, the configuration information corresponding to the version number is modified to a valid version number.
[0083] According to an embodiment of the present disclosure, this operation may correspond to, for example, Figure 5 Operations S506 to S508 in: in operation S506, determine whether version has a value; in operation S507, determine whether version is legal; in operation S508, prompt the user that the version is invalid and please fill in the correct value; among them, operation S507 takes effect when the judgment result of operation S506 is yes, and operation S508 takes effect when the judgment result of operation S507 is no.
[0084] According to an embodiment of the present disclosure, for the above operation S507, when the flutter warehouse has the version number, it is valid, otherwise it is invalid. The operation S507 can be implemented using the git ls-remote--tags$version--verifyrefs / heads / $version command, for example. If the judgment result of the above operation S507 is yes, continue to perform the subsequent operation S511.
[0085] In operation S406, when the configuration information corresponding to the version number, branch type, and warehouse address is valid, the initial configuration file is used as the environment configuration file.
[0086] According to the embodiment of the present disclosure, through the above operations S402 to S405, the validation processing of each item of configuration information in the above initial configuration file can be achieved, so that an environment configuration file with valid content can be obtained.
[0087] According to the embodiments of the present disclosure, since the repository corresponding to the repo address in the above-mentioned valid environment configuration file does not necessarily directly store the downloaded local cache code that can be used to implement the target application environment, temporary download is still required in the process of parsing the environment configuration file to implement the switching of the application environment. In order to reduce the temporary download process and implement the operation of directly entering the switching of the application environment by parsing the environment configuration file, the above-mentioned process of creating the environment configuration file may also include the following operations S407 to S408.
[0088] In operation S407, when the configuration information corresponding to the version number is empty and there is no local cache code for implementing the target application environment corresponding to the branch type in the warehouse corresponding to the warehouse address, a cache directory named after the branch type is created in the warehouse corresponding to the warehouse address; the local cache code for implementing the target application environment corresponding to the branch type is obtained by downloading through the warehouse address; and the local cache code for implementing the target application environment corresponding to the branch type is stored in the cache directory named after the branch type.
[0089] According to an embodiment of the present disclosure, this operation may correspond to, for example, Figure 5 Operations S509 to S510 in: In operation S509, determine whether there is a local cache of the channel; in operation S510, use git to pull the flutter warehouse whose warehouse address is repo and whose branch is channel, and the local warehouse directory name is the value of the channel; wherein, operation S509 takes effect when the judgment result of operation S506 is no, and operation S510 takes effect when the judgment result of operation S509 is no.
[0090] According to an embodiment of the present disclosure, for the above operation S509, it is determined whether there is a cache directory of channel (for example, master) locally. If not, a folder named channel value (for example, master) is created, and then the flutter code of the master branch is downloaded through the repo value, and the code is saved in the folder named master. If the judgment result of the above operation S509 is yes, the subsequent operation S513 is continued.
[0091] In operation S408, when the configuration information corresponding to the version number is non-empty and there is no local cache code for implementing the target application environment corresponding to the version number in the warehouse corresponding to the warehouse address, a cache directory named after the version number is created in the warehouse corresponding to the warehouse address; the local cache code for implementing the target application environment corresponding to the version number is obtained by downloading through the warehouse address; and the local cache code for implementing the target application environment corresponding to the version number is stored in the cache directory named after the version number.
[0092] According to an embodiment of the present disclosure, this operation may correspond to, for example, Figure 5 Operations S511 to S512 in: In operation S511, determine whether there is a local cache of the version; in operation S512, use git to pull the flutter warehouse whose warehouse address is repo and whose commit point is version, and the local warehouse directory name is the value of the version; wherein, operation S511 takes effect when the judgment result of operation S507 is yes, and operation S512 takes effect when the judgment result of operation S511 is no.
[0093] According to an embodiment of the present disclosure, for the above operation S511, it is determined whether there is a cache with a directory of the version value (for example, v1.12.13+hotfix.9) locally. If not, a folder named with the version value (for example, v1.12.13+hotfix.9) is created, and then the flutter code with the submission point of the v1.12.13+hotfix.9 cache directory is downloaded through the repo address. If the judgment result of the above operation S511 is yes, the subsequent operation S513 is continued.
[0094] According to an embodiment of the present disclosure, the above operation S513 may correspond to, for example, Figure 2 In operation S203, the above operation S513 can also take effect after the above operations S510 and S512 are completed. In operation S513, the flutter environment variable path is changed to the address of a folder (for example, it can be a cache directory obtained by operation S509 or S510, or it can be a cache directory obtained by operation S511 or S512). After operation S513 is completed, the switching of the application environment can be completed.
[0095] According to an embodiment of the present disclosure, after the above operations S407 to S408, the local cache code for implementing the target application environment can be stored in the warehouse corresponding to the repo address of the environment configuration file in which the above content is valid, thereby reducing the repeated download process when it is necessary to switch to the target application environment in the future, and the cache directory corresponding to the local cache code for implementing the target application environment with the corresponding version number or branch can be directly obtained by parsing the environment configuration file.
[0096] According to an embodiment of the present disclosure, by executing the above operations S401 to S408, the environment configuration file in the above operation S201 having a valid version number or branch type and a warehouse address, and the warehouse corresponding to the warehouse address stores the downloaded local cache code for implementing the target application environment. By parsing the environment configuration file, the cache directory in the above operation S202 can be directly obtained, and on this basis, by executing the above operation S203, the application environment switching can be completed.
[0097] According to an embodiment of the present disclosure, since the warehouse address corresponding to the initial application environment (local flutter) may be different from the repo address in the environment configuration file, in order to ensure that the application environment can be switched normally, the process of executing the above operation S203 also includes: modifying the warehouse address corresponding to the initial application environment to the warehouse address (repo address) in the environment configuration file.
[0098] It should be noted that the above operations S401 to S408 can be used as a series of sub-operations for implementing the creation of the environment configuration file in the above operation S201, but are not limited to this. For example, in other embodiments, it can also be expressed as: the above operation S401 is equivalent to the above operation S201, so as to provide a tool that supports the flutter environment configuration file required for one-click initialization of the project, and the flutter environment configuration file obtained thereby supports editing configuration items; the above operations S402 to S408 are equivalent to the above operation S202, so as to provide a tool that supports configuration file parsing, and the environment configuration file created by operation S201 can be parsed, and the parsing result obtained through the parsing process is used to support the switching of subsequent application environments; and the above operation S203 is used as the execution process for implementing the application environment switching, so as to provide a tool that supports the automatic completion of the flutter environment, and the operation S203 enters the execution process based on the parsing result obtained by the above operations S402 to S408. For example, for the environment configuration file created in operation S201, the parsing process of operations S402 to S408 is performed to obtain the cache directory (parsing result) of the target application environment, and then operation S203 is performed based on the cache directory to implement the switching of the application environment.
[0099] It should be noted that all operations for implementing the above-mentioned method for switching the application environment can be implemented by designing an automated program. For example, in the above-mentioned embodiment, the flutterw instruction and the flutterw init instruction are designed, and the switching of the application environment can be completed by executing the two instructions.
[0100] Through the above-mentioned embodiment of the present disclosure, when multiple projects rely on different flutter versions, the environment configuration file is used, and multiple flutter versions such as the channel or version corresponding to the configuration file can be cached locally. When switching between different versions or branches, the path of the global environment variable of flutter can be directly changed to the corresponding channel or version of the cache directory to achieve the switching of flutter environments of different versions or branches, without the need to go through the time-consuming processes such as Dart SDK download and Flutter Tool compilation every time the switch is switched, which greatly improves the switching speed of the flutter environment. In addition, by describing the required flutter version, branch and other information in the configuration file, and combining the use of scripts to solidify the above-mentioned operation steps for switching the application environment, the script can be used to automatically complete the switching of the flutter environment. For example, the switching process can be completed with only one command line (such as flutterw), which solves the problem of too long time consumption caused by switching versions in a single flutter warehouse using the flutter channel xx or flutter version yy command, and there is no need to execute the complicated flutter environment configuration process, which greatly improves the speed and convenience of use.
[0101] Figure 6 A block diagram of an application environment switching device according to an embodiment of the present disclosure is schematically shown.
[0102] like Figure 6 As shown, the application environment switching device 600 includes a first creation module 610 , an acquisition module 620 and a switching module 630 .
[0103] A first creation module 610 is used to create an environment configuration file, wherein the environment configuration file includes a version number, a branch type, and a warehouse address of a target application environment, and a local cache code for implementing the target application environment corresponding to the version number or the branch type is stored in a warehouse corresponding to the warehouse address;
[0104] The acquisition module 620 is used to acquire the cache directory corresponding to the local cache code from the warehouse corresponding to the warehouse address according to the version number or branch type; and
[0105] The switching module 630 is used to configure the cache directory as a global environment variable to achieve switching from the initial application environment to the target application environment.
[0106] According to an embodiment of the present disclosure, the above-mentioned application environment switching device also includes an execution module, a judgment module and a second creation module.
[0107] The execution module is used to execute operation commands.
[0108] The judgment module is used to judge whether the warehouse corresponding to the initial application environment contains an environment configuration file according to the operation command.
[0109] The second creation module is used to create an environment configuration file when the warehouse corresponding to the initial application environment does not contain the environment configuration file.
[0110] According to an embodiment of the present disclosure, the above-mentioned first creation module includes a first creation unit, a reading unit, a first modification unit, a second modification unit, a third modification unit and a definition unit.
[0111] The first creation unit is used to create an initial configuration file, wherein the initial configuration file includes configuration items for representing a version number, a branch type, and a warehouse address of a target application environment, respectively, and each configuration item corresponds to configuration information.
[0112] The reading unit is used to read the configuration information corresponding to each configuration item in the initial configuration file.
[0113] The first modification unit is used to modify the configuration information corresponding to the warehouse address to a valid warehouse address when the configuration information corresponding to the warehouse address is empty or invalid.
[0114] The second modifying unit is used to modify the configuration information corresponding to the branch type into a valid branch when the configuration information corresponding to the branch type is empty or invalid.
[0115] The third modification unit is used to modify the configuration information corresponding to the version number to a valid version number when the configuration information corresponding to the version number is non-empty and invalid.
[0116] The definition unit is used to use the initial configuration file as the environment configuration file when the configuration information corresponding to the version number, branch type, and warehouse address are all valid.
[0117] According to an embodiment of the present disclosure, the above-mentioned first creation module also includes a second creation unit, a first downloading unit and a first storage unit.
[0118] The second creation unit is used to create a cache directory named after the branch type in the warehouse corresponding to the warehouse address when the configuration information corresponding to the version number is empty and there is no local cache code in the warehouse corresponding to the warehouse address for implementing the target application environment corresponding to the branch type.
[0119] The first downloading unit is used to download and obtain, through a warehouse address, a local cache code for implementing a target application environment corresponding to a branch type.
[0120] The first storage unit is used to store the local cache code used to implement the target application environment corresponding to the branch type in a cache directory named after the branch type.
[0121] According to an embodiment of the present disclosure, the above-mentioned first creation module also includes a third creation unit, a second downloading unit and a second storage unit.
[0122] The third creation unit is used to create a cache directory named after the version number in the warehouse corresponding to the warehouse address when the configuration information corresponding to the version number is non-empty and there is no local cache code in the warehouse corresponding to the warehouse address for implementing the target application environment corresponding to the version number.
[0123] The second downloading unit is used to download and obtain the local cache code for implementing the target application environment corresponding to the version number through the warehouse address.
[0124] The second storage unit is used to store the local cache code used to implement the target application environment corresponding to the version number in a cache directory named after the version number.
[0125] According to an embodiment of the present disclosure, the above-mentioned application environment switching device further includes a fourth modifying unit.
[0126] The fourth modification unit is used to modify the warehouse address corresponding to the initial application environment to the warehouse address in the environment configuration file.
[0127] According to the embodiments of the present invention, any one or more of the modules, units, and sub-units, or at least part of the functions of any one of them can be implemented in one module. According to the embodiments of the present invention, any one or more of the modules, units, and sub-units can be split into multiple modules for implementation. According to the embodiments of the present invention, any one or more of the modules, units, and sub-units can be at least partially implemented as hardware circuits, such as field programmable gate arrays (FPGAs), programmable logic arrays (PLAs), systems on chips, systems on substrates, systems on packages, application specific integrated circuits (ASICs), or can be implemented by hardware or firmware in any other reasonable way of integrating or packaging the circuit, or in any one of the three implementation methods of software, hardware, and firmware, or in any appropriate combination of any of them. Alternatively, according to the embodiments of the present invention, one or more of the modules, units, and sub-units can be at least partially implemented as computer program modules, and when the computer program modules are run, the corresponding functions can be performed.
[0128] For example, any multiple of the first creation module 610, the acquisition module 620, and the switching module 630 can be combined in one module / unit / subunit for implementation, or any one of the modules / units / subunits can be split into multiple modules / units / subunits. Alternatively, at least part of the functions of one or more of these modules / units / subunits can be combined with at least part of the functions of other modules / units / subunits and implemented in one module / unit / subunit. According to an embodiment of the present disclosure, at least one of the first creation module 610, the acquisition module 620, and the switching module 630 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or by any one of the three implementation methods of software, hardware, and firmware, or by a suitable combination of any of them. Alternatively, at least one of the first creation module 610 , the acquisition module 620 , and the switching module 630 may be at least partially implemented as a computer program module, and when the computer program module is executed, a corresponding function may be performed.
[0129] It should be noted that the application environment switching device part in the embodiment of the present disclosure corresponds to the application environment switching method part in the embodiment of the present disclosure. The description of the application environment switching device part specifically refers to the application environment switching method part, which will not be repeated here.
[0130] Figure 7 A block diagram of a computer system suitable for implementing the application environment switching method described above according to an embodiment of the present disclosure is schematically shown. Figure 6 The computer system shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0131] like Figure 7 As shown, the computer system 700 according to the embodiment of the present disclosure includes a processor 701, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 702 or the program loaded from the storage part 708 to the random access memory (RAM) 703. The processor 701 may include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (for example, an application-specific integrated circuit (ASIC)), etc. The processor 701 may also include an onboard memory for caching purposes. The processor 701 may include a single processing unit or multiple processing units for performing different actions of the method flow according to the embodiment of the present disclosure.
[0132] In RAM 703, various programs and data required for the operation of system 700 are stored. Processor 701, ROM 702 and RAM 703 are connected to each other through bus 704. Processor 701 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 702 and / or RAM 703. It should be noted that the program can also be stored in one or more memories other than ROM 702 and RAM 703. Processor 701 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.
[0133] According to an embodiment of the present disclosure, the system 700 may further include an input / output (I / O) interface 705, which is also connected to the bus 704. The system 700 may further include one or more of the following components connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage section 708 as needed.
[0134] According to an embodiment of the present disclosure, the method flow according to an embodiment of the present disclosure can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program contains a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the processor 701, the above-mentioned functions defined in the system of the embodiment of the present disclosure are executed. According to an embodiment of the present disclosure, the system, equipment, device, module, unit, etc. described above can be implemented by a computer program module.
[0135] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.
[0136] According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium. For example, it may include, but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, apparatus, or device.
[0137] For example, according to an embodiment of the present disclosure, the computer-readable storage medium may include the ROM 702 and / or the RAM 703 described above and / or one or more memories other than the ROM 702 and the RAM 703 .
[0138] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram may represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box may also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions. It can be understood by those skilled in the art that the features recorded in the various embodiments and / or claims of the present disclosure can be combined and / or combined in a variety of ways, even if such a combination or combination is not explicitly recorded in the present disclosure. In particular, without departing from the spirit and teaching of the present disclosure, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways. All of these combinations and / or combinations fall within the scope of the present disclosure.
[0139] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. The scope of the present disclosure is defined by the attached claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.
Claims
1. A method for switching an application environment, comprising: Creating an environment configuration file, wherein the environment configuration file includes a version number, a branch type, and a warehouse address of the target application environment, and a local cache code for implementing the target application environment corresponding to the version number or the branch type is stored in a warehouse corresponding to the warehouse address; According to the version number or the branch type, obtaining a cache directory corresponding to the local cache code from the warehouse corresponding to the warehouse address; and The cache directory is configured as a global environment variable to implement the switch from the initial application environment to the target application environment, wherein the creating environment configuration file includes: Creating an initial configuration file, wherein the initial configuration file includes configuration items for characterizing the version number, branch type, and warehouse address of the target application environment, respectively, and each of the configuration items corresponds to configuration information; Read the configuration information corresponding to each configuration item in the initial configuration file; When the configuration information corresponding to the warehouse address is empty or invalid, modify the configuration information corresponding to the warehouse address to a valid warehouse address; When the configuration information corresponding to the branch type is empty or invalid, modify the configuration information corresponding to the branch type to a valid branch; If the configuration information corresponding to the version number is not empty and invalid, modify the configuration information corresponding to the version number to a valid version number; and When the configuration information corresponding to the version number, the branch type, and the warehouse address are all valid, the initial configuration file is used as the environment configuration file.
2. The method according to claim 1, wherein: Before creating the environment configuration file, the method further includes: Execute operation commands; Determining, according to the operation command, whether the warehouse corresponding to the initial application environment contains the environment configuration file; and When the environment configuration file is not included in the warehouse corresponding to the initial application environment, the environment configuration file is created.
3. The method according to claim 1, further comprising: When the configuration information corresponding to the version number is empty and there is no local cache code for implementing the target application environment corresponding to the branch type in the warehouse corresponding to the warehouse address, create a cache directory named after the branch type in the warehouse corresponding to the warehouse address; Obtaining the local cache code for implementing the target application environment corresponding to the branch type by downloading from the warehouse address; as well as The local cache code for implementing the target application environment corresponding to the branch type is stored in the cache directory named after the branch type.
4. The method according to claim 1 or 3, further comprising: If the configuration information corresponding to the version number is not empty and there is no local cache code for implementing the target application environment corresponding to the version number in the warehouse corresponding to the warehouse address, create a cache directory named with the version number in the warehouse corresponding to the warehouse address; Obtaining the local cache code for implementing the target application environment corresponding to the version number by downloading from the warehouse address; as well as The local cache code for implementing the target application environment corresponding to the version number is stored in the cache directory named after the version number.
5. The method according to claim 1, further comprising: The warehouse address corresponding to the initial application environment is modified to the warehouse address in the environment configuration file.
6. An application environment switching device, comprising: A first creation module is used to create an environment configuration file, wherein the environment configuration file includes a version number, a branch type, and a warehouse address of a target application environment, and a local cache code for implementing a target application environment corresponding to the version number or the branch type is stored in a warehouse corresponding to the warehouse address; an acquisition module, configured to acquire, according to the version number or the branch type, a cache directory corresponding to the local cache code from the warehouse corresponding to the warehouse address; and A switching module is used to configure the cache directory as a global environment variable to achieve switching from the initial application environment to the target application environment, wherein the first creation module includes: A first creation unit is used to create an initial configuration file, wherein the initial configuration file includes configuration items for representing a version number, a branch type, and a warehouse address of the target application environment, respectively, and each of the configuration items corresponds to configuration information; A reading unit, used to read the configuration information corresponding to each configuration item in the initial configuration file; A first modification unit, configured to modify the configuration information corresponding to the warehouse address to a valid warehouse address when the configuration information corresponding to the warehouse address is empty or invalid; A second modification unit, configured to modify the configuration information corresponding to the branch type to a valid branch when the configuration information corresponding to the branch type is empty or invalid; A third modifying unit, configured to modify the configuration information corresponding to the version number to a valid version number when the configuration information corresponding to the version number is non-empty and invalid; and A definition unit is used to use the initial configuration file as the environment configuration file when the configuration information corresponding to the version number, the branch type and the warehouse address are all valid.
7. The apparatus according to claim 6, further comprising: An execution module, used for executing operation commands; A judgment module, used for judging whether the warehouse corresponding to the initial application environment contains the environment configuration file according to the operation command; as well as The second creation module is used to create the environment configuration file when the warehouse corresponding to the initial application environment does not contain the environment configuration file.
8. A computer system comprising: one or more processors; a memory for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 5.
9. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, enables the processor to implement the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Method for rapid system deployment adaptive to multiple environmental configurations
CN106815052A
Software deploying method and device and computer readable storage medium
CN107291504A
Running environment switching method and device and computer-readable storage medium
CN107861863A
Environment switching method and system for front-end development
CN108536428A
Environment configuration management method, system and terminal device
CN109471797A
