@byfungsi/funforge 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.
- package/README.md +273 -0
- package/dist/__tests__/api.test.d.ts +5 -0
- package/dist/__tests__/api.test.d.ts.map +1 -0
- package/dist/__tests__/api.test.js +177 -0
- package/dist/__tests__/config.test.d.ts +5 -0
- package/dist/__tests__/config.test.d.ts.map +1 -0
- package/dist/__tests__/config.test.js +58 -0
- package/dist/__tests__/mcp.test.d.ts +7 -0
- package/dist/__tests__/mcp.test.d.ts.map +1 -0
- package/dist/__tests__/mcp.test.js +142 -0
- package/dist/__tests__/project-config.test.d.ts +5 -0
- package/dist/__tests__/project-config.test.d.ts.map +1 -0
- package/dist/__tests__/project-config.test.js +122 -0
- package/dist/__tests__/tarball.test.d.ts +5 -0
- package/dist/__tests__/tarball.test.d.ts.map +1 -0
- package/dist/__tests__/tarball.test.js +113 -0
- package/dist/api.d.ts +157 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +165 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +129 -0
- package/dist/commands/apps.d.ts +29 -0
- package/dist/commands/apps.d.ts.map +1 -0
- package/dist/commands/apps.js +151 -0
- package/dist/commands/auth.d.ts +27 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +127 -0
- package/dist/commands/config.d.ts +31 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +287 -0
- package/dist/commands/deploy.d.ts +24 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +196 -0
- package/dist/commands/domains.d.ts +35 -0
- package/dist/commands/domains.d.ts.map +1 -0
- package/dist/commands/domains.js +217 -0
- package/dist/commands/env.d.ts +26 -0
- package/dist/commands/env.d.ts.map +1 -0
- package/dist/commands/env.js +183 -0
- package/dist/config.d.ts +22 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +23 -0
- package/dist/credentials.d.ts +46 -0
- package/dist/credentials.d.ts.map +1 -0
- package/dist/credentials.js +60 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/mcp.d.ts +19 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +480 -0
- package/dist/project-config.d.ts +47 -0
- package/dist/project-config.d.ts.map +1 -0
- package/dist/project-config.js +55 -0
- package/dist/tarball.d.ts +29 -0
- package/dist/tarball.d.ts.map +1 -0
- package/dist/tarball.js +148 -0
- package/package.json +45 -0
package/dist/tarball.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tarball Utilities
|
|
3
|
+
*
|
|
4
|
+
* Creates gzipped tarballs from project directories,
|
|
5
|
+
* respecting .gitignore and .funforgeignore patterns.
|
|
6
|
+
*/
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
8
|
+
import { createReadStream } from "node:fs";
|
|
9
|
+
import { readFile, stat } from "node:fs/promises";
|
|
10
|
+
import { tmpdir } from "node:os";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
import { glob } from "glob";
|
|
13
|
+
import ignore from "ignore";
|
|
14
|
+
import * as tar from "tar";
|
|
15
|
+
/**
|
|
16
|
+
* Default ignore patterns (always excluded)
|
|
17
|
+
*/
|
|
18
|
+
const DEFAULT_IGNORES = [
|
|
19
|
+
// Version control
|
|
20
|
+
".git",
|
|
21
|
+
".svn",
|
|
22
|
+
".hg",
|
|
23
|
+
// Dependencies
|
|
24
|
+
"node_modules",
|
|
25
|
+
".pnpm-store",
|
|
26
|
+
// Build outputs (usually regenerated)
|
|
27
|
+
".next",
|
|
28
|
+
".nuxt",
|
|
29
|
+
".output",
|
|
30
|
+
"dist",
|
|
31
|
+
"build",
|
|
32
|
+
// IDE and editor
|
|
33
|
+
".idea",
|
|
34
|
+
".vscode",
|
|
35
|
+
"*.swp",
|
|
36
|
+
"*.swo",
|
|
37
|
+
// OS files
|
|
38
|
+
".DS_Store",
|
|
39
|
+
"Thumbs.db",
|
|
40
|
+
// Logs
|
|
41
|
+
"*.log",
|
|
42
|
+
"npm-debug.log*",
|
|
43
|
+
"yarn-debug.log*",
|
|
44
|
+
"yarn-error.log*",
|
|
45
|
+
// Environment files (security)
|
|
46
|
+
".env",
|
|
47
|
+
".env.*",
|
|
48
|
+
"!.env.example",
|
|
49
|
+
// FunForge ignore file (not needed in build)
|
|
50
|
+
".funforgeignore",
|
|
51
|
+
];
|
|
52
|
+
/**
|
|
53
|
+
* Load ignore patterns from .gitignore and .funforgeignore
|
|
54
|
+
*/
|
|
55
|
+
async function loadIgnorePatterns(projectDir) {
|
|
56
|
+
const patterns = [...DEFAULT_IGNORES];
|
|
57
|
+
// Load .gitignore
|
|
58
|
+
try {
|
|
59
|
+
const gitignore = await readFile(join(projectDir, ".gitignore"), "utf-8");
|
|
60
|
+
patterns.push(...gitignore
|
|
61
|
+
.split("\n")
|
|
62
|
+
.filter((line) => line.trim() && !line.startsWith("#")));
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
// .gitignore doesn't exist, that's fine
|
|
66
|
+
}
|
|
67
|
+
// Load .funforgeignore (overrides)
|
|
68
|
+
try {
|
|
69
|
+
const funforgeignore = await readFile(join(projectDir, ".funforgeignore"), "utf-8");
|
|
70
|
+
patterns.push(...funforgeignore
|
|
71
|
+
.split("\n")
|
|
72
|
+
.filter((line) => line.trim() && !line.startsWith("#")));
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// .funforgeignore doesn't exist, that's fine
|
|
76
|
+
}
|
|
77
|
+
return patterns;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Create a gzipped tarball from a project directory
|
|
81
|
+
*/
|
|
82
|
+
export async function createTarball(projectDir) {
|
|
83
|
+
// Load ignore patterns
|
|
84
|
+
const patterns = await loadIgnorePatterns(projectDir);
|
|
85
|
+
const ig = ignore().add(patterns);
|
|
86
|
+
// Find all files
|
|
87
|
+
const allFiles = await glob("**/*", {
|
|
88
|
+
cwd: projectDir,
|
|
89
|
+
nodir: true,
|
|
90
|
+
dot: true,
|
|
91
|
+
follow: false,
|
|
92
|
+
});
|
|
93
|
+
// Filter files using ignore patterns
|
|
94
|
+
const files = allFiles.filter((file) => !ig.ignores(file));
|
|
95
|
+
if (files.length === 0) {
|
|
96
|
+
throw new Error("No files to include in tarball. Check your ignore patterns.");
|
|
97
|
+
}
|
|
98
|
+
// Create tarball in temp directory
|
|
99
|
+
const tarballPath = join(tmpdir(), `funforge-${Date.now()}.tar.gz`);
|
|
100
|
+
// Create tar archive
|
|
101
|
+
await tar.create({
|
|
102
|
+
gzip: true,
|
|
103
|
+
file: tarballPath,
|
|
104
|
+
cwd: projectDir,
|
|
105
|
+
portable: true,
|
|
106
|
+
}, files);
|
|
107
|
+
// Get file stats and hash
|
|
108
|
+
const stats = await stat(tarballPath);
|
|
109
|
+
const hash = await hashFile(tarballPath);
|
|
110
|
+
return {
|
|
111
|
+
path: tarballPath,
|
|
112
|
+
size: stats.size,
|
|
113
|
+
sha256: hash,
|
|
114
|
+
fileCount: files.length,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Calculate SHA-256 hash of a file
|
|
119
|
+
*/
|
|
120
|
+
async function hashFile(filePath) {
|
|
121
|
+
const hash = createHash("sha256");
|
|
122
|
+
const stream = createReadStream(filePath);
|
|
123
|
+
for await (const chunk of stream) {
|
|
124
|
+
hash.update(chunk);
|
|
125
|
+
}
|
|
126
|
+
return hash.digest("hex");
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Read tarball as buffer
|
|
130
|
+
*/
|
|
131
|
+
export async function readTarball(tarballPath) {
|
|
132
|
+
const chunks = [];
|
|
133
|
+
const stream = createReadStream(tarballPath);
|
|
134
|
+
for await (const chunk of stream) {
|
|
135
|
+
chunks.push(chunk);
|
|
136
|
+
}
|
|
137
|
+
return Buffer.concat(chunks);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Format file size for display
|
|
141
|
+
*/
|
|
142
|
+
export function formatSize(bytes) {
|
|
143
|
+
if (bytes < 1024)
|
|
144
|
+
return `${bytes} B`;
|
|
145
|
+
if (bytes < 1024 * 1024)
|
|
146
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
147
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
148
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@byfungsi/funforge",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Deploy without git, without leaving your editor",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"funforge": "./dist/cli.js",
|
|
10
|
+
"funforge-mcp": "./dist/mcp.js"
|
|
11
|
+
},
|
|
12
|
+
"files": ["dist", "README.md"],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"dev": "tsc --watch",
|
|
16
|
+
"typecheck": "tsc --noEmit",
|
|
17
|
+
"test": "vitest run",
|
|
18
|
+
"start": "node dist/cli.js",
|
|
19
|
+
"mcp": "node dist/mcp.js"
|
|
20
|
+
},
|
|
21
|
+
"keywords": ["cli", "deploy", "funforge", "fungsi", "mcp"],
|
|
22
|
+
"author": "Fungsi",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=18.0.0"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
29
|
+
"chalk": "^5.4.1",
|
|
30
|
+
"commander": "^13.1.0",
|
|
31
|
+
"conf": "^13.1.0",
|
|
32
|
+
"glob": "^11.0.1",
|
|
33
|
+
"ignore": "^7.0.4",
|
|
34
|
+
"open": "^10.1.0",
|
|
35
|
+
"ora": "^8.2.0",
|
|
36
|
+
"tar": "^7.4.3",
|
|
37
|
+
"zod": "^3.25.34"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/node": "^22.15.21",
|
|
41
|
+
"@types/tar": "^6.1.13",
|
|
42
|
+
"typescript": "^5.0.0",
|
|
43
|
+
"vitest": "^4.0.16"
|
|
44
|
+
}
|
|
45
|
+
}
|