@simplr-ai/release-cli 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 +53 -0
- package/dist/chunk-YPVQ3FRD.js +22 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +101 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +8 -0
- package/package.json +27 -0
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# @simplr-ai/release-cli
|
|
2
|
+
|
|
3
|
+
Push commits and CI test results to **Simplr Release Notes** from a git hook or CI step.
|
|
4
|
+
Feeds the same `/v1/release-ingest` API the GitHub App and VS Code extension use, so it
|
|
5
|
+
works for any provider.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bun add -d @simplr-ai/release-cli # or npm i -D
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Auth
|
|
14
|
+
|
|
15
|
+
Create a project **ingest token** in the Simplr dashboard (Release Notes → project → Connect).
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
export SIMPLR_RELEASE_TOKEN=rnit_xxx
|
|
19
|
+
export SIMPLR_API_URL=https://api.simplr.so # optional, this is the default
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Capture a commit
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Captures HEAD (sha, branch, message, author) automatically:
|
|
26
|
+
simplr-release release push
|
|
27
|
+
|
|
28
|
+
# Or be explicit / override the environment mapping:
|
|
29
|
+
simplr-release release push --ref main --env uat --title "Checkout v2"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Wire it into `.git/hooks/post-commit` or a CI step to capture every push.
|
|
33
|
+
|
|
34
|
+
## Report a test result (gates flag rollout + release publishing)
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
simplr-release test report --status passed --tag ci-main
|
|
38
|
+
simplr-release test report --status failed --tag ci-main
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
A feature flag with `rollout_mode=auto` and `rollout_tag=ci-main` will advance only
|
|
42
|
+
while the latest reported run for that tag is green, and halt on red — the same gate
|
|
43
|
+
GitHub Actions results feed.
|
|
44
|
+
|
|
45
|
+
## Programmatic use
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { pushChange, reportTest } from "@simplr-ai/release-cli";
|
|
49
|
+
|
|
50
|
+
const opts = { apiUrl: "https://api.simplr.so", token: process.env.SIMPLR_RELEASE_TOKEN! };
|
|
51
|
+
await pushChange(opts, { kind: "commit", title: "Fix login", ref: "main" });
|
|
52
|
+
await reportTest(opts, { status: "passed", tag: "ci-main" });
|
|
53
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
async function post(opts, path, body) {
|
|
3
|
+
const res = await fetch(`${opts.apiUrl}${path}`, {
|
|
4
|
+
method: "POST",
|
|
5
|
+
headers: { "Content-Type": "application/json", Authorization: `Bearer ${opts.token}` },
|
|
6
|
+
body: JSON.stringify(body)
|
|
7
|
+
});
|
|
8
|
+
const json = await res.json().catch(() => ({}));
|
|
9
|
+
if (!res.ok) throw new Error(json?.message || `Request failed (${res.status})`);
|
|
10
|
+
return json;
|
|
11
|
+
}
|
|
12
|
+
function pushChange(opts, input) {
|
|
13
|
+
return post(opts, "/v1/release-ingest/changes", input);
|
|
14
|
+
}
|
|
15
|
+
function reportTest(opts, input) {
|
|
16
|
+
return post(opts, "/v1/release-ingest/test-result", { ...input, external_id: input.externalId });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
pushChange,
|
|
21
|
+
reportTest
|
|
22
|
+
};
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
pushChange,
|
|
4
|
+
reportTest
|
|
5
|
+
} from "./chunk-YPVQ3FRD.js";
|
|
6
|
+
|
|
7
|
+
// src/cli.ts
|
|
8
|
+
import { execSync } from "child_process";
|
|
9
|
+
function getOptions(args) {
|
|
10
|
+
const token = args.get("token") ?? process.env.SIMPLR_RELEASE_TOKEN ?? "";
|
|
11
|
+
const apiUrl = args.get("api") ?? process.env.SIMPLR_API_URL ?? "https://api.simplr.so";
|
|
12
|
+
if (!token) {
|
|
13
|
+
console.error("Missing token. Pass --token <rnit_\u2026> or set SIMPLR_RELEASE_TOKEN.");
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
return { token, apiUrl };
|
|
17
|
+
}
|
|
18
|
+
function git(cmd) {
|
|
19
|
+
try {
|
|
20
|
+
return execSync(`git ${cmd}`, { encoding: "utf8" }).trim();
|
|
21
|
+
} catch {
|
|
22
|
+
return "";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function parseArgs(argv) {
|
|
26
|
+
const flags = /* @__PURE__ */ new Map();
|
|
27
|
+
const positional = [];
|
|
28
|
+
for (let i = 0; i < argv.length; i++) {
|
|
29
|
+
const a = argv[i];
|
|
30
|
+
if (a.startsWith("--")) {
|
|
31
|
+
const key = a.slice(2);
|
|
32
|
+
const next = argv[i + 1];
|
|
33
|
+
if (next && !next.startsWith("--")) {
|
|
34
|
+
flags.set(key, next);
|
|
35
|
+
i++;
|
|
36
|
+
} else {
|
|
37
|
+
flags.set(key, "true");
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
positional.push(a);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return { command: positional[0] ?? "", sub: positional[1] ?? "", flags };
|
|
44
|
+
}
|
|
45
|
+
var HELP = `simplr-release \u2014 push commits and CI results to Simplr Release Notes
|
|
46
|
+
|
|
47
|
+
Usage:
|
|
48
|
+
simplr-release release push [--ref <ref>] [--sha <sha>] [--title <msg>] [--env <key>]
|
|
49
|
+
simplr-release test report --status <passed|failed|\u2026> [--tag <t>] [--name <n>] [--env <key>]
|
|
50
|
+
|
|
51
|
+
Auth:
|
|
52
|
+
--token <rnit_\u2026> or SIMPLR_RELEASE_TOKEN
|
|
53
|
+
--api <url> or SIMPLR_API_URL (default https://api.simplr.so)
|
|
54
|
+
|
|
55
|
+
Examples:
|
|
56
|
+
simplr-release release push # captures HEAD commit
|
|
57
|
+
simplr-release test report --status passed --tag ci-main
|
|
58
|
+
`;
|
|
59
|
+
async function main() {
|
|
60
|
+
const { command, sub, flags } = parseArgs(process.argv.slice(2));
|
|
61
|
+
if (!command || flags.has("help")) {
|
|
62
|
+
console.log(HELP);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const opts = getOptions(flags);
|
|
66
|
+
if (command === "release" && sub === "push") {
|
|
67
|
+
const sha = flags.get("sha") ?? git("rev-parse HEAD");
|
|
68
|
+
const ref = flags.get("ref") ?? git("rev-parse --abbrev-ref HEAD");
|
|
69
|
+
const title = flags.get("title") ?? git("log -1 --pretty=%s") ?? "(no message)";
|
|
70
|
+
const body = git("log -1 --pretty=%b") || void 0;
|
|
71
|
+
const author = git("log -1 --pretty=%an") || void 0;
|
|
72
|
+
await pushChange(opts, { kind: "commit", sha, ref, title, body, author, environment: flags.get("env") });
|
|
73
|
+
console.log(`\u2713 Pushed commit ${sha.slice(0, 7)} (${ref}) to Simplr`);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (command === "test" && sub === "report") {
|
|
77
|
+
const status = flags.get("status");
|
|
78
|
+
if (!status) {
|
|
79
|
+
console.error("--status is required (passed|failed|queued|running|cancelled)");
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
await reportTest(opts, {
|
|
83
|
+
status,
|
|
84
|
+
tag: flags.get("tag"),
|
|
85
|
+
name: flags.get("name"),
|
|
86
|
+
ref: flags.get("ref") ?? git("rev-parse --abbrev-ref HEAD"),
|
|
87
|
+
sha: flags.get("sha") ?? git("rev-parse HEAD"),
|
|
88
|
+
url: flags.get("url"),
|
|
89
|
+
environment: flags.get("env"),
|
|
90
|
+
externalId: flags.get("id")
|
|
91
|
+
});
|
|
92
|
+
console.log(`\u2713 Reported test "${flags.get("tag") ?? flags.get("name") ?? status}" as ${status}`);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
console.log(HELP);
|
|
96
|
+
process.exit(1);
|
|
97
|
+
}
|
|
98
|
+
main().catch((e) => {
|
|
99
|
+
console.error(`\u2717 ${e instanceof Error ? e.message : e}`);
|
|
100
|
+
process.exit(1);
|
|
101
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
interface ReleaseClientOptions {
|
|
2
|
+
/** Base API URL, e.g. https://api.simplr.so */
|
|
3
|
+
apiUrl: string;
|
|
4
|
+
/** A project ingest token (rnit_…) created in the dashboard. */
|
|
5
|
+
token: string;
|
|
6
|
+
}
|
|
7
|
+
type ChangeKind = "commit" | "pr" | "deploy";
|
|
8
|
+
interface PushChangeInput {
|
|
9
|
+
kind: ChangeKind;
|
|
10
|
+
title: string;
|
|
11
|
+
ref?: string;
|
|
12
|
+
sha?: string;
|
|
13
|
+
body?: string;
|
|
14
|
+
author?: string;
|
|
15
|
+
url?: string;
|
|
16
|
+
/** Explicit environment key (overrides project mapping). */
|
|
17
|
+
environment?: string;
|
|
18
|
+
}
|
|
19
|
+
type TestStatus = "queued" | "running" | "passed" | "failed" | "cancelled";
|
|
20
|
+
interface ReportTestInput {
|
|
21
|
+
status: TestStatus;
|
|
22
|
+
name?: string;
|
|
23
|
+
tag?: string;
|
|
24
|
+
ref?: string;
|
|
25
|
+
sha?: string;
|
|
26
|
+
url?: string;
|
|
27
|
+
environment?: string;
|
|
28
|
+
externalId?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Push a single change (commit/PR/deploy) into the project's release pipeline. */
|
|
31
|
+
declare function pushChange(opts: ReleaseClientOptions, input: PushChangeInput): Promise<any>;
|
|
32
|
+
/** Report a CI test result that can gate flag rollouts and release publishing. */
|
|
33
|
+
declare function reportTest(opts: ReleaseClientOptions, input: ReportTestInput): Promise<any>;
|
|
34
|
+
|
|
35
|
+
export { type ChangeKind, type PushChangeInput, type ReleaseClientOptions, type ReportTestInput, type TestStatus, pushChange, reportTest };
|
package/dist/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@simplr-ai/release-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Simplr release CLI — push commits and report CI test results to Simplr Release Notes from a git hook or CI step.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"bin": {
|
|
10
|
+
"simplr-release": "./dist/cli.js"
|
|
11
|
+
},
|
|
12
|
+
"files": ["dist"],
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=18"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsup",
|
|
18
|
+
"dev": "tsup --watch",
|
|
19
|
+
"typecheck": "tsc --noEmit"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/node": "^20.0.0",
|
|
23
|
+
"tsup": "^8.0.0",
|
|
24
|
+
"typescript": "^5.3.0"
|
|
25
|
+
},
|
|
26
|
+
"keywords": ["simplr", "release-notes", "changelog", "ci", "cli"]
|
|
27
|
+
}
|