Skip to content

Commit

Permalink
Merge pull request #244 from coollabsio/v2.2.3
Browse files Browse the repository at this point in the history
v2.2.3
  • Loading branch information
andrasbacsai committed Mar 31, 2022
2 parents d9b74ad + 17d56aa commit 80f95a4
Show file tree
Hide file tree
Showing 10 changed files with 694 additions and 23 deletions.
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "coolify",
"description": "An open-source & self-hostable Heroku / Netlify alternative.",
"version": "2.2.2",
"version": "2.2.3",
"license": "AGPL-3.0",
"scripts": {
"dev": "docker-compose -f docker-compose-dev.yaml up -d && NODE_ENV=development svelte-kit dev",
Expand Down
2 changes: 2 additions & 0 deletions src/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ declare namespace App {
isRunning: boolean;
appId: string;
readOnly: boolean;
source: string;
settings: string;
}
}

Expand Down
23 changes: 15 additions & 8 deletions src/lib/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import child from 'child_process';
import util from 'util';
import { dev } from '$app/env';
import * as Sentry from '@sentry/node';
import { uniqueNamesGenerator, Config, adjectives, colors, animals } from 'unique-names-generator';
import { uniqueNamesGenerator, adjectives, colors, animals } from 'unique-names-generator';
import type { Config } from 'unique-names-generator';

import * as db from '$lib/database';
import { buildLogQueue } from './queues';
Expand Down Expand Up @@ -107,11 +108,6 @@ export function getEngine(engine) {
return engine === '/var/run/docker.sock' ? 'unix:///var/run/docker.sock' : engine;
}

// export async function saveSshKey(destination) {
// return await asyncExecShell(
// `echo '${destination.sshPrivateKey}' > /tmp/id_rsa_${destination.id} && chmod 600 /tmp/id_rsa_${destination.id}`
// );
// }
export async function removeContainer(id, engine) {
const host = getEngine(engine);
try {
Expand All @@ -133,8 +129,9 @@ export const removeDestinationDocker = async ({ id, engine }) => {
};

export const createDirectories = async ({ repository, buildId }) => {
const repodir = `/tmp/build-sources/${repository}/`;
const workdir = `/tmp/build-sources/${repository}/${buildId}`;
const dashedRepository = dashify(repository);
const repodir = `/tmp/build-sources/${dashedRepository}/`;
const workdir = `/tmp/build-sources/${dashedRepository}/${buildId}`;

await asyncExecShell(`mkdir -p ${workdir}`);

Expand All @@ -151,3 +148,13 @@ export function generateTimestamp() {
export function getDomain(domain) {
return domain?.replace('https://', '').replace('http://', '');
}

export function dashify(str: string, options?: any): string {
if (typeof str !== 'string') return str;
return str
.trim()
.replace(/\W/g, (m) => (/[À-ž]/.test(m) ? m : '-'))
.replace(/^-+|-+$/g, '')
.replace(/-{2,}/g, (m) => (options && options.condense ? '-' : m))
.toLowerCase();
}
10 changes: 10 additions & 0 deletions src/lib/components/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,13 @@ export function getDomain(domain) {
export function generateRemoteEngine(destination) {
return `ssh://${destination.user}@${destination.ipAddress}:${destination.port}`;
}

export function dashify(str: string, options?: any): string {
if (typeof str !== 'string') return str;
return str
.trim()
.replace(/\W/g, (m) => (/[À-ž]/.test(m) ? m : '-'))
.replace(/^-+|-+$/g, '')
.replace(/-{2,}/g, (m) => (options && options.condense ? '-' : m))
.toLowerCase();
}
3 changes: 2 additions & 1 deletion src/lib/database/applications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ export async function getApplicationWebhook({ projectId, branch }) {
destinationDocker: true,
settings: true,
gitSource: { include: { githubApp: true, gitlabApp: true } },
secrets: true
secrets: true,
persistentStorage: true
}
});
if (!application) {
Expand Down
9 changes: 0 additions & 9 deletions src/lib/github.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/routes/new/source/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</div>

<div class="flex-col space-y-2 pb-10 text-center">
<div class="text-xl font-bold text-white">Offical providers</div>
<div class="text-xl font-bold text-white">Official providers</div>
<div class="flex justify-center space-x-2">
<button class="w-32" on:click={() => setPredefined('github')}>GitHub.com</button>
<button class="w-32" on:click={() => setPredefined('gitlab')}>GitLab.com</button>
Expand Down
3 changes: 1 addition & 2 deletions src/routes/sources/[id]/newGithubApp.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@

<script>
import { dev } from '$app/env';
import { getDomain } from '$lib/components/common';
import { dashify } from '$lib/github';
import { getDomain, dashify } from '$lib/components/common';
export let source;
export let settings;
Expand Down
2 changes: 1 addition & 1 deletion src/routes/webhooks/github/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export const post: RequestHandler = async (event) => {
'sha256=' + hmac.update(JSON.stringify(body)).digest('hex'),
'utf8'
);
const checksum = Buffer.from(githubSignature, 'utf8');
if (!dev) {
const checksum = Buffer.from(githubSignature, 'utf8');
if (checksum.length !== digest.length || !crypto.timingSafeEqual(digest, checksum)) {
return {
status: 500,
Expand Down

0 comments on commit 80f95a4

Please sign in to comment.