Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feat/sequence-update
Browse files Browse the repository at this point in the history
  • Loading branch information
Quan Nguyen Ba committed Nov 19, 2024
2 parents 64a4abd + a1a85de commit 77acc90
Show file tree
Hide file tree
Showing 53 changed files with 4,753 additions and 136 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/run-test-and-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Build packages
run: npm run build

- name: Run Unit Tests
run: npm run test

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/run-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Build packages
run: npm run build

- name: Run Unit Tests
run: npm run test

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![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

Expand All @@ -10,7 +10,7 @@ This package provides core functionalities for implementing the Command Query Re

## 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.

## Features

Expand Down Expand Up @@ -95,5 +95,6 @@ $ npm run release
- Serverless framework: https://www.serverless.com/framework/docs

## License

Copyright © 2024, Murakami Business Consulting, Inc. https://www.mbc-net.com/
This project and sub projects are under the MIT License.
2 changes: 1 addition & 1 deletion lerna.json
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/*"]
}
19 changes: 9 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"bugs": {
"url": "https://github.com/mbc-net/mbc-cqrs-serverless/issues"
},
"homepage": "https://mbc-net.github.io/mbc-cqrs-serverless-doc/",
"homepage": "https://mbc-cqrs-serverless.mbc-net.com/",
"devDependencies": {
"@aws-sdk/client-dynamodb": "^3.478.0",
"@aws-sdk/client-s3": "^3.478.0",
Expand Down
33 changes: 31 additions & 2 deletions packages/cli/README.md
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.
7 changes: 3 additions & 4 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mbc-cqrs-serverless/cli",
"version": "0.1.21-beta.0",
"version": "0.1.30-beta.0",
"description": "a CLI to get started with MBC CQRS serverless framework",
"keywords": [
"mbc",
Expand Down Expand Up @@ -38,7 +38,7 @@
"bugs": {
"url": "https://github.com/mbc-net/mbc-cqrs-serverless/issues"
},
"homepage": "https://mbc-net.github.io/mbc-cqrs-serverless-doc/",
"homepage": "https://mbc-cqrs-serverless.mbc-net.com/",
"publishConfig": {
"access": "public"
},
Expand All @@ -47,7 +47,6 @@
"rimraf": "^5.0.5"
},
"devDependencies": {
"@faker-js/faker": "^8.3.1",
"@mbc-cqrs-serverless/core": "^0.1.21-beta.0"
"@faker-js/faker": "^8.3.1"
}
}
42 changes: 42 additions & 0 deletions packages/cli/src/actions/new.action.get-package-version.spec.ts
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 packages/cli/src/actions/new.action.is-latest-version.spec.ts
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)
})
})
Loading

0 comments on commit 77acc90

Please sign in to comment.