-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from mbc-net/feat/isolate-docker
[CLI]: isolate docker environment for each project
- Loading branch information
Showing
11 changed files
with
93 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"$schema": "node_modules/lerna/schemas/lerna-schema.json", | ||
"version": "0.1.40-beta.0", | ||
"version": "0.1.41-beta.0", | ||
"packages": ["packages/*"] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
49 changes: 49 additions & 0 deletions
49
packages/cli/src/actions/new.action.update-env-local.spec.ts
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,49 @@ | ||
import { readFileSync, writeFileSync } from 'fs' | ||
|
||
import { exportsForTesting } from './new.action' | ||
|
||
const { updateEnvLocal } = exportsForTesting | ||
|
||
jest.mock('fs') | ||
|
||
describe('updateEnvLocal', () => { | ||
const mockEnvContent = ` | ||
# name of application | ||
APP_NAME=%%projectName%% | ||
# name of docker compose | ||
COMPOSE_PROJECT_NAME=%%projectName%% | ||
` | ||
|
||
const envPath = './.env.local' | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks() | ||
}) | ||
|
||
it('should update the specified value in the .env.local file', () => { | ||
const searchValue = '%%projectName%%' | ||
const replaceValue = 'new-project-name' | ||
|
||
;(readFileSync as jest.Mock).mockReturnValue(mockEnvContent) | ||
|
||
updateEnvLocal(envPath, searchValue, replaceValue) | ||
|
||
expect(readFileSync).toHaveBeenCalledWith(envPath, 'utf8') | ||
|
||
const expectedContent = mockEnvContent.replaceAll(searchValue, replaceValue) | ||
expect(writeFileSync).toHaveBeenCalledWith(envPath, expectedContent) | ||
}) | ||
|
||
it('should not change the file content if searchValue is not found', () => { | ||
const searchValue = 'non-existent-value' | ||
const replaceValue = 'new-project-name' | ||
|
||
;(readFileSync as jest.Mock).mockReturnValue(mockEnvContent) | ||
|
||
updateEnvLocal(envPath, searchValue, replaceValue) | ||
|
||
expect(readFileSync).toHaveBeenCalledWith(envPath, 'utf8') | ||
|
||
expect(writeFileSync).toHaveBeenCalledWith(envPath, mockEnvContent) | ||
}) | ||
}) |
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
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