vona-cli-set-api 1.0.402 → 1.0.405
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 +1 -1
- package/cli/templates/create/project/basic/boilerplate/env/.env.prod +1 -1
- package/cli/templates/create/project/basic/boilerplate/package.original.json +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/backend/config/config/config.ts +1 -0
- package/cli/templates/tools/crud/snippets/2-meta.index.ts +10 -5
- package/cli/templates/tools/crud/snippets/2-meta.version.ts +11 -9
- package/cli/templates/tools/crud/snippets/3-en-us.ts +1 -1
- package/cli/templates/tools/crud/snippets/4-zh-cn.ts +1 -1
- package/cli/templates/tools/crud/utils.ts +15 -15
- package/dist/index.js +3313 -3
- package/dist/lib/bean/cli.bin.buildGeneral.d.ts +12 -0
- package/dist/lib/beans.d.ts +2 -0
- package/dist/lib/command/bin.buildGeneral.d.ts +19 -0
- package/dist/lib/commands.d.ts +18 -0
- package/package.json +9 -9
- package/dist/lib/bean/cli.bin.build.js +0 -185
- package/dist/lib/bean/cli.bin.buildModule.js +0 -106
- package/dist/lib/bean/cli.bin.dbReset.js +0 -48
- package/dist/lib/bean/cli.bin.dev.js +0 -66
- package/dist/lib/bean/cli.bin.play.js +0 -92
- package/dist/lib/bean/cli.bin.test.js +0 -93
- package/dist/lib/bean/cli.bin.tsc.js +0 -48
- package/dist/lib/bean/cli.create.bean.js +0 -81
- package/dist/lib/bean/cli.create.module.js +0 -73
- package/dist/lib/bean/cli.create.project.js +0 -119
- package/dist/lib/bean/cli.create.suite.js +0 -35
- package/dist/lib/bean/cli.create.test.js +0 -39
- package/dist/lib/bean/cli.default.list.js +0 -93
- package/dist/lib/bean/cli.init.appMonkey.js +0 -24
- package/dist/lib/bean/cli.init.asset.js +0 -28
- package/dist/lib/bean/cli.init.config.js +0 -38
- package/dist/lib/bean/cli.init.constant.js +0 -38
- package/dist/lib/bean/cli.init.error.js +0 -49
- package/dist/lib/bean/cli.init.lib.js +0 -38
- package/dist/lib/bean/cli.init.locale.js +0 -38
- package/dist/lib/bean/cli.init.main.js +0 -38
- package/dist/lib/bean/cli.init.monkey.js +0 -64
- package/dist/lib/bean/cli.init.static.js +0 -38
- package/dist/lib/bean/cli.init.types.js +0 -38
- package/dist/lib/bean/cli.tools.crud.js +0 -46
- package/dist/lib/bean/cli.tools.deps.js +0 -42
- package/dist/lib/bean/cli.tools.metadata.js +0 -234
- package/dist/lib/bean/toolsBin/configUtils.js +0 -56
- package/dist/lib/bean/toolsBin/dbReset.js +0 -8
- package/dist/lib/bean/toolsBin/generateEntryFiles.js +0 -90
- package/dist/lib/bean/toolsBin/generateVonaMeta.js +0 -17
- package/dist/lib/bean/toolsBin/generateZod.js +0 -48
- package/dist/lib/bean/toolsBin/play.js +0 -59
- package/dist/lib/bean/toolsBin/test.js +0 -137
- package/dist/lib/bean/toolsBin/types.js +0 -1
- package/dist/lib/bean/toolsMetadata/generateBeanGenerals.js +0 -33
- package/dist/lib/bean/toolsMetadata/generateConfig.js +0 -62
- package/dist/lib/bean/toolsMetadata/generateMetadataCustom.js +0 -23
- package/dist/lib/bean/toolsMetadata/generateMonkey.js +0 -24
- package/dist/lib/bean/toolsMetadata/generateOnions.js +0 -112
- package/dist/lib/bean/toolsMetadata/generateScope.js +0 -83
- package/dist/lib/bean/toolsMetadata/generateScopeResources.js +0 -33
- package/dist/lib/bean/toolsMetadata/generateScopeResourcesMeta.js +0 -13
- package/dist/lib/bean/toolsMetadata/utils.js +0 -84
- package/dist/lib/beans.js +0 -56
- package/dist/lib/command/bin.build.js +0 -18
- package/dist/lib/command/bin.buildModule.js +0 -18
- package/dist/lib/command/bin.dbReset.js +0 -14
- package/dist/lib/command/bin.dev.js +0 -18
- package/dist/lib/command/bin.play.js +0 -27
- package/dist/lib/command/bin.test.js +0 -18
- package/dist/lib/command/bin.tsc.js +0 -14
- package/dist/lib/command/create.bean.js +0 -46
- package/dist/lib/command/create.module.js +0 -36
- package/dist/lib/command/create.project.js +0 -43
- package/dist/lib/command/create.suite.js +0 -23
- package/dist/lib/command/create.test.js +0 -33
- package/dist/lib/command/default.list.js +0 -18
- package/dist/lib/command/init.appMonkey.js +0 -10
- package/dist/lib/command/init.asset.js +0 -33
- package/dist/lib/command/init.config.js +0 -10
- package/dist/lib/command/init.constant.js +0 -10
- package/dist/lib/command/init.error.js +0 -10
- package/dist/lib/command/init.lib.js +0 -10
- package/dist/lib/command/init.locale.js +0 -10
- package/dist/lib/command/init.main.js +0 -10
- package/dist/lib/command/init.monkey.js +0 -10
- package/dist/lib/command/init.static.js +0 -10
- package/dist/lib/command/init.types.js +0 -10
- package/dist/lib/command/tools.crud.js +0 -33
- package/dist/lib/command/tools.deps.js +0 -9
- package/dist/lib/command/tools.metadata.js +0 -14
- package/dist/lib/commands.js +0 -67
- package/dist/lib/this.js +0 -1
- package/dist/lib/utils.js +0 -80
- package/dist/typings.js +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BeanCliBase } from '@cabloy/cli';
|
|
2
|
+
declare module '@cabloy/cli' {
|
|
3
|
+
interface ICommandArgv {
|
|
4
|
+
minify: boolean;
|
|
5
|
+
sourcemap: boolean;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export declare class CliBinBuildGeneral extends BeanCliBase {
|
|
9
|
+
execute(): Promise<void>;
|
|
10
|
+
_build(projectPath: string): Promise<void>;
|
|
11
|
+
_rollup(projectPath: string): Promise<void>;
|
|
12
|
+
}
|
package/dist/lib/beans.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CliBinBuild } from './bean/cli.bin.build.ts';
|
|
2
|
+
import { CliBinBuildGeneral } from './bean/cli.bin.buildGeneral.ts';
|
|
2
3
|
import { CliBinBuildModule } from './bean/cli.bin.buildModule.ts';
|
|
3
4
|
import { CliBinDbReset } from './bean/cli.bin.dbReset.ts';
|
|
4
5
|
import { CliBinDev } from './bean/cli.bin.dev.ts';
|
|
@@ -29,6 +30,7 @@ export declare const beans: {
|
|
|
29
30
|
'default.list': typeof CliDefaultList;
|
|
30
31
|
'bin.build': typeof CliBinBuild;
|
|
31
32
|
'bin.buildModule': typeof CliBinBuildModule;
|
|
33
|
+
'bin.buildGeneral': typeof CliBinBuildGeneral;
|
|
32
34
|
'bin.dbReset': typeof CliBinDbReset;
|
|
33
35
|
'bin.play': typeof CliBinPlay;
|
|
34
36
|
'bin.dev': typeof CliBinDev;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
bean: string;
|
|
3
|
+
info: {
|
|
4
|
+
version: string;
|
|
5
|
+
title: string;
|
|
6
|
+
usage: string;
|
|
7
|
+
};
|
|
8
|
+
options: {
|
|
9
|
+
minify: {
|
|
10
|
+
description: string;
|
|
11
|
+
type: string;
|
|
12
|
+
};
|
|
13
|
+
sourcemap: {
|
|
14
|
+
description: string;
|
|
15
|
+
type: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export default _default;
|
package/dist/lib/commands.d.ts
CHANGED
|
@@ -56,6 +56,24 @@ export declare const commands: {
|
|
|
56
56
|
};
|
|
57
57
|
};
|
|
58
58
|
};
|
|
59
|
+
buildGeneral: {
|
|
60
|
+
bean: string;
|
|
61
|
+
info: {
|
|
62
|
+
version: string;
|
|
63
|
+
title: string;
|
|
64
|
+
usage: string;
|
|
65
|
+
};
|
|
66
|
+
options: {
|
|
67
|
+
minify: {
|
|
68
|
+
description: string;
|
|
69
|
+
type: string;
|
|
70
|
+
};
|
|
71
|
+
sourcemap: {
|
|
72
|
+
description: string;
|
|
73
|
+
type: string;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
};
|
|
59
77
|
dbReset: {
|
|
60
78
|
bean: string;
|
|
61
79
|
info: {
|
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.405",
|
|
5
5
|
"description": "vona cli-set-api",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -31,11 +31,12 @@
|
|
|
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.
|
|
36
|
-
"@cabloy/extend": "^3.1.
|
|
37
|
-
"@cabloy/module-glob": "^5.2.
|
|
38
|
-
"@cabloy/module-info": "^1.3.
|
|
34
|
+
"@cabloy/cli": "^3.0.68",
|
|
35
|
+
"@cabloy/dotenv": "^1.1.12",
|
|
36
|
+
"@cabloy/extend": "^3.1.11",
|
|
37
|
+
"@cabloy/module-glob": "^5.2.35",
|
|
38
|
+
"@cabloy/module-info": "^1.3.32",
|
|
39
|
+
"@cabloy/utils": "^1.0.49",
|
|
39
40
|
"@cabloy/word-utils": "^2.0.1",
|
|
40
41
|
"@lcov-viewer/cli": "^1.3.0",
|
|
41
42
|
"@rollup/plugin-alias": "^5.1.1",
|
|
@@ -61,14 +62,13 @@
|
|
|
61
62
|
"ts-node-maintained": "^10.9.6",
|
|
62
63
|
"urllib": "^4.6.11",
|
|
63
64
|
"uuid": "^11.1.0",
|
|
64
|
-
"vona-core": "^5.0.
|
|
65
|
+
"vona-core": "^5.0.105",
|
|
65
66
|
"why-is-node-running": "^3.2.2",
|
|
66
67
|
"yargs-parser": "^22.0.0"
|
|
67
68
|
},
|
|
68
69
|
"gitHead": "0eab9dc4a5622caffe89e7b1b3f02c08ccbc4c4b",
|
|
69
70
|
"scripts": {
|
|
70
|
-
"lint": "eslint .",
|
|
71
71
|
"clean": "rimraf dist tsconfig.tsbuildinfo",
|
|
72
|
-
"tsc:publish": "npm run clean && tsc"
|
|
72
|
+
"tsc:publish": "npm run clean && vona :bin:buildGeneral && tsc"
|
|
73
73
|
}
|
|
74
74
|
}
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { BeanCliBase } from '@cabloy/cli';
|
|
3
|
-
import aliasImport from '@rollup/plugin-alias';
|
|
4
|
-
import babelImport from '@rollup/plugin-babel';
|
|
5
|
-
import commonjsImport from '@rollup/plugin-commonjs';
|
|
6
|
-
import jsonImport from '@rollup/plugin-json';
|
|
7
|
-
import resolveImport from '@rollup/plugin-node-resolve';
|
|
8
|
-
import replaceImport from '@rollup/plugin-replace';
|
|
9
|
-
import terserImport from '@rollup/plugin-terser';
|
|
10
|
-
import fse from 'fs-extra';
|
|
11
|
-
import { globby } from 'globby';
|
|
12
|
-
import { rimraf } from 'rimraf';
|
|
13
|
-
import { rollup } from 'rollup';
|
|
14
|
-
import { generateConfigDefine, getAbsolutePathOfModule, getOutDir, getOutReleasesDir } from "../utils.js";
|
|
15
|
-
import { generateVonaMeta } from "./toolsBin/generateVonaMeta.js";
|
|
16
|
-
const commonjs = commonjsImport;
|
|
17
|
-
const resolve = resolveImport;
|
|
18
|
-
// const swc = swcImport as any as typeof swcImport.default;
|
|
19
|
-
const json = jsonImport;
|
|
20
|
-
const babel = babelImport;
|
|
21
|
-
const terser = terserImport;
|
|
22
|
-
const alias = aliasImport;
|
|
23
|
-
const replace = replaceImport;
|
|
24
|
-
const __dialectDriversAll = ['pg', 'mysql2', 'better-sqlite3', 'mysql', 'oracledb', 'pg-native', 'pg-query-stream', 'sqlite3', 'tedious', 'cloudflare:sockets'];
|
|
25
|
-
export class CliBinBuild extends BeanCliBase {
|
|
26
|
-
async execute() {
|
|
27
|
-
const { argv } = this.context;
|
|
28
|
-
// super
|
|
29
|
-
await super.execute();
|
|
30
|
-
const projectPath = argv.projectPath;
|
|
31
|
-
await this._build(projectPath);
|
|
32
|
-
}
|
|
33
|
-
async _build(projectPath) {
|
|
34
|
-
const { argv } = this.context;
|
|
35
|
-
const mode = 'prod';
|
|
36
|
-
const flavor = argv.flavor || 'normal';
|
|
37
|
-
const configMeta = { flavor, mode };
|
|
38
|
-
const configOptions = {
|
|
39
|
-
appDir: projectPath,
|
|
40
|
-
runtimeDir: '.vona',
|
|
41
|
-
workers: argv.workers,
|
|
42
|
-
};
|
|
43
|
-
const { env, modulesMeta } = await generateVonaMeta(configMeta, configOptions);
|
|
44
|
-
const outDir = path.join(projectPath, getOutDir());
|
|
45
|
-
await rimraf(outDir);
|
|
46
|
-
await this._rollup(projectPath, env, outDir);
|
|
47
|
-
await this._assets(projectPath, modulesMeta, outDir);
|
|
48
|
-
// custom
|
|
49
|
-
await this._custom(projectPath, env, outDir);
|
|
50
|
-
// remove .vona
|
|
51
|
-
await rimraf(path.join(projectPath, '.vona'));
|
|
52
|
-
// copy
|
|
53
|
-
const outReleasesDir = path.join(projectPath, getOutReleasesDir());
|
|
54
|
-
await rimraf(outReleasesDir);
|
|
55
|
-
fse.copySync(outDir, outReleasesDir);
|
|
56
|
-
// copy
|
|
57
|
-
if (process.env.BUILD_COPY_DIST) {
|
|
58
|
-
const envDist = path.isAbsolute(process.env.BUILD_COPY_DIST)
|
|
59
|
-
? process.env.BUILD_COPY_DIST
|
|
60
|
-
: path.join(projectPath, process.env.BUILD_COPY_DIST);
|
|
61
|
-
const outDirCopy = path.join(envDist, path.basename(outDir));
|
|
62
|
-
fse.removeSync(outDirCopy);
|
|
63
|
-
fse.copySync(outDir, outDirCopy);
|
|
64
|
-
}
|
|
65
|
-
if (process.env.BUILD_COPY_RELEASE) {
|
|
66
|
-
const envRelease = path.isAbsolute(process.env.BUILD_COPY_RELEASE)
|
|
67
|
-
? process.env.BUILD_COPY_RELEASE
|
|
68
|
-
: path.join(projectPath, process.env.BUILD_COPY_RELEASE);
|
|
69
|
-
const outReleasesDirCopy = path.join(envRelease, path.basename(outReleasesDir));
|
|
70
|
-
fse.removeSync(outReleasesDirCopy);
|
|
71
|
-
fse.copySync(outDir, outReleasesDirCopy);
|
|
72
|
-
}
|
|
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
|
-
}
|
|
89
|
-
async _assets(_projectPath, modulesMeta, outDir) {
|
|
90
|
-
const assetsPath = path.join(outDir, 'assets');
|
|
91
|
-
for (const relativeName in modulesMeta.modules) {
|
|
92
|
-
const module = modulesMeta.modules[relativeName];
|
|
93
|
-
const scenes = await globby('assets/*', { cwd: module.root, onlyDirectories: true });
|
|
94
|
-
for (const scene2 of scenes) {
|
|
95
|
-
const scene = scene2.substring('assets/'.length);
|
|
96
|
-
const scenePath = path.join(module.root, scene2);
|
|
97
|
-
const destPath = path.join(assetsPath, scene, relativeName);
|
|
98
|
-
await fse.copy(scenePath, destPath);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
async _rollup(projectPath, env, outDir) {
|
|
103
|
-
const aliasEntries = [];
|
|
104
|
-
const dialectDrivers = (process.env.BUILD_DIALECT_DRIVERS || '').split(',');
|
|
105
|
-
for (const name of __dialectDriversAll) {
|
|
106
|
-
if (dialectDrivers.includes(name))
|
|
107
|
-
continue;
|
|
108
|
-
aliasEntries.push({ find: name, replacement: 'vona-shared' });
|
|
109
|
-
}
|
|
110
|
-
const replaceValues = generateConfigDefine(env, ['NODE_ENV', 'META_MODE', 'META_FLAVOR']);
|
|
111
|
-
const babelPluginZovaBeanModule = getAbsolutePathOfModule('babel-plugin-zova-bean-module', '');
|
|
112
|
-
const babelPluginTransformTypescriptMetadata = getAbsolutePathOfModule('babel-plugin-transform-typescript-metadata', '');
|
|
113
|
-
const babelPluginProposalDecorators = getAbsolutePathOfModule('@babel/plugin-proposal-decorators', '');
|
|
114
|
-
const babelPluginTransformClassProperties = getAbsolutePathOfModule('@babel/plugin-transform-class-properties', '');
|
|
115
|
-
const babelPluginTransformTypescript = getAbsolutePathOfModule('@babel/plugin-transform-typescript', '');
|
|
116
|
-
const plugins = [
|
|
117
|
-
alias({
|
|
118
|
-
entries: aliasEntries,
|
|
119
|
-
}),
|
|
120
|
-
resolve({
|
|
121
|
-
preferBuiltins: true,
|
|
122
|
-
}),
|
|
123
|
-
replace({
|
|
124
|
-
values: replaceValues,
|
|
125
|
-
preventAssignment: false,
|
|
126
|
-
}),
|
|
127
|
-
json(),
|
|
128
|
-
commonjs(),
|
|
129
|
-
babel({
|
|
130
|
-
include: '**/*.ts',
|
|
131
|
-
extensions: ['.ts', '.tsx'],
|
|
132
|
-
babelHelpers: 'bundled',
|
|
133
|
-
skipPreflightCheck: true,
|
|
134
|
-
babelrc: false,
|
|
135
|
-
configFile: false,
|
|
136
|
-
plugins: [
|
|
137
|
-
[babelPluginZovaBeanModule, { brandName: 'vona' }],
|
|
138
|
-
[babelPluginTransformTypescriptMetadata],
|
|
139
|
-
[babelPluginProposalDecorators, { version: 'legacy' }],
|
|
140
|
-
[babelPluginTransformClassProperties, { loose: true }],
|
|
141
|
-
[babelPluginTransformTypescript],
|
|
142
|
-
],
|
|
143
|
-
}),
|
|
144
|
-
];
|
|
145
|
-
if (process.env.BUILD_MINIFY === 'true') {
|
|
146
|
-
plugins.push(terser({
|
|
147
|
-
keep_classnames: true,
|
|
148
|
-
}));
|
|
149
|
-
}
|
|
150
|
-
const inputOptions = {
|
|
151
|
-
input: path.join(projectPath, '.vona/bootstrap.ts'),
|
|
152
|
-
plugins,
|
|
153
|
-
onLog: (level, log, defaultHandler) => {
|
|
154
|
-
if (log.code === 'CIRCULAR_DEPENDENCY' && process.env.BUILD_LOG_CIRCULAR_DEPENDENCY === 'false')
|
|
155
|
-
return;
|
|
156
|
-
if (log.code === 'THIS_IS_UNDEFINED' && (log.message.includes('ramda/es/partialObject.js') || log.message.includes("The 'this' keyword is equivalent to 'undefined' at the top level of an ES module")))
|
|
157
|
-
return;
|
|
158
|
-
if (log.code === 'EVAL' && log.message.includes('depd/index.js'))
|
|
159
|
-
return;
|
|
160
|
-
if (log.code === 'EVAL' && log.message.includes('bluebird/js/release/util.js'))
|
|
161
|
-
return;
|
|
162
|
-
defaultHandler(level, log);
|
|
163
|
-
},
|
|
164
|
-
};
|
|
165
|
-
const outputOption = {
|
|
166
|
-
dir: outDir,
|
|
167
|
-
// file: path.join(projectPath, 'dist/index.js'),
|
|
168
|
-
format: 'esm',
|
|
169
|
-
sourcemap: process.env.BUILD_SOURCEMAP === 'true',
|
|
170
|
-
// https://github.com/rollup/rollup/issues/4166
|
|
171
|
-
inlineDynamicImports: false, // should not true
|
|
172
|
-
};
|
|
173
|
-
let bundle;
|
|
174
|
-
try {
|
|
175
|
-
bundle = await rollup(inputOptions);
|
|
176
|
-
await bundle.write(outputOption);
|
|
177
|
-
}
|
|
178
|
-
finally {
|
|
179
|
-
if (bundle) {
|
|
180
|
-
// closes the bundle
|
|
181
|
-
await bundle.close();
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { BeanCliBase } from '@cabloy/cli';
|
|
3
|
-
import aliasImport from '@rollup/plugin-alias';
|
|
4
|
-
import babelImport from '@rollup/plugin-babel';
|
|
5
|
-
import commonjsImport from '@rollup/plugin-commonjs';
|
|
6
|
-
import jsonImport from '@rollup/plugin-json';
|
|
7
|
-
import resolveImport from '@rollup/plugin-node-resolve';
|
|
8
|
-
import terserImport from '@rollup/plugin-terser';
|
|
9
|
-
import { rimraf } from 'rimraf';
|
|
10
|
-
import { rollup } from 'rollup';
|
|
11
|
-
const commonjs = commonjsImport;
|
|
12
|
-
const resolve = resolveImport;
|
|
13
|
-
// const swc = swcImport as any as typeof swcImport.default;
|
|
14
|
-
const json = jsonImport;
|
|
15
|
-
const babel = babelImport;
|
|
16
|
-
const terser = terserImport;
|
|
17
|
-
const alias = aliasImport;
|
|
18
|
-
export class CliBinBuildModule extends BeanCliBase {
|
|
19
|
-
async execute() {
|
|
20
|
-
const { argv } = this.context;
|
|
21
|
-
// super
|
|
22
|
-
await super.execute();
|
|
23
|
-
const projectPath = argv.projectPath;
|
|
24
|
-
await this._build(projectPath);
|
|
25
|
-
}
|
|
26
|
-
async _build(projectPath) {
|
|
27
|
-
await rimraf(path.join(projectPath, 'dist'));
|
|
28
|
-
await this._rollup(projectPath);
|
|
29
|
-
}
|
|
30
|
-
async _rollup(projectPath) {
|
|
31
|
-
const { argv } = this.context;
|
|
32
|
-
const aliasEntries = [];
|
|
33
|
-
for (const name of ['better-sqlite3', 'mysql', 'oracledb', 'pg-native', 'pg-query-stream', 'sqlite3', 'tedious', 'cloudflare:sockets']) {
|
|
34
|
-
aliasEntries.push({ find: name, replacement: 'vona-shared' });
|
|
35
|
-
}
|
|
36
|
-
const plugins = [
|
|
37
|
-
alias({
|
|
38
|
-
entries: aliasEntries,
|
|
39
|
-
}),
|
|
40
|
-
resolve({
|
|
41
|
-
preferBuiltins: true,
|
|
42
|
-
}),
|
|
43
|
-
json(),
|
|
44
|
-
commonjs(),
|
|
45
|
-
babel({
|
|
46
|
-
include: '**/*.ts',
|
|
47
|
-
extensions: ['.ts', '.tsx'],
|
|
48
|
-
babelHelpers: 'bundled',
|
|
49
|
-
skipPreflightCheck: true,
|
|
50
|
-
babelrc: false,
|
|
51
|
-
configFile: false,
|
|
52
|
-
plugins: [
|
|
53
|
-
['babel-plugin-zova-bean-module', { brandName: 'vona' }],
|
|
54
|
-
['babel-plugin-transform-typescript-metadata'],
|
|
55
|
-
['@babel/plugin-proposal-decorators', { version: 'legacy' }],
|
|
56
|
-
['@babel/plugin-transform-class-properties', { loose: true }],
|
|
57
|
-
['@babel/plugin-transform-typescript'],
|
|
58
|
-
],
|
|
59
|
-
}),
|
|
60
|
-
];
|
|
61
|
-
if (argv.minify) {
|
|
62
|
-
plugins.push(terser({
|
|
63
|
-
keep_classnames: true,
|
|
64
|
-
}));
|
|
65
|
-
}
|
|
66
|
-
const inputOptions = {
|
|
67
|
-
input: path.join(projectPath, 'src/index.ts'),
|
|
68
|
-
plugins,
|
|
69
|
-
onLog: (level, log, defaultHandler) => {
|
|
70
|
-
if (log.code === 'CIRCULAR_DEPENDENCY')
|
|
71
|
-
return;
|
|
72
|
-
if (log.code === 'THIS_IS_UNDEFINED' && (log.message.includes('ramda/es/partialObject.js') || log.message.includes("The 'this' keyword is equivalent to 'undefined' at the top level of an ES module")))
|
|
73
|
-
return;
|
|
74
|
-
if (log.code === 'EVAL' && log.message.includes('depd/index.js'))
|
|
75
|
-
return;
|
|
76
|
-
if (log.code === 'EVAL' && log.message.includes('bluebird/js/release/util.js'))
|
|
77
|
-
return;
|
|
78
|
-
defaultHandler(level, log);
|
|
79
|
-
},
|
|
80
|
-
external(source, _importer, _isResolved) {
|
|
81
|
-
if (source.includes('/src/') || source.startsWith('.'))
|
|
82
|
-
return false;
|
|
83
|
-
return true;
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
const outputOption = {
|
|
87
|
-
dir: path.join(projectPath, 'dist'),
|
|
88
|
-
// file: path.join(projectPath, 'dist/index.js'),
|
|
89
|
-
format: 'esm',
|
|
90
|
-
sourcemap: argv.sourcemap,
|
|
91
|
-
// https://github.com/rollup/rollup/issues/4166
|
|
92
|
-
inlineDynamicImports: true,
|
|
93
|
-
};
|
|
94
|
-
let bundle;
|
|
95
|
-
try {
|
|
96
|
-
bundle = await rollup(inputOptions);
|
|
97
|
-
await bundle.write(outputOption);
|
|
98
|
-
}
|
|
99
|
-
finally {
|
|
100
|
-
if (bundle) {
|
|
101
|
-
// closes the bundle
|
|
102
|
-
await bundle.close();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { BeanCliBase } from '@cabloy/cli';
|
|
3
|
-
import fse from 'fs-extra';
|
|
4
|
-
import { rimraf } from 'rimraf';
|
|
5
|
-
import { getImportEsm } from "../utils.js";
|
|
6
|
-
import { generateVonaMeta } from "./toolsBin/generateVonaMeta.js";
|
|
7
|
-
export class CliBinDbReset extends BeanCliBase {
|
|
8
|
-
async execute() {
|
|
9
|
-
const { argv } = this.context;
|
|
10
|
-
// super
|
|
11
|
-
await super.execute();
|
|
12
|
-
const projectPath = argv.projectPath;
|
|
13
|
-
// test
|
|
14
|
-
await this._dbReset(projectPath);
|
|
15
|
-
}
|
|
16
|
-
async _dbReset(projectPath) {
|
|
17
|
-
const { argv } = this.context;
|
|
18
|
-
const mode = 'test';
|
|
19
|
-
const flavor = argv.flavor || 'normal';
|
|
20
|
-
const configMeta = { flavor, mode };
|
|
21
|
-
const configOptions = {
|
|
22
|
-
appDir: projectPath,
|
|
23
|
-
runtimeDir: '.vona',
|
|
24
|
-
workers: 1,
|
|
25
|
-
};
|
|
26
|
-
const { modulesMeta } = await generateVonaMeta(configMeta, configOptions);
|
|
27
|
-
await this._run(projectPath, modulesMeta);
|
|
28
|
-
await rimraf(path.join(projectPath, '.vona'));
|
|
29
|
-
}
|
|
30
|
-
async _run(projectPath, _modulesMeta) {
|
|
31
|
-
// testFile
|
|
32
|
-
let testFile = path.join(import.meta.dirname, './toolsBin/dbReset.ts');
|
|
33
|
-
if (!fse.existsSync(testFile)) {
|
|
34
|
-
testFile = path.join(import.meta.dirname, './toolsBin/dbReset.js');
|
|
35
|
-
}
|
|
36
|
-
// run
|
|
37
|
-
let args = [];
|
|
38
|
-
args = args.concat([getImportEsm(), testFile, projectPath]);
|
|
39
|
-
// args = args.concat(['--experimental-transform-types', getImportEsm(), testFile, projectPath]);
|
|
40
|
-
await this.helper.spawnExe({
|
|
41
|
-
cmd: 'node',
|
|
42
|
-
args,
|
|
43
|
-
options: {
|
|
44
|
-
cwd: projectPath,
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { BeanCliBase } from '@cabloy/cli';
|
|
3
|
-
import nodemon from 'nodemon';
|
|
4
|
-
import { rimraf } from 'rimraf';
|
|
5
|
-
import { getImportEsm } from "../utils.js";
|
|
6
|
-
import { generateVonaMeta } from "./toolsBin/generateVonaMeta.js";
|
|
7
|
-
export class CliBinDev extends BeanCliBase {
|
|
8
|
-
async execute() {
|
|
9
|
-
const { argv } = this.context;
|
|
10
|
-
// super
|
|
11
|
-
await super.execute();
|
|
12
|
-
const projectPath = argv.projectPath;
|
|
13
|
-
// run
|
|
14
|
-
await this._dev(projectPath);
|
|
15
|
-
}
|
|
16
|
-
async _dev(projectPath) {
|
|
17
|
-
const { argv } = this.context;
|
|
18
|
-
const mode = 'dev';
|
|
19
|
-
const flavor = argv.flavor || 'normal';
|
|
20
|
-
const configMeta = { flavor, mode };
|
|
21
|
-
const configOptions = {
|
|
22
|
-
appDir: projectPath,
|
|
23
|
-
runtimeDir: '.vona',
|
|
24
|
-
workers: argv.workers,
|
|
25
|
-
};
|
|
26
|
-
const { modulesMeta } = await generateVonaMeta(configMeta, configOptions);
|
|
27
|
-
await this._run(projectPath, modulesMeta);
|
|
28
|
-
await rimraf(path.join(projectPath, '.vona'));
|
|
29
|
-
}
|
|
30
|
-
async _run(projectPath, _modulesMeta) {
|
|
31
|
-
return new Promise((resolve, _reject) => {
|
|
32
|
-
nodemon({
|
|
33
|
-
script: '.vona/bootstrap.ts',
|
|
34
|
-
cwd: projectPath,
|
|
35
|
-
exec: 'node',
|
|
36
|
-
execArgs: [getImportEsm()],
|
|
37
|
-
// execArgs: ['--experimental-transform-types', getImportEsm(), '--trace-deprecation'],
|
|
38
|
-
// signal: 'SIGHUP',
|
|
39
|
-
watch: [
|
|
40
|
-
'packages-utils',
|
|
41
|
-
'packages-vona',
|
|
42
|
-
'./src',
|
|
43
|
-
],
|
|
44
|
-
ignore: [
|
|
45
|
-
'**/dist/**',
|
|
46
|
-
'**/test/**/*.test.ts',
|
|
47
|
-
'src/backend/play/**',
|
|
48
|
-
'src/backend/typing/**',
|
|
49
|
-
],
|
|
50
|
-
});
|
|
51
|
-
nodemon.on('quit', () => {
|
|
52
|
-
resolve(undefined);
|
|
53
|
-
}).on('restart', files => {
|
|
54
|
-
// eslint-disable-next-line
|
|
55
|
-
console.log('App restarted due to: ', files);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
// await this.helper.spawnExe({
|
|
59
|
-
// cmd: 'node',
|
|
60
|
-
// args: ['--experimental-transform-types', '--loader=ts-node/esm', '.vona/bootstrap.ts'],
|
|
61
|
-
// options: {
|
|
62
|
-
// cwd: projectPath,
|
|
63
|
-
// },
|
|
64
|
-
// });
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { BeanCliBase } from '@cabloy/cli';
|
|
3
|
-
import fse from 'fs-extra';
|
|
4
|
-
import { getImportEsm, loadJSONFile } from "../utils.js";
|
|
5
|
-
import { generateVonaMeta } from "./toolsBin/generateVonaMeta.js";
|
|
6
|
-
export class CliBinPlay extends BeanCliBase {
|
|
7
|
-
async execute() {
|
|
8
|
-
const { argv } = this.context;
|
|
9
|
-
// super
|
|
10
|
-
await super.execute();
|
|
11
|
-
const projectPath = argv.projectPath;
|
|
12
|
-
// test
|
|
13
|
-
await this._play(projectPath);
|
|
14
|
-
}
|
|
15
|
-
async _play(projectPath) {
|
|
16
|
-
const { argv } = this.context;
|
|
17
|
-
const mode = argv.mode || 'dev';
|
|
18
|
-
const flavor = argv.flavor || 'play';
|
|
19
|
-
const configMeta = { flavor, mode };
|
|
20
|
-
if (!argv.retainRuntime || !fse.existsSync(path.join(projectPath, '.vona'))) {
|
|
21
|
-
const configOptions = {
|
|
22
|
-
appDir: projectPath,
|
|
23
|
-
runtimeDir: '.vona',
|
|
24
|
-
workers: 1,
|
|
25
|
-
};
|
|
26
|
-
await generateVonaMeta(configMeta, configOptions);
|
|
27
|
-
}
|
|
28
|
-
if (argv.attach) {
|
|
29
|
-
await this._runAttach(projectPath);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
await this._runIsolate(projectPath);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
async _runAttach(projectPath) {
|
|
36
|
-
const runtimeFile = path.join(projectPath, '.app/runtime/-.json');
|
|
37
|
-
if (!fse.existsSync(runtimeFile))
|
|
38
|
-
throw new Error('dev server not running');
|
|
39
|
-
// args
|
|
40
|
-
let args = [];
|
|
41
|
-
const pos = process.argv.indexOf(':bin:play');
|
|
42
|
-
if (pos > -1) {
|
|
43
|
-
args = args.concat(process.argv.slice(pos + 1));
|
|
44
|
-
}
|
|
45
|
-
const body = { args, projectPath };
|
|
46
|
-
//
|
|
47
|
-
const runtime = await loadJSONFile(runtimeFile);
|
|
48
|
-
const runtimeCore = runtime['a-core'];
|
|
49
|
-
const runtimeUser = runtime['a-user'];
|
|
50
|
-
const result = await fetch(`${runtimeCore?.protocol}://${runtimeCore?.host}/api/play`, {
|
|
51
|
-
method: 'post',
|
|
52
|
-
headers: {
|
|
53
|
-
'content-type': 'application/json',
|
|
54
|
-
'authorization': `Bearer ${runtimeUser?.accessToken}`,
|
|
55
|
-
},
|
|
56
|
-
body: JSON.stringify(body),
|
|
57
|
-
});
|
|
58
|
-
if (result.status !== 200) {
|
|
59
|
-
const message = `error: ${result.status}, ${result.statusText}`;
|
|
60
|
-
throw new Error(message);
|
|
61
|
-
}
|
|
62
|
-
const res = await result.json();
|
|
63
|
-
if (res.code !== 0)
|
|
64
|
-
throw new Error(res.message);
|
|
65
|
-
if (res.data !== undefined) {
|
|
66
|
-
// eslint-disable-next-line no-console
|
|
67
|
-
console.log(res.data);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
async _runIsolate(projectPath) {
|
|
71
|
-
// testFile
|
|
72
|
-
let testFile = path.join(import.meta.dirname, './toolsBin/play.ts');
|
|
73
|
-
if (!fse.existsSync(testFile)) {
|
|
74
|
-
testFile = path.join(import.meta.dirname, './toolsBin/play.js');
|
|
75
|
-
}
|
|
76
|
-
// run
|
|
77
|
-
let args = [];
|
|
78
|
-
args = args.concat([getImportEsm(), testFile, projectPath]);
|
|
79
|
-
// args = args.concat(['--experimental-transform-types', getImportEsm(), testFile, projectPath]);
|
|
80
|
-
const pos = process.argv.indexOf(':bin:play');
|
|
81
|
-
if (pos > -1) {
|
|
82
|
-
args = args.concat(process.argv.slice(pos + 1));
|
|
83
|
-
}
|
|
84
|
-
await this.helper.spawnExe({
|
|
85
|
-
cmd: 'node',
|
|
86
|
-
args,
|
|
87
|
-
options: {
|
|
88
|
-
cwd: projectPath,
|
|
89
|
-
},
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}
|