@pega/custom-dx-components 0.25.48 → 0.25.49-TEST-0.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 CHANGED
@@ -1,7 +1,15 @@
1
1
  {
2
2
  "name": "@pega/custom-dx-components",
3
- "version": "0.25.48",
3
+ "version": "0.25.49-TEST-0.1",
4
4
  "description": "Utility for building custom UI components",
5
+ "keywords": [
6
+ "pega",
7
+ "custom-components"
8
+ ],
9
+ "license": "SEE LICENSE IN LICENSE",
10
+ "author": "Custom component dev",
11
+ "sideEffects": false,
12
+ "type": "module",
5
13
  "bin": "./bin/index.js",
6
14
  "scripts": {
7
15
  "lint:es": "eslint .",
@@ -12,13 +20,11 @@
12
20
  "test:unit:local": "node --input-type=module --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand /tests/unit",
13
21
  "test:functional:local": "jest --runInBand /tests/functional --detectOpenHandles --coverage"
14
22
  },
15
- "type": "module",
16
- "sideEffects": false,
17
23
  "dependencies": {
18
- "@babel/core": "^7.27.1",
24
+ "@babel/core": "^7.28.1",
19
25
  "@babel/plugin-transform-class-properties": "^7.27.1",
20
26
  "@babel/preset-react": "^7.27.1",
21
- "@pega/auth": "^0.2.24",
27
+ "@pega/auth": "^0.2.27",
22
28
  "@pega/constellation-dx-components-build-utils": "^2.0.7",
23
29
  "@pega/inquirer-fuzzy-path": "^3.0.0",
24
30
  "ajv": "^8.17.1",
@@ -31,8 +37,8 @@
31
37
  "compression-webpack-plugin": "^11.1.0",
32
38
  "css-loader": "7.1.2",
33
39
  "css-minimizer-webpack-plugin": "^7.0.2",
34
- "eslint": "^9.27.0",
35
- "execa": "^9.5.2",
40
+ "eslint": "^9.31.0",
41
+ "execa": "^9.6.0",
36
42
  "file-loader": "6.2.0",
37
43
  "fs-extra": "^11.3.0",
38
44
  "gitignore": "^0.7.0",
@@ -46,9 +52,9 @@
46
52
  "node-stream-zip": "^1.15.0",
47
53
  "ora": "^8.2.0",
48
54
  "pascalcase": "^2.0.0",
49
- "postcss": "^8.5.3",
55
+ "postcss": "^8.5.6",
50
56
  "postcss-loader": "8.1.1",
51
- "postcss-preset-env": "10.1.6",
57
+ "postcss-preset-env": "10.2.4",
52
58
  "prop-types": "^15.8.1",
53
59
  "react": "^18.2.0",
54
60
  "react-dev-utils": "^12.0.1",
@@ -60,26 +66,20 @@
60
66
  "typescript": "~5.8.3",
61
67
  "unarchive": "^1.1.3",
62
68
  "url-loader": "4.1.1",
63
- "webpack": "5.99.8",
69
+ "webpack": "5.100.2",
64
70
  "webpack-cli": "^6.0.1"
65
71
  },
66
- "author": "Custom component dev",
67
- "license": "SEE LICENSE IN LICENSE",
68
- "keywords": [
69
- "pega",
70
- "custom-components"
71
- ],
72
72
  "devDependencies": {
73
- "@babel/preset-env": "^7.27.2",
74
- "@pega/configs": "^0.16.3",
75
- "@pega/prettier-config": "^0.16.3",
73
+ "@babel/preset-env": "^7.28.0",
74
+ "@pega/configs": "^0.17.0",
75
+ "@pega/prettier-config": "^0.17.0",
76
76
  "@types/jest": "^29.5.14",
77
77
  "babel-jest": "^29.7.0",
78
78
  "cspell": "^8.19.4",
79
79
  "jest": "^29.7.0",
80
80
  "jest-environment-jsdom": "^29.7.0",
81
81
  "jest-junit": "^16.0.0",
82
- "prettier": "3.5.3",
83
- "ts-jest": "^29.3.2"
82
+ "prettier": "3.6.2",
83
+ "ts-jest": "^29.4.0"
84
84
  }
85
85
  }
@@ -3,7 +3,7 @@ import fs from 'fs-extra';
3
3
  import webpack from 'webpack';
4
4
  import FileSizeReporter from 'react-dev-utils/FileSizeReporter.js';
5
5
  import printBuildError from 'react-dev-utils/printBuildError.js';
6
- import { getUseWebPackPromotion, addDebugLog} from '../../../util.js';
6
+ import { getUseWebPackPromotion, addDebugLog, emptyDirSync } from '../../../util.js';
7
7
 
8
8
 
9
9
 
@@ -44,7 +44,7 @@ let compilationErrors = null;
44
44
 
45
45
  // Create the build and print the deployment instructions.
46
46
  function build(config, previousFileSizes, showStats = true) {
47
- addDebugLog("bundle build", `config: ${JSON.stringify(config)}, \npreviousFileSizes: ${JSON.stringify(previousFileSizes)}, showStats: ${showStats}`, "");
47
+ addDebugLog("bundle build", `config: ${JSON.stringify(config)}, \npreviousFileSizes: ${JSON.stringify(previousFileSizes)}, showStats: ${showStats}`, "");
48
48
 
49
49
  if (showStats) {
50
50
  console.log(`Creating a ${Env} build...`);
@@ -55,14 +55,14 @@ addDebugLog("bundle build", `config: ${JSON.stringify(config)}, \npreviousFileSi
55
55
  return new Promise((resolve, reject) => {
56
56
  compiler.run((err, stats) => {
57
57
 
58
- if (err != null && typeof (err) == "object") {
59
- if (err.error != undefined) {
60
- //store and print elsewhere
61
- compilationErrors = err.error;
62
- //console.log("err:" + err);
63
- }
64
- }
65
- if (stats != null & typeof(stats) == "object") {
58
+ if (err != null && typeof (err) == "object") {
59
+ if (err.error != undefined) {
60
+ //store and print elsewhere
61
+ compilationErrors = err.error;
62
+ //console.log("err:" + err);
63
+ }
64
+ }
65
+ if (stats != null & typeof (stats) == "object") {
66
66
  if (stats.errors != undefined) {
67
67
  if (showStats) {
68
68
  console.log("stats:" + stats);
@@ -79,7 +79,7 @@ addDebugLog("bundle build", `config: ${JSON.stringify(config)}, \npreviousFileSi
79
79
 
80
80
  }
81
81
 
82
- }
82
+ }
83
83
 
84
84
 
85
85
  let messages;
@@ -118,7 +118,7 @@ addDebugLog("bundle build", `config: ${JSON.stringify(config)}, \npreviousFileSi
118
118
  console.log(
119
119
  chalk.yellow(
120
120
  '\nTreating warnings as errors because process.env.CI = true.\n' +
121
- 'Most CI servers set it automatically.\n'
121
+ 'Most CI servers set it automatically.\n'
122
122
  )
123
123
  );
124
124
  return reject(new Error(messages.warnings.join('\n\n')));
@@ -148,7 +148,7 @@ export default async ({
148
148
  // used by promote and revert webPack commands, do not change
149
149
  const configFactory = (
150
150
  await import(`${usePromoted ? `../../../../../../../webpack.config.js` : `./webpack.config.js`}`)
151
- ).default
151
+ ).default;
152
152
 
153
153
  // Generate configuration
154
154
  const config = configFactory(Env, {
@@ -170,7 +170,7 @@ export default async ({
170
170
  .then(previousFileSizes => {
171
171
  // Remove all content but keep the directory so that
172
172
  // if you're in it, you don't end up in Trash
173
- fs.emptyDirSync(paths.appBuild);
173
+ emptyDirSync(paths.appBuild);
174
174
  // Start the webpack build
175
175
  return build(config, previousFileSizes, showStats);
176
176
  })
@@ -202,7 +202,7 @@ export default async ({
202
202
 
203
203
  resolve('done emitting');
204
204
  },
205
- err => {
205
+ err => {
206
206
  reject();
207
207
  const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true';
208
208
  if (tscCompileOnError) {
@@ -1,30 +1,25 @@
1
+
1
2
  import path from 'path';
2
3
  import fs from 'fs';
3
4
  import { fileURLToPath } from 'url';
4
5
  import { promisify } from 'util';
5
- import { exec } from 'child_process';
6
-
7
6
  import chalk from 'chalk';
8
7
  import { execa } from 'execa';
9
- import ncp from 'ncp';
10
8
  import { Listr } from 'listr2';
11
9
  import gitignore from 'gitignore';
12
10
  import inquirer from 'inquirer';
11
+ import { compileMustacheTemplate, isPascalCase, convertIntoPascalCase, sanitize } from '../../util.js';
12
+ import { getInitProjectQuestions } from './helper.js';
13
13
 
14
- import {
15
- compileMustacheTemplate,
16
- isPascalCase,
17
- convertIntoPascalCase,
18
- sanitize
19
- } from '../../util.js';
14
+ const writeGitignore = promisify(gitignore.writeFile);
20
15
 
21
- import { getInitProjectQuestions } from './helper.js';
22
16
 
23
- const execPromise = promisify(exec);
17
+ const copyProjectDir = async (src, dest) => {
18
+ if (typeof fs.cp === 'function') {
19
+ await fs.promises.cp(src, dest, { recursive: true, errorOnExist: false, force: false });
20
+ }
21
+ };
24
22
 
25
- const copy = promisify(ncp);
26
- const writeGitignore = promisify(gitignore.writeFile);
27
- const writeFile = promisify(fs.writeFile);
28
23
 
29
24
  const createGitignore = async options => {
30
25
  const file = fs.createWriteStream(path.join(options.targetDirectory, '.gitignore'), {
@@ -37,51 +32,54 @@ const createGitignore = async options => {
37
32
  };
38
33
 
39
34
  const createLicense = async options => {
35
+ // Write LICENSE file directly
40
36
  const targetPath = path.join(options.targetDirectory, 'LICENSE');
41
37
  const licenseContent = 'Enter license text here';
42
- return writeFile(targetPath, licenseContent, 'utf8');
38
+ await fs.promises.writeFile(targetPath, licenseContent, 'utf8');
43
39
  };
44
40
 
41
+
45
42
  const copyProjectTemplate = async options => {
46
- await copy(options.templateDirectory, options.targetDirectory, {
47
- clobber: false
48
- });
43
+ // Use fast copy
44
+ await copyProjectDir(options.templateDirectory, options.targetDirectory);
49
45
  const packageJsonPath = path.join(options.targetDirectory, 'package.json.mustache');
50
46
  const templateNPMRCPath = path.join(options.targetDirectory, 'templateNPMRC.txt');
51
47
 
52
48
  let { organization, projectName } = options;
53
-
54
49
  projectName = sanitize(projectName).toLowerCase();
55
-
56
50
  organization = sanitize(organization);
57
51
  if (!isPascalCase(organization)) {
58
52
  organization = convertIntoPascalCase(organization);
59
53
  }
54
+ options = { ...options, organization, projectName };
60
55
 
61
- options = {
62
- ...options,
63
- organization,
64
- projectName
65
- };
56
+ // Compile and write package.json in one go
66
57
  const output = compileMustacheTemplate(packageJsonPath, options);
67
- fs.writeFileSync(packageJsonPath, output);
68
- fs.renameSync(packageJsonPath, packageJsonPath.replace('.mustache', ''));
69
-
70
- // rename template NPMRC to .npmrc, need to do this because npmjs won't publish an .npmrc file
71
- fs.renameSync(templateNPMRCPath, templateNPMRCPath.replace('templateNPMRC.txt', '.npmrc'));
58
+ await fs.promises.writeFile(packageJsonPath, output);
59
+ await fs.promises.rename(packageJsonPath, packageJsonPath.replace('.mustache', ''));
60
+
61
+ // Rename templateNPMRC.txt to .npmrc if exists
62
+ try {
63
+ await fs.promises.rename(templateNPMRCPath, templateNPMRCPath.replace('templateNPMRC.txt', '.npmrc'));
64
+ } catch (e) {
65
+ // ignore if not present
66
+ }
72
67
 
73
68
  await createLicense(options);
74
69
  };
75
70
 
71
+
76
72
  const initGit = async options => {
73
+ // Use execa for async git init
77
74
  const result = await execa('git', ['init'], {
78
75
  cwd: options.targetDirectory
79
76
  });
80
77
  if (result.failed) {
81
- return Promise.reject(new Error('Failed to initialize git'));
78
+ throw new Error('Failed to initialize git');
82
79
  }
83
80
  };
84
81
 
82
+
85
83
  export default async options => {
86
84
  options.templateDirectory = path.resolve(
87
85
  path.dirname(fileURLToPath(import.meta.url)),
@@ -90,32 +88,28 @@ export default async options => {
90
88
  let projectName = 'test';
91
89
 
92
90
  const questions = getInitProjectQuestions();
91
+ const answers = await inquirer.prompt(questions);
92
+ projectName = sanitize(answers.projectName).toLowerCase();
93
+ options = { ...options, ...answers };
94
+
95
+ const projectDirectory = `./${projectName}`;
96
+ if (!fs.existsSync(projectDirectory)) {
97
+ fs.mkdirSync(projectDirectory);
98
+ } else {
99
+ console.log(chalk.bold.red(`A project with name ${projectName} already exists. Exiting...`));
100
+ process.exit();
101
+ }
93
102
 
94
- await inquirer.prompt(questions).then(async answers => {
95
- projectName = answers.projectName;
96
- projectName = sanitize(projectName).toLowerCase();
97
- options = { ...options, ...answers };
98
-
99
- const projectDirectory = `./${projectName}`;
100
-
101
- if (!fs.existsSync(projectDirectory)) {
102
- fs.mkdirSync(projectDirectory);
103
- } else {
104
- console.log(chalk.bold.red(`A project with name ${projectName} already exists. Exiting...`));
105
- process.exit();
106
- }
107
-
108
- const targetDirectory = options.targetDirectory || process.cwd();
109
- options.targetDirectory = path.join(targetDirectory, projectName);
110
- options.componentDirectory = path.join(
111
- options.targetDirectory,
112
- 'node_modules/@pega/custom-dx-components'
113
- );
114
- options.componentLibraryUtilsDirectory = path.join(
115
- options.targetDirectory,
116
- 'node_modules/@pega/constellation-dx-components-build-utils'
117
- );
118
- });
103
+ const targetDirectory = options.targetDirectory || process.cwd();
104
+ options.targetDirectory = path.join(targetDirectory, projectName);
105
+ options.componentDirectory = path.join(
106
+ options.targetDirectory,
107
+ 'node_modules/@pega/custom-dx-components'
108
+ );
109
+ options.componentLibraryUtilsDirectory = path.join(
110
+ options.targetDirectory,
111
+ 'node_modules/@pega/constellation-dx-components-build-utils'
112
+ );
119
113
 
120
114
  const installDependenciesText = `Installing dependencies. This will take a couple of minutes.`;
121
115
 
@@ -138,35 +132,38 @@ export default async options => {
138
132
  {
139
133
  title: installDependenciesText,
140
134
  task: () =>
141
- execPromise('npm i --force --production=false', { cwd: options.targetDirectory })
135
+ execa('npm', ['i', '--force', '--production=false'], { cwd: options.targetDirectory })
142
136
  },
143
137
  */
144
138
  {
145
139
  title: installDependenciesText,
146
140
  task: () =>
147
- execPromise('npm i --force --include=dev', { cwd: options.targetDirectory })
141
+ execa('npm', ['i', '--force', '--no-audit', '--no-fund', '--loglevel=error'], { cwd: options.targetDirectory })
148
142
  },
149
143
  /*
150
144
  {
151
145
  title: 'Installing tasks dependencies',
152
146
  task: () =>
153
- execPromise('npm i --force --production=false', { cwd: options.componentDirectory })
147
+ execa('npm', ['i', '--force', '--production=false'], { cwd: options.componentDirectory })
154
148
  },
155
149
  {
156
150
  title: 'Installing tasks library dependencies',
157
151
  task: () =>
158
- execPromise('npm i --force --production=false', {
152
+ execa('npm', ['i', '--force', '--production=false'], {
159
153
  cwd: options.componentLibraryUtilsDirectory
160
154
  })
161
155
  },
162
156
  */
157
+
158
+ /*
163
159
  {
164
160
  title: 'Updating',
165
- task: () => execPromise('npm update --dev', { cwd: options.targetDirectory })
161
+ task: () => execa('npm', ['update', '--dev', '--no-audit', '--no-fund', '--loglevel=error'], { cwd: options.targetDirectory })
166
162
  }
163
+ */
167
164
  /* {
168
165
  title: 'Installing quick run',
169
- task: () => execPromise('npm i -g npm-quick-run', { cwd: options.targetDirectory })
166
+ task: () => execa('npm', ['i', '-g', 'npm-quick-run'], { cwd: options.targetDirectory })
170
167
  } */
171
168
  ],
172
169
  {
@@ -99,7 +99,6 @@
99
99
  "react-is": "^18.3.1",
100
100
  "react-redux": "^7.2.9",
101
101
  "serve": "^14.2.4",
102
- "shelljs": "^0.8.5",
103
102
  "styled-components": "^5.3.11",
104
103
  "ts-loader": "^9.5.2"
105
104
  },
@@ -108,7 +107,7 @@
108
107
  "@babel/preset-react": "^7.27.1",
109
108
  "@babel/preset-typescript": "^7.27.1",
110
109
  "@pega/configs": "^0.16.3",
111
- "@pega/custom-dx-components": "~0.25.48",
110
+ "@pega/custom-dx-components": "~0.25.49-TEST-0.1",
112
111
  "@pega/pcore-pconnect-typedefs": "^4.1.0-alpha.1",
113
112
  "@storybook/addon-actions": "^8.6.14",
114
113
  "@storybook/addon-essentials": "^8.6.14",
package/src/util.js CHANGED
@@ -2843,5 +2843,11 @@ export const isComponentValidLength = (componentKey) => {
2843
2843
  return false;
2844
2844
  }
2845
2845
 
2846
+
2847
+ export const emptyDirSync = dir => (
2848
+ fs.rmSync(dir, { recursive: true, force: true }),
2849
+ fs.mkdirSync(dir, { recursive: true })
2850
+ )
2851
+
2846
2852
  // init
2847
2853
  await forceDefaultsUpdate();