auth0-config-cli 1.0.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.
Files changed (3) hide show
  1. package/README.md +73 -0
  2. package/dist/index.js +188 -0
  3. package/package.json +47 -0
package/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # auth0-config-cli
2
+
3
+ CLI tool for generating and managing Auth0 identity platform configurations — authentication flows and API authorization
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g auth0-config-cli
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Initialize configuration
14
+
15
+ ```bash
16
+ auth0-config init
17
+ auth0-config init --template advanced
18
+ auth0-config init --output custom-config.json
19
+ ```
20
+
21
+ ### Validate configuration
22
+
23
+ ```bash
24
+ auth0-config validate
25
+ auth0-config validate path/to/config.json
26
+ ```
27
+
28
+ ### View configuration
29
+
30
+ ```bash
31
+ auth0-config show
32
+ auth0-config show --env production
33
+ auth0-config show --json
34
+ ```
35
+
36
+ ### Modify configuration
37
+
38
+ ```bash
39
+ auth0-config set settings.debug true
40
+ auth0-config set settings.logLevel \"warn\"
41
+ ```
42
+
43
+ ### Compare configurations
44
+
45
+ ```bash
46
+ auth0-config diff config-dev.json config-prod.json
47
+ ```
48
+
49
+ ### List templates
50
+
51
+ ```bash
52
+ auth0-config templates
53
+ ```
54
+
55
+ ## Templates
56
+
57
+ | Template | Description |
58
+ |----------|-------------|
59
+ | `minimal` | Bare minimum configuration |
60
+ | `standard` | Recommended defaults for most projects |
61
+ | `advanced` | Full-featured with security, caching, and multi-environment support |
62
+
63
+ ## Why auth0-config-cli?
64
+
65
+ - **Zero dependencies at runtime** — just `commander` and `chalk`
66
+ - **Template-based** — start with minimal, standard, or advanced presets
67
+ - **Validation built-in** — catch config errors before deployment
68
+ - **Environment-aware** — manage dev/staging/production configs in one file
69
+ - **Diff support** — compare configs across environments
70
+
71
+ ## License
72
+
73
+ MIT
package/dist/index.js ADDED
@@ -0,0 +1,188 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.ts
4
+ import { program } from "commander";
5
+ import chalk from "chalk";
6
+ import fs from "fs";
7
+ import path from "path";
8
+ var TEMPLATES = {
9
+ minimal: {
10
+ version: "1.0",
11
+ settings: {}
12
+ },
13
+ standard: {
14
+ version: "1.0",
15
+ settings: {
16
+ debug: false,
17
+ logLevel: "info",
18
+ timeout: 3e4
19
+ },
20
+ plugins: [],
21
+ environments: {
22
+ development: {},
23
+ production: {}
24
+ }
25
+ },
26
+ advanced: {
27
+ version: "1.0",
28
+ settings: {
29
+ debug: false,
30
+ logLevel: "info",
31
+ timeout: 3e4,
32
+ retries: 3,
33
+ cache: { enabled: true, ttl: 3600 }
34
+ },
35
+ plugins: [],
36
+ environments: {
37
+ development: { debug: true, logLevel: "debug" },
38
+ staging: { logLevel: "warn" },
39
+ production: { logLevel: "error", cache: { ttl: 86400 } }
40
+ },
41
+ security: {
42
+ cors: true,
43
+ helmet: true,
44
+ rateLimit: { windowMs: 9e5, max: 100 }
45
+ }
46
+ }
47
+ };
48
+ function generateConfig(template) {
49
+ return JSON.parse(JSON.stringify(TEMPLATES[template] || TEMPLATES.standard));
50
+ }
51
+ program.name("auth0-config").description("Configuration generator and manager for auth0 config").version("1.0.0");
52
+ program.command("init").description("Initialize a new auth0 config configuration file").option("-t, --template <template>", "Template: minimal | standard | advanced", "standard").option("-o, --output <file>", "Output file path", "auth0-config.config.json").option("-f, --force", "Overwrite existing config").action((opts) => {
53
+ const outPath = path.resolve(opts.output || "auth0-config.config.json");
54
+ if (fs.existsSync(outPath) && !opts.force) {
55
+ console.error(chalk.red(`Config already exists: ${outPath}`));
56
+ console.log(chalk.dim("Use --force to overwrite."));
57
+ process.exit(1);
58
+ }
59
+ const config = generateConfig(opts.template || "standard");
60
+ fs.writeFileSync(outPath, JSON.stringify(config, null, 2));
61
+ console.log(chalk.green(`\u2714 Created ${path.basename(outPath)} (${opts.template || "standard"} template)`));
62
+ });
63
+ program.command("validate [file]").description("Validate a auth0 config configuration file").action((file) => {
64
+ const configPath = path.resolve(file || "auth0-config.config.json");
65
+ if (!fs.existsSync(configPath)) {
66
+ console.error(chalk.red(`Config not found: ${configPath}`));
67
+ process.exit(1);
68
+ }
69
+ try {
70
+ const raw = fs.readFileSync(configPath, "utf-8");
71
+ const config = JSON.parse(raw);
72
+ const issues = [];
73
+ if (!config.version) issues.push("Missing 'version' field");
74
+ if (!config.settings || typeof config.settings !== "object") issues.push("Missing or invalid 'settings' object");
75
+ if (issues.length > 0) {
76
+ console.log(chalk.red("\u2716 Validation failed:"));
77
+ issues.forEach((i) => console.log(chalk.yellow(` \u26A0 ${i}`)));
78
+ process.exit(1);
79
+ }
80
+ console.log(chalk.green(`\u2714 ${path.basename(configPath)} is valid`));
81
+ console.log(chalk.dim(` Version: ${config.version}`));
82
+ console.log(chalk.dim(` Settings: ${Object.keys(config.settings).length} key(s)`));
83
+ if (config.environments) {
84
+ console.log(chalk.dim(` Environments: ${Object.keys(config.environments).join(", ")}`));
85
+ }
86
+ } catch (e) {
87
+ console.error(chalk.red(`\u2716 Invalid JSON: ${e.message}`));
88
+ process.exit(1);
89
+ }
90
+ });
91
+ program.command("show [file]").description("Display the current configuration").option("--env <env>", "Show environment-specific config").option("--json", "Output raw JSON").action((file, opts) => {
92
+ const configPath = path.resolve(file || "auth0-config.config.json");
93
+ if (!fs.existsSync(configPath)) {
94
+ console.error(chalk.red(`Config not found: ${configPath}`));
95
+ process.exit(1);
96
+ }
97
+ const config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
98
+ if (opts.env && config.environments?.[opts.env]) {
99
+ const merged = { ...config.settings, ...config.environments[opts.env] };
100
+ if (opts.json) {
101
+ console.log(JSON.stringify(merged, null, 2));
102
+ return;
103
+ }
104
+ console.log(chalk.bold(`
105
+ auth0 config config \u2014 ${opts.env}
106
+ `));
107
+ for (const [k, v] of Object.entries(merged)) {
108
+ console.log(` ${chalk.cyan(k)}: ${chalk.white(JSON.stringify(v))}`);
109
+ }
110
+ return;
111
+ }
112
+ if (opts.json) {
113
+ console.log(JSON.stringify(config, null, 2));
114
+ return;
115
+ }
116
+ console.log(chalk.bold(`
117
+ auth0 config configuration
118
+ `));
119
+ for (const [k, v] of Object.entries(config)) {
120
+ if (typeof v === "object" && v !== null) {
121
+ console.log(` ${chalk.cyan(k)}:`);
122
+ for (const [sk, sv] of Object.entries(v)) {
123
+ console.log(` ${chalk.dim(sk)}: ${chalk.white(JSON.stringify(sv))}`);
124
+ }
125
+ } else {
126
+ console.log(` ${chalk.cyan(k)}: ${chalk.white(String(v))}`);
127
+ }
128
+ }
129
+ });
130
+ program.command("set <key> <value> [file]").description("Set a configuration value").action((key, value, file) => {
131
+ const configPath = path.resolve(file || "auth0-config.config.json");
132
+ if (!fs.existsSync(configPath)) {
133
+ console.error(chalk.red(`Config not found: ${configPath}`));
134
+ process.exit(1);
135
+ }
136
+ const config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
137
+ const keys = key.split(".");
138
+ let obj = config;
139
+ for (let i = 0; i < keys.length - 1; i++) {
140
+ if (!obj[keys[i]]) obj[keys[i]] = {};
141
+ obj = obj[keys[i]];
142
+ }
143
+ let parsed;
144
+ try {
145
+ parsed = JSON.parse(value);
146
+ } catch {
147
+ parsed = value;
148
+ }
149
+ obj[keys[keys.length - 1]] = parsed;
150
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
151
+ console.log(chalk.green(`\u2714 Set ${key} = ${JSON.stringify(parsed)}`));
152
+ });
153
+ program.command("diff <file1> <file2>").description("Compare two configuration files").action((file1, file2) => {
154
+ const c1 = JSON.parse(fs.readFileSync(path.resolve(file1), "utf-8"));
155
+ const c2 = JSON.parse(fs.readFileSync(path.resolve(file2), "utf-8"));
156
+ const allKeys = /* @__PURE__ */ new Set([...Object.keys(c1), ...Object.keys(c2)]);
157
+ let diffs = 0;
158
+ console.log(chalk.bold(`
159
+ Diff: ${file1} vs ${file2}
160
+ `));
161
+ for (const key of allKeys) {
162
+ const v1 = JSON.stringify(c1[key]);
163
+ const v2 = JSON.stringify(c2[key]);
164
+ if (v1 !== v2) {
165
+ diffs++;
166
+ if (!c1[key]) console.log(chalk.green(` + ${key}: ${v2}`));
167
+ else if (!c2[key]) console.log(chalk.red(` - ${key}: ${v1}`));
168
+ else {
169
+ console.log(chalk.yellow(` ~ ${key}:`));
170
+ console.log(chalk.red(` - ${v1}`));
171
+ console.log(chalk.green(` + ${v2}`));
172
+ }
173
+ }
174
+ }
175
+ if (diffs === 0) console.log(chalk.green(" No differences found."));
176
+ else console.log(chalk.dim(`
177
+ ${diffs} difference(s) found.`));
178
+ });
179
+ program.command("templates").description("List available configuration templates").action(() => {
180
+ console.log(chalk.bold(`
181
+ Available templates for auth0 config:
182
+ `));
183
+ for (const [name, tmpl] of Object.entries(TEMPLATES)) {
184
+ const keys = Object.keys(tmpl);
185
+ console.log(` ${chalk.cyan(name)} \u2014 ${keys.length} top-level keys (${keys.join(", ")})`);
186
+ }
187
+ });
188
+ program.parse();
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "auth0-config-cli",
3
+ "version": "1.0.0",
4
+ "description": "CLI tool for generating and managing Auth0 identity platform configurations \u2014 authentication flows and API authorization",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "module": "dist/index.js",
8
+ "bin": {
9
+ "auth0-config": "./dist/index.js"
10
+ },
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "scripts": {
15
+ "build": "tsup",
16
+ "dev": "tsup --watch",
17
+ "start": "node dist/index.js"
18
+ },
19
+ "keywords": [
20
+ "auth0-config",
21
+ "config",
22
+ "cli",
23
+ "generator"
24
+ ],
25
+ "author": "",
26
+ "license": "MIT",
27
+ "dependencies": {
28
+ "chalk": "^5.4.1",
29
+ "commander": "^13.1.0"
30
+ },
31
+ "devDependencies": {
32
+ "tsup": "^8.4.0",
33
+ "typescript": "^5.8.3"
34
+ },
35
+ "engines": {
36
+ "node": ">=18"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "https://github.com/okirmio-create/cli-forge.git",
41
+ "directory": "auth0-config-cli"
42
+ },
43
+ "homepage": "https://github.com/okirmio-create/cli-forge/tree/main/auth0-config-cli",
44
+ "bugs": {
45
+ "url": "https://github.com/okirmio-create/cli-forge/issues"
46
+ }
47
+ }