Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fe20e62

Browse files
Merge pull request #1 from vuejsco/develop
Add new variables
2 parents 320efd0 + dc75f76 commit fe20e62

File tree

9 files changed

+346
-166
lines changed

9 files changed

+346
-166
lines changed

‎README.md

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ The extension provides predefined templates for various Vue.js file types, makin
110110
],
111111
"vuejs.generator.project.author": "Manuel Gil",
112112
"vuejs.generator.project.owner": "Vue JS Colombia",
113-
"vuejs.generator.project.maintainer": "VueJS Team"
113+
"vuejs.generator.project.maintainers": "VueJS Team",
114+
"vuejs.generator.project.license": "MIT",
115+
"vuejs.generator.project.version": "1.0.0"
114116
}
115117
```
116118

@@ -128,29 +130,45 @@ You can customize **VueJS File Generator** by modifying its settings in `.vscode
128130
- `vuejs.generator.templates.customComponents`: Define custom component templates. Each template should include a `name`, `description`, `type`, and `template`.
129131
- `vuejs.generator.project.author`: Set the author name for the project.
130132
- `vuejs.generator.project.owner`: Set the owner name for the project.
131-
- `vuejs.generator.project.maintainer`: Set the maintainer name for the project.
133+
- `vuejs.generator.project.maintainers`: Set the maintainers name for the project.
134+
- `vuejs.generator.project.license`: Set the license for the project.
135+
- `vuejs.generator.project.version`: Set the version for the project.
132136

133137
The following variables can be used in the template:
134138

135-
| Variable | Description |
136-
|-------------------------|-------------|
137-
| `fileName` | The unmodified file name. Example: `"MyComponent"` |
138-
| `fileNameWithExt` | The file name with its extension. Example: `"MyComponent.vue"` |
139-
| `fileExt` | The file extension. Example: `"vue"` |
140-
| `fileNameCamelCase` | The file name in **camelCase**. Example: `"myComponent"` |
141-
| `fileNamePascalCase` | The file name in **PascalCase** (used for class and component names). Example: `"MyComponent"` |
142-
| `fileNameKebabCase` | The file name in **kebab-case** (commonly used for filenames and CSS classes). Example: `"my-component"` |
143-
| `fileNameSnakeCase` | The file name in **snake_case**. Example: `"my_component"` |
144-
| `fileNameConstantCase` | The file name in **CONSTANT_CASE** (used for constants in JavaScript/TypeScript). Example: `"MY_COMPONENT"` |
145-
| `fileNameDotCase` | The file name in **dot.case** (used in namespaces). Example: `"my.component"` |
146-
| `fileNamePathCase` | The file name in **path/case** (similar to file paths). Example: `"my/component"` |
147-
| `fileNameSentenceCase` | The file name in **Sentence case** (capitalizing only the first word). Example: `"My component"` |
148-
| `fileNameLowerCase` | The file name in **lowercase**. Example: `"my component"` |
149-
| `fileNameTitleCase` | The file name in **Title Case** (capitalizing each word). Example: `"My Component"` |
150-
| `date` | The current date in `YYYY-MM-DD` format. Example: `"2025年01月28日"` |
151-
| `author` | The author set in `project.author`. Example: `"Manuel Gil"` |
152-
| `owner` | The owner set in `project.owner`. Example: `"Vue JS Colombia"` |
153-
| `maintainer` | The maintainers set in `project.maintainer`. Example: `"VueJS Team"` |
139+
| Variable | Description |
140+
|----------------------------------|-------------|
141+
| `fileName` | The unmodified file name. Example: `"MyComponent"` |
142+
| `fileNameWithExtention` | The file name with its extension. Example: `"MyComponent.vue"` |
143+
| `fileExtension` | The file extension. Example: `"vue"` |
144+
| `fileNameCamelCase` | The file name in **camelCase**. Example: `"myComponent"` |
145+
| `fileNamePascalCase` | The file name in **PascalCase**. Example: `"MyComponent"` |
146+
| `fileNameKebabCase` | The file name in **kebab-case**. Example: `"my-component"` |
147+
| `fileNameSnakeCase` | The file name in **snake_case**. Example: `"my_component"` |
148+
| `fileNameConstantCase` | The file name in **CONSTANT_CASE**. Example: `"MY_COMPONENT"` |
149+
| `fileNameDotCase` | The file name in **dot.case**. Example: `"my.component"` |
150+
| `fileNamePathCase` | The file name in **path/case**. Example: `"my/component"` |
151+
| `fileNameSentenceCase` | The file name in **Sentence case**. Example: `"My component"` |
152+
| `fileNameLowerCase` | The file name in **lowercase**. Example: `"my component"` |
153+
| `fileNameTitleCase` | The file name in **Title Case**. Example: `"My Component"` |
154+
| `fileNamePluralCase` | The plural form of the file name. Example: `"MyComponents"` |
155+
| `fileNameSingularCase` | The singular form of the file name. Example: `"MyComponent"` |
156+
| `folderName` | The name of the folder where the file is created. |
157+
| `date` | The current date in `YYYY-MM-DD` format. Example: `"2025年01月28日"` |
158+
| `year` | The current year. Example: `"2025"` |
159+
| `time` | The current time in local format. Example: `"14:35:20"` |
160+
| `timestamp` | The current timestamp in milliseconds. Example: `"1706402120000"` |
161+
| `timestampISO` | The current timestamp in ISO format. Example: `"2025年01月28日T14:35:20.000Z"` |
162+
| `timestampUTC` | The current timestamp in UTC format. Example: `"2025年1月28日 14:35:20 GMT"` |
163+
| `timestampLocale` | The current timestamp in locale string format. Example: `"1/28/2025, 2:35:20 PM"` |
164+
| `timestampDate` | The current timestamp in date string format. Example: `"Tue Jan 28 2025"` |
165+
| `timestampTime` | The current timestamp in time string format. Example: `"14:35:20 GMT+0000 (Coordinated Universal Time)"` |
166+
| `timestampLocaleDate` | The current timestamp in locale date string format. Example: `"1/28/2025"` |
167+
| `author` | The author set in `project.author`. Example: `"Manuel Gil"` |
168+
| `owner` | The owner set in `project.owner`. Example: `"Vue JS Colombia"` |
169+
| `maintainers` | The maintainers set in `project.maintainers`. Example: `"VueJS Team"` |
170+
| `license` | The license set in `project.license`. Example: `"MIT"` |
171+
| `version` | The project version set in `project.version`. Example: `"1.0.0"` |
154172

155173
## Community
156174

‎package.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,23 @@
242242
"scope": "resource",
243243
"description": "%vuejs.generator.project.owner%"
244244
},
245-
"vuejs.generator.project.maintainer": {
245+
"vuejs.generator.project.maintainers": {
246246
"type": "string",
247247
"default": "",
248248
"scope": "resource",
249-
"description": "%vuejs.generator.project.maintainer%"
249+
"description": "%vuejs.generator.project.maintainers%"
250+
},
251+
"vuejs.generator.project.license": {
252+
"type": "string",
253+
"default": "MIT",
254+
"scope": "resource",
255+
"description": "%vuejs.generator.project.license%"
256+
},
257+
"vuejs.generator.project.version": {
258+
"type": "string",
259+
"default": "1.0.0",
260+
"scope": "resource",
261+
"description": "%vuejs.generator.project.version%"
250262
}
251263
}
252264
},

‎package.nls.es.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"vuejs.generator.templates.customComponents": "Templates de componentes personalizados",
99
"vuejs.generator.project.author": "Autor",
1010
"vuejs.generator.project.owner": "Propietario",
11-
"vuejs.generator.project.maintainer": "Mantenedor",
11+
"vuejs.generator.project.maintainers": "Mantenedores",
12+
"vuejs.generator.project.license": "Licencia",
13+
"vuejs.generator.project.version": "Versión",
1214
"vuejs.generator.generateCustomComponent": "Generar componente personalizado",
1315
"vuejs.generator.generateComponent": "Generar componente",
1416
"vuejs.generator.generatePage": "Generar página",

‎package.nls.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"vuejs.generator.templates.customComponents": "Custom components templates",
99
"vuejs.generator.project.author": "Author",
1010
"vuejs.generator.project.owner": "Owner",
11-
"vuejs.generator.project.maintainer": "Maintainer",
11+
"vuejs.generator.project.maintainers": "Maintainers",
12+
"vuejs.generator.project.license": "License",
13+
"vuejs.generator.project.version": "Version",
1214
"vuejs.generator.generateCustomComponent": "Generate Custom Component",
1315
"vuejs.generator.generateComponent": "Generate Component",
1416
"vuejs.generator.generatePage": "Generate Page",

‎schemas/config.schema.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,17 @@
126126
"default": "",
127127
"scope": "resource",
128128
"description": "Maintainer"
129+
},
130+
"vuejs.generator.project.license": {
131+
"type": "string",
132+
"default": "MIT",
133+
"scope": "resource",
134+
"description": "License"
135+
},
136+
"vuejs.generator.project.version": {
137+
"type": "string",
138+
"default": "1.0.0",
139+
"scope": "resource",
140+
"description": "Version"
129141
}
130142
}

‎src/app/configs/constants.config.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,27 @@ export const DEFAULT_OWNER: string = '';
249249
* @returns {string} - The default maintainer of the extension
250250
*/
251251
export const DEFAULT_MAINTAINER: string = '';
252+
253+
/**
254+
* DEFAULT_LICENSE: The default license of the extension.
255+
* @type {string}
256+
* @public
257+
* @memberof Constants
258+
* @example
259+
* console.log(DEFAULT_LICENSE);
260+
*
261+
* @returns {string} - The default license of the extension
262+
*/
263+
export const DEFAULT_LICENSE: string = 'MIT';
264+
265+
/**
266+
* DEFAULT_VERSION: The default version of the extension.
267+
* @type {string}
268+
* @public
269+
* @memberof Constants
270+
* @example
271+
* console.log(DEFAULT_VERSION);
272+
*
273+
* @returns {string} - The default version of the extension
274+
*/
275+
export const DEFAULT_VERSION: string = '1.0.0';

‎src/app/configs/extension.config.ts

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ import {
99
DEFAULT_EXCLUDE_SEMI_COLON_AT_END_OF_LINE,
1010
DEFAULT_HEADER_COMMENT_TEMPLATE,
1111
DEFAULT_INSERT_FINAL_NEWLINE,
12+
DEFAULT_LICENSE,
1213
DEFAULT_MAINTAINER,
1314
DEFAULT_OWNER,
1415
DEFAULT_SKIP_FOLDER_CONFIRMATION,
16+
DEFAULT_VERSION,
1517
} from './constants.config';
1618

1719
/**
@@ -156,7 +158,31 @@ export class ExtensionConfig {
156158
* console.log(config.repository);
157159
* @default ''
158160
*/
159-
maintainer: string;
161+
maintainers: string;
162+
163+
/**
164+
* The license.
165+
* @type {string}
166+
* @public
167+
* @memberof ExtensionConfig
168+
* @example
169+
* const config = new ExtensionConfig(workspace.getConfiguration());
170+
* console.log(config.license);
171+
* @default ''
172+
*/
173+
license: string;
174+
175+
/**
176+
* The version.
177+
* @type {string}
178+
* @public
179+
* @memberof ExtensionConfig
180+
* @example
181+
* const config = new ExtensionConfig(workspace.getConfiguration());
182+
* console.log(config.version);
183+
* @default ''
184+
*/
185+
version: string;
160186

161187
// -----------------------------------------------------------------
162188
// Constructor
@@ -198,10 +224,12 @@ export class ExtensionConfig {
198224
);
199225
this.author = config.get<string>('project.author', DEFAULT_AUTHOR);
200226
this.owner = config.get<string>('project.owner', DEFAULT_OWNER);
201-
this.maintainer = config.get<string>(
202-
'project.maintainer',
227+
this.maintainers = config.get<string>(
228+
'project.maintainers',
203229
DEFAULT_MAINTAINER,
204230
);
231+
this.license = config.get<string>('project.license', DEFAULT_LICENSE);
232+
this.version = config.get<string>('project.version', DEFAULT_VERSION);
205233
}
206234

207235
// -----------------------------------------------------------------
@@ -248,6 +276,11 @@ export class ExtensionConfig {
248276
);
249277
this.author = config.get<string>('project.author', this.author);
250278
this.owner = config.get<string>('project.owner', this.owner);
251-
this.maintainer = config.get<string>('project.maintainer', this.maintainer);
279+
this.maintainers = config.get<string>(
280+
'project.maintainers',
281+
this.maintainers,
282+
);
283+
this.license = config.get<string>('project.license', this.license);
284+
this.version = config.get<string>('project.version', this.version);
252285
}
253286
}

‎src/app/helpers/inflector.helper.ts

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import * as vscode from 'vscode';
2-
31
/**
42
* Changes a string of words separated by spaces or underscores to camel case.
53
*
@@ -14,7 +12,11 @@ export const camelize = (str: string): string => {
1412
.replace(/(?:^\w|[A-Z]|\b\w)/g, (word, index) =>
1513
index === 0 ? word.toLowerCase() : word.toUpperCase(),
1614
)
17-
.replace(/\s+/g, '');
15+
.replace(/\s+/g, '')
16+
.replace(/-+/g, '')
17+
.replace(/_+/g, '')
18+
.replace(/\.+/g, '')
19+
.replace(/\/+/g, '');
1820
};
1921

2022
/**
@@ -29,7 +31,11 @@ export const camelize = (str: string): string => {
2931
export const pascalize = (str: string): string => {
3032
return str
3133
.replace(/(?:^\w|[A-Z]|\b\w)/g, (word) => word.toUpperCase())
32-
.replace(/\s+/g, '');
34+
.replace(/\s+/g, '')
35+
.replace(/-+/g, '')
36+
.replace(/_+/g, '')
37+
.replace(/\.+/g, '')
38+
.replace(/\/+/g, '');
3339
};
3440

3541
/**
@@ -42,7 +48,12 @@ export const pascalize = (str: string): string => {
4248
* @returns {string} - The kebabized string
4349
*/
4450
export const kebabize = (str: string): string => {
45-
return str.replace(/\s+/g, '-').toLowerCase();
51+
return str
52+
.replace(/\s+/g, '-')
53+
.replace(/_+/g, '-')
54+
.replace(/\.+/g, '-')
55+
.replace(/\/+/g, '-')
56+
.toLowerCase();
4657
};
4758

4859
/**
@@ -55,7 +66,12 @@ export const kebabize = (str: string): string => {
5566
* @returns {string} - The snakeized string
5667
*/
5768
export const snakeize = (str: string): string => {
58-
return str.replace(/\s+/g, '_').toLowerCase();
69+
return str
70+
.replace(/\s+/g, '_')
71+
.replace(/-+/g, '_')
72+
.replace(/\.+/g, '_')
73+
.replace(/\/+/g, '_')
74+
.toLowerCase();
5975
};
6076

6177
/**
@@ -68,7 +84,12 @@ export const snakeize = (str: string): string => {
6884
* @returns {string} - The constantized string
6985
*/
7086
export const constantize = (str: string): string => {
71-
return str.replace(/\s+/g, '_').toUpperCase();
87+
return str
88+
.replace(/\s+/g, '_')
89+
.replace(/-+/g, '_')
90+
.replace(/\.+/g, '_')
91+
.replace(/\/+/g, '_')
92+
.toUpperCase();
7293
};
7394

7495
/**
@@ -99,3 +120,41 @@ export const titleize = (str: string): string => {
99120
export const sentenceCase = (str: string): string => {
100121
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
101122
};
123+
124+
/**
125+
* Changes a string to its plural form.
126+
*
127+
* @param {string} str - The string to pluralize
128+
* @example
129+
* pluralize('foo');
130+
*
131+
* @returns {string} - The pluralized string
132+
*/
133+
export const pluralize = (str: string): string => {
134+
if (str.endsWith('y')) {
135+
return str.slice(0, -1) + 'ies';
136+
}
137+
if (str.endsWith('s')) {
138+
return str;
139+
}
140+
return str + 's';
141+
};
142+
143+
/**
144+
* Changes a string to its singular form.
145+
*
146+
* @param {string} str - The string to singularize
147+
* @example
148+
* singularize('foos');
149+
*
150+
* @returns {string} - The singularized string
151+
*/
152+
export const singularize = (str: string): string => {
153+
if (str.endsWith('ies')) {
154+
return str.slice(0, -3) + 'y';
155+
}
156+
if (str.endsWith('s')) {
157+
return str.slice(0, -1);
158+
}
159+
return str;
160+
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /