@ductape/cli 0.2.3 → 0.2.4

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.
@@ -45,7 +45,9 @@ export async function runCloud(target, verb, opts, extraArgs) {
45
45
  import: ['resources.import', [body]],
46
46
  provision: ['resources.provision', [body]],
47
47
  'import-persist': ['resources.importAndPersist', [body]],
48
+ 'import-persist-all': ['resources.importAndPersistAll', [body]],
48
49
  'provision-persist': ['resources.provisionAndPersist', [body]],
50
+ 'provision-persist-all': ['resources.provisionAndPersistAll', [body]],
49
51
  };
50
52
  const entry = map[verb.toLowerCase()];
51
53
  if (!entry)
@@ -1,17 +1,31 @@
1
+ const REDACTED_KEYS = new Set(['private_key']);
2
+ function redactSensitiveFields(data) {
3
+ if (Array.isArray(data))
4
+ return data.map(redactSensitiveFields);
5
+ if (data !== null && typeof data === 'object') {
6
+ const result = {};
7
+ for (const [key, value] of Object.entries(data)) {
8
+ result[key] = REDACTED_KEYS.has(key) ? '[REDACTED]' : redactSensitiveFields(value);
9
+ }
10
+ return result;
11
+ }
12
+ return data;
13
+ }
1
14
  export function printJson(data, jsonMode) {
15
+ const safe = redactSensitiveFields(data);
2
16
  if (jsonMode) {
3
- console.log(JSON.stringify(data, null, 2));
17
+ console.log(JSON.stringify(safe, null, 2));
4
18
  return;
5
19
  }
6
- if (data === undefined || data === null) {
20
+ if (safe === undefined || safe === null) {
7
21
  console.log('(no data)');
8
22
  return;
9
23
  }
10
- if (typeof data === 'object') {
11
- console.log(JSON.stringify(data, null, 2));
24
+ if (typeof safe === 'object') {
25
+ console.log(JSON.stringify(safe, null, 2));
12
26
  return;
13
27
  }
14
- console.log(String(data));
28
+ console.log(String(safe));
15
29
  }
16
30
  export function success(message) {
17
31
  console.log(`✓ ${message}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ductape/cli",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Ductape CLI — local platform, login, link projects, and manage resources via the proxy (Workbench-compatible)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -54,7 +54,9 @@ export async function runCloud(
54
54
  import: ['resources.import', [body]],
55
55
  provision: ['resources.provision', [body]],
56
56
  'import-persist': ['resources.importAndPersist', [body]],
57
+ 'import-persist-all': ['resources.importAndPersistAll', [body]],
57
58
  'provision-persist': ['resources.provisionAndPersist', [body]],
59
+ 'provision-persist-all': ['resources.provisionAndPersistAll', [body]],
58
60
  };
59
61
  const entry = map[verb.toLowerCase()];
60
62
  if (!entry) throw new Error(`Unknown cloud resources verb: ${verb}`);
package/src/lib/output.ts CHANGED
@@ -1,17 +1,32 @@
1
+ const REDACTED_KEYS = new Set(['private_key']);
2
+
3
+ function redactSensitiveFields(data: unknown): unknown {
4
+ if (Array.isArray(data)) return data.map(redactSensitiveFields);
5
+ if (data !== null && typeof data === 'object') {
6
+ const result: Record<string, unknown> = {};
7
+ for (const [key, value] of Object.entries(data as Record<string, unknown>)) {
8
+ result[key] = REDACTED_KEYS.has(key) ? '[REDACTED]' : redactSensitiveFields(value);
9
+ }
10
+ return result;
11
+ }
12
+ return data;
13
+ }
14
+
1
15
  export function printJson(data: unknown, jsonMode: boolean): void {
16
+ const safe = redactSensitiveFields(data);
2
17
  if (jsonMode) {
3
- console.log(JSON.stringify(data, null, 2));
18
+ console.log(JSON.stringify(safe, null, 2));
4
19
  return;
5
20
  }
6
- if (data === undefined || data === null) {
21
+ if (safe === undefined || safe === null) {
7
22
  console.log('(no data)');
8
23
  return;
9
24
  }
10
- if (typeof data === 'object') {
11
- console.log(JSON.stringify(data, null, 2));
25
+ if (typeof safe === 'object') {
26
+ console.log(JSON.stringify(safe, null, 2));
12
27
  return;
13
28
  }
14
- console.log(String(data));
29
+ console.log(String(safe));
15
30
  }
16
31
 
17
32
  export function success(message: string): void {