@batijs/cli 0.0.87 → 0.0.90
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 +3 -3
- package/dist/boilerplates/@batijs/edgedb/{package-HMOHSPQH.js → package-GNDOJELP.js} +4 -4
- package/dist/boilerplates/@batijs/eslint/files/$package.json.js +17 -0
- package/dist/boilerplates/@batijs/eslint/files/.eslintignore +7 -0
- package/dist/boilerplates/@batijs/eslint/files/.eslintrc.json +10 -0
- package/dist/boilerplates/@batijs/eslint/package-5LDRGH5F.js +61 -0
- package/dist/boilerplates/@batijs/express/files/$package.json.js +4 -4
- package/dist/boilerplates/@batijs/express/files/express-entry.ts +11 -11
- package/dist/boilerplates/@batijs/express/{package-LVAF3GMH.js → package-RZJTUW3J.js} +4 -4
- package/dist/boilerplates/@batijs/h3/files/$package.json.js +4 -4
- package/dist/boilerplates/@batijs/h3/files/h3-entry.ts +2 -2
- package/dist/boilerplates/@batijs/h3/{package-OCNH7HWJ.js → package-BKHMKPRT.js} +4 -4
- package/dist/boilerplates/@batijs/hattip/files/$package.json.js +4 -4
- package/dist/boilerplates/@batijs/hattip/files/$vite.config.ts.js +2 -2
- package/dist/boilerplates/@batijs/hattip/files/hattip-entry.ts +4 -4
- package/dist/boilerplates/@batijs/hattip/{package-FDRQH742.js → package-OYV3342B.js} +4 -4
- package/dist/boilerplates/@batijs/prisma/files/$.env.js +2 -2
- package/dist/boilerplates/@batijs/prisma/files/$package.json.js +3 -3
- package/dist/boilerplates/@batijs/prisma/{package-JX35CIXF.js → package-ODDEEC2P.js} +4 -4
- package/dist/boilerplates/@batijs/react/files/$.eslintrc.json.js +16 -0
- package/dist/boilerplates/@batijs/react/files/$package.json.js +8 -3
- package/dist/boilerplates/@batijs/react/files/$tsconfig.json.js +2 -2
- package/dist/boilerplates/@batijs/react/files/$vite.config.ts.js +3 -3
- package/dist/boilerplates/@batijs/react/files/components/Link.tsx +8 -10
- package/dist/boilerplates/@batijs/react/files/layouts/HeadDefault.tsx +1 -1
- package/dist/boilerplates/@batijs/react/files/layouts/LayoutDefault.tsx +11 -11
- package/dist/boilerplates/@batijs/react/files/pages/_error/+Page.tsx +1 -3
- package/dist/boilerplates/@batijs/react/files/pages/index/+Page.tsx +1 -1
- package/dist/boilerplates/@batijs/react/files/pages/index/Counter.tsx +2 -4
- package/dist/boilerplates/@batijs/react/files/pages/star-wars/@id/+Page.tsx +1 -3
- package/dist/boilerplates/@batijs/react/files/pages/star-wars/@id/+onBeforeRender.ts +2 -4
- package/dist/boilerplates/@batijs/react/files/pages/star-wars/filterMovieData.ts +1 -5
- package/dist/boilerplates/@batijs/react/files/pages/star-wars/index/+Page.tsx +1 -3
- package/dist/boilerplates/@batijs/react/files/pages/star-wars/index/+onBeforeRender.ts +2 -5
- package/dist/boilerplates/@batijs/react/{package-5YB3UKUO.js → package-EPEDDI5A.js} +10 -6
- package/dist/boilerplates/@batijs/react-telefunc/files/database/todoItems.ts +2 -5
- package/dist/boilerplates/@batijs/react-telefunc/files/pages/todo/+config.h.ts +3 -1
- package/dist/boilerplates/@batijs/react-telefunc/files/pages/todo/+onBeforeRender.ts +1 -3
- package/dist/boilerplates/@batijs/react-telefunc/files/pages/todo/TodoList.telefunc.ts +2 -4
- package/dist/boilerplates/@batijs/shared/files/$index.html.js +188 -2
- package/dist/boilerplates/@batijs/solid/files/$.eslintrc.json.js +13 -0
- package/dist/boilerplates/@batijs/solid/files/$package.json.js +8 -3
- package/dist/boilerplates/@batijs/solid/files/$tsconfig.json.js +2 -2
- package/dist/boilerplates/@batijs/solid/files/$vite.config.ts.js +3 -3
- package/dist/boilerplates/@batijs/solid/files/layouts/HeadDefault.tsx +2 -2
- package/dist/boilerplates/@batijs/solid/files/layouts/LayoutDefault.tsx +11 -11
- package/dist/boilerplates/@batijs/solid/files/pages/_error/+Page.tsx +17 -16
- 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/files/pages/star-wars/index/+Page.tsx +1 -1
- package/dist/boilerplates/@batijs/solid/files/pages/star-wars/index/+onBeforeRender.ts +3 -2
- package/dist/boilerplates/@batijs/solid/{package-BLWCB4NH.js → package-GTL3FIFH.js} +7 -6
- package/dist/boilerplates/@batijs/solid-telefunc/files/pages/todo/+Page.tsx +3 -4
- package/dist/boilerplates/@batijs/solid-telefunc/files/pages/todo/+onBeforeRender.ts +2 -2
- package/dist/boilerplates/@batijs/solid-telefunc/files/pages/todo/TodoList.tsx +3 -4
- package/dist/boilerplates/@batijs/tailwindcss/files/$package.json.js +3 -3
- package/dist/boilerplates/@batijs/tailwindcss/{package-34V34OFJ.js → package-2PEXROGS.js} +4 -4
- package/dist/boilerplates/@batijs/telefunc/files/$package.json.js +3 -3
- package/dist/boilerplates/@batijs/telefunc/files/$vite.config.ts.js +2 -2
- package/dist/boilerplates/@batijs/telefunc/{package-LPS6TFJV.js → package-YBU74HVR.js} +4 -4
- package/dist/boilerplates/@batijs/vercel/files/$package.json.js +3 -3
- package/dist/boilerplates/@batijs/vercel/files/$vite.config.ts.js +2 -2
- package/dist/boilerplates/@batijs/vercel/{package-EAL6NF5P.js → package-75BTKTCC.js} +4 -4
- package/dist/boilerplates/@batijs/vue/files/$.eslintrc.json.js +16 -0
- package/dist/boilerplates/@batijs/vue/files/$package.json.js +15 -4
- package/dist/boilerplates/@batijs/vue/files/$tsconfig.json.js +2 -2
- package/dist/boilerplates/@batijs/vue/files/$vite.config.ts.js +2 -2
- package/dist/boilerplates/@batijs/vue/files/components/Content.vue +1 -1
- package/dist/boilerplates/@batijs/vue/files/components/Counter.vue +3 -3
- package/dist/boilerplates/@batijs/vue/files/components/Link.vue +13 -11
- package/dist/boilerplates/@batijs/vue/files/components/Logo.vue +6 -2
- package/dist/boilerplates/@batijs/vue/files/components/Sidebar.vue +1 -1
- package/dist/boilerplates/@batijs/vue/files/layouts/HeadDefault.vue +10 -3
- package/dist/boilerplates/@batijs/vue/files/layouts/LayoutDefault.vue +11 -5
- package/dist/boilerplates/@batijs/vue/files/pages/index/+Page.vue +1 -1
- package/dist/boilerplates/@batijs/vue/files/pages/star-wars/@id/+Page.vue +8 -3
- package/dist/boilerplates/@batijs/vue/files/pages/star-wars/index/+Page.vue +10 -2
- package/dist/boilerplates/@batijs/vue/files/pages/star-wars/index/+onBeforeRender.ts +3 -2
- package/dist/boilerplates/@batijs/vue/{package-HDC4A5UP.js → package-7JAOIAC3.js} +6 -5
- package/dist/boilerplates/@batijs/vue-telefunc/files/components/TodoList.vue +15 -4
- package/dist/boilerplates/@batijs/vue-telefunc/files/pages/todo/+Page.vue +3 -2
- package/dist/boilerplates/boilerplates.json +70 -80
- package/dist/index.js +901 -74
- package/package.json +6 -4
package/dist/index.js
CHANGED
|
@@ -448,11 +448,25 @@ async function runMain(cmd, opts = {}) {
|
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
450
|
|
|
451
|
-
// ../build/dist/
|
|
452
|
-
import { loadFile, renderSquirrelly, transformAstAndGenerate } from "@batijs/core";
|
|
451
|
+
// ../build/dist/index.js
|
|
453
452
|
import { existsSync } from "fs";
|
|
454
453
|
import { copyFile, mkdir, opendir, readFile, writeFile } from "fs/promises";
|
|
455
454
|
import path from "path";
|
|
455
|
+
import { loadFile, renderSquirrelly, transformAstAndGenerate } from "@batijs/core";
|
|
456
|
+
function queue() {
|
|
457
|
+
const tasks = [];
|
|
458
|
+
return {
|
|
459
|
+
add(task) {
|
|
460
|
+
tasks.push(task);
|
|
461
|
+
},
|
|
462
|
+
async run() {
|
|
463
|
+
let task;
|
|
464
|
+
while (task = tasks.shift()) {
|
|
465
|
+
await task();
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
}
|
|
456
470
|
var reIgnoreFile = /^(chunk-|asset-|#)/gi;
|
|
457
471
|
var isWin = process.platform === "win32";
|
|
458
472
|
function toDist(filepath, source, dist) {
|
|
@@ -508,9 +522,16 @@ async function fileContainsBatiMeta(filepath) {
|
|
|
508
522
|
const code = await readFile(filepath, { encoding: "utf-8" });
|
|
509
523
|
return code.includes("import.meta.BATI_");
|
|
510
524
|
}
|
|
525
|
+
async function importTransformer(p) {
|
|
526
|
+
const importFile = isWin ? "file://" + p : p;
|
|
527
|
+
const f = await import(importFile);
|
|
528
|
+
return f.default;
|
|
529
|
+
}
|
|
511
530
|
async function main(options, meta) {
|
|
512
531
|
const sources = Array.isArray(options.source) ? options.source : [options.source];
|
|
513
532
|
const targets = /* @__PURE__ */ new Set();
|
|
533
|
+
const simpleCopyQ = queue();
|
|
534
|
+
const transformAndWriteQ = queue();
|
|
514
535
|
for (const source of sources) {
|
|
515
536
|
for await (const p of walk(source)) {
|
|
516
537
|
const target = toDist(p, source, options.dist);
|
|
@@ -523,48 +544,63 @@ async function main(options, meta) {
|
|
|
523
544
|
Please report this issue to https://github.com/magne4000/bati`
|
|
524
545
|
);
|
|
525
546
|
} else if (parsed.name.startsWith("$") && parsed.ext.match(/\.jsx?$/)) {
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
547
|
+
transformAndWriteQ.add(async () => {
|
|
548
|
+
const transformer = await importTransformer(p);
|
|
549
|
+
const rf = () => {
|
|
550
|
+
return readFile(target, { encoding: "utf-8" });
|
|
551
|
+
};
|
|
552
|
+
const fileContent = transformFileAfterExec(
|
|
553
|
+
target,
|
|
554
|
+
await transformer({
|
|
555
|
+
readfile: targets.has(target) ? rf : void 0,
|
|
556
|
+
meta,
|
|
557
|
+
source,
|
|
558
|
+
target
|
|
559
|
+
})
|
|
560
|
+
);
|
|
561
|
+
if (fileContent !== null) {
|
|
562
|
+
await safeWriteFile(target, fileContent);
|
|
563
|
+
targets.add(target);
|
|
564
|
+
}
|
|
565
|
+
});
|
|
536
566
|
} else if (await fileContainsBatiMeta(p)) {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
567
|
+
transformAndWriteQ.add(async () => {
|
|
568
|
+
let fileContent = "";
|
|
569
|
+
if (parsed.ext.match(/\.[tj]sx?$/)) {
|
|
570
|
+
const mod = await loadFile(p);
|
|
571
|
+
fileContent = await transformAstAndGenerate(mod.$ast, meta, {
|
|
572
|
+
filepath: p
|
|
573
|
+
});
|
|
574
|
+
} else {
|
|
575
|
+
const template = await readFile(p, { encoding: "utf-8" });
|
|
576
|
+
try {
|
|
577
|
+
fileContent = renderSquirrelly(template, meta);
|
|
578
|
+
} catch (e) {
|
|
579
|
+
console.error("SquirrellyJS error while rendering", p);
|
|
580
|
+
throw e;
|
|
581
|
+
}
|
|
550
582
|
}
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
583
|
+
if (fileContent) {
|
|
584
|
+
await safeWriteFile(target, fileContent);
|
|
585
|
+
targets.add(target);
|
|
586
|
+
}
|
|
587
|
+
});
|
|
556
588
|
} else {
|
|
557
|
-
|
|
558
|
-
|
|
589
|
+
simpleCopyQ.add(async () => {
|
|
590
|
+
await safeCopyFile(p, target);
|
|
591
|
+
targets.add(target);
|
|
592
|
+
});
|
|
559
593
|
}
|
|
560
594
|
}
|
|
561
595
|
}
|
|
596
|
+
await simpleCopyQ.run();
|
|
597
|
+
await transformAndWriteQ.run();
|
|
562
598
|
}
|
|
563
599
|
|
|
564
600
|
// package.json
|
|
565
601
|
var package_default = {
|
|
566
602
|
name: "@batijs/cli",
|
|
567
|
-
version: "0.0.
|
|
603
|
+
version: "0.0.90",
|
|
568
604
|
type: "module",
|
|
569
605
|
scripts: {
|
|
570
606
|
prerelease: "rimraf ./dist",
|
|
@@ -586,12 +622,14 @@ var package_default = {
|
|
|
586
622
|
esbuild: "^0.19.4",
|
|
587
623
|
execa: "^8.0.1",
|
|
588
624
|
rimraf: "^5.0.5",
|
|
625
|
+
sift: "^17.0.1",
|
|
589
626
|
tsup: "^7.2.0",
|
|
590
627
|
typescript: "^5.2.2",
|
|
591
628
|
vite: "^4.4.11"
|
|
592
629
|
},
|
|
593
630
|
dependencies: {
|
|
594
|
-
"@batijs/core": "workspace:*"
|
|
631
|
+
"@batijs/core": "workspace:*",
|
|
632
|
+
"@batijs/features": "workspace:*"
|
|
595
633
|
},
|
|
596
634
|
bin: "./dist/index.js",
|
|
597
635
|
exports: {
|
|
@@ -603,8 +641,9 @@ var package_default = {
|
|
|
603
641
|
};
|
|
604
642
|
|
|
605
643
|
// index.ts
|
|
606
|
-
import {
|
|
607
|
-
import {
|
|
644
|
+
import { withIcon } from "@batijs/core";
|
|
645
|
+
import { features, flags as coreFlags } from "@batijs/features";
|
|
646
|
+
import { execRules } from "@batijs/features/rules";
|
|
608
647
|
import { existsSync as existsSync2 } from "fs";
|
|
609
648
|
import { fileURLToPath } from "url";
|
|
610
649
|
import { dirname, join, parse } from "path";
|
|
@@ -726,7 +765,7 @@ var {
|
|
|
726
765
|
} = createColors();
|
|
727
766
|
|
|
728
767
|
// rules.ts
|
|
729
|
-
import { RulesMessage } from "@batijs/
|
|
768
|
+
import { RulesMessage } from "@batijs/features/rules";
|
|
730
769
|
function error(value) {
|
|
731
770
|
return {
|
|
732
771
|
type: "error",
|
|
@@ -748,6 +787,781 @@ var rulesMessages = {
|
|
|
748
787
|
[RulesMessage.INFO_HATTIP]: info(`${inverse(bold("HatTip"))} is an experimental project`)
|
|
749
788
|
};
|
|
750
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
|
+
|
|
751
1565
|
// index.ts
|
|
752
1566
|
var __filename = fileURLToPath(import.meta.url);
|
|
753
1567
|
var __dirname = dirname(__filename);
|
|
@@ -774,29 +1588,29 @@ function toArg(flag, description) {
|
|
|
774
1588
|
}
|
|
775
1589
|
};
|
|
776
1590
|
}
|
|
777
|
-
function findDescription(key
|
|
778
|
-
const
|
|
779
|
-
if (!
|
|
1591
|
+
function findDescription(key) {
|
|
1592
|
+
const feat = features.find((f) => f.flag === key);
|
|
1593
|
+
if (!feat)
|
|
780
1594
|
return;
|
|
781
|
-
if (
|
|
782
|
-
return
|
|
783
|
-
} else if (
|
|
784
|
-
return `Include ${
|
|
785
|
-
} else if (
|
|
786
|
-
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}`;
|
|
787
1601
|
}
|
|
788
1602
|
}
|
|
789
|
-
function printOK(dist, flags
|
|
1603
|
+
function printOK(dist, flags) {
|
|
790
1604
|
const arrow0 = withIcon("\u2192", blueBright);
|
|
791
1605
|
const list3 = withIcon("-", void 0, 3);
|
|
792
1606
|
const cmd3 = withIcon("$", gray, 3);
|
|
793
1607
|
console.log(bold(`${green("\u2713")} Project created at ${cyan(dist)} with:`));
|
|
794
1608
|
console.log(list3(green("Typescript")));
|
|
795
1609
|
for (const key of flags) {
|
|
796
|
-
const
|
|
797
|
-
if (!
|
|
1610
|
+
const feature = features.find((f) => f.flag === key);
|
|
1611
|
+
if (!feature || !feature.label)
|
|
798
1612
|
continue;
|
|
799
|
-
console.log(list3(green(
|
|
1613
|
+
console.log(list3(green(feature.label)));
|
|
800
1614
|
}
|
|
801
1615
|
console.log("\n" + bold(arrow0("Next steps:")));
|
|
802
1616
|
console.log(cmd3(`cd ${dist}`));
|
|
@@ -854,8 +1668,7 @@ async function checkArguments(args) {
|
|
|
854
1668
|
}
|
|
855
1669
|
}
|
|
856
1670
|
function checkRules(flags) {
|
|
857
|
-
const
|
|
858
|
-
const potentialRulesMessages = execRules(flagsWithNs, rulesMessages);
|
|
1671
|
+
const potentialRulesMessages = execRules(flags, rulesMessages);
|
|
859
1672
|
const infos = potentialRulesMessages.filter((m) => m.type === "info");
|
|
860
1673
|
const warnings = potentialRulesMessages.filter((m) => m.type === "warning");
|
|
861
1674
|
const errors = potentialRulesMessages.filter((m) => m.type === "error");
|
|
@@ -900,13 +1713,10 @@ async function retrieveHooks(hooks) {
|
|
|
900
1713
|
return map;
|
|
901
1714
|
}
|
|
902
1715
|
function testFlags(flags, bl) {
|
|
903
|
-
if (
|
|
904
|
-
return
|
|
905
|
-
}
|
|
906
|
-
if (Array.isArray(bl.config.includeIf)) {
|
|
907
|
-
return bl.config.includeIf.every((f) => flags.includes(f));
|
|
1716
|
+
if (bl.config.if) {
|
|
1717
|
+
return createDefaultQueryTester(bl.config.if)(flags.map((f) => ({ flag: f })));
|
|
908
1718
|
}
|
|
909
|
-
return
|
|
1719
|
+
return true;
|
|
910
1720
|
}
|
|
911
1721
|
async function run() {
|
|
912
1722
|
const dir = boilerplatesDir();
|
|
@@ -920,24 +1730,26 @@ async function run() {
|
|
|
920
1730
|
args: Object.assign(
|
|
921
1731
|
{},
|
|
922
1732
|
defaultDef,
|
|
923
|
-
...
|
|
1733
|
+
...coreFlags.map((k) => toArg(k, findDescription(k)))
|
|
924
1734
|
),
|
|
925
1735
|
async run({ args }) {
|
|
926
1736
|
await checkArguments(args);
|
|
927
1737
|
const sources = [];
|
|
928
1738
|
const hooks = [];
|
|
929
|
-
const features = [];
|
|
930
1739
|
const flags = Object.entries(args).filter(([, val]) => val === true).map(([key]) => key);
|
|
931
1740
|
checkRules(flags);
|
|
932
|
-
|
|
933
|
-
if (
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
1741
|
+
boilerplates.sort((b1, b2) => {
|
|
1742
|
+
if (b1.config.enforce === "pre")
|
|
1743
|
+
return -1;
|
|
1744
|
+
if (b1.config.enforce === "post")
|
|
1745
|
+
return 1;
|
|
1746
|
+
if (b2.config.enforce === "pre")
|
|
1747
|
+
return 1;
|
|
1748
|
+
if (b2.config.enforce === "post")
|
|
1749
|
+
return -1;
|
|
1750
|
+
return 0;
|
|
1751
|
+
});
|
|
1752
|
+
for (const bl of boilerplates) {
|
|
941
1753
|
if (testFlags(flags, bl)) {
|
|
942
1754
|
if (bl.subfolders.includes("files")) {
|
|
943
1755
|
sources.push(join(dir, bl.folder, "files"));
|
|
@@ -947,12 +1759,9 @@ async function run() {
|
|
|
947
1759
|
}
|
|
948
1760
|
}
|
|
949
1761
|
}
|
|
950
|
-
for (const flag of flags) {
|
|
951
|
-
features.push(coreFlags.get(flag));
|
|
952
|
-
}
|
|
953
1762
|
const hooksMap = await retrieveHooks(hooks);
|
|
954
1763
|
const meta = {
|
|
955
|
-
BATI_MODULES:
|
|
1764
|
+
BATI_MODULES: flags
|
|
956
1765
|
};
|
|
957
1766
|
await main(
|
|
958
1767
|
{
|
|
@@ -961,7 +1770,7 @@ async function run() {
|
|
|
961
1770
|
},
|
|
962
1771
|
meta
|
|
963
1772
|
);
|
|
964
|
-
printOK(args.project, flags
|
|
1773
|
+
printOK(args.project, flags);
|
|
965
1774
|
for (const oncli of hooksMap.get("cli") ?? []) {
|
|
966
1775
|
await oncli(meta);
|
|
967
1776
|
}
|
|
@@ -978,3 +1787,21 @@ run().then(() => {
|
|
|
978
1787
|
export {
|
|
979
1788
|
yn as default
|
|
980
1789
|
};
|
|
1790
|
+
/*! Bundled license information:
|
|
1791
|
+
|
|
1792
|
+
sift/es5m/index.js:
|
|
1793
|
+
(*! *****************************************************************************
|
|
1794
|
+
Copyright (c) Microsoft Corporation.
|
|
1795
|
+
|
|
1796
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
1797
|
+
purpose with or without fee is hereby granted.
|
|
1798
|
+
|
|
1799
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
1800
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
1801
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
1802
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
1803
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
1804
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1805
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
1806
|
+
***************************************************************************** *)
|
|
1807
|
+
*/
|