nextjs-cms 0.5.60 → 0.5.62
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/db/config.d.ts.map +1 -1
- package/dist/db/config.js +32 -15
- package/package.json +2 -2
package/dist/db/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/db/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/db/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAEjD,MAAM,WAAW,QAAS,SAAQ,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;IAClG,QAAQ,EAAE,MAAM,CAAA;CACnB;AAQD,wBAAgB,eAAe,CAAC,SAAS,GAAE,OAAO,CAAC,QAAQ,CAAM,GAAG,QAAQ,CAyC3E"}
|
package/dist/db/config.js
CHANGED
|
@@ -1,22 +1,39 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
1
2
|
const defaultConfig = {
|
|
2
3
|
host: 'localhost',
|
|
3
|
-
user: 'root',
|
|
4
|
-
password: 'password',
|
|
5
|
-
database: 'nextjs_cms_db',
|
|
6
4
|
port: 3306,
|
|
7
5
|
charset: 'utf8mb4',
|
|
8
6
|
};
|
|
9
7
|
export function resolveDbConfig(overrides = {}) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
try {
|
|
9
|
+
const base = {
|
|
10
|
+
host: process.env.DB_HOST ?? defaultConfig.host,
|
|
11
|
+
user: process.env.DB_USER ?? undefined,
|
|
12
|
+
password: process.env.DB_PASSWORD ?? undefined,
|
|
13
|
+
database: process.env.DB_NAME ?? undefined,
|
|
14
|
+
port: process.env.DB_PORT ? parseInt(process.env.DB_PORT, 10) : defaultConfig.port,
|
|
15
|
+
charset: process.env.DB_CHARSET ?? defaultConfig.charset,
|
|
16
|
+
};
|
|
17
|
+
const config = {
|
|
18
|
+
...base,
|
|
19
|
+
...overrides,
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Make sure database and user are not undefined
|
|
23
|
+
*/
|
|
24
|
+
if (!config.database || !config.user) {
|
|
25
|
+
throw new Error(chalk.red('Database name and user are required'), {
|
|
26
|
+
cause: 'Database configuration is incomplete.',
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return config;
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
const idDev = process.env.NODE_ENV === 'development';
|
|
33
|
+
console.log('');
|
|
34
|
+
console.error(chalk.redBright('Database name and user are required'));
|
|
35
|
+
console.log(chalk.gray(`Make sure to set the ${chalk.white.italic('DB_NAME')} and ${chalk.white.italic('DB_USER')} in your ${idDev ? 'development' : 'production'} environment variables.`));
|
|
36
|
+
console.log(chalk.gray(`Or, you can run ${chalk.greenBright.italic(`nextjs-cms-kit ${idDev ? '--dev' : ''} db-config`)} command at the root of your nextjs-cms project to set db config interactively.`));
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
22
39
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nextjs-cms",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.62",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -150,8 +150,8 @@
|
|
|
150
150
|
"prettier": "^3.3.3",
|
|
151
151
|
"tsx": "^4.20.6",
|
|
152
152
|
"typescript": "^5.9.2",
|
|
153
|
-
"@lzcms/eslint-config": "0.3.0",
|
|
154
153
|
"@lzcms/prettier-config": "0.1.0",
|
|
154
|
+
"@lzcms/eslint-config": "0.3.0",
|
|
155
155
|
"@lzcms/tsconfig": "0.1.0"
|
|
156
156
|
},
|
|
157
157
|
"license": "MIT",
|