@blkc-code/cli 0.0.0-stage → 0.1.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/LICENSE +201 -0
- package/NOTICE +5 -0
- package/README.md +12 -2
- package/dist/commands/block.d.ts +2 -0
- package/dist/commands/block.js +284 -0
- package/dist/commands/block.js.map +1 -0
- package/dist/commands/circuit.d.ts +2 -0
- package/dist/commands/circuit.js +166 -0
- package/dist/commands/circuit.js.map +1 -0
- package/dist/commands/kit.d.ts +2 -0
- package/dist/commands/kit.js +175 -0
- package/dist/commands/kit.js.map +1 -0
- package/dist/commands/logbook.d.ts +2 -0
- package/dist/commands/logbook.js +156 -0
- package/dist/commands/logbook.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/filesystem.d.ts +5 -0
- package/dist/utils/filesystem.js +21 -0
- package/dist/utils/filesystem.js.map +1 -0
- package/dist/utils/github.d.ts +23 -0
- package/dist/utils/github.js +66 -0
- package/dist/utils/github.js.map +1 -0
- package/package.json +47 -4
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type CreateRepoOptions = {
|
|
2
|
+
org?: string;
|
|
3
|
+
name: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
private?: boolean;
|
|
6
|
+
token?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const ensureGithubRepo: (opts: CreateRepoOptions) => Promise<{
|
|
9
|
+
created: boolean;
|
|
10
|
+
message: string;
|
|
11
|
+
repo?: undefined;
|
|
12
|
+
details?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
created: boolean;
|
|
15
|
+
message: string;
|
|
16
|
+
repo: any;
|
|
17
|
+
details?: undefined;
|
|
18
|
+
} | {
|
|
19
|
+
created: boolean;
|
|
20
|
+
message: any;
|
|
21
|
+
details: any;
|
|
22
|
+
repo?: undefined;
|
|
23
|
+
}>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import https from "node:https";
|
|
2
|
+
import { URL } from "node:url";
|
|
3
|
+
const requestJson = (url, token, body) => new Promise((resolve, reject) => {
|
|
4
|
+
try {
|
|
5
|
+
const u = new URL(url);
|
|
6
|
+
const data = JSON.stringify(body);
|
|
7
|
+
const headers = {
|
|
8
|
+
Authorization: token ? `token ${token}` : "",
|
|
9
|
+
"Content-Type": "application/json",
|
|
10
|
+
Accept: "application/vnd.github+json",
|
|
11
|
+
"User-Agent": "blkc-cli",
|
|
12
|
+
"Content-Length": Buffer.byteLength(data).toString(),
|
|
13
|
+
};
|
|
14
|
+
const opts = {
|
|
15
|
+
method: "POST",
|
|
16
|
+
hostname: u.hostname,
|
|
17
|
+
path: u.pathname + (u.search ?? ""),
|
|
18
|
+
headers,
|
|
19
|
+
};
|
|
20
|
+
const req = https.request(opts, (res) => {
|
|
21
|
+
let raw = "";
|
|
22
|
+
res.setEncoding("utf8");
|
|
23
|
+
res.on("data", (chunk) => (raw += chunk));
|
|
24
|
+
res.on("end", () => {
|
|
25
|
+
try {
|
|
26
|
+
const parsed = raw ? JSON.parse(raw) : {};
|
|
27
|
+
resolve({ statusCode: res.statusCode, body: parsed });
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
reject(err);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
req.on("error", (err) => reject(err));
|
|
35
|
+
req.write(data);
|
|
36
|
+
req.end();
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
reject(error);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
export const ensureGithubRepo = async (opts) => {
|
|
43
|
+
if (!opts.token) {
|
|
44
|
+
return { created: false, message: "No GITHUB_TOKEN provided; skipping GitHub repo creation." };
|
|
45
|
+
}
|
|
46
|
+
const url = opts.org
|
|
47
|
+
? `https://api.github.com/orgs/${opts.org}/repos`
|
|
48
|
+
: `https://api.github.com/user/repos`;
|
|
49
|
+
const body = {
|
|
50
|
+
name: opts.name,
|
|
51
|
+
description: opts.description ?? "",
|
|
52
|
+
private: !!opts.private,
|
|
53
|
+
auto_init: true,
|
|
54
|
+
};
|
|
55
|
+
try {
|
|
56
|
+
const res = await requestJson(url, opts.token, body);
|
|
57
|
+
if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
|
|
58
|
+
return { created: true, message: "Repository created", repo: res.body.html_url };
|
|
59
|
+
}
|
|
60
|
+
return { created: false, message: res.body?.message || "Failed to create repo", details: res.body };
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
return { created: false, message: error.message };
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=github.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.js","sourceRoot":"","sources":["../../src/utils/github.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAU/B,MAAM,WAAW,GAAG,CAAC,GAAW,EAAE,KAAyB,EAAE,IAAY,EAAE,EAAE,CAC3E,IAAI,OAAO,CAAM,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;IACnC,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACvB,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAClC,MAAM,OAAO,GAA2B;YACtC,aAAa,EAAE,KAAK,CAAC,CAAC,CAAC,SAAS,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE;YAC5C,cAAc,EAAE,kBAAkB;YAClC,MAAM,EAAE,6BAA6B;YACrC,YAAY,EAAE,UAAU;YACxB,gBAAgB,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE;SACrD,CAAC;QAEF,MAAM,IAAI,GAAyB;YACjC,MAAM,EAAE,MAAM;YACd,QAA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
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"blkc": "dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"LICENSE",
|
|
14
|
+
"NOTICE",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc -p tsconfig.json",
|
|
19
|
+
"clean": "rimraf dist tsconfig.tsbuildinfo",
|
|
20
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
21
|
+
"lint": "eslint \"src/**/*.{ts,tsx}\"",
|
|
22
|
+
"test": "vitest",
|
|
23
|
+
"prepublishOnly": "bun run clean && bun run build"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@blkc-code/core": "0.1.1",
|
|
27
|
+
"@blkc-code/logbook": "0.1.1",
|
|
28
|
+
"@commander-js/extra-typings": "^12.1.0",
|
|
29
|
+
"chalk": "^5.3.0",
|
|
30
|
+
"commander": "^12.1.0",
|
|
31
|
+
"fs-extra": "^11.2.0",
|
|
32
|
+
"inquirer": "^12.3.0",
|
|
33
|
+
"ora": "^8.0.1"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^20.14.9",
|
|
37
|
+
"@typescript-eslint/eslint-plugin": "^8.44.0",
|
|
38
|
+
"@typescript-eslint/parser": "^8.44.0",
|
|
39
|
+
"eslint": "^9.16.0",
|
|
40
|
+
"eslint-config-prettier": "^10.1.1",
|
|
41
|
+
"rimraf": "^6.0.1",
|
|
42
|
+
"typescript": "^5.6.3",
|
|
43
|
+
"vitest": "^3.2.4"
|
|
44
|
+
},
|
|
45
|
+
"homepage": "https://github.com/blkc-community",
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public"
|
|
48
|
+
}
|
|
49
|
+
}
|