diff --git a/src/app.d.ts b/src/app.d.ts index 2ebfc021b..0557299b9 100644 --- a/src/app.d.ts +++ b/src/app.d.ts @@ -13,6 +13,8 @@ declare namespace App { isRunning: boolean; appId: string; readOnly: boolean; + source: string; + settings: string; } } diff --git a/src/lib/common.ts b/src/lib/common.ts index 996ec4750..c7f229b0e 100644 --- a/src/lib/common.ts +++ b/src/lib/common.ts @@ -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'; @@ -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 { @@ -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}`); @@ -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(); +} diff --git a/src/lib/components/common.ts b/src/lib/components/common.ts index 890338597..b9b3ac982 100644 --- a/src/lib/components/common.ts +++ b/src/lib/components/common.ts @@ -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(); +} diff --git a/src/lib/github.ts b/src/lib/github.ts deleted file mode 100644 index 0fb68ea0a..000000000 --- a/src/lib/github.ts +++ /dev/null @@ -1,9 +0,0 @@ -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(); -} diff --git a/src/routes/sources/[id]/newGithubApp.svelte b/src/routes/sources/[id]/newGithubApp.svelte index 80139acc2..c8cb4f6f3 100644 --- a/src/routes/sources/[id]/newGithubApp.svelte +++ b/src/routes/sources/[id]/newGithubApp.svelte @@ -30,8 +30,7 @@