Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 16 additions & 30 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
"node": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"ignorePatterns": ["dist", "types", "package-lock.json", "react-example"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"ignorePatterns": ["dist", "package-lock.json", "react-example"],
"overrides": [
{
"files": ["**/*.ts", "**/*.tsx"],
Expand All @@ -24,10 +21,7 @@
},
"plugins": ["@typescript-eslint"],
"rules": {
"quotes": [
"error",
"single"
]
"quotes": ["error", "single"]
}
}
],
Expand All @@ -36,31 +30,23 @@
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
"sort-imports-es6-autofix"
],
"plugins": ["@typescript-eslint", "sort-imports-es6-autofix"],
"rules": {
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"semi": [
"error",
"never"
],
"indent": ["error", 2],
"linebreak-style": ["error", "unix"],
"semi": ["error", "never"],
"no-multi-spaces": ["error"],
"no-unused-vars": "error",
"comma-dangle": "error",
"object-curly-spacing": ["error", "never"],
"sort-imports-es6-autofix/sort-imports-es6": [2, {
"ignoreCase": false,
"ignoreMemberSort": false,
"memberSyntaxSortOrder": ["none", "all", "multiple", "single"]
}],
"sort-imports-es6-autofix/sort-imports-es6": [
2,
{
"ignoreCase": false,
"ignoreMemberSort": false,
"memberSyntaxSortOrder": ["none", "all", "multiple", "single"]
}
],
"max-len": ["error", {"code": 120}]
}
}
112 changes: 56 additions & 56 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,53 +11,53 @@ jobs:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v3
- name: 'Install Node'
uses: actions/setup-node@v3
with:
node-version: '20.x'
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: true
- name: Run ESLint
run: pnpm run lint
- uses: actions/checkout@v3
- name: 'Install Node'
uses: actions/setup-node@v3
with:
node-version: '20.x'
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: true
- name: Run ESLint
run: pnpm run lint
test:
name: Test Code Base
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v3
- name: 'Install Node'
uses: actions/setup-node@v3
with:
node-version: '20.x'
- name: Install xsel
run: sudo apt-get install -y xsel
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: true
- name: 'Test'
run: pnpm run turbo:coverage
- name: 'Report Core Coverage'
if: always() # Also generate the report if tests are failing
uses: davelosert/vitest-coverage-report-action@v1
with:
json-summary-path: './coverage/coverage-summary.json'
json-final-path: './coverage/coverage-final.json'
vite-config-path: './configs/vitest/vitest.config.ts'
- name: 'Report CLI Coverage'
if: always() # Also generate the report if tests are failing
uses: davelosert/vitest-coverage-report-action@v1
with:
json-summary-path: './packages/cli/coverage/coverage-summary.json'
json-final-path: './packages/cli/coverage/coverage-final.json'
vite-config-path: './packages/cli/vitest.config.ts'
- uses: actions/checkout@v3
- name: 'Install Node'
uses: actions/setup-node@v3
with:
node-version: '20.x'
- name: Install xsel
run: sudo apt-get install -y xsel
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: true
- name: 'Test'
run: pnpm run turbo:coverage
- name: 'Report Core Coverage'
if: always() # Also generate the report if tests are failing
uses: davelosert/vitest-coverage-report-action@v1
with:
json-summary-path: './coverage/coverage-summary.json'
json-final-path: './coverage/coverage-final.json'
vite-config-path: './configs/vitest/vitest.config.ts'
- name: 'Report CLI Coverage'
if: always() # Also generate the report if tests are failing
uses: davelosert/vitest-coverage-report-action@v1
with:
json-summary-path: './packages/cli/coverage/coverage-summary.json'
json-final-path: './packages/cli/coverage/coverage-final.json'
vite-config-path: './packages/cli/vitest.config.ts'
design-request:
name: Test Design Request Creation
runs-on: ubuntu-latest
Expand All @@ -66,19 +66,19 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- name: 'Install Node'
uses: actions/setup-node@v3
with:
node-version: '20.x'
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: false
- name: 'Install Deps'
run: cd packages/cli && pnpm install && pnpm run setup:dev
- name: 'Setup CLI'
run: cd packages/cli/dist && node index.mjs config --api-host ${{vars.API_HOST}} --ws-host ${{vars.WEBSOCKET_HOST}} --api-key ${{secrets.API_KEY}} --user-id GITHUB-ACTIONS
- name: 'Test'
run: cd packages/cli/dist && node index.mjs mb-client design-request new --title $(date +'%Y-%m-%d') --subtitle ${GITHUB_REF##*/} --occasion baby --style 6117 --book-size 8x8 --cover-type sc --page-type sp --image-density low --image-filtering-level best --embellishment-level lots --text-sticker-level few --image-set 00-nice-and-rome
- uses: actions/checkout@v3
- name: 'Install Node'
uses: actions/setup-node@v3
with:
node-version: '20.x'
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: false
- name: 'Install Deps'
run: cd packages/cli && pnpm install && pnpm run setup:dev
- name: 'Setup CLI'
run: cd packages/cli/dist && node index.mjs config --api-host ${{vars.API_HOST}} --ws-host ${{vars.WEBSOCKET_HOST}} --api-key ${{secrets.API_KEY}} --user-id GITHUB-ACTIONS
- name: 'Test'
run: cd packages/cli/dist && node index.mjs mb-client design-request new --title $(date +'%Y-%m-%d') --subtitle ${GITHUB_REF##*/} --occasion baby --style 6117 --book-size 8x8 --cover-type sc --page-type sp --image-density low --image-filtering-level best --embellishment-level lots --text-sticker-level few --image-set 00-nice-and-rome
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.next/
_next/
__tmp__/
dist/
node_modules/
.strapi/
pnpm-lock.yaml
14 changes: 14 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"quoteProps": "as-needed",
"jsxSingleQuote": true,
"trailingComma": "none",
"bracketSpacing": false,
"bracketSameLine": false,
"arrowParens": "always",
"singleAttributePerLine": true
}
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@

![GitHub CI](https://github.com/magiclabs-ai/mb-client/actions/workflows/ci.yml/badge.svg) [![npm version](https://img.shields.io/npm/v/@magiclabs.ai/magicbook-client.svg)](https://www.npmjs.com/package/@magiclabs.ai/magicbook-client)

# mb-client

TypeScript monorepo that contains `@magiclabs.ai/magicbook-cli` and `@magiclabs.ai/magicbook-client`

## Usage

You can run the coverage for all the packages at once using the following command

```bash
pnpm run turbo:coverage
```

## Deploy

You can deploy all the packages at once using the command

```bash
pnpm run pub:release
```
5 changes: 1 addition & 4 deletions configs/tsconfigs/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": [
"ESNext",
"DOM"
],
"lib": ["ESNext", "DOM"],
"moduleResolution": "Node",
"strict": true,
"resolveJsonModule": true,
Expand Down
9 changes: 2 additions & 7 deletions configs/vitest/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@ export default defineConfig({
]
},
test: {
setupFiles: [
'./core/tests/mocks/fetch.ts'
],
exclude: [
'node_modules',
'packages'
],
setupFiles: ['./core/tests/mocks/fetch.ts'],
exclude: ['node_modules', 'packages'],
environment: 'jsdom',
coverage: {
all: true,
Expand Down
11 changes: 8 additions & 3 deletions core/data/design-request.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {DesignRequestEventDetail} from '../models/design-request'
import {DesignRequestEventDetail} from '../types/design-request'

export const states = [
'new',
Expand All @@ -16,8 +16,13 @@ export const states = [
'error',
'cancelled'
] as const
export const statesToCloseWS: ReadonlyArray<typeof states[number]> = ['error', 'timeout', 'ready', 'cancelled'] as const
export const statesToReport: ReadonlyArray<typeof states[number]> = ['error', 'timeout'] as const
export const statesToCloseWS: ReadonlyArray<(typeof states)[number]> = [
'error',
'timeout',
'ready',
'cancelled'
] as const
export const statesToReport: ReadonlyArray<(typeof states)[number]> = ['error', 'timeout'] as const
export const isDesignRequestSubmitted = (state: string) => !['new', 'ingesting'].includes(state)
export const canSubmitDesignRequest = (state: string) => ['new', 'ingesting', 'ready'].includes(state)
export const occasions = [
Expand Down
Loading