Compare commits

...

100 Commits

Author SHA1 Message Date
f77f36312f 1.0.56 2021-08-18 18:55:44 +02:00
c508c85473 fix(core): update 2021-08-18 18:55:43 +02:00
50a0cadd11 1.0.55 2021-08-17 17:55:54 +02:00
d5cb794ea6 fix(core): update 2021-08-17 17:55:54 +02:00
3bb65bedf6 1.0.54 2021-07-26 21:44:35 +02:00
53147a8812 fix(core): update 2021-07-26 21:44:35 +02:00
c63a5f88d5 1.0.53 2021-07-26 21:42:52 +02:00
f039ace7bc fix(core): update 2021-07-26 21:42:51 +02:00
bbc34ad98b 1.0.52 2021-03-08 00:28:16 +00:00
c699954d08 fix(core): update 2021-03-08 00:28:15 +00:00
1c84726ed8 1.0.51 2021-03-08 00:26:45 +00:00
c589e20222 fix(core): update 2021-03-08 00:26:44 +00:00
f170cb8909 1.0.50 2020-07-07 18:30:17 +00:00
ca1d058789 fix(core): update 2020-07-07 18:30:17 +00:00
4423631fa9 1.0.49 2020-07-04 10:49:01 +00:00
5e62fa2124 fix(core): update 2020-07-04 10:49:00 +00:00
8ef3b47e76 1.0.48 2020-07-04 10:45:57 +00:00
ed91da6e3f fix(core): update 2020-07-04 10:45:56 +00:00
7b777ea1a9 1.0.47 2020-07-04 10:35:16 +00:00
faec3d38bc fix(core): update 2020-07-04 10:35:16 +00:00
a2ff76dc78 1.0.46 2020-05-22 08:15:00 +00:00
7e973c906a fix(core): update 2020-05-22 08:14:59 +00:00
6c109cb381 1.0.45 2020-05-22 07:59:06 +00:00
2266813faf fix(core): update 2020-05-22 07:59:05 +00:00
bf7a2c9146 1.0.44 2020-05-22 07:58:02 +00:00
1a4ada879d fix(core): update 2020-05-22 07:58:01 +00:00
0046985b82 1.0.43 2020-05-22 07:25:35 +00:00
d876b09337 fix(core): update 2020-05-22 07:25:34 +00:00
f48ba50236 1.0.42 2020-05-22 07:19:40 +00:00
f04833d5b5 fix(core): update 2020-05-22 07:19:39 +00:00
073685e683 1.0.41 2020-05-22 00:53:11 +00:00
b91b3e0a0c fix(core): update 2020-05-22 00:53:11 +00:00
12d31533f5 1.0.40 2020-05-22 00:46:13 +00:00
f9b8a356e4 fix(core): update 2020-05-22 00:46:12 +00:00
408b6f8fc5 1.0.39 2020-03-13 18:44:22 +00:00
80dd3ee970 fix(core): update 2020-03-13 18:44:21 +00:00
717e1d29ed 1.0.38 2020-03-13 18:19:01 +00:00
a8254e6962 fix(core): update 2020-03-13 18:19:00 +00:00
35ee69981d 1.0.37 2020-03-13 18:07:45 +00:00
bd66e9a897 fix(core): update 2020-03-13 18:07:45 +00:00
fc356e62f4 1.0.36 2020-03-13 17:48:20 +00:00
a34d98b840 fix(core): update 2020-03-13 17:48:19 +00:00
9525f28507 1.0.35 2020-03-13 17:46:58 +00:00
787aae63d7 fix(core): update 2020-03-13 17:46:57 +00:00
bf2a32a5d5 1.0.34 2020-03-13 17:43:58 +00:00
7ced66fc28 fix(core): update 2020-03-13 17:43:57 +00:00
d01905ae99 1.0.33 2020-03-09 15:08:06 +00:00
59c744cc5e fix(core): update 2020-03-09 15:08:05 +00:00
4d23145529 1.0.32 2020-03-09 14:52:38 +00:00
27e0d7588d fix(core): update 2020-03-09 14:52:37 +00:00
88d4bf6be0 1.0.31 2020-03-05 09:26:41 +00:00
d4f8215f35 fix(core): update 2020-03-05 09:26:41 +00:00
85f72feeb9 1.0.30 2019-10-14 14:57:43 +02:00
bd4ccbd215 fix(core): update 2019-10-14 14:57:43 +02:00
79940cec3f 1.0.29 2019-10-14 14:53:56 +02:00
e20508ffbc fix(core): update 2019-10-14 14:53:55 +02:00
21b962b9a8 1.0.28 2019-10-12 18:09:42 +02:00
f673e8577b fix(core): update 2019-10-12 18:09:41 +02:00
e4278ed270 1.0.27 2019-10-12 17:43:44 +02:00
8ae0f960ac fix(core): update 2019-10-12 17:43:43 +02:00
c9a3b996cb 1.0.26 2019-10-12 17:34:05 +02:00
d81d19008a fix(core): update 2019-10-12 17:34:05 +02:00
e4ef6bad8f 1.0.25 2019-10-12 17:31:26 +02:00
2873314742 fix(core): update 2019-10-12 17:31:25 +02:00
e26fa92744 1.0.24 2019-10-12 17:17:32 +02:00
995f296319 fix(core): update 2019-10-12 17:17:31 +02:00
e7866dadb7 1.0.23 2019-10-12 17:12:51 +02:00
9302e78f86 fix(core): update 2019-10-12 17:12:50 +02:00
0a302bee95 1.0.22 2019-10-12 16:54:19 +02:00
deb5e1daf9 1.0.21 2019-10-12 16:54:03 +02:00
5fe27ee706 fix(core): update 2019-10-12 16:54:03 +02:00
b73807baf0 1.0.20 2019-10-12 15:57:44 +02:00
1e71fc24d5 fix(core): update 2019-10-12 15:57:43 +02:00
e8071e76a1 1.0.19 2019-10-12 15:07:45 +02:00
b11d03dd41 fix(core): update 2019-10-12 15:07:44 +02:00
72297d2f58 1.0.18 2019-05-28 14:28:50 +02:00
71b900ac47 fix(core): update 2019-05-28 14:28:50 +02:00
f6d06edced 1.0.17 2019-05-28 11:35:04 +02:00
3e98005843 fix(core): update 2019-05-28 11:35:03 +02:00
7c4673a5b6 1.0.16 2019-05-27 15:38:07 +02:00
99ec82ab55 fix(core): update 2019-05-27 15:38:07 +02:00
1f0c1964dd 1.0.15 2019-05-27 14:46:34 +02:00
828229872d fix(core): update 2019-05-27 14:46:33 +02:00
0ff482bd01 1.0.14 2019-05-27 14:07:14 +02:00
39c8da4f74 fix(core): update 2019-05-27 14:07:13 +02:00
fcd2029744 1.0.13 2019-05-22 16:52:38 +02:00
d89e0a13d5 fix(core): update 2019-05-22 16:52:38 +02:00
64c7815bca 1.0.12 2019-05-22 16:45:49 +02:00
f3e69eb15e fix(core): update 2019-05-22 16:45:48 +02:00
386e4c07c6 1.0.11 2019-05-14 08:45:10 +02:00
82557c96d6 1.0.10 2019-05-13 18:54:06 +02:00
c94d89fa8a fix(core): update 2019-05-13 18:54:05 +02:00
639a5eebea 1.0.9 2019-05-13 09:48:36 +02:00
fb88d3384e fix(core): update 2019-05-13 09:48:35 +02:00
e38342604b 1.0.8 2019-05-09 00:08:41 +02:00
390200ad2a fix(core): update 2019-05-09 00:08:40 +02:00
1960b1d125 1.0.7 2019-05-08 11:16:25 +02:00
7ce6245286 fix(core): update 2019-05-08 11:16:24 +02:00
3a8513d3a0 1.0.6 2019-05-08 11:14:57 +02:00
d425e290dd fix(core): update 2019-05-08 11:14:57 +02:00
40 changed files with 25042 additions and 1344 deletions

16
.gitignore vendored
View File

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

View File

@@ -1,10 +1,10 @@
# gitzone standard # gitzone ci_default
image: hosttoday/ht-docker-node:npmci image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache: cache:
paths: paths:
- .npmci_cache/ - .npmci_cache/
key: "$CI_BUILD_STAGE" key: '$CI_BUILD_STAGE'
stages: stages:
- security - security
@@ -19,50 +19,42 @@ mirror:
stage: security stage: security
script: script:
- npmci git mirror - npmci git mirror
only:
- tags
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
snyk: auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security stage: security
script: script:
- npmci npm prepare - npmci npm prepare
- npmci command npm install -g snyk - npmci command npm install --production --ignore-scripts
- npmci command npm install --ignore-scripts - npmci command npm config set registry https://registry.npmjs.org
- npmci command snyk test - npmci command npm audit --audit-level=high --only=prod --production
tags: tags:
- docker - docker
- notpriv allow_failure: true
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- 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
# ==================== # ====================
# test stage # test stage
# ==================== # ====================
testLEGACY:
stage: test
script:
- npmci npm prepare
- npmci node install legacy
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
allow_failure: true
testLTS: testStable:
stage: test
script:
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
testSTABLE:
stage: test stage: test
script: script:
- npmci npm prepare - npmci npm prepare
@@ -72,7 +64,17 @@ testSTABLE:
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
- notpriv
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: release:
stage: release stage: release
@@ -82,6 +84,7 @@ release:
only: only:
- tags - tags
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
@@ -90,20 +93,16 @@ release:
# ==================== # ====================
codequality: codequality:
stage: metadata stage: metadata
image: docker:stable
allow_failure: true allow_failure: true
services: only:
- docker:stable-dind - tags
script: script:
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/') - npmci command npm install -g tslint typescript
- docker run - npmci npm prepare
--env SOURCE_CODE="$PWD" - npmci npm install
--volume "$PWD":/code - npmci command "tslint -c tslint.json ./ts/**/*.ts"
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
artifacts:
paths: [codeclimate.json]
tags: tags:
- lossless
- docker - docker
- priv - priv
@@ -114,18 +113,20 @@ trigger:
only: only:
- tags - tags
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
pages: pages:
image: hosttoday/ht-docker-node:npmci
stage: metadata stage: metadata
script: script:
- npmci command npm install -g typedoc typescript - npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare - npmci npm prepare
- npmci npm install - npmci npm install
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/ - npmci command tsdoc
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
only: only:
@@ -135,13 +136,3 @@ pages:
paths: paths:
- public - public
allow_failure: true allow_failure: true
windowsCompatibility:
image: stefanscherer/node-windows:10-build-tools
stage: metadata
script:
- npm install & npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- windows
allow_failure: true

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

@@ -0,0 +1,29 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "current file",
"type": "node",
"request": "launch",
"args": [
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
}
]
}

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"]
}
}
}
}
}
}
]
}

3
cli.js
View File

@@ -1,3 +1,4 @@
#!/usr/bin/env node #!/usr/bin/env node
process.env.CLI_CALL = 'true'; process.env.CLI_CALL = 'true';
require('./dist/index'); const cliTool = require('./dist_ts/index');
cliTool.runCli();

View File

@@ -1,4 +1,5 @@
#!/usr/bin/env node #!/usr/bin/env node
process.env.CLI_CALL = 'true'; process.env.CLI_CALL = 'true';
require('@gitzone/tsrun'); require('@gitzone/tsrun');
require('./ts/index'); const cliTool = require('./ts/index');
cliTool.runCli();

2
dist_ts/index.d.ts vendored Normal file
View File

@@ -0,0 +1,2 @@
export * from './tswatch.classes.tswatch';
export * from './tswatch.cli';

30
dist_ts/index.js Normal file
View File

@@ -0,0 +1,30 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
const early = __importStar(require("@pushrocks/early"));
early.start('tswatch');
__exportStar(require("./tswatch.classes.tswatch"), exports);
__exportStar(require("./tswatch.cli"), exports);
early.stop();
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSx3REFBMEM7QUFDMUMsS0FBSyxDQUFDLEtBQUssQ0FBQyxTQUFTLENBQUMsQ0FBQztBQUN2Qiw0REFBMEM7QUFDMUMsZ0RBQThCO0FBQzlCLEtBQUssQ0FBQyxJQUFJLEVBQUUsQ0FBQyJ9

1
dist_ts/interfaces/index.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export * from './interfaces.watchmodes';

View File

@@ -0,0 +1,14 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./interfaces.watchmodes"), exports);
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9pbnRlcmZhY2VzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7OztBQUFBLDBEQUF3QyJ9

View File

@@ -0,0 +1 @@
export declare type TWatchModes = 'test' | 'gitzone_npm' | 'gitzone_service' | 'gitzone_element' | 'gitzone_website' | 'echoSomething';

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50ZXJmYWNlcy53YXRjaG1vZGVzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vdHMvaW50ZXJmYWNlcy9pbnRlcmZhY2VzLndhdGNobW9kZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9

3
dist_ts/tswatch.classes.parcel.d.ts vendored Normal file
View File

@@ -0,0 +1,3 @@
export declare class Parcel {
start(): Promise<void>;
}

View File

@@ -0,0 +1,44 @@
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = __importStar(require("./tswatch.plugins"));
const paths = __importStar(require("./tswatch.paths"));
class Parcel {
async start() {
const entryFiles = plugins.path.join(paths.cwd, './html/index.html');
// Bundler options
const options = {
outDir: './dist_watch',
outFile: 'index.html',
publicUrl: '/',
watch: true,
cache: true,
cacheDir: '.nogit/.parcelcache',
contentHash: false,
global: 'moduleName',
minify: false,
scopeHoist: false,
target: 'browser',
bundleNodeModules: true,
https: null,
logLevel: 3,
hmr: true,
hmrPort: 3003,
sourceMaps: true,
hmrHostname: '',
detailedReport: false // Prints a detailed report of the bundles, assets, filesizes and times, defaults to false, reports are only printed if watch is disabled
};
const bundler = new plugins.parcel(entryFiles, options);
// Run the bundler, this returns the main bundle
// Use the events if you're using watch mode as this promise will only trigger once and not for every rebuild
const bundle = await bundler.serve(3002);
}
}
exports.Parcel = Parcel;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHN3YXRjaC5jbGFzc2VzLnBhcmNlbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3Rzd2F0Y2guY2xhc3Nlcy5wYXJjZWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7O0FBQUEsMkRBQTZDO0FBQzdDLHVEQUF5QztBQUV6QyxNQUFhLE1BQU07SUFDVixLQUFLLENBQUMsS0FBSztRQUNoQixNQUFNLFVBQVUsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUMsR0FBRyxFQUFFLG1CQUFtQixDQUFDLENBQUM7UUFFckUsa0JBQWtCO1FBQ2xCLE1BQU0sT0FBTyxHQUFpQztZQUM1QyxNQUFNLEVBQUUsY0FBYztZQUN0QixPQUFPLEVBQUUsWUFBWTtZQUNyQixTQUFTLEVBQUUsR0FBRztZQUNkLEtBQUssRUFBRSxJQUFJO1lBQ1gsS0FBSyxFQUFFLElBQUk7WUFDWCxRQUFRLEVBQUUscUJBQXFCO1lBQy9CLFdBQVcsRUFBRSxLQUFLO1lBQ2xCLE1BQU0sRUFBRSxZQUFZO1lBQ3BCLE1BQU0sRUFBRSxLQUFLO1lBQ2IsVUFBVSxFQUFFLEtBQUs7WUFDakIsTUFBTSxFQUFFLFNBQVM7WUFDakIsaUJBQWlCLEVBQUUsSUFBSTtZQUN2QixLQUFLLEVBQUUsSUFBSTtZQUNYLFFBQVEsRUFBRSxDQUFDO1lBQ1gsR0FBRyxFQUFFLElBQUk7WUFDVCxPQUFPLEVBQUUsSUFBSTtZQUNiLFVBQVUsRUFBRSxJQUFJO1lBQ2hCLFdBQVcsRUFBRSxFQUFFO1lBQ2YsY0FBYyxFQUFFLEtBQUssQ0FBQyx5SUFBeUk7U0FDaEssQ0FBQztRQUVGLE1BQU0sT0FBTyxHQUFHLElBQUksT0FBTyxDQUFDLE1BQU0sQ0FBQyxVQUFVLEVBQUUsT0FBTyxDQUFDLENBQUM7UUFFeEQsZ0RBQWdEO1FBQ2hELDZHQUE2RztRQUM3RyxNQUFNLE1BQU0sR0FBRyxNQUFNLE9BQU8sQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLENBQUM7SUFDM0MsQ0FBQztDQUNGO0FBakNELHdCQWlDQyJ9

17
dist_ts/tswatch.classes.tswatch.d.ts vendored Normal file
View File

@@ -0,0 +1,17 @@
import * as plugins from './tswatch.plugins';
import * as interfaces from './interfaces';
import { Watcher } from './tswatch.classes.watcher';
export declare class TsWatch {
watchmode: interfaces.TWatchModes;
watcherMap: plugins.lik.ObjectMap<Watcher>;
smartserve: plugins.smartserve.SmartServe;
constructor(watchmodeArg: interfaces.TWatchModes);
/**
* starts the TsWatch instance
*/
start(): Promise<void>;
/**
* stops the execution of any active Watchers
*/
stop(): Promise<void>;
}

View File

@@ -0,0 +1,104 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TsWatch = void 0;
const plugins = __importStar(require("./tswatch.plugins"));
const paths = __importStar(require("./tswatch.paths"));
const tswatch_classes_watcher_1 = require("./tswatch.classes.watcher");
class TsWatch {
constructor(watchmodeArg) {
this.watcherMap = new plugins.lik.ObjectMap();
this.watchmode = watchmodeArg;
}
/**
* starts the TsWatch instance
*/
async start() {
switch (this.watchmode) {
case 'test':
this.watcherMap.add(new tswatch_classes_watcher_1.Watcher({
filePathToWatch: paths.cwd,
commandToExecute: 'npm run test2',
timeout: null,
}));
break;
case 'gitzone_npm':
this.watcherMap.add(new tswatch_classes_watcher_1.Watcher({
filePathToWatch: paths.cwd,
commandToExecute: 'npm run test',
timeout: null,
}));
break;
case 'gitzone_element':
// lets create a standard server
console.log('bundling TypeScript files to "dist_watch" Note: This is for development only!');
const parcel = new plugins.smartparcel.Parcel(plugins.path.join(process.cwd(), './html/index.html'), plugins.path.join(process.cwd(), './dist_watch'), 'index.html');
await parcel.start();
break;
case 'gitzone_website':
this.watcherMap.add(new tswatch_classes_watcher_1.Watcher({
filePathToWatch: plugins.path.join(paths.cwd, './ts/'),
commandToExecute: 'npm run startTs',
timeout: null,
}));
// client directory
const parcelWebsite = new plugins.smartparcel.Parcel(plugins.path.join(process.cwd(), './ts_web/index.ts'), plugins.path.join(process.cwd(), './dist_serve'), 'bundle.js');
await parcelWebsite.start();
break;
case 'gitzone_service':
this.watcherMap.add(new tswatch_classes_watcher_1.Watcher({
filePathToWatch: plugins.path.join(paths.cwd, './ts/'),
commandToExecute: 'npm run startTs',
timeout: null,
}));
break;
case 'echoSomething':
const tsWatchInstanceEchoSomething = new tswatch_classes_watcher_1.Watcher({
filePathToWatch: plugins.path.join(paths.cwd, './ts'),
commandToExecute: 'npm -v',
timeout: null,
});
this.watcherMap.add(tsWatchInstanceEchoSomething);
break;
default:
break;
}
this.watcherMap.forEach(async (watcher) => {
await watcher.start();
});
if (this.smartserve) {
await this.smartserve.start();
}
}
/**
* stops the execution of any active Watchers
*/
async stop() {
if (this.smartserve) {
await this.smartserve.stop();
}
this.watcherMap.forEach(async (watcher) => {
await watcher.stop();
});
}
}
exports.TsWatch = TsWatch;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHN3YXRjaC5jbGFzc2VzLnRzd2F0Y2guanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy90c3dhdGNoLmNsYXNzZXMudHN3YXRjaC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsMkRBQTZDO0FBQzdDLHVEQUF5QztBQUd6Qyx1RUFBb0Q7QUFFcEQsTUFBYSxPQUFPO0lBS2xCLFlBQVksWUFBb0M7UUFIekMsZUFBVSxHQUFHLElBQUksT0FBTyxDQUFDLEdBQUcsQ0FBQyxTQUFTLEVBQVcsQ0FBQztRQUl2RCxJQUFJLENBQUMsU0FBUyxHQUFHLFlBQVksQ0FBQztJQUNoQyxDQUFDO0lBRUQ7O09BRUc7SUFDSSxLQUFLLENBQUMsS0FBSztRQUNoQixRQUFRLElBQUksQ0FBQyxTQUFTLEVBQUU7WUFDdEIsS0FBSyxNQUFNO2dCQUNULElBQUksQ0FBQyxVQUFVLENBQUMsR0FBRyxDQUNqQixJQUFJLGlDQUFPLENBQUM7b0JBQ1YsZUFBZSxFQUFFLEtBQUssQ0FBQyxHQUFHO29CQU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QztnQkFDbEQsTUFBTTtZQUNSO2dCQUNFLE1BQU07U0FDVDtRQUNELElBQUksQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLEtBQUssRUFBRSxPQUFPLEVBQUUsRUFBRTtZQUN4QyxNQUFNLE9BQU8sQ0FBQyxLQUFLLEVBQUUsQ0FBQztRQUN4QixDQUFDLENBQUMsQ0FBQztRQUNILElBQUksSUFBSSxDQUFDLFVBQVUsRUFBRTtZQUNuQixNQUFNLElBQUksQ0FBQyxVQUFVLENBQUMsS0FBSyxFQUFFLENBQUM7U0FDL0I7SUFDSCxDQUFDO0lBRUQ7O09BRUc7SUFDSSxLQUFLLENBQUMsSUFBSTtRQUNmLElBQUksSUFBSSxDQUFDLFVBQVUsRUFBRTtZQUNuQixNQUFNLElBQUksQ0FBQyxVQUFVLENBQUMsSUFBSSxFQUFFLENBQUM7U0FDOUI7UUFDRCxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxLQUFLLEVBQUUsT0FBTyxFQUFFLEVBQUU7WUFDeEMsTUFBTSxPQUFPLENBQUMsSUFBSSxFQUFFLENBQUM7UUFDdkIsQ0FBQyxDQUFDLENBQUM7SUFDTCxDQUFDO0NBQ0Y7QUFwR0QsMEJBb0dDIn0=

35
dist_ts/tswatch.classes.watcher.d.ts vendored Normal file
View File

@@ -0,0 +1,35 @@
export declare type TCommandFunction = () => Promise<void>;
export interface IWatcherConstructorOptions {
filePathToWatch: string;
commandToExecute: string | TCommandFunction;
timeout?: number;
}
/**
* A watcher keeps track of one child execution
*/
export declare class Watcher {
/**
* used to execute shell commands
*/
private smartshellInstance;
private currentExecution;
private smartchokWatcher;
private options;
constructor(optionsArg: IWatcherConstructorOptions);
/**
* start the file
*/
start(): Promise<void>;
/**
* updates the current execution
*/
private updateCurrentExecution;
/**
* this method sets up a clean exit strategy
*/
private setupCleanup;
/**
* stops the watcher
*/
stop(): Promise<void>;
}

View File

@@ -0,0 +1,107 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Watcher = void 0;
const plugins = __importStar(require("./tswatch.plugins"));
const tswatch_logging_1 = require("./tswatch.logging");
/**
* A watcher keeps track of one child execution
*/
class Watcher {
constructor(optionsArg) {
/**
* used to execute shell commands
*/
this.smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash',
});
this.smartchokWatcher = new plugins.smartchok.Smartchok([], {});
this.options = optionsArg;
}
/**
* start the file
*/
async start() {
await this.setupCleanup();
console.log(`Looking at ${this.options.filePathToWatch} for changes`);
this.smartchokWatcher.add([this.options.filePathToWatch]); // __dirname refers to the directory of this very file
await this.smartchokWatcher.start();
const changeObservable = await this.smartchokWatcher.getObservableFor('change');
changeObservable.subscribe(() => {
this.updateCurrentExecution();
});
await this.updateCurrentExecution();
}
/**
* updates the current execution
*/
async updateCurrentExecution() {
if (typeof this.options.commandToExecute === 'string') {
if (this.currentExecution) {
tswatch_logging_1.logger.log('ok', `reexecuting ${this.options.commandToExecute}`);
this.currentExecution.kill();
}
else {
tswatch_logging_1.logger.log('ok', `executing ${this.options.commandToExecute} for the first time`);
}
this.currentExecution = await this.smartshellInstance.execStreaming(this.options.commandToExecute);
}
else {
console.log('cannot run execution task');
}
}
/**
* this method sets up a clean exit strategy
*/
async setupCleanup() {
process.on('exit', () => {
console.log('');
console.log('now exiting!');
this.stop();
process.exit(0);
});
process.on('SIGINT', () => {
console.log('');
console.log('ok! got SIGINT We are exiting! Just cleaning up to exit neatly :)');
this.stop();
process.exit(0);
});
// handle timeout
if (this.options.timeout) {
plugins.smartdelay.delayFor(this.options.timeout).then(() => {
console.log(`timed out afer ${this.options.timeout} milliseconds! exiting!`);
this.stop();
process.exit(0);
});
}
}
/**
* stops the watcher
*/
async stop() {
await this.smartchokWatcher.stop();
if (this.currentExecution && !this.currentExecution.childProcess.killed) {
this.currentExecution.kill();
}
}
}
exports.Watcher = Watcher;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHN3YXRjaC5jbGFzc2VzLndhdGNoZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy90c3dhdGNoLmNsYXNzZXMud2F0Y2hlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsMkRBQTZDO0FBQzdDLHVEQUEyQztBQVUzQzs7R0FFRztBQUNILE1BQWEsT0FBTztJQVlsQixZQUFZLFVBQXNDO1FBWGxEOztXQUVHO1FBQ0ssdUJBQWtCLEdBQUcsSUFBSSxPQUFPLENBQUMsVUFBVSxDQUFDLFVBQVUsQ0FBQztZQUM3RCxRQUFRLEVBQUUsTUFBTTtTQUNqQixDQUFDLENBQUM7UUFHSyxxQkFBZ0IsR0FBRyxJQUFJLE9BQU8sQ0FBQyxTQUFTLENBQUMsU0FBUyxDQUFDLEVBQUUsRUFBRSxFQUFFLENBQUMsQ0FBQztRQUlqRSxJQUFJLENBQUMsT0FBTyxHQUFHLFVBQVUsQ0FBQztJQUM1QixDQUFDO0lBRUQ7O09BRUc7SUFDSSxLQUFLLENBQUMsS0FBSztRQUNoQixNQUFNLElBQUksQ0FBQyxZQUFZLEVBQUUsQ0FBQztRQUMxQixPQUFPLENBQUMsR0FBRyxD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TtnQkFDMUQsT0FBTyxDQUFDLEdBQUcsQ0FBQyxrQkFBa0IsSUFBSSxDQUFDLE9BQU8sQ0FBQyxPQUFPLHlCQUF5QixDQUFDLENBQUM7Z0JBQzdFLElBQUksQ0FBQyxJQUFJLEVBQUUsQ0FBQztnQkFDWixPQUFPLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxDQUFDO1lBQ2xCLENBQUMsQ0FBQyxDQUFDO1NBQ0o7SUFDSCxDQUFDO0lBRUQ7O09BRUc7SUFDSSxLQUFLLENBQUMsSUFBSTtRQUNmLE1BQU0sSUFBSSxDQUFDLGdCQUFnQixDQUFDLElBQUksRUFBRSxDQUFDO1FBQ25DLElBQUksSUFBSSxDQUFDLGdCQUFnQixJQUFJLENBQUMsSUFBSSxDQUFDLGdCQUFnQixDQUFDLFlBQVksQ0FBQyxNQUFNLEVBQUU7WUFDdkUsSUFBSSxDQUFDLGdCQUFnQixDQUFDLElBQUksRUFBRSxDQUFDO1NBQzlCO0lBQ0gsQ0FBQztDQUNGO0FBdEZELDBCQXNGQyJ9

1
dist_ts/tswatch.cli.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export declare const runCli: () => Promise<void>;

57
dist_ts/tswatch.cli.js Normal file
View File

@@ -0,0 +1,57 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.runCli = void 0;
const plugins = __importStar(require("./tswatch.plugins"));
const tswatch_logging_1 = require("./tswatch.logging");
const tswatch_classes_tswatch_1 = require("./tswatch.classes.tswatch");
const tswatchCli = new plugins.smartcli.Smartcli();
// standard behaviour will assume gitzone setup
tswatchCli.addCommand('element').subscribe(async (argvArg) => {
tswatch_logging_1.logger.log('info', `running watch task for a gitzone element project`);
const tsWatch = new tswatch_classes_tswatch_1.TsWatch('gitzone_element');
await tsWatch.start();
});
tswatchCli.addCommand('npm').subscribe(async (argvArg) => {
tswatch_logging_1.logger.log('info', `running watch task for a gitzone element project`);
const tsWatch = new tswatch_classes_tswatch_1.TsWatch('gitzone_npm');
await tsWatch.start();
});
tswatchCli.addCommand('service').subscribe(async (argvArg) => {
tswatch_logging_1.logger.log('info', `running test task`);
const tsWatch = new tswatch_classes_tswatch_1.TsWatch('gitzone_service');
await tsWatch.start();
});
tswatchCli.addCommand('test').subscribe(async (argvArg) => {
tswatch_logging_1.logger.log('info', `running test task`);
const tsWatch = new tswatch_classes_tswatch_1.TsWatch('test');
await tsWatch.start();
});
tswatchCli.addCommand('website').subscribe(async (argvArg) => {
tswatch_logging_1.logger.log('info', `running watch task for a gitzone website project`);
const tsWatch = new tswatch_classes_tswatch_1.TsWatch('gitzone_website');
await tsWatch.start();
});
const runCli = async () => {
tswatchCli.startParse();
};
exports.runCli = runCli;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHN3YXRjaC5jbGkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy90c3dhdGNoLmNsaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsMkRBQTZDO0FBRTdDLHVEQUEyQztBQUUzQyx1RUFBb0Q7QUFFcEQsTUFBTSxVQUFVLEdBQUcsSUFBSSxPQUFPLENBQUMsUU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FVBQVUsQ0FBQyxNQUFNLENBQUMsQ0FBQyxTQUFTLENBQUMsS0FBSyxFQUFFLE9BQU8sRUFBRSxFQUFFO0lBQ3hELHdCQUFNLENBQUMsR0FBRyxDQUFDLE1BQU0sRUFBRSxtQkFBbUIsQ0FBQyxDQUFDO0lBQ3hDLE1BQU0sT0FBTyxHQUFHLElBQUksaUNBQU8sQ0FBQyxNQUFNLENBQUMsQ0FBQztJQUNwQyxNQUFNLE9BQU8sQ0FBQyxLQUFLLEVBQUUsQ0FBQztBQUN4QixDQUFDLENBQUMsQ0FBQztBQUVILFVBQVUsQ0FBQyxVQUFVLENBQUMsU0FBUyxDQUFDLENBQUMsU0FBUyxDQUFDLEtBQUssRUFBRSxPQUFPLEVBQUUsRUFBRTtJQUMzRCx3QkFBTSxDQUFDLEdBQUcsQ0FBQyxNQUFNLEVBQUUsa0RBQWtELENBQUMsQ0FBQztJQUN2RSxNQUFNLE9BQU8sR0FBRyxJQUFJLGlDQUFPLENBQUMsaUJBQWlCLENBQUMsQ0FBQztJQUMvQyxNQUFNLE9BQU8sQ0FBQyxLQUFLLEVBQUUsQ0FBQztBQUN4QixDQUFDLENBQUMsQ0FBQztBQUVJLE1BQU0sTUFBTSxHQUFHLEtBQUssSUFBSSxFQUFFO0lBQy9CLFVBQVUsQ0FBQyxVQUFVLEVBQUUsQ0FBQztBQUMxQixDQUFDLENBQUM7QUFGVyxRQUFBLE1BQU0sVUFFakIifQ==

2
dist_ts/tswatch.logging.d.ts vendored Normal file
View File

@@ -0,0 +1,2 @@
import * as plugins from './tswatch.plugins';
export declare const logger: plugins.smartlog.Smartlog;

View File

@@ -0,0 +1,36 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.logger = void 0;
const plugins = __importStar(require("./tswatch.plugins"));
exports.logger = new plugins.smartlog.Smartlog({
logContext: {
company: 'Some Company',
companyunit: 'Some CompanyUnit',
containerName: 'Some Containername',
environment: 'local',
runtime: 'node',
zone: 'gitzone',
},
minimumLogLevel: 'silly',
});
exports.logger.addLogDestination(new plugins.smartlogDestinationLocal.DestinationLocal());
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHN3YXRjaC5sb2dnaW5nLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvdHN3YXRjaC5sb2dnaW5nLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSwyREFBNkM7QUFFaEMsUUFBQSxNQUFNLEdBQUcsSUFBSSxPQUFPLENBQUMsUUFBUSxDQUFDLFFBQVEsQ0FBQztJQUNsRCxVQUFVLEVBQUU7UUFDVixPQUFPLEVBQUUsY0FBYztRQUN2QixXQUFXLEVBQUUsa0JBQWtCO1FBQy9CLGFBQWEsRUFBRSxvQkFBb0I7UUFDbkMsV0FBVyxFQUFFLE9BQU87UUFDcEIsT0FBTyxFQUFFLE1BQU07UUFDZixJQUFJLEVBQUUsU0FBUztLQUNoQjtJQUNELGVBQWUsRUFBRSxPQUFPO0NBQ3pCLENBQUMsQ0FBQztBQUVILGNBQU0sQ0FBQyxpQkFBaUIsQ0FBQyxJQUFJLE9BQU8sQ0FBQyx3QkFBd0IsQ0FBQyxnQkFBZ0IsRUFBRSxDQUFDLENBQUMifQ==

1
dist_ts/tswatch.paths.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export declare const cwd: string;

5
dist_ts/tswatch.paths.js Normal file
View File

@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.cwd = void 0;
exports.cwd = process.cwd();
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHN3YXRjaC5wYXRocy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3Rzd2F0Y2gucGF0aHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBRWEsUUFBQSxHQUFHLEdBQUcsT0FBTyxDQUFDLEdBQUcsRUFBRSxDQUFDIn0=

13
dist_ts/tswatch.plugins.d.ts vendored Normal file
View File

@@ -0,0 +1,13 @@
import * as path from 'path';
export { path };
import * as lik from '@pushrocks/lik';
import * as smartchok from '@pushrocks/smartchok';
import * as smartcli from '@pushrocks/smartcli';
import * as smartdelay from '@pushrocks/smartdelay';
import * as smartlog from '@pushrocks/smartlog';
import * as smartlogDestinationLocal from '@pushrocks/smartlog-destination-local';
import * as smartparcel from '@pushrocks/smartparcel';
import * as smartserve from '@pushrocks/smartserve';
import * as smartshell from '@pushrocks/smartshell';
import * as taskbuffer from '@pushrocks/taskbuffer';
export { lik, smartchok, smartcli, smartdelay, smartlog, smartlogDestinationLocal, smartparcel, smartserve, smartshell, taskbuffer, };

View File

@@ -0,0 +1,46 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.taskbuffer = exports.smartshell = exports.smartserve = exports.smartparcel = exports.smartlogDestinationLocal = exports.smartlog = exports.smartdelay = exports.smartcli = exports.smartchok = exports.lik = exports.path = void 0;
const path = __importStar(require("path"));
exports.path = path;
// @pushrocks scope
const lik = __importStar(require("@pushrocks/lik"));
exports.lik = lik;
const smartchok = __importStar(require("@pushrocks/smartchok"));
exports.smartchok = smartchok;
const smartcli = __importStar(require("@pushrocks/smartcli"));
exports.smartcli = smartcli;
const smartdelay = __importStar(require("@pushrocks/smartdelay"));
exports.smartdelay = smartdelay;
const smartlog = __importStar(require("@pushrocks/smartlog"));
exports.smartlog = smartlog;
const smartlogDestinationLocal = __importStar(require("@pushrocks/smartlog-destination-local"));
exports.smartlogDestinationLocal = smartlogDestinationLocal;
const smartparcel = __importStar(require("@pushrocks/smartparcel"));
exports.smartparcel = smartparcel;
const smartserve = __importStar(require("@pushrocks/smartserve"));
exports.smartserve = smartserve;
const smartshell = __importStar(require("@pushrocks/smartshell"));
exports.smartshell = smartshell;
const taskbuffer = __importStar(require("@pushrocks/taskbuffer"));
exports.taskbuffer = taskbuffer;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHN3YXRjaC5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvdHN3YXRjaC5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSwyQ0FBNkI7QUFDcEIsb0JBQUk7QUFFYixtQkFBbUI7QUFDbkIsb0RBQXNDO0FBWXBDLGtCQUFHO0FBWEwsZ0VBQWtEO0FBWWhELDhCQUFTO0FBWFgsOERBQWdEO0FBWTlDLDRCQUFRO0FBWFYsa0VBQW9EO0FBWWxELGdDQUFVO0FBWFosOERBQWdEO0FBWTlDLDRCQUFRO0FBWFYsZ0dBQWtGO0FBWWhGLDREQUF3QjtBQVgxQixvRUFBc0Q7QUFZcEQsa0NBQVc7QUFYYixrRUFBb0Q7QUFZbEQsZ0NBQVU7QUFYWixrRUFBb0Q7QUFZbEQsZ0NBQVU7QUFYWixrRUFBb0Q7QUFZbEQsZ0NBQVUifQ==

View File

@@ -2,5 +2,16 @@
"npmci": { "npmci": {
"npmGlobalTools": [], "npmGlobalTools": [],
"npmAccessLevel": "public" "npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "gitzone",
"gitrepo": "tswatch",
"shortDescription": "watch typescript projects during development",
"npmPackagename": "@gitzone/tswatch",
"license": "MIT"
}
} }
} }

25091
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,30 +1,54 @@
{ {
"name": "@gitzone/tswatch", "name": "@gitzone/tswatch",
"version": "1.0.5", "version": "1.0.56",
"private": false, "private": false,
"description": "watch typescript projects during development", "description": "watch typescript projects during development",
"main": "dist/index.js", "main": "dist_ts/index.js",
"typings": "dist/index.d.ts", "typings": "dist_ts/index.d.ts",
"author": "Lossless GmbH", "author": "Lossless GmbH",
"license": "MIT", "license": "MIT",
"bin": {
"tswatch": "cli.js"
},
"scripts": { "scripts": {
"test": "node ./cli.ts.js test --timeout 10000", "test": "(tstest test/ --web)",
"test2": "(tstest test/)", "build": "(tsbuild --web)"
"build": "(tsbuild)",
"format": "(gitzone format)"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.11", "@gitzone/tsbuild": "^2.1.26",
"@gitzone/tstest": "^1.0.20", "@gitzone/tstest": "^1.0.54",
"@pushrocks/tapbundle": "^3.0.9", "@pushrocks/tapbundle": "^3.2.1",
"@types/node": "^12.0.0", "@types/node": "^16.6.1",
"tslint": "^5.16.0", "tslint": "^6.1.2",
"tslint-config-prettier": "^1.18.0" "tslint-config-prettier": "^1.18.0"
}, },
"dependencies": { "dependencies": {
"@gitzone/tsrun": "^1.2.6", "@gitzone/tsrun": "^1.2.17",
"@pushrocks/smartcli": "^3.0.7", "@pushrocks/early": "^3.0.3",
"@pushrocks/smartdelay": "^2.0.3", "@pushrocks/lik": "^4.0.13",
"@pushrocks/smartshell": "^2.0.13" "@pushrocks/smartchok": "^1.0.23",
} "@pushrocks/smartcli": "^3.0.14",
"@pushrocks/smartdelay": "^2.0.13",
"@pushrocks/smartlog": "^2.0.44",
"@pushrocks/smartlog-destination-local": "^8.0.8",
"@pushrocks/smartparcel": "^1.0.9",
"@pushrocks/smartserve": "^1.1.41",
"@pushrocks/smartshell": "^2.0.28",
"@pushrocks/taskbuffer": "^2.1.1"
},
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
]
} }

39
readme.md Normal file
View File

@@ -0,0 +1,39 @@
# @gitzone/tswatch
watch typescript projects during development
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@gitzone/tswatch)
* [gitlab.com (source)](https://gitlab.com/gitzone/tswatch)
* [github.com (source mirror)](https://github.com/gitzone/tswatch)
* [docs (typedoc)](https://gitzone.gitlab.io/tswatch/)
## Status for master
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/gitzone/tswatch/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/gitzone/tswatch/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@gitzone/tswatch)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/gitzone/tswatch)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@gitzone/tswatch)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@gitzone/tswatch)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@gitzone/tswatch)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
## Usage
Use TypeScript for best in class intellisense
## Contribution
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
For further information read the linked docs at the top of this readme.
> MIT licensed | **&copy;** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

View File

@@ -1,23 +1,20 @@
// tslint:disable-next-line: no-implicit-dependencies
import { expect, tap } from '@pushrocks/tapbundle'; import { expect, tap } from '@pushrocks/tapbundle';
import * as tswatch from '../ts/index'; import * as tswatch from '../ts/index';
let testTsWatchInstance: tswatch.TsWatch; let testTsWatchInstance: tswatch.TsWatch;
tap.test('should create a valid TsWatch instance', async () => { tap.test('should create a valid TsWatch instance', async () => {
testTsWatchInstance = new tswatch.TsWatch({ testTsWatchInstance = new tswatch.TsWatch('echoSomething');
filePathToWatch: process.cwd(),
commandToExecute: 'npm -v',
timeout: 1000
});
}); });
tap.test('should start the tswatch instance', async () => { tap.test('should start the tswatch instance', async () => {
testTsWatchInstance.start(); await testTsWatchInstance.start();
console.log('test executed');
}); });
tap.test('should run abitrary commands', async () => { tap.test('should stop the instance', async (tools) => {
tools.delayFor(2000);
testTsWatchInstance.stop();
}); });
tap.start(); tap.start();

View File

@@ -1,3 +1,5 @@
import * as early from '@pushrocks/early';
early.start('tswatch');
export * from './tswatch.classes.tswatch'; export * from './tswatch.classes.tswatch';
export * from './tswatch.cli';
import './tswatch.cli'; early.stop();

1
ts/interfaces/index.ts Normal file
View File

@@ -0,0 +1 @@
export * from './interfaces.watchmodes';

View File

@@ -0,0 +1,7 @@
export type TWatchModes =
| 'test'
| 'gitzone_npm'
| 'gitzone_service'
| 'gitzone_element'
| 'gitzone_website'
| 'echoSomething';

View File

@@ -1,80 +1,107 @@
import * as plugins from './tswatch.plugins'; import * as plugins from './tswatch.plugins';
import * as paths from './tswatch.paths';
import * as interfaces from './interfaces';
export interface ITsWatchConstructorOptions { import { Watcher } from './tswatch.classes.watcher';
filePathToWatch: string;
commandToExecute: string;
timeout?: number;
}
/**
* handles the management of watching for foes
*/
export class TsWatch { export class TsWatch {
private smartshellInstance = new plugins.smartshell.Smartshell({ public watchmode: interfaces.TWatchModes;
executor: 'bash' public watcherMap = new plugins.lik.ObjectMap<Watcher>();
}); public smartserve: plugins.smartserve.SmartServe;
private currentExecution: plugins.smartshell.IExecResultStreaming;
private watcher;
private options: ITsWatchConstructorOptions;
constructor(optionsArg: ITsWatchConstructorOptions) { constructor(watchmodeArg: interfaces.TWatchModes) {
this.options = optionsArg; this.watchmode = watchmodeArg;
} }
/** /**
* start the file * starts the TsWatch instance
*/ */
public async start() { public async start() {
this.setupCleanup(); switch (this.watchmode) {
console.log(`Looking at ${this.options.filePathToWatch} for changes`); case 'test':
this.watcher.add(this.options.filePathToWatch); // __dirname refers to the directory of this very file this.watcherMap.add(
this.watcher.on('change', async (file, stat) => { new Watcher({
console.log('Noticed change!'); filePathToWatch: paths.cwd,
if (!stat) { commandToExecute: 'npm run test2',
console.log('deleted'); timeout: null,
} })
this.updateCurrentExecution(); );
}); break;
this.updateCurrentExecution(); case 'gitzone_npm':
} this.watcherMap.add(
new Watcher({
filePathToWatch: paths.cwd,
commandToExecute: 'npm run test',
timeout: null,
})
);
break;
case 'gitzone_element':
// lets create a standard server
console.log(
'bundling TypeScript files to "dist_watch" Note: This is for development only!'
);
const parcel = new plugins.smartparcel.Parcel(
plugins.path.join(process.cwd(), './html/index.html'),
plugins.path.join(process.cwd(), './dist_watch'),
'index.html'
);
await parcel.start();
break;
case 'gitzone_website':
this.watcherMap.add(
new Watcher({
filePathToWatch: plugins.path.join(paths.cwd, './ts/'),
commandToExecute: 'npm run startTs',
timeout: null,
})
);
private async updateCurrentExecution() { // client directory
if (this.currentExecution) { const parcelWebsite = new plugins.smartparcel.Parcel(
process.kill(-this.currentExecution.childProcess.pid); plugins.path.join(process.cwd(), './ts_web/index.ts'),
plugins.path.join(process.cwd(), './dist_serve'),
'bundle.js'
);
await parcelWebsite.start();
break;
case 'gitzone_service':
this.watcherMap.add(
new Watcher({
filePathToWatch: plugins.path.join(paths.cwd, './ts/'),
commandToExecute: 'npm run startTs',
timeout: null,
})
);
break;
case 'echoSomething':
const tsWatchInstanceEchoSomething = new Watcher({
filePathToWatch: plugins.path.join(paths.cwd, './ts'),
commandToExecute: 'npm -v',
timeout: null,
});
this.watcherMap.add(tsWatchInstanceEchoSomething);
break;
default:
break;
}
this.watcherMap.forEach(async (watcher) => {
await watcher.start();
});
if (this.smartserve) {
await this.smartserve.start();
} }
this.currentExecution = await this.smartshellInstance.execStreaming(this.options.commandToExecute);
this.currentExecution = null;
} }
/** /**
* this method sets up a clean exit strategy * stops the execution of any active Watchers
*/ */
private async setupCleanup() { public async stop() {
const cleanup = () => { if (this.smartserve) {
if (this.currentExecution) { await this.smartserve.stop();
process.kill(-this.currentExecution.childProcess.pid);
} }
}; this.watcherMap.forEach(async (watcher) => {
process.on('exit', () => { await watcher.stop();
console.log('');
console.log('now exiting!');
cleanup();
process.exit(0);
});
process.on('SIGINT', () => {
console.log('');
console.log('ok! got SIGINT We are exiting! Just cleaning up to exit neatly :)');
cleanup();
process.exit(0);
});
// handle timeout
if (this.options.timeout) {
plugins.smartdelay.delayFor(this.options.timeout).then(() => {
console.log(`timed out afer ${this.options.timeout} milliseconds! exiting!`);
cleanup();
process.exit(0);
}); });
} }
} }
}

View File

@@ -0,0 +1,101 @@
import * as plugins from './tswatch.plugins';
import { logger } from './tswatch.logging';
export type TCommandFunction = () => Promise<void>;
export interface IWatcherConstructorOptions {
filePathToWatch: string;
commandToExecute: string | TCommandFunction;
timeout?: number;
}
/**
* A watcher keeps track of one child execution
*/
export class Watcher {
/**
* used to execute shell commands
*/
private smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash',
});
private currentExecution: plugins.smartshell.IExecResultStreaming;
private smartchokWatcher = new plugins.smartchok.Smartchok([], {});
private options: IWatcherConstructorOptions;
constructor(optionsArg: IWatcherConstructorOptions) {
this.options = optionsArg;
}
/**
* start the file
*/
public async start() {
await this.setupCleanup();
console.log(`Looking at ${this.options.filePathToWatch} for changes`);
this.smartchokWatcher.add([this.options.filePathToWatch]); // __dirname refers to the directory of this very file
await this.smartchokWatcher.start();
const changeObservable = await this.smartchokWatcher.getObservableFor('change');
changeObservable.subscribe(() => {
this.updateCurrentExecution();
});
await this.updateCurrentExecution();
}
/**
* updates the current execution
*/
private async updateCurrentExecution() {
if (typeof this.options.commandToExecute === 'string') {
if (this.currentExecution) {
logger.log('ok', `reexecuting ${this.options.commandToExecute}`);
this.currentExecution.kill();
} else {
logger.log('ok', `executing ${this.options.commandToExecute} for the first time`);
}
this.currentExecution = await this.smartshellInstance.execStreaming(
this.options.commandToExecute
);
} else {
console.log('cannot run execution task');
}
}
/**
* this method sets up a clean exit strategy
*/
private async setupCleanup() {
process.on('exit', () => {
console.log('');
console.log('now exiting!');
this.stop();
process.exit(0);
});
process.on('SIGINT', () => {
console.log('');
console.log('ok! got SIGINT We are exiting! Just cleaning up to exit neatly :)');
this.stop();
process.exit(0);
});
// handle timeout
if (this.options.timeout) {
plugins.smartdelay.delayFor(this.options.timeout).then(() => {
console.log(`timed out afer ${this.options.timeout} milliseconds! exiting!`);
this.stop();
process.exit(0);
});
}
}
/**
* stops the watcher
*/
public async stop() {
await this.smartchokWatcher.stop();
if (this.currentExecution && !this.currentExecution.childProcess.killed) {
this.currentExecution.kill();
}
}
}

View File

@@ -1,24 +1,43 @@
import * as plugins from './tswatch.plugins'; import * as plugins from './tswatch.plugins';
import * as paths from './tswatch.paths'; import * as paths from './tswatch.paths';
import { logger } from './tswatch.logging';
import { TsWatch } from './tswatch.classes.tswatch'; import { TsWatch } from './tswatch.classes.tswatch';
const tswatchCli = new plugins.smartcli.Smartcli(); const tswatchCli = new plugins.smartcli.Smartcli();
tswatchCli.addCommand('test').subscribe(argvArg => { // standard behaviour will assume gitzone setup
const tsWatch = new TsWatch({
filePathToWatch: paths.cwd, tswatchCli.addCommand('element').subscribe(async (argvArg) => {
commandToExecute: 'npm run test2', logger.log('info', `running watch task for a gitzone element project`);
timeout: (() => { const tsWatch = new TsWatch('gitzone_element');
if (argvArg.timeout) { await tsWatch.start();
console.log(`timeing out after ${argvArg.timeout}`);
return argvArg.timeout;
} else {
return null;
}
})()
});
tsWatch.start();
}); });
tswatchCli.addCommand('npm').subscribe(async (argvArg) => {
logger.log('info', `running watch task for a gitzone element project`);
const tsWatch = new TsWatch('gitzone_npm');
await tsWatch.start();
});
tswatchCli.addCommand('service').subscribe(async (argvArg) => {
logger.log('info', `running test task`);
const tsWatch = new TsWatch('gitzone_service');
await tsWatch.start();
});
tswatchCli.addCommand('test').subscribe(async (argvArg) => {
logger.log('info', `running test task`);
const tsWatch = new TsWatch('test');
await tsWatch.start();
});
tswatchCli.addCommand('website').subscribe(async (argvArg) => {
logger.log('info', `running watch task for a gitzone website project`);
const tsWatch = new TsWatch('gitzone_website');
await tsWatch.start();
});
export const runCli = async () => {
tswatchCli.startParse(); tswatchCli.startParse();
};

15
ts/tswatch.logging.ts Normal file
View File

@@ -0,0 +1,15 @@
import * as plugins from './tswatch.plugins';
export const logger = new plugins.smartlog.Smartlog({
logContext: {
company: 'Some Company',
companyunit: 'Some CompanyUnit',
containerName: 'Some Containername',
environment: 'local',
runtime: 'node',
zone: 'gitzone',
},
minimumLogLevel: 'silly',
});
logger.addLogDestination(new plugins.smartlogDestinationLocal.DestinationLocal());

View File

@@ -2,13 +2,26 @@ import * as path from 'path';
export { path }; export { path };
// @pushrocks scope // @pushrocks scope
import * as lik from '@pushrocks/lik';
import * as smartchok from '@pushrocks/smartchok';
import * as smartcli from '@pushrocks/smartcli'; import * as smartcli from '@pushrocks/smartcli';
import * as smartdelay from '@pushrocks/smartdelay'; import * as smartdelay from '@pushrocks/smartdelay';
import * as smartlog from '@pushrocks/smartlog';
import * as smartlogDestinationLocal from '@pushrocks/smartlog-destination-local';
import * as smartparcel from '@pushrocks/smartparcel';
import * as smartserve from '@pushrocks/smartserve';
import * as smartshell from '@pushrocks/smartshell'; import * as smartshell from '@pushrocks/smartshell';
import * as taskbuffer from '@pushrocks/taskbuffer';
export { smartdelay, smartshell, smartcli }; export {
lik,
// Third Pary smartchok,
import * as fileWatcher from 'filewatcher'; smartcli,
smartdelay,
export { fileWatcher }; smartlog,
smartlogDestinationLocal,
smartparcel,
smartserve,
smartshell,
taskbuffer,
};

View File

@@ -4,7 +4,14 @@
"semicolon": [true, "always"], "semicolon": [true, "always"],
"no-console": false, "no-console": false,
"ordered-imports": false, "ordered-imports": false,
"object-literal-sort-keys": false "object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
}, },
"defaultSeverity": "warning" "defaultSeverity": "warning"
} }