@addev-be/framework-utils 2.7.4 → 2.7.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/bin/commit-release.mjs +12 -12
- package/bin/nuget-publish.mjs +11 -11
- package/bin/update-version.mjs +7 -7
- package/eslint/node.config.mjs +17 -17
- package/eslint/react.config.mjs +51 -51
- package/node/commit-release.mjs +21 -21
- package/node/create-jira-version.mjs +32 -32
- package/node/helpers/docker.mjs +97 -97
- package/node/helpers/jira.mjs +56 -56
- package/node/helpers/versions.mjs +150 -150
- package/node/nuget-publish.mjs +30 -30
- package/node/update-version.mjs +55 -55
- package/package.json +1 -1
package/bin/commit-release.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { commitRelease } from '../node/commit-release.mjs';
|
|
4
|
-
import { runPreReleaseChecks } from '../node/pre-release-checks.mjs';
|
|
5
|
-
|
|
6
|
-
// Run pre-release checks first (UI build is mandatory)
|
|
7
|
-
runPreReleaseChecks({
|
|
8
|
-
skipBackend: true, // Backend check is optional for releases
|
|
9
|
-
skipLint: false, // Keep linting check
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
commitRelease();
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { commitRelease } from '../node/commit-release.mjs';
|
|
4
|
+
import { runPreReleaseChecks } from '../node/pre-release-checks.mjs';
|
|
5
|
+
|
|
6
|
+
// Run pre-release checks first (UI build is mandatory)
|
|
7
|
+
runPreReleaseChecks({
|
|
8
|
+
skipBackend: true, // Backend check is optional for releases
|
|
9
|
+
skipLint: false, // Keep linting check
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
commitRelease();
|
package/bin/nuget-publish.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { getCurrentVersion } from '../node/helpers/versions.mjs';
|
|
4
|
-
import { publishNugetPackageToRemoteServer } from '../node/nuget-publish.mjs';
|
|
5
|
-
|
|
6
|
-
const currentVersion = getCurrentVersion();
|
|
7
|
-
const backendPackagePath = `./packages/backend/bin/Release/ADDEV.Framework.Backend.${currentVersion}.nupkg`;
|
|
8
|
-
const testingPackagePath = `./packages/testing/bin/Debug/ADDEV.Framework.Testing.${currentVersion}.nupkg`;
|
|
9
|
-
|
|
10
|
-
await publishNugetPackageToRemoteServer(backendPackagePath);
|
|
11
|
-
await publishNugetPackageToRemoteServer(testingPackagePath);
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { getCurrentVersion } from '../node/helpers/versions.mjs';
|
|
4
|
+
import { publishNugetPackageToRemoteServer } from '../node/nuget-publish.mjs';
|
|
5
|
+
|
|
6
|
+
const currentVersion = getCurrentVersion();
|
|
7
|
+
const backendPackagePath = `./packages/backend/bin/Release/ADDEV.Framework.Backend.${currentVersion}.nupkg`;
|
|
8
|
+
const testingPackagePath = `./packages/testing/bin/Debug/ADDEV.Framework.Testing.${currentVersion}.nupkg`;
|
|
9
|
+
|
|
10
|
+
await publishNugetPackageToRemoteServer(backendPackagePath);
|
|
11
|
+
await publishNugetPackageToRemoteServer(testingPackagePath);
|
package/bin/update-version.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { getUpdateTypeFromArgv } from '../node/helpers/versions.mjs';
|
|
4
|
-
import { updatePackagesVersion } from '../node/update-version.mjs';
|
|
5
|
-
|
|
6
|
-
const updateType = getUpdateTypeFromArgv();
|
|
7
|
-
updatePackagesVersion(updateType);
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { getUpdateTypeFromArgv } from '../node/helpers/versions.mjs';
|
|
4
|
+
import { updatePackagesVersion } from '../node/update-version.mjs';
|
|
5
|
+
|
|
6
|
+
const updateType = getUpdateTypeFromArgv();
|
|
7
|
+
updatePackagesVersion(updateType);
|
package/eslint/node.config.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { defineConfig } from 'eslint/config';
|
|
2
|
-
import globals from 'globals';
|
|
3
|
-
import js from '@eslint/js';
|
|
4
|
-
import tseslint from 'typescript-eslint';
|
|
5
|
-
|
|
6
|
-
export const eslintNodeConfig = defineConfig([
|
|
7
|
-
{
|
|
8
|
-
files: ['**/*.{js,mjs,cjs,ts,mts,cts}'],
|
|
9
|
-
plugins: { js },
|
|
10
|
-
extends: ['js/recommended'],
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
files: ['**/*.{js,mjs,cjs,ts,mts,cts}'],
|
|
14
|
-
languageOptions: { globals: globals.browser },
|
|
15
|
-
},
|
|
16
|
-
tseslint.configs.recommended,
|
|
17
|
-
]);
|
|
1
|
+
import { defineConfig } from 'eslint/config';
|
|
2
|
+
import globals from 'globals';
|
|
3
|
+
import js from '@eslint/js';
|
|
4
|
+
import tseslint from 'typescript-eslint';
|
|
5
|
+
|
|
6
|
+
export const eslintNodeConfig = defineConfig([
|
|
7
|
+
{
|
|
8
|
+
files: ['**/*.{js,mjs,cjs,ts,mts,cts}'],
|
|
9
|
+
plugins: { js },
|
|
10
|
+
extends: ['js/recommended'],
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
files: ['**/*.{js,mjs,cjs,ts,mts,cts}'],
|
|
14
|
+
languageOptions: { globals: globals.browser },
|
|
15
|
+
},
|
|
16
|
+
tseslint.configs.recommended,
|
|
17
|
+
]);
|
package/eslint/react.config.mjs
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import * as reactHooks from 'eslint-plugin-react-hooks';
|
|
2
|
-
import * as reactRefresh from 'eslint-plugin-react-refresh';
|
|
3
|
-
|
|
4
|
-
import { defineConfig } from 'eslint/config';
|
|
5
|
-
import globals from 'globals';
|
|
6
|
-
import importZod from 'eslint-plugin-import-zod';
|
|
7
|
-
import js from '@eslint/js';
|
|
8
|
-
import pluginReact from 'eslint-plugin-react';
|
|
9
|
-
import tseslint from 'typescript-eslint';
|
|
10
|
-
|
|
11
|
-
/** @typedef {{ exhaustiveDepsAdditionalHooks?: string; }} ReactConfigOptions*/
|
|
12
|
-
|
|
13
|
-
/** @type {ReactConfigOptions} */
|
|
14
|
-
const defaultOptions = {};
|
|
15
|
-
|
|
16
|
-
export const createEslintReactConfig = (options = defaultOptions) =>
|
|
17
|
-
defineConfig([
|
|
18
|
-
{
|
|
19
|
-
files: ['**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
20
|
-
plugins: { js },
|
|
21
|
-
extends: ['js/recommended'],
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
files: ['**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
25
|
-
languageOptions: { globals: globals.browser },
|
|
26
|
-
},
|
|
27
|
-
tseslint.configs.recommended,
|
|
28
|
-
pluginReact.configs.flat.recommended,
|
|
29
|
-
reactHooks.configs['recommended-latest'],
|
|
30
|
-
reactRefresh.configs.vite,
|
|
31
|
-
importZod.configs.recommended,
|
|
32
|
-
|
|
33
|
-
{
|
|
34
|
-
rules: {
|
|
35
|
-
'@typescript-eslint/no-empty-function': 'off',
|
|
36
|
-
'@typescript-eslint/no-empty-object-type': 'off',
|
|
37
|
-
'react/no-unescaped-entities': 'off',
|
|
38
|
-
'react/prop-types': 'off',
|
|
39
|
-
'react/react-in-jsx-scope': 'off',
|
|
40
|
-
'react-hooks/exhaustive-deps': [
|
|
41
|
-
'error',
|
|
42
|
-
{
|
|
43
|
-
additionalHooks: options.exhaustiveDepsAdditionalHooks,
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
'react-refresh/only-export-components': 'off',
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
]);
|
|
50
|
-
|
|
51
|
-
export const eslintReactConfig = createEslintReactConfig();
|
|
1
|
+
import * as reactHooks from 'eslint-plugin-react-hooks';
|
|
2
|
+
import * as reactRefresh from 'eslint-plugin-react-refresh';
|
|
3
|
+
|
|
4
|
+
import { defineConfig } from 'eslint/config';
|
|
5
|
+
import globals from 'globals';
|
|
6
|
+
import importZod from 'eslint-plugin-import-zod';
|
|
7
|
+
import js from '@eslint/js';
|
|
8
|
+
import pluginReact from 'eslint-plugin-react';
|
|
9
|
+
import tseslint from 'typescript-eslint';
|
|
10
|
+
|
|
11
|
+
/** @typedef {{ exhaustiveDepsAdditionalHooks?: string; }} ReactConfigOptions*/
|
|
12
|
+
|
|
13
|
+
/** @type {ReactConfigOptions} */
|
|
14
|
+
const defaultOptions = {};
|
|
15
|
+
|
|
16
|
+
export const createEslintReactConfig = (options = defaultOptions) =>
|
|
17
|
+
defineConfig([
|
|
18
|
+
{
|
|
19
|
+
files: ['**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
20
|
+
plugins: { js },
|
|
21
|
+
extends: ['js/recommended'],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
files: ['**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
25
|
+
languageOptions: { globals: globals.browser },
|
|
26
|
+
},
|
|
27
|
+
tseslint.configs.recommended,
|
|
28
|
+
pluginReact.configs.flat.recommended,
|
|
29
|
+
reactHooks.configs['recommended-latest'],
|
|
30
|
+
reactRefresh.configs.vite,
|
|
31
|
+
importZod.configs.recommended,
|
|
32
|
+
|
|
33
|
+
{
|
|
34
|
+
rules: {
|
|
35
|
+
'@typescript-eslint/no-empty-function': 'off',
|
|
36
|
+
'@typescript-eslint/no-empty-object-type': 'off',
|
|
37
|
+
'react/no-unescaped-entities': 'off',
|
|
38
|
+
'react/prop-types': 'off',
|
|
39
|
+
'react/react-in-jsx-scope': 'off',
|
|
40
|
+
'react-hooks/exhaustive-deps': [
|
|
41
|
+
'error',
|
|
42
|
+
{
|
|
43
|
+
additionalHooks: options.exhaustiveDepsAdditionalHooks,
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
'react-refresh/only-export-components': 'off',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
]);
|
|
50
|
+
|
|
51
|
+
export const eslintReactConfig = createEslintReactConfig();
|
package/node/commit-release.mjs
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { execSync } from 'child_process';
|
|
2
|
-
import { getCurrentVersion } from './helpers/versions.mjs';
|
|
3
|
-
import { runPreReleaseChecks } from './pre-release-checks.mjs';
|
|
4
|
-
|
|
5
|
-
export const commitRelease = () => {
|
|
6
|
-
const newVersion = getCurrentVersion();
|
|
7
|
-
|
|
8
|
-
execSync('git add .', { stdio: 'inherit' });
|
|
9
|
-
execSync(`git commit -m "chore: release ${newVersion}"`, {
|
|
10
|
-
stdio: 'inherit',
|
|
11
|
-
});
|
|
12
|
-
execSync(`git tag -a ${newVersion} -m "${newVersion}"`, {
|
|
13
|
-
stdio: 'inherit',
|
|
14
|
-
});
|
|
15
|
-
execSync(`git push origin`, {
|
|
16
|
-
stdio: 'inherit',
|
|
17
|
-
});
|
|
18
|
-
execSync(`git push origin --tags`, {
|
|
19
|
-
stdio: 'inherit',
|
|
20
|
-
});
|
|
21
|
-
};
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
import { getCurrentVersion } from './helpers/versions.mjs';
|
|
3
|
+
import { runPreReleaseChecks } from './pre-release-checks.mjs';
|
|
4
|
+
|
|
5
|
+
export const commitRelease = () => {
|
|
6
|
+
const newVersion = getCurrentVersion();
|
|
7
|
+
|
|
8
|
+
execSync('git add .', { stdio: 'inherit' });
|
|
9
|
+
execSync(`git commit -m "chore: release ${newVersion}"`, {
|
|
10
|
+
stdio: 'inherit',
|
|
11
|
+
});
|
|
12
|
+
execSync(`git tag -a ${newVersion} -m "${newVersion}"`, {
|
|
13
|
+
stdio: 'inherit',
|
|
14
|
+
});
|
|
15
|
+
execSync(`git push origin`, {
|
|
16
|
+
stdio: 'inherit',
|
|
17
|
+
});
|
|
18
|
+
execSync(`git push origin --tags`, {
|
|
19
|
+
stdio: 'inherit',
|
|
20
|
+
});
|
|
21
|
+
};
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createJiraVersionInApi,
|
|
3
|
-
getJiraProjectIdFromApi,
|
|
4
|
-
} from './helpers/jira.mjs';
|
|
5
|
-
|
|
6
|
-
export const createJiraVersion = async (
|
|
7
|
-
jiraUrl,
|
|
8
|
-
projectKey,
|
|
9
|
-
version,
|
|
10
|
-
email,
|
|
11
|
-
token
|
|
12
|
-
) => {
|
|
13
|
-
const projectId = await getJiraProjectIdFromApi(
|
|
14
|
-
jiraUrl,
|
|
15
|
-
projectKey,
|
|
16
|
-
email,
|
|
17
|
-
token
|
|
18
|
-
);
|
|
19
|
-
if (!projectId) {
|
|
20
|
-
throw new Error(`Could not find Jira project with key ${projectKey}`);
|
|
21
|
-
}
|
|
22
|
-
const success = await createJiraVersionInApi(
|
|
23
|
-
jiraUrl,
|
|
24
|
-
projectId,
|
|
25
|
-
version,
|
|
26
|
-
email,
|
|
27
|
-
token
|
|
28
|
-
);
|
|
29
|
-
if (!success) {
|
|
30
|
-
throw new Error(`Could not create Jira version ${version}`);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
createJiraVersionInApi,
|
|
3
|
+
getJiraProjectIdFromApi,
|
|
4
|
+
} from './helpers/jira.mjs';
|
|
5
|
+
|
|
6
|
+
export const createJiraVersion = async (
|
|
7
|
+
jiraUrl,
|
|
8
|
+
projectKey,
|
|
9
|
+
version,
|
|
10
|
+
email,
|
|
11
|
+
token
|
|
12
|
+
) => {
|
|
13
|
+
const projectId = await getJiraProjectIdFromApi(
|
|
14
|
+
jiraUrl,
|
|
15
|
+
projectKey,
|
|
16
|
+
email,
|
|
17
|
+
token
|
|
18
|
+
);
|
|
19
|
+
if (!projectId) {
|
|
20
|
+
throw new Error(`Could not find Jira project with key ${projectKey}`);
|
|
21
|
+
}
|
|
22
|
+
const success = await createJiraVersionInApi(
|
|
23
|
+
jiraUrl,
|
|
24
|
+
projectId,
|
|
25
|
+
version,
|
|
26
|
+
email,
|
|
27
|
+
token
|
|
28
|
+
);
|
|
29
|
+
if (!success) {
|
|
30
|
+
throw new Error(`Could not create Jira version ${version}`);
|
|
31
|
+
}
|
|
32
|
+
};
|
package/node/helpers/docker.mjs
CHANGED
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { spawn } from 'child_process';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Builds a Docker image from a specified local directory.
|
|
6
|
-
* @param {string} directory - The path to the directory containing the Dockerfile.
|
|
7
|
-
* @param {string} tag - Image tag (e.g., 'my-image:latest').
|
|
8
|
-
* @returns {Promise<void>} Resolves when the build is complete.
|
|
9
|
-
*/
|
|
10
|
-
export async function buildDockerImage(imageFile, tag, registryUrl) {
|
|
11
|
-
return new Promise((resolve, reject) => {
|
|
12
|
-
const args = [
|
|
13
|
-
'build',
|
|
14
|
-
'-t',
|
|
15
|
-
`${registryUrl ? registryUrl + '/' : ''}${tag}`,
|
|
16
|
-
'-f',
|
|
17
|
-
imageFile,
|
|
18
|
-
'.',
|
|
19
|
-
];
|
|
20
|
-
const buildProcess = spawn('docker', args, {
|
|
21
|
-
stdio: 'inherit',
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
buildProcess.on('close', (code) => {
|
|
25
|
-
if (code === 0) {
|
|
26
|
-
resolve();
|
|
27
|
-
} else {
|
|
28
|
-
reject(new Error(`Docker build failed with exit code ${code}`));
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
buildProcess.on('error', (err) => {
|
|
33
|
-
reject(err);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Pushes a Docker image to a Docker server.
|
|
40
|
-
* @param {string} tag - The image tag to push (e.g., 'my-image:latest' or 'myregistry.example.com/my-image:latest').
|
|
41
|
-
* @param {string} [registryUrl] - Optional custom registry URL (e.g., 'myregistry.example.com').
|
|
42
|
-
* @returns {Promise<void>} Resolves when the push is complete.
|
|
43
|
-
*/
|
|
44
|
-
export async function pushDockerImage(tag, registryUrl) {
|
|
45
|
-
return new Promise((resolve, reject) => {
|
|
46
|
-
let imageTag = tag;
|
|
47
|
-
// If a custom registry URL is provided and not already in the tag, prepend it
|
|
48
|
-
if (registryUrl && !tag.startsWith(registryUrl)) {
|
|
49
|
-
// Remove trailing slash from registryUrl if present
|
|
50
|
-
const cleanRegistryUrl = registryUrl.replace(/\/$/, '');
|
|
51
|
-
imageTag = `${cleanRegistryUrl}/${tag}`;
|
|
52
|
-
}
|
|
53
|
-
const args = ['push', imageTag];
|
|
54
|
-
const pushProcess = spawn('docker', args, {
|
|
55
|
-
stdio: 'inherit',
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
pushProcess.on('close', (code) => {
|
|
59
|
-
if (code === 0) {
|
|
60
|
-
resolve();
|
|
61
|
-
} else {
|
|
62
|
-
reject(new Error(`Docker push failed with exit code ${code}`));
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
pushProcess.on('error', (err) => {
|
|
67
|
-
reject(err);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Tags an existing Docker image with a new tag.
|
|
74
|
-
* @param {string} existingTag - The current image tag (e.g., 'my-image:latest').
|
|
75
|
-
* @param {string} newTag - The new tag to apply (e.g., 'my-image:prod').
|
|
76
|
-
* @returns {Promise<void>} Resolves when the tagging is complete.
|
|
77
|
-
*/
|
|
78
|
-
export async function tagDockerImage(existingTag, newTag) {
|
|
79
|
-
return new Promise((resolve, reject) => {
|
|
80
|
-
const args = ['tag', existingTag, newTag];
|
|
81
|
-
const tagProcess = spawn('docker', args, {
|
|
82
|
-
stdio: 'inherit',
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
tagProcess.on('close', (code) => {
|
|
86
|
-
if (code === 0) {
|
|
87
|
-
resolve();
|
|
88
|
-
} else {
|
|
89
|
-
reject(new Error(`Docker tag failed with exit code ${code}`));
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
tagProcess.on('error', (err) => {
|
|
94
|
-
reject(err);
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
}
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { spawn } from 'child_process';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Builds a Docker image from a specified local directory.
|
|
6
|
+
* @param {string} directory - The path to the directory containing the Dockerfile.
|
|
7
|
+
* @param {string} tag - Image tag (e.g., 'my-image:latest').
|
|
8
|
+
* @returns {Promise<void>} Resolves when the build is complete.
|
|
9
|
+
*/
|
|
10
|
+
export async function buildDockerImage(imageFile, tag, registryUrl) {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
const args = [
|
|
13
|
+
'build',
|
|
14
|
+
'-t',
|
|
15
|
+
`${registryUrl ? registryUrl + '/' : ''}${tag}`,
|
|
16
|
+
'-f',
|
|
17
|
+
imageFile,
|
|
18
|
+
'.',
|
|
19
|
+
];
|
|
20
|
+
const buildProcess = spawn('docker', args, {
|
|
21
|
+
stdio: 'inherit',
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
buildProcess.on('close', (code) => {
|
|
25
|
+
if (code === 0) {
|
|
26
|
+
resolve();
|
|
27
|
+
} else {
|
|
28
|
+
reject(new Error(`Docker build failed with exit code ${code}`));
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
buildProcess.on('error', (err) => {
|
|
33
|
+
reject(err);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Pushes a Docker image to a Docker server.
|
|
40
|
+
* @param {string} tag - The image tag to push (e.g., 'my-image:latest' or 'myregistry.example.com/my-image:latest').
|
|
41
|
+
* @param {string} [registryUrl] - Optional custom registry URL (e.g., 'myregistry.example.com').
|
|
42
|
+
* @returns {Promise<void>} Resolves when the push is complete.
|
|
43
|
+
*/
|
|
44
|
+
export async function pushDockerImage(tag, registryUrl) {
|
|
45
|
+
return new Promise((resolve, reject) => {
|
|
46
|
+
let imageTag = tag;
|
|
47
|
+
// If a custom registry URL is provided and not already in the tag, prepend it
|
|
48
|
+
if (registryUrl && !tag.startsWith(registryUrl)) {
|
|
49
|
+
// Remove trailing slash from registryUrl if present
|
|
50
|
+
const cleanRegistryUrl = registryUrl.replace(/\/$/, '');
|
|
51
|
+
imageTag = `${cleanRegistryUrl}/${tag}`;
|
|
52
|
+
}
|
|
53
|
+
const args = ['push', imageTag];
|
|
54
|
+
const pushProcess = spawn('docker', args, {
|
|
55
|
+
stdio: 'inherit',
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
pushProcess.on('close', (code) => {
|
|
59
|
+
if (code === 0) {
|
|
60
|
+
resolve();
|
|
61
|
+
} else {
|
|
62
|
+
reject(new Error(`Docker push failed with exit code ${code}`));
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
pushProcess.on('error', (err) => {
|
|
67
|
+
reject(err);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Tags an existing Docker image with a new tag.
|
|
74
|
+
* @param {string} existingTag - The current image tag (e.g., 'my-image:latest').
|
|
75
|
+
* @param {string} newTag - The new tag to apply (e.g., 'my-image:prod').
|
|
76
|
+
* @returns {Promise<void>} Resolves when the tagging is complete.
|
|
77
|
+
*/
|
|
78
|
+
export async function tagDockerImage(existingTag, newTag) {
|
|
79
|
+
return new Promise((resolve, reject) => {
|
|
80
|
+
const args = ['tag', existingTag, newTag];
|
|
81
|
+
const tagProcess = spawn('docker', args, {
|
|
82
|
+
stdio: 'inherit',
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
tagProcess.on('close', (code) => {
|
|
86
|
+
if (code === 0) {
|
|
87
|
+
resolve();
|
|
88
|
+
} else {
|
|
89
|
+
reject(new Error(`Docker tag failed with exit code ${code}`));
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
tagProcess.on('error', (err) => {
|
|
94
|
+
reject(err);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
}
|
package/node/helpers/jira.mjs
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get Jira Project ID from Project Key
|
|
3
|
-
* @param {string} jiraUrl
|
|
4
|
-
* @param {string} projectKey
|
|
5
|
-
* @returns
|
|
6
|
-
*/
|
|
7
|
-
export const getJiraProjectIdFromApi = async (
|
|
8
|
-
jiraUrl,
|
|
9
|
-
projectKey,
|
|
10
|
-
email,
|
|
11
|
-
token
|
|
12
|
-
) => {
|
|
13
|
-
const response = await fetch(
|
|
14
|
-
`${jiraUrl.trimEnd('/')}/rest/api/3/project/${projectKey}`,
|
|
15
|
-
{
|
|
16
|
-
method: 'GET',
|
|
17
|
-
headers: {
|
|
18
|
-
Authorization: `Basic ${Buffer.from(email + ':' + token).toString(
|
|
19
|
-
'base64'
|
|
20
|
-
)}`,
|
|
21
|
-
Accept: 'application/json',
|
|
22
|
-
},
|
|
23
|
-
}
|
|
24
|
-
).then((response) => response.json());
|
|
25
|
-
|
|
26
|
-
return response.id;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const createJiraVersionInApi = async (
|
|
30
|
-
jiraUrl,
|
|
31
|
-
projectId,
|
|
32
|
-
name,
|
|
33
|
-
email,
|
|
34
|
-
token
|
|
35
|
-
) => {
|
|
36
|
-
const response = await fetch(`${jiraUrl.trimEnd('/')}/rest/api/3/version`, {
|
|
37
|
-
method: 'POST',
|
|
38
|
-
headers: {
|
|
39
|
-
Authorization: `Basic ${Buffer.from(email + ':' + token).toString(
|
|
40
|
-
'base64'
|
|
41
|
-
)}`,
|
|
42
|
-
Accept: 'application/json',
|
|
43
|
-
'Content-Type': 'application/json',
|
|
44
|
-
},
|
|
45
|
-
body: JSON.stringify({
|
|
46
|
-
archived: false,
|
|
47
|
-
description: `GitLab release ${name}`,
|
|
48
|
-
name,
|
|
49
|
-
projectId,
|
|
50
|
-
releaseDate: new Date().toISOString().split('T')[0],
|
|
51
|
-
released: false,
|
|
52
|
-
}),
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
return response.ok;
|
|
56
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Get Jira Project ID from Project Key
|
|
3
|
+
* @param {string} jiraUrl
|
|
4
|
+
* @param {string} projectKey
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export const getJiraProjectIdFromApi = async (
|
|
8
|
+
jiraUrl,
|
|
9
|
+
projectKey,
|
|
10
|
+
email,
|
|
11
|
+
token
|
|
12
|
+
) => {
|
|
13
|
+
const response = await fetch(
|
|
14
|
+
`${jiraUrl.trimEnd('/')}/rest/api/3/project/${projectKey}`,
|
|
15
|
+
{
|
|
16
|
+
method: 'GET',
|
|
17
|
+
headers: {
|
|
18
|
+
Authorization: `Basic ${Buffer.from(email + ':' + token).toString(
|
|
19
|
+
'base64'
|
|
20
|
+
)}`,
|
|
21
|
+
Accept: 'application/json',
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
).then((response) => response.json());
|
|
25
|
+
|
|
26
|
+
return response.id;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const createJiraVersionInApi = async (
|
|
30
|
+
jiraUrl,
|
|
31
|
+
projectId,
|
|
32
|
+
name,
|
|
33
|
+
email,
|
|
34
|
+
token
|
|
35
|
+
) => {
|
|
36
|
+
const response = await fetch(`${jiraUrl.trimEnd('/')}/rest/api/3/version`, {
|
|
37
|
+
method: 'POST',
|
|
38
|
+
headers: {
|
|
39
|
+
Authorization: `Basic ${Buffer.from(email + ':' + token).toString(
|
|
40
|
+
'base64'
|
|
41
|
+
)}`,
|
|
42
|
+
Accept: 'application/json',
|
|
43
|
+
'Content-Type': 'application/json',
|
|
44
|
+
},
|
|
45
|
+
body: JSON.stringify({
|
|
46
|
+
archived: false,
|
|
47
|
+
description: `GitLab release ${name}`,
|
|
48
|
+
name,
|
|
49
|
+
projectId,
|
|
50
|
+
releaseDate: new Date().toISOString().split('T')[0],
|
|
51
|
+
released: false,
|
|
52
|
+
}),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
return response.ok;
|
|
56
|
+
};
|
|
@@ -1,150 +1,150 @@
|
|
|
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
|
-
import { v4 } from 'uuid';
|
|
8
|
-
|
|
9
|
-
const __dirname = cwd();
|
|
10
|
-
|
|
11
|
-
export const replaceVersionInCSharpProject = (path, newVersion) => {
|
|
12
|
-
console.log('Replacing version in C# project file', path);
|
|
13
|
-
const fileContents = readFileSync(path, 'utf-8');
|
|
14
|
-
const newFileContents = fileContents
|
|
15
|
-
.replace(/<Version>.*<\/Version>/g, `<Version>${newVersion}</Version>`)
|
|
16
|
-
.replace(
|
|
17
|
-
/<AssemblyVersion>.*<\/AssemblyVersion>/g,
|
|
18
|
-
`<AssemblyVersion>${newVersion}</AssemblyVersion>`
|
|
19
|
-
)
|
|
20
|
-
.replace(
|
|
21
|
-
/<FileVersion>.*<\/FileVersion>/g,
|
|
22
|
-
`<FileVersion>${newVersion}</FileVersion>`
|
|
23
|
-
);
|
|
24
|
-
writeFileSync(path, newFileContents);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const replaceVersionInCSharpProjects = (globPath, newVersion) => {
|
|
28
|
-
const files = glob.sync(globPath.replace(/\\/g, '/'));
|
|
29
|
-
files.forEach((file) => replaceVersionInCSharpProject(file, newVersion));
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export const replaceVersionInAssemblyInfoFile = (path, newVersion) => {
|
|
33
|
-
console.log('Replacing version in C# AssemblyInfo file', path);
|
|
34
|
-
const fileContents = readFileSync(path, 'utf-8');
|
|
35
|
-
const newFileContents = fileContents.replace(
|
|
36
|
-
/Version\("\d+\.\d+\.\d+"\)\]/g,
|
|
37
|
-
`Version("${newVersion}")]`
|
|
38
|
-
);
|
|
39
|
-
writeFileSync(path, newFileContents);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const replaceVersionInAssemblyInfoFiles = (globPath, newVersion) => {
|
|
43
|
-
const files = glob.sync(globPath.replace(/\\/g, '/'));
|
|
44
|
-
files.forEach((file) => replaceVersionInAssemblyInfoFile(file, newVersion));
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export const replaceVersionInCSharpAssemblyInfo = (path, newVersion) => {
|
|
48
|
-
const fileContents = readFileSync(path, 'utf-8');
|
|
49
|
-
const newFileContents = fileContents.replace(
|
|
50
|
-
/Version\("\d+\.\d+\.\d+"\)\]/g,
|
|
51
|
-
`Version("${newVersion}")]`
|
|
52
|
-
);
|
|
53
|
-
writeFileSync(path, newFileContents);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export const replaceVersionInMsiFile = (path, newVersion) => {
|
|
57
|
-
console.log('Replacing version in MSI file', path);
|
|
58
|
-
const fileContents = readFileSync(path, 'utf-8');
|
|
59
|
-
const newFileContents = fileContents
|
|
60
|
-
.replace(
|
|
61
|
-
/<ROW Property="ProductVersion" Value="\d+\.\d+\.\d+"/g,
|
|
62
|
-
`<ROW Property="ProductVersion" Value="${newVersion}"`
|
|
63
|
-
)
|
|
64
|
-
.replace(
|
|
65
|
-
/<ROW Property="ProductCode" Value="1033:\{[0-9A-F-]{36}\}/g,
|
|
66
|
-
`<ROW Property="ProductCode" Value="1033:{${v4().toUpperCase()}}`
|
|
67
|
-
);
|
|
68
|
-
writeFileSync(path, newFileContents);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export const replaceVersionInMsiFiles = (globPath, newVersion) => {
|
|
72
|
-
const files = glob.sync(globPath.replace(/\\/g, '/'));
|
|
73
|
-
files.forEach((file) => replaceVersionInMsiFile(file, newVersion));
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export const replaceVersionInPackageJsonFile = (path, newVersion) => {
|
|
77
|
-
console.log('Replacing version in package.json', path);
|
|
78
|
-
const fileContents = readFileSync(path, 'utf-8');
|
|
79
|
-
const newFileContents = fileContents.replace(
|
|
80
|
-
/"version": "\d+\.\d+\.\d+"/g,
|
|
81
|
-
`"version": "${newVersion}"`
|
|
82
|
-
);
|
|
83
|
-
writeFileSync(path, newFileContents);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export const replaceVersionInPackageJsonFiles = (globPath, newVersion) => {
|
|
87
|
-
const files = glob.sync(globPath.replace(/\\/g, '/'), {
|
|
88
|
-
ignore: ['./node_modules/**', '**/node_modules/**'],
|
|
89
|
-
});
|
|
90
|
-
files.forEach((file) => replaceVersionInPackageJsonFile(file, newVersion));
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export const replaceVersionInEnvFile = (path, newVersion) => {
|
|
94
|
-
console.log('Replacing version in env file', path);
|
|
95
|
-
const fileContents = readFileSync(path, 'utf-8');
|
|
96
|
-
const newFileContents = fileContents.replace(
|
|
97
|
-
/APP_VERSION=\d+\.\d+\.\d+/g,
|
|
98
|
-
`APP_VERSION=${newVersion}`
|
|
99
|
-
);
|
|
100
|
-
writeFileSync(path, newFileContents);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export const replaceVersionInEnvFiles = (globPath, newVersion) => {
|
|
104
|
-
const files = glob.sync(globPath.replace(/\\/g, '/'));
|
|
105
|
-
files.forEach((file) => replaceVersionInEnvFile(file, newVersion));
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
export const replaceVersionInGitLabCi = (path, newVersion) => {
|
|
109
|
-
console.log('Replacing version in GitLab CI file', path);
|
|
110
|
-
const fileContents = readFileSync(path, 'utf-8');
|
|
111
|
-
const newFileContents = fileContents.replace(
|
|
112
|
-
/APP_VERSION: \d+\.\d+\.\d+/g,
|
|
113
|
-
`APP_VERSION: ${newVersion}`
|
|
114
|
-
);
|
|
115
|
-
writeFileSync(path, newFileContents);
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
export const replaceVersionInDockerCompose = (path, newVersion) => {
|
|
119
|
-
console.log('Replacing version in Docker Compose file', path);
|
|
120
|
-
const fileContents = readFileSync(path, 'utf-8');
|
|
121
|
-
const newFileContents = fileContents.replace(
|
|
122
|
-
/image: ([^\:]+):\d+\.\d+\.\d+/g,
|
|
123
|
-
`image: $1:${newVersion}`
|
|
124
|
-
);
|
|
125
|
-
writeFileSync(path, newFileContents);
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
export const getCurrentVersion = () => {
|
|
129
|
-
const packageJson = JSON.parse(
|
|
130
|
-
readFileSync(join(__dirname, 'package.json'), 'utf-8')
|
|
131
|
-
);
|
|
132
|
-
return packageJson.version;
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
export const getUpdateTypeFromArgv = () => {
|
|
136
|
-
const [, , updateType] = process.argv;
|
|
137
|
-
if (!updateType) {
|
|
138
|
-
console.error('No version update type provided');
|
|
139
|
-
process.exit(1);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (!['major', 'minor', 'patch'].includes(updateType)) {
|
|
143
|
-
console.error(
|
|
144
|
-
'Invalid version update type : expected "major", "minor" or "patch"'
|
|
145
|
-
);
|
|
146
|
-
process.exit(1);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return updateType;
|
|
150
|
-
};
|
|
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
|
+
import { v4 } from 'uuid';
|
|
8
|
+
|
|
9
|
+
const __dirname = cwd();
|
|
10
|
+
|
|
11
|
+
export const replaceVersionInCSharpProject = (path, newVersion) => {
|
|
12
|
+
console.log('Replacing version in C# project file', path);
|
|
13
|
+
const fileContents = readFileSync(path, 'utf-8');
|
|
14
|
+
const newFileContents = fileContents
|
|
15
|
+
.replace(/<Version>.*<\/Version>/g, `<Version>${newVersion}</Version>`)
|
|
16
|
+
.replace(
|
|
17
|
+
/<AssemblyVersion>.*<\/AssemblyVersion>/g,
|
|
18
|
+
`<AssemblyVersion>${newVersion}</AssemblyVersion>`
|
|
19
|
+
)
|
|
20
|
+
.replace(
|
|
21
|
+
/<FileVersion>.*<\/FileVersion>/g,
|
|
22
|
+
`<FileVersion>${newVersion}</FileVersion>`
|
|
23
|
+
);
|
|
24
|
+
writeFileSync(path, newFileContents);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const replaceVersionInCSharpProjects = (globPath, newVersion) => {
|
|
28
|
+
const files = glob.sync(globPath.replace(/\\/g, '/'));
|
|
29
|
+
files.forEach((file) => replaceVersionInCSharpProject(file, newVersion));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const replaceVersionInAssemblyInfoFile = (path, newVersion) => {
|
|
33
|
+
console.log('Replacing version in C# AssemblyInfo file', path);
|
|
34
|
+
const fileContents = readFileSync(path, 'utf-8');
|
|
35
|
+
const newFileContents = fileContents.replace(
|
|
36
|
+
/Version\("\d+\.\d+\.\d+"\)\]/g,
|
|
37
|
+
`Version("${newVersion}")]`
|
|
38
|
+
);
|
|
39
|
+
writeFileSync(path, newFileContents);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const replaceVersionInAssemblyInfoFiles = (globPath, newVersion) => {
|
|
43
|
+
const files = glob.sync(globPath.replace(/\\/g, '/'));
|
|
44
|
+
files.forEach((file) => replaceVersionInAssemblyInfoFile(file, newVersion));
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const replaceVersionInCSharpAssemblyInfo = (path, newVersion) => {
|
|
48
|
+
const fileContents = readFileSync(path, 'utf-8');
|
|
49
|
+
const newFileContents = fileContents.replace(
|
|
50
|
+
/Version\("\d+\.\d+\.\d+"\)\]/g,
|
|
51
|
+
`Version("${newVersion}")]`
|
|
52
|
+
);
|
|
53
|
+
writeFileSync(path, newFileContents);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const replaceVersionInMsiFile = (path, newVersion) => {
|
|
57
|
+
console.log('Replacing version in MSI file', path);
|
|
58
|
+
const fileContents = readFileSync(path, 'utf-8');
|
|
59
|
+
const newFileContents = fileContents
|
|
60
|
+
.replace(
|
|
61
|
+
/<ROW Property="ProductVersion" Value="\d+\.\d+\.\d+"/g,
|
|
62
|
+
`<ROW Property="ProductVersion" Value="${newVersion}"`
|
|
63
|
+
)
|
|
64
|
+
.replace(
|
|
65
|
+
/<ROW Property="ProductCode" Value="1033:\{[0-9A-F-]{36}\}/g,
|
|
66
|
+
`<ROW Property="ProductCode" Value="1033:{${v4().toUpperCase()}}`
|
|
67
|
+
);
|
|
68
|
+
writeFileSync(path, newFileContents);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const replaceVersionInMsiFiles = (globPath, newVersion) => {
|
|
72
|
+
const files = glob.sync(globPath.replace(/\\/g, '/'));
|
|
73
|
+
files.forEach((file) => replaceVersionInMsiFile(file, newVersion));
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const replaceVersionInPackageJsonFile = (path, newVersion) => {
|
|
77
|
+
console.log('Replacing version in package.json', path);
|
|
78
|
+
const fileContents = readFileSync(path, 'utf-8');
|
|
79
|
+
const newFileContents = fileContents.replace(
|
|
80
|
+
/"version": "\d+\.\d+\.\d+"/g,
|
|
81
|
+
`"version": "${newVersion}"`
|
|
82
|
+
);
|
|
83
|
+
writeFileSync(path, newFileContents);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const replaceVersionInPackageJsonFiles = (globPath, newVersion) => {
|
|
87
|
+
const files = glob.sync(globPath.replace(/\\/g, '/'), {
|
|
88
|
+
ignore: ['./node_modules/**', '**/node_modules/**'],
|
|
89
|
+
});
|
|
90
|
+
files.forEach((file) => replaceVersionInPackageJsonFile(file, newVersion));
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const replaceVersionInEnvFile = (path, newVersion) => {
|
|
94
|
+
console.log('Replacing version in env file', path);
|
|
95
|
+
const fileContents = readFileSync(path, 'utf-8');
|
|
96
|
+
const newFileContents = fileContents.replace(
|
|
97
|
+
/APP_VERSION=\d+\.\d+\.\d+/g,
|
|
98
|
+
`APP_VERSION=${newVersion}`
|
|
99
|
+
);
|
|
100
|
+
writeFileSync(path, newFileContents);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const replaceVersionInEnvFiles = (globPath, newVersion) => {
|
|
104
|
+
const files = glob.sync(globPath.replace(/\\/g, '/'));
|
|
105
|
+
files.forEach((file) => replaceVersionInEnvFile(file, newVersion));
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export const replaceVersionInGitLabCi = (path, newVersion) => {
|
|
109
|
+
console.log('Replacing version in GitLab CI file', path);
|
|
110
|
+
const fileContents = readFileSync(path, 'utf-8');
|
|
111
|
+
const newFileContents = fileContents.replace(
|
|
112
|
+
/APP_VERSION: \d+\.\d+\.\d+/g,
|
|
113
|
+
`APP_VERSION: ${newVersion}`
|
|
114
|
+
);
|
|
115
|
+
writeFileSync(path, newFileContents);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const replaceVersionInDockerCompose = (path, newVersion) => {
|
|
119
|
+
console.log('Replacing version in Docker Compose file', path);
|
|
120
|
+
const fileContents = readFileSync(path, 'utf-8');
|
|
121
|
+
const newFileContents = fileContents.replace(
|
|
122
|
+
/image: ([^\:]+):\d+\.\d+\.\d+/g,
|
|
123
|
+
`image: $1:${newVersion}`
|
|
124
|
+
);
|
|
125
|
+
writeFileSync(path, newFileContents);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export const getCurrentVersion = () => {
|
|
129
|
+
const packageJson = JSON.parse(
|
|
130
|
+
readFileSync(join(__dirname, 'package.json'), 'utf-8')
|
|
131
|
+
);
|
|
132
|
+
return packageJson.version;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export const getUpdateTypeFromArgv = () => {
|
|
136
|
+
const [, , updateType] = process.argv;
|
|
137
|
+
if (!updateType) {
|
|
138
|
+
console.error('No version update type provided');
|
|
139
|
+
process.exit(1);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (!['major', 'minor', 'patch'].includes(updateType)) {
|
|
143
|
+
console.error(
|
|
144
|
+
'Invalid version update type : expected "major", "minor" or "patch"'
|
|
145
|
+
);
|
|
146
|
+
process.exit(1);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return updateType;
|
|
150
|
+
};
|
package/node/nuget-publish.mjs
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { exec } from 'child_process';
|
|
4
|
-
import { existsSync } from 'fs';
|
|
5
|
-
|
|
6
|
-
export const publishNugetPackageToRemoteServer = async (nugetPackagePath) => {
|
|
7
|
-
const nugetFeedUrl = 'https://nuget.ad-dev.be/v3/index.json';
|
|
8
|
-
const nugetApiKey = '4d1745649b06';
|
|
9
|
-
|
|
10
|
-
// Check if the nuget feed directory exists
|
|
11
|
-
if (!existsSync(nugetPackagePath)) {
|
|
12
|
-
console.log('NuGet package', nugetPackagePath, 'not found');
|
|
13
|
-
process.exit(1);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
console.log(`Publishing ${nugetPackagePath} file to nuget server...`);
|
|
17
|
-
exec(
|
|
18
|
-
`dotnet nuget push -s "${nugetFeedUrl}" -k ${nugetApiKey} ${nugetPackagePath} --skip-duplicate`,
|
|
19
|
-
(err, stdout, stderr) => {
|
|
20
|
-
if (err) {
|
|
21
|
-
console.error(`Error publishing ${nugetPackagePath}:`, err);
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
console.log(stdout);
|
|
25
|
-
console.error(stderr);
|
|
26
|
-
}
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
console.log('Publishing complete.');
|
|
30
|
-
};
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { exec } from 'child_process';
|
|
4
|
+
import { existsSync } from 'fs';
|
|
5
|
+
|
|
6
|
+
export const publishNugetPackageToRemoteServer = async (nugetPackagePath) => {
|
|
7
|
+
const nugetFeedUrl = 'https://nuget.ad-dev.be/v3/index.json';
|
|
8
|
+
const nugetApiKey = '4d1745649b06';
|
|
9
|
+
|
|
10
|
+
// Check if the nuget feed directory exists
|
|
11
|
+
if (!existsSync(nugetPackagePath)) {
|
|
12
|
+
console.log('NuGet package', nugetPackagePath, 'not found');
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
console.log(`Publishing ${nugetPackagePath} file to nuget server...`);
|
|
17
|
+
exec(
|
|
18
|
+
`dotnet nuget push -s "${nugetFeedUrl}" -k ${nugetApiKey} ${nugetPackagePath} --skip-duplicate`,
|
|
19
|
+
(err, stdout, stderr) => {
|
|
20
|
+
if (err) {
|
|
21
|
+
console.error(`Error publishing ${nugetPackagePath}:`, err);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
console.log(stdout);
|
|
25
|
+
console.error(stderr);
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
console.log('Publishing complete.');
|
|
30
|
+
};
|
package/node/update-version.mjs
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getCurrentVersion,
|
|
3
|
-
replaceVersionInCSharpProjects,
|
|
4
|
-
replaceVersionInPackageJsonFile,
|
|
5
|
-
replaceVersionInPackageJsonFiles,
|
|
6
|
-
} from './helpers/versions.mjs';
|
|
7
|
-
|
|
8
|
-
import { cwd } from 'process';
|
|
9
|
-
import { inc } from 'semver';
|
|
10
|
-
import { join } from 'path';
|
|
11
|
-
|
|
12
|
-
export const defaultUpdateFunc = (newVersion) => {
|
|
13
|
-
replaceVersionInPackageJsonFile(join(cwd(), 'package.json'), newVersion);
|
|
14
|
-
replaceVersionInPackageJsonFiles(
|
|
15
|
-
join(cwd(), 'packages/**/package.json'),
|
|
16
|
-
newVersion
|
|
17
|
-
);
|
|
18
|
-
replaceVersionInCSharpProjects(
|
|
19
|
-
join(cwd(), 'packages/**/*.csproj'),
|
|
20
|
-
newVersion
|
|
21
|
-
);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const updatePackagesVersion = (
|
|
25
|
-
updateType,
|
|
26
|
-
updateFunc = defaultUpdateFunc
|
|
27
|
-
) => {
|
|
28
|
-
console.log('~~~ Update packages version ~~~');
|
|
29
|
-
|
|
30
|
-
const currentVersion = getCurrentVersion();
|
|
31
|
-
if (!currentVersion) {
|
|
32
|
-
throw new Error('Could not get current version from package.json');
|
|
33
|
-
}
|
|
34
|
-
console.log(`Current version: ${currentVersion}`);
|
|
35
|
-
|
|
36
|
-
switch (updateType) {
|
|
37
|
-
case 'major':
|
|
38
|
-
case 'minor':
|
|
39
|
-
case 'patch': {
|
|
40
|
-
const incrementedVersion = inc(currentVersion, updateType);
|
|
41
|
-
updateFunc(incrementedVersion);
|
|
42
|
-
break;
|
|
43
|
-
}
|
|
44
|
-
default:
|
|
45
|
-
console.log('Invalid version update type');
|
|
46
|
-
throw new Error(
|
|
47
|
-
'Invalid version update type, should be "major", "minor" or "patch"'
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const newVersion = getCurrentVersion();
|
|
52
|
-
console.log(`Updated version to: ${newVersion}`);
|
|
53
|
-
|
|
54
|
-
return newVersion;
|
|
55
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
getCurrentVersion,
|
|
3
|
+
replaceVersionInCSharpProjects,
|
|
4
|
+
replaceVersionInPackageJsonFile,
|
|
5
|
+
replaceVersionInPackageJsonFiles,
|
|
6
|
+
} from './helpers/versions.mjs';
|
|
7
|
+
|
|
8
|
+
import { cwd } from 'process';
|
|
9
|
+
import { inc } from 'semver';
|
|
10
|
+
import { join } from 'path';
|
|
11
|
+
|
|
12
|
+
export const defaultUpdateFunc = (newVersion) => {
|
|
13
|
+
replaceVersionInPackageJsonFile(join(cwd(), 'package.json'), newVersion);
|
|
14
|
+
replaceVersionInPackageJsonFiles(
|
|
15
|
+
join(cwd(), 'packages/**/package.json'),
|
|
16
|
+
newVersion
|
|
17
|
+
);
|
|
18
|
+
replaceVersionInCSharpProjects(
|
|
19
|
+
join(cwd(), 'packages/**/*.csproj'),
|
|
20
|
+
newVersion
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const updatePackagesVersion = (
|
|
25
|
+
updateType,
|
|
26
|
+
updateFunc = defaultUpdateFunc
|
|
27
|
+
) => {
|
|
28
|
+
console.log('~~~ Update packages version ~~~');
|
|
29
|
+
|
|
30
|
+
const currentVersion = getCurrentVersion();
|
|
31
|
+
if (!currentVersion) {
|
|
32
|
+
throw new Error('Could not get current version from package.json');
|
|
33
|
+
}
|
|
34
|
+
console.log(`Current version: ${currentVersion}`);
|
|
35
|
+
|
|
36
|
+
switch (updateType) {
|
|
37
|
+
case 'major':
|
|
38
|
+
case 'minor':
|
|
39
|
+
case 'patch': {
|
|
40
|
+
const incrementedVersion = inc(currentVersion, updateType);
|
|
41
|
+
updateFunc(incrementedVersion);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
default:
|
|
45
|
+
console.log('Invalid version update type');
|
|
46
|
+
throw new Error(
|
|
47
|
+
'Invalid version update type, should be "major", "minor" or "patch"'
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const newVersion = getCurrentVersion();
|
|
52
|
+
console.log(`Updated version to: ${newVersion}`);
|
|
53
|
+
|
|
54
|
+
return newVersion;
|
|
55
|
+
};
|