Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CI/DI #17

Merged
merged 3 commits into from
Mar 1, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/all-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

- name: Install dependencies
run: |
npm install -g pnpm rollup
npm install -g pnpm
pnpm install

- name: Run tests
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,7 @@
"typescript": "^5.2.2"
},
"packageManager": "[email protected]",
"dependencies": {}
"dependencies": {
"rollup": "^4.12.0"
}
}
9 changes: 1 addition & 8 deletions packages/shopify/src/bot/flows/info.flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,8 @@ export default addKeyword(EVENTS.ACTION)
.addAction(async (ctx, { state, flowDynamic }) => {
const runnable = ClassManager.hub().get<RunnableV2>('runnablev2')
const channel = ClassManager.hub().get('channel')
const store = ClassManager.hub().get('storeInformation')
let context: string;

if (store) {
context = Object.entries(store).map(s => s.join(': ')).join('\n')
}else {
context = await channel.getStoreInfo()
}

const context = await channel.getStoreInfo()

const textLarge = await runnable.toInfo(ctx.body, context, state)
const chunks = textLarge.split(/(?<!\d)\.\s+/g)
Expand Down
43 changes: 26 additions & 17 deletions packages/shopify/src/channels/shopify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import axios from "axios"
import { Channel } from "./respository"
import { Products, ShopDetail } from "../types"
import { cleanHtml } from "../utils/cleanHtml"
import { ClassManager } from "../ioc"


/**
Expand Down Expand Up @@ -38,23 +39,31 @@ class Shopify implements Channel {

try {
const url = `${this.buildUrl}/shop.json`
const { data } = await axios.get<{ shop: ShopDetail }>(url, {
headers: {
'Content-Type': 'application/json',
'X-Shopify-Access-Token': this.apiKey,
}
})

const info = [
`Name: ${data.shop.name}`,
`Email: ${data.shop.email}`,
`City: ${data.shop.city}`,
`Address: ${data.shop.zip}, ${data.shop.city}`,
`Domain: ${data.shop.domain}`,
`Currency: ${data.shop.currency}`,
`Claims and complaints: For claims, complaints,
and refunds, please leave us an email at the following address ${data.shop.email}`
].join('\n')
const store = ClassManager.hub().get('storeInformation')

let info: string;

if (!store) {
const { data } = await axios.get<{ shop: ShopDetail }>(url, {
headers: {
'Content-Type': 'application/json',
'X-Shopify-Access-Token': this.apiKey,
}
})

info = [
`Name: ${data.shop.name}`,
`Email: ${data.shop.email}`,
`City: ${data.shop.city}`,
`Address: ${data.shop.zip}, ${data.shop.city}`,
`Domain: ${data.shop.domain}`,
`Currency: ${data.shop.currency}`,
`Claims and complaints: For claims, complaints,
and refunds, please leave us an email at the following address ${data.shop.email}`
].join('\n')
}else {
info = Object.entries(store).map(s => s.join(': ')).join('\n')
}

return info

Expand Down
Loading
Loading