@eui/tools 6.13.15 → 6.14.0

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.
@@ -10,21 +10,20 @@ const tools = require('../../utils/tools');
10
10
  const innerGlobal = require('./global');
11
11
  const innerPackages = require('./packages');
12
12
 
13
-
14
13
  // PRIVATE FUNCTIONS
15
14
  const getProjectMetadataDefs = (projectName) => {
16
15
  return {
17
16
  devopsMetadataFile: `app-${projectName}-build-metadata.json`,
18
17
  devopsEnvsMetadataFile: `app-${projectName}-envs-metadata.json`,
19
18
  devopsVersionsMetadataFile: `app-${projectName}-versions-metadata.json`,
20
- devopsHistoryMetadataFile: `app-${projectName}-history-metadata.json`
19
+ devopsHistoryMetadataFile: `app-${projectName}-history-metadata.json`,
21
20
  };
22
- }
21
+ };
23
22
 
24
23
  const getProjectOptions = (prj) => {
25
24
  let options = {
26
25
  BUILD_VERSION_STRATEGY: 'DEFAULT',
27
- BUILD_VERSION_STRATEGY_ENVS_CYCLE: 'DEFAULT'
26
+ BUILD_VERSION_STRATEGY_ENVS_CYCLE: 'DEFAULT',
28
27
  };
29
28
 
30
29
  if (prj.build) {
@@ -33,7 +32,7 @@ const getProjectOptions = (prj) => {
33
32
  }
34
33
  }
35
34
  return { options: options };
36
- }
35
+ };
37
36
 
38
37
  const getProjectPaths = (prj) => {
39
38
  const rootPath = path.join(process.cwd(), prj.folder);
@@ -43,6 +42,7 @@ const getProjectPaths = (prj) => {
43
42
  }
44
43
  const assetsPath = path.join(angularPath, 'src', 'assets');
45
44
  const elementsPath = path.join(angularPath, 'src', 'assets', 'elements');
45
+ const distPath = path.join(angularPath, 'dist');
46
46
 
47
47
  let installPath = process.cwd();
48
48
  let nodeModulesPath = path.join(process.cwd(), 'node_modules');
@@ -58,33 +58,36 @@ const getProjectPaths = (prj) => {
58
58
  installPath: installPath,
59
59
  nodeModulesPath: nodeModulesPath,
60
60
  assetsPath: assetsPath,
61
+ distPath: distPath,
61
62
  };
62
63
 
63
64
  // locate and find the TSLint or ESLint configuration files
64
- if(tools.isFileExists(path.join(rootPath, 'src', 'tslint.json'))) {
65
+ if (tools.isFileExists(path.join(rootPath, 'src', 'tslint.json'))) {
65
66
  paths.tslintPath = path.join(rootPath, 'src', 'tslint.json');
66
- } else if(tools.isFileExists(path.join(rootPath, '.tslint.json'))) {
67
+ } else if (tools.isFileExists(path.join(rootPath, '.tslint.json'))) {
67
68
  paths.tslintPath = path.join(rootPath, '.tslint.json');
68
- } else if(tools.isFileExists(path.join(rootPath, 'src', '.eslintrc.json'))) {
69
+ } else if (tools.isFileExists(path.join(rootPath, 'src', '.eslintrc.json'))) {
69
70
  paths.eslintPath = path.join(rootPath, 'src', '.eslintrc.json');
70
71
  }
71
72
 
72
73
  return { paths: paths };
73
- }
74
-
74
+ };
75
75
 
76
76
  module.exports.getProject = (projectName) => {
77
77
  const { root, project } = tools.getArgs();
78
78
 
79
79
  if (!projectName && !project) {
80
80
  projectName = root || 'app';
81
-
82
81
  } else if (project && !projectName) {
83
82
  projectName = project;
84
83
  }
85
84
 
86
85
  const config = innerGlobal.getConfig();
87
86
 
87
+ // console.log('TEST TEST TEST');
88
+ // console.log(projectName);
89
+ // console.log(config.projects[projectName]);
90
+
88
91
  if (!config.projects[projectName]) {
89
92
  return null;
90
93
  }
@@ -102,12 +105,10 @@ module.exports.getProject = (projectName) => {
102
105
  ...prj,
103
106
  ...getProjectPaths(prj),
104
107
  ...getProjectMetadataDefs(projectName),
105
- ...getProjectOptions(prj)
106
- }
108
+ ...getProjectOptions(prj),
109
+ };
107
110
  }
108
- }
109
-
110
-
111
+ };
111
112
 
112
113
  module.exports.getCsdrProject = (projectName) => {
113
114
  const prj = innerGlobal.getCsdrConfig(false).projects[projectName];
@@ -119,30 +120,45 @@ module.exports.getCsdrProject = (projectName) => {
119
120
  ...prj,
120
121
  ...getProjectPaths(prj),
121
122
  ...getProjectMetadataDefs(projectName),
122
- ...getProjectOptions(prj)
123
- }
123
+ ...getProjectOptions(prj),
124
+ };
125
+ }
126
+ };
127
+
128
+ module.exports.getCsdrProjectsGroupForEuiVersion = (projectsGroupName, euiVersion) => {
129
+ const prjGroup = innerGlobal.getCsdrConfig(false).projects[projectsGroupName];
130
+
131
+ if (!prjGroup) {
132
+ throw new Error('PROJECT_GROUP_NOT_FOUND');
124
133
  }
125
- }
126
134
 
127
- const getProjects = module.exports.getProjects = () => {
135
+ tools.logInfo(`Project group found for : ${projectsGroupName} and eUI version : ${euiVersion}`);
136
+ const prjGroupFromEuiVersion = prjGroup[euiVersion];
137
+ if (!prjGroupFromEuiVersion) {
138
+ throw new Error('PROJECT_GROUP_NOT_FOUND_FOR_EUI_VERSION');
139
+ }
140
+
141
+ console.log(prjGroupFromEuiVersion);
142
+ return prjGroupFromEuiVersion;
143
+ };
144
+
145
+ const getProjects = (module.exports.getProjects = () => {
128
146
  const projects = innerGlobal.getConfig().projects;
129
- return Object.keys(projects).map(p => this.getProject(p));
130
- }
147
+ return Object.keys(projects).map((p) => this.getProject(p));
148
+ });
131
149
 
132
150
  module.exports.getCsdrProjects = () => {
133
-
134
151
  const projects = [];
135
152
 
136
153
  const csdrProjects = innerGlobal.getCsdrConfig(false).projects;
137
154
  const csdrPackages = innerPackages.getCsdrPackages();
138
155
 
139
- Object.keys(csdrProjects).forEach(prj => {
140
-
156
+ Object.keys(csdrProjects).forEach((prj) => {
141
157
  const project = csdrProjects[prj];
142
158
  const teams = new Set();
143
159
 
144
160
  if (project.packages) {
145
- project.packages.forEach(p => {
161
+ project.packages.forEach((p) => {
146
162
  const pkg = csdrPackages[p];
147
163
 
148
164
  if (!pkg) {
@@ -151,7 +167,7 @@ module.exports.getCsdrProjects = () => {
151
167
  }
152
168
 
153
169
  if (pkg.teams) {
154
- pkg.teams.forEach(team => teams.add(team));
170
+ pkg.teams.forEach((team) => teams.add(team));
155
171
  }
156
172
  });
157
173
  }
@@ -159,18 +175,14 @@ module.exports.getCsdrProjects = () => {
159
175
  project.teams = Array.from(teams);
160
176
 
161
177
  projects.push(project);
162
-
163
178
  });
164
179
  return projects;
165
- }
166
-
167
-
168
-
180
+ };
169
181
 
170
182
  module.exports.getTeamsProject = (projects, project) => {
171
183
  let teams = [];
172
184
 
173
- projects.forEach(p => {
185
+ projects.forEach((p) => {
174
186
  if (p.name === project) {
175
187
  teams = p.teams;
176
188
  }
@@ -179,8 +191,6 @@ module.exports.getTeamsProject = (projects, project) => {
179
191
  return teams;
180
192
  };
181
193
 
182
-
183
-
184
194
  module.exports.getBaseHref = (prj, version, providedBaseHref) => {
185
195
  if (providedBaseHref) {
186
196
  return providedBaseHref;
@@ -189,7 +199,6 @@ module.exports.getBaseHref = (prj, version, providedBaseHref) => {
189
199
  if (prj.build) {
190
200
  if (prj.build.baseHref) {
191
201
  return prj.build.baseHref;
192
-
193
202
  } else {
194
203
  if (prj.build.distribution) {
195
204
  const distOptions = prj.build.distribution;
@@ -198,7 +207,6 @@ module.exports.getBaseHref = (prj, version, providedBaseHref) => {
198
207
  let baseHref = distOptions.folder;
199
208
  if (distOptions.includeMajorVersion && version) {
200
209
  baseHref = '/' + baseHref + '-' + version.split('.')[0] + '.x' + '/';
201
-
202
210
  } else {
203
211
  if (distOptions.folder === '/') {
204
212
  baseHref = '/';
@@ -208,7 +216,6 @@ module.exports.getBaseHref = (prj, version, providedBaseHref) => {
208
216
  }
209
217
 
210
218
  return baseHref;
211
-
212
219
  } else {
213
220
  return null;
214
221
  }
@@ -217,8 +224,7 @@ module.exports.getBaseHref = (prj, version, providedBaseHref) => {
217
224
  }
218
225
 
219
226
  return null;
220
- }
221
-
227
+ };
222
228
 
223
229
  const getEuiVersionCore = (project) => {
224
230
  let version;
@@ -228,7 +234,6 @@ const getEuiVersionCore = (project) => {
228
234
 
229
235
  if (!tools.isFileExists(depsCompositeFile)) {
230
236
  tools.logWarning('Unable to find project version / dependencies-composite.json does not exist in project');
231
-
232
237
  } else {
233
238
  tools.logInfo(`parsing ${depsCompositeFile}`);
234
239
  const jsonFileContnet = JSON.parse(tools.getFileContent(depsCompositeFile));
@@ -236,14 +241,13 @@ const getEuiVersionCore = (project) => {
236
241
 
237
242
  if (!deps) {
238
243
  version = 'DEFAULT';
239
-
240
244
  } else {
241
245
  const euiDepsBase = deps['@eui/deps-base'];
242
246
 
243
247
  if (euiDepsBase) {
244
248
  let euiVersion = euiDepsBase.split('.')[0];
245
249
 
246
- if (euiVersion.substr(0,1) === '^') {
250
+ if (euiVersion.substr(0, 1) === '^') {
247
251
  euiVersion = euiVersion.substr(1);
248
252
  }
249
253
  version = `${euiVersion}.x`;
@@ -256,11 +260,9 @@ const getEuiVersionCore = (project) => {
256
260
  }
257
261
 
258
262
  return version;
259
- }
260
-
263
+ };
261
264
 
262
265
  module.exports.getProjectEuiVersion = (project) => {
263
-
264
266
  const version = getEuiVersionCore(project);
265
267
 
266
268
  if (version) {
@@ -270,8 +272,7 @@ module.exports.getProjectEuiVersion = (project) => {
270
272
  }
271
273
 
272
274
  return version;
273
- }
274
-
275
+ };
275
276
 
276
277
  module.exports.getLocalProjectsEuiVersion = () => {
277
278
  tools.logInfo('Getting local projects installed eUI version...');
@@ -289,9 +290,9 @@ module.exports.getLocalProjectsEuiVersion = () => {
289
290
  }
290
291
 
291
292
  versionsFound.push(version);
292
- })
293
+ });
293
294
 
294
295
  versionsFound = tools.removeArrayDuplicates(versionsFound);
295
296
 
296
297
  return versionsFound;
297
- }
298
+ };
@@ -0,0 +1,64 @@
1
+ 'use strict';
2
+
3
+ const tools = require('../../utils/tools');
4
+ const initUtils = require('./init-utils');
5
+ const installUtils = require('../install/install-utils');
6
+ const configUtils = require('../config/config-utils');
7
+
8
+ const { skipClone, skipInstall, build } = tools.getArgs();
9
+
10
+ module.exports.init = (finalResponse) => {
11
+ return (
12
+ Promise.resolve()
13
+ // Initializing .euirc.json local file - the core of CSDR operations
14
+ .then(() => {
15
+ // Initialize config
16
+ return configUtils.init.run(finalResponse);
17
+ })
18
+
19
+ // Initializing .meta based on .euirc.json for local respoisitories cloning
20
+ .then(() => {
21
+ return initUtils.meta.init();
22
+ })
23
+
24
+ // Cloning repositories based on the .meta file generated
25
+ .then(() => {
26
+ if (!skipClone) {
27
+ return initUtils.repos.init(finalResponse);
28
+ }
29
+ })
30
+
31
+ // adapt and inject particular root data/config for eUI version detected on project
32
+ // if multiple versions of eUI are detected on the same project, an exception is thrown
33
+ .then(() => {
34
+ return initUtils.global.initRootFilesAndResolutions();
35
+ })
36
+
37
+ // Install deps based on current config generated => take last know snapshots
38
+ .then(() => {
39
+ // this is only executed for local dev installation,
40
+ // in case of release the initialisation is managed by the application / package themselves
41
+ if (!build && !skipInstall) {
42
+ return installUtils.localDev.install();
43
+ }
44
+ })
45
+
46
+ // Attaching app scripts to root package.json
47
+ .then(() => {
48
+ return initUtils.projects.importScripts();
49
+ })
50
+
51
+ // Attaching extra tsconfig from project
52
+ .then(() => {
53
+ return initUtils.projects.importExtraTsConfig();
54
+ })
55
+
56
+ .then(() => {
57
+ tools.logSuccess('OK => Projects group successfully initialized');
58
+ })
59
+
60
+ .catch((e) => {
61
+ throw e;
62
+ })
63
+ );
64
+ };
@@ -5,6 +5,7 @@ const configUtils = require('../../csdr/config/config-utils');
5
5
 
6
6
  // inner modules
7
7
  const innerInitProject = require('./init-project');
8
+ const innerInitProjectsGroup = require('./init-projects-group');
8
9
  const innerInitPackage = require('./init-package');
9
10
  const innerInitRemote = require('./init-remote');
10
11
  const innerInitCustom = require('./init-custom');
@@ -13,7 +14,8 @@ const innerInitCustom = require('./init-custom');
13
14
  // Getting arguments if they are provided for the CI/CD pipeline
14
15
  const {
15
16
  project, team, pkg, branch, configOnly, skipClone, skipInstall, reset, pkgOnly, prjOnly,
16
- build, containerOnly, skipAppContainers, remote, euiVersion, remoteOnly, virtual, custom
17
+ build, containerOnly, skipAppContainers, remote, euiVersion, remoteOnly, virtual, custom,
18
+ projectsGroup,
17
19
  } = tools.getArgs();
18
20
 
19
21
 
@@ -36,7 +38,8 @@ module.exports.init = () => {
36
38
  build: build || false,
37
39
  containerOnly: containerOnly || false,
38
40
  skipAppContainers: skipAppContainers || false,
39
- custom: custom || false
41
+ custom: custom || false,
42
+ projectsGroup: projectsGroup || null,
40
43
  }
41
44
 
42
45
  // converting inputs args
@@ -63,7 +66,7 @@ module.exports.init = () => {
63
66
  .then(() => {
64
67
 
65
68
  // if no project has been provided we prompt for project and team selection
66
- if (!project && !pkg && !remote && !custom ) {
69
+ if (!project && !pkg && !remote && !custom && !projectsGroup ) {
67
70
  // TODO refactor to handle dynamic mywp-host-playground install (pre-remotes install etc...)
68
71
  // return initUtils.prompt.start();
69
72
  tools.logError('****************************************');
@@ -102,6 +105,9 @@ module.exports.init = () => {
102
105
 
103
106
  } else if (finalResponse.custom) {
104
107
  return innerInitCustom.init(finalResponse);
108
+
109
+ } else if (finalResponse.projectsGroup) {
110
+ return innerInitProjectsGroup.init(finalResponse);
105
111
  }
106
112
  })
107
113
 
@@ -1,115 +1,113 @@
1
1
  'use strict';
2
2
 
3
- const inquirer = require('inquirer');
4
-
5
- const tools = require('../../utils/tools');
6
- const configUtils = require('../config/config-utils');
7
-
8
-
9
3
  module.exports.start = () => {
10
- const csdrProjects = configUtils.projects.getCsdrProjects();
11
-
12
- tools.logTitle('Project & team selection');
13
-
14
- const startPrompt = async () => {
15
- try {
16
- const answersProject = await inquirer.prompt({
17
- type: "list",
18
- name: "project",
19
- message: "Which app / project do you work on?",
20
- choices: csdrProjects.filter((p) => {
21
- return p.initListVisible === true;
22
- }).map(p => ({ name: p.name, value: p.name }))
23
- });
24
-
25
- const answersTeam = await inquirer.prompt({
26
- type: "list",
27
- name: "team",
28
- message: "Which team do you work in?",
29
- choices: configUtils.projects.getTeamsProject(csdrProjects, answersProject.project)
30
- .map(t => ({ name: getLabelTeam(t), value: t }))
31
- .sort((a, b) => a.name > b.name ? 1 : a.name < b.name ? -1 : 0)
32
- .concat([{ name: '* Install all packages', value: 'all' }])
33
- });
34
-
35
- const project = answersProject.project;
36
- const team = answersTeam.team;
37
-
38
- return { project, team };
39
-
40
- } catch (e) {
41
- throw e;
42
- }
43
- };
44
-
45
-
46
- return Promise.resolve()
47
- .then(() => {
48
- return startPrompt();
49
- })
50
- .then((response) => {
51
- tools.logTitle('Validating selection...');
52
-
53
- if (!response.project) {
54
- throw Error('Project is NOT DEFINED');
55
- }
56
-
57
- if (response.team) {
58
- tools.logInfo(`Project: ${response.project}`);
59
- tools.logInfo(`Team: ${response.team}`);
60
- } else {
61
- tools.logInfo(`Project: ${response.project}`);
62
- }
63
-
64
- const { valid, message } = validateProjectAndTeam(csdrProjects, response.project, response.team);
65
-
66
- if (!valid) {
67
- throw Error(`Error: ${message ? message : 'The project or team provided does not exist.'}`);
68
- }
69
-
70
- tools.logSuccess();
71
-
72
- return response;
73
- })
74
- .catch((e) => {
75
- throw e;
76
- })
77
- }
78
-
79
-
80
-
81
-
82
- const getLabelTeam = (team) => {
83
- const groups = ['track1', 'track2', 'track3'];
84
-
85
- if (groups.indexOf(team) >= 0) {
86
- return `Install all packages of "${team}"`;
87
- }
88
- return team;
89
- };
90
-
91
-
92
- const validateProjectAndTeam = (projects, project, team) => {
93
- let valid = false;
94
- let message;
95
-
96
- projects.forEach((p) => {
97
- if (p.name === project) {
98
- if (!p.teams) {
99
- valid = true;
100
- return;
101
- }
102
-
103
- if (!team) {
104
- message = `You need to provide a team for project "${project}"`;
105
- }
4
+ const tools = require('../../utils/tools');
106
5
 
107
- if (p.teams.indexOf(team) >= 0 || team === 'all') {
108
- valid = true;
109
- }
110
- }
111
- });
6
+ tools.logWarning('WARNING: discontinued, follow documentation for installing PROJECT + packages from "npm run init" command');
112
7
 
113
- return { valid, message };
8
+ throw new Error('DISCONTINUED');
114
9
  };
115
10
 
11
+ // module.exports.start = () => {
12
+ // const configUtils = require('../config/co³nfig-utils');
13
+ // const inquirer = require('inquirer');
14
+ // const csdrProjects = configUtils.projects.getCsdrProjects();
15
+
16
+ // tools.logTitle('Project & team selection');
17
+
18
+ // const startPrompt = async () => {
19
+ // try {
20
+ // const answersProject = await inquirer.prompt({
21
+ // type: "list",
22
+ // name: "project",
23
+ // message: "Which app / project do you work on?",
24
+ // choices: csdrProjects.filter((p) => {
25
+ // return p.initListVisible === true;
26
+ // }).map(p => ({ name: p.name, value: p.name }))
27
+ // });
28
+
29
+ // const answersTeam = await inquirer.prompt({
30
+ // type: "list",
31
+ // name: "team",
32
+ // message: "Which team do you work in?",
33
+ // choices: configUtils.projects.getTeamsProject(csdrProjects, answersProject.project)
34
+ // .map(t => ({ name: getLabelTeam(t), value: t }))
35
+ // .sort((a, b) => a.name > b.name ? 1 : a.name < b.name ? -1 : 0)
36
+ // .concat([{ name: '* Install all packages', value: 'all' }])
37
+ // });
38
+
39
+ // const project = answersProject.project;
40
+ // const team = answersTeam.team;
41
+
42
+ // return { project, team };
43
+
44
+ // } catch (e) {
45
+ // throw e;
46
+ // }
47
+ // };
48
+
49
+ // return Promise.resolve()
50
+ // .then(() => {
51
+ // return startPrompt();
52
+ // })
53
+ // .then((response) => {
54
+ // tools.logTitle('Validating selection...');
55
+
56
+ // if (!response.project) {
57
+ // throw Error('Project is NOT DEFINED');
58
+ // }
59
+
60
+ // if (response.team) {
61
+ // tools.logInfo(`Project: ${response.project}`);
62
+ // tools.logInfo(`Team: ${response.team}`);
63
+ // } else {
64
+ // tools.logInfo(`Project: ${response.project}`);
65
+ // }
66
+
67
+ // const { valid, message } = validateProjectAndTeam(csdrProjects, response.project, response.team);
68
+
69
+ // if (!valid) {
70
+ // throw Error(`Error: ${message ? message : 'The project or team provided does not exist.'}`);
71
+ // }
72
+
73
+ // tools.logSuccess();
74
+
75
+ // return response;
76
+ // })
77
+ // .catch((e) => {
78
+ // throw e;
79
+ // })
80
+ // }
81
+
82
+ // const getLabelTeam = (team) => {
83
+ // const groups = ['track1', 'track2', 'track3'];
84
+
85
+ // if (groups.indexOf(team) >= 0) {
86
+ // return `Install all packages of "${team}"`;
87
+ // }
88
+ // return team;
89
+ // };
90
+
91
+ // const validateProjectAndTeam = (projects, project, team) => {
92
+ // let valid = false;
93
+ // let message;
94
+
95
+ // projects.forEach((p) => {
96
+ // if (p.name === project) {
97
+ // if (!p.teams) {
98
+ // valid = true;
99
+ // return;
100
+ // }
101
+
102
+ // if (!team) {
103
+ // message = `You need to provide a team for project "${project}"`;
104
+ // }
105
+
106
+ // if (p.teams.indexOf(team) >= 0 || team === 'all') {
107
+ // valid = true;
108
+ // }
109
+ // }
110
+ // });
111
+
112
+ // return { valid, message };
113
+ // };
@@ -9,12 +9,12 @@ const { skipEuiToolsClone, shallowClone } = tools.getArgs();
9
9
 
10
10
 
11
11
  const getRepos = (project, pkg, prjOnly, pkgOnly) => {
12
- const projects = innerMeta.getMetaProjects();
12
+ const metaProjects = innerMeta.getMetaProjects();
13
13
 
14
- const repos = Object.keys(projects).map((folder) => (
14
+ const repos = Object.keys(metaProjects).map((folder) => (
15
15
  {
16
16
  folder,
17
- uri: projects[folder],
17
+ uri: metaProjects[folder],
18
18
  }
19
19
  ));
20
20