@eui/tools 6.19.3 → 6.20.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.
Files changed (33) hide show
  1. package/.version.properties +1 -1
  2. package/CHANGELOG.md +24 -0
  3. package/bin/eui-scripts.js +2 -0
  4. package/bin/scripts/release-package-standalone.js +5 -0
  5. package/init.js +2 -0
  6. package/package.json +1 -1
  7. package/scripts/csdr/audit/yarn.js +15 -2
  8. package/scripts/csdr/config/angular.js +14 -1
  9. package/scripts/csdr/config/config-skeletons.js +45 -1
  10. package/scripts/csdr/config/global.js +16 -4
  11. package/scripts/csdr/config/packages.js +42 -3
  12. package/scripts/csdr/config/remotes.js +2 -0
  13. package/scripts/csdr/init/global.js +8 -2
  14. package/scripts/csdr/init/packages.js +8 -0
  15. package/scripts/csdr/init/standalone/18.x/.eslintrc.eui18.standalone.json +133 -0
  16. package/scripts/csdr/init/standalone/18.x/.eslintrc.json +44 -0
  17. package/scripts/csdr/init/standalone/18.x/karma.conf.standalone.js +7 -0
  18. package/scripts/csdr/init/standalone/18.x/tsconfig.lib.standalone.json +34 -0
  19. package/scripts/csdr/init/standalone/18.x/tsconfig.spec.standalone.json +17 -0
  20. package/scripts/csdr/init/standalone/18.x/tsconfig.standalone.json +17 -0
  21. package/scripts/csdr/install/common.js +110 -2
  22. package/scripts/csdr/install/packages.js +59 -6
  23. package/scripts/csdr/metadata/package-utils.js +100 -25
  24. package/scripts/csdr/release/package/common.js +96 -52
  25. package/scripts/csdr/release/package/release-package-standalone.js +24 -0
  26. package/scripts/csdr/release/package/release-ui-standalone.js +169 -0
  27. package/scripts/index.js +2 -0
  28. package/scripts/utils/changelog-utils.js +25 -15
  29. package/scripts/utils/clean/clean-utils.js +10 -2
  30. package/scripts/utils/git-utils.js +10 -6
  31. package/scripts/utils/notification/config.js +7 -1
  32. package/scripts/utils/publish/npm.js +18 -4
  33. package/scripts/utils/sonar/sonar-utils.js +13 -4
@@ -0,0 +1,169 @@
1
+ 'use strict';
2
+
3
+ // UTILS
4
+ const utils = require('../../../utils');
5
+
6
+ // CSDR RELATED
7
+ const configUtils = require('../../config/config-utils');
8
+ const auditUtils = require('../../audit/audit-utils');
9
+ const initUtils = require('../../init/init-utils');
10
+ const installUtils = require('../../install/install-utils');
11
+
12
+ // INNER MODULES
13
+ const innerCommon = require('./common');
14
+
15
+
16
+ // LOCAL TEST :
17
+ // - symlink eUI tools sources to node_modules of standalone pkg folder node_modules to test
18
+ // - execute this command on the standalone pkg folder :
19
+ // npx @eui/tools release-package-standalone --dryRun --debug --debugNotification --skipCommitsCheck --skipAudit --skipPublish --skipGitUpdates
20
+
21
+
22
+ module.exports.run = () => {
23
+ const { dryRun } = utils.tools.getArgs();
24
+
25
+ utils.tools.logBanner('Starting UI stand-alone pipeline');
26
+
27
+ // utils.tools.logTitle('Provided arguments : ');
28
+ // console.log(utils.tools.getArgs());
29
+
30
+ // local saved vars
31
+ let newVersion, commitsMetadata;
32
+
33
+ // getting the package information - mimics CSDR package config
34
+ const pkg = configUtils.packages.getStandalonePackage();
35
+
36
+ // get branches config
37
+ const branches = innerCommon.getBranchesFromRepo();
38
+
39
+ return (
40
+ Promise.resolve()
41
+
42
+ // RELEASE PACKAGE START
43
+
44
+ // Starting the release flow
45
+ .then(() => {
46
+ return innerCommon.initMessage(pkg, branches);
47
+ })
48
+
49
+ // CHECK BRANCH VALIDITY
50
+ .then(() => {
51
+ innerCommon.checkBranchValidity(branches);
52
+ })
53
+
54
+ // COMMIT METADATA CHECKS
55
+ .then(() => {
56
+ return innerCommon.commitMetadataChecks(pkg);
57
+ })
58
+ .then((metadata) => {
59
+ commitsMetadata = metadata;
60
+ })
61
+
62
+ // SPECIFIC INJECTION FOR STANDALONE PKG ROOT FILES
63
+ .then(() => {
64
+ return initUtils.packages.injectStandaloneResources(pkg);
65
+ })
66
+
67
+ // INIT PACKAGE CONFIG
68
+ .then(() => {
69
+ // generating angular.json config if not existing
70
+ configUtils.angular.checkAngularConfig();
71
+
72
+ // registering package angular config
73
+ configUtils.angular.registerAngularPackage(pkg);
74
+ })
75
+
76
+ // INIT ROOT FILES - yarn lock and resolution based on current eUI version of the package
77
+ .then(() => {
78
+ const euiVersion = configUtils.packages.getPackageEuiVersion(pkg);
79
+ return initUtils.global.initRootFilesAndResolutions(euiVersion);
80
+ })
81
+
82
+ // INSTALL dependencies by type
83
+ .then(() => {
84
+ utils.tools.logBanner('INSTALL DEPENDENCIES');
85
+
86
+ return (
87
+ Promise.resolve()
88
+ .then(() => {
89
+ return installUtils.packages.installDepsStandalone(pkg, branches.isMaster);
90
+ })
91
+
92
+ // auditing dependencies
93
+ .then(() => {
94
+ return auditUtils.yarn.audit(pkg);
95
+ })
96
+ .catch((e) => {
97
+ throw e;
98
+ })
99
+ );
100
+ })
101
+
102
+ // BUILD PACKAGE
103
+ .then(() => {
104
+ return utils.buildPackage.build(pkg, branches.isMaster, false);
105
+ })
106
+
107
+ // EXECUTING SONAR ANALYSIS
108
+ .then(() => {
109
+ return utils.sonar.run(pkg, branches.isMaster);
110
+ })
111
+
112
+ // GENERATE and UPDATE new version
113
+ .then(() => {
114
+ return innerCommon.updateVersion(pkg, commitsMetadata);
115
+ })
116
+ .then((version) => {
117
+ // storing version for later use
118
+ newVersion = version;
119
+ })
120
+
121
+ // GENERATE CHANGELOG
122
+ .then(() => {
123
+ utils.tools.logTitle('generating changelog...');
124
+ return utils.changelog.generate(pkg, newVersion, commitsMetadata.commits);
125
+ })
126
+
127
+ // WRITE CHANGELOG for MASTER and SUPPORT
128
+ .then((changelogContent) => {
129
+ utils.tools.logTitle('writing changelog...');
130
+
131
+ if ((branches.isSupport || branches.isNext || branches.isMaster) && !dryRun) {
132
+ return utils.changelog.writeChangelog(changelogContent, pkg.paths.root);
133
+
134
+ } else {
135
+ utils.tools.logInfo('WRITING SKIPPED - (either DRY-RUN or snapshot release) - Actual changelog :');
136
+ console.log(changelogContent);
137
+ }
138
+ })
139
+
140
+ // PUBLISH PACKAGE
141
+ .then(() => {
142
+ return utils.publish.publish(pkg);
143
+ })
144
+
145
+ // GIT OPERATIONS
146
+ .then(() => {
147
+ return innerCommon.runGitOperations(pkg, newVersion);
148
+ })
149
+
150
+ // SEND SUCCESS NOTIFICATION
151
+ .then(() => {
152
+ return innerCommon.sendSuccessNotification(pkg, newVersion, commitsMetadata, false).then(() => {
153
+ return innerCommon.close(pkg);
154
+ });
155
+ })
156
+
157
+ // SEND ERROR NOTIFICATION
158
+ .catch((e) => {
159
+ return innerCommon
160
+ .sendErrorNotification(pkg, e, commitsMetadata, false)
161
+ .then(() => {
162
+ return innerCommon.close(pkg);
163
+ })
164
+ .then(() => {
165
+ process.exit(1);
166
+ });
167
+ })
168
+ );
169
+ };
package/scripts/index.js CHANGED
@@ -91,12 +91,14 @@ module.exports.cliPackageConstants = require('./csdr/cli/constants');
91
91
 
92
92
  // csdr - config
93
93
  module.exports.configAngular = require('./csdr/config/angular');
94
+ module.exports.configSkeletons = require('./csdr/config/config-skeletons');
94
95
  module.exports.configUtils = require('./csdr/config/config-utils');
95
96
  module.exports.configGlobal = require('./csdr/config/global');
96
97
  module.exports.configInit = require('./csdr/config/init');
97
98
  module.exports.configPackages = require('./csdr/config/packages');
98
99
  module.exports.configProjects = require('./csdr/config/projects');
99
100
  module.exports.configRegister = require('./csdr/config/register');
101
+ module.exports.configRemotes = require('./csdr/config/remotes');
100
102
  module.exports.configSync = require('./csdr/config/sync');
101
103
 
102
104
  // csdr -init
@@ -32,18 +32,29 @@ const TYPES = {
32
32
 
33
33
  module.exports.generate = (pkg, version, commits) => {
34
34
 
35
- var content = [];
36
- var date = new Date().toJSON().slice(0, 10);
37
- var heading = '##';
35
+ let content = [];
36
+ let date = new Date().toJSON().slice(0, 10);
37
+ let heading = '##';
38
38
 
39
- var repoUrl;
39
+ let repoUrl;
40
+
41
+ if (!commits) {
42
+ tools.logWarning('Unable to find commits metadata to parse');
43
+ return null;
44
+ }
40
45
 
41
46
  heading += ' ' + version + ' (' + date + ')';
42
47
 
43
48
  content.push(heading);
44
49
  content.push('');
45
50
 
46
- const iSSUES_MANAGER_HOST = configUtils.global.getConfigOptions().ISSUES_MANAGER_HOST;
51
+ let ISSUES_MANAGER_HOST;
52
+
53
+ if (pkg.standalone) {
54
+ ISSUES_MANAGER_HOST = configUtils.global.getConfigOptionsStandalone().ISSUES_MANAGER_HOST;
55
+ } else {
56
+ ISSUES_MANAGER_HOST = configUtils.global.getConfigOptions().ISSUES_MANAGER_HOST;
57
+ }
47
58
 
48
59
  return Promise.resolve()
49
60
  .then(() => {
@@ -53,15 +64,15 @@ module.exports.generate = (pkg, version, commits) => {
53
64
  repoUrl = repoUrlFound;
54
65
  })
55
66
  .then(() => {
56
- var types = {}
67
+ let types = {}
57
68
 
58
69
  commits.forEach((commit) => {
59
- var type = TYPES[commit.type] ? commit.type : DEFAULT_TYPE;
70
+ let type = TYPES[commit.type] ? commit.type : DEFAULT_TYPE;
60
71
 
61
72
  if (commit.body && commit.body.indexOf('BREAKING CHANGE') !== -1) {
62
73
  type = 'breakingChange';
63
74
  }
64
- var category = commit.category ? commit.category : DEFAULT_CATEGORY;
75
+ let category = commit.category ? commit.category : DEFAULT_CATEGORY;
65
76
 
66
77
  types[type] = types[type] || {};
67
78
  types[type][category] = types[type][category] || [];
@@ -71,7 +82,7 @@ module.exports.generate = (pkg, version, commits) => {
71
82
  return types;
72
83
  })
73
84
  .then((rawTypes) => {
74
- var types = rawTypes;
85
+ let types = rawTypes;
75
86
 
76
87
  Object.keys(rawTypes).sort().forEach((type) => {
77
88
 
@@ -79,23 +90,22 @@ module.exports.generate = (pkg, version, commits) => {
79
90
  content.push('');
80
91
 
81
92
  Object.keys(rawTypes[type]).forEach(function (category) {
82
- var prefix = '*';
83
- var nested = types[type][category].length > 1;
84
- var categoryHeading = prefix + (category ? ' **' + category + ':**' : '');
93
+ let prefix = '*';
94
+ let categoryHeading = prefix + (category ? ' **' + category + ':**' : '');
85
95
 
86
96
  content.push(categoryHeading);
87
97
  prefix = ' *';
88
98
 
89
99
  types[type][category].forEach(function (commit) {
90
100
 
91
- var shorthash = commit.hash.substring(0, 8);
101
+ let shorthash = commit.hash.substring(0, 8);
92
102
  if (repoUrl) {
93
103
  shorthash = '[' + shorthash + '](' + repoUrl + '/commits/' + commit.hash + ')';
94
104
  }
95
105
 
96
- var issueString = '';
106
+ let issueString = '';
97
107
  if (commit.issue) {
98
- issueString += '[' + commit.issue + '](' + iSSUES_MANAGER_HOST + commit.issue + ') ';
108
+ issueString += '[' + commit.issue + '](' + ISSUES_MANAGER_HOST + commit.issue + ') ';
99
109
  }
100
110
 
101
111
  content.push(prefix + ' ' + commit.subject + ' ' + issueString + ' (' + shorthash + ')');
@@ -7,7 +7,11 @@ module.exports.cleanPackage = (pkg) => {
7
7
  return Promise.resolve()
8
8
  .then(() => {
9
9
  tools.logInfo('Cleaning dist')
10
- return tools.rimraf(pkg.paths.root + '/**/dist');
10
+ if (pkg.standalone) {
11
+ return tools.rimraf(pkg.paths.root + '/dist');
12
+ } else {
13
+ return tools.rimraf(pkg.paths.root + '/**/dist');
14
+ }
11
15
  })
12
16
  .then(() => {
13
17
  tools.logInfo('Cleaning out-tsc')
@@ -23,7 +27,11 @@ module.exports.cleanPackage = (pkg) => {
23
27
  })
24
28
  .then(() => {
25
29
  tools.logInfo('Cleaning test files')
26
- return tools.rimraf(pkg.paths.root + '/**/test');
30
+ if (pkg.standalone) {
31
+ return tools.rimraf(pkg.paths.root + '/test');
32
+ } else {
33
+ return tools.rimraf(pkg.paths.root + '/**/test');
34
+ }
27
35
  })
28
36
  .then(() => {
29
37
  tools.logSuccess();
@@ -11,7 +11,7 @@ const { getPackageConfig } = require('./notification/config');
11
11
  // const versionUtils = require('./version-utils');
12
12
 
13
13
  // FETCH ARGS
14
- const { dryRun, git, debug, build } = tools.getArgs();
14
+ const { dryRun, git, debug, build, skipGitUpdates } = tools.getArgs();
15
15
 
16
16
 
17
17
  const getLastTag = (folder) => {
@@ -30,7 +30,10 @@ const getLastTag = (folder) => {
30
30
  });
31
31
  }
32
32
 
33
-
33
+ const getBranchName = (folder = process.cwd()) => {
34
+ const branchName = execa.sync('git', ['rev-parse','--abbrev-ref', 'HEAD'], { cwd: folder }).stdout;
35
+ return branchName;
36
+ }
34
37
 
35
38
  const getRepoUrl = (folder) => {
36
39
  return Promise.resolve()
@@ -93,7 +96,7 @@ const commitAndPush = (branch, message, folder) => {
93
96
  tools.logTitle('Commit and pushing files');
94
97
  tools.logInfo(`on branch : ${branch} / folder provided : ${folder}`);
95
98
 
96
- if (dryRun) {
99
+ if (dryRun || skipGitUpdates) {
97
100
  tools.logInfo('DRY-RUN: skipping commit and push files');
98
101
 
99
102
  } else {
@@ -131,7 +134,7 @@ const tagVersion = (version, branch, message, folder) => {
131
134
  tools.logInfo(`Pushing changes to origin/${branch}...`);
132
135
  tools.logInfo(`Tagging MASTER branch with v${version}...`);
133
136
 
134
- if (dryRun) {
137
+ if (dryRun || skipGitUpdates) {
135
138
  tools.logInfo('DRY-RUN: skipping tagging of version');
136
139
  return Promise.resolve();
137
140
 
@@ -164,7 +167,7 @@ const mergeMasterToDevelop = (pkg, folder, version) => {
164
167
  tools.logTitle('Merge back on develop');
165
168
  tools.logInfo(`Merging release changes into "develop" branch...`);
166
169
 
167
- if (dryRun) {
170
+ if (dryRun || skipGitUpdates) {
168
171
  tools.logInfo('DRY-RUN: skipping merge master to develop');
169
172
  return;
170
173
 
@@ -204,7 +207,7 @@ const mergeSupportToSupportDevelop = (pkg, folder, supportBranch, supportSnapsho
204
207
  tools.logTitle(`Merge back on ${supportSnapshotBranch}`);
205
208
  tools.logInfo(`Merging release changes into ${supportSnapshotBranch} branch...`);
206
209
 
207
- if (dryRun) {
210
+ if (dryRun || skipGitUpdates) {
208
211
  tools.logInfo('DRY-RUN: skipping merge support to supportDevelop');
209
212
  return Promise.resolve();
210
213
  }
@@ -425,6 +428,7 @@ module.exports.getGitHost = getGitHost;
425
428
  module.exports.getLastTag = getLastTag;
426
429
  module.exports.getTags = getTags;
427
430
  module.exports.hasCommitsSinceLastTag = hasCommitsSinceLastTag;
431
+ module.exports.getBranchName = getBranchName;
428
432
  module.exports.commitAndPush = commitAndPush;
429
433
  module.exports.tagVersion = tagVersion;
430
434
  module.exports.mergeMasterToDevelop = mergeMasterToDevelop;
@@ -10,7 +10,13 @@ const configUtils = require('../../csdr/config/config-utils');
10
10
 
11
11
  module.exports.getPackageConfig = (pkg) => {
12
12
  // Fetching global config - default if not overriden in package own config
13
- const globalConfig = configUtils.global.getConfigOptions();
13
+ let globalConfig;
14
+
15
+ if (pkg.standalone) {
16
+ globalConfig = configUtils.global.getConfigOptionsStandalone()
17
+ } else {
18
+ globalConfig = configUtils.global.getConfigOptions();
19
+ }
14
20
 
15
21
  let slackChannel, msTeamsChannel;
16
22
 
@@ -10,7 +10,7 @@ const notificationUtils = require('../notification/notification-utils');
10
10
  const configUtils = require('../../csdr/config/config-utils');
11
11
 
12
12
  // FETCH ARGS
13
- const { dryRun, registry } = tools.getArgs();
13
+ const { dryRun, registry, skipPublish } = tools.getArgs();
14
14
 
15
15
 
16
16
 
@@ -42,7 +42,7 @@ const publishCore = module.exports.publishCore = (pkg, registry, isPublicAccess)
42
42
  // command += ' --access public';
43
43
  }
44
44
 
45
- if (dryRun) {
45
+ if (dryRun || skipPublish) {
46
46
  tools.logInfo(`DRY-RUN: npm publish command to be executed : ${args}`);
47
47
 
48
48
  return notificationUtils.package.sendPackageMessage({
@@ -109,7 +109,13 @@ const publishCore = module.exports.publishCore = (pkg, registry, isPublicAccess)
109
109
 
110
110
  const publishPackage = (pkg, parentPkg) => {
111
111
 
112
- const configOptions = configUtils.global.getConfigOptions();
112
+ let configOptions;
113
+
114
+ if (pkg.standalone) {
115
+ configOptions = configUtils.global.getConfigOptionsStandalone();
116
+ } else {
117
+ configOptions = configUtils.global.getConfigOptions();
118
+ }
113
119
 
114
120
  let pkgPublicRegistry;
115
121
 
@@ -192,7 +198,15 @@ module.exports.publish = (pkg) => {
192
198
 
193
199
  } else {
194
200
  // building normal package without linked children
195
- const pkgFull = configUtils.packages.getPackage(pkg.name); // TO CHECK
201
+ let pkgFull;
202
+
203
+ if (pkg.standalone) {
204
+ pkgFull = pkg;
205
+
206
+ } else {
207
+ pkgFull = configUtils.packages.getPackage(pkg.name); // TO CHECK
208
+ }
209
+
196
210
  return publishPackage(pkgFull);
197
211
  }
198
212
 
@@ -21,9 +21,11 @@ const { branch, dryRun, sonarQubeToken } = tools.getArgs();
21
21
  const runCore = (pkg, isMaster) => {
22
22
 
23
23
  // check at metadata global flag level if enabled
24
- if (!configUtils.global.isSonarEnabled()) {
25
- tools.logInfo('Sonar scanner globally disabled');
26
- return Promise.resolve();
24
+ if (!pkg.standalone) {
25
+ if (!configUtils.global.isSonarEnabled()) {
26
+ tools.logInfo('Sonar scanner globally disabled');
27
+ return Promise.resolve();
28
+ }
27
29
  }
28
30
 
29
31
  // check at package config level if enabled
@@ -115,7 +117,14 @@ const runUI = (pkg, isMaster) => {
115
117
  .then(() => {
116
118
  if (!dryRun) {
117
119
  tools.logInfo('Calling Sonar scanner...');
118
- const SONAR_HOST = configUtils.global.getConfigOptions().SONAR_HOST;
120
+
121
+ let SONAR_HOST;
122
+ if (pkg.standalone) {
123
+ SONAR_HOST = configUtils.global.getConfigOptionsStandalone().SONAR_HOST;
124
+ } else {
125
+ SONAR_HOST = configUtils.global.getConfigOptions().SONAR_HOST;
126
+ }
127
+
119
128
  return execa.shellSync(`sonar-scanner -Dsonar.branch.name=${branch} -Dsonar.host.url=${SONAR_HOST} -Dsonar.login=${sonarQubeToken}`, { cwd: pkg.paths.root, stdio: 'inherit' });
120
129
  }
121
130
  })