@pega/custom-dx-components 0.0.1 → 0.23.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.
- package/.vscode/extensions.json +1 -1
- package/README.md +6 -189
- package/package.json +34 -32
- package/src/auth.js +608 -0
- package/src/cli.js +42 -0
- package/src/constants.js +122 -8
- package/src/tasks/authenticate/helper.js +91 -8
- package/src/tasks/authenticate/index.js +169 -49
- package/src/tasks/build/helper.js +122 -0
- package/src/tasks/build/index.js +54 -0
- package/src/tasks/build-all/helper.js +70 -0
- package/src/tasks/build-all/index.js +79 -0
- package/src/tasks/{publish/bundle → bundle}/builder/index.js +49 -5
- package/src/tasks/{publish/bundle → bundle}/builder/webpack.config.js +5 -3
- package/src/tasks/{publish/bundle → bundle}/index.js +2 -2
- package/src/tasks/create/index.js +87 -64
- package/src/tasks/create/templates/Constellation/Field/Boolean/Boolean.js.mustache +38 -0
- package/src/tasks/create/templates/Constellation/Field/Boolean/boolean-format.js.mustache +26 -0
- package/src/tasks/create/templates/Constellation/Field/Boolean/config.json.mustache +145 -0
- package/src/tasks/create/templates/Constellation/Field/Boolean/demo.stories.jsx.mustache +61 -0
- package/src/tasks/create/templates/Constellation/Field/Boolean/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Boolean/index.jsx.mustache +170 -0
- package/src/tasks/create/templates/Constellation/Field/Boolean/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Boolean/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Date/DateFormatter.js.mustache +61 -0
- package/src/tasks/create/templates/Constellation/Field/Date/FormattedText.jsx.mustache +41 -0
- package/src/tasks/create/templates/Constellation/Field/Date/config.json.mustache +195 -0
- package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +439 -0
- package/src/tasks/create/templates/Constellation/Field/Date/demo.stories.jsx.mustache +73 -0
- package/src/tasks/create/templates/Constellation/Field/Date/index.jsx.mustache +256 -0
- package/src/tasks/create/templates/Constellation/Field/Date/mock.stories.js.mustache +23 -0
- package/src/tasks/create/templates/Constellation/Field/Date/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Date/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/config.json.mustache +256 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +92 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/date-utils.js.mustache +287 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +328 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/demo.stories.jsx.mustache +73 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/index.jsx.mustache +254 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/mock.stories.js.mustache +23 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/config.json.mustache +278 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/demo.stories.jsx.mustache +49 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/index.jsx.mustache +273 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/config.json.mustache +291 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/demo.stories.jsx.mustache +53 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/index.jsx.mustache +299 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/mock.stories.js.mustache +23 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/config.json.mustache +93 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/demo.stories.jsx.mustache +49 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/index.jsx.mustache +281 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/config.json.mustache +347 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/demo.stories.jsx.mustache +49 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/index.jsx.mustache +336 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/config.json.mustache +114 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/demo.stories.jsx.mustache +78 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/index.jsx.mustache +351 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/mock.stories.js.mustache +67 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/suggestions-handler.js +10 -0
- package/src/tasks/create/{template → templates/Constellation/Field/Text}/config.json.mustache +14 -5
- package/src/tasks/create/templates/Constellation/Field/Text/demo.stories.jsx.mustache +51 -0
- package/src/tasks/create/{template → templates/Constellation/Field/Text}/index.jsx.mustache +5 -0
- package/src/tasks/create/templates/Constellation/Field/Text/mock.stories.js.mustache +13 -0
- package/src/tasks/create/templates/Constellation/Field/Text/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/config.json.mustache +111 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/demo.stories.jsx.mustache +48 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/index.jsx.mustache +231 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/mock.stories.js.mustache +22 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/StatusWork.jsx +26 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/config.json.mustache +111 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/demo.stories.jsx.mustache +48 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/index.jsx.mustache +239 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/config.json.mustache +111 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.stories.jsx.mustache +48 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/index.jsx.mustache +231 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/mock.stories.js.mustache +20 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/config.json.mustache +123 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/demo.stories.jsx.mustache +46 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.jsx.mustache +267 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/mock.stories.js.mustache +37 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/config.json.mustache +237 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/demo.stories.jsx.mustache +46 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/index.jsx.mustache +232 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/mock.stories.js.mustache +22 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/text-url.jsx.mustache +173 -0
- package/src/tasks/create/templates/Constellation/Field/TimeOfDay/config.json.mustache +185 -0
- package/src/tasks/create/templates/Constellation/Field/TimeOfDay/demo.stories.jsx.mustache +57 -0
- package/src/tasks/create/templates/Constellation/Field/TimeOfDay/index.jsx.mustache +213 -0
- package/src/tasks/create/templates/Constellation/Field/TimeOfDay/mock.stories.js.mustache +20 -0
- package/src/tasks/create/templates/Constellation/Field/TimeOfDay/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/TimeOfDay/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/TimeOfDay/time-of-day.js.mustache +287 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/OneColumnDetails.svg +22 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/StatusWork.jsx.mustache +26 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/config.json.mustache +35 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.jsx.mustache +132 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/index.jsx.mustache +86 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.stories.js.mustache +189 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/utils.js.mustache +152 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/StatusWork.jsx.mustache +26 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/TwoColumnDetails.svg +28 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/config.json.mustache +42 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.jsx.mustache +136 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.jsx.mustache +86 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.stories.js.mustache +230 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/utils.js.mustache +155 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/DefaultForm.svg +29 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/config.json.mustache +45 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/demo.stories.jsx.mustache +169 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/index.jsx.mustache +45 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/mock.stories.js.mustache +137 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/TwoColumn.svg +38 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/config.json.mustache +27 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.stories.jsx.mustache +178 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +48 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/mock.stories.js.mustache +143 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/GetNextWork.jsx.mustache +35 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/OneColumnPage.svg +36 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/config.json.mustache +32 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/demo.stories.jsx.mustache +102 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/index.jsx.mustache +70 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/localizations.json.mustache +4 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/mock.stories.js.mustache +94 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/utils.js.mustache +229 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/OneColumnPage.svg +36 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/config.json.mustache +23 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/demo.stories.jsx.mustache +78 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/index.jsx.mustache +76 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/mock.stories.js.mustache +390 -0
- package/src/tasks/create/{template → templates/Constellation/Widget/CASE}/styles.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Widget/PAGE/OneColumnPage.svg +36 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/config.json.mustache +59 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.jsx.mustache +30 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/index.jsx.mustache +48 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/mock.stories.js.mustache +23 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/Avatar.jsx.mustache +75 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/OneColumnPage.svg +36 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/Operator.jsx.mustache +240 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/config.json.mustache +66 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.stories.jsx.mustache +68 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/index.jsx.mustache +110 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/mock.stories.js.mustache +51 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/styles.js.mustache +7 -0
- package/src/tasks/create-all/index.js +398 -0
- package/src/tasks/delete/helper.js +6 -4
- package/src/tasks/delete/index.js +4 -0
- package/src/tasks/delete-all/helper.js +153 -0
- package/src/tasks/delete-all/index.js +49 -0
- package/src/tasks/generate-ai/aiPrompt.txt.mustache +121 -0
- package/src/tasks/generate-ai/helper.js +184 -0
- package/src/tasks/generate-ai/index.js +33 -0
- package/src/tasks/index.js +7 -0
- package/src/tasks/init/index.js +9 -3
- package/src/tasks/init/template/.eslintignore +8 -0
- package/src/tasks/init/template/.eslintrc.json +186 -5
- package/src/tasks/init/template/.vscode/extensions.json +1 -1
- package/src/tasks/init/template/README.md +80 -61
- package/src/tasks/init/template/keys/DX-ComponentDev.zip +0 -0
- package/src/tasks/init/template/keys/dxcb.crt +32 -0
- package/src/tasks/init/template/keys/dxcb.key +51 -0
- package/src/tasks/init/template/package.json.mustache +44 -21
- package/src/tasks/init/template/tasks.config.json +19 -5
- package/src/tasks/init/template/templateNPMRC.txt +8 -0
- package/src/tasks/linter/index.js +46 -0
- package/src/tasks/list/helper.js +19 -6
- package/src/tasks/list/index.js +4 -0
- package/src/tasks/publish/helper.js +13 -4
- package/src/tasks/publish/index.js +14 -1
- package/src/tasks/publish-all/helper.js +154 -0
- package/src/tasks/publish-all/index.js +95 -0
- package/src/tasks/rename/index.js +314 -0
- package/src/tasks/validator/index.js +291 -18
- package/src/util.js +247 -6
- package/src/tasks/create/template/demo.stories.jsx.mustache +0 -44
- package/src/tasks/init/template/src/components/MBTAList/MBTAList.stories.tsx +0 -10
- package/src/tasks/init/template/src/components/MBTAList/MBTAList.tsx +0 -122
- package/src/tasks/init/template/src/components/MBTAList/icons/accessible.icon.tsx +0 -14
- package/src/tasks/init/template/src/components/MBTAList/icons/bus.icon.tsx +0 -13
- package/src/tasks/init/template/src/components/MBTAList/icons/mbta.icon.tsx +0 -10
- package/src/tasks/init/template/src/components/MBTAList/icons/subway.icon.tsx +0 -14
- package/src/tasks/init/template/src/components/MBTAList/index.ts +0 -2
- /package/src/tasks/{publish/bundle → bundle}/builder/modules.js +0 -0
- /package/src/tasks/{publish/bundle → bundle}/builder/paths.js +0 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import https from 'https';
|
|
4
|
+
|
|
5
|
+
import fetch from 'node-fetch';
|
|
6
|
+
import AdmZip from 'adm-zip';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
constructCompleteUrl,
|
|
11
|
+
getComponentDirectoryPath,
|
|
12
|
+
getComponents,
|
|
13
|
+
getPegaServerConfig
|
|
14
|
+
} from '../../util.js';
|
|
15
|
+
import { PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH } from '../../constants.js';
|
|
16
|
+
|
|
17
|
+
export const getPublishComponentQuestions = async () => {
|
|
18
|
+
const components = await getComponents();
|
|
19
|
+
const defaultPegaConfig = await getPegaServerConfig();
|
|
20
|
+
|
|
21
|
+
return [
|
|
22
|
+
{
|
|
23
|
+
name: 'componentKey',
|
|
24
|
+
type: 'rawlist',
|
|
25
|
+
message: 'Select component to build',
|
|
26
|
+
choices: components
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'sourceMap',
|
|
30
|
+
message: 'Generate source map ?',
|
|
31
|
+
default: defaultPegaConfig.sourceMap,
|
|
32
|
+
when: () => false && !process.env.SOURCE_MAP
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'devBuild',
|
|
36
|
+
message: 'Generate development build ?',
|
|
37
|
+
default: defaultPegaConfig.devBuild
|
|
38
|
+
}
|
|
39
|
+
];
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const zipComponent = async componentKey => {
|
|
43
|
+
const srcDirectory = await getComponentDirectoryPath(componentKey);
|
|
44
|
+
const buildDirectory = await path.join(path.resolve(), 'dist/components', componentKey);
|
|
45
|
+
const configJson = `${srcDirectory}/config.json`;
|
|
46
|
+
|
|
47
|
+
const zip = new AdmZip();
|
|
48
|
+
|
|
49
|
+
zip.addLocalFolder(srcDirectory, 'src/');
|
|
50
|
+
zip.addLocalFile(configJson);
|
|
51
|
+
zip.addLocalFolder(buildDirectory);
|
|
52
|
+
const zipContent = zip.toBuffer().toString('base64');
|
|
53
|
+
|
|
54
|
+
const configContent = Buffer.from(fs.readFileSync(`${srcDirectory}/config.json`)).toString();
|
|
55
|
+
fs.rmdir('dist', { recursive: true }, err => {
|
|
56
|
+
if (err) {
|
|
57
|
+
throw err;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
return { zipContent, configContent };
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const publishComponentToServer = async data => {
|
|
64
|
+
const { configContent, zipContent, componentKey, rulesetName, rulesetVersion } = data;
|
|
65
|
+
|
|
66
|
+
const apiBody = {
|
|
67
|
+
configContent,
|
|
68
|
+
zipContent,
|
|
69
|
+
componentKey: JSON.parse(configContent).componentKey,
|
|
70
|
+
publishFor: 'constellation',
|
|
71
|
+
rulesetName,
|
|
72
|
+
rulesetVersion,
|
|
73
|
+
category: ''
|
|
74
|
+
};
|
|
75
|
+
const defaultPegaConfig = await getPegaServerConfig();
|
|
76
|
+
const url = constructCompleteUrl(
|
|
77
|
+
defaultPegaConfig.server,
|
|
78
|
+
PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT
|
|
79
|
+
);
|
|
80
|
+
try {
|
|
81
|
+
const OauthData = fs.readFileSync(TOKEN_PATH, 'utf8');
|
|
82
|
+
if (OauthData) {
|
|
83
|
+
const {
|
|
84
|
+
access_token: accessToken,
|
|
85
|
+
token_type: tokenType,
|
|
86
|
+
refresh_token: refreshToken
|
|
87
|
+
} = JSON.parse(OauthData);
|
|
88
|
+
let status = 500;
|
|
89
|
+
fetch(url, {
|
|
90
|
+
method: 'POST',
|
|
91
|
+
agent: new https.Agent({ rejectUnauthorized: false }),
|
|
92
|
+
headers: {
|
|
93
|
+
Authorization: `${tokenType} ${accessToken}`
|
|
94
|
+
},
|
|
95
|
+
body: JSON.stringify(apiBody)
|
|
96
|
+
})
|
|
97
|
+
.then(response => {
|
|
98
|
+
status = response.status;
|
|
99
|
+
return response.text();
|
|
100
|
+
})
|
|
101
|
+
.then(resp => {
|
|
102
|
+
const respData = JSON.parse(resp);
|
|
103
|
+
if (status === 401) {
|
|
104
|
+
throw new Error(
|
|
105
|
+
'Error occurred in authentication. Please regenerate using authenticate'
|
|
106
|
+
);
|
|
107
|
+
// console.log(accessTokenUri, refreshToken);
|
|
108
|
+
/* TODO - Handle refresh_token */
|
|
109
|
+
} else if (status == 200) {
|
|
110
|
+
console.log(chalk.bold.green(`Success : ${respData.message}`));
|
|
111
|
+
} else {
|
|
112
|
+
throw new Error(`${respData.message}`);
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
.catch(e => Promise.reject(`${chalk.bold.red(e)}`));
|
|
116
|
+
} else {
|
|
117
|
+
throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
|
|
118
|
+
}
|
|
119
|
+
} catch (err) {
|
|
120
|
+
throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import inquirer from 'inquirer';
|
|
2
|
+
import Listr from 'listr';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
|
|
5
|
+
import validate from '../validator/index.js';
|
|
6
|
+
|
|
7
|
+
import bundleComponent from '../bundle/index.js';
|
|
8
|
+
import lintComponent from '../linter/index.js';
|
|
9
|
+
import { getPublishComponentQuestions } from './helper.js';
|
|
10
|
+
import { getComponentDirectoryPath, showVersion } from '../../util.js';
|
|
11
|
+
|
|
12
|
+
export default async options => {
|
|
13
|
+
showVersion();
|
|
14
|
+
|
|
15
|
+
const questions = await getPublishComponentQuestions();
|
|
16
|
+
const answers = await inquirer.prompt(questions);
|
|
17
|
+
const { componentKey, sourceMap, devBuild } = answers;
|
|
18
|
+
|
|
19
|
+
let content = {
|
|
20
|
+
...answers
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const tasks = new Listr(
|
|
24
|
+
[
|
|
25
|
+
{
|
|
26
|
+
title: 'Validate config schema',
|
|
27
|
+
task: async () => {
|
|
28
|
+
await validate(componentKey);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
title: 'Lint component',
|
|
33
|
+
task: async () => {
|
|
34
|
+
const targetDirectory = await getComponentDirectoryPath(componentKey);
|
|
35
|
+
// console.log(`in buildComponent Lint component task: componentKey: ${componentKey} targetDirectory: ${targetDirectory}`);
|
|
36
|
+
await lintComponent(targetDirectory);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
title: 'Bundle Component',
|
|
41
|
+
task: async () => await bundleComponent(componentKey, sourceMap, devBuild),
|
|
42
|
+
skip: () => (options.skipBundle ? 'Skipped bundling component' : undefined)
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
{
|
|
46
|
+
exitOnError: true
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
await tasks.run().catch(err => {
|
|
51
|
+
console.log(chalk.bold.red(err.toString()));
|
|
52
|
+
});
|
|
53
|
+
return true;
|
|
54
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
import AdmZip from 'adm-zip';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
getComponentDirectoryPath,
|
|
9
|
+
getComponents,
|
|
10
|
+
getPegaServerConfig
|
|
11
|
+
} from '../../util.js';
|
|
12
|
+
import { COMPONENT_SCHEMA } from '../../constants.js';
|
|
13
|
+
|
|
14
|
+
export const cleanUp = async () => {
|
|
15
|
+
fs.rm('dist/components', { recursive: true }, err => {
|
|
16
|
+
if (err) {
|
|
17
|
+
throw err;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
fs.rm('lib', { recursive: true }, err => {
|
|
22
|
+
if (err) {
|
|
23
|
+
throw err;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
export const getBuildComponentQuestions = async () => {
|
|
31
|
+
const components = await getComponents();
|
|
32
|
+
const defaultPegaConfig = await getPegaServerConfig();
|
|
33
|
+
|
|
34
|
+
if (components.length == 0) {
|
|
35
|
+
console.log(chalk.bold.yellow(`No components to build`));
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return [
|
|
40
|
+
{
|
|
41
|
+
name: 'devBuild',
|
|
42
|
+
message: 'Generate development build ?',
|
|
43
|
+
default: defaultPegaConfig.devBuild
|
|
44
|
+
}
|
|
45
|
+
];
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
export const zipComponent = async (componentKey) => {
|
|
51
|
+
const srcDirectory = await getComponentDirectoryPath(componentKey);
|
|
52
|
+
const buildDirectory = await path.join(path.resolve(), 'dist/components', componentKey);
|
|
53
|
+
const configJson = `${srcDirectory}/config.json`;
|
|
54
|
+
|
|
55
|
+
const zip = new AdmZip();
|
|
56
|
+
|
|
57
|
+
zip.addLocalFolder(srcDirectory, 'src/');
|
|
58
|
+
zip.addLocalFile(configJson);
|
|
59
|
+
zip.addLocalFolder(buildDirectory);
|
|
60
|
+
const zipContent = zip.toBuffer().toString('base64');
|
|
61
|
+
|
|
62
|
+
const configContent = Buffer.from(fs.readFileSync(`${srcDirectory}/config.json`)).toString();
|
|
63
|
+
// clean up now happens in function cleanUp
|
|
64
|
+
// fs.rmd('dist/components', { recursive: true }, err => {
|
|
65
|
+
// if (err) {
|
|
66
|
+
// throw err;
|
|
67
|
+
// }
|
|
68
|
+
// });
|
|
69
|
+
return { zipContent, configContent };
|
|
70
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import inquirer from 'inquirer';
|
|
2
|
+
import Listr from 'listr';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
|
|
5
|
+
import validate from '../validator/index.js';
|
|
6
|
+
|
|
7
|
+
import bundleComponent from '../bundle/index.js';
|
|
8
|
+
import lintComponent from '../linter/index.js';
|
|
9
|
+
import { getBuildComponentQuestions, cleanUp } from './helper.js';
|
|
10
|
+
import { getComponentDirectoryPath, showVersion, getComponentsObj } from '../../util.js';
|
|
11
|
+
|
|
12
|
+
import { CATEGORY_CONSTELLATION } from '../../constants.js';
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export function getCustomTasks(componentKey, sourceMap, devBuild) {
|
|
16
|
+
|
|
17
|
+
const customTasks = new Listr(
|
|
18
|
+
[
|
|
19
|
+
{
|
|
20
|
+
title: 'Validate config schema',
|
|
21
|
+
task: async () => {
|
|
22
|
+
await validate(componentKey);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
title: 'Lint component',
|
|
27
|
+
task: async () => {
|
|
28
|
+
const targetDirectory = await getComponentDirectoryPath(componentKey);
|
|
29
|
+
// console.log(`in buildComponent Lint component task: componentKey: ${componentKey} targetDirectory: ${targetDirectory}`);
|
|
30
|
+
await lintComponent(targetDirectory);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
title: 'Bundle component',
|
|
35
|
+
task: async () => await bundleComponent(componentKey, sourceMap, devBuild),
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
{
|
|
39
|
+
exitOnError: true
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
return customTasks;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
export default async options => {
|
|
50
|
+
showVersion();
|
|
51
|
+
|
|
52
|
+
let category = CATEGORY_CONSTELLATION;
|
|
53
|
+
|
|
54
|
+
const components = await getComponentsObj();
|
|
55
|
+
const questions = await getBuildComponentQuestions();
|
|
56
|
+
const answers = await inquirer.prompt(questions);
|
|
57
|
+
const { sourceMap, devBuild } = answers;
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
var componentKey;
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
for (var index in components) {
|
|
65
|
+
componentKey = components[index].value;
|
|
66
|
+
console.log(chalk.bold.green("Building: " + components[index].name));
|
|
67
|
+
|
|
68
|
+
let myCustomTasks = getCustomTasks(componentKey, sourceMap, devBuild );
|
|
69
|
+
|
|
70
|
+
await myCustomTasks.run().catch(err => {
|
|
71
|
+
console.log(chalk.bold.red(err.toString()));
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
cleanUp();
|
|
77
|
+
|
|
78
|
+
return true;
|
|
79
|
+
};
|
|
@@ -36,13 +36,40 @@ const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
|
|
|
36
36
|
const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
|
37
37
|
const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
|
|
38
38
|
|
|
39
|
+
let compilationErrors = null;
|
|
40
|
+
|
|
39
41
|
// Create the build and print the deployment instructions.
|
|
40
42
|
function build(config, previousFileSizes) {
|
|
41
43
|
console.log(`Creating a ${Env} build...`);
|
|
42
44
|
|
|
45
|
+
|
|
46
|
+
|
|
43
47
|
const compiler = webpack(config);
|
|
44
48
|
return new Promise((resolve, reject) => {
|
|
45
49
|
compiler.run((err, stats) => {
|
|
50
|
+
|
|
51
|
+
if (err != null && typeof (err) == "object") {
|
|
52
|
+
if (err.error != undefined) {
|
|
53
|
+
//store and print elsewhere
|
|
54
|
+
compilationErrors = err.error;
|
|
55
|
+
//console.log("err:" + err);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (stats != null & typeof(stats) == "object") {
|
|
59
|
+
if (stats.errors != undefined) {
|
|
60
|
+
console.log("stats:" + stats);
|
|
61
|
+
}
|
|
62
|
+
else if (stats.compilation != undefined && stats.compilation.errors != undefined) {
|
|
63
|
+
|
|
64
|
+
//store and print elsewhere
|
|
65
|
+
compilationErrors = stats.compilation.errors;
|
|
66
|
+
|
|
67
|
+
console.log("stats:" + stats);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
46
73
|
let messages;
|
|
47
74
|
if (err) {
|
|
48
75
|
if (!err.message) {
|
|
@@ -131,7 +158,11 @@ export default ({
|
|
|
131
158
|
.then(
|
|
132
159
|
({ stats, previousFileSizes, warnings }) => {
|
|
133
160
|
if (warnings.length) {
|
|
134
|
-
console.log(chalk.yellow('Compiled with warnings.\n'), warnings[0].message);
|
|
161
|
+
//console.log(chalk.yellow('Compiled with warnings.\n'), warnings[0].message);
|
|
162
|
+
console.log(chalk.yellow('Compiled with warnings.\n'));
|
|
163
|
+
for (let warning in warnings) {
|
|
164
|
+
console.log(chalk.yellow("Warning.."), warnings[warning].message);
|
|
165
|
+
}
|
|
135
166
|
} else {
|
|
136
167
|
console.log(chalk.green('Compiled successfully.\n'));
|
|
137
168
|
}
|
|
@@ -146,7 +177,7 @@ export default ({
|
|
|
146
177
|
);
|
|
147
178
|
resolve('done emitting');
|
|
148
179
|
},
|
|
149
|
-
err
|
|
180
|
+
err => {
|
|
150
181
|
reject();
|
|
151
182
|
const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true';
|
|
152
183
|
if (tscCompileOnError) {
|
|
@@ -156,11 +187,24 @@ export default ({
|
|
|
156
187
|
)
|
|
157
188
|
);
|
|
158
189
|
printBuildError(err);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
190
|
+
}
|
|
191
|
+
else if (compilationErrors != null) {
|
|
192
|
+
if (compilationErrors.length == undefined) {
|
|
193
|
+
console.log(chalk.red("Error..."), compilationErrors.message);
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
for (let error in compilationErrors) {
|
|
197
|
+
console.log(chalk.red("Error..."), compilationErrors[error].message);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
162
201
|
process.exit(1);
|
|
163
202
|
}
|
|
203
|
+
else {
|
|
204
|
+
console.log(chalk.red('Failed to compile.\n'));
|
|
205
|
+
printBuildError(JSON.stringify(err));
|
|
206
|
+
|
|
207
|
+
}
|
|
164
208
|
}
|
|
165
209
|
)
|
|
166
210
|
.catch(err => {
|
|
@@ -103,13 +103,13 @@ export default (
|
|
|
103
103
|
return loaders;
|
|
104
104
|
};
|
|
105
105
|
return {
|
|
106
|
-
mode:
|
|
106
|
+
mode: devBuild ? 'development' : 'production',
|
|
107
107
|
// Stop compilation early in production
|
|
108
108
|
bail: isEnvProduction,
|
|
109
109
|
// These are the "entry points" to our application.
|
|
110
110
|
// This means they will be the "root" imports that are included in JS bundle.
|
|
111
111
|
entry: inputFile,
|
|
112
|
-
devtool:
|
|
112
|
+
devtool: devBuild ? 'eval-cheap-module-source-map' : false,
|
|
113
113
|
output: {
|
|
114
114
|
// The build folder.
|
|
115
115
|
path: paths.appBuild,
|
|
@@ -310,18 +310,20 @@ export default (
|
|
|
310
310
|
resourceRegExp: /^\.\/icons$/,
|
|
311
311
|
contextRegExp: /@pega\/cosmos-react-core\/lib\/components\/Icon$/
|
|
312
312
|
}),
|
|
313
|
+
|
|
313
314
|
/* Ignore cosmos icons - windows */
|
|
314
315
|
new webpack.IgnorePlugin({
|
|
315
316
|
resourceRegExp: /^\.\/icons$/,
|
|
316
317
|
contextRegExp: /@pega\\cosmos-react-core\\lib\\components\\Icon$/
|
|
317
318
|
}),
|
|
319
|
+
|
|
318
320
|
new webpack.optimize.LimitChunkCountPlugin({
|
|
319
321
|
maxChunks: 5
|
|
320
322
|
}),
|
|
321
323
|
new webpack.optimize.MinChunkSizePlugin({
|
|
322
324
|
minChunkSize: 100000 // Minimum number of characters
|
|
323
325
|
}),
|
|
324
|
-
|
|
326
|
+
!devBuild && new CompressionPlugin(compressionBRConfObj)
|
|
325
327
|
|
|
326
328
|
/* Dont generate gzip file */
|
|
327
329
|
/* isEnvProduction && new CompressionPlugin(compressionGZConfObj) */
|
|
@@ -2,8 +2,8 @@ import path from 'path';
|
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import { stat } from 'fs/promises';
|
|
4
4
|
|
|
5
|
-
import { BUILD_CONFIG_JSON_FILENAME } from '
|
|
6
|
-
import { getComponentDirectoryPath } from '
|
|
5
|
+
import { BUILD_CONFIG_JSON_FILENAME } from '../../constants.js';
|
|
6
|
+
import { getComponentDirectoryPath } from '../../util.js';
|
|
7
7
|
|
|
8
8
|
import buildComponent from './builder/index.js';
|
|
9
9
|
|