vona-cli-set-api 1.0.61 → 1.0.65
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/_.npmrc +1 -0
- package/cli/templates/create/project/basic/boilerplate/package.original.json +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/controller/passport.ts +2 -1
- package/cli/templates/tools/crud/snippets/2-meta.index.ts +47 -0
- package/dist/lib/bean/cli.bin.build.js +3 -2
- package/dist/lib/bean/toolsBin/test.js +1 -1
- package/dist/lib/utils.js +5 -3
- package/package.json +2 -2
|
@@ -13,6 +13,7 @@ public-hoist-pattern[]=*cabloy*
|
|
|
13
13
|
public-hoist-pattern[]=*@cabloy*
|
|
14
14
|
public-hoist-pattern[]=*why-is-node-running*
|
|
15
15
|
public-hoist-pattern[]=*ts-node*
|
|
16
|
+
public-hoist-pattern[]=zod
|
|
16
17
|
link-workspace-packages = 'deep'
|
|
17
18
|
prefer-workspace-packages = true
|
|
18
19
|
auto-install-peers = true
|
|
@@ -17,6 +17,7 @@ export interface IControllerOptionsPassport extends IDecoratorControllerOptions
|
|
|
17
17
|
@Controller<IControllerOptionsPassport>('passport')
|
|
18
18
|
export class ControllerPassport extends BeanBase {
|
|
19
19
|
@Web.get('current')
|
|
20
|
+
@Passport.public()
|
|
20
21
|
@Api.body(v.optional(), v.object(DtoPassport))
|
|
21
22
|
current(): DtoPassport | undefined {
|
|
22
23
|
return this._combineDtoPassport();
|
|
@@ -106,7 +107,7 @@ export class ControllerPassport extends BeanBase {
|
|
|
106
107
|
|
|
107
108
|
private _combineDtoPassport(): DtoPassport | undefined {
|
|
108
109
|
const passport = this.bean.passport.getCurrent();
|
|
109
|
-
if (!passport) return;
|
|
110
|
+
if (!passport || !passport.auth) return;
|
|
110
111
|
return {
|
|
111
112
|
user: passport.user as EntityUser,
|
|
112
113
|
auth: { id: passport.auth!.id },
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { metadataCustomSnippet } from '@cabloy/cli';
|
|
3
|
+
import { catchError } from '@cabloy/utils';
|
|
4
|
+
|
|
5
|
+
declare module '@cabloy/cli' {
|
|
6
|
+
interface ICommandArgv {
|
|
7
|
+
module: string;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const __snippet_import1 = 'import { $tableColumns } from \'vona-module-a-database\';\n';
|
|
12
|
+
const __snippet_import2 = 'import { Entity<%=argv.resourceNameCapitalize%> } from \'../entity/<%=argv.resourceName%>.ts\';\n';
|
|
13
|
+
const __snippet_update = `...$tableColumns(
|
|
14
|
+
() => Entity<%=argv.resourceNameCapitalize%>,
|
|
15
|
+
entity => entity.name,
|
|
16
|
+
),`;
|
|
17
|
+
|
|
18
|
+
export default metadataCustomSnippet({
|
|
19
|
+
file: 'src/bean/meta.index.ts',
|
|
20
|
+
language: 'plain',
|
|
21
|
+
init: async ({ cli, argv, targetFile }) => {
|
|
22
|
+
await catchError(() => {
|
|
23
|
+
return cli.helper.invokeCli([
|
|
24
|
+
':create:bean',
|
|
25
|
+
'meta',
|
|
26
|
+
'index',
|
|
27
|
+
`--module=${argv.module}`,
|
|
28
|
+
], { cwd: argv.projectPath });
|
|
29
|
+
});
|
|
30
|
+
return fs.readFileSync(targetFile).toString('utf8');
|
|
31
|
+
},
|
|
32
|
+
async transform({ cli, ast }) {
|
|
33
|
+
// import1
|
|
34
|
+
if (!ast.includes(__snippet_import1)) {
|
|
35
|
+
const code = await cli.template.renderContent({ content: __snippet_import1 });
|
|
36
|
+
ast = `${code}${ast}`;
|
|
37
|
+
}
|
|
38
|
+
// import2
|
|
39
|
+
let code = await cli.template.renderContent({ content: __snippet_import2 });
|
|
40
|
+
ast = `${code}${ast}`;
|
|
41
|
+
// update
|
|
42
|
+
code = await cli.template.renderContent({ content: __snippet_update });
|
|
43
|
+
ast = ast.replace('indexes: {', `indexes: {\n${code}`);
|
|
44
|
+
// ok
|
|
45
|
+
return ast;
|
|
46
|
+
},
|
|
47
|
+
});
|
|
@@ -10,7 +10,7 @@ import terserImport from '@rollup/plugin-terser';
|
|
|
10
10
|
import fse from 'fs-extra';
|
|
11
11
|
import { rimraf } from 'rimraf';
|
|
12
12
|
import { rollup } from 'rollup';
|
|
13
|
-
import { generateConfigDefine, getOutDir, getOutReleasesDir } from "../utils.js";
|
|
13
|
+
import { generateConfigDefine, getAbsolutePathOfModule, getOutDir, getOutReleasesDir } from "../utils.js";
|
|
14
14
|
import { generateVonaMeta } from "./toolsBin/generateVonaMeta.js";
|
|
15
15
|
const commonjs = commonjsImport;
|
|
16
16
|
const resolve = resolveImport;
|
|
@@ -89,6 +89,7 @@ export class CliBinBuild extends BeanCliBase {
|
|
|
89
89
|
aliasEntries.push({ find: name, replacement: 'vona-shared' });
|
|
90
90
|
}
|
|
91
91
|
const replaceValues = generateConfigDefine(env, ['NODE_ENV', 'META_MODE', 'META_FLAVOR']);
|
|
92
|
+
const babelPluginZovaBeanModule = getAbsolutePathOfModule('babel-plugin-zova-bean-module', '');
|
|
92
93
|
const plugins = [
|
|
93
94
|
alias({
|
|
94
95
|
entries: aliasEntries,
|
|
@@ -110,7 +111,7 @@ export class CliBinBuild extends BeanCliBase {
|
|
|
110
111
|
babelrc: false,
|
|
111
112
|
configFile: false,
|
|
112
113
|
plugins: [
|
|
113
|
-
[
|
|
114
|
+
[babelPluginZovaBeanModule, { brandName: 'vona' }],
|
|
114
115
|
['babel-plugin-transform-typescript-metadata'],
|
|
115
116
|
['@babel/plugin-proposal-decorators', { version: 'legacy' }],
|
|
116
117
|
['@babel/plugin-transform-class-properties', { loose: true }],
|
|
@@ -44,7 +44,7 @@ async function testRun(projectPath, coverage, patterns) {
|
|
|
44
44
|
let coverageIncludeGlobs = [];
|
|
45
45
|
if (coverage) {
|
|
46
46
|
if (fse.existsSync(path.join(projectPath, 'packages-vona/vona-core'))) {
|
|
47
|
-
coverageIncludeGlobs = coverageIncludeGlobs.concat(['packages-vona/vona-core/**/*.ts', 'src/
|
|
47
|
+
coverageIncludeGlobs = coverageIncludeGlobs.concat(['packages-vona/vona-core/**/*.ts', 'src/suite-vendor/a-vona/**/*.ts']);
|
|
48
48
|
}
|
|
49
49
|
else {
|
|
50
50
|
coverageIncludeGlobs = coverageIncludeGlobs.concat(['src/module/**/*.ts', 'src/suite/**/*.ts']);
|
package/dist/lib/utils.js
CHANGED
|
@@ -29,9 +29,11 @@ export function generateConfigDefine(env, translates) {
|
|
|
29
29
|
export function getAbsolutePathOfModule(id, postfix = 'index.js') {
|
|
30
30
|
const require = createRequire(import.meta.url);
|
|
31
31
|
let modulePath = require.resolve(id);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
if (postfix) {
|
|
33
|
+
const pos = modulePath.lastIndexOf(postfix);
|
|
34
|
+
if (pos > -1) {
|
|
35
|
+
modulePath = modulePath.substring(0, modulePath.length - postfix.length - 1);
|
|
36
|
+
}
|
|
35
37
|
}
|
|
36
38
|
return modulePath;
|
|
37
39
|
}
|
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.65",
|
|
5
5
|
"description": "vona cli-set-api",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"ts-node": "^10.9.2",
|
|
61
61
|
"urllib": "^4.6.11",
|
|
62
62
|
"uuid": "^11.1.0",
|
|
63
|
-
"vona-core": "^5.0.
|
|
63
|
+
"vona-core": "^5.0.21",
|
|
64
64
|
"why-is-node-running": "^3.2.2",
|
|
65
65
|
"yargs-parser": "^21.1.1"
|
|
66
66
|
},
|