Skip to content

Commit f0ad77a

Browse files
committed
Merge branch 'release/0.0.6'
2 parents 6b8dd4d + fbb25c0 commit f0ad77a

File tree

6 files changed

+79
-27
lines changed

6 files changed

+79
-27
lines changed

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# Change Log
22

33
## [0.0.6] 2022-02-01
4-
- Added - Files settings option to retain v-inc line in file.
4+
- Added - Files settings option to retain v-inc line in file (`RetainLine`).
5+
- Added - Files settings option to trim characters from start of line with V-INC macro (`TrimTextStart`).
6+
- Added - Files settings option to trim characters from end of line with V-INC macro (`TrimTextEnd`).
57
- Added - Date and Time macros.
68
- Added - Edit example files command.
9+
- Updated - Screenshot has been updated to reflect the new changes.
710

811
## [0.0.5] 2022-01-23
9-
- Fixed - Status bar item will default to `"name"` entry if `"displayName"` entry is not defined.
12+
- Fixed - Status bar item text will default to `"name"` entry if `"displayName"` entry is not defined.
1013

1114
## [0.0.4] 2022-01-17
1215
- Fixed - Will now create projects files list json file if it does not exist.

README.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,24 @@ Here is the default settings...
3737
```
3838
[
3939
{
40-
"filename": "example.md",
41-
"filelocation": "${globalStorage}",
42-
"enable": false,
40+
"Filename": "example.md",
41+
"FileLocation": "${globalStorage}",
42+
"Enable": false,
4343
"RetainLine": true,
44-
"insertbefore": "",
45-
"insertafter": ""
44+
"InsertBefore": "",
45+
"InsertAfter": ""
46+
"TrimTextStart": 5,
47+
"TrimTextEnd": 38
4648
},
4749
{
48-
"filename": "example.js",
49-
"filelocation": "${globalStorage}",
50-
"enable": false,
50+
"Filename": "example.js",
51+
"FileLocation": "${globalStorage}",
52+
"Enable": false,
5153
"RetainLine": false,
52-
"insertbefore": "v",
53-
"insertafter": "-Beta"
54+
"InsertBefore": "v",
55+
"InsertAfter": "-Beta"
56+
"TrimTextStart": 0,
57+
"TrimTextEnd": 0
5458
}
5559
]
5660
```
@@ -66,10 +70,14 @@ The `"FileLocation":` entry is the path to the file to update. This can be set t
6670

6771
`"InsertAfter":` String to insert after the new version string.
6872

73+
`"TrimTextStart":` Number of characters to trim from the start of the line with the v-inc macro.
6974

70-
To see this extension in operation, open the example files with the command `Version Inc: Edit Example Files`, then enable the example files (Set Enable to true), then run the increment version command to see the results.
75+
`"TrimTextEnd":` Number of characters to trim from the end of the line with the v-inc macro.
7176

72-
Note: The `RetainLine` option was added in v0-0-0-6 so if you have modified the settings file from a previous version you will need to add the line to the settings file (see the example settings above).
77+
78+
To see this extension in operation, open the example files with the command `Version Inc: Edit Example Files`, then enable the example files (Set Enable to true), then run the increment version command to see the results. Note that this will increment the version in your package.json file but you can use the command `Version Inc: Decrement Package.json Version` to restore it after you have examined the example files.
79+
80+
Note: The `RetainLine`, `"TrimTextStart"` and `"TrimTextStart"` options were added in v0-0-0-6 so if you have modified the settings file from a previous version you will need to add the line to the settings file (see the example settings above).
7381

7482
Note: The updated files are not automatically saved. This allows you to review the changes made and to continue making any other changes you require.
7583

RELEASE.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# Release Notes
22

33
## [0.0.6] 2022-02-01
4-
- Added - Files settings option to retain v-inc line in file.
4+
- Added - Files settings option to retain v-inc line in file (`RetainLine`).
5+
- Added - Files settings option to trim characters from start of line with V-INC macro (`TrimTextStart`).
6+
- Added - Files settings option to trim characters from end of line with V-INC macro (`TrimTextEnd`).
57
- Added - Date and Time macros.
68
- Added - Edit example files command.
9+
- Updated - Screenshot has been updated to reflect the new changes.
710

811

912
For a full list of changes, please see the projects [Changelog](CHANGELOG.md) file.

images/version-inc-demo.gif

245 KB
Loading

releases/version-inc-0.0.6.vsix

433 KB
Binary file not shown.

src/extension.js

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,12 @@ async function updateOtherFiles(newVersion) {
289289
}
290290

291291
// Retrieve the rest of the settings
292-
var enable = packageJson[i]['Enable']; // Enable replace flag
293-
var insBefore = packageJson[i]['InsertBefore']; // String to insert before version string
294-
var insAfter = packageJson[i]['InsertAfter']; // String to insert after version string
295-
var retainLine = packageJson[i]['RetainLine']; // Retain version string trigger line
292+
var enable = packageJson[i]['Enable']; // Enable replace flag
293+
var insBefore = packageJson[i]['InsertBefore']; // String to insert before version string
294+
var insAfter = packageJson[i]['InsertAfter']; // String to insert after version string
295+
var retainLine = packageJson[i]['RetainLine']; // Retain version string macro line
296+
var trimTextStart = packageJson[i]['TrimTextStart']; // Number of characters to trim from start of line
297+
var trimTextEnd = packageJson[i]['TrimTextEnd']; // Number of characters to trim from end of line
296298
var newVersionString = insBefore + newVersion + insAfter; // Final new version string
297299

298300
//----------------------------------------
@@ -338,8 +340,8 @@ async function updateOtherFiles(newVersion) {
338340
var date = new Date();
339341
var [year, month, day] = [date.getFullYear(), date.getMonth()+1, date.getDate()];
340342
var [hours, minutes, seconds] = [date.getHours(), date.getMinutes(), date.getSeconds()];
341-
//hours = 12; // For testing hours, REMOVE when done
342-
//month = 12; // For testing months, REMOVE when done
343+
//hours = 12; // For testing hours, REMOVE when done
344+
//month = 12; // For testing months, REMOVE when done
343345
var h12 = hours;
344346
var h24 = hours;
345347
var ampmU = 'AM';
@@ -512,11 +514,14 @@ async function updateOtherFiles(newVersion) {
512514
}
513515

514516
if (vincMatched) {
515-
if (retainLine == true) {
516-
result = text+'\n\n'+result; // Save Trigger Line for Reuse
517-
}
518517
dirtyFlag = true;
518+
if (trimTextStart > 0 || trimTextEnd > 0) {
519+
result = result.substring(trimTextStart,result.length-trimTextEnd)
519520
}
521+
if (retainLine == true) {
522+
result = text+'\n\n'+result; // Save Macro Line for Reuse
523+
}
524+
}
520525

521526
//----------------------------------------
522527
// Now Replace Current Line in the File
@@ -539,11 +544,44 @@ async function updateOtherFiles(newVersion) {
539544
async function initSettingsFilePath(context) {
540545

541546
// Default files list settings json file
542-
const defaultSettings = "[\n\t{\n\t\t\"Filename\": \"example.md\",\n\t\t\"FileLocation\": \"${globalStorage}\",\n\t\t\"Enable\": false,\n\t\t\"RetainLine\": true,\n\t\t\"InsertBefore\": \"\",\n\t\t\"InsertAfter\": \"\"\n\t},\n\t{\n\t\t\"Filename\": \"example.js\",\n\t\t\"FileLocation\": \"${globalStorage}\",\n\t\t\"Enable\": false,\n\t\t\"RetainLine\": false,\n\t\t\"InsertBefore\": \"v\",\n\t\t\"InsertAfter\": \"-Beta\"\n\t}\n]\n";
547+
const defaultSettings = '[\n\t' +
548+
'{\n\t\t' +
549+
'\"Filename\": \"example.md\",\n\t\t' +
550+
'\"FileLocation\": \"${globalStorage}\",\n\t\t' +
551+
'\"Enable\": false,\n\t\t' +
552+
'\"RetainLine\": true,\n\t\t' +
553+
'\"InsertBefore\": \"\",\n\t\t' +
554+
'\"InsertAfter\": \"\",\n\t\t' +
555+
'\"TrimTextStart\": 5,\n\t\t' +
556+
'\"TrimTextEnd\": 38\n\t' +
557+
'},\n\t' +
558+
'{\n\t\t' +
559+
'\"Filename\": \"example.js\",\n\t\t' +
560+
'\"FileLocation\": \"${globalStorage}\",\n\t\t' +
561+
'\"Enable\": false,\n\t\t' +
562+
'\"RetainLine\": false,\n\t\t' +
563+
'\"InsertBefore\": \"v\",\n\t\t' +
564+
'\"InsertAfter\": \"-Beta\",\n\t\t' +
565+
'\"TrimTextStart\": 0,\n\t\t' +
566+
'\"TrimTextEnd\": 0\n\t' +
567+
'}\n' +
568+
']\n';
543569
// example.md file
544-
const exampleMD = "# Example of using Version-Inc in a markdown file\n\n## Change Log\n\n## [v-inc] - ${DATE}\n";
570+
const exampleMD = '# Version-Inc example in a markdown file\n\n' +
571+
'## Change Log\n\n' +
572+
'<!-- ## [v-inc] - ${YEAR4}-${MONTHNUMBER}-${DATE} Note: this Line will be preserved -->\n';
545573
// example.js file
546-
const exampleJS = "//----------------------------------\n// Version-Inc example in a java script file\n//\n// File version: V-INC\n//\n// Product version: v-inc\n//----------------------------------\n";
574+
const exampleJS = '//--------------------------------------------------\n' +
575+
'// Version-Inc example in a java script file\n' +
576+
'//--------------------------------------------------\n' +
577+
'//\n' +
578+
'// Last Modification: ${MONTHTEXTL} ${DATE} ${YEAR4}\n' +
579+
'// At: ${H12}:${MIN}:${SEC} ${AMPMU}\n' +
580+
'//\n' +
581+
'// File Version...: V-INC\n' +
582+
'//\n' +
583+
'// Product version: v-inc\n' +
584+
'//--------------------------------------------------\n';
547585
// If folder does exist then verifiy extensions files exist
548586
if (fs.existsSync(globalSettingsPath)) {
549587
if (!fs.existsSync(globalSettingsFile)) {

0 commit comments

Comments
 (0)