nrdocs 0.1.8 → 0.2.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/dist/bin.mjs +122 -11
- package/package.json +3 -2
package/dist/bin.mjs
CHANGED
|
@@ -680,6 +680,7 @@ jobs:
|
|
|
680
680
|
run: nrdocs publish --docs-dir ${docsDir}
|
|
681
681
|
env:
|
|
682
682
|
NRDOCS_API_URL: ${apiUrl}
|
|
683
|
+
NRDOCS_DOCS_PASSWORD: \${{ secrets.NRDOCS_DOCS_PASSWORD }}
|
|
683
684
|
`;
|
|
684
685
|
}
|
|
685
686
|
function parseInitArgs(args2) {
|
|
@@ -6918,15 +6919,23 @@ var ApiClient = class {
|
|
|
6918
6919
|
password
|
|
6919
6920
|
});
|
|
6920
6921
|
}
|
|
6922
|
+
async setSelfPasswordAllow(owner, repo, allow) {
|
|
6923
|
+
const path12 = allow ? `/api/repos/${owner}/${repo}/allow-self-password` : `/api/repos/${owner}/${repo}/disallow-self-password`;
|
|
6924
|
+
return this.request("POST", path12);
|
|
6925
|
+
}
|
|
6921
6926
|
async listRules() {
|
|
6922
6927
|
return this.request("GET", "/api/auto-approval-rules");
|
|
6923
6928
|
}
|
|
6924
|
-
async addRule(pattern, accessMode, applyExisting) {
|
|
6925
|
-
|
|
6929
|
+
async addRule(pattern, accessMode, applyExisting, defaultAllowSelfPassword) {
|
|
6930
|
+
const body = {
|
|
6926
6931
|
pattern,
|
|
6927
6932
|
access_mode: accessMode,
|
|
6928
6933
|
apply_existing: applyExisting ?? false
|
|
6929
|
-
}
|
|
6934
|
+
};
|
|
6935
|
+
if (defaultAllowSelfPassword !== void 0) {
|
|
6936
|
+
body["default_allow_repo_owner_password"] = defaultAllowSelfPassword;
|
|
6937
|
+
}
|
|
6938
|
+
return this.request("POST", "/api/auto-approval-rules", body);
|
|
6930
6939
|
}
|
|
6931
6940
|
async removeRule(ruleId) {
|
|
6932
6941
|
return this.request("DELETE", `/api/auto-approval-rules/${ruleId}`);
|
|
@@ -7228,6 +7237,10 @@ async function handlePublish(args2) {
|
|
|
7228
7237
|
artifact: { format: "tar.gz", size_bytes: archive.length },
|
|
7229
7238
|
nrdocs: { cli_version: "0.1.1" }
|
|
7230
7239
|
}));
|
|
7240
|
+
const docsPasswordRaw = process.env["NRDOCS_DOCS_PASSWORD"];
|
|
7241
|
+
if (typeof docsPasswordRaw === "string" && docsPasswordRaw.length > 0) {
|
|
7242
|
+
formData.append("password", docsPasswordRaw);
|
|
7243
|
+
}
|
|
7231
7244
|
const result = await client.publish(formData, opts.verbose);
|
|
7232
7245
|
if (result.ok) {
|
|
7233
7246
|
const data = result.data;
|
|
@@ -8188,6 +8201,83 @@ async function handlePasswordSet(args2) {
|
|
|
8188
8201
|
console.log(`Password set for ${owner}/${repo}.`);
|
|
8189
8202
|
}
|
|
8190
8203
|
}
|
|
8204
|
+
function parsePasswordAllowArgs(args2) {
|
|
8205
|
+
const opts = {};
|
|
8206
|
+
for (let i = 0; i < args2.length; i++) {
|
|
8207
|
+
const arg = args2[i];
|
|
8208
|
+
if (arg === "--json") {
|
|
8209
|
+
opts.json = true;
|
|
8210
|
+
} else if (!arg?.startsWith("--") && !opts.repo) {
|
|
8211
|
+
opts.repo = arg;
|
|
8212
|
+
}
|
|
8213
|
+
}
|
|
8214
|
+
return opts;
|
|
8215
|
+
}
|
|
8216
|
+
function parsePasswordDisallowArgs(args2) {
|
|
8217
|
+
return parsePasswordAllowArgs(args2);
|
|
8218
|
+
}
|
|
8219
|
+
async function handlePasswordAllow(args2) {
|
|
8220
|
+
const opts = parsePasswordAllowArgs(args2);
|
|
8221
|
+
if (!opts.repo) {
|
|
8222
|
+
console.error("Error: Repository required. Usage: nrdocs password allow owner/repo");
|
|
8223
|
+
process.exit(2);
|
|
8224
|
+
}
|
|
8225
|
+
const parts = opts.repo.split("/");
|
|
8226
|
+
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
8227
|
+
console.error('Error: Repository must be in "owner/repo" format.');
|
|
8228
|
+
process.exit(2);
|
|
8229
|
+
}
|
|
8230
|
+
const [owner, repo] = parts;
|
|
8231
|
+
let creds;
|
|
8232
|
+
try {
|
|
8233
|
+
creds = resolveCredentials();
|
|
8234
|
+
} catch (e) {
|
|
8235
|
+
console.error(e instanceof Error ? e.message : String(e));
|
|
8236
|
+
process.exit(1);
|
|
8237
|
+
}
|
|
8238
|
+
const client = new ApiClient(creds.api_url, creds.operator_token);
|
|
8239
|
+
const res = await client.setSelfPasswordAllow(owner, repo, true);
|
|
8240
|
+
if (!res.ok) {
|
|
8241
|
+
console.error(`Error: ${res.error?.message ?? "Unknown error"}`);
|
|
8242
|
+
process.exit(1);
|
|
8243
|
+
}
|
|
8244
|
+
if (opts.json) {
|
|
8245
|
+
console.log(JSON.stringify(res.data, null, 2));
|
|
8246
|
+
} else {
|
|
8247
|
+
console.log(`Self-service password enabled for ${owner}/${repo}.`);
|
|
8248
|
+
}
|
|
8249
|
+
}
|
|
8250
|
+
async function handlePasswordDisallow(args2) {
|
|
8251
|
+
const opts = parsePasswordDisallowArgs(args2);
|
|
8252
|
+
if (!opts.repo) {
|
|
8253
|
+
console.error("Error: Repository required. Usage: nrdocs password disallow owner/repo");
|
|
8254
|
+
process.exit(2);
|
|
8255
|
+
}
|
|
8256
|
+
const parts = opts.repo.split("/");
|
|
8257
|
+
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
8258
|
+
console.error('Error: Repository must be in "owner/repo" format.');
|
|
8259
|
+
process.exit(2);
|
|
8260
|
+
}
|
|
8261
|
+
const [owner, repo] = parts;
|
|
8262
|
+
let creds;
|
|
8263
|
+
try {
|
|
8264
|
+
creds = resolveCredentials();
|
|
8265
|
+
} catch (e) {
|
|
8266
|
+
console.error(e instanceof Error ? e.message : String(e));
|
|
8267
|
+
process.exit(1);
|
|
8268
|
+
}
|
|
8269
|
+
const client = new ApiClient(creds.api_url, creds.operator_token);
|
|
8270
|
+
const res = await client.setSelfPasswordAllow(owner, repo, false);
|
|
8271
|
+
if (!res.ok) {
|
|
8272
|
+
console.error(`Error: ${res.error?.message ?? "Unknown error"}`);
|
|
8273
|
+
process.exit(1);
|
|
8274
|
+
}
|
|
8275
|
+
if (opts.json) {
|
|
8276
|
+
console.log(JSON.stringify(res.data, null, 2));
|
|
8277
|
+
} else {
|
|
8278
|
+
console.log(`Self-service password disabled for ${owner}/${repo}.`);
|
|
8279
|
+
}
|
|
8280
|
+
}
|
|
8191
8281
|
|
|
8192
8282
|
// src/commands/rules.ts
|
|
8193
8283
|
function parseRulesListArgs(args2) {
|
|
@@ -8206,6 +8296,13 @@ function parseRulesAddArgs(args2) {
|
|
|
8206
8296
|
opts.access = args2[++i];
|
|
8207
8297
|
} else if (arg === "--apply-existing") {
|
|
8208
8298
|
opts.applyExisting = true;
|
|
8299
|
+
} else if (arg === "--self-set-password" && i + 1 < args2.length) {
|
|
8300
|
+
const v = args2[++i];
|
|
8301
|
+
if (v === "allow" || v === "deny") {
|
|
8302
|
+
opts.selfSetPassword = v;
|
|
8303
|
+
} else {
|
|
8304
|
+
opts.selfSetPassword = "__invalid__";
|
|
8305
|
+
}
|
|
8209
8306
|
} else if (arg === "--json") {
|
|
8210
8307
|
opts.json = true;
|
|
8211
8308
|
} else if (!arg?.startsWith("--")) {
|
|
@@ -8229,11 +8326,12 @@ function parseRulesRemoveArgs(args2) {
|
|
|
8229
8326
|
}
|
|
8230
8327
|
function formatRulesTable(rules) {
|
|
8231
8328
|
if (rules.length === 0) return "No rules configured.";
|
|
8232
|
-
const headers = ["ID", "PATTERN", "ACCESS", "ENABLED", "PRIORITY"];
|
|
8329
|
+
const headers = ["ID", "PATTERN", "ACCESS", "SELF-PWD", "ENABLED", "PRIORITY"];
|
|
8233
8330
|
const rows = rules.map((r) => [
|
|
8234
8331
|
String(r["id"] ?? "-").slice(0, 8),
|
|
8235
8332
|
String(r["pattern"] ?? "-"),
|
|
8236
8333
|
String(r["access_mode"] ?? "-"),
|
|
8334
|
+
r["default_allow_repo_owner_password"] === true ? "allow" : "deny",
|
|
8237
8335
|
String(r["enabled"] ?? "-"),
|
|
8238
8336
|
String(r["priority"] ?? "-")
|
|
8239
8337
|
]);
|
|
@@ -8286,6 +8384,11 @@ async function handleRulesAdd(args2) {
|
|
|
8286
8384
|
console.error('Error: --access is required and must be "public" or "password".');
|
|
8287
8385
|
process.exit(2);
|
|
8288
8386
|
}
|
|
8387
|
+
if (opts.selfSetPassword !== void 0 && opts.selfSetPassword !== "allow" && opts.selfSetPassword !== "deny") {
|
|
8388
|
+
console.error('Error: --self-set-password must be "allow" or "deny".');
|
|
8389
|
+
process.exit(2);
|
|
8390
|
+
}
|
|
8391
|
+
const defaultAllowSelfPassword = opts.selfSetPassword === void 0 ? true : opts.selfSetPassword === "allow";
|
|
8289
8392
|
let creds;
|
|
8290
8393
|
try {
|
|
8291
8394
|
creds = resolveCredentials();
|
|
@@ -8294,7 +8397,7 @@ async function handleRulesAdd(args2) {
|
|
|
8294
8397
|
process.exit(1);
|
|
8295
8398
|
}
|
|
8296
8399
|
const client = new ApiClient(creds.api_url, creds.operator_token);
|
|
8297
|
-
const res = await client.addRule(opts.pattern, opts.access, opts.applyExisting);
|
|
8400
|
+
const res = await client.addRule(opts.pattern, opts.access, opts.applyExisting, defaultAllowSelfPassword);
|
|
8298
8401
|
if (!res.ok) {
|
|
8299
8402
|
console.error(`Error: ${res.error?.message ?? "Unknown error"}`);
|
|
8300
8403
|
process.exit(1);
|
|
@@ -8564,11 +8667,19 @@ async function runCommand(args2) {
|
|
|
8564
8667
|
}
|
|
8565
8668
|
break;
|
|
8566
8669
|
case "password":
|
|
8567
|
-
|
|
8568
|
-
|
|
8569
|
-
|
|
8570
|
-
|
|
8571
|
-
|
|
8670
|
+
switch (subCmd) {
|
|
8671
|
+
case "set":
|
|
8672
|
+
await handlePasswordSet(args2.slice(2));
|
|
8673
|
+
break;
|
|
8674
|
+
case "allow":
|
|
8675
|
+
await handlePasswordAllow(args2.slice(2));
|
|
8676
|
+
break;
|
|
8677
|
+
case "disallow":
|
|
8678
|
+
await handlePasswordDisallow(args2.slice(2));
|
|
8679
|
+
break;
|
|
8680
|
+
default:
|
|
8681
|
+
console.error("Usage: nrdocs password <set|allow|disallow> <owner/repo> [...]");
|
|
8682
|
+
process.exitCode = 1;
|
|
8572
8683
|
}
|
|
8573
8684
|
break;
|
|
8574
8685
|
case "rules":
|
|
@@ -8682,7 +8793,7 @@ Operator commands:
|
|
|
8682
8793
|
approve Approve a repo for serving
|
|
8683
8794
|
disable Disable serving for a repo
|
|
8684
8795
|
access Change access mode
|
|
8685
|
-
password
|
|
8796
|
+
password Manage passwords (set | allow | disallow)
|
|
8686
8797
|
rules Manage auto-approval rules
|
|
8687
8798
|
status Show repo status
|
|
8688
8799
|
config Show configuration
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nrdocs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "CLI for nrdocs - serverless docs publishing for private GitHub repos",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -23,8 +23,9 @@
|
|
|
23
23
|
"@types/markdown-it": "^14.1.2",
|
|
24
24
|
"@types/node": "^20.14.0",
|
|
25
25
|
"esbuild": "^0.28.0",
|
|
26
|
-
"
|
|
26
|
+
"fast-check": "^4.8.0",
|
|
27
27
|
"markdown-it": "^14.1.1",
|
|
28
|
+
"mermaid": "^11.6.0",
|
|
28
29
|
"typescript": "^5.5.0",
|
|
29
30
|
"vitest": "^2.0.0"
|
|
30
31
|
},
|