@pega/custom-dx-components 0.24.16 → 0.242.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/package.json +1 -1
- package/src/cli.js +32 -2
- package/src/constants.js +9 -0
- package/src/tasks/authenticate/index.js +12 -1
- package/src/tasks/build-lib/helper.js +71 -0
- package/src/tasks/build-lib/index.js +165 -0
- package/src/tasks/create/index.js +59 -6
- package/src/tasks/create/templates/Constellation/Field/Icon-Button-URL/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/HighlightRender.tsx.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/HighlightRender.tsx.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Widget/PAGE/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Launchpad/Field/Icon-Button-URL/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Launchpad/Widget/PAGE/index.tsx.mustache +1 -0
- package/src/tasks/create-all/index.js +57 -6
- package/src/tasks/delete/index.js +8 -2
- package/src/tasks/delete-all/index.js +8 -2
- package/src/tasks/delete-lib/helper.js +75 -0
- package/src/tasks/delete-lib/index.js +97 -0
- package/src/tasks/index.js +5 -0
- package/src/tasks/init/template/package.json.mustache +32 -9
- package/src/tasks/init/template/tasks.config.json +3 -2
- package/src/tasks/list/index.js +9 -3
- package/src/tasks/list-lib/helper.js +72 -0
- package/src/tasks/list-lib/index.js +75 -0
- package/src/tasks/promote-webpack/index.js +8 -1
- package/src/tasks/promote-webpack/webpack.config.js +26 -0
- package/src/tasks/publish/index.js +8 -1
- package/src/tasks/publish-all/index.js +8 -1
- package/src/tasks/publish-lib/helper.js +53 -0
- package/src/tasks/publish-lib/index.js +212 -0
- package/src/tasks/rename-lib/index.js +353 -0
- package/src/tasks/revert-webpack/index.js +8 -1
- package/src/util.js +201 -2
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -5,15 +5,20 @@ import {
|
|
|
5
5
|
authenticate,
|
|
6
6
|
buildComponent,
|
|
7
7
|
buildAllComponents,
|
|
8
|
+
buildLibrary,
|
|
8
9
|
createComponent,
|
|
9
10
|
createAllComponents,
|
|
10
11
|
deleteComponent,
|
|
11
12
|
deleteAllComponents,
|
|
13
|
+
deleteLibrary,
|
|
12
14
|
initProject,
|
|
13
15
|
listComponents,
|
|
16
|
+
listLibrary,
|
|
14
17
|
publishComponent,
|
|
15
18
|
publishAllComponents,
|
|
19
|
+
publishLibrary,
|
|
16
20
|
renameComponent,
|
|
21
|
+
renameLibrary,
|
|
17
22
|
revertWebPack,
|
|
18
23
|
promoteWebPack,
|
|
19
24
|
updateComponent,
|
|
@@ -28,16 +33,21 @@ const TASKS = {
|
|
|
28
33
|
CREATE_ALL: 'createAll',
|
|
29
34
|
BUILD: 'buildComponent',
|
|
30
35
|
BUILD_ALL: 'buildAllComponents',
|
|
36
|
+
BUILD_LIB: 'buildLibrary',
|
|
31
37
|
PROMOTE_WEBPACK: 'promoteWebPack',
|
|
32
38
|
REVERT_WEBPACK: 'revertWebPack',
|
|
33
39
|
PUBLISH: 'publish',
|
|
34
|
-
|
|
40
|
+
PUBLISH_ALL: 'publishAll',
|
|
41
|
+
PUBLISH_LIB: 'publishLibrary',
|
|
35
42
|
RENAME: 'rename',
|
|
43
|
+
RENAME_LIB: 'renameLibrary',
|
|
36
44
|
LIST: 'list',
|
|
45
|
+
LIST_LIB: 'listLibrary',
|
|
37
46
|
VALIDATE_SCHEMA: 'validateSchema',
|
|
38
47
|
UPDATE: 'update',
|
|
39
48
|
DELETE: 'delete',
|
|
40
49
|
DELETE_ALL: "deleteAll",
|
|
50
|
+
DELETE_LIBRARY: "deleteLibrary",
|
|
41
51
|
AUTHENTICATE: 'authenticate',
|
|
42
52
|
UPGRADE: 'upgrade',
|
|
43
53
|
BUILD_JEST_ASSETS: 'buildJestAssets'
|
|
@@ -90,14 +100,22 @@ export default async (args = []) => {
|
|
|
90
100
|
publishComponent(options);
|
|
91
101
|
break;
|
|
92
102
|
}
|
|
93
|
-
case TASKS.
|
|
103
|
+
case TASKS.PUBLISH_ALL: {
|
|
94
104
|
publishAllComponents(options);
|
|
95
105
|
break;
|
|
96
106
|
}
|
|
107
|
+
case TASKS.PUBLISH_LIB: {
|
|
108
|
+
publishLibrary(options);
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
97
111
|
case TASKS.RENAME: {
|
|
98
112
|
renameComponent(options);
|
|
99
113
|
break;
|
|
100
114
|
}
|
|
115
|
+
case TASKS.RENAME_LIB: {
|
|
116
|
+
renameLibrary(options);
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
101
119
|
case TASKS.BUILD: {
|
|
102
120
|
buildComponent(options);
|
|
103
121
|
break;
|
|
@@ -106,10 +124,18 @@ export default async (args = []) => {
|
|
|
106
124
|
buildAllComponents(options);
|
|
107
125
|
break;
|
|
108
126
|
}
|
|
127
|
+
case TASKS.BUILD_LIB: {
|
|
128
|
+
buildLibrary(options);
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
109
131
|
case TASKS.LIST: {
|
|
110
132
|
listComponents(options);
|
|
111
133
|
break;
|
|
112
134
|
}
|
|
135
|
+
case TASKS.LIST_LIB: {
|
|
136
|
+
listLibrary(options);
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
113
139
|
case TASKS.VALIDATE_SCHEMA: {
|
|
114
140
|
validate(options);
|
|
115
141
|
break;
|
|
@@ -126,6 +152,10 @@ export default async (args = []) => {
|
|
|
126
152
|
deleteAllComponents(options);
|
|
127
153
|
break;
|
|
128
154
|
}
|
|
155
|
+
case TASKS.DELETE_LIBRARY: {
|
|
156
|
+
deleteLibrary(options);
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
129
159
|
case TASKS.AUTHENTICATE: {
|
|
130
160
|
authenticate(options);
|
|
131
161
|
break;
|
package/src/constants.js
CHANGED
|
@@ -9,6 +9,8 @@ export const COMPONENTS_DIRECTORY_PATH = 'components-directory-path';
|
|
|
9
9
|
export const COMPONENTS_PATH = 'component';
|
|
10
10
|
export const TOKEN_PATH = 'node_modules/@pega/custom-dx-components/.access_token';
|
|
11
11
|
export const OOTB_COMPONENTS = 'node_modules/@pega/custom-dx-components/.ootb_components';
|
|
12
|
+
export const LIBRARY_BASED = 'libraryBased';
|
|
13
|
+
export const SHARED_DIRECTORY = 'shared';
|
|
12
14
|
|
|
13
15
|
/* REST end points */
|
|
14
16
|
export const PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/publish_component';
|
|
@@ -39,6 +41,8 @@ export const BUILDER_DIR_FILE_PATH = '../bundle/builder';
|
|
|
39
41
|
|
|
40
42
|
export const CATEGORY_CONSTELLATION = 'constellation';
|
|
41
43
|
|
|
44
|
+
export const BOOTSTRAP_CONFIG = 'PRRestService/api/application/v2/data_views/D_pxBootstrapConfig';
|
|
45
|
+
|
|
42
46
|
export const JEST_ASSETS_PATH = 'node_modules/@pega/custom-dx-components/tests/assets/components/';
|
|
43
47
|
export const JEST_CREATE_PATH = 'create/';
|
|
44
48
|
export const JEST_CREATE_ALL_CONSTELLATION_PATH = 'createAll/Constellation/';
|
|
@@ -53,6 +57,11 @@ export const AUTHENTICATE_DEFAULTS = {
|
|
|
53
57
|
redirectUri: 'https://localhost:4010/'
|
|
54
58
|
};
|
|
55
59
|
|
|
60
|
+
export const SHARED_FILE_NAMES = [
|
|
61
|
+
"suggestions-handler.ts",
|
|
62
|
+
"PConnProps.d.ts"
|
|
63
|
+
];
|
|
64
|
+
|
|
56
65
|
export const AUTHENTICATE_SCHEMA = {
|
|
57
66
|
serverType: [
|
|
58
67
|
{
|
|
@@ -4,7 +4,7 @@ import fs from 'node:fs';
|
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
import inquirer from 'inquirer';
|
|
6
6
|
|
|
7
|
-
import { checkPathAccess, showVersion } from '../../util.js';
|
|
7
|
+
import { checkPathAccess, showVersion, updateC11NB2SForInfinity } from '../../util.js';
|
|
8
8
|
import {
|
|
9
9
|
TOKEN_PATH,
|
|
10
10
|
INF_TOKEN_URL_V1,
|
|
@@ -250,5 +250,16 @@ export default async options => {
|
|
|
250
250
|
} catch (e) {}
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
+
if (authOK) {
|
|
254
|
+
// get C11B2S token
|
|
255
|
+
if (isLaunchPad) {
|
|
256
|
+
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
// update B2N token in access token file
|
|
260
|
+
await updateC11NB2SForInfinity();
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
253
264
|
process.exit();
|
|
254
265
|
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
getComponents,
|
|
7
|
+
getPegaServerConfig,
|
|
8
|
+
checkPathAccess,
|
|
9
|
+
getComponentDefaults,
|
|
10
|
+
validateSemver
|
|
11
|
+
} from '../../util.js';
|
|
12
|
+
import { TASKS_CONFIG_JSON_FILENAME, COMPONENTS_DIRECTORY_PATH, COMPONENTS_PATH } from '../../constants.js';
|
|
13
|
+
|
|
14
|
+
const pegaConfigJsonPath = path.join(path.resolve(), TASKS_CONFIG_JSON_FILENAME);
|
|
15
|
+
|
|
16
|
+
export const getOrgLib = async () => {
|
|
17
|
+
const defaultPegaConfig = await getPegaServerConfig();
|
|
18
|
+
|
|
19
|
+
await checkPathAccess(pegaConfigJsonPath);
|
|
20
|
+
|
|
21
|
+
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
22
|
+
data = data && JSON.parse(data);
|
|
23
|
+
|
|
24
|
+
if (!data[COMPONENTS_DIRECTORY_PATH]) {
|
|
25
|
+
console.error(`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const componentData = data[COMPONENTS_PATH];
|
|
30
|
+
|
|
31
|
+
let library;
|
|
32
|
+
({ library } = componentData);
|
|
33
|
+
let { organization } = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'));
|
|
34
|
+
|
|
35
|
+
const componentDefaults = await getComponentDefaults();
|
|
36
|
+
componentDefaults.library = library;
|
|
37
|
+
componentDefaults.organization = organization;
|
|
38
|
+
|
|
39
|
+
return componentDefaults;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const getBuildComponentQuestions = async (defaultVersion) => {
|
|
43
|
+
const components = await getComponents();
|
|
44
|
+
const defaultPegaConfig = await getPegaServerConfig();
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
if (components.length == 0) {
|
|
48
|
+
console.log(chalk.redBright("No components to build"));
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return [
|
|
53
|
+
{
|
|
54
|
+
name: 'version',
|
|
55
|
+
message: 'Enter library version',
|
|
56
|
+
default: defaultVersion,
|
|
57
|
+
validate: (value) => {
|
|
58
|
+
if (validateSemver(value)) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
return 'Please provide semver compatible version e.g 0.0.1';
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'devBuild',
|
|
66
|
+
type: 'confirm',
|
|
67
|
+
message: 'Generate development build ?',
|
|
68
|
+
default: defaultPegaConfig.devBuild
|
|
69
|
+
}
|
|
70
|
+
];
|
|
71
|
+
};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import inquirer from 'inquirer';
|
|
2
|
+
import { Listr } from 'listr2';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
import validate from '../validator/index.js';
|
|
9
|
+
import { lintComponent } from '../linter/index.js';
|
|
10
|
+
import { getComponentDirectoryPath, showVersion, getComponents, getLibraryBased, getC11NB2STokenAndStaticServer, updateComponentDefaultVersion, deleteLocalLibrary } from '../../util.js';
|
|
11
|
+
|
|
12
|
+
import { getBuildComponentQuestions, getOrgLib } from './helper.js';
|
|
13
|
+
import { buildLib } from '@pega/constellation-dx-components-build-utils/index.js';
|
|
14
|
+
|
|
15
|
+
const isLibraryBased = await getLibraryBased();
|
|
16
|
+
|
|
17
|
+
export const updateConfigVersion = async (componentKey, buildVersion) => {
|
|
18
|
+
const componentDirectory = await getComponentDirectoryPath(componentKey);
|
|
19
|
+
let configFileName = "config.json";
|
|
20
|
+
|
|
21
|
+
const configFile = path.join(componentDirectory, configFileName);
|
|
22
|
+
let configData;
|
|
23
|
+
try {
|
|
24
|
+
configData = fs.readFileSync(path.resolve(configFile), 'utf8');
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
|
|
28
|
+
// for now, if now file just end
|
|
29
|
+
console.log(`${chalk.bold.yellow('Config file not availabe for: ' + componentToValidate)}`);
|
|
30
|
+
return;
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let data;
|
|
35
|
+
try {
|
|
36
|
+
data = JSON.parse(configData);
|
|
37
|
+
}
|
|
38
|
+
catch (er) {
|
|
39
|
+
throw new Error(`Invalid schema json in config.json: ${er}`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
data.version = buildVersion;
|
|
43
|
+
|
|
44
|
+
// write back file
|
|
45
|
+
fs.writeFileSync(configFile, JSON.stringify(data, null, 4), { encoding: 'utf8' });
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
export function getCustomTasks(componentKey, devBuild, buildVersion, options) {
|
|
50
|
+
|
|
51
|
+
const sDevBuild = devBuild ? '(dev build)' : '';
|
|
52
|
+
return new Listr(
|
|
53
|
+
[
|
|
54
|
+
{
|
|
55
|
+
title: 'Validate config schema',
|
|
56
|
+
task: async () => {
|
|
57
|
+
await updateConfigVersion(componentKey, buildVersion);
|
|
58
|
+
await validate(componentKey);
|
|
59
|
+
},
|
|
60
|
+
skip: () => (componentKey === "shared" ? true : false)
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
title: 'Lint component',
|
|
64
|
+
task: async () => {
|
|
65
|
+
const targetDirectory = await getComponentDirectoryPath(componentKey);
|
|
66
|
+
// console.log(`in buildComponent Lint component task: componentKey: ${componentKey} targetDirectory: ${targetDirectory}`);
|
|
67
|
+
await lintComponent(targetDirectory);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
],
|
|
72
|
+
{ concurrent: false, exitOnError: true }
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
export default async (options) => {
|
|
82
|
+
if (!isLibraryBased) {
|
|
83
|
+
console.log(`Command only supported for ${chalk.bold.green('library based')} components.`)
|
|
84
|
+
process.exit();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
showVersion();
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
const components = await getComponents();
|
|
91
|
+
|
|
92
|
+
const compDef = await getOrgLib();
|
|
93
|
+
const organization = compDef.organization;
|
|
94
|
+
const library = compDef.library;
|
|
95
|
+
const currentOrgLib = organization.concat("_").concat(library);
|
|
96
|
+
|
|
97
|
+
let version;
|
|
98
|
+
let devBuild;
|
|
99
|
+
|
|
100
|
+
if (options.params.length >= 5) {
|
|
101
|
+
version = options.params[3];
|
|
102
|
+
const dBuild = options.params[4];
|
|
103
|
+
devBuild = (dBuild === 'Y' ||
|
|
104
|
+
dBuild === 'y' ||
|
|
105
|
+
dBuild === true ||
|
|
106
|
+
dBuild === 'true') ? true : false;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
console.log(`\nLibrary ${chalk.bold.green(currentOrgLib)} `)
|
|
113
|
+
const questions = await getBuildComponentQuestions(compDef.version);
|
|
114
|
+
const answers = await inquirer.prompt(questions);
|
|
115
|
+
({ version, devBuild } = answers);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
|
|
120
|
+
|
|
121
|
+
if (tokenAndStaticServer.C11NB2S === undefined) {
|
|
122
|
+
console.log(chalk.redBright("Need to authenticate, missing services token.\nBuilding a library requires authentication to acquire a token to build."));
|
|
123
|
+
process.exit(1);
|
|
124
|
+
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const buildLibName = organization.concat("_").concat(library);
|
|
128
|
+
|
|
129
|
+
await updateComponentDefaultVersion(version);
|
|
130
|
+
|
|
131
|
+
const buildVersion = devBuild && version.indexOf("-dev") < 0 ? version.concat("-dev") : version;
|
|
132
|
+
|
|
133
|
+
for await (const componentKey of components) {
|
|
134
|
+
console.log(chalk.bold.green(`Building ${componentKey}`));
|
|
135
|
+
|
|
136
|
+
const myCustomTasks = getCustomTasks(componentKey, devBuild, buildVersion, options );
|
|
137
|
+
|
|
138
|
+
try {
|
|
139
|
+
await myCustomTasks.run();
|
|
140
|
+
}
|
|
141
|
+
catch (err) {
|
|
142
|
+
console.log(chalk.bold.red(err.toString()));
|
|
143
|
+
process.exit(1);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
console.log(""); // line break
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
console.log(chalk.green.bold("Building Library... "));
|
|
151
|
+
|
|
152
|
+
// delete and rebuild library
|
|
153
|
+
try {
|
|
154
|
+
await deleteLocalLibrary(currentOrgLib);
|
|
155
|
+
}
|
|
156
|
+
catch (ex) {}
|
|
157
|
+
|
|
158
|
+
// call constellation-dx-components-build-utils build library, which will create a directory of the "buildLibName"
|
|
159
|
+
// with subdirectories for each version.
|
|
160
|
+
// If "buildDev", we append to version "-dev". Currently, only "-dev" versions, when published, can be deleted.
|
|
161
|
+
buildLib(buildLibName, buildVersion, tokenAndStaticServer.C11NB2S, tokenAndStaticServer.appStaticContentServer);
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
return true;
|
|
165
|
+
};
|
|
@@ -16,9 +16,13 @@ import {
|
|
|
16
16
|
getPegaServerConfig,
|
|
17
17
|
sanitize,
|
|
18
18
|
validateSemver,
|
|
19
|
-
showVersion
|
|
19
|
+
showVersion,
|
|
20
|
+
updateComponentDefaultLibrary,
|
|
21
|
+
updateComponentDefaultVersion,
|
|
22
|
+
copyFileToShared,
|
|
23
|
+
getLibraryBased
|
|
20
24
|
} from '../../util.js';
|
|
21
|
-
import { COMPONENT_SCHEMA } from '../../constants.js';
|
|
25
|
+
import { COMPONENT_SCHEMA, SHARED_FILE_NAMES } from '../../constants.js';
|
|
22
26
|
|
|
23
27
|
const copy = promisify(ncp);
|
|
24
28
|
|
|
@@ -28,6 +32,8 @@ const copyComponentTemplate = async options => {
|
|
|
28
32
|
});
|
|
29
33
|
};
|
|
30
34
|
|
|
35
|
+
const isLibraryBased = await getLibraryBased();
|
|
36
|
+
|
|
31
37
|
const compileMustacheTemplates = async (
|
|
32
38
|
componentDirectory,
|
|
33
39
|
{
|
|
@@ -90,6 +96,11 @@ const compileMustacheTemplates = async (
|
|
|
90
96
|
allowedApplications = [].concat(allowedApplications);
|
|
91
97
|
}
|
|
92
98
|
|
|
99
|
+
const orgLib = organization.concat("_").concat(library);
|
|
100
|
+
const componentLabelOrgLib = componentLabel.concat(` (${orgLib})`);
|
|
101
|
+
const desciptionOrgLib = description == null || description === "" ? componentLabelOrgLib : description.concat(` (${orgLib})`);
|
|
102
|
+
|
|
103
|
+
|
|
93
104
|
allowedApplications = allowedApplications.filter(el => !!el.trim()).map(el => el.trim());
|
|
94
105
|
files.forEach(file => {
|
|
95
106
|
const filePath = path.join(componentDirectory, file);
|
|
@@ -97,7 +108,7 @@ const compileMustacheTemplates = async (
|
|
|
97
108
|
const output = compileMustacheTemplate(filePath, {
|
|
98
109
|
COMPONENT_KEY: componentKey,
|
|
99
110
|
COMPONENT_NAME: componentName,
|
|
100
|
-
COMPONENT_LABEL: componentLabel,
|
|
111
|
+
COMPONENT_LABEL: isLibraryBased ? componentLabelOrgLib : componentLabel,
|
|
101
112
|
COMPONENT_CLASS_NAME: componentClassName,
|
|
102
113
|
ORGANIZATION: organization,
|
|
103
114
|
VERSION: version,
|
|
@@ -105,14 +116,47 @@ const compileMustacheTemplates = async (
|
|
|
105
116
|
ALLOWEDAPPS: JSON.stringify(allowedApplications),
|
|
106
117
|
TYPE: type,
|
|
107
118
|
SUB_TYPE: JSON.stringify(mustacheSubType),
|
|
108
|
-
DESCRIPTION:
|
|
119
|
+
DESCRIPTION: isLibraryBased ? desciptionOrgLib : description,
|
|
109
120
|
IS_TEMPLATE: isTemplate,
|
|
110
121
|
IS_PICKLIST: isPicklist,
|
|
111
122
|
IS_BOOLEAN: isBool,
|
|
112
123
|
IS_PHONE: isPhone
|
|
113
124
|
});
|
|
114
|
-
|
|
115
|
-
|
|
125
|
+
|
|
126
|
+
const realFileName = file.replace('.mustache', '');
|
|
127
|
+
if ( isLibraryBased) {
|
|
128
|
+
if (SHARED_FILE_NAMES.includes(realFileName)) {
|
|
129
|
+
// write to shared
|
|
130
|
+
copyFileToShared(realFileName, output);
|
|
131
|
+
|
|
132
|
+
// delete file from main components
|
|
133
|
+
fs.rmSync(filePath);
|
|
134
|
+
}
|
|
135
|
+
else if (realFileName === "index.tsx" || realFileName === "index.ts" ) {
|
|
136
|
+
// going to search for shared file names an change the import path
|
|
137
|
+
let newOutput = output;
|
|
138
|
+
for (const index in SHARED_FILE_NAMES) {
|
|
139
|
+
const sFileName = SHARED_FILE_NAMES[index].split(".")[0];
|
|
140
|
+
const orgPath = "./".concat(sFileName);
|
|
141
|
+
const newPath = "../shared/".concat(sFileName);
|
|
142
|
+
|
|
143
|
+
newOutput = newOutput.replaceAll(orgPath, newPath);
|
|
144
|
+
}
|
|
145
|
+
fs.writeFileSync(filePath, newOutput);
|
|
146
|
+
fs.renameSync(filePath, filePath.replace('.mustache', ''));
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
fs.writeFileSync(filePath, output);
|
|
150
|
+
fs.renameSync(filePath, filePath.replace('.mustache', ''));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
fs.writeFileSync(filePath, output);
|
|
156
|
+
fs.renameSync(filePath, filePath.replace('.mustache', ''));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
|
|
116
160
|
});
|
|
117
161
|
};
|
|
118
162
|
|
|
@@ -143,6 +187,15 @@ const validateCompile = async (
|
|
|
143
187
|
}
|
|
144
188
|
|
|
145
189
|
|
|
190
|
+
// check of library or version has changed from default, if so, update componentDefaults
|
|
191
|
+
const componentDefaults = await getComponentDefaults();
|
|
192
|
+
if (componentDefaults.library == null || componentDefaults.library !== library) {
|
|
193
|
+
await updateComponentDefaultLibrary(library);
|
|
194
|
+
}
|
|
195
|
+
if (componentDefaults.version == null || componentDefaults.version !== version) {
|
|
196
|
+
await updateComponentDefaultVersion(version);
|
|
197
|
+
}
|
|
198
|
+
|
|
146
199
|
|
|
147
200
|
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
148
201
|
const isLaunchpad = defaultPegaServerConfig.serverType === 'launchpad';
|
|
@@ -119,6 +119,7 @@ function {{COMPONENT_CLASS_NAME}}(props: {{COMPONENT_CLASS_NAME}}Props) {
|
|
|
119
119
|
// only retrieve table data if table is shown
|
|
120
120
|
if (showTable) {
|
|
121
121
|
PCore.getDataPageUtils()
|
|
122
|
+
// @ts-ignore
|
|
122
123
|
.getDataAsync(dataViewName, context, params, null, null)
|
|
123
124
|
// @ts-ignore
|
|
124
125
|
.then((response: any) => {
|
package/src/tasks/create/templates/Constellation/Template/DETAILS/HighlightRender.tsx.mustache
CHANGED
|
@@ -18,7 +18,7 @@ const HighlightRender = (props: HighlightRenderProps) => {
|
|
|
18
18
|
field.config.displayAsStatus = true;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const configProps = getPConnect().resolveConfigProps(field.config);
|
|
21
|
+
const configProps: any = getPConnect().resolveConfigProps(field.config);
|
|
22
22
|
|
|
23
23
|
// @ts-ignore
|
|
24
24
|
const reactField = getPConnect().createComponent(field);
|
|
@@ -18,7 +18,7 @@ const HighlightRender = (props: HighlightRenderProps) => {
|
|
|
18
18
|
field.config.displayAsStatus = true;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const configProps = getPConnect().resolveConfigProps(field.config);
|
|
21
|
+
const configProps: any = getPConnect().resolveConfigProps(field.config);
|
|
22
22
|
|
|
23
23
|
// @ts-ignore
|
|
24
24
|
const reactField = getPConnect().createComponent(field);
|
|
@@ -116,6 +116,7 @@ function {{COMPONENT_CLASS_NAME}}(props: {{COMPONENT_CLASS_NAME}}Props) {
|
|
|
116
116
|
// only retrieve table data if table is shown
|
|
117
117
|
if (showTable) {
|
|
118
118
|
PCore.getDataPageUtils()
|
|
119
|
+
// @ts-ignore
|
|
119
120
|
.getDataAsync(dataViewName, context, params, null, null)
|
|
120
121
|
// @ts-ignore
|
|
121
122
|
.then((response: any) => {
|
|
@@ -17,10 +17,14 @@ import { checkPathAccess, showVersion ,
|
|
|
17
17
|
getComponents,
|
|
18
18
|
getComponentDefaults,
|
|
19
19
|
sanitize,
|
|
20
|
-
validateSemver
|
|
20
|
+
validateSemver,
|
|
21
|
+
updateComponentDefaultLibrary,
|
|
22
|
+
updateComponentDefaultVersion,
|
|
23
|
+
copyFileToShared,
|
|
24
|
+
getLibraryBased
|
|
21
25
|
} from '../../util.js';
|
|
22
26
|
|
|
23
|
-
import { COMPONENT_SCHEMA, COMPONENTS_DIRECTORY_PATH, TASKS_CONFIG_JSON_FILENAME, COMPONENTS_PATH, CATEGORY_CONSTELLATION } from '../../constants.js';
|
|
27
|
+
import { COMPONENT_SCHEMA, COMPONENTS_DIRECTORY_PATH, TASKS_CONFIG_JSON_FILENAME, COMPONENTS_PATH, CATEGORY_CONSTELLATION, SHARED_FILE_NAMES } from '../../constants.js';
|
|
24
28
|
|
|
25
29
|
export const DXCB_CONFIG_INTERNAL_JSON_FILENAME = 'src/dxcb.config.json';
|
|
26
30
|
|
|
@@ -28,6 +32,8 @@ const pegaConfigJsonPath = path.join(path.resolve(), TASKS_CONFIG_JSON_FILENAME)
|
|
|
28
32
|
|
|
29
33
|
const copy = promisify(ncp);
|
|
30
34
|
|
|
35
|
+
const isLibraryBased = await getLibraryBased();
|
|
36
|
+
|
|
31
37
|
const copyComponentTemplate = async (options) => {
|
|
32
38
|
if (options.targetDirectory) {
|
|
33
39
|
return copy(options.templateDirectory, options.targetDirectory, {
|
|
@@ -99,6 +105,10 @@ export const compileMustacheTemplates = async (
|
|
|
99
105
|
allowedApplications = [].concat(allowedApplications);
|
|
100
106
|
}
|
|
101
107
|
|
|
108
|
+
const orgLib = organization.concat("_").concat(library);
|
|
109
|
+
const componentLabelOrgLib = componentLabel.concat(` (${orgLib})`);
|
|
110
|
+
const desciptionOrgLib = description == null || description === "" ? componentLabelOrgLib : description.concat(` (${orgLib})`);
|
|
111
|
+
|
|
102
112
|
allowedApplications = allowedApplications.filter((el) => !!el.trim()).map((el) => el.trim());
|
|
103
113
|
files.forEach((file) => {
|
|
104
114
|
const filePath = path.join(componentDirectory, file);
|
|
@@ -106,7 +116,7 @@ export const compileMustacheTemplates = async (
|
|
|
106
116
|
const output = compileMustacheTemplate(filePath, {
|
|
107
117
|
COMPONENT_KEY: componentKey,
|
|
108
118
|
COMPONENT_NAME: componentName,
|
|
109
|
-
COMPONENT_LABEL: componentLabel,
|
|
119
|
+
COMPONENT_LABEL: isLibraryBased ? componentLabelOrgLib : componentLabel,
|
|
110
120
|
COMPONENT_CLASS_NAME: componentClassName,
|
|
111
121
|
ORGANIZATION: organization,
|
|
112
122
|
VERSION: version,
|
|
@@ -114,14 +124,46 @@ export const compileMustacheTemplates = async (
|
|
|
114
124
|
ALLOWEDAPPS: JSON.stringify(allowedApplications),
|
|
115
125
|
TYPE: type,
|
|
116
126
|
SUB_TYPE: JSON.stringify(mustacheSubType),
|
|
117
|
-
DESCRIPTION:
|
|
127
|
+
DESCRIPTION: isLibraryBased ? desciptionOrgLib : description,
|
|
118
128
|
IS_TEMPLATE: isTemplate,
|
|
119
129
|
IS_PICKLIST: isPicklist,
|
|
120
130
|
IS_BOOLEAN: isBool,
|
|
121
131
|
IS_PHONE: isPhone
|
|
122
132
|
});
|
|
123
|
-
|
|
124
|
-
|
|
133
|
+
|
|
134
|
+
const realFileName = file.replace('.mustache', '');
|
|
135
|
+
if ( isLibraryBased) {
|
|
136
|
+
if (SHARED_FILE_NAMES.includes(realFileName)) {
|
|
137
|
+
// write to shared
|
|
138
|
+
copyFileToShared(realFileName, output);
|
|
139
|
+
|
|
140
|
+
// delete file from main components
|
|
141
|
+
fs.rmSync(filePath);
|
|
142
|
+
}
|
|
143
|
+
else if (realFileName === "index.tsx" || realFileName === "index.ts" ) {
|
|
144
|
+
// going to search for shared file names an change the import path
|
|
145
|
+
let newOutput = output;
|
|
146
|
+
for (const index in SHARED_FILE_NAMES) {
|
|
147
|
+
const sFileName = SHARED_FILE_NAMES[index].split(".")[0];
|
|
148
|
+
const orgPath = "./".concat(sFileName);
|
|
149
|
+
const newPath = "../shared/".concat(sFileName);
|
|
150
|
+
|
|
151
|
+
newOutput = newOutput.replaceAll(orgPath, newPath);
|
|
152
|
+
}
|
|
153
|
+
fs.writeFileSync(filePath, newOutput);
|
|
154
|
+
fs.renameSync(filePath, filePath.replace('.mustache', ''));
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
fs.writeFileSync(filePath, output);
|
|
158
|
+
fs.renameSync(filePath, filePath.replace('.mustache', ''));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
fs.writeFileSync(filePath, output);
|
|
164
|
+
fs.renameSync(filePath, filePath.replace('.mustache', ''));
|
|
165
|
+
}
|
|
166
|
+
|
|
125
167
|
});
|
|
126
168
|
};
|
|
127
169
|
|
|
@@ -148,6 +190,15 @@ export const validateCompile = async (
|
|
|
148
190
|
const isLaunchpad = defaultPegaServerConfig.serverType === 'launchpad';
|
|
149
191
|
const originalFramework = framework;
|
|
150
192
|
|
|
193
|
+
// check of library or version has changed from default, if so, update componentDefaults
|
|
194
|
+
const componentDefaults = await getComponentDefaults();
|
|
195
|
+
if (componentDefaults.library == null || componentDefaults.library !== library) {
|
|
196
|
+
await updateComponentDefaultLibrary(library);
|
|
197
|
+
}
|
|
198
|
+
if (componentDefaults.version == null || componentDefaults.version !== version) {
|
|
199
|
+
await updateComponentDefaultVersion(version);
|
|
200
|
+
}
|
|
201
|
+
|
|
151
202
|
if (isLaunchpad) {
|
|
152
203
|
framework = "Launchpad";
|
|
153
204
|
|