@batijs/cli 0.0.87 → 0.0.88
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-Z3MWAXVW.js} +1 -1
- 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-6IZEDCMJ.js +61 -0
- package/dist/boilerplates/@batijs/express/files/$package.json.js +4 -4
- package/dist/boilerplates/@batijs/express/{package-LVAF3GMH.js → package-TAXLRPPG.js} +1 -1
- package/dist/boilerplates/@batijs/h3/files/$package.json.js +4 -4
- package/dist/boilerplates/@batijs/h3/{package-OCNH7HWJ.js → package-GAI6KFVK.js} +1 -1
- 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/{package-FDRQH742.js → package-3BN33DJA.js} +1 -1
- 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-5JR5MUIX.js} +1 -1
- 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/LayoutDefault.tsx +1 -1
- package/dist/boilerplates/@batijs/react/files/pages/_error/+Page.tsx +1 -3
- package/dist/boilerplates/@batijs/react/files/pages/index/Counter.tsx +1 -3
- 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-EYTH4VNP.js} +7 -3
- 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 +2 -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 +1 -1
- package/dist/boilerplates/@batijs/solid/files/pages/_error/+Page.tsx +17 -16
- 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-3SC4XVSR.js} +4 -3
- 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-GTN2QH7M.js} +1 -1
- 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-3G2SQFKV.js} +1 -1
- 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-2NMHCJGC.js} +1 -1
- 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/Counter.vue +2 -2
- package/dist/boilerplates/@batijs/vue/files/components/Link.vue +13 -11
- package/dist/boilerplates/@batijs/vue/files/components/Logo.vue +5 -1
- package/dist/boilerplates/@batijs/vue/files/layouts/HeadDefault.vue +9 -2
- package/dist/boilerplates/@batijs/vue/files/layouts/LayoutDefault.vue +9 -3
- 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-SEZV7AAY.js} +3 -2
- 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 +15 -1
- package/dist/index.js +84 -45
- package/package.json +4 -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.88",
|
|
568
604
|
type: "module",
|
|
569
605
|
scripts: {
|
|
570
606
|
prerelease: "rimraf ./dist",
|
|
@@ -900,13 +936,13 @@ async function retrieveHooks(hooks) {
|
|
|
900
936
|
return map;
|
|
901
937
|
}
|
|
902
938
|
function testFlags(flags, bl) {
|
|
903
|
-
if (
|
|
904
|
-
return
|
|
939
|
+
if (bl.config.flag) {
|
|
940
|
+
return flags.includes(bl.config.flag);
|
|
905
941
|
}
|
|
906
942
|
if (Array.isArray(bl.config.includeIf)) {
|
|
907
943
|
return bl.config.includeIf.every((f) => flags.includes(f));
|
|
908
944
|
}
|
|
909
|
-
return
|
|
945
|
+
return true;
|
|
910
946
|
}
|
|
911
947
|
async function run() {
|
|
912
948
|
const dir = boilerplatesDir();
|
|
@@ -929,15 +965,18 @@ async function run() {
|
|
|
929
965
|
const features = [];
|
|
930
966
|
const flags = Object.entries(args).filter(([, val]) => val === true).map(([key]) => key);
|
|
931
967
|
checkRules(flags);
|
|
932
|
-
|
|
933
|
-
if (
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
968
|
+
boilerplates.sort((b1, b2) => {
|
|
969
|
+
if (b1.config.enforce === "pre")
|
|
970
|
+
return -1;
|
|
971
|
+
if (b1.config.enforce === "post")
|
|
972
|
+
return 1;
|
|
973
|
+
if (b2.config.enforce === "pre")
|
|
974
|
+
return 1;
|
|
975
|
+
if (b2.config.enforce === "post")
|
|
976
|
+
return -1;
|
|
977
|
+
return 0;
|
|
978
|
+
});
|
|
979
|
+
for (const bl of boilerplates) {
|
|
941
980
|
if (testFlags(flags, bl)) {
|
|
942
981
|
if (bl.subfolders.includes("files")) {
|
|
943
982
|
sources.push(join(dir, bl.folder, "files"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@batijs/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.88",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"description": "Next-gen scaffolder. Get started with fully-functional apps, and choose any tool you want",
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"tsup": "^7.2.0",
|
|
19
19
|
"typescript": "^5.2.2",
|
|
20
20
|
"vite": "^4.4.11",
|
|
21
|
-
"@batijs/build": "0.0.
|
|
22
|
-
"@batijs/tsup": "0.0.
|
|
21
|
+
"@batijs/build": "0.0.88",
|
|
22
|
+
"@batijs/tsup": "0.0.88"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@batijs/core": "0.0.
|
|
25
|
+
"@batijs/core": "0.0.88"
|
|
26
26
|
},
|
|
27
27
|
"bin": "./dist/index.js",
|
|
28
28
|
"exports": {
|