-
Notifications
You must be signed in to change notification settings - Fork 2
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
171429e
commit a87213e
Showing
10 changed files
with
188 additions
and
45 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
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
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,66 @@ | ||
import {magenta} from 'kleur'; | ||
import {existsSync} from 'node:fs'; | ||
import {execute} from '../utils/cmd.utils'; | ||
import {checkDockerVersion} from '../utils/env.utils'; | ||
import {copyTemplateFile} from '../utils/fs.utils'; | ||
import {confirmAndExit} from '../utils/prompt.utils'; | ||
|
||
const TEMPLATE_PATH = '../templates/docker'; | ||
const DESTINATION_PATH = '.'; | ||
|
||
export const start = async () => { | ||
const {valid} = await checkDockerVersion(); | ||
|
||
if (valid === 'error') { | ||
console.error(`Cannot detect Docker version. Is Docker installed on your machine?`); | ||
return; | ||
} | ||
|
||
if (!valid) { | ||
return; | ||
} | ||
|
||
await assertJunoDevConfig(); | ||
await assertDockerCompose(); | ||
|
||
await execute({ | ||
command: 'docker', | ||
args: ['compose', 'up'] | ||
}); | ||
}; | ||
|
||
const assertJunoDevConfig = async () => { | ||
if (existsSync('juno.dev.json')) { | ||
return; | ||
} | ||
|
||
await confirmAndExit( | ||
`A config file is required for development. Would you like the CLI to create a default ${magenta( | ||
'juno.dev.json' | ||
)} for you?` | ||
); | ||
|
||
await copyTemplateFile({ | ||
template: 'juno.dev.json', | ||
sourceFolder: TEMPLATE_PATH, | ||
destinationFolder: DESTINATION_PATH | ||
}); | ||
}; | ||
|
||
const assertDockerCompose = async () => { | ||
if (existsSync('docker-compose.yml')) { | ||
return; | ||
} | ||
|
||
await confirmAndExit( | ||
`The CLI utilizes Docker Compose, which is handy for customizing configurations. Would you like the CLI to generate a default ${magenta( | ||
'docker-compose.yml' | ||
)} file for you?` | ||
); | ||
|
||
await copyTemplateFile({ | ||
template: 'docker-compose.yml', | ||
sourceFolder: TEMPLATE_PATH, | ||
destinationFolder: DESTINATION_PATH | ||
}); | ||
}; |
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
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,35 @@ | ||
import {yellow} from 'kleur'; | ||
import {existsSync} from 'node:fs'; | ||
import {copyFile as fsCopyFile} from 'node:fs/promises'; | ||
import {dirname, join, relative} from 'node:path'; | ||
import {fileURLToPath} from 'url'; | ||
import {confirm} from './prompt.utils'; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = dirname(__filename); | ||
|
||
export const copyTemplateFile = async ({ | ||
sourceFolder, | ||
destinationFolder, | ||
template | ||
}: { | ||
sourceFolder: string; | ||
destinationFolder: string; | ||
template: string; | ||
}) => { | ||
const destination = join(process.cwd(), destinationFolder, template); | ||
|
||
if (existsSync(destination)) { | ||
const answer = await confirm( | ||
`File ${yellow( | ||
relative(process.cwd(), destination) | ||
)} already exists. Do you want to overwrite it?` | ||
); | ||
|
||
if (!answer) { | ||
return; | ||
} | ||
} | ||
|
||
await fsCopyFile(join(__dirname, sourceFolder, template), destination); | ||
}; |
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,12 @@ | ||
services: | ||
juno-satellite: | ||
image: juno-satellite | ||
ports: | ||
- 5987:5987 | ||
volumes: | ||
- my_dapp_new:/juno/.juno | ||
- ./juno.dev.json:/juno/juno.dev.json | ||
- ./target/deploy:/juno/target/deploy/ | ||
|
||
volumes: | ||
my_dapp_new: |
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,16 @@ | ||
{ | ||
"satellite": { | ||
"collections": { | ||
"db": [ | ||
{ | ||
"collection": "demo", | ||
"read": "managed", | ||
"write": "managed", | ||
"memory": "heap" | ||
} | ||
], | ||
"storage": [] | ||
}, | ||
"controllers": [] | ||
} | ||
} |