-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1979f77
commit 3e5870c
Showing
6 changed files
with
66 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Command } from 'commander'; | ||
import { projectConfig } from '../../config/project'; | ||
|
||
export const composeCommand = () => { | ||
const command = new Command(); | ||
const config = projectConfig(); | ||
|
||
command | ||
.name('compose') | ||
.summary('Container orchestration command for DEMS') | ||
.description( | ||
'Aids in container orchestration for services in DEMS.\n' + | ||
'Uses Compose under the hood.', | ||
) | ||
.action(async (options) => {}); | ||
|
||
return command; | ||
}; | ||
|
||
export default composeCommand(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const COMPOSE_SPEC_JSON_FILE_RULE = | ||
'https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json'; | ||
|
||
const downloadComposeSpecJSON = ( | ||
url: URL = new URL(COMPOSE_SPEC_JSON_FILE_RULE), | ||
) => { | ||
console.log(url.toString()); | ||
}; | ||
|
||
// Execute script only if called directly | ||
if (import.meta.path === Bun.main) { | ||
downloadComposeSpecJSON(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,34 @@ | ||
import fs from 'node:fs'; | ||
import path from 'path'; | ||
import { projectConfig } from '../config/project'; | ||
import type { ComposeFilesParams } from './interfaces'; | ||
|
||
export const composeFiles = ({ | ||
filesDir = '.dems', | ||
prefix = 'compose', | ||
filesDir = 'src/compose', | ||
dockerDir = '.docker', | ||
repos = projectConfig().repositories, | ||
reposRoot = projectConfig().paths.repos_root, | ||
}: ComposeFilesParams): string => { | ||
let composeFileString = ''; | ||
const composeDirs = []; | ||
|
||
const readFilesRecursively = (currentDir: string) => { | ||
const files = fs.readdirSync(currentDir); | ||
for (const dir of repos) { | ||
composeDirs.push(`${reposRoot}/${dir}/${filesDir}`); | ||
} | ||
|
||
for (const dir of composeDirs) { | ||
const files = fs.readdirSync(dir); | ||
for (const file of files) { | ||
const filePath = path.join(currentDir, file); | ||
const isDirectory = fs.statSync(filePath).isDirectory(); | ||
|
||
if (isDirectory && file === dockerDir) { | ||
readFilesRecursively(filePath); | ||
} else if (file.match(`${prefix}.*.yml`)) { | ||
composeFileString += ` -f ${filePath}`; | ||
if (file.match(`${prefix}*.yml`)) { | ||
composeFileString += ` -f ${path.join(dir, file)}`; | ||
} | ||
} | ||
}; | ||
|
||
readFilesRecursively(filesDir); | ||
} | ||
|
||
return composeFileString; | ||
}; | ||
|
||
// Execute script only if called directly | ||
if (import.meta.path === Bun.main) { | ||
console.log(composeFiles({ prefix: 'compose', filesDir: '.dems' })); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters