35 Commits

Author SHA1 Message Date
83bcdc4eb0 update description 2024-05-29 14:16:25 +02:00
5c2f318158 3.0.3 2024-05-14 19:28:39 +02:00
e8043c5734 fix(core): update 2024-05-14 19:28:39 +02:00
b9805efa57 update tsconfig 2024-04-14 18:21:57 +02:00
a52a4ab7fd update tsconfig 2024-04-01 21:41:12 +02:00
ea609f83d7 update npmextra.json: githost 2024-04-01 19:59:44 +02:00
3db25512ee update npmextra.json: githost 2024-03-30 21:48:44 +01:00
5c2e3fea6c 3.0.2 2022-07-28 23:14:25 +02:00
7e5178d825 fix(core): update 2022-07-28 23:14:25 +02:00
9795489d67 3.0.1 2022-07-28 23:03:29 +02:00
28733cbd73 fix(core): update 2022-07-28 23:03:29 +02:00
f12335ea62 3.0.0 2022-07-28 22:35:17 +02:00
f12a92660f BREAKING CHANGE(core): switch to esm 2022-07-28 22:35:16 +02:00
c81800cfab 2.0.9 2019-08-23 00:30:02 +02:00
05b94469b5 fix(core): update 2019-08-23 00:30:01 +02:00
eda415893c 2.0.8 2019-08-22 10:42:47 +02:00
630b7661d9 fix(core): update 2019-08-22 10:42:47 +02:00
702c0164a2 2.0.7 2019-08-22 09:26:30 +02:00
0220252b28 fix(core): update 2019-08-22 09:26:30 +02:00
fcdcd4b929 2.0.6 2019-08-22 00:32:10 +02:00
c2f7e98481 fix(core): update 2019-08-22 00:32:09 +02:00
a2242105a1 2.0.5 2019-08-22 00:04:27 +02:00
44431e7d25 fix(core): update 2019-08-22 00:04:27 +02:00
3999015b23 2.0.4 2019-04-08 15:39:18 +02:00
77ad483a8a fix(core): update 2019-04-08 15:39:17 +02:00
904309564a 2.0.3 2019-04-08 15:13:48 +02:00
d8c03fd9ca fix(core): update 2019-04-08 15:13:47 +02:00
7e5c0fe678 2.0.2 2018-08-07 11:13:03 +02:00
93b44ba888 fix(core): update testing framework 2018-08-07 11:13:03 +02:00
30249ad254 2.0.1 2018-08-02 15:35:55 +02:00
07be849d2f fix(package): npm access level 2018-08-02 15:35:55 +02:00
d31f85c6cb 2.0.0 2018-08-02 15:31:06 +02:00
fb2b72a97f BREAKING CHANGE(package): change scope 2018-08-02 15:31:05 +02:00
18dfa70d16 1.0.11 2017-11-28 16:30:04 +01:00
1cb892c357 update ci 2017-11-28 16:30:02 +01:00
44 changed files with 21963 additions and 1018 deletions

20
.gitignore vendored
View File

@ -1,4 +1,20 @@
node_modules/
.nogit/
# artifacts
coverage/
pages/
public/
pages/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_*/
# custom

View File

@ -1,49 +1,55 @@
# gitzone standard
image: hosttoday/ht-docker-node:npmci
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .yarn/
key: "$CI_BUILD_STAGE"
- .npmci_cache/
key: '$CI_BUILD_STAGE'
stages:
- mirror
- test
- release
- trigger
- pages
- security
- test
- release
- metadata
mirror:
stage: mirror
script:
- npmci git mirror
tags:
- docker
before_script:
- npm install -g @shipzone/npmci
testLEGACY:
stage: test
# ====================
# security stage
# ====================
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci node install legacy
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
- npmci npm prepare
- npmci command npm install --production --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- docker
allow_failure: true
testLTS:
stage: test
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci node install lts
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=dev
tags:
- docker
allow_failure: true
testSTABLE:
# ====================
# test stage
# ====================
testStable:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
@ -51,36 +57,72 @@ testSTABLE:
tags:
- docker
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
release:
stage: release
script:
- npmci npm prepare
- npmci node install stable
- npmci npm publish
only:
- tags
tags:
- lossless
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
only:
- tags
script:
- npmci command npm install -g typescript
- npmci npm prepare
- npmci npm install
tags:
- lossless
- docker
- priv
trigger:
stage: trigger
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- lossless
- docker
- notpriv
pages:
image: hosttoday/ht-docker-node:npmci
stage: pages
stage: metadata
script:
- npmci command yarn global add npmpage
- npmci command npmpage
- npmci node install stable
- npmci npm prepare
- npmci npm install
- npmci command npm run buildDocs
tags:
- lossless
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
allow_failure: true

11
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

View File

@ -1,53 +0,0 @@
# smartipc
smart subprocess handling
## Availabililty
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartipc)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/smartipc)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartipc)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartipc/)
## Status for master
[![build status](https://GitLab.com/pushrocks/smartipc/badges/master/build.svg)](https://GitLab.com/pushrocks/smartipc/commits/master)
[![coverage report](https://GitLab.com/pushrocks/smartipc/badges/master/coverage.svg)](https://GitLab.com/pushrocks/smartipc/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/smartipc.svg)](https://www.npmjs.com/package/smartipc)
[![Dependency Status](https://david-dm.org/pushrocks/smartipc.svg)](https://david-dm.org/pushrocks/smartipc)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartipc/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartipc/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartipc/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartipc)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage
Use TypeScript for best in class instellisense.
### Understand the Purpose
smartipc makes it easy to spawn tasks into subprocesses without loosing control over what those processes do.
You can transparently call functions and expect returned data using promises.
### How To
**Master.ts:**
```javascript
import * as smartipc from 'smartipc'
smartipc.setBasePathArg(__dirname) // if you want to avoid typings out full paths every time
let myThread = new smartipc.Thread('worker')
myThread.send('someMessageOrObject').then(messageResponse => {
console.log(messageResponse)
})
```
**worker.ts**
```javascript
```
For further information read the linked docs at the top of this README.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)

2
assets/typescriptwrap.js Normal file
View File

@ -0,0 +1,2 @@
require('@git.zone/tsrun');
require('spawn-wrap').runMain()

5
dist/index.d.ts vendored
View File

@ -1,5 +0,0 @@
export * from './smartipc.classes.thread';
export * from './smartipc.classes.threadfunction';
export * from './smartipc.classes.threadsimple';
export * from './smartipc.classes.pool';
export * from './smartipc.wrap';

11
dist/index.js vendored
View File

@ -1,11 +0,0 @@
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./smartipc.classes.thread"));
__export(require("./smartipc.classes.threadfunction"));
__export(require("./smartipc.classes.threadsimple"));
__export(require("./smartipc.classes.pool"));
__export(require("./smartipc.wrap"));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLCtDQUF5QztBQUN6Qyx1REFBaUQ7QUFDakQscURBQStDO0FBQy9DLDZDQUF1QztBQUN2QyxxQ0FBK0IifQ==

View File

@ -1,5 +0,0 @@
export declare class Pool {
pool: any;
constructor();
run(workerPathArg: string): any;
}

View File

@ -1,13 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./smartipc.plugins");
class Pool {
constructor() {
this.pool = new plugins.threads.Pool();
}
run(workerPathArg) {
return this.pool.run(workerPathArg);
}
}
exports.Pool = Pool;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRpcGMuY2xhc3Nlcy5wb29sLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRpcGMuY2xhc3Nlcy5wb29sLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsOENBQTZDO0FBRTdDO0lBRUU7UUFDRSxJQUFJLENBQUMsSUFBSSxHQUFHLElBQUksT0FBTyxDQUFDLE9BQU8sQ0FBQyxJQUFJLEVBQUUsQ0FBQTtJQUN4QyxDQUFDO0lBQ0QsR0FBRyxDQUFDLGFBQXFCO1FBQ3ZCLE1BQU0sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLEdBQUcsQ0FBQyxhQUFhLENBQUMsQ0FBQTtJQUNyQyxDQUFDO0NBQ0Y7QUFSRCxvQkFRQyJ9

View File

@ -1,25 +0,0 @@
import { Pool } from './smartipc.classes.pool';
export declare let workerBasePath: string;
export declare let setWorkerBasePath: (basePathArg: string) => void;
export declare class Thread {
thread: any;
workerPath: string;
running: boolean;
assignedPool: Pool;
constructor(filePathArg: string);
/**
* sends a message to the spawned process
* spawns it and keeps running
*/
send<T>(message: any): Promise<T>;
/**
* sends a command once and then kills the child process
*/
sendOnce<T>(message: any): Promise<T>;
/**
* kills the thread
*/
kill(): void;
assignToPool(poolArg: Pool): void;
private checkSpawn();
}

View File

@ -1,72 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./smartipc.plugins");
const q = require("smartq");
exports.workerBasePath = null;
exports.setWorkerBasePath = (basePathArg) => {
exports.workerBasePath = basePathArg;
plugins.threads.config.set({
basepath: {
node: exports.workerBasePath
}
});
};
class Thread {
constructor(filePathArg) {
this.running = false;
this.assignedPool = null;
this.workerPath = filePathArg;
}
/**
* sends a message to the spawned process
* spawns it and keeps running
*/
send(message) {
let done = q.defer();
this.checkSpawn();
this.thread.send(message);
this.thread.on('message', (message) => {
done.resolve(message);
});
this.thread.on('done', (job, message) => {
done.resolve(message);
});
this.thread.on('error', err => {
done.reject(err);
});
return done.promise;
}
/**
* sends a command once and then kills the child process
*/
sendOnce(message) {
let done = q.defer();
this.send(message).then(message => {
done.resolve(message);
this.kill();
});
return done.promise;
}
/**
* kills the thread
*/
kill() {
this.thread.kill();
this.running = false;
}
assignToPool(poolArg) {
this.assignedPool = poolArg;
}
checkSpawn() {
if (!this.running && !this.assignedPool) {
this.running = true;
this.thread = plugins.threads.spawn(this.workerPath);
}
else if (!this.running && this.assignedPool) {
this.running = true;
this.thread = this.assignedPool.run(this.workerPath);
}
}
}
exports.Thread = Thread;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRpcGMuY2xhc3Nlcy50aHJlYWQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGlwYy5jbGFzc2VzLnRocmVhZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDhDQUE2QztBQUM3Qyw0QkFBMkI7QUFJaEIsUUFBQSxjQUFjLEdBQVcsSUFBSSxDQUFBO0FBRTdCLFFBQUEsaUJBQWlCLEdBQUcsQ0FBQyxXQUFtQixFQUFFLEVBQUU7SUFDckQsc0JBQWMsR0FBRyxXQUFXLENBQUE7SUFDNUIsT0FBTyxDQUFDLE9BQU8sQ0FBQyxNQUFNLENBQUMsR0FBRyxDQUFDO1FBQ3pCLFFBQVEsRUFBRTtZQUNSLElBQUksRUFBRSxzQkFBYztTQUNyQjtLQUNGLENBQUMsQ0FBQTtBQUNKLENBQUMsQ0FBQTtBQUVEO0lBS0UsWUFBWSxXQUFtQjtRQUYvQixZQUFPLEdBQVksS0FBSyxDQUFBO1FBQ3hCLGlCQUFZLEdBQVMsSUFBSSxDQUFBO1FBRXZCLElBQUksQ0FBQyxVQUFVLEdBQUcsV0FBVyxDQUFBO0lBQy9CLENBQUM7SUFFRDs7O09BR0c7SUFDSCxJQUFJLENBQUksT0FBWTtRQUNsQixJQUFJLElBQUksR0FBRyxDQUFDLENBQUMsS0FBSyxFQUFLLENBQUE7UUFDdkIsSUFBSSxDQUFDLFVBQVUsRUFBRSxDQUFBO1FBQ2pCLElBQUksQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxDQUFBO1FBQ3pCLElBQUksQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDLFNBQVMsRUFBRSxDQUFDLE9BQVUsRUFBRSxFQUFFO1lBQ3ZDLElBQUksQ0FBQyxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUE7UUFDdkIsQ0FBQyxDQUFDLENBQUE7UUFDRixJQUFJLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxHQUFHLEVBQUUsT0FBVSxFQUFFLEVBQUU7WUFDekMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FBQTtRQUN2QixDQUFDLENBQUMsQ0FBQTtRQUNGLElBQUksQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDLE9BQU8sRUFBRSxHQUFHLENBQUMsRUFBRTtZQUM1QixJQUFJLENBQUMsTUFBTSxDQUFDLEdBQUcsQ0FBQyxDQUFBO1FBQ2xCLENBQUMsQ0FBQyxDQUFBO1FBQ0YsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUE7SUFDckIsQ0FBQztJQUVEOztPQUVHO0lBQ0gsUUFBUSxDQUFJLE9BQU87UUFDakIsSUFBSSxJQUFJLEdBQUcsQ0FBQyxDQUFDLEtBQUssRUFBSyxDQUFBO1FBQ3ZCLElBQUksQ0FBQyxJQUFJLENBQUksT0FBTyxDQUFDLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxFQUFFO1lBQ25DLElBQUksQ0FBQyxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUE7WUFDckIsSUFBSSxDQUFDLElBQUksRUFBRSxDQUFBO1FBQ2IsQ0FBQyxDQUFDLENBQUE7UUFDRixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQTtJQUNyQixDQUFDO0lBRUQ7O09BRUc7SUFDSCxJQUFJO1FBQ0YsSUFBSSxDQUFDLE1BQU0sQ0FBQyxJQUFJLEVBQUUsQ0FBQTtRQUNsQixJQUFJLENBQUMsT0FBTyxHQUFHLEtBQUssQ0FBQTtJQUN0QixDQUFDO0lBRUQsWUFBWSxDQUFDLE9BQWE7UUFDeEIsSUFBSSxDQUFDLFlBQVksR0FBRyxPQUFPLENBQUE7SUFDN0IsQ0FBQztJQUVPLFVBQVU7UUFDaEIsRUFBRSxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsT0FBTyxJQUFJLENBQUMsSUFBSSxDQUFDLFlBQVksQ0FBQyxDQUFDLENBQUM7WUFDeEMsSUFBSSxDQUFDLE9BQU8sR0FBRyxJQUFJLENBQUE7WUFDbkIsSUFBSSxDQUFDLE1BQU0sR0FBRyxPQUFPLENBQUMsT0FBTyxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUFDLENBQUE7UUFDdEQsQ0FBQztRQUFDLElBQUksQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxPQUFPLElBQUksSUFBSSxDQUFDLFlBQVksQ0FBQyxDQUFDLENBQUM7WUFDOUMsSUFBSSxDQUFDLE9BQU8sR0FBRyxJQUFJLENBQUE7WUFDbkIsSUFBSSxDQUFDLE1BQU0sR0FBRyxJQUFJLENBQUMsWUFBWSxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUFDLENBQUE7UUFDdEQsQ0FBQztJQUNILENBQUM7Q0FDRjtBQTlERCx3QkE4REMifQ==

View File

@ -1,13 +0,0 @@
import 'typings-global';
export interface IThreadFunction {
(input: any, done: any): void;
}
export declare class ThreadFunction {
thread: any;
constructor(functionArg: IThreadFunction);
/**
* sends a message to the spawned process
*/
send<T>(message: any): Promise<T>;
kill(): void;
}

View File

@ -1,27 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("typings-global");
const plugins = require("./smartipc.plugins");
const q = require("smartq");
class ThreadFunction {
constructor(functionArg) {
this.thread = plugins.threads.spawn(functionArg);
}
/**
* sends a message to the spawned process
*/
send(message) {
let done = q.defer();
this.thread.send(message).on('message', (message) => {
done.resolve(message);
}).on('error', err => {
done.reject(err);
});
return done.promise;
}
kill() {
this.thread.kill();
}
}
exports.ThreadFunction = ThreadFunction;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRpcGMuY2xhc3Nlcy50aHJlYWRmdW5jdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0aXBjLmNsYXNzZXMudGhyZWFkZnVuY3Rpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSwwQkFBdUI7QUFDdkIsOENBQTZDO0FBQzdDLDRCQUEyQjtBQU0zQjtJQUVFLFlBQVksV0FBNEI7UUFDdEMsSUFBSSxDQUFDLE1BQU0sR0FBRyxPQUFPLENBQUMsT0FBTyxDQUFDLEtBQUssQ0FBQyxXQUFXLENBQUMsQ0FBQTtJQUNsRCxDQUFDO0lBRUQ7O09BRUc7SUFDSCxJQUFJLENBQUksT0FBWTtRQUNsQixJQUFJLElBQUksR0FBRyxDQUFDLENBQUMsS0FBSyxFQUFLLENBQUE7UUFDdkIsSUFBSSxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLENBQUMsRUFBRSxDQUFDLFNBQVMsRUFBRSxDQUFDLE9BQVUsRUFBRSxFQUFFO1lBQ3JELElBQUksQ0FBQyxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUE7UUFDdkIsQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDLE9BQU8sRUFBRSxHQUFHLENBQUMsRUFBRTtZQUNuQixJQUFJLENBQUMsTUFBTSxDQUFDLEdBQUcsQ0FBQyxDQUFBO1FBQ2xCLENBQUMsQ0FBQyxDQUFBO1FBQ0YsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUE7SUFDckIsQ0FBQztJQUVELElBQUk7UUFDRixJQUFJLENBQUMsTUFBTSxDQUFDLElBQUksRUFBRSxDQUFBO0lBQ3BCLENBQUM7Q0FDRjtBQXRCRCx3Q0FzQkMifQ==

View File

@ -1,10 +0,0 @@
/// <reference types="node" />
import * as childProcess from 'child_process';
export declare class ThreadSimple {
workerPath: string;
threadChildProcess: childProcess.ChildProcess;
forkOptions: childProcess.ForkOptions;
argvArgs: string[];
constructor(filePathArg: string, argvArgs?: string[], forkOptionsArg?: childProcess.ForkOptions);
run(): Promise<childProcess.ChildProcess>;
}

View File

@ -1,29 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./smartipc.plugins");
const smartq = require("smartq");
const childProcess = require("child_process");
const smartipc_classes_thread_1 = require("./smartipc.classes.thread");
class ThreadSimple {
constructor(filePathArg, argvArgs = [], forkOptionsArg = {}) {
this.workerPath = filePathArg;
this.forkOptions = forkOptionsArg;
this.argvArgs = argvArgs;
}
run() {
let done = smartq.defer();
let forkPath = (() => {
if (smartipc_classes_thread_1.workerBasePath) {
return plugins.path.join(smartipc_classes_thread_1.workerBasePath, this.workerPath);
}
else {
return this.workerPath;
}
})();
this.threadChildProcess = childProcess.fork(forkPath, this.argvArgs, this.forkOptions);
done.resolve(this.threadChildProcess);
return done.promise;
}
}
exports.ThreadSimple = ThreadSimple;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRpcGMuY2xhc3Nlcy50aHJlYWRzaW1wbGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGlwYy5jbGFzc2VzLnRocmVhZHNpbXBsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDhDQUE2QztBQUM3QyxpQ0FBZ0M7QUFDaEMsOENBQTZDO0FBRTdDLHVFQUEwRDtBQUUxRDtJQUtFLFlBQWEsV0FBbUIsRUFBRSxXQUFxQixFQUFFLEVBQUUsaUJBQTJDLEVBQUU7UUFDdEcsSUFBSSxDQUFDLFVBQVUsR0FBRyxXQUFXLENBQUE7UUFDN0IsSUFBSSxDQUFDLFdBQVcsR0FBRyxjQUFjLENBQUE7UUFDakMsSUFBSSxDQUFDLFFBQVEsR0FBRyxRQUFRLENBQUE7SUFDMUIsQ0FBQztJQUVELEdBQUc7UUFDRCxJQUFJLElBQUksR0FBRyxNQUFNLENBQUMsS0FBSyxFQUE2QixDQUFBO1FBQ3BELElBQUksUUFBUSxHQUFHLENBQUMsR0FBRyxFQUFFO1lBQ25CLEVBQUUsQ0FBQyxDQUFDLHdDQUFjLENBQUMsQ0FBQyxDQUFDO2dCQUNuQixNQUFNLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsd0NBQWMsRUFBRSxJQUFJLENBQUMsVUFBVSxDQUFDLENBQUE7WUFDM0QsQ0FBQztZQUFDLElBQUksQ0FBQyxDQUFDO2dCQUNOLE1BQU0sQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUFBO1lBQ3hCLENBQUM7UUFDSCxDQUFDLENBQUMsRUFBRSxDQUFBO1FBQ0osSUFBSSxDQUFDLGtCQUFrQixHQUFHLFlBQVksQ0FBQyxJQUFJLENBQUMsUUFBUSxFQUFFLElBQUksQ0FBQyxRQUFRLEVBQUUsSUFBSSxDQUFDLFdBQVcsQ0FBQyxDQUFBO1FBQ3RGLElBQUksQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLGtCQUFrQixDQUFDLENBQUE7UUFDckMsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUE7SUFDckIsQ0FBQztDQUNGO0FBeEJELG9DQXdCQyJ9

View File

@ -1,5 +0,0 @@
import 'typings-global';
import * as path from 'path';
declare let threads: any;
import * as smartq from 'smartq';
export { path, smartq, threads };

View File

@ -1,10 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("typings-global");
const path = require("path");
exports.path = path;
let threads = require('threads');
exports.threads = threads;
const smartq = require("smartq");
exports.smartq = smartq;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRpcGMucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0aXBjLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSwwQkFBdUI7QUFDdkIsNkJBQTRCO0FBS3hCLG9CQUFJO0FBSlIsSUFBSSxPQUFPLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFBO0FBTTVCLDBCQUFPO0FBTFgsaUNBQWdDO0FBSTVCLHdCQUFNIn0=

View File

@ -1,2 +0,0 @@
export declare let startSpawnWrap: (filePath: string, cliArgs?: string[], envArgs?: any) => void;
export declare let endSpawnWrap: () => void;

18
dist/smartipc.wrap.js vendored
View File

@ -1,18 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const spawnWrap = require("spawn-wrap");
let unwrap = null;
exports.startSpawnWrap = (filePath, cliArgs = [], envArgs = {}) => {
let spawnArray = [filePath];
for (let cliArg of cliArgs) {
spawnArray.push(cliArg);
}
unwrap = spawnWrap(spawnArray, envArgs);
};
exports.endSpawnWrap = () => {
if (unwrap) {
unwrap();
unwrap = null;
}
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRpcGMud3JhcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0aXBjLndyYXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSx3Q0FBdUM7QUFFdkMsSUFBSSxNQUFNLEdBQVEsSUFBSSxDQUFBO0FBRVgsUUFBQSxjQUFjLEdBQUcsQ0FBQyxRQUFnQixFQUFFLFVBQW9CLEVBQUUsRUFBRSxVQUFlLEVBQUUsRUFBRSxFQUFFO0lBQzFGLElBQUksVUFBVSxHQUFHLENBQUMsUUFBUSxDQUFDLENBQUE7SUFDM0IsR0FBRyxDQUFDLENBQUMsSUFBSSxNQUFNLElBQUksT0FBTyxDQUFDLENBQUMsQ0FBQztRQUMzQixVQUFVLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxDQUFBO0lBQ3pCLENBQUM7SUFDRCxNQUFNLEdBQUcsU0FBUyxDQUFDLFVBQVUsRUFBRSxPQUFPLENBQUMsQ0FBQTtBQUN6QyxDQUFDLENBQUE7QUFFVSxRQUFBLFlBQVksR0FBRyxHQUFHLEVBQUU7SUFDN0IsRUFBRSxDQUFDLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQztRQUNYLE1BQU0sRUFBRSxDQUFBO1FBQ1IsTUFBTSxHQUFHLElBQUksQ0FBQTtJQUNmLENBQUM7QUFDSCxDQUFDLENBQUEifQ==

View File

@ -5,8 +5,31 @@
}
},
"npmci": {
"globalNpmTools": [
"npmts"
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "smartspawn",
"description": "A node module for smart subprocess handling with support for promises and streamlined subprocess communication.",
"npmPackagename": "@push.rocks/smartspawn",
"license": "MIT",
"keywords": [
"subprocess",
"child_process",
"spawn",
"threading",
"multithreading",
"process management",
"async",
"promise"
]
}
},
"tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
}
}

14878
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,30 +1,62 @@
{
"name": "smartipc",
"version": "1.0.10",
"description": "smart subprocess handling",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"name": "@push.rocks/smartspawn",
"version": "3.0.3",
"private": false,
"description": "A node module for smart subprocess handling with support for promises and streamlined subprocess communication.",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"scripts": {
"test": "(npmts)"
"test": "(tstest test/)",
"build": "(tsbuild --web --allowimplicitany)",
"buildDocs": "tsdoc"
},
"repository": {
"type": "git",
"url": "git+ssh://git@gitlab.com/pushrocks/smartipc.git"
"url": "https://code.foss.global/push.rocks/smartspawn.git"
},
"author": "Lossless GmbH",
"license": "MIT",
"bugs": {
"url": "https://gitlab.com/pushrocks/smartipc/issues"
},
"homepage": "https://gitlab.com/pushrocks/smartipc#README",
"homepage": "https://code.foss.global/push.rocks/smartspawn",
"dependencies": {
"@types/lodash": "^4.14.85",
"smartq": "^1.1.6",
"spawn-wrap": "^1.4.1",
"threads": "^0.8.1",
"typings-global": "^1.0.23"
"@push.rocks/smartpromise": "^4.0.3",
"spawn-wrap": "^2.0.0",
"threads": "1.7.0",
"tiny-worker": "^2.2.0"
},
"devDependencies": {
"tapbundle": "^1.1.8"
}
"@git.zone/tsbuild": "^2.1.11",
"@git.zone/tsrun": "^1.2.8",
"@git.zone/tstest": "^1.0.24",
"@push.rocks/tapbundle": "^5.0.4",
"@types/node": "^20.12.12"
},
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
],
"keywords": [
"subprocess",
"child_process",
"spawn",
"threading",
"multithreading",
"process management",
"async",
"promise"
]
}

6651
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

1
readme.hints.md Normal file
View File

@ -0,0 +1 @@

120
readme.md Normal file
View File

@ -0,0 +1,120 @@
Given the provided files and their contents, the comprehensive documentation for using **`@push.rocks/smartspawn`** with TypeScript and in a manner that provides thorough examples and descriptions of features and scenarios is extensive. However, I'll outline a concise and informative usage guide that can serve as a helpful starting point. For an in-depth understanding and a complete reference to all features, further reading, exploration, and experimentation with the library are recommended.
# @push.rocks/smartspawn
smart subprocess handling
## Install
To install `@push.rocks/smartspawn`, open your terminal and run the following command:
```bash
npm install @push.rocks/smartspawn
```
This command fetches the package from npm and adds it to your project's dependencies.
## Usage
This guide uses TypeScript and ESM syntax to demonstrate how to utilize `@push.rocks/smartspawn` for smart subprocess handling in your application.
First, ensure that your TypeScript environment is set up to support ECMAScript modules (ESM). Your `tsconfig.json` should include:
```json
{
"compilerOptions": {
"module": "ESNext",
"target": "ESNext",
"moduleResolution": "node"
}
}
```
### Starting and Stopping a Simple Thread
`ThreadSimple` class allows you to manage subprocesses effectively. Here's how to start and stop a simple thread:
```typescript
// Import the necessary components from the library
import { ThreadSimple } from '@push.rocks/smartspawn';
// Define a function that creates, starts, and stops a thread
async function demonstrateThreadSimple() {
// Create an instance of ThreadSimple
const mySimpleThread = new ThreadSimple('./path/to/worker.js');
// Start the thread
await mySimpleThread.start();
console.log('Thread has started.');
// Stop the thread
await mySimpleThread.stop();
console.log('Thread has stopped.');
}
// Call the function to demonstrate its functionality
demonstrateThreadSimple();
```
The `./path/to/worker.js` should be the path to your worker script that you want to execute in a separate process.
### Wrapping Processes
`smartspawn` also provides functionality to wrap subprocesses, allowing you to modify or set up an environment before execution. Here's how to wrap and unwrap subprocesses:
```typescript
import { startSpawnWrap, endSpawnWrap } from '@push.rocks/smartspawn';
// Start a wrap
startSpawnWrap('path/to/script', ['arg1', 'arg2'], { ENV_VAR: 'value' });
console.log('Subprocess wrapped.');
// End the wrap when it's no longer needed
endSpawnWrap();
console.log('Subprocess unwrapped.');
```
### Advanced Thread Management
`@push.rocks/smartspawn` integrates with the `threads` package to provide advanced threading capabilities. Here's a brief example showing how you might utilize it for more complex scenarios:
```typescript
import { Thread, spawn, Worker } from 'threads';
async function advancedThreadExample() {
const thread = await spawn(new Worker('./worker'));
const result = await thread.doWork();
console.log(`Result from thread: ${result}`);
await Thread.terminate(thread);
}
advancedThreadExample();
```
Ensure you explore the `threads` documentation for a more detailed understanding of creating workers and communicating between the main process and threads.
### Conclusion
The `@push.rocks/smartspawn` package simplifies managing subprocesses in your Node.js applications, offering straightforward APIs for starting, stopping, and communicating with child processes. Whether you need to execute a simple script in the background or leverage sophisticated multi-threading capabilities, `smartspawn` provides the tools necessary to implement these features efficiently and robustly.
Remember, the examples above are starting points. Review the source code, tests, and type declarations for a comprehensive understanding of everything `@push.rocks/smartspawn` and its integrated packages can do. Experiment with the library in your projects to best learn how to utilize its full potential in real-world applications.
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.

View File

@ -1,5 +0,0 @@
import 'typings-global'
import 'smartq'
module.exports = (input, done) => {
done(input)
}

View File

@ -1,60 +1,7 @@
import { expect, tap } from 'tapbundle'
import { expect, tap } from '@push.rocks/tapbundle';
import * as smartipc from '../ts/index'
import * as smartspawn from '../ts/index.js';
let testThreadFunction: smartipc.ThreadFunction
let testThread: smartipc.Thread
let testPool: smartipc.Pool
tap.test('should create a simple test function', async () => {});
/**
* create a normal ThreadFunction
*/
tap.test('should create an instance of ThreadFunction', async () => {
testThreadFunction = new smartipc.ThreadFunction((input, done) => {
let url = require('url')
done(url.parse(input))
})
const message = await testThreadFunction.send('https://google.com')
console.log(message)
testThreadFunction.kill()
})
tap.test('should create an instance of Thread', async () => {
smartipc.setWorkerBasePath(__dirname)
testThread = new smartipc.Thread('child.js')
const message = await testThread.send('https://google.com')
console.log(message)
testThread.kill()
})
tap.test('should not spawn when nothing is sent', async () => {
smartipc.setWorkerBasePath(__dirname)
let testThread = new smartipc.Thread('child.js')
})
tap.test('should run in a Pool', async () => {
let testPool = new smartipc.Pool()
let testThread = new smartipc.Thread('child.js')
testThread.assignToPool(testPool)
// first run
let message = await testThread.send('what')
expect(message).to.equal('what')
console.log(message)
// second run
message = await testThread.send('another')
expect(message).to.equal('another')
console.log(message)
// kill all
testThread.assignedPool.pool.killAll()
})
tap.test('should once', async () => {
let testThread = new smartipc.Thread('child.js')
const message = await testThread.sendOnce('what')
expect(message).to.equal('what')
})
tap.start()
export default tap.start();

3
testassets/child.ts Normal file
View File

@ -0,0 +1,3 @@
module.exports = (input, done) => {
done(input);
};

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smartspawn',
version: '3.0.3',
description: 'A node module for smart subprocess handling with support for promises and streamlined subprocess communication.'
}

View File

@ -1,6 +1,4 @@
export * from './smartipc.classes.thread'
export * from './smartipc.classes.threadfunction'
export * from './smartipc.classes.threadsimple'
export * from './smartipc.classes.pool'
export * from './smartipc.wrap'
export * from './smartspawn.classes.threadsimple.js';
export * from './smartspawn.wrap.js';
export * from 'threads';

View File

@ -1,11 +0,0 @@
import * as plugins from './smartipc.plugins'
export class Pool {
pool
constructor() {
this.pool = new plugins.threads.Pool()
}
run(workerPathArg: string) {
return this.pool.run(workerPathArg)
}
}

View File

@ -1,79 +0,0 @@
import * as plugins from './smartipc.plugins'
import * as q from 'smartq'
import { Pool } from './smartipc.classes.pool'
export let workerBasePath: string = null
export let setWorkerBasePath = (basePathArg: string) => {
workerBasePath = basePathArg
plugins.threads.config.set({
basepath: {
node: workerBasePath
}
})
}
export class Thread {
thread
workerPath: string
running: boolean = false
assignedPool: Pool = null
constructor(filePathArg: string) {
this.workerPath = filePathArg
}
/**
* sends a message to the spawned process
* spawns it and keeps running
*/
send<T>(message: any): Promise<T> {
let done = q.defer<T>()
this.checkSpawn()
this.thread.send(message)
this.thread.on('message', (message: T) => {
done.resolve(message)
})
this.thread.on('done', (job, message: T) => {
done.resolve(message)
})
this.thread.on('error', err => {
done.reject(err)
})
return done.promise
}
/**
* sends a command once and then kills the child process
*/
sendOnce<T>(message): Promise<T> {
let done = q.defer<T>()
this.send<T>(message).then(message => {
done.resolve(message)
this.kill()
})
return done.promise
}
/**
* kills the thread
*/
kill() {
this.thread.kill()
this.running = false
}
assignToPool(poolArg: Pool) {
this.assignedPool = poolArg
}
private checkSpawn() {
if (!this.running && !this.assignedPool) {
this.running = true
this.thread = plugins.threads.spawn(this.workerPath)
} else if (!this.running && this.assignedPool) {
this.running = true
this.thread = this.assignedPool.run(this.workerPath)
}
}
}

View File

@ -1,31 +0,0 @@
import 'typings-global'
import * as plugins from './smartipc.plugins'
import * as q from 'smartq'
export interface IThreadFunction {
(input, done): void
}
export class ThreadFunction {
thread
constructor(functionArg: IThreadFunction) {
this.thread = plugins.threads.spawn(functionArg)
}
/**
* sends a message to the spawned process
*/
send<T>(message: any): Promise<T> {
let done = q.defer<T>()
this.thread.send(message).on('message', (message: T) => {
done.resolve(message)
}).on('error', err => {
done.reject(err)
})
return done.promise
}
kill() {
this.thread.kill()
}
}

View File

@ -1,31 +0,0 @@
import * as plugins from './smartipc.plugins'
import * as smartq from 'smartq'
import * as childProcess from 'child_process'
import { workerBasePath } from './smartipc.classes.thread'
export class ThreadSimple {
workerPath: string
threadChildProcess: childProcess.ChildProcess
forkOptions: childProcess.ForkOptions
argvArgs: string[]
constructor (filePathArg: string, argvArgs: string[] = [], forkOptionsArg: childProcess.ForkOptions = {}) {
this.workerPath = filePathArg
this.forkOptions = forkOptionsArg
this.argvArgs = argvArgs
}
run () {
let done = smartq.defer<childProcess.ChildProcess>()
let forkPath = (() => {
if (workerBasePath) {
return plugins.path.join(workerBasePath, this.workerPath)
} else {
return this.workerPath
}
})()
this.threadChildProcess = childProcess.fork(forkPath, this.argvArgs, this.forkOptions)
done.resolve(this.threadChildProcess)
return done.promise
}
}

View File

@ -1,10 +0,0 @@
import 'typings-global'
import * as path from 'path'
let threads = require('threads')
import * as smartq from 'smartq'
export {
path,
smartq,
threads
}

View File

@ -1,18 +0,0 @@
import * as spawnWrap from 'spawn-wrap'
let unwrap: any = null
export let startSpawnWrap = (filePath: string, cliArgs: string[] = [], envArgs: any = {}) => {
let spawnArray = [filePath]
for (let cliArg of cliArgs) {
spawnArray.push(cliArg)
}
unwrap = spawnWrap(spawnArray, envArgs)
}
export let endSpawnWrap = () => {
if (unwrap) {
unwrap()
unwrap = null
}
}

View File

@ -0,0 +1,29 @@
import * as plugins from './smartspawn.plugins.js';
import * as smartpromise from '@push.rocks/smartpromise';
import * as childProcess from 'child_process';
export class ThreadSimple {
public workerPath: string;
public threadChildProcess: childProcess.ChildProcess;
public forkOptions: childProcess.ForkOptions;
public argvArgs: string[];
constructor(
filePathArg: string,
argvArgs: string[] = [],
forkOptionsArg: childProcess.ForkOptions = {}
) {
this.workerPath = filePathArg;
this.forkOptions = forkOptionsArg;
this.argvArgs = argvArgs;
}
public async start() {
const forkPath = this.workerPath;
this.threadChildProcess = childProcess.fork(forkPath, this.argvArgs, this.forkOptions);
return this.threadChildProcess;
}
public async stop() {
this.threadChildProcess.kill();
}
}

4
ts/smartspawn.paths.ts Normal file
View File

@ -0,0 +1,4 @@
import * as plugins from './smartspawn.plugins.js';
export const packageBase = plugins.path.join(__dirname, '../');
export const typescriptwrapJs = plugins.path.join(packageBase, 'assets/typescriptwrap.js');

5
ts/smartspawn.plugins.ts Normal file
View File

@ -0,0 +1,5 @@
import * as path from 'path';
import * as threads from 'threads';
import * as smartpromise from '@push.rocks/smartpromise';
export { path, smartpromise, threads };

18
ts/smartspawn.wrap.ts Normal file
View File

@ -0,0 +1,18 @@
import * as spawnWrap from 'spawn-wrap';
let unwrap: any = null;
export const startSpawnWrap = (filePath: string, cliArgs: string[] = [], envArgs: any = {}) => {
const spawnArray = [filePath];
for (const cliArg of cliArgs) {
spawnArray.push(cliArg);
}
unwrap = spawnWrap(spawnArray, envArgs);
};
export const endSpawnWrap = () => {
if (unwrap) {
unwrap();
unwrap = null;
}
};

14
tsconfig.json Normal file
View File

@ -0,0 +1,14 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"verbatimModuleSyntax": true
},
"exclude": [
"dist_*/**/*.d.ts"
]
}

View File

@ -1,3 +0,0 @@
{
"extends": "tslint-config-standard"
}

397
yarn.lock
View File

@ -1,397 +0,0 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@types/code@^4.0.3":
version "4.0.3"
resolved "https://registry.yarnpkg.com/@types/code/-/code-4.0.3.tgz#9c4de39f86eb3eba070146d2dab7dbc3f8eac35f"
"@types/lodash@^4.14.85":
version "4.14.85"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.85.tgz#a16fbf942422f6eca5622b6910492c496c35069b"
"@types/node@^8.0.33":
version "8.0.53"
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.53.tgz#396b35af826fa66aad472c8cb7b8d5e277f4e6d8"
"@types/which@^1.0.28":
version "1.0.28"
resolved "https://registry.yarnpkg.com/@types/which/-/which-1.0.28.tgz#016e387629b8817bed653fe32eab5d11279c8df6"
ansi-256-colors@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/ansi-256-colors/-/ansi-256-colors-1.1.0.tgz#910de50efcc7c09e3d82f2f87abd6b700c18818a"
balanced-match@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
beautycolor@^1.0.7:
version "1.0.11"
resolved "https://registry.yarnpkg.com/beautycolor/-/beautycolor-1.0.11.tgz#71c5568d5a7ed5c144d3a54f753ad1b08862aea5"
dependencies:
ansi-256-colors "^1.1.0"
typings-global "^1.0.14"
bindings@^1.2.1:
version "1.3.0"
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.3.0.tgz#b346f6ecf6a95f5a815c5839fc7cdb22502f1ed7"
brace-expansion@^1.1.7:
version "1.1.8"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292"
dependencies:
balanced-match "^1.0.0"
concat-map "0.0.1"
code@^5.1.0:
version "5.1.2"
resolved "https://registry.yarnpkg.com/code/-/code-5.1.2.tgz#e3310c2078ca7dc0b49b9c39a8b0a7b06bd75efe"
dependencies:
hoek "5.x.x"
concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
cross-spawn@^4:
version "4.0.2"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-4.0.2.tgz#7b9247621c23adfdd3856004a823cbe397424d41"
dependencies:
lru-cache "^4.0.1"
which "^1.2.9"
define-properties@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94"
dependencies:
foreach "^2.0.5"
object-keys "^1.0.8"
early@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/early/-/early-2.1.1.tgz#841e23254ea5dc54d8afaeee82f5ab65c00ee23c"
dependencies:
beautycolor "^1.0.7"
smartq "^1.1.1"
typings-global "^1.0.16"
es-abstract@^1.5.1:
version "1.10.0"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.10.0.tgz#1ecb36c197842a00d8ee4c2dfd8646bb97d60864"
dependencies:
es-to-primitive "^1.1.1"
function-bind "^1.1.1"
has "^1.0.1"
is-callable "^1.1.3"
is-regex "^1.0.4"
es-to-primitive@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d"
dependencies:
is-callable "^1.1.1"
is-date-object "^1.0.1"
is-symbol "^1.0.1"
es6-error@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/es6-error/-/es6-error-4.0.2.tgz#eec5c726eacef51b7f6b73c20db6e1b13b069c98"
eventemitter3@^2.0.2:
version "2.0.3"
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-2.0.3.tgz#b5e1079b59fb5e1ba2771c0a993be060a58c99ba"
foreach@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99"
foreground-child@^1.5.6:
version "1.5.6"
resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-1.5.6.tgz#4fd71ad2dfde96789b980a5c0a295937cb2f5ce9"
dependencies:
cross-spawn "^4"
signal-exit "^3.0.0"
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
function-bind@^1.0.2, function-bind@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
glob@^7.0.0, glob@^7.0.5:
version "7.1.2"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.4"
once "^1.3.0"
path-is-absolute "^1.0.0"
has@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28"
dependencies:
function-bind "^1.0.2"
hoek@5.x.x:
version "5.0.2"
resolved "https://registry.yarnpkg.com/hoek/-/hoek-5.0.2.tgz#d2f2c95d36fe7189cf8aa8c237abc1950eca1378"
inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
dependencies:
once "^1.3.0"
wrappy "1"
inherits@2:
version "2.0.3"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
interpret@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.1.0.tgz#7ed1b1410c6a0e0f78cf95d3b8440c63f78b8614"
is-callable@^1.1.1, is-callable@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2"
is-date-object@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16"
is-regex@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491"
dependencies:
has "^1.0.1"
is-symbol@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572"
isexe@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
leakage@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/leakage/-/leakage-0.3.0.tgz#15d698abdc76bbc6439601f4f3020e77e2d50c39"
dependencies:
es6-error "^4.0.2"
left-pad "^1.1.3"
memwatch-next "^0.3.0"
minimist "^1.2.0"
pretty-bytes "^4.0.2"
left-pad@^1.1.3:
version "1.2.0"
resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.2.0.tgz#d30a73c6b8201d8f7d8e7956ba9616087a68e0ee"
lru-cache@^4.0.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.1.tgz#622e32e82488b49279114a4f9ecf45e7cd6bba55"
dependencies:
pseudomap "^1.0.2"
yallist "^2.1.2"
memwatch-next@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/memwatch-next/-/memwatch-next-0.3.0.tgz#2111050f9a906e0aa2d72a4ec0f0089c78726f8f"
dependencies:
bindings "^1.2.1"
nan "^2.3.2"
minimatch@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
dependencies:
brace-expansion "^1.1.7"
minimist@0.0.8:
version "0.0.8"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"
minimist@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
mkdirp@^0.5.0:
version "0.5.1"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903"
dependencies:
minimist "0.0.8"
nan@^2.3.2:
version "2.8.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.8.0.tgz#ed715f3fe9de02b57a5e6252d90a96675e1f085a"
native-promise-only@^0.8.1:
version "0.8.1"
resolved "https://registry.yarnpkg.com/native-promise-only/-/native-promise-only-0.8.1.tgz#20a318c30cb45f71fe7adfbf7b21c99c1472ef11"
object-keys@^1.0.8:
version "1.0.11"
resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d"
object.getownpropertydescriptors@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz#8758c846f5b407adab0f236e0986f14b051caa16"
dependencies:
define-properties "^1.1.2"
es-abstract "^1.5.1"
once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
dependencies:
wrappy "1"
os-homedir@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3"
path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
path-parse@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1"
pretty-bytes@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-4.0.2.tgz#b2bf82e7350d65c6c33aa95aaa5a4f6327f61cd9"
pseudomap@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3"
rechoir@^0.6.2:
version "0.6.2"
resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384"
dependencies:
resolve "^1.1.6"
resolve@^1.1.6:
version "1.5.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.5.0.tgz#1f09acce796c9a762579f31b2c1cc4c3cddf9f36"
dependencies:
path-parse "^1.0.5"
rimraf@^2.6.2:
version "2.6.2"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36"
dependencies:
glob "^7.0.5"
semver@^5.3.0:
version "5.4.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e"
shelljs@^0.7.8:
version "0.7.8"
resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.8.tgz#decbcf874b0d1e5fb72e14b164a9683048e9acb3"
dependencies:
glob "^7.0.0"
interpret "^1.0.0"
rechoir "^0.6.2"
signal-exit@^3.0.0, signal-exit@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"
smartchai@^1.0.3:
version "1.0.8"
resolved "https://registry.yarnpkg.com/smartchai/-/smartchai-1.0.8.tgz#a074836f4ddd4b98c50f1e7ae9e8e8ad9f6f1902"
dependencies:
"@types/code" "^4.0.3"
code "^5.1.0"
typings-global "^1.0.20"
smartdelay@^1.0.3:
version "1.0.4"
resolved "https://registry.yarnpkg.com/smartdelay/-/smartdelay-1.0.4.tgz#791c1a4ee6770494064c10b1d2d2b8e6f3105b82"
dependencies:
smartq "^1.1.1"
typings-global "^1.0.16"
smartq@^1.1.1, smartq@^1.1.6:
version "1.1.6"
resolved "https://registry.yarnpkg.com/smartq/-/smartq-1.1.6.tgz#0c1ff4336d95e95b4f1fdd8ccd7e2c5a323b8412"
dependencies:
typings-global "^1.0.19"
util.promisify "^1.0.0"
smartshell@^1.0.6:
version "1.0.19"
resolved "https://registry.yarnpkg.com/smartshell/-/smartshell-1.0.19.tgz#459c7a9fab8a25007848ffc711b7a817dd6ffc00"
dependencies:
"@types/which" "^1.0.28"
shelljs "^0.7.8"
smartq "^1.1.6"
typings-global "^1.0.23"
which "^1.3.0"
spawn-wrap@^1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/spawn-wrap/-/spawn-wrap-1.4.1.tgz#36156a4826cd633766eb22325a9424eed6728a43"
dependencies:
foreground-child "^1.5.6"
mkdirp "^0.5.0"
os-homedir "^1.0.1"
rimraf "^2.6.2"
signal-exit "^3.0.2"
which "^1.3.0"
tapbundle@^1.1.8:
version "1.1.8"
resolved "https://registry.yarnpkg.com/tapbundle/-/tapbundle-1.1.8.tgz#e08aee0e100a830d8a26a583a85d37ce53312e02"
dependencies:
"@types/node" "^8.0.33"
early "^2.1.1"
leakage "^0.3.0"
smartchai "^1.0.3"
smartdelay "^1.0.3"
smartq "^1.1.1"
typings-global "^1.0.19"
threads@^0.8.1:
version "0.8.1"
resolved "https://registry.yarnpkg.com/threads/-/threads-0.8.1.tgz#e340115b5947316d2f7ee3123c4c2c5bf9c76d72"
dependencies:
eventemitter3 "^2.0.2"
native-promise-only "^0.8.1"
typings-global@^1.0.14, typings-global@^1.0.16, typings-global@^1.0.19, typings-global@^1.0.20, typings-global@^1.0.23:
version "1.0.23"
resolved "https://registry.yarnpkg.com/typings-global/-/typings-global-1.0.23.tgz#cdd085803049dd07d95b2e1475243c6b2db378ab"
dependencies:
semver "^5.3.0"
smartshell "^1.0.6"
util.promisify@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/util.promisify/-/util.promisify-1.0.0.tgz#440f7165a459c9a16dc145eb8e72f35687097030"
dependencies:
define-properties "^1.1.2"
object.getownpropertydescriptors "^2.0.3"
which@^1.2.9, which@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a"
dependencies:
isexe "^2.0.0"
wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
yallist@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52"