@openpolicy/cli 0.0.5 → 0.0.7
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/_cli-BVVbyDQ9.js +49 -0
- package/dist/_cli-BjVuFgXe.js +33 -0
- package/dist/_cli-C-Vx-Nop.js +58 -0
- package/dist/_cli-DrypJgn2.js +247 -0
- package/dist/_lib-9AbI1LBo.js +35 -0
- package/dist/_lib-9AbI1LBo.js.map +1 -0
- package/dist/_lib-D2I-M4OU.js +51 -0
- package/dist/_lib-D2I-M4OU.js.map +1 -0
- package/dist/_lib-D2LkleUQ.js +60 -0
- package/dist/_lib-D2LkleUQ.js.map +1 -0
- package/dist/_lib-MI0GKJMR.js +249 -0
- package/dist/_lib-MI0GKJMR.js.map +1 -0
- package/dist/cli +0 -0
- package/dist/cli.js +381 -2759
- package/dist/generate-ItFTJ-jj.js +60 -0
- package/dist/generate-ItFTJ-jj.js.map +1 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -961
- package/dist/index.js.map +1 -0
- package/dist/init-37NxG-6N.js +249 -0
- package/dist/init-37NxG-6N.js.map +1 -0
- package/dist/load-config-Bw8yiDkb.js +35 -0
- package/dist/load-config-Bw8yiDkb.js.map +1 -0
- package/dist/validate-DPge58Uv.js +51 -0
- package/dist/validate-DPge58Uv.js.map +1 -0
- package/package.json +4 -19
- package/src/cli.ts +0 -5
- package/src/commands/generate.test.ts +0 -19
- package/src/commands/generate.ts +0 -58
- package/src/commands/init.test.ts +0 -15
- package/src/commands/init.ts +0 -197
- package/src/commands/validate.test.ts +0 -15
- package/src/commands/validate.ts +0 -53
- package/src/index.test.ts +0 -29
- package/src/index.ts +0 -21
- package/src/utils/load-config.ts +0 -32
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { n as detectType, t as loadConfig } from "./load-config-Bw8yiDkb.js";
|
|
2
|
+
import { defineCommand } from "citty";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { compilePolicy } from "@openpolicy/core";
|
|
5
|
+
import consola from "consola";
|
|
6
|
+
//#region src/commands/generate.ts
|
|
7
|
+
const generateCommand = defineCommand({
|
|
8
|
+
meta: {
|
|
9
|
+
name: "generate",
|
|
10
|
+
description: "Compile a policy config to one or more output formats"
|
|
11
|
+
},
|
|
12
|
+
args: {
|
|
13
|
+
config: {
|
|
14
|
+
type: "positional",
|
|
15
|
+
description: "Path to policy config file",
|
|
16
|
+
default: "./policy.config.ts"
|
|
17
|
+
},
|
|
18
|
+
format: {
|
|
19
|
+
type: "string",
|
|
20
|
+
description: "Comma-separated output formats: markdown,pdf,jsx",
|
|
21
|
+
default: "markdown"
|
|
22
|
+
},
|
|
23
|
+
out: {
|
|
24
|
+
type: "string",
|
|
25
|
+
description: "Output directory",
|
|
26
|
+
default: "./output"
|
|
27
|
+
},
|
|
28
|
+
type: {
|
|
29
|
+
type: "string",
|
|
30
|
+
description: "Policy type: \"privacy\" or \"terms\" (auto-detected from filename if omitted)",
|
|
31
|
+
default: ""
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
async run({ args }) {
|
|
35
|
+
const formats = (args.format ?? "markdown").split(",").map((f) => f.trim()).filter(Boolean);
|
|
36
|
+
const outDir = args.out ?? "./output";
|
|
37
|
+
const configPath = args.config ?? "./policy.config.ts";
|
|
38
|
+
const policyType = detectType(args.type || void 0, configPath);
|
|
39
|
+
consola.start(`Generating ${policyType} policy from ${configPath} → formats: ${formats.join(", ")}`);
|
|
40
|
+
const config = await loadConfig(configPath);
|
|
41
|
+
const outputFilename = policyType === "terms" ? "terms-of-service" : "privacy-policy";
|
|
42
|
+
const results = compilePolicy(policyType === "terms" ? {
|
|
43
|
+
type: "terms",
|
|
44
|
+
...config
|
|
45
|
+
} : {
|
|
46
|
+
type: "privacy",
|
|
47
|
+
...config
|
|
48
|
+
}, { formats });
|
|
49
|
+
for (const result of results) {
|
|
50
|
+
const outPath = join(outDir, `${outputFilename}.${result.format === "markdown" ? "md" : result.format}`);
|
|
51
|
+
await Bun.write(outPath, result.content);
|
|
52
|
+
consola.success(`Written: ${outPath}`);
|
|
53
|
+
}
|
|
54
|
+
consola.success(`Policy generation complete → ${outDir}`);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
//#endregion
|
|
58
|
+
export { generateCommand };
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=generate-ItFTJ-jj.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-ItFTJ-jj.js","names":[],"sources":["../src/commands/generate.ts"],"sourcesContent":["import { join } from \"node:path\";\nimport type {\n\tOutputFormat,\n\tPrivacyPolicyConfig,\n\tTermsOfServiceConfig,\n} from \"@openpolicy/core\";\nimport { compilePolicy } from \"@openpolicy/core\";\nimport { defineCommand } from \"citty\";\nimport consola from \"consola\";\nimport { detectType } from \"../utils/detect-type\";\nimport { loadConfig } from \"../utils/load-config\";\n\nexport const generateCommand = defineCommand({\n\tmeta: {\n\t\tname: \"generate\",\n\t\tdescription: \"Compile a policy config to one or more output formats\",\n\t},\n\targs: {\n\t\tconfig: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Path to policy config file\",\n\t\t\tdefault: \"./policy.config.ts\",\n\t\t},\n\t\tformat: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Comma-separated output formats: markdown,pdf,jsx\",\n\t\t\tdefault: \"markdown\",\n\t\t},\n\t\tout: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Output directory\",\n\t\t\tdefault: \"./output\",\n\t\t},\n\t\ttype: {\n\t\t\ttype: \"string\",\n\t\t\tdescription:\n\t\t\t\t'Policy type: \"privacy\" or \"terms\" (auto-detected from filename if omitted)',\n\t\t\tdefault: \"\",\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst formats = (args.format ?? \"markdown\")\n\t\t\t.split(\",\")\n\t\t\t.map((f) => f.trim())\n\t\t\t.filter(Boolean) as OutputFormat[];\n\n\t\tconst outDir = args.out ?? \"./output\";\n\t\tconst configPath = args.config ?? \"./policy.config.ts\";\n\t\tconst policyType = detectType(args.type || undefined, configPath);\n\n\t\tconsola.start(\n\t\t\t`Generating ${policyType} policy from ${configPath} → formats: ${formats.join(\", \")}`,\n\t\t);\n\n\t\tconst config = await loadConfig(configPath);\n\n\t\tconst outputFilename =\n\t\t\tpolicyType === \"terms\" ? \"terms-of-service\" : \"privacy-policy\";\n\n\t\tconst results = compilePolicy(\n\t\t\tpolicyType === \"terms\"\n\t\t\t\t? { type: \"terms\", ...(config as TermsOfServiceConfig) }\n\t\t\t\t: { type: \"privacy\", ...(config as PrivacyPolicyConfig) },\n\t\t\t{ formats },\n\t\t);\n\n\t\tfor (const result of results) {\n\t\t\tconst ext = result.format === \"markdown\" ? \"md\" : result.format;\n\t\t\tconst outPath = join(outDir, `${outputFilename}.${ext}`);\n\t\t\tawait Bun.write(outPath, result.content);\n\t\t\tconsola.success(`Written: ${outPath}`);\n\t\t}\n\n\t\tconsola.success(`Policy generation complete → ${outDir}`);\n\t},\n});\n"],"mappings":";;;;;;AAYA,MAAa,kBAAkB,cAAc;CAC5C,MAAM;EACL,MAAM;EACN,aAAa;EACb;CACD,MAAM;EACL,QAAQ;GACP,MAAM;GACN,aAAa;GACb,SAAS;GACT;EACD,QAAQ;GACP,MAAM;GACN,aAAa;GACb,SAAS;GACT;EACD,KAAK;GACJ,MAAM;GACN,aAAa;GACb,SAAS;GACT;EACD,MAAM;GACL,MAAM;GACN,aACC;GACD,SAAS;GACT;EACD;CACD,MAAM,IAAI,EAAE,QAAQ;EACnB,MAAM,WAAW,KAAK,UAAU,YAC9B,MAAM,IAAI,CACV,KAAK,MAAM,EAAE,MAAM,CAAC,CACpB,OAAO,QAAQ;EAEjB,MAAM,SAAS,KAAK,OAAO;EAC3B,MAAM,aAAa,KAAK,UAAU;EAClC,MAAM,aAAa,WAAW,KAAK,QAAQ,KAAA,GAAW,WAAW;AAEjE,UAAQ,MACP,cAAc,WAAW,eAAe,WAAW,cAAc,QAAQ,KAAK,KAAK,GACnF;EAED,MAAM,SAAS,MAAM,WAAW,WAAW;EAE3C,MAAM,iBACL,eAAe,UAAU,qBAAqB;EAE/C,MAAM,UAAU,cACf,eAAe,UACZ;GAAE,MAAM;GAAS,GAAI;GAAiC,GACtD;GAAE,MAAM;GAAW,GAAI;GAAgC,EAC1D,EAAE,SAAS,CACX;AAED,OAAK,MAAM,UAAU,SAAS;GAE7B,MAAM,UAAU,KAAK,QAAQ,GAAG,eAAe,GADnC,OAAO,WAAW,aAAa,OAAO,OAAO,SACD;AACxD,SAAM,IAAI,MAAM,SAAS,OAAO,QAAQ;AACxC,WAAQ,QAAQ,YAAY,UAAU;;AAGvC,UAAQ,QAAQ,gCAAgC,SAAS;;CAE1D,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as citty from "citty";
|
|
2
|
+
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
declare const mainCommand: citty.CommandDef<citty.ArgsDef>;
|
|
5
|
+
declare function run(): Promise<void>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { mainCommand, run };
|
|
3
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;cAEa,WAAA,EAAW,KAAA,CAAA,UAAA,CAatB,KAAA,CAbsB,OAAA;AAAA,iBAeF,GAAA,CAAA,GAAG,OAAA"}
|