gazill 1.0.0 → 1.0.1

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 (41) hide show
  1. package/dist/commands/new.js +1 -1
  2. package/dist/commands/new.js.map +1 -1
  3. package/dist/commands/status.js +1 -1
  4. package/dist/commands/status.js.map +1 -1
  5. package/dist/lib/api.d.ts +1 -1
  6. package/dist/lib/api.d.ts.map +1 -1
  7. package/dist/lib/config.d.ts +1 -1
  8. package/dist/lib/config.d.ts.map +1 -1
  9. package/dist/lib/config.js +1 -1
  10. package/dist/lib/config.js.map +1 -1
  11. package/dist/lib/watcher.d.ts +1 -1
  12. package/dist/lib/watcher.d.ts.map +1 -1
  13. package/dist/lib/watcher.js +1 -1
  14. package/dist/lib/watcher.js.map +1 -1
  15. package/dist/shared/constants.d.ts +26 -0
  16. package/dist/shared/constants.d.ts.map +1 -0
  17. package/dist/shared/constants.js +33 -0
  18. package/dist/shared/constants.js.map +1 -0
  19. package/dist/shared/index.d.ts +4 -0
  20. package/dist/shared/index.d.ts.map +1 -0
  21. package/dist/shared/index.js +4 -0
  22. package/dist/shared/index.js.map +1 -0
  23. package/dist/shared/types.d.ts +103 -0
  24. package/dist/shared/types.d.ts.map +1 -0
  25. package/dist/shared/types.js +2 -0
  26. package/dist/shared/types.js.map +1 -0
  27. package/dist/shared/validation.d.ts +84 -0
  28. package/dist/shared/validation.d.ts.map +1 -0
  29. package/dist/shared/validation.js +57 -0
  30. package/dist/shared/validation.js.map +1 -0
  31. package/package.json +11 -4
  32. package/src/commands/login.ts +0 -90
  33. package/src/commands/logout.ts +0 -15
  34. package/src/commands/logs.ts +0 -90
  35. package/src/commands/new.ts +0 -162
  36. package/src/commands/status.ts +0 -70
  37. package/src/index.ts +0 -48
  38. package/src/lib/api.ts +0 -104
  39. package/src/lib/config.ts +0 -75
  40. package/src/lib/watcher.ts +0 -181
  41. package/tsconfig.json +0 -8
@@ -1,181 +0,0 @@
1
- import chokidar from 'chokidar';
2
- import { promises as fs } from 'fs';
3
- import path from 'path';
4
- import debounce from 'lodash/debounce.js';
5
- import chalk from 'chalk';
6
- import ora from 'ora';
7
- import type { DeployFile } from '@gazill/shared';
8
- import { DEPLOY_DEBOUNCE_MS, MAX_FILE_SIZE_BYTES } from '@gazill/shared';
9
- import { deploy } from './api.js';
10
-
11
- const IGNORED_PATTERNS = [
12
- /(^|[/\\])\../, // dotfiles
13
- 'node_modules/**',
14
- '.git/**',
15
- '*.log',
16
- '.gazill/**',
17
- 'dist/**',
18
- 'build/**',
19
- '__pycache__/**',
20
- '*.pyc',
21
- '.env',
22
- '.env.*',
23
- 'Dockerfile',
24
- ];
25
-
26
- interface WatcherOptions {
27
- projectId: string;
28
- projectDir: string;
29
- onDeploy?: (files: DeployFile[]) => void;
30
- onError?: (error: Error) => void;
31
- }
32
-
33
- export async function startWatcher(options: WatcherOptions): Promise<chokidar.FSWatcher> {
34
- const { projectId, projectDir, onDeploy, onError } = options;
35
-
36
- const changedFiles = new Set<string>();
37
- let isDeploying = false;
38
-
39
- // Collect all files for initial deploy
40
- async function collectAllFiles(): Promise<DeployFile[]> {
41
- const files: DeployFile[] = [];
42
-
43
- async function walkDir(dir: string): Promise<void> {
44
- const entries = await fs.readdir(dir, { withFileTypes: true });
45
-
46
- for (const entry of entries) {
47
- const fullPath = path.join(dir, entry.name);
48
- const relativePath = path.relative(projectDir, fullPath);
49
-
50
- // Skip ignored patterns
51
- if (IGNORED_PATTERNS.some((pattern) => {
52
- if (typeof pattern === 'string') {
53
- return relativePath.includes(pattern.replace('/**', ''));
54
- }
55
- return pattern.test(relativePath);
56
- })) {
57
- continue;
58
- }
59
-
60
- if (entry.isDirectory()) {
61
- await walkDir(fullPath);
62
- } else if (entry.isFile()) {
63
- try {
64
- const stats = await fs.stat(fullPath);
65
- if (stats.size <= MAX_FILE_SIZE_BYTES) {
66
- const content = await fs.readFile(fullPath, 'utf-8');
67
- files.push({ path: relativePath, content });
68
- }
69
- } catch {
70
- // Skip files that can't be read
71
- }
72
- }
73
- }
74
- }
75
-
76
- await walkDir(projectDir);
77
- return files;
78
- }
79
-
80
- // Deploy changed files
81
- const doDeploy = debounce(async () => {
82
- if (isDeploying || changedFiles.size === 0) return;
83
-
84
- isDeploying = true;
85
- const filesToDeploy = Array.from(changedFiles);
86
- changedFiles.clear();
87
-
88
- const spinner = ora('Deploying changes...').start();
89
-
90
- try {
91
- const files: DeployFile[] = [];
92
-
93
- for (const filePath of filesToDeploy) {
94
- const fullPath = path.join(projectDir, filePath);
95
- try {
96
- const stats = await fs.stat(fullPath);
97
- if (stats.size <= MAX_FILE_SIZE_BYTES) {
98
- const content = await fs.readFile(fullPath, 'utf-8');
99
- files.push({ path: filePath, content });
100
- }
101
- } catch {
102
- // File might have been deleted
103
- }
104
- }
105
-
106
- if (files.length > 0) {
107
- const result = await deploy(projectId, files);
108
- spinner.succeed(
109
- chalk.green(`Deployed ${files.length} file(s) - ${result.url}`)
110
- );
111
- onDeploy?.(files);
112
- } else {
113
- spinner.info('No files to deploy');
114
- }
115
- } catch (error) {
116
- const message = error instanceof Error ? error.message : 'Deploy failed';
117
- spinner.fail(chalk.red(message));
118
- onError?.(error instanceof Error ? error : new Error(message));
119
- } finally {
120
- isDeploying = false;
121
- }
122
- }, DEPLOY_DEBOUNCE_MS);
123
-
124
- // Create watcher
125
- const watcher = chokidar.watch(projectDir, {
126
- ignored: IGNORED_PATTERNS,
127
- persistent: true,
128
- ignoreInitial: true,
129
- awaitWriteFinish: {
130
- stabilityThreshold: 100,
131
- pollInterval: 50,
132
- },
133
- });
134
-
135
- // Handle file changes
136
- watcher.on('add', (filePath) => {
137
- const relativePath = path.relative(projectDir, filePath);
138
- console.log(chalk.gray(`+ ${relativePath}`));
139
- changedFiles.add(relativePath);
140
- doDeploy();
141
- });
142
-
143
- watcher.on('change', (filePath) => {
144
- const relativePath = path.relative(projectDir, filePath);
145
- console.log(chalk.gray(`~ ${relativePath}`));
146
- changedFiles.add(relativePath);
147
- doDeploy();
148
- });
149
-
150
- watcher.on('unlink', (filePath) => {
151
- const relativePath = path.relative(projectDir, filePath);
152
- console.log(chalk.gray(`- ${relativePath}`));
153
- // Note: File deletion isn't fully handled - would need separate API endpoint
154
- });
155
-
156
- watcher.on('error', (error) => {
157
- console.error(chalk.red('Watcher error:'), error);
158
- onError?.(error);
159
- });
160
-
161
- // Initial deploy of all files
162
- console.log(chalk.blue('Scanning files...'));
163
- const allFiles = await collectAllFiles();
164
-
165
- if (allFiles.length > 0) {
166
- const spinner = ora(`Deploying ${allFiles.length} files...`).start();
167
- try {
168
- const result = await deploy(projectId, allFiles);
169
- spinner.succeed(
170
- chalk.green(`Initial deploy complete - ${result.url}`)
171
- );
172
- } catch (error) {
173
- const message = error instanceof Error ? error.message : 'Deploy failed';
174
- spinner.fail(chalk.red(message));
175
- }
176
- }
177
-
178
- console.log(chalk.blue('\nWatching for changes... (Ctrl+C to stop)\n'));
179
-
180
- return watcher;
181
- }
package/tsconfig.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "outDir": "dist",
5
- "rootDir": "src"
6
- },
7
- "include": ["src/**/*"]
8
- }