@astrojs/db 0.18.0 → 0.18.1

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
  import { existsSync } from "node:fs";
2
- import { green } from "kleur/colors";
2
+ import colors from "picocolors";
3
3
  import { isDbError } from "../../../../runtime/utils.js";
4
4
  import {
5
5
  EXEC_DEFAULT_EXPORT_ERROR,
@@ -53,7 +53,7 @@ async function cmd({
53
53
  }
54
54
  try {
55
55
  await mod.default();
56
- console.info(`${green("\u2714")} File run successfully.`);
56
+ console.info(`${colors.green("\u2714")} File run successfully.`);
57
57
  } catch (e) {
58
58
  if (isDbError(e)) throw new Error(EXEC_ERROR(e.message));
59
59
  else throw e;
@@ -2,8 +2,8 @@ import { stripVTControlCharacters } from "node:util";
2
2
  import deepDiff from "deep-diff";
3
3
  import { sql } from "drizzle-orm";
4
4
  import { SQLiteAsyncDialect } from "drizzle-orm/sqlite-core";
5
- import * as color from "kleur/colors";
6
5
  import { customAlphabet } from "nanoid";
6
+ import color from "picocolors";
7
7
  import { isSerializedSQL } from "../../runtime/types.js";
8
8
  import { hasPrimaryKey, isDbError } from "../../runtime/utils.js";
9
9
  import { MIGRATION_VERSION } from "../consts.js";
@@ -1,4 +1,4 @@
1
- import { bgGreen, bgWhite, black, bold, dim, green } from "kleur/colors";
1
+ import colors from "picocolors";
2
2
  function printHelp({
3
3
  commandName,
4
4
  headline,
@@ -7,7 +7,7 @@ function printHelp({
7
7
  description
8
8
  }) {
9
9
  const linebreak = () => "";
10
- const title = (label) => ` ${bgWhite(black(` ${label} `))}`;
10
+ const title = (label) => ` ${colors.bgWhite(colors.black(` ${label} `))}`;
11
11
  const table = (rows, { padding }) => {
12
12
  const split = process.stdout.columns < 60;
13
13
  let raw = "";
@@ -18,7 +18,7 @@ function printHelp({
18
18
  } else {
19
19
  raw += `${`${row[0]}`.padStart(padding)}`;
20
20
  }
21
- raw += " " + dim(row[1]) + "\n";
21
+ raw += " " + colors.dim(row[1]) + "\n";
22
22
  }
23
23
  return raw.slice(0, -1);
24
24
  };
@@ -26,13 +26,13 @@ function printHelp({
26
26
  if (headline) {
27
27
  message.push(
28
28
  linebreak(),
29
- ` ${bgGreen(black(` ${commandName} `))} ${green(
30
- `v${"0.18.0"}`
29
+ ` ${colors.bgGreen(colors.black(` ${commandName} `))} ${colors.green(
30
+ `v${"0.18.1"}`
31
31
  )} ${headline}`
32
32
  );
33
33
  }
34
34
  if (usage) {
35
- message.push(linebreak(), ` ${green(commandName)} ${bold(usage)}`);
35
+ message.push(linebreak(), ` ${colors.green(commandName)} ${colors.bold(usage)}`);
36
36
  }
37
37
  if (tables) {
38
38
  let calculateTablePadding2 = function(rows) {
@@ -1,10 +1,10 @@
1
- import { bold, cyan, red } from "kleur/colors";
2
- const MISSING_EXECUTE_PATH_ERROR = `${red(
1
+ import colors from "picocolors";
2
+ const MISSING_EXECUTE_PATH_ERROR = `${colors.red(
3
3
  "\u25B6 No file path provided."
4
- )} Provide a path by running ${cyan("astro db execute <path>")}
4
+ )} Provide a path by running ${colors.cyan("astro db execute <path>")}
5
5
  `;
6
6
  const RENAME_TABLE_ERROR = (oldTable, newTable) => {
7
- return red("\u25B6 Potential table rename detected: " + oldTable + " -> " + newTable) + `
7
+ return colors.red("\u25B6 Potential table rename detected: " + oldTable + " -> " + newTable) + `
8
8
  You cannot add and remove tables in the same schema update batch.
9
9
 
10
10
  1. Use "deprecated: true" to deprecate a table before renaming.
@@ -13,28 +13,28 @@ const RENAME_TABLE_ERROR = (oldTable, newTable) => {
13
13
  Visit https://docs.astro.build/en/guides/astro-db/#renaming-tables to learn more.`;
14
14
  };
15
15
  const RENAME_COLUMN_ERROR = (oldSelector, newSelector) => {
16
- return red("\u25B6 Potential column rename detected: " + oldSelector + ", " + newSelector) + `
16
+ return colors.red("\u25B6 Potential column rename detected: " + oldSelector + ", " + newSelector) + `
17
17
  You cannot add and remove columns in the same table.
18
18
  To resolve, add a 'deprecated: true' flag to '${oldSelector}' instead.`;
19
19
  };
20
- const FILE_NOT_FOUND_ERROR = (path) => `${red("\u25B6 File not found:")} ${bold(path)}
20
+ const FILE_NOT_FOUND_ERROR = (path) => `${colors.red("\u25B6 File not found:")} ${colors.bold(path)}
21
21
  `;
22
- const SHELL_QUERY_MISSING_ERROR = `${red(
22
+ const SHELL_QUERY_MISSING_ERROR = `${colors.red(
23
23
  "\u25B6 Please provide a query to execute using the --query flag."
24
24
  )}
25
25
  `;
26
26
  const EXEC_ERROR = (error) => {
27
- return `${red(`Error while executing file:`)}
27
+ return `${colors.red(`Error while executing file:`)}
28
28
 
29
29
  ${error}`;
30
30
  };
31
31
  const EXEC_DEFAULT_EXPORT_ERROR = (fileName) => {
32
- return EXEC_ERROR(`Missing default function export in ${bold(fileName)}`);
32
+ return EXEC_ERROR(`Missing default function export in ${colors.bold(fileName)}`);
33
33
  };
34
34
  const INTEGRATION_TABLE_CONFLICT_ERROR = (integrationName, tableName, isUserConflict) => {
35
- return red("\u25B6 Conflicting table name in integration " + bold(integrationName)) + isUserConflict ? `
36
- A user-defined table named ${bold(tableName)} already exists` : `
37
- Another integration already added a table named ${bold(tableName)}`;
35
+ return colors.red("\u25B6 Conflicting table name in integration " + colors.bold(integrationName)) + isUserConflict ? `
36
+ A user-defined table named ${colors.bold(tableName)} already exists` : `
37
+ Another integration already added a table named ${colors.bold(tableName)}`;
38
38
  };
39
39
  export {
40
40
  EXEC_DEFAULT_EXPORT_ERROR,
@@ -2,7 +2,7 @@ import { existsSync } from "node:fs";
2
2
  import { mkdir, writeFile } from "node:fs/promises";
3
3
  import { dirname } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
- import { blue, yellow } from "kleur/colors";
5
+ import colors from "picocolors";
6
6
  import {
7
7
  createServer,
8
8
  loadEnv,
@@ -151,7 +151,9 @@ function astroDBIntegration(options) {
151
151
  const hint = "Learn more connecting to libSQL: https://docs.astro.build/en/guides/astro-db/#connect-a-libsql-database-for-production";
152
152
  throw new AstroDbError(message, hint);
153
153
  }
154
- logger.info("database: " + (connectToRemote ? yellow("remote") : blue("local database.")));
154
+ logger.info(
155
+ "database: " + (connectToRemote ? colors.yellow("remote") : colors.blue("local database."))
156
+ );
155
157
  },
156
158
  "astro:build:setup": async ({ vite }) => {
157
159
  tempViteServer = await getTempViteServer({ viteConfig: vite });
@@ -1,5 +1,5 @@
1
1
  import { SQLiteAsyncDialect } from "drizzle-orm/sqlite-core";
2
- import { bold } from "kleur/colors";
2
+ import colors from "picocolors";
3
3
  import {
4
4
  FOREIGN_KEY_DNE_ERROR,
5
5
  FOREIGN_KEY_REFERENCES_EMPTY_ERROR,
@@ -144,7 +144,7 @@ function getDefaultValueSql(columnName, column) {
144
144
  stringified = JSON.stringify(column.schema.default);
145
145
  } catch {
146
146
  console.log(
147
- `Invalid default value for column ${bold(
147
+ `Invalid default value for column ${colors.bold(
148
148
  columnName
149
149
  )}. Defaults must be valid JSON when using the \`json()\` type.`
150
150
  );
@@ -1,21 +1,21 @@
1
- import { bold } from "kleur/colors";
1
+ import colors from "picocolors";
2
2
  const FOREIGN_KEY_DNE_ERROR = (tableName) => {
3
- return `Table ${bold(
3
+ return `Table ${colors.bold(
4
4
  tableName
5
5
  )} references a table that does not exist. Did you apply the referenced table to the \`tables\` object in your db config?`;
6
6
  };
7
7
  const FOREIGN_KEY_REFERENCES_LENGTH_ERROR = (tableName) => {
8
- return `Foreign key on ${bold(
8
+ return `Foreign key on ${colors.bold(
9
9
  tableName
10
10
  )} is misconfigured. \`columns\` and \`references\` must be the same length.`;
11
11
  };
12
12
  const FOREIGN_KEY_REFERENCES_EMPTY_ERROR = (tableName) => {
13
- return `Foreign key on ${bold(
13
+ return `Foreign key on ${colors.bold(
14
14
  tableName
15
15
  )} is misconfigured. \`references\` array cannot be empty.`;
16
16
  };
17
17
  const REFERENCE_DNE_ERROR = (columnName) => {
18
- return `Column ${bold(
18
+ return `Column ${colors.bold(
19
19
  columnName
20
20
  )} references a table that does not exist. Did you apply the referenced table to the \`tables\` object in your db config?`;
21
21
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/db",
3
- "version": "0.18.0",
3
+ "version": "0.18.1",
4
4
  "description": "Add libSQL support to your Astro site",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -66,8 +66,8 @@
66
66
  "@libsql/client": "^0.15.15",
67
67
  "deep-diff": "^1.0.2",
68
68
  "drizzle-orm": "^0.42.0",
69
- "kleur": "^4.1.5",
70
- "nanoid": "^5.1.5",
69
+ "nanoid": "^5.1.6",
70
+ "picocolors": "^1.1.1",
71
71
  "prompts": "^2.4.2",
72
72
  "yargs-parser": "^21.1.1",
73
73
  "zod": "^3.25.76"
@@ -78,10 +78,10 @@
78
78
  "@types/yargs-parser": "^21.0.3",
79
79
  "cheerio": "1.1.2",
80
80
  "expect-type": "^1.2.2",
81
- "typescript": "^5.9.2",
82
- "vite": "^6.3.6",
83
- "astro-scripts": "0.0.14",
84
- "astro": "5.13.8"
81
+ "typescript": "^5.9.3",
82
+ "vite": "^6.4.0",
83
+ "astro": "5.15.0",
84
+ "astro-scripts": "0.0.14"
85
85
  },
86
86
  "scripts": {
87
87
  "types:virtual": "tsc -p ./tsconfig.virtual.json",