-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* CB-5988 generate plugin template * CB-5988 add add plugin script * CB-5988 review fixes --------- Co-authored-by: mr-anton-t <[email protected]> Co-authored-by: sergeyteleshev <[email protected]>
- Loading branch information
1 parent
78aafaf
commit 398f9b7
Showing
11 changed files
with
464 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
webapp/packages/core-cli/_templates/plugin/new/index.ts.ejs.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
to: <%= name %>/src/index.ts | ||
--- | ||
import { <%= h.changeCase.camel(name) %>Manifest } from './manifest.js'; | ||
|
||
export default <%= h.changeCase.camel(name) %>Manifest; | ||
export { <%= h.changeCase.camel(name) %>Manifest }; |
12 changes: 12 additions & 0 deletions
12
webapp/packages/core-cli/_templates/plugin/new/manifest.ts.ejs.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
to: <%= name %>/src/manifest.ts | ||
--- | ||
import type { PluginManifest } from '@cloudbeaver/core-di'; | ||
|
||
export const <%= h.changeCase.camel(name) %>Manifest: PluginManifest = { | ||
info: { | ||
name: '<%= h.changeCase.sentence(name) %>', | ||
}, | ||
|
||
providers: [() => import('./<%= h.changeCase.pascal(name) %>ServiceBootstrap.js').then(m => m.<%= h.changeCase.pascal(name) %>ServiceBootstrap)], | ||
}; |
31 changes: 31 additions & 0 deletions
31
webapp/packages/core-cli/_templates/plugin/new/package.json.ejs.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
to: <%= name %>/package.json | ||
--- | ||
{ | ||
"name": "@cloudbeaver/<%= name %>", | ||
"type": "module", | ||
"sideEffects": [ | ||
"src/**/*.css", | ||
"src/**/*.scss", | ||
"public/**/*" | ||
], | ||
"version": "0.1.0", | ||
"description": "", | ||
"license": "Apache-2.0", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"build": "tsc -b", | ||
"clean": "rimraf --glob dist", | ||
"lint": "eslint ./src/ --ext .ts,.tsx", | ||
"test": "core-cli-test", | ||
"validate-dependencies": "core-cli-validate-dependencies", | ||
"update-ts-references": "yarn run clean && typescript-resolve-references" | ||
}, | ||
"dependencies": { | ||
"@cloudbeaver/core-di": "^0" | ||
}, | ||
"peerDependencies": {}, | ||
"devDependencies": { | ||
"typescript": "^5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* CloudBeaver - Cloud Database Manager | ||
* Copyright (C) 2020-2024 DBeaver Corp and others | ||
* | ||
* Licensed under the Apache License, Version 2.0. | ||
* you may not use this file except in compliance with the License. | ||
*/ | ||
|
||
module.exports = [ | ||
{ | ||
type: 'input', | ||
name: 'name', | ||
message: 'What is the name of your plugin?', | ||
}, | ||
]; |
15 changes: 15 additions & 0 deletions
15
webapp/packages/core-cli/_templates/plugin/new/service.ts.ejs.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
to: <%= name %>/src/<%= h.changeCase.pascal(name) %>ServiceBootstrap.ts | ||
--- | ||
import { Bootstrap, injectable } from '@cloudbeaver/core-di'; | ||
|
||
@injectable() | ||
export class <%= h.changeCase.pascal(name) %>ServiceBootstrap extends Bootstrap { | ||
constructor() { | ||
super(); | ||
} | ||
|
||
override register() { | ||
console.log('<%= h.changeCase.no(name) %> is registered'); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
webapp/packages/core-cli/_templates/plugin/new/tsconfig.json.ejs.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
to: <%= name %>/tsconfig.json | ||
--- | ||
<% isEE = cwd.includes('cloudbeaver-ee'); %> | ||
{ | ||
"extends": "<%= isEE ? '../../../../cloudbeaver/webapp/tsconfig.base.json' : '../../tsconfig.base.json' %>", | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"outDir": "dist", | ||
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo" | ||
}, | ||
"references": [ | ||
{ | ||
"path": "<%= isEE ? '../../../../cloudbeaver/webapp/packages/core-di/tsconfig.json' : '../core-di/tsconfig.json' %>" | ||
} | ||
], | ||
"include": [ | ||
"__custom_mocks__/**/*", | ||
"src/**/*", | ||
"src/**/*.json", | ||
"src/**/*.css", | ||
"src/**/*.scss" | ||
], | ||
"exclude": [ | ||
"**/node_modules", | ||
"lib/**/*", | ||
"dist/**/*" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env node | ||
|
||
'use strict'; | ||
process.title = 'core-add-plugin'; | ||
|
||
const { resolve, join } = require('path'); | ||
const { runner, Logger } = require('hygen'); | ||
|
||
const templates = join(__dirname, '../_templates'); | ||
const currentDir = resolve(); | ||
|
||
runner(['plugin', 'new'], { | ||
templates, | ||
cwd: join(currentDir, 'packages'), | ||
logger: new Logger(console.log.bind(console)), | ||
debug: !!process.env.DEBUG, | ||
exec: (action, body) => { | ||
const opts = body && body.length > 0 ? { input: body } : {}; | ||
return require('execa').command(action, { ...opts, shell: true }); | ||
}, | ||
createPrompter: () => require('enquirer'), | ||
}).then(({ success }) => process.exit(success ? 0 : 1)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.