@batijs/cli 0.0.15 → 0.0.17

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.
Files changed (30) hide show
  1. package/dist/boilerplates/@batijs/edgedb/$package.json.js +14 -0
  2. package/dist/boilerplates/@batijs/edgedb/chunk-package-YA6LQX6A.js +62 -0
  3. package/dist/boilerplates/@batijs/edgedb/dbschema/default.esdl +3 -0
  4. package/dist/boilerplates/@batijs/edgedb/dbschema/futures.esdl +4 -0
  5. package/dist/boilerplates/@batijs/edgedb/dbschema/migrations/.gitkeep +0 -0
  6. package/dist/boilerplates/@batijs/edgedb/edgedb.toml +2 -0
  7. package/dist/boilerplates/@batijs/express/$package.json.js +2 -2
  8. package/dist/boilerplates/@batijs/express/{chunk-package-4Z6WSCOA.js → chunk-package-HAYHYJN6.js} +3 -1
  9. package/dist/boilerplates/@batijs/express/express-entry.ts +5 -8
  10. package/dist/boilerplates/@batijs/hattip/$package.json.js +2 -2
  11. package/dist/boilerplates/@batijs/hattip/{chunk-package-TWBPPJM3.js → chunk-package-2ZCYV5QA.js} +3 -1
  12. package/dist/boilerplates/@batijs/hattip/hattip-entry.ts +2 -2
  13. package/dist/boilerplates/@batijs/prisma/$.env.js +24 -0
  14. package/dist/boilerplates/@batijs/prisma/$package.json.js +12 -0
  15. package/dist/boilerplates/@batijs/prisma/chunk-package-4ZWXXBQR.js +61 -0
  16. package/dist/boilerplates/@batijs/prisma/prisma/schema.prisma +11 -0
  17. package/dist/boilerplates/@batijs/shared/package.json +1 -1
  18. package/dist/boilerplates/@batijs/solid/$package.json.js +1 -1
  19. package/dist/boilerplates/@batijs/solid/{chunk-package-HU2A6XJ4.js → chunk-package-VU2VJMMM.js} +3 -1
  20. package/dist/boilerplates/@batijs/solid/layouts/LayoutDefault.tsx +9 -9
  21. package/dist/boilerplates/@batijs/solid/pages/index/+Page.tsx +1 -1
  22. package/dist/boilerplates/@batijs/solid/pages/index/Counter.tsx +1 -1
  23. package/dist/boilerplates/@batijs/tailwindcss/$package.json.js +1 -1
  24. package/dist/boilerplates/@batijs/tailwindcss/{chunk-package-L4PYFLEY.js → chunk-package-TPBRD2TI.js} +3 -1
  25. package/dist/boilerplates/@batijs/telefunc/$package.json.js +1 -1
  26. package/dist/boilerplates/@batijs/telefunc/{chunk-package-35435SXA.js → chunk-package-YNWFSVHU.js} +3 -1
  27. package/dist/boilerplates/boilerplates.json +1 -1
  28. package/dist/index.d.ts +2 -1
  29. package/dist/index.js +223 -27
  30. package/package.json +5 -5
@@ -0,0 +1,14 @@
1
+ // files/$package.json.ts
2
+ import { addDependency, loadAsJson } from "@batijs/core";
3
+ async function getPackageJson(currentContent) {
4
+ const packageJson = await loadAsJson(currentContent);
5
+ packageJson.scripts["edgedb:generate-queries"] = "@edgedb/generate queries";
6
+ packageJson.scripts["edgedb:generate-edgeql-js"] = "@edgedb/generate edgeql-js";
7
+ return addDependency(packageJson, await import("./chunk-package-YA6LQX6A.js"), {
8
+ devDependencies: ["@edgedb/generate"],
9
+ dependencies: ["edgedb"]
10
+ });
11
+ }
12
+ export {
13
+ getPackageJson as default
14
+ };
@@ -0,0 +1,62 @@
1
+ // package.json
2
+ var name = "@batijs/edgedb";
3
+ var private2 = true;
4
+ var version = "0.0.17";
5
+ var description = "";
6
+ var type = "module";
7
+ var scripts = {
8
+ build: "tsup"
9
+ };
10
+ var keywords = [];
11
+ var author = "";
12
+ var license = "MIT";
13
+ var devDependencies = {
14
+ "@batijs/tsup": "workspace:*",
15
+ "@edgedb/generate": "^0.1.1",
16
+ "@prisma/client": "^4.14.0",
17
+ "@types/node": "^16.18.27",
18
+ edgedb: "^1.2.2"
19
+ };
20
+ var dependencies = {
21
+ "@batijs/core": "workspace:*"
22
+ };
23
+ var files = [
24
+ "dist/"
25
+ ];
26
+ var bati = {
27
+ flag: "edgedb",
28
+ name: "EdgeDB",
29
+ homepage: "https://www.edgedb.com",
30
+ boilerplate: "./dist/files"
31
+ };
32
+ var package_default = {
33
+ name,
34
+ private: private2,
35
+ version,
36
+ description,
37
+ type,
38
+ scripts,
39
+ keywords,
40
+ author,
41
+ license,
42
+ devDependencies,
43
+ dependencies,
44
+ files,
45
+ bati
46
+ };
47
+ export {
48
+ author,
49
+ bati,
50
+ package_default as default,
51
+ dependencies,
52
+ description,
53
+ devDependencies,
54
+ files,
55
+ keywords,
56
+ license,
57
+ name,
58
+ private2 as private,
59
+ scripts,
60
+ type,
61
+ version
62
+ };
@@ -0,0 +1,3 @@
1
+ module default {
2
+
3
+ };
@@ -0,0 +1,4 @@
1
+ # Disable the application of access policies within access policies
2
+ # themselves. This behavior will become the default in EdgeDB 3.0.
3
+ # See: https://www.edgedb.com/docs/reference/ddl/access_policies#nonrecursive
4
+ using future nonrecursive_access_policies;
@@ -0,0 +1,2 @@
1
+ [edgedb]
2
+ server-version = "2.15"
@@ -4,7 +4,7 @@ async function getPackageJson(currentContent, meta) {
4
4
  const packageJson = await loadAsJson(currentContent);
5
5
  packageJson.scripts.dev = "tsx ./express-entry.ts";
6
6
  packageJson.scripts.build = "vite build";
7
- return addDependency(packageJson, await import("./chunk-package-4Z6WSCOA.js"), {
7
+ return addDependency(packageJson, await import("./chunk-package-HAYHYJN6.js"), {
8
8
  devDependencies: ["@types/express"],
9
9
  dependencies: [
10
10
  "@hattip/adapter-node",
@@ -12,7 +12,7 @@ async function getPackageJson(currentContent, meta) {
12
12
  "tsx",
13
13
  "vite",
14
14
  "vite-plugin-ssr",
15
- ...meta.VIKE_MODULES?.includes("auth:authjs") ? ["@auth/core", "vike-authjs"] : []
15
+ ...meta.BATI_MODULES?.includes("auth:authjs") ? ["@auth/core", "vike-authjs"] : []
16
16
  ]
17
17
  });
18
18
  }
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var name = "@batijs/express";
3
3
  var private2 = true;
4
- var version = "0.0.15";
4
+ var version = "0.0.17";
5
5
  var description = "";
6
6
  var type = "module";
7
7
  var scripts = {
@@ -31,6 +31,8 @@ var files = [
31
31
  ];
32
32
  var bati = {
33
33
  flag: "express",
34
+ name: "Express",
35
+ homepage: "https://expressjs.com",
34
36
  boilerplate: "./dist/files"
35
37
  };
36
38
  var package_default = {
@@ -33,7 +33,7 @@ async function startServer() {
33
33
  app.use(viteDevMiddleware);
34
34
  }
35
35
 
36
- if (import.meta.VIKE_MODULES?.includes("auth:authjs")) {
36
+ if (import.meta.BATI_MODULES?.includes("auth:authjs")) {
37
37
  /**
38
38
  * AuthJS
39
39
  *
@@ -72,7 +72,7 @@ async function startServer() {
72
72
  );
73
73
  }
74
74
 
75
- if (import.meta.VIKE_MODULES?.includes("rpc:telefunc")) {
75
+ if (import.meta.BATI_MODULES?.includes("rpc:telefunc")) {
76
76
  /**
77
77
  * Telefunc route
78
78
  *
@@ -113,12 +113,9 @@ async function startServer() {
113
113
  const pageContext = await renderPage(pageContextInit);
114
114
  if (pageContext.httpResponse === null) return next();
115
115
 
116
- if ((pageContext as Record<string, unknown>)._isStream) {
117
- pageContext.httpResponse.pipe(res);
118
- } else {
119
- const { body, statusCode, contentType } = pageContext.httpResponse;
120
- res.status(statusCode).type(contentType).send(body);
121
- }
116
+ const { statusCode, contentType } = pageContext.httpResponse;
117
+ res.status(statusCode).type(contentType);
118
+ pageContext.httpResponse.pipe(res);
122
119
  });
123
120
 
124
121
  app.listen(process.env.PORT ? parseInt(process.env.PORT) : 3000, "localhost", () => {
@@ -7,14 +7,14 @@ async function getPackageJson(currentContent, meta) {
7
7
  if (packageJson.scripts.preview) {
8
8
  delete packageJson.scripts.preview;
9
9
  }
10
- return addDependency(packageJson, await import("./chunk-package-TWBPPJM3.js"), {
10
+ return addDependency(packageJson, await import("./chunk-package-2ZCYV5QA.js"), {
11
11
  devDependencies: ["@hattip/vite", "@hattip/adapter-node"],
12
12
  dependencies: [
13
13
  "@hattip/router",
14
14
  "hattip",
15
15
  "vite",
16
16
  "vite-plugin-ssr",
17
- ...meta.VIKE_MODULES?.includes("auth:authjs") ? ["@auth/core", "vike-authjs"] : []
17
+ ...meta.BATI_MODULES?.includes("auth:authjs") ? ["@auth/core", "vike-authjs"] : []
18
18
  ]
19
19
  });
20
20
  }
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var name = "@batijs/hattip";
3
3
  var private2 = true;
4
- var version = "0.0.15";
4
+ var version = "0.0.17";
5
5
  var description = "";
6
6
  var type = "module";
7
7
  var scripts = {
@@ -31,6 +31,8 @@ var files = [
31
31
  ];
32
32
  var bati = {
33
33
  flag: "hattip",
34
+ name: "Hattip",
35
+ homepage: "https://github.com/hattipjs/hattip",
34
36
  boilerplate: "./dist/files"
35
37
  };
36
38
  var package_default = {
@@ -6,7 +6,7 @@ import CredentialsProvider from "@auth/core/providers/credentials";
6
6
 
7
7
  const router = createRouter();
8
8
 
9
- if (import.meta.VIKE_MODULES?.includes("rpc:telefunc")) {
9
+ if (import.meta.BATI_MODULES?.includes("rpc:telefunc")) {
10
10
  /**
11
11
  * Telefunc route
12
12
  *
@@ -29,7 +29,7 @@ if (import.meta.VIKE_MODULES?.includes("rpc:telefunc")) {
29
29
  });
30
30
  }
31
31
 
32
- if (import.meta.VIKE_MODULES?.includes("auth:authjs")) {
32
+ if (import.meta.BATI_MODULES?.includes("auth:authjs")) {
33
33
  /**
34
34
  * AuthJS
35
35
  *
@@ -0,0 +1,24 @@
1
+ // files/$.env.ts
2
+ async function getEnv(currentContent) {
3
+ let envContent = await currentContent?.() ?? "";
4
+ if (envContent.endsWith("\n\n")) {
5
+ } else if (envContent.endsWith("\n")) {
6
+ envContent = envContent + "\n";
7
+ } else if (envContent) {
8
+ envContent = envContent + "\n\n";
9
+ }
10
+ const prismaContent = `# Prisma
11
+
12
+ # Environment variables declared in this file are automatically made available to Prisma.
13
+ # See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
14
+
15
+ # Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
16
+ # See the documentation for all the connection string options: https://pris.ly/d/connection-strings
17
+
18
+ DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public"
19
+ `;
20
+ return envContent + prismaContent;
21
+ }
22
+ export {
23
+ getEnv as default
24
+ };
@@ -0,0 +1,12 @@
1
+ // files/$package.json.ts
2
+ import { addDependency, loadAsJson } from "@batijs/core";
3
+ async function getPackageJson(currentContent) {
4
+ const packageJson = await loadAsJson(currentContent);
5
+ return addDependency(packageJson, await import("./chunk-package-4ZWXXBQR.js"), {
6
+ devDependencies: ["prisma"],
7
+ dependencies: ["@prisma/client"]
8
+ });
9
+ }
10
+ export {
11
+ getPackageJson as default
12
+ };
@@ -0,0 +1,61 @@
1
+ // package.json
2
+ var name = "@batijs/prisma";
3
+ var private2 = true;
4
+ var version = "0.0.17";
5
+ var description = "";
6
+ var type = "module";
7
+ var scripts = {
8
+ build: "tsup"
9
+ };
10
+ var keywords = [];
11
+ var author = "";
12
+ var license = "MIT";
13
+ var devDependencies = {
14
+ "@batijs/tsup": "workspace:*",
15
+ "@prisma/client": "^4.14.0",
16
+ "@types/node": "^16.18.27",
17
+ prisma: "^4.14.0"
18
+ };
19
+ var dependencies = {
20
+ "@batijs/core": "workspace:*"
21
+ };
22
+ var files = [
23
+ "dist/"
24
+ ];
25
+ var bati = {
26
+ flag: "prisma",
27
+ name: "Prisma",
28
+ homepage: "https://www.prisma.io",
29
+ boilerplate: "./dist/files"
30
+ };
31
+ var package_default = {
32
+ name,
33
+ private: private2,
34
+ version,
35
+ description,
36
+ type,
37
+ scripts,
38
+ keywords,
39
+ author,
40
+ license,
41
+ devDependencies,
42
+ dependencies,
43
+ files,
44
+ bati
45
+ };
46
+ export {
47
+ author,
48
+ bati,
49
+ package_default as default,
50
+ dependencies,
51
+ description,
52
+ devDependencies,
53
+ files,
54
+ keywords,
55
+ license,
56
+ name,
57
+ private2 as private,
58
+ scripts,
59
+ type,
60
+ version
61
+ };
@@ -0,0 +1,11 @@
1
+ // This is your Prisma schema file,
2
+ // learn more about it in the docs: https://pris.ly/d/prisma-schema
3
+
4
+ generator client {
5
+ provider = "prisma-client-js"
6
+ }
7
+
8
+ datasource db {
9
+ provider = "postgresql"
10
+ url = env("DATABASE_URL")
11
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "my-app",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -2,7 +2,7 @@
2
2
  import { addDependency, loadAsJson } from "@batijs/core";
3
3
  async function getPackageJson(currentContent) {
4
4
  const packageJson = await loadAsJson(currentContent);
5
- return addDependency(packageJson, await import("./chunk-package-HU2A6XJ4.js"), {
5
+ return addDependency(packageJson, await import("./chunk-package-VU2VJMMM.js"), {
6
6
  devDependencies: ["vite"],
7
7
  dependencies: ["cross-fetch", "solid-js", "vike-solid"]
8
8
  });
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var name = "@batijs/solid";
3
3
  var private2 = true;
4
- var version = "0.0.15";
4
+ var version = "0.0.17";
5
5
  var description = "";
6
6
  var type = "module";
7
7
  var scripts = {
@@ -30,6 +30,8 @@ var files = [
30
30
  ];
31
31
  var bati = {
32
32
  flag: "solid",
33
+ name: "SolidJS",
34
+ homepage: "https://www.solidjs.com",
33
35
  boilerplate: "./dist/files"
34
36
  };
35
37
  var package_default = {
@@ -1,5 +1,5 @@
1
1
  import "./style.css";
2
- //# import.meta.VIKE_MODULES?.includes("uikit:tailwindcss")
2
+ //# import.meta.BATI_MODULES?.includes("uikit:tailwindcss")
3
3
  import "./tailwind.css";
4
4
  import logoUrl from "../assets/logo.svg";
5
5
  import { Link } from "../components/Link";
@@ -8,9 +8,9 @@ import type { JSX } from "solid-js";
8
8
  export default function LayoutDefault(props: { children?: JSX.Element }) {
9
9
  return (
10
10
  <div
11
- //# import.meta.VIKE_MODULES?.includes("uikit:tailwindcss")
11
+ //# import.meta.BATI_MODULES?.includes("uikit:tailwindcss")
12
12
  class="flex max-w-5xl m-auto"
13
- //# !import.meta.VIKE_MODULES?.includes("uikit:tailwindcss")
13
+ //# !import.meta.BATI_MODULES?.includes("uikit:tailwindcss")
14
14
  style={{
15
15
  display: "flex",
16
16
  "max-width": "900px",
@@ -31,9 +31,9 @@ function Sidebar(props: { children: JSX.Element }) {
31
31
  return (
32
32
  <div
33
33
  id="sidebar"
34
- //# import.meta.VIKE_MODULES?.includes("uikit:tailwindcss")
34
+ //# import.meta.BATI_MODULES?.includes("uikit:tailwindcss")
35
35
  class="p-5 flex flex-col shrink-0 border-r-2 border-r-gray-200"
36
- //# !import.meta.VIKE_MODULES?.includes("uikit:tailwindcss")
36
+ //# !import.meta.BATI_MODULES?.includes("uikit:tailwindcss")
37
37
  style={{
38
38
  padding: "20px",
39
39
  "flex-shrink": 0,
@@ -53,9 +53,9 @@ function Content(props: { children: JSX.Element }) {
53
53
  <div id="page-container">
54
54
  <div
55
55
  id="page-content"
56
- //# import.meta.VIKE_MODULES?.includes("uikit:tailwindcss")
56
+ //# import.meta.BATI_MODULES?.includes("uikit:tailwindcss")
57
57
  class="p-5 pb-12 min-h-screen"
58
- //# !import.meta.VIKE_MODULES?.includes("uikit:tailwindcss")
58
+ //# !import.meta.BATI_MODULES?.includes("uikit:tailwindcss")
59
59
  style={{
60
60
  padding: "20px",
61
61
  "padding-bottom": "50px",
@@ -71,9 +71,9 @@ function Content(props: { children: JSX.Element }) {
71
71
  function Logo() {
72
72
  return (
73
73
  <div
74
- //# import.meta.VIKE_MODULES?.includes("uikit:tailwindcss")
74
+ //# import.meta.BATI_MODULES?.includes("uikit:tailwindcss")
75
75
  class="p-5 mb-2"
76
- //# !import.meta.VIKE_MODULES?.includes("uikit:tailwindcss")
76
+ //# !import.meta.BATI_MODULES?.includes("uikit:tailwindcss")
77
77
  style={{
78
78
  "margin-top": "20px",
79
79
  "margin-bottom": "10px",
@@ -4,7 +4,7 @@ export default function Page() {
4
4
  return (
5
5
  <>
6
6
  <h1
7
- //# import.meta.VIKE_MODULES?.includes("uikit:tailwindcss")
7
+ //# import.meta.BATI_MODULES?.includes("uikit:tailwindcss")
8
8
  class="font-bold text-3xl pb-4"
9
9
  >
10
10
  My Vike app
@@ -8,7 +8,7 @@ function Counter() {
8
8
  return (
9
9
  <button
10
10
  type="button"
11
- //# import.meta.VIKE_MODULES?.includes("uikit:tailwindcss")
11
+ //# import.meta.BATI_MODULES?.includes("uikit:tailwindcss")
12
12
  class="inline-block border border-black rounded bg-gray-200 px-2 py-1 text-xs font-medium uppercase leading-normal"
13
13
  onClick={() => setCount((count) => count + 1)}
14
14
  >
@@ -2,7 +2,7 @@
2
2
  import { addDependency, loadAsJson } from "@batijs/core";
3
3
  async function getPackageJson(currentContent, meta) {
4
4
  const packageJson = await loadAsJson(currentContent);
5
- return addDependency(packageJson, await import("./chunk-package-L4PYFLEY.js"), {
5
+ return addDependency(packageJson, await import("./chunk-package-TPBRD2TI.js"), {
6
6
  devDependencies: ["tailwindcss", "postcss", "autoprefixer"]
7
7
  });
8
8
  }
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var name = "@batijs/tailwindcss";
3
3
  var private2 = true;
4
- var version = "0.0.15";
4
+ var version = "0.0.17";
5
5
  var description = "";
6
6
  var type = "module";
7
7
  var scripts = {
@@ -27,6 +27,8 @@ var files = [
27
27
  ];
28
28
  var bati = {
29
29
  flag: "tailwindcss",
30
+ name: "TailwindCSS",
31
+ homepage: "https://tailwindcss.com",
30
32
  boilerplate: "./dist/files"
31
33
  };
32
34
  var package_default = {
@@ -2,7 +2,7 @@
2
2
  import { addDependency, loadAsJson } from "@batijs/core";
3
3
  async function getPackageJson(currentContent) {
4
4
  const packageJson = await loadAsJson(currentContent);
5
- return addDependency(packageJson, await import("./chunk-package-35435SXA.js"), {
5
+ return addDependency(packageJson, await import("./chunk-package-YNWFSVHU.js"), {
6
6
  dependencies: ["telefunc"]
7
7
  });
8
8
  }
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var name = "@batijs/telefunc";
3
3
  var private2 = true;
4
- var version = "0.0.15";
4
+ var version = "0.0.17";
5
5
  var description = "";
6
6
  var type = "module";
7
7
  var scripts = {
@@ -25,6 +25,8 @@ var files = [
25
25
  ];
26
26
  var bati = {
27
27
  flag: "telefunc",
28
+ name: "Telefunc",
29
+ homepage: "https://telefunc.com",
28
30
  boilerplate: "./dist/files"
29
31
  };
30
32
  var package_default = {
@@ -1 +1 @@
1
- [{"config":{"flag":"express","boilerplate":"./dist/files"},"folder":"@batijs/express"},{"config":{"flag":"hattip","boilerplate":"./dist/files"},"folder":"@batijs/hattip"},{"config":{"boilerplate":"./files"},"folder":"@batijs/shared"},{"config":{"flag":"solid","boilerplate":"./dist/files"},"folder":"@batijs/solid"},{"config":{"flag":"tailwindcss","boilerplate":"./dist/files"},"folder":"@batijs/tailwindcss"},{"config":{"flag":"telefunc","boilerplate":"./dist/files"},"folder":"@batijs/telefunc"}]
1
+ [{"config":{"flag":"authjs","name":"Auth.js","homepage":"https://authjs.dev"},"folder":"@batijs/authjs","description":""},{"config":{"flag":"edgedb","name":"EdgeDB","homepage":"https://www.edgedb.com","boilerplate":"./dist/files"},"folder":"@batijs/edgedb","description":""},{"config":{"flag":"express","name":"Express","homepage":"https://expressjs.com","boilerplate":"./dist/files"},"folder":"@batijs/express","description":""},{"config":{"flag":"hattip","name":"Hattip","homepage":"https://github.com/hattipjs/hattip","boilerplate":"./dist/files"},"folder":"@batijs/hattip","description":""},{"config":{"flag":"prisma","name":"Prisma","homepage":"https://www.prisma.io","boilerplate":"./dist/files"},"folder":"@batijs/prisma","description":""},{"config":{"boilerplate":"./files"},"folder":"@batijs/shared","description":""},{"config":{"flag":"solid","name":"SolidJS","homepage":"https://www.solidjs.com","boilerplate":"./dist/files"},"folder":"@batijs/solid","description":""},{"config":{"flag":"tailwindcss","name":"TailwindCSS","homepage":"https://tailwindcss.com","boilerplate":"./dist/files"},"folder":"@batijs/tailwindcss","description":""},{"config":{"flag":"telefunc","name":"Telefunc","homepage":"https://telefunc.com","boilerplate":"./dist/files"},"folder":"@batijs/telefunc","description":""}]
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
+ declare function yn(value: unknown, default_?: boolean): boolean | undefined;
1
2
 
2
- export { }
3
+ export { yn as default };
package/dist/index.js CHANGED
@@ -476,7 +476,7 @@ var colors = {
476
476
  bgWhiteBright: init(107, 49)
477
477
  };
478
478
  var createColors = ({ useColor = isColorSupported } = {}) => useColor ? colors : Object.keys(colors).reduce(
479
- (colors2, key) => ({ ...colors2, [key]: String }),
479
+ (colors3, key) => ({ ...colors3, [key]: String }),
480
480
  {}
481
481
  );
482
482
  var {
@@ -583,25 +583,27 @@ async function* walk(dir, meta) {
583
583
  }
584
584
  function transformFileAfterExec(filepath, fileContent) {
585
585
  const parsed = path.parse(filepath);
586
- switch (parsed.ext) {
586
+ const ext = parsed.ext || parsed.name;
587
+ switch (ext) {
587
588
  case ".ts":
588
589
  case ".js":
589
590
  case ".tsx":
590
591
  case ".jsx":
592
+ case ".env":
591
593
  return fileContent;
592
594
  case ".json":
593
595
  return JSON.stringify(fileContent, null, 2);
594
596
  default:
595
- throw new Error(`Unsupported extension ${parsed.ext} (${filepath})`);
597
+ throw new Error(`Unsupported extension ${ext} (${filepath})`);
596
598
  }
597
599
  }
598
- async function fileContainsVikeMeta(filepath) {
600
+ async function fileContainsBatiMeta(filepath) {
599
601
  const code = await readFile(filepath, { encoding: "utf-8" });
600
- return code.includes("import.meta.VIKE_");
602
+ return code.includes("import.meta.BATI_");
601
603
  }
602
604
  async function main(options, meta) {
603
605
  const sources = Array.isArray(options.source) ? options.source : [options.source];
604
- const targets = /* @__PURE__ */ new Map();
606
+ const targets = /* @__PURE__ */ new Set();
605
607
  for (const source of sources) {
606
608
  for await (const p of walk(source, meta)) {
607
609
  const target = toDist(p, source, options.dist);
@@ -609,15 +611,21 @@ async function main(options, meta) {
609
611
  if (parsed.name.match(reIgnoreFile)) {
610
612
  continue;
611
613
  } else if (parsed.name.startsWith("$") && parsed.ext.match(/\.tsx?$/)) {
612
- throw new Error(`Typescript file needs to be compiled before it can be executed: '${p}'`);
614
+ throw new Error(
615
+ `Typescript file needs to be compiled before it can be executed: '${p}'.
616
+ Please report this issue to https://github.com/magne4000/bati`
617
+ );
613
618
  } else if (parsed.name.startsWith("$") && parsed.ext.match(/\.jsx?$/)) {
614
619
  const f = await import(p);
615
- const fileContent = transformFileAfterExec(target, await f.default(targets.get(target), meta));
620
+ const fileContent = transformFileAfterExec(
621
+ target,
622
+ await f.default(targets.has(target) ? () => readFile(target, { encoding: "utf-8" }) : void 0, meta)
623
+ );
616
624
  if (fileContent !== null) {
617
625
  await safeWriteFile(target, fileContent);
618
626
  }
619
- targets.set(target, () => fileContent);
620
- } else if (parsed.ext.match(/\.[tj]sx?$/) && await fileContainsVikeMeta(p)) {
627
+ targets.add(target);
628
+ } else if (parsed.ext.match(/\.[tj]sx?$/) && await fileContainsBatiMeta(p)) {
621
629
  const mod = await loadFile(p);
622
630
  const fileContent = await transformAndGenerate(mod.$ast, meta, {
623
631
  filepath: p
@@ -625,10 +633,10 @@ async function main(options, meta) {
625
633
  if (fileContent) {
626
634
  await safeWriteFile(target, fileContent);
627
635
  }
628
- targets.set(target, () => fileContent);
636
+ targets.add(target);
629
637
  } else {
630
638
  await safeCopyFile(p, target);
631
- targets.set(target, () => readFile(p, { encoding: "utf-8" }));
639
+ targets.add(target);
632
640
  }
633
641
  }
634
642
  }
@@ -637,8 +645,8 @@ async function main(options, meta) {
637
645
  // package.json
638
646
  var package_default = {
639
647
  name: "@batijs/cli",
640
- version: "0.0.15",
641
- description: "",
648
+ version: "0.0.17",
649
+ description: "Scaffold typescript projects with ease and modularity",
642
650
  type: "module",
643
651
  scripts: {
644
652
  prerelease: "rm -rf ./dist",
@@ -688,7 +696,124 @@ import { flags as coreFlags } from "@batijs/core";
688
696
  import { existsSync } from "fs";
689
697
  import { fileURLToPath } from "url";
690
698
  import { dirname, join } from "path";
691
- import { readFile as readFile2 } from "fs/promises";
699
+ import { access, constants, lstat, readdir, readFile as readFile2 } from "fs/promises";
700
+
701
+ // ../../node_modules/.pnpm/colorette@2.0.20/node_modules/colorette/index.js
702
+ import * as tty2 from "tty";
703
+ var {
704
+ env: env2 = {},
705
+ argv: argv2 = [],
706
+ platform: platform2 = ""
707
+ } = typeof process === "undefined" ? {} : process;
708
+ var isDisabled2 = "NO_COLOR" in env2 || argv2.includes("--no-color");
709
+ var isForced2 = "FORCE_COLOR" in env2 || argv2.includes("--color");
710
+ var isWindows2 = platform2 === "win32";
711
+ var isDumbTerminal2 = env2.TERM === "dumb";
712
+ var isCompatibleTerminal2 = tty2 && tty2.isatty && tty2.isatty(1) && env2.TERM && !isDumbTerminal2;
713
+ var isCI2 = "CI" in env2 && ("GITHUB_ACTIONS" in env2 || "GITLAB_CI" in env2 || "CIRCLECI" in env2);
714
+ var isColorSupported2 = !isDisabled2 && (isForced2 || isWindows2 && !isDumbTerminal2 || isCompatibleTerminal2 || isCI2);
715
+ var replaceClose2 = (index, string, close, replace, head = string.substring(0, index) + replace, tail = string.substring(index + close.length), next = tail.indexOf(close)) => head + (next < 0 ? tail : replaceClose2(next, tail, close, replace));
716
+ var clearBleed2 = (index, string, open, close, replace) => index < 0 ? open + string + close : open + replaceClose2(index, string, close, replace) + close;
717
+ var filterEmpty2 = (open, close, replace = open, at = open.length + 1) => (string) => string || !(string === "" || string === void 0) ? clearBleed2(
718
+ ("" + string).indexOf(close, at),
719
+ string,
720
+ open,
721
+ close,
722
+ replace
723
+ ) : "";
724
+ var init2 = (open, close, replace) => filterEmpty2(`\x1B[${open}m`, `\x1B[${close}m`, replace);
725
+ var colors2 = {
726
+ reset: init2(0, 0),
727
+ bold: init2(1, 22, "\x1B[22m\x1B[1m"),
728
+ dim: init2(2, 22, "\x1B[22m\x1B[2m"),
729
+ italic: init2(3, 23),
730
+ underline: init2(4, 24),
731
+ inverse: init2(7, 27),
732
+ hidden: init2(8, 28),
733
+ strikethrough: init2(9, 29),
734
+ black: init2(30, 39),
735
+ red: init2(31, 39),
736
+ green: init2(32, 39),
737
+ yellow: init2(33, 39),
738
+ blue: init2(34, 39),
739
+ magenta: init2(35, 39),
740
+ cyan: init2(36, 39),
741
+ white: init2(37, 39),
742
+ gray: init2(90, 39),
743
+ bgBlack: init2(40, 49),
744
+ bgRed: init2(41, 49),
745
+ bgGreen: init2(42, 49),
746
+ bgYellow: init2(43, 49),
747
+ bgBlue: init2(44, 49),
748
+ bgMagenta: init2(45, 49),
749
+ bgCyan: init2(46, 49),
750
+ bgWhite: init2(47, 49),
751
+ blackBright: init2(90, 39),
752
+ redBright: init2(91, 39),
753
+ greenBright: init2(92, 39),
754
+ yellowBright: init2(93, 39),
755
+ blueBright: init2(94, 39),
756
+ magentaBright: init2(95, 39),
757
+ cyanBright: init2(96, 39),
758
+ whiteBright: init2(97, 39),
759
+ bgBlackBright: init2(100, 49),
760
+ bgRedBright: init2(101, 49),
761
+ bgGreenBright: init2(102, 49),
762
+ bgYellowBright: init2(103, 49),
763
+ bgBlueBright: init2(104, 49),
764
+ bgMagentaBright: init2(105, 49),
765
+ bgCyanBright: init2(106, 49),
766
+ bgWhiteBright: init2(107, 49)
767
+ };
768
+ var createColors2 = ({ useColor = isColorSupported2 } = {}) => useColor ? colors2 : Object.keys(colors2).reduce(
769
+ (colors3, key) => ({ ...colors3, [key]: String }),
770
+ {}
771
+ );
772
+ var {
773
+ reset: reset2,
774
+ bold: bold2,
775
+ dim: dim2,
776
+ italic: italic2,
777
+ underline: underline2,
778
+ inverse: inverse2,
779
+ hidden: hidden2,
780
+ strikethrough: strikethrough2,
781
+ black: black2,
782
+ red: red2,
783
+ green: green2,
784
+ yellow: yellow2,
785
+ blue: blue2,
786
+ magenta: magenta2,
787
+ cyan: cyan2,
788
+ white: white2,
789
+ gray: gray2,
790
+ bgBlack: bgBlack2,
791
+ bgRed: bgRed2,
792
+ bgGreen: bgGreen2,
793
+ bgYellow: bgYellow2,
794
+ bgBlue: bgBlue2,
795
+ bgMagenta: bgMagenta2,
796
+ bgCyan: bgCyan2,
797
+ bgWhite: bgWhite2,
798
+ blackBright: blackBright2,
799
+ redBright: redBright2,
800
+ greenBright: greenBright2,
801
+ yellowBright: yellowBright2,
802
+ blueBright: blueBright2,
803
+ magentaBright: magentaBright2,
804
+ cyanBright: cyanBright2,
805
+ whiteBright: whiteBright2,
806
+ bgBlackBright: bgBlackBright2,
807
+ bgRedBright: bgRedBright2,
808
+ bgGreenBright: bgGreenBright2,
809
+ bgYellowBright: bgYellowBright2,
810
+ bgBlueBright: bgBlueBright2,
811
+ bgMagentaBright: bgMagentaBright2,
812
+ bgCyanBright: bgCyanBright2,
813
+ bgWhiteBright: bgWhiteBright2
814
+ } = createColors2();
815
+
816
+ // index.ts
692
817
  var __filename = fileURLToPath(import.meta.url);
693
818
  var __dirname = dirname(__filename);
694
819
  function boilerplatesDir() {
@@ -702,16 +827,87 @@ function boilerplatesDir() {
702
827
  async function parseBoilerplates(dir) {
703
828
  return JSON.parse(await readFile2(join(dir, "boilerplates.json"), "utf-8"));
704
829
  }
705
- function toArg(flag) {
830
+ function toArg(flag, description) {
706
831
  if (!flag)
707
832
  return {};
708
833
  return {
709
834
  [flag]: {
710
835
  type: "boolean",
711
- required: false
836
+ required: false,
837
+ description
712
838
  }
713
839
  };
714
840
  }
841
+ function findDescription(key, boilerplates) {
842
+ const bl = boilerplates.find((b) => b.config.flag === key);
843
+ if (!bl)
844
+ return;
845
+ if (bl.description) {
846
+ return bl.description;
847
+ } else if (bl.config.name && bl.config.homepage) {
848
+ return `Include ${bl.config.name} - ${bl.config.homepage}`;
849
+ } else if (bl.config.name) {
850
+ return `Include ${bl.config.name}`;
851
+ }
852
+ }
853
+ function printOK(dist, flags, boilerplates) {
854
+ console.log(bold2(`${green2("\u2713")} Project created at ${cyan2(dist)} with:`));
855
+ console.log(` - ${green2("Typescript")}`);
856
+ for (const key of flags) {
857
+ const bl = boilerplates.find((b) => b.config.flag === key);
858
+ if (!bl || !bl.config.name)
859
+ continue;
860
+ console.log(` - ${green2(bl.config.name)}`);
861
+ }
862
+ }
863
+ var defaultDef = {
864
+ project: {
865
+ type: "positional",
866
+ description: "Project directory",
867
+ required: true
868
+ }
869
+ };
870
+ function yn(value, default_) {
871
+ if (value === void 0 || value === null) {
872
+ return default_;
873
+ }
874
+ value = String(value).trim();
875
+ if (/^(?:y|yes|true|1|on)$/i.test(value)) {
876
+ return true;
877
+ }
878
+ if (/^(?:n|no|false|0|off)$/i.test(value)) {
879
+ return false;
880
+ }
881
+ return default_;
882
+ }
883
+ async function checkArguments(args) {
884
+ if (existsSync(args.project)) {
885
+ const stat = await lstat(args.project);
886
+ if (!stat.isDirectory()) {
887
+ console.error(
888
+ `${yellow2("\u26A0")} Target ${cyan2(args.project)} already exists but is not a directory. ${yellow2("Aborting")}.`
889
+ );
890
+ process.exit(2);
891
+ }
892
+ try {
893
+ await access(args.project, constants.W_OK);
894
+ } catch (_) {
895
+ console.error(
896
+ `${yellow2("\u26A0")} Target folder ${cyan2(args.project)} already exists but is not writable. ${yellow2("Aborting")}.`
897
+ );
898
+ process.exit(3);
899
+ }
900
+ if ((await readdir(args.project)).length > 0) {
901
+ console.error(
902
+ `${yellow2("\u26A0")} Target folder ${cyan2(
903
+ args.project
904
+ )} already exists and is not empty.
905
+ Continuing might erase existing files. ${yellow2("Aborting")}.`
906
+ );
907
+ process.exit(4);
908
+ }
909
+ }
910
+ }
715
911
  async function run() {
716
912
  const dir = boilerplatesDir();
717
913
  const boilerplates = await parseBoilerplates(dir);
@@ -722,16 +918,12 @@ async function run() {
722
918
  description: package_default.description
723
919
  },
724
920
  args: Object.assign(
725
- {
726
- dist: {
727
- type: "positional",
728
- description: "Dist folder",
729
- required: true
730
- }
731
- },
732
- ...Array.from(coreFlags.keys()).map(toArg)
921
+ {},
922
+ defaultDef,
923
+ ...Array.from(coreFlags.keys()).map((k) => toArg(k, findDescription(k, boilerplates)))
733
924
  ),
734
925
  async run({ args }) {
926
+ await checkArguments(args);
735
927
  const sources = [];
736
928
  const features = [];
737
929
  const flags = Object.entries(args).filter(([, val]) => val === true).map(([key]) => key);
@@ -749,12 +941,13 @@ async function run() {
749
941
  await main(
750
942
  {
751
943
  source: sources,
752
- dist: args.dist
944
+ dist: args.project
753
945
  },
754
946
  {
755
- VIKE_MODULES: features
947
+ BATI_MODULES: features
756
948
  }
757
949
  );
950
+ printOK(args.project, flags, boilerplates);
758
951
  }
759
952
  });
760
953
  await runMain(main2);
@@ -765,3 +958,6 @@ run().then(() => {
765
958
  console.error(e);
766
959
  process.exit(1);
767
960
  });
961
+ export {
962
+ yn as default
963
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@batijs/cli",
3
- "version": "0.0.15",
4
- "description": "",
3
+ "version": "0.0.17",
4
+ "description": "Scaffold typescript projects with ease and modularity",
5
5
  "type": "module",
6
6
  "keywords": [],
7
7
  "author": "",
@@ -18,11 +18,11 @@
18
18
  "typescript": "^5.0.4",
19
19
  "vitest": "^0.31.0",
20
20
  "wait-for-localhost": "^4.0.1",
21
- "@batijs/build": "0.0.15",
22
- "@batijs/tsup": "0.0.15"
21
+ "@batijs/tsup": "0.0.17",
22
+ "@batijs/build": "0.0.17"
23
23
  },
24
24
  "dependencies": {
25
- "@batijs/core": "0.0.15"
25
+ "@batijs/core": "0.0.17"
26
26
  },
27
27
  "bin": "./dist/index.js",
28
28
  "exports": {