| 611 | return Option.none() |
| 612 | } |
| 613 | |
| 614 | return Option.some({ |
| 615 | path: fullPath, |
| 616 | name: f.name |
| 617 | }) |
| 618 | })), |
| 619 | { |
| 620 | concurrency: "unbounded" |
| 621 | } |
| 622 | ) |
| 623 | .pipe(Effect.map(Array.getSomes)) |
| 624 | |
| 625 | const gistFromCache = (yield* SynchronizedRef.get(cache)).entries.find((_) => _.name === name) |
| 626 | |
| 627 | // if the gist's name exists in cache, update the existing gist |
| 628 | // otherwise, create a new gist and update the local cache |
| 629 | if (gistFromCache) { |
| 630 | yield* Effect.logInfo(`Updating existing gist ${gistFromCache.name} with ID ${gistFromCache.id}`) |
| 631 | |
| 632 | // get current files in the gist to detect removed files |
| 633 | const gistFileNames = new Set( |
| 634 | yield* GH.getGistFileNames({ |
| 635 | gist_id: gistFromCache.id, |
| 636 | gist_name: gistFromCache.name, |
| 637 | env: CONFIG.env |
| 638 | }) |
| 639 | ) |
| 640 | |
| 641 | const expectedFiles = new Set(filesOnDiskWithFullPath.map(({ name }) => name)) |
| 642 | |
| 643 | // remove files that are no longer in YAML configuration |
| 644 | for (const gf of gistFileNames) { |
| 645 | if (!expectedFiles.has(gf)) { |
| 646 | yield* GH.removeFileFromGist({ |
| 647 | gist_id: gistFromCache.id, |
| 648 | gist_name: gistFromCache.name, |
| 649 | file_name: gf, |
| 650 | env: CONFIG.env |
| 651 | }) |
| 652 | } |
| 653 | } |
| 654 | |
| 655 | // update/add files from configuration |
| 656 | for (const f of filesOnDiskWithFullPath) { |
| 657 | if (gistFileNames.has(f.name)) { |
| 658 | yield* GH.updateFileOfGist({ |
| 659 | gist_id: gistFromCache.id, |
| 660 | gist_name: gistFromCache.name, |
| 661 | file_name: f.name, |
| 662 | file_path: f.path, |
| 663 | env: CONFIG.env |
| 664 | }) |
| 665 | } else { |
| 666 | yield* GH.addFileToGist({ |
| 667 | gist_id: gistFromCache.id, |
| 668 | gist_name: gistFromCache.name, |
| 669 | file: f, |
| 670 | env: CONFIG.env |
nothing calls this directly
no test coverage detected
searching dependent graphs…