(id: string, type: string)
| 860 | const servicesToDuplicate = input.selectedServices || []; |
| 861 | |
| 862 | const duplicateService = async (id: string, type: string) => { |
| 863 | switch (type) { |
| 864 | case "application": { |
| 865 | const { |
| 866 | applicationId, |
| 867 | domains, |
| 868 | security, |
| 869 | ports, |
| 870 | registry, |
| 871 | redirects, |
| 872 | previewDeployments, |
| 873 | mounts, |
| 874 | appName, |
| 875 | refreshToken, |
| 876 | ...application |
| 877 | } = await findApplicationById(id); |
| 878 | const newAppName = appName.substring( |
| 879 | 0, |
| 880 | appName.lastIndexOf("-"), |
| 881 | ); |
| 882 | |
| 883 | const newApplication = await createApplication({ |
| 884 | ...application, |
| 885 | appName: newAppName, |
| 886 | name: input.duplicateInSameProject |
| 887 | ? `${application.name} (copy)` |
| 888 | : application.name, |
| 889 | environmentId: targetProject?.environmentId || "", |
| 890 | }); |
| 891 | |
| 892 | for (const domain of domains) { |
| 893 | const { domainId, ...rest } = domain; |
| 894 | await createDomain({ |
| 895 | ...rest, |
| 896 | applicationId: newApplication.applicationId, |
| 897 | domainType: "application", |
| 898 | }); |
| 899 | } |
| 900 | |
| 901 | for (const port of ports) { |
| 902 | const { portId, ...rest } = port; |
| 903 | await createPort({ |
| 904 | ...rest, |
| 905 | applicationId: newApplication.applicationId, |
| 906 | }); |
| 907 | } |
| 908 | |
| 909 | for (const mount of mounts) { |
| 910 | const { mountId, ...rest } = mount; |
| 911 | await createMount({ |
| 912 | ...rest, |
| 913 | serviceId: newApplication.applicationId, |
| 914 | serviceType: "application", |
| 915 | }); |
| 916 | } |
| 917 | |
| 918 | for (const redirect of redirects) { |
| 919 | const { redirectId, ...rest } = redirect; |
no test coverage detected