@carlos-tzin/tzin 0.1.5 → 0.1.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.
Files changed (2) hide show
  1. package/dist/cli.js +62 -0
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -8,6 +8,8 @@ function usage() {
8
8
 
9
9
  Commands:
10
10
  tzin dev [entry] [--port N] start dev server with hot reload
11
+ tzin build build for production
12
+ tzin deploy [--target <target>] deploy (node, workers)
11
13
  tzin generate route <name> generate a route stub
12
14
  tzin generate middleware <name> generate a middleware stub
13
15
  tzin generate test <name> generate a test stub`);
@@ -35,6 +37,66 @@ if (cmd === 'dev') {
35
37
  child.on('exit', (code) => process.exit(code ?? 0));
36
38
  process.exit(0);
37
39
  }
40
+ // ── build ─────────────────────────────────────────────────────────────
41
+ if (cmd === 'build') {
42
+ const cwd = process.cwd();
43
+ // Check for tsconfig
44
+ if (!existsSync(resolve(cwd, 'tsconfig.json'))) {
45
+ console.error('No tsconfig.json found');
46
+ process.exit(1);
47
+ }
48
+ // Check for src/app.ts
49
+ if (!existsSync(resolve(cwd, 'src/app.ts'))) {
50
+ console.error('No src/app.ts found. Create an app first.');
51
+ process.exit(1);
52
+ }
53
+ console.log('Building...');
54
+ const child = spawn('npx', ['tsc', '-p', 'tsconfig.json'], {
55
+ cwd,
56
+ stdio: 'inherit',
57
+ });
58
+ child.on('exit', (code) => {
59
+ if (code === 0) {
60
+ console.log('\n✓ Build complete → dist/');
61
+ }
62
+ process.exit(code ?? 1);
63
+ });
64
+ process.exit(0);
65
+ }
66
+ // ── deploy ────────────────────────────────────────────────────────────
67
+ if (cmd === 'deploy') {
68
+ const cwd = process.cwd();
69
+ const targetFlag = rest.indexOf('--target');
70
+ const target = targetFlag !== -1 ? rest[targetFlag + 1] : 'node';
71
+ if (target === 'workers') {
72
+ console.log('Deploying to Cloudflare Workers...');
73
+ // Check for wrangler.toml
74
+ if (!existsSync(resolve(cwd, 'wrangler.toml'))) {
75
+ console.error('No wrangler.toml found. Run: npx wrangler init');
76
+ process.exit(1);
77
+ }
78
+ const child = spawn('npx', ['wrangler', 'deploy'], {
79
+ cwd,
80
+ stdio: 'inherit',
81
+ });
82
+ child.on('exit', (code) => process.exit(code ?? 1));
83
+ process.exit(0);
84
+ }
85
+ // Default: Node
86
+ console.log('Building for production...');
87
+ const build = spawn('npx', ['tsc', '-p', 'tsconfig.json'], {
88
+ cwd,
89
+ stdio: 'inherit',
90
+ });
91
+ build.on('exit', (code) => {
92
+ if (code !== 0)
93
+ process.exit(code ?? 1);
94
+ console.log('\n✓ Build complete');
95
+ console.log('Run: node dist/index.js');
96
+ process.exit(0);
97
+ });
98
+ process.exit(0);
99
+ }
38
100
  // ── generate ─────────────────────────────────────────────────────────
39
101
  if (cmd === 'generate' || cmd === 'g') {
40
102
  const [sub, ...args] = rest;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carlos-tzin/tzin",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Contract-first TypeScript framework. Types that scale, realtime channels with presence, and an MCP server for every API.",
5
5
  "license": "MIT",
6
6
  "author": "The tzin authors",