@addev-be/framework-utils 0.10.3 → 0.10.5
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/node/helpers/versions.mjs +130 -130
- package/node/index.mjs +5 -5
- package/package.json +1 -1
|
@@ -1,130 +1,130 @@
|
|
|
1
|
-
import * as glob from 'glob';
|
|
2
|
-
|
|
3
|
-
import { readFileSync, writeFileSync } from 'fs';
|
|
4
|
-
|
|
5
|
-
import { cwd } from 'process';
|
|
6
|
-
import { join } from 'path';
|
|
7
|
-
|
|
8
|
-
const __dirname = cwd();
|
|
9
|
-
|
|
10
|
-
export const replaceVersionInCSharpProject = (path, newVersion) => {
|
|
11
|
-
console.log('Replacing version in C# project file', path);
|
|
12
|
-
const fileContents = readFileSync(path, 'utf-8');
|
|
13
|
-
const newFileContents = fileContents
|
|
14
|
-
.replace(/<Version>.*<\/Version>/g, `<Version>${newVersion}</Version>`)
|
|
15
|
-
.replace(
|
|
16
|
-
/<AssemblyVersion>.*<\/AssemblyVersion>/g,
|
|
17
|
-
`<AssemblyVersion>${newVersion}</AssemblyVersion>`
|
|
18
|
-
)
|
|
19
|
-
.replace(
|
|
20
|
-
/<FileVersion>.*<\/FileVersion>/g,
|
|
21
|
-
`<FileVersion>${newVersion}</FileVersion>`
|
|
22
|
-
);
|
|
23
|
-
writeFileSync(path, newFileContents);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const replaceVersionInCSharpProjects = (globPath, newVersion) => {
|
|
27
|
-
const files = glob.sync(globPath.replace(/\\/g, '/'));
|
|
28
|
-
files.forEach((file) => replaceVersionInCSharpProject(file, newVersion));
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const replaceVersionInAssemblyInfoFile = (path, newVersion) => {
|
|
32
|
-
console.log('Replacing version in C# AssemblyInfo file', path);
|
|
33
|
-
const fileContents = readFileSync(path, 'utf-8');
|
|
34
|
-
const newFileContents = fileContents.replace(
|
|
35
|
-
/Version\("\d+\.\d+\.\d+"\)\]/g,
|
|
36
|
-
`Version("${newVersion}")]`
|
|
37
|
-
);
|
|
38
|
-
writeFileSync(path, newFileContents);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const replaceVersionInAssemblyInfoFiles = (globPath, newVersion) => {
|
|
42
|
-
const files = glob.sync(globPath.replace(/\\/g, '/'));
|
|
43
|
-
files.forEach((file) => replaceVersionInAssemblyInfoFile(file, newVersion));
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export const replaceVersionInMsiFile = (path, newVersion) => {
|
|
47
|
-
console.log('Replacing version in MSI file', path);
|
|
48
|
-
const fileContents = readFileSync(path, 'utf-8');
|
|
49
|
-
const newFileContents = fileContents
|
|
50
|
-
.replace(
|
|
51
|
-
/<ROW Property="ProductVersion" Value="\d+\.\d+\.\d+"/g,
|
|
52
|
-
`<ROW Property="ProductVersion" Value="${newVersion}"`
|
|
53
|
-
)
|
|
54
|
-
.replace(
|
|
55
|
-
/<ROW Property="ProductCode" Value="1033:\{[0-9A-F-]{36}\}/g,
|
|
56
|
-
`<ROW Property="ProductCode" Value="1033:{${v4().toUpperCase()}}`
|
|
57
|
-
);
|
|
58
|
-
writeFileSync(path, newFileContents);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export const replaceVersionInMsiFiles = (globPath, newVersion) => {
|
|
62
|
-
const files = glob.sync(globPath.replace(/\\/g, '/'));
|
|
63
|
-
files.forEach((file) => replaceVersionInMsiFile(file, newVersion));
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
export const replaceVersionInPackageJsonFile = (path, newVersion) => {
|
|
67
|
-
console.log('Replacing version in package.json', path);
|
|
68
|
-
const fileContents = readFileSync(path, 'utf-8');
|
|
69
|
-
const newFileContents = fileContents.replace(
|
|
70
|
-
/"version": "\d+\.\d+\.\d+"/g,
|
|
71
|
-
`"version": "${newVersion}"`
|
|
72
|
-
);
|
|
73
|
-
writeFileSync(path, newFileContents);
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export const replaceVersionInPackageJsonFiles = (globPath, newVersion) => {
|
|
77
|
-
const files = glob.sync(globPath.replace(/\\/g, '/'), {
|
|
78
|
-
ignore: ['./node_modules/**', '**/node_modules/**'],
|
|
79
|
-
});
|
|
80
|
-
files.forEach((file) => replaceVersionInPackageJsonFile(file, newVersion));
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export const replaceVersionInEnvFile = (path, newVersion) => {
|
|
84
|
-
console.log('Replacing version in env file', path);
|
|
85
|
-
const fileContents = readFileSync(path, 'utf-8');
|
|
86
|
-
const newFileContents = fileContents.replace(
|
|
87
|
-
/APP_VERSION=\d+\.\d+\.\d+/g,
|
|
88
|
-
`APP_VERSION=${newVersion}`
|
|
89
|
-
);
|
|
90
|
-
writeFileSync(path, newFileContents);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export const replaceVersionInEnvFiles = (globPath, newVersion) => {
|
|
94
|
-
const files = glob.sync(globPath.replace(/\\/g, '/'));
|
|
95
|
-
files.forEach((file) => replaceVersionInEnvFile(file, newVersion));
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export const replaceVersionInGitLabCi = (path, newVersion) => {
|
|
99
|
-
console.log('Replacing version in GitLab CI file', path);
|
|
100
|
-
const fileContents = readFileSync(path, 'utf-8');
|
|
101
|
-
const newFileContents = fileContents.replace(
|
|
102
|
-
/APP_VERSION: \d+\.\d+\.\d+/g,
|
|
103
|
-
`APP_VERSION: ${newVersion}`
|
|
104
|
-
);
|
|
105
|
-
writeFileSync(path, newFileContents);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
export const getCurrentVersion = () => {
|
|
109
|
-
const packageJson = JSON.parse(
|
|
110
|
-
readFileSync(join(__dirname, 'package.json'), 'utf-8')
|
|
111
|
-
);
|
|
112
|
-
return packageJson.version;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
export const getUpdateTypeFromArgv = () => {
|
|
116
|
-
const [, , updateType] = process.argv;
|
|
117
|
-
if (!updateType) {
|
|
118
|
-
console.error('No version update type provided');
|
|
119
|
-
process.exit(1);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (!['major', 'minor', 'patch'].includes(updateType)) {
|
|
123
|
-
console.error(
|
|
124
|
-
'Invalid version update type : expected "major", "minor" or "patch"'
|
|
125
|
-
);
|
|
126
|
-
process.exit(1);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return updateType;
|
|
130
|
-
};
|
|
1
|
+
import * as glob from 'glob';
|
|
2
|
+
|
|
3
|
+
import { readFileSync, writeFileSync } from 'fs';
|
|
4
|
+
|
|
5
|
+
import { cwd } from 'process';
|
|
6
|
+
import { join } from 'path';
|
|
7
|
+
|
|
8
|
+
const __dirname = cwd();
|
|
9
|
+
|
|
10
|
+
export const replaceVersionInCSharpProject = (path, newVersion) => {
|
|
11
|
+
console.log('Replacing version in C# project file', path);
|
|
12
|
+
const fileContents = readFileSync(path, 'utf-8');
|
|
13
|
+
const newFileContents = fileContents
|
|
14
|
+
.replace(/<Version>.*<\/Version>/g, `<Version>${newVersion}</Version>`)
|
|
15
|
+
.replace(
|
|
16
|
+
/<AssemblyVersion>.*<\/AssemblyVersion>/g,
|
|
17
|
+
`<AssemblyVersion>${newVersion}</AssemblyVersion>`
|
|
18
|
+
)
|
|
19
|
+
.replace(
|
|
20
|
+
/<FileVersion>.*<\/FileVersion>/g,
|
|
21
|
+
`<FileVersion>${newVersion}</FileVersion>`
|
|
22
|
+
);
|
|
23
|
+
writeFileSync(path, newFileContents);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const replaceVersionInCSharpProjects = (globPath, newVersion) => {
|
|
27
|
+
const files = glob.sync(globPath.replace(/\\/g, '/'));
|
|
28
|
+
files.forEach((file) => replaceVersionInCSharpProject(file, newVersion));
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const replaceVersionInAssemblyInfoFile = (path, newVersion) => {
|
|
32
|
+
console.log('Replacing version in C# AssemblyInfo file', path);
|
|
33
|
+
const fileContents = readFileSync(path, 'utf-8');
|
|
34
|
+
const newFileContents = fileContents.replace(
|
|
35
|
+
/Version\("\d+\.\d+\.\d+"\)\]/g,
|
|
36
|
+
`Version("${newVersion}")]`
|
|
37
|
+
);
|
|
38
|
+
writeFileSync(path, newFileContents);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const replaceVersionInAssemblyInfoFiles = (globPath, newVersion) => {
|
|
42
|
+
const files = glob.sync(globPath.replace(/\\/g, '/'));
|
|
43
|
+
files.forEach((file) => replaceVersionInAssemblyInfoFile(file, newVersion));
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const replaceVersionInMsiFile = (path, newVersion) => {
|
|
47
|
+
console.log('Replacing version in MSI file', path);
|
|
48
|
+
const fileContents = readFileSync(path, 'utf-8');
|
|
49
|
+
const newFileContents = fileContents
|
|
50
|
+
.replace(
|
|
51
|
+
/<ROW Property="ProductVersion" Value="\d+\.\d+\.\d+"/g,
|
|
52
|
+
`<ROW Property="ProductVersion" Value="${newVersion}"`
|
|
53
|
+
)
|
|
54
|
+
.replace(
|
|
55
|
+
/<ROW Property="ProductCode" Value="1033:\{[0-9A-F-]{36}\}/g,
|
|
56
|
+
`<ROW Property="ProductCode" Value="1033:{${v4().toUpperCase()}}`
|
|
57
|
+
);
|
|
58
|
+
writeFileSync(path, newFileContents);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const replaceVersionInMsiFiles = (globPath, newVersion) => {
|
|
62
|
+
const files = glob.sync(globPath.replace(/\\/g, '/'));
|
|
63
|
+
files.forEach((file) => replaceVersionInMsiFile(file, newVersion));
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const replaceVersionInPackageJsonFile = (path, newVersion) => {
|
|
67
|
+
console.log('Replacing version in package.json', path);
|
|
68
|
+
const fileContents = readFileSync(path, 'utf-8');
|
|
69
|
+
const newFileContents = fileContents.replace(
|
|
70
|
+
/"version": "\d+\.\d+\.\d+"/g,
|
|
71
|
+
`"version": "${newVersion}"`
|
|
72
|
+
);
|
|
73
|
+
writeFileSync(path, newFileContents);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const replaceVersionInPackageJsonFiles = (globPath, newVersion) => {
|
|
77
|
+
const files = glob.sync(globPath.replace(/\\/g, '/'), {
|
|
78
|
+
ignore: ['./node_modules/**', '**/node_modules/**'],
|
|
79
|
+
});
|
|
80
|
+
files.forEach((file) => replaceVersionInPackageJsonFile(file, newVersion));
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const replaceVersionInEnvFile = (path, newVersion) => {
|
|
84
|
+
console.log('Replacing version in env file', path);
|
|
85
|
+
const fileContents = readFileSync(path, 'utf-8');
|
|
86
|
+
const newFileContents = fileContents.replace(
|
|
87
|
+
/APP_VERSION=\d+\.\d+\.\d+/g,
|
|
88
|
+
`APP_VERSION=${newVersion}`
|
|
89
|
+
);
|
|
90
|
+
writeFileSync(path, newFileContents);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const replaceVersionInEnvFiles = (globPath, newVersion) => {
|
|
94
|
+
const files = glob.sync(globPath.replace(/\\/g, '/'));
|
|
95
|
+
files.forEach((file) => replaceVersionInEnvFile(file, newVersion));
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export const replaceVersionInGitLabCi = (path, newVersion) => {
|
|
99
|
+
console.log('Replacing version in GitLab CI file', path);
|
|
100
|
+
const fileContents = readFileSync(path, 'utf-8');
|
|
101
|
+
const newFileContents = fileContents.replace(
|
|
102
|
+
/APP_VERSION: \d+\.\d+\.\d+/g,
|
|
103
|
+
`APP_VERSION: ${newVersion}`
|
|
104
|
+
);
|
|
105
|
+
writeFileSync(path, newFileContents);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export const getCurrentVersion = () => {
|
|
109
|
+
const packageJson = JSON.parse(
|
|
110
|
+
readFileSync(join(__dirname, 'package.json'), 'utf-8')
|
|
111
|
+
);
|
|
112
|
+
return packageJson.version;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const getUpdateTypeFromArgv = () => {
|
|
116
|
+
const [, , updateType] = process.argv;
|
|
117
|
+
if (!updateType) {
|
|
118
|
+
console.error('No version update type provided');
|
|
119
|
+
process.exit(1);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (!['major', 'minor', 'patch'].includes(updateType)) {
|
|
123
|
+
console.error(
|
|
124
|
+
'Invalid version update type : expected "major", "minor" or "patch"'
|
|
125
|
+
);
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return updateType;
|
|
130
|
+
};
|
package/node/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './helpers/versions.mjs';
|
|
2
|
-
|
|
3
|
-
export * from './commit-release.mjs';
|
|
4
|
-
export * from './nuget-publish.mjs';
|
|
5
|
-
export * from './update-version.mjs';
|
|
1
|
+
export * from './helpers/versions.mjs';
|
|
2
|
+
|
|
3
|
+
export * from './commit-release.mjs';
|
|
4
|
+
export * from './nuget-publish.mjs';
|
|
5
|
+
export * from './update-version.mjs';
|