vona-cli-set-api 1.0.397 → 1.0.401
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/cli/templates/create/project/basic/boilerplate/env/.env +5 -2
- package/cli/templates/create/project/basic/boilerplate/env/.env.prod +4 -1
- package/cli/templates/create/project/basic/boilerplate/env/.env.prod.ci +4 -1
- package/cli/templates/create/project/basic/boilerplate/env/.env.prod.docker +4 -1
- package/cli/templates/create/project/basic/boilerplate/package.original.json +1 -1
- package/cli/templates/create/project/basic/boilerplate/pnpm-workspace.yaml +7 -0
- package/cli/templates/create/project/basic/boilerplate/src/backend/cli.ts +7 -0
- package/cli/templates/create/project/basic/boilerplate/src/backend/config/config/config.ts +10 -1
- package/dist/lib/bean/cli.bin.build.d.ts +1 -0
- package/dist/lib/bean/cli.bin.build.js +18 -0
- package/dist/lib/bean/toolsBin/test.js +26 -16
- package/package.json +6 -6
|
@@ -39,7 +39,7 @@ BUILD_MINIFY = true
|
|
|
39
39
|
BUILD_LOG_CIRCULAR_DEPENDENCY = false
|
|
40
40
|
BUILD_COPY_DIST =
|
|
41
41
|
BUILD_COPY_RELEASE =
|
|
42
|
-
BUILD_DIALECT_DRIVERS = pg,mysql2
|
|
42
|
+
BUILD_DIALECT_DRIVERS = pg,mysql2,better-sqlite3
|
|
43
43
|
|
|
44
44
|
# test
|
|
45
45
|
|
|
@@ -50,7 +50,10 @@ TEST_PATTERNS_IGNORE = '**/test-vona/test/cache/cacheMem.test.ts,**/test-vona/te
|
|
|
50
50
|
|
|
51
51
|
# database
|
|
52
52
|
|
|
53
|
-
DATABASE_DEFAULT_CLIENT = '
|
|
53
|
+
DATABASE_DEFAULT_CLIENT = 'sqlite3' # sqlite3/pg/mysql
|
|
54
|
+
|
|
55
|
+
DATABASE_CLIENT_SQLITE3_FILENAME =
|
|
56
|
+
DATABASE_CLIENT_SQLITE3_NATIVEBINDING =
|
|
54
57
|
|
|
55
58
|
DATABASE_CLIENT_PG_HOST = 127.0.0.1
|
|
56
59
|
DATABASE_CLIENT_PG_PORT = 5432
|
|
@@ -4,7 +4,10 @@ SERVER_KEYS = <%=argv.SERVER_KEYS_PROD%>
|
|
|
4
4
|
|
|
5
5
|
# database
|
|
6
6
|
|
|
7
|
-
DATABASE_DEFAULT_CLIENT = '
|
|
7
|
+
DATABASE_DEFAULT_CLIENT = 'sqlite3' # sqlite3/pg/mysql
|
|
8
|
+
|
|
9
|
+
DATABASE_CLIENT_SQLITE3_FILENAME =
|
|
10
|
+
DATABASE_CLIENT_SQLITE3_NATIVEBINDING = node/better_sqlite3.node
|
|
8
11
|
|
|
9
12
|
DATABASE_CLIENT_PG_HOST = 127.0.0.1
|
|
10
13
|
DATABASE_CLIENT_PG_PORT = 5432
|
|
@@ -4,7 +4,10 @@ SERVER_LISTEN_DISABLE = true
|
|
|
4
4
|
|
|
5
5
|
# database
|
|
6
6
|
|
|
7
|
-
DATABASE_DEFAULT_CLIENT = '
|
|
7
|
+
DATABASE_DEFAULT_CLIENT = 'sqlite3' # sqlite3/pg/mysql
|
|
8
|
+
|
|
9
|
+
DATABASE_CLIENT_SQLITE3_FILENAME =
|
|
10
|
+
DATABASE_CLIENT_SQLITE3_NATIVEBINDING = node/better_sqlite3.node
|
|
8
11
|
|
|
9
12
|
DATABASE_CLIENT_PG_HOST = 127.0.0.1
|
|
10
13
|
DATABASE_CLIENT_PG_PORT = 5432
|
|
@@ -9,7 +9,10 @@ BUILD_COPY_DIST = ./docker-compose/output/dist
|
|
|
9
9
|
|
|
10
10
|
# database
|
|
11
11
|
|
|
12
|
-
DATABASE_DEFAULT_CLIENT = '
|
|
12
|
+
DATABASE_DEFAULT_CLIENT = 'sqlite3' # sqlite3/pg/mysql
|
|
13
|
+
|
|
14
|
+
DATABASE_CLIENT_SQLITE3_FILENAME =
|
|
15
|
+
DATABASE_CLIENT_SQLITE3_NATIVEBINDING = node/better_sqlite3.node
|
|
13
16
|
|
|
14
17
|
DATABASE_CLIENT_PG_HOST = pg # see: docker-compose.yml
|
|
15
18
|
DATABASE_CLIENT_PG_PORT = 5432
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ICliBuildCustomOptions } from '@cabloy/cli';
|
|
2
|
+
import { copySqlite3NativeBinding } from 'vona';
|
|
3
|
+
|
|
4
|
+
export async function afterBuild(options: ICliBuildCustomOptions) {
|
|
5
|
+
const { projectPath, outDir, env } = options;
|
|
6
|
+
await copySqlite3NativeBinding(projectPath, outDir, env);
|
|
7
|
+
}
|
|
@@ -3,7 +3,7 @@ import type { IMailClientRecord, TypeMailTransportService } from 'vona-module-a-
|
|
|
3
3
|
import type { IDatabaseClientRecord } from 'vona-module-a-orm';
|
|
4
4
|
import type * as Winston from 'winston';
|
|
5
5
|
import { replaceTemplate } from '@cabloy/utils';
|
|
6
|
-
import { $customKey, formatLoggerAxiosError, formatLoggerCtx, getLoggerPathPhysicalRoot, getPublicPathPhysicalRoot } from 'vona';
|
|
6
|
+
import { $customKey, formatLoggerAxiosError, formatLoggerCtx, getLoggerPathPhysicalRoot, getPublicPathPhysicalRoot, getSqlite3DatabaseNameDefault, getSqlite3NativeBinding } from 'vona';
|
|
7
7
|
|
|
8
8
|
declare module 'vona' {
|
|
9
9
|
export interface IInstanceRecord {
|
|
@@ -140,6 +140,15 @@ export default async function (app: VonaApplication, env: VonaConfigEnv) {
|
|
|
140
140
|
},
|
|
141
141
|
defaultClient: env.DATABASE_DEFAULT_CLIENT as keyof IDatabaseClientRecord,
|
|
142
142
|
clients: {
|
|
143
|
+
sqlite3: {
|
|
144
|
+
client: 'better-sqlite3',
|
|
145
|
+
connection: {
|
|
146
|
+
filename: env.DATABASE_CLIENT_SQLITE3_FILENAME || getSqlite3DatabaseNameDefault(app),
|
|
147
|
+
options: {
|
|
148
|
+
nativeBinding: getSqlite3NativeBinding(app, env.DATABASE_CLIENT_SQLITE3_NATIVEBINDING),
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
143
152
|
pg: {
|
|
144
153
|
client: 'pg',
|
|
145
154
|
connection: {
|
|
@@ -10,6 +10,7 @@ declare module '@cabloy/cli' {
|
|
|
10
10
|
export declare class CliBinBuild extends BeanCliBase {
|
|
11
11
|
execute(): Promise<void>;
|
|
12
12
|
_build(projectPath: string): Promise<void>;
|
|
13
|
+
_custom(projectPath: string, env: NodeJS.ProcessEnv, outDir: string): Promise<any>;
|
|
13
14
|
_assets(_projectPath: string, modulesMeta: Awaited<ReturnType<typeof glob>>, outDir: string): Promise<void>;
|
|
14
15
|
_rollup(projectPath: string, env: NodeJS.ProcessEnv, outDir: string): Promise<void>;
|
|
15
16
|
}
|
|
@@ -45,6 +45,9 @@ export class CliBinBuild extends BeanCliBase {
|
|
|
45
45
|
await rimraf(outDir);
|
|
46
46
|
await this._rollup(projectPath, env, outDir);
|
|
47
47
|
await this._assets(projectPath, modulesMeta, outDir);
|
|
48
|
+
// custom
|
|
49
|
+
await this._custom(projectPath, env, outDir);
|
|
50
|
+
// remove .vona
|
|
48
51
|
await rimraf(path.join(projectPath, '.vona'));
|
|
49
52
|
// copy
|
|
50
53
|
const outReleasesDir = path.join(projectPath, getOutReleasesDir());
|
|
@@ -68,6 +71,21 @@ export class CliBinBuild extends BeanCliBase {
|
|
|
68
71
|
fse.copySync(outDir, outReleasesDirCopy);
|
|
69
72
|
}
|
|
70
73
|
}
|
|
74
|
+
async _custom(projectPath, env, outDir) {
|
|
75
|
+
// custom
|
|
76
|
+
const jsFile = path.join(projectPath, 'src/backend/cli.ts');
|
|
77
|
+
if (!fse.existsSync(jsFile))
|
|
78
|
+
return;
|
|
79
|
+
return await this.helper.importDynamic(jsFile, async (instance) => {
|
|
80
|
+
const options = {
|
|
81
|
+
cli: this,
|
|
82
|
+
env,
|
|
83
|
+
outDir,
|
|
84
|
+
projectPath,
|
|
85
|
+
};
|
|
86
|
+
return await instance.afterBuild(options);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
71
89
|
async _assets(_projectPath, modulesMeta, outDir) {
|
|
72
90
|
const assetsPath = path.join(outDir, 'assets');
|
|
73
91
|
for (const relativeName in modulesMeta.modules) {
|
|
@@ -7,7 +7,7 @@ import { catchError, sleep } from '@cabloy/utils';
|
|
|
7
7
|
import TableClass from 'cli-table3';
|
|
8
8
|
import fse from 'fs-extra';
|
|
9
9
|
import { globby } from 'globby';
|
|
10
|
-
import { createGeneralApp } from 'vona-core';
|
|
10
|
+
import { cast, createGeneralApp } from 'vona-core';
|
|
11
11
|
import whyIsNodeRunning from 'why-is-node-running';
|
|
12
12
|
import { resolveTemplatePath } from "../../utils.js";
|
|
13
13
|
const argv = process.argv.slice(2);
|
|
@@ -29,17 +29,6 @@ async function testRun(projectPath, coverage, patterns) {
|
|
|
29
29
|
else {
|
|
30
30
|
files.push(resolveTemplatePath('test/done.test.js'));
|
|
31
31
|
}
|
|
32
|
-
// concurrency
|
|
33
|
-
let concurrency = 1;
|
|
34
|
-
if (process.env.TEST_CONCURRENCY === 'true') {
|
|
35
|
-
concurrency = os.cpus().length;
|
|
36
|
-
}
|
|
37
|
-
else if (process.env.TEST_CONCURRENCY === 'false') {
|
|
38
|
-
concurrency = 1;
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
concurrency = Number.parseInt(process.env.TEST_CONCURRENCY);
|
|
42
|
-
}
|
|
43
32
|
// coverage
|
|
44
33
|
let coverageIncludeGlobs = [];
|
|
45
34
|
if (coverage) {
|
|
@@ -60,8 +49,11 @@ async function testRun(projectPath, coverage, patterns) {
|
|
|
60
49
|
'src/suite-vendor/*/modules/*/cli/**/*.ts',
|
|
61
50
|
'src/suite-vendor/*/modules/*/templates/**/*.ts',
|
|
62
51
|
];
|
|
52
|
+
// app
|
|
53
|
+
const app = await createGeneralApp(projectPath);
|
|
54
|
+
// concurrency
|
|
55
|
+
const concurrency = await prepareConcurrency(app);
|
|
63
56
|
return new Promise(resolve => {
|
|
64
|
-
let app;
|
|
65
57
|
const testStream = run({
|
|
66
58
|
isolation: 'none',
|
|
67
59
|
concurrency,
|
|
@@ -71,9 +63,7 @@ async function testRun(projectPath, coverage, patterns) {
|
|
|
71
63
|
coverageExcludeGlobs,
|
|
72
64
|
cwd: projectPath,
|
|
73
65
|
files,
|
|
74
|
-
setup: async () => {
|
|
75
|
-
app = await createGeneralApp(projectPath);
|
|
76
|
-
},
|
|
66
|
+
setup: async () => { },
|
|
77
67
|
})
|
|
78
68
|
.on('test:coverage', data => {
|
|
79
69
|
outputCoverageReport(data.summary.totals);
|
|
@@ -112,6 +102,26 @@ async function testRun(projectPath, coverage, patterns) {
|
|
|
112
102
|
}
|
|
113
103
|
});
|
|
114
104
|
}
|
|
105
|
+
async function prepareConcurrency(app) {
|
|
106
|
+
// check
|
|
107
|
+
let concurrency = 1;
|
|
108
|
+
if (process.env.TEST_CONCURRENCY === 'true') {
|
|
109
|
+
concurrency = os.cpus().length;
|
|
110
|
+
}
|
|
111
|
+
else if (process.env.TEST_CONCURRENCY === 'false') {
|
|
112
|
+
concurrency = 1;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
concurrency = Number.parseInt(process.env.TEST_CONCURRENCY);
|
|
116
|
+
}
|
|
117
|
+
if (concurrency === 1)
|
|
118
|
+
return concurrency;
|
|
119
|
+
// check again
|
|
120
|
+
return await cast(app.bean).executor.mockCtx(async () => {
|
|
121
|
+
const db = cast(app.bean).database.getDb();
|
|
122
|
+
return db.dialect.capabilities.level ? concurrency : 1;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
115
125
|
function outputCoverageReport(totals) {
|
|
116
126
|
// table
|
|
117
127
|
const table = new TableClass({
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vona-cli-set-api",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.401",
|
|
5
5
|
"description": "vona cli-set-api",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"@babel/plugin-proposal-decorators": "^7.25.9",
|
|
32
32
|
"@babel/plugin-transform-class-properties": "^7.25.9",
|
|
33
33
|
"@babel/plugin-transform-typescript": "^7.26.8",
|
|
34
|
-
"@cabloy/cli": "^3.0.
|
|
35
|
-
"@cabloy/dotenv": "^1.1.
|
|
34
|
+
"@cabloy/cli": "^3.0.67",
|
|
35
|
+
"@cabloy/dotenv": "^1.1.11",
|
|
36
36
|
"@cabloy/extend": "^3.1.10",
|
|
37
|
-
"@cabloy/module-glob": "^5.2.
|
|
37
|
+
"@cabloy/module-glob": "^5.2.34",
|
|
38
38
|
"@cabloy/module-info": "^1.3.31",
|
|
39
39
|
"@cabloy/word-utils": "^2.0.1",
|
|
40
40
|
"@lcov-viewer/cli": "^1.3.0",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"cli-table3": "^0.6.5",
|
|
52
52
|
"compressing": "^1.10.0",
|
|
53
53
|
"fs-extra": "^11.2.0",
|
|
54
|
-
"globby": "^
|
|
54
|
+
"globby": "^16.0.0",
|
|
55
55
|
"gogocode": "^1.0.53",
|
|
56
56
|
"lodash": "^4.17.21",
|
|
57
57
|
"nodemon": "^3.1.9",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"ts-node-maintained": "^10.9.6",
|
|
62
62
|
"urllib": "^4.6.11",
|
|
63
63
|
"uuid": "^11.1.0",
|
|
64
|
-
"vona-core": "^5.0.
|
|
64
|
+
"vona-core": "^5.0.104",
|
|
65
65
|
"why-is-node-running": "^3.2.2",
|
|
66
66
|
"yargs-parser": "^22.0.0"
|
|
67
67
|
},
|