nrdocs 0.1.7 → 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 +131 -14
- package/dist/runtime/mermaid.min.js +185 -184
- 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) {
|
|
@@ -6204,10 +6205,16 @@ function wrapInTemplate(options) {
|
|
|
6204
6205
|
<script>
|
|
6205
6206
|
(function(){
|
|
6206
6207
|
function theme(){var t=document.documentElement.dataset.theme;return t==='dark'||t==='light'?t:(window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light');}
|
|
6208
|
+
function api(){
|
|
6209
|
+
var g=typeof globalThis!=='undefined'?globalThis:(typeof window!=='undefined'?window:null);
|
|
6210
|
+
if(!g||!g.mermaid)return null;
|
|
6211
|
+
var m=g.mermaid;
|
|
6212
|
+
return (m.default&&typeof m.default.initialize==='function')?m.default:m;
|
|
6213
|
+
}
|
|
6207
6214
|
function initMermaid(){
|
|
6208
|
-
if(
|
|
6209
|
-
|
|
6210
|
-
|
|
6215
|
+
var m=api();if(!m)return;
|
|
6216
|
+
m.initialize({startOnLoad:true,theme:theme()==='dark'?'dark':'default'});
|
|
6217
|
+
m.run();
|
|
6211
6218
|
}
|
|
6212
6219
|
document.addEventListener('DOMContentLoaded',initMermaid);
|
|
6213
6220
|
document.addEventListener('nrdocs-theme-change',initMermaid);
|
|
@@ -6912,15 +6919,23 @@ var ApiClient = class {
|
|
|
6912
6919
|
password
|
|
6913
6920
|
});
|
|
6914
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
|
+
}
|
|
6915
6926
|
async listRules() {
|
|
6916
6927
|
return this.request("GET", "/api/auto-approval-rules");
|
|
6917
6928
|
}
|
|
6918
|
-
async addRule(pattern, accessMode, applyExisting) {
|
|
6919
|
-
|
|
6929
|
+
async addRule(pattern, accessMode, applyExisting, defaultAllowSelfPassword) {
|
|
6930
|
+
const body = {
|
|
6920
6931
|
pattern,
|
|
6921
6932
|
access_mode: accessMode,
|
|
6922
6933
|
apply_existing: applyExisting ?? false
|
|
6923
|
-
}
|
|
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);
|
|
6924
6939
|
}
|
|
6925
6940
|
async removeRule(ruleId) {
|
|
6926
6941
|
return this.request("DELETE", `/api/auto-approval-rules/${ruleId}`);
|
|
@@ -7222,6 +7237,10 @@ async function handlePublish(args2) {
|
|
|
7222
7237
|
artifact: { format: "tar.gz", size_bytes: archive.length },
|
|
7223
7238
|
nrdocs: { cli_version: "0.1.1" }
|
|
7224
7239
|
}));
|
|
7240
|
+
const docsPasswordRaw = process.env["NRDOCS_DOCS_PASSWORD"];
|
|
7241
|
+
if (typeof docsPasswordRaw === "string" && docsPasswordRaw.length > 0) {
|
|
7242
|
+
formData.append("password", docsPasswordRaw);
|
|
7243
|
+
}
|
|
7225
7244
|
const result = await client.publish(formData, opts.verbose);
|
|
7226
7245
|
if (result.ok) {
|
|
7227
7246
|
const data = result.data;
|
|
@@ -8182,6 +8201,83 @@ async function handlePasswordSet(args2) {
|
|
|
8182
8201
|
console.log(`Password set for ${owner}/${repo}.`);
|
|
8183
8202
|
}
|
|
8184
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
|
+
}
|
|
8185
8281
|
|
|
8186
8282
|
// src/commands/rules.ts
|
|
8187
8283
|
function parseRulesListArgs(args2) {
|
|
@@ -8200,6 +8296,13 @@ function parseRulesAddArgs(args2) {
|
|
|
8200
8296
|
opts.access = args2[++i];
|
|
8201
8297
|
} else if (arg === "--apply-existing") {
|
|
8202
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
|
+
}
|
|
8203
8306
|
} else if (arg === "--json") {
|
|
8204
8307
|
opts.json = true;
|
|
8205
8308
|
} else if (!arg?.startsWith("--")) {
|
|
@@ -8223,11 +8326,12 @@ function parseRulesRemoveArgs(args2) {
|
|
|
8223
8326
|
}
|
|
8224
8327
|
function formatRulesTable(rules) {
|
|
8225
8328
|
if (rules.length === 0) return "No rules configured.";
|
|
8226
|
-
const headers = ["ID", "PATTERN", "ACCESS", "ENABLED", "PRIORITY"];
|
|
8329
|
+
const headers = ["ID", "PATTERN", "ACCESS", "SELF-PWD", "ENABLED", "PRIORITY"];
|
|
8227
8330
|
const rows = rules.map((r) => [
|
|
8228
8331
|
String(r["id"] ?? "-").slice(0, 8),
|
|
8229
8332
|
String(r["pattern"] ?? "-"),
|
|
8230
8333
|
String(r["access_mode"] ?? "-"),
|
|
8334
|
+
r["default_allow_repo_owner_password"] === true ? "allow" : "deny",
|
|
8231
8335
|
String(r["enabled"] ?? "-"),
|
|
8232
8336
|
String(r["priority"] ?? "-")
|
|
8233
8337
|
]);
|
|
@@ -8280,6 +8384,11 @@ async function handleRulesAdd(args2) {
|
|
|
8280
8384
|
console.error('Error: --access is required and must be "public" or "password".');
|
|
8281
8385
|
process.exit(2);
|
|
8282
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";
|
|
8283
8392
|
let creds;
|
|
8284
8393
|
try {
|
|
8285
8394
|
creds = resolveCredentials();
|
|
@@ -8288,7 +8397,7 @@ async function handleRulesAdd(args2) {
|
|
|
8288
8397
|
process.exit(1);
|
|
8289
8398
|
}
|
|
8290
8399
|
const client = new ApiClient(creds.api_url, creds.operator_token);
|
|
8291
|
-
const res = await client.addRule(opts.pattern, opts.access, opts.applyExisting);
|
|
8400
|
+
const res = await client.addRule(opts.pattern, opts.access, opts.applyExisting, defaultAllowSelfPassword);
|
|
8292
8401
|
if (!res.ok) {
|
|
8293
8402
|
console.error(`Error: ${res.error?.message ?? "Unknown error"}`);
|
|
8294
8403
|
process.exit(1);
|
|
@@ -8558,11 +8667,19 @@ async function runCommand(args2) {
|
|
|
8558
8667
|
}
|
|
8559
8668
|
break;
|
|
8560
8669
|
case "password":
|
|
8561
|
-
|
|
8562
|
-
|
|
8563
|
-
|
|
8564
|
-
|
|
8565
|
-
|
|
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;
|
|
8566
8683
|
}
|
|
8567
8684
|
break;
|
|
8568
8685
|
case "rules":
|
|
@@ -8676,7 +8793,7 @@ Operator commands:
|
|
|
8676
8793
|
approve Approve a repo for serving
|
|
8677
8794
|
disable Disable serving for a repo
|
|
8678
8795
|
access Change access mode
|
|
8679
|
-
password
|
|
8796
|
+
password Manage passwords (set | allow | disallow)
|
|
8680
8797
|
rules Manage auto-approval rules
|
|
8681
8798
|
status Show repo status
|
|
8682
8799
|
config Show configuration
|