@batijs/cli 0.0.281 → 0.0.286
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/authjs/files/$package.json.js +2 -3
- package/dist/boilerplates/@batijs/authjs/files/global.d.ts +11 -0
- package/dist/boilerplates/@batijs/aws/files/$package.json.js +2 -1
- package/dist/boilerplates/@batijs/cloudflare/files/$package.json.js +18 -11
- package/dist/boilerplates/@batijs/d1-sqlite/files/database/d1/queries/lucia-auth.ts +1 -0
- package/dist/boilerplates/@batijs/drizzle/files/$package.json.js +8 -2
- package/dist/boilerplates/@batijs/drizzle/files/drizzle.config.ts +1 -0
- package/dist/boilerplates/@batijs/drizzle/types/drizzle.config.d.ts +1 -0
- package/dist/boilerplates/@batijs/express/files/$package.json.js +2 -8
- package/dist/boilerplates/@batijs/fastify/files/$package.json.js +3 -4
- package/dist/boilerplates/@batijs/fastify/files/global.d.ts +0 -11
- package/dist/boilerplates/@batijs/firebase-auth/files/$package.json.js +2 -2
- package/dist/boilerplates/@batijs/h3/files/$package.json.js +3 -5
- package/dist/boilerplates/@batijs/h3/files/global.d.ts +0 -12
- package/dist/boilerplates/@batijs/hattip/files/$package.json.js +4 -3
- package/dist/boilerplates/@batijs/hono/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/lucia-auth/files/$package.json.js +2 -1
- package/dist/boilerplates/@batijs/lucia-auth/files/server/lucia-auth-handlers.ts +10 -7
- package/dist/boilerplates/@batijs/sqlite/files/$package.json.js +2 -2
- package/dist/boilerplates/@batijs/sqlite/files/database/sqlite/queries/lucia-auth.ts +1 -0
- package/dist/boilerplates/@batijs/sqlite/files/database/sqlite/schema/lucia-auth.ts +2 -1
- package/dist/boilerplates/@batijs/trpc/types/server/trpc-handler.d.ts +1 -1
- package/dist/boilerplates/@batijs/trpc/types/trpc/client.d.ts +8 -8
- package/dist/boilerplates/boilerplates.json +4 -2
- package/dist/index.js +84 -29
- package/package.json +5 -5
- package/dist/boilerplates/@batijs/auth0/files/global.d.ts +0 -11
|
@@ -44,8 +44,7 @@ var require_package = __commonJS({
|
|
|
44
44
|
"@auth/core": "^0.35.0",
|
|
45
45
|
"@batijs/compile": "workspace:*",
|
|
46
46
|
"@types/node": "^18.19.14",
|
|
47
|
-
"@universal-middleware/core": "^0.2.10"
|
|
48
|
-
dotenv: "^16.4.5"
|
|
47
|
+
"@universal-middleware/core": "^0.2.10"
|
|
49
48
|
},
|
|
50
49
|
dependencies: {
|
|
51
50
|
"@batijs/core": "workspace:*"
|
|
@@ -84,7 +83,7 @@ import { addDependency, loadAsJson } from "@batijs/core";
|
|
|
84
83
|
async function getPackageJson(props) {
|
|
85
84
|
const packageJson = await loadAsJson(props);
|
|
86
85
|
return addDependency(packageJson, await Promise.resolve().then(() => __toESM(require_package(), 1)).then((x) => x.default), {
|
|
87
|
-
dependencies: ["@auth/core", "@universal-middleware/core"
|
|
86
|
+
dependencies: ["@auth/core", "@universal-middleware/core"]
|
|
88
87
|
});
|
|
89
88
|
}
|
|
90
89
|
export {
|
|
@@ -58,7 +58,8 @@ var require_package = __commonJS({
|
|
|
58
58
|
bati: {
|
|
59
59
|
if: {
|
|
60
60
|
flag: "cloudflare"
|
|
61
|
-
}
|
|
61
|
+
},
|
|
62
|
+
enforce: "post"
|
|
62
63
|
},
|
|
63
64
|
exports: {
|
|
64
65
|
"./test": {
|
|
@@ -77,38 +78,44 @@ var require_package = __commonJS({
|
|
|
77
78
|
});
|
|
78
79
|
|
|
79
80
|
// files/$package.json.ts
|
|
80
|
-
import { addDependency, loadAsJson, setScripts } from "@batijs/core";
|
|
81
|
+
import { addDependency, loadAsJson, removeDependency, setScripts } from "@batijs/core";
|
|
81
82
|
async function getPackageJson(props) {
|
|
82
83
|
const packageJson = await loadAsJson(props);
|
|
83
84
|
setScripts(packageJson, {
|
|
84
85
|
"preview:wrangler": {
|
|
85
86
|
value: "wrangler pages dev",
|
|
86
|
-
precedence:
|
|
87
|
+
precedence: 40,
|
|
87
88
|
warnIfReplaced: true
|
|
88
89
|
},
|
|
89
90
|
preview: {
|
|
90
91
|
value: "run-s build preview:wrangler",
|
|
91
|
-
precedence:
|
|
92
|
+
precedence: 40,
|
|
92
93
|
warnIfReplaced: true
|
|
93
94
|
},
|
|
94
95
|
"deploy:wrangler": {
|
|
95
96
|
value: "wrangler pages deploy",
|
|
96
|
-
precedence:
|
|
97
|
+
precedence: 40,
|
|
97
98
|
warnIfReplaced: true
|
|
98
99
|
},
|
|
99
100
|
deploy: {
|
|
100
101
|
value: "run-s build deploy:wrangler",
|
|
101
|
-
precedence:
|
|
102
|
+
precedence: 40,
|
|
102
103
|
warnIfReplaced: true
|
|
103
104
|
}
|
|
104
105
|
});
|
|
105
|
-
|
|
106
|
+
addDependency(packageJson, await Promise.resolve().then(() => __toESM(require_package(), 1)).then((x) => x.default), {
|
|
106
107
|
devDependencies: ["wrangler", "npm-run-all2", "@cloudflare/workers-types"],
|
|
107
|
-
dependencies: [
|
|
108
|
-
"vike-cloudflare",
|
|
109
|
-
...props.meta.BATI.has("hattip") ? ["@hattip/adapter-cloudflare-workers"] : []
|
|
110
|
-
]
|
|
108
|
+
dependencies: ["vike-cloudflare"]
|
|
111
109
|
});
|
|
110
|
+
if (props.meta.BATI.has("hattip")) {
|
|
111
|
+
addDependency(packageJson, await Promise.resolve().then(() => __toESM(require_package(), 1)).then((x) => x.default), {
|
|
112
|
+
dependencies: ["@hattip/adapter-cloudflare-workers"]
|
|
113
|
+
});
|
|
114
|
+
} else {
|
|
115
|
+
removeDependency(packageJson, "tsx");
|
|
116
|
+
removeDependency(packageJson, "cross-env");
|
|
117
|
+
}
|
|
118
|
+
return packageJson;
|
|
112
119
|
}
|
|
113
120
|
export {
|
|
114
121
|
getPackageJson as default
|
|
@@ -114,9 +114,15 @@ async function getPackageJson(props) {
|
|
|
114
114
|
packageJson.scripts["drizzle:generate"] = "drizzle-kit generate";
|
|
115
115
|
packageJson.scripts["drizzle:migrate"] = props.meta.BATI.hasD1 ? "wrangler d1 migrations apply YOUR_DATABASE_NAME --local" : "drizzle-kit migrate";
|
|
116
116
|
packageJson.scripts["drizzle:studio"] = "drizzle-kit studio";
|
|
117
|
+
if (!props.meta.BATI.hasD1) {
|
|
118
|
+
addDependency(packageJson, await Promise.resolve().then(() => __toESM(require_package(), 1)).then((x) => x.default), {
|
|
119
|
+
devDependencies: ["@types/better-sqlite3"],
|
|
120
|
+
dependencies: ["better-sqlite3"]
|
|
121
|
+
});
|
|
122
|
+
}
|
|
117
123
|
return addDependency(packageJson, await Promise.resolve().then(() => __toESM(require_package(), 1)).then((x) => x.default), {
|
|
118
|
-
devDependencies: ["
|
|
119
|
-
dependencies: ["
|
|
124
|
+
devDependencies: ["tsx"],
|
|
125
|
+
dependencies: ["drizzle-kit", "drizzle-orm", "dotenv"]
|
|
120
126
|
});
|
|
121
127
|
}
|
|
122
128
|
export {
|
|
@@ -44,15 +44,12 @@ var require_package = __commonJS({
|
|
|
44
44
|
"@auth/core": "^0.35.0",
|
|
45
45
|
"@batijs/compile": "workspace:*",
|
|
46
46
|
"@trpc/server": "^10.45.2",
|
|
47
|
-
"@types/cookie-parser": "^1.4.7",
|
|
48
47
|
"@types/express": "^4.17.21",
|
|
49
48
|
"@types/node": "^18.19.14",
|
|
50
49
|
"@universal-middleware/express": "^0.2.6",
|
|
51
|
-
"cookie-parser": "^1.4.6",
|
|
52
50
|
"cross-env": "^7.0.3",
|
|
53
51
|
dotenv: "^16.4.5",
|
|
54
52
|
express: "^4.21.0",
|
|
55
|
-
"express-openid-connect": "^2.17.1",
|
|
56
53
|
telefunc: "^0.1.79",
|
|
57
54
|
tsx: "^4.19.1",
|
|
58
55
|
vike: "^0.4.196",
|
|
@@ -106,10 +103,7 @@ async function getPackageJson(props) {
|
|
|
106
103
|
}
|
|
107
104
|
});
|
|
108
105
|
return addDependency(packageJson, await Promise.resolve().then(() => __toESM(require_package(), 1)).then((x) => x.default), {
|
|
109
|
-
devDependencies: [
|
|
110
|
-
"@types/express",
|
|
111
|
-
...props.meta.BATI.has("firebase-auth") ? ["@types/cookie-parser"] : []
|
|
112
|
-
],
|
|
106
|
+
devDependencies: ["@types/express"],
|
|
113
107
|
dependencies: [
|
|
114
108
|
"@universal-middleware/express",
|
|
115
109
|
"cross-env",
|
|
@@ -117,7 +111,7 @@ async function getPackageJson(props) {
|
|
|
117
111
|
"tsx",
|
|
118
112
|
"vite",
|
|
119
113
|
"vike",
|
|
120
|
-
...props.meta.BATI.has("
|
|
114
|
+
...props.meta.BATI.has("auth0") || props.meta.BATI.hasDatabase ? ["dotenv"] : []
|
|
121
115
|
]
|
|
122
116
|
});
|
|
123
117
|
}
|
|
@@ -105,16 +105,15 @@ async function getPackageJson(props) {
|
|
|
105
105
|
}
|
|
106
106
|
});
|
|
107
107
|
return addDependency(packageJson, await Promise.resolve().then(() => __toESM(require_package(), 1)).then((x) => x.default), {
|
|
108
|
-
devDependencies: ["
|
|
108
|
+
devDependencies: ["cross-env", "tsx", "@types/node"],
|
|
109
109
|
dependencies: [
|
|
110
110
|
"@fastify/middie",
|
|
111
111
|
"@fastify/static",
|
|
112
112
|
"@universal-middleware/fastify",
|
|
113
|
-
"cross-env",
|
|
114
113
|
"fastify",
|
|
115
|
-
"tsx",
|
|
116
114
|
"vike",
|
|
117
|
-
"vite"
|
|
115
|
+
"vite",
|
|
116
|
+
...props.meta.BATI.has("auth0") || props.meta.BATI.hasDatabase ? ["dotenv"] : []
|
|
118
117
|
]
|
|
119
118
|
});
|
|
120
119
|
}
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
import type { RequestContext, ResponseContext } from "express-openid-connect";
|
|
2
1
|
import type { UserRecord } from "firebase-admin/auth";
|
|
3
2
|
|
|
4
|
-
//# BATI.has("auth0")
|
|
5
|
-
declare module "node:http" {
|
|
6
|
-
interface IncomingMessage {
|
|
7
|
-
oidc: RequestContext;
|
|
8
|
-
}
|
|
9
|
-
interface ServerResponse {
|
|
10
|
-
oidc: ResponseContext;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
3
|
//# BATI.has("firebase-auth")
|
|
15
4
|
declare module "fastify" {
|
|
16
5
|
interface FastifyRequest {
|
|
@@ -115,8 +115,8 @@ import { addDependency, loadAsJson } from "@batijs/core";
|
|
|
115
115
|
async function getPackageJson(props) {
|
|
116
116
|
const packageJson = await loadAsJson(props);
|
|
117
117
|
return addDependency(packageJson, await Promise.resolve().then(() => __toESM(require_package(), 1)).then((x) => x.default), {
|
|
118
|
-
devDependencies: ["
|
|
119
|
-
dependencies: ["firebase", "firebase-admin", "firebaseui", "cookie", "@universal-middleware/core"]
|
|
118
|
+
devDependencies: ["@types/cookie"],
|
|
119
|
+
dependencies: ["firebase", "firebase-admin", "firebaseui", "cookie", "@universal-middleware/core", "dotenv"]
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
122
|
export {
|
|
@@ -106,10 +106,7 @@ async function getPackageJson(props) {
|
|
|
106
106
|
}
|
|
107
107
|
});
|
|
108
108
|
return addDependency(packageJson, await Promise.resolve().then(() => __toESM(require_package(), 1)).then((x) => x.default), {
|
|
109
|
-
devDependencies: [
|
|
110
|
-
"@types/serve-static",
|
|
111
|
-
...props.meta.BATI.has("auth0") ? ["@types/express", "dotenv"] : []
|
|
112
|
-
],
|
|
109
|
+
devDependencies: ["@types/serve-static"],
|
|
113
110
|
dependencies: [
|
|
114
111
|
"@hattip/polyfills",
|
|
115
112
|
"cross-env",
|
|
@@ -119,7 +116,8 @@ async function getPackageJson(props) {
|
|
|
119
116
|
"vike",
|
|
120
117
|
"vite",
|
|
121
118
|
"@universal-middleware/h3",
|
|
122
|
-
...props.meta.BATI.has("authjs") || props.meta.BATI.has("auth0") ? ["@auth/core"] : []
|
|
119
|
+
...props.meta.BATI.has("authjs") || props.meta.BATI.has("auth0") ? ["@auth/core"] : [],
|
|
120
|
+
...props.meta.BATI.has("auth0") || props.meta.BATI.hasDatabase ? ["dotenv"] : []
|
|
123
121
|
]
|
|
124
122
|
});
|
|
125
123
|
}
|
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
import type { RequestContext, ResponseContext } from "express-openid-connect";
|
|
2
1
|
import type { UserRecord } from "firebase-admin/auth";
|
|
3
2
|
|
|
4
|
-
//# BATI.has("auth0")
|
|
5
|
-
declare module "node:http" {
|
|
6
|
-
interface IncomingMessage {
|
|
7
|
-
oidc: RequestContext;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface ServerResponse {
|
|
11
|
-
oidc: ResponseContext;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
3
|
//# BATI.has("firebase-auth")
|
|
16
4
|
declare module "h3" {
|
|
17
5
|
interface H3EventContext {
|
|
@@ -97,7 +97,7 @@ var require_package = __commonJS({
|
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
// files/$package.json.ts
|
|
100
|
-
import { addDependency, loadAsJson, setScripts } from "@batijs/core";
|
|
100
|
+
import { addDependency, loadAsJson, removeDependency, setScripts } from "@batijs/core";
|
|
101
101
|
async function getPackageJson(props) {
|
|
102
102
|
const packageJson = await loadAsJson(props);
|
|
103
103
|
setScripts(packageJson, {
|
|
@@ -127,7 +127,7 @@ async function getPackageJson(props) {
|
|
|
127
127
|
if (packageJson.scripts.preview) {
|
|
128
128
|
delete packageJson.scripts.preview;
|
|
129
129
|
}
|
|
130
|
-
|
|
130
|
+
addDependency(packageJson, await Promise.resolve().then(() => __toESM(require_package(), 1)).then((x) => x.default), {
|
|
131
131
|
devDependencies: ["@hattip/vite", "@hattip/adapter-node"],
|
|
132
132
|
dependencies: [
|
|
133
133
|
"@hattip/core",
|
|
@@ -137,11 +137,12 @@ async function getPackageJson(props) {
|
|
|
137
137
|
"vite",
|
|
138
138
|
"vike",
|
|
139
139
|
"@universal-middleware/hattip",
|
|
140
|
-
"dotenv",
|
|
140
|
+
...props.meta.BATI.has("auth0") || props.meta.BATI.hasDatabase ? ["dotenv"] : [],
|
|
141
141
|
...props.meta.BATI.has("vercel") ? ["@hattip/adapter-vercel-edge"] : [],
|
|
142
142
|
...props.meta.BATI.has("aws") ? ["@types/aws-lambda", "@hattip/adapter-aws-lambda", "@hattip/static", "@hattip/walk"] : []
|
|
143
143
|
]
|
|
144
144
|
});
|
|
145
|
+
return removeDependency(packageJson, "tsx");
|
|
145
146
|
}
|
|
146
147
|
export {
|
|
147
148
|
getPackageJson as default
|
|
@@ -102,12 +102,13 @@ import { addDependency, loadAsJson } from "@batijs/core";
|
|
|
102
102
|
async function getPackageJson(props) {
|
|
103
103
|
const packageJson = await loadAsJson(props);
|
|
104
104
|
return addDependency(packageJson, await Promise.resolve().then(() => __toESM(require_package(), 1)).then((x) => x.default), {
|
|
105
|
-
devDependencies: ["
|
|
105
|
+
devDependencies: ["@types/better-sqlite3", "@types/cookie"],
|
|
106
106
|
dependencies: [
|
|
107
107
|
"arctic",
|
|
108
108
|
"cookie",
|
|
109
109
|
"lucia",
|
|
110
110
|
"@universal-middleware/core",
|
|
111
|
+
"dotenv",
|
|
111
112
|
...props.meta.BATI.has("drizzle") ? ["@lucia-auth/adapter-drizzle"] : ["better-sqlite3", "@lucia-auth/adapter-sqlite"]
|
|
112
113
|
]
|
|
113
114
|
});
|
|
@@ -147,13 +147,16 @@ export const luciaAuthSignupHandler = (() => async (request, context, _runtime)
|
|
|
147
147
|
},
|
|
148
148
|
});
|
|
149
149
|
} catch (error) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
150
|
+
console.error(error);
|
|
151
|
+
if (BATI.has("sqlite") && !BATI.hasD1) {
|
|
152
|
+
if (error instanceof SqliteError && error.code === "SQLITE_CONSTRAINT_UNIQUE") {
|
|
153
|
+
return new Response(JSON.stringify({ error: { username: "Username already in use" } }), {
|
|
154
|
+
status: 422,
|
|
155
|
+
headers: {
|
|
156
|
+
"content-type": "application/json",
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
}
|
|
157
160
|
}
|
|
158
161
|
|
|
159
162
|
return new Response(JSON.stringify({ error: { invalid: "An unknown error has occurred" } }), {
|
|
@@ -120,8 +120,8 @@ async function getPackageJson(props) {
|
|
|
120
120
|
const packageJson = await loadAsJson(props);
|
|
121
121
|
packageJson.scripts["sqlite:migrate"] = "tsx ./database/sqlite/schema/all.ts";
|
|
122
122
|
return addDependency(packageJson, await Promise.resolve().then(() => __toESM(require_package(), 1)).then((x) => x.default), {
|
|
123
|
-
devDependencies: ["
|
|
124
|
-
dependencies: ["better-sqlite3"]
|
|
123
|
+
devDependencies: ["@types/better-sqlite3", "tsx"],
|
|
124
|
+
dependencies: ["better-sqlite3", "dotenv"]
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
export {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/*{ @if (it.BATI.has("lucia-auth")) }*/
|
|
2
2
|
import "dotenv/config";
|
|
3
3
|
import { db } from "../db";
|
|
4
4
|
|
|
@@ -29,3 +29,4 @@ client.exec(`CREATE TABLE IF NOT EXISTS sessions (
|
|
|
29
29
|
user_id TEXT NOT NULL,
|
|
30
30
|
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE cascade ON DELETE cascade
|
|
31
31
|
)`);
|
|
32
|
+
/*{ /if }*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const trpcHandler: (endpoint: string) => (request: Request, context: Universal.Context, runtime: import("@universal-middleware/core").RuntimeAdapter) => Promise<Response>;
|
|
1
|
+
export declare const trpcHandler: (endpoint: string) => (request: Request<unknown, CfProperties<unknown>>, context: Universal.Context, runtime: import("@universal-middleware/core").RuntimeAdapter) => Promise<Response>;
|
|
@@ -5,9 +5,9 @@ export declare const trpc: {
|
|
|
5
5
|
ctx: object & {
|
|
6
6
|
db: ReturnType<typeof import("@batijs/sqlite/database/sqlite/db").db>;
|
|
7
7
|
} & {
|
|
8
|
-
db: ReturnType<
|
|
8
|
+
db: ReturnType<typeof import("@batijs/drizzle/database/drizzle/db").dbSqlite>;
|
|
9
9
|
} & {
|
|
10
|
-
db: ReturnType<
|
|
10
|
+
db: ReturnType<typeof import("@batijs/drizzle/database/drizzle/db").dbD1>;
|
|
11
11
|
} & {
|
|
12
12
|
db: import("@cloudflare/workers-types").D1Database;
|
|
13
13
|
};
|
|
@@ -18,9 +18,9 @@ export declare const trpc: {
|
|
|
18
18
|
_ctx_out: object & {
|
|
19
19
|
db: ReturnType<typeof import("@batijs/sqlite/database/sqlite/db").db>;
|
|
20
20
|
} & {
|
|
21
|
-
db: ReturnType<
|
|
21
|
+
db: ReturnType<typeof import("@batijs/drizzle/database/drizzle/db").dbSqlite>;
|
|
22
22
|
} & {
|
|
23
|
-
db: ReturnType<
|
|
23
|
+
db: ReturnType<typeof import("@batijs/drizzle/database/drizzle/db").dbD1>;
|
|
24
24
|
} & {
|
|
25
25
|
db: import("@cloudflare/workers-types").D1Database;
|
|
26
26
|
};
|
|
@@ -39,9 +39,9 @@ export declare const trpc: {
|
|
|
39
39
|
ctx: object & {
|
|
40
40
|
db: ReturnType<typeof import("@batijs/sqlite/database/sqlite/db").db>;
|
|
41
41
|
} & {
|
|
42
|
-
db: ReturnType<
|
|
42
|
+
db: ReturnType<typeof import("@batijs/drizzle/database/drizzle/db").dbSqlite>;
|
|
43
43
|
} & {
|
|
44
|
-
db: ReturnType<
|
|
44
|
+
db: ReturnType<typeof import("@batijs/drizzle/database/drizzle/db").dbD1>;
|
|
45
45
|
} & {
|
|
46
46
|
db: import("@cloudflare/workers-types").D1Database;
|
|
47
47
|
};
|
|
@@ -53,9 +53,9 @@ export declare const trpc: {
|
|
|
53
53
|
_ctx_out: object & {
|
|
54
54
|
db: ReturnType<typeof import("@batijs/sqlite/database/sqlite/db").db>;
|
|
55
55
|
} & {
|
|
56
|
-
db: ReturnType<
|
|
56
|
+
db: ReturnType<typeof import("@batijs/drizzle/database/drizzle/db").dbSqlite>;
|
|
57
57
|
} & {
|
|
58
|
-
db: ReturnType<
|
|
58
|
+
db: ReturnType<typeof import("@batijs/drizzle/database/drizzle/db").dbD1>;
|
|
59
59
|
} & {
|
|
60
60
|
db: import("@cloudflare/workers-types").D1Database;
|
|
61
61
|
};
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
"config": {
|
|
31
31
|
"if": {
|
|
32
32
|
"flag": "aws"
|
|
33
|
-
}
|
|
33
|
+
},
|
|
34
|
+
"enforce": "post"
|
|
34
35
|
},
|
|
35
36
|
"folder": "@batijs/aws",
|
|
36
37
|
"subfolders": [
|
|
@@ -52,7 +53,8 @@
|
|
|
52
53
|
"config": {
|
|
53
54
|
"if": {
|
|
54
55
|
"flag": "cloudflare"
|
|
55
|
-
}
|
|
56
|
+
},
|
|
57
|
+
"enforce": "post"
|
|
56
58
|
},
|
|
57
59
|
"folder": "@batijs/cloudflare",
|
|
58
60
|
"subfolders": [
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,7 @@ import { relative } from "node:path";
|
|
|
22
22
|
import { parseModule, transformAndFormat } from "@batijs/core";
|
|
23
23
|
import { parse } from "path";
|
|
24
24
|
import { formatCode } from "@batijs/core";
|
|
25
|
+
import { extname } from "node:path";
|
|
25
26
|
async function mergeDts({
|
|
26
27
|
fileContent,
|
|
27
28
|
previousContent,
|
|
@@ -180,6 +181,77 @@ Please report this issue to https://github.com/vikejs/bati`);
|
|
|
180
181
|
}
|
|
181
182
|
}
|
|
182
183
|
};
|
|
184
|
+
var RelationFile = class _RelationFile {
|
|
185
|
+
constructor(pathAbsolute, includeIfImported) {
|
|
186
|
+
this.pathAbsolute = pathAbsolute;
|
|
187
|
+
this.includeIfImported = includeIfImported;
|
|
188
|
+
_RelationFile.allPathAbsolute.set(pathAbsolute, this);
|
|
189
|
+
if (includeIfImported) {
|
|
190
|
+
_RelationFile.allIncludeIfImported.push(this);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
static allPathAbsolute = /* @__PURE__ */ new Map();
|
|
194
|
+
static allIncludeIfImported = [];
|
|
195
|
+
};
|
|
196
|
+
var RelationImport = class _RelationImport {
|
|
197
|
+
constructor(source, importTarget) {
|
|
198
|
+
this.source = source;
|
|
199
|
+
this.importTarget = importTarget;
|
|
200
|
+
_RelationImport.allImports.push(this);
|
|
201
|
+
}
|
|
202
|
+
static allImports = [];
|
|
203
|
+
get importTargetRelationFile() {
|
|
204
|
+
const potentialTargets = importToPotentialTargets(this.importTarget);
|
|
205
|
+
for (const target of potentialTargets) {
|
|
206
|
+
if (RelationFile.allPathAbsolute.has(target)) {
|
|
207
|
+
return RelationFile.allPathAbsolute.get(target);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
static computeUnimportedFiles() {
|
|
212
|
+
const unimportedFiles = [];
|
|
213
|
+
const importedByVolatileFile = [];
|
|
214
|
+
for (const file of RelationFile.allIncludeIfImported) {
|
|
215
|
+
const importedFile = _RelationImport.allImports.find((ai) => ai.importTargetRelationFile === file);
|
|
216
|
+
if (!importedFile) {
|
|
217
|
+
unimportedFiles.push(file);
|
|
218
|
+
} else if (importedFile.source.includeIfImported) {
|
|
219
|
+
importedByVolatileFile.push(importedFile);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return computeDeepUnimportedFiles(importedByVolatileFile, unimportedFiles);
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
function computeDeepUnimportedFiles(importedByVolatileFile, unimportedFiles) {
|
|
226
|
+
const copyImportedByVolatileFile = Array.from(importedByVolatileFile);
|
|
227
|
+
let redo = false;
|
|
228
|
+
for (const relationImport of copyImportedByVolatileFile) {
|
|
229
|
+
const found = unimportedFiles.find((uf) => uf === relationImport.source);
|
|
230
|
+
if (found) {
|
|
231
|
+
redo = true;
|
|
232
|
+
unimportedFiles.push(relationImport.importTargetRelationFile);
|
|
233
|
+
importedByVolatileFile = importedByVolatileFile.filter((i) => i !== relationImport);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (redo) {
|
|
237
|
+
computeDeepUnimportedFiles(importedByVolatileFile, unimportedFiles);
|
|
238
|
+
}
|
|
239
|
+
return unimportedFiles;
|
|
240
|
+
}
|
|
241
|
+
function importToPotentialTargets(imp) {
|
|
242
|
+
let subject = imp;
|
|
243
|
+
const ext = extname(imp);
|
|
244
|
+
const targets = [];
|
|
245
|
+
if (ext.match(/^\.[jt]sx?$/)) {
|
|
246
|
+
subject = subject.replace(/^\.[jt]sx?$/, "");
|
|
247
|
+
}
|
|
248
|
+
if (!ext || subject !== imp) {
|
|
249
|
+
targets.push(...[".js", ".jsx", ".ts", ".tsx", ".cjs", ".mjs"].map((e) => `${subject}${e}`));
|
|
250
|
+
} else {
|
|
251
|
+
targets.push(imp);
|
|
252
|
+
}
|
|
253
|
+
return targets;
|
|
254
|
+
}
|
|
183
255
|
var reIgnoreFile = /^(chunk-|asset-|#)/gi;
|
|
184
256
|
function toDist(filepath, source, dist) {
|
|
185
257
|
const split = filepath.split(path.sep);
|
|
@@ -223,32 +295,16 @@ async function* walk(dir) {
|
|
|
223
295
|
} else if (d.isFile()) yield entry;
|
|
224
296
|
}
|
|
225
297
|
}
|
|
226
|
-
function importToPotentialTargets(imp) {
|
|
227
|
-
let subject = imp;
|
|
228
|
-
const ext = path.extname(imp);
|
|
229
|
-
const targets = [];
|
|
230
|
-
if (ext.match(/^\.[jt]sx?$/)) {
|
|
231
|
-
subject = subject.replace(/^\.[jt]sx?$/, "");
|
|
232
|
-
}
|
|
233
|
-
if (!ext || subject !== imp) {
|
|
234
|
-
targets.push(...[".js", ".jsx", ".ts", ".tsx", ".cjs", ".mjs"].map((e) => `${subject}${e}`));
|
|
235
|
-
} else {
|
|
236
|
-
targets.push(imp);
|
|
237
|
-
}
|
|
238
|
-
return targets;
|
|
239
|
-
}
|
|
240
298
|
async function main(options, meta) {
|
|
241
299
|
const sources = Array.isArray(options.source) ? options.source : [options.source];
|
|
242
|
-
const allImports = /* @__PURE__ */ new
|
|
300
|
+
const allImports = /* @__PURE__ */ new Map();
|
|
243
301
|
const filesContainingIncludeIfImported = /* @__PURE__ */ new Set();
|
|
244
|
-
function updateAllImports(target, imports) {
|
|
302
|
+
function updateAllImports(target, imports, includeIfImported) {
|
|
303
|
+
const rf = new RelationFile(target, includeIfImported);
|
|
245
304
|
if (!imports) return;
|
|
246
305
|
for (const imp of imports.values()) {
|
|
247
306
|
const importTarget = path.resolve(path.dirname(target), imp);
|
|
248
|
-
|
|
249
|
-
for (const imp2 of importTargets) {
|
|
250
|
-
allImports.add(imp2);
|
|
251
|
-
}
|
|
307
|
+
new RelationImport(rf, importTarget);
|
|
252
308
|
}
|
|
253
309
|
}
|
|
254
310
|
const rearranger = new OperationsRearranger();
|
|
@@ -298,7 +354,11 @@ Please report this issue to https://github.com/vikejs/bati`
|
|
|
298
354
|
meta,
|
|
299
355
|
previousOperationSameDestination: previousOp
|
|
300
356
|
});
|
|
301
|
-
updateAllImports(
|
|
357
|
+
updateAllImports(
|
|
358
|
+
op.destinationAbsolute,
|
|
359
|
+
report.context?.imports,
|
|
360
|
+
Boolean(report.context?.flags.has("include-if-imported"))
|
|
361
|
+
);
|
|
302
362
|
} else if (op.kind === "transform") {
|
|
303
363
|
report = await executeOperationTransform(op, {
|
|
304
364
|
meta,
|
|
@@ -308,18 +368,13 @@ Please report this issue to https://github.com/vikejs/bati`
|
|
|
308
368
|
if (report.content) {
|
|
309
369
|
await safeWriteFile(op.destination, report.content.trimStart());
|
|
310
370
|
}
|
|
311
|
-
if (report.context?.flags.has("include-if-imported")) {
|
|
312
|
-
filesContainingIncludeIfImported.add(op.destinationAbsolute);
|
|
313
|
-
}
|
|
314
371
|
previousOp = {
|
|
315
372
|
...op,
|
|
316
373
|
...report
|
|
317
374
|
};
|
|
318
375
|
}
|
|
319
|
-
for (const target of
|
|
320
|
-
|
|
321
|
-
await safeRmFile(target, { removeEmptyDir: true });
|
|
322
|
-
}
|
|
376
|
+
for (const target of RelationImport.computeUnimportedFiles()) {
|
|
377
|
+
await safeRmFile(target.pathAbsolute, { removeEmptyDir: true });
|
|
323
378
|
}
|
|
324
379
|
}
|
|
325
380
|
|
|
@@ -1677,7 +1732,7 @@ var createDefaultQueryTester = function(query, options) {
|
|
|
1677
1732
|
// package.json
|
|
1678
1733
|
var package_default = {
|
|
1679
1734
|
name: "@batijs/cli",
|
|
1680
|
-
version: "0.0.
|
|
1735
|
+
version: "0.0.286",
|
|
1681
1736
|
type: "module",
|
|
1682
1737
|
scripts: {
|
|
1683
1738
|
"check-types": "tsc --noEmit",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@batijs/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.286",
|
|
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",
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
"typescript": "^5.6.2",
|
|
21
21
|
"unplugin-purge-polyfills": "^0.0.6",
|
|
22
22
|
"vite": "^5.4.7",
|
|
23
|
-
"@batijs/build": "0.0.
|
|
24
|
-
"@batijs/compile": "0.0.
|
|
23
|
+
"@batijs/build": "0.0.286",
|
|
24
|
+
"@batijs/compile": "0.0.286"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@batijs/core": "0.0.
|
|
28
|
-
"@batijs/features": "0.0.
|
|
27
|
+
"@batijs/core": "0.0.286",
|
|
28
|
+
"@batijs/features": "0.0.286"
|
|
29
29
|
},
|
|
30
30
|
"bin": "./dist/index.js",
|
|
31
31
|
"exports": {
|