@catladder/cli 0.0.0-refactor-untangle-gitlab-api-requests-from-vorpal-57cf3cf2 → 0.0.0-reference-database-url-1befbbee
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundles/catenv/index.js +2146 -23675
- package/dist/bundles/cli/index.js +575 -1032
- package/dist/cli/src/apps/cli/commands/project/commandGitlabCi.d.ts +2 -5
- package/dist/cli/src/apps/cli/commands/project/commandGitlabCi.js +9 -26
- package/dist/cli/src/apps/cli/commands/project/commandGitlabCi.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/commandSetup.js +5 -3
- package/dist/cli/src/apps/cli/commands/project/commandSetup.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/index.d.ts +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/index.js +6 -17
- package/dist/cli/src/apps/cli/commands/project/setup/index.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/setupAccessTokens.d.ts +1 -4
- package/dist/cli/src/apps/cli/commands/project/setup/setupAccessTokens.js +23 -35
- package/dist/cli/src/apps/cli/commands/project/setup/setupAccessTokens.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/setupKubernetes.d.ts +2 -5
- package/dist/cli/src/apps/cli/commands/project/setup/setupKubernetes.js +23 -38
- package/dist/cli/src/apps/cli/commands/project/setup/setupKubernetes.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/setupTopic.d.ts +1 -2
- package/dist/cli/src/apps/cli/commands/project/setup/setupTopic.js +4 -5
- package/dist/cli/src/apps/cli/commands/project/setup/setupTopic.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/utils/autocompletions.d.ts +1 -0
- package/dist/cli/src/apps/cli/commands/project/utils/autocompletions.js +9 -1
- package/dist/cli/src/apps/cli/commands/project/utils/autocompletions.js.map +1 -1
- package/dist/cli/src/apps/cli/utils/getGoogleAuthUserNumber.d.ts +1 -1
- package/dist/cli/src/apps/cli/utils/getGoogleAuthUserNumber.js +11 -20
- package/dist/cli/src/apps/cli/utils/getGoogleAuthUserNumber.js.map +1 -1
- package/dist/cli/src/apps/cli/verify/index.js +5 -22
- package/dist/cli/src/apps/cli/verify/index.js.map +1 -1
- package/dist/cli/src/config/getProjectConfig.d.ts +1 -1
- package/dist/cli/src/config/getProjectConfig.js +10 -12
- package/dist/cli/src/config/getProjectConfig.js.map +1 -1
- package/dist/cli/src/git/gitProjectInformation.d.ts +1 -14
- package/dist/cli/src/git/gitProjectInformation.js +2 -29
- package/dist/cli/src/git/gitProjectInformation.js.map +1 -1
- package/dist/cli/src/utils/gitlab.d.ts +23 -17
- package/dist/cli/src/utils/gitlab.js +161 -120
- package/dist/cli/src/utils/gitlab.js.map +1 -1
- package/dist/cli/src/utils/log.d.ts +0 -15
- package/dist/cli/src/utils/log.js +1 -23
- package/dist/cli/src/utils/log.js.map +1 -1
- package/dist/cli/src/utils/preferences.d.ts +4 -0
- package/dist/cli/src/utils/preferences.js +58 -0
- package/dist/cli/src/utils/preferences.js.map +1 -0
- package/dist/pipeline/src/build/artifacts/createBuildJobArtifact.js +3 -1
- package/dist/pipeline/src/build/artifacts/createBuildJobArtifact.js.map +1 -1
- package/dist/pipeline/src/build/base/index.d.ts +2 -3
- package/dist/pipeline/src/build/base/index.js.map +1 -1
- package/dist/pipeline/src/build/cache/getAllCacheConfigsFromConfig.js +6 -4
- package/dist/pipeline/src/build/cache/getAllCacheConfigsFromConfig.js.map +1 -1
- package/dist/pipeline/src/build/custom/buildJob.d.ts +2 -2
- package/dist/pipeline/src/build/custom/buildJob.js.map +1 -1
- package/dist/pipeline/src/build/custom/index.d.ts +2 -2
- package/dist/pipeline/src/build/custom/index.js.map +1 -1
- package/dist/pipeline/src/build/custom/testJob.d.ts +2 -2
- package/dist/pipeline/src/build/custom/testJob.js.map +1 -1
- package/dist/pipeline/src/build/docker.d.ts +4 -4
- package/dist/pipeline/src/build/docker.js +1 -1
- package/dist/pipeline/src/build/docker.js.map +1 -1
- package/dist/pipeline/src/build/index.d.ts +2 -2
- package/dist/pipeline/src/build/index.js +2 -3
- package/dist/pipeline/src/build/index.js.map +1 -1
- package/dist/pipeline/src/build/node/buildJob.d.ts +5 -3
- package/dist/pipeline/src/build/node/buildJob.js.map +1 -1
- package/dist/pipeline/src/build/node/index.d.ts +4 -4
- package/dist/pipeline/src/build/node/index.js.map +1 -1
- package/dist/pipeline/src/build/node/meteor.d.ts +2 -2
- package/dist/pipeline/src/build/node/meteor.js.map +1 -1
- package/dist/pipeline/src/build/node/yarn.d.ts +1 -1
- package/dist/pipeline/src/build/node/yarn.js +3 -1
- package/dist/pipeline/src/build/node/yarn.js.map +1 -1
- package/dist/pipeline/src/build/rails/build.d.ts +2 -2
- package/dist/pipeline/src/build/rails/build.js +0 -1
- package/dist/pipeline/src/build/rails/build.js.map +1 -1
- package/dist/pipeline/src/build/rails/index.d.ts +2 -2
- package/dist/pipeline/src/build/rails/index.js.map +1 -1
- package/dist/pipeline/src/build/rails/test.js +18 -1
- package/dist/pipeline/src/build/rails/test.js.map +1 -1
- package/dist/pipeline/src/build/sbom.d.ts +2 -2
- package/dist/pipeline/src/build/sbom.js +4 -1
- package/dist/pipeline/src/build/sbom.js.map +1 -1
- package/dist/pipeline/src/build/types.d.ts +8 -0
- package/dist/pipeline/src/build/types.js.map +1 -1
- package/dist/pipeline/src/context/createComponentContext.js +17 -6
- package/dist/pipeline/src/context/createComponentContext.js.map +1 -1
- package/dist/pipeline/src/context/getLabels.js +3 -1
- package/dist/pipeline/src/context/getLabels.js.map +1 -1
- package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunJobs.js +2 -2
- package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunJobs.js.map +1 -1
- package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunServices.js +32 -7
- package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunServices.js.map +1 -1
- package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/onDeploy.d.ts +1 -2
- package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/onDeploy.js +3 -10
- package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/onDeploy.js.map +1 -1
- package/dist/pipeline/src/deploy/cloudRun/createJobs/healthCheck.d.ts +5 -0
- package/dist/pipeline/src/deploy/cloudRun/createJobs/healthCheck.js +51 -0
- package/dist/pipeline/src/deploy/cloudRun/createJobs/healthCheck.js.map +1 -0
- package/dist/pipeline/src/deploy/cloudRun/index.js +7 -4
- package/dist/pipeline/src/deploy/cloudRun/index.js.map +1 -1
- package/dist/pipeline/src/deploy/cloudRun/utils/database.d.ts +21 -2
- package/dist/pipeline/src/deploy/cloudRun/utils/database.js +55 -6
- package/dist/pipeline/src/deploy/cloudRun/utils/database.js.map +1 -1
- package/dist/pipeline/src/deploy/cloudRun/utils/getJobOrServiceArgs.d.ts +2 -0
- package/dist/pipeline/src/deploy/cloudRun/utils/getJobOrServiceArgs.js +12 -0
- package/dist/pipeline/src/deploy/cloudRun/utils/getJobOrServiceArgs.js.map +1 -0
- package/dist/pipeline/src/deploy/kubernetes/kubeValues.d.ts +2 -2
- package/dist/pipeline/src/deploy/kubernetes/kubeValues.js +3 -1
- package/dist/pipeline/src/deploy/kubernetes/kubeValues.js.map +1 -1
- package/dist/pipeline/src/deploy/sbom.js +4 -3
- package/dist/pipeline/src/deploy/sbom.js.map +1 -1
- package/dist/pipeline/src/deploy/types/googleCloudRun.d.ts +100 -0
- package/dist/pipeline/src/deploy/types/googleCloudRun.js +16 -0
- package/dist/pipeline/src/deploy/types/googleCloudRun.js.map +1 -1
- package/dist/pipeline/src/pipeline/createJobsForComponent.js +3 -1
- package/dist/pipeline/src/pipeline/createJobsForComponent.js.map +1 -1
- package/dist/pipeline/src/types/config.d.ts +1 -1
- package/dist/pipeline/src/types/context.d.ts +6 -1
- package/dist/pipeline/src/types/context.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/apps/cli/commands/project/commandGitlabCi.ts +20 -58
- package/src/apps/cli/commands/project/commandSetup.ts +5 -3
- package/src/apps/cli/commands/project/setup/index.ts +9 -19
- package/src/apps/cli/commands/project/setup/setupAccessTokens.ts +45 -62
- package/src/apps/cli/commands/project/setup/setupKubernetes.ts +32 -53
- package/src/apps/cli/commands/project/setup/setupTopic.ts +12 -17
- package/src/apps/cli/commands/project/utils/autocompletions.ts +9 -0
- package/src/apps/cli/utils/getGoogleAuthUserNumber.ts +18 -28
- package/src/apps/cli/verify/index.ts +7 -25
- package/src/config/getProjectConfig.ts +21 -22
- package/src/git/gitProjectInformation.ts +1 -31
- package/src/utils/gitlab.ts +247 -200
- package/src/utils/log.ts +0 -26
- package/src/utils/preferences.ts +60 -0
- package/dist/cli/src/utils/gitlab-without-vorpal/FetchGitLabError.d.ts +0 -18
- package/dist/cli/src/utils/gitlab-without-vorpal/FetchGitLabError.js +0 -32
- package/dist/cli/src/utils/gitlab-without-vorpal/FetchGitLabError.js.map +0 -1
- package/dist/cli/src/utils/gitlab-without-vorpal/FetchMethod.d.ts +0 -1
- package/dist/cli/src/utils/gitlab-without-vorpal/FetchMethod.js +0 -3
- package/dist/cli/src/utils/gitlab-without-vorpal/FetchMethod.js.map +0 -1
- package/dist/cli/src/utils/gitlab-without-vorpal/GitLabApiDataOptional.d.ts +0 -14
- package/dist/cli/src/utils/gitlab-without-vorpal/GitLabApiDataOptional.js +0 -3
- package/dist/cli/src/utils/gitlab-without-vorpal/GitLabApiDataOptional.js.map +0 -1
- package/dist/cli/src/utils/gitlab-without-vorpal/GitLabTokenMissingError.d.ts +0 -4
- package/dist/cli/src/utils/gitlab-without-vorpal/GitLabTokenMissingError.js +0 -12
- package/dist/cli/src/utils/gitlab-without-vorpal/GitLabTokenMissingError.js.map +0 -1
- package/dist/cli/src/utils/gitlab-without-vorpal/fetchGitLabApi.d.ts +0 -8
- package/dist/cli/src/utils/gitlab-without-vorpal/fetchGitLabApi.js +0 -47
- package/dist/cli/src/utils/gitlab-without-vorpal/fetchGitLabApi.js.map +0 -1
- package/dist/cli/src/utils/gitlab-without-vorpal/getGitlabHostPathToken.d.ts +0 -20
- package/dist/cli/src/utils/gitlab-without-vorpal/getGitlabHostPathToken.js +0 -15
- package/dist/cli/src/utils/gitlab-without-vorpal/getGitlabHostPathToken.js.map +0 -1
- package/dist/cli/src/utils/gitlab-without-vorpal/gitLabProjectByGitPath.d.ts +0 -23
- package/dist/cli/src/utils/gitlab-without-vorpal/gitLabProjectByGitPath.js +0 -30
- package/dist/cli/src/utils/gitlab-without-vorpal/gitLabProjectByGitPath.js.map +0 -1
- package/dist/cli/src/utils/gitlab-without-vorpal/gitLabVariables.d.ts +0 -66
- package/dist/cli/src/utils/gitlab-without-vorpal/gitLabVariables.js +0 -129
- package/dist/cli/src/utils/gitlab-without-vorpal/gitLabVariables.js.map +0 -1
- package/dist/cli/src/utils/gitlab-without-vorpal/index.d.ts +0 -12
- package/dist/cli/src/utils/gitlab-without-vorpal/index.js +0 -29
- package/dist/cli/src/utils/gitlab-without-vorpal/index.js.map +0 -1
- package/dist/cli/src/utils/gitlab-without-vorpal/insertProjectTopics.d.ts +0 -5
- package/dist/cli/src/utils/gitlab-without-vorpal/insertProjectTopics.js +0 -23
- package/dist/cli/src/utils/gitlab-without-vorpal/insertProjectTopics.js.map +0 -1
- package/dist/cli/src/utils/gitlab-without-vorpal/loadGitLabToken.d.ts +0 -2
- package/dist/cli/src/utils/gitlab-without-vorpal/loadGitLabToken.js +0 -27
- package/dist/cli/src/utils/gitlab-without-vorpal/loadGitLabToken.js.map +0 -1
- package/dist/cli/src/utils/gitlab-without-vorpal/projectAccessToken.d.ts +0 -29
- package/dist/cli/src/utils/gitlab-without-vorpal/projectAccessToken.js +0 -24
- package/dist/cli/src/utils/gitlab-without-vorpal/projectAccessToken.js.map +0 -1
- package/dist/cli/src/utils/gitlab-without-vorpal/storeGitLabToken.d.ts +0 -3
- package/dist/cli/src/utils/gitlab-without-vorpal/storeGitLabToken.js +0 -19
- package/dist/cli/src/utils/gitlab-without-vorpal/storeGitLabToken.js.map +0 -1
- package/dist/cli/src/utils/preferences/CatladderPreferences.d.ts +0 -27
- package/dist/cli/src/utils/preferences/CatladderPreferences.js +0 -34
- package/dist/cli/src/utils/preferences/CatladderPreferences.js.map +0 -1
- package/dist/cli/src/utils/preferences/index.d.ts +0 -11
- package/dist/cli/src/utils/preferences/index.js +0 -79
- package/dist/cli/src/utils/preferences/index.js.map +0 -1
- package/src/utils/gitlab-without-vorpal/FetchGitLabError.ts +0 -57
- package/src/utils/gitlab-without-vorpal/FetchMethod.ts +0 -1
- package/src/utils/gitlab-without-vorpal/GitLabApiDataOptional.ts +0 -14
- package/src/utils/gitlab-without-vorpal/GitLabTokenMissingError.ts +0 -7
- package/src/utils/gitlab-without-vorpal/fetchGitLabApi.ts +0 -74
- package/src/utils/gitlab-without-vorpal/getGitlabHostPathToken.ts +0 -31
- package/src/utils/gitlab-without-vorpal/gitLabProjectByGitPath.ts +0 -57
- package/src/utils/gitlab-without-vorpal/gitLabVariables.ts +0 -290
- package/src/utils/gitlab-without-vorpal/index.ts +0 -12
- package/src/utils/gitlab-without-vorpal/insertProjectTopics.ts +0 -35
- package/src/utils/gitlab-without-vorpal/loadGitLabToken.ts +0 -29
- package/src/utils/gitlab-without-vorpal/projectAccessToken.ts +0 -86
- package/src/utils/gitlab-without-vorpal/storeGitLabToken.ts +0 -23
- package/src/utils/preferences/CatladderPreferences.ts +0 -51
- package/src/utils/preferences/index.ts +0 -103
|
@@ -1451,7 +1451,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
1451
1451
|
const child_process_promise_1 = __nccwpck_require__(75763);
|
|
1452
1452
|
const lodash_1 = __nccwpck_require__(23255);
|
|
1453
1453
|
const open_1 = __importDefault(__nccwpck_require__(14247));
|
|
1454
|
-
const gitlab_without_vorpal_1 = __nccwpck_require__(84346);
|
|
1455
1454
|
const gitlab_1 = __nccwpck_require__(12927);
|
|
1456
1455
|
const statusEmojiMap = {
|
|
1457
1456
|
failed: "🙀",
|
|
@@ -1471,14 +1470,8 @@ const getCurrentCommit = async () => {
|
|
|
1471
1470
|
return result.stdout && result.stdout.replace(/\n$/, "");
|
|
1472
1471
|
};
|
|
1473
1472
|
const delay = async (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
1474
|
-
const promptJob = async (vorpal, projectId, ctx
|
|
1475
|
-
const
|
|
1476
|
-
const token = inputToken || (await (0, gitlab_1.getGitlabToken)(vorpal, host));
|
|
1477
|
-
const jobs = await (0, gitlab_1.doGitlabRequest)(vorpal, {
|
|
1478
|
-
path: `projects/${projectId}/jobs`,
|
|
1479
|
-
host,
|
|
1480
|
-
token,
|
|
1481
|
-
});
|
|
1473
|
+
const promptJob = async (vorpal, projectId, ctx) => {
|
|
1474
|
+
const jobs = await (0, gitlab_1.doGitlabRequest)(vorpal, `projects/${projectId}/jobs`);
|
|
1482
1475
|
const commitId = await getCurrentCommit();
|
|
1483
1476
|
const jobsToName = (jo) => jo.map((j) => `${j.ref}-${j.name}-${j.user.username}-${j.status}-${j.id}`);
|
|
1484
1477
|
const preferredJobs = jobs.filter((j) => j.commit.id === commitId);
|
|
@@ -1499,30 +1492,21 @@ const promptJob = async (vorpal, projectId, ctx, existing = {}) => {
|
|
|
1499
1492
|
const jobId = Number((0, lodash_1.last)(jobName.split("-")));
|
|
1500
1493
|
return jobs.find((j) => j.id === jobId);
|
|
1501
1494
|
};
|
|
1502
|
-
|
|
1495
|
+
exports["default"] = async (vorpal) => {
|
|
1503
1496
|
vorpal.command("project-ci-job-open", "Open a Job").action(async function () {
|
|
1504
|
-
const {
|
|
1505
|
-
const
|
|
1506
|
-
const id = projectId || (await (0, gitlab_without_vorpal_1.getGitLabProjectId)({ host, path, token }, vorpal));
|
|
1507
|
-
const job = await promptJob(this, id, this, { host, path, token });
|
|
1497
|
+
const { id: projectId } = await (0, gitlab_1.getProjectInfo)(this);
|
|
1498
|
+
const job = await promptJob(this, projectId, this);
|
|
1508
1499
|
(0, open_1.default)(job.web_url);
|
|
1509
1500
|
});
|
|
1510
1501
|
vorpal
|
|
1511
1502
|
.command("project-ci-job-log", "Show a job's log")
|
|
1512
1503
|
.action(async function () {
|
|
1513
|
-
const {
|
|
1514
|
-
const
|
|
1515
|
-
const apiData = { host, path, token };
|
|
1516
|
-
const pId = projectId || (await (0, gitlab_without_vorpal_1.getGitLabProjectId)({ host, path, token }, vorpal));
|
|
1517
|
-
const { id } = await promptJob(this, pId, this, apiData);
|
|
1504
|
+
const { id: projectId } = await (0, gitlab_1.getProjectInfo)(this);
|
|
1505
|
+
const { id } = await promptJob(this, projectId, this);
|
|
1518
1506
|
let finished = false;
|
|
1519
1507
|
while (!finished) {
|
|
1520
|
-
const trace = await (0, child_process_promise_1.exec)(`curl -s --header "PRIVATE-TOKEN: ${
|
|
1521
|
-
const job = await (0, gitlab_1.doGitlabRequest)(this, {
|
|
1522
|
-
path: `projects/${pId}/jobs/${id}`,
|
|
1523
|
-
host,
|
|
1524
|
-
token,
|
|
1525
|
-
});
|
|
1508
|
+
const trace = await (0, child_process_promise_1.exec)(`curl -s --header "PRIVATE-TOKEN: ${await (0, gitlab_1.getGitlabToken)(this)}" "https://git.panter.ch/api/v4/projects/${projectId}/jobs/${id}/trace"`);
|
|
1509
|
+
const job = await (0, gitlab_1.doGitlabRequest)(this, `projects/${projectId}/jobs/${id}`);
|
|
1526
1510
|
if (trace.stdout) {
|
|
1527
1511
|
vorpal.ui.redraw(`${trace.stdout}`);
|
|
1528
1512
|
}
|
|
@@ -1544,7 +1528,6 @@ const commandGitlabCi = async (vorpal, { projectId, ...existing } = {}) => {
|
|
|
1544
1528
|
}
|
|
1545
1529
|
});
|
|
1546
1530
|
};
|
|
1547
|
-
exports["default"] = commandGitlabCi;
|
|
1548
1531
|
//# sourceMappingURL=commandGitlabCi.js.map
|
|
1549
1532
|
|
|
1550
1533
|
/***/ }),
|
|
@@ -1859,10 +1842,12 @@ exports["default"] = async (vorpal) => {
|
|
|
1859
1842
|
|
|
1860
1843
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1861
1844
|
const setup_1 = __nccwpck_require__(33309);
|
|
1845
|
+
const autocompletions_1 = __nccwpck_require__(39855);
|
|
1862
1846
|
exports["default"] = async (vorpal) => vorpal
|
|
1863
|
-
.command("project-setup", "Initializes all environments and creates requires resources, service accounts, etc.")
|
|
1864
|
-
.
|
|
1865
|
-
|
|
1847
|
+
.command("project-setup [component]", "Initializes all environments and creates requires resources, service accounts, etc.")
|
|
1848
|
+
.autocomplete(await (0, autocompletions_1.allComponents)())
|
|
1849
|
+
.action(async function ({ component }) {
|
|
1850
|
+
await (0, setup_1.setupProject)(this, component);
|
|
1866
1851
|
});
|
|
1867
1852
|
//# sourceMappingURL=commandSetup.js.map
|
|
1868
1853
|
|
|
@@ -1996,32 +1981,21 @@ exports["default"] = async (vorpal) => {
|
|
|
1996
1981
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1997
1982
|
exports.setupProject = void 0;
|
|
1998
1983
|
const getProjectConfig_1 = __nccwpck_require__(12145);
|
|
1999
|
-
const commandConfigSecrets_1 = __nccwpck_require__(23410);
|
|
2000
1984
|
const setupAccessTokens_1 = __nccwpck_require__(84195);
|
|
2001
1985
|
const setupContext_1 = __nccwpck_require__(44310);
|
|
2002
1986
|
const setupTopic_1 = __nccwpck_require__(84290);
|
|
2003
|
-
const setupProject = async (instance) => {
|
|
2004
|
-
const allContext = await (0, getProjectConfig_1.getAllPipelineContexts)();
|
|
1987
|
+
const setupProject = async (instance, onlyComponents) => {
|
|
1988
|
+
const allContext = await (0, getProjectConfig_1.getAllPipelineContexts)(onlyComponents);
|
|
1989
|
+
instance.log("will setup those contexts:");
|
|
1990
|
+
allContext.forEach((context) => {
|
|
1991
|
+
instance.log(` - ${context.name}:${context.env}`);
|
|
1992
|
+
});
|
|
2005
1993
|
for (const context of allContext) {
|
|
2006
1994
|
await (0, setupContext_1.setupContext)(instance, context);
|
|
2007
1995
|
}
|
|
2008
1996
|
await (0, setupAccessTokens_1.setupAccessTokens)(instance);
|
|
2009
1997
|
await (0, setupTopic_1.setupTopic)(instance);
|
|
2010
1998
|
instance.log("");
|
|
2011
|
-
const { configSecrets } = await instance.prompt({
|
|
2012
|
-
default: true,
|
|
2013
|
-
message: "Before deployments work, you need to config secrets. Do it now?",
|
|
2014
|
-
name: "configSecrets",
|
|
2015
|
-
type: "confirm",
|
|
2016
|
-
});
|
|
2017
|
-
instance.log("");
|
|
2018
|
-
if (configSecrets) {
|
|
2019
|
-
await (0, commandConfigSecrets_1.projectConfigSecrets)(instance);
|
|
2020
|
-
}
|
|
2021
|
-
else {
|
|
2022
|
-
instance.log("👆 don't forget to config secret using `project-config-secrets`");
|
|
2023
|
-
}
|
|
2024
|
-
instance.log("");
|
|
2025
1999
|
instance.log("gitlab is ready! 🥂");
|
|
2026
2000
|
instance.log("\n");
|
|
2027
2001
|
instance.log("do not forget to make sure that:");
|
|
@@ -2048,49 +2022,37 @@ exports.setupProject = setupProject;
|
|
|
2048
2022
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2049
2023
|
exports.setupAccessTokens = void 0;
|
|
2050
2024
|
const date_fns_1 = __nccwpck_require__(44438);
|
|
2051
|
-
const gitlab_without_vorpal_1 = __nccwpck_require__(84346);
|
|
2052
2025
|
const gitlab_1 = __nccwpck_require__(12927);
|
|
2053
2026
|
const TOKEN_NAME = "semantic-release";
|
|
2054
|
-
const setupAccessTokens = async (
|
|
2055
|
-
const {
|
|
2056
|
-
const
|
|
2057
|
-
const
|
|
2058
|
-
const
|
|
2059
|
-
const
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
data: { expires_at },
|
|
2068
|
-
}, vorpal)
|
|
2069
|
-
: await gitlab_without_vorpal_1.gitLabProjectAccessToken.create({
|
|
2070
|
-
projectId: id,
|
|
2071
|
-
token,
|
|
2072
|
-
host,
|
|
2073
|
-
data: {
|
|
2074
|
-
expires_at,
|
|
2075
|
-
name: TOKEN_NAME,
|
|
2076
|
-
scopes: ["api", "read_repository"],
|
|
2077
|
-
access_level: 40, // Maintainer
|
|
2078
|
-
},
|
|
2079
|
-
}, vorpal);
|
|
2080
|
-
const fetchCommon = { key: "GL_TOKEN", projectId: id, host, token };
|
|
2027
|
+
const setupAccessTokens = async (instance) => {
|
|
2028
|
+
const { id: projectId } = await (0, gitlab_1.getProjectInfo)(instance);
|
|
2029
|
+
const projectTokens = await (0, gitlab_1.doGitlabRequest)(instance, `projects/${projectId}/access_tokens`);
|
|
2030
|
+
const token = projectTokens.find((t) => t.name === TOKEN_NAME && t.active === true);
|
|
2031
|
+
const expires_at = (0, date_fns_1.format)((0, date_fns_1.add)(new Date(), { years: 1, days: -1 }), "yyyy-MM-dd");
|
|
2032
|
+
const newToken = token
|
|
2033
|
+
? await (0, gitlab_1.doGitlabRequest)(instance, `projects/${projectId}/access_tokens/${token.id}/rotate`, { expires_at }, "POST")
|
|
2034
|
+
: await (0, gitlab_1.doGitlabRequest)(instance, `projects/${projectId}/access_tokens`, {
|
|
2035
|
+
name: TOKEN_NAME,
|
|
2036
|
+
scopes: ["api", "read_repository"],
|
|
2037
|
+
access_level: 40, // Maintainer
|
|
2038
|
+
expires_at,
|
|
2039
|
+
}, "POST");
|
|
2081
2040
|
try {
|
|
2082
|
-
await
|
|
2083
|
-
await
|
|
2041
|
+
await (0, gitlab_1.doGitlabRequest)(instance, `projects/${projectId}/variables/GL_TOKEN`);
|
|
2042
|
+
await (0, gitlab_1.doGitlabRequest)(instance, `projects/${projectId}/variables/GL_TOKEN`, { value: newToken.token }, "PUT");
|
|
2084
2043
|
}
|
|
2085
2044
|
catch (e) {
|
|
2086
|
-
if (
|
|
2087
|
-
throw e;
|
|
2088
|
-
if (e.status !== 404)
|
|
2045
|
+
if (e.message !== "not found") {
|
|
2089
2046
|
throw e;
|
|
2047
|
+
}
|
|
2090
2048
|
// not found
|
|
2091
|
-
await
|
|
2049
|
+
await (0, gitlab_1.doGitlabRequest)(instance, `projects/${projectId}/variables`, {
|
|
2050
|
+
key: "GL_TOKEN",
|
|
2051
|
+
value: newToken.token,
|
|
2052
|
+
masked: true,
|
|
2053
|
+
}, "POST");
|
|
2092
2054
|
}
|
|
2093
|
-
|
|
2055
|
+
instance.log("Token configured for semantic release. Renew me again in a year!");
|
|
2094
2056
|
};
|
|
2095
2057
|
exports.setupAccessTokens = setupAccessTokens;
|
|
2096
2058
|
//# sourceMappingURL=setupAccessTokens.js.map
|
|
@@ -2203,53 +2165,39 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
2203
2165
|
};
|
|
2204
2166
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2205
2167
|
exports.setupKubernetes = void 0;
|
|
2206
|
-
const child_process_promise_1 = __nccwpck_require__(75763);
|
|
2207
2168
|
const pipeline_1 = __nccwpck_require__(10603);
|
|
2208
|
-
const
|
|
2209
|
-
const gitlab_without_vorpal_1 = __nccwpck_require__(84346);
|
|
2210
|
-
const gitlab_1 = __nccwpck_require__(12927);
|
|
2169
|
+
const child_process_promise_1 = __nccwpck_require__(75763);
|
|
2211
2170
|
const cluster_1 = __nccwpck_require__(62774);
|
|
2212
|
-
const
|
|
2171
|
+
const gitlab_1 = __nccwpck_require__(12927);
|
|
2172
|
+
const ensureNamespace_1 = __importDefault(__nccwpck_require__(81349));
|
|
2173
|
+
const setupKubernetes = async (instance, context) => {
|
|
2213
2174
|
var _a;
|
|
2214
2175
|
const deployConfig = (_a = context.deploy) === null || _a === void 0 ? void 0 : _a.config;
|
|
2215
2176
|
if (!(0, pipeline_1.isOfDeployType)(deployConfig, "kubernetes")) {
|
|
2216
2177
|
throw new Error("cannot run setupKubernetes on non-kubernetes deployments");
|
|
2217
2178
|
}
|
|
2218
|
-
const {
|
|
2219
|
-
const
|
|
2220
|
-
const id = projectId || (await (0, gitlab_without_vorpal_1.getGitLabProjectId)({ host, path, token }, vorpal));
|
|
2221
|
-
const requestInfo = { host, path, token, projectId: id };
|
|
2222
|
-
const deploy_tokens = await (0, gitlab_1.doGitlabRequest)(vorpal, {
|
|
2223
|
-
path: `projects/${id}/deploy_tokens`,
|
|
2224
|
-
host,
|
|
2225
|
-
token,
|
|
2226
|
-
});
|
|
2179
|
+
const { id: projectId } = await (0, gitlab_1.getProjectInfo)(instance);
|
|
2180
|
+
const deploy_tokens = await (0, gitlab_1.doGitlabRequest)(instance, `projects/${projectId}/deploy_tokens`);
|
|
2227
2181
|
if (!deploy_tokens.find((v) => v.name === "gitlab-deploy-token")) {
|
|
2228
|
-
|
|
2229
|
-
await (0, gitlab_1.doGitlabRequest)(
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
scopes: ["read_registry"],
|
|
2235
|
-
},
|
|
2236
|
-
method: "POST",
|
|
2237
|
-
host,
|
|
2238
|
-
token,
|
|
2239
|
-
});
|
|
2182
|
+
instance.log("I will setup the 'GitLab Deploy Token', so Kubernetes can pull images from this project.");
|
|
2183
|
+
await (0, gitlab_1.doGitlabRequest)(instance, `projects/${projectId}/deploy_tokens`, {
|
|
2184
|
+
id: projectId,
|
|
2185
|
+
name: "gitlab-deploy-token",
|
|
2186
|
+
scopes: ["read_registry"],
|
|
2187
|
+
}, "POST");
|
|
2240
2188
|
}
|
|
2241
2189
|
const fullName = (0, pipeline_1.getFullKubernetesClusterName)(deployConfig.cluster);
|
|
2242
|
-
|
|
2190
|
+
instance.log(`cluster: ${fullName}`);
|
|
2243
2191
|
await (0, cluster_1.connectToCluster)(fullName);
|
|
2244
|
-
|
|
2245
|
-
|
|
2192
|
+
instance.log("");
|
|
2193
|
+
instance.log("ensuring namespace ...");
|
|
2246
2194
|
const namespace = await (0, ensureNamespace_1.default)(context);
|
|
2247
|
-
|
|
2248
|
-
|
|
2195
|
+
instance.log("Namespace " + namespace + " created / updated!");
|
|
2196
|
+
instance.log("");
|
|
2249
2197
|
//$.verbose = true;
|
|
2250
2198
|
// we name the service account and the role and the role binding with the same name
|
|
2251
2199
|
// we currently create one per component to better separate them
|
|
2252
|
-
|
|
2200
|
+
instance.log("ensuring service accounts...");
|
|
2253
2201
|
const serviceAccountName = `cl-${context.name}-deploy`;
|
|
2254
2202
|
const KUBE_URL = await (0, child_process_promise_1.exec)(`TERM=dumb kubectl cluster-info | grep -E 'Kubernetes master|Kubernetes control plane' | awk '/http/ {print $NF}'`).then((s) => s.stdout.trim());
|
|
2255
2203
|
// first upsert service acount in the ns
|
|
@@ -2318,12 +2266,11 @@ EOF
|
|
|
2318
2266
|
fullName +
|
|
2319
2267
|
"'");
|
|
2320
2268
|
}
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
await (0, gitlab_1.upsertAllVariables)(
|
|
2325
|
-
|
|
2326
|
-
vorpal.log("done!");
|
|
2269
|
+
instance.log("service accounts created / updated!");
|
|
2270
|
+
instance.log("");
|
|
2271
|
+
instance.log("pusing secrets to gitlab...");
|
|
2272
|
+
await (0, gitlab_1.upsertAllVariables)(instance, vars, context.env, context.name, false);
|
|
2273
|
+
instance.log("done!");
|
|
2327
2274
|
};
|
|
2328
2275
|
exports.setupKubernetes = setupKubernetes;
|
|
2329
2276
|
//# sourceMappingURL=setupKubernetes.js.map
|
|
@@ -2337,13 +2284,12 @@ exports.setupKubernetes = setupKubernetes;
|
|
|
2337
2284
|
|
|
2338
2285
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2339
2286
|
exports.setupTopic = void 0;
|
|
2340
|
-
const gitlab_without_vorpal_1 = __nccwpck_require__(84346);
|
|
2341
2287
|
const gitlab_1 = __nccwpck_require__(12927);
|
|
2342
2288
|
const catladderTopic = "catladder";
|
|
2343
|
-
const setupTopic = async (
|
|
2344
|
-
const {
|
|
2345
|
-
const
|
|
2346
|
-
|
|
2289
|
+
const setupTopic = async (instance) => {
|
|
2290
|
+
const { id: projectId } = await (0, gitlab_1.getProjectInfo)(instance);
|
|
2291
|
+
const { topics } = await (0, gitlab_1.doGitlabRequest)(instance, `projects/${projectId}`);
|
|
2292
|
+
await (0, gitlab_1.doGitlabRequest)(instance, `projects/${projectId}`, { topics: [catladderTopic, ...topics] }, "PUT");
|
|
2347
2293
|
};
|
|
2348
2294
|
exports.setupTopic = setupTopic;
|
|
2349
2295
|
//# sourceMappingURL=setupTopic.js.map
|
|
@@ -2356,7 +2302,7 @@ exports.setupTopic = setupTopic;
|
|
|
2356
2302
|
"use strict";
|
|
2357
2303
|
|
|
2358
2304
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2359
|
-
exports.allEnvsAndAllComponents = exports.envAndComponents = exports.allEnvs = void 0;
|
|
2305
|
+
exports.allEnvsAndAllComponents = exports.envAndComponents = exports.allComponents = exports.allEnvs = void 0;
|
|
2360
2306
|
const pipeline_1 = __nccwpck_require__(10603);
|
|
2361
2307
|
const getProjectConfig_1 = __nccwpck_require__(12145);
|
|
2362
2308
|
const allEnvs = async () => {
|
|
@@ -2367,6 +2313,14 @@ const allEnvs = async () => {
|
|
|
2367
2313
|
return (0, pipeline_1.getAllEnvsInAllComponents)(config);
|
|
2368
2314
|
};
|
|
2369
2315
|
exports.allEnvs = allEnvs;
|
|
2316
|
+
const allComponents = async () => {
|
|
2317
|
+
const config = await (0, getProjectConfig_1.getProjectConfig)();
|
|
2318
|
+
if (!config) {
|
|
2319
|
+
return [];
|
|
2320
|
+
}
|
|
2321
|
+
return Object.keys(config.components);
|
|
2322
|
+
};
|
|
2323
|
+
exports.allComponents = allComponents;
|
|
2370
2324
|
const envAndComponents = async () => {
|
|
2371
2325
|
const allEnvAndcomponents = await (0, getProjectConfig_1.getAllComponentsWithAllEnvsFlat)();
|
|
2372
2326
|
return allEnvAndcomponents.reduce((acc, { env, componentName }) => [...acc, env + ":" + componentName], []);
|
|
@@ -2536,29 +2490,20 @@ exports["default"] = async (vorpal) => {
|
|
|
2536
2490
|
|
|
2537
2491
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2538
2492
|
exports.getGoogleAuthUserNumber = void 0;
|
|
2539
|
-
const
|
|
2540
|
-
const
|
|
2493
|
+
const preferences_1 = __nccwpck_require__(13511);
|
|
2494
|
+
const KEY = "googleAuthUserNumber";
|
|
2541
2495
|
const getGoogleAuthUserNumber = async function () {
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
default: "0",
|
|
2552
|
-
message: "Auth user ",
|
|
2553
|
-
});
|
|
2554
|
-
if (typeof googleAuthUserNumber === "number" ||
|
|
2555
|
-
(typeof googleAuthUserNumber === "string" &&
|
|
2556
|
-
googleAuthUserNumber.length > 0)) {
|
|
2557
|
-
await (0, preferences_1.upsertPreferences)({ googleAuthUserNumber }, this);
|
|
2558
|
-
return googleAuthUserNumber;
|
|
2496
|
+
if (!(await (0, preferences_1.hasPreference)(KEY))) {
|
|
2497
|
+
this.log("Please type in your google auth user number (0 if you have only one google account or maybe 1 if you have multiple)");
|
|
2498
|
+
const { authUserNumber } = await this.prompt({
|
|
2499
|
+
type: "number",
|
|
2500
|
+
name: "authUserNumber",
|
|
2501
|
+
default: "0",
|
|
2502
|
+
message: "Auth user ",
|
|
2503
|
+
});
|
|
2504
|
+
await (0, preferences_1.setPreference)(KEY, authUserNumber);
|
|
2559
2505
|
}
|
|
2560
|
-
(0,
|
|
2561
|
-
process.exit(1);
|
|
2506
|
+
return (0, preferences_1.getPreference)(KEY);
|
|
2562
2507
|
};
|
|
2563
2508
|
exports.getGoogleAuthUserNumber = getGoogleAuthUserNumber;
|
|
2564
2509
|
//# sourceMappingURL=getGoogleAuthUserNumber.js.map
|
|
@@ -2573,31 +2518,14 @@ exports.getGoogleAuthUserNumber = getGoogleAuthUserNumber;
|
|
|
2573
2518
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2574
2519
|
exports.verify = void 0;
|
|
2575
2520
|
const gitlab_1 = __nccwpck_require__(12927);
|
|
2576
|
-
const preferences_1 = __nccwpck_require__(62636);
|
|
2577
|
-
const git_1 = __nccwpck_require__(85096);
|
|
2578
2521
|
const verify = async (vorpal) => {
|
|
2579
|
-
var _a, _b;
|
|
2580
|
-
const [preferences, { gitRemoteHost }] = await Promise.all([
|
|
2581
|
-
(0, preferences_1.getPreferences)(vorpal),
|
|
2582
|
-
(0, git_1.getGitRemoteHostAndPath)(),
|
|
2583
|
-
]);
|
|
2584
2522
|
// check if has all settings
|
|
2585
|
-
if ((
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
await (0, preferences_1.upsertPreferences)({
|
|
2591
|
-
gitlabTokens: {
|
|
2592
|
-
[gitRemoteHost]: preferences["gitlab-personal-access-token"],
|
|
2593
|
-
},
|
|
2594
|
-
}, vorpal);
|
|
2595
|
-
return;
|
|
2523
|
+
if (!(await (0, gitlab_1.hasGitlabToken)())) {
|
|
2524
|
+
vorpal.command("setup-gitlab-token").action(async function () {
|
|
2525
|
+
await (0, gitlab_1.setupGitlabToken)(this);
|
|
2526
|
+
});
|
|
2527
|
+
vorpal.exec("setup-gitlab-token");
|
|
2596
2528
|
}
|
|
2597
|
-
vorpal.command("setup-gitlab-token").action(async function () {
|
|
2598
|
-
await (0, gitlab_1.setupGitlabToken)(this, gitRemoteHost);
|
|
2599
|
-
});
|
|
2600
|
-
vorpal.exec("setup-gitlab-token");
|
|
2601
2529
|
};
|
|
2602
2530
|
exports.verify = verify;
|
|
2603
2531
|
//# sourceMappingURL=index.js.map
|
|
@@ -2626,11 +2554,10 @@ const cli_1 = __importDefault(__nccwpck_require__(12200));
|
|
|
2626
2554
|
|
|
2627
2555
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2628
2556
|
exports.getJobOnlyEnvVarsResolved = exports.getEnvVarsResolved = exports.getGitlabVar = exports.getEnvironment = exports.getAllPipelineContexts = exports.getAllComponentsWithAllEnvsHierarchical = exports.getAllComponentsWithAllEnvsFlat = exports.getPipelineContextByChoice = exports.getProjectComponents = exports.getProjectConfig = exports.parseChoice = void 0;
|
|
2629
|
-
const fs_1 = __nccwpck_require__(57147);
|
|
2630
2557
|
const pipeline_1 = __nccwpck_require__(10603);
|
|
2631
2558
|
const gitlab_1 = __nccwpck_require__(12927);
|
|
2632
2559
|
const projects_1 = __nccwpck_require__(79011);
|
|
2633
|
-
const
|
|
2560
|
+
const fs_1 = __nccwpck_require__(57147);
|
|
2634
2561
|
var parseChoice_1 = __nccwpck_require__(83941);
|
|
2635
2562
|
Object.defineProperty(exports, "parseChoice", ({ enumerable: true, get: function () { return parseChoice_1.parseChoice; } }));
|
|
2636
2563
|
let currentConfig = null;
|
|
@@ -2695,9 +2622,15 @@ const getAllComponentsWithAllEnvsHierarchical = async () => {
|
|
|
2695
2622
|
]));
|
|
2696
2623
|
};
|
|
2697
2624
|
exports.getAllComponentsWithAllEnvsHierarchical = getAllComponentsWithAllEnvsHierarchical;
|
|
2698
|
-
const getAllPipelineContexts = async () => {
|
|
2625
|
+
const getAllPipelineContexts = async (onlyComponent) => {
|
|
2626
|
+
const onlyComponentsArray = onlyComponent
|
|
2627
|
+
? Array.isArray(onlyComponent)
|
|
2628
|
+
? onlyComponent
|
|
2629
|
+
: [onlyComponent]
|
|
2630
|
+
: null;
|
|
2699
2631
|
return Promise.all((await (0, exports.getAllComponentsWithAllEnvsFlat)())
|
|
2700
2632
|
.filter((c) => c.env !== "local")
|
|
2633
|
+
.filter((c) => !onlyComponentsArray || onlyComponentsArray.includes(c.componentName))
|
|
2701
2634
|
.map(({ env, componentName }) => (0, exports.getPipelineContextByChoice)(env, componentName)));
|
|
2702
2635
|
};
|
|
2703
2636
|
exports.getAllPipelineContexts = getAllPipelineContexts;
|
|
@@ -2711,15 +2644,8 @@ const getGitlabVar = async (vorpal, env, componentName, variableName) => {
|
|
|
2711
2644
|
return await (0, gitlab_1.getVariableValueByRawName)(vorpal, rawVariableName);
|
|
2712
2645
|
};
|
|
2713
2646
|
exports.getGitlabVar = getGitlabVar;
|
|
2714
|
-
const resolveSecrets = async (vorpal, varSets
|
|
2715
|
-
const
|
|
2716
|
-
const token = inputToken || (await (0, gitlab_1.getGitlabToken)(vorpal, host));
|
|
2717
|
-
const allVariablesInGitlab = await gitlab_without_vorpal_1.gitLabVariable.getAll({
|
|
2718
|
-
logger: vorpal,
|
|
2719
|
-
token,
|
|
2720
|
-
host,
|
|
2721
|
-
path,
|
|
2722
|
-
});
|
|
2647
|
+
const resolveSecrets = async (vorpal, varSets) => {
|
|
2648
|
+
const allVariablesInGitlab = await (0, gitlab_1.getAllVariables)(vorpal);
|
|
2723
2649
|
return Object.fromEntries(varSets.flatMap(({ envVars, secretEnvVarKeys }) => Object.entries(envVars)
|
|
2724
2650
|
.filter(([key, value]) => {
|
|
2725
2651
|
var _a;
|
|
@@ -3093,7 +3019,7 @@ exports.gitConfigSet = gitConfigSet;
|
|
|
3093
3019
|
"use strict";
|
|
3094
3020
|
|
|
3095
3021
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3096
|
-
exports.
|
|
3022
|
+
exports.gitProjectInformation = exports.getGitRemoteHostAndPath = exports.getProjectRootPath = void 0;
|
|
3097
3023
|
const gitConfig_1 = __nccwpck_require__(72745);
|
|
3098
3024
|
const child_process_promise_1 = __nccwpck_require__(75763);
|
|
3099
3025
|
/**
|
|
@@ -3107,11 +3033,8 @@ exports.getProjectRootPath = getProjectRootPath;
|
|
|
3107
3033
|
/**
|
|
3108
3034
|
* Get the git remote hostname and project path from the git config.
|
|
3109
3035
|
*/
|
|
3110
|
-
const getGitRemoteHostAndPath = async (
|
|
3036
|
+
const getGitRemoteHostAndPath = async () => {
|
|
3111
3037
|
var _a;
|
|
3112
|
-
if ((host === null || host === void 0 ? void 0 : host.length) && (path === null || path === void 0 ? void 0 : path.length)) {
|
|
3113
|
-
return { gitRemoteHost: host, gitRemotePath: path };
|
|
3114
|
-
}
|
|
3115
3038
|
const remoteUrl = await (0, gitConfig_1.gitConfigGet)("remote.origin.url");
|
|
3116
3039
|
const remoteReg = /(https:\/\/|git@)([^:/]+)[:/]([^.]*)(\.git)?/;
|
|
3117
3040
|
const match = (_a = remoteUrl.match(remoteReg)) !== null && _a !== void 0 ? _a : [];
|
|
@@ -3131,60 +3054,10 @@ const gitProjectInformation = async () => {
|
|
|
3131
3054
|
};
|
|
3132
3055
|
};
|
|
3133
3056
|
exports.gitProjectInformation = gitProjectInformation;
|
|
3134
|
-
/**
|
|
3135
|
-
* Get the git remote hostname.
|
|
3136
|
-
* Will only run a shell execution when hostnamePresent is nil or empty.
|
|
3137
|
-
*/
|
|
3138
|
-
const getGitRemoteHost = async (hostnamePresent) => {
|
|
3139
|
-
if (hostnamePresent === null || hostnamePresent === void 0 ? void 0 : hostnamePresent.length) {
|
|
3140
|
-
return hostnamePresent;
|
|
3141
|
-
}
|
|
3142
|
-
const { gitRemoteHost } = await (0, exports.getGitRemoteHostAndPath)();
|
|
3143
|
-
return gitRemoteHost;
|
|
3144
|
-
};
|
|
3145
|
-
exports.getGitRemoteHost = getGitRemoteHost;
|
|
3146
|
-
/**
|
|
3147
|
-
* Get the git remote path.
|
|
3148
|
-
* Will only run a shell execution when pathPresent is nil or empty.
|
|
3149
|
-
*/
|
|
3150
|
-
const getGitRemotePath = async (pathPresent) => {
|
|
3151
|
-
if (pathPresent === null || pathPresent === void 0 ? void 0 : pathPresent.length) {
|
|
3152
|
-
return pathPresent;
|
|
3153
|
-
}
|
|
3154
|
-
const { gitRemotePath } = await (0, exports.getGitRemoteHostAndPath)();
|
|
3155
|
-
return gitRemotePath;
|
|
3156
|
-
};
|
|
3157
|
-
exports.getGitRemotePath = getGitRemotePath;
|
|
3158
3057
|
//# sourceMappingURL=gitProjectInformation.js.map
|
|
3159
3058
|
|
|
3160
3059
|
/***/ }),
|
|
3161
3060
|
|
|
3162
|
-
/***/ 85096:
|
|
3163
|
-
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
3164
|
-
|
|
3165
|
-
"use strict";
|
|
3166
|
-
|
|
3167
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3168
|
-
if (k2 === undefined) k2 = k;
|
|
3169
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
3170
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
3171
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
3172
|
-
}
|
|
3173
|
-
Object.defineProperty(o, k2, desc);
|
|
3174
|
-
}) : (function(o, m, k, k2) {
|
|
3175
|
-
if (k2 === undefined) k2 = k;
|
|
3176
|
-
o[k2] = m[k];
|
|
3177
|
-
}));
|
|
3178
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
3179
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
3180
|
-
};
|
|
3181
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3182
|
-
__exportStar(__nccwpck_require__(72745), exports);
|
|
3183
|
-
__exportStar(__nccwpck_require__(78329), exports);
|
|
3184
|
-
//# sourceMappingURL=index.js.map
|
|
3185
|
-
|
|
3186
|
-
/***/ }),
|
|
3187
|
-
|
|
3188
3061
|
/***/ 79672:
|
|
3189
3062
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
3190
3063
|
|
|
@@ -3469,85 +3342,7 @@ exports["default"] = async () => {
|
|
|
3469
3342
|
|
|
3470
3343
|
/***/ }),
|
|
3471
3344
|
|
|
3472
|
-
/***/
|
|
3473
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
3474
|
-
|
|
3475
|
-
"use strict";
|
|
3476
|
-
|
|
3477
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3478
|
-
exports.FetchGitLabError = void 0;
|
|
3479
|
-
class FetchGitLabError extends Error {
|
|
3480
|
-
constructor(response, { resourcePath, data, method, cause, } = {}, extraMessage = "") {
|
|
3481
|
-
const status = response === null || response === void 0 ? void 0 : response.status;
|
|
3482
|
-
const statusMsg = status ? ` ${status}` : "";
|
|
3483
|
-
const methodPath = [method, resourcePath].filter(Boolean).join(" ");
|
|
3484
|
-
const customMsg = (extraMessage === null || extraMessage === void 0 ? void 0 : extraMessage.length) ? `: ${extraMessage}` : "";
|
|
3485
|
-
super(`GitLab API Error${statusMsg}${(methodPath === null || methodPath === void 0 ? void 0 : methodPath.length) ? ` ${methodPath}` : ""}${customMsg}`, {
|
|
3486
|
-
cause: Object.entries({ resourcePath, data, method, cause }).reduce((acc, [k, v]) => {
|
|
3487
|
-
if (v) {
|
|
3488
|
-
acc[k] = v;
|
|
3489
|
-
}
|
|
3490
|
-
return acc;
|
|
3491
|
-
}, {}),
|
|
3492
|
-
});
|
|
3493
|
-
this.response = response;
|
|
3494
|
-
this.name = "FetchGitLabError";
|
|
3495
|
-
this.cause = cause;
|
|
3496
|
-
this.resourcePath = resourcePath;
|
|
3497
|
-
this.data = data;
|
|
3498
|
-
this.method = method;
|
|
3499
|
-
if (response) {
|
|
3500
|
-
this.status = status;
|
|
3501
|
-
this.contentType = response.headers.get("content-type");
|
|
3502
|
-
this.statusText = response.statusText;
|
|
3503
|
-
}
|
|
3504
|
-
}
|
|
3505
|
-
}
|
|
3506
|
-
exports.FetchGitLabError = FetchGitLabError;
|
|
3507
|
-
//# sourceMappingURL=FetchGitLabError.js.map
|
|
3508
|
-
|
|
3509
|
-
/***/ }),
|
|
3510
|
-
|
|
3511
|
-
/***/ 64361:
|
|
3512
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
3513
|
-
|
|
3514
|
-
"use strict";
|
|
3515
|
-
|
|
3516
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3517
|
-
//# sourceMappingURL=FetchMethod.js.map
|
|
3518
|
-
|
|
3519
|
-
/***/ }),
|
|
3520
|
-
|
|
3521
|
-
/***/ 971:
|
|
3522
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
3523
|
-
|
|
3524
|
-
"use strict";
|
|
3525
|
-
|
|
3526
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3527
|
-
//# sourceMappingURL=GitLabApiDataOptional.js.map
|
|
3528
|
-
|
|
3529
|
-
/***/ }),
|
|
3530
|
-
|
|
3531
|
-
/***/ 47231:
|
|
3532
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
3533
|
-
|
|
3534
|
-
"use strict";
|
|
3535
|
-
|
|
3536
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3537
|
-
exports.GitLabTokenMissingError = void 0;
|
|
3538
|
-
class GitLabTokenMissingError extends Error {
|
|
3539
|
-
constructor(message = "", additional = {}) {
|
|
3540
|
-
const notice = `GitLab token is missing${(message === null || message === void 0 ? void 0 : message.length) ? `: ${message}` : ""}`;
|
|
3541
|
-
super(notice, additional);
|
|
3542
|
-
this.name = "GitLabTokenMissingError";
|
|
3543
|
-
}
|
|
3544
|
-
}
|
|
3545
|
-
exports.GitLabTokenMissingError = GitLabTokenMissingError;
|
|
3546
|
-
//# sourceMappingURL=GitLabTokenMissingError.js.map
|
|
3547
|
-
|
|
3548
|
-
/***/ }),
|
|
3549
|
-
|
|
3550
|
-
/***/ 48585:
|
|
3345
|
+
/***/ 12927:
|
|
3551
3346
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
3552
3347
|
|
|
3553
3348
|
"use strict";
|
|
@@ -3556,575 +3351,210 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3556
3351
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
3557
3352
|
};
|
|
3558
3353
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3559
|
-
exports.
|
|
3354
|
+
exports.upsertAllVariables = exports.clearBackups = exports.getVariableValueByRawName = exports.getAllVariables = exports.getProjectInfo = exports.doGitlabRequest = exports.getGitlabToken = exports.setupGitlabToken = exports.hasGitlabToken = void 0;
|
|
3355
|
+
const pipeline_1 = __nccwpck_require__(10603);
|
|
3356
|
+
const lodash_1 = __nccwpck_require__(23255);
|
|
3357
|
+
const memoizee_1 = __importDefault(__nccwpck_require__(85839));
|
|
3560
3358
|
const node_fetch_1 = __importDefault(__nccwpck_require__(26372));
|
|
3561
|
-
const
|
|
3562
|
-
const
|
|
3563
|
-
const
|
|
3564
|
-
const
|
|
3565
|
-
const
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3359
|
+
const open_1 = __importDefault(__nccwpck_require__(14247));
|
|
3360
|
+
const preferences_1 = __nccwpck_require__(13511);
|
|
3361
|
+
const gitProjectInformation_1 = __nccwpck_require__(78329);
|
|
3362
|
+
const TOKEN_KEY = "gitlab-personal-access-token";
|
|
3363
|
+
const hasGitlabToken = async () => await (0, preferences_1.hasPreference)(TOKEN_KEY);
|
|
3364
|
+
exports.hasGitlabToken = hasGitlabToken;
|
|
3365
|
+
const setupGitlabToken = async (vorpal) => {
|
|
3366
|
+
vorpal.log("");
|
|
3367
|
+
vorpal.log("☝ in order to access the api, we need a personal access token");
|
|
3368
|
+
vorpal.log("Its best to create one specifically for catladder");
|
|
3369
|
+
vorpal.log("Scopes needed: api");
|
|
3370
|
+
vorpal.log("");
|
|
3371
|
+
vorpal.log("☝ we open up the settings page for you!");
|
|
3372
|
+
vorpal.log("");
|
|
3373
|
+
const [{ shouldContinue }, { gitRemoteHost }] = await Promise.all([
|
|
3374
|
+
vorpal.prompt({
|
|
3375
|
+
default: true,
|
|
3376
|
+
message: "Ok",
|
|
3377
|
+
name: "shouldContinue",
|
|
3378
|
+
type: "prompt",
|
|
3379
|
+
}),
|
|
3380
|
+
(0, gitProjectInformation_1.getGitRemoteHostAndPath)(),
|
|
3381
|
+
]);
|
|
3382
|
+
(0, open_1.default)(`https://${gitRemoteHost}/-/user_settings/personal_access_tokens`);
|
|
3383
|
+
vorpal.log("Please type in gitlab's personal access token");
|
|
3384
|
+
const { personalToken } = await vorpal.prompt({
|
|
3385
|
+
type: "string",
|
|
3386
|
+
name: "personalToken",
|
|
3387
|
+
default: "",
|
|
3388
|
+
message: "Your personal access token ",
|
|
3389
|
+
});
|
|
3390
|
+
if (personalToken) {
|
|
3391
|
+
await (0, preferences_1.setPreference)(TOKEN_KEY, personalToken);
|
|
3591
3392
|
}
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3393
|
+
};
|
|
3394
|
+
exports.setupGitlabToken = setupGitlabToken;
|
|
3395
|
+
const getGitlabToken = async (vorpal) => {
|
|
3396
|
+
if (!(await (0, exports.hasGitlabToken)())) {
|
|
3397
|
+
if (!vorpal) {
|
|
3398
|
+
console.error("⚠️ gitlab token missing, please run catladder to set it up");
|
|
3399
|
+
process.exit(1);
|
|
3595
3400
|
}
|
|
3596
|
-
|
|
3401
|
+
await (0, exports.setupGitlabToken)(vorpal);
|
|
3597
3402
|
}
|
|
3403
|
+
return (0, preferences_1.getPreference)(TOKEN_KEY);
|
|
3598
3404
|
};
|
|
3599
|
-
exports.
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
/***/ 82250:
|
|
3605
|
-
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
3606
|
-
|
|
3607
|
-
"use strict";
|
|
3608
|
-
|
|
3609
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3610
|
-
exports.getGitLabHostPathToken = void 0;
|
|
3611
|
-
const loadGitLabToken_1 = __nccwpck_require__(32643);
|
|
3612
|
-
const git_1 = __nccwpck_require__(85096);
|
|
3613
|
-
/**
|
|
3614
|
-
* Lazy gather the GitLab api request data
|
|
3615
|
-
*/
|
|
3616
|
-
const getGitLabHostPathToken = async ({ token: inputToken, ...existing } = {}, logger = console) => {
|
|
3617
|
-
const { gitRemotePath: path, gitRemoteHost: host } = await (0, git_1.getGitRemoteHostAndPath)(existing);
|
|
3618
|
-
const token = inputToken || (await (0, loadGitLabToken_1.loadGitLabToken)(host, logger));
|
|
3619
|
-
return { host, path, token: token || undefined };
|
|
3620
|
-
};
|
|
3621
|
-
exports.getGitLabHostPathToken = getGitLabHostPathToken;
|
|
3622
|
-
//# sourceMappingURL=getGitlabHostPathToken.js.map
|
|
3623
|
-
|
|
3624
|
-
/***/ }),
|
|
3625
|
-
|
|
3626
|
-
/***/ 12113:
|
|
3627
|
-
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
3628
|
-
|
|
3629
|
-
"use strict";
|
|
3630
|
-
|
|
3631
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3632
|
-
exports.getGitLabProjectId = exports.gitLabProjectByGitPath = void 0;
|
|
3633
|
-
const preferences_1 = __nccwpck_require__(62636);
|
|
3634
|
-
const fetchGitLabApi_1 = __nccwpck_require__(48585);
|
|
3635
|
-
const getGitlabHostPathToken_1 = __nccwpck_require__(82250);
|
|
3636
|
-
const gitLabProjectByGitPath = async (existing = {}, logger = console) => {
|
|
3637
|
-
const { host, path, token } = await (0, getGitlabHostPathToken_1.getGitLabHostPathToken)(existing, logger);
|
|
3638
|
-
return (0, fetchGitLabApi_1.fetchGitLabApi)({
|
|
3639
|
-
resourcePath: `projects/${encodeURIComponent(path)}`,
|
|
3640
|
-
host,
|
|
3641
|
-
token,
|
|
3642
|
-
}, logger);
|
|
3643
|
-
};
|
|
3644
|
-
exports.gitLabProjectByGitPath = gitLabProjectByGitPath;
|
|
3645
|
-
const getGitLabProjectId = async (existing = {}, logger = console) => {
|
|
3646
|
-
const [preferences, { host, path, token }] = await Promise.all([
|
|
3647
|
-
(0, preferences_1.getPreferences)(logger),
|
|
3648
|
-
(0, getGitlabHostPathToken_1.getGitLabHostPathToken)(existing, logger),
|
|
3405
|
+
exports.getGitlabToken = getGitlabToken;
|
|
3406
|
+
const doGitlabRequest = async (vorpal, path, data = undefined, method = "GET") => {
|
|
3407
|
+
const [rootToken, { gitRemoteHost }] = await Promise.all([
|
|
3408
|
+
(0, exports.getGitlabToken)(vorpal),
|
|
3409
|
+
(0, gitProjectInformation_1.getGitRemoteHostAndPath)(),
|
|
3649
3410
|
]);
|
|
3650
|
-
const
|
|
3651
|
-
|
|
3652
|
-
|
|
3411
|
+
//const method = data ? (update ? "PUT" : "POST") : "GET";
|
|
3412
|
+
const result = await (0, node_fetch_1.default)(`https://${gitRemoteHost}/api/v4/${path}`, {
|
|
3413
|
+
method,
|
|
3414
|
+
headers: {
|
|
3415
|
+
"Content-Type": "application/json",
|
|
3416
|
+
"Private-Token": rootToken,
|
|
3417
|
+
},
|
|
3418
|
+
body: data ? JSON.stringify(data) : undefined,
|
|
3419
|
+
});
|
|
3420
|
+
if (result.status >= 200 && result.status < 400) {
|
|
3421
|
+
if (result.headers.get("content-type") === "application/json") {
|
|
3422
|
+
return result.json();
|
|
3423
|
+
}
|
|
3424
|
+
return null;
|
|
3653
3425
|
}
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
};
|
|
3658
|
-
exports.getGitLabProjectId = getGitLabProjectId;
|
|
3659
|
-
//# sourceMappingURL=gitLabProjectByGitPath.js.map
|
|
3660
|
-
|
|
3661
|
-
/***/ }),
|
|
3662
|
-
|
|
3663
|
-
/***/ 55854:
|
|
3664
|
-
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
3665
|
-
|
|
3666
|
-
"use strict";
|
|
3667
|
-
|
|
3668
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3669
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
3426
|
+
if (result.status === 404) {
|
|
3427
|
+
throw new Error("not found");
|
|
3428
|
+
}
|
|
3429
|
+
throw new Error(`Could not send request to gitlab api ${path}: ${result.status} "${result.statusText}".\nResponse: ${JSON.stringify(await result.json(), null, 2)}`);
|
|
3670
3430
|
};
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
const
|
|
3674
|
-
const
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
* @see {@link https://gitlab.com/gitlab-org/gitlab-foss/-/blob/master/spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js#L20}
|
|
3681
|
-
*/
|
|
3682
|
-
const maskableRegex = new RegExp("^[a-zA-Z0-9_+=/@:.~-]{8,}$");
|
|
3683
|
-
/**
|
|
3684
|
-
* @see {@link https://gitlab.com/gitlab-org/gitlab-foss/-/blob/master/spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js#L20}
|
|
3685
|
-
*/
|
|
3686
|
-
const isMaskable = (value) => maskableRegex.test(value);
|
|
3687
|
-
const getGitLabVariable = async ({ projectId, key, host, token, }, logger = console) => (0, fetchGitLabApi_1.fetchGitLabApi)({
|
|
3688
|
-
resourcePath: `projects/${projectId}/variables/${key}`,
|
|
3689
|
-
host,
|
|
3690
|
-
token,
|
|
3691
|
-
}, logger);
|
|
3692
|
-
const createGitLabVariable = async ({ projectId, key, value, masked = true, scope = "*", host, token, }, logger = console) => (0, fetchGitLabApi_1.fetchGitLabApi)({
|
|
3693
|
-
resourcePath: `projects/${projectId}/variables`,
|
|
3694
|
-
method: "POST",
|
|
3695
|
-
data: {
|
|
3696
|
-
key,
|
|
3697
|
-
value,
|
|
3698
|
-
masked: masked && isMaskable(value),
|
|
3699
|
-
environment_scope: scope,
|
|
3700
|
-
},
|
|
3701
|
-
host,
|
|
3702
|
-
token,
|
|
3703
|
-
}, logger);
|
|
3704
|
-
const updateGitLabVariable = async ({ projectId, key, value, masked = true, host, token, }, logger = console) => (0, fetchGitLabApi_1.fetchGitLabApi)({
|
|
3705
|
-
resourcePath: `projects/${projectId}/variables/${key}`,
|
|
3706
|
-
method: "PUT",
|
|
3707
|
-
data: {
|
|
3708
|
-
value,
|
|
3709
|
-
masked: masked && isMaskable(value),
|
|
3710
|
-
},
|
|
3711
|
-
host,
|
|
3712
|
-
token,
|
|
3713
|
-
}, logger);
|
|
3714
|
-
const deleteGitLabVariable = async ({ projectId, key, host, token, }, logger = console) => (0, fetchGitLabApi_1.fetchGitLabApi)({
|
|
3715
|
-
resourcePath: `projects/${projectId}/variables/${key}`,
|
|
3716
|
-
method: "DELETE",
|
|
3717
|
-
host,
|
|
3718
|
-
token,
|
|
3719
|
-
}, logger);
|
|
3720
|
-
const getGitlabVariablesPage = async ({ projectId, page = 1, perPage = 100, host, token, }, logger = console) => (0, fetchGitLabApi_1.fetchGitLabApi)({
|
|
3721
|
-
resourcePath: `projects/${projectId}/variables?per_page=${perPage}&page=${page}`,
|
|
3722
|
-
host,
|
|
3723
|
-
token,
|
|
3724
|
-
}, logger);
|
|
3725
|
-
const getAllVariables = (0, memoizee_1.default)(async ({ logger = console, parallelRequests = 5, projectId, ...existing } = {}) => {
|
|
3726
|
-
const { host, path, token } = await (0, getGitlabHostPathToken_1.getGitLabHostPathToken)(existing, logger);
|
|
3727
|
-
if (!(token === null || token === void 0 ? void 0 : token.length)) {
|
|
3728
|
-
throw new GitLabTokenMissingError_1.GitLabTokenMissingError();
|
|
3729
|
-
}
|
|
3730
|
-
const id = projectId || (await (0, gitLabProjectByGitPath_1.getGitLabProjectId)({ host, path, token }, logger));
|
|
3431
|
+
exports.doGitlabRequest = doGitlabRequest;
|
|
3432
|
+
const getProjectInfo = async (vorpal) => {
|
|
3433
|
+
const { gitRemotePath } = await (0, gitProjectInformation_1.getGitRemoteHostAndPath)();
|
|
3434
|
+
const project = await (0, exports.doGitlabRequest)(vorpal, `projects/${encodeURIComponent(gitRemotePath)}`);
|
|
3435
|
+
return project;
|
|
3436
|
+
};
|
|
3437
|
+
exports.getProjectInfo = getProjectInfo;
|
|
3438
|
+
exports.getAllVariables = (0, memoizee_1.default)(async (vorpal, n = 5) => {
|
|
3439
|
+
const { id } = await (0, exports.getProjectInfo)(vorpal);
|
|
3731
3440
|
let all = [];
|
|
3732
3441
|
let result = [];
|
|
3733
3442
|
let page = 1;
|
|
3734
3443
|
do {
|
|
3735
|
-
// Create an array of promises for
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3444
|
+
// Create an array of promises for N pages
|
|
3445
|
+
const promises = Array.from({ length: n }, (_, i) => {
|
|
3446
|
+
return (0, exports.doGitlabRequest)(vorpal, `projects/${id}/variables?per_page=100&page=${page + i}`);
|
|
3447
|
+
});
|
|
3448
|
+
// Wait for all promises to resolve
|
|
3449
|
+
result = await Promise.all(promises);
|
|
3450
|
+
// Increment the page by N
|
|
3451
|
+
page += n;
|
|
3739
3452
|
// Flatten the result array and add it to 'all'
|
|
3740
|
-
all = all
|
|
3453
|
+
all = [...all, ...result.flat()];
|
|
3741
3454
|
// Continue only if the last page had results
|
|
3742
|
-
} while (result.length > 0 && result.
|
|
3455
|
+
} while (result.length > 0 && result[result.length - 1].length > 0);
|
|
3743
3456
|
return all;
|
|
3744
3457
|
}, { promise: true });
|
|
3745
|
-
const
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3458
|
+
const getVariableValueByRawName = async (vorpal, rawName) => {
|
|
3459
|
+
var _a;
|
|
3460
|
+
const allVariables = await (0, exports.getAllVariables)(vorpal);
|
|
3461
|
+
return (_a = allVariables.find((v) => v.key === rawName)) === null || _a === void 0 ? void 0 : _a.value;
|
|
3462
|
+
};
|
|
3463
|
+
exports.getVariableValueByRawName = getVariableValueByRawName;
|
|
3464
|
+
const maskableRegex = new RegExp("^[a-zA-Z0-9_+=/@:.~-]{8,}$"); // SEE https://gitlab.com/gitlab-org/gitlab-foss/-/blob/master/spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js#L20
|
|
3465
|
+
const isMaskable = (value) => maskableRegex.test(value);
|
|
3466
|
+
const createVariable = async (vorpal, projectId, key, value, masked = true, environment_scope = "*") => {
|
|
3467
|
+
return await (0, exports.doGitlabRequest)(vorpal, `projects/${projectId}/variables`, {
|
|
3468
|
+
key,
|
|
3469
|
+
value,
|
|
3470
|
+
masked: masked && isMaskable(value),
|
|
3471
|
+
environment_scope,
|
|
3472
|
+
}, "POST");
|
|
3473
|
+
};
|
|
3474
|
+
const updateVariable = async (vorpal, projectId, key, value, masked = true) => {
|
|
3475
|
+
return await (0, exports.doGitlabRequest)(vorpal, `projects/${projectId}/variables/${key}`, {
|
|
3476
|
+
value,
|
|
3477
|
+
masked: masked && isMaskable(value),
|
|
3478
|
+
}, "PUT");
|
|
3479
|
+
};
|
|
3480
|
+
const deleteVariable = async (vorpal, projectId, key) => {
|
|
3481
|
+
return await (0, exports.doGitlabRequest)(vorpal, `projects/${projectId}/variables/${key}`, undefined, "DELETE");
|
|
3482
|
+
};
|
|
3483
|
+
const getAllCatladderEnvVarsInGitlab = async (vorpal) => {
|
|
3484
|
+
const allVariables = await (0, exports.getAllVariables)(vorpal).then((v) => v.reduce((acc, variable) => {
|
|
3760
3485
|
var _a, _b, _c, _d;
|
|
3761
|
-
const
|
|
3762
|
-
if (
|
|
3763
|
-
const
|
|
3764
|
-
|
|
3765
|
-
|
|
3486
|
+
const { key } = variable;
|
|
3487
|
+
if (key.startsWith("CL_")) {
|
|
3488
|
+
const matchBackup = key.match(/(CL_.*)_backup_([0-9]+)/);
|
|
3489
|
+
if (matchBackup) {
|
|
3490
|
+
const key = matchBackup[1];
|
|
3491
|
+
const timestamp = Number(matchBackup[2]);
|
|
3492
|
+
const backups = [...((_b = (_a = acc[key]) === null || _a === void 0 ? void 0 : _a.backups) !== null && _b !== void 0 ? _b : []), timestamp];
|
|
3493
|
+
return {
|
|
3494
|
+
...acc,
|
|
3495
|
+
[key]: {
|
|
3496
|
+
...((_c = acc[key]) !== null && _c !== void 0 ? _c : {}), // add value
|
|
3497
|
+
backups,
|
|
3498
|
+
},
|
|
3499
|
+
};
|
|
3500
|
+
}
|
|
3766
3501
|
return {
|
|
3767
3502
|
...acc,
|
|
3768
3503
|
[key]: {
|
|
3769
|
-
|
|
3770
|
-
backups
|
|
3504
|
+
backups: [],
|
|
3505
|
+
...((_d = acc[key]) !== null && _d !== void 0 ? _d : {}), // may add backups
|
|
3506
|
+
value: variable.value,
|
|
3771
3507
|
},
|
|
3772
3508
|
};
|
|
3773
3509
|
}
|
|
3774
|
-
return
|
|
3775
|
-
|
|
3776
|
-
[key]: {
|
|
3777
|
-
backups: [],
|
|
3778
|
-
...((_d = acc[key]) !== null && _d !== void 0 ? _d : {}), // may add backups
|
|
3779
|
-
value,
|
|
3780
|
-
...rest,
|
|
3781
|
-
},
|
|
3782
|
-
};
|
|
3783
|
-
}, {});
|
|
3510
|
+
return acc;
|
|
3511
|
+
}, {}));
|
|
3784
3512
|
return allVariables;
|
|
3785
3513
|
};
|
|
3786
|
-
exports.gitLabVariable = {
|
|
3787
|
-
get: getGitLabVariable,
|
|
3788
|
-
create: createGitLabVariable,
|
|
3789
|
-
update: updateGitLabVariable,
|
|
3790
|
-
delete: deleteGitLabVariable,
|
|
3791
|
-
getPage: getGitlabVariablesPage,
|
|
3792
|
-
getAll: getAllVariables,
|
|
3793
|
-
getAllCatladder: getAllCatladderEnvVars,
|
|
3794
|
-
};
|
|
3795
|
-
//# sourceMappingURL=gitLabVariables.js.map
|
|
3796
|
-
|
|
3797
|
-
/***/ }),
|
|
3798
|
-
|
|
3799
|
-
/***/ 84346:
|
|
3800
|
-
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
3801
|
-
|
|
3802
|
-
"use strict";
|
|
3803
|
-
|
|
3804
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3805
|
-
if (k2 === undefined) k2 = k;
|
|
3806
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
3807
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
3808
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
3809
|
-
}
|
|
3810
|
-
Object.defineProperty(o, k2, desc);
|
|
3811
|
-
}) : (function(o, m, k, k2) {
|
|
3812
|
-
if (k2 === undefined) k2 = k;
|
|
3813
|
-
o[k2] = m[k];
|
|
3814
|
-
}));
|
|
3815
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
3816
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
3817
|
-
};
|
|
3818
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3819
|
-
__exportStar(__nccwpck_require__(35438), exports);
|
|
3820
|
-
__exportStar(__nccwpck_require__(64361), exports);
|
|
3821
|
-
__exportStar(__nccwpck_require__(971), exports);
|
|
3822
|
-
__exportStar(__nccwpck_require__(47231), exports);
|
|
3823
|
-
__exportStar(__nccwpck_require__(48585), exports);
|
|
3824
|
-
__exportStar(__nccwpck_require__(82250), exports);
|
|
3825
|
-
__exportStar(__nccwpck_require__(12113), exports);
|
|
3826
|
-
__exportStar(__nccwpck_require__(55854), exports);
|
|
3827
|
-
__exportStar(__nccwpck_require__(53699), exports);
|
|
3828
|
-
__exportStar(__nccwpck_require__(32643), exports);
|
|
3829
|
-
__exportStar(__nccwpck_require__(5638), exports);
|
|
3830
|
-
__exportStar(__nccwpck_require__(11166), exports);
|
|
3831
|
-
//# sourceMappingURL=index.js.map
|
|
3832
|
-
|
|
3833
|
-
/***/ }),
|
|
3834
|
-
|
|
3835
|
-
/***/ 53699:
|
|
3836
|
-
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
3837
|
-
|
|
3838
|
-
"use strict";
|
|
3839
|
-
|
|
3840
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3841
|
-
exports.insertProjectTopics = void 0;
|
|
3842
|
-
const fetchGitLabApi_1 = __nccwpck_require__(48585);
|
|
3843
|
-
const getGitlabHostPathToken_1 = __nccwpck_require__(82250);
|
|
3844
|
-
const gitLabProjectByGitPath_1 = __nccwpck_require__(12113);
|
|
3845
|
-
const GitLabTokenMissingError_1 = __nccwpck_require__(47231);
|
|
3846
|
-
const insertProjectTopics = async ({ topics: insertTopics, ...existing }, logger = console) => {
|
|
3847
|
-
const { host, path, token } = await (0, getGitlabHostPathToken_1.getGitLabHostPathToken)(existing, logger);
|
|
3848
|
-
if (!(token === null || token === void 0 ? void 0 : token.length)) {
|
|
3849
|
-
throw new GitLabTokenMissingError_1.GitLabTokenMissingError();
|
|
3850
|
-
}
|
|
3851
|
-
const { id, topics } = await (0, gitLabProjectByGitPath_1.gitLabProjectByGitPath)({ path, host, token }, logger);
|
|
3852
|
-
await (0, fetchGitLabApi_1.fetchGitLabApi)({
|
|
3853
|
-
resourcePath: `projects/${id}`,
|
|
3854
|
-
data: { topics: [...insertTopics, ...topics] },
|
|
3855
|
-
method: "PUT",
|
|
3856
|
-
host,
|
|
3857
|
-
token,
|
|
3858
|
-
}, logger);
|
|
3859
|
-
};
|
|
3860
|
-
exports.insertProjectTopics = insertProjectTopics;
|
|
3861
|
-
//# sourceMappingURL=insertProjectTopics.js.map
|
|
3862
|
-
|
|
3863
|
-
/***/ }),
|
|
3864
|
-
|
|
3865
|
-
/***/ 32643:
|
|
3866
|
-
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
3867
|
-
|
|
3868
|
-
"use strict";
|
|
3869
|
-
|
|
3870
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3871
|
-
exports.loadGitLabToken = void 0;
|
|
3872
|
-
const GitLabTokenMissingError_1 = __nccwpck_require__(47231);
|
|
3873
|
-
const storeGitLabToken_1 = __nccwpck_require__(11166);
|
|
3874
|
-
const preferences_1 = __nccwpck_require__(62636);
|
|
3875
|
-
const git_1 = __nccwpck_require__(85096);
|
|
3876
|
-
const loadGitLabToken = async (gitlabHost, logger = console) => {
|
|
3877
|
-
var _a, _b;
|
|
3878
|
-
const [preferences, host] = await Promise.all([
|
|
3879
|
-
(0, preferences_1.getPreferences)(logger),
|
|
3880
|
-
(0, git_1.getGitRemoteHost)(gitlabHost),
|
|
3881
|
-
]);
|
|
3882
|
-
if ((_a = preferences.gitlabTokens[host]) === null || _a === void 0 ? void 0 : _a.length) {
|
|
3883
|
-
return preferences.gitlabTokens[host];
|
|
3884
|
-
}
|
|
3885
|
-
if ((_b = preferences["gitlab-personal-access-token"]) === null || _b === void 0 ? void 0 : _b.length) {
|
|
3886
|
-
// Add the token to the hostname based preferences
|
|
3887
|
-
return (0, storeGitLabToken_1.storeGitLabToken)({
|
|
3888
|
-
token: preferences["gitlab-personal-access-token"],
|
|
3889
|
-
host,
|
|
3890
|
-
}, logger);
|
|
3891
|
-
}
|
|
3892
|
-
throw new GitLabTokenMissingError_1.GitLabTokenMissingError();
|
|
3893
|
-
};
|
|
3894
|
-
exports.loadGitLabToken = loadGitLabToken;
|
|
3895
|
-
//# sourceMappingURL=loadGitLabToken.js.map
|
|
3896
|
-
|
|
3897
|
-
/***/ }),
|
|
3898
|
-
|
|
3899
|
-
/***/ 5638:
|
|
3900
|
-
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
3901
|
-
|
|
3902
|
-
"use strict";
|
|
3903
|
-
|
|
3904
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3905
|
-
exports.gitLabProjectAccessToken = void 0;
|
|
3906
|
-
const date_fns_1 = __nccwpck_require__(44438);
|
|
3907
|
-
const fetchGitLabApi_1 = __nccwpck_require__(48585);
|
|
3908
|
-
const getProjectAccessTokens = async ({ projectId, path, ...existing }, logger = console) => (0, fetchGitLabApi_1.fetchGitLabApi)({ resourcePath: `projects/${projectId}/access_tokens`, ...existing }, logger);
|
|
3909
|
-
const rotate = async ({ projectId, tokenId, data: { expires_at }, path, ...existing }, logger = console) => (0, fetchGitLabApi_1.fetchGitLabApi)({
|
|
3910
|
-
resourcePath: `projects/${projectId}/access_tokens/${tokenId}/rotate`,
|
|
3911
|
-
data: { expires_at: (0, date_fns_1.format)(expires_at, "yyyy-MM-dd") },
|
|
3912
|
-
method: "POST",
|
|
3913
|
-
...existing,
|
|
3914
|
-
}, logger);
|
|
3915
|
-
const create = async ({ projectId, path, data: { expires_at, ...data }, ...existing }, logger = console) => (0, fetchGitLabApi_1.fetchGitLabApi)({
|
|
3916
|
-
resourcePath: `projects/${projectId}/access_tokens`,
|
|
3917
|
-
data: { expires_at: (0, date_fns_1.format)(expires_at, "yyyy-MM-dd"), ...data },
|
|
3918
|
-
method: "POST",
|
|
3919
|
-
...existing,
|
|
3920
|
-
}, logger);
|
|
3921
|
-
exports.gitLabProjectAccessToken = {
|
|
3922
|
-
getList: getProjectAccessTokens,
|
|
3923
|
-
rotate,
|
|
3924
|
-
create,
|
|
3925
|
-
};
|
|
3926
|
-
//# sourceMappingURL=projectAccessToken.js.map
|
|
3927
|
-
|
|
3928
|
-
/***/ }),
|
|
3929
|
-
|
|
3930
|
-
/***/ 11166:
|
|
3931
|
-
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
3932
|
-
|
|
3933
|
-
"use strict";
|
|
3934
|
-
|
|
3935
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3936
|
-
exports.storeGitLabToken = void 0;
|
|
3937
|
-
const preferences_1 = __nccwpck_require__(62636);
|
|
3938
|
-
const GitLabTokenMissingError_1 = __nccwpck_require__(47231);
|
|
3939
|
-
const git_1 = __nccwpck_require__(85096);
|
|
3940
|
-
const storeGitLabToken = async ({ token, host }, logger = console) => {
|
|
3941
|
-
if (typeof token !== "string" || !token.length) {
|
|
3942
|
-
throw new GitLabTokenMissingError_1.GitLabTokenMissingError();
|
|
3943
|
-
}
|
|
3944
|
-
const gitRemoteHost = await (0, git_1.getGitRemoteHost)(host);
|
|
3945
|
-
await (0, preferences_1.upsertPreferences)({
|
|
3946
|
-
"gitlab-personal-access-token": token,
|
|
3947
|
-
gitlabTokens: { [gitRemoteHost]: token },
|
|
3948
|
-
}, logger);
|
|
3949
|
-
return token;
|
|
3950
|
-
};
|
|
3951
|
-
exports.storeGitLabToken = storeGitLabToken;
|
|
3952
|
-
//# sourceMappingURL=storeGitLabToken.js.map
|
|
3953
|
-
|
|
3954
|
-
/***/ }),
|
|
3955
|
-
|
|
3956
|
-
/***/ 12927:
|
|
3957
|
-
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
3958
|
-
|
|
3959
|
-
"use strict";
|
|
3960
|
-
|
|
3961
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3962
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
3963
|
-
};
|
|
3964
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3965
|
-
exports.upsertAllVariables = exports.clearBackups = exports.getVariableValueByRawName = exports.doGitlabRequest = exports.getGitlabToken = exports.setupGitlabToken = void 0;
|
|
3966
|
-
const lodash_1 = __nccwpck_require__(23255);
|
|
3967
|
-
const open_1 = __importDefault(__nccwpck_require__(14247));
|
|
3968
|
-
const pipeline_1 = __nccwpck_require__(10603);
|
|
3969
|
-
const gitProjectInformation_1 = __nccwpck_require__(78329);
|
|
3970
|
-
const log_1 = __nccwpck_require__(66921);
|
|
3971
|
-
const gitlab_without_vorpal_1 = __nccwpck_require__(84346);
|
|
3972
|
-
const setupGitlabToken = async (vorpal, host) => {
|
|
3973
|
-
(0, log_1.logNotice)(vorpal, "In order to access the API, you need your personal access token.", "It's best to create a specific token for CatLadder.");
|
|
3974
|
-
const gitRemoteHost = await (0, gitProjectInformation_1.getGitRemoteHost)(host);
|
|
3975
|
-
const accessTokenSettingsUrl = `https://${gitRemoteHost}/-/user_settings/personal_access_tokens`;
|
|
3976
|
-
(0, log_1.logNotice)(vorpal, "We'll open up the GitLab settings page in your browser for you!", accessTokenSettingsUrl);
|
|
3977
|
-
const { shouldContinue } = await vorpal.prompt({
|
|
3978
|
-
default: true,
|
|
3979
|
-
message: "Ok",
|
|
3980
|
-
name: "shouldContinue",
|
|
3981
|
-
type: "prompt",
|
|
3982
|
-
});
|
|
3983
|
-
(0, open_1.default)(accessTokenSettingsUrl);
|
|
3984
|
-
(0, log_1.logLines)(vorpal, "Please enter GitLab's personal access token.");
|
|
3985
|
-
const { personalToken: token } = await vorpal.prompt({
|
|
3986
|
-
type: "string",
|
|
3987
|
-
name: "personalToken",
|
|
3988
|
-
default: "",
|
|
3989
|
-
message: "Your personal access token ",
|
|
3990
|
-
});
|
|
3991
|
-
try {
|
|
3992
|
-
return (0, gitlab_without_vorpal_1.storeGitLabToken)({ token, host }, vorpal);
|
|
3993
|
-
}
|
|
3994
|
-
catch (error) {
|
|
3995
|
-
if (error instanceof gitlab_without_vorpal_1.GitLabTokenMissingError) {
|
|
3996
|
-
(0, log_1.logError)(vorpal, "Token missing", "Please run catladder again");
|
|
3997
|
-
process.exit(1);
|
|
3998
|
-
}
|
|
3999
|
-
else {
|
|
4000
|
-
throw error;
|
|
4001
|
-
}
|
|
4002
|
-
}
|
|
4003
|
-
};
|
|
4004
|
-
exports.setupGitlabToken = setupGitlabToken;
|
|
4005
|
-
const getGitlabToken = async (vorpal, host) => {
|
|
4006
|
-
const gitRemoteHost = await (0, gitProjectInformation_1.getGitRemoteHost)(host);
|
|
4007
|
-
try {
|
|
4008
|
-
return (0, gitlab_without_vorpal_1.loadGitLabToken)(gitRemoteHost, vorpal);
|
|
4009
|
-
}
|
|
4010
|
-
catch (error) {
|
|
4011
|
-
if (!(error instanceof gitlab_without_vorpal_1.GitLabTokenMissingError))
|
|
4012
|
-
throw error;
|
|
4013
|
-
if (vorpal) {
|
|
4014
|
-
return (0, exports.setupGitlabToken)(vorpal, gitRemoteHost);
|
|
4015
|
-
}
|
|
4016
|
-
(0, log_1.logError)(console, "GitLab token missing!", "Please run catladder to set it up");
|
|
4017
|
-
process.exit(1);
|
|
4018
|
-
}
|
|
4019
|
-
};
|
|
4020
|
-
exports.getGitlabToken = getGitlabToken;
|
|
4021
|
-
const doGitlabRequest = async (vorpal, { path: resourcePath, ...args }) => (0, gitlab_without_vorpal_1.fetchGitLabApi)({ resourcePath, ...args }, vorpal);
|
|
4022
|
-
exports.doGitlabRequest = doGitlabRequest;
|
|
4023
|
-
const getVariableValueByRawName = async (vorpal, rawName, { projectId, ...existing } = {}) => {
|
|
4024
|
-
var _a;
|
|
4025
|
-
const { host, path, token: inputToken, } = await (0, gitlab_without_vorpal_1.getGitLabHostPathToken)(existing, vorpal);
|
|
4026
|
-
const token = inputToken || (await (0, exports.getGitlabToken)(vorpal, host));
|
|
4027
|
-
const id = projectId || (await (0, gitlab_without_vorpal_1.getGitLabProjectId)({ host, path, token }, vorpal));
|
|
4028
|
-
const allVariables = await gitlab_without_vorpal_1.gitLabVariable.getAll({
|
|
4029
|
-
logger: vorpal,
|
|
4030
|
-
host,
|
|
4031
|
-
path,
|
|
4032
|
-
token,
|
|
4033
|
-
projectId: id,
|
|
4034
|
-
});
|
|
4035
|
-
return (_a = allVariables.find((v) => v.key === rawName)) === null || _a === void 0 ? void 0 : _a.value;
|
|
4036
|
-
};
|
|
4037
|
-
exports.getVariableValueByRawName = getVariableValueByRawName;
|
|
4038
|
-
const getAllCatladderEnvVarsInGitlab = async (vorpal, { projectId, ...existing } = {}) => {
|
|
4039
|
-
const { host, path, token: inputToken, } = await (0, gitlab_without_vorpal_1.getGitLabHostPathToken)(existing, vorpal);
|
|
4040
|
-
const token = inputToken || (await (0, exports.getGitlabToken)(vorpal, host));
|
|
4041
|
-
const id = projectId || (await (0, gitlab_without_vorpal_1.getGitLabProjectId)({ host, path, token }, vorpal));
|
|
4042
|
-
return gitlab_without_vorpal_1.gitLabVariable.getAllCatladder({
|
|
4043
|
-
logger: vorpal,
|
|
4044
|
-
host,
|
|
4045
|
-
path,
|
|
4046
|
-
token,
|
|
4047
|
-
projectId: id,
|
|
4048
|
-
});
|
|
4049
|
-
};
|
|
4050
3514
|
const getBackupKey = (fullKey, timestamp) => `${fullKey}_backup_${timestamp}`;
|
|
4051
|
-
const clearBackups = async (vorpal, keep
|
|
4052
|
-
const
|
|
4053
|
-
const
|
|
4054
|
-
const id = await (0, gitlab_without_vorpal_1.getGitLabProjectId)({ host, path, token }, vorpal);
|
|
4055
|
-
const existingVariables = await getAllCatladderEnvVarsInGitlab(vorpal, {
|
|
4056
|
-
projectId: id,
|
|
4057
|
-
host,
|
|
4058
|
-
path,
|
|
4059
|
-
token,
|
|
4060
|
-
});
|
|
3515
|
+
const clearBackups = async (vorpal, keep) => {
|
|
3516
|
+
const existingVariables = await getAllCatladderEnvVarsInGitlab(vorpal);
|
|
3517
|
+
const { id } = await (0, exports.getProjectInfo)(vorpal);
|
|
4061
3518
|
for (const [key, { backups }] of Object.entries(existingVariables)) {
|
|
4062
3519
|
const backupsSorted = backups.sort((a, b) => b - a);
|
|
4063
3520
|
//const toKeep = backupsSorted.slice(0, keep);
|
|
4064
3521
|
const toDelete = backupsSorted.slice(keep);
|
|
4065
3522
|
for (const timestamp of toDelete) {
|
|
4066
|
-
await
|
|
3523
|
+
await deleteVariable(vorpal, id, getBackupKey(key, timestamp));
|
|
4067
3524
|
}
|
|
4068
3525
|
}
|
|
4069
3526
|
};
|
|
4070
3527
|
exports.clearBackups = clearBackups;
|
|
4071
|
-
const upsertAllVariables = async (vorpal, variables, env, componentName, backup = true, masked = true
|
|
4072
|
-
{ projectId, ...existing } = {}) => {
|
|
3528
|
+
const upsertAllVariables = async (vorpal, variables, env, componentName, backup = true, masked = true) => {
|
|
4073
3529
|
var _a;
|
|
4074
|
-
const {
|
|
4075
|
-
const token = inputToken || (await (0, exports.getGitlabToken)(vorpal, host));
|
|
4076
|
-
const id = projectId || (await (0, gitlab_without_vorpal_1.getGitLabProjectId)({ host, path, token }, vorpal));
|
|
3530
|
+
const { id } = await (0, exports.getProjectInfo)(vorpal);
|
|
4077
3531
|
// we list all existing variables. We also gather backup versions, but its currently unused
|
|
4078
|
-
const existingVariables = await getAllCatladderEnvVarsInGitlab(vorpal
|
|
4079
|
-
projectId: id,
|
|
4080
|
-
host,
|
|
4081
|
-
path,
|
|
4082
|
-
token,
|
|
4083
|
-
});
|
|
3532
|
+
const existingVariables = await getAllCatladderEnvVarsInGitlab(vorpal);
|
|
4084
3533
|
for (const [key, value] of Object.entries(variables !== null && variables !== void 0 ? variables : {})) {
|
|
4085
3534
|
const fullKey = (0, pipeline_1.getSecretVarName)(env, componentName, key);
|
|
4086
3535
|
const valueSanitized = (0, lodash_1.isObject)(value) ? JSON.stringify(value) : `${value}`;
|
|
4087
3536
|
const exists = (0, lodash_1.has)(existingVariables, fullKey);
|
|
4088
3537
|
const oldValue = (_a = existingVariables[fullKey]) === null || _a === void 0 ? void 0 : _a.value;
|
|
4089
3538
|
const changed = oldValue !== valueSanitized;
|
|
4090
|
-
if (
|
|
4091
|
-
|
|
4092
|
-
|
|
3539
|
+
if (changed) {
|
|
3540
|
+
if (exists) {
|
|
3541
|
+
vorpal.log(`changed: ${key}`);
|
|
3542
|
+
await updateVariable(vorpal, id, fullKey, valueSanitized, masked);
|
|
3543
|
+
// write backup
|
|
3544
|
+
if (backup) {
|
|
3545
|
+
await createVariable(vorpal, id, getBackupKey(fullKey, new Date().getTime()), oldValue, masked, "_backup");
|
|
3546
|
+
}
|
|
3547
|
+
}
|
|
3548
|
+
else {
|
|
3549
|
+
vorpal.log(`new : ${key}`);
|
|
3550
|
+
await createVariable(vorpal, id, fullKey, valueSanitized, masked);
|
|
3551
|
+
}
|
|
4093
3552
|
}
|
|
4094
|
-
|
|
4095
|
-
vorpal.log(`
|
|
4096
|
-
await gitlab_without_vorpal_1.gitLabVariable.create({
|
|
4097
|
-
projectId: id,
|
|
4098
|
-
key: fullKey,
|
|
4099
|
-
value: valueSanitized,
|
|
4100
|
-
masked,
|
|
4101
|
-
host,
|
|
4102
|
-
token,
|
|
4103
|
-
}, vorpal);
|
|
4104
|
-
continue;
|
|
3553
|
+
else {
|
|
3554
|
+
vorpal.log(`skip : ${key}`);
|
|
4105
3555
|
}
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
projectId: id,
|
|
4109
|
-
key: fullKey,
|
|
4110
|
-
value: valueSanitized,
|
|
4111
|
-
masked,
|
|
4112
|
-
host,
|
|
4113
|
-
token,
|
|
4114
|
-
}, vorpal);
|
|
4115
|
-
// write backup
|
|
4116
|
-
if (backup) {
|
|
4117
|
-
await gitlab_without_vorpal_1.gitLabVariable.create({
|
|
4118
|
-
projectId: id,
|
|
4119
|
-
key: getBackupKey(fullKey, new Date().getTime()),
|
|
4120
|
-
value: oldValue,
|
|
4121
|
-
masked,
|
|
4122
|
-
host,
|
|
4123
|
-
token,
|
|
4124
|
-
}, vorpal);
|
|
4125
|
-
}
|
|
4126
|
-
}
|
|
4127
|
-
gitlab_without_vorpal_1.gitLabVariable.getAll.clear();
|
|
3556
|
+
}
|
|
3557
|
+
exports.getAllVariables.clear();
|
|
4128
3558
|
};
|
|
4129
3559
|
exports.upsertAllVariables = upsertAllVariables;
|
|
4130
3560
|
//# sourceMappingURL=gitlab.js.map
|
|
@@ -4137,7 +3567,7 @@ exports.upsertAllVariables = upsertAllVariables;
|
|
|
4137
3567
|
"use strict";
|
|
4138
3568
|
|
|
4139
3569
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4140
|
-
exports.
|
|
3570
|
+
exports.logWarning = exports.logError = exports.logLines = void 0;
|
|
4141
3571
|
/**
|
|
4142
3572
|
* Logs multiple lines using the log method of the provided {@link LoggerCmdInstance}.
|
|
4143
3573
|
*
|
|
@@ -4202,28 +3632,6 @@ const logWarning = (cmd = console, message, ...additionalMessages) => {
|
|
|
4202
3632
|
logLines(cmd, "");
|
|
4203
3633
|
};
|
|
4204
3634
|
exports.logWarning = logWarning;
|
|
4205
|
-
/**
|
|
4206
|
-
* Logs a notification message using the log method of the provided {@link LoggerCmdInstance}.
|
|
4207
|
-
*
|
|
4208
|
-
* Line items that are `null` or `undefined` are logged as empty lines.
|
|
4209
|
-
*
|
|
4210
|
-
* @example
|
|
4211
|
-
* ```ts
|
|
4212
|
-
* logNotice(cmd, "Message");
|
|
4213
|
-
* logNotice(cmd, "Message", "Additional message");
|
|
4214
|
-
* logNotice(cmd, "Message", "Additional message", "Another additional message line");
|
|
4215
|
-
* logNotice(cmd, "Message", ...additionalMessages); // arrays can be spread into the function
|
|
4216
|
-
* logNotice(cmd, "Message", additionalMessages); // but it will flatten the plain array for convenience
|
|
4217
|
-
* ```
|
|
4218
|
-
*/
|
|
4219
|
-
const logNotice = (cmd = console, message, ...additionalMessages) => {
|
|
4220
|
-
logLines(cmd, "", `[NOTICE] ☝ : ${message}`);
|
|
4221
|
-
if (additionalMessages === null || additionalMessages === void 0 ? void 0 : additionalMessages.length) {
|
|
4222
|
-
logLines(cmd, ...additionalMessages.flat());
|
|
4223
|
-
}
|
|
4224
|
-
logLines(cmd, "");
|
|
4225
|
-
};
|
|
4226
|
-
exports.logNotice = logNotice;
|
|
4227
3635
|
//# sourceMappingURL=log.js.map
|
|
4228
3636
|
|
|
4229
3637
|
/***/ }),
|
|
@@ -4283,130 +3691,68 @@ exports.stopAllPortForwards = stopAllPortForwards;
|
|
|
4283
3691
|
|
|
4284
3692
|
/***/ }),
|
|
4285
3693
|
|
|
4286
|
-
/***/
|
|
4287
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
4288
|
-
|
|
4289
|
-
"use strict";
|
|
4290
|
-
|
|
4291
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4292
|
-
exports.mergeWithFallback = void 0;
|
|
4293
|
-
const gitlabPersonalAccessToken = "gitlab-personal-access-token";
|
|
4294
|
-
const googleAuthUserNumber = "googleAuthUserNumber";
|
|
4295
|
-
const gitlabTokens = "gitlabTokens";
|
|
4296
|
-
const gitLabProjectIds = "gitLabProjectIds";
|
|
4297
|
-
const preferenceKeys = [
|
|
4298
|
-
gitlabPersonalAccessToken,
|
|
4299
|
-
googleAuthUserNumber,
|
|
4300
|
-
gitlabTokens,
|
|
4301
|
-
gitLabProjectIds,
|
|
4302
|
-
];
|
|
4303
|
-
const perfFallback = {
|
|
4304
|
-
[gitlabPersonalAccessToken]: undefined,
|
|
4305
|
-
[googleAuthUserNumber]: undefined,
|
|
4306
|
-
[gitlabTokens]: {},
|
|
4307
|
-
[gitLabProjectIds]: {},
|
|
4308
|
-
};
|
|
4309
|
-
/**
|
|
4310
|
-
* Merges a partial configuration object with a fallback configuration object.
|
|
4311
|
-
* @param config - A partial configuration object of type `Partial<CatladderPreferences>`.
|
|
4312
|
-
* @param fallback - The fallback can be passed, in order to use this function for upserting as well.
|
|
4313
|
-
*/
|
|
4314
|
-
const mergeWithFallback = (config = {}, fallback = perfFallback) => preferenceKeys.reduce((acc, key) => {
|
|
4315
|
-
var _a, _b;
|
|
4316
|
-
return Object.assign(acc, {
|
|
4317
|
-
[key]: typeof fallback[key] === "object"
|
|
4318
|
-
? Object.assign(fallback[key], (_a = config[key]) !== null && _a !== void 0 ? _a : {})
|
|
4319
|
-
: ((_b = config[key]) !== null && _b !== void 0 ? _b : fallback[key]),
|
|
4320
|
-
});
|
|
4321
|
-
}, {});
|
|
4322
|
-
exports.mergeWithFallback = mergeWithFallback;
|
|
4323
|
-
//# sourceMappingURL=CatladderPreferences.js.map
|
|
4324
|
-
|
|
4325
|
-
/***/ }),
|
|
4326
|
-
|
|
4327
|
-
/***/ 62636:
|
|
3694
|
+
/***/ 13511:
|
|
4328
3695
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
4329
3696
|
|
|
4330
3697
|
"use strict";
|
|
4331
3698
|
|
|
4332
3699
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4333
|
-
exports.
|
|
4334
|
-
const fs_1 = __nccwpck_require__(57147);
|
|
3700
|
+
exports.setPreference = exports.getPreference = exports.hasPreference = exports.getPreferences = void 0;
|
|
4335
3701
|
const promises_1 = __nccwpck_require__(73292);
|
|
3702
|
+
const fs_1 = __nccwpck_require__(57147);
|
|
3703
|
+
const path_1 = __nccwpck_require__(71017);
|
|
4336
3704
|
const os_1 = __nccwpck_require__(22037);
|
|
4337
|
-
const posix_1 = __nccwpck_require__(58034);
|
|
4338
3705
|
const yaml_1 = __nccwpck_require__(68033);
|
|
4339
|
-
const
|
|
4340
|
-
const
|
|
4341
|
-
const
|
|
4342
|
-
|
|
4343
|
-
const configDir = (0, posix_1.join)((0, os_1.homedir)(), ".config/catladder");
|
|
4344
|
-
const configPath = (0, posix_1.join)(configDir, "preferences.yml");
|
|
4345
|
-
const legacyBackupPath = (0, posix_1.join)(configDir, "old_preferences_backup.yml");
|
|
4346
|
-
const encoding = "utf-8";
|
|
4347
|
-
const mode = 0o600;
|
|
4348
|
-
const readPerfString = () => (0, promises_1.readFile)(configPath, { encoding });
|
|
4349
|
-
const writePerfString = (str) => (0, promises_1.writeFile)(configPath, str, { encoding, mode });
|
|
4350
|
-
const isConfigPath = () => (0, fs_1.existsSync)(configPath);
|
|
4351
|
-
const isLegacyPath = () => (0, fs_1.existsSync)(legacyPath);
|
|
4352
|
-
const createDir = () => (0, promises_1.mkdir)(configDir, { recursive: true, mode: 0o700 });
|
|
4353
|
-
const copyLegacyConfig = async (target = configPath) => {
|
|
4354
|
-
await (0, promises_1.cp)(legacyPath, target);
|
|
4355
|
-
return (0, promises_1.chmod)(target, mode);
|
|
4356
|
-
};
|
|
4357
|
-
const parseConfigString = (yamlString, logger = console) => {
|
|
4358
|
-
var _a;
|
|
4359
|
-
try {
|
|
4360
|
-
return (0, CatladderPreferences_1.mergeWithFallback)((_a = (0, yaml_1.parse)(yamlString)) !== null && _a !== void 0 ? _a : {});
|
|
4361
|
-
}
|
|
4362
|
-
catch (error) {
|
|
4363
|
-
(0, log_1.logError)(logger, "Error when trying to parse preferences", `${error}`);
|
|
4364
|
-
throw error;
|
|
4365
|
-
}
|
|
4366
|
-
};
|
|
4367
|
-
const readPreferences = async (logger = console) => {
|
|
4368
|
-
const yamlContent = await readPerfString();
|
|
4369
|
-
return parseConfigString(yamlContent, logger);
|
|
4370
|
-
};
|
|
4371
|
-
const stringifyConfig = (config = {}, logger = console) => {
|
|
4372
|
-
try {
|
|
4373
|
-
const preferences = (0, CatladderPreferences_1.mergeWithFallback)(config);
|
|
4374
|
-
return (0, yaml_1.stringify)(preferences);
|
|
4375
|
-
}
|
|
4376
|
-
catch (error) {
|
|
4377
|
-
(0, log_1.logError)(logger, "Error when trying to stringify preferences", `${error}`);
|
|
4378
|
-
throw error;
|
|
4379
|
-
}
|
|
4380
|
-
};
|
|
4381
|
-
const writePreferences = async (preferences = {}, logger = console) => writePerfString(stringifyConfig(preferences, logger));
|
|
4382
|
-
const ensureConfigFile = async () => {
|
|
4383
|
-
if (isConfigPath()) {
|
|
3706
|
+
const legacyPreferencesPath = (0, path_1.join)((0, os_1.homedir)(), ".catladder/preferences.yml");
|
|
3707
|
+
const preferencesPath = (0, path_1.join)((0, os_1.homedir)(), ".config/catladder/preferences.yml");
|
|
3708
|
+
const ensurePreferencesFile = async () => {
|
|
3709
|
+
if ((0, fs_1.existsSync)(preferencesPath)) {
|
|
4384
3710
|
return;
|
|
4385
3711
|
}
|
|
4386
|
-
await
|
|
4387
|
-
if (!
|
|
4388
|
-
return
|
|
3712
|
+
await (0, promises_1.mkdir)((0, path_1.dirname)(preferencesPath), { recursive: true, mode: 0o700 });
|
|
3713
|
+
if (!(0, fs_1.existsSync)(legacyPreferencesPath)) {
|
|
3714
|
+
return (0, promises_1.writeFile)(preferencesPath, "---\n{}", {
|
|
3715
|
+
encoding: "utf-8",
|
|
3716
|
+
mode: 0o600,
|
|
3717
|
+
});
|
|
4389
3718
|
}
|
|
4390
|
-
await
|
|
4391
|
-
|
|
3719
|
+
await (0, promises_1.cp)(legacyPreferencesPath, preferencesPath);
|
|
3720
|
+
await (0, promises_1.chmod)(preferencesPath, 0o600);
|
|
3721
|
+
await (0, promises_1.cp)(preferencesPath, (0, path_1.join)((0, path_1.dirname)(preferencesPath), "old_preferences_backup.yml"));
|
|
4392
3722
|
};
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
3723
|
+
const loadPreferences = async () => {
|
|
3724
|
+
await ensurePreferencesFile();
|
|
3725
|
+
return (0, promises_1.readFile)(preferencesPath, { encoding: "utf-8" });
|
|
3726
|
+
};
|
|
3727
|
+
const getPreferences = async () => {
|
|
3728
|
+
var _a;
|
|
3729
|
+
const yamlContent = await loadPreferences();
|
|
3730
|
+
return ((_a = (0, yaml_1.parse)(yamlContent)) !== null && _a !== void 0 ? _a : {});
|
|
4399
3731
|
};
|
|
4400
3732
|
exports.getPreferences = getPreferences;
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
3733
|
+
const hasPreference = async (key) => {
|
|
3734
|
+
const preferences = await (0, exports.getPreferences)();
|
|
3735
|
+
return key in preferences;
|
|
3736
|
+
};
|
|
3737
|
+
exports.hasPreference = hasPreference;
|
|
3738
|
+
const getPreference = async (key) => {
|
|
3739
|
+
const preferences = await (0, exports.getPreferences)();
|
|
3740
|
+
return preferences[key];
|
|
3741
|
+
};
|
|
3742
|
+
exports.getPreference = getPreference;
|
|
3743
|
+
const setPreference = async (key, value) => {
|
|
3744
|
+
const preferences = await (0, exports.getPreferences)();
|
|
3745
|
+
const newPreferences = {
|
|
3746
|
+
...preferences,
|
|
3747
|
+
[key]: value,
|
|
3748
|
+
};
|
|
3749
|
+
await (0, promises_1.writeFile)(preferencesPath, (0, yaml_1.stringify)(newPreferences), {
|
|
3750
|
+
encoding: "utf-8",
|
|
3751
|
+
mode: 0o600,
|
|
3752
|
+
});
|
|
4407
3753
|
};
|
|
4408
|
-
exports.
|
|
4409
|
-
//# sourceMappingURL=
|
|
3754
|
+
exports.setPreference = setPreference;
|
|
3755
|
+
//# sourceMappingURL=preferences.js.map
|
|
4410
3756
|
|
|
4411
3757
|
/***/ }),
|
|
4412
3758
|
|
|
@@ -4905,7 +4251,9 @@ exports.createBuildJobArtifacts = createBuildJobArtifacts;
|
|
|
4905
4251
|
const getArtifactsPathForComponent = (c, additionalPaths) => {
|
|
4906
4252
|
var _a, _b;
|
|
4907
4253
|
return (_b = [
|
|
4908
|
-
...(
|
|
4254
|
+
...(c.build.type !== "disabled"
|
|
4255
|
+
? ((_a = c.build.config.artifactsPaths) !== null && _a !== void 0 ? _a : [])
|
|
4256
|
+
: []),
|
|
4909
4257
|
...(additionalPaths !== null && additionalPaths !== void 0 ? additionalPaths : []),
|
|
4910
4258
|
]) === null || _b === void 0 ? void 0 : _b.flatMap((artifact) => c.build
|
|
4911
4259
|
// in theory, we only need "direct",
|
|
@@ -5281,10 +4629,12 @@ const getAllCacheConfigsFromConfig = (context, configWithCache) => {
|
|
|
5281
4629
|
// we would probably need to introduce a path to the right config property (build-->test or so)
|
|
5282
4630
|
context.components.flatMap((componentContext) => {
|
|
5283
4631
|
var _a;
|
|
5284
|
-
return
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
|
|
4632
|
+
return componentContext.build.type !== "disabled"
|
|
4633
|
+
? ((_a = (0, index_1.ensureArray)(componentContext.build.config.cache).map((c) => ({
|
|
4634
|
+
...c,
|
|
4635
|
+
baseDir: componentContext.build.dir,
|
|
4636
|
+
}))) !== null && _a !== void 0 ? _a : [])
|
|
4637
|
+
: [];
|
|
5288
4638
|
})
|
|
5289
4639
|
: []),
|
|
5290
4640
|
];
|
|
@@ -5499,7 +4849,7 @@ const requiresDockerBuild = (context) => {
|
|
|
5499
4849
|
exports.requiresDockerBuild = requiresDockerBuild;
|
|
5500
4850
|
// those need to be runner variables
|
|
5501
4851
|
const getDockerBuildRunnerVariables = () => ({
|
|
5502
|
-
DOCKER_HOST: "tcp://
|
|
4852
|
+
DOCKER_HOST: "tcp://docker:2375",
|
|
5503
4853
|
DOCKER_TLS_CERTDIR: "",
|
|
5504
4854
|
DOCKER_DRIVER: "overlay2",
|
|
5505
4855
|
DOCKER_BUILDKIT: "1", // see https://docs.docker.com/develop/develop-images/build_enhancements/
|
|
@@ -5675,10 +5025,9 @@ exports.BUILD_TYPES = {
|
|
|
5675
5025
|
rails: {
|
|
5676
5026
|
jobs: rails_1.createRailsJobs,
|
|
5677
5027
|
defaults: () => ({
|
|
5678
|
-
startCommand: "/cnb/process/web",
|
|
5679
5028
|
cnbBuilder: {
|
|
5680
|
-
image: "heroku/builder:
|
|
5681
|
-
packVersion: "0.
|
|
5029
|
+
image: "heroku/builder:24",
|
|
5030
|
+
packVersion: "0.36.4",
|
|
5682
5031
|
},
|
|
5683
5032
|
}),
|
|
5684
5033
|
},
|
|
@@ -6052,7 +5401,9 @@ const ensureNodeVersion = (context) => (0, gitlab_1.collapseableSection)("nodein
|
|
|
6052
5401
|
]);
|
|
6053
5402
|
exports.ensureNodeVersion = ensureNodeVersion;
|
|
6054
5403
|
const getYarnInstall = (context, options) => {
|
|
6055
|
-
const postInstall = context.type !== "workspace" &&
|
|
5404
|
+
const postInstall = context.type !== "workspace" &&
|
|
5405
|
+
context.build.type !== "disabled" &&
|
|
5406
|
+
"postInstall" in context.build.config
|
|
6056
5407
|
? context.build.config.postInstall
|
|
6057
5408
|
: null;
|
|
6058
5409
|
return [
|
|
@@ -6138,7 +5489,6 @@ const createRailsBuildJobs = (context) => {
|
|
|
6138
5489
|
script: [
|
|
6139
5490
|
...(0, docker_1.gitlabDockerLogin)(context),
|
|
6140
5491
|
`cd ${context.build.dir}`,
|
|
6141
|
-
`docker pull $DOCKER_CACHE_IMAGE || true`,
|
|
6142
5492
|
`wget --output-document=- https://github.com/buildpacks/pack/releases/download/v${cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion}/pack-v${cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion}-linux.tgz | tar -zx --directory /usr/local/bin pack`,
|
|
6143
5493
|
`chmod +x /usr/local/bin/pack`,
|
|
6144
5494
|
// replace private git ssh gem sources with https to make bundler with credentials via env var work
|
|
@@ -6180,7 +5530,7 @@ exports.createRailsTestJobs = void 0;
|
|
|
6180
5530
|
const __1 = __nccwpck_require__(10603);
|
|
6181
5531
|
const utils_1 = __nccwpck_require__(32497);
|
|
6182
5532
|
const createRailsTestJobs = (context) => {
|
|
6183
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
5533
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
6184
5534
|
// don't run tests after release
|
|
6185
5535
|
// TODO: this will be replaced by using rules
|
|
6186
5536
|
if (context.trigger === "taggedRelease") {
|
|
@@ -6253,9 +5603,26 @@ const createRailsTestJobs = (context) => {
|
|
|
6253
5603
|
`cd ${context.build.dir}`,
|
|
6254
5604
|
...bundlerInstall,
|
|
6255
5605
|
...((_q = (0, utils_1.ensureArrayOrNull)((_p = buildConfig.test) === null || _p === void 0 ? void 0 : _p.command)) !== null && _q !== void 0 ? _q : [
|
|
5606
|
+
"bundle exec rake db:test:prepare",
|
|
5607
|
+
"bundle exec rake assets:precompile assets:clean",
|
|
6256
5608
|
"bundle exec rspec",
|
|
6257
5609
|
]),
|
|
6258
5610
|
],
|
|
5611
|
+
runnerVariables: {
|
|
5612
|
+
RAILS_ENV: "test",
|
|
5613
|
+
DATABASE_URL: "postgresql://postgres@database",
|
|
5614
|
+
},
|
|
5615
|
+
services: [
|
|
5616
|
+
{
|
|
5617
|
+
name: buildConfig.test && "databaseImage" in buildConfig.test
|
|
5618
|
+
? ((_s = (_r = buildConfig === null || buildConfig === void 0 ? void 0 : buildConfig.test) === null || _r === void 0 ? void 0 : _r.databaseImage) !== null && _s !== void 0 ? _s : "docker.io/postgres:latest")
|
|
5619
|
+
: "docker.io/postgres:latest",
|
|
5620
|
+
alias: "database",
|
|
5621
|
+
variables: {
|
|
5622
|
+
POSTGRES_HOST_AUTH_METHOD: "trust",
|
|
5623
|
+
},
|
|
5624
|
+
},
|
|
5625
|
+
],
|
|
6259
5626
|
}
|
|
6260
5627
|
: null;
|
|
6261
5628
|
return [auditJob, lintJob, testJob].filter(utils_1.notNil);
|
|
@@ -6279,7 +5646,10 @@ exports.SBOM_FILE = "__sbom.json";
|
|
|
6279
5646
|
const createSbomBuildJob = (context) => {
|
|
6280
5647
|
var _a, _b, _c, _d;
|
|
6281
5648
|
const buildConfig = context.build.config;
|
|
6282
|
-
const defaultImage =
|
|
5649
|
+
const defaultImage = {
|
|
5650
|
+
name: "aquasec/trivy:0.58.2",
|
|
5651
|
+
entrypoint: [""],
|
|
5652
|
+
};
|
|
6283
5653
|
const defaultScript = [
|
|
6284
5654
|
`trivy fs --quiet --format cyclonedx --output "${exports.SBOM_FILE}" ${context.packageManagerInfo.componentIsInWorkspace
|
|
6285
5655
|
? "."
|
|
@@ -6510,19 +5880,23 @@ const createComponentContext = async (ctx) => {
|
|
|
6510
5880
|
const packageManagerInfo = await (0, packageManager_1.getPackageManagerInfoForComponent)(ctx.config, ctx.componentName);
|
|
6511
5881
|
const envContext = (0, getEnvironmentContext_1.getEnvironmentContext)(ctx);
|
|
6512
5882
|
const componentConfigWithoutDefaults = envContext.envConfigRaw;
|
|
6513
|
-
const resolvedBuildType =
|
|
6514
|
-
?
|
|
6515
|
-
: (
|
|
6516
|
-
|
|
5883
|
+
const resolvedBuildType = componentConfigWithoutDefaults.build === false
|
|
5884
|
+
? false
|
|
5885
|
+
: (0, build_1.isStandaloneBuildConfig)(componentConfigWithoutDefaults.build)
|
|
5886
|
+
? componentConfigWithoutDefaults.build.type
|
|
5887
|
+
: (_a = ctx.config.builds) === null || _a === void 0 ? void 0 : _a[componentConfigWithoutDefaults.build.from].type;
|
|
5888
|
+
if (resolvedBuildType === undefined) {
|
|
6517
5889
|
throw new Error("build type not found, is the build config correct?");
|
|
6518
5890
|
}
|
|
6519
5891
|
const defaults = componentConfigWithoutDefaults.deploy
|
|
6520
5892
|
? {
|
|
6521
|
-
build:
|
|
5893
|
+
build: resolvedBuildType &&
|
|
5894
|
+
build_1.BUILD_TYPES[resolvedBuildType].defaults(envContext),
|
|
6522
5895
|
deploy: deploy_1.DEPLOY_TYPES[componentConfigWithoutDefaults.deploy.type].defaults(envContext),
|
|
6523
5896
|
}
|
|
6524
5897
|
: {
|
|
6525
|
-
build:
|
|
5898
|
+
build: resolvedBuildType &&
|
|
5899
|
+
build_1.BUILD_TYPES[resolvedBuildType].defaults(envContext),
|
|
6526
5900
|
deploy: {},
|
|
6527
5901
|
};
|
|
6528
5902
|
const componentConfig = (0, utils_1.mergeWithMergingArrays)(defaults, componentConfigWithoutDefaults);
|
|
@@ -6540,6 +5914,13 @@ const createComponentContext = async (ctx) => {
|
|
|
6540
5914
|
};
|
|
6541
5915
|
const _getBuildContext = () => {
|
|
6542
5916
|
var _a;
|
|
5917
|
+
if (build === false) {
|
|
5918
|
+
return {
|
|
5919
|
+
type: "disabled",
|
|
5920
|
+
getComponentDirs,
|
|
5921
|
+
dir,
|
|
5922
|
+
};
|
|
5923
|
+
}
|
|
6543
5924
|
if ((0, build_1.isStandaloneBuildConfig)(build)) {
|
|
6544
5925
|
return {
|
|
6545
5926
|
dir: dir,
|
|
@@ -6956,7 +6337,9 @@ const getLabels = (context) => {
|
|
|
6956
6337
|
"app-name": sanitize(context.fullConfig.appName),
|
|
6957
6338
|
"env-type": sanitize(context.environment.envType),
|
|
6958
6339
|
"env-name": sanitize(context.env),
|
|
6959
|
-
"build-type":
|
|
6340
|
+
"build-type": context.build.type === "disabled"
|
|
6341
|
+
? "disabled"
|
|
6342
|
+
: sanitize(context.build.buildType),
|
|
6960
6343
|
...((_b = (_a = context.fullConfig.meta) === null || _a === void 0 ? void 0 : _a.labels) !== null && _b !== void 0 ? _b : {}),
|
|
6961
6344
|
};
|
|
6962
6345
|
return labels;
|
|
@@ -7550,7 +6933,7 @@ const jobName_1 = __nccwpck_require__(9626);
|
|
|
7550
6933
|
const common_1 = __nccwpck_require__(73325);
|
|
7551
6934
|
const constants_1 = __nccwpck_require__(38865);
|
|
7552
6935
|
const volumes_1 = __nccwpck_require__(60847);
|
|
7553
|
-
const
|
|
6936
|
+
const getJobOrServiceArgs_1 = __nccwpck_require__(61741);
|
|
7554
6937
|
const getDeleteJobsScripts = (context) => {
|
|
7555
6938
|
const commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
|
|
7556
6939
|
const commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
|
|
@@ -7570,7 +6953,7 @@ const getJobCreateScripts = (context) => (0, exports.getCloudRunJobsWithNames)(c
|
|
|
7570
6953
|
const { image: commonImage, project, region, ...deployArgs } = (0, common_1.getCommonDeployArgs)(context);
|
|
7571
6954
|
const commonDeployArgsString = (0, createArgsString_1.createArgsString)({
|
|
7572
6955
|
command: `"${commandArray.join(",")}"`,
|
|
7573
|
-
args: (0,
|
|
6956
|
+
args: (0, getJobOrServiceArgs_1.getCloudRunServiceOrJobArgsArg)(job.args),
|
|
7574
6957
|
labels: `"${(0, common_1.makeLabelString)((0, getLabels_1.getLabels)(context))},cloud-run-job-name=$current_job_name"`,
|
|
7575
6958
|
image: `"${(_a = job.image) !== null && _a !== void 0 ? _a : commonImage}"`,
|
|
7576
6959
|
project,
|
|
@@ -7630,17 +7013,21 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
7630
7013
|
exports.getServiceDeleteScript = exports.getServiceDeployScript = void 0;
|
|
7631
7014
|
const getLabels_1 = __nccwpck_require__(30920);
|
|
7632
7015
|
const createArgsString_1 = __nccwpck_require__(49598);
|
|
7016
|
+
const getJobOrServiceArgs_1 = __nccwpck_require__(61741);
|
|
7633
7017
|
const getServiceName_1 = __nccwpck_require__(38128);
|
|
7634
7018
|
const common_1 = __nccwpck_require__(73325);
|
|
7635
7019
|
const constants_1 = __nccwpck_require__(38865);
|
|
7020
|
+
const healthCheck_1 = __nccwpck_require__(30193);
|
|
7636
7021
|
const volumes_1 = __nccwpck_require__(60847);
|
|
7637
7022
|
const getServiceDeployScript = (context, service, nameSuffix) => {
|
|
7638
|
-
var _a, _b, _c, _d, _e;
|
|
7023
|
+
var _a, _b, _c, _d, _e, _f;
|
|
7639
7024
|
const commonDeployArgs = (0, common_1.getCommonDeployArgs)(context);
|
|
7640
7025
|
const serviceName = (0, getServiceName_1.getServiceName)(context);
|
|
7641
7026
|
const customConfig = service !== true ? service : undefined;
|
|
7642
7027
|
const command = service !== true
|
|
7643
|
-
? ((_a = service === null || service === void 0 ? void 0 : service.command) !== null && _a !== void 0 ? _a : context.build.
|
|
7028
|
+
? ((_a = service === null || service === void 0 ? void 0 : service.command) !== null && _a !== void 0 ? _a : (context.build.type !== "disabled"
|
|
7029
|
+
? context.build.config.startCommand
|
|
7030
|
+
: undefined))
|
|
7644
7031
|
: undefined;
|
|
7645
7032
|
const commandArray = command
|
|
7646
7033
|
? Array.isArray(command)
|
|
@@ -7651,14 +7038,16 @@ const getServiceDeployScript = (context, service, nameSuffix) => {
|
|
|
7651
7038
|
const argsString = (0, createArgsString_1.createArgsString)({
|
|
7652
7039
|
// command as empty string resets it to default (uses the image's entrypoint)
|
|
7653
7040
|
command: commandArray ? '"' + commandArray.join(",") + '"' : '""',
|
|
7041
|
+
args: (0, getJobOrServiceArgs_1.getCloudRunServiceOrJobArgsArg)(customConfig === null || customConfig === void 0 ? void 0 : customConfig.args),
|
|
7654
7042
|
...commonDeployArgs,
|
|
7043
|
+
image: (_b = customConfig === null || customConfig === void 0 ? void 0 : customConfig.image) !== null && _b !== void 0 ? _b : commonDeployArgs.image,
|
|
7655
7044
|
labels: (0, common_1.makeLabelString)({
|
|
7656
7045
|
...(0, getLabels_1.getLabels)(context),
|
|
7657
7046
|
"cloud-run-service-name": fullServiceName,
|
|
7658
7047
|
}),
|
|
7659
7048
|
"env-vars-file": constants_1.ENV_VARS_FILENAME,
|
|
7660
|
-
"min-instances": (
|
|
7661
|
-
"max-instances": (
|
|
7049
|
+
"min-instances": (_c = customConfig === null || customConfig === void 0 ? void 0 : customConfig.minInstances) !== null && _c !== void 0 ? _c : 0,
|
|
7050
|
+
"max-instances": (_d = customConfig === null || customConfig === void 0 ? void 0 : customConfig.maxInstances) !== null && _d !== void 0 ? _d : 100,
|
|
7662
7051
|
"cpu-throttling": (customConfig === null || customConfig === void 0 ? void 0 : customConfig.noCpuThrottling) !== true,
|
|
7663
7052
|
cpu: customConfig === null || customConfig === void 0 ? void 0 : customConfig.cpu,
|
|
7664
7053
|
memory: customConfig === null || customConfig === void 0 ? void 0 : customConfig.memory,
|
|
@@ -7668,12 +7057,16 @@ const getServiceDeployScript = (context, service, nameSuffix) => {
|
|
|
7668
7057
|
network: customConfig === null || customConfig === void 0 ? void 0 : customConfig.network,
|
|
7669
7058
|
subnet: customConfig === null || customConfig === void 0 ? void 0 : customConfig.subnet,
|
|
7670
7059
|
"use-http2": customConfig === null || customConfig === void 0 ? void 0 : customConfig.http2,
|
|
7671
|
-
"allow-unauthenticated": (
|
|
7672
|
-
ingress: (
|
|
7060
|
+
"allow-unauthenticated": (_e = customConfig === null || customConfig === void 0 ? void 0 : customConfig.allowUnauthenticated) !== null && _e !== void 0 ? _e : true,
|
|
7061
|
+
ingress: (_f = customConfig === null || customConfig === void 0 ? void 0 : customConfig.ingress) !== null && _f !== void 0 ? _f : "all",
|
|
7673
7062
|
"cpu-boost": true,
|
|
7674
7063
|
"execution-environment": customConfig === null || customConfig === void 0 ? void 0 : customConfig.executionEnvironment,
|
|
7064
|
+
gpu: customConfig === null || customConfig === void 0 ? void 0 : customConfig.gpu,
|
|
7065
|
+
"gpu-type": customConfig === null || customConfig === void 0 ? void 0 : customConfig.gpuType,
|
|
7066
|
+
...(0, healthCheck_1.healthCheckCliArgs)(customConfig === null || customConfig === void 0 ? void 0 : customConfig.healthCheck),
|
|
7675
7067
|
}, ...(0, volumes_1.createVolumeConfig)(customConfig === null || customConfig === void 0 ? void 0 : customConfig.volumes, "service"));
|
|
7676
|
-
|
|
7068
|
+
const version = requiresBeta(customConfig) ? "beta" : undefined;
|
|
7069
|
+
return `${(0, common_1.gcloudRunCmd)(version)} deploy ${fullServiceName} ${argsString}`;
|
|
7677
7070
|
};
|
|
7678
7071
|
exports.getServiceDeployScript = getServiceDeployScript;
|
|
7679
7072
|
const getServiceDeleteScript = (context, serviceSuffix) => {
|
|
@@ -7688,6 +7081,21 @@ const getServiceDeleteScript = (context, serviceSuffix) => {
|
|
|
7688
7081
|
];
|
|
7689
7082
|
};
|
|
7690
7083
|
exports.getServiceDeleteScript = getServiceDeleteScript;
|
|
7084
|
+
const requiresBeta = (config) => {
|
|
7085
|
+
if (!config) {
|
|
7086
|
+
return false;
|
|
7087
|
+
}
|
|
7088
|
+
if (config.gpuType) {
|
|
7089
|
+
return true;
|
|
7090
|
+
}
|
|
7091
|
+
if (config.gpu && config.gpu > 0) {
|
|
7092
|
+
return true;
|
|
7093
|
+
}
|
|
7094
|
+
if (config.healthCheck !== undefined) {
|
|
7095
|
+
return true;
|
|
7096
|
+
}
|
|
7097
|
+
return false;
|
|
7098
|
+
};
|
|
7691
7099
|
//# sourceMappingURL=cloudRunServices.js.map
|
|
7692
7100
|
|
|
7693
7101
|
/***/ }),
|
|
@@ -7774,8 +7182,9 @@ exports.ENV_VARS_FILENAME = "____envvars.yaml";
|
|
|
7774
7182
|
"use strict";
|
|
7775
7183
|
|
|
7776
7184
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
7777
|
-
exports.
|
|
7185
|
+
exports.getOnDeployExecuteScript = void 0;
|
|
7778
7186
|
const createArgsString_1 = __nccwpck_require__(49598);
|
|
7187
|
+
const getJobOrServiceArgs_1 = __nccwpck_require__(61741);
|
|
7779
7188
|
const jobName_1 = __nccwpck_require__(9626);
|
|
7780
7189
|
const cloudRunJobs_1 = __nccwpck_require__(61224);
|
|
7781
7190
|
const common_1 = __nccwpck_require__(73325);
|
|
@@ -7843,19 +7252,11 @@ const getJobRunScriptForExecute = (context, { jobName, config }) => {
|
|
|
7843
7252
|
const argString = (0, createArgsString_1.createArgsString)({
|
|
7844
7253
|
...commonArgs,
|
|
7845
7254
|
wait: waitForCompletion === true ? true : undefined,
|
|
7846
|
-
args: (0,
|
|
7255
|
+
args: (0, getJobOrServiceArgs_1.getCloudRunServiceOrJobArgsArg)(config.args),
|
|
7847
7256
|
});
|
|
7848
7257
|
const fullJobName = (0, jobName_1.getFullJobName)(context, jobName);
|
|
7849
7258
|
return `${(0, common_1.gcloudRunCmd)()} jobs execute ${fullJobName.toString()} ${argString}`;
|
|
7850
7259
|
};
|
|
7851
|
-
const getCloudRunJobArgsArg = (args) => {
|
|
7852
|
-
return args !== undefined
|
|
7853
|
-
? args.length > 0
|
|
7854
|
-
? args === null || args === void 0 ? void 0 : args.map((arg) => `"${arg}"`).join(",")
|
|
7855
|
-
: ""
|
|
7856
|
-
: undefined;
|
|
7857
|
-
};
|
|
7858
|
-
exports.getCloudRunJobArgsArg = getCloudRunJobArgsArg;
|
|
7859
7260
|
//# sourceMappingURL=onDeploy.js.map
|
|
7860
7261
|
|
|
7861
7262
|
/***/ }),
|
|
@@ -8095,6 +7496,64 @@ exports.getCloudRunStopScripts = getCloudRunStopScripts;
|
|
|
8095
7496
|
|
|
8096
7497
|
/***/ }),
|
|
8097
7498
|
|
|
7499
|
+
/***/ 30193:
|
|
7500
|
+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
7501
|
+
|
|
7502
|
+
"use strict";
|
|
7503
|
+
|
|
7504
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
7505
|
+
exports.healthCheckCliArgs = void 0;
|
|
7506
|
+
const types_1 = __nccwpck_require__(75781);
|
|
7507
|
+
const PORT = 8080;
|
|
7508
|
+
function healthCheckCliArgs(healthCheck) {
|
|
7509
|
+
const shouldNotSetHealthCheck = healthCheck === undefined;
|
|
7510
|
+
if (shouldNotSetHealthCheck) {
|
|
7511
|
+
return undefined;
|
|
7512
|
+
}
|
|
7513
|
+
const shouldUseDefaultProbe = healthCheck === true;
|
|
7514
|
+
if (shouldUseDefaultProbe) {
|
|
7515
|
+
return {
|
|
7516
|
+
"startup-probe": toArgValue(probeToKeyValuePairs(types_1.defaultStartupProbe)),
|
|
7517
|
+
"liveness-probe": toArgValue(probeToKeyValuePairs(types_1.defaultLivenessProbe)),
|
|
7518
|
+
};
|
|
7519
|
+
}
|
|
7520
|
+
return {
|
|
7521
|
+
"startup-probe": toArgValue(probeToKeyValuePairs(healthCheck.startupProbe)),
|
|
7522
|
+
"liveness-probe": healthCheck.livenessProbe
|
|
7523
|
+
? toArgValue(probeToKeyValuePairs(healthCheck.livenessProbe))
|
|
7524
|
+
: "", // NOTE: empty string ("") removes liveness probe
|
|
7525
|
+
};
|
|
7526
|
+
}
|
|
7527
|
+
exports.healthCheckCliArgs = healthCheckCliArgs;
|
|
7528
|
+
function probeToKeyValuePairs(probe) {
|
|
7529
|
+
const sharedArgs = Object.entries({
|
|
7530
|
+
initialDelaySeconds: probe.initialDelaySeconds,
|
|
7531
|
+
timeoutSeconds: probe.timeoutSeconds,
|
|
7532
|
+
periodSeconds: probe.periodSeconds,
|
|
7533
|
+
failureThreshold: probe.failureThreshold,
|
|
7534
|
+
});
|
|
7535
|
+
switch (probe.type) {
|
|
7536
|
+
case "tcp":
|
|
7537
|
+
return [...sharedArgs, ["tcpSocket.port", PORT]];
|
|
7538
|
+
case "http1":
|
|
7539
|
+
return [
|
|
7540
|
+
...sharedArgs,
|
|
7541
|
+
["httpGet.port", PORT],
|
|
7542
|
+
["httpGet.path", probe.path],
|
|
7543
|
+
// NOTE: headers are not supported by "gcloud beta" at the moment
|
|
7544
|
+
];
|
|
7545
|
+
default:
|
|
7546
|
+
probe;
|
|
7547
|
+
return [];
|
|
7548
|
+
}
|
|
7549
|
+
}
|
|
7550
|
+
function toArgValue(keyValues) {
|
|
7551
|
+
return keyValues.map(([key, value]) => `${key}=${value}`).join(",");
|
|
7552
|
+
}
|
|
7553
|
+
//# sourceMappingURL=healthCheck.js.map
|
|
7554
|
+
|
|
7555
|
+
/***/ }),
|
|
7556
|
+
|
|
8098
7557
|
/***/ 34069:
|
|
8099
7558
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
8100
7559
|
|
|
@@ -8192,19 +7651,22 @@ exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = "GCLOUD_DEPLOY_credentialsKey";
|
|
|
8192
7651
|
// FIXME: rename to internalHostSuffix, but this means that project-setup needs to be rerun, so its kindof a breaking change
|
|
8193
7652
|
exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = "GCLOUD_RUN_canonicalHostSuffix";
|
|
8194
7653
|
const getCloudSqlVariables = ({ deployConfigRaw, environmentSlugPrefix, env, componentName, fullConfig, }) => {
|
|
8195
|
-
var _a, _b;
|
|
7654
|
+
var _a, _b, _c;
|
|
8196
7655
|
if (deployConfigRaw && deployConfigRaw.cloudSql) {
|
|
8197
7656
|
const DB_NAME = (0, utils_1.getFullDbName)(deployConfigRaw.cloudSql, fullConfig, environmentSlugPrefix, componentName);
|
|
8198
7657
|
const additionalQueryParamsString = Object.entries((_a = deployConfigRaw.cloudSql.dbAdditionalQueryParams) !== null && _a !== void 0 ? _a : {})
|
|
8199
7658
|
.map(([key, value]) => `&${key}=${value}`)
|
|
8200
7659
|
.join("");
|
|
8201
|
-
|
|
7660
|
+
const dbVars = {
|
|
8202
7661
|
CLOUD_SQL_INSTANCE_CONNECTION_NAME: deployConfigRaw.cloudSql.instanceConnectionName,
|
|
8203
7662
|
DB_NAME: DB_NAME,
|
|
8204
7663
|
DB_USER: (_b = deployConfigRaw.cloudSql.dbUser) !== null && _b !== void 0 ? _b : "postgres",
|
|
8205
7664
|
DB_PASSWORD: "$" + (0, context_1.getSecretVarName)(env, componentName, "DB_PASSWORD"),
|
|
8206
|
-
|
|
8207
|
-
|
|
7665
|
+
};
|
|
7666
|
+
return {
|
|
7667
|
+
...dbVars,
|
|
7668
|
+
DATABASE_URL: (0, database_1.getDatabaseConnectionString)(deployConfigRaw.cloudSql, dbVars).concat(additionalQueryParamsString),
|
|
7669
|
+
DATABASE_JDBC_URL: (0, database_1.getDatabaseJdbcUrl)(dbVars, (_c = deployConfigRaw.cloudSql.dbConnectionStringVariablesMode) !== null && _c !== void 0 ? _c : database_1.DEFAULT_DB_VARIABLES_MODE),
|
|
8208
7670
|
};
|
|
8209
7671
|
}
|
|
8210
7672
|
return {};
|
|
@@ -8328,7 +7790,8 @@ exports.createArgsString = createArgsString;
|
|
|
8328
7790
|
"use strict";
|
|
8329
7791
|
|
|
8330
7792
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
8331
|
-
exports.getDatabaseConnectionString = exports.
|
|
7793
|
+
exports.getDatabaseConnectionString = exports.getPrismaDatabaseConnectionString = exports.getRailsDatabaseConnectionString = exports.getDatabaseJdbcUrl = exports.DEFAULT_DB_VARIABLES_MODE = exports.getDatabaseCreateScript = exports.getDatabaseDeleteScript = void 0;
|
|
7794
|
+
const bash_1 = __nccwpck_require__(22990);
|
|
8332
7795
|
const gitlab_1 = __nccwpck_require__(38490);
|
|
8333
7796
|
const getDatabaseDeleteScript = (context, deployConfig) => {
|
|
8334
7797
|
if (!deployConfig.cloudSql || !deployConfig.cloudSql.deleteDatabaseOnStop) {
|
|
@@ -8366,16 +7829,64 @@ const getDatabaseCreateScript = (context, deployConfig) => {
|
|
|
8366
7829
|
]);
|
|
8367
7830
|
};
|
|
8368
7831
|
exports.getDatabaseCreateScript = getDatabaseCreateScript;
|
|
8369
|
-
exports.
|
|
8370
|
-
const
|
|
7832
|
+
exports.DEFAULT_DB_VARIABLES_MODE = "legacy";
|
|
7833
|
+
const getVariableOrValue = (key, variables, mode) => {
|
|
7834
|
+
return mode === "legacy" ? `$${key}` : variables[key];
|
|
7835
|
+
};
|
|
7836
|
+
const getDatabaseJdbcUrl = (variables, mode) => {
|
|
7837
|
+
const parts = [
|
|
7838
|
+
"jdbc:postgresql:///",
|
|
7839
|
+
getVariableOrValue("DB_NAME", variables, mode),
|
|
7840
|
+
"?cloudSqlInstance=",
|
|
7841
|
+
getVariableOrValue("CLOUD_SQL_INSTANCE_CONNECTION_NAME", variables, mode),
|
|
7842
|
+
"&socketFactory=com.google.cloud.sql.postgres.SocketFactory&user=",
|
|
7843
|
+
getVariableOrValue("DB_USER", variables, mode),
|
|
7844
|
+
"&password=",
|
|
7845
|
+
getVariableOrValue("DB_PASSWORD", variables, mode),
|
|
7846
|
+
];
|
|
7847
|
+
return (0, bash_1.joinBashExpressions)(parts);
|
|
7848
|
+
};
|
|
7849
|
+
exports.getDatabaseJdbcUrl = getDatabaseJdbcUrl;
|
|
7850
|
+
const getRailsDatabaseConnectionString = (variables, mode) => {
|
|
7851
|
+
const parts = [
|
|
7852
|
+
"postgresql://",
|
|
7853
|
+
getVariableOrValue("DB_USER", variables, mode),
|
|
7854
|
+
":",
|
|
7855
|
+
getVariableOrValue("DB_PASSWORD", variables, mode),
|
|
7856
|
+
"@",
|
|
7857
|
+
encodeURIComponent(`/cloudsql/${variables.CLOUD_SQL_INSTANCE_CONNECTION_NAME}`),
|
|
7858
|
+
"/",
|
|
7859
|
+
getVariableOrValue("DB_NAME", variables, mode),
|
|
7860
|
+
"?",
|
|
7861
|
+
];
|
|
7862
|
+
return (0, bash_1.joinBashExpressions)(parts);
|
|
7863
|
+
};
|
|
7864
|
+
exports.getRailsDatabaseConnectionString = getRailsDatabaseConnectionString;
|
|
7865
|
+
const getPrismaDatabaseConnectionString = (variables, mode) => {
|
|
7866
|
+
const parts = [
|
|
7867
|
+
"postgresql://",
|
|
7868
|
+
getVariableOrValue("DB_USER", variables, mode),
|
|
7869
|
+
":",
|
|
7870
|
+
getVariableOrValue("DB_PASSWORD", variables, mode),
|
|
7871
|
+
"@localhost/",
|
|
7872
|
+
getVariableOrValue("DB_NAME", variables, mode),
|
|
7873
|
+
"?host=/cloudsql/",
|
|
7874
|
+
getVariableOrValue("CLOUD_SQL_INSTANCE_CONNECTION_NAME", variables, mode),
|
|
7875
|
+
];
|
|
7876
|
+
return (0, bash_1.joinBashExpressions)(parts);
|
|
7877
|
+
};
|
|
7878
|
+
exports.getPrismaDatabaseConnectionString = getPrismaDatabaseConnectionString;
|
|
7879
|
+
const getDatabaseConnectionString = (config, variables) => {
|
|
7880
|
+
var _a;
|
|
7881
|
+
const mode = (_a = config.dbConnectionStringVariablesMode) !== null && _a !== void 0 ? _a : exports.DEFAULT_DB_VARIABLES_MODE;
|
|
8371
7882
|
switch (config.dbConnectionStringFormat) {
|
|
8372
7883
|
case "jdbc":
|
|
8373
|
-
return exports.
|
|
7884
|
+
return (0, exports.getDatabaseJdbcUrl)(variables, mode);
|
|
8374
7885
|
case "rails":
|
|
8375
|
-
return
|
|
7886
|
+
return (0, exports.getRailsDatabaseConnectionString)(variables, mode);
|
|
8376
7887
|
default:
|
|
8377
7888
|
// prisma
|
|
8378
|
-
return
|
|
7889
|
+
return (0, exports.getPrismaDatabaseConnectionString)(variables, mode);
|
|
8379
7890
|
}
|
|
8380
7891
|
};
|
|
8381
7892
|
exports.getDatabaseConnectionString = getDatabaseConnectionString;
|
|
@@ -8400,6 +7911,25 @@ exports.gcloudServiceAccountLoginCommands = gcloudServiceAccountLoginCommands;
|
|
|
8400
7911
|
|
|
8401
7912
|
/***/ }),
|
|
8402
7913
|
|
|
7914
|
+
/***/ 61741:
|
|
7915
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
7916
|
+
|
|
7917
|
+
"use strict";
|
|
7918
|
+
|
|
7919
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
7920
|
+
exports.getCloudRunServiceOrJobArgsArg = void 0;
|
|
7921
|
+
const getCloudRunServiceOrJobArgsArg = (args) => {
|
|
7922
|
+
return args !== undefined
|
|
7923
|
+
? args.length > 0
|
|
7924
|
+
? args === null || args === void 0 ? void 0 : args.map((arg) => `"${arg}"`).join(",")
|
|
7925
|
+
: ""
|
|
7926
|
+
: undefined;
|
|
7927
|
+
};
|
|
7928
|
+
exports.getCloudRunServiceOrJobArgsArg = getCloudRunServiceOrJobArgsArg;
|
|
7929
|
+
//# sourceMappingURL=getJobOrServiceArgs.js.map
|
|
7930
|
+
|
|
7931
|
+
/***/ }),
|
|
7932
|
+
|
|
8403
7933
|
/***/ 38128:
|
|
8404
7934
|
/***/ ((__unused_webpack_module, exports) => {
|
|
8405
7935
|
|
|
@@ -8942,7 +8472,9 @@ const createAppConfig = (context, application) => {
|
|
|
8942
8472
|
const { healthRoute, command, ...rest } = application !== null && application !== void 0 ? application : {};
|
|
8943
8473
|
return (0, utils_1.mergeWithMergingArrays)({
|
|
8944
8474
|
host: context.environment.envVars.HOSTNAME,
|
|
8945
|
-
command: command !== null && command !== void 0 ? command : context.build.
|
|
8475
|
+
command: command !== null && command !== void 0 ? command : (context.build.type !== "disabled"
|
|
8476
|
+
? context.build.config.startCommand
|
|
8477
|
+
: undefined),
|
|
8946
8478
|
livenessProbe: {
|
|
8947
8479
|
httpGet: {
|
|
8948
8480
|
path: healthRoute !== null && healthRoute !== void 0 ? healthRoute : "__health",
|
|
@@ -9122,9 +8654,10 @@ exports.getDependencyTrackDeleteScript = exports.getDependencyTrackUploadScript
|
|
|
9122
8654
|
const BashExpression_1 = __nccwpck_require__(42376);
|
|
9123
8655
|
const sbom_1 = __nccwpck_require__(37038);
|
|
9124
8656
|
const context_1 = __nccwpck_require__(61724);
|
|
9125
|
-
const sbomDeactivated = (context) =>
|
|
9126
|
-
context
|
|
9127
|
-
|
|
8657
|
+
const sbomDeactivated = (context) => context.build.type === "disabled" ||
|
|
8658
|
+
((0, context_1.componentContextIsStandaloneBuild)(context) &&
|
|
8659
|
+
context.build.config.type === "custom" &&
|
|
8660
|
+
context.build.config.sbom === false);
|
|
9128
8661
|
exports.sbomDeactivated = sbomDeactivated;
|
|
9129
8662
|
const getDependencyTrackUploadScript = (context) => {
|
|
9130
8663
|
return (0, exports.sbomDeactivated)(context)
|
|
@@ -9174,6 +8707,22 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
9174
8707
|
"use strict";
|
|
9175
8708
|
|
|
9176
8709
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
8710
|
+
exports.defaultLivenessProbe = exports.defaultStartupProbe = void 0;
|
|
8711
|
+
exports.defaultStartupProbe = {
|
|
8712
|
+
type: "http1",
|
|
8713
|
+
path: "/__health",
|
|
8714
|
+
initialDelaySeconds: 5,
|
|
8715
|
+
timeoutSeconds: 1,
|
|
8716
|
+
periodSeconds: 30,
|
|
8717
|
+
failureThreshold: 3,
|
|
8718
|
+
};
|
|
8719
|
+
exports.defaultLivenessProbe = {
|
|
8720
|
+
...exports.defaultStartupProbe,
|
|
8721
|
+
initialDelaySeconds: 0,
|
|
8722
|
+
timeoutSeconds: 10,
|
|
8723
|
+
periodSeconds: 30,
|
|
8724
|
+
failureThreshold: 3,
|
|
8725
|
+
};
|
|
9177
8726
|
//# sourceMappingURL=googleCloudRun.js.map
|
|
9178
8727
|
|
|
9179
8728
|
/***/ }),
|
|
@@ -9417,7 +8966,9 @@ const getCustomJobs = (context) => {
|
|
|
9417
8966
|
return injectDefaultVarsInCustomJobs(context, rawJobs);
|
|
9418
8967
|
};
|
|
9419
8968
|
const createJobsForComponentContext = (context) => {
|
|
9420
|
-
const buildJobs =
|
|
8969
|
+
const buildJobs = context.build.type !== "disabled"
|
|
8970
|
+
? build_1.BUILD_TYPES[context.build.buildType].jobs(context)
|
|
8971
|
+
: [];
|
|
9421
8972
|
const deployJobs = context.componentConfig.deploy !== false
|
|
9422
8973
|
? deploy_1.DEPLOY_TYPES[context.componentConfig.deploy.type].jobs(context)
|
|
9423
8974
|
: [];
|
|
@@ -300553,14 +300104,6 @@ module.exports = require("path");
|
|
|
300553
300104
|
|
|
300554
300105
|
/***/ }),
|
|
300555
300106
|
|
|
300556
|
-
/***/ 58034:
|
|
300557
|
-
/***/ ((module) => {
|
|
300558
|
-
|
|
300559
|
-
"use strict";
|
|
300560
|
-
module.exports = require("path/posix");
|
|
300561
|
-
|
|
300562
|
-
/***/ }),
|
|
300563
|
-
|
|
300564
300107
|
/***/ 85477:
|
|
300565
300108
|
/***/ ((module) => {
|
|
300566
300109
|
|