@kitecd/cli 1.0.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 (37) hide show
  1. package/bin/kite.js +2 -0
  2. package/dist/home.js +114 -0
  3. package/dist/index.js +603 -0
  4. package/dist/local-server.js +434 -0
  5. package/dist/local-store.js +142 -0
  6. package/dist/pack.js +137 -0
  7. package/dist/serve.js +208 -0
  8. package/dist/server/index.js +30043 -0
  9. package/dist/upload.js +84 -0
  10. package/dist/web/assets/Dashboard-pjIWWLub.js +1 -0
  11. package/dist/web/assets/DefaultLayout-Bj8fPWym.css +1 -0
  12. package/dist/web/assets/DefaultLayout-DelfwTTT.js +1 -0
  13. package/dist/web/assets/FileExplorer-xY5ejhhN.js +1 -0
  14. package/dist/web/assets/LogBoard-DzW-cEqH.css +1 -0
  15. package/dist/web/assets/LogBoard-tT61QjOx.js +6 -0
  16. package/dist/web/assets/Login-B4C149oC.js +1 -0
  17. package/dist/web/assets/ProjectDetail-Z8cZoqr5.js +1 -0
  18. package/dist/web/assets/ProjectList-9rbMuJeY.js +1 -0
  19. package/dist/web/assets/Settings-CtCNDUXY.js +1 -0
  20. package/dist/web/assets/activity-DItEGOtI.js +1 -0
  21. package/dist/web/assets/circle-alert-Bfrn_ovD.js +1 -0
  22. package/dist/web/assets/clock-BPXGSCIV.js +1 -0
  23. package/dist/web/assets/constants-C4Zrkm2g.js +1 -0
  24. package/dist/web/assets/createLucideIcon-Cgv1AIRL.js +1 -0
  25. package/dist/web/assets/folder-open-jX-_Q7bA.js +1 -0
  26. package/dist/web/assets/index-C615tnMi.js +2 -0
  27. package/dist/web/assets/index-C9LiRc31.css +1 -0
  28. package/dist/web/assets/project-BFuaDcvV.js +1 -0
  29. package/dist/web/assets/refresh-cw-DWmqwQRn.js +1 -0
  30. package/dist/web/assets/save-BkiMrL9q.js +1 -0
  31. package/dist/web/assets/server-C33taHNn.js +1 -0
  32. package/dist/web/assets/settings-CrCWmNyB.js +1 -0
  33. package/dist/web/assets/square-terminal-C8toRwjx.js +1 -0
  34. package/dist/web/favicon.svg +5 -0
  35. package/dist/web/icons.svg +24 -0
  36. package/dist/web/index.html +15 -0
  37. package/package.json +40 -0
package/bin/kite.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../dist/index.js';
package/dist/home.js ADDED
@@ -0,0 +1,114 @@
1
+ import fs from 'fs';
2
+ import os from 'os';
3
+ import path from 'path';
4
+ import crypto from 'crypto';
5
+ export function getKiteHome() {
6
+ return process.env.KITE_HOME || path.join(os.homedir(), '.kite');
7
+ }
8
+ export function ensureKiteHome() {
9
+ const home = getKiteHome();
10
+ fs.mkdirSync(home, { recursive: true });
11
+ fs.mkdirSync(path.join(home, 'deployments'), { recursive: true });
12
+ fs.mkdirSync(path.join(home, 'tmp'), { recursive: true });
13
+ return home;
14
+ }
15
+ export function getConfigPath() {
16
+ return path.join(ensureKiteHome(), 'config.json');
17
+ }
18
+ export function readGlobalConfig() {
19
+ const configPath = getConfigPath();
20
+ if (!fs.existsSync(configPath))
21
+ return {};
22
+ return JSON.parse(fs.readFileSync(configPath, 'utf-8'));
23
+ }
24
+ export function writeGlobalConfig(config) {
25
+ fs.writeFileSync(getConfigPath(), `${JSON.stringify(config, null, 2)}\n`);
26
+ }
27
+ export function setGlobalConfig(key, value) {
28
+ const config = readGlobalConfig();
29
+ config[key] = value;
30
+ writeGlobalConfig(config);
31
+ }
32
+ export function randomToken(prefix) {
33
+ return `${prefix}_${crypto.randomUUID().replace(/-/g, '')}`;
34
+ }
35
+ export function readLocalEnv(cwd = process.cwd()) {
36
+ const envPath = path.join(cwd, '.env.local');
37
+ if (!fs.existsSync(envPath))
38
+ return {};
39
+ const env = {};
40
+ for (const line of fs.readFileSync(envPath, 'utf-8').split(/\r?\n/)) {
41
+ const trimmed = line.trim();
42
+ if (!trimmed || trimmed.startsWith('#'))
43
+ continue;
44
+ const separatorIndex = trimmed.indexOf('=');
45
+ if (separatorIndex < 0)
46
+ continue;
47
+ const key = trimmed.slice(0, separatorIndex).trim();
48
+ const rawValue = trimmed.slice(separatorIndex + 1).trim();
49
+ env[key] = rawValue.replace(/^['"]|['"]$/g, '');
50
+ }
51
+ return env;
52
+ }
53
+ /**
54
+ * Scan cwd for kite.config*.json files.
55
+ * Returns array sorted: default first, then alphabetical by env name.
56
+ */
57
+ export function listProjectEnvs(cwd = process.cwd()) {
58
+ const files = fs.readdirSync(cwd).filter(f => /^kite\.config(\.[a-zA-Z0-9_-]+)?\.json$/.test(f));
59
+ const results = [];
60
+ for (const file of files.sort()) {
61
+ const match = file.match(/^kite\.config(?:\.([a-zA-Z0-9_-]+))?\.json$/);
62
+ if (!match)
63
+ continue;
64
+ const env = match[1]; // undefined for kite.config.json
65
+ const configPath = path.join(cwd, file);
66
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
67
+ results.push({ env, config, configPath });
68
+ }
69
+ // default (no env) first, then alphabetical
70
+ return results.sort((a, b) => {
71
+ if (!a.env && b.env)
72
+ return -1;
73
+ if (a.env && !b.env)
74
+ return 1;
75
+ return (a.env || '').localeCompare(b.env || '');
76
+ });
77
+ }
78
+ /**
79
+ * Resolve a single project config by env name.
80
+ * If env is undefined, returns the default config (kite.config.json).
81
+ */
82
+ export function resolveProjectConfig(env, cwd = process.cwd()) {
83
+ const all = listProjectEnvs(cwd);
84
+ if (all.length === 0)
85
+ return null;
86
+ if (env === undefined) {
87
+ return all.find(e => e.env === undefined) || null;
88
+ }
89
+ return all.find(e => e.env === env) || null;
90
+ }
91
+ /**
92
+ * Build the token lookup key for projectToken storage.
93
+ * With env: "projectId:env", without env: "projectId"
94
+ */
95
+ export function envTokenKey(projectId, env) {
96
+ return env ? `${projectId}:${env}` : projectId;
97
+ }
98
+ export function writeLocalEnvValue(key, value, cwd = process.cwd()) {
99
+ const envPath = path.join(cwd, '.env.local');
100
+ const lines = fs.existsSync(envPath)
101
+ ? fs.readFileSync(envPath, 'utf-8').split(/\r?\n/)
102
+ : [];
103
+ let found = false;
104
+ const nextLines = lines.map((line) => {
105
+ if (line.trim().startsWith(`${key}=`)) {
106
+ found = true;
107
+ return `${key}=${value}`;
108
+ }
109
+ return line;
110
+ }).filter((line, index, arr) => line || index < arr.length - 1);
111
+ if (!found)
112
+ nextLines.push(`${key}=${value}`);
113
+ fs.writeFileSync(envPath, `${nextLines.join('\n')}\n`);
114
+ }