@pushto/cli 0.0.7 → 0.1.0

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 (55) hide show
  1. package/dist/cli.d.ts +3 -0
  2. package/dist/cli.d.ts.map +1 -0
  3. package/dist/cli.js +2 -1
  4. package/dist/cli.js.map +1 -0
  5. package/dist/commands/deploy.d.ts.map +1 -1
  6. package/dist/commands/deploy.js +36 -7
  7. package/dist/commands/deploy.js.map +1 -1
  8. package/dist/commands/domain.d.ts.map +1 -1
  9. package/dist/commands/domain.js +25 -14
  10. package/dist/commands/domain.js.map +1 -1
  11. package/dist/commands/env.d.ts.map +1 -1
  12. package/dist/commands/env.js +50 -7
  13. package/dist/commands/env.js.map +1 -1
  14. package/dist/commands/init.d.ts.map +1 -1
  15. package/dist/commands/init.js +2 -1
  16. package/dist/commands/init.js.map +1 -1
  17. package/dist/commands/status.d.ts.map +1 -1
  18. package/dist/commands/status.js +3 -2
  19. package/dist/commands/status.js.map +1 -1
  20. package/dist/commands/upgrade.d.ts +2 -0
  21. package/dist/commands/upgrade.d.ts.map +1 -0
  22. package/dist/commands/upgrade.js +19 -0
  23. package/dist/commands/upgrade.js.map +1 -0
  24. package/dist/commands/whoami.d.ts +2 -0
  25. package/dist/commands/whoami.d.ts.map +1 -0
  26. package/dist/commands/whoami.js +35 -0
  27. package/dist/commands/whoami.js.map +1 -0
  28. package/dist/index.d.ts +0 -1
  29. package/dist/index.js +14 -1
  30. package/dist/index.js.map +1 -1
  31. package/dist/lib/api.d.ts.map +1 -1
  32. package/dist/lib/api.js +6 -2
  33. package/dist/lib/api.js.map +1 -1
  34. package/dist/lib/safe-json.d.ts +7 -0
  35. package/dist/lib/safe-json.d.ts.map +1 -0
  36. package/dist/lib/safe-json.js +15 -0
  37. package/dist/lib/safe-json.js.map +1 -0
  38. package/package.json +5 -2
  39. package/.turbo/turbo-build.log +0 -4
  40. package/bin/pushto.js +0 -2
  41. package/src/commands/deploy.ts +0 -125
  42. package/src/commands/doctor.ts +0 -160
  43. package/src/commands/domain.ts +0 -54
  44. package/src/commands/env.ts +0 -128
  45. package/src/commands/init.ts +0 -65
  46. package/src/commands/login.ts +0 -97
  47. package/src/commands/logs.ts +0 -24
  48. package/src/commands/open.ts +0 -27
  49. package/src/commands/rollback.ts +0 -43
  50. package/src/commands/status.ts +0 -58
  51. package/src/index.ts +0 -88
  52. package/src/lib/api.ts +0 -20
  53. package/src/lib/config.ts +0 -30
  54. package/src/lib/resolve-slug.ts +0 -23
  55. package/tsconfig.json +0 -18
@@ -1,24 +0,0 @@
1
- import chalk from 'chalk';
2
- import { getToken } from '../lib/config.js';
3
- import { resolveSlug } from '../lib/resolve-slug.js';
4
-
5
- export const logs = async (): Promise<void> => {
6
- const token = getToken();
7
- if (!token) {
8
- console.log(chalk.red('> not logged in.'));
9
- console.log(chalk.dim(' run ') + chalk.cyan('pushto login') + chalk.dim(' first.'));
10
- process.exit(1);
11
- }
12
-
13
- const slug = resolveSlug();
14
- if (!slug) {
15
- console.log(chalk.red('> no project here. run pushto init first.'));
16
- process.exit(1);
17
- }
18
-
19
- console.log(chalk.dim(`> streaming logs for ${slug}...`));
20
- console.log(chalk.dim(' (ctrl+c to stop)\n'));
21
-
22
- // TODO: Phase 3 — SSE connection to log stream API
23
- console.log(chalk.yellow('> log streaming coming soon. deploy first, then we\'ll show you everything.'));
24
- };
@@ -1,27 +0,0 @@
1
- import chalk from 'chalk';
2
- import { execSync } from 'node:child_process';
3
- import { resolveSlug } from '../lib/resolve-slug.js';
4
-
5
- export const open = async (): Promise<void> => {
6
- const slug = resolveSlug();
7
- if (!slug) {
8
- console.log(chalk.red('> no project here. run pushto init first.'));
9
- process.exit(1);
10
- }
11
-
12
- const url = `https://${slug}.pushto.host`;
13
- console.log(chalk.green(`> opening ${url}`));
14
-
15
- const cmd =
16
- process.platform === 'darwin'
17
- ? `open "${url}"`
18
- : process.platform === 'win32'
19
- ? `start "${url}"`
20
- : `xdg-open "${url}"`;
21
-
22
- try {
23
- execSync(cmd, { stdio: 'ignore' });
24
- } catch {
25
- console.log(chalk.dim(` couldn't open browser. go to: `) + chalk.cyan(url));
26
- }
27
- };
@@ -1,43 +0,0 @@
1
- import chalk from 'chalk';
2
- import ora from 'ora';
3
- import { getToken } from '../lib/config.js';
4
- import { resolveSlug } from '../lib/resolve-slug.js';
5
- import { api } from '../lib/api.js';
6
-
7
- export const rollback = async (version?: string): Promise<void> => {
8
- const token = getToken();
9
- if (!token) {
10
- console.log(chalk.red('> not logged in.'));
11
- process.exit(1);
12
- }
13
-
14
- const slug = resolveSlug();
15
- if (!slug) {
16
- console.log(chalk.red('> no project here. run pushto init first.'));
17
- process.exit(1);
18
- }
19
-
20
- const spinner = ora('rolling back...').start();
21
-
22
- try {
23
- // TODO: when build engine is live, this will call the rollback API
24
- // which restores the previous Fly Machine image
25
- spinner.info(chalk.yellow('> rollback is ready to wire up.'));
26
- console.log();
27
- console.log(chalk.dim(' when the build engine is live, this command will:'));
28
- console.log(chalk.dim(' 1. find the last working deployment'));
29
- console.log(chalk.dim(' 2. restore that container image'));
30
- console.log(chalk.dim(' 3. update DNS to point to it'));
31
- console.log(chalk.dim(' 4. mark the current deploy as rolled back'));
32
- console.log();
33
- if (version) {
34
- console.log(chalk.dim(` target version: v${version}`));
35
- } else {
36
- console.log(chalk.dim(' target: previous working deploy'));
37
- }
38
- console.log(chalk.dim(" you're early. this will work soon."));
39
- } catch {
40
- spinner.fail(chalk.red('> rollback failed.'));
41
- process.exit(1);
42
- }
43
- };
@@ -1,58 +0,0 @@
1
- import chalk from 'chalk';
2
- import { getToken } from '../lib/config.js';
3
- import { api } from '../lib/api.js';
4
- import { resolveSlug } from '../lib/resolve-slug.js';
5
-
6
- const STATUS_COLORS: Record<string, (s: string) => string> = {
7
- CREATED: chalk.dim,
8
- BUILDING: chalk.yellow,
9
- DEPLOYING: chalk.yellow,
10
- LIVE: chalk.green,
11
- SLEEPING: chalk.cyan,
12
- FAILED: chalk.red,
13
- SUSPENDED: chalk.red,
14
- };
15
-
16
- export const status = async (): Promise<void> => {
17
- const token = getToken();
18
- if (!token) {
19
- console.log(chalk.red('> not logged in.'));
20
- console.log(chalk.dim(' run ') + chalk.cyan('pushto login') + chalk.dim(' first.'));
21
- process.exit(1);
22
- }
23
-
24
- const slug = resolveSlug();
25
- if (!slug) {
26
- console.log(chalk.red('> no project here.'));
27
- console.log(chalk.dim(' run ') + chalk.cyan('pushto init <name>') + chalk.dim(' first.'));
28
- process.exit(1);
29
- }
30
-
31
- try {
32
- const res = await api(`/cli/projects/${slug}`);
33
-
34
- if (!res.ok) {
35
- const data = (await res.json()) as { error?: string };
36
- console.log(chalk.red(`> ${data.error ?? 'something went wrong.'}`));
37
- process.exit(1);
38
- }
39
-
40
- const project = (await res.json()) as {
41
- name: string;
42
- status: string;
43
- subdomain: string;
44
- customDomain?: string | null;
45
- };
46
- const colorFn = STATUS_COLORS[project.status] ?? chalk.dim;
47
-
48
- console.log(chalk.green(`> ${project.name}`));
49
- console.log(chalk.dim(' status: ') + colorFn(project.status.toLowerCase()));
50
- console.log(chalk.dim(' url: ') + chalk.cyan(`${project.subdomain}.pushto.host`));
51
- if (project.customDomain) {
52
- console.log(chalk.dim(' domain: ') + chalk.cyan(project.customDomain));
53
- }
54
- } catch {
55
- console.log(chalk.red('> could not reach pushto.host. check your internet.'));
56
- process.exit(1);
57
- }
58
- };
package/src/index.ts DELETED
@@ -1,88 +0,0 @@
1
- #!/usr/bin/env node
2
- import { Command } from 'commander';
3
- import chalk from 'chalk';
4
- import { init } from './commands/init.js';
5
- import { deploy } from './commands/deploy.js';
6
- import { login } from './commands/login.js';
7
- import { logs } from './commands/logs.js';
8
- import { status } from './commands/status.js';
9
- import { doctor } from './commands/doctor.js';
10
- import { env } from './commands/env.js';
11
- import { open } from './commands/open.js';
12
- import { rollback } from './commands/rollback.js';
13
- import { domain } from './commands/domain.js';
14
-
15
- const program = new Command();
16
-
17
- program
18
- .name('pushto')
19
- .description(chalk.green('pushto') + chalk.dim(' — deploy from your terminal. no yaml. no drama.'))
20
- .version('0.0.1')
21
- .action(async () => {
22
- await deploy();
23
- });
24
-
25
- program
26
- .command('init <name>')
27
- .description('create a new project')
28
- .action(async (name: string) => {
29
- await init(name);
30
- });
31
-
32
- program
33
- .command('login')
34
- .description('authenticate with pushto.host')
35
- .action(async () => {
36
- await login();
37
- });
38
-
39
- program
40
- .command('logs')
41
- .description('stream logs from your project')
42
- .action(async () => {
43
- await logs();
44
- });
45
-
46
- program
47
- .command('status')
48
- .description('check your project status')
49
- .action(async () => {
50
- await status();
51
- });
52
-
53
- program
54
- .command('doctor')
55
- .description('check if your project is ready to deploy')
56
- .action(async () => {
57
- await doctor();
58
- });
59
-
60
- program
61
- .command('env <action> [args...]')
62
- .description('manage environment variables (set, list, pull, rm)')
63
- .action(async (action: string, args: string[]) => {
64
- await env(action, args);
65
- });
66
-
67
- program
68
- .command('open')
69
- .description('open your live site in the browser')
70
- .action(async () => {
71
- await open();
72
- });
73
-
74
- program
75
- .command('rollback [version]')
76
- .description('rollback to a previous deployment')
77
- .action(async (version?: string) => {
78
- await rollback(version);
79
- });
80
-
81
- program
82
- .command('domain <action> [domain]')
83
- .description('manage custom domains (add, remove)')
84
- .action(async (action: string, domainName?: string) => {
85
- await domain(action, domainName);
86
- });
87
-
88
- program.parse();
package/src/lib/api.ts DELETED
@@ -1,20 +0,0 @@
1
- import { config, getToken } from './config.js';
2
-
3
- export const api = async (path: string, options: RequestInit = {}): Promise<Response> => {
4
- const baseUrl = config.get('apiUrl');
5
- const token = getToken();
6
-
7
- const headers: Record<string, string> = {
8
- 'Content-Type': 'application/json',
9
- ...((options.headers as Record<string, string>) ?? {}),
10
- };
11
-
12
- if (token) {
13
- headers['Authorization'] = `Bearer ${token}`;
14
- }
15
-
16
- return fetch(`${baseUrl}/api${path}`, {
17
- ...options,
18
- headers,
19
- });
20
- };
package/src/lib/config.ts DELETED
@@ -1,30 +0,0 @@
1
- import Conf from 'conf';
2
-
3
- interface PushtoConfig {
4
- token?: string;
5
- apiUrl: string;
6
- projectSlug?: string;
7
- }
8
-
9
- export const config = new Conf<PushtoConfig>({
10
- projectName: 'pushto',
11
- defaults: {
12
- apiUrl: 'https://pushto.host',
13
- },
14
- });
15
-
16
- export const getToken = (): string | undefined => config.get('token');
17
-
18
- export const setToken = (token: string): void => {
19
- config.set('token', token);
20
- };
21
-
22
- export const clearToken = (): void => {
23
- config.delete('token');
24
- };
25
-
26
- export const getProjectSlug = (): string | undefined => config.get('projectSlug');
27
-
28
- export const setProjectSlug = (slug: string): void => {
29
- config.set('projectSlug', slug);
30
- };
@@ -1,23 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import { getProjectSlug } from './config.js';
4
-
5
- /**
6
- * Resolve the project slug from:
7
- * 1. .pushto file in the current directory
8
- * 2. Global config (last `pushto init`)
9
- */
10
- export const resolveSlug = (): string | undefined => {
11
- // Check for .pushto file in cwd
12
- const pushtoFile = path.join(process.cwd(), '.pushto');
13
- try {
14
- const content = fs.readFileSync(pushtoFile, 'utf-8');
15
- const parsed = JSON.parse(content);
16
- if (parsed.slug) return parsed.slug;
17
- } catch {
18
- // No .pushto file or invalid JSON — fall through
19
- }
20
-
21
- // Fall back to global config
22
- return getProjectSlug();
23
- };
package/tsconfig.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "NodeNext",
5
- "moduleResolution": "NodeNext",
6
- "outDir": "./dist",
7
- "rootDir": "./src",
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "resolveJsonModule": true,
13
- "declaration": true,
14
- "declarationMap": true,
15
- "sourceMap": true
16
- },
17
- "include": ["src"]
18
- }