-
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 branch 'main' of github.com:mbc-net/mbc-cqrs-serverless into fe…
…at/sequence-update
- Loading branch information
Showing
69 changed files
with
5,590 additions
and
391 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,80 @@ | ||
name: Run test develop | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
|
||
permissions: | ||
contents: write | ||
actions: read | ||
checks: write | ||
|
||
jobs: | ||
unit_tests: | ||
name: Unit Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
cache: npm | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Build packages | ||
run: npm run build | ||
|
||
- name: Run Unit Tests | ||
run: npm run test | ||
|
||
- name: Unit Test Report | ||
uses: dorny/test-reporter@v1 | ||
if: success() || failure() | ||
with: | ||
name: Unit Tests Reporter | ||
path: report/unit.xml | ||
reporter: jest-junit | ||
fail-on-error: 'true' | ||
|
||
e2e_tests: | ||
name: E2e Test For Core package | ||
needs: unit_tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
cache: npm | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Build test | ||
run: npx lerna run build:test --scope=@mbc-cqrs-serverless/core | ||
|
||
- name: Run e2e Tests | ||
run: npx lerna run test:e2e --scope=@mbc-cqrs-serverless/core | ||
|
||
- uses: actions/upload-artifact@v4 | ||
name: 'upload artifact' | ||
if: success() || failure() | ||
with: | ||
name: my-artifacts | ||
path: ./packages/core/test/scripts/*.out.txt | ||
|
||
- name: E2E Test Report | ||
uses: dorny/test-reporter@v1 | ||
if: success() || failure() | ||
with: | ||
name: E2E Core Tests Reporter | ||
path: report/e2e-core.xml | ||
reporter: jest-junit | ||
fail-on-error: 'true' |
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.35-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.