1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/* eslint-disable @gitlab/require-i18n-strings */
import {
DEFAULT_PLATFORM,
LINUX_PLATFORM,
MACOS_PLATFORM,
WINDOWS_PLATFORM,
DOWNLOAD_LOCATIONS,
} from '../../constants';
import linuxInstall from './scripts/linux/install.sh?raw';
import osxInstall from './scripts/osx/install.sh?raw';
import windowsInstall from './scripts/windows/install.ps1?raw';
const OS = {
[LINUX_PLATFORM]: {
commandPrompt: '$',
executable: 'gitlab-runner',
},
[MACOS_PLATFORM]: {
commandPrompt: '$',
executable: 'gitlab-runner',
},
[WINDOWS_PLATFORM]: {
commandPrompt: '>',
executable: '.\\gitlab-runner.exe',
},
};
export const commandPrompt = ({ platform }) => {
return (OS[platform] || OS[DEFAULT_PLATFORM]).commandPrompt;
};
export const executable = ({ platform }) => {
return (OS[platform] || OS[DEFAULT_PLATFORM]).executable;
};
export const registerCommand = ({ platform, url = gon.gitlab_url, registrationToken }) => {
return [
`${executable({ platform })} register`,
` --url ${url}`,
...(registrationToken ? [` --registration-token ${registrationToken}`] : []),
];
};
export const runCommand = ({ platform }) => {
return `${executable({ platform })} run`;
};
const importInstallScript = ({ platform = DEFAULT_PLATFORM }) => {
switch (platform) {
case LINUX_PLATFORM:
return linuxInstall;
case MACOS_PLATFORM:
return osxInstall;
case WINDOWS_PLATFORM:
return windowsInstall;
default:
return '';
}
};
export const platformArchitectures = ({ platform }) => {
return DOWNLOAD_LOCATIONS[platform].map(({ arch }) => arch);
};
export const installScript = ({ platform, architecture }) => {
const downloadLocation = DOWNLOAD_LOCATIONS[platform].find(({ arch }) => arch === architecture)
.url;
return importInstallScript({ platform })
.replace(
// eslint-disable-next-line no-template-curly-in-string
'${GITLAB_CI_RUNNER_DOWNLOAD_LOCATION}',
downloadLocation,
)
.trim();
};
|