Detailed Description
Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood that the description is illustrative only and is not intended to limit the scope of the present disclosure. In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the embodiments of the disclosure. It may be evident, however, that one or more embodiments may be practiced without these specific details. Moreover, in the following description, descriptions of well-known structures and techniques are omitted so as to not unnecessarily obscure the concepts of the present disclosure.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The terms "comprises," "comprising," and the like, as used herein, specify the presence of stated features, steps, operations, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, or components.
All terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art unless otherwise defined. It is noted that the terms used herein should be interpreted as having a meaning that is consistent with the context of this specification and should not be interpreted in an idealized or overly formal sense.
Where a convention analogous to "at least one of A, B and C, etc." is used, in general such a construction is intended in the sense one having skill in the art would understand the convention (e.g., "a system having at least one of A, B and C" would include but not be limited to systems that have a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.). Where a convention analogous to "A, B or at least one of C, etc." is used, in general such a construction is intended in the sense one having skill in the art would understand the convention (e.g., "a system having at least one of A, B or C" would include but not be limited to systems that have a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.).
In the field of integrated development, flutter is increasingly favored by developers due to its cross-platform property, excellent rendering and execution speed, and especially in developing mobile end pages, flutter technology is considered as an important consideration.
Environment configuration is needed before development of flutter, and the environment of flutter includes the following parts: a flutter git repository, flutter-related tool script code, flutter built-in components, version numbers of the dependent development language Dart SDK, and Pub tools. The Dart SDK is used as a development language package required by developing the flutter application, is used for compiling and running the flutter application, and compiles a first part of flutter tool script code to generate a snapshot (command line tool); the Pub tool is used for packaging and issuing flutter application; and configuring global environment variables according to the local git warehouse path for use in subsequent flutter development.
Different flutter projects may require different flutter version development environments, which often face the problem of frequent switching of the flutter environments. For example, when developing a flutter app of a desktop end (macOS, Windows, etc.), a channel (branch) needs to be switched to a master branch, and when developing an app of a mobile phone end, a channel often needs to be switched to a stable branch for development. There are more extreme scenarios where even if all are on the same channel, different versions of flutter may cause the same code warehouse to be not compiled or to be inconsistent in effect on some machines. Therefore, when different projects are developed, the local flutter environment needs to be switched to a required flutter version number or branch, and the switching process is generally realized by using a flutter channel xx branch or a flutter version yy version and other commands provided by a flutter official party.
However, in the process of implementing the concept of the present disclosure, the inventors found that, in the process of executing the environment switching by the foregoing flutter channel xx branch or flutter version yy version command, since the switching to the xx branch or yy version is implemented by using the git command, it is necessary to first determine whether the current flatter dependent Dark SDK is consistent with the version of the local cache, and in the case of determining inconsistency, it is necessary to temporarily download the dependent Dark SDK (usually about 200M), then compile the flutter source code using the downloaded Dark SDK, and download the flutter, iOS, android, and desktop-side related resources, even in the case of determining consistency, it is still necessary to go through other flows except for the download. Therefore, when environment switching is performed through two commands of a flutter channel xx branch or a flutter version yy version, each switching needs to go through multiple processes of downloading, compiling and the like, and the switching once may take 20-30 minutes according to the difference of the current network environment and the performance of the machine.
Embodiments of the present disclosure provide an application environment switching method, an application environment switching apparatus, a computer system, and a computer-readable storage medium. The method comprises the steps of creating an environment configuration file, wherein the environment configuration file comprises a version number, a branch type and a warehouse address of a target application environment, and a local cache code for realizing 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 a warehouse corresponding to the warehouse address; and configuring the cache directory as a global environment variable to realize switching from the initial application environment to the target application environment.
Fig. 1 schematically shows anexemplary system architecture 100 to which the application context switching method may be applied, according to an embodiment of the present disclosure. It should be noted that fig. 1 is only an example of a system architecture to which the embodiments of the present disclosure may be applied to help those skilled in the art understand the technical content of the present disclosure, and does not mean that the embodiments of the present disclosure may not be applied to other devices, systems, environments or scenarios.
As shown in fig. 1, thesystem architecture 100 according to this embodiment may includeterminal devices 101, 102, 103, anetwork 104 and aserver 105. Thenetwork 104 serves as a medium for providing communication links between theterminal devices 101, 102, 103 and theserver 105.Network 104 may include various connection types, such as wired and/or wireless communication links, and so forth.
A user may use theterminal devices 101, 102, 103 to interact with theserver 105 over thenetwork 104 to receive or transmit data or the like. Various communication client applications may be installed on theterminal devices 101, 102, and 103, for example, the communication client applications may be integrated environment type applications for Java development, such as Eclipse, MyEclipse, and aid, or a mobile UI framework, such as flutter, or other programming class or client class applications.
Theterminal devices 101, 102, 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 portable computers, desktop computers, and the like.
Theserver 105 may be a server providing various services, such as a background management server providing support for requests made by users with theterminal devices 101, 102, 103. The background management server may analyze and perform other processing on the received data such as the user request, and feed back a processing result (e.g., a webpage, information, an instruction, or data obtained or generated according to the user request) to the terminal device.
It should be noted that the application environment switching method provided by the embodiment of the present disclosure may be generally executed by theserver 105. Accordingly, the application environment switching device provided by the embodiment of the present disclosure may be generally disposed in theserver 105. The application environment switching method provided by the embodiment of the present disclosure may also be executed by a server or a server cluster that is different from theserver 105 and is capable of communicating with theterminal devices 101, 102, 103 and/or theserver 105. Accordingly, the application environment switching device provided by the embodiment of the present disclosure may also be disposed in a server or a server cluster different from theserver 105 and capable of communicating with theterminal devices 101, 102, 103 and/or theserver 105. Alternatively, the application environment switching method provided by the embodiment of the present disclosure may also be executed by theterminal device 101, 102, or 103, or may also be executed by another terminal device different from theterminal device 101, 102, or 103. Accordingly, the application environment switching apparatus provided by the embodiment of the present disclosure may also be disposed in theterminal device 101, 102, or 103, or in another terminal device different from theterminal device 101, 102, or 103.
For example, the initial application environment may be originally stored in any one of theterminal apparatuses 101, 102, or 103 (e.g., theterminal apparatus 101, but not limited thereto), or may be stored on an external storage apparatus and may be imported into theterminal apparatus 101. Then, theterminal device 101 may 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 another terminal device, a server, or a server cluster, and execute the application environment switching method provided by the embodiment of the present disclosure by another terminal device, a server, or a server cluster that receives the relevant configuration information of the initial application environment.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Fig. 2 schematically shows a simple flowchart of an application context switching method according to an embodiment of the present disclosure.
As shown in fig. 2, the method includes operations S201 to S203.
In operation S201, an environment configuration file is created, where 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.
According to the embodiment of the present disclosure, the creation of the environment profile may be manually created, or may be implemented by inputting an instruction with a function of creating a default profile by one key in a command line tool, and then implementing the creation of the environment profile according to the instruction. The environment configuration file may be, for example, a valid version number or a valid branch type, and a warehouse address, and a local cache code for implementing the target application environment, which is downloaded and is stored in a warehouse corresponding to the warehouse address, is stored in the warehouse. The target application environment may be, for example, a specific application environment that requires switching of a current application environment (which may be referred to as an initial application environment, for example) to support a project to a corresponding version or branch that is more suitable for development of the project, or may be another application environment that is different from the version or branch of the current application environment. The locally cached code is, for example, code that has completed downloading and is stored in the repository.
In operation S202, according to the version number or the branch type, the cache directory corresponding to the local cache code is obtained from the warehouse corresponding to the warehouse address.
According to an embodiment of the present disclosure, the switching of the application environment may include, for example, a switching on version or a switching on branch with respect to the initial application environment. Under the condition that the version needs to be switched, namely a cache directory where a local cache code for realizing a target application environment corresponding to a target version number is located is obtained from a warehouse; and under the condition that the branch needs to be switched, namely acquiring a cache directory in which local cache codes for realizing the target application environment corresponding to the target branch are located from the warehouse. And the target version number and the target branch respectively correspond to the version number and the branch type in the environment configuration file.
In operation S203, the cache directory is configured as a global environment variable, and a switch from the initial application environment to the target application environment is implemented.
According to an embodiment of the present disclosure, the content stored in the cache directory may be, for example, a required code of a target application environment corresponding to the target version number or a required code of a target application environment corresponding to the target branch. The global environment variable is used as a variable for providing basic environment support for the operation of the system, and the cache directory is directly configured as the global environment variable, namely, the environment for representing the current system operation is the environment provided by the codes stored in the cache directory, namely, the application environment realizes the switching from the initial application environment to the target application environment corresponding to the version number or the branch type in the environment configuration file.
According to the embodiment of the disclosure, the idea of changing space into time is adopted, codes for realizing the target application environment are cached locally without repeated downloading, and time consumed in downloading and compiling processes is reduced, so that the switching time of the application environment can be reduced, and the switching efficiency is improved.
According to a specific embodiment of the present disclosure, the application environment may be, for example, a flutter environment, and the branch corresponding to the flutter environment may include, for example, a master branch, a stable branch, and the like.
Based on the above embodiment, the method shown in fig. 2 will be further described with reference to fig. 3 to 5.
According to an embodiment of the present disclosure, before the above operation S201, the method further includes: executing the operation command; judging whether the warehouse corresponding to the initial application environment contains an environment configuration file or not according to the operation command; and under the condition that the warehouse corresponding to the initial application environment does not contain the environment configuration file, creating the environment configuration file.
According to an embodiment of the present disclosure, the operation command may be flutterw, and the determining whether the repository corresponding to the initial application environment contains the environment configuration file according to the operation command includes two specific implementations, namely implementation 1 and implementation 2.
Embodiment 1: in the case that the application environment needs to be switched without executing the actual project, it can be directly determined whether the repository corresponding to the initial application environment contains the environment configuration file. If yes, switching from the initial application environment to the target application environment can be realized on the basis of the environment configuration file in combination with the operations S202 to S203; if not, all of the above operations S201 to S203 are performed to implement the switching from the initial application environment to the target application environment.
Embodiment 2: in the case that an actual project needs to be executed, and the application environment (i.e., the initial application environment) in which the project is located is not compatible with the application environment (i.e., the target application environment) in which the project depends, and the application environment needs to be switched, it may be determined whether the project includes an environment configuration file in an engineering catalog (also referred to as a git repository) of the project. If yes, switching from the initial application environment to the target application environment can be realized on the basis of the environment configuration file in combination with the operations S202 to S203; if not, an environment configuration file for the project is constructed according to the flutter version or branch required to be depended on by the project, and the environment configuration file is placed in the project catalog of the project as a single file of the project.
FIG. 3 schematically illustrates a flowchart of operations performed prior to creating an environment profile, according to an embodiment of the disclosure.
According to an embodiment of the present disclosure, as an example of the above embodiment 2, and as shown in fig. 3, before the above creating the environment configuration file (i.e., performing operation S201), operations S301 to S304 are further included.
In operation S301, a flutterw command is executed.
In operation S302, it is determined whether a configuration file exists under the project directory.
According to an embodiment of the present disclosure, the configuration file may be, for example, a flutter environment configuration file.
In operation S303, the user is prompted to find no profile, please create a profile.
According to an embodiment of the present disclosure, the creating of the profile may be implemented, for example, by entering an instruction in the command line tool having a one-key create default profile function, which may be defined, for example, as a flutterw init. Accordingly, in this operation, the creation of the configuration file may be achieved, for example, by prompting the user to initialize the configuration file using a flutterw init.
In operation S304, configuration parsing logic is executed.
It should be noted that the operation S303 is only effective when the determination result of the operation S302 is no, and the subsequent operation S304 is performed when the determination result of the operation S302 is yes.
Through the above embodiments of the present disclosure, a configuration file matched with the target application environment on which the configuration file depends may be created for each project, and the configuration file may be stored in a warehouse corresponding to the initial application environment, or may be stored in an engineering directory of the actual project. The difference is that the former can be independent of the item, i.e. can realize the switch of the application environment without executing the item, and the latter is more prone to the switch of the environment in the process of the item implementation. The latter sets up independent flutter environment sandbox (being the environment configuration file) for appointed flutter business engineering, through the thought that the space trades time, has greatly reduced the time that the switching of flutter environment took, still can make things convenient for all personnel who participate in this project to be in the time of pulling the project simultaneously, can both synchronize to this file, need not repeated configuration.
FIG. 4 schematically shows a flow diagram for creating an environment profile according to an embodiment of the disclosure.
FIG. 5 schematically shows a flow diagram of execution of configuration resolution logic according to an embodiment of the disclosure.
It should be noted that, the creating environment configuration file may be implemented, for example, by combining the executing configuration analysis logic; alternatively, the created environment profile may represent only the creation of an environment profile, and the execution configuration parsing logic may represent only the parsing of an already created environment profile. In different embodiments, the two can be combined or independently implemented.
As shown in fig. 4, the flow includes operations S401 to S408.
In operation S401, an initial configuration file is created, where the initial configuration file includes configuration items respectively used for characterizing a version number, a branch type, and a warehouse address of a target application environment, and each configuration item corresponds to configuration information.
According to the embodiment of the present disclosure, the creation of the initial profile may be, for example, the user directly creating at any time, or may be performed when the determination result in operation S302 is negative.
According to the embodiment of the present disclosure, taking the case of creating the initial configuration file through the foregoing flutterw init command as an example, the command line tool parses and executes corresponding logic operations after receiving the flutterw init command, where the logic operations may include, for example: and creating an initial configuration file by using a touch command of the shell, and adding the configuration items and the configuration information in the configuration file by using an echo command, thereby completing the creation of the initial configuration file.
According to an embodiment of the present disclosure, taking a specific item as an example, the process of creating the initial configuration file may include: the flutter environment information on which the project depends is abstracted into an initial configuration file, and the initial configuration file is constructed by dividing each configuration item by a line feed, and dividing the configuration item key and the configuration information value by a colon. For example, in the flutter environment information that a certain item depends on, the flutter version number (version) is: v1.12.13+ hotfix.9, flutter branch (channel) type: master, flutter warehouse address (repo) is: https: com/flutter, git, then the configuration file for the project created from the flutter environment information is as follows:
version:v1.12.13+hotfix.9
channel:master
repo:https://github.com/flutter/flutter.git
according to the embodiment of the present disclosure, since it is not guaranteed that the configuration information (configuration information including version number, branch type, warehouse address, etc.) in the initial configuration file created by the instruction created by the above one-key is completely valid, in order to obtain the environment configuration file having valid configuration information, on the basis of operation S401, for example, operations S402 to S406 may be further included to obtain the environment configuration file whose content is valid by combining the process of invalidation judgment.
In operation S402, configuration information corresponding to each configuration item in the initial configuration file is read.
According to an embodiment of the present disclosure, the operation may correspond to, for example, operation S501 in fig. 5: and reading the configuration information, and acquiring version, channel and repo configuration items.
According to an embodiment of the present disclosure, the reading configuration information may include, for example: respectively reading the configuration items (version, channel and repo) and the corresponding configuration information (flutter version, flutter warehouse branch and flutter warehouse address) in the initial configuration file, wherein the reading mode can be, for example, reading the initial configuration file by using a shell's cat command.
In operation S403, in the case that the configuration information corresponding to the warehouse address is empty or invalid, the configuration information corresponding to the warehouse address is modified into a valid warehouse address.
According to an embodiment of the present disclosure, this operation may correspond to, for example, operations S502 to S503 in fig. 5: in operation S502, it is determined whether repo is valid; in operation S503, the user is prompted that the repo is invalid and please fill in the correct value; operation S503 is validated when the determination result in operation S502 is no.
According to an embodiment of the present disclosure, for operation S502 described above, when repo is empty or not a git warehouse, the operation may be implemented using, for example, git ls-remote commands. If the determination result in the above operation S502 is yes, the subsequent operation S504 is continuously performed.
In operation S404, in the case that the configuration information corresponding to the branch type is empty or invalid, the configuration information corresponding to the branch type is modified into a valid branch.
According to an embodiment of the present disclosure, this operation may correspond to, for example, operations S504 to S505 in fig. 5: in operation S504, it is determined whether a channel is valid; in operation S505, the user is prompted that the channel is invalid and please fill in a correct value; in the case where the determination result in operation S504 is no, operation S505 takes effect.
According to an embodiment of the present disclosure, for the above operation S504, when the channel is empty or the flutter warehouse does not have the branch, the operation may be implemented using, for example, git ls-remote-heads $ channel-verify-refresh refs/heads/$ channel command. If the determination result of the above operation S504 is yes, the subsequent operation S506 is continuously performed.
In operation S405, if 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.
According to an embodiment of the present disclosure, this operation may correspond to operations S506 to S508 in fig. 5, for example: in operation S506, it is determined whether version has a value; in operation S507, it is determined whether version is legal; in operation S508, the user is prompted that version is invalid and please fill in the correct value; here, the operation S507 is validated when the determination result in the operation S506 is yes, and the operation S508 is validated when the determination result in the operation S507 is no.
According to an embodiment of the present disclosure, for the operation S507, if the flutter warehouse has the version number, the version number is valid, otherwise, the operation S507 is invalid, and the operation S507 may be implemented by using git ls-remote-tags $ version-verify refs/heads/$ version command, for example. In the case where the judgment result of the above operation S507 is yes, the subsequent operation S511 is continuously performed.
In operation S406, in the case that the configuration information corresponding to each of the version number, the branch type, and the warehouse address is valid, the initial configuration file is used as the environment configuration file.
According to the embodiment of the present disclosure, through the operations S402 to S405, validation processing of each item of configuration information in the initial configuration file may be implemented, so that an environment configuration file with valid content may be obtained.
According to the embodiment of the present disclosure, since the local cache code that is used for implementing the target application environment and is downloaded is not necessarily directly stored in the warehouse corresponding to the repo address in the environment configuration file with the valid content, the local cache code still needs to be temporarily downloaded during the process of analyzing the environment configuration file to implement the switching of the application environments. In order to reduce the flow of the temporary download and realize the operation of directly entering the switching of the application environment by analyzing the environment configuration file, the process of creating the environment configuration file may further include the following operations S407 to S408, for example.
In operation S407, under the condition that the configuration information corresponding to the version number is null and the local cache code for implementing the target application environment corresponding to the branch type is not present in the repository corresponding to the repository address, creating a cache directory named by the branch type in the repository corresponding to the repository address; obtaining a local cache code for realizing a target application environment corresponding to the branch type through downloading of the warehouse address; and storing the local cache code for realizing the target application environment corresponding to the branch type into a cache directory named by the branch type.
According to an embodiment of the present disclosure, this operation may correspond to, for example, operations S509 to S510 in fig. 5: in operation S509, it is determined whether the channel cache exists locally; in operation S510, a git is used to pull a flutter warehouse with a warehouse address of repo and a branch of a channel, and a local warehouse directory name is a value of the channel; here, the operation S509 is validated when the determination result of the operation S506 is no, and the operation S510 is validated when the determination result of the operation S509 is no.
According to the embodiment of the present disclosure, with respect to the above operation S509, it is determined whether there is a cache directory of a channel (e.g., master) locally, and if not, a folder named a channel value (e.g., master) is created, and then a flutter code branched to the master is downloaded through a repo value and saved under the folder named the master. If the determination result in the above operation S509 is yes, the subsequent operation S513 is continuously performed.
In operation S408, under the condition that the configuration information corresponding to the version number is non-empty and the local cache code for implementing the target application environment corresponding to the version number does not exist in the warehouse corresponding to the warehouse address, a cache directory named with the version number is created in the warehouse corresponding to the warehouse address; downloading and obtaining a local cache code for realizing a target application environment corresponding to the version number through a warehouse address; and storing the local cache codes for realizing the target application environment corresponding to the version number into a cache directory named by the version number.
According to an embodiment of the present disclosure, the operation may correspond to, for example, operations S511 to S512 in fig. 5: in operation S511, it is determined whether the version cache exists locally; in operation S512, a git is used to pull a flutter warehouse with a warehouse address of repo and a commit point of version, and the local warehouse directory name is the value of the version; here, the operation S511 is validated when the determination result in the operation S507 is yes, and the operation S512 is validated when the determination result in the operation S511 is no.
According to the embodiment of the present disclosure, with respect to the above operation S511, it is determined whether there is a cache whose directory is the version value (for example, v1.12.13+ hotfix.9) locally, if not, a folder named as the version value (for example, v1.12.13+ hotfix.9) is created, and then the flutter code whose extract point is the v1.12.13+ hotfix.9 cache directory is downloaded through the repo address. In the case where the judgment result of the above operation S511 is yes, the subsequent operation S513 is continuously performed.
According to an embodiment of the present disclosure, the operation S513 may correspond to the operation S203 in fig. 2, for example, and the operation S513 may be further validated after the operations S510 and S512 are completed. In operation S513, the context variable path of flutter is changed to the address of the folder (e.g., may be the cache directory obtained in operation S509 or S510, or may be the cache directory obtained in operation S511 or S512). After the execution of operation S513 is completed, the switching of the application environment may be completed.
According to the embodiment of the present disclosure, through the operations S407 to S408, the local cache code for implementing the target application environment is stored in the warehouse corresponding to the repo address of the environment configuration file with the valid content, so that the repeated downloading process can be reduced in the case of switching 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 analyzing the environment configuration file.
According to the embodiment of the present disclosure, by executing the processes of the operations S401 to S408, the environment configuration file having the valid version number or branch type and the warehouse address in the operation S201, and the downloaded local cache code for implementing the target application environment is stored in the warehouse corresponding to the warehouse address. By analyzing the environment configuration file, the cache directory in the operation S202 can be directly obtained, and on this basis, the switching of the application environment can be completed by executing the operation S203.
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 performing the operation S203 further includes: and modifying the warehouse address corresponding to the initial application environment into a warehouse address (repo address) in the environment configuration file.
It should be noted that the operations S401 to S408 may be implemented as a series of sub-operations for creating the environment configuration file in the operation S201, but are not limited thereto. For example, in other embodiments, it may also be expressed as: the operation S401 is equivalent to the operation S201, and is used to provide a tool for supporting the flutter environment configuration file required by the one-key initialization item, and the flutter environment configuration file obtained by the tool supports editing the configuration item; the operations S402 to S408 are equivalent to the operation S202, so as to provide a tool for supporting the configuration file analysis, the tool can analyze the environment configuration file created in the operation S201, and the analysis result obtained through the analysis process is used to support the switching of the subsequent application environment; and using the operation S203 as an execution process for implementing application environment switching to provide a tool for supporting an automated flutter environment, where the operation S203 enters the execution process based on the analysis results obtained in the operations S402 to S408. For example, for the environment configuration file created in operation S201, the parsing process in operations S402 to S408 is executed to obtain a cache directory (parsing result) of the target application environment, and then operation S203 is executed based on the cache directory to implement switching of the application environment.
It should be noted that all the operations for implementing the application environment switching method can be implemented by designing an automation program. For example, the foregoing embodiment designs a flutterw instruction and a flutterw init instruction, and the switching of the application environments can be completed by executing the two instructions.
Through the embodiment of the disclosure, the environment configuration file is used under the condition that a plurality of items depend on different Flutter versions, a plurality of Flutter versions such as channel or version corresponding to the local cache configuration file can be cached, when different versions or branches are switched, switching of the Flutter environments of different versions or branches can be realized by directly changing the path of the global environment variable of the Flutter into the form of the corresponding channel or version cache directory, time-consuming processes such as Dart SDK downloading and Flutter Tool compiling are not needed to be carried out for each switching, and the switching speed of the Flutter environments is greatly improved. Moreover, the required information of the flutter version, the branch and the like is described in the configuration file, the operation steps for realizing the application environment switching are solidified by combining the script, the switching work of the flutter environment can be automatically completed by using the script, for example, the switching process can be completed only by one command line (such as flutter), the problem of overlong time consumption caused by switching the version in a single flutter warehouse by using the flutter channel xx or flutter version yy command is solved, the complicated flow of the flutter environment configuration is not required to be executed, and the use speed and the convenience are greatly improved.
Fig. 6 schematically shows a block diagram of an application context switching apparatus according to an embodiment of the present disclosure.
As shown in fig. 6, the applicationenvironment switching apparatus 600 includes a first creatingmodule 610, an obtainingmodule 620, and aswitching module 630.
A first creatingmodule 610, configured to create an environment configuration file, where the environment configuration file includes a version number of a target application environment, a branch type, and a warehouse address, 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;
an obtainingmodule 620, configured to obtain, 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
theswitching module 630 is configured to configure the cache directory as a global environment variable, so as to implement switching from the initial application environment to the target application environment.
According to the embodiment of the disclosure, the application environment switching device further comprises an execution module, a judgment module and a second creation module.
And the execution module is used for executing the operation command.
And the judging module is used for judging whether the warehouse corresponding to the initial application environment contains the environment configuration file or not according to the operation command.
And the second creating module is used for creating the environment configuration file under the condition that the warehouse corresponding to the initial application environment does not contain the environment configuration file.
According to an embodiment of the present disclosure, the first creating module includes a first creating unit, a reading unit, a first modifying unit, a second modifying unit, a third modifying unit, and a defining unit.
The device comprises a first creating unit, a second creating unit and a third creating unit, wherein the first creating unit is used for creating an initial configuration file, the initial configuration file comprises configuration items respectively used for representing the version number, the branch type and the warehouse address of the target application environment, and each configuration item corresponds to configuration information.
And the reading unit is used for reading the configuration information corresponding to each configuration item in the initial configuration file.
And the first modification unit is used for modifying the configuration information corresponding to the warehouse address into a valid warehouse address under the condition that the configuration information corresponding to the warehouse address is empty or invalid.
And the second modification unit is used for modifying the configuration information corresponding to the branch type into a valid branch under the condition that the configuration information corresponding to the branch type is empty or invalid.
And the third modifying unit is used for modifying the configuration information corresponding to the version number into a valid version number under the condition that the configuration information corresponding to the version number is not empty and invalid.
And the defining unit is used for taking the initial configuration file as the environment configuration file under the condition that the configuration information corresponding to the version number, the branch type and the warehouse address is valid.
According to an embodiment of the present disclosure, the first creating module further includes a second creating unit, a first downloading unit, and a first storing unit.
And a second creating unit, configured to create, in the repository corresponding to the repository address, a cache directory named by the branch type if the configuration information corresponding to the version number is null and there is no local cache code for implementing the target application environment corresponding to the branch type in the repository corresponding to the repository address.
And the first downloading unit is used for obtaining the local cache codes for realizing the target application environment corresponding to the branch type through the downloading of the warehouse address.
The first storage unit is used for storing the local cache codes for realizing the target application environment corresponding to the branch type into the cache directory named by the branch type.
According to an embodiment of the present disclosure, the first creating module further includes a third creating unit, a second downloading unit, and a second storing unit.
And a third creating unit, configured to create, when the configuration information corresponding to the version number is non-empty and a local cache code for implementing the target application environment corresponding to the version number does not exist in the repository corresponding to the repository address, a cache directory named with the version number in the repository corresponding to the repository address.
And the second downloading unit is used for downloading and obtaining the local cache codes for realizing the target application environment corresponding to the version number through the warehouse address.
And the second storage unit is used for storing the local cache codes for realizing the target application environment corresponding to the version number into the cache directory named by the version number.
According to an embodiment of the present disclosure, the application environment switching apparatus further includes a fourth modification unit.
And the fourth modification unit is used for modifying the warehouse address corresponding to the initial application environment into the warehouse address in the environment configuration file.
Any of the modules, units, sub-units, or at least part of the functionality of any of them according to embodiments of the present disclosure may be implemented in one module. Any one or more of the modules, units and sub-units according to the embodiments of the present disclosure may be implemented by being split into a plurality of modules. Any one or more of the modules, units, sub-units according to the embodiments of the present disclosure may be implemented at least partially 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 may be implemented in any other reasonable manner of hardware or firmware by integrating or packaging a circuit, or in any one of three implementations of software, hardware, and firmware, or in any suitable combination of any of them. Alternatively, one or more of the modules, units, sub-units according to embodiments of the disclosure may be at least partially implemented as computer program modules, which, when executed, may perform the corresponding functions.
For example, any plurality of the first creatingmodule 610, the obtainingmodule 620 and theswitching module 630 may be combined and implemented in one module/unit/sub-unit, or any one of the modules/units/sub-units may be split into a plurality of modules/units/sub-units. Alternatively, at least part of the functionality of one or more of these modules/units/sub-units may be combined with at least part of the functionality of other modules/units/sub-units and implemented in one module/unit/sub-unit. According to an embodiment of the present disclosure, at least one of the first creatingmodule 610, the obtainingmodule 620, and theswitching module 630 may be implemented at least partially 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 may be implemented in hardware or firmware in any other reasonable manner of integrating or packaging a circuit, or in any one of or a suitable combination of software, hardware, and firmware. Alternatively, at least one of the first creatingmodule 610, the obtainingmodule 620 and theswitching module 630 may be at least partially implemented as a computer program module, which when executed, may perform a corresponding function.
It should be noted that the application environment switching device portion in the embodiment of the present disclosure corresponds to the application environment switching method portion in the embodiment of the present disclosure, and the description of the application environment switching device portion specifically refers to the application environment switching method portion, and is not described herein again.
FIG. 7 schematically illustrates a block diagram of a computer system suitable for implementing the application context switching method described above, according to an embodiment of the present disclosure. The computer system illustrated in FIG. 6 is only one example and should not impose any limitations on the scope of use or functionality of embodiments of the disclosure.
As shown in fig. 7, acomputer system 700 according to an embodiment of the present disclosure includes aprocessor 701, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)702 or a program loaded from astorage section 708 into a Random Access Memory (RAM) 703. Theprocessor 701 may include, for example, a general purpose microprocessor (e.g., a CPU), an instruction set processor and/or associated chipset, and/or a special purpose microprocessor (e.g., an Application Specific Integrated Circuit (ASIC)), among others. Theprocessor 701 may also include on-board memory for caching purposes. Theprocessor 701 may comprise a single processing unit or a plurality of processing units for performing the different actions of the method flows according to embodiments of the present disclosure.
In theRAM 703, various programs and data necessary for the operation of thesystem 700 are stored. Theprocessor 701, theROM 702, and theRAM 703 are connected to each other by abus 704. Theprocessor 701 performs various operations of the method flows according to the embodiments of the present disclosure by executing programs in theROM 702 and/or theRAM 703. It is noted that the programs may also be stored in one or more memories other than theROM 702 andRAM 703. Theprocessor 701 may also perform various operations of method flows according to embodiments of the present disclosure by executing programs stored in the one or more memories.
According to an embodiment of the present disclosure, thesystem 700 may also include an input/output (I/O)interface 705, the input/output (I/O)interface 705 also being connected to thebus 704. Thesystem 700 may also include one or more of the following components connected to the I/O interface 705: aninput portion 706 including a keyboard, a mouse, and the like; anoutput section 707 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; astorage section 708 including a hard disk and the like; and acommunication section 709 including a network interface card such as a LAN card, a modem, or the like. Thecommunication section 709 performs communication processing via a network such as the internet. Adrive 710 is also connected to the I/O interface 705 as needed. Aremovable medium 711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on thedrive 710 as necessary, so that a computer program read out therefrom is mounted into thestorage section 708 as necessary.
According to embodiments of the present disclosure, method flows according to embodiments of the present disclosure may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable storage medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through thecommunication section 709, and/or installed from theremovable medium 711. The computer program, when executed by theprocessor 701, performs the above-described functions defined in the system of the embodiment of the present disclosure. The systems, devices, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
The present disclosure also provides a computer-readable storage medium, which may be contained in the apparatus/device/system described in the above embodiments; or may exist separately and not be assembled into the device/apparatus/system. The computer-readable storage medium carries one or more programs which, when executed, implement the method according to an embodiment of the disclosure.
According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium. Examples may include, but are not limited to: 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), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
For example, according to embodiments of the present disclosure, a computer-readable storage medium may include theROM 702 and/or theRAM 703 and/or one or more memories other than theROM 702 and theRAM 703 described above.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions. Those skilled in the art will appreciate that various combinations and/or combinations of features recited in the various embodiments and/or claims of the present disclosure can be made, even if such combinations or combinations are not expressly recited in the present disclosure. In particular, various combinations and/or combinations of the features recited in the various embodiments and/or claims of the present disclosure may be made without departing from the spirit or teaching of the present disclosure. All such combinations and/or associations are within the scope of the present disclosure.
The embodiments of the present disclosure have been described above. However, these examples are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although the embodiments are described separately above, this does not mean that the measures in the embodiments cannot be used in advantageous combination. The scope of the disclosure is defined by the appended claims and equivalents thereof. Various alternatives and modifications can be devised by those skilled in the art without departing from the scope of the present disclosure, and such alternatives and modifications are intended to be within the scope of the present disclosure.