@pega/custom-dx-components 0.25.24 → 0.25.25

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/custom-dx-components",
3
- "version": "0.25.24",
3
+ "version": "0.25.25",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
@@ -29,7 +29,7 @@
29
29
  "publishAll": "custom-dx-components publishAll",
30
30
  "promoteWebPack": "custom-dx-components promoteWebPack",
31
31
  "revertWebPack": "custom-dx-components revertWebPack",
32
- "_***Library_mode_only***": "Library mode only commands, Beta capability and subject to change. Developer experimental. Do not use in a Production Deployment",
32
+ "_***Library_mode_only***": "Library CL mode only commands",
33
33
  "createLib": "custom-dx-components createLibrary",
34
34
  "switchLib": "custom-dx-components switchLibrary",
35
35
  "createLibVersion": "custom-dx-components createVersion",
@@ -49,6 +49,10 @@
49
49
  "exportLibVersion": "custom-dx-components exportArchive",
50
50
  "validate": "custom-dx-components buildComponent",
51
51
  "validateAll": "custom-dx-components buildAllComponents",
52
+ "_***Local component server***": "Commands to lauch local component server for debugging of run time",
53
+ "localDev": "node scripts/esbuild.dev.js",
54
+ "localGenerate": "node scripts/main.js",
55
+ "localStart": "npm run localGenerate && npm run localDev",
52
56
  "_***Internal_only***": "Internal usage only",
53
57
  "_internal-test-coverage": "node --input-type=module --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand node_modules/@pega/custom-dx-component --ci --testResultsProcessor='jest-junit' --coverage",
54
58
  "_internal-test": "echo 'Running functional and unit tests will DELETE existing local components, proceed (y/n)?' && read proceed && if test \"$proceed\" = \"y\"; then npm run _internal-test-full; fi ",
@@ -107,7 +111,7 @@
107
111
  "@babel/preset-react": "^7.26.3",
108
112
  "@babel/preset-typescript": "^7.26.0",
109
113
  "@pega/configs": "^0.16.2",
110
- "@pega/custom-dx-components": "~0.25.24",
114
+ "@pega/custom-dx-components": "~0.25.25",
111
115
  "@pega/pcore-pconnect-typedefs": "^4.1.0-alpha.1",
112
116
  "@storybook/addon-actions": "^7.6.19",
113
117
  "@storybook/addon-essentials": "^7.6.19",
@@ -153,6 +157,7 @@
153
157
  "storybook": "^7.6.19",
154
158
  "stylelint": "^16.10.0",
155
159
  "ts-jest": "^29.2.5",
156
- "typescript": "~5.5.4"
160
+ "typescript": "~5.5.4",
161
+ "esbuild": "^0.25.0"
157
162
  }
158
163
  }
@@ -0,0 +1,3 @@
1
+ {
2
+ "components": []
3
+ }
@@ -0,0 +1,34 @@
1
+ import esbuild from 'esbuild';
2
+
3
+ async function startDevServer() {
4
+ const ctx = await esbuild.context({
5
+ entryPoints: ['scripts/index.ts'],
6
+ bundle: true,
7
+ outdir: 'dist',
8
+ sourcemap: true,
9
+ loader: { '.js': 'jsx' },
10
+ platform: 'browser',
11
+ logLevel: 'info',
12
+ });
13
+
14
+ // Initial build
15
+ await ctx.rebuild();
16
+ console.log('✨ Initial build complete');
17
+
18
+ // Watch for changes
19
+ await ctx.watch();
20
+ console.log('👀 Watching for changes...');
21
+
22
+ let { host, port } = await ctx.serve({
23
+ servedir: 'dist',
24
+ port: 3030,
25
+ host: 'localhost'
26
+ });
27
+
28
+ console.log(`🚀 Development server running at http://${host}:${port}`);
29
+ }
30
+
31
+ startDevServer().catch((err) => {
32
+ console.error('Error:', err);
33
+ process.exit(1);
34
+ });
@@ -0,0 +1,26 @@
1
+ export const loadable = (importFn: () => Promise<any>, componentName: string) => {
2
+ return async () => {
3
+ if (!PCore.getComponentsRegistry().lazyMap[componentName]) {
4
+ const component = await importFn();
5
+ PCore.getComponentsRegistry().lazyMap[componentName] = component.default;
6
+ }
7
+ };
8
+ };
9
+
10
+ const reactComponentsMap = {
11
+ {{#components}}
12
+ {{name}}: {
13
+ modules: [
14
+ loadable(
15
+ () =>
16
+ import(
17
+ /* webpackChunkName: "{{name}}" */ "../src/components/{{name}}/index"
18
+ ),
19
+ "{{name}}"
20
+ ),
21
+ ],
22
+ scripts: [],
23
+ },
24
+ {{/components}}
25
+ };
26
+ PCore.getComponentsRegistry().mergeComponentsMap(reactComponentsMap);
@@ -0,0 +1 @@
1
+ /* entry point for component map */
@@ -0,0 +1,75 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { fileURLToPath } from 'url';
4
+ import Mustache from 'mustache';
5
+
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
8
+
9
+ const componentsDir = path.join(__dirname, '../src/components');
10
+ const componentsJsonPath = path.join(__dirname, './components.json');
11
+
12
+ async function populateComponents() {
13
+ try {
14
+ if (!fs.existsSync(componentsDir)) {
15
+ throw new Error(`Components directory not found: ${componentsDir}`);
16
+ }
17
+
18
+ const componentNames = fs.readdirSync(componentsDir)
19
+ .filter(file => {
20
+ const componentPath = path.join(componentsDir, file);
21
+ const configPath = path.join(componentPath, 'config.json');
22
+ return fs.statSync(componentPath).isDirectory() && fs.existsSync(configPath);
23
+ })
24
+ .map(dir => {
25
+ const configPath = path.join(componentsDir, dir, 'config.json');
26
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
27
+ return config.componentKey || dir;
28
+ });
29
+
30
+ const data = { components: componentNames };
31
+ fs.writeFileSync(componentsJsonPath, JSON.stringify(data, null, 2));
32
+ console.log('Components list updated:', componentNames);
33
+ return componentNames;
34
+ } catch (err) {
35
+ console.error('Error populating components:', err.message);
36
+ process.exit(1);
37
+ }
38
+ }
39
+
40
+ async function generateIndex(components) {
41
+ try {
42
+ const templatePath = path.join(__dirname, './index.mustache');
43
+ const outputPath = path.join(__dirname, './index.ts');
44
+
45
+ if (!fs.existsSync(templatePath)) {
46
+ throw new Error('Template file missing: index.mustache');
47
+ }
48
+
49
+ const template = fs.readFileSync(templatePath, 'utf-8');
50
+ const templateData = {
51
+ components: components.map(name => ({ name }))
52
+ };
53
+
54
+ const output = Mustache.render(template, templateData);
55
+
56
+ // Ensure src directory exists
57
+ const srcDir = path.dirname(outputPath);
58
+ if (!fs.existsSync(srcDir)) {
59
+ fs.mkdirSync(srcDir, { recursive: true });
60
+ }
61
+
62
+ fs.writeFileSync(outputPath, output, 'utf-8');
63
+ console.log('Generated exports for components:', components);
64
+ } catch (err) {
65
+ console.error('Error generating index:', err.message);
66
+ process.exit(1);
67
+ }
68
+ }
69
+
70
+ async function main() {
71
+ const components = await populateComponents();
72
+ await generateIndex(components);
73
+ }
74
+
75
+ main();
package/src/util.js CHANGED
@@ -337,6 +337,8 @@ if (showDebug) addDebugLog("applyPegaData", "", "");
337
337
 
338
338
  export const checkJWTExpiration = async () => {
339
339
  const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
340
+ const isLibraryBased = getLibraryBased();
341
+ const isLibraryBasedCL = getLibraryBasedCL();
340
342
 
341
343
  if (tokenAndStaticServer.C11NB2S === undefined) {
342
344
  console.log(chalk.redBright("Need to authenticate, missing services token.\nBuilding a library requires authentication to acquire a token to build."));
@@ -350,13 +352,19 @@ export const checkJWTExpiration = async () => {
350
352
  process.exit(1);
351
353
  }
352
354
 
353
- // check that there is customer_org
354
- if (!customer_org || customer_org === "") {
355
- console.log(chalk.red(`PegaInfinity server DSS setting ${chalk.redBright.bold(`C11nCCv2CustomerOrg`)} is NOT set.`));
356
- console.log(chalk.red("Please update DSS setting, save and then reauthenticate."));
357
- process.exit(1);
355
+
356
+ // only check if older isLibraryBased
357
+ if (!isLibraryBasedCL && isLibraryBased) {
358
+ // check that there is customer_org
359
+ if (!customer_org || customer_org === "") {
360
+ console.log(chalk.red(`PegaInfinity server DSS setting ${chalk.redBright.bold(`C11nCCv2CustomerOrg`)} is NOT set.`));
361
+ console.log(chalk.red("Please update DSS setting, save and then reauthenticate."));
362
+ process.exit(1);
363
+ }
364
+
358
365
  }
359
366
 
367
+
360
368
  }
361
369
 
362
370
  export const checkAccessTokenExpiration = async() => {