bmd-extension 1.6.3
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/.vscode/launch.json +14 -0
- package/.vscode/settings.json +1 -0
- package/CHANGELOG.md +9 -0
- package/DEPLOY.md +4 -0
- package/README.md +17 -0
- package/README_PRIVATE.md +1 -0
- package/build.sh +5 -0
- package/logo.png +0 -0
- package/media/dark/add.svg +40 -0
- package/media/dark/block.svg +1 -0
- package/media/dark/checklist-1.svg +1 -0
- package/media/dark/checklist.svg +1 -0
- package/media/dark/control.svg +1 -0
- package/media/dark/create.svg +1 -0
- package/media/dark/delete-1.svg +1 -0
- package/media/dark/delete.svg +1 -0
- package/media/dark/deploy-1.svg +2 -0
- package/media/dark/deploy.svg +2 -0
- package/media/dark/documents.svg +66 -0
- package/media/dark/earth.svg +68 -0
- package/media/dark/exe.svg +15 -0
- package/media/dark/export.svg +1 -0
- package/media/dark/function.svg +1 -0
- package/media/dark/game-controller.svg +77 -0
- package/media/dark/get.svg +1 -0
- package/media/dark/id-card.svg +59 -0
- package/media/dark/identity.svg +81 -0
- package/media/dark/import.svg +1 -0
- package/media/dark/information.svg +1 -0
- package/media/dark/interface.svg +1 -0
- package/media/dark/layout.svg +41 -0
- package/media/dark/leaf.svg +54 -0
- package/media/dark/list.svg +13 -0
- package/media/dark/logo.svg +249 -0
- package/media/dark/mockup.svg +1 -0
- package/media/dark/needle.svg +1 -0
- package/media/dark/pass.svg +46 -0
- package/media/dark/plus.svg +1 -0
- package/media/dark/post.svg +1 -0
- package/media/dark/quit.svg +1 -0
- package/media/dark/rocket.svg +28 -0
- package/media/dark/service.svg +1 -0
- package/media/dark/settings.svg +98 -0
- package/media/dark/social.svg +1 -0
- package/media/dark/spaceship-1.svg +1 -0
- package/media/dark/spaceship-2.svg +1 -0
- package/media/dark/spaceship.svg +1 -0
- package/media/dark/support.svg +88 -0
- package/media/dark/transfer.svg +1 -0
- package/media/dark/transform.svg +92 -0
- package/media/dark/update.svg +45 -0
- package/media/dark/upload-1.svg +1 -0
- package/media/dark/upload.svg +41 -0
- package/media/dark/vaccine.svg +1 -0
- package/media/dark/vr-gaming.svg +1 -0
- package/media/light/add.svg +40 -0
- package/media/light/block.svg +1 -0
- package/media/light/checklist-1.svg +1 -0
- package/media/light/checklist.svg +1 -0
- package/media/light/control.svg +1 -0
- package/media/light/create.svg +1 -0
- package/media/light/delete-1.svg +1 -0
- package/media/light/delete.svg +1 -0
- package/media/light/deploy-1.svg +2 -0
- package/media/light/deploy.svg +2 -0
- package/media/light/documents.svg +66 -0
- package/media/light/earth.svg +68 -0
- package/media/light/exe.svg +15 -0
- package/media/light/export.svg +1 -0
- package/media/light/function.svg +1 -0
- package/media/light/game-controller.svg +77 -0
- package/media/light/get.svg +1 -0
- package/media/light/id-card.svg +59 -0
- package/media/light/identity.svg +81 -0
- package/media/light/import.svg +1 -0
- package/media/light/information.svg +1 -0
- package/media/light/interface.svg +1 -0
- package/media/light/layout.svg +41 -0
- package/media/light/leaf.svg +54 -0
- package/media/light/list.svg +13 -0
- package/media/light/logo.svg +249 -0
- package/media/light/mockup.svg +1 -0
- package/media/light/needle.svg +1 -0
- package/media/light/pass.svg +46 -0
- package/media/light/plus.svg +1 -0
- package/media/light/post.svg +1 -0
- package/media/light/quit.svg +1 -0
- package/media/light/rocket.svg +28 -0
- package/media/light/service.svg +1 -0
- package/media/light/settings.svg +98 -0
- package/media/light/social.svg +1 -0
- package/media/light/spaceship-1.svg +1 -0
- package/media/light/spaceship-2.svg +1 -0
- package/media/light/spaceship.svg +1 -0
- package/media/light/support.svg +88 -0
- package/media/light/transfer.svg +1 -0
- package/media/light/transform.svg +92 -0
- package/media/light/update.svg +45 -0
- package/media/light/upload-1.svg +1 -0
- package/media/light/upload.svg +41 -0
- package/media/light/vaccine.svg +1 -0
- package/media/light/vr-gaming.svg +1 -0
- package/package-lock.json +6430 -0
- package/package.json +540 -0
- package/snippets-tsr.json +512 -0
- package/snippets.json +761 -0
- package/src/API.ts +14 -0
- package/src/FsProvider.ts +105 -0
- package/src/Request.ts +24 -0
- package/src/assets/api/api.txt +27 -0
- package/src/assets/configuration/AdminConfigurationController.ts.txt +72 -0
- package/src/assets/configuration/Configuration.ts.txt +37 -0
- package/src/assets/configuration/ConfigurationService.ts.txt +26 -0
- package/src/assets/contentDefine/AdminContentDefineController.ts.txt +91 -0
- package/src/assets/contentDefine/ContentDefine.ts.txt +45 -0
- package/src/assets/contentDefine/ContentDefineService.ts.txt +19 -0
- package/src/assets/contentDefine/CustomerContentDefineController.ts.txt +34 -0
- package/src/assets/controller/controller.txt +46 -0
- package/src/assets/controller/controllerResource.txt +103 -0
- package/src/assets/entity/entity.txt +22 -0
- package/src/assets/entity-request/entity-request.txt +18 -0
- package/src/assets/init/.env.example.txt +37 -0
- package/src/assets/init/.env.production.txt +37 -0
- package/src/assets/init/.gitignore.txt +8 -0
- package/src/assets/init/config.ts.txt +55 -0
- package/src/assets/init/deploy.sh.txt +46 -0
- package/src/assets/init/package-lock.json.txt +4184 -0
- package/src/assets/init/package.json.txt +79 -0
- package/src/assets/init/src/Server.ts.txt +167 -0
- package/src/assets/init/src/controllers/admin/AuthController.ts.txt +96 -0
- package/src/assets/init/src/controllers/admin/CustomerController.ts.txt +107 -0
- package/src/assets/init/src/controllers/admin/RoleController.ts.txt +143 -0
- package/src/assets/init/src/controllers/admin/StaffController.ts.txt +192 -0
- package/src/assets/init/src/controllers/customer/AuthController.ts.txt +170 -0
- package/src/assets/init/src/controllers/customer/CustomerController.ts.txt +32 -0
- package/src/assets/init/src/core/entity/CoreEntity.ts.txt +70 -0
- package/src/assets/init/src/core/services/CoreService.ts.txt +21 -0
- package/src/assets/init/src/entity/Customer.ts.txt +68 -0
- package/src/assets/init/src/entity/Permission.ts.txt +29 -0
- package/src/assets/init/src/entity/Role.ts.txt +36 -0
- package/src/assets/init/src/entity/Staff.ts.txt +54 -0
- package/src/assets/init/src/entity-request/CustomerInsert.ts.txt +42 -0
- package/src/assets/init/src/entity-request/CustomerUpdate.ts.txt +40 -0
- package/src/assets/init/src/entity-request/PermissionImport.ts.txt +12 -0
- package/src/assets/init/src/entity-request/StaffUpdate.ts.txt +33 -0
- package/src/assets/init/src/index.ts.txt +13 -0
- package/src/assets/init/src/middleware/auth/Verification.ts.txt +16 -0
- package/src/assets/init/src/middleware/auth/VerificationJWT.ts.txt +16 -0
- package/src/assets/init/src/middleware/auth/strategy/AuthStrategy.ts.txt +5 -0
- package/src/assets/init/src/middleware/auth/strategy/JWT.ts.txt +147 -0
- package/src/assets/init/src/middleware/error/handleError.ts.txt +22 -0
- package/src/assets/init/src/middleware/error/handleNotFound.ts.txt +7 -0
- package/src/assets/init/src/middleware/response/CustomSendResponse.ts.txt +35 -0
- package/src/assets/init/src/middleware/response/responseAPI.ts.txt +76 -0
- package/src/assets/init/src/middleware/validator/Validator.ts.txt +103 -0
- package/src/assets/init/src/services/CustomerService.ts.txt +79 -0
- package/src/assets/init/src/services/InitService.ts.txt +11 -0
- package/src/assets/init/src/services/MailService.ts.txt +271 -0
- package/src/assets/init/src/services/RoleService.ts.txt +66 -0
- package/src/assets/init/src/services/StaffService.ts.txt +104 -0
- package/src/assets/init/src/ssl/certificate-ca.crt +0 -0
- package/src/assets/init/src/ssl/certificate.crt +0 -0
- package/src/assets/init/src/ssl/private.key +0 -0
- package/src/assets/init/src/types/express.d.ts.txt +97 -0
- package/src/assets/init/src/util/expo.ts.txt +53 -0
- package/src/assets/init/src/util/helper.ts.txt +321 -0
- package/src/assets/init/src/util/language.ts.txt +8 -0
- package/src/assets/init/src/util/logger.ts.txt +47 -0
- package/src/assets/init/src/util/mailer.ts.txt +32 -0
- package/src/assets/init/src/util/password.ts.txt +13 -0
- package/src/assets/init/tsconfig.json.txt +26 -0
- package/src/assets/service/service.txt +34 -0
- package/src/constant.ts +83 -0
- package/src/extension.ts +459 -0
- package/src/provider/codeAction/controller/addPathParams.ts +65 -0
- package/src/provider/codeAction/controller/addTokenParam.ts +43 -0
- package/src/provider/codeAction/controller/addValidation.ts +47 -0
- package/src/provider/codeAction/controller/codeAction.ts +34 -0
- package/src/provider/codeAction/controller/util.ts +48 -0
- package/src/provider/codeAction/entity/codeAction.ts +48 -0
- package/src/provider/codeAction/entity/handleBuilder.ts +87 -0
- package/src/provider/codeAction/entity/handleFunction.ts +487 -0
- package/src/provider/codeAction/entity/handleProperty.ts +32 -0
- package/src/provider/codeAction/entity/handleRelation.ts +72 -0
- package/src/provider/codeAction/entity/helper.ts +132 -0
- package/src/provider/codeAction/entity-request/codeAction.ts +178 -0
- package/src/provider/codeAction/enum/codeAction.ts +95 -0
- package/src/provider/codeAction/service/codeAction.ts +232 -0
- package/src/provider/completion/CompletionProvider.ts +108 -0
- package/src/provider/errorChecking/checkHeaderToken.ts +60 -0
- package/src/provider/errorChecking/checkPathParam.ts +64 -0
- package/src/provider/errorChecking/checkRequired.ts +56 -0
- package/src/provider/errorChecking/errorChecking.ts +35 -0
- package/src/provider/errorChecking/util.ts +56 -0
- package/src/provider/treeDataProvider/Dependency.ts +26 -0
- package/src/provider/treeDataProvider/TreeProviderCommand.ts +60 -0
- package/src/provider/treeDataProvider/TreeProviderProject.ts +65 -0
- package/src/provider/treeDataProvider/api/createApi.ts +106 -0
- package/src/provider/treeDataProvider/controller/command/createController.ts +99 -0
- package/src/provider/treeDataProvider/controller/command/handleMethod.ts +363 -0
- package/src/provider/treeDataProvider/controller/treeData.ts +81 -0
- package/src/provider/treeDataProvider/deploy/command/handleDeploy.ts +70 -0
- package/src/provider/treeDataProvider/deploy/treeData.ts +21 -0
- package/src/provider/treeDataProvider/entity/command/addProperty.ts +144 -0
- package/src/provider/treeDataProvider/entity/command/addRelation.ts +125 -0
- package/src/provider/treeDataProvider/entity/command/createEntity.ts +53 -0
- package/src/provider/treeDataProvider/entity/command/createEntityRequest.ts +65 -0
- package/src/provider/treeDataProvider/entity/command/exportInterface.ts +130 -0
- package/src/provider/treeDataProvider/entity/treeData.ts +49 -0
- package/src/provider/treeDataProvider/module/command/configuration.ts +34 -0
- package/src/provider/treeDataProvider/module/command/contentDefine.ts +36 -0
- package/src/provider/treeDataProvider/module/command/initProject.ts +155 -0
- package/src/provider/treeDataProvider/module/treeData.ts +28 -0
- package/src/provider/treeDataProvider/project/command/addEnum.ts +0 -0
- package/src/provider/treeDataProvider/project/command/addProjectName.ts +23 -0
- package/src/provider/treeDataProvider/project/command/getProjectDetails.ts +284 -0
- package/src/provider/treeDataProvider/project/treeData.ts +28 -0
- package/src/provider/treeDataProvider/service/command/createService.ts +70 -0
- package/src/provider/treeDataProvider/service/command/handleConstructor.ts +134 -0
- package/src/provider/treeDataProvider/service/treeData.ts +25 -0
- package/src/types/project.d.ts +7 -0
- package/src/util.ts +145 -0
- package/src/utils/Password.ts +19 -0
- package/tsconfig.json +18 -0
- package/tslint.json +15 -0
- package/vsc-extension-quickstart.md +42 -0
@@ -0,0 +1,70 @@
|
|
1
|
+
import { FSProvider } from "../../../../FsProvider"
|
2
|
+
import * as vscode from 'vscode';
|
3
|
+
import { getFullTextType, getLastFolderFromPath, words, toSnakeCase, toUpperCaseFirstLetter } from "../../../../util";
|
4
|
+
import { Confirmation, OTHER } from "../../../../constant";
|
5
|
+
import { Uri, commands } from "vscode";
|
6
|
+
|
7
|
+
export async function createService(fsPath: string) {
|
8
|
+
if (!FSProvider.isValidStructure()) {
|
9
|
+
return vscode.window.showInformationMessage("Cancel!. Wrong project's structure.");
|
10
|
+
}
|
11
|
+
|
12
|
+
if (fsPath != undefined && !fsPath.includes('services')) {
|
13
|
+
return vscode.window.showInformationMessage("Please select 'services' folder")
|
14
|
+
}
|
15
|
+
|
16
|
+
const entities = FSProvider.getAllFileInFolder('/src/entity')
|
17
|
+
const entitySelected = await vscode.window.showQuickPick(
|
18
|
+
[...entities, OTHER],
|
19
|
+
{ ignoreFocusOut: true }
|
20
|
+
)
|
21
|
+
let service = ''
|
22
|
+
if (entitySelected && entitySelected != OTHER) {
|
23
|
+
service = entitySelected
|
24
|
+
} else {
|
25
|
+
let input = await vscode.window.showInputBox({
|
26
|
+
placeHolder: "Enter service name: ",
|
27
|
+
ignoreFocusOut: true
|
28
|
+
})
|
29
|
+
if (!input)
|
30
|
+
return vscode.window.showInformationMessage("Cancel!. Do not input service name.");
|
31
|
+
|
32
|
+
service = input.replace('service', '').replace('Service', '')
|
33
|
+
}
|
34
|
+
|
35
|
+
if (!service) {
|
36
|
+
return vscode.window.showInformationMessage("Cancel!. Do not input service name.");
|
37
|
+
}
|
38
|
+
|
39
|
+
const serviceTextTypes = getFullTextType(service)
|
40
|
+
|
41
|
+
const distPath = `src/services/${serviceTextTypes.classifyCase}Service.ts`
|
42
|
+
if (FSProvider.checkExist(distPath)) {
|
43
|
+
const confirm = await vscode.window.showQuickPick(
|
44
|
+
[Confirmation.Yes, Confirmation.No],
|
45
|
+
{
|
46
|
+
placeHolder: "This file already exist in this folder. Do you want to replace it?",
|
47
|
+
ignoreFocusOut: true
|
48
|
+
}
|
49
|
+
)
|
50
|
+
if (!confirm || confirm == Confirmation.No) {
|
51
|
+
return vscode.window.showInformationMessage("Cancel create service!.");
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
FSProvider.copyAndReplaceFile(
|
56
|
+
'service/service.txt',
|
57
|
+
distPath,
|
58
|
+
[
|
59
|
+
{ regex: /{{snake}}/g, value: serviceTextTypes.snakeCase },
|
60
|
+
{ regex: /{{classify}}/g, value: serviceTextTypes.classifyCase },
|
61
|
+
{ regex: /{{camel}}/g, value: serviceTextTypes.camelCase },
|
62
|
+
{ regex: /ys/g, value: 'ies' },
|
63
|
+
])
|
64
|
+
|
65
|
+
|
66
|
+
let uri = Uri.file(FSProvider.getFullPath(distPath))
|
67
|
+
await commands.executeCommand('vscode.openFolder', uri)
|
68
|
+
|
69
|
+
return vscode.window.showInformationMessage("Create SERVICE successfully!");
|
70
|
+
}
|
@@ -0,0 +1,134 @@
|
|
1
|
+
import * as vscode from 'vscode';
|
2
|
+
import { getFullTextType } from '../../../../util';
|
3
|
+
import { FSProvider } from '../../../../FsProvider';
|
4
|
+
import { ConstructorFunction } from '../../../../constant';
|
5
|
+
|
6
|
+
export async function insertPrivateService(typeFunc: ConstructorFunction, document: any) {
|
7
|
+
|
8
|
+
if (!document || !document.uri) {
|
9
|
+
document = vscode.window.activeTextEditor?.document
|
10
|
+
}
|
11
|
+
|
12
|
+
if (!document) {
|
13
|
+
vscode.window.showInformationMessage("Cancel: Can not find open document to insert")
|
14
|
+
return
|
15
|
+
}
|
16
|
+
|
17
|
+
const edit = new vscode.WorkspaceEdit();
|
18
|
+
const services = FSProvider.getAllFileInFolder('/src/services')
|
19
|
+
const service = await vscode.window.showQuickPick(
|
20
|
+
[...services], { ignoreFocusOut: true }
|
21
|
+
)
|
22
|
+
if (!service) return vscode.window.showInformationMessage('Please select service to complete action')
|
23
|
+
const fullTextService = getFullTextType(service)
|
24
|
+
const content = `\n\t\tprivate ${fullTextService.camelCase}: ${service},`
|
25
|
+
|
26
|
+
await insertConstructIfNotExist(document)
|
27
|
+
|
28
|
+
for (let index = 0; index < document.lineCount; index++) {
|
29
|
+
const line = document.lineAt(index).text
|
30
|
+
if (line.includes('constructor')) {
|
31
|
+
const matched1 = 'constructor()'
|
32
|
+
const matched2 = 'constructor('
|
33
|
+
|
34
|
+
if (line.indexOf(matched1) != -1) {
|
35
|
+
const indexOf = line.indexOf(matched1) + matched1.length
|
36
|
+
edit.insert(document.uri, new vscode.Position(index, indexOf - 1), content + `\n`);
|
37
|
+
} else {
|
38
|
+
const indexOf = line.indexOf(matched2) + matched2.length
|
39
|
+
edit.insert(document.uri, new vscode.Position(index, indexOf), content);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
vscode.workspace.applyEdit(edit)
|
45
|
+
}
|
46
|
+
|
47
|
+
async function insertConstructIfNotExist(document: vscode.TextDocument) {
|
48
|
+
if (isExistConstructor(document)) return
|
49
|
+
const content = ` constructor(
|
50
|
+
) { }\n`
|
51
|
+
const index = getIndexOfLineIncludeClass(document)
|
52
|
+
const edit = new vscode.WorkspaceEdit();
|
53
|
+
edit.insert(document.uri, new vscode.Position(index + 1, 0), content);
|
54
|
+
await vscode.workspace.applyEdit(edit)
|
55
|
+
}
|
56
|
+
|
57
|
+
function getIndexOfLineIncludeClass(document: vscode.TextDocument) {
|
58
|
+
const lines = document.lineCount
|
59
|
+
let indexLine = 0
|
60
|
+
|
61
|
+
for (let index = 0; index < lines; index++) {
|
62
|
+
const line = document.lineAt(index)
|
63
|
+
if (line.text.includes('class')) {
|
64
|
+
indexLine = index
|
65
|
+
break;
|
66
|
+
}
|
67
|
+
}
|
68
|
+
return indexLine
|
69
|
+
}
|
70
|
+
|
71
|
+
function isExistConstructor(document: vscode.TextDocument) {
|
72
|
+
const lines = document.lineCount
|
73
|
+
let isExist = false
|
74
|
+
|
75
|
+
for (let index = 0; index < lines; index++) {
|
76
|
+
const line = document.lineAt(index)
|
77
|
+
if (line.text.includes('constructor')) {
|
78
|
+
isExist = true
|
79
|
+
}
|
80
|
+
}
|
81
|
+
return isExist
|
82
|
+
}
|
83
|
+
|
84
|
+
// export function insertConstructorAction(
|
85
|
+
// document: vscode.TextDocument | undefined,
|
86
|
+
// range: any,
|
87
|
+
// ) {
|
88
|
+
// if (!document || !document.uri) {
|
89
|
+
// document = vscode.window.activeTextEditor?.document
|
90
|
+
// }
|
91
|
+
|
92
|
+
// if (!document) {
|
93
|
+
// vscode.window.showInformationMessage("Cancel: Can not find open document to insert")
|
94
|
+
// return
|
95
|
+
// }
|
96
|
+
|
97
|
+
// if (isConstructorFunction(document, range)) {
|
98
|
+
// const insertPrivateService = createConstructorFunc(document, range, ConstructorFunction.PrivateService);
|
99
|
+
|
100
|
+
// return [
|
101
|
+
// insertPrivateService
|
102
|
+
// ]
|
103
|
+
// } else {
|
104
|
+
// return []
|
105
|
+
// }
|
106
|
+
// }
|
107
|
+
|
108
|
+
// function isConstructorFunction(document: vscode.TextDocument, range: vscode.Range) {
|
109
|
+
// const start = range.start;
|
110
|
+
// const line = document.lineAt(start.line);
|
111
|
+
// return line.text.includes('constructor')
|
112
|
+
// }
|
113
|
+
|
114
|
+
|
115
|
+
// function createConstructorFunc(document: vscode.TextDocument, range: vscode.Range, typeFunc: ConstructorFunction): vscode.CodeAction {
|
116
|
+
// const controller = new vscode.CodeAction(typeFunc, vscode.CodeActionKind.QuickFix);
|
117
|
+
// switch (typeFunc) {
|
118
|
+
// case ConstructorFunction.PrivateService:
|
119
|
+
// controller.command = {
|
120
|
+
// command: typeFunc,
|
121
|
+
// title: 'Insert private service.',
|
122
|
+
// tooltip: 'Insert private service.',
|
123
|
+
// arguments: [document]
|
124
|
+
// };
|
125
|
+
// break
|
126
|
+
|
127
|
+
|
128
|
+
// default:
|
129
|
+
// break;
|
130
|
+
|
131
|
+
// }
|
132
|
+
|
133
|
+
// return controller;
|
134
|
+
// }
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { BMDCommand, ConstructorFunction } from "../../../constant";
|
2
|
+
import { Dependency } from "../Dependency";
|
3
|
+
import * as vscode from 'vscode';
|
4
|
+
import { ItemCommand } from "../TreeProviderCommand";
|
5
|
+
|
6
|
+
const serviceCommands: ItemCommand[] =
|
7
|
+
[{
|
8
|
+
id: BMDCommand.CreateService,
|
9
|
+
title: 'SERVICE',
|
10
|
+
icon: 'add'
|
11
|
+
}, {
|
12
|
+
id: ConstructorFunction.PrivateService,
|
13
|
+
title: 'INJECT CONSTRUCTOR',
|
14
|
+
icon: 'vaccine'
|
15
|
+
},]
|
16
|
+
|
17
|
+
export const serviceDependencies = serviceCommands.map(c => {
|
18
|
+
return new Dependency(
|
19
|
+
c.title,
|
20
|
+
vscode.TreeItemCollapsibleState.None,
|
21
|
+
undefined,
|
22
|
+
c.id,
|
23
|
+
c.icon ? c.icon : 'none'
|
24
|
+
);
|
25
|
+
})
|
package/src/util.ts
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
export function replaceSymbolTemplate(content: string) {
|
2
|
+
content = content.replace(/{{backtick}}/g, '`');
|
3
|
+
content = content.replace(/{{dollar}}/g, '$');
|
4
|
+
return content
|
5
|
+
}
|
6
|
+
|
7
|
+
export function toLowerCaseFirstLetter(name: string) {
|
8
|
+
return name.charAt(0).toLowerCase() + name.slice(1)
|
9
|
+
}
|
10
|
+
|
11
|
+
export function toUpperCaseFirstLetter(name: string) {
|
12
|
+
return name.charAt(0).toUpperCase() + name.slice(1)
|
13
|
+
}
|
14
|
+
|
15
|
+
interface TextType {
|
16
|
+
lowerCase: string,
|
17
|
+
upperCase: string,
|
18
|
+
camelCase: string,
|
19
|
+
kebabCase: string,
|
20
|
+
titleCase: string,
|
21
|
+
snakeCase: string,
|
22
|
+
snakeUpperCase: string,
|
23
|
+
classifyCase: string
|
24
|
+
}
|
25
|
+
|
26
|
+
export function getFullTextType(text: string): TextType {
|
27
|
+
return {
|
28
|
+
lowerCase: text.toLowerCase(),
|
29
|
+
upperCase: text.toUpperCase(),
|
30
|
+
camelCase: toCamelCase(text),
|
31
|
+
kebabCase: toKebabCase(text),
|
32
|
+
titleCase: toTitleCase(text),
|
33
|
+
snakeCase: toSnakeCase(text),
|
34
|
+
snakeUpperCase: toSnakeUpperCase(text),
|
35
|
+
classifyCase: capitalize(text)
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
export const words = (str: any, pattern = /[^a-zA-Z-]+/): string[] => str.split(pattern).filter(Boolean);
|
40
|
+
|
41
|
+
export const toCamelCase = (str: any) => {
|
42
|
+
let s =
|
43
|
+
str &&
|
44
|
+
str
|
45
|
+
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
46
|
+
.map((x: any) => {
|
47
|
+
return x.slice(0, 1).toUpperCase() + x.slice(1).toLowerCase();
|
48
|
+
})
|
49
|
+
.join('');
|
50
|
+
return s.slice(0, 1).toLowerCase() + s.slice(1);
|
51
|
+
};
|
52
|
+
|
53
|
+
export const toKebabCase = (str: any) =>
|
54
|
+
str &&
|
55
|
+
str
|
56
|
+
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
57
|
+
.map((x: any) => x.toLowerCase())
|
58
|
+
.join('-');
|
59
|
+
|
60
|
+
export const toTitleCase = (str: any) =>
|
61
|
+
str
|
62
|
+
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
63
|
+
.map((x: any) => x.charAt(0).toUpperCase() + x.slice(1))
|
64
|
+
.join(' ');
|
65
|
+
|
66
|
+
export const capitalize = ([first, ...rest]: string, lowerRest = false) => {
|
67
|
+
return first.toUpperCase() + (lowerRest ? rest.join('').toLowerCase() : rest.join(''));
|
68
|
+
};
|
69
|
+
|
70
|
+
export const toSnakeCase = (str: any) => {
|
71
|
+
return str &&
|
72
|
+
str
|
73
|
+
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
74
|
+
.map((x: any) => x.toLowerCase())
|
75
|
+
.join('_');
|
76
|
+
}
|
77
|
+
|
78
|
+
export const toSnakeUpperCase = (str: any) => {
|
79
|
+
return str &&
|
80
|
+
str
|
81
|
+
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
82
|
+
.map((x: any) => x.toUpperCase())
|
83
|
+
.join('_');
|
84
|
+
}
|
85
|
+
|
86
|
+
export function getLastFolderFromPath(path: string): string {
|
87
|
+
if (!path) return ''
|
88
|
+
const folders = path.split('/')
|
89
|
+
return folders[folders.length - 1]
|
90
|
+
}
|
91
|
+
|
92
|
+
export function getWordBetweenSpace(line: string, indexSelected: number) {
|
93
|
+
const symbolBreakWork = [' ', '`', "'", '.', '(', ')']
|
94
|
+
let isBreakByDot = false
|
95
|
+
|
96
|
+
let text = ''
|
97
|
+
let lastIndex = indexSelected - 1
|
98
|
+
for (let index = indexSelected - 1; index > 0; index--) {
|
99
|
+
const char = line[index];
|
100
|
+
if (!symbolBreakWork.includes(char)) {
|
101
|
+
text = char + text
|
102
|
+
} else {
|
103
|
+
if (char == '.') isBreakByDot = true
|
104
|
+
break
|
105
|
+
}
|
106
|
+
}
|
107
|
+
|
108
|
+
for (let index = indexSelected; index < line.length; index++) {
|
109
|
+
const char = line[index]
|
110
|
+
if (!symbolBreakWork.includes(char)) {
|
111
|
+
text += char
|
112
|
+
lastIndex = index
|
113
|
+
} else {
|
114
|
+
break
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
return { text, lastIndex, isBreakByDot }
|
119
|
+
}
|
120
|
+
|
121
|
+
export function removePlural(name: string) {
|
122
|
+
name = name.replace(/ies$/, 'y')
|
123
|
+
name = name.replace(/ses$/, 's')
|
124
|
+
name = name.replace(/s$/, '')
|
125
|
+
return name
|
126
|
+
}
|
127
|
+
|
128
|
+
export function getMatch(regex: any, str: string) {
|
129
|
+
let m;
|
130
|
+
|
131
|
+
const matches: string[] = []
|
132
|
+
while ((m = regex.exec(str)) !== null) {
|
133
|
+
// This is necessary to avoid infinite loops with zero-width matches
|
134
|
+
if (m.index === regex.lastIndex) {
|
135
|
+
regex.lastIndex++;
|
136
|
+
}
|
137
|
+
|
138
|
+
// The result can be accessed through the `m`-variable.
|
139
|
+
m.forEach((match: string, groupIndex: number) => {
|
140
|
+
matches.push(match)
|
141
|
+
});
|
142
|
+
}
|
143
|
+
|
144
|
+
return matches
|
145
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import * as vscode from 'vscode';
|
2
|
+
|
3
|
+
|
4
|
+
export class Password {
|
5
|
+
|
6
|
+
static getProjectPassword() {
|
7
|
+
const config = vscode.workspace.getConfiguration("bmdextension")
|
8
|
+
const password = config.projectPassword;
|
9
|
+
|
10
|
+
return password;
|
11
|
+
}
|
12
|
+
|
13
|
+
static getApiPassword() {
|
14
|
+
const config = vscode.workspace.getConfiguration("bmdextension")
|
15
|
+
const password = config.apiPassword;
|
16
|
+
|
17
|
+
return password;
|
18
|
+
}
|
19
|
+
}
|
package/tsconfig.json
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"module": "commonjs",
|
4
|
+
"target": "es6",
|
5
|
+
"skipDefaultLibCheck": true,
|
6
|
+
"skipLibCheck": true,
|
7
|
+
"outDir": "out",
|
8
|
+
"lib": ["es6"],
|
9
|
+
"sourceMap": true,
|
10
|
+
"rootDir": "src",
|
11
|
+
"strict": true /* enable all strict type-checking options */
|
12
|
+
/* Additional Checks */
|
13
|
+
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
14
|
+
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
15
|
+
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
16
|
+
},
|
17
|
+
"exclude": ["node_modules", ".vscode-test", "**/assets/**"]
|
18
|
+
}
|
package/tslint.json
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
{
|
2
|
+
"rules": {
|
3
|
+
"no-string-throw": true,
|
4
|
+
"no-unused-expression": true,
|
5
|
+
"no-duplicate-variable": true,
|
6
|
+
"curly": true,
|
7
|
+
"class-name": true,
|
8
|
+
"semicolon": [
|
9
|
+
true,
|
10
|
+
"always"
|
11
|
+
],
|
12
|
+
"triple-equals": true
|
13
|
+
},
|
14
|
+
"defaultSeverity": "warning"
|
15
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# Welcome to your VS Code Extension
|
2
|
+
|
3
|
+
## What's in the folder
|
4
|
+
|
5
|
+
* This folder contains all of the files necessary for your extension.
|
6
|
+
* `package.json` - this is the manifest file in which you declare your extension and command.
|
7
|
+
* The sample plugin registers a command and defines its title and command name. With this information VS Code can show the command in the command palette. It doesn’t yet need to load the plugin.
|
8
|
+
* `src/extension.ts` - this is the main file where you will provide the implementation of your command.
|
9
|
+
* The file exports one function, `activate`, which is called the very first time your extension is activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`.
|
10
|
+
* We pass the function containing the implementation of the command as the second parameter to `registerCommand`.
|
11
|
+
|
12
|
+
## Get up and running straight away
|
13
|
+
|
14
|
+
* Press `F5` to open a new window with your extension loaded.
|
15
|
+
* Run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`.
|
16
|
+
* Set breakpoints in your code inside `src/extension.ts` to debug your extension.
|
17
|
+
* Find output from your extension in the debug console.
|
18
|
+
|
19
|
+
## Make changes
|
20
|
+
|
21
|
+
* You can relaunch the extension from the debug toolbar after changing code in `src/extension.ts`.
|
22
|
+
* You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes.
|
23
|
+
|
24
|
+
|
25
|
+
## Explore the API
|
26
|
+
|
27
|
+
* You can open the full set of our API when you open the file `node_modules/@types/vscode/index.d.ts`.
|
28
|
+
|
29
|
+
## Run tests
|
30
|
+
|
31
|
+
* Open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Extension Tests`.
|
32
|
+
* Press `F5` to run the tests in a new window with your extension loaded.
|
33
|
+
* See the output of the test result in the debug console.
|
34
|
+
* Make changes to `src/test/suite/extension.test.ts` or create new test files inside the `test/suite` folder.
|
35
|
+
* The provided test runner will only consider files matching the name pattern `**.test.ts`.
|
36
|
+
* You can create folders inside the `test` folder to structure your tests any way you want.
|
37
|
+
|
38
|
+
## Go further
|
39
|
+
|
40
|
+
* Reduce the extension size and improve the startup time by [bundling your extension](https://code.visualstudio.com/api/working-with-extensions/bundling-extension).
|
41
|
+
* [Publish your extension](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) on the VSCode extension marketplace.
|
42
|
+
* Automate builds by setting up [Continuous Integration](https://code.visualstudio.com/api/working-with-extensions/continuous-integration).
|