diff --git a/src/cleanupFiles.ts b/src/cleanupFiles.ts index c5b5e60..85cbaa5 100644 --- a/src/cleanupFiles.ts +++ b/src/cleanupFiles.ts @@ -2,7 +2,7 @@ import { walk } from "@std/fs"; export async function cleanupFiles(localPath: string, files: string[]) { const allFiles = await Array.fromAsync( - walk(localPath, { includeDirs: false }) + walk(localPath, { includeDirs: false }), ); const diff = allFiles.filter((f) => !files.includes(f.path)); console.log(`TODO: Cleanup ${diff.length} files`); diff --git a/src/cloneRepo.ts b/src/cloneRepo.ts index 6ae0a28..71e51ad 100644 --- a/src/cloneRepo.ts +++ b/src/cloneRepo.ts @@ -8,13 +8,14 @@ export interface TRepo { export async function cloneRepo( logger: TLogger, repo: string, - branch: string + branch: string, ): Promise { const path = await Deno.makeTempDir(); logger.log(`Cloning ${repo} on branch ${branch}`); const lines = - await $`git clone --branch ${branch} --single-branch --depth 1 ${repo} ${path}`.lines(); + await $`git clone --branch ${branch} --single-branch --depth 1 ${repo} ${path}` + .lines(); lines.forEach((line) => logger.log(line)); return { path }; diff --git a/src/copyFiles.ts b/src/copyFiles.ts index e478828..0cd4fab 100644 --- a/src/copyFiles.ts +++ b/src/copyFiles.ts @@ -7,7 +7,7 @@ export async function copyFiles( repoPath: string, remotePath: string, localPath: string, - files: string[] + files: string[], ): Promise { const baseFolder = resolve(repoPath, remotePath); for (const file of files) { diff --git a/src/getInstalledVersion.ts b/src/getInstalledVersion.ts index bd582ce..db88ce4 100644 --- a/src/getInstalledVersion.ts +++ b/src/getInstalledVersion.ts @@ -10,30 +10,30 @@ const ListSchema = v.array( v.string(), v.object({ version: v.string(), - }) - ) + }), + ), ), devDependencies: v.optional( v.record( v.string(), v.object({ version: v.string(), - }) - ) + }), + ), ), - }) + }), ); export async function getInstalledVersion( - name: string + name: string, ): Promise { const currentVersion = await $`pnpm list --depth 0 --json ${name}`.json(); const result = v.parse(ListSchema, currentVersion); if (result.length === 0) { return null; } - const deps = - result[0].dependencies?.[name] ?? result[0].devDependencies?.[name]; + const deps = result[0].dependencies?.[name] ?? + result[0].devDependencies?.[name]; if (!deps) { return null; } diff --git a/src/installDeps.ts b/src/installDeps.ts index a1d5d5f..eeddca3 100644 --- a/src/installDeps.ts +++ b/src/installDeps.ts @@ -1,5 +1,5 @@ import $ from "@david/dax"; -import { parseRange, parse as parseVersion, satisfies } from "@std/semver"; +import { parse as parseVersion, parseRange, satisfies } from "@std/semver"; import { getInstalledVersion } from "./getInstalledVersion.ts"; import { readPackageJson } from "./readPackageJson.ts"; @@ -8,7 +8,7 @@ export async function installDeps(deps: Record): Promise { const packagesToInstall: string[] = []; for (const [name, requiredRange] of Object.entries(deps)) { const isInstalled = Boolean( - currentPkg.dependencies?.[name] || currentPkg.devDependencies?.[name] + currentPkg.dependencies?.[name] || currentPkg.devDependencies?.[name], ); if (!isInstalled) { // Install the dependency @@ -24,7 +24,7 @@ export async function installDeps(deps: Record): Promise { } if (!satisfies(parseVersion(currentVersion), parseRange(requiredRange))) { console.error( - `Version mismatch for ${name}: required ${requiredRange}, found ${currentVersion}` + `Version mismatch for ${name}: required ${requiredRange}, found ${currentVersion}`, ); continue; } diff --git a/src/resolveDeps.ts b/src/resolveDeps.ts index ecba496..5ae184a 100644 --- a/src/resolveDeps.ts +++ b/src/resolveDeps.ts @@ -12,7 +12,7 @@ export async function resolveDeps( repoPath: string, remotePath: string, baseFiles: string[], - remotePkg: TPackageJson + remotePkg: TPackageJson, ): Promise { const baseFolder = resolve(repoPath, remotePath); const project = new Project(); @@ -77,7 +77,7 @@ export async function resolveDeps( return; } throw new Error( - `Could not resolve module ${moduleSpecifier} in ${directory}` + `Could not resolve module ${moduleSpecifier} in ${directory}`, ); } } @@ -88,7 +88,7 @@ export async function resolveDeps( */ async function resolveNodeFile( path: string, - allowDirectory = true + allowDirectory = true, ): Promise { if (await exists(path, { isFile: true })) { return path; @@ -111,7 +111,7 @@ async function resolveNodeFile( function findDependency( deps: Record, - moduleSpecifier: string + moduleSpecifier: string, ): { name: string; version: string } | null { for (const [mode, version] of Object.entries(deps)) { if (mode === moduleSpecifier) { diff --git a/src/resolveFiles.ts b/src/resolveFiles.ts index 5fad410..bc8581d 100644 --- a/src/resolveFiles.ts +++ b/src/resolveFiles.ts @@ -4,14 +4,14 @@ import { resolve } from "@std/path"; export async function resolveFiles( repoPath: string, remotePath: string, - patterns: string[] + patterns: string[], ): Promise { const baseFolder = resolve(repoPath, remotePath); const files = new Set(); for (const pattern of patterns) { const patFiles = await Array.fromAsync( - expandGlob(pattern, { root: baseFolder, includeDirs: false }) + expandGlob(pattern, { root: baseFolder, includeDirs: false }), ); for await (const file of patFiles) { files.add(file.path); diff --git a/src/runJob.ts b/src/runJob.ts index 149096a..9d949de 100644 --- a/src/runJob.ts +++ b/src/runJob.ts @@ -19,7 +19,7 @@ export async function runJob(job: TConfigJob): Promise { cloned.path, remotePath, baseFiles, - remotePkg + remotePkg, ); await copyFiles(cloned.path, remotePath, localPath, allDeps.files); await installDeps(allDeps.dependencies);