Skip to content

Commit

Permalink
refactor: replace rxjs from cli
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Smart committed Apr 6, 2022
1 parent 36e388e commit aa0a6f1
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 20 deletions.
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@oclif/plugin-help": "^3.2.0",
"chokidar": "^3.4.3",
"js-yaml": "^4.0.0",
"rxjs": "^7.3.0",
"strict-callbag-basics": "^0.25.0",
"ts-node": "^10.4.0",
"tslib": "^2.0.3",
"typescript": "^4.2.3"
Expand Down
32 changes: 13 additions & 19 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import * as TSNode from "ts-node";
TSNode.register({ transpileOnly: true });

import { availableFormats, generate } from "@fpk/core";
import { Command, flags } from "@oclif/command";
import { watch } from "chokidar";
import { promises as fs } from "fs";
import * as Yaml from "js-yaml";
import * as path from "path";
import { watch } from "chokidar";
import * as Rx from "rxjs";
import * as RxOp from "rxjs/operators";
import * as CB from "strict-callbag-basics";
import * as TSNode from "ts-node";

TSNode.register({ transpileOnly: true });

export default class FpkCli extends Command {
static description = "Generate configuration from an fpk config tree";
Expand Down Expand Up @@ -95,19 +94,14 @@ export default class FpkCli extends Command {
await generator();

if (flags.watch) {
Rx.fromEvent(
watch(flags.source, {
ignoreInitial: true,
}),
"all",
)
.pipe(
RxOp.tap((e: any) => console.log("WATCH", e.slice(0, 2))),
RxOp.auditTime(200),
RxOp.tap(resetCache),
RxOp.concatMap(() => Rx.from(generator())),
)
.subscribe();
CB.pipe(
CB.fromEventP(watch(flags.source, { ignoreInitial: true }), "all"),
CB.tap((e: any) => console.log("WATCH", e.slice(0, 2))),
CB.auditTimeP(200),
CB.tap(resetCache),
CB.chain(() => CB.fromPromise_(generator, (e) => e)),
CB.run_,
);

console.log("WATCH", "Started");
}
Expand Down
143 changes: 143 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,111 @@ call-bind@^1.0.0, call-bind@^1.0.2:
function-bind "^1.1.1"
get-intrinsic "^1.0.2"

callbag-buffer-time@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/callbag-buffer-time/-/callbag-buffer-time-1.0.0.tgz#32c0f3165460ff9d76b80ffa2c6c6ed4f392f422"
integrity sha512-Y9XqJWqs0M9gTvn8jQit+pXDYxrzh7KqIgN9MhwT5NzQGgEACSCzYKQpjT6p9ejfnimFjHWQC9+bifjIKnKxDQ==
dependencies:
callbag-buffer "^1.0.0"
callbag-interval "^1.0.0"

callbag-buffer@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/callbag-buffer/-/callbag-buffer-1.0.0.tgz#797f07b781591f03821e3c7ed0ddf837d128238b"
integrity sha512-o2QIDeWbwSoBxI7oC9WABNRX38J4N+oCH9vbAvte1jssbie/kaRG/X4fBeGoMsocR4wYNk23NTn3DMqY+C5fgA==

callbag-concat@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/callbag-concat/-/callbag-concat-1.2.1.tgz#3b10bcc5a7cbbcba3bdf1c46136e5d16f36291bd"
integrity sha512-iIC4FCUF7sKnt4gDKHNjMRHekebdaA1/udjON/mCLg31EzzTO/dE9nfxpcj+G/63KopFXVQdZKQDsu7UOYGpPg==
dependencies:
callbag "^1.2.0"

callbag-filter@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/callbag-filter/-/callbag-filter-1.1.0.tgz#d3116bf839702e859ee7e76eb9525925a6bff8b3"
integrity sha512-m6ZHEd9JYHBAYJAdeqgt3gIKSoZOizfJTxIPd8EvDwY8Dr44+slm090WvCrrlz2SZoU8mCqpmZ8TFrGKXHo/yw==
dependencies:
callbag "^1.1.0"

callbag-flatten@^1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/callbag-flatten/-/callbag-flatten-1.7.0.tgz#5edb7c0b59f8eafdcb3e5ffb34505ace423fa6e2"
integrity sha512-1nekVS5GwI38CRcIzmLFRFmXeoHkLG/SkUAwwvarwL4srmHW994UzFAcwwQbZjI9gudqfVDvY+LnopNb4Dtc4w==
dependencies:
callbag "^1.1.0"

callbag-from-iter@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/callbag-from-iter/-/callbag-from-iter-1.3.0.tgz#6757c1de9f8558b877546d475e3082823662c54c"
integrity sha512-iBc6O6DYDWQBjlOZzdU/SbJofK0pN3TjNWC4fDIQePBk5FWCZKVll/coXiVU6gpwbBaS0Om/d/PVbVK8Ki17Ew==
dependencies:
callbag "^1.2.0"

callbag-from-obs@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/callbag-from-obs/-/callbag-from-obs-1.2.0.tgz#f092f302f302b53abaf1a4d7a5393f9a65fac517"
integrity sha512-InhdPC6P4Gdpg7nuXSkocDFlb+//sbwCrVCYhxOHhSVm1gDcw/zSA+IF1gHdYtk4RQKKaCymUFCkVVUVSRThVQ==
dependencies:
symbol-observable "^1.2.0"

callbag-interval@^1.0.0, callbag-interval@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/callbag-interval/-/callbag-interval-1.2.0.tgz#9b1e1ebbbaa46999d77dabff1acb26889fe3ad2b"
integrity sha512-jo2UQZ+vvGWvCCykqKzL7ixSoTmvzDysQGTQkI3qQF28weRSMSmH5k86qmm7ddfPW1yNczcL93uhGnWC5e34Og==
dependencies:
callbag "^1.1.0"

callbag-map@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/callbag-map/-/callbag-map-1.1.0.tgz#6ddd28a3f634fbd2394ef136a181b4ba5e3b062c"
integrity sha512-/xFzvJCtx1xulZpFeI4wq+ZD7tkg417XOeJ3wS9v8bHLLpt+fHKXgbZ8TBnnIxywJN6Uu/ZhL+c1DzUG6KXYFQ==
dependencies:
callbag "^1.1.0"

callbag-scan@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/callbag-scan/-/callbag-scan-1.1.0.tgz#09e5bea479b849d51c0087be81a28044f9c5ddf3"
integrity sha512-5Aw9LR8b4Fg/gC++lWrq9sXEqgO0c5Gk+HWaFhFoVqgujSUVRxFw+c4bLw1eExWrBX6OeBDbVZ/2rMr/E0q9cQ==
dependencies:
callbag "^1.1.0"

callbag-share@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/callbag-share/-/callbag-share-1.3.0.tgz#4284f7c13f83b0888b246c13fa099ef6ce7c4e45"
integrity sha512-KqM16UzlvK3DcYRsT6Myabm4GqvsMQIoGLWmawVVoMAw3534O0XCa+6Sai0mjFKenC3tqTacyChlusoZoZmdsg==
dependencies:
callbag "^1.1.0"

callbag-start-with@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/callbag-start-with/-/callbag-start-with-3.1.0.tgz#58c7f7cb3f3f44049e130166c2cf884c76e332ac"
integrity sha512-jeEvUoZqZj8ZVMgST7ci9wCH33e9vaARQCFrPy/8et0HYL6RNzgwi3BmfcIy63d6vpqGbciYex/3T4TiFxGgyA==

callbag-take-while@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/callbag-take-while/-/callbag-take-while-2.0.0.tgz#2b6e4a69fab13862b9a067c01c9441ec66b1fc80"
integrity sha512-c6nnV14Xh/QEzkD6dgFSitMs0moh4ejF0zSf5SyHxNZdOjJtO+B9G9FKH7GCKPI9q485sjJ51/WcZLCloY1RdA==
dependencies:
callbag "^1.1.0"

callbag-take@^1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/callbag-take/-/callbag-take-1.5.0.tgz#3062b42f8ed4ed7e021d2cd1306c029d2ef4a12d"
integrity sha512-8aOxp+gzfVQtDe+tk9PhKbC9QR9Vap4KFA0xccUiXFK9VjIS0fSt/Yi454viPpMhJkhRcx1BsjyF34Cj57W89A==
dependencies:
callbag "^1.1.0"

callbag-to-async-iterable@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/callbag-to-async-iterable/-/callbag-to-async-iterable-1.0.0.tgz#d2ed65831a91e4ed9e23b4a37187370b9fad3cb8"
integrity sha512-+N53OaDKIq/LfZf20IkoiltbYx/8RI6d+j8A9vaYP5/VsoxXFKscz9Mz6JaBprb1I/PVq1b9CKOrTe7ESxiPVw==

callbag@^1.1.0, callbag@^1.2.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/callbag/-/callbag-1.5.0.tgz#b9d0be57e979c39d1616280320a4d3636f08c9e9"
integrity sha512-PH3id0HEb/cNS+BehYlF4Z5wzjKAIUao6ab2hWtMs2bi6aW+0PXl0jymqwnFyT2cQO2h30ggUgpQlmzOpAIKNg==

callsites@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73"
Expand Down Expand Up @@ -4735,6 +4840,34 @@ ssri@^8.0.0, ssri@^8.0.1:
dependencies:
minipass "^3.1.1"

strict-callbag-basics@^0.25.0:
version "0.25.0"
resolved "https://registry.yarnpkg.com/strict-callbag-basics/-/strict-callbag-basics-0.25.0.tgz#bd4596b0031604c1927727d8c0044dcd5fc9d0c9"
integrity sha512-AhIaxOOA0upuZrdvBBZKNx4dx7oPkIYzfne2OyNorjW9wc0HcOwCtB+ZQRTJxul7wsN2kb+fW9Gyz6oR0f5H9Q==
dependencies:
callbag-buffer "^1.0.0"
callbag-buffer-time "^1.0.0"
callbag-concat "^1.2.1"
callbag-filter "^1.1.0"
callbag-flatten "^1.7.0"
callbag-from-iter "^1.3.0"
callbag-from-obs "^1.2.0"
callbag-interval "^1.2.0"
callbag-map "^1.1.0"
callbag-scan "^1.1.0"
callbag-share "^1.3.0"
callbag-start-with "^3.1.0"
callbag-take "^1.5.0"
callbag-take-while "^2.0.0"
callbag-to-async-iterable "^1.0.0"
strict-callbag "^0.9.0"
symbol-observable "^4.0.0"

strict-callbag@^0.9.0:
version "0.9.2"
resolved "https://registry.yarnpkg.com/strict-callbag/-/strict-callbag-0.9.2.tgz#5f8538c8aa9bc35d4fd4b4f7c4eb1f067181bc34"
integrity sha512-0w+G27Yfa2PylOu0ImX+9U/oTk/phAHmTkgsii5WSEdY6KoCPE6/k8Y7TBMkHyOJPHOlM73NzM0K3bEYO7zkEg==

strict-uri-encode@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546"
Expand Down Expand Up @@ -4890,6 +5023,16 @@ supports-preserve-symlinks-flag@^1.0.0:
resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09"
integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==

symbol-observable@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804"
integrity sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==

symbol-observable@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-4.0.0.tgz#5b425f192279e87f2f9b937ac8540d1984b39205"
integrity sha512-b19dMThMV4HVFynSAM1++gBHAbk2Tc/osgLIBZMKsyqh34jb2e8Os7T6ZW/Bt3pJFdBTd2JwAnAAEQV7rSNvcQ==

symlink-or-copy@^1.1.8:
version "1.3.1"
resolved "https://registry.yarnpkg.com/symlink-or-copy/-/symlink-or-copy-1.3.1.tgz#9506dd64d8e98fa21dcbf4018d1eab23e77f71fe"
Expand Down

0 comments on commit aa0a6f1

Please sign in to comment.