nanobazaar-cli 1.0.10 → 1.0.11
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/bin/nanobazaar +0 -78
- package/package.json +1 -1
package/bin/nanobazaar
CHANGED
|
@@ -675,9 +675,6 @@ Commands:
|
|
|
675
675
|
[--state-path <path>] [--openclaw-bin <bin>] [--fswatch-bin <bin>]
|
|
676
676
|
[--event-text <text>] [--mode now|next] [--debounce-ms <ms>]
|
|
677
677
|
Run relay watch + state watcher together (recommended)
|
|
678
|
-
cron enable [--schedule "*/5 * * * *"]
|
|
679
|
-
Install cron entry to run poll
|
|
680
|
-
cron disable Remove the cron entry
|
|
681
678
|
|
|
682
679
|
Global flags:
|
|
683
680
|
--help Show this help
|
|
@@ -1997,69 +1994,6 @@ async function runWatchAll(argv) {
|
|
|
1997
1994
|
await Promise.all([runWatch(argv), runWatchState(argv)]);
|
|
1998
1995
|
}
|
|
1999
1996
|
|
|
2000
|
-
function runCronEnable(argv) {
|
|
2001
|
-
const {flags} = parseArgs(argv);
|
|
2002
|
-
const config = buildConfig();
|
|
2003
|
-
const schedule = flags.schedule || '*/5 * * * *';
|
|
2004
|
-
const nodeBin = process.execPath;
|
|
2005
|
-
const cliPath = path.resolve(__filename);
|
|
2006
|
-
|
|
2007
|
-
const envPairs = [];
|
|
2008
|
-
if (getEnvValue('NBR_RELAY_URL')) {
|
|
2009
|
-
envPairs.push(`NBR_RELAY_URL=${shellEscape(getEnvValue('NBR_RELAY_URL'))}`);
|
|
2010
|
-
}
|
|
2011
|
-
if (getEnvValue('NBR_STATE_PATH')) {
|
|
2012
|
-
envPairs.push(`NBR_STATE_PATH=${shellEscape(expandHomePath(getEnvValue('NBR_STATE_PATH')))}`);
|
|
2013
|
-
}
|
|
2014
|
-
if (getEnvValue('NBR_POLL_LIMIT')) {
|
|
2015
|
-
envPairs.push(`NBR_POLL_LIMIT=${shellEscape(getEnvValue('NBR_POLL_LIMIT'))}`);
|
|
2016
|
-
}
|
|
2017
|
-
if (getEnvValue('NBR_POLL_TYPES')) {
|
|
2018
|
-
envPairs.push(`NBR_POLL_TYPES=${shellEscape(getEnvValue('NBR_POLL_TYPES'))}`);
|
|
2019
|
-
}
|
|
2020
|
-
|
|
2021
|
-
const envPrefix = envPairs.length > 0 ? `${envPairs.join(' ')} ` : '';
|
|
2022
|
-
const command = `${shellEscape(nodeBin)} ${shellEscape(cliPath)} poll`;
|
|
2023
|
-
const cronLine = `${schedule} ${envPrefix}${command} # nanobazaar-cli`;
|
|
2024
|
-
|
|
2025
|
-
const listResult = spawnSync('crontab', ['-l'], {encoding: 'utf8'});
|
|
2026
|
-
const current = listResult.status === 0 ? listResult.stdout : '';
|
|
2027
|
-
const filtered = current
|
|
2028
|
-
.split(/\r?\n/)
|
|
2029
|
-
.filter((line) => line.trim() && !line.includes('# nanobazaar-cli'))
|
|
2030
|
-
.join('\n');
|
|
2031
|
-
|
|
2032
|
-
const next = [filtered, cronLine].filter(Boolean).join('\n') + '\n';
|
|
2033
|
-
const installResult = spawnSync('crontab', ['-'], {input: next, encoding: 'utf8'});
|
|
2034
|
-
if (installResult.status !== 0) {
|
|
2035
|
-
throw new Error(`Failed to install cron entry: ${installResult.stderr || 'unknown error'}`);
|
|
2036
|
-
}
|
|
2037
|
-
|
|
2038
|
-
console.log('Cron enabled.');
|
|
2039
|
-
console.log(`Schedule: ${schedule}`);
|
|
2040
|
-
console.log(`Command: ${envPrefix}${command}`);
|
|
2041
|
-
console.log(`State path: ${config.state_path}`);
|
|
2042
|
-
}
|
|
2043
|
-
|
|
2044
|
-
function runCronDisable() {
|
|
2045
|
-
const listResult = spawnSync('crontab', ['-l'], {encoding: 'utf8'});
|
|
2046
|
-
if (listResult.status !== 0) {
|
|
2047
|
-
console.log('No crontab entries found.');
|
|
2048
|
-
return;
|
|
2049
|
-
}
|
|
2050
|
-
const filtered = listResult.stdout
|
|
2051
|
-
.split(/\r?\n/)
|
|
2052
|
-
.filter((line) => line.trim() && !line.includes('# nanobazaar-cli'))
|
|
2053
|
-
.join('\n');
|
|
2054
|
-
|
|
2055
|
-
const next = filtered ? `${filtered}\n` : '';
|
|
2056
|
-
const installResult = spawnSync('crontab', ['-'], {input: next, encoding: 'utf8'});
|
|
2057
|
-
if (installResult.status !== 0) {
|
|
2058
|
-
throw new Error(`Failed to remove cron entry: ${installResult.stderr || 'unknown error'}`);
|
|
2059
|
-
}
|
|
2060
|
-
console.log('Cron disabled.');
|
|
2061
|
-
}
|
|
2062
|
-
|
|
2063
1997
|
function loadVersion() {
|
|
2064
1998
|
try {
|
|
2065
1999
|
for (const name of ['package.json', 'skill.json']) {
|
|
@@ -2165,18 +2099,6 @@ async function main() {
|
|
|
2165
2099
|
case 'watch-all':
|
|
2166
2100
|
await runWatchAll(rest);
|
|
2167
2101
|
return;
|
|
2168
|
-
case 'cron': {
|
|
2169
|
-
const sub = rest[0];
|
|
2170
|
-
if (sub === 'enable') {
|
|
2171
|
-
runCronEnable(rest.slice(1));
|
|
2172
|
-
return;
|
|
2173
|
-
}
|
|
2174
|
-
if (sub === 'disable') {
|
|
2175
|
-
runCronDisable();
|
|
2176
|
-
return;
|
|
2177
|
-
}
|
|
2178
|
-
throw new Error('Unknown cron command. Use: cron enable|disable');
|
|
2179
|
-
}
|
|
2180
2102
|
default:
|
|
2181
2103
|
throw new Error(`Unknown command: ${command}`);
|
|
2182
2104
|
}
|