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.
- package/dist/commands/new.js +1 -1
- package/dist/commands/new.js.map +1 -1
- package/dist/commands/status.js +1 -1
- package/dist/commands/status.js.map +1 -1
- package/dist/lib/api.d.ts +1 -1
- package/dist/lib/api.d.ts.map +1 -1
- package/dist/lib/config.d.ts +1 -1
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +1 -1
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/watcher.d.ts +1 -1
- package/dist/lib/watcher.d.ts.map +1 -1
- package/dist/lib/watcher.js +1 -1
- package/dist/lib/watcher.js.map +1 -1
- package/dist/shared/constants.d.ts +26 -0
- package/dist/shared/constants.d.ts.map +1 -0
- package/dist/shared/constants.js +33 -0
- package/dist/shared/constants.js.map +1 -0
- package/dist/shared/index.d.ts +4 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +4 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/types.d.ts +103 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +2 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/shared/validation.d.ts +84 -0
- package/dist/shared/validation.d.ts.map +1 -0
- package/dist/shared/validation.js +57 -0
- package/dist/shared/validation.js.map +1 -0
- package/package.json +11 -4
- package/src/commands/login.ts +0 -90
- package/src/commands/logout.ts +0 -15
- package/src/commands/logs.ts +0 -90
- package/src/commands/new.ts +0 -162
- package/src/commands/status.ts +0 -70
- package/src/index.ts +0 -48
- package/src/lib/api.ts +0 -104
- package/src/lib/config.ts +0 -75
- package/src/lib/watcher.ts +0 -181
- package/tsconfig.json +0 -8
package/src/commands/login.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import inquirer from 'inquirer';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import ora from 'ora';
|
|
4
|
-
import { signin, signup } from '../lib/api.js';
|
|
5
|
-
import { saveAuth, isAuthenticated, getAuth } from '../lib/config.js';
|
|
6
|
-
|
|
7
|
-
export async function loginCommand(): Promise<void> {
|
|
8
|
-
// Check if already authenticated
|
|
9
|
-
if (await isAuthenticated()) {
|
|
10
|
-
const auth = await getAuth();
|
|
11
|
-
console.log(chalk.yellow(`Already logged in as ${auth?.email}`));
|
|
12
|
-
console.log(chalk.gray('Run "gazill logout" to switch accounts.'));
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// Ask for action
|
|
17
|
-
const { action } = await inquirer.prompt<{ action: 'signin' | 'signup' }>([
|
|
18
|
-
{
|
|
19
|
-
type: 'list',
|
|
20
|
-
name: 'action',
|
|
21
|
-
message: 'What would you like to do?',
|
|
22
|
-
choices: [
|
|
23
|
-
{ name: 'Sign in to existing account', value: 'signin' },
|
|
24
|
-
{ name: 'Create a new account', value: 'signup' },
|
|
25
|
-
],
|
|
26
|
-
},
|
|
27
|
-
]);
|
|
28
|
-
|
|
29
|
-
// Get credentials
|
|
30
|
-
const { email, password } = await inquirer.prompt<{
|
|
31
|
-
email: string;
|
|
32
|
-
password: string;
|
|
33
|
-
}>([
|
|
34
|
-
{
|
|
35
|
-
type: 'input',
|
|
36
|
-
name: 'email',
|
|
37
|
-
message: 'Email:',
|
|
38
|
-
validate: (input: string) => {
|
|
39
|
-
if (!input || !input.includes('@')) {
|
|
40
|
-
return 'Please enter a valid email address';
|
|
41
|
-
}
|
|
42
|
-
return true;
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
type: 'password',
|
|
47
|
-
name: 'password',
|
|
48
|
-
message: 'Password:',
|
|
49
|
-
mask: '*',
|
|
50
|
-
validate: (input: string) => {
|
|
51
|
-
if (!input || input.length < 8) {
|
|
52
|
-
return 'Password must be at least 8 characters';
|
|
53
|
-
}
|
|
54
|
-
return true;
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
]);
|
|
58
|
-
|
|
59
|
-
const spinner = ora(
|
|
60
|
-
action === 'signup' ? 'Creating account...' : 'Signing in...'
|
|
61
|
-
).start();
|
|
62
|
-
|
|
63
|
-
try {
|
|
64
|
-
const response =
|
|
65
|
-
action === 'signup'
|
|
66
|
-
? await signup(email, password)
|
|
67
|
-
: await signin(email, password);
|
|
68
|
-
|
|
69
|
-
// Save auth token
|
|
70
|
-
await saveAuth({
|
|
71
|
-
token: response.token,
|
|
72
|
-
email: response.user.email,
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
spinner.succeed(
|
|
76
|
-
chalk.green(
|
|
77
|
-
action === 'signup'
|
|
78
|
-
? 'Account created successfully!'
|
|
79
|
-
: 'Signed in successfully!'
|
|
80
|
-
)
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
console.log(chalk.blue(`\nWelcome, ${response.user.email}!`));
|
|
84
|
-
console.log(chalk.gray('Run "gazill new <project-name>" to create a project.'));
|
|
85
|
-
} catch (error) {
|
|
86
|
-
const message = error instanceof Error ? error.message : 'Authentication failed';
|
|
87
|
-
spinner.fail(chalk.red(message));
|
|
88
|
-
process.exit(1);
|
|
89
|
-
}
|
|
90
|
-
}
|
package/src/commands/logout.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { clearAuth, isAuthenticated, getAuth } from '../lib/config.js';
|
|
3
|
-
|
|
4
|
-
export async function logoutCommand(): Promise<void> {
|
|
5
|
-
if (!(await isAuthenticated())) {
|
|
6
|
-
console.log(chalk.yellow('You are not logged in.'));
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const auth = await getAuth();
|
|
11
|
-
await clearAuth();
|
|
12
|
-
|
|
13
|
-
console.log(chalk.green(`Logged out successfully.`));
|
|
14
|
-
console.log(chalk.gray(`Goodbye, ${auth?.email}!`));
|
|
15
|
-
}
|
package/src/commands/logs.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { promises as fs } from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
import ora from 'ora';
|
|
5
|
-
import { listProjects, getLogs } from '../lib/api.js';
|
|
6
|
-
import { isAuthenticated } from '../lib/config.js';
|
|
7
|
-
|
|
8
|
-
export async function logsCommand(nameOrId?: string): Promise<void> {
|
|
9
|
-
// Check authentication
|
|
10
|
-
if (!(await isAuthenticated())) {
|
|
11
|
-
console.log(chalk.red('Please log in first.'));
|
|
12
|
-
console.log(chalk.gray('Run "gazill login" to authenticate.'));
|
|
13
|
-
process.exit(1);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
let projectId: string | undefined;
|
|
17
|
-
let projectName: string | undefined;
|
|
18
|
-
|
|
19
|
-
// If no name provided, try to get from current directory
|
|
20
|
-
if (!nameOrId) {
|
|
21
|
-
const projectConfigPath = path.join(process.cwd(), '.gazill', 'project.json');
|
|
22
|
-
try {
|
|
23
|
-
const configContent = await fs.readFile(projectConfigPath, 'utf-8');
|
|
24
|
-
const projectConfig = JSON.parse(configContent) as {
|
|
25
|
-
id: string;
|
|
26
|
-
name: string;
|
|
27
|
-
};
|
|
28
|
-
projectId = projectConfig.id;
|
|
29
|
-
projectName = projectConfig.name;
|
|
30
|
-
} catch {
|
|
31
|
-
console.log(chalk.red('No project specified.'));
|
|
32
|
-
console.log(
|
|
33
|
-
chalk.gray('Run "gazill logs <project-name>" or run from a project directory.')
|
|
34
|
-
);
|
|
35
|
-
process.exit(1);
|
|
36
|
-
}
|
|
37
|
-
} else {
|
|
38
|
-
// Find project by name or ID
|
|
39
|
-
const spinner = ora('Finding project...').start();
|
|
40
|
-
try {
|
|
41
|
-
const { projects } = await listProjects();
|
|
42
|
-
const project = projects.find(
|
|
43
|
-
(p) => p.name === nameOrId || p.id === nameOrId
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
if (!project) {
|
|
47
|
-
spinner.fail(chalk.red(`Project "${nameOrId}" not found.`));
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
projectId = project.id;
|
|
52
|
-
projectName = project.name;
|
|
53
|
-
spinner.stop();
|
|
54
|
-
} catch (error) {
|
|
55
|
-
const message = error instanceof Error ? error.message : 'Failed to find project';
|
|
56
|
-
spinner.fail(chalk.red(message));
|
|
57
|
-
process.exit(1);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Fetch logs
|
|
62
|
-
const spinner = ora(`Fetching logs for ${projectName}...`).start();
|
|
63
|
-
|
|
64
|
-
try {
|
|
65
|
-
const { logs } = await getLogs(projectId, 100);
|
|
66
|
-
|
|
67
|
-
spinner.stop();
|
|
68
|
-
|
|
69
|
-
if (logs.length === 0) {
|
|
70
|
-
console.log(chalk.yellow('No logs available.'));
|
|
71
|
-
console.log(
|
|
72
|
-
chalk.gray('The container may not have started yet or has no output.')
|
|
73
|
-
);
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
console.log(chalk.bold(`\nLogs for ${projectName}:\n`));
|
|
78
|
-
console.log(chalk.gray('-'.repeat(60)));
|
|
79
|
-
|
|
80
|
-
for (const entry of logs) {
|
|
81
|
-
console.log(entry.message);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
console.log(chalk.gray('-'.repeat(60)));
|
|
85
|
-
} catch (error) {
|
|
86
|
-
const message = error instanceof Error ? error.message : 'Failed to fetch logs';
|
|
87
|
-
spinner.fail(chalk.red(message));
|
|
88
|
-
process.exit(1);
|
|
89
|
-
}
|
|
90
|
-
}
|
package/src/commands/new.ts
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { promises as fs } from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
import ora from 'ora';
|
|
5
|
-
import { projectNameSchema, BASE_DOMAIN } from '@gazill/shared';
|
|
6
|
-
import { createProject } from '../lib/api.js';
|
|
7
|
-
import { isAuthenticated } from '../lib/config.js';
|
|
8
|
-
import { startWatcher } from '../lib/watcher.js';
|
|
9
|
-
|
|
10
|
-
// Starter files for a basic Node.js project
|
|
11
|
-
const STARTER_FILES = {
|
|
12
|
-
'package.json': JSON.stringify(
|
|
13
|
-
{
|
|
14
|
-
name: '{{PROJECT_NAME}}',
|
|
15
|
-
version: '1.0.0',
|
|
16
|
-
scripts: {
|
|
17
|
-
start: 'node index.js',
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
null,
|
|
21
|
-
2
|
|
22
|
-
),
|
|
23
|
-
'index.js': `const http = require('http');
|
|
24
|
-
|
|
25
|
-
const port = process.env.PORT || 3000;
|
|
26
|
-
|
|
27
|
-
const server = http.createServer((req, res) => {
|
|
28
|
-
res.writeHead(200, { 'Content-Type': 'text/html' });
|
|
29
|
-
res.end('<h1>Hello from Gazill!</h1><p>Edit index.js and save to see changes.</p>');
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
server.listen(port, () => {
|
|
33
|
-
console.log(\`Server running on port \${port}\`);
|
|
34
|
-
});
|
|
35
|
-
`,
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export async function newCommand(name: string): Promise<void> {
|
|
39
|
-
// Check authentication
|
|
40
|
-
if (!(await isAuthenticated())) {
|
|
41
|
-
console.log(chalk.red('Please log in first.'));
|
|
42
|
-
console.log(chalk.gray('Run "gazill login" to authenticate.'));
|
|
43
|
-
process.exit(1);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Validate project name
|
|
47
|
-
try {
|
|
48
|
-
projectNameSchema.parse(name);
|
|
49
|
-
} catch {
|
|
50
|
-
console.log(chalk.red('Invalid project name.'));
|
|
51
|
-
console.log(
|
|
52
|
-
chalk.gray(
|
|
53
|
-
'Project names must be 3-63 characters, lowercase alphanumeric with hyphens.'
|
|
54
|
-
)
|
|
55
|
-
);
|
|
56
|
-
console.log(chalk.gray('Example: my-awesome-app'));
|
|
57
|
-
process.exit(1);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Check if directory already exists
|
|
61
|
-
const projectDir = path.resolve(process.cwd(), name);
|
|
62
|
-
try {
|
|
63
|
-
await fs.access(projectDir);
|
|
64
|
-
console.log(chalk.red(`Directory "${name}" already exists.`));
|
|
65
|
-
process.exit(1);
|
|
66
|
-
} catch {
|
|
67
|
-
// Directory doesn't exist, good to proceed
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Create project via API
|
|
71
|
-
const spinner = ora('Creating project...').start();
|
|
72
|
-
|
|
73
|
-
try {
|
|
74
|
-
const { project, url } = await createProject(name);
|
|
75
|
-
|
|
76
|
-
// Create local directory
|
|
77
|
-
await fs.mkdir(projectDir, { recursive: true });
|
|
78
|
-
|
|
79
|
-
// Create starter files
|
|
80
|
-
for (const [filename, content] of Object.entries(STARTER_FILES)) {
|
|
81
|
-
const fileContent = content.replace('{{PROJECT_NAME}}', name);
|
|
82
|
-
await fs.writeFile(path.join(projectDir, filename), fileContent, 'utf-8');
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Create .gazill directory with project config
|
|
86
|
-
const gazillDir = path.join(projectDir, '.gazill');
|
|
87
|
-
await fs.mkdir(gazillDir, { recursive: true });
|
|
88
|
-
await fs.writeFile(
|
|
89
|
-
path.join(gazillDir, 'project.json'),
|
|
90
|
-
JSON.stringify(
|
|
91
|
-
{
|
|
92
|
-
id: project.id,
|
|
93
|
-
name: project.name,
|
|
94
|
-
subdomain: project.subdomain,
|
|
95
|
-
},
|
|
96
|
-
null,
|
|
97
|
-
2
|
|
98
|
-
),
|
|
99
|
-
'utf-8'
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
spinner.succeed(chalk.green('Project created!'));
|
|
103
|
-
|
|
104
|
-
console.log('');
|
|
105
|
-
console.log(chalk.blue('Project:'), name);
|
|
106
|
-
console.log(chalk.blue('URL:'), chalk.underline(url));
|
|
107
|
-
console.log('');
|
|
108
|
-
console.log(chalk.gray('Starting file watcher...'));
|
|
109
|
-
console.log('');
|
|
110
|
-
|
|
111
|
-
// Change to project directory and start watcher
|
|
112
|
-
process.chdir(projectDir);
|
|
113
|
-
|
|
114
|
-
await startWatcher({
|
|
115
|
-
projectId: project.id,
|
|
116
|
-
projectDir,
|
|
117
|
-
});
|
|
118
|
-
} catch (error) {
|
|
119
|
-
const message = error instanceof Error ? error.message : 'Failed to create project';
|
|
120
|
-
spinner.fail(chalk.red(message));
|
|
121
|
-
process.exit(1);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Watch an existing project
|
|
126
|
-
export async function watchCommand(): Promise<void> {
|
|
127
|
-
// Check authentication
|
|
128
|
-
if (!(await isAuthenticated())) {
|
|
129
|
-
console.log(chalk.red('Please log in first.'));
|
|
130
|
-
console.log(chalk.gray('Run "gazill login" to authenticate.'));
|
|
131
|
-
process.exit(1);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const projectDir = process.cwd();
|
|
135
|
-
const projectConfigPath = path.join(projectDir, '.gazill', 'project.json');
|
|
136
|
-
|
|
137
|
-
// Check if this is a Gazill project
|
|
138
|
-
try {
|
|
139
|
-
const configContent = await fs.readFile(projectConfigPath, 'utf-8');
|
|
140
|
-
const projectConfig = JSON.parse(configContent) as {
|
|
141
|
-
id: string;
|
|
142
|
-
name: string;
|
|
143
|
-
subdomain: string;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
console.log(chalk.blue('Project:'), projectConfig.name);
|
|
147
|
-
console.log(
|
|
148
|
-
chalk.blue('URL:'),
|
|
149
|
-
chalk.underline(`https://${projectConfig.subdomain}.${BASE_DOMAIN}`)
|
|
150
|
-
);
|
|
151
|
-
console.log('');
|
|
152
|
-
|
|
153
|
-
await startWatcher({
|
|
154
|
-
projectId: projectConfig.id,
|
|
155
|
-
projectDir,
|
|
156
|
-
});
|
|
157
|
-
} catch {
|
|
158
|
-
console.log(chalk.red('Not a Gazill project.'));
|
|
159
|
-
console.log(chalk.gray('Run "gazill new <name>" to create a new project.'));
|
|
160
|
-
process.exit(1);
|
|
161
|
-
}
|
|
162
|
-
}
|
package/src/commands/status.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import ora from 'ora';
|
|
3
|
-
import { BASE_DOMAIN } from '@gazill/shared';
|
|
4
|
-
import { listProjects } from '../lib/api.js';
|
|
5
|
-
import { isAuthenticated } from '../lib/config.js';
|
|
6
|
-
|
|
7
|
-
const STATUS_COLORS: Record<string, (text: string) => string> = {
|
|
8
|
-
pending: chalk.yellow,
|
|
9
|
-
building: chalk.blue,
|
|
10
|
-
running: chalk.green,
|
|
11
|
-
stopped: chalk.gray,
|
|
12
|
-
error: chalk.red,
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export async function statusCommand(): Promise<void> {
|
|
16
|
-
// Check authentication
|
|
17
|
-
if (!(await isAuthenticated())) {
|
|
18
|
-
console.log(chalk.red('Please log in first.'));
|
|
19
|
-
console.log(chalk.gray('Run "gazill login" to authenticate.'));
|
|
20
|
-
process.exit(1);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const spinner = ora('Fetching projects...').start();
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
const { projects } = await listProjects();
|
|
27
|
-
|
|
28
|
-
if (projects.length === 0) {
|
|
29
|
-
spinner.info('No projects found.');
|
|
30
|
-
console.log(chalk.gray('\nRun "gazill new <name>" to create a project.'));
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
spinner.stop();
|
|
35
|
-
|
|
36
|
-
console.log(chalk.bold('\nYour Projects:\n'));
|
|
37
|
-
|
|
38
|
-
// Calculate column widths
|
|
39
|
-
const nameWidth = Math.max(...projects.map((p) => p.name.length), 4);
|
|
40
|
-
const statusWidth = 8;
|
|
41
|
-
const urlWidth = Math.max(
|
|
42
|
-
...projects.map((p) => `${p.subdomain}.${BASE_DOMAIN}`.length),
|
|
43
|
-
3
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
// Header
|
|
47
|
-
console.log(
|
|
48
|
-
chalk.gray(
|
|
49
|
-
`${'NAME'.padEnd(nameWidth)} ${'STATUS'.padEnd(statusWidth)} ${'URL'.padEnd(urlWidth)}`
|
|
50
|
-
)
|
|
51
|
-
);
|
|
52
|
-
console.log(chalk.gray('-'.repeat(nameWidth + statusWidth + urlWidth + 4)));
|
|
53
|
-
|
|
54
|
-
// Projects
|
|
55
|
-
for (const project of projects) {
|
|
56
|
-
const colorFn = STATUS_COLORS[project.status] || chalk.white;
|
|
57
|
-
const url = `${project.subdomain}.${BASE_DOMAIN}`;
|
|
58
|
-
|
|
59
|
-
console.log(
|
|
60
|
-
`${project.name.padEnd(nameWidth)} ${colorFn(project.status.padEnd(statusWidth))} ${chalk.underline(url)}`
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
console.log('');
|
|
65
|
-
} catch (error) {
|
|
66
|
-
const message = error instanceof Error ? error.message : 'Failed to fetch projects';
|
|
67
|
-
spinner.fail(chalk.red(message));
|
|
68
|
-
process.exit(1);
|
|
69
|
-
}
|
|
70
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { Command } from 'commander';
|
|
4
|
-
import { loginCommand } from './commands/login.js';
|
|
5
|
-
import { logoutCommand } from './commands/logout.js';
|
|
6
|
-
import { newCommand, watchCommand } from './commands/new.js';
|
|
7
|
-
import { statusCommand } from './commands/status.js';
|
|
8
|
-
import { logsCommand } from './commands/logs.js';
|
|
9
|
-
|
|
10
|
-
const program = new Command();
|
|
11
|
-
|
|
12
|
-
program
|
|
13
|
-
.name('gazill')
|
|
14
|
-
.description('Auto-deploy platform for developers')
|
|
15
|
-
.version('1.0.0');
|
|
16
|
-
|
|
17
|
-
program
|
|
18
|
-
.command('login')
|
|
19
|
-
.description('Authenticate with Gazill')
|
|
20
|
-
.action(loginCommand);
|
|
21
|
-
|
|
22
|
-
program
|
|
23
|
-
.command('logout')
|
|
24
|
-
.description('Log out from Gazill')
|
|
25
|
-
.action(logoutCommand);
|
|
26
|
-
|
|
27
|
-
program
|
|
28
|
-
.command('new <name>')
|
|
29
|
-
.description('Create a new project and start watching for changes')
|
|
30
|
-
.action(newCommand);
|
|
31
|
-
|
|
32
|
-
program
|
|
33
|
-
.command('watch')
|
|
34
|
-
.description('Watch the current project for changes')
|
|
35
|
-
.action(watchCommand);
|
|
36
|
-
|
|
37
|
-
program
|
|
38
|
-
.command('status')
|
|
39
|
-
.alias('ls')
|
|
40
|
-
.description('List all your projects')
|
|
41
|
-
.action(statusCommand);
|
|
42
|
-
|
|
43
|
-
program
|
|
44
|
-
.command('logs [name]')
|
|
45
|
-
.description('View logs for a project')
|
|
46
|
-
.action(logsCommand);
|
|
47
|
-
|
|
48
|
-
program.parse();
|
package/src/lib/api.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AuthResponse,
|
|
3
|
-
CreateProjectResponse,
|
|
4
|
-
ProjectListResponse,
|
|
5
|
-
DeployResponse,
|
|
6
|
-
LogsResponse,
|
|
7
|
-
ApiError,
|
|
8
|
-
DeployFile,
|
|
9
|
-
} from '@gazill/shared';
|
|
10
|
-
import { getApiUrl, getAuth } from './config.js';
|
|
11
|
-
|
|
12
|
-
interface RequestOptions {
|
|
13
|
-
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
14
|
-
body?: unknown;
|
|
15
|
-
auth?: boolean;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async function request<T>(endpoint: string, options: RequestOptions): Promise<T> {
|
|
19
|
-
const apiUrl = await getApiUrl();
|
|
20
|
-
const url = `${apiUrl}${endpoint}`;
|
|
21
|
-
|
|
22
|
-
const headers: Record<string, string> = {
|
|
23
|
-
'Content-Type': 'application/json',
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
if (options.auth !== false) {
|
|
27
|
-
const auth = await getAuth();
|
|
28
|
-
if (auth?.token) {
|
|
29
|
-
headers['Authorization'] = `Bearer ${auth.token}`;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const response = await fetch(url, {
|
|
34
|
-
method: options.method,
|
|
35
|
-
headers,
|
|
36
|
-
body: options.body ? JSON.stringify(options.body) : undefined,
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const data = await response.json();
|
|
40
|
-
|
|
41
|
-
if (!response.ok) {
|
|
42
|
-
const error = data as ApiError;
|
|
43
|
-
throw new Error(error.message || 'Request failed');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return data as T;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Auth API
|
|
50
|
-
export async function signup(email: string, password: string): Promise<AuthResponse> {
|
|
51
|
-
return request<AuthResponse>('/api/auth/signup', {
|
|
52
|
-
method: 'POST',
|
|
53
|
-
body: { email, password },
|
|
54
|
-
auth: false,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export async function signin(email: string, password: string): Promise<AuthResponse> {
|
|
59
|
-
return request<AuthResponse>('/api/auth/signin', {
|
|
60
|
-
method: 'POST',
|
|
61
|
-
body: { email, password },
|
|
62
|
-
auth: false,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Projects API
|
|
67
|
-
export async function createProject(name: string): Promise<CreateProjectResponse> {
|
|
68
|
-
return request<CreateProjectResponse>('/api/projects', {
|
|
69
|
-
method: 'POST',
|
|
70
|
-
body: { name },
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export async function listProjects(): Promise<ProjectListResponse> {
|
|
75
|
-
return request<ProjectListResponse>('/api/projects', {
|
|
76
|
-
method: 'GET',
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export async function getProject(id: string): Promise<{ project: CreateProjectResponse['project']; url: string }> {
|
|
81
|
-
return request('/api/projects/' + id, {
|
|
82
|
-
method: 'GET',
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export async function deleteProject(id: string): Promise<void> {
|
|
87
|
-
await request('/api/projects/' + id, {
|
|
88
|
-
method: 'DELETE',
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Deployments API
|
|
93
|
-
export async function deploy(projectId: string, files: DeployFile[]): Promise<DeployResponse> {
|
|
94
|
-
return request<DeployResponse>(`/api/projects/${projectId}/deploy`, {
|
|
95
|
-
method: 'POST',
|
|
96
|
-
body: { files },
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export async function getLogs(projectId: string, lines: number = 100): Promise<LogsResponse> {
|
|
101
|
-
return request<LogsResponse>(`/api/projects/${projectId}/logs?lines=${lines}`, {
|
|
102
|
-
method: 'GET',
|
|
103
|
-
});
|
|
104
|
-
}
|
package/src/lib/config.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { promises as fs } from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import os from 'os';
|
|
4
|
-
import type { CliConfig, CliAuth } from '@gazill/shared';
|
|
5
|
-
import { API_BASE_URL } from '@gazill/shared';
|
|
6
|
-
|
|
7
|
-
const CONFIG_DIR = path.join(os.homedir(), '.gazill');
|
|
8
|
-
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
|
|
9
|
-
const AUTH_FILE = path.join(CONFIG_DIR, 'auth.json');
|
|
10
|
-
|
|
11
|
-
// Ensure config directory exists
|
|
12
|
-
async function ensureConfigDir(): Promise<void> {
|
|
13
|
-
try {
|
|
14
|
-
await fs.mkdir(CONFIG_DIR, { recursive: true });
|
|
15
|
-
} catch {
|
|
16
|
-
// Directory might already exist
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Get CLI configuration
|
|
21
|
-
export async function getConfig(): Promise<CliConfig> {
|
|
22
|
-
try {
|
|
23
|
-
const content = await fs.readFile(CONFIG_FILE, 'utf-8');
|
|
24
|
-
return JSON.parse(content) as CliConfig;
|
|
25
|
-
} catch {
|
|
26
|
-
return {
|
|
27
|
-
apiUrl: API_BASE_URL,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Save CLI configuration
|
|
33
|
-
export async function saveConfig(config: CliConfig): Promise<void> {
|
|
34
|
-
await ensureConfigDir();
|
|
35
|
-
await fs.writeFile(CONFIG_FILE, JSON.stringify(config, null, 2), 'utf-8');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Get authentication info
|
|
39
|
-
export async function getAuth(): Promise<CliAuth | null> {
|
|
40
|
-
try {
|
|
41
|
-
const content = await fs.readFile(AUTH_FILE, 'utf-8');
|
|
42
|
-
return JSON.parse(content) as CliAuth;
|
|
43
|
-
} catch {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Save authentication info
|
|
49
|
-
export async function saveAuth(auth: CliAuth): Promise<void> {
|
|
50
|
-
await ensureConfigDir();
|
|
51
|
-
await fs.writeFile(AUTH_FILE, JSON.stringify(auth, null, 2), {
|
|
52
|
-
mode: 0o600, // Read/write for owner only
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Clear authentication info
|
|
57
|
-
export async function clearAuth(): Promise<void> {
|
|
58
|
-
try {
|
|
59
|
-
await fs.unlink(AUTH_FILE);
|
|
60
|
-
} catch {
|
|
61
|
-
// File might not exist
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Check if user is authenticated
|
|
66
|
-
export async function isAuthenticated(): Promise<boolean> {
|
|
67
|
-
const auth = await getAuth();
|
|
68
|
-
return auth !== null && !!auth.token;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Get API URL
|
|
72
|
-
export async function getApiUrl(): Promise<string> {
|
|
73
|
-
const config = await getConfig();
|
|
74
|
-
return config.apiUrl;
|
|
75
|
-
}
|