Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
cb41dbaf1c | |||
149eb800e7 | |||
91e84c8422 | |||
ff26cd0678 | |||
acdd729e06 | |||
522fbfc42c | |||
b854715940 | |||
35f59054f8 |
22
changelog.md
22
changelog.md
@ -1,5 +1,27 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2024-12-13 - 3.2.2 - fix(core)
|
||||||
|
Fix minor code style and formatting issues
|
||||||
|
|
||||||
|
|
||||||
|
## 2024-12-13 - 3.2.1 - fix(dependencies)
|
||||||
|
Update @types/node dependency version
|
||||||
|
|
||||||
|
- Updated @types/node dependency from version ^22.10.1 to ^22.10.2.
|
||||||
|
|
||||||
|
## 2024-12-09 - 3.2.0 - feat(SmartExecution)
|
||||||
|
Add support for scheduling restarts to SmartExecution
|
||||||
|
|
||||||
|
- Introduced the ability to handle consecutive restarts efficiently in SmartExecution.
|
||||||
|
- Ensures that multiple restart requests merge into a single additional restart request if one is already in progress.
|
||||||
|
|
||||||
|
## 2024-12-09 - 3.1.0 - feat(core)
|
||||||
|
Refactor codebase and update dependencies.
|
||||||
|
|
||||||
|
- Refactored core classes with improved structure and modularization.
|
||||||
|
- Updated tsbuild, tsrun, tapbundle, and @types/node dependencies to newer versions.
|
||||||
|
- Improved build script in package.json to use tsbuild with tsfolders.
|
||||||
|
|
||||||
## 2024-09-17 - 3.0.6 - fix(core)
|
## 2024-09-17 - 3.0.6 - fix(core)
|
||||||
Fix interactive shell execution and update dependencies
|
Fix interactive shell execution and update dependencies
|
||||||
|
|
||||||
|
14
package.json
14
package.json
@ -1,14 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "@push.rocks/smartshell",
|
"name": "@push.rocks/smartshell",
|
||||||
"private": false,
|
"private": false,
|
||||||
"version": "3.0.6",
|
"version": "3.2.2",
|
||||||
"description": "A library for executing shell commands using promises.",
|
"description": "A library for executing shell commands using promises.",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "(tstest test/)",
|
||||||
"build": "(tsbuild --web)",
|
"build": "(tsbuild tsfolders --web)",
|
||||||
"buildDocs": "tsdoc"
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@ -33,11 +33,11 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://code.foss.global/push.rocks/smartshell",
|
"homepage": "https://code.foss.global/push.rocks/smartshell",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@git.zone/tsbuild": "^2.1.84",
|
"@git.zone/tsbuild": "^2.2.0",
|
||||||
"@git.zone/tsrun": "^1.2.49",
|
"@git.zone/tsrun": "^1.3.3",
|
||||||
"@git.zone/tstest": "^1.0.90",
|
"@git.zone/tstest": "^1.0.90",
|
||||||
"@push.rocks/tapbundle": "^5.0.24",
|
"@push.rocks/tapbundle": "^5.5.3",
|
||||||
"@types/node": "^22.5.5"
|
"@types/node": "^22.10.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@push.rocks/smartdelay": "^3.0.1",
|
"@push.rocks/smartdelay": "^3.0.1",
|
||||||
@ -45,7 +45,7 @@
|
|||||||
"@push.rocks/smartpromise": "^4.0.4",
|
"@push.rocks/smartpromise": "^4.0.4",
|
||||||
"@types/which": "^3.0.4",
|
"@types/which": "^3.0.4",
|
||||||
"tree-kill": "^1.2.2",
|
"tree-kill": "^1.2.2",
|
||||||
"which": "^4.0.0"
|
"which": "^5.0.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
|
3729
pnpm-lock.yaml
generated
3729
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartshell',
|
name: '@push.rocks/smartshell',
|
||||||
version: '3.0.6',
|
version: '3.2.2',
|
||||||
description: 'A library for executing shell commands using promises.'
|
description: 'A library for executing shell commands using promises.'
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from './smartshell.plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* a log handler for spawned logs
|
* a log handler for spawned logs
|
55
ts/classes.smartexecution.ts
Normal file
55
ts/classes.smartexecution.ts
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
import * as plugins from './plugins.js';
|
||||||
|
import { Smartshell, type IExecResultStreaming } from './classes.smartshell.js';
|
||||||
|
|
||||||
|
export interface IDeferred<T> {
|
||||||
|
resolve: (value?: T | PromiseLike<T>) => void;
|
||||||
|
reject: (reason?: any) => void;
|
||||||
|
promise: Promise<T>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class SmartExecution {
|
||||||
|
public smartshell: Smartshell;
|
||||||
|
public currentStreamingExecution: IExecResultStreaming;
|
||||||
|
public commandString: string;
|
||||||
|
|
||||||
|
private isRestartInProgress = false;
|
||||||
|
private isAnotherRestartRequested = false;
|
||||||
|
|
||||||
|
constructor(commandStringArg: string) {
|
||||||
|
this.commandString = commandStringArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schedules a restart. If a restart is currently in progress, any additional calls
|
||||||
|
* to restart will merge into a single additional restart request, which will only execute
|
||||||
|
* once the current restart completes.
|
||||||
|
*/
|
||||||
|
public async restart(): Promise<void> {
|
||||||
|
if (this.isRestartInProgress) {
|
||||||
|
// If there's already a restart in progress, just mark that another restart was requested
|
||||||
|
this.isAnotherRestartRequested = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isRestartInProgress = true;
|
||||||
|
try {
|
||||||
|
if (!this.smartshell) {
|
||||||
|
this.smartshell = new Smartshell({
|
||||||
|
executor: 'bash',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (this.currentStreamingExecution) {
|
||||||
|
await this.currentStreamingExecution.kill();
|
||||||
|
}
|
||||||
|
this.currentStreamingExecution = await this.smartshell.execStreaming(this.commandString);
|
||||||
|
} finally {
|
||||||
|
this.isRestartInProgress = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If another restart was requested while we were busy, we handle it now
|
||||||
|
if (this.isAnotherRestartRequested) {
|
||||||
|
this.isAnotherRestartRequested = false;
|
||||||
|
await this.restart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
import * as plugins from './smartshell.plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
import { ShellEnv } from './smartshell.classes.shellenv.js';
|
import { ShellEnv } from './classes.shellenv.js';
|
||||||
import type { IShellEnvContructorOptions, TExecutor } from './smartshell.classes.shellenv.js';
|
import type { IShellEnvContructorOptions, TExecutor } from './classes.shellenv.js';
|
||||||
import { ShellLog } from './smartshell.classes.shelllog.js';
|
import { ShellLog } from './classes.shelllog.js';
|
||||||
|
|
||||||
import * as cp from 'child_process';
|
import * as cp from 'child_process';
|
||||||
|
|
@ -1,2 +1,3 @@
|
|||||||
export * from './smartshell.classes.smartshell.js';
|
export * from './classes.smartshell.js';
|
||||||
export { which } from './smartshell.plugins.js';
|
export * from './classes.smartexecution.js';
|
||||||
|
export { which } from './plugins.js';
|
||||||
|
Reference in New Issue
Block a user