@pega/dx-component-builder-sdk 0.1.5 → 0.1.7

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 (35) hide show
  1. package/package.json +1 -1
  2. package/src/constants.js +8 -4
  3. package/src/tasks/build/helper.js +4 -22
  4. package/src/tasks/build/index.js +54 -7
  5. package/src/tasks/bundle/index.js +2 -2
  6. package/src/tasks/create/index.js +50 -4
  7. package/src/tasks/create/templates/SDK-React/Field/Boolean/demo.stories.jsx.mustache +26 -14
  8. package/src/tasks/create/templates/SDK-React/Field/Boolean/mock.stories.js.mustache +15 -0
  9. package/src/tasks/create/templates/SDK-React/Field/Decimal/demo.stories.jsx.mustache +17 -10
  10. package/src/tasks/create/templates/SDK-React/Field/Decimal/mock.stories.js.mustache +14 -0
  11. package/src/tasks/create/templates/SDK-React/Field/Decimal-Currency/demo.stories.jsx.mustache +16 -10
  12. package/src/tasks/create/templates/SDK-React/Field/Decimal-Currency/mock.stories.js.mustache +14 -0
  13. package/src/tasks/create/templates/SDK-React/Field/Decimal-Percentage/demo.stories.jsx.mustache +17 -10
  14. package/src/tasks/create/templates/SDK-React/Field/Decimal-Percentage/mock.stories.js.mustache +14 -0
  15. package/src/tasks/create/templates/SDK-React/Field/Integer/demo.stories.jsx.mustache +16 -10
  16. package/src/tasks/create/templates/SDK-React/Field/Integer/mock.stories.js.mustache +14 -0
  17. package/src/tasks/create/templates/SDK-React/Field/Picklist/demo.stories.jsx.mustache +25 -16
  18. package/src/tasks/create/templates/SDK-React/Field/Picklist/mock.stories.js.mustache +30 -0
  19. package/src/tasks/create/templates/SDK-React/Field/Text-Phone/demo.stories.jsx.mustache +3 -1
  20. package/src/tasks/create/templates/SDK-React/Template/PAGE/demo.stories.jsx.mustache +79 -0
  21. package/src/tasks/create/templates/SDK-React/Template/PAGE/mock.stories.js.mustache +115 -0
  22. package/src/tasks/delete/helper.js +9 -24
  23. package/src/tasks/delete/index.js +2 -3
  24. package/src/tasks/delete-all/helper.js +9 -23
  25. package/src/tasks/delete-all/index.js +2 -3
  26. package/src/tasks/list/helper.js +3 -21
  27. package/src/tasks/list/index.js +2 -3
  28. package/src/tasks/map/map.js +4 -3
  29. package/src/tasks/override/index.js +13 -13
  30. package/src/tasks/publish/helper.js +77 -15
  31. package/src/tasks/publish/index.js +103 -15
  32. package/src/tasks/publish-all/helper.js +77 -13
  33. package/src/tasks/publish-all/index.js +109 -25
  34. package/src/tasks/validator/index.js +7 -5
  35. package/src/util.js +69 -17
@@ -13,12 +13,39 @@ import {
13
13
  getComponentsObj,
14
14
  getComponentsAndSubDirectory,
15
15
  getPegaServerConfig,
16
- validateRulesetVersion
16
+ validateRulesetVersion,
17
+ getOptionsCategory
17
18
  } from '../../util.js';
18
- import { PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH } from '../../constants.js';
19
+ import { PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH, COMPONENT_SCHEMA, CATEGORY_CONSTELLATION, CATEGORY_CUSTOM } from '../../constants.js';
19
20
 
20
- export const getPublishComponentQuestions = async () => {
21
- const components = await getComponentsObj(true);
21
+
22
+ export const mapConfigJsonToCompanion = async ( componentKey ) => {
23
+ const srcDirectory = await getComponentDirectoryPath(componentKey, CATEGORY_CUSTOM);
24
+ const companionDirectory = await getComponentDirectoryPath(componentKey, CATEGORY_CONSTELLATION);
25
+ let configContent = fs.readFileSync(`${srcDirectory}/config.json`, { encoding: 'utf8' });
26
+
27
+ fs.writeFileSync(`${companionDirectory}/config.json`, configContent, { encoding: 'utf8' });
28
+
29
+ }
30
+
31
+ export const getBuildCategory = async (options) => {
32
+ const categoryType = getOptionsCategory(options);
33
+
34
+ return [
35
+ {
36
+ name: 'category',
37
+ type: 'rawlist',
38
+ message: 'Category of components ?',
39
+ choices: COMPONENT_SCHEMA.category,
40
+ when() {
41
+ return !options.params[4] && categoryType == null;
42
+ }
43
+ }
44
+ ];
45
+ };
46
+
47
+ export const getPublishComponentQuestions = async (category) => {
48
+ const components = await getComponentsObj(true, category);
22
49
  const defaultPegaConfig = await getPegaServerConfig();
23
50
 
24
51
  return [
@@ -64,24 +91,59 @@ export const getPublishComponentQuestions = async () => {
64
91
  ];
65
92
  };
66
93
 
67
- export const zipComponent = async componentKey => {
68
- const srcDirectory = await getComponentDirectoryPath(componentKey);
94
+ export const zipComponent = async (componentKey, category = CATEGORY_CUSTOM) => {
95
+ const srcDirectory = await getComponentDirectoryPath(componentKey, category);
69
96
  const buildDirectory = await path.join(path.resolve(), 'dist/components', componentKey);
70
97
  const configJson = `${srcDirectory}/config.json`;
98
+ const configExtJson = `${srcDirectory}/config-ext.json`;
71
99
 
72
100
  const zip = new AdmZip();
73
101
 
74
102
  zip.addLocalFolder(srcDirectory, 'src/');
75
- zip.addLocalFile(configJson);
103
+ if (category === CATEGORY_CUSTOM || category == CATEGORY_CONSTELLATION) {
104
+ zip.addLocalFile(configJson);
105
+ }
106
+ else {
107
+ // check to see if have file
108
+ if (fs.existsSync(configExtJson)) {
109
+ zip.addLocalFile(configExtJson);
110
+ }
111
+
112
+ }
113
+
76
114
  zip.addLocalFolder(buildDirectory);
77
115
  const zipContent = zip.toBuffer().toString('base64');
78
116
 
79
- const configContent = Buffer.from(fs.readFileSync(`${srcDirectory}/config.json`)).toString();
80
- fs.rmdir('dist', { recursive: true }, err => {
81
- if (err) {
82
- throw err;
117
+ let configContent = "{ }";
118
+ if (category === CATEGORY_CUSTOM || category === CATEGORY_CONSTELLATION) {
119
+ configContent = Buffer.from(fs.readFileSync(`${srcDirectory}/config.json`)).toString();
120
+ fs.rmdir('dist', { recursive: true }, err => {
121
+ if (err) {
122
+ throw err;
123
+ }
124
+ });
125
+ }
126
+ else {
127
+ if (fs.existsSync(configExtJson)) {
128
+ configContent = Buffer.from(fs.readFileSync(`${srcDirectory}/config-ext.json`)).toString();
129
+ fs.rmdir('dist', { recursive: true }, err => {
130
+ if (err) {
131
+ throw err;
132
+ }
133
+ });
83
134
  }
84
- });
135
+ else {
136
+ const tempConfig = { "componentKey" : ""};
137
+ if (componentKey.indexOf("/") >= 0) {
138
+ componentKey = componentKey.split("/")[1];
139
+ }
140
+ tempConfig.componentKey = `${componentKey}`;
141
+
142
+ configContent = JSON.stringify(tempConfig);
143
+ }
144
+
145
+ }
146
+
85
147
  return { zipContent, configContent };
86
148
  };
87
149
 
@@ -127,7 +189,7 @@ export const publishComponentToServer = async data => {
127
189
  const respData = JSON.parse(resp);
128
190
  if (status === 401) {
129
191
  throw new Error(
130
- 'Error occured in authentication. Please regenerate using authenticate'
192
+ 'Error occurred in authentication. Please regenerate using authenticate'
131
193
  );
132
194
  // console.log(accessTokenUri, refreshToken);
133
195
  /* TODO - Handle refresh_token */
@@ -139,9 +201,9 @@ export const publishComponentToServer = async data => {
139
201
  })
140
202
  .catch(e => Promise.reject(`${chalk.bold.red(e)}`));
141
203
  } else {
142
- throw new Error(`Error occured in authentication. Please regenerate using authenticate`);
204
+ throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
143
205
  }
144
206
  } catch (err) {
145
- throw new Error(`Error occured in authentication. Please regenerate using authenticate`);
207
+ throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
146
208
  }
147
209
  };
@@ -3,17 +3,28 @@ import Listr from 'listr';
3
3
  import chalk from 'chalk';
4
4
 
5
5
  import validate from '../validator/index.js';
6
- import { getComponentDirectoryPath, showVersion } from '../../util.js';
6
+ import { getComponentDirectoryPath, showVersion, getOptionsCategory } 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';
10
+ import { CATEGORY_CONSTELLATION, CATEGORY_CUSTOM } from '../../constants.js';
11
+
12
+
13
+ import { getPublishComponentQuestions, publishComponentToServer, zipComponent, getBuildCategory, mapConfigJsonToCompanion } from './helper.js';
10
14
 
11
- import { getPublishComponentQuestions, publishComponentToServer, zipComponent } from './helper.js';
12
15
 
13
16
  export default async options => {
14
17
  showVersion();
15
18
 
16
- const questions = await getPublishComponentQuestions();
19
+ const catQuestion = await getBuildCategory(options);
20
+ const catAnwers = await inquirer.prompt(catQuestion);
21
+
22
+ let category = catAnwers.category;
23
+ if (category == null) {
24
+ category = getOptionsCategory(options);
25
+ }
26
+
27
+ const questions = await getPublishComponentQuestions(category);
17
28
  const answers = await inquirer.prompt(questions);
18
29
  const { componentKey, sourceMap, devBuild } = answers;
19
30
 
@@ -21,54 +32,131 @@ export default async options => {
21
32
  ...answers
22
33
  };
23
34
 
24
- const tasks = new Listr(
35
+ const customTasks = new Listr(
25
36
  [
37
+
26
38
  {
27
39
  title: 'Validate config schema',
28
40
  task: async () => {
29
- await validate(componentKey);
41
+ await validate(componentKey, category);
30
42
  }
31
43
  },
32
44
  {
33
45
  title: 'Lint component',
34
46
  task: async () => {
35
- const targetDirectory = await getComponentDirectoryPath(componentKey);
47
+ const targetDirectory = await getComponentDirectoryPath(componentKey, category);
36
48
  // console.log(`in buildComponent Lint component task: componentKey: ${componentKey} targetDirectory: ${targetDirectory}`);
37
49
  await lintComponent(targetDirectory);
38
50
  }
39
51
  },
40
52
  {
41
- title: 'Bundle Component',
42
- task: async () => await bundleComponent(componentKey, sourceMap, devBuild),
53
+ title: 'Bundle component',
54
+ task: async () => await bundleComponent(componentKey, sourceMap, devBuild, category),
43
55
  skip: () => (options.skipBundle ? 'Skipped bundling component' : undefined)
44
56
  },
45
57
  {
46
- title: 'Update Component Map',
58
+ title: 'Update component map',
47
59
  task: async () => {
48
60
  await updateComponentMap(componentKey);
49
61
  }
50
62
  },
51
63
  {
52
- title: 'Zip Component',
64
+ title: 'Lint companion component',
65
+ task: async () => {
66
+ const targetDirectory = await getComponentDirectoryPath(componentKey, CATEGORY_CONSTELLATION);
67
+ // console.log(`in buildComponent Lint component task: componentKey: ${componentKey} targetDirectory: ${targetDirectory}`);
68
+ await lintComponent(targetDirectory);
69
+ }
70
+ },
71
+ {
72
+ title: 'Map config to companion component',
73
+ task: async () => {
74
+ mapConfigJsonToCompanion(componentKey);
75
+ }
76
+ },
77
+ {
78
+ title: 'Bundle companion component',
79
+ task: async () => await bundleComponent(componentKey, sourceMap, devBuild, CATEGORY_CONSTELLATION),
80
+ skip: () => (options.skipBundle ? 'Skipped bundling component' : undefined)
81
+ },
82
+ {
83
+ title: 'Zip companion component',
84
+ task: async () => {
85
+ const output = await zipComponent(componentKey, CATEGORY_CONSTELLATION);
86
+ content = { ...content, ...output };
87
+ }
88
+ },
89
+ {
90
+ title: 'Publish companion component',
91
+ task: async () => {
92
+ await publishComponentToServer(content);
93
+ }
94
+ }
95
+ ],
96
+ {
97
+ exitOnError: true
98
+ }
99
+ );
100
+
101
+ const overrideTasks = new Listr(
102
+ [
103
+ {
104
+ title: 'Validate config schema',
105
+ task: async () => {
106
+ await validate(componentKey, category);
107
+ }
108
+ },
109
+ {
110
+ title: 'Lint component',
111
+ task: async () => {
112
+ const targetDirectory = await getComponentDirectoryPath(componentKey, category);
113
+ // console.log(`in buildComponent Lint component task: componentKey: ${componentKey} targetDirectory: ${targetDirectory}`);
114
+ await lintComponent(targetDirectory);
115
+ }
116
+ },
117
+ {
118
+ title: 'Bundle component',
119
+ task: async () => await bundleComponent(componentKey, sourceMap, devBuild, category),
120
+ skip: () => (options.skipBundle ? 'Skipped bundling component' : undefined)
121
+ },
122
+ {
123
+ title: 'Update component map',
53
124
  task: async () => {
54
- const output = await zipComponent(componentKey);
125
+ await updateComponentMap(componentKey, category);
126
+ }
127
+ },
128
+ {
129
+ title: 'Zip component',
130
+ task: async () => {
131
+ const output = await zipComponent(componentKey, category);
55
132
  content = { ...content, ...output };
56
133
  }
57
134
  },
135
+ /*
58
136
  {
59
- title: 'Publish Component',
137
+ title: 'Publish component',
60
138
  task: async () => {
61
139
  await publishComponentToServer(content);
62
140
  }
63
141
  }
142
+ */
64
143
  ],
65
144
  {
66
145
  exitOnError: true
67
146
  }
68
147
  );
69
148
 
70
- await tasks.run().catch(err => {
71
- console.log(chalk.bold.red(err.toString()));
72
- });
149
+ if (category === CATEGORY_CUSTOM) {
150
+ await customTasks.run().catch(err => {
151
+ console.log(chalk.bold.red(err.toString()));
152
+ });
153
+ }
154
+ else {
155
+ await overrideTasks.run().catch(err => {
156
+ console.log(chalk.bold.red(err.toString()));
157
+ });
158
+
159
+ }
160
+
73
161
  return true;
74
162
  };
@@ -9,11 +9,40 @@ import chalk from 'chalk';
9
9
  import {
10
10
  constructCompleteUrl,
11
11
  getComponentDirectoryPath,
12
+ getComponents,
12
13
  getComponentsObj,
14
+ getComponentsAndSubDirectory,
13
15
  getPegaServerConfig,
14
- validateRulesetVersion
16
+ validateRulesetVersion,
17
+ getOptionsCategory
15
18
  } from '../../util.js';
16
- import { PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH } from '../../constants.js';
19
+ import { PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH, COMPONENT_SCHEMA, CATEGORY_CONSTELLATION, CATEGORY_CUSTOM } from '../../constants.js';
20
+
21
+
22
+ export const mapConfigJsonToCompanion = async ( componentKey ) => {
23
+ const srcDirectory = await getComponentDirectoryPath(componentKey, CATEGORY_CUSTOM);
24
+ const companionDirectory = await getComponentDirectoryPath(componentKey, CATEGORY_CONSTELLATION);
25
+ let configContent = fs.readFileSync(`${srcDirectory}/config.json`, { encoding: 'utf8' });
26
+
27
+ fs.writeFileSync(`${companionDirectory}/config.json`, configContent, { encoding: 'utf8' });
28
+
29
+ }
30
+
31
+ export const getBuildCategory = async (options) => {
32
+ const categoryType = getOptionsCategory(options);
33
+
34
+ return [
35
+ {
36
+ name: 'category',
37
+ type: 'rawlist',
38
+ message: 'Category of components ?',
39
+ choices: COMPONENT_SCHEMA.category,
40
+ when() {
41
+ return !options.params[4] && categoryType == null;
42
+ }
43
+ }
44
+ ];
45
+ };
17
46
 
18
47
  export const getPublishComponentQuestions = async () => {
19
48
  const components = await getComponentsObj();
@@ -56,24 +85,59 @@ export const getPublishComponentQuestions = async () => {
56
85
  ];
57
86
  };
58
87
 
59
- export const zipComponent = async componentKey => {
60
- const srcDirectory = await getComponentDirectoryPath(componentKey);
88
+ export const zipComponent = async (componentKey, category = CATEGORY_CUSTOM) => {
89
+ const srcDirectory = await getComponentDirectoryPath(componentKey, category);
61
90
  const buildDirectory = await path.join(path.resolve(), 'dist/components', componentKey);
62
91
  const configJson = `${srcDirectory}/config.json`;
92
+ const configExtJson = `${srcDirectory}/config-ext.json`;
63
93
 
64
94
  const zip = new AdmZip();
65
95
 
66
96
  zip.addLocalFolder(srcDirectory, 'src/');
67
- zip.addLocalFile(configJson);
97
+ if (category === CATEGORY_CUSTOM || category == CATEGORY_CONSTELLATION) {
98
+ zip.addLocalFile(configJson);
99
+ }
100
+ else {
101
+ // check to see if have file
102
+ if (fs.existsSync(configExtJson)) {
103
+ zip.addLocalFile(configExtJson);
104
+ }
105
+
106
+ }
107
+
68
108
  zip.addLocalFolder(buildDirectory);
69
109
  const zipContent = zip.toBuffer().toString('base64');
70
110
 
71
- const configContent = Buffer.from(fs.readFileSync(`${srcDirectory}/config.json`)).toString();
72
- fs.rmdir('dist', { recursive: true }, err => {
73
- if (err) {
74
- throw err;
111
+ let configContent = "{ }";
112
+ if (category === CATEGORY_CUSTOM || category === CATEGORY_CONSTELLATION) {
113
+ configContent = Buffer.from(fs.readFileSync(`${srcDirectory}/config.json`)).toString();
114
+ fs.rm('dist', { recursive: true }, err => {
115
+ if (err) {
116
+ throw err;
117
+ }
118
+ });
119
+ }
120
+ else {
121
+ if (fs.existsSync(configExtJson)) {
122
+ configContent = Buffer.from(fs.readFileSync(`${srcDirectory}/config-ext.json`)).toString();
123
+ fs.rm('dist', { recursive: true }, err => {
124
+ if (err) {
125
+ throw err;
126
+ }
127
+ });
75
128
  }
76
- });
129
+ else {
130
+ const tempConfig = { "componentKey" : ""};
131
+ if (componentKey.indexOf("/") >= 0) {
132
+ componentKey = componentKey.split("/")[1];
133
+ }
134
+ tempConfig.componentKey = `${componentKey}`;
135
+
136
+ configContent = JSON.stringify(tempConfig);
137
+ }
138
+
139
+ }
140
+
77
141
  return { zipContent, configContent };
78
142
  };
79
143
 
@@ -119,7 +183,7 @@ export const publishComponentToServer = async data => {
119
183
  const respData = JSON.parse(resp);
120
184
  if (status === 401) {
121
185
  throw new Error(
122
- 'Error occured in authentication. Please regenerate using authenticate'
186
+ 'Error occurred in authentication. Please regenerate using authenticate'
123
187
  );
124
188
  // console.log(accessTokenUri, refreshToken);
125
189
  /* TODO - Handle refresh_token */
@@ -131,9 +195,9 @@ export const publishComponentToServer = async data => {
131
195
  })
132
196
  .catch(e => Promise.reject(`${chalk.bold.red(e)}`));
133
197
  } else {
134
- throw new Error(`Error occured in authentication. Please regenerate using authenticate`);
198
+ throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
135
199
  }
136
200
  } catch (err) {
137
- throw new Error(`Error occured in authentication. Please regenerate using authenticate`);
201
+ throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
138
202
  }
139
203
  };
@@ -3,23 +3,30 @@ import Listr from 'listr';
3
3
  import chalk from 'chalk';
4
4
 
5
5
  import validate from '../validator/index.js';
6
-
6
+ import { getComponentDirectoryPath, showVersion, getOptionsCategory, getComponentsObj } from '../../util.js';
7
7
  import bundleComponent from '../bundle/index.js';
8
- import { updateComponentMap } from '../map/map.js';
9
-
10
- import { getPublishComponentQuestions, publishComponentToServer, zipComponent } from './helper.js';
11
- import {
12
- getComponentsObj,
13
- getComponentDirectoryPath,
14
- showVersion
15
- } from '../../util.js';
8
+ import { updateComponentMap } from '../map/map.js';
16
9
  import { lintComponent } from '../linter/index.js';
10
+ import { CATEGORY_CONSTELLATION, CATEGORY_CUSTOM } from '../../constants.js';
11
+
12
+
13
+ import { getPublishComponentQuestions, publishComponentToServer, zipComponent, getBuildCategory, mapConfigJsonToCompanion } from './helper.js';
14
+
15
+
17
16
 
18
17
  export default async options => {
19
18
  showVersion();
20
19
 
21
- const components = await getComponentsObj();
22
- const questions = await getPublishComponentQuestions();
20
+ const catQuestion = await getBuildCategory(options);
21
+ const catAnwers = await inquirer.prompt(catQuestion);
22
+
23
+ let category = catAnwers.category;
24
+ if (category == null) {
25
+ category = getOptionsCategory(options);
26
+ }
27
+
28
+ const components = await getComponentsObj(false, category);
29
+ const questions = await getPublishComponentQuestions(category);
23
30
  const answers = await inquirer.prompt(questions);
24
31
  const {sourceMap, devBuild } = answers;
25
32
 
@@ -29,59 +36,136 @@ export default async options => {
29
36
 
30
37
  var componentKey;
31
38
 
32
- const tasks = new Listr(
39
+ const customTasks = new Listr(
33
40
  [
41
+
34
42
  {
35
43
  title: 'Validate config schema',
36
44
  task: async () => {
37
- await validate(componentKey);
45
+ await validate(componentKey, category);
38
46
  }
39
47
  },
40
48
  {
41
49
  title: 'Lint component',
42
50
  task: async () => {
43
- const targetDirectory = await getComponentDirectoryPath(componentKey);
51
+ const targetDirectory = await getComponentDirectoryPath(componentKey, category);
52
+ // console.log(`in buildComponent Lint component task: componentKey: ${componentKey} targetDirectory: ${targetDirectory}`);
53
+ await lintComponent(targetDirectory);
54
+ }
55
+ },
56
+ {
57
+ title: 'Update component map',
58
+ task: async () => {
59
+ await updateComponentMap(componentKey);
60
+ }
61
+ },
62
+ {
63
+ title: 'Lint companion component',
64
+ task: async () => {
65
+ const targetDirectory = await getComponentDirectoryPath(componentKey, CATEGORY_CONSTELLATION);
66
+ // console.log(`in buildComponent Lint component task: componentKey: ${componentKey} targetDirectory: ${targetDirectory}`);
67
+ await lintComponent(targetDirectory);
68
+ }
69
+ },
70
+ {
71
+ title: 'Map config to companion component',
72
+ task: async () => {
73
+ mapConfigJsonToCompanion(componentKey);
74
+ }
75
+ },
76
+ {
77
+ title: 'Bundle companion component',
78
+ task: async () => await bundleComponent(componentKey, sourceMap, devBuild, CATEGORY_CONSTELLATION),
79
+ skip: () => (options.skipBundle ? 'Skipped bundling component' : undefined)
80
+ },
81
+ {
82
+ title: 'Zip companion component',
83
+ task: async () => {
84
+ const output = await zipComponent(componentKey, CATEGORY_CONSTELLATION);
85
+ content = { ...content, ...output };
86
+ }
87
+ },
88
+ {
89
+ title: 'Publish companion component',
90
+ task: async () => {
91
+ await publishComponentToServer(content);
92
+ }
93
+ }
94
+ ],
95
+ {
96
+ exitOnError: true
97
+ }
98
+ );
99
+
100
+ const overrideTasks = new Listr(
101
+ [
102
+ {
103
+ title: 'Validate config schema',
104
+ task: async () => {
105
+ await validate(componentKey, category);
106
+ }
107
+ },
108
+ {
109
+ title: 'Lint component',
110
+ task: async () => {
111
+ const targetDirectory = await getComponentDirectoryPath(componentKey, category);
44
112
  // console.log(`in buildComponent Lint component task: componentKey: ${componentKey} targetDirectory: ${targetDirectory}`);
45
113
  await lintComponent(targetDirectory);
46
114
  }
47
115
  },
48
116
  {
49
117
  title: 'Bundle Component',
50
- task: async () => await bundleComponent(componentKey, sourceMap, devBuild),
118
+ task: async () => await bundleComponent(componentKey, sourceMap, devBuild, category),
51
119
  skip: () => (options.skipBundle ? 'Skipped bundling component' : undefined)
52
120
  },
53
121
  {
54
122
  title: 'Update Component Map',
55
123
  task: async () => {
56
- await updateComponentMap(componentKey);
124
+ await updateComponentMap(componentKey, category);
57
125
  }
58
126
  },
59
127
  {
60
128
  title: 'Zip Component',
61
129
  task: async () => {
62
- const output = await zipComponent(componentKey);
130
+ const output = await zipComponent(componentKey, category);
63
131
  content = { ...content, ...output };
64
132
  }
65
- },
133
+ }
134
+ /*
66
135
  {
67
- title: 'Publish Component',
136
+ title: 'Publish component',
68
137
  task: async () => {
69
138
  await publishComponentToServer(content);
70
139
  }
71
140
  }
141
+ */
72
142
  ],
73
143
  {
74
144
  exitOnError: true
75
145
  }
76
146
  );
77
147
 
78
- for (var index in components) {
79
- componentKey = components[index].value;
80
- console.log(chalk.bold.green("Publishing: " + components[index].name));
81
- await tasks.run().catch(err => {
82
- console.log(chalk.bold.red(err.toString()));
83
- });
148
+
149
+ if (category === CATEGORY_CUSTOM) {
150
+ for (var index in components) {
151
+ componentKey = components[index].value;
152
+ console.log(chalk.bold.green("Publishing: " + components[index].name));
153
+ await customTasks.run().catch(err => {
154
+ console.log(chalk.bold.red(err.toString()));
155
+ });
156
+ }
84
157
  }
158
+ else {
159
+ for (var index in components) {
160
+ componentKey = components[index].value;
161
+ console.log(chalk.bold.green("Publishing: " + components[index].name));
162
+ await overrideTasks.run().catch(err => {
163
+ console.log(chalk.bold.red(err.toString()));
164
+ });
165
+ }
166
+ }
167
+
168
+
85
169
 
86
170
  return true;
87
171
  };
@@ -9,7 +9,9 @@ import {
9
9
  COMPONENT_SCHEMA,
10
10
  COMPONENT_PREFIX_FIELD_PATH,
11
11
  COMPONENT_PREFIX_TEMPLATE_PATH,
12
- COMPONENT_PREFIX_WIDGET_PATH } from '../../constants.js';
12
+ COMPONENT_PREFIX_WIDGET_PATH,
13
+ CATEGORY_CUSTOM,
14
+ CATEGORY_OVERRIDE } from '../../constants.js';
13
15
  import {
14
16
  getComponentDirectoryPath,
15
17
  getComponents,
@@ -169,7 +171,7 @@ const validateSchema = ajv.compile(schema);
169
171
 
170
172
 
171
173
 
172
- export default async (option, category = "custom") => {
174
+ export default async (option, category = CATEGORY_CUSTOM) => {
173
175
  let componentToValidate = null;
174
176
  if (option.params && option.params[3]) {
175
177
  componentToValidate = option.params[3];
@@ -196,10 +198,10 @@ export default async (option, category = "custom") => {
196
198
  configData = fs.readFileSync(path.resolve(configFile), 'utf8');
197
199
  }
198
200
  catch (err) {
199
- if (category == "custom") {
201
+ if (category === CATEGORY_CUSTOM) {
200
202
  throw new Error(`Missing config file for: ${componentToValidate}`);
201
203
  }
202
- else if (category == "override") {
204
+ else if (category === CATEGORY_OVERRIDE) {
203
205
  // for now, if now file just end
204
206
  console.log(`${chalk.bold.yellow('config file not availabe for: ' + componentToValidate)}`);
205
207
  return;
@@ -222,7 +224,7 @@ export default async (option, category = "custom") => {
222
224
  ) {
223
225
  const ootbComponents = await getOOTBComponents();
224
226
  if (ootbComponents.includes(componentToValidate)) {
225
- throw new Error(`Invalid: Error occured in validating ${componentToValidate}`);
227
+ throw new Error(`Invalid: Error occurred in validating ${componentToValidate}`);
226
228
  }
227
229
  }
228
230