Skip to content

Commit a93356d

Browse files
committed
refactor: ♻️ update file patterns in configuration and improve code readability
1 parent 62261f5 commit a93356d

16 files changed

+150
-110
lines changed

.vscode/settings.json

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,5 @@
88
},
99
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
1010
"typescript.tsc.autoDetect": "off",
11-
"[typescript]": {
12-
"editor.defaultFormatter": "biomejs.biome"
13-
},
14-
"[javascript]": {
15-
"editor.defaultFormatter": "biomejs.biome"
16-
},
17-
"[html]": {
18-
"editor.defaultFormatter": "biomejs.biome"
19-
},
20-
"[css]": {
21-
"editor.defaultFormatter": "biomejs.biome"
22-
}
11+
"editor.defaultFormatter": "biomejs.biome"
2312
}

l10n/bundle.l10n.es.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44
"Welcome to {0} version {1}! The extension is now active": "¡Bienvenido a {0} versión {1}! La extensión ahora está activa",
55
"New version of {0} is available. Check out the release notes for version {1}": "Hay disponible una nueva versión de {0}. Consulte las notas de la versión {1}",
66
"Release Notes": "Notas de la versión",
7-
"Close": "Cerrar",
7+
"Dismiss": "Descartar",
8+
"About Us": "Acerca de Nosotros",
9+
"Documentation": "Documentación",
10+
"Report Issues": "Reportar Problemas",
11+
"Rate Us": "Calificanos",
12+
"Follow Us": "Síguenos",
13+
"Support Us": "Apóyanos",
814
"Become a Sponsor": "Conviértete en Patrocinador",
915
"Donate via PayPal": "Donar a través de PayPal",
1016
"Although {0} is offered at no cost, your support is deeply appreciated if you find it beneficial. Thank you for considering!": "Aunque {0} se ofrece sin costo, su apoyo es muy apreciado si lo encuentra beneficioso. ¡Gracias por considerarlo!",

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"configuration": {
5151
"title": "My Extension",
5252
"properties": {
53-
"extensionIdentifier.files.include": {
53+
"extensionIdentifier.files.includedFilePatterns": {
5454
"type": "array",
5555
"default": [
5656
"ts",
@@ -62,9 +62,9 @@
6262
"less"
6363
],
6464
"scope": "resource",
65-
"description": "%extensionIdentifier.files.include%"
65+
"description": "%extensionIdentifier.files.includedFilePatterns%"
6666
},
67-
"extensionIdentifier.files.exclude": {
67+
"extensionIdentifier.files.excludedFilePatterns": {
6868
"type": "array",
6969
"default": [
7070
"**/node_modules/**",
@@ -74,13 +74,13 @@
7474
"**/.*/**"
7575
],
7676
"scope": "resource",
77-
"description": "%extensionIdentifier.files.exclude%"
77+
"description": "%extensionIdentifier.files.excludedFilePatterns%"
7878
},
79-
"extensionIdentifier.files.showPath": {
79+
"extensionIdentifier.files.includeFilePath": {
8080
"type": "boolean",
8181
"default": true,
8282
"scope": "resource",
83-
"description": "%extensionIdentifier.files.showPath%"
83+
"description": "%extensionIdentifier.files.includeFilePath%"
8484
},
8585
"extensionIdentifier.openai.apiKey": {
8686
"type": "string",

package.nls.es.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"extensionIdentifier.files.include": "Patrones Glob para incluir en el paquete. El valor predeterminado es ts, js, json, html, css, scss, less",
3-
"extensionIdentifier.files.exclude": "Patrones Glob para excluir del paquete. El valor predeterminado es node_modules, dist, out, build y cualquier archivo oculto",
4-
"extensionIdentifier.files.showPath": "Mostrar la ruta del archivo en el nombre de la lista de archivos generados",
2+
"extensionIdentifier.files.includedFilePatterns": "Patrones Glob para incluir en el paquete. El valor predeterminado es ts, js, json, html, css, scss, less",
3+
"extensionIdentifier.files.excludedFilePatterns": "Patrones Glob para excluir del paquete. El valor predeterminado es node_modules, dist, out, build y cualquier archivo oculto",
4+
"extensionIdentifier.files.includeFilePath": "Mostrar la ruta del archivo en el nombre de la lista de archivos generados",
55
"extensionIdentifier.openai.apiKey": "Clave de API de OpenAI. Obténgala de https://platform.openai.com/account/api-keys",
66
"extensionIdentifier.openai.model": "Modelo de OpenAI. El valor predeterminado es gpt-3.5-turbo. Obtenga más información de https://platform.openai.com/docs/models/model-endpoint-compatibility",
77
"extensionIdentifier.helloWorld": "Hola Mundo",

package.nls.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"extensionIdentifier.files.include": "Glob patterns to include in the package. The default is ts, js, json, html, css, scss, less",
3-
"extensionIdentifier.files.exclude": "Glob patterns to exclude from the package. The default is node_modules, dist, out, build, and any hidden files",
4-
"extensionIdentifier.files.showPath": "Show the path of the file in the name of the list of generated files",
2+
"extensionIdentifier.files.includedFilePatterns": "Glob patterns to include in the package. The default is ts, js, json, html, css, scss, less",
3+
"extensionIdentifier.files.excludedFilePatterns": "Glob patterns to exclude from the package. The default is node_modules, dist, out, build, and any hidden files",
4+
"extensionIdentifier.files.includeFilePath": "Show the path of the file in the name of the list of generated files",
55
"extensionIdentifier.openai.apiKey": "OpenAI API Key. Get it from https://platform.openai.com/account/api-keys",
66
"extensionIdentifier.openai.model": "OpenAI Model. The default is gpt-3.5-turbo. Get more information from https://platform.openai.com/docs/models/model-endpoint-compatibility",
77
"extensionIdentifier.helloWorld": "Hello World",

schemas/config.schema.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"type": "object",
44
"properties": {
5-
"extensionIdentifier.files.include": {
5+
"extensionIdentifier.files.includedFilePatterns": {
66
"type": "array",
77
"default": [
88
"ts",
@@ -16,7 +16,7 @@
1616
"scope": "resource",
1717
"description": "Glob patterns to include in the package. The default is ts, js, json, html, css, scss, less."
1818
},
19-
"extensionIdentifier.files.exclude": {
19+
"extensionIdentifier.files.excludedFilePatterns": {
2020
"type": "array",
2121
"default": [
2222
"**/node_modules/**",
@@ -28,7 +28,7 @@
2828
"scope": "resource",
2929
"description": "Glob patterns to exclude from the package. The default is node_modules, dist, out, build, and any hidden files."
3030
},
31-
"extensionIdentifier.files.showPath": {
31+
"extensionIdentifier.files.includeFilePath": {
3232
"type": "boolean",
3333
"default": true,
3434
"scope": "resource",

src/app/configs/constants.config.ts

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,40 +35,40 @@ export const EXTENSION_NAME: string = 'vscode-extension-starter-advanced';
3535
export const EXTENSION_DISPLAY_NAME: string = 'My Extension';
3636

3737
/**
38-
* USER_NAME: The githubUsername of the extension.
38+
* GITHUB_USER_NAME: The githubUsername of the extension.
3939
* @type {string}
4040
* @public
4141
* @memberof Constants
4242
* @example
43-
* console.log(USER_NAME);
43+
* console.log(GITHUB_USER_NAME);
4444
*
4545
* @returns {string} - The githubUsername of the extension
4646
*/
47-
export const USER_NAME: string = 'githubUsername';
47+
export const GITHUB_USER_NAME: string = 'githubUsername';
4848

4949
/**
50-
* USER_PUBLISHER: The publisher of the extension.
50+
* EXTENSION_USER_PUBLISHER: The publisher of the extension.
5151
* @type {string}
5252
* @public
5353
* @memberof Constants
5454
* @example
55-
* console.log(USER_PUBLISHER);
55+
* console.log(EXTENSION_USER_PUBLISHER);
5656
*
5757
* @returns {string} - The publisher of the extension
5858
*/
59-
export const USER_PUBLISHER: string = 'extensionPublisher';
59+
export const EXTENSION_USER_PUBLISHER: string = 'extensionPublisher';
6060

6161
/**
62-
* REPOSITORY_URL: The documentation URL of the extension.
62+
* EXTENSION_REPOSITORY_URL: The repository URL of the extension.
6363
* @type {string}
6464
* @public
6565
* @memberof Constants
6666
* @example
67-
* console.log(REPOSITORY_URL);
67+
* console.log(EXTENSION_REPOSITORY_URL);
6868
*
69-
* @returns {string} - The documentation URL of the extension
69+
* @returns {string} - The repository URL of the extension
7070
*/
71-
export const REPOSITORY_URL: string = `https://github.com/${USER_NAME}/${EXTENSION_NAME}`;
71+
export const EXTENSION_REPOSITORY_URL: string = `https://github.com/${GITHUB_USER_NAME}/${EXTENSION_NAME}`;
7272

7373
/**
7474
* MARKETPLACE_URL: The marketplace URL of the extension.
@@ -80,45 +80,46 @@ export const REPOSITORY_URL: string = `https://github.com/${USER_NAME}/${EXTENSI
8080
*
8181
* @returns {string} - The marketplace URL of the extension
8282
*/
83-
export const MARKETPLACE_URL: string = `https://marketplace.visualstudio.com/items?itemName=${USER_PUBLISHER}.${EXTENSION_NAME}`;
83+
export const EXTENSION_MARKETPLACE_URL: string = `https://marketplace.visualstudio.com/items?itemName=${EXTENSION_USER_PUBLISHER}.${EXTENSION_NAME}`;
8484

8585
/**
86-
* INCLUDE: The files to include.
86+
* DEFAULT_INCLUDE_PATTERNS: The files to include.
8787
* @type {string[]}
8888
* @public
8989
* @memberof Constants
9090
* @example
91-
* console.log(INCLUDE);
91+
* console.log(DEFAULT_INCLUDE_PATTERNS);
9292
*
9393
* @returns {string[]} - The files to include
9494
*/
95-
export const INCLUDE: string[] = ['ts', 'html', 'css', 'scss', 'less'];
95+
export const DEFAULT_INCLUDE_PATTERNS: string[] = ['**/*'];
96+
9697
/**
97-
* EXCLUDE: The files to exclude.
98+
* DEFAULT_EXCLUDE_PATTERNS: The patterns to exclude from the search.
9899
* @type {string[]}
99100
* @public
100101
* @memberof Constants
101102
* @example
102-
* console.log(EXCLUDE);
103+
* console.log(DEFAULT_EXCLUDE_PATTERNS);
103104
*
104105
* @returns {string[]} - The files to exclude
105106
*/
106-
export const EXCLUDE: string[] = [
107+
export const DEFAULT_EXCLUDE_PATTERNS: string[] = [
107108
'**/node_modules/**',
108109
'**/dist/**',
109110
'**/out/**',
110111
'**/build/**',
111112
'**/.*/**',
112113
];
113114

114-
/**
115-
* SHOW_PATH: Whether to show the path or not.
115+
/**IS_INCLUDE_FILE_PATH_DEFAULT
116+
* DEFAULT_INCLUDE_FILE_PATH: Whether to show the path or not.
116117
* @type {boolean}
117118
* @public
118119
* @memberof Constants
119120
* @example
120-
* console.log(SHOW_PATH);
121+
* console.log(IS_INCLUDE_FILE_PATH_DEFAULT);
121122
*
122123
* @returns {boolean} - Whether to show the path or not
123124
*/
124-
export const SHOW_PATH: boolean = true;
125+
export const IS_INCLUDE_FILE_PATH_DEFAULT: boolean = true;

src/app/configs/extension.config.ts

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { WorkspaceConfiguration } from 'vscode';
22

3-
import { EXCLUDE, INCLUDE, SHOW_PATH } from './constants.config';
3+
import {
4+
DEFAULT_EXCLUDE_PATTERNS,
5+
IS_INCLUDE_FILE_PATH_DEFAULT,
6+
DEFAULT_INCLUDE_PATTERNS,
7+
} from './constants.config';
48

59
/**
610
* The Config class.
@@ -33,7 +37,7 @@ export class ExtensionConfig {
3337
* const config = new Config(workspace.getConfiguration());
3438
* console.log(config.include);
3539
*/
36-
include: string[];
40+
includedFilePatterns: string[];
3741
/**
3842
* The files to exclude.
3943
* @type {string[]}
@@ -43,7 +47,7 @@ export class ExtensionConfig {
4347
* const config = new Config(workspace.getConfiguration());
4448
* console.log(config.exclude);
4549
*/
46-
exclude: string[];
50+
excludedFilePatterns: string[];
4751
/**
4852
* Whether to show the path or not.
4953
* @type {boolean}
@@ -53,7 +57,7 @@ export class ExtensionConfig {
5357
* const config = new Config(workspace.getConfiguration());
5458
* console.log(config.showPath);
5559
*/
56-
showPath: boolean;
60+
includeFilePath: boolean;
5761
/**
5862
* The OpenAI API key.
5963
* @type {string}
@@ -81,9 +85,22 @@ export class ExtensionConfig {
8185
* @memberof Config
8286
*/
8387
constructor(readonly config: WorkspaceConfiguration) {
84-
this.include = config.get<string[]>('files.include', INCLUDE);
85-
this.exclude = config.get<string[]>('files.exclude', EXCLUDE);
86-
this.showPath = config.get<boolean>('files.showPath', SHOW_PATH);
88+
// Extensions to include in the search
89+
this.includedFilePatterns = config.get<string[]>(
90+
'files.includedFilePatterns',
91+
DEFAULT_INCLUDE_PATTERNS,
92+
);
93+
// Patterns of files and folders to exclude from the search
94+
this.excludedFilePatterns = config.get<string[]>(
95+
'files.excludedFilePatterns',
96+
DEFAULT_EXCLUDE_PATTERNS,
97+
);
98+
// Whether to show the path or not in the search results
99+
this.includeFilePath = config.get<boolean>(
100+
'files.includeFilePath',
101+
IS_INCLUDE_FILE_PATH_DEFAULT,
102+
);
103+
// OpenAI API key and model to use
87104
this.openai = {
88105
apiKey: config.get<string>('openai.apiKey', ''),
89106
model: config.get<string>('openai.model', ''),
@@ -107,12 +124,25 @@ export class ExtensionConfig {
107124
* config.update(workspace.getConfiguration());
108125
*/
109126
update(config: WorkspaceConfiguration): void {
110-
this.include = config.get<string[]>('files.include', INCLUDE);
111-
this.exclude = config.get<string[]>('files.exclude', EXCLUDE);
112-
this.showPath = config.get<boolean>('files.showPath', SHOW_PATH);
127+
// Extensions to include in the search
128+
this.includedFilePatterns = config.get<string[]>(
129+
'files.includedFilePatterns',
130+
this.includedFilePatterns,
131+
);
132+
// Patterns of files and folders to exclude from the search
133+
this.excludedFilePatterns = config.get<string[]>(
134+
'files.excludedFilePatterns',
135+
this.excludedFilePatterns,
136+
);
137+
// Whether to show the path or not in the search results
138+
this.includeFilePath = config.get<boolean>(
139+
'files.includeFilePath',
140+
this.includeFilePath,
141+
);
142+
// OpenAI API key and model to use
113143
this.openai = {
114-
apiKey: config.get<string>('openai.apiKey', ''),
115-
model: config.get<string>('openai.model', ''),
144+
apiKey: config.get<string>('openai.apiKey', this.openai.apiKey),
145+
model: config.get<string>('openai.model', this.openai.model),
116146
};
117147
}
118148
}

src/app/controllers/example.controller.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ export class ExampleController {
7474
* @returns {Promise<void>} - The promise with no return value
7575
*/
7676
async getFilesInFolder(path?: Uri): Promise<void> {
77+
const { includedFilePatterns, excludedFilePatterns } = this.config;
78+
7779
// Get the relative path
7880
const folderPath: string = path ? await getRelativePath(path.path) : '';
7981

@@ -97,8 +99,8 @@ export class ExampleController {
9799

98100
// Get the files in the folder
99101
const files = await directoryMap(folder, {
100-
extensions: this.config.include,
101-
ignore: this.config.exclude,
102+
extensions: includedFilePatterns,
103+
ignore: excludedFilePatterns,
102104
maxResults: 512,
103105
});
104106

0 commit comments

Comments
 (0)