-
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 remote-tracking branch 'origin/develop' into feat/sequence-update
- Loading branch information
Showing
53 changed files
with
4,753 additions
and
136 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
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.21-beta.0", | ||
"version": "0.1.30-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,39 @@ | ||
![MBC CQRS serverless framework](https://mbc-net.github.io/mbc-cqrs-serverless-doc/img/mbc-cqrs-serverless.png) | ||
![MBC CQRS serverless framework](https://mbc-cqrs-serverless.mbc-net.com/img/mbc-cqrs-serverless.png) | ||
|
||
# MBC CQRS serverless framework CLI package | ||
|
||
## Description | ||
|
||
The MBC CLI is a command-line interface tool that helps you to initialize your mbc-cqrs-serverless applications. | ||
|
||
## Installation | ||
|
||
To install `mbc`, run: | ||
|
||
```bash | ||
npm install -g @mbc-cqrs-serverless/cli | ||
``` | ||
|
||
## Usage | ||
|
||
### `mbc new|n [projectName@version]` | ||
|
||
There are 3 usages for the new command: | ||
|
||
- `mbc new` | ||
- Creates a new project in the current folder using a default name with the latest framework version. | ||
- `mbc new [projectName]` | ||
- Creates a new project in the `projectName` folder using the latest framework version. | ||
- `mbc new [projectName@version]` | ||
- If the specified version exists, the CLI uses that exact version. | ||
- If the provided version is a prefix, the CLI uses the latest version matching that prefix. | ||
- If no matching version is found, the CLI logs an error and provides a list of available versions for the user. | ||
|
||
## Documentation | ||
|
||
Visit https://mbc-net.github.io/mbc-cqrs-serverless-doc/ to view the full documentation. | ||
Visit https://mbc-cqrs-serverless.mbc-net.com/ to view the full documentation. | ||
|
||
## License | ||
|
||
Copyright © 2024, Murakami Business Consulting, Inc. https://www.mbc-net.com/ | ||
This project and sub projects are under the MIT License. |
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
42 changes: 42 additions & 0 deletions
42
packages/cli/src/actions/new.action.get-package-version.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,42 @@ | ||
import { execSync } from 'child_process' | ||
|
||
import { exportsForTesting } from './new.action' | ||
|
||
const { getPackageVersion } = exportsForTesting | ||
|
||
jest.mock('child_process', () => ({ | ||
execSync: jest.fn(), | ||
})) | ||
|
||
describe('getPackageVersion', () => { | ||
const mockExecSync = execSync as jest.MockedFunction<typeof execSync> | ||
const packageName = '@mbc-cqrs-serverless/core' | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks() | ||
}) | ||
|
||
it('should return the latest version when isLatest is true', () => { | ||
const mockLatestVersion = '1.2.3' | ||
mockExecSync.mockReturnValue(Buffer.from(`${mockLatestVersion}\n`)) | ||
|
||
const result = getPackageVersion(packageName, true) | ||
|
||
expect(mockExecSync).toHaveBeenCalledWith( | ||
`npm view ${packageName} dist-tags.latest`, | ||
) | ||
expect(result).toEqual([mockLatestVersion]) | ||
}) | ||
|
||
it('should return all versions when isLatest is false', () => { | ||
const mockVersions = ['1.0.0', '1.1.0', '1.2.0'] | ||
mockExecSync.mockReturnValue(Buffer.from(JSON.stringify(mockVersions))) | ||
|
||
const result = getPackageVersion(packageName, false) | ||
|
||
expect(mockExecSync).toHaveBeenCalledWith( | ||
`npm view ${packageName} versions --json`, | ||
) | ||
expect(result).toEqual(mockVersions) | ||
}) | ||
}) |
46 changes: 46 additions & 0 deletions
46
packages/cli/src/actions/new.action.is-latest-version.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,46 @@ | ||
import { execSync } from 'child_process' | ||
|
||
import { exportsForTesting } from './new.action' | ||
|
||
const { isLatestCli } = exportsForTesting | ||
|
||
jest.mock('child_process', () => ({ | ||
execSync: jest.fn(), | ||
})) | ||
|
||
jest.mock('fs', () => ({ | ||
readFileSync: jest.fn(() => JSON.stringify({ version: '1.0.0' })), | ||
})) | ||
jest.mock('path', () => ({ | ||
join: jest.fn(() => '/mocked/path/to/package.json'), | ||
})) | ||
|
||
describe('isLatestCli', () => { | ||
const mockExecSync = execSync as jest.MockedFunction<typeof execSync> | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks() | ||
}) | ||
|
||
it('should return true if the current version matches the latest version', () => { | ||
const mockLatestVersion = ['1.0.0'] | ||
mockExecSync.mockReturnValue(Buffer.from(`${mockLatestVersion}\n`)) | ||
|
||
// Run the function | ||
const result = isLatestCli() | ||
|
||
// Assert that the result is true | ||
expect(result).toBe(true) | ||
}) | ||
|
||
it('should return false if the current version does not match the latest version', () => { | ||
const mockLatestVersion = ['1.2.3'] | ||
mockExecSync.mockReturnValue(Buffer.from(`${mockLatestVersion}\n`)) | ||
|
||
// Run the function | ||
const result = isLatestCli() | ||
|
||
// Assert that the result is true | ||
expect(result).toBe(false) | ||
}) | ||
}) |
Oops, something went wrong.