@ystemsrx/cfshare 0.1.3 → 0.1.5
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/README.md +339 -336
- package/README.zh.md +339 -336
- package/dist/src/cli.js +12 -7
- package/package.json +1 -1
- package/src/cli.ts +14 -7
package/dist/src/cli.js
CHANGED
|
@@ -16,6 +16,7 @@ const TOOL_NAMES = new Set([
|
|
|
16
16
|
"audit_query",
|
|
17
17
|
"audit_export",
|
|
18
18
|
]);
|
|
19
|
+
const CLI_DEFAULT_STATE_DIR = "~/.cfshare";
|
|
19
20
|
function normalizeCommand(input) {
|
|
20
21
|
return input.trim().toLowerCase().replace(/-/g, "_");
|
|
21
22
|
}
|
|
@@ -57,8 +58,8 @@ function printHelp() {
|
|
|
57
58
|
" --config <json> Runtime config JSON (same as plugin config)",
|
|
58
59
|
" --config-file <path> Read runtime config from JSON file",
|
|
59
60
|
" --workspace-dir <dir> Workspace dir for expose_files context",
|
|
60
|
-
" --keep-alive Keep process running after expose_*",
|
|
61
|
-
" --no-keep-alive Exit
|
|
61
|
+
" --keep-alive Keep process running after expose_* (foreground)",
|
|
62
|
+
" --no-keep-alive Exit after printing expose_* result (default)",
|
|
62
63
|
" --compact Compact JSON output",
|
|
63
64
|
" -h, --help Show help",
|
|
64
65
|
" -v, --version Show version",
|
|
@@ -201,17 +202,21 @@ function createRuntimeApi(config) {
|
|
|
201
202
|
}
|
|
202
203
|
},
|
|
203
204
|
};
|
|
205
|
+
const runtimeConfig = {
|
|
206
|
+
stateDir: CLI_DEFAULT_STATE_DIR,
|
|
207
|
+
...config,
|
|
208
|
+
};
|
|
204
209
|
return {
|
|
205
210
|
logger,
|
|
206
211
|
resolvePath: resolvePathFromCwd,
|
|
207
|
-
pluginConfig:
|
|
212
|
+
pluginConfig: runtimeConfig,
|
|
208
213
|
};
|
|
209
214
|
}
|
|
210
|
-
function shouldKeepAlive(
|
|
215
|
+
function shouldKeepAlive(keepAliveFlag) {
|
|
211
216
|
if (typeof keepAliveFlag === "boolean") {
|
|
212
217
|
return keepAliveFlag;
|
|
213
218
|
}
|
|
214
|
-
return
|
|
219
|
+
return false;
|
|
215
220
|
}
|
|
216
221
|
async function waitUntilExposureStops(manager, id) {
|
|
217
222
|
await new Promise((resolve, reject) => {
|
|
@@ -352,12 +357,12 @@ async function main() {
|
|
|
352
357
|
const manager = new CfshareManager(createRuntimeApi(config));
|
|
353
358
|
const result = await runTool(manager, command, params, options);
|
|
354
359
|
process.stdout.write(`${JSON.stringify(result, null, options.compact ? undefined : 2)}\n`);
|
|
355
|
-
if (shouldKeepAlive(
|
|
360
|
+
if (shouldKeepAlive(options.keepAlive)) {
|
|
356
361
|
const exposureId = typeof result === "object" && result ? result.id : undefined;
|
|
357
362
|
if (typeof exposureId !== "string" || !exposureId) {
|
|
358
363
|
return;
|
|
359
364
|
}
|
|
360
|
-
process.stderr.write(`cfshare: exposure ${exposureId} is running. Press Ctrl+C to stop
|
|
365
|
+
process.stderr.write(`cfshare: exposure ${exposureId} is running. Press Ctrl+C to stop.\n`);
|
|
361
366
|
await waitUntilExposureStops(manager, exposureId);
|
|
362
367
|
}
|
|
363
368
|
}
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -33,6 +33,8 @@ const TOOL_NAMES = new Set([
|
|
|
33
33
|
"audit_export",
|
|
34
34
|
]);
|
|
35
35
|
|
|
36
|
+
const CLI_DEFAULT_STATE_DIR = "~/.cfshare";
|
|
37
|
+
|
|
36
38
|
function normalizeCommand(input: string): string {
|
|
37
39
|
return input.trim().toLowerCase().replace(/-/g, "_");
|
|
38
40
|
}
|
|
@@ -77,8 +79,8 @@ function printHelp() {
|
|
|
77
79
|
" --config <json> Runtime config JSON (same as plugin config)",
|
|
78
80
|
" --config-file <path> Read runtime config from JSON file",
|
|
79
81
|
" --workspace-dir <dir> Workspace dir for expose_files context",
|
|
80
|
-
" --keep-alive Keep process running after expose_*",
|
|
81
|
-
" --no-keep-alive Exit
|
|
82
|
+
" --keep-alive Keep process running after expose_* (foreground)",
|
|
83
|
+
" --no-keep-alive Exit after printing expose_* result (default)",
|
|
82
84
|
" --compact Compact JSON output",
|
|
83
85
|
" -h, --help Show help",
|
|
84
86
|
" -v, --version Show version",
|
|
@@ -231,18 +233,23 @@ function createRuntimeApi(config: CfsharePluginConfig): CfshareRuntimeApi {
|
|
|
231
233
|
},
|
|
232
234
|
} as unknown as CfshareRuntimeApi["logger"];
|
|
233
235
|
|
|
236
|
+
const runtimeConfig: CfsharePluginConfig = {
|
|
237
|
+
stateDir: CLI_DEFAULT_STATE_DIR,
|
|
238
|
+
...config,
|
|
239
|
+
};
|
|
240
|
+
|
|
234
241
|
return {
|
|
235
242
|
logger,
|
|
236
243
|
resolvePath: resolvePathFromCwd,
|
|
237
|
-
pluginConfig:
|
|
244
|
+
pluginConfig: runtimeConfig,
|
|
238
245
|
};
|
|
239
246
|
}
|
|
240
247
|
|
|
241
|
-
function shouldKeepAlive(
|
|
248
|
+
function shouldKeepAlive(keepAliveFlag: boolean | undefined): boolean {
|
|
242
249
|
if (typeof keepAliveFlag === "boolean") {
|
|
243
250
|
return keepAliveFlag;
|
|
244
251
|
}
|
|
245
|
-
return
|
|
252
|
+
return false;
|
|
246
253
|
}
|
|
247
254
|
|
|
248
255
|
async function waitUntilExposureStops(manager: CfshareManager, id: string): Promise<void> {
|
|
@@ -465,13 +472,13 @@ async function main() {
|
|
|
465
472
|
const result = await runTool(manager, command, params, options);
|
|
466
473
|
process.stdout.write(`${JSON.stringify(result, null, options.compact ? undefined : 2)}\n`);
|
|
467
474
|
|
|
468
|
-
if (shouldKeepAlive(
|
|
475
|
+
if (shouldKeepAlive(options.keepAlive)) {
|
|
469
476
|
const exposureId = typeof result === "object" && result ? (result as { id?: unknown }).id : undefined;
|
|
470
477
|
if (typeof exposureId !== "string" || !exposureId) {
|
|
471
478
|
return;
|
|
472
479
|
}
|
|
473
480
|
process.stderr.write(
|
|
474
|
-
`cfshare: exposure ${exposureId} is running. Press Ctrl+C to stop
|
|
481
|
+
`cfshare: exposure ${exposureId} is running. Press Ctrl+C to stop.\n`,
|
|
475
482
|
);
|
|
476
483
|
await waitUntilExposureStops(manager, exposureId);
|
|
477
484
|
}
|