@stacksjs/cloud 0.58.43 → 0.58.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +292 -721
- package/package.json +30 -30
package/dist/index.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
set: (newValue) => all[name] = () => newValue
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
|
|
2
13
|
// src/helpers.ts
|
|
3
14
|
import {CloudFormation} from "@aws-sdk/client-cloudformation";
|
|
4
15
|
import {CloudWatchLogsClient, DeleteLogGroupCommand, DescribeLogGroupsCommand} from "@aws-sdk/client-cloudwatch-logs";
|
|
@@ -477,361 +488,25 @@ class AiStack {
|
|
|
477
488
|
import {Duration as Duration2, Fn, CfnOutput as Output2, aws_cloudfront as cloudfront, aws_cloudfront_origins as origins, aws_route53 as route53, aws_route53_targets as targets} from "aws-cdk-lib";
|
|
478
489
|
import {config as config6} from "@stacksjs/config";
|
|
479
490
|
|
|
480
|
-
// /
|
|
491
|
+
// /home/runner/work/stacks/stacks/storage/framework/core/storage/src/files.ts
|
|
481
492
|
import {detectIndent, detectNewline} from "@stacksjs/strings";
|
|
482
493
|
import {dirname, join as join2, path as p2} from "@stacksjs/path";
|
|
483
494
|
|
|
484
|
-
// /
|
|
495
|
+
// /home/runner/work/stacks/stacks/storage/framework/core/arrays/src/helpers.ts
|
|
485
496
|
import {clamp} from "@stacksjs/utils";
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
return Array.isArray(array) ? array : [array];
|
|
489
|
-
};
|
|
490
|
-
var flatten = function(array) {
|
|
491
|
-
return toArray(array).flat(1);
|
|
492
|
-
};
|
|
493
|
-
var mergeArrayable = function(...args) {
|
|
494
|
-
return args.flatMap((i) => toArray(i));
|
|
495
|
-
};
|
|
496
|
-
var partition = function(array, ...filters) {
|
|
497
|
-
const result = Array.from({ length: filters.length + 1 }).fill(null).map(() => []);
|
|
498
|
-
array.forEach((e, idx, arr) => {
|
|
499
|
-
let i = 0;
|
|
500
|
-
for (const filter of filters) {
|
|
501
|
-
if (filter(e, idx, arr)) {
|
|
502
|
-
result[i].push(e);
|
|
503
|
-
return;
|
|
504
|
-
}
|
|
505
|
-
i += 1;
|
|
506
|
-
}
|
|
507
|
-
result[i].push(e);
|
|
508
|
-
});
|
|
509
|
-
return result;
|
|
510
|
-
};
|
|
511
|
-
var uniq = function(array) {
|
|
512
|
-
return Array.from(new Set(array));
|
|
513
|
-
};
|
|
514
|
-
var unique = function(array) {
|
|
515
|
-
return uniq(array);
|
|
516
|
-
};
|
|
517
|
-
var uniqueBy = function(array, equalFn) {
|
|
518
|
-
return array.reduce((acc, cur) => {
|
|
519
|
-
const index = acc.findIndex((item) => equalFn(cur, item));
|
|
520
|
-
if (index === -1)
|
|
521
|
-
acc.push(cur);
|
|
522
|
-
return acc;
|
|
523
|
-
}, []);
|
|
524
|
-
};
|
|
525
|
-
var last = function(array) {
|
|
526
|
-
return at(array, -1);
|
|
527
|
-
};
|
|
528
|
-
var remove = function(array, value) {
|
|
529
|
-
if (!array)
|
|
530
|
-
return false;
|
|
531
|
-
const index = array.indexOf(value);
|
|
532
|
-
if (index >= 0) {
|
|
533
|
-
array.splice(index, 1);
|
|
534
|
-
return true;
|
|
535
|
-
}
|
|
536
|
-
return false;
|
|
537
|
-
};
|
|
538
|
-
var at = function(array, index) {
|
|
539
|
-
const len = array.length;
|
|
540
|
-
if (!len)
|
|
541
|
-
return;
|
|
542
|
-
if (index < 0)
|
|
543
|
-
index += len;
|
|
544
|
-
return array[index];
|
|
545
|
-
};
|
|
546
|
-
var move = function(array, from, to) {
|
|
547
|
-
const len = array.length;
|
|
548
|
-
if (!len)
|
|
549
|
-
return [];
|
|
550
|
-
if (from < 0)
|
|
551
|
-
from += len;
|
|
552
|
-
if (to < 0)
|
|
553
|
-
to += len;
|
|
554
|
-
const item = array.splice(from, 1)[0];
|
|
555
|
-
array.splice(to, 0, item);
|
|
556
|
-
return array;
|
|
557
|
-
};
|
|
558
|
-
var clampArrayRange = function(arr, n) {
|
|
559
|
-
return clamp(n, 0, arr.length - 1);
|
|
560
|
-
};
|
|
561
|
-
var sample = function(arr, count) {
|
|
562
|
-
return Array.from({ length: count }, (_) => arr[Math.round(Math.random() * (arr.length - 1))]);
|
|
563
|
-
};
|
|
564
|
-
var shuffle = function(array) {
|
|
565
|
-
for (let i = array.length - 1;i > 0; i--) {
|
|
566
|
-
const j = Math.floor(Math.random() * (i + 1));
|
|
567
|
-
[array[i], array[j]] = [array[j], array[i]];
|
|
568
|
-
}
|
|
569
|
-
return array;
|
|
570
|
-
};
|
|
571
|
-
var average = function(arr) {
|
|
572
|
-
return sum(arr) / arr.length;
|
|
573
|
-
};
|
|
574
|
-
var avg = function(arr) {
|
|
575
|
-
return average(arr);
|
|
576
|
-
};
|
|
577
|
-
var median = function(arr) {
|
|
578
|
-
return arr[Math.floor(arr.length / 2)];
|
|
579
|
-
};
|
|
580
|
-
var mode = function(arr) {
|
|
581
|
-
return arr.sort((a, b) => arr.filter((v) => v === a).length - arr.filter((v) => v === b).length).pop();
|
|
582
|
-
};
|
|
583
|
-
var sum = function(array) {
|
|
584
|
-
return array.reduce((acc, cur) => acc + cur, 0);
|
|
585
|
-
};
|
|
586
|
-
var product = function(array) {
|
|
587
|
-
return array.reduce((acc, cur) => acc * cur, 1);
|
|
588
|
-
};
|
|
589
|
-
var min = function(array) {
|
|
590
|
-
return Math.min(...array);
|
|
591
|
-
};
|
|
592
|
-
var max = function(array) {
|
|
593
|
-
return Math.max(...array);
|
|
594
|
-
};
|
|
595
|
-
var range = function(array) {
|
|
596
|
-
return max(array) - min(array);
|
|
597
|
-
};
|
|
598
|
-
var variance = function(array) {
|
|
599
|
-
const mean = average(array);
|
|
600
|
-
return average(array.map((num) => (num - mean) ** 2));
|
|
601
|
-
};
|
|
602
|
-
var standardDeviation = function(array) {
|
|
603
|
-
return Math.sqrt(variance(array));
|
|
604
|
-
};
|
|
605
|
-
var zScore = function(array, num) {
|
|
606
|
-
return (num - average(array)) / standardDeviation(array);
|
|
607
|
-
};
|
|
608
|
-
var percentile = function(array, num) {
|
|
609
|
-
return array.filter((n) => n < num).length / array.length;
|
|
610
|
-
};
|
|
611
|
-
var interquartileRange = function(array) {
|
|
612
|
-
const q1 = median(array.slice(0, Math.floor(array.length / 2)));
|
|
613
|
-
const q3 = median(array.slice(Math.ceil(array.length / 2)));
|
|
614
|
-
return q3 - q1;
|
|
615
|
-
};
|
|
616
|
-
var covariance = function(array1, array2) {
|
|
617
|
-
const mean1 = average(array1);
|
|
618
|
-
const mean2 = average(array2);
|
|
619
|
-
return average(array1.map((num1, i) => (num1 - mean1) * (array2[i] - mean2)));
|
|
620
|
-
};
|
|
621
|
-
var contains = function(needle, haystack) {
|
|
497
|
+
// /home/runner/work/stacks/stacks/storage/framework/core/arrays/src/contains.ts
|
|
498
|
+
function contains(needle, haystack) {
|
|
622
499
|
return haystack.some((hay) => needle.includes(hay));
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
return needles.every((needle) => contains(needle, haystack));
|
|
626
|
-
};
|
|
627
|
-
var containsAny = function(needles, haystack) {
|
|
628
|
-
return needles.some((needle) => contains(needle, haystack));
|
|
629
|
-
};
|
|
630
|
-
var containsNone = function(needles, haystack) {
|
|
631
|
-
return !containsAny(needles, haystack);
|
|
632
|
-
};
|
|
633
|
-
var containsOnly = function(needles, haystack) {
|
|
634
|
-
return containsAll(haystack, needles);
|
|
635
|
-
};
|
|
636
|
-
var doesNotContain = function(needle, haystack) {
|
|
637
|
-
return !contains(needle, haystack);
|
|
638
|
-
};
|
|
639
|
-
var __defProp = Object.defineProperty;
|
|
640
|
-
var __export = (target, all) => {
|
|
641
|
-
for (var name in all)
|
|
642
|
-
__defProp(target, name, {
|
|
643
|
-
get: all[name],
|
|
644
|
-
enumerable: true,
|
|
645
|
-
configurable: true,
|
|
646
|
-
set: (newValue) => all[name] = () => newValue
|
|
647
|
-
});
|
|
648
|
-
};
|
|
649
|
-
var exports_arr = {};
|
|
650
|
-
__export(exports_arr, {
|
|
651
|
-
zScore: () => {
|
|
652
|
-
{
|
|
653
|
-
return zScore;
|
|
654
|
-
}
|
|
655
|
-
},
|
|
656
|
-
variance: () => {
|
|
657
|
-
{
|
|
658
|
-
return variance;
|
|
659
|
-
}
|
|
660
|
-
},
|
|
661
|
-
uniqueBy: () => {
|
|
662
|
-
{
|
|
663
|
-
return uniqueBy;
|
|
664
|
-
}
|
|
665
|
-
},
|
|
666
|
-
unique: () => {
|
|
667
|
-
{
|
|
668
|
-
return unique;
|
|
669
|
-
}
|
|
670
|
-
},
|
|
671
|
-
uniq: () => {
|
|
672
|
-
{
|
|
673
|
-
return uniq;
|
|
674
|
-
}
|
|
675
|
-
},
|
|
676
|
-
toArray: () => {
|
|
677
|
-
{
|
|
678
|
-
return toArray;
|
|
679
|
-
}
|
|
680
|
-
},
|
|
681
|
-
sum: () => {
|
|
682
|
-
{
|
|
683
|
-
return sum;
|
|
684
|
-
}
|
|
685
|
-
},
|
|
686
|
-
standardDeviation: () => {
|
|
687
|
-
{
|
|
688
|
-
return standardDeviation;
|
|
689
|
-
}
|
|
690
|
-
},
|
|
691
|
-
shuffle: () => {
|
|
692
|
-
{
|
|
693
|
-
return shuffle;
|
|
694
|
-
}
|
|
695
|
-
},
|
|
696
|
-
sample: () => {
|
|
697
|
-
{
|
|
698
|
-
return sample;
|
|
699
|
-
}
|
|
700
|
-
},
|
|
701
|
-
remove: () => {
|
|
702
|
-
{
|
|
703
|
-
return remove;
|
|
704
|
-
}
|
|
705
|
-
},
|
|
706
|
-
range: () => {
|
|
707
|
-
{
|
|
708
|
-
return range;
|
|
709
|
-
}
|
|
710
|
-
},
|
|
711
|
-
product: () => {
|
|
712
|
-
{
|
|
713
|
-
return product;
|
|
714
|
-
}
|
|
715
|
-
},
|
|
716
|
-
percentile: () => {
|
|
717
|
-
{
|
|
718
|
-
return percentile;
|
|
719
|
-
}
|
|
720
|
-
},
|
|
721
|
-
partition: () => {
|
|
722
|
-
{
|
|
723
|
-
return partition;
|
|
724
|
-
}
|
|
725
|
-
},
|
|
726
|
-
move: () => {
|
|
727
|
-
{
|
|
728
|
-
return move;
|
|
729
|
-
}
|
|
730
|
-
},
|
|
731
|
-
mode: () => {
|
|
732
|
-
{
|
|
733
|
-
return mode;
|
|
734
|
-
}
|
|
735
|
-
},
|
|
736
|
-
min: () => {
|
|
737
|
-
{
|
|
738
|
-
return min;
|
|
739
|
-
}
|
|
740
|
-
},
|
|
741
|
-
mergeArrayable: () => {
|
|
742
|
-
{
|
|
743
|
-
return mergeArrayable;
|
|
744
|
-
}
|
|
745
|
-
},
|
|
746
|
-
median: () => {
|
|
747
|
-
{
|
|
748
|
-
return median;
|
|
749
|
-
}
|
|
750
|
-
},
|
|
751
|
-
max: () => {
|
|
752
|
-
{
|
|
753
|
-
return max;
|
|
754
|
-
}
|
|
755
|
-
},
|
|
756
|
-
last: () => {
|
|
757
|
-
{
|
|
758
|
-
return last;
|
|
759
|
-
}
|
|
760
|
-
},
|
|
761
|
-
interquartileRange: () => {
|
|
762
|
-
{
|
|
763
|
-
return interquartileRange;
|
|
764
|
-
}
|
|
765
|
-
},
|
|
766
|
-
flatten: () => {
|
|
767
|
-
{
|
|
768
|
-
return flatten;
|
|
769
|
-
}
|
|
770
|
-
},
|
|
771
|
-
doesNotContain: () => {
|
|
772
|
-
{
|
|
773
|
-
return doesNotContain;
|
|
774
|
-
}
|
|
775
|
-
},
|
|
776
|
-
covariance: () => {
|
|
777
|
-
{
|
|
778
|
-
return covariance;
|
|
779
|
-
}
|
|
780
|
-
},
|
|
781
|
-
containsOnly: () => {
|
|
782
|
-
{
|
|
783
|
-
return containsOnly;
|
|
784
|
-
}
|
|
785
|
-
},
|
|
786
|
-
containsNone: () => {
|
|
787
|
-
{
|
|
788
|
-
return containsNone;
|
|
789
|
-
}
|
|
790
|
-
},
|
|
791
|
-
containsAny: () => {
|
|
792
|
-
{
|
|
793
|
-
return containsAny;
|
|
794
|
-
}
|
|
795
|
-
},
|
|
796
|
-
containsAll: () => {
|
|
797
|
-
{
|
|
798
|
-
return containsAll;
|
|
799
|
-
}
|
|
800
|
-
},
|
|
801
|
-
contains: () => {
|
|
802
|
-
{
|
|
803
|
-
return contains;
|
|
804
|
-
}
|
|
805
|
-
},
|
|
806
|
-
clampArrayRange: () => {
|
|
807
|
-
{
|
|
808
|
-
return clampArrayRange;
|
|
809
|
-
}
|
|
810
|
-
},
|
|
811
|
-
avg: () => {
|
|
812
|
-
{
|
|
813
|
-
return avg;
|
|
814
|
-
}
|
|
815
|
-
},
|
|
816
|
-
average: () => {
|
|
817
|
-
{
|
|
818
|
-
return average;
|
|
819
|
-
}
|
|
820
|
-
},
|
|
821
|
-
at: () => {
|
|
822
|
-
{
|
|
823
|
-
return at;
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
});
|
|
827
|
-
|
|
828
|
-
// /Users/chrisbreuer/Code/stacks/storage/framework/core/storage/dist/index.js
|
|
500
|
+
}
|
|
501
|
+
// /home/runner/work/stacks/stacks/storage/framework/core/storage/src/fs.ts
|
|
829
502
|
import {mkdirSync, writeFileSync} from "fs";
|
|
830
503
|
import * as fs from "fs-extra";
|
|
831
|
-
import {pathExists as
|
|
832
|
-
async function exists(
|
|
833
|
-
return await
|
|
504
|
+
import {pathExists as existsSync} from "fs-extra";
|
|
505
|
+
async function exists(path2) {
|
|
506
|
+
return await existsSync(path2);
|
|
834
507
|
}
|
|
508
|
+
|
|
509
|
+
// /home/runner/work/stacks/stacks/storage/framework/core/storage/src/files.ts
|
|
835
510
|
async function readJsonFile(name, cwd) {
|
|
836
511
|
const file = await readTextFile(name, cwd);
|
|
837
512
|
const data = JSON.parse(file.data);
|
|
@@ -843,14 +518,14 @@ async function readPackageJson(name, cwd) {
|
|
|
843
518
|
const file = await readJsonFile(name, cwd);
|
|
844
519
|
return file.data;
|
|
845
520
|
}
|
|
846
|
-
async function writeFile(
|
|
847
|
-
if (typeof
|
|
848
|
-
const dirPath = dirname(
|
|
849
|
-
if (!await
|
|
521
|
+
async function writeFile(path3, data) {
|
|
522
|
+
if (typeof path3 === "string") {
|
|
523
|
+
const dirPath = dirname(path3);
|
|
524
|
+
if (!await existsSync(dirPath))
|
|
850
525
|
await createFolder(dirPath);
|
|
851
|
-
return await Bun.write(Bun.file(
|
|
526
|
+
return await Bun.write(Bun.file(path3), data);
|
|
852
527
|
}
|
|
853
|
-
return await Bun.write(
|
|
528
|
+
return await Bun.write(path3, data);
|
|
854
529
|
}
|
|
855
530
|
async function writeJsonFile(file) {
|
|
856
531
|
let json = JSON.stringify(file.data, undefined, file.indent);
|
|
@@ -858,7 +533,7 @@ async function writeJsonFile(file) {
|
|
|
858
533
|
json += file.newline;
|
|
859
534
|
return writeTextFile({ ...file, data: json });
|
|
860
535
|
}
|
|
861
|
-
|
|
536
|
+
function readTextFile(name, cwd) {
|
|
862
537
|
return new Promise((resolve, reject) => {
|
|
863
538
|
let filePath;
|
|
864
539
|
if (cwd)
|
|
@@ -876,48 +551,48 @@ var readTextFile = function(name, cwd) {
|
|
|
876
551
|
}
|
|
877
552
|
});
|
|
878
553
|
});
|
|
879
|
-
}
|
|
554
|
+
}
|
|
880
555
|
async function writeTextFile(file) {
|
|
881
556
|
return await Bun.write(file.path, file.data);
|
|
882
557
|
}
|
|
883
|
-
|
|
884
|
-
return fs.existsSync(
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
return !isFile(
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
return !isFile(
|
|
891
|
-
}
|
|
892
|
-
|
|
558
|
+
function isFile(path3) {
|
|
559
|
+
return fs.existsSync(path3);
|
|
560
|
+
}
|
|
561
|
+
function doesExist(path3) {
|
|
562
|
+
return !isFile(path3) || !isFolder(path3);
|
|
563
|
+
}
|
|
564
|
+
function doesNotExist(path3) {
|
|
565
|
+
return !isFile(path3) && !isFolder(path3);
|
|
566
|
+
}
|
|
567
|
+
function hasFiles(folder) {
|
|
893
568
|
try {
|
|
894
569
|
return fs.readdirSync(folder).length > 0;
|
|
895
570
|
} catch (err2) {
|
|
896
571
|
return false;
|
|
897
572
|
}
|
|
898
|
-
}
|
|
899
|
-
|
|
573
|
+
}
|
|
574
|
+
function hasComponents() {
|
|
900
575
|
return hasFiles(p2.componentsPath());
|
|
901
|
-
}
|
|
902
|
-
|
|
576
|
+
}
|
|
577
|
+
function hasFunctions() {
|
|
903
578
|
return hasFiles(p2.functionsPath());
|
|
904
|
-
}
|
|
905
|
-
|
|
579
|
+
}
|
|
580
|
+
function deleteFiles(dir, exclude = []) {
|
|
906
581
|
if (fs.existsSync(dir)) {
|
|
907
582
|
fs.readdirSync(dir).forEach((file) => {
|
|
908
|
-
const
|
|
909
|
-
if (fs.statSync(
|
|
910
|
-
if (fs.readdirSync(
|
|
911
|
-
fs.rmSync(
|
|
583
|
+
const p3 = join2(dir, file);
|
|
584
|
+
if (fs.statSync(p3).isDirectory()) {
|
|
585
|
+
if (fs.readdirSync(p3).length === 0)
|
|
586
|
+
fs.rmSync(p3, { recursive: true, force: true });
|
|
912
587
|
else
|
|
913
|
-
deleteFiles(
|
|
914
|
-
} else if (!contains(
|
|
915
|
-
fs.rmSync(
|
|
588
|
+
deleteFiles(p3, exclude);
|
|
589
|
+
} else if (!contains(p3, exclude)) {
|
|
590
|
+
fs.rmSync(p3);
|
|
916
591
|
}
|
|
917
592
|
});
|
|
918
593
|
}
|
|
919
|
-
}
|
|
920
|
-
|
|
594
|
+
}
|
|
595
|
+
function getFiles(dir, exclude = []) {
|
|
921
596
|
let results = [];
|
|
922
597
|
const list = fs.readdirSync(dir);
|
|
923
598
|
list.forEach((file) => {
|
|
@@ -929,34 +604,50 @@ var getFiles = function(dir, exclude = []) {
|
|
|
929
604
|
results.push(file);
|
|
930
605
|
});
|
|
931
606
|
return results;
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
const dirPath = dirname(
|
|
607
|
+
}
|
|
608
|
+
function put(path3, contents) {
|
|
609
|
+
const dirPath = dirname(path3);
|
|
935
610
|
if (!fs.existsSync(dirPath))
|
|
936
611
|
fs.mkdirSync(dirPath, { recursive: true });
|
|
937
|
-
fs.writeFileSync(
|
|
938
|
-
}
|
|
939
|
-
async function get(
|
|
940
|
-
return Bun.file(
|
|
612
|
+
fs.writeFileSync(path3, contents, "utf-8");
|
|
613
|
+
}
|
|
614
|
+
async function get(path3) {
|
|
615
|
+
return Bun.file(path3).text();
|
|
941
616
|
}
|
|
617
|
+
var files = {
|
|
618
|
+
readJsonFile,
|
|
619
|
+
readPackageJson,
|
|
620
|
+
readTextFile,
|
|
621
|
+
writeJsonFile,
|
|
622
|
+
writeTextFile,
|
|
623
|
+
isFile,
|
|
624
|
+
hasFiles,
|
|
625
|
+
hasComponents,
|
|
626
|
+
hasFunctions,
|
|
627
|
+
deleteFiles,
|
|
628
|
+
getFiles,
|
|
629
|
+
put,
|
|
630
|
+
get
|
|
631
|
+
};
|
|
632
|
+
// /home/runner/work/stacks/stacks/storage/framework/core/storage/src/folders.ts
|
|
942
633
|
import {join as join3} from "@stacksjs/path";
|
|
943
|
-
|
|
634
|
+
function isFolder2(path4) {
|
|
944
635
|
try {
|
|
945
|
-
return fs.statSync(
|
|
636
|
+
return fs.statSync(path4).isDirectory();
|
|
946
637
|
} catch {
|
|
947
638
|
return false;
|
|
948
639
|
}
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
return isFolder2(
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
return isFolder2(
|
|
955
|
-
}
|
|
956
|
-
|
|
957
|
-
return fs.existsSync(
|
|
958
|
-
}
|
|
959
|
-
|
|
640
|
+
}
|
|
641
|
+
function isDirectory(path4) {
|
|
642
|
+
return isFolder2(path4);
|
|
643
|
+
}
|
|
644
|
+
function isDir(path4) {
|
|
645
|
+
return isFolder2(path4);
|
|
646
|
+
}
|
|
647
|
+
function doesFolderExist(path4) {
|
|
648
|
+
return fs.existsSync(path4);
|
|
649
|
+
}
|
|
650
|
+
function createFolder2(dir) {
|
|
960
651
|
return new Promise((resolve, reject) => {
|
|
961
652
|
fs.mkdirs(dir, (err2) => {
|
|
962
653
|
if (err2)
|
|
@@ -965,17 +656,24 @@ var createFolder2 = function(dir) {
|
|
|
965
656
|
resolve();
|
|
966
657
|
});
|
|
967
658
|
});
|
|
968
|
-
}
|
|
969
|
-
|
|
659
|
+
}
|
|
660
|
+
function getFolders(dir) {
|
|
970
661
|
return fs.readdirSync(dir).filter((file) => {
|
|
971
662
|
return fs.statSync(join3(dir, file)).isDirectory();
|
|
972
663
|
});
|
|
664
|
+
}
|
|
665
|
+
var folders = {
|
|
666
|
+
isFolder: isFolder2,
|
|
667
|
+
doesFolderExist,
|
|
668
|
+
createFolder: createFolder2,
|
|
669
|
+
getFolders
|
|
973
670
|
};
|
|
974
|
-
|
|
975
|
-
import {path as
|
|
671
|
+
// /home/runner/work/stacks/stacks/storage/framework/core/storage/src/hash.ts
|
|
672
|
+
import {path as p3} from "@stacksjs/path";
|
|
673
|
+
// /home/runner/work/stacks/stacks/storage/framework/core/storage/src/helpers.ts
|
|
976
674
|
import {fileURLToPath} from "url";
|
|
977
675
|
import {dirname as dirname2} from "@stacksjs/path";
|
|
978
|
-
|
|
676
|
+
function updateConfigFile(filePath, newConfig) {
|
|
979
677
|
return new Promise((resolve, reject) => {
|
|
980
678
|
const config5 = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
981
679
|
for (const key in newConfig)
|
|
@@ -987,9 +685,16 @@ var updateConfigFile = function(filePath, newConfig) {
|
|
|
987
685
|
reject(error);
|
|
988
686
|
}
|
|
989
687
|
});
|
|
688
|
+
}
|
|
689
|
+
var __dirname = "/home/runner/work/stacks/stacks/storage/framework/core/storage/src";
|
|
690
|
+
var _dirname = typeof __dirname !== "undefined" ? __dirname : dirname2(fileURLToPath(import.meta.url));
|
|
691
|
+
var helpers3 = {
|
|
692
|
+
_dirname,
|
|
693
|
+
updateConfigFile
|
|
990
694
|
};
|
|
695
|
+
// /home/runner/work/stacks/stacks/storage/framework/core/storage/src/copy.ts
|
|
991
696
|
import {join as join4} from "@stacksjs/path";
|
|
992
|
-
|
|
697
|
+
function copy(src, dest, exclude = []) {
|
|
993
698
|
if (Array.isArray(src)) {
|
|
994
699
|
src.forEach((file) => {
|
|
995
700
|
copy(file, dest, exclude);
|
|
@@ -1000,11 +705,11 @@ var copy = function(src, dest, exclude = []) {
|
|
|
1000
705
|
else
|
|
1001
706
|
copyFile(src, dest);
|
|
1002
707
|
}
|
|
1003
|
-
}
|
|
1004
|
-
|
|
708
|
+
}
|
|
709
|
+
function copyFile(src, dest) {
|
|
1005
710
|
fs.copyFileSync(src, dest);
|
|
1006
|
-
}
|
|
1007
|
-
|
|
711
|
+
}
|
|
712
|
+
function copyFolder(src, dest, exclude = []) {
|
|
1008
713
|
if (!fs.existsSync(dest))
|
|
1009
714
|
fs.mkdirSync(dest, { recursive: true });
|
|
1010
715
|
if (fs.existsSync(src)) {
|
|
@@ -1019,28 +724,30 @@ var copyFolder = function(src, dest, exclude = []) {
|
|
|
1019
724
|
}
|
|
1020
725
|
});
|
|
1021
726
|
}
|
|
1022
|
-
}
|
|
727
|
+
}
|
|
728
|
+
// /home/runner/work/stacks/stacks/storage/framework/core/storage/src/glob.ts
|
|
1023
729
|
import {default as default2} from "fast-glob";
|
|
730
|
+
// /home/runner/work/stacks/stacks/storage/framework/core/storage/src/delete.ts
|
|
1024
731
|
import {err as err2, ok as ok2} from "@stacksjs/error-handling";
|
|
1025
732
|
import {italic, log as log2} from "@stacksjs/cli";
|
|
1026
|
-
|
|
733
|
+
function deleteFolder(path7) {
|
|
1027
734
|
return new Promise((resolve, reject) => {
|
|
1028
735
|
try {
|
|
1029
|
-
if (isFolder2(
|
|
1030
|
-
fs.rmSync(
|
|
1031
|
-
return resolve(ok2(`Deleted ${
|
|
736
|
+
if (isFolder2(path7)) {
|
|
737
|
+
fs.rmSync(path7, { recursive: true, force: true });
|
|
738
|
+
return resolve(ok2(`Deleted ${path7}`));
|
|
1032
739
|
}
|
|
1033
|
-
return resolve(ok2(`Path ${
|
|
740
|
+
return resolve(ok2(`Path ${path7} was not a directory`));
|
|
1034
741
|
} catch (error) {
|
|
1035
742
|
return reject(err2(error));
|
|
1036
743
|
}
|
|
1037
744
|
});
|
|
1038
|
-
}
|
|
1039
|
-
async function isDirectoryEmpty(
|
|
745
|
+
}
|
|
746
|
+
async function isDirectoryEmpty(path7) {
|
|
1040
747
|
return new Promise((resolve, reject) => {
|
|
1041
748
|
try {
|
|
1042
|
-
if (fs.statSync(
|
|
1043
|
-
if (fs.readdirSync(
|
|
749
|
+
if (fs.statSync(path7).isDirectory()) {
|
|
750
|
+
if (fs.readdirSync(path7).length === 0)
|
|
1044
751
|
return resolve(ok2(true));
|
|
1045
752
|
else
|
|
1046
753
|
return resolve(ok2(false));
|
|
@@ -1051,18 +758,18 @@ async function isDirectoryEmpty(path62) {
|
|
|
1051
758
|
}
|
|
1052
759
|
});
|
|
1053
760
|
}
|
|
1054
|
-
async function deleteEmptyFolder(
|
|
761
|
+
async function deleteEmptyFolder(path7) {
|
|
1055
762
|
return new Promise((resolve, reject) => {
|
|
1056
763
|
try {
|
|
1057
|
-
if (fs.statSync(
|
|
1058
|
-
if (fs.readdirSync(
|
|
1059
|
-
fs.rmSync(
|
|
1060
|
-
return resolve(ok2(`Deleted ${
|
|
764
|
+
if (fs.statSync(path7).isDirectory()) {
|
|
765
|
+
if (fs.readdirSync(path7).length === 0) {
|
|
766
|
+
fs.rmSync(path7, { recursive: true, force: true });
|
|
767
|
+
return resolve(ok2(`Deleted ${path7}`));
|
|
1061
768
|
} else {
|
|
1062
|
-
return resolve(ok2(`Path ${
|
|
769
|
+
return resolve(ok2(`Path ${path7} was not empty`));
|
|
1063
770
|
}
|
|
1064
771
|
}
|
|
1065
|
-
return resolve(ok2(`Path ${
|
|
772
|
+
return resolve(ok2(`Path ${path7} was not a directory`));
|
|
1066
773
|
} catch (error) {
|
|
1067
774
|
return reject(err2(error));
|
|
1068
775
|
}
|
|
@@ -1074,12 +781,12 @@ async function deleteEmptyFolders(dir) {
|
|
|
1074
781
|
return ok2(`Path ${dir} does not exist`);
|
|
1075
782
|
const files3 = fs.readdirSync(dir);
|
|
1076
783
|
for (const file of files3) {
|
|
1077
|
-
const
|
|
1078
|
-
if (isFolder2(
|
|
1079
|
-
if (fs.readdirSync(
|
|
1080
|
-
fs.rmSync(
|
|
784
|
+
const p4 = join(dir, file);
|
|
785
|
+
if (isFolder2(p4)) {
|
|
786
|
+
if (fs.readdirSync(p4).length === 0)
|
|
787
|
+
fs.rmSync(p4, { recursive: true, force: true });
|
|
1081
788
|
else
|
|
1082
|
-
await deleteEmptyFolders(
|
|
789
|
+
await deleteEmptyFolders(p4);
|
|
1083
790
|
}
|
|
1084
791
|
}
|
|
1085
792
|
return ok2(`Deleted empty folders located in ${dir}`);
|
|
@@ -1087,23 +794,23 @@ async function deleteEmptyFolders(dir) {
|
|
|
1087
794
|
return err2(error);
|
|
1088
795
|
}
|
|
1089
796
|
}
|
|
1090
|
-
|
|
797
|
+
function deleteFile(path7) {
|
|
1091
798
|
return new Promise((resolve, reject) => {
|
|
1092
799
|
try {
|
|
1093
|
-
if (isFile(
|
|
1094
|
-
fs.rmSync(
|
|
1095
|
-
return resolve(ok2(`Deleted ${
|
|
800
|
+
if (isFile(path7)) {
|
|
801
|
+
fs.rmSync(path7, { recursive: true, force: true });
|
|
802
|
+
return resolve(ok2(`Deleted ${path7}`));
|
|
1096
803
|
}
|
|
1097
|
-
return resolve(ok2(`Path ${
|
|
804
|
+
return resolve(ok2(`Path ${path7} was not a file`));
|
|
1098
805
|
} catch (error) {
|
|
1099
806
|
return reject(err2(error));
|
|
1100
807
|
}
|
|
1101
808
|
});
|
|
1102
|
-
}
|
|
1103
|
-
async function deleteGlob(
|
|
1104
|
-
if (!
|
|
1105
|
-
return err2(handleError(`Path ${
|
|
1106
|
-
const directories = await default2([
|
|
809
|
+
}
|
|
810
|
+
async function deleteGlob(path7) {
|
|
811
|
+
if (!path7.includes("*"))
|
|
812
|
+
return err2(handleError(`Path ${path7} does not contain a glob`));
|
|
813
|
+
const directories = await default2([path7], { onlyDirectories: true });
|
|
1107
814
|
for (const directory of directories) {
|
|
1108
815
|
const result = await deleteFolder(directory);
|
|
1109
816
|
if (result.isErr()) {
|
|
@@ -1114,15 +821,16 @@ async function deleteGlob(path62) {
|
|
|
1114
821
|
}
|
|
1115
822
|
return ok2(`Deleted ${directories.length} directories`);
|
|
1116
823
|
}
|
|
1117
|
-
async function del(
|
|
1118
|
-
if (isFile(
|
|
1119
|
-
return await deleteFile(
|
|
1120
|
-
if (isFolder2(
|
|
1121
|
-
return await deleteFolder(
|
|
1122
|
-
if (
|
|
1123
|
-
return await deleteGlob(
|
|
1124
|
-
return err2(handleError(`Path ${
|
|
824
|
+
async function del(path7) {
|
|
825
|
+
if (isFile(path7))
|
|
826
|
+
return await deleteFile(path7);
|
|
827
|
+
if (isFolder2(path7))
|
|
828
|
+
return await deleteFolder(path7);
|
|
829
|
+
if (path7.includes("*"))
|
|
830
|
+
return await deleteGlob(path7);
|
|
831
|
+
return err2(handleError(`Path ${path7} cannot be deleted due to an unhandled condition. Please report this issue.`));
|
|
1125
832
|
}
|
|
833
|
+
// /home/runner/work/stacks/stacks/storage/framework/core/storage/src/zip.ts
|
|
1126
834
|
import {runCommand} from "@stacksjs/cli";
|
|
1127
835
|
async function zip(from, to, options) {
|
|
1128
836
|
const toPath = to || "archive.zip";
|
|
@@ -1136,126 +844,33 @@ async function unzip(paths) {
|
|
|
1136
844
|
return runCommand(`unzip ${paths.join(" ")}`);
|
|
1137
845
|
return runCommand(`unzip ${paths}`);
|
|
1138
846
|
}
|
|
1139
|
-
|
|
847
|
+
function archive(paths) {
|
|
1140
848
|
return zip(paths);
|
|
1141
|
-
}
|
|
1142
|
-
|
|
849
|
+
}
|
|
850
|
+
function unarchive(paths) {
|
|
1143
851
|
return unzip(paths);
|
|
1144
|
-
}
|
|
1145
|
-
|
|
852
|
+
}
|
|
853
|
+
function compress(paths) {
|
|
1146
854
|
return zip(paths);
|
|
1147
|
-
}
|
|
1148
|
-
|
|
855
|
+
}
|
|
856
|
+
function decompress(paths) {
|
|
1149
857
|
return unzip(paths);
|
|
1150
|
-
}
|
|
1151
|
-
|
|
858
|
+
}
|
|
859
|
+
function gzipSync(data, options) {
|
|
1152
860
|
return Bun.gzipSync(data, options);
|
|
1153
|
-
}
|
|
1154
|
-
|
|
861
|
+
}
|
|
862
|
+
function gunzipSync(data) {
|
|
1155
863
|
return Bun.gunzipSync(data);
|
|
1156
|
-
}
|
|
1157
|
-
|
|
864
|
+
}
|
|
865
|
+
function deflateSync(data, options) {
|
|
1158
866
|
return Bun.deflateSync(data, options);
|
|
1159
|
-
};
|
|
1160
|
-
var inflateSync = function(data) {
|
|
1161
|
-
return Bun.inflateSync(data);
|
|
1162
|
-
};
|
|
1163
|
-
import {err as err22, ok as ok22} from "@stacksjs/error-handling";
|
|
1164
|
-
import {log as log22} from "@stacksjs/logging";
|
|
1165
|
-
import {path as path72} from "@stacksjs/path";
|
|
1166
|
-
async function move2(src, dest, options) {
|
|
1167
|
-
try {
|
|
1168
|
-
if (Array.isArray(src)) {
|
|
1169
|
-
const operations = src.map(async (file) => {
|
|
1170
|
-
const from2 = file;
|
|
1171
|
-
const to2 = path72.resolve(dest, path72.basename(file));
|
|
1172
|
-
const result2 = await rename(from2, to2, options);
|
|
1173
|
-
if (result2.isErr()) {
|
|
1174
|
-
log22.error(result2.error);
|
|
1175
|
-
return err22(handleError(result2.error.message, result2.error));
|
|
1176
|
-
}
|
|
1177
|
-
});
|
|
1178
|
-
await Promise.all(operations);
|
|
1179
|
-
return ok22({ message: "Files moved successfully" });
|
|
1180
|
-
}
|
|
1181
|
-
const from = src;
|
|
1182
|
-
const to = dest;
|
|
1183
|
-
const result = await rename(from, to, options);
|
|
1184
|
-
if (result.isErr()) {
|
|
1185
|
-
log22.error(result.error);
|
|
1186
|
-
return err22(handleError(result.error));
|
|
1187
|
-
}
|
|
1188
|
-
return ok22({ message: "File moved successfully" });
|
|
1189
|
-
} catch (error) {
|
|
1190
|
-
return err22(handleError(error));
|
|
1191
|
-
}
|
|
1192
867
|
}
|
|
1193
|
-
|
|
1194
|
-
return
|
|
1195
|
-
try {
|
|
1196
|
-
const dir = path72.dirname(to);
|
|
1197
|
-
if (!fs.existsSync(dir))
|
|
1198
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
1199
|
-
if (!fs.existsSync(from))
|
|
1200
|
-
return reject(err22(new Error(`File or directory does not exist: ${from}`)));
|
|
1201
|
-
if (fs.existsSync(to)) {
|
|
1202
|
-
if (!options?.overwrite)
|
|
1203
|
-
return reject(err22(new Error(`File or directory already exists: ${to}`)));
|
|
1204
|
-
fs.unlinkSync(to);
|
|
1205
|
-
}
|
|
1206
|
-
fs.renameSync(from, to);
|
|
1207
|
-
return resolve(ok22({ message: "File moved successfully" }));
|
|
1208
|
-
} catch (error) {
|
|
1209
|
-
if (error.code === "ENOENT")
|
|
1210
|
-
log22.error("File or directory does not exist\n\n", error);
|
|
1211
|
-
else
|
|
1212
|
-
log22.error(error);
|
|
1213
|
-
return reject(err22(new Error(error)));
|
|
1214
|
-
}
|
|
1215
|
-
});
|
|
868
|
+
function inflateSync(data) {
|
|
869
|
+
return Bun.inflateSync(data);
|
|
1216
870
|
}
|
|
1217
|
-
|
|
1218
|
-
return "wip";
|
|
1219
|
-
};
|
|
1220
|
-
var __defProp2 = Object.defineProperty;
|
|
1221
|
-
var __export2 = (target, all) => {
|
|
1222
|
-
for (var name in all)
|
|
1223
|
-
__defProp2(target, name, {
|
|
1224
|
-
get: all[name],
|
|
1225
|
-
enumerable: true,
|
|
1226
|
-
configurable: true,
|
|
1227
|
-
set: (newValue) => all[name] = () => newValue
|
|
1228
|
-
});
|
|
1229
|
-
};
|
|
1230
|
-
var files = {
|
|
1231
|
-
readJsonFile,
|
|
1232
|
-
readPackageJson,
|
|
1233
|
-
readTextFile,
|
|
1234
|
-
writeJsonFile,
|
|
1235
|
-
writeTextFile,
|
|
1236
|
-
isFile,
|
|
1237
|
-
hasFiles,
|
|
1238
|
-
hasComponents,
|
|
1239
|
-
hasFunctions,
|
|
1240
|
-
deleteFiles,
|
|
1241
|
-
getFiles,
|
|
1242
|
-
put,
|
|
1243
|
-
get
|
|
1244
|
-
};
|
|
1245
|
-
var folders = {
|
|
1246
|
-
isFolder: isFolder2,
|
|
1247
|
-
doesFolderExist,
|
|
1248
|
-
createFolder: createFolder2,
|
|
1249
|
-
getFolders
|
|
1250
|
-
};
|
|
1251
|
-
var __dirname2 = "/Users/chrisbreuer/Code/stacks/storage/framework/core/storage/src";
|
|
1252
|
-
var _dirname = typeof __dirname2 !== "undefined" ? __dirname2 : dirname2(fileURLToPath(import.meta.url));
|
|
1253
|
-
var helpers = {
|
|
1254
|
-
_dirname,
|
|
1255
|
-
updateConfigFile
|
|
1256
|
-
};
|
|
871
|
+
// /home/runner/work/stacks/stacks/storage/framework/core/storage/src/storage.ts
|
|
1257
872
|
var exports_storage = {};
|
|
1258
|
-
|
|
873
|
+
__export(exports_storage, {
|
|
1259
874
|
zip: () => {
|
|
1260
875
|
{
|
|
1261
876
|
return zip;
|
|
@@ -1368,7 +983,7 @@ __export2(exports_storage, {
|
|
|
1368
983
|
},
|
|
1369
984
|
helpers: () => {
|
|
1370
985
|
{
|
|
1371
|
-
return
|
|
986
|
+
return helpers3;
|
|
1372
987
|
}
|
|
1373
988
|
},
|
|
1374
989
|
hasFunctions: () => {
|
|
@@ -1428,7 +1043,7 @@ __export2(exports_storage, {
|
|
|
1428
1043
|
},
|
|
1429
1044
|
existsSync: () => {
|
|
1430
1045
|
{
|
|
1431
|
-
return
|
|
1046
|
+
return existsSync;
|
|
1432
1047
|
}
|
|
1433
1048
|
},
|
|
1434
1049
|
exists: () => {
|
|
@@ -1533,8 +1148,67 @@ __export2(exports_storage, {
|
|
|
1533
1148
|
}
|
|
1534
1149
|
});
|
|
1535
1150
|
|
|
1151
|
+
// /home/runner/work/stacks/stacks/storage/framework/core/storage/src/move.ts
|
|
1152
|
+
import {err as err3, ok as ok3} from "@stacksjs/error-handling";
|
|
1153
|
+
import {log as log3} from "@stacksjs/logging";
|
|
1154
|
+
import {path as path8} from "@stacksjs/path";
|
|
1155
|
+
async function move2(src, dest, options) {
|
|
1156
|
+
try {
|
|
1157
|
+
if (Array.isArray(src)) {
|
|
1158
|
+
const operations = src.map(async (file) => {
|
|
1159
|
+
const from2 = file;
|
|
1160
|
+
const to2 = path8.resolve(dest, path8.basename(file));
|
|
1161
|
+
const result2 = await rename(from2, to2, options);
|
|
1162
|
+
if (result2.isErr()) {
|
|
1163
|
+
log3.error(result2.error);
|
|
1164
|
+
return err3(handleError(result2.error.message, result2.error));
|
|
1165
|
+
}
|
|
1166
|
+
});
|
|
1167
|
+
await Promise.all(operations);
|
|
1168
|
+
return ok3({ message: "Files moved successfully" });
|
|
1169
|
+
}
|
|
1170
|
+
const from = src;
|
|
1171
|
+
const to = dest;
|
|
1172
|
+
const result = await rename(from, to, options);
|
|
1173
|
+
if (result.isErr()) {
|
|
1174
|
+
log3.error(result.error);
|
|
1175
|
+
return err3(handleError(result.error));
|
|
1176
|
+
}
|
|
1177
|
+
return ok3({ message: "File moved successfully" });
|
|
1178
|
+
} catch (error) {
|
|
1179
|
+
return err3(handleError(error));
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
async function rename(from, to, options) {
|
|
1183
|
+
return new Promise((resolve, reject) => {
|
|
1184
|
+
try {
|
|
1185
|
+
const dir = path8.dirname(to);
|
|
1186
|
+
if (!fs.existsSync(dir))
|
|
1187
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
1188
|
+
if (!fs.existsSync(from))
|
|
1189
|
+
return reject(err3(new Error(`File or directory does not exist: ${from}`)));
|
|
1190
|
+
if (fs.existsSync(to)) {
|
|
1191
|
+
if (!options?.overwrite)
|
|
1192
|
+
return reject(err3(new Error(`File or directory already exists: ${to}`)));
|
|
1193
|
+
fs.unlinkSync(to);
|
|
1194
|
+
}
|
|
1195
|
+
fs.renameSync(from, to);
|
|
1196
|
+
return resolve(ok3({ message: "File moved successfully" }));
|
|
1197
|
+
} catch (error) {
|
|
1198
|
+
if (error.code === "ENOENT")
|
|
1199
|
+
log3.error("File or directory does not exist\n\n", error);
|
|
1200
|
+
else
|
|
1201
|
+
log3.error(error);
|
|
1202
|
+
return reject(err3(new Error(error)));
|
|
1203
|
+
}
|
|
1204
|
+
});
|
|
1205
|
+
}
|
|
1206
|
+
// /home/runner/work/stacks/stacks/storage/framework/core/storage/src/visibility.ts
|
|
1207
|
+
function setVisibility() {
|
|
1208
|
+
return "wip";
|
|
1209
|
+
}
|
|
1536
1210
|
// src/cloud/cdn.ts
|
|
1537
|
-
import {path as
|
|
1211
|
+
import {path as p4} from "@stacksjs/path";
|
|
1538
1212
|
import {env as env2} from "@stacksjs/env";
|
|
1539
1213
|
|
|
1540
1214
|
class CdnStack {
|
|
@@ -1677,9 +1351,9 @@ class CdnStack {
|
|
|
1677
1351
|
}
|
|
1678
1352
|
apiBehaviorOptions(scope, props) {
|
|
1679
1353
|
const hostname = Fn.select(2, Fn.split("/", props.webServerUrl.url));
|
|
1680
|
-
const origin = (
|
|
1354
|
+
const origin = (path10 = "/api") => {
|
|
1681
1355
|
return new origins.HttpOrigin(hostname, {
|
|
1682
|
-
originPath:
|
|
1356
|
+
originPath: path10,
|
|
1683
1357
|
protocolPolicy: cloudfront.OriginProtocolPolicy.HTTPS_ONLY
|
|
1684
1358
|
});
|
|
1685
1359
|
};
|
|
@@ -1791,7 +1465,7 @@ class CdnStack {
|
|
|
1791
1465
|
return config6.cloud.cli;
|
|
1792
1466
|
}
|
|
1793
1467
|
shouldDeployDocs() {
|
|
1794
|
-
return hasFiles(
|
|
1468
|
+
return hasFiles(p4.projectPath("docs"));
|
|
1795
1469
|
}
|
|
1796
1470
|
additionalBehaviors(scope, props) {
|
|
1797
1471
|
let behaviorOptions = {};
|
|
@@ -1895,7 +1569,7 @@ class DnsStack {
|
|
|
1895
1569
|
// src/cloud/docs.ts
|
|
1896
1570
|
import {AssetHashType, CfnOutput as Output4, RemovalPolicy as RemovalPolicy2, aws_lambda as lambda3} from "aws-cdk-lib";
|
|
1897
1571
|
import {config as config8} from "@stacksjs/config";
|
|
1898
|
-
import {path as
|
|
1572
|
+
import {path as p5} from "@stacksjs/path";
|
|
1899
1573
|
import {originRequestFunctionHash} from "@stacksjs/utils";
|
|
1900
1574
|
|
|
1901
1575
|
class DocsStack {
|
|
@@ -1907,14 +1581,14 @@ class DocsStack {
|
|
|
1907
1581
|
description: "The Stacks Origin Request function that prettifies URLs",
|
|
1908
1582
|
runtime: lambda3.Runtime.NODEJS_18_X,
|
|
1909
1583
|
handler: "dist/origin-request.handler",
|
|
1910
|
-
code: lambda3.Code.fromAsset(
|
|
1584
|
+
code: lambda3.Code.fromAsset(p5.corePath("cloud/dist.zip"), {
|
|
1911
1585
|
assetHash: originRequestFunctionHash,
|
|
1912
1586
|
assetHashType: AssetHashType.CUSTOM
|
|
1913
1587
|
})
|
|
1914
1588
|
});
|
|
1915
1589
|
const cfnOriginRequestFunction = this.originRequestFunction.node.defaultChild;
|
|
1916
1590
|
cfnOriginRequestFunction.applyRemovalPolicy(RemovalPolicy2.RETAIN);
|
|
1917
|
-
if (!config8.app.docMode && exports_storage.hasFiles(
|
|
1591
|
+
if (!config8.app.docMode && exports_storage.hasFiles(p5.projectPath("docs"))) {
|
|
1918
1592
|
new Output4(scope, "DocsUrl", {
|
|
1919
1593
|
value: `https://${props.domain}/${docsPrefix}`,
|
|
1920
1594
|
description: "The URL of the deployed documentation"
|
|
@@ -2664,7 +2338,7 @@ class PermissionsStack {
|
|
|
2664
2338
|
|
|
2665
2339
|
// src/cloud/compute.ts
|
|
2666
2340
|
import {Duration as Duration6, CfnOutput as Output6, aws_lambda as lambda5, aws_logs as logs, aws_secretsmanager as secretsmanager} from "aws-cdk-lib";
|
|
2667
|
-
import {path as
|
|
2341
|
+
import {path as p6} from "@stacksjs/path";
|
|
2668
2342
|
import {env as env6} from "@stacksjs/env";
|
|
2669
2343
|
|
|
2670
2344
|
class ComputeStack {
|
|
@@ -2678,7 +2352,7 @@ class ComputeStack {
|
|
|
2678
2352
|
this.apiServer = new lambda5.Function(scope, "WebServer", {
|
|
2679
2353
|
functionName: `${props.slug}-${props.appEnv}-web-server`,
|
|
2680
2354
|
description: "The web server for the Stacks application",
|
|
2681
|
-
code: lambda5.Code.fromAssetImage(
|
|
2355
|
+
code: lambda5.Code.fromAssetImage(p6.frameworkPath("server")),
|
|
2682
2356
|
handler: lambda5.Handler.FROM_IMAGE,
|
|
2683
2357
|
runtime: lambda5.Runtime.FROM_IMAGE,
|
|
2684
2358
|
vpc,
|
|
@@ -2779,135 +2453,13 @@ class Cloud extends Stack2 {
|
|
|
2779
2453
|
});
|
|
2780
2454
|
}
|
|
2781
2455
|
}
|
|
2782
|
-
// /
|
|
2783
|
-
import
|
|
2456
|
+
// /home/runner/work/stacks/stacks/storage/framework/core/router/src/middleware.ts
|
|
2457
|
+
import {appPath} from "@stacksjs/path";
|
|
2784
2458
|
async function importMiddlewares(directory) {
|
|
2785
2459
|
return [directory];
|
|
2786
2460
|
}
|
|
2787
|
-
import {extname as extname2} from "path";
|
|
2788
|
-
import {URL} from "url";
|
|
2789
|
-
import {localUrl} from "@stacksjs/config";
|
|
2790
|
-
async function serverResponse(req) {
|
|
2791
|
-
console.log("serverResponse", req);
|
|
2792
|
-
const routesList = await route.getRoutes();
|
|
2793
|
-
const url = new URL(req.url);
|
|
2794
|
-
const foundRoute = routesList.find((route2) => {
|
|
2795
|
-
const pattern = new RegExp(`^${route2.uri.replace(/:\w+/g, "\\w+")}$`);
|
|
2796
|
-
return pattern.test(url.pathname);
|
|
2797
|
-
});
|
|
2798
|
-
if (!foundRoute)
|
|
2799
|
-
return new Response("Not found", { status: 404 });
|
|
2800
|
-
addRouteParamsAndQuery(url, foundRoute);
|
|
2801
|
-
executeMiddleware(foundRoute);
|
|
2802
|
-
return execute(foundRoute, req, { statusCode: foundRoute?.statusCode });
|
|
2803
|
-
}
|
|
2804
|
-
var normalizeWindowsPath = function(input = "") {
|
|
2805
|
-
if (!input) {
|
|
2806
|
-
return input;
|
|
2807
|
-
}
|
|
2808
|
-
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
2809
|
-
};
|
|
2810
|
-
var cwd = function() {
|
|
2811
|
-
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
2812
|
-
return process.cwd().replace(/\\/g, "/");
|
|
2813
|
-
}
|
|
2814
|
-
return "/";
|
|
2815
|
-
};
|
|
2816
|
-
var normalizeString = function(path11, allowAboveRoot) {
|
|
2817
|
-
let res = "";
|
|
2818
|
-
let lastSegmentLength = 0;
|
|
2819
|
-
let lastSlash = -1;
|
|
2820
|
-
let dots = 0;
|
|
2821
|
-
let char = null;
|
|
2822
|
-
for (let index = 0;index <= path11.length; ++index) {
|
|
2823
|
-
if (index < path11.length) {
|
|
2824
|
-
char = path11[index];
|
|
2825
|
-
} else if (char === "/") {
|
|
2826
|
-
break;
|
|
2827
|
-
} else {
|
|
2828
|
-
char = "/";
|
|
2829
|
-
}
|
|
2830
|
-
if (char === "/") {
|
|
2831
|
-
if (lastSlash === index - 1 || dots === 1)
|
|
2832
|
-
;
|
|
2833
|
-
else if (dots === 2) {
|
|
2834
|
-
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
2835
|
-
if (res.length > 2) {
|
|
2836
|
-
const lastSlashIndex = res.lastIndexOf("/");
|
|
2837
|
-
if (lastSlashIndex === -1) {
|
|
2838
|
-
res = "";
|
|
2839
|
-
lastSegmentLength = 0;
|
|
2840
|
-
} else {
|
|
2841
|
-
res = res.slice(0, lastSlashIndex);
|
|
2842
|
-
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
2843
|
-
}
|
|
2844
|
-
lastSlash = index;
|
|
2845
|
-
dots = 0;
|
|
2846
|
-
continue;
|
|
2847
|
-
} else if (res.length > 0) {
|
|
2848
|
-
res = "";
|
|
2849
|
-
lastSegmentLength = 0;
|
|
2850
|
-
lastSlash = index;
|
|
2851
|
-
dots = 0;
|
|
2852
|
-
continue;
|
|
2853
|
-
}
|
|
2854
|
-
}
|
|
2855
|
-
if (allowAboveRoot) {
|
|
2856
|
-
res += res.length > 0 ? "/.." : "..";
|
|
2857
|
-
lastSegmentLength = 2;
|
|
2858
|
-
}
|
|
2859
|
-
} else {
|
|
2860
|
-
if (res.length > 0) {
|
|
2861
|
-
res += `/${path11.slice(lastSlash + 1, index)}`;
|
|
2862
|
-
} else {
|
|
2863
|
-
res = path11.slice(lastSlash + 1, index);
|
|
2864
|
-
}
|
|
2865
|
-
lastSegmentLength = index - lastSlash - 1;
|
|
2866
|
-
}
|
|
2867
|
-
lastSlash = index;
|
|
2868
|
-
dots = 0;
|
|
2869
|
-
} else if (char === "." && dots !== -1) {
|
|
2870
|
-
++dots;
|
|
2871
|
-
} else {
|
|
2872
|
-
dots = -1;
|
|
2873
|
-
}
|
|
2874
|
-
}
|
|
2875
|
-
return res;
|
|
2876
|
-
};
|
|
2877
|
-
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
2878
|
-
var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
2879
|
-
var resolve = function(...arguments_) {
|
|
2880
|
-
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
2881
|
-
let resolvedPath = "";
|
|
2882
|
-
let resolvedAbsolute = false;
|
|
2883
|
-
for (let index = arguments_.length - 1;index >= -1 && !resolvedAbsolute; index--) {
|
|
2884
|
-
const path11 = index >= 0 ? arguments_[index] : cwd();
|
|
2885
|
-
if (!path11 || path11.length === 0) {
|
|
2886
|
-
continue;
|
|
2887
|
-
}
|
|
2888
|
-
resolvedPath = `${path11}/${resolvedPath}`;
|
|
2889
|
-
resolvedAbsolute = isAbsolute(path11);
|
|
2890
|
-
}
|
|
2891
|
-
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
2892
|
-
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
|
2893
|
-
return `/${resolvedPath}`;
|
|
2894
|
-
}
|
|
2895
|
-
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
2896
|
-
};
|
|
2897
|
-
var isAbsolute = function(p6) {
|
|
2898
|
-
return _IS_ABSOLUTE_RE.test(p6);
|
|
2899
|
-
};
|
|
2900
|
-
var appPath = function(path22) {
|
|
2901
|
-
return projectPath(`app/${path22 || ""}`);
|
|
2902
|
-
};
|
|
2903
|
-
var projectPath = function(filePath = "") {
|
|
2904
|
-
let path22 = process2.cwd();
|
|
2905
|
-
while (path22.includes("storage"))
|
|
2906
|
-
path22 = resolve(path22, "..");
|
|
2907
|
-
return resolve(path22, filePath);
|
|
2908
|
-
};
|
|
2909
2461
|
var middlewares = await importMiddlewares(appPath("middleware"));
|
|
2910
|
-
|
|
2462
|
+
// /home/runner/work/stacks/stacks/storage/framework/core/router/src/request.ts
|
|
2911
2463
|
class Request {
|
|
2912
2464
|
query = {};
|
|
2913
2465
|
params = null;
|
|
@@ -2927,7 +2479,7 @@ class Request {
|
|
|
2927
2479
|
return Object.keys(this.query).length === 0;
|
|
2928
2480
|
}
|
|
2929
2481
|
extractParamsFromRoute(routePattern, pathname) {
|
|
2930
|
-
const pattern = new RegExp(`^${routePattern.replace(/:(\w+)/g, (match2, paramName) => `(?<${paramName}>\\w+)`)}
|
|
2482
|
+
const pattern = new RegExp(`^${routePattern.replace(/:(\w+)/g, (match2, paramName) => `(?<${paramName}>\\w+)`)}\$`);
|
|
2931
2483
|
const match = pattern.exec(pathname);
|
|
2932
2484
|
if (match?.groups)
|
|
2933
2485
|
this.params = match?.groups;
|
|
@@ -2937,6 +2489,24 @@ class Request {
|
|
|
2937
2489
|
}
|
|
2938
2490
|
}
|
|
2939
2491
|
var request = new Request;
|
|
2492
|
+
// /home/runner/work/stacks/stacks/storage/framework/core/router/src/server.ts
|
|
2493
|
+
import {extname} from "path";
|
|
2494
|
+
import {URL} from "url";
|
|
2495
|
+
import {localUrl} from "@stacksjs/config";
|
|
2496
|
+
async function serverResponse(req) {
|
|
2497
|
+
console.log("serverResponse", req);
|
|
2498
|
+
const routesList = await route.getRoutes();
|
|
2499
|
+
const url = new URL(req.url);
|
|
2500
|
+
const foundRoute = routesList.find((route2) => {
|
|
2501
|
+
const pattern = new RegExp(`^${route2.uri.replace(/:\w+/g, "\\w+")}\$`);
|
|
2502
|
+
return pattern.test(url.pathname);
|
|
2503
|
+
});
|
|
2504
|
+
if (!foundRoute)
|
|
2505
|
+
return new Response("Not found", { status: 404 });
|
|
2506
|
+
addRouteParamsAndQuery(url, foundRoute);
|
|
2507
|
+
executeMiddleware(foundRoute);
|
|
2508
|
+
return execute(foundRoute, req, { statusCode: foundRoute?.statusCode });
|
|
2509
|
+
}
|
|
2940
2510
|
var addRouteParamsAndQuery = function(url, route2) {
|
|
2941
2511
|
if (!isObjectNotEmpty(url.searchParams))
|
|
2942
2512
|
request.addQuery(url);
|
|
@@ -2972,7 +2542,7 @@ var execute = function(route2, request3, { statusCode }) {
|
|
|
2972
2542
|
}
|
|
2973
2543
|
if (route2?.method !== request3.method)
|
|
2974
2544
|
return new Response("Method not allowed", { status: 405 });
|
|
2975
|
-
if (isString(route2.callback) &&
|
|
2545
|
+
if (isString(route2.callback) && extname(route2.callback) === ".html") {
|
|
2976
2546
|
try {
|
|
2977
2547
|
const fileContent = Bun.file(route2.callback);
|
|
2978
2548
|
return new Response(fileContent, { headers: { "Content-Type": "text/html" } });
|
|
@@ -3008,6 +2578,8 @@ var isFunction = function(val) {
|
|
|
3008
2578
|
var isObject = function(val) {
|
|
3009
2579
|
return val !== null && typeof val === "object" && !Array.isArray(val);
|
|
3010
2580
|
};
|
|
2581
|
+
// /home/runner/work/stacks/stacks/storage/framework/core/router/src/router.ts
|
|
2582
|
+
import {projectPath} from "@stacksjs/path";
|
|
3011
2583
|
|
|
3012
2584
|
class Router {
|
|
3013
2585
|
routes = [];
|
|
@@ -3015,7 +2587,7 @@ class Router {
|
|
|
3015
2587
|
const name = uri.replace(/\//g, ".").replace(/:/g, "");
|
|
3016
2588
|
const pattern = new RegExp(`^${uri.replace(/:[a-zA-Z]+/g, (_match) => {
|
|
3017
2589
|
return "([a-zA-Z0-9-]+)";
|
|
3018
|
-
})}
|
|
2590
|
+
})}\$`);
|
|
3019
2591
|
let routeCallback;
|
|
3020
2592
|
if (typeof callback === "string" || typeof callback === "object") {
|
|
3021
2593
|
routeCallback = () => callback;
|
|
@@ -3033,32 +2605,32 @@ class Router {
|
|
|
3033
2605
|
paramNames: []
|
|
3034
2606
|
});
|
|
3035
2607
|
}
|
|
3036
|
-
get(
|
|
3037
|
-
this.addRoute("GET",
|
|
2608
|
+
get(path14, callback) {
|
|
2609
|
+
this.addRoute("GET", path14, callback, 200);
|
|
3038
2610
|
return this;
|
|
3039
2611
|
}
|
|
3040
|
-
post(
|
|
3041
|
-
this.addRoute("POST",
|
|
2612
|
+
post(path14, callback) {
|
|
2613
|
+
this.addRoute("POST", path14, callback, 201);
|
|
3042
2614
|
return this;
|
|
3043
2615
|
}
|
|
3044
|
-
view(
|
|
3045
|
-
this.addRoute("GET",
|
|
2616
|
+
view(path14, callback) {
|
|
2617
|
+
this.addRoute("GET", path14, callback, 200);
|
|
3046
2618
|
return this;
|
|
3047
2619
|
}
|
|
3048
|
-
redirect(
|
|
3049
|
-
this.addRoute("GET",
|
|
2620
|
+
redirect(path14, callback, _status) {
|
|
2621
|
+
this.addRoute("GET", path14, callback, 302);
|
|
3050
2622
|
return this;
|
|
3051
2623
|
}
|
|
3052
|
-
delete(
|
|
3053
|
-
this.addRoute("DELETE",
|
|
2624
|
+
delete(path14, callback) {
|
|
2625
|
+
this.addRoute("DELETE", path14, callback, 204);
|
|
3054
2626
|
return this;
|
|
3055
2627
|
}
|
|
3056
|
-
patch(
|
|
3057
|
-
this.addRoute("PATCH",
|
|
2628
|
+
patch(path14, callback) {
|
|
2629
|
+
this.addRoute("PATCH", path14, callback, 202);
|
|
3058
2630
|
return this;
|
|
3059
2631
|
}
|
|
3060
|
-
put(
|
|
3061
|
-
this.addRoute("PUT",
|
|
2632
|
+
put(path14, callback) {
|
|
2633
|
+
this.addRoute("PUT", path14, callback, 202);
|
|
3062
2634
|
return this;
|
|
3063
2635
|
}
|
|
3064
2636
|
group(options, callback) {
|
|
@@ -3103,21 +2675,20 @@ class Router {
|
|
|
3103
2675
|
}
|
|
3104
2676
|
}
|
|
3105
2677
|
var route = new Router;
|
|
3106
|
-
|
|
3107
2678
|
// src/runtime/server.ts
|
|
3108
2679
|
var server_default = {
|
|
3109
|
-
async fetch(
|
|
2680
|
+
async fetch(request4, server2) {
|
|
3110
2681
|
console.log("Request", {
|
|
3111
|
-
url:
|
|
3112
|
-
method:
|
|
3113
|
-
headers:
|
|
3114
|
-
body:
|
|
2682
|
+
url: request4.url,
|
|
2683
|
+
method: request4.method,
|
|
2684
|
+
headers: request4.headers.toJSON(),
|
|
2685
|
+
body: request4.body ? await request4.text() : null
|
|
3115
2686
|
});
|
|
3116
|
-
if (
|
|
2687
|
+
if (server2.upgrade(request4)) {
|
|
3117
2688
|
console.log("WebSocket upgraded");
|
|
3118
2689
|
return;
|
|
3119
2690
|
}
|
|
3120
|
-
return serverResponse(
|
|
2691
|
+
return serverResponse(request4);
|
|
3121
2692
|
},
|
|
3122
2693
|
websocket: {}
|
|
3123
2694
|
};
|