@batijs/cli 0.0.249 → 0.0.252

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.
@@ -1,5 +1,5 @@
1
1
  /*# BATI include-if-imported #*/
2
- import { integer, primaryKey, sqliteTable, text, int } from "drizzle-orm/sqlite-core";
2
+ import { int, integer, primaryKey, sqliteTable, text } from "drizzle-orm/sqlite-core";
3
3
 
4
4
  export const userTable = sqliteTable("users", {
5
5
  id: text("id").notNull().primaryKey(),
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import { fileURLToPath } from "node:url";
13
13
 
14
14
  // ../build/dist/index.js
15
15
  import { existsSync } from "node:fs";
16
- import { mkdir, opendir, rm, writeFile } from "node:fs/promises";
16
+ import { mkdir, opendir, rm, rmdir, writeFile } from "node:fs/promises";
17
17
  import path from "node:path";
18
18
  import "@batijs/core";
19
19
  import { transformAndFormat as transformAndFormat2 } from "@batijs/core";
@@ -192,7 +192,7 @@ async function safeWriteFile(destination, content) {
192
192
  });
193
193
  await writeFile(destination, content, { encoding: "utf-8" });
194
194
  }
195
- async function safeRmFile(destination) {
195
+ async function safeRmFile(destination, options) {
196
196
  try {
197
197
  await rm(destination, {
198
198
  force: true,
@@ -200,6 +200,15 @@ async function safeRmFile(destination) {
200
200
  recursive: false,
201
201
  retryDelay: 150
202
202
  });
203
+ if (options?.removeEmptyDir) {
204
+ try {
205
+ await rmdir(path.dirname(destination), {
206
+ maxRetries: 3,
207
+ retryDelay: 150
208
+ });
209
+ } catch {
210
+ }
211
+ }
203
212
  } catch {
204
213
  console.warn(`Failed to remove unecessary file: ${destination}`);
205
214
  }
@@ -298,6 +307,9 @@ Please report this issue to https://github.com/vikejs/bati`
298
307
  if (report.content) {
299
308
  await safeWriteFile(op.destination, report.content.trimStart());
300
309
  }
310
+ if (report.context?.flags.has("include-if-imported")) {
311
+ filesContainingIncludeIfImported.add(op.destinationAbsolute);
312
+ }
301
313
  previousOp = {
302
314
  ...op,
303
315
  ...report
@@ -305,7 +317,7 @@ Please report this issue to https://github.com/vikejs/bati`
305
317
  }
306
318
  for (const target of filesContainingIncludeIfImported) {
307
319
  if (!allImports.has(target)) {
308
- await safeRmFile(target);
320
+ await safeRmFile(target, { removeEmptyDir: true });
309
321
  }
310
322
  }
311
323
  }
@@ -1664,7 +1676,7 @@ var createDefaultQueryTester = function(query, options) {
1664
1676
  // package.json
1665
1677
  var package_default = {
1666
1678
  name: "@batijs/cli",
1667
- version: "0.0.249",
1679
+ version: "0.0.252",
1668
1680
  type: "module",
1669
1681
  scripts: {
1670
1682
  "check-types": "tsc --noEmit",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@batijs/cli",
3
- "version": "0.0.249",
3
+ "version": "0.0.252",
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/build": "0.0.249",
24
- "@batijs/compile": "0.0.249"
23
+ "@batijs/build": "0.0.252",
24
+ "@batijs/compile": "0.0.252"
25
25
  },
26
26
  "dependencies": {
27
- "@batijs/features": "0.0.249",
28
- "@batijs/core": "0.0.249"
27
+ "@batijs/core": "0.0.252",
28
+ "@batijs/features": "0.0.252"
29
29
  },
30
30
  "bin": "./dist/index.js",
31
31
  "exports": {