@batijs/cli 0.0.88 → 0.0.91
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/boilerplates/@batijs/edgedb/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/edgedb/{package-Z3MWAXVW.js → package-5WKC2CL4.js} +4 -4
- package/dist/boilerplates/@batijs/eslint/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/eslint/{package-6IZEDCMJ.js → package-GGZI5PQR.js} +4 -4
- package/dist/boilerplates/@batijs/express/files/$package.json.js +2 -2
- package/dist/boilerplates/@batijs/express/files/express-entry.ts +11 -11
- package/dist/boilerplates/@batijs/express/{package-TAXLRPPG.js → package-JZRJ7GNY.js} +4 -4
- package/dist/boilerplates/@batijs/h3/files/$package.json.js +2 -2
- package/dist/boilerplates/@batijs/h3/files/h3-entry.ts +2 -2
- package/dist/boilerplates/@batijs/h3/{package-GAI6KFVK.js → package-JKFT7NOM.js} +4 -4
- package/dist/boilerplates/@batijs/hattip/files/$package.json.js +2 -2
- package/dist/boilerplates/@batijs/hattip/files/hattip-entry.ts +4 -4
- package/dist/boilerplates/@batijs/hattip/{package-3BN33DJA.js → package-V7LHU4NY.js} +4 -4
- package/dist/boilerplates/@batijs/prisma/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/prisma/{package-5JR5MUIX.js → package-WIYNQ5BD.js} +4 -4
- package/dist/boilerplates/@batijs/react/files/$.eslintrc.json.js +1 -1
- package/dist/boilerplates/@batijs/react/files/$package.json.js +3 -3
- package/dist/boilerplates/@batijs/react/files/$vite.config.ts.js +1 -1
- package/dist/boilerplates/@batijs/react/files/layouts/HeadDefault.tsx +1 -1
- package/dist/boilerplates/@batijs/react/files/layouts/LayoutDefault.tsx +10 -10
- package/dist/boilerplates/@batijs/react/files/pages/index/+Page.tsx +1 -1
- package/dist/boilerplates/@batijs/react/files/pages/index/Counter.tsx +1 -1
- package/dist/boilerplates/@batijs/react/{package-EYTH4VNP.js → package-ACYBLYSP.js} +4 -4
- package/dist/boilerplates/@batijs/shared/files/$index.html.js +187 -1
- package/dist/boilerplates/@batijs/solid/files/$.eslintrc.json.js +1 -1
- package/dist/boilerplates/@batijs/solid/files/$package.json.js +3 -3
- package/dist/boilerplates/@batijs/solid/files/$vite.config.ts.js +1 -1
- package/dist/boilerplates/@batijs/solid/files/layouts/HeadDefault.tsx +1 -1
- package/dist/boilerplates/@batijs/solid/files/layouts/LayoutDefault.tsx +11 -11
- package/dist/boilerplates/@batijs/solid/files/pages/index/+Page.tsx +1 -1
- package/dist/boilerplates/@batijs/solid/files/pages/index/Counter.tsx +1 -1
- package/dist/boilerplates/@batijs/solid/{package-3SC4XVSR.js → package-F2YY6VVI.js} +4 -4
- package/dist/boilerplates/@batijs/tailwindcss/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/tailwindcss/{package-GTN2QH7M.js → package-Y7SLF7W4.js} +4 -4
- package/dist/boilerplates/@batijs/telefunc/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/telefunc/{package-3G2SQFKV.js → package-OXKJ46FP.js} +4 -4
- package/dist/boilerplates/@batijs/vercel/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/vercel/{package-2NMHCJGC.js → package-OB7R6LX5.js} +4 -4
- package/dist/boilerplates/@batijs/vue/files/$.eslintrc.json.js +1 -1
- package/dist/boilerplates/@batijs/vue/files/$package.json.js +3 -3
- package/dist/boilerplates/@batijs/vue/files/components/Content.vue +1 -1
- package/dist/boilerplates/@batijs/vue/files/components/Counter.vue +1 -1
- package/dist/boilerplates/@batijs/vue/files/components/Logo.vue +1 -1
- package/dist/boilerplates/@batijs/vue/files/components/Sidebar.vue +1 -1
- package/dist/boilerplates/@batijs/vue/files/layouts/HeadDefault.vue +1 -1
- package/dist/boilerplates/@batijs/vue/files/layouts/LayoutDefault.vue +2 -2
- package/dist/boilerplates/@batijs/vue/files/pages/index/+Page.vue +1 -1
- package/dist/boilerplates/@batijs/vue/{package-SEZV7AAY.js → package-XO6TJLGD.js} +4 -4
- package/dist/boilerplates/boilerplates.json +60 -84
- package/dist/index.js +823 -34
- package/package.json +6 -4
package/dist/index.js
CHANGED
|
@@ -600,7 +600,7 @@ Please report this issue to https://github.com/magne4000/bati`
|
|
|
600
600
|
// package.json
|
|
601
601
|
var package_default = {
|
|
602
602
|
name: "@batijs/cli",
|
|
603
|
-
version: "0.0.
|
|
603
|
+
version: "0.0.91",
|
|
604
604
|
type: "module",
|
|
605
605
|
scripts: {
|
|
606
606
|
prerelease: "rimraf ./dist",
|
|
@@ -622,12 +622,14 @@ var package_default = {
|
|
|
622
622
|
esbuild: "^0.19.4",
|
|
623
623
|
execa: "^8.0.1",
|
|
624
624
|
rimraf: "^5.0.5",
|
|
625
|
+
sift: "^17.0.1",
|
|
625
626
|
tsup: "^7.2.0",
|
|
626
627
|
typescript: "^5.2.2",
|
|
627
628
|
vite: "^4.4.11"
|
|
628
629
|
},
|
|
629
630
|
dependencies: {
|
|
630
|
-
"@batijs/core": "workspace:*"
|
|
631
|
+
"@batijs/core": "workspace:*",
|
|
632
|
+
"@batijs/features": "workspace:*"
|
|
631
633
|
},
|
|
632
634
|
bin: "./dist/index.js",
|
|
633
635
|
exports: {
|
|
@@ -639,8 +641,9 @@ var package_default = {
|
|
|
639
641
|
};
|
|
640
642
|
|
|
641
643
|
// index.ts
|
|
642
|
-
import {
|
|
643
|
-
import {
|
|
644
|
+
import { withIcon } from "@batijs/core";
|
|
645
|
+
import { features, flags as coreFlags } from "@batijs/features";
|
|
646
|
+
import { execRules } from "@batijs/features/rules";
|
|
644
647
|
import { existsSync as existsSync2 } from "fs";
|
|
645
648
|
import { fileURLToPath } from "url";
|
|
646
649
|
import { dirname, join, parse } from "path";
|
|
@@ -762,7 +765,7 @@ var {
|
|
|
762
765
|
} = createColors();
|
|
763
766
|
|
|
764
767
|
// rules.ts
|
|
765
|
-
import { RulesMessage } from "@batijs/
|
|
768
|
+
import { RulesMessage } from "@batijs/features/rules";
|
|
766
769
|
function error(value) {
|
|
767
770
|
return {
|
|
768
771
|
type: "error",
|
|
@@ -784,6 +787,781 @@ var rulesMessages = {
|
|
|
784
787
|
[RulesMessage.INFO_HATTIP]: info(`${inverse(bold("HatTip"))} is an experimental project`)
|
|
785
788
|
};
|
|
786
789
|
|
|
790
|
+
// ../../node_modules/.pnpm/sift@17.0.1/node_modules/sift/es5m/index.js
|
|
791
|
+
var extendStatics = function(d, b) {
|
|
792
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
793
|
+
d2.__proto__ = b2;
|
|
794
|
+
} || function(d2, b2) {
|
|
795
|
+
for (var p in b2)
|
|
796
|
+
if (Object.prototype.hasOwnProperty.call(b2, p))
|
|
797
|
+
d2[p] = b2[p];
|
|
798
|
+
};
|
|
799
|
+
return extendStatics(d, b);
|
|
800
|
+
};
|
|
801
|
+
function __extends(d, b) {
|
|
802
|
+
if (typeof b !== "function" && b !== null)
|
|
803
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
804
|
+
extendStatics(d, b);
|
|
805
|
+
function __() {
|
|
806
|
+
this.constructor = d;
|
|
807
|
+
}
|
|
808
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
809
|
+
}
|
|
810
|
+
var typeChecker = function(type) {
|
|
811
|
+
var typeString = "[object " + type + "]";
|
|
812
|
+
return function(value) {
|
|
813
|
+
return getClassName(value) === typeString;
|
|
814
|
+
};
|
|
815
|
+
};
|
|
816
|
+
var getClassName = function(value) {
|
|
817
|
+
return Object.prototype.toString.call(value);
|
|
818
|
+
};
|
|
819
|
+
var comparable = function(value) {
|
|
820
|
+
if (value instanceof Date) {
|
|
821
|
+
return value.getTime();
|
|
822
|
+
} else if (isArray(value)) {
|
|
823
|
+
return value.map(comparable);
|
|
824
|
+
} else if (value && typeof value.toJSON === "function") {
|
|
825
|
+
return value.toJSON();
|
|
826
|
+
}
|
|
827
|
+
return value;
|
|
828
|
+
};
|
|
829
|
+
var coercePotentiallyNull = function(value) {
|
|
830
|
+
return value == null ? null : value;
|
|
831
|
+
};
|
|
832
|
+
var isArray = typeChecker("Array");
|
|
833
|
+
var isObject = typeChecker("Object");
|
|
834
|
+
var isFunction = typeChecker("Function");
|
|
835
|
+
var isVanillaObject = function(value) {
|
|
836
|
+
return value && (value.constructor === Object || value.constructor === Array || value.constructor.toString() === "function Object() { [native code] }" || value.constructor.toString() === "function Array() { [native code] }") && !value.toJSON;
|
|
837
|
+
};
|
|
838
|
+
var equals = function(a, b) {
|
|
839
|
+
if (a == null && a == b) {
|
|
840
|
+
return true;
|
|
841
|
+
}
|
|
842
|
+
if (a === b) {
|
|
843
|
+
return true;
|
|
844
|
+
}
|
|
845
|
+
if (Object.prototype.toString.call(a) !== Object.prototype.toString.call(b)) {
|
|
846
|
+
return false;
|
|
847
|
+
}
|
|
848
|
+
if (isArray(a)) {
|
|
849
|
+
if (a.length !== b.length) {
|
|
850
|
+
return false;
|
|
851
|
+
}
|
|
852
|
+
for (var i = 0, length_1 = a.length; i < length_1; i++) {
|
|
853
|
+
if (!equals(a[i], b[i]))
|
|
854
|
+
return false;
|
|
855
|
+
}
|
|
856
|
+
return true;
|
|
857
|
+
} else if (isObject(a)) {
|
|
858
|
+
if (Object.keys(a).length !== Object.keys(b).length) {
|
|
859
|
+
return false;
|
|
860
|
+
}
|
|
861
|
+
for (var key in a) {
|
|
862
|
+
if (!equals(a[key], b[key]))
|
|
863
|
+
return false;
|
|
864
|
+
}
|
|
865
|
+
return true;
|
|
866
|
+
}
|
|
867
|
+
return false;
|
|
868
|
+
};
|
|
869
|
+
var walkKeyPathValues = function(item, keyPath, next, depth, key, owner) {
|
|
870
|
+
var currentKey = keyPath[depth];
|
|
871
|
+
if (isArray(item) && isNaN(Number(currentKey))) {
|
|
872
|
+
for (var i = 0, length_1 = item.length; i < length_1; i++) {
|
|
873
|
+
if (!walkKeyPathValues(item[i], keyPath, next, depth, i, item)) {
|
|
874
|
+
return false;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
if (depth === keyPath.length || item == null) {
|
|
879
|
+
return next(item, key, owner, depth === 0);
|
|
880
|
+
}
|
|
881
|
+
return walkKeyPathValues(item[currentKey], keyPath, next, depth + 1, currentKey, item);
|
|
882
|
+
};
|
|
883
|
+
var BaseOperation = (
|
|
884
|
+
/** @class */
|
|
885
|
+
function() {
|
|
886
|
+
function BaseOperation2(params, owneryQuery, options, name) {
|
|
887
|
+
this.params = params;
|
|
888
|
+
this.owneryQuery = owneryQuery;
|
|
889
|
+
this.options = options;
|
|
890
|
+
this.name = name;
|
|
891
|
+
this.init();
|
|
892
|
+
}
|
|
893
|
+
BaseOperation2.prototype.init = function() {
|
|
894
|
+
};
|
|
895
|
+
BaseOperation2.prototype.reset = function() {
|
|
896
|
+
this.done = false;
|
|
897
|
+
this.keep = false;
|
|
898
|
+
};
|
|
899
|
+
return BaseOperation2;
|
|
900
|
+
}()
|
|
901
|
+
);
|
|
902
|
+
var GroupOperation = (
|
|
903
|
+
/** @class */
|
|
904
|
+
function(_super) {
|
|
905
|
+
__extends(GroupOperation2, _super);
|
|
906
|
+
function GroupOperation2(params, owneryQuery, options, children) {
|
|
907
|
+
var _this = _super.call(this, params, owneryQuery, options) || this;
|
|
908
|
+
_this.children = children;
|
|
909
|
+
return _this;
|
|
910
|
+
}
|
|
911
|
+
GroupOperation2.prototype.reset = function() {
|
|
912
|
+
this.keep = false;
|
|
913
|
+
this.done = false;
|
|
914
|
+
for (var i = 0, length_2 = this.children.length; i < length_2; i++) {
|
|
915
|
+
this.children[i].reset();
|
|
916
|
+
}
|
|
917
|
+
};
|
|
918
|
+
GroupOperation2.prototype.childrenNext = function(item, key, owner, root) {
|
|
919
|
+
var done = true;
|
|
920
|
+
var keep = true;
|
|
921
|
+
for (var i = 0, length_3 = this.children.length; i < length_3; i++) {
|
|
922
|
+
var childOperation = this.children[i];
|
|
923
|
+
if (!childOperation.done) {
|
|
924
|
+
childOperation.next(item, key, owner, root);
|
|
925
|
+
}
|
|
926
|
+
if (!childOperation.keep) {
|
|
927
|
+
keep = false;
|
|
928
|
+
}
|
|
929
|
+
if (childOperation.done) {
|
|
930
|
+
if (!childOperation.keep) {
|
|
931
|
+
break;
|
|
932
|
+
}
|
|
933
|
+
} else {
|
|
934
|
+
done = false;
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
this.done = done;
|
|
938
|
+
this.keep = keep;
|
|
939
|
+
};
|
|
940
|
+
return GroupOperation2;
|
|
941
|
+
}(BaseOperation)
|
|
942
|
+
);
|
|
943
|
+
var NamedGroupOperation = (
|
|
944
|
+
/** @class */
|
|
945
|
+
function(_super) {
|
|
946
|
+
__extends(NamedGroupOperation2, _super);
|
|
947
|
+
function NamedGroupOperation2(params, owneryQuery, options, children, name) {
|
|
948
|
+
var _this = _super.call(this, params, owneryQuery, options, children) || this;
|
|
949
|
+
_this.name = name;
|
|
950
|
+
return _this;
|
|
951
|
+
}
|
|
952
|
+
return NamedGroupOperation2;
|
|
953
|
+
}(GroupOperation)
|
|
954
|
+
);
|
|
955
|
+
var QueryOperation = (
|
|
956
|
+
/** @class */
|
|
957
|
+
function(_super) {
|
|
958
|
+
__extends(QueryOperation2, _super);
|
|
959
|
+
function QueryOperation2() {
|
|
960
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
961
|
+
_this.propop = true;
|
|
962
|
+
return _this;
|
|
963
|
+
}
|
|
964
|
+
QueryOperation2.prototype.next = function(item, key, parent, root) {
|
|
965
|
+
this.childrenNext(item, key, parent, root);
|
|
966
|
+
};
|
|
967
|
+
return QueryOperation2;
|
|
968
|
+
}(GroupOperation)
|
|
969
|
+
);
|
|
970
|
+
var NestedOperation = (
|
|
971
|
+
/** @class */
|
|
972
|
+
function(_super) {
|
|
973
|
+
__extends(NestedOperation2, _super);
|
|
974
|
+
function NestedOperation2(keyPath, params, owneryQuery, options, children) {
|
|
975
|
+
var _this = _super.call(this, params, owneryQuery, options, children) || this;
|
|
976
|
+
_this.keyPath = keyPath;
|
|
977
|
+
_this.propop = true;
|
|
978
|
+
_this._nextNestedValue = function(value, key, owner, root) {
|
|
979
|
+
_this.childrenNext(value, key, owner, root);
|
|
980
|
+
return !_this.done;
|
|
981
|
+
};
|
|
982
|
+
return _this;
|
|
983
|
+
}
|
|
984
|
+
NestedOperation2.prototype.next = function(item, key, parent) {
|
|
985
|
+
walkKeyPathValues(item, this.keyPath, this._nextNestedValue, 0, key, parent);
|
|
986
|
+
};
|
|
987
|
+
return NestedOperation2;
|
|
988
|
+
}(GroupOperation)
|
|
989
|
+
);
|
|
990
|
+
var createTester = function(a, compare) {
|
|
991
|
+
if (a instanceof Function) {
|
|
992
|
+
return a;
|
|
993
|
+
}
|
|
994
|
+
if (a instanceof RegExp) {
|
|
995
|
+
return function(b) {
|
|
996
|
+
var result = typeof b === "string" && a.test(b);
|
|
997
|
+
a.lastIndex = 0;
|
|
998
|
+
return result;
|
|
999
|
+
};
|
|
1000
|
+
}
|
|
1001
|
+
var comparableA = comparable(a);
|
|
1002
|
+
return function(b) {
|
|
1003
|
+
return compare(comparableA, comparable(b));
|
|
1004
|
+
};
|
|
1005
|
+
};
|
|
1006
|
+
var EqualsOperation = (
|
|
1007
|
+
/** @class */
|
|
1008
|
+
function(_super) {
|
|
1009
|
+
__extends(EqualsOperation2, _super);
|
|
1010
|
+
function EqualsOperation2() {
|
|
1011
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
1012
|
+
_this.propop = true;
|
|
1013
|
+
return _this;
|
|
1014
|
+
}
|
|
1015
|
+
EqualsOperation2.prototype.init = function() {
|
|
1016
|
+
this._test = createTester(this.params, this.options.compare);
|
|
1017
|
+
};
|
|
1018
|
+
EqualsOperation2.prototype.next = function(item, key, parent) {
|
|
1019
|
+
if (!Array.isArray(parent) || parent.hasOwnProperty(key)) {
|
|
1020
|
+
if (this._test(item, key, parent)) {
|
|
1021
|
+
this.done = true;
|
|
1022
|
+
this.keep = true;
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
};
|
|
1026
|
+
return EqualsOperation2;
|
|
1027
|
+
}(BaseOperation)
|
|
1028
|
+
);
|
|
1029
|
+
var numericalOperationCreator = function(createNumericalOperation) {
|
|
1030
|
+
return function(params, owneryQuery, options, name) {
|
|
1031
|
+
return createNumericalOperation(params, owneryQuery, options, name);
|
|
1032
|
+
};
|
|
1033
|
+
};
|
|
1034
|
+
var numericalOperation = function(createTester2) {
|
|
1035
|
+
return numericalOperationCreator(function(params, owneryQuery, options, name) {
|
|
1036
|
+
var typeofParams = typeof comparable(params);
|
|
1037
|
+
var test = createTester2(params);
|
|
1038
|
+
return new EqualsOperation(function(b) {
|
|
1039
|
+
var actualValue = coercePotentiallyNull(b);
|
|
1040
|
+
return typeof comparable(actualValue) === typeofParams && test(actualValue);
|
|
1041
|
+
}, owneryQuery, options, name);
|
|
1042
|
+
});
|
|
1043
|
+
};
|
|
1044
|
+
var createNamedOperation = function(name, params, parentQuery, options) {
|
|
1045
|
+
var operationCreator = options.operations[name];
|
|
1046
|
+
if (!operationCreator) {
|
|
1047
|
+
throwUnsupportedOperation(name);
|
|
1048
|
+
}
|
|
1049
|
+
return operationCreator(params, parentQuery, options, name);
|
|
1050
|
+
};
|
|
1051
|
+
var throwUnsupportedOperation = function(name) {
|
|
1052
|
+
throw new Error("Unsupported operation: " + name);
|
|
1053
|
+
};
|
|
1054
|
+
var containsOperation = function(query, options) {
|
|
1055
|
+
for (var key in query) {
|
|
1056
|
+
if (options.operations.hasOwnProperty(key) || key.charAt(0) === "$")
|
|
1057
|
+
return true;
|
|
1058
|
+
}
|
|
1059
|
+
return false;
|
|
1060
|
+
};
|
|
1061
|
+
var createNestedOperation = function(keyPath, nestedQuery, parentKey, owneryQuery, options) {
|
|
1062
|
+
if (containsOperation(nestedQuery, options)) {
|
|
1063
|
+
var _a = createQueryOperations(nestedQuery, parentKey, options), selfOperations = _a[0], nestedOperations = _a[1];
|
|
1064
|
+
if (nestedOperations.length) {
|
|
1065
|
+
throw new Error("Property queries must contain only operations, or exact objects.");
|
|
1066
|
+
}
|
|
1067
|
+
return new NestedOperation(keyPath, nestedQuery, owneryQuery, options, selfOperations);
|
|
1068
|
+
}
|
|
1069
|
+
return new NestedOperation(keyPath, nestedQuery, owneryQuery, options, [
|
|
1070
|
+
new EqualsOperation(nestedQuery, owneryQuery, options)
|
|
1071
|
+
]);
|
|
1072
|
+
};
|
|
1073
|
+
var createQueryOperation = function(query, owneryQuery, _a) {
|
|
1074
|
+
if (owneryQuery === void 0) {
|
|
1075
|
+
owneryQuery = null;
|
|
1076
|
+
}
|
|
1077
|
+
var _b = _a === void 0 ? {} : _a, compare = _b.compare, operations = _b.operations;
|
|
1078
|
+
var options = {
|
|
1079
|
+
compare: compare || equals,
|
|
1080
|
+
operations: Object.assign({}, operations || {})
|
|
1081
|
+
};
|
|
1082
|
+
var _c = createQueryOperations(query, null, options), selfOperations = _c[0], nestedOperations = _c[1];
|
|
1083
|
+
var ops = [];
|
|
1084
|
+
if (selfOperations.length) {
|
|
1085
|
+
ops.push(new NestedOperation([], query, owneryQuery, options, selfOperations));
|
|
1086
|
+
}
|
|
1087
|
+
ops.push.apply(ops, nestedOperations);
|
|
1088
|
+
if (ops.length === 1) {
|
|
1089
|
+
return ops[0];
|
|
1090
|
+
}
|
|
1091
|
+
return new QueryOperation(query, owneryQuery, options, ops);
|
|
1092
|
+
};
|
|
1093
|
+
var createQueryOperations = function(query, parentKey, options) {
|
|
1094
|
+
var selfOperations = [];
|
|
1095
|
+
var nestedOperations = [];
|
|
1096
|
+
if (!isVanillaObject(query)) {
|
|
1097
|
+
selfOperations.push(new EqualsOperation(query, query, options));
|
|
1098
|
+
return [selfOperations, nestedOperations];
|
|
1099
|
+
}
|
|
1100
|
+
for (var key in query) {
|
|
1101
|
+
if (options.operations.hasOwnProperty(key)) {
|
|
1102
|
+
var op = createNamedOperation(key, query[key], query, options);
|
|
1103
|
+
if (op) {
|
|
1104
|
+
if (!op.propop && parentKey && !options.operations[parentKey]) {
|
|
1105
|
+
throw new Error("Malformed query. " + key + " cannot be matched against property.");
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
if (op != null) {
|
|
1109
|
+
selfOperations.push(op);
|
|
1110
|
+
}
|
|
1111
|
+
} else if (key.charAt(0) === "$") {
|
|
1112
|
+
throwUnsupportedOperation(key);
|
|
1113
|
+
} else {
|
|
1114
|
+
nestedOperations.push(createNestedOperation(key.split("."), query[key], key, query, options));
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
return [selfOperations, nestedOperations];
|
|
1118
|
+
};
|
|
1119
|
+
var createOperationTester = function(operation) {
|
|
1120
|
+
return function(item, key, owner) {
|
|
1121
|
+
operation.reset();
|
|
1122
|
+
operation.next(item, key, owner);
|
|
1123
|
+
return operation.keep;
|
|
1124
|
+
};
|
|
1125
|
+
};
|
|
1126
|
+
var $Ne = (
|
|
1127
|
+
/** @class */
|
|
1128
|
+
function(_super) {
|
|
1129
|
+
__extends($Ne2, _super);
|
|
1130
|
+
function $Ne2() {
|
|
1131
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
1132
|
+
_this.propop = true;
|
|
1133
|
+
return _this;
|
|
1134
|
+
}
|
|
1135
|
+
$Ne2.prototype.init = function() {
|
|
1136
|
+
this._test = createTester(this.params, this.options.compare);
|
|
1137
|
+
};
|
|
1138
|
+
$Ne2.prototype.reset = function() {
|
|
1139
|
+
_super.prototype.reset.call(this);
|
|
1140
|
+
this.keep = true;
|
|
1141
|
+
};
|
|
1142
|
+
$Ne2.prototype.next = function(item) {
|
|
1143
|
+
if (this._test(item)) {
|
|
1144
|
+
this.done = true;
|
|
1145
|
+
this.keep = false;
|
|
1146
|
+
}
|
|
1147
|
+
};
|
|
1148
|
+
return $Ne2;
|
|
1149
|
+
}(BaseOperation)
|
|
1150
|
+
);
|
|
1151
|
+
var $ElemMatch = (
|
|
1152
|
+
/** @class */
|
|
1153
|
+
function(_super) {
|
|
1154
|
+
__extends($ElemMatch2, _super);
|
|
1155
|
+
function $ElemMatch2() {
|
|
1156
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
1157
|
+
_this.propop = true;
|
|
1158
|
+
return _this;
|
|
1159
|
+
}
|
|
1160
|
+
$ElemMatch2.prototype.init = function() {
|
|
1161
|
+
if (!this.params || typeof this.params !== "object") {
|
|
1162
|
+
throw new Error("Malformed query. $elemMatch must by an object.");
|
|
1163
|
+
}
|
|
1164
|
+
this._queryOperation = createQueryOperation(this.params, this.owneryQuery, this.options);
|
|
1165
|
+
};
|
|
1166
|
+
$ElemMatch2.prototype.reset = function() {
|
|
1167
|
+
_super.prototype.reset.call(this);
|
|
1168
|
+
this._queryOperation.reset();
|
|
1169
|
+
};
|
|
1170
|
+
$ElemMatch2.prototype.next = function(item) {
|
|
1171
|
+
if (isArray(item)) {
|
|
1172
|
+
for (var i = 0, length_1 = item.length; i < length_1; i++) {
|
|
1173
|
+
this._queryOperation.reset();
|
|
1174
|
+
var child = item[i];
|
|
1175
|
+
this._queryOperation.next(child, i, item, false);
|
|
1176
|
+
this.keep = this.keep || this._queryOperation.keep;
|
|
1177
|
+
}
|
|
1178
|
+
this.done = true;
|
|
1179
|
+
} else {
|
|
1180
|
+
this.done = false;
|
|
1181
|
+
this.keep = false;
|
|
1182
|
+
}
|
|
1183
|
+
};
|
|
1184
|
+
return $ElemMatch2;
|
|
1185
|
+
}(BaseOperation)
|
|
1186
|
+
);
|
|
1187
|
+
var $Not = (
|
|
1188
|
+
/** @class */
|
|
1189
|
+
function(_super) {
|
|
1190
|
+
__extends($Not2, _super);
|
|
1191
|
+
function $Not2() {
|
|
1192
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
1193
|
+
_this.propop = true;
|
|
1194
|
+
return _this;
|
|
1195
|
+
}
|
|
1196
|
+
$Not2.prototype.init = function() {
|
|
1197
|
+
this._queryOperation = createQueryOperation(this.params, this.owneryQuery, this.options);
|
|
1198
|
+
};
|
|
1199
|
+
$Not2.prototype.reset = function() {
|
|
1200
|
+
_super.prototype.reset.call(this);
|
|
1201
|
+
this._queryOperation.reset();
|
|
1202
|
+
};
|
|
1203
|
+
$Not2.prototype.next = function(item, key, owner, root) {
|
|
1204
|
+
this._queryOperation.next(item, key, owner, root);
|
|
1205
|
+
this.done = this._queryOperation.done;
|
|
1206
|
+
this.keep = !this._queryOperation.keep;
|
|
1207
|
+
};
|
|
1208
|
+
return $Not2;
|
|
1209
|
+
}(BaseOperation)
|
|
1210
|
+
);
|
|
1211
|
+
var $Size = (
|
|
1212
|
+
/** @class */
|
|
1213
|
+
function(_super) {
|
|
1214
|
+
__extends($Size2, _super);
|
|
1215
|
+
function $Size2() {
|
|
1216
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
1217
|
+
_this.propop = true;
|
|
1218
|
+
return _this;
|
|
1219
|
+
}
|
|
1220
|
+
$Size2.prototype.init = function() {
|
|
1221
|
+
};
|
|
1222
|
+
$Size2.prototype.next = function(item) {
|
|
1223
|
+
if (isArray(item) && item.length === this.params) {
|
|
1224
|
+
this.done = true;
|
|
1225
|
+
this.keep = true;
|
|
1226
|
+
}
|
|
1227
|
+
};
|
|
1228
|
+
return $Size2;
|
|
1229
|
+
}(BaseOperation)
|
|
1230
|
+
);
|
|
1231
|
+
var assertGroupNotEmpty = function(values) {
|
|
1232
|
+
if (values.length === 0) {
|
|
1233
|
+
throw new Error("$and/$or/$nor must be a nonempty array");
|
|
1234
|
+
}
|
|
1235
|
+
};
|
|
1236
|
+
var $Or = (
|
|
1237
|
+
/** @class */
|
|
1238
|
+
function(_super) {
|
|
1239
|
+
__extends($Or2, _super);
|
|
1240
|
+
function $Or2() {
|
|
1241
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
1242
|
+
_this.propop = false;
|
|
1243
|
+
return _this;
|
|
1244
|
+
}
|
|
1245
|
+
$Or2.prototype.init = function() {
|
|
1246
|
+
var _this = this;
|
|
1247
|
+
assertGroupNotEmpty(this.params);
|
|
1248
|
+
this._ops = this.params.map(function(op) {
|
|
1249
|
+
return createQueryOperation(op, null, _this.options);
|
|
1250
|
+
});
|
|
1251
|
+
};
|
|
1252
|
+
$Or2.prototype.reset = function() {
|
|
1253
|
+
this.done = false;
|
|
1254
|
+
this.keep = false;
|
|
1255
|
+
for (var i = 0, length_2 = this._ops.length; i < length_2; i++) {
|
|
1256
|
+
this._ops[i].reset();
|
|
1257
|
+
}
|
|
1258
|
+
};
|
|
1259
|
+
$Or2.prototype.next = function(item, key, owner) {
|
|
1260
|
+
var done = false;
|
|
1261
|
+
var success = false;
|
|
1262
|
+
for (var i = 0, length_3 = this._ops.length; i < length_3; i++) {
|
|
1263
|
+
var op = this._ops[i];
|
|
1264
|
+
op.next(item, key, owner);
|
|
1265
|
+
if (op.keep) {
|
|
1266
|
+
done = true;
|
|
1267
|
+
success = op.keep;
|
|
1268
|
+
break;
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
this.keep = success;
|
|
1272
|
+
this.done = done;
|
|
1273
|
+
};
|
|
1274
|
+
return $Or2;
|
|
1275
|
+
}(BaseOperation)
|
|
1276
|
+
);
|
|
1277
|
+
var $Nor = (
|
|
1278
|
+
/** @class */
|
|
1279
|
+
function(_super) {
|
|
1280
|
+
__extends($Nor2, _super);
|
|
1281
|
+
function $Nor2() {
|
|
1282
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
1283
|
+
_this.propop = false;
|
|
1284
|
+
return _this;
|
|
1285
|
+
}
|
|
1286
|
+
$Nor2.prototype.next = function(item, key, owner) {
|
|
1287
|
+
_super.prototype.next.call(this, item, key, owner);
|
|
1288
|
+
this.keep = !this.keep;
|
|
1289
|
+
};
|
|
1290
|
+
return $Nor2;
|
|
1291
|
+
}($Or)
|
|
1292
|
+
);
|
|
1293
|
+
var $In = (
|
|
1294
|
+
/** @class */
|
|
1295
|
+
function(_super) {
|
|
1296
|
+
__extends($In2, _super);
|
|
1297
|
+
function $In2() {
|
|
1298
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
1299
|
+
_this.propop = true;
|
|
1300
|
+
return _this;
|
|
1301
|
+
}
|
|
1302
|
+
$In2.prototype.init = function() {
|
|
1303
|
+
var _this = this;
|
|
1304
|
+
this._testers = this.params.map(function(value) {
|
|
1305
|
+
if (containsOperation(value, _this.options)) {
|
|
1306
|
+
throw new Error("cannot nest $ under " + _this.name.toLowerCase());
|
|
1307
|
+
}
|
|
1308
|
+
return createTester(value, _this.options.compare);
|
|
1309
|
+
});
|
|
1310
|
+
};
|
|
1311
|
+
$In2.prototype.next = function(item, key, owner) {
|
|
1312
|
+
var done = false;
|
|
1313
|
+
var success = false;
|
|
1314
|
+
for (var i = 0, length_4 = this._testers.length; i < length_4; i++) {
|
|
1315
|
+
var test = this._testers[i];
|
|
1316
|
+
if (test(item)) {
|
|
1317
|
+
done = true;
|
|
1318
|
+
success = true;
|
|
1319
|
+
break;
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
this.keep = success;
|
|
1323
|
+
this.done = done;
|
|
1324
|
+
};
|
|
1325
|
+
return $In2;
|
|
1326
|
+
}(BaseOperation)
|
|
1327
|
+
);
|
|
1328
|
+
var $Nin = (
|
|
1329
|
+
/** @class */
|
|
1330
|
+
function(_super) {
|
|
1331
|
+
__extends($Nin2, _super);
|
|
1332
|
+
function $Nin2(params, ownerQuery, options, name) {
|
|
1333
|
+
var _this = _super.call(this, params, ownerQuery, options, name) || this;
|
|
1334
|
+
_this.propop = true;
|
|
1335
|
+
_this._in = new $In(params, ownerQuery, options, name);
|
|
1336
|
+
return _this;
|
|
1337
|
+
}
|
|
1338
|
+
$Nin2.prototype.next = function(item, key, owner, root) {
|
|
1339
|
+
this._in.next(item, key, owner);
|
|
1340
|
+
if (isArray(owner) && !root) {
|
|
1341
|
+
if (this._in.keep) {
|
|
1342
|
+
this.keep = false;
|
|
1343
|
+
this.done = true;
|
|
1344
|
+
} else if (key == owner.length - 1) {
|
|
1345
|
+
this.keep = true;
|
|
1346
|
+
this.done = true;
|
|
1347
|
+
}
|
|
1348
|
+
} else {
|
|
1349
|
+
this.keep = !this._in.keep;
|
|
1350
|
+
this.done = true;
|
|
1351
|
+
}
|
|
1352
|
+
};
|
|
1353
|
+
$Nin2.prototype.reset = function() {
|
|
1354
|
+
_super.prototype.reset.call(this);
|
|
1355
|
+
this._in.reset();
|
|
1356
|
+
};
|
|
1357
|
+
return $Nin2;
|
|
1358
|
+
}(BaseOperation)
|
|
1359
|
+
);
|
|
1360
|
+
var $Exists = (
|
|
1361
|
+
/** @class */
|
|
1362
|
+
function(_super) {
|
|
1363
|
+
__extends($Exists2, _super);
|
|
1364
|
+
function $Exists2() {
|
|
1365
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
1366
|
+
_this.propop = true;
|
|
1367
|
+
return _this;
|
|
1368
|
+
}
|
|
1369
|
+
$Exists2.prototype.next = function(item, key, owner) {
|
|
1370
|
+
if (owner.hasOwnProperty(key) === this.params) {
|
|
1371
|
+
this.done = true;
|
|
1372
|
+
this.keep = true;
|
|
1373
|
+
}
|
|
1374
|
+
};
|
|
1375
|
+
return $Exists2;
|
|
1376
|
+
}(BaseOperation)
|
|
1377
|
+
);
|
|
1378
|
+
var $And = (
|
|
1379
|
+
/** @class */
|
|
1380
|
+
function(_super) {
|
|
1381
|
+
__extends($And2, _super);
|
|
1382
|
+
function $And2(params, owneryQuery, options, name) {
|
|
1383
|
+
var _this = _super.call(this, params, owneryQuery, options, params.map(function(query) {
|
|
1384
|
+
return createQueryOperation(query, owneryQuery, options);
|
|
1385
|
+
}), name) || this;
|
|
1386
|
+
_this.propop = false;
|
|
1387
|
+
assertGroupNotEmpty(params);
|
|
1388
|
+
return _this;
|
|
1389
|
+
}
|
|
1390
|
+
$And2.prototype.next = function(item, key, owner, root) {
|
|
1391
|
+
this.childrenNext(item, key, owner, root);
|
|
1392
|
+
};
|
|
1393
|
+
return $And2;
|
|
1394
|
+
}(NamedGroupOperation)
|
|
1395
|
+
);
|
|
1396
|
+
var $All = (
|
|
1397
|
+
/** @class */
|
|
1398
|
+
function(_super) {
|
|
1399
|
+
__extends($All2, _super);
|
|
1400
|
+
function $All2(params, owneryQuery, options, name) {
|
|
1401
|
+
var _this = _super.call(this, params, owneryQuery, options, params.map(function(query) {
|
|
1402
|
+
return createQueryOperation(query, owneryQuery, options);
|
|
1403
|
+
}), name) || this;
|
|
1404
|
+
_this.propop = true;
|
|
1405
|
+
return _this;
|
|
1406
|
+
}
|
|
1407
|
+
$All2.prototype.next = function(item, key, owner, root) {
|
|
1408
|
+
this.childrenNext(item, key, owner, root);
|
|
1409
|
+
};
|
|
1410
|
+
return $All2;
|
|
1411
|
+
}(NamedGroupOperation)
|
|
1412
|
+
);
|
|
1413
|
+
var $eq = function(params, owneryQuery, options) {
|
|
1414
|
+
return new EqualsOperation(params, owneryQuery, options);
|
|
1415
|
+
};
|
|
1416
|
+
var $ne = function(params, owneryQuery, options, name) {
|
|
1417
|
+
return new $Ne(params, owneryQuery, options, name);
|
|
1418
|
+
};
|
|
1419
|
+
var $or = function(params, owneryQuery, options, name) {
|
|
1420
|
+
return new $Or(params, owneryQuery, options, name);
|
|
1421
|
+
};
|
|
1422
|
+
var $nor = function(params, owneryQuery, options, name) {
|
|
1423
|
+
return new $Nor(params, owneryQuery, options, name);
|
|
1424
|
+
};
|
|
1425
|
+
var $elemMatch = function(params, owneryQuery, options, name) {
|
|
1426
|
+
return new $ElemMatch(params, owneryQuery, options, name);
|
|
1427
|
+
};
|
|
1428
|
+
var $nin = function(params, owneryQuery, options, name) {
|
|
1429
|
+
return new $Nin(params, owneryQuery, options, name);
|
|
1430
|
+
};
|
|
1431
|
+
var $in = function(params, owneryQuery, options, name) {
|
|
1432
|
+
return new $In(params, owneryQuery, options, name);
|
|
1433
|
+
};
|
|
1434
|
+
var $lt = numericalOperation(function(params) {
|
|
1435
|
+
return function(b) {
|
|
1436
|
+
return b != null && b < params;
|
|
1437
|
+
};
|
|
1438
|
+
});
|
|
1439
|
+
var $lte = numericalOperation(function(params) {
|
|
1440
|
+
return function(b) {
|
|
1441
|
+
return b === params || b <= params;
|
|
1442
|
+
};
|
|
1443
|
+
});
|
|
1444
|
+
var $gt = numericalOperation(function(params) {
|
|
1445
|
+
return function(b) {
|
|
1446
|
+
return b != null && b > params;
|
|
1447
|
+
};
|
|
1448
|
+
});
|
|
1449
|
+
var $gte = numericalOperation(function(params) {
|
|
1450
|
+
return function(b) {
|
|
1451
|
+
return b === params || b >= params;
|
|
1452
|
+
};
|
|
1453
|
+
});
|
|
1454
|
+
var $mod = function(_a, owneryQuery, options) {
|
|
1455
|
+
var mod = _a[0], equalsValue = _a[1];
|
|
1456
|
+
return new EqualsOperation(function(b) {
|
|
1457
|
+
return comparable(b) % mod === equalsValue;
|
|
1458
|
+
}, owneryQuery, options);
|
|
1459
|
+
};
|
|
1460
|
+
var $exists = function(params, owneryQuery, options, name) {
|
|
1461
|
+
return new $Exists(params, owneryQuery, options, name);
|
|
1462
|
+
};
|
|
1463
|
+
var $regex = function(pattern, owneryQuery, options) {
|
|
1464
|
+
return new EqualsOperation(new RegExp(pattern, owneryQuery.$options), owneryQuery, options);
|
|
1465
|
+
};
|
|
1466
|
+
var $not = function(params, owneryQuery, options, name) {
|
|
1467
|
+
return new $Not(params, owneryQuery, options, name);
|
|
1468
|
+
};
|
|
1469
|
+
var typeAliases = {
|
|
1470
|
+
number: function(v) {
|
|
1471
|
+
return typeof v === "number";
|
|
1472
|
+
},
|
|
1473
|
+
string: function(v) {
|
|
1474
|
+
return typeof v === "string";
|
|
1475
|
+
},
|
|
1476
|
+
bool: function(v) {
|
|
1477
|
+
return typeof v === "boolean";
|
|
1478
|
+
},
|
|
1479
|
+
array: function(v) {
|
|
1480
|
+
return Array.isArray(v);
|
|
1481
|
+
},
|
|
1482
|
+
null: function(v) {
|
|
1483
|
+
return v === null;
|
|
1484
|
+
},
|
|
1485
|
+
timestamp: function(v) {
|
|
1486
|
+
return v instanceof Date;
|
|
1487
|
+
}
|
|
1488
|
+
};
|
|
1489
|
+
var $type = function(clazz, owneryQuery, options) {
|
|
1490
|
+
return new EqualsOperation(function(b) {
|
|
1491
|
+
if (typeof clazz === "string") {
|
|
1492
|
+
if (!typeAliases[clazz]) {
|
|
1493
|
+
throw new Error("Type alias does not exist");
|
|
1494
|
+
}
|
|
1495
|
+
return typeAliases[clazz](b);
|
|
1496
|
+
}
|
|
1497
|
+
return b != null ? b instanceof clazz || b.constructor === clazz : false;
|
|
1498
|
+
}, owneryQuery, options);
|
|
1499
|
+
};
|
|
1500
|
+
var $and = function(params, ownerQuery, options, name) {
|
|
1501
|
+
return new $And(params, ownerQuery, options, name);
|
|
1502
|
+
};
|
|
1503
|
+
var $all = function(params, ownerQuery, options, name) {
|
|
1504
|
+
return new $All(params, ownerQuery, options, name);
|
|
1505
|
+
};
|
|
1506
|
+
var $size = function(params, ownerQuery, options) {
|
|
1507
|
+
return new $Size(params, ownerQuery, options, "$size");
|
|
1508
|
+
};
|
|
1509
|
+
var $options = function() {
|
|
1510
|
+
return null;
|
|
1511
|
+
};
|
|
1512
|
+
var $where = function(params, ownerQuery, options) {
|
|
1513
|
+
var test;
|
|
1514
|
+
if (isFunction(params)) {
|
|
1515
|
+
test = params;
|
|
1516
|
+
} else if (!process.env.CSP_ENABLED) {
|
|
1517
|
+
test = new Function("obj", "return " + params);
|
|
1518
|
+
} else {
|
|
1519
|
+
throw new Error('In CSP mode, sift does not support strings in "$where" condition');
|
|
1520
|
+
}
|
|
1521
|
+
return new EqualsOperation(function(b) {
|
|
1522
|
+
return test.bind(b)(b);
|
|
1523
|
+
}, ownerQuery, options);
|
|
1524
|
+
};
|
|
1525
|
+
var defaultOperations = /* @__PURE__ */ Object.freeze({
|
|
1526
|
+
__proto__: null,
|
|
1527
|
+
$Size,
|
|
1528
|
+
$eq,
|
|
1529
|
+
$ne,
|
|
1530
|
+
$or,
|
|
1531
|
+
$nor,
|
|
1532
|
+
$elemMatch,
|
|
1533
|
+
$nin,
|
|
1534
|
+
$in,
|
|
1535
|
+
$lt,
|
|
1536
|
+
$lte,
|
|
1537
|
+
$gt,
|
|
1538
|
+
$gte,
|
|
1539
|
+
$mod,
|
|
1540
|
+
$exists,
|
|
1541
|
+
$regex,
|
|
1542
|
+
$not,
|
|
1543
|
+
$type,
|
|
1544
|
+
$and,
|
|
1545
|
+
$all,
|
|
1546
|
+
$size,
|
|
1547
|
+
$options,
|
|
1548
|
+
$where
|
|
1549
|
+
});
|
|
1550
|
+
var createDefaultQueryOperation = function(query, ownerQuery, _a) {
|
|
1551
|
+
var _b = _a === void 0 ? {} : _a, compare = _b.compare, operations = _b.operations;
|
|
1552
|
+
return createQueryOperation(query, ownerQuery, {
|
|
1553
|
+
compare,
|
|
1554
|
+
operations: Object.assign({}, defaultOperations, operations || {})
|
|
1555
|
+
});
|
|
1556
|
+
};
|
|
1557
|
+
var createDefaultQueryTester = function(query, options) {
|
|
1558
|
+
if (options === void 0) {
|
|
1559
|
+
options = {};
|
|
1560
|
+
}
|
|
1561
|
+
var op = createDefaultQueryOperation(query, null, options);
|
|
1562
|
+
return createOperationTester(op);
|
|
1563
|
+
};
|
|
1564
|
+
|
|
787
1565
|
// index.ts
|
|
788
1566
|
var __filename = fileURLToPath(import.meta.url);
|
|
789
1567
|
var __dirname = dirname(__filename);
|
|
@@ -810,29 +1588,29 @@ function toArg(flag, description) {
|
|
|
810
1588
|
}
|
|
811
1589
|
};
|
|
812
1590
|
}
|
|
813
|
-
function findDescription(key
|
|
814
|
-
const
|
|
815
|
-
if (!
|
|
1591
|
+
function findDescription(key) {
|
|
1592
|
+
const feat = features.find((f) => f.flag === key);
|
|
1593
|
+
if (!feat)
|
|
816
1594
|
return;
|
|
817
|
-
if (
|
|
818
|
-
return
|
|
819
|
-
} else if (
|
|
820
|
-
return `Include ${
|
|
821
|
-
} else if (
|
|
822
|
-
return `Include ${
|
|
1595
|
+
if (feat.description) {
|
|
1596
|
+
return feat.description;
|
|
1597
|
+
} else if (feat.label && feat.url) {
|
|
1598
|
+
return `Include ${feat.label} - ${feat.url}`;
|
|
1599
|
+
} else if (feat.label) {
|
|
1600
|
+
return `Include ${feat.label}`;
|
|
823
1601
|
}
|
|
824
1602
|
}
|
|
825
|
-
function printOK(dist, flags
|
|
1603
|
+
function printOK(dist, flags) {
|
|
826
1604
|
const arrow0 = withIcon("\u2192", blueBright);
|
|
827
1605
|
const list3 = withIcon("-", void 0, 3);
|
|
828
1606
|
const cmd3 = withIcon("$", gray, 3);
|
|
829
1607
|
console.log(bold(`${green("\u2713")} Project created at ${cyan(dist)} with:`));
|
|
830
|
-
console.log(list3(green("
|
|
1608
|
+
console.log(list3(green("Vike")));
|
|
831
1609
|
for (const key of flags) {
|
|
832
|
-
const
|
|
833
|
-
if (!
|
|
1610
|
+
const feature = features.find((f) => f.flag === key);
|
|
1611
|
+
if (!feature || !feature.label)
|
|
834
1612
|
continue;
|
|
835
|
-
console.log(list3(green(
|
|
1613
|
+
console.log(list3(green(feature.label)));
|
|
836
1614
|
}
|
|
837
1615
|
console.log("\n" + bold(arrow0("Next steps:")));
|
|
838
1616
|
console.log(cmd3(`cd ${dist}`));
|
|
@@ -843,7 +1621,8 @@ var defaultDef = {
|
|
|
843
1621
|
project: {
|
|
844
1622
|
type: "positional",
|
|
845
1623
|
description: "Project directory",
|
|
846
|
-
required:
|
|
1624
|
+
required: false,
|
|
1625
|
+
default: "my-app"
|
|
847
1626
|
}
|
|
848
1627
|
};
|
|
849
1628
|
function yn(value, default_) {
|
|
@@ -890,8 +1669,7 @@ async function checkArguments(args) {
|
|
|
890
1669
|
}
|
|
891
1670
|
}
|
|
892
1671
|
function checkRules(flags) {
|
|
893
|
-
const
|
|
894
|
-
const potentialRulesMessages = execRules(flagsWithNs, rulesMessages);
|
|
1672
|
+
const potentialRulesMessages = execRules(flags, rulesMessages);
|
|
895
1673
|
const infos = potentialRulesMessages.filter((m) => m.type === "info");
|
|
896
1674
|
const warnings = potentialRulesMessages.filter((m) => m.type === "warning");
|
|
897
1675
|
const errors = potentialRulesMessages.filter((m) => m.type === "error");
|
|
@@ -936,11 +1714,8 @@ async function retrieveHooks(hooks) {
|
|
|
936
1714
|
return map;
|
|
937
1715
|
}
|
|
938
1716
|
function testFlags(flags, bl) {
|
|
939
|
-
if (bl.config.
|
|
940
|
-
return
|
|
941
|
-
}
|
|
942
|
-
if (Array.isArray(bl.config.includeIf)) {
|
|
943
|
-
return bl.config.includeIf.every((f) => flags.includes(f));
|
|
1717
|
+
if (bl.config.if) {
|
|
1718
|
+
return createDefaultQueryTester(bl.config.if)(flags.map((f) => ({ flag: f })));
|
|
944
1719
|
}
|
|
945
1720
|
return true;
|
|
946
1721
|
}
|
|
@@ -956,13 +1731,12 @@ async function run() {
|
|
|
956
1731
|
args: Object.assign(
|
|
957
1732
|
{},
|
|
958
1733
|
defaultDef,
|
|
959
|
-
...
|
|
1734
|
+
...coreFlags.map((k) => toArg(k, findDescription(k)))
|
|
960
1735
|
),
|
|
961
1736
|
async run({ args }) {
|
|
962
1737
|
await checkArguments(args);
|
|
963
1738
|
const sources = [];
|
|
964
1739
|
const hooks = [];
|
|
965
|
-
const features = [];
|
|
966
1740
|
const flags = Object.entries(args).filter(([, val]) => val === true).map(([key]) => key);
|
|
967
1741
|
checkRules(flags);
|
|
968
1742
|
boilerplates.sort((b1, b2) => {
|
|
@@ -986,12 +1760,9 @@ async function run() {
|
|
|
986
1760
|
}
|
|
987
1761
|
}
|
|
988
1762
|
}
|
|
989
|
-
for (const flag of flags) {
|
|
990
|
-
features.push(coreFlags.get(flag));
|
|
991
|
-
}
|
|
992
1763
|
const hooksMap = await retrieveHooks(hooks);
|
|
993
1764
|
const meta = {
|
|
994
|
-
BATI_MODULES:
|
|
1765
|
+
BATI_MODULES: flags
|
|
995
1766
|
};
|
|
996
1767
|
await main(
|
|
997
1768
|
{
|
|
@@ -1000,7 +1771,7 @@ async function run() {
|
|
|
1000
1771
|
},
|
|
1001
1772
|
meta
|
|
1002
1773
|
);
|
|
1003
|
-
printOK(args.project, flags
|
|
1774
|
+
printOK(args.project, flags);
|
|
1004
1775
|
for (const oncli of hooksMap.get("cli") ?? []) {
|
|
1005
1776
|
await oncli(meta);
|
|
1006
1777
|
}
|
|
@@ -1017,3 +1788,21 @@ run().then(() => {
|
|
|
1017
1788
|
export {
|
|
1018
1789
|
yn as default
|
|
1019
1790
|
};
|
|
1791
|
+
/*! Bundled license information:
|
|
1792
|
+
|
|
1793
|
+
sift/es5m/index.js:
|
|
1794
|
+
(*! *****************************************************************************
|
|
1795
|
+
Copyright (c) Microsoft Corporation.
|
|
1796
|
+
|
|
1797
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
1798
|
+
purpose with or without fee is hereby granted.
|
|
1799
|
+
|
|
1800
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
1801
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
1802
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
1803
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
1804
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
1805
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1806
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
1807
|
+
***************************************************************************** *)
|
|
1808
|
+
*/
|