nivii 0.3.2 → 0.3.3
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/cli.js +48 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/pro.d.ts +2 -0
- package/dist/commands/pro.d.ts.map +1 -0
- package/dist/commands/pro.js +174 -0
- package/dist/commands/pro.js.map +1 -0
- package/dist/commands/share.d.ts.map +1 -1
- package/dist/commands/share.js +5 -4
- package/dist/commands/share.js.map +1 -1
- package/dist/core/upload.d.ts +2 -1
- package/dist/core/upload.d.ts.map +1 -1
- package/dist/core/upload.js +2 -0
- package/dist/core/upload.js.map +1 -1
- package/dist/ui/spinner.d.ts +1 -0
- package/dist/ui/spinner.d.ts.map +1 -1
- package/dist/ui/spinner.js +3 -0
- package/dist/ui/spinner.js.map +1 -1
- package/dist/ui/welcome.d.ts.map +1 -1
- package/dist/ui/welcome.js +6 -3
- package/dist/ui/welcome.js.map +1 -1
- package/dist/utils/config.d.ts +3 -0
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js.map +1 -1
- package/package.json +1 -1
- package/dist/dist/cli.d.ts +0 -3
- package/dist/dist/cli.d.ts.map +0 -1
- package/dist/dist/cli.js +0 -144
- package/dist/dist/cli.js.map +0 -1
- package/dist/dist/commands/config.d.ts +0 -2
- package/dist/dist/commands/config.d.ts.map +0 -1
- package/dist/dist/commands/config.js +0 -32
- package/dist/dist/commands/config.js.map +0 -1
- package/dist/dist/commands/share.d.ts +0 -18
- package/dist/dist/commands/share.d.ts.map +0 -1
- package/dist/dist/commands/share.js +0 -125
- package/dist/dist/commands/share.js.map +0 -1
- package/dist/dist/commands/whoami.d.ts +0 -2
- package/dist/dist/commands/whoami.d.ts.map +0 -1
- package/dist/dist/commands/whoami.js +0 -17
- package/dist/dist/commands/whoami.js.map +0 -1
- package/dist/dist/core/analytics.d.ts +0 -11
- package/dist/dist/core/analytics.d.ts.map +0 -1
- package/dist/dist/core/analytics.js +0 -47
- package/dist/dist/core/analytics.js.map +0 -1
- package/dist/dist/core/build.d.ts +0 -11
- package/dist/dist/core/build.d.ts.map +0 -1
- package/dist/dist/core/build.js +0 -34
- package/dist/dist/core/build.js.map +0 -1
- package/dist/dist/core/detect.d.ts +0 -12
- package/dist/dist/core/detect.d.ts.map +0 -1
- package/dist/dist/core/detect.js +0 -122
- package/dist/dist/core/detect.js.map +0 -1
- package/dist/dist/core/qr.d.ts +0 -4
- package/dist/dist/core/qr.d.ts.map +0 -1
- package/dist/dist/core/qr.js +0 -29
- package/dist/dist/core/qr.js.map +0 -1
- package/dist/dist/core/tunnel.d.ts +0 -9
- package/dist/dist/core/tunnel.d.ts.map +0 -1
- package/dist/dist/core/tunnel.js +0 -55
- package/dist/dist/core/tunnel.js.map +0 -1
- package/dist/dist/core/upload.d.ts +0 -22
- package/dist/dist/core/upload.d.ts.map +0 -1
- package/dist/dist/core/upload.js +0 -73
- package/dist/dist/core/upload.js.map +0 -1
- package/dist/dist/ui/spinner.d.ts +0 -8
- package/dist/dist/ui/spinner.d.ts.map +0 -1
- package/dist/dist/ui/spinner.js +0 -35
- package/dist/dist/ui/spinner.js.map +0 -1
- package/dist/dist/ui/theme.d.ts +0 -14
- package/dist/dist/ui/theme.d.ts.map +0 -1
- package/dist/dist/ui/theme.js +0 -32
- package/dist/dist/ui/theme.js.map +0 -1
- package/dist/dist/ui/welcome.d.ts +0 -4
- package/dist/dist/ui/welcome.d.ts.map +0 -1
- package/dist/dist/ui/welcome.js +0 -95
- package/dist/dist/ui/welcome.js.map +0 -1
- package/dist/dist/utils/config.d.ts +0 -19
- package/dist/dist/utils/config.d.ts.map +0 -1
- package/dist/dist/utils/config.js +0 -31
- package/dist/dist/utils/config.js.map +0 -1
- package/dist/dist/utils/hash.d.ts +0 -3
- package/dist/dist/utils/hash.d.ts.map +0 -1
- package/dist/dist/utils/hash.js +0 -10
- package/dist/dist/utils/hash.js.map +0 -1
- package/dist/dist/utils/zip.d.ts +0 -2
- package/dist/dist/utils/zip.d.ts.map +0 -1
- package/dist/dist/utils/zip.js +0 -19
- package/dist/dist/utils/zip.js.map +0 -1
- package/src/cli.ts +0 -118
- package/src/commands/config.ts +0 -33
- package/src/commands/share.ts +0 -159
- package/src/commands/whoami.ts +0 -16
- package/src/core/analytics.ts +0 -64
- package/src/core/build.ts +0 -46
- package/src/core/detect.ts +0 -159
- package/src/core/qr.ts +0 -30
- package/src/core/tunnel.ts +0 -70
- package/src/core/upload.ts +0 -95
- package/src/ui/spinner.ts +0 -36
- package/src/ui/theme.ts +0 -35
- package/src/ui/welcome.ts +0 -104
- package/src/utils/config.ts +0 -47
- package/src/utils/hash.ts +0 -11
- package/src/utils/zip.ts +0 -22
- /package/dist/{dist/commands → commands}/fullstack.d.ts +0 -0
- /package/dist/{dist/commands → commands}/fullstack.d.ts.map +0 -0
- /package/dist/{dist/commands → commands}/fullstack.js +0 -0
- /package/dist/{dist/commands → commands}/fullstack.js.map +0 -0
- /package/dist/{dist/core → core}/backend.d.ts +0 -0
- /package/dist/{dist/core → core}/backend.d.ts.map +0 -0
- /package/dist/{dist/core → core}/backend.js +0 -0
- /package/dist/{dist/core → core}/backend.js.map +0 -0
- /package/dist/{dist/core → core}/env.d.ts +0 -0
- /package/dist/{dist/core → core}/env.d.ts.map +0 -0
- /package/dist/{dist/core → core}/env.js +0 -0
- /package/dist/{dist/core → core}/env.js.map +0 -0
- /package/dist/{dist/core → core}/fullstack.d.ts +0 -0
- /package/dist/{dist/core → core}/fullstack.d.ts.map +0 -0
- /package/dist/{dist/core → core}/fullstack.js +0 -0
- /package/dist/{dist/core → core}/fullstack.js.map +0 -0
package/src/core/detect.ts
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
|
|
4
|
-
export type Framework =
|
|
5
|
-
| 'nextjs'
|
|
6
|
-
| 'vite'
|
|
7
|
-
| 'react-cra'
|
|
8
|
-
| 'vue'
|
|
9
|
-
| 'svelte'
|
|
10
|
-
| 'sveltekit'
|
|
11
|
-
| 'astro'
|
|
12
|
-
| 'remix'
|
|
13
|
-
| 'nuxt'
|
|
14
|
-
| 'solid'
|
|
15
|
-
| 'express'
|
|
16
|
-
| 'fastify'
|
|
17
|
-
| 'hono'
|
|
18
|
-
| 'static'
|
|
19
|
-
| 'unknown';
|
|
20
|
-
|
|
21
|
-
export interface DetectResult {
|
|
22
|
-
framework: Framework;
|
|
23
|
-
buildCommand: string | null;
|
|
24
|
-
outputDir: string;
|
|
25
|
-
isServer: boolean;
|
|
26
|
-
port?: number;
|
|
27
|
-
packageManager: 'npm' | 'pnpm' | 'yarn' | 'bun';
|
|
28
|
-
confidence: number; // 0-100
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function detectFramework(cwd: string): DetectResult {
|
|
32
|
-
const pkg = readJson(path.join(cwd, 'package.json'));
|
|
33
|
-
const deps = {
|
|
34
|
-
...(pkg?.dependencies || {}),
|
|
35
|
-
...(pkg?.devDependencies || {}),
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const has = (name: string) => name in deps;
|
|
39
|
-
const hasFile = (...files: string[]) =>
|
|
40
|
-
files.some(f => fs.existsSync(path.join(cwd, f)));
|
|
41
|
-
|
|
42
|
-
const pm = detectPackageManager(cwd);
|
|
43
|
-
|
|
44
|
-
// Next.js
|
|
45
|
-
if (has('next')) {
|
|
46
|
-
const outputDir = fs.existsSync(path.join(cwd, 'out')) ? 'out' :
|
|
47
|
-
fs.existsSync(path.join(cwd, '.next')) ? '.next' : 'out';
|
|
48
|
-
return {
|
|
49
|
-
framework: 'nextjs',
|
|
50
|
-
buildCommand: `${pm} run build`,
|
|
51
|
-
outputDir,
|
|
52
|
-
isServer: false,
|
|
53
|
-
packageManager: pm,
|
|
54
|
-
confidence: 99,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// SvelteKit
|
|
59
|
-
if (has('@sveltejs/kit')) {
|
|
60
|
-
return {
|
|
61
|
-
framework: 'sveltekit',
|
|
62
|
-
buildCommand: `${pm} run build`,
|
|
63
|
-
outputDir: 'build',
|
|
64
|
-
isServer: false,
|
|
65
|
-
packageManager: pm,
|
|
66
|
-
confidence: 95,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Astro
|
|
71
|
-
if (has('astro')) {
|
|
72
|
-
return {
|
|
73
|
-
framework: 'astro',
|
|
74
|
-
buildCommand: `${pm} run build`,
|
|
75
|
-
outputDir: 'dist',
|
|
76
|
-
isServer: false,
|
|
77
|
-
packageManager: pm,
|
|
78
|
-
confidence: 95,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Remix
|
|
83
|
-
if (has('@remix-run/react') || has('@remix-run/node')) {
|
|
84
|
-
return {
|
|
85
|
-
framework: 'remix',
|
|
86
|
-
buildCommand: `${pm} run build`,
|
|
87
|
-
outputDir: 'public',
|
|
88
|
-
isServer: true,
|
|
89
|
-
packageManager: pm,
|
|
90
|
-
confidence: 90,
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Nuxt
|
|
95
|
-
if (has('nuxt') || has('nuxt3') || has('nuxt-edge')) {
|
|
96
|
-
return {
|
|
97
|
-
framework: 'nuxt',
|
|
98
|
-
buildCommand: `${pm} run generate`,
|
|
99
|
-
outputDir: '.output/public',
|
|
100
|
-
isServer: false,
|
|
101
|
-
packageManager: pm,
|
|
102
|
-
confidence: 90,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Vite (React/Vue/Svelte/Solid)
|
|
107
|
-
if (has('vite')) {
|
|
108
|
-
const outputDir = 'dist';
|
|
109
|
-
if (has('react') || has('react-dom')) {
|
|
110
|
-
return { framework: 'react-cra', buildCommand: `${pm} run build`, outputDir, isServer: false, packageManager: pm, confidence: 88 };
|
|
111
|
-
}
|
|
112
|
-
if (has('vue')) {
|
|
113
|
-
return { framework: 'vue', buildCommand: `${pm} run build`, outputDir, isServer: false, packageManager: pm, confidence: 88 };
|
|
114
|
-
}
|
|
115
|
-
if (has('svelte')) {
|
|
116
|
-
return { framework: 'svelte', buildCommand: `${pm} run build`, outputDir, isServer: false, packageManager: pm, confidence: 88 };
|
|
117
|
-
}
|
|
118
|
-
if (has('solid-js')) {
|
|
119
|
-
return { framework: 'solid', buildCommand: `${pm} run build`, outputDir, isServer: false, packageManager: pm, confidence: 88 };
|
|
120
|
-
}
|
|
121
|
-
return { framework: 'vite', buildCommand: `${pm} run build`, outputDir, isServer: false, packageManager: pm, confidence: 85 };
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// Express/Fastify/Hono server
|
|
125
|
-
if (has('express')) {
|
|
126
|
-
return { framework: 'express', buildCommand: null, outputDir: '.', isServer: true, port: 3000, packageManager: pm, confidence: 80 };
|
|
127
|
-
}
|
|
128
|
-
if (has('fastify')) {
|
|
129
|
-
return { framework: 'fastify', buildCommand: null, outputDir: '.', isServer: true, port: 3000, packageManager: pm, confidence: 80 };
|
|
130
|
-
}
|
|
131
|
-
if (has('hono')) {
|
|
132
|
-
return { framework: 'hono', buildCommand: null, outputDir: '.', isServer: true, port: 3000, packageManager: pm, confidence: 80 };
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Static HTML/dist/build
|
|
136
|
-
if (hasFile('index.html') || hasFile('dist/index.html') || hasFile('build/index.html') || hasFile('out/index.html')) {
|
|
137
|
-
const outputDir = fs.existsSync(path.join(cwd, 'dist/index.html')) ? 'dist' :
|
|
138
|
-
fs.existsSync(path.join(cwd, 'build/index.html')) ? 'build' :
|
|
139
|
-
fs.existsSync(path.join(cwd, 'out/index.html')) ? 'out' : '.';
|
|
140
|
-
return { framework: 'static', buildCommand: null, outputDir, isServer: false, packageManager: pm, confidence: 70 };
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return { framework: 'unknown', buildCommand: null, outputDir: '.', isServer: false, packageManager: pm, confidence: 10 };
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function detectPackageManager(cwd: string): 'npm' | 'pnpm' | 'yarn' | 'bun' {
|
|
147
|
-
if (fs.existsSync(path.join(cwd, 'bun.lockb'))) return 'bun';
|
|
148
|
-
if (fs.existsSync(path.join(cwd, 'pnpm-lock.yaml'))) return 'pnpm';
|
|
149
|
-
if (fs.existsSync(path.join(cwd, 'yarn.lock'))) return 'yarn';
|
|
150
|
-
return 'npm';
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function readJson(filePath: string): any {
|
|
154
|
-
try {
|
|
155
|
-
return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
156
|
-
} catch {
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
}
|
package/src/core/qr.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import qrcode from 'qrcode-terminal';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { theme } from '../ui/theme.js';
|
|
4
|
-
|
|
5
|
-
export async function showQR(url: string): Promise<void> {
|
|
6
|
-
console.log('');
|
|
7
|
-
console.log(theme.muted(' ┌─────────────────────────────────┐'));
|
|
8
|
-
console.log(theme.muted(' │') + ' ' + theme.accent('Scan to open on mobile') + ' ' + theme.muted('│'));
|
|
9
|
-
console.log(theme.muted(' └─────────────────────────────────┘'));
|
|
10
|
-
console.log('');
|
|
11
|
-
qrcode.generate(url, { small: true });
|
|
12
|
-
console.log('');
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export async function copyToClipboard(text: string): Promise<boolean> {
|
|
16
|
-
try {
|
|
17
|
-
const { default: clipboardy } = await import('clipboardy');
|
|
18
|
-
await clipboardy.write(text);
|
|
19
|
-
return true;
|
|
20
|
-
} catch {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export async function openBrowser(url: string): Promise<void> {
|
|
26
|
-
try {
|
|
27
|
-
const { default: open } = await import('open');
|
|
28
|
-
await open(url);
|
|
29
|
-
} catch {}
|
|
30
|
-
}
|
package/src/core/tunnel.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import WebSocket from 'ws';
|
|
2
|
-
import chokidar from 'chokidar';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import chalk from 'chalk';
|
|
5
|
-
import { theme } from '../ui/theme.js';
|
|
6
|
-
|
|
7
|
-
export interface LiveSyncOptions {
|
|
8
|
-
watchDir: string;
|
|
9
|
-
slug: string;
|
|
10
|
-
liveToken: string;
|
|
11
|
-
wsBase?: string;
|
|
12
|
-
onUpdate?: () => Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function startLiveSync(opts: LiveSyncOptions): () => void {
|
|
16
|
-
const wsUrl = opts.wsBase || 'wss://live.nivii.app';
|
|
17
|
-
let ws: WebSocket | null = null;
|
|
18
|
-
let reconnectTimer: ReturnType<typeof setTimeout> | null = null;
|
|
19
|
-
|
|
20
|
-
function connect() {
|
|
21
|
-
ws = new WebSocket(`${wsUrl}/live/${opts.slug}?token=${opts.liveToken}`);
|
|
22
|
-
|
|
23
|
-
ws.on('open', () => {
|
|
24
|
-
console.log(theme.success(' ⚡') + ' ' + chalk.white('Live sync connected'));
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
ws.on('close', () => {
|
|
28
|
-
console.log(theme.muted(' ↻ Live sync reconnecting…'));
|
|
29
|
-
reconnectTimer = setTimeout(connect, 3000);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
ws.on('error', () => {
|
|
33
|
-
// silent
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
connect();
|
|
38
|
-
|
|
39
|
-
// Watch for file changes
|
|
40
|
-
const watcher = chokidar.watch(opts.watchDir, {
|
|
41
|
-
ignored: /(^|[/\\])\..|(node_modules)/,
|
|
42
|
-
persistent: true,
|
|
43
|
-
ignoreInitial: true,
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
let debounceTimer: ReturnType<typeof setTimeout> | null = null;
|
|
47
|
-
const triggerUpdate = (filePath: string) => {
|
|
48
|
-
if (debounceTimer) clearTimeout(debounceTimer);
|
|
49
|
-
debounceTimer = setTimeout(async () => {
|
|
50
|
-
console.log('');
|
|
51
|
-
console.log(theme.accent(' ⚡') + ' ' + chalk.white('Change detected: ') + chalk.hex('#6B7280')(path.relative(opts.watchDir, filePath)));
|
|
52
|
-
if (opts.onUpdate) {
|
|
53
|
-
await opts.onUpdate();
|
|
54
|
-
}
|
|
55
|
-
if (ws?.readyState === WebSocket.OPEN) {
|
|
56
|
-
ws.send(JSON.stringify({ type: 'reload', slug: opts.slug }));
|
|
57
|
-
}
|
|
58
|
-
}, 300);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
watcher.on('change', triggerUpdate);
|
|
62
|
-
watcher.on('add', triggerUpdate);
|
|
63
|
-
watcher.on('unlink', triggerUpdate);
|
|
64
|
-
|
|
65
|
-
return () => {
|
|
66
|
-
watcher.close();
|
|
67
|
-
if (reconnectTimer) clearTimeout(reconnectTimer);
|
|
68
|
-
ws?.close();
|
|
69
|
-
};
|
|
70
|
-
}
|
package/src/core/upload.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import os from 'os';
|
|
4
|
-
import fetch from 'node-fetch';
|
|
5
|
-
import FormData from 'form-data';
|
|
6
|
-
import { createSpinner } from '../ui/spinner.js';
|
|
7
|
-
import { API_BASE } from '../utils/config.js';
|
|
8
|
-
import chalk from 'chalk';
|
|
9
|
-
|
|
10
|
-
export interface UploadOptions {
|
|
11
|
-
buildDir: string; // path to the built output directory
|
|
12
|
-
slug: string;
|
|
13
|
-
token?: string;
|
|
14
|
-
password?: string;
|
|
15
|
-
otp?: boolean;
|
|
16
|
-
expires?: string;
|
|
17
|
-
live?: boolean;
|
|
18
|
-
collab?: boolean;
|
|
19
|
-
maxViews?: number;
|
|
20
|
-
selfDestruct?: boolean;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface DeployResult {
|
|
24
|
-
url: string;
|
|
25
|
-
slug: string;
|
|
26
|
-
liveToken?: string;
|
|
27
|
-
collabToken?: string;
|
|
28
|
-
otpCode?: string;
|
|
29
|
-
expiresAt?: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** Recursively collect all files under a directory */
|
|
33
|
-
function collectFiles(dir: string, base: string = dir): { abs: string; rel: string }[] {
|
|
34
|
-
const results: { abs: string; rel: string }[] = [];
|
|
35
|
-
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
36
|
-
const abs = path.join(dir, entry.name);
|
|
37
|
-
if (entry.isDirectory()) {
|
|
38
|
-
results.push(...collectFiles(abs, base));
|
|
39
|
-
} else {
|
|
40
|
-
results.push({ abs, rel: path.relative(base, abs).replace(/\\/g, '/') });
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return results;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export async function uploadDeploy(opts: UploadOptions): Promise<DeployResult> {
|
|
47
|
-
const spinner = createSpinner('Uploading to edge network…');
|
|
48
|
-
spinner.start();
|
|
49
|
-
|
|
50
|
-
try {
|
|
51
|
-
const files = collectFiles(opts.buildDir);
|
|
52
|
-
|
|
53
|
-
if (files.length === 0) {
|
|
54
|
-
throw new Error('No files found in build directory');
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const form = new FormData();
|
|
58
|
-
form.append('slug', opts.slug);
|
|
59
|
-
form.append('fileCount', String(files.length));
|
|
60
|
-
if (opts.password) form.append('password', opts.password);
|
|
61
|
-
if (opts.otp) form.append('otp', 'true');
|
|
62
|
-
if (opts.expires) form.append('expires', opts.expires);
|
|
63
|
-
if (opts.live) form.append('live', 'true');
|
|
64
|
-
if (opts.collab) form.append('collab', 'true');
|
|
65
|
-
if (opts.maxViews) form.append('maxViews', String(opts.maxViews));
|
|
66
|
-
if (opts.selfDestruct) form.append('selfDestruct', 'true');
|
|
67
|
-
|
|
68
|
-
// Attach each file with its relative path as the field name
|
|
69
|
-
for (const { abs, rel } of files) {
|
|
70
|
-
form.append('file[]', fs.createReadStream(abs), { filename: rel });
|
|
71
|
-
form.append('path[]', rel);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const res = await fetch(`${API_BASE}/deploy`, {
|
|
75
|
-
method: 'POST',
|
|
76
|
-
headers: {
|
|
77
|
-
...(opts.token ? { Authorization: `Bearer ${opts.token}` } : {}),
|
|
78
|
-
...form.getHeaders(),
|
|
79
|
-
},
|
|
80
|
-
body: form,
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
if (!res.ok) {
|
|
84
|
-
const body = await res.text();
|
|
85
|
-
throw new Error(`Upload failed: ${res.status} ${body}`);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const result = await res.json() as DeployResult;
|
|
89
|
-
spinner.succeed(chalk.hex('#10B981')('Deployed to edge ') + chalk.hex('#6B7280')(`(${opts.slug})`));
|
|
90
|
-
return result;
|
|
91
|
-
} catch (err: any) {
|
|
92
|
-
spinner.fail(chalk.hex('#EF4444')('Upload failed'));
|
|
93
|
-
throw err;
|
|
94
|
-
}
|
|
95
|
-
}
|
package/src/ui/spinner.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import ora, { Ora } from 'ora';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
|
|
4
|
-
const FRAMES = ['⠋','⠙','⠹','⠸','⠼','⠴','⠦','⠧','⠇','⠏'];
|
|
5
|
-
|
|
6
|
-
export function createSpinner(text: string): Ora {
|
|
7
|
-
return ora({
|
|
8
|
-
text: chalk.hex('#A78BFA')(text),
|
|
9
|
-
spinner: {
|
|
10
|
-
interval: 80,
|
|
11
|
-
frames: FRAMES.map(f => chalk.hex('#7C3AED')(f)),
|
|
12
|
-
},
|
|
13
|
-
color: 'magenta',
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function step(emoji: string, text: string, detail?: string) {
|
|
18
|
-
const msg = chalk.hex('#A78BFA')(emoji + ' ' + chalk.white(text));
|
|
19
|
-
if (detail) {
|
|
20
|
-
console.log(msg + ' ' + chalk.hex('#6B7280')(detail));
|
|
21
|
-
} else {
|
|
22
|
-
console.log(msg);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function success(text: string) {
|
|
27
|
-
console.log(chalk.hex('#10B981')(' ✓ ') + chalk.white(text));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function warn(text: string) {
|
|
31
|
-
console.log(chalk.hex('#F59E0B')(' ⚠ ') + chalk.white(text));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function error(text: string) {
|
|
35
|
-
console.log(chalk.hex('#EF4444')(' ✗ ') + chalk.white(text));
|
|
36
|
-
}
|
package/src/ui/theme.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
|
|
3
|
-
export const theme = {
|
|
4
|
-
primary: chalk.hex('#7C3AED'), // violet
|
|
5
|
-
accent: chalk.hex('#06B6D4'), // cyan
|
|
6
|
-
success: chalk.hex('#10B981'), // emerald
|
|
7
|
-
warning: chalk.hex('#F59E0B'), // amber
|
|
8
|
-
error: chalk.hex('#EF4444'), // red
|
|
9
|
-
muted: chalk.hex('#6B7280'), // gray
|
|
10
|
-
white: chalk.white,
|
|
11
|
-
bold: chalk.bold,
|
|
12
|
-
dim: chalk.dim,
|
|
13
|
-
|
|
14
|
-
gradient: (text: string) => {
|
|
15
|
-
const chars = text.split('');
|
|
16
|
-
const colors = ['#7C3AED', '#8B5CF6', '#A78BFA', '#06B6D4', '#22D3EE'];
|
|
17
|
-
return chars.map((c, i) => chalk.hex(colors[i % colors.length])(c)).join('');
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
box: (lines: string[]) => {
|
|
21
|
-
const maxLen = Math.max(...lines.map(l => stripAnsi(l).length));
|
|
22
|
-
const border = chalk.hex('#7C3AED')('─'.repeat(maxLen + 4));
|
|
23
|
-
const top = chalk.hex('#7C3AED')('╭') + border + chalk.hex('#7C3AED')('╮');
|
|
24
|
-
const bottom = chalk.hex('#7C3AED')('╰') + border + chalk.hex('#7C3AED')('╯');
|
|
25
|
-
const mid = lines.map(l => {
|
|
26
|
-
const pad = maxLen - stripAnsi(l).length;
|
|
27
|
-
return chalk.hex('#7C3AED')('│') + ' ' + l + ' '.repeat(pad) + ' ' + chalk.hex('#7C3AED')('│');
|
|
28
|
-
});
|
|
29
|
-
return [top, ...mid, bottom].join('\n');
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
function stripAnsi(str: string): string {
|
|
34
|
-
return str.replace(/\x1b\[[0-9;]*m/g, '');
|
|
35
|
-
}
|
package/src/ui/welcome.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
|
|
3
|
-
// Fixed NIVII ASCII art — V now properly narrows to a point
|
|
4
|
-
const NIVII_ASCII = [
|
|
5
|
-
'███╗ ██╗██╗██╗ ██╗██╗██╗',
|
|
6
|
-
'████╗ ██║██║██║ ██║██║██║',
|
|
7
|
-
'██╔██╗ ██║██║██║ ██║██║██║',
|
|
8
|
-
'██║╚██╗██║██║╚██╗ ██╔╝██║██║',
|
|
9
|
-
'██║ ╚████║██║ ╚████╔╝ ██║██║',
|
|
10
|
-
'╚═╝ ╚═══╝╚═╝ ╚═══╝ ╚═╝╚═╝',
|
|
11
|
-
];
|
|
12
|
-
|
|
13
|
-
const GRADIENT = [
|
|
14
|
-
'#6B21A8',
|
|
15
|
-
'#7C3AED',
|
|
16
|
-
'#8B5CF6',
|
|
17
|
-
'#A78BFA',
|
|
18
|
-
'#C4B5FD',
|
|
19
|
-
'#DDD6FE',
|
|
20
|
-
];
|
|
21
|
-
|
|
22
|
-
const cyan = chalk.hex('#06B6D4');
|
|
23
|
-
const gray = chalk.hex('#6B7280');
|
|
24
|
-
const green = chalk.hex('#10B981');
|
|
25
|
-
const orange = chalk.hex('#F97316');
|
|
26
|
-
const white = chalk.white;
|
|
27
|
-
const purple = chalk.hex('#A78BFA');
|
|
28
|
-
|
|
29
|
-
// Snow/sparkle effect row
|
|
30
|
-
const SNOW_CHARS = ['✦', '✧', '⋆', '·', '❄', '❆', '✵', '˚', '*', ' ', ' ', ' ', ' ', ' '];
|
|
31
|
-
function snowRow(width: number, color: string): string {
|
|
32
|
-
return Array.from({ length: width }, () => {
|
|
33
|
-
const ch = SNOW_CHARS[Math.floor(Math.random() * SNOW_CHARS.length)];
|
|
34
|
-
return chalk.hex(color)(ch);
|
|
35
|
-
}).join('');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function printSnow(): void {
|
|
39
|
-
// Two rows of snow — alternating purple shades
|
|
40
|
-
console.log(' ' + snowRow(30, '#7C3AED'));
|
|
41
|
-
console.log(' ' + snowRow(30, '#A78BFA'));
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function showWelcome(): void {
|
|
45
|
-
console.log('');
|
|
46
|
-
printSnow();
|
|
47
|
-
for (let i = 0; i < NIVII_ASCII.length; i++) {
|
|
48
|
-
console.log(' ' + chalk.hex(GRADIENT[i])(NIVII_ASCII[i]));
|
|
49
|
-
}
|
|
50
|
-
printSnow();
|
|
51
|
-
console.log('');
|
|
52
|
-
console.log(' ' + orange('⚡') + ' ' + cyan('Share any project in seconds. No accounts. No config.'));
|
|
53
|
-
console.log(' ' + gray('v0.1.8 · nivii.app'));
|
|
54
|
-
console.log('');
|
|
55
|
-
console.log(' ' + gray('─'.repeat(46)));
|
|
56
|
-
console.log(' ' + cyan('Quick start:') + ' ' + white('nivii share'));
|
|
57
|
-
console.log(' ' + cyan('Custom slug:') + ' ' + white('nivii share --slug my-demo'));
|
|
58
|
-
console.log(' ' + cyan('With password:') + white('nivii share --pass secret123'));
|
|
59
|
-
console.log(' ' + cyan('Live sync:') + ' ' + white('nivii share --live'));
|
|
60
|
-
console.log(' ' + gray('─'.repeat(46)));
|
|
61
|
-
console.log('');
|
|
62
|
-
console.log(' ' + green('✓') + ' ' + cyan('First-run setup complete!') + gray(' Config saved to ~/.nivii/config.json'));
|
|
63
|
-
console.log('');
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function showHelp(): void {
|
|
67
|
-
console.log('');
|
|
68
|
-
printSnow();
|
|
69
|
-
for (let i = 0; i < NIVII_ASCII.length; i++) {
|
|
70
|
-
console.log(' ' + chalk.hex(GRADIENT[i])(NIVII_ASCII[i]));
|
|
71
|
-
}
|
|
72
|
-
printSnow();
|
|
73
|
-
console.log('');
|
|
74
|
-
console.log(' ' + orange('⚡') + ' ' + cyan('Share any project in seconds. No accounts. No config.'));
|
|
75
|
-
console.log(' ' + gray('v0.1.8 · nivii.app'));
|
|
76
|
-
console.log('');
|
|
77
|
-
console.log(' ' + gray('─'.repeat(50)));
|
|
78
|
-
console.log(' ' + purple.bold('Commands'));
|
|
79
|
-
console.log('');
|
|
80
|
-
console.log(' ' + cyan('nivii share') + ' ' + gray('Deploy current directory'));
|
|
81
|
-
console.log(' ' + cyan('nivii share --slug my-demo') + ' ' + gray('Custom slug (Pro)'));
|
|
82
|
-
console.log(' ' + cyan('nivii share --pass secret') + ' ' + gray('Password protect'));
|
|
83
|
-
console.log(' ' + cyan('nivii share --expires 24h') + ' ' + gray('Set expiry (1h/24h/7d/30d)'));
|
|
84
|
-
console.log(' ' + cyan('nivii share --live') + ' ' + gray('Live sync on file changes'));
|
|
85
|
-
console.log(' ' + cyan('nivii share --no-build') + ' ' + gray('Skip build step'));
|
|
86
|
-
console.log(' ' + cyan('nivii ls') + ' ' + gray('List recent deployments'));
|
|
87
|
-
console.log(' ' + cyan('nivii whoami') + ' ' + gray('Show account info'));
|
|
88
|
-
console.log(' ' + cyan('nivii analytics [slug]') + ' ' + gray('View deployment analytics'));
|
|
89
|
-
console.log(' ' + cyan('nivii config') + ' ' + gray('View/set config values'));
|
|
90
|
-
console.log('');
|
|
91
|
-
console.log(' ' + gray('─'.repeat(50)));
|
|
92
|
-
console.log(' ' + gray('Docs: ') + white('https://nivii.app') + ' ' + gray('·') + ' ' + gray('Pro: ') + white('https://nivii.app/#pricing'));
|
|
93
|
-
console.log('');
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export function showBanner(): void {
|
|
97
|
-
console.log('');
|
|
98
|
-
console.log(
|
|
99
|
-
' ' + orange('⚡') + ' ' +
|
|
100
|
-
chalk.hex('#A78BFA').bold('NIVII') + ' ' +
|
|
101
|
-
gray('v0.1.8')
|
|
102
|
-
);
|
|
103
|
-
console.log('');
|
|
104
|
-
}
|
package/src/utils/config.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import os from 'os';
|
|
4
|
-
|
|
5
|
-
export interface NiviiConfig {
|
|
6
|
-
token?: string;
|
|
7
|
-
plan?: 'free' | 'pro';
|
|
8
|
-
apiBase?: string;
|
|
9
|
-
firstRun?: boolean;
|
|
10
|
-
deployments?: Array<{
|
|
11
|
-
slug: string;
|
|
12
|
-
url: string;
|
|
13
|
-
createdAt: string;
|
|
14
|
-
expiresAt?: string;
|
|
15
|
-
}>;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const CONFIG_DIR = path.join(os.homedir(), '.nivii');
|
|
19
|
-
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
|
|
20
|
-
|
|
21
|
-
export const API_BASE = process.env.NIVII_API || 'https://api.nivii.app';
|
|
22
|
-
|
|
23
|
-
export function loadConfig(): NiviiConfig {
|
|
24
|
-
try {
|
|
25
|
-
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
26
|
-
if (!fs.existsSync(CONFIG_FILE)) {
|
|
27
|
-
const defaults: NiviiConfig = { firstRun: true, apiBase: API_BASE, deployments: [] };
|
|
28
|
-
saveConfig(defaults);
|
|
29
|
-
return defaults;
|
|
30
|
-
}
|
|
31
|
-
return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf-8'));
|
|
32
|
-
} catch {
|
|
33
|
-
return { firstRun: true, apiBase: API_BASE, deployments: [] };
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function saveConfig(config: NiviiConfig): void {
|
|
38
|
-
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
39
|
-
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function updateConfig(updates: Partial<NiviiConfig>): NiviiConfig {
|
|
43
|
-
const current = loadConfig();
|
|
44
|
-
const updated = { ...current, ...updates };
|
|
45
|
-
saveConfig(updated);
|
|
46
|
-
return updated;
|
|
47
|
-
}
|
package/src/utils/hash.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import crypto from 'crypto';
|
|
2
|
-
|
|
3
|
-
export function generateSlug(length = 8): string {
|
|
4
|
-
const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
|
5
|
-
const bytes = crypto.randomBytes(length);
|
|
6
|
-
return Array.from(bytes).map(b => chars[b % chars.length]).join('');
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function hashFile(content: Buffer): string {
|
|
10
|
-
return crypto.createHash('sha256').update(content).digest('hex').slice(0, 16);
|
|
11
|
-
}
|
package/src/utils/zip.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { createWriteStream } from 'fs';
|
|
4
|
-
import archiver from 'archiver';
|
|
5
|
-
import os from 'os';
|
|
6
|
-
|
|
7
|
-
export async function zipDirectory(sourceDir: string): Promise<string> {
|
|
8
|
-
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'nivii-'));
|
|
9
|
-
const zipPath = path.join(tmpDir, 'deploy.zip');
|
|
10
|
-
|
|
11
|
-
return new Promise((resolve, reject) => {
|
|
12
|
-
const output = createWriteStream(zipPath);
|
|
13
|
-
const archive = archiver('zip', { zlib: { level: 9 } });
|
|
14
|
-
|
|
15
|
-
output.on('close', () => resolve(zipPath));
|
|
16
|
-
archive.on('error', reject);
|
|
17
|
-
|
|
18
|
-
archive.pipe(output);
|
|
19
|
-
archive.directory(sourceDir, false);
|
|
20
|
-
archive.finalize();
|
|
21
|
-
});
|
|
22
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|