@eui/tools 5.2.0 → 5.2.1

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.
@@ -1 +1 @@
1
- 5.2.0
1
+ 5.2.1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 5.2.1 (2022-05-02)
2
+
3
+ ##### Bug Fixes
4
+
5
+ * **other:**
6
+ * wrong initial version set for envTarget remote delivery - EUI-5632 [EUI-5632](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-5632) ([cc894439](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/cc8944393d48bb9b7ae2ee5afb3ab5052983f4a5))
7
+
8
+ * * *
9
+ * * *
1
10
  ## 5.2.0 (2022-04-29)
2
11
 
3
12
  ##### New Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eui/tools",
3
- "version": "5.2.0",
3
+ "version": "5.2.1",
4
4
  "tag": "latest",
5
5
  "license": "EUPL-1.1",
6
6
  "description": "eUI common tools and scripts",
package/sandbox.js CHANGED
@@ -790,7 +790,7 @@ const versionUtils = require('./scripts/csdr/version/version-utils');
790
790
  // METADATA API TESTING
791
791
  // --------------------
792
792
  // const metadataModule = require('./scripts/csdr/metadata/v2');
793
- // const pkg = configUtils.packages.getPackage('mywp-dummy-eui10-remote-el-ui');
793
+ // const pkg = configUtils.packages.getPackage('cc-task-details-eui10-remote-el-ui');
794
794
 
795
795
  // Promise.resolve()
796
796
  // .then(() => {
@@ -840,12 +840,33 @@ const versionUtils = require('./scripts/csdr/version/version-utils');
840
840
  // })
841
841
 
842
842
 
843
- const pkg = configUtils.packages.getPackage('opsys-epc-esub-bo-ui', true);
843
+ // METADATA ESTING
844
+ // --------------------
845
+ const pkg = configUtils.packages.getPackage('cc-task-details-eui10-remote-el-ui');
846
+ const envTarget = 'DEV';
847
+
848
+ let versionsMetadata, envsMetadata;
844
849
 
845
850
  Promise.resolve()
851
+ // generating new version based on the env target and the envs cycle type
846
852
  .then(() => {
847
- return metadataUtils.package.getPackageVersionsByMajor(pkg, '10', false)
853
+ return versionUtils.packageRemote.getNewVersion(pkg, envTarget);
848
854
  })
849
- .then((versions) => {
850
- console.log(versions);
855
+ .then((version) => {
856
+ console.log(version);
851
857
  })
858
+
859
+
860
+
861
+
862
+
863
+
864
+ // const pkg = configUtils.packages.getPackage('opsys-epc-esub-bo-ui', true);
865
+
866
+ // Promise.resolve()
867
+ // .then(() => {
868
+ // return metadataUtils.package.getPackageVersionsByMajor(pkg, '10', false)
869
+ // })
870
+ // .then((versions) => {
871
+ // console.log(versions);
872
+ // })
@@ -260,7 +260,8 @@ module.exports.updateVersion = (pkg, pkgMetadata, envTarget) => {
260
260
  (branches.isSnapshot || branches.isSupportSnapshot),
261
261
  branches.isNext,
262
262
  branches.isSupport,
263
- branches.isHotfix
263
+ branches.isHotfix,
264
+ envTarget
264
265
  );
265
266
  })
266
267
 
@@ -7,7 +7,7 @@ const semver = require('semver');
7
7
  const tools = require('../../utils/tools');
8
8
 
9
9
 
10
- const getNewVersionForDev = (versionsMetadata, envsMetadata, rootEnv) => {
10
+ const getNewVersionForDev = (versionsMetadata, envsMetadata, rootEnv, currentVersion) => {
11
11
  let version;
12
12
  const lastIntMetadata = envsMetadata[rootEnv];
13
13
 
@@ -19,7 +19,11 @@ const getNewVersionForDev = (versionsMetadata, envsMetadata, rootEnv) => {
19
19
 
20
20
  } else {
21
21
  tools.logInfo('No INT metadata found : initializing version');
22
- version = '1.0.0-SNAPSHOT';
22
+ if (currentVersion) {
23
+ version = semver.coerce(currentVersion).raw + '-SNAPSHOT';
24
+ } else {
25
+ version = '1.0.0-SNAPSHOT';
26
+ }
23
27
  tools.logInfo(`version intialized : ${version}`);
24
28
  }
25
29
 
@@ -48,6 +52,7 @@ const getNewVersionForDev = (versionsMetadata, envsMetadata, rootEnv) => {
48
52
 
49
53
  // if it's a branch new DEV stream release, the snapshot is itialized
50
54
  } else {
55
+ tools.logInfo(`prevVersions matching: ${version} not found initializing first release of raw version`);
51
56
  version += '.0';
52
57
  }
53
58
  }
@@ -132,7 +137,7 @@ const getNewVersionForEnv = (versionsMetadata, envsMetadata, rootEnv, envTarget)
132
137
 
133
138
 
134
139
 
135
- module.exports.getNewVersionDefault = (envTarget, versionsMetadata, envsMetadata) => {
140
+ module.exports.getNewVersionDefault = (envTarget, versionsMetadata, envsMetadata, currentVersion) => {
136
141
  tools.logInfo(`Retrieve version for ${envTarget}`);
137
142
 
138
143
  return Promise.resolve()
@@ -145,7 +150,7 @@ module.exports.getNewVersionDefault = (envTarget, versionsMetadata, envsMetadata
145
150
  // =====================================================================
146
151
 
147
152
  if (envTarget === 'DEV') {
148
- version = getNewVersionForDev(versionsMetadata, envsMetadata, 'INT');
153
+ version = getNewVersionForDev(versionsMetadata, envsMetadata, 'INT', currentVersion);
149
154
  }
150
155
 
151
156
 
@@ -16,7 +16,7 @@ const configUtils = require('../config/config-utils');
16
16
  const { dryRun, nexusUser, nexusPassword } = tools.getArgs();
17
17
 
18
18
 
19
- const writePackageJsonCore = (newVersion, folder, isSnapshot, isNextBranch, isSupportBranch, isHotfixBranch) => {
19
+ const writePackageJsonCore = (newVersion, folder, isSnapshot, isNextBranch, isSupportBranch, isHotfixBranch, envTarget) => {
20
20
  return Promise.resolve()
21
21
  .then(() => {
22
22
  const pkgJsonFile = path.resolve(folder, 'package.json');
@@ -24,14 +24,18 @@ const writePackageJsonCore = (newVersion, folder, isSnapshot, isNextBranch, isSu
24
24
 
25
25
  let tag;
26
26
 
27
- if (isSnapshot) {
27
+ if (envTarget && envTarget === 'DEV') {
28
28
  tag = 'snapshot';
29
- } else if (isNextBranch) {
30
- tag = 'next';
31
- } else if (isSupportBranch) {
32
- tag = 'prev';
33
29
  } else {
34
- tag = 'latest';
30
+ if (isSnapshot) {
31
+ tag = 'snapshot';
32
+ } else if (isNextBranch) {
33
+ tag = 'next';
34
+ } else if (isSupportBranch) {
35
+ tag = 'prev';
36
+ } else {
37
+ tag = 'latest';
38
+ }
35
39
  }
36
40
 
37
41
  pkgJson.version = newVersion;
@@ -48,7 +52,7 @@ const writePackageJsonCore = (newVersion, folder, isSnapshot, isNextBranch, isSu
48
52
  })
49
53
  }
50
54
 
51
- const writePackageJson = (pkg, newVersion, isSnapshot, isNextBranch, isSupportBranch, isHotfixBranch) => {
55
+ const writePackageJson = (pkg, newVersion, isSnapshot, isNextBranch, isSupportBranch, isHotfixBranch, envTarget) => {
52
56
  return Promise.resolve()
53
57
  .then(() => {
54
58
  tools.logTitle('updating package version');
@@ -56,11 +60,11 @@ const writePackageJson = (pkg, newVersion, isSnapshot, isNextBranch, isSupportBr
56
60
  if (!pkg.parent) {
57
61
  return Promise.resolve()
58
62
  .then(() => {
59
- return writePackageJsonCore(newVersion, pkg.paths.pkgDirectory, isSnapshot, isNextBranch, isSupportBranch, isHotfixBranch);
63
+ return writePackageJsonCore(newVersion, pkg.paths.pkgDirectory, isSnapshot, isNextBranch, isSupportBranch, isHotfixBranch, envTarget);
60
64
  })
61
65
  .then(() => {
62
66
  if (!pkg.element && !pkg.config) {
63
- return writePackageJsonCore(newVersion, pkg.paths.pkgPublish, isSnapshot, isNextBranch, isSupportBranch, isHotfixBranch);
67
+ return writePackageJsonCore(newVersion, pkg.paths.pkgPublish, isSnapshot, isNextBranch, isSupportBranch, isHotfixBranch, envTarget);
64
68
  }
65
69
  })
66
70
  .catch((e) => {
@@ -70,7 +74,7 @@ const writePackageJson = (pkg, newVersion, isSnapshot, isNextBranch, isSupportBr
70
74
  } else {
71
75
  return Promise.resolve()
72
76
  .then(() => {
73
- return writePackageJsonCore(newVersion, pkg.paths.pkgDirectory, isSnapshot, isNextBranch, isSupportBranch, isHotfixBranch);
77
+ return writePackageJsonCore(newVersion, pkg.paths.pkgDirectory, isSnapshot, isNextBranch, isSupportBranch, isHotfixBranch, envTarget);
74
78
  })
75
79
  .then(() => {
76
80
  let linkedPackages = Object.keys(pkg.packages)
@@ -85,7 +89,7 @@ const writePackageJson = (pkg, newVersion, isSnapshot, isNextBranch, isSupportBr
85
89
  .then((linkedPackages) => Promise.resolve().then(() => {
86
90
  return linkedPackages.reduce((promise, pkg) => {
87
91
  return promise.then(() => (
88
- writePackageJsonCore(newVersion, pkg.paths.pkgPublish, isSnapshot, isNextBranch, isSupportBranch, isHotfixBranch)
92
+ writePackageJsonCore(newVersion, pkg.paths.pkgPublish, isSnapshot, isNextBranch, isSupportBranch, isHotfixBranch, envTarget)
89
93
  ));
90
94
  }, Promise.resolve());
91
95
  }))
@@ -113,7 +117,7 @@ const writePomXml = (pkg, newVersion, isSnapshot, isForceTimestamp = true) => {
113
117
  if (dryRun) {
114
118
  return;
115
119
  }
116
-
120
+
117
121
  return Promise.resolve()
118
122
  .then(() => {
119
123
  return templateUtils.generateMavenSettings(nexusUser, nexusPassword);
@@ -146,13 +150,56 @@ const writePomXml = (pkg, newVersion, isSnapshot, isForceTimestamp = true) => {
146
150
 
147
151
 
148
152
 
149
- module.exports.updateVersion = (pkg, newVersion, isSnapshot, isNextBranch, isSupportBranch, isHotfixBranch) => {
153
+ module.exports.updateVersion = (pkg, newVersion, isSnapshot, isNextBranch, isSupportBranch, isHotfixBranch, envTarget) => {
150
154
  if (pkg.backend) {
151
155
  return writePomXml(pkg, newVersion, isSnapshot);
152
156
  }
153
157
  else {
154
- return writePackageJson(pkg, newVersion, isSnapshot, isNextBranch, isSupportBranch, isHotfixBranch);
158
+ return writePackageJson(pkg, newVersion, isSnapshot, isNextBranch, isSupportBranch, isHotfixBranch, envTarget);
155
159
  }
156
160
  }
157
161
 
158
162
 
163
+ module.exports.getCurrentVersion = (pkg) => {
164
+ return Promise.resolve()
165
+ .then(() => {
166
+ let currentVersion;
167
+
168
+ tools.logTitle('Extracting current version');
169
+
170
+ if (pkg.backend) {
171
+ // if nodejs backend, explicitely declared
172
+ if (pkg.build && pkg.build.nodejs) {
173
+ tools.logInfo('UI package => extracting from package.json');
174
+
175
+ const pathPkgJson = path.resolve(pkg.paths.pkgDirectory, 'package.json');
176
+ const pkgJson = require(pathPkgJson);
177
+ currentVersion = pkgJson.version;
178
+
179
+ // by default maven java backend is taken into account
180
+ } else {
181
+ tools.logInfo('Backend => extracting pom.xml');
182
+ const xmlContent = tools.getXMLJsContent(path.join(pkg.paths.pkgDirectory, 'pom.xml'));
183
+
184
+ tools.logInfo('Content found:');
185
+ console.log(xmlContent);
186
+
187
+ currentVersion = xmlContent.project.version.toString();
188
+ }
189
+
190
+ } else {
191
+ tools.logInfo('UI package => extracting from package.json');
192
+
193
+ const pathPkgJson = path.resolve(pkg.paths.pkgDirectory, 'package.json');
194
+ const pkgJson = require(pathPkgJson);
195
+ currentVersion = pkgJson.version;
196
+ }
197
+
198
+ tools.logSuccess('Current version found : ' + currentVersion);
199
+ return currentVersion;
200
+ })
201
+ .catch((e) => {
202
+ throw e;
203
+ })
204
+ }
205
+
@@ -2,57 +2,13 @@
2
2
 
3
3
  // externals
4
4
  const semver = require('semver');
5
- const path = require('path');
6
5
 
7
6
  // local
8
7
  const tools = require('../../utils/tools');
9
8
 
10
- const RELEASE_TYPES = ['major', 'minor', 'patch'];
9
+ // inner
10
+ const innerPackageCommon = require('./package-common');
11
11
 
12
- const getCurrentVersion = (pkg) => {
13
- return Promise.resolve()
14
- .then(() => {
15
- let currentVersion;
16
-
17
- tools.logTitle('Extracting current version');
18
-
19
- if (pkg.backend) {
20
- // if nodejs backend, explicitely declared
21
- if (pkg.build && pkg.build.nodejs) {
22
- tools.logInfo('UI package => extracting from package.json');
23
-
24
- const pathPkgJson = path.resolve(pkg.paths.pkgDirectory, 'package.json');
25
- const pkgJson = require(pathPkgJson);
26
- currentVersion = pkgJson.version;
27
-
28
- // by default maven java backend is taken into account
29
- } else {
30
- tools.logInfo('Backend => extracting pom.xml');
31
- const xmlContent = tools.getXMLJsContent(path.join(pkg.paths.pkgDirectory, 'pom.xml'));
32
-
33
- tools.logInfo('Content found:');
34
- console.log(xmlContent);
35
-
36
- currentVersion = xmlContent.project.version.toString();
37
- }
38
-
39
- } else {
40
- tools.logInfo('UI package => extracting from package.json');
41
-
42
- const pathPkgJson = path.resolve(pkg.paths.pkgDirectory, 'package.json');
43
- const pkgJson = require(pathPkgJson);
44
- currentVersion = pkgJson.version;
45
- }
46
-
47
- tools.logSuccess('Current version found : ' + currentVersion);
48
- return currentVersion;
49
- })
50
- .catch((e) => {
51
- throw e;
52
- })
53
- }
54
-
55
- // PUBLIC METHODS
56
12
 
57
13
  module.exports.getNewVersion = (
58
14
  pkg,
@@ -61,7 +17,7 @@ module.exports.getNewVersion = (
61
17
  ) => {
62
18
  return Promise.resolve()
63
19
  .then(() => {
64
- return getCurrentVersion(pkg);
20
+ return innerPackageCommon.getCurrentVersion(pkg);
65
21
  })
66
22
 
67
23
  .then((currentVersion) => {
@@ -69,6 +25,8 @@ module.exports.getNewVersion = (
69
25
 
70
26
  tools.logInfo(`Current version found : ${currentVersion}`);
71
27
 
28
+ const RELEASE_TYPES = ['major', 'minor', 'patch'];
29
+
72
30
  let newVersion = '1.0.0';
73
31
 
74
32
  if (commits) {
@@ -12,6 +12,7 @@ const metadataUtils = require('../metadata/metadata-utils');
12
12
 
13
13
  // inner modules
14
14
  const innerCommon = require('./common');
15
+ const innerPackageCommon = require('./package-common');
15
16
 
16
17
  // constants
17
18
  const { dryRun } = tools.getArgs();
@@ -21,8 +22,17 @@ const { dryRun } = tools.getArgs();
21
22
  module.exports.getNewVersion = (pkg, envTarget) => {
22
23
  let versionsMetadata;
23
24
  let envsMetadata;
25
+ let currentVersion;
24
26
 
25
27
  return Promise.resolve()
28
+ // get current version
29
+ .then(() => {
30
+ return innerPackageCommon.getCurrentVersion(pkg);
31
+ })
32
+ .then((version) => {
33
+ currentVersion = version;
34
+ })
35
+
26
36
  // fetch versions history and store
27
37
  .then(() => {
28
38
  return metadataUtils.packageVersions.getMetadata(pkg);
@@ -42,7 +52,7 @@ module.exports.getNewVersion = (pkg, envTarget) => {
42
52
 
43
53
  // generating new version based on the env target and the envs cycle type
44
54
  .then(() => {
45
- return innerCommon.getNewVersionDefault(envTarget, versionsMetadata, envsMetadata);
55
+ return innerCommon.getNewVersionDefault(envTarget, versionsMetadata, envsMetadata, currentVersion);
46
56
  })
47
57
 
48
58
  .catch((e) => {
@@ -9,6 +9,7 @@ const innerPackage = require('./package');
9
9
  const innerPackageCommon = require('./package-common');
10
10
  const innerPackageRemote = require('./package-remote');
11
11
  const innerPackageDefault = require('./package-default');
12
+ const innerCommon = require('./common');
12
13
 
13
14
  // re-exports inner modules
14
15
  module.exports.app = innerApp;
@@ -19,3 +20,4 @@ module.exports.package = innerPackage;
19
20
  module.exports.packageCommon = innerPackageCommon;
20
21
  module.exports.packageRemote = innerPackageRemote;
21
22
  module.exports.packageDefault = innerPackageDefault;
23
+ module.exports.common = innerCommon;