@crossdelta/platform-sdk 0.13.3 → 0.13.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +312 -0
- package/bin/docs/generators/README.md +56 -0
- package/bin/docs/generators/code-style.md +96 -0
- package/bin/docs/generators/hono-bun.md +181 -0
- package/bin/docs/generators/hono-node.md +194 -0
- package/bin/docs/generators/nest.md +358 -0
- package/bin/docs/generators/service.md +564 -0
- package/bin/docs/generators/testing.md +97 -0
- package/bin/integration.collection.json +18 -0
- package/bin/templates/hono-microservice/Dockerfile.hbs +16 -0
- package/bin/templates/hono-microservice/biome.json.hbs +3 -0
- package/bin/templates/hono-microservice/src/index.ts.hbs +18 -0
- package/bin/templates/hono-microservice/tsconfig.json.hbs +14 -0
- package/bin/templates/nest-microservice/Dockerfile.hbs +37 -0
- package/bin/templates/nest-microservice/biome.json.hbs +3 -0
- package/bin/templates/nest-microservice/src/app.context.ts.hbs +17 -0
- package/bin/templates/nest-microservice/src/events/events.module.ts.hbs +8 -0
- package/bin/templates/nest-microservice/src/events/events.service.ts.hbs +22 -0
- package/bin/templates/nest-microservice/src/main.ts.hbs +34 -0
- package/bin/templates/workspace/biome.json.hbs +62 -0
- package/bin/templates/workspace/bunfig.toml.hbs +5 -0
- package/bin/templates/workspace/editorconfig.hbs +9 -0
- package/bin/templates/workspace/gitignore.hbs +15 -0
- package/bin/templates/workspace/infra/Pulumi.dev.yaml.hbs +5 -0
- package/bin/templates/workspace/infra/Pulumi.yaml.hbs +6 -0
- package/bin/templates/workspace/infra/index.ts.hbs +56 -0
- package/bin/templates/workspace/infra/package.json.hbs +23 -0
- package/bin/templates/workspace/infra/tsconfig.json.hbs +15 -0
- package/bin/templates/workspace/npmrc.hbs +2 -0
- package/bin/templates/workspace/package.json.hbs +51 -0
- package/bin/templates/workspace/packages/contracts/README.md.hbs +166 -0
- package/bin/templates/workspace/packages/contracts/package.json.hbs +22 -0
- package/bin/templates/workspace/packages/contracts/src/events/index.ts +16 -0
- package/bin/templates/workspace/packages/contracts/src/index.ts +10 -0
- package/bin/templates/workspace/packages/contracts/src/stream-policies.ts.hbs +40 -0
- package/bin/templates/workspace/packages/contracts/tsconfig.json.hbs +7 -0
- package/bin/templates/workspace/pnpm-workspace.yaml.hbs +5 -0
- package/bin/templates/workspace/turbo.json +38 -0
- package/bin/templates/workspace/turbo.json.hbs +29 -0
- package/install.sh +46 -8
- package/package.json +1 -3
- package/scripts/postinstall.js +0 -53
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* {{workspaceName}} Stream Policies
|
|
3
|
+
*
|
|
4
|
+
* Business rules for NATS JetStream stream configuration.
|
|
5
|
+
* Defines retention, replication, and storage policies per stream.
|
|
6
|
+
*
|
|
7
|
+
* Architecture:
|
|
8
|
+
* - This file: Business rules (data)
|
|
9
|
+
* - @crossdelta/infrastructure: Deployment logic
|
|
10
|
+
* - infra/streams: Connects business rules + deployment logic
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { StreamPolicy } from '@crossdelta/infrastructure'
|
|
14
|
+
|
|
15
|
+
// Time constants for readability
|
|
16
|
+
const DAYS = 24 * 60 * 60 * 1000
|
|
17
|
+
const MB = 1024 * 1024
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Stream-specific policies
|
|
21
|
+
* Add entries here as you create new streams via event contracts
|
|
22
|
+
*/
|
|
23
|
+
export const STREAM_POLICIES: Record<string, Partial<StreamPolicy>> = {
|
|
24
|
+
// Example:
|
|
25
|
+
// ORDERS: {
|
|
26
|
+
// maxAge: 14 * DAYS,
|
|
27
|
+
// replicas: 3,
|
|
28
|
+
// },
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Default stream policy
|
|
33
|
+
* Applied to all streams without specific overrides
|
|
34
|
+
*/
|
|
35
|
+
export const DEFAULT_POLICY: Partial<StreamPolicy> = {
|
|
36
|
+
maxAge: 7 * DAYS, // 7 days default retention
|
|
37
|
+
storage: 'file', // Persistent storage
|
|
38
|
+
replicas: 1, // Single replica for non-critical streams
|
|
39
|
+
maxMsgSize: 1 * MB, // 1MB max message size
|
|
40
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://turborepo.org/schema.json",
|
|
3
|
+
"tasks": {
|
|
4
|
+
"start:dev": {
|
|
5
|
+
"cache": false,
|
|
6
|
+
"persistent": true
|
|
7
|
+
},
|
|
8
|
+
"sync-templates": {
|
|
9
|
+
"cache": false
|
|
10
|
+
},
|
|
11
|
+
"sync-templates:check": {
|
|
12
|
+
"cache": false
|
|
13
|
+
},
|
|
14
|
+
"pulumi": {},
|
|
15
|
+
"build": {
|
|
16
|
+
"cache": false,
|
|
17
|
+
"dependsOn": ["^build"]
|
|
18
|
+
},
|
|
19
|
+
"test": {
|
|
20
|
+
"cache": false
|
|
21
|
+
},
|
|
22
|
+
"format": {
|
|
23
|
+
"cache": false
|
|
24
|
+
},
|
|
25
|
+
"lint": {
|
|
26
|
+
"cache": false
|
|
27
|
+
},
|
|
28
|
+
"preview": {
|
|
29
|
+
"cache": false,
|
|
30
|
+
"persistent": true
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"ui": "tui",
|
|
34
|
+
"concurrency": "50",
|
|
35
|
+
"globalPassThroughEnv": [
|
|
36
|
+
"*"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://turborepo.org/schema.json",
|
|
3
|
+
"tasks": {
|
|
4
|
+
"start:dev": {
|
|
5
|
+
"cache": false,
|
|
6
|
+
"persistent": true
|
|
7
|
+
},
|
|
8
|
+
"pulumi": {},
|
|
9
|
+
"build": {
|
|
10
|
+
"cache": false
|
|
11
|
+
},
|
|
12
|
+
"test": {
|
|
13
|
+
"cache": false
|
|
14
|
+
},
|
|
15
|
+
"format": {
|
|
16
|
+
"cache": false
|
|
17
|
+
},
|
|
18
|
+
"lint": {
|
|
19
|
+
"cache": false
|
|
20
|
+
},
|
|
21
|
+
"preview": {
|
|
22
|
+
"cache": false,
|
|
23
|
+
"persistent": true
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"ui": "tui",
|
|
27
|
+
"concurrency": "50",
|
|
28
|
+
"globalPassThroughEnv": ["*"]
|
|
29
|
+
}
|
package/install.sh
CHANGED
|
@@ -49,22 +49,38 @@ detect_or_install_package_manager() {
|
|
|
49
49
|
printf "${YELLOW}No package manager found (bun, pnpm, yarn, npm).${NC}\n"
|
|
50
50
|
printf "${YELLOW}To use @crossdelta/platform-sdk, we recommend installing Bun (fast JavaScript runtime).${NC}\n"
|
|
51
51
|
printf "\n"
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
|
|
53
|
+
# Check if stdin is a terminal (interactive mode)
|
|
54
|
+
if [ -t 0 ]; then
|
|
55
|
+
# Interactive: ask user
|
|
56
|
+
read -p "Do you want to install Bun now? (y/n) " -n 1 -r
|
|
57
|
+
printf "\n"
|
|
54
58
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
60
|
+
printf "${RED}Installation cancelled. Please install Bun or another package manager manually.${NC}\n"
|
|
61
|
+
printf "${BLUE}Visit: https://bun.sh${NC}\n"
|
|
62
|
+
exit 1
|
|
63
|
+
fi
|
|
64
|
+
else
|
|
65
|
+
# Non-interactive (e.g., piped from curl): auto-install
|
|
66
|
+
printf "${BLUE}Auto-installing Bun (non-interactive mode)...${NC}\n"
|
|
59
67
|
fi
|
|
60
68
|
|
|
61
69
|
# Install Bun
|
|
62
70
|
printf "${BLUE}Installing Bun...${NC}\n"
|
|
63
71
|
curl -fsSL https://bun.sh/install | bash
|
|
64
72
|
|
|
65
|
-
#
|
|
66
|
-
|
|
73
|
+
# Reload Bun environment (Bun's installer writes to ~/.bashrc/~/.zshrc)
|
|
74
|
+
# But we need it in the current shell session
|
|
75
|
+
export BUN_INSTALL="${BUN_INSTALL:-$HOME/.bun}"
|
|
67
76
|
export PATH="$BUN_INSTALL/bin:$PATH"
|
|
77
|
+
|
|
78
|
+
# Verify Bun is now available
|
|
79
|
+
if ! command_exists bun; then
|
|
80
|
+
printf "${RED}✗ Bun installation failed or not in PATH${NC}\n"
|
|
81
|
+
printf "${YELLOW}Please restart your shell and try again${NC}\n"
|
|
82
|
+
exit 1
|
|
83
|
+
fi
|
|
68
84
|
|
|
69
85
|
printf "${GREEN}✓${NC} Bun installed successfully\n"
|
|
70
86
|
echo "bun"
|
|
@@ -102,6 +118,28 @@ if [ $# -eq 0 ]; then
|
|
|
102
118
|
printf "\n"
|
|
103
119
|
printf "${GREEN}✨ Installation successful!${NC}\n"
|
|
104
120
|
printf "\n"
|
|
121
|
+
|
|
122
|
+
# Check if pf is available in current session
|
|
123
|
+
if ! command_exists pf; then
|
|
124
|
+
# Detect shell config file
|
|
125
|
+
SHELL_CONFIG=""
|
|
126
|
+
if [ -n "$ZSH_VERSION" ] || [[ "$SHELL" == */zsh ]]; then
|
|
127
|
+
SHELL_CONFIG="~/.zshrc"
|
|
128
|
+
elif [[ "$SHELL" == */bash ]]; then
|
|
129
|
+
SHELL_CONFIG="~/.bashrc"
|
|
130
|
+
fi
|
|
131
|
+
|
|
132
|
+
printf "${YELLOW}⚠️ To use pf in this terminal session, run:${NC}\n"
|
|
133
|
+
if [ -n "$SHELL_CONFIG" ]; then
|
|
134
|
+
printf " ${BLUE}source $SHELL_CONFIG${NC}\n"
|
|
135
|
+
else
|
|
136
|
+
printf " ${BLUE}export PATH=\"\$HOME/.bun/bin:\$PATH\"${NC}\n"
|
|
137
|
+
fi
|
|
138
|
+
printf "\n"
|
|
139
|
+
printf "${CYAN}Or simply open a new terminal.${NC}\n"
|
|
140
|
+
printf "\n"
|
|
141
|
+
fi
|
|
142
|
+
|
|
105
143
|
printf "${CYAN}Next steps:${NC}\n"
|
|
106
144
|
printf " # Create a new workspace\n"
|
|
107
145
|
printf " ${BLUE}pf new workspace my-platform${NC}\n"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crossdelta/platform-sdk",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.6",
|
|
4
4
|
"description": "Platform toolkit for event-driven microservices — keeping code and infrastructure in lockstep.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -32,7 +32,6 @@
|
|
|
32
32
|
"bin/**/*.json",
|
|
33
33
|
"!bin/**/*.map",
|
|
34
34
|
"dist/",
|
|
35
|
-
"scripts/postinstall.js",
|
|
36
35
|
"README.md",
|
|
37
36
|
"logo.png",
|
|
38
37
|
"schemas",
|
|
@@ -81,7 +80,6 @@
|
|
|
81
80
|
}
|
|
82
81
|
},
|
|
83
82
|
"scripts": {
|
|
84
|
-
"postinstall": "node scripts/postinstall.js",
|
|
85
83
|
"start:dev": "node esbuild.config.mjs --watch",
|
|
86
84
|
"build:cli": "node esbuild.config.mjs",
|
|
87
85
|
"build:cli:copy": "cp cli/integration.collection.json bin/integration.collection.json && rm -rf bin/templates && mkdir -p bin/templates && cp -r cli/src/commands/create/workspace/templates bin/templates/workspace && cp -r cli/src/commands/create/hono-microservice/templates bin/templates/hono-microservice && cp -r cli/src/commands/create/nest-microservice/templates bin/templates/nest-microservice && mkdir -p bin/docs/generators && cp -r docs/generators/* bin/docs/generators/",
|
package/scripts/postinstall.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Post-install message for global installations.
|
|
4
|
-
* Reminds users to add Bun/npm/pnpm/yarn bin directory to PATH.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const os = require('node:os')
|
|
8
|
-
const path = require('node:path')
|
|
9
|
-
const fs = require('node:fs')
|
|
10
|
-
|
|
11
|
-
// Check if this is a global installation
|
|
12
|
-
// For npm/pnpm/yarn: npm_config_global or npm_config_prefix
|
|
13
|
-
// For Bun: Check if we're in ~/.bun/install/global/
|
|
14
|
-
const isGlobal = process.env.npm_config_global === 'true' ||
|
|
15
|
-
process.env.npm_config_prefix !== undefined ||
|
|
16
|
-
__dirname.includes('.bun/install/global')
|
|
17
|
-
|
|
18
|
-
if (!isGlobal) {
|
|
19
|
-
// Local installation - no message needed
|
|
20
|
-
process.exit(0)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const homeDir = os.homedir()
|
|
24
|
-
let binPath = ''
|
|
25
|
-
let shellConfig = ''
|
|
26
|
-
|
|
27
|
-
// Detect package manager and shell
|
|
28
|
-
if (process.env.BUN_INSTALL) {
|
|
29
|
-
binPath = path.join(process.env.BUN_INSTALL, 'bin')
|
|
30
|
-
shellConfig = process.env.SHELL?.includes('zsh') ? '~/.zshrc' : '~/.bashrc'
|
|
31
|
-
} else if (process.env.npm_config_prefix) {
|
|
32
|
-
binPath = path.join(process.env.npm_config_prefix, 'bin')
|
|
33
|
-
shellConfig = process.env.SHELL?.includes('zsh') ? '~/.zshrc' : '~/.bashrc'
|
|
34
|
-
} else {
|
|
35
|
-
binPath = path.join(homeDir, '.bun', 'bin')
|
|
36
|
-
shellConfig = process.env.SHELL?.includes('zsh') ? '~/.zshrc' : '~/.bashrc'
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Check if binPath is in PATH
|
|
40
|
-
const pathDirs = (process.env.PATH || '').split(':')
|
|
41
|
-
if (pathDirs.includes(binPath)) {
|
|
42
|
-
// Already in PATH - success message only
|
|
43
|
-
console.log('\n✅ @crossdelta/platform-sdk installed successfully!')
|
|
44
|
-
console.log('\nRun: \x1b[36mpf --help\x1b[0m')
|
|
45
|
-
process.exit(0)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Not in PATH - show instructions
|
|
49
|
-
console.log('\n\x1b[33m⚠️ One more step!\x1b[0m')
|
|
50
|
-
console.log('\nTo use the \x1b[36mpf\x1b[0m command, add this to your \x1b[36m' + shellConfig + '\x1b[0m:\n')
|
|
51
|
-
console.log(' \x1b[32mexport PATH="' + binPath + ':$PATH"\x1b[0m\n')
|
|
52
|
-
console.log('Then reload your shell:')
|
|
53
|
-
console.log(' \x1b[32msource ' + shellConfig + '\x1b[0m\n')
|