@pega/dx-component-builder-sdk 0.1.0 → 0.1.2

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.
@@ -3,7 +3,7 @@ import inquirer from 'inquirer';
3
3
  import ora from 'ora';
4
4
  //import { element } from 'prop-types';
5
5
 
6
- import { LIST_COMPONENT_SERVICE_REST_ENDPOINT } from '../../constants.js';
6
+ import { LIST_COMPONENT_SERVICE_REST_ENDPOINT, COMPONENT_SCHEMA } from '../../constants.js';
7
7
  import {
8
8
  constructCompleteUrl,
9
9
  deleteLocalComponent,
@@ -21,25 +21,55 @@ export const SOURCE_OF_COMPONENT_TYPES = {
21
21
  LOCAL: 'Local'
22
22
  };
23
23
 
24
+
25
+ export const getOptionsCategory = (options) => {
26
+ let categoryType = null;
27
+ if (options.params[3]) {
28
+ let catType = options.params[3];
29
+
30
+ switch (catType.toLowerCase()) {
31
+ case "override" :
32
+ case "o" :
33
+ categoryType = "override";
34
+ break;
35
+ case "custom" :
36
+ case "c" :
37
+ categoryType = "custom";
38
+ break;
39
+ }
40
+ }
41
+ return categoryType;
42
+ }
43
+
24
44
  export const getDeleteComponentsQuestions = async (options, sourceOfComponentsOption) => {
25
45
  const defaultPegaServerConfig = await getPegaServerConfig();
46
+ const categoryType = getOptionsCategory(options);
26
47
 
27
48
  return [
49
+ {
50
+ name: 'category',
51
+ type: 'rawlist',
52
+ message: 'Category of components ?',
53
+ choices: COMPONENT_SCHEMA.category,
54
+ when() {
55
+ return !options.params[4] && categoryType == null;
56
+ }
57
+ },
28
58
  {
29
59
  name: 'sourceOfComponents',
30
60
  type: 'rawlist',
31
61
  message: 'Delete components from Server or Local ?',
32
62
  choices: Object.values(SOURCE_OF_COMPONENT_TYPES),
33
63
  default: defaultPegaServerConfig.sourceOfComponents,
34
- when() {
35
- return !options.params[3];
64
+ when(answers) {
65
+ return !options.params[4] && answers.category != 'override' && categoryType != 'override';
36
66
  }
37
67
  }
38
68
  ];
39
69
  };
40
70
 
41
- export const deleteLocalComponents = async sourceOfComponents => {
42
- const localComponents = await getComponentsObj(true);
71
+ export const deleteLocalComponents = async (sourceOfComponents, category = "custom") => {
72
+ const localComponents = await getComponentsObj(true, category);
43
73
  //const localComponentsAndSub = await getComponentsAndSubDirectory();
44
74
 
45
75
  if (localComponents.length > 0) {
@@ -58,7 +88,18 @@ export const deleteLocalComponents = async sourceOfComponents => {
58
88
  }
59
89
  ]);
60
90
  if (answers.confirmDeletion) {
61
- await deleteLocalComponent(answers.componentKey);
91
+ await deleteLocalComponent(answers.componentKey, category);
92
+
93
+ if (category === "override") {
94
+ // need to remove the map as well
95
+ if (answers.componentKey != undefined) {
96
+ await deleteFromComponentMap(answers.componentKey, category);
97
+ }
98
+ else {
99
+ console.log(chalk.bold.redBright(`No component in map: ` + componnetName));
100
+ }
101
+
102
+ }
62
103
  }
63
104
  } else {
64
105
  console.log(chalk.bold.redBright(`No custom components in ${sourceOfComponents}`));
@@ -1,18 +1,22 @@
1
1
  import inquirer from 'inquirer';
2
2
  import ora from 'ora';
3
3
  import chalk from 'chalk';
4
+ import { showVersion } from '../../util.js';
4
5
 
5
6
  import {
6
7
  deleteLocalComponents,
7
8
  SOURCE_OF_COMPONENT_TYPES,
8
9
  deleteServerComponents,
9
- getDeleteComponentsQuestions
10
+ getDeleteComponentsQuestions,
11
+ getOptionsCategory
10
12
  } from './helper.js';
11
13
 
14
+
15
+
12
16
  const deleteComponentsFn = async (sourceOfComponents, answers) => {
13
17
  switch (sourceOfComponents) {
14
18
  case SOURCE_OF_COMPONENT_TYPES.LOCAL: {
15
- await deleteLocalComponents(sourceOfComponents);
19
+ await deleteLocalComponents(sourceOfComponents, answers.category);
16
20
  break;
17
21
  }
18
22
  case SOURCE_OF_COMPONENT_TYPES.SERVER: {
@@ -27,19 +31,28 @@ const deleteComponentsFn = async (sourceOfComponents, answers) => {
27
31
  };
28
32
 
29
33
  export default async options => {
34
+ showVersion();
35
+
30
36
  let sourceOfComponentsOption = SOURCE_OF_COMPONENT_TYPES.LOCAL;
31
- if (options.params[3] === SOURCE_OF_COMPONENT_TYPES.LOCAL) {
37
+ if (options.params[4] === SOURCE_OF_COMPONENT_TYPES.LOCAL) {
32
38
  sourceOfComponentsOption = options.params[3];
33
39
  await deleteComponentsFn(sourceOfComponentsOption);
34
- } else if (options.params[3] === SOURCE_OF_COMPONENT_TYPES.SERVER) {
40
+ } else if (options.params[4] === SOURCE_OF_COMPONENT_TYPES.SERVER) {
35
41
  sourceOfComponentsOption = options.params[3];
36
42
  const questions = await getDeleteComponentsQuestions(options, sourceOfComponentsOption);
37
43
  const answers = await inquirer.prompt(questions);
38
44
  await deleteComponentsFn(sourceOfComponentsOption, answers);
39
45
  } else {
40
46
  const questions = await getDeleteComponentsQuestions(options);
41
- const answers = await inquirer.prompt(questions);
42
- const { sourceOfComponents } = answers;
47
+ let answers = await inquirer.prompt(questions);
48
+ const categoryType = getOptionsCategory(options);
49
+ let { sourceOfComponents, category } = answers;
50
+ if (!sourceOfComponents) {
51
+ sourceOfComponents = SOURCE_OF_COMPONENT_TYPES.LOCAL
52
+ }
53
+ if (categoryType != null) {
54
+ answers.category = categoryType;
55
+ }
43
56
  await deleteComponentsFn(sourceOfComponents, answers);
44
57
  }
45
58
  };
@@ -2,7 +2,7 @@ import chalk from 'chalk';
2
2
  import inquirer from 'inquirer';
3
3
  import ora from 'ora';
4
4
 
5
- import { LIST_COMPONENT_SERVICE_REST_ENDPOINT } from '../..//constants.js';
5
+ import { LIST_COMPONENT_SERVICE_REST_ENDPOINT, COMPONENT_SCHEMA } from '../..//constants.js';
6
6
  import {
7
7
  constructCompleteUrl,
8
8
  deleteLocalComponent,
@@ -22,19 +22,48 @@ export const SOURCE_OF_COMPONENT_TYPES = {
22
22
  LOCAL: 'Local'
23
23
  };
24
24
 
25
+ export const getOptionsCategory = (options) => {
26
+ let categoryType = null;
27
+ if (options.params[3]) {
28
+ let catType = options.params[3];
29
+
30
+ switch (catType.toLowerCase()) {
31
+ case "override" :
32
+ case "o" :
33
+ categoryType = "override";
34
+ break;
35
+ case "custom" :
36
+ case "c" :
37
+ categoryType = "custom";
38
+ break;
39
+ }
40
+ }
41
+ return categoryType;
42
+ }
43
+
25
44
  export const getDeleteComponentsQuestions = async (options, sourceOfComponentsOption) => {
26
45
  const defaultPegaServerConfig = await getPegaServerConfig();
27
-
46
+ const categoryType = getOptionsCategory(options);
28
47
 
29
48
  return [
49
+ {
50
+ name: 'category',
51
+ type: 'rawlist',
52
+ message: 'Category of components ?',
53
+ choices: COMPONENT_SCHEMA.category,
54
+ when() {
55
+ return !options.params[4] && categoryType == null;
56
+ }
57
+ },
30
58
  {
31
59
  name: 'sourceOfComponents',
32
60
  type: 'rawlist',
33
61
  message: 'Delete components from Server or Local ?',
34
62
  choices: Object.values(SOURCE_OF_COMPONENT_TYPES),
35
63
  default: defaultPegaServerConfig.sourceOfComponents,
36
- when() {
37
- return !options.params[3];
64
+ when(answers) {
65
+ return !options.params[4] && answers.category != 'override' && categoryType != 'override';
66
+
38
67
  }
39
68
  }
40
69
  ];
@@ -42,8 +71,8 @@ export const getDeleteComponentsQuestions = async (options, sourceOfComponentsOp
42
71
 
43
72
 
44
73
 
45
- export const deleteLocalComponents = async sourceOfComponents => {
46
- const localComponents = await getComponentsObj(true);
74
+ export const deleteLocalComponents = async (sourceOfComponents, category = "custom") => {
75
+ const localComponents = await getComponentsObj(true, category);
47
76
 
48
77
  for (var index in localComponents) {
49
78
  if (localComponents[index].type != undefined && localComponents[index].type === "separator") {
@@ -69,7 +98,18 @@ export const deleteLocalComponents = async sourceOfComponents => {
69
98
  for (var index in localComponents) {
70
99
  if (localComponents[index].type == undefined) {
71
100
  var componentToDelete = localComponents[index].value;
72
- await deleteLocalComponent(componentToDelete);
101
+ await deleteLocalComponent(componentToDelete, category);
102
+
103
+ if (category === "override") {
104
+ // need to remove the map as well
105
+ if (componentToDelete != undefined) {
106
+ await deleteFromComponentMap(componentToDelete, category);
107
+ }
108
+ else {
109
+ console.log(chalk.bold.redBright(`No component in map: ` + componentToDelete));
110
+ }
111
+
112
+ }
73
113
  }
74
114
 
75
115
  }
@@ -6,13 +6,16 @@ import {
6
6
  deleteLocalComponents,
7
7
  SOURCE_OF_COMPONENT_TYPES,
8
8
  deleteServerComponents,
9
- getDeleteComponentsQuestions
9
+ getDeleteComponentsQuestions,
10
+ getOptionsCategory
10
11
  } from './helper.js';
11
12
 
13
+ import { showVersion } from '../../util.js';
14
+
12
15
  const deleteComponentsFn = async (sourceOfComponents, answers) => {
13
16
  switch (sourceOfComponents) {
14
17
  case SOURCE_OF_COMPONENT_TYPES.LOCAL: {
15
- await deleteLocalComponents(sourceOfComponents);
18
+ await deleteLocalComponents(sourceOfComponents, answers.category);
16
19
  break;
17
20
  }
18
21
  case SOURCE_OF_COMPONENT_TYPES.SERVER: {
@@ -27,6 +30,8 @@ const deleteComponentsFn = async (sourceOfComponents, answers) => {
27
30
  };
28
31
 
29
32
  export default async options => {
33
+ showVersion();
34
+
30
35
  let sourceOfComponentsOption = SOURCE_OF_COMPONENT_TYPES.LOCAL;
31
36
  if (options.params[3] === SOURCE_OF_COMPONENT_TYPES.LOCAL) {
32
37
  sourceOfComponentsOption = options.params[3];
@@ -38,8 +43,15 @@ export default async options => {
38
43
  await deleteComponentsFn(sourceOfComponentsOption, answers);
39
44
  } else {
40
45
  const questions = await getDeleteComponentsQuestions(options);
41
- const answers = await inquirer.prompt(questions);
42
- const { sourceOfComponents } = answers;
46
+ let answers = await inquirer.prompt(questions);
47
+ const categoryType = getOptionsCategory(options);
48
+ let { sourceOfComponents, category } = answers;
49
+ if (!sourceOfComponents) {
50
+ sourceOfComponents = SOURCE_OF_COMPONENT_TYPES.LOCAL
51
+ }
52
+ if (categoryType != null) {
53
+ answers.category = categoryType;
54
+ }
43
55
  await deleteComponentsFn(sourceOfComponents, answers);
44
56
  }
45
57
  };
@@ -1,4 +1,5 @@
1
1
  export { default as createComponent } from './create/index.js';
2
+ export { default as overrideComponent } from './override/index.js';
2
3
  export { default as deleteComponent } from './delete/index.js';
3
4
  export { default as deleteAllComponents } from './delete-all/index.js';
4
5
  export { default as publishComponent } from './publish/index.js';
@@ -4,33 +4,64 @@ import https from 'https';
4
4
  import chalk from 'chalk';
5
5
  import fetch from 'node-fetch';
6
6
 
7
- import { LIST_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH } from '../../constants.js';
7
+ import { LIST_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH, COMPONENT_SCHEMA } from '../../constants.js';
8
8
  import { constructCompleteUrl, getComponents, getPegaServerConfig } from '../../util.js';
9
9
 
10
+
10
11
  export const SOURCE_OF_COMPONENT_TYPES = {
11
12
  SERVER: 'Server',
12
13
  LOCAL: 'Local'
13
14
  };
14
15
 
16
+ export const getOptionsCategory = (options) => {
17
+ let categoryType = null;
18
+ if (options.params[3]) {
19
+ let catType = options.params[3];
20
+
21
+ switch (catType.toLowerCase()) {
22
+ case "override" :
23
+ case "o" :
24
+ categoryType = "override";
25
+ break;
26
+ case "custom" :
27
+ case "c" :
28
+ categoryType = "custom";
29
+ break;
30
+ }
31
+ }
32
+ return categoryType;
33
+ }
34
+
15
35
  export const getListComponentsQuestions = async (options, sourceOfComponentsOption) => {
16
36
  const defaultPegaServerConfig = await getPegaServerConfig();
17
37
 
38
+ const categoryType = getOptionsCategory(options);
39
+
18
40
  return [
41
+ {
42
+ name: 'category',
43
+ type: 'rawlist',
44
+ message: 'Category of components ?',
45
+ choices: COMPONENT_SCHEMA.category,
46
+ when() {
47
+ return !options.params[4] && categoryType == null;
48
+ }
49
+ },
19
50
  {
20
51
  name: 'sourceOfComponents',
21
52
  type: 'rawlist',
22
53
  message: 'List components from Server or Local ?',
23
54
  choices: Object.values(SOURCE_OF_COMPONENT_TYPES),
24
55
  default: defaultPegaServerConfig.sourceOfComponents,
25
- when() {
26
- return !options.params[3];
56
+ when(answers) {
57
+ return !options.params[4] && answers.category != 'override' && categoryType != 'override';
27
58
  }
28
59
  }
29
60
  ];
30
61
  };
31
62
 
32
- export const listLocalComponents = async sourceOfComponents => {
33
- let localComponents = await getComponents();
63
+ export const listLocalComponents = async (sourceOfComponents, category = "custom") => {
64
+ let localComponents = await getComponents(false, category);
34
65
  localComponents = localComponents.map(name => ({ 'Rule name': name }));
35
66
  if (localComponents.length > 0) {
36
67
  console.log(chalk.bold.blueBright(`List of custom components in ${sourceOfComponents}`));
@@ -7,13 +7,17 @@ import {
7
7
  SOURCE_OF_COMPONENT_TYPES,
8
8
  getComponentsFromServer,
9
9
  displayServerComponents,
10
- getListComponentsQuestions
10
+ getListComponentsQuestions,
11
+ getOptionsCategory
11
12
  } from './helper.js';
12
13
 
14
+ import { showVersion } from '../../util.js';
15
+
16
+
13
17
  const getList = async (sourceOfComponents, answers) => {
14
18
  switch (sourceOfComponents) {
15
19
  case SOURCE_OF_COMPONENT_TYPES.LOCAL: {
16
- await listLocalComponents(sourceOfComponents);
20
+ await listLocalComponents(sourceOfComponents, answers.category);
17
21
  break;
18
22
  }
19
23
  case SOURCE_OF_COMPONENT_TYPES.SERVER: {
@@ -32,20 +36,30 @@ const getList = async (sourceOfComponents, answers) => {
32
36
  };
33
37
 
34
38
  export default async options => {
39
+
40
+ showVersion();
41
+
35
42
  let sourceOfComponentsOption = SOURCE_OF_COMPONENT_TYPES.LOCAL;
36
43
 
37
- if (options.params[3] === SOURCE_OF_COMPONENT_TYPES.LOCAL) {
44
+ if (options.params[4] === SOURCE_OF_COMPONENT_TYPES.LOCAL) {
38
45
  sourceOfComponentsOption = options.params[3];
39
46
  await getList(sourceOfComponentsOption);
40
- } else if (options.params[3] === SOURCE_OF_COMPONENT_TYPES.SERVER) {
47
+ } else if (options.params[4] === SOURCE_OF_COMPONENT_TYPES.SERVER) {
41
48
  sourceOfComponentsOption = options.params[3];
42
49
  const questions = await getListComponentsQuestions(options, sourceOfComponentsOption);
43
50
  const answers = await inquirer.prompt(questions);
44
51
  await getList(sourceOfComponentsOption, answers);
45
52
  } else {
46
53
  const questions = await getListComponentsQuestions(options);
47
- const answers = await inquirer.prompt(questions);
48
- const { sourceOfComponents } = answers;
54
+ let answers = await inquirer.prompt(questions);
55
+ const categoryType = getOptionsCategory(options);
56
+ let { sourceOfComponents, category } = answers;
57
+ if (!sourceOfComponents) {
58
+ sourceOfComponents = SOURCE_OF_COMPONENT_TYPES.LOCAL
59
+ }
60
+ if (categoryType != null) {
61
+ answers.category = categoryType;
62
+ }
49
63
  await getList(sourceOfComponents, answers);
50
64
  }
51
65
  };
@@ -80,6 +80,7 @@ export const updateComponentMap = async (componentKey, category = "custom") => {
80
80
  export const deleteFromComponentMap = async (componentKey, category = "custom") => {
81
81
  const pegaLocalComponentMapPath = path.join(path.resolve(), SDK_LOCAL_COMPONENT_MAP_FILENAME);
82
82
  const categoryDirectory = join("/", category.toLowerCase());
83
+ const pegaConfigJsonPath = path.join(path.resolve(), DXCB_CONFIG_JSON_FILENAME);
83
84
 
84
85
  const componentNameNoPrefix = removeComponentPrefix(componentKey);
85
86
  const componentName = convertIntoPascalCase(componentNameNoPrefix);
@@ -96,7 +97,8 @@ export const deleteFromComponentMap = async (componentKey, category = "custom")
96
97
  process.exit(1);
97
98
  }
98
99
 
99
- let importComponent = join("./", data[COMPONENTS_DIRECTORY_PATH], categoryDirectory, componentKey);
100
+ let importComponent = join(data[COMPONENTS_DIRECTORY_PATH], categoryDirectory, componentKey);
101
+ importComponent = "./".concat(importComponent);
100
102
 
101
103
  let importFull = "import ".concat(componentName).concat(" from '").concat(importComponent).concat("/';");
102
104
  let mapFull = "\"".concat(componentNameNoPrefix).concat("\" : " ).concat(componentName).concat(",");
@@ -0,0 +1,208 @@
1
+ import path from 'path';
2
+ import { URL, fileURLToPath } from 'url';
3
+ import fs from 'fs';
4
+ import { promisify } from 'util';
5
+ import { createRequire } from "module";
6
+ import { join } from 'path';
7
+
8
+ import inquirer from 'inquirer';
9
+ import ncp from 'ncp';
10
+ import chalk from 'chalk';
11
+ import { updateComponentMap } from '../map/map.js';
12
+
13
+ import { checkPathAccess, getTokenUrl, showVersion } from '../../util.js';
14
+
15
+
16
+ export const DXCB_CONFIG_JSON_FILENAME = 'dxcb.config.json';
17
+ export const DXCB_CONFIG_INTERNAL_JSON_FILENAME = 'src/dxcb.config.json';
18
+
19
+ const pegaConfigJsonPath = path.join(path.resolve(), DXCB_CONFIG_JSON_FILENAME);
20
+ const pegaConfigInternalJsonPath = path.join(path.resolve(), DXCB_CONFIG_INTERNAL_JSON_FILENAME);
21
+
22
+ import {
23
+ convertIntoPascalCase,
24
+ compileMustacheTemplate,
25
+ getComponentDirectoryPath,
26
+ getComponents,
27
+ getComponentDefaults,
28
+ sanitize,
29
+ validateSemver
30
+ } from '@pega/dx-component-builder-sdk/src/util.js';
31
+ import { COMPONENT_SCHEMA } from '../../constants.js';
32
+
33
+ const copy = promisify(ncp);
34
+
35
+ const copyComponentTemplate = async options => {
36
+ return copy(options.overrideDirectory, options.targetDirectory, {
37
+ clobber: false
38
+ });
39
+ };
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+ const validateCompile = async (
48
+ {
49
+ componentName,
50
+ type
51
+ },
52
+ options
53
+ ) => {
54
+
55
+ // componentName has sub directory if components are in a sub directory of main "type"
56
+ const overrideDirectory = `node_modules/@pega/react-sdk-overrides/lib/${type}/${componentName}`;
57
+
58
+ await checkPathAccess(overrideDirectory);
59
+
60
+ let componentKey = componentName;
61
+ if (componentKey.indexOf("/") >= 0) {
62
+ componentKey = componentKey.split("/")[1];
63
+ }
64
+ const typeLC = type.toLowerCase();
65
+ const targetDirectory = await getComponentDirectoryPath(join(typeLC, "/",componentKey), "override");
66
+
67
+ const components = await getComponents(false, "override");
68
+ if (components.includes(componentKey)) {
69
+ console.log(chalk.red(`${componentKey} component already exists in ${targetDirectory}`));
70
+ return;
71
+ }
72
+
73
+ await copyComponentTemplate({
74
+ ...options,
75
+ targetDirectory,
76
+ overrideDirectory
77
+ });
78
+
79
+
80
+ console.log(chalk.green(`> Created ${componentKey} component in ${targetDirectory}`));
81
+
82
+ const componentKeyWithType = join(type, componentKey);
83
+ await updateComponentMap(componentKeyWithType, "override");
84
+
85
+ console.log(chalk.green(`> Added ${componentKeyWithType} to map`));
86
+
87
+ };
88
+
89
+ export default async options => {
90
+ showVersion();
91
+
92
+ let promptType = null;
93
+ if (options.params[3]) {
94
+ let inputType = options.params[3];
95
+
96
+ switch (inputType.toLowerCase()) {
97
+ case "forms" :
98
+ case "f" :
99
+ promptType = "forms";
100
+ break;
101
+ case "templates" :
102
+ case "t" :
103
+ promptType = "templates";
104
+ break;
105
+ case "widgets" :
106
+ case "w" :
107
+ promptType = "widgets";
108
+ break;
109
+ case "designsystemextensions" :
110
+ case "des" :
111
+ case "d" :
112
+ promptType = "designSystemExtensions";
113
+ break;
114
+ case "infra" :
115
+ case "i" :
116
+ promptType = "infra";
117
+ break;
118
+ }
119
+ }
120
+
121
+ await checkPathAccess(pegaConfigJsonPath);
122
+
123
+ let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
124
+ data = data && JSON.parse(data);
125
+
126
+ const componentData = data['component'];
127
+
128
+ const { organization, library} = componentData;
129
+
130
+ let componentDefaults = await getComponentDefaults();
131
+ componentDefaults.library = library;
132
+
133
+
134
+ const questions = [
135
+ {
136
+ name: 'type',
137
+ type: 'rawlist',
138
+ message: 'Enter type of component',
139
+ choices: COMPONENT_SCHEMA.overrideType,
140
+ when (propmtType) {
141
+ return promptType === null;
142
+ }
143
+ },
144
+ {
145
+ name: 'componentName',
146
+ type: 'rawlist',
147
+ message: 'Enter component to be overridden',
148
+ choices: COMPONENT_SCHEMA.overrideComponent.forms,
149
+ when(answers) {
150
+ return answers.type === 'forms' || promptType === 'forms';
151
+ }
152
+ },
153
+ {
154
+ name: 'componentName',
155
+ type: 'rawlist',
156
+ message: 'Enter component to be overridden',
157
+ choices: COMPONENT_SCHEMA.overrideComponent.designSystemExtensions,
158
+ when(answers) {
159
+ return answers.type === 'designSystemExtensions' || promptType === 'designSystemExtensions';
160
+ }
161
+ },
162
+ {
163
+ name: 'componentName',
164
+ type: 'rawlist',
165
+ message: 'Enter component to be overridden',
166
+ choices: COMPONENT_SCHEMA.overrideComponent.infra,
167
+ when(answers) {
168
+ return answers.type === 'infra' || promptType === 'infra';
169
+ }
170
+ },
171
+ {
172
+ name: 'componentName',
173
+ type: 'rawlist',
174
+ message: 'Enter component to be overridden',
175
+ choices: COMPONENT_SCHEMA.overrideComponent.templates,
176
+ when(answers) {
177
+ return answers.type === 'templates' || promptType === 'templates';
178
+ }
179
+ },
180
+ {
181
+ name: 'componentName',
182
+ type: 'rawlist',
183
+ message: 'Enter component to be overridden',
184
+ choices: COMPONENT_SCHEMA.overrideComponent.widgets,
185
+ when(answers) {
186
+ return answers.type === 'widgets' || promptType === 'widgets';
187
+ }
188
+ },
189
+
190
+ ];
191
+
192
+ await inquirer.prompt(questions).then(async answers => {
193
+ let {
194
+ componentName,
195
+ type
196
+ } = answers;
197
+ if (promptType) type = promptType;
198
+
199
+ await validateCompile(
200
+ {
201
+ componentName,
202
+ type
203
+ },
204
+ options
205
+ );
206
+ });
207
+
208
+ };
@@ -3,7 +3,7 @@ import Listr from 'listr';
3
3
  import chalk from 'chalk';
4
4
 
5
5
  import validate from '../validator/index.js';
6
- import { getComponentDirectoryPath } from '../../util.js';
6
+ import { getComponentDirectoryPath, showVersion } from '../../util.js';
7
7
  import bundleComponent from '../bundle/index.js';
8
8
  import { updateComponentMap } from '../map/map.js';
9
9
  import { lintComponent } from '../linter/index.js';
@@ -11,6 +11,8 @@ import { lintComponent } from '../linter/index.js';
11
11
  import { getPublishComponentQuestions, publishComponentToServer, zipComponent } from './helper.js';
12
12
 
13
13
  export default async options => {
14
+ showVersion();
15
+
14
16
  const questions = await getPublishComponentQuestions();
15
17
  const answers = await inquirer.prompt(questions);
16
18
  const { componentKey, sourceMap, devBuild } = answers;
@@ -9,12 +9,15 @@ import { updateComponentMap } from '../map/map.js';
9
9
 
10
10
  import { getPublishComponentQuestions, publishComponentToServer, zipComponent } from './helper.js';
11
11
  import {
12
- getComponentsObj,
13
- getComponentDirectoryPath
12
+ getComponentsObj,
13
+ getComponentDirectoryPath,
14
+ showVersion
14
15
  } from '../../util.js';
15
16
  import { lintComponent } from '../linter/index.js';
16
17
 
17
18
  export default async options => {
19
+ showVersion();
20
+
18
21
  const components = await getComponentsObj();
19
22
  const questions = await getPublishComponentQuestions();
20
23
  const answers = await inquirer.prompt(questions);