@batijs/cli 0.0.247 → 0.0.249
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 +1 -1
- package/dist/boilerplates/@batijs/drizzle/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/express/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/fastify/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/firebase-auth/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/h3/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/hattip/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/hono/files/$package.json.js +2 -2
- package/dist/boilerplates/@batijs/lucia-auth/files/$package.json.js +2 -2
- package/dist/boilerplates/@batijs/react/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/shared-server/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/telefunc/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/ts-rest/files/$package.json.js +1 -1
- package/dist/index.js +181 -112
- package/package.json +5 -5
|
@@ -42,9 +42,9 @@ var require_package = __commonJS({
|
|
|
42
42
|
license: "MIT",
|
|
43
43
|
devDependencies: {
|
|
44
44
|
"@auth/core": "^0.34.2",
|
|
45
|
-
"@universal-middleware/core": "^0.2.3",
|
|
46
45
|
"@batijs/compile": "workspace:*",
|
|
47
46
|
"@types/node": "^18.19.14",
|
|
47
|
+
"@universal-middleware/core": "^0.2.5",
|
|
48
48
|
dotenv: "^16.4.5"
|
|
49
49
|
},
|
|
50
50
|
dependencies: {
|
|
@@ -44,7 +44,7 @@ var require_package = __commonJS({
|
|
|
44
44
|
"@batijs/compile": "workspace:*",
|
|
45
45
|
"@types/better-sqlite3": "^7.6.11",
|
|
46
46
|
"@types/node": "^18.19.14",
|
|
47
|
-
"better-sqlite3": "^11.1
|
|
47
|
+
"better-sqlite3": "^11.2.1",
|
|
48
48
|
"drizzle-kit": "^0.24.0",
|
|
49
49
|
"drizzle-orm": "^0.33.0",
|
|
50
50
|
tsx: "^4.17.0"
|
|
@@ -55,7 +55,7 @@ var require_package = __commonJS({
|
|
|
55
55
|
"@types/cookie-parser": "^1.4.7",
|
|
56
56
|
"@types/express": "^4.17.21",
|
|
57
57
|
"@types/node": "^18.19.14",
|
|
58
|
-
"@universal-middleware/express": "^0.2.
|
|
58
|
+
"@universal-middleware/express": "^0.2.2",
|
|
59
59
|
"cookie-parser": "^1.4.6",
|
|
60
60
|
"cross-env": "^7.0.3",
|
|
61
61
|
dotenv: "^16.4.5",
|
|
@@ -56,7 +56,7 @@ var require_package = __commonJS({
|
|
|
56
56
|
"@trpc/server": "^10.45.2",
|
|
57
57
|
"@types/express": "^4.17.21",
|
|
58
58
|
"@types/node": "^18.19.14",
|
|
59
|
-
"@universal-middleware/fastify": "^0.2.
|
|
59
|
+
"@universal-middleware/fastify": "^0.2.2",
|
|
60
60
|
"cross-env": "^7.0.3",
|
|
61
61
|
dotenv: "^16.4.5",
|
|
62
62
|
fastify: "^4.28.1",
|
|
@@ -44,7 +44,7 @@ var require_package = __commonJS({
|
|
|
44
44
|
"@batijs/compile": "workspace:*",
|
|
45
45
|
"@types/cookie": "^0.6.0",
|
|
46
46
|
"@types/node": "^18.19.14",
|
|
47
|
-
"@universal-middleware/core": "^0.2.
|
|
47
|
+
"@universal-middleware/core": "^0.2.5",
|
|
48
48
|
cookie: "^0.6.0",
|
|
49
49
|
dotenv: "^16.4.5",
|
|
50
50
|
firebase: "^10.13.0",
|
|
@@ -56,7 +56,7 @@ var require_package = __commonJS({
|
|
|
56
56
|
"@types/express": "^4.17.21",
|
|
57
57
|
"@types/node": "^18.19.14",
|
|
58
58
|
"@types/serve-static": "^1.15.7",
|
|
59
|
-
"@universal-middleware/h3": "^0.2.
|
|
59
|
+
"@universal-middleware/h3": "^0.2.1",
|
|
60
60
|
"cross-env": "^7.0.3",
|
|
61
61
|
dotenv: "^16.4.5",
|
|
62
62
|
h3: "~1.12.0",
|
|
@@ -58,7 +58,7 @@ var require_package = __commonJS({
|
|
|
58
58
|
"@hattip/vite": "^0.0.47",
|
|
59
59
|
"@trpc/server": "^10.45.2",
|
|
60
60
|
"@types/node": "^18.19.14",
|
|
61
|
-
"@universal-middleware/hattip": "^0.2.
|
|
61
|
+
"@universal-middleware/hattip": "^0.2.2",
|
|
62
62
|
"cross-env": "^7.0.3",
|
|
63
63
|
dotenv: "^16.4.5",
|
|
64
64
|
hattip: "^0.0.33",
|
|
@@ -55,10 +55,10 @@ var require_package = __commonJS({
|
|
|
55
55
|
"@hono/vite-dev-server": "^0.14.0",
|
|
56
56
|
"@trpc/server": "^10.45.2",
|
|
57
57
|
"@types/node": "^18.19.14",
|
|
58
|
-
"@universal-middleware/hono": "^0.2.
|
|
58
|
+
"@universal-middleware/hono": "^0.2.3",
|
|
59
59
|
"cross-env": "^7.0.3",
|
|
60
60
|
dotenv: "^16.4.5",
|
|
61
|
-
hono: "^4.5.
|
|
61
|
+
hono: "^4.5.7",
|
|
62
62
|
telefunc: "^0.1.76",
|
|
63
63
|
tsx: "^4.17.0",
|
|
64
64
|
vike: "^0.4.191",
|
|
@@ -48,9 +48,9 @@ var require_package = __commonJS({
|
|
|
48
48
|
"@types/better-sqlite3": "^7.6.11",
|
|
49
49
|
"@types/cookie": "^0.6.0",
|
|
50
50
|
"@types/node": "^18.19.14",
|
|
51
|
-
"@universal-middleware/core": "^0.2.
|
|
51
|
+
"@universal-middleware/core": "^0.2.5",
|
|
52
52
|
arctic: "^1.9.2",
|
|
53
|
-
"better-sqlite3": "^11.1
|
|
53
|
+
"better-sqlite3": "^11.2.1",
|
|
54
54
|
cookie: "^0.6.0",
|
|
55
55
|
dotenv: "^16.4.5",
|
|
56
56
|
"drizzle-orm": "^0.33.0",
|
|
@@ -51,7 +51,7 @@ var require_package = __commonJS({
|
|
|
51
51
|
"@batijs/trpc": "workspace:^",
|
|
52
52
|
"@batijs/ts-rest": "workspace:*",
|
|
53
53
|
"@types/node": "^18.19.14",
|
|
54
|
-
"@types/react": "^18.3.
|
|
54
|
+
"@types/react": "^18.3.4",
|
|
55
55
|
"@types/react-dom": "^18.3.0",
|
|
56
56
|
"@vitejs/plugin-react": "^4.3.1",
|
|
57
57
|
"cross-fetch": "^4.0.0",
|
|
@@ -48,7 +48,7 @@ var require_package = __commonJS({
|
|
|
48
48
|
"@batijs/features": "workspace:*",
|
|
49
49
|
"@batijs/shared-no-db": "workspace:*",
|
|
50
50
|
"@types/node": "^18.19.14",
|
|
51
|
-
"@universal-middleware/core": "^0.2.
|
|
51
|
+
"@universal-middleware/core": "^0.2.5",
|
|
52
52
|
vike: "^0.4.191",
|
|
53
53
|
vite: "^5.4.2"
|
|
54
54
|
},
|
|
@@ -46,7 +46,7 @@ var require_package = __commonJS({
|
|
|
46
46
|
"@batijs/shared-no-db": "workspace:*",
|
|
47
47
|
"@batijs/shared-todo": "workspace:*",
|
|
48
48
|
"@types/node": "^18.19.14",
|
|
49
|
-
"@universal-middleware/core": "^0.2.
|
|
49
|
+
"@universal-middleware/core": "^0.2.5",
|
|
50
50
|
telefunc: "^0.1.76",
|
|
51
51
|
vike: "^0.4.191",
|
|
52
52
|
vite: "^5.4.2"
|
|
@@ -47,7 +47,7 @@ var require_package = __commonJS({
|
|
|
47
47
|
"@ts-rest/core": "^3.50.0",
|
|
48
48
|
"@ts-rest/serverless": "^3.50.0",
|
|
49
49
|
"@types/node": "^18.19.14",
|
|
50
|
-
"@universal-middleware/core": "^0.2.
|
|
50
|
+
"@universal-middleware/core": "^0.2.5",
|
|
51
51
|
zod: "^3.23.8"
|
|
52
52
|
},
|
|
53
53
|
dependencies: {
|
package/dist/index.js
CHANGED
|
@@ -7,25 +7,28 @@ import {
|
|
|
7
7
|
// index.ts
|
|
8
8
|
import { existsSync as existsSync2, rmSync } from "node:fs";
|
|
9
9
|
import { execSync } from "node:child_process";
|
|
10
|
-
import { access, constants, lstat, readdir, readFile as
|
|
11
|
-
import { dirname, join, parse } from "node:path";
|
|
10
|
+
import { access, constants, lstat, readdir, readFile as readFile2 } from "node:fs/promises";
|
|
11
|
+
import { dirname, join, parse as parse2 } from "node:path";
|
|
12
12
|
import { fileURLToPath } from "node:url";
|
|
13
13
|
|
|
14
14
|
// ../build/dist/index.js
|
|
15
15
|
import { existsSync } from "node:fs";
|
|
16
|
-
import { mkdir, opendir,
|
|
16
|
+
import { mkdir, opendir, rm, writeFile } from "node:fs/promises";
|
|
17
17
|
import path from "node:path";
|
|
18
|
-
import
|
|
18
|
+
import "@batijs/core";
|
|
19
|
+
import { transformAndFormat as transformAndFormat2 } from "@batijs/core";
|
|
19
20
|
import { readFile } from "node:fs/promises";
|
|
21
|
+
import { relative } from "node:path";
|
|
20
22
|
import { parseModule, transformAndFormat } from "@batijs/core";
|
|
23
|
+
import { parse } from "path";
|
|
24
|
+
import { formatCode } from "@batijs/core";
|
|
21
25
|
async function mergeDts({
|
|
22
|
-
target,
|
|
23
26
|
fileContent,
|
|
27
|
+
previousContent,
|
|
24
28
|
filepath,
|
|
25
29
|
meta
|
|
26
30
|
}) {
|
|
27
|
-
const
|
|
28
|
-
const previousAst = parseModule(previousCode);
|
|
31
|
+
const previousAst = parseModule(previousContent);
|
|
29
32
|
const currentAst = parseModule(fileContent);
|
|
30
33
|
for (const imp of previousAst.imports.$items) {
|
|
31
34
|
currentAst.imports[imp.local] = imp;
|
|
@@ -48,46 +51,33 @@ async function mergeDts({
|
|
|
48
51
|
});
|
|
49
52
|
return res.code;
|
|
50
53
|
}
|
|
51
|
-
function
|
|
52
|
-
|
|
54
|
+
async function executeOperationFile(op, {
|
|
55
|
+
meta,
|
|
56
|
+
previousOperationSameDestination
|
|
57
|
+
}) {
|
|
58
|
+
const code = await readFile(op.sourceAbsolute, { encoding: "utf-8" });
|
|
59
|
+
const filepath = relative(op.source, op.sourceAbsolute);
|
|
60
|
+
const result = await transformAndFormat2(code, meta, {
|
|
61
|
+
filepath
|
|
62
|
+
});
|
|
63
|
+
let fileContent = result.code;
|
|
64
|
+
if (op.sourceAbsolute.endsWith(".d.ts") && previousOperationSameDestination?.content) {
|
|
65
|
+
fileContent = await mergeDts({
|
|
66
|
+
fileContent,
|
|
67
|
+
previousContent: previousOperationSameDestination.content,
|
|
68
|
+
meta,
|
|
69
|
+
filepath
|
|
70
|
+
});
|
|
71
|
+
}
|
|
53
72
|
return {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
async run() {
|
|
58
|
-
let task;
|
|
59
|
-
while (task = tasks.shift()) {
|
|
60
|
-
await task();
|
|
61
|
-
}
|
|
62
|
-
}
|
|
73
|
+
context: result.context,
|
|
74
|
+
content: fileContent ? fileContent.trimStart() : void 0
|
|
63
75
|
};
|
|
64
76
|
}
|
|
65
|
-
var reIgnoreFile = /^(chunk-|asset-|#)/gi;
|
|
66
77
|
var isWin = process.platform === "win32";
|
|
67
|
-
function toDist(filepath, source, dist) {
|
|
68
|
-
const split = filepath.split(path.sep);
|
|
69
|
-
split[split.length - 1] = split[split.length - 1].replace(/^\$\$?(.*)\.[tj]sx?$/, "$1");
|
|
70
|
-
return split.join(path.sep).replace(source, dist);
|
|
71
|
-
}
|
|
72
|
-
async function safeWriteFile(destination, content) {
|
|
73
|
-
const destinationDir = path.dirname(destination);
|
|
74
|
-
await mkdir(destinationDir, {
|
|
75
|
-
recursive: true
|
|
76
|
-
});
|
|
77
|
-
await writeFile(destination, content, { encoding: "utf-8" });
|
|
78
|
-
}
|
|
79
|
-
async function* walk(dir) {
|
|
80
|
-
if (!existsSync(dir)) return;
|
|
81
|
-
for await (const d of await opendir(dir)) {
|
|
82
|
-
const entry = path.join(dir, d.name);
|
|
83
|
-
if (d.isDirectory()) {
|
|
84
|
-
yield* walk(entry);
|
|
85
|
-
} else if (d.isFile()) yield entry;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
78
|
async function transformFileAfterExec(filepath, fileContent) {
|
|
89
79
|
if (fileContent === void 0 || fileContent === null) return null;
|
|
90
|
-
const parsed =
|
|
80
|
+
const parsed = parse(filepath);
|
|
91
81
|
const toTest = [parsed.base, parsed.ext, parsed.name].filter(Boolean);
|
|
92
82
|
for (const ext of toTest) {
|
|
93
83
|
switch (ext) {
|
|
@@ -124,6 +114,105 @@ async function importTransformer(p) {
|
|
|
124
114
|
const f = await import(importFile);
|
|
125
115
|
return f.default;
|
|
126
116
|
}
|
|
117
|
+
async function executeOperationTransform(op, {
|
|
118
|
+
meta,
|
|
119
|
+
previousOperationSameDestination
|
|
120
|
+
}) {
|
|
121
|
+
const transformer = await importTransformer(op.sourceAbsolute);
|
|
122
|
+
const previousContent = previousOperationSameDestination?.content;
|
|
123
|
+
const fileContent = await transformFileAfterExec(
|
|
124
|
+
op.destination,
|
|
125
|
+
await transformer({
|
|
126
|
+
readfile: previousContent ? () => previousContent : void 0,
|
|
127
|
+
meta,
|
|
128
|
+
source: op.source,
|
|
129
|
+
target: op.destination
|
|
130
|
+
})
|
|
131
|
+
);
|
|
132
|
+
return {
|
|
133
|
+
content: fileContent !== null ? fileContent : void 0
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function orderBy(array, getter) {
|
|
137
|
+
return array.slice().sort((a, b) => {
|
|
138
|
+
const valueA = getter(a);
|
|
139
|
+
const valueB = getter(b);
|
|
140
|
+
if (valueA < valueB) return -1;
|
|
141
|
+
if (valueA > valueB) return 1;
|
|
142
|
+
return 0;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
var OperationsRearranger = class {
|
|
146
|
+
files;
|
|
147
|
+
constructor() {
|
|
148
|
+
this.files = /* @__PURE__ */ new Map();
|
|
149
|
+
}
|
|
150
|
+
addFile(file) {
|
|
151
|
+
if (!this.files.has(file.destination)) {
|
|
152
|
+
this.files.set(file.destination, []);
|
|
153
|
+
}
|
|
154
|
+
this.files.get(file.destination).push(file);
|
|
155
|
+
}
|
|
156
|
+
*compute() {
|
|
157
|
+
for (const file of this.files.values()) {
|
|
158
|
+
if (file.filter((op) => op.important).length >= 2) {
|
|
159
|
+
throw new Error(`Error while trying to generate file: '${file[0].destination}'.
|
|
160
|
+
Multiple important file is not yet supported.
|
|
161
|
+
Please report this issue to https://github.com/vikejs/bati`);
|
|
162
|
+
}
|
|
163
|
+
const newOrder = orderBy(file, (op) => {
|
|
164
|
+
if (op.kind === "file" && !op.important) return 1;
|
|
165
|
+
if (op.kind === "file" && op.important) return 2;
|
|
166
|
+
if (op.kind === "transform" && !op.important) return 3;
|
|
167
|
+
if (op.kind === "transform" && op.important) return 4;
|
|
168
|
+
throw new Error("Unhandled OperationsRearranger.compute orderBy case");
|
|
169
|
+
});
|
|
170
|
+
if (file[0].sourceAbsolute.endsWith(".d.ts")) {
|
|
171
|
+
yield* newOrder.filter((op) => op.kind === "file");
|
|
172
|
+
} else {
|
|
173
|
+
const input = newOrder.filter((op) => op.kind === "file").at(-1);
|
|
174
|
+
if (input) {
|
|
175
|
+
yield input;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
yield* newOrder.filter((op) => op.kind !== "file");
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
var reIgnoreFile = /^(chunk-|asset-|#)/gi;
|
|
183
|
+
function toDist(filepath, source, dist) {
|
|
184
|
+
const split = filepath.split(path.sep);
|
|
185
|
+
split[split.length - 1] = split[split.length - 1].replace(/^\$\$?(.*)\.[tj]sx?$/, "$1").replace(/^!(.*)$/, "$1");
|
|
186
|
+
return split.join(path.sep).replace(source, dist);
|
|
187
|
+
}
|
|
188
|
+
async function safeWriteFile(destination, content) {
|
|
189
|
+
const destinationDir = path.dirname(destination);
|
|
190
|
+
await mkdir(destinationDir, {
|
|
191
|
+
recursive: true
|
|
192
|
+
});
|
|
193
|
+
await writeFile(destination, content, { encoding: "utf-8" });
|
|
194
|
+
}
|
|
195
|
+
async function safeRmFile(destination) {
|
|
196
|
+
try {
|
|
197
|
+
await rm(destination, {
|
|
198
|
+
force: true,
|
|
199
|
+
maxRetries: 3,
|
|
200
|
+
recursive: false,
|
|
201
|
+
retryDelay: 150
|
|
202
|
+
});
|
|
203
|
+
} catch {
|
|
204
|
+
console.warn(`Failed to remove unecessary file: ${destination}`);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
async function* walk(dir) {
|
|
208
|
+
if (!existsSync(dir)) return;
|
|
209
|
+
for await (const d of await opendir(dir)) {
|
|
210
|
+
const entry = path.join(dir, d.name);
|
|
211
|
+
if (d.isDirectory()) {
|
|
212
|
+
yield* walk(entry);
|
|
213
|
+
} else if (d.isFile()) yield entry;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
127
216
|
function importToPotentialTargets(imp) {
|
|
128
217
|
let subject = imp;
|
|
129
218
|
const ext = path.extname(imp);
|
|
@@ -140,11 +229,8 @@ function importToPotentialTargets(imp) {
|
|
|
140
229
|
}
|
|
141
230
|
async function main(options, meta) {
|
|
142
231
|
const sources = Array.isArray(options.source) ? options.source : [options.source];
|
|
143
|
-
const targets = /* @__PURE__ */ new Set();
|
|
144
232
|
const allImports = /* @__PURE__ */ new Set();
|
|
145
|
-
const
|
|
146
|
-
const priorityQ = queue();
|
|
147
|
-
const transformAndWriteQ = queue();
|
|
233
|
+
const filesContainingIncludeIfImported = /* @__PURE__ */ new Set();
|
|
148
234
|
function updateAllImports(target, imports) {
|
|
149
235
|
if (!imports) return;
|
|
150
236
|
for (const imp of imports.values()) {
|
|
@@ -155,21 +241,7 @@ async function main(options, meta) {
|
|
|
155
241
|
}
|
|
156
242
|
}
|
|
157
243
|
}
|
|
158
|
-
|
|
159
|
-
if (!imports) return;
|
|
160
|
-
for (const imp of imports.values()) {
|
|
161
|
-
const importTarget = path.resolve(path.dirname(target), imp);
|
|
162
|
-
const importTargets = importToPotentialTargets(importTarget);
|
|
163
|
-
for (const imp2 of importTargets) {
|
|
164
|
-
if (includeIfImported.has(imp2)) {
|
|
165
|
-
const fn = includeIfImported.get(imp2);
|
|
166
|
-
includeIfImported.delete(imp2);
|
|
167
|
-
await fn();
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
244
|
+
const rearranger = new OperationsRearranger();
|
|
173
245
|
for (const source of sources) {
|
|
174
246
|
for await (const p of walk(source)) {
|
|
175
247
|
const target = toDist(p, source, options.dist);
|
|
@@ -182,61 +254,58 @@ async function main(options, meta) {
|
|
|
182
254
|
`Typescript file needs to be compiled before it can be executed: '${p}'.
|
|
183
255
|
Please report this issue to https://github.com/vikejs/bati`
|
|
184
256
|
);
|
|
185
|
-
} else if (parsed.name.startsWith("$") && parsed.ext.match(/\.jsx?$/)) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
readfile: targets.has(target) ? rf : void 0,
|
|
195
|
-
meta,
|
|
196
|
-
source,
|
|
197
|
-
target
|
|
198
|
-
})
|
|
199
|
-
);
|
|
200
|
-
if (fileContent !== null) {
|
|
201
|
-
await safeWriteFile(target, fileContent);
|
|
202
|
-
targets.add(target);
|
|
203
|
-
}
|
|
257
|
+
} else if ((parsed.name.startsWith("!$") || parsed.name.startsWith("$")) && parsed.ext.match(/\.jsx?$/)) {
|
|
258
|
+
rearranger.addFile({
|
|
259
|
+
source,
|
|
260
|
+
sourceAbsolute: p,
|
|
261
|
+
destination: target,
|
|
262
|
+
destinationAbsolute: targetAbsolute,
|
|
263
|
+
kind: "transform",
|
|
264
|
+
parsed,
|
|
265
|
+
important: parsed.name.startsWith("!")
|
|
204
266
|
});
|
|
205
267
|
} else {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
fileContent = await mergeDts({
|
|
215
|
-
fileContent,
|
|
216
|
-
target,
|
|
217
|
-
meta,
|
|
218
|
-
filepath
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
if (fileContent) {
|
|
222
|
-
updateAllImports(targetAbsolute, result.context?.imports);
|
|
223
|
-
if (!result.context?.flags.has("include-if-imported") || allImports.has(targetAbsolute)) {
|
|
224
|
-
await safeWriteFile(target, fileContent.trimStart());
|
|
225
|
-
await triggerPendingTargets(targetAbsolute, result.context?.imports);
|
|
226
|
-
} else {
|
|
227
|
-
includeIfImported.set(targetAbsolute, () => safeWriteFile(target, fileContent.trimStart()));
|
|
228
|
-
}
|
|
229
|
-
targets.add(target);
|
|
230
|
-
}
|
|
268
|
+
rearranger.addFile({
|
|
269
|
+
source,
|
|
270
|
+
sourceAbsolute: p,
|
|
271
|
+
destination: target,
|
|
272
|
+
destinationAbsolute: targetAbsolute,
|
|
273
|
+
kind: "file",
|
|
274
|
+
parsed,
|
|
275
|
+
important: parsed.name.startsWith("!")
|
|
231
276
|
});
|
|
232
277
|
}
|
|
233
278
|
}
|
|
234
279
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
280
|
+
let previousOp = void 0;
|
|
281
|
+
for (const op of rearranger.compute()) {
|
|
282
|
+
if (previousOp?.destination !== op.destination) {
|
|
283
|
+
previousOp = void 0;
|
|
284
|
+
}
|
|
285
|
+
let report = {};
|
|
286
|
+
if (op.kind === "file") {
|
|
287
|
+
report = await executeOperationFile(op, {
|
|
288
|
+
meta,
|
|
289
|
+
previousOperationSameDestination: previousOp
|
|
290
|
+
});
|
|
291
|
+
updateAllImports(op.destinationAbsolute, report.context?.imports);
|
|
292
|
+
} else if (op.kind === "transform") {
|
|
293
|
+
report = await executeOperationTransform(op, {
|
|
294
|
+
meta,
|
|
295
|
+
previousOperationSameDestination: previousOp
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
if (report.content) {
|
|
299
|
+
await safeWriteFile(op.destination, report.content.trimStart());
|
|
300
|
+
}
|
|
301
|
+
previousOp = {
|
|
302
|
+
...op,
|
|
303
|
+
...report
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
for (const target of filesContainingIncludeIfImported) {
|
|
307
|
+
if (!allImports.has(target)) {
|
|
308
|
+
await safeRmFile(target);
|
|
240
309
|
}
|
|
241
310
|
}
|
|
242
311
|
}
|
|
@@ -1595,7 +1664,7 @@ var createDefaultQueryTester = function(query, options) {
|
|
|
1595
1664
|
// package.json
|
|
1596
1665
|
var package_default = {
|
|
1597
1666
|
name: "@batijs/cli",
|
|
1598
|
-
version: "0.0.
|
|
1667
|
+
version: "0.0.249",
|
|
1599
1668
|
type: "module",
|
|
1600
1669
|
scripts: {
|
|
1601
1670
|
"check-types": "tsc --noEmit",
|
|
@@ -1689,7 +1758,7 @@ function boilerplatesDir() {
|
|
|
1689
1758
|
throw new Error("Missing boilerplates.json file. Run `pnpm run build`");
|
|
1690
1759
|
}
|
|
1691
1760
|
async function parseBoilerplates(dir) {
|
|
1692
|
-
return JSON.parse(await
|
|
1761
|
+
return JSON.parse(await readFile2(join(dir, "boilerplates.json"), "utf-8"));
|
|
1693
1762
|
}
|
|
1694
1763
|
function toArg(flag, description) {
|
|
1695
1764
|
if (!flag) return {};
|
|
@@ -1865,7 +1934,7 @@ async function retrieveHooks(hooks) {
|
|
|
1865
1934
|
const map = /* @__PURE__ */ new Map();
|
|
1866
1935
|
for (const hook of hooks) {
|
|
1867
1936
|
for await (const file of walk(hook)) {
|
|
1868
|
-
const parsed =
|
|
1937
|
+
const parsed = parse2(file);
|
|
1869
1938
|
const importFile = isWin2 ? "file://" + file : file;
|
|
1870
1939
|
switch (parsed.name) {
|
|
1871
1940
|
case "after":
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@batijs/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.249",
|
|
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.5.4",
|
|
21
21
|
"unplugin-purge-polyfills": "^0.0.4",
|
|
22
22
|
"vite": "^5.4.2",
|
|
23
|
-
"@batijs/
|
|
24
|
-
"@batijs/
|
|
23
|
+
"@batijs/build": "0.0.249",
|
|
24
|
+
"@batijs/compile": "0.0.249"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@batijs/
|
|
28
|
-
"@batijs/
|
|
27
|
+
"@batijs/features": "0.0.249",
|
|
28
|
+
"@batijs/core": "0.0.249"
|
|
29
29
|
},
|
|
30
30
|
"bin": "./dist/index.js",
|
|
31
31
|
"exports": {
|