Skip to content

Commit 029c60d

Browse files
committed
chore: wip
1 parent 429346d commit 029c60d

File tree

12 files changed

+1350
-1584
lines changed

12 files changed

+1350
-1584
lines changed

.stacks/core/alias/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"alias",
2121
"stacks"
2222
],
23-
"module": "dist/index.mjs",
2423
"main": "dist/index.mjs",
24+
"module": "dist/index.mjs",
2525
"types": "dist/index.d.ts",
2626
"contributors": [
2727
"Chris Breuer <chris@ow3.org>"

.stacks/core/chat/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
},
4444
"peerDependencies": {
4545
"@novu/discord": "^0.12.0",
46+
"@novu/ms-teams": "^0.12.0",
4647
"@novu/node": "^0.12.0",
4748
"@novu/slack": "^0.12.0",
4849
"@novu/stateless": "^0.12.0",
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { MsTeamsProvider } from '@novu/ms-teams'
2+
import { italic } from '@stacksjs/cli'
3+
import type { ChatOptions } from '@stacksjs/types'
4+
import { ResultAsync } from '@stacksjs/error-handling'
5+
import { notification } from '@stacksjs/config'
6+
7+
const env = notification.chat.msTeams
8+
9+
const provider = new MsTeamsProvider({
10+
applicationId: env.appId,
11+
clientId: env.clientId,
12+
secretKey: env.secret,
13+
})
14+
15+
function send(options: ChatOptions) {
16+
return ResultAsync.fromPromise(
17+
provider.sendMessage(options),
18+
() => new Error(`Failed to send message using provider: ${italic('MsTeams')}`),
19+
)
20+
}
21+
22+
export { send as Send, send }

.stacks/core/config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"configuration",
2121
"stacks"
2222
],
23-
"module": "dist/index.mjs",
2423
"main": "dist/index.mjs",
24+
"module": "dist/index.mjs",
2525
"types": "dist/index.d.ts",
2626
"contributors": [
2727
"Chris Breuer <chris@ow3.org>"
Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { filesystem } from '@stacksjs/storage'
22
import type { Model } from '@stacksjs/types'
3+
import { faker } from '@stacksjs/faker'
4+
import { client as Client } from '@stacksjs/database'
5+
import { projectPath } from '@stacksjs/path'
6+
7+
const prisma = new Client()
38

49
const { fs } = filesystem
510

@@ -29,25 +34,38 @@ function readModels(folderPath: string): Promise<Model[]> {
2934
})
3035
}
3136

32-
// const seedData = Array.from({ length: count }).map(() => {
33-
// const fields = Object.entries(model.fields)
34-
// const data: Record<string, any> = {}
35-
36-
// fields.forEach(([name, type]) => {
37-
// switch (type) {
38-
// case 'string':
39-
// data[name] = faker.lorem.words(3)
40-
// break
41-
// case 'number':
42-
// // data[name] = faker.random.number()
43-
// break
44-
// case 'boolean':
45-
// // data[name] = faker.random.boolean()
46-
// break
47-
// }
48-
// })
49-
50-
// return data
51-
// })
52-
53-
export { readModels as seed }
37+
function seedData(model: Model) {
38+
const fields = Object.entries(model.fields)
39+
const data: Record<string, any> = {}
40+
41+
fields.forEach(([name, type]) => {
42+
switch (type) {
43+
case 'string':
44+
data[name] = faker.lorem.words(3)
45+
break
46+
case 'number':
47+
data[name] = faker.random.numeric()
48+
break
49+
case 'boolean':
50+
data[name] = Math.round(Math.random())
51+
break
52+
}
53+
})
54+
55+
return data
56+
}
57+
58+
async function seed() {
59+
const models = await readModels(projectPath('app/models'))
60+
const promises = models.map((model) => {
61+
const data = seedData(model)
62+
63+
return prisma[model.name].create({
64+
data,
65+
})
66+
})
67+
68+
return Promise.all(promises)
69+
}
70+
71+
export { seed }

.stacks/core/path/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
"functions",
2525
"stacks"
2626
],
27-
"module": "dist/index.mjs",
2827
"main": "dist/index.mjs",
28+
"module": "dist/index.mjs",
2929
"types": "dist/index.d.ts",
3030
"contributors": [
3131
"Chris Breuer <chris@ow3.org>"

.stacks/core/server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"google cloud",
2626
"stacks"
2727
],
28-
"module": "dist/index.mjs",
2928
"main": "dist/index.mjs",
29+
"module": "dist/index.mjs",
3030
"types": "dist/index.d.ts",
3131
"contributors": [
3232
"Chris Breuer <chris@ow3.org>"

.stacks/core/types/src/notifications.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ export interface NotificationOptions {
119119
clientId: string
120120
secret: string
121121
}
122+
123+
msTeams: {
124+
appId: string
125+
clientId: string
126+
secret: string
127+
}
122128
}
123129
}
124130

.stacks/core/utils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
"functions",
2727
"stacks"
2828
],
29-
"module": "dist/index.mjs",
3029
"main": "dist/index.mjs",
30+
"module": "dist/index.mjs",
3131
"types": "dist/index.d.ts",
3232
"contributors": [
3333
"Chris Breuer <chris@ow3.org>"

.stacks/scripts/ensure.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ if [[ "$INSTALLED_NODE_MAJOR" -lt "$REQUIRED_NODE_MAJOR" ||
1818
("$INSTALLED_NODE_MAJOR" -eq "$REQUIRED_NODE_MAJOR" && "$INSTALLED_NODE_MINOR" -eq "$REQUIRED_NODE_MINOR" && "$INSTALLED_NODE_PATCH" -lt "$REQUIRED_NODE_PATCH") ]]; then
1919
sh ./setup.sh
2020
node_version=$(exec $SHELL -l -c "source ~/.zshrc; tea +nodejs.org'=$REQUIRED_NODE_VERSION' >/dev/null 2>&1; tea +nodejs.org'=$REQUIRED_NODE_VERSION' node -v")
21-
pnpm_version=$(exec $SHELL -c "source ~/.zshrc; tea >/dev/null 2>&1; pnpm -v")
22-
echo " Stacks Managed"
23-
echo "Node.js $node_version"
21+
pnpm_version=$(exec $SHELL -c "source ~/.zshrc; tea >/dev/null 2>&1; pnpm -v >/dev/null 2>&1; pnpm -v")
22+
echo " # managed by stacks"
23+
echo "node.js $node_version"
2424
echo " • pnpm v$pnpm_version"
2525

2626
echo "\n Please reopen your shell for updates to take effect." | awk '{print "\033[3m" $0 "\033[0m"}'

0 commit comments

Comments
 (0)