@pega/custom-dx-components 0.25.34 → 0.25.36
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/tasks/create/templates/Launchpad/Widget/PAGE-CASE/Avatar.tsx.mustache +0 -1
- package/src/tasks/create-lib/helper.js +70 -1
- package/src/tasks/create-lib/index.js +38 -3
- package/src/tasks/create-version/index.js +1 -1
- package/src/tasks/delete-lib/index.js +1 -1
- package/src/tasks/delete-version/index.js +1 -1
- package/src/tasks/init/template/eslint.config.mjs +1 -3
- package/src/tasks/init/template/package.json.mustache +1 -1
- package/src/tasks/publish/index.js +6 -2
- package/src/tasks/switch-lib/index.js +1 -1
- package/src/tasks/switch-version/index.js +1 -1
- package/src/util.js +1 -3
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyPageCaseWidget/Avatar.tsx +0 -1
- package/src/tasks/init/template/.eslintignore +0 -15
package/package.json
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { join } from 'path';
|
|
3
6
|
|
|
4
7
|
import {
|
|
5
8
|
sanitize,
|
|
@@ -9,9 +12,12 @@ import {
|
|
|
9
12
|
getConfigDefaults,
|
|
10
13
|
getComponents,
|
|
11
14
|
updateConfigVersion,
|
|
12
|
-
getLibraryBasedCL
|
|
15
|
+
getLibraryBasedCL,
|
|
16
|
+
copyFileToShared
|
|
13
17
|
} from '../../util.js';
|
|
14
18
|
|
|
19
|
+
import { SHARED_FILE_NAMES } from '../../constants.js';
|
|
20
|
+
|
|
15
21
|
|
|
16
22
|
export const updateAllComponentsConfig = async( newVersion ) => {
|
|
17
23
|
addDebugLog("updateAllComponentsConfig", `newVersion: ${newVersion}`, "");
|
|
@@ -27,6 +33,69 @@ addDebugLog("updateAllComponentsConfig", `newVersion: ${newVersion}`, "");
|
|
|
27
33
|
}
|
|
28
34
|
};
|
|
29
35
|
|
|
36
|
+
export const updateAllMigrateToLibChanges = async() => {
|
|
37
|
+
// get src/components directories
|
|
38
|
+
const componentList = await getComponents();
|
|
39
|
+
const currentDirectory = process.cwd();
|
|
40
|
+
// for each directory
|
|
41
|
+
|
|
42
|
+
for (const index in componentList) {
|
|
43
|
+
const componentKey = componentList[index];
|
|
44
|
+
const compDir = join(currentDirectory,'src', 'components', componentKey);
|
|
45
|
+
|
|
46
|
+
const componentFiles = fs.readdirSync(compDir);
|
|
47
|
+
|
|
48
|
+
componentFiles.forEach( file => {
|
|
49
|
+
|
|
50
|
+
const filePath = join(compDir, file);
|
|
51
|
+
const fileData = fs.readFileSync(filePath, { encoding: 'utf8' });
|
|
52
|
+
|
|
53
|
+
let newOutput = fileData;
|
|
54
|
+
if (SHARED_FILE_NAMES.includes(file)) {
|
|
55
|
+
|
|
56
|
+
// fix create nonce for ESLint 9
|
|
57
|
+
if (file.includes('create-nonce')) {
|
|
58
|
+
newOutput = newOutput.replace("__webpack_nonce__ = window.__webpack_nonce__;", "// eslint-disable-next-line no-undef\n__webpack_nonce__ = window.__webpack_nonce__;");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// write to shared
|
|
62
|
+
copyFileToShared(file, newOutput);
|
|
63
|
+
|
|
64
|
+
// delete file from main components
|
|
65
|
+
fs.rmSync(filePath);
|
|
66
|
+
}
|
|
67
|
+
else if (file.includes(".tsx") || file.includes(".ts") ) {
|
|
68
|
+
|
|
69
|
+
// going to search for shared file names and change the import path
|
|
70
|
+
|
|
71
|
+
for (const index in SHARED_FILE_NAMES) {
|
|
72
|
+
const sFileName = SHARED_FILE_NAMES[index].split(".")[0];
|
|
73
|
+
const orgPath = "./".concat(sFileName);
|
|
74
|
+
const newPath = "../shared/".concat(sFileName);
|
|
75
|
+
|
|
76
|
+
newOutput = newOutput.replaceAll(orgPath, newPath);
|
|
77
|
+
|
|
78
|
+
// updates for ESLint 9
|
|
79
|
+
newOutput = newOutput.replaceAll("/* eslint-disable react-hooks/exhaustive-deps */", "");
|
|
80
|
+
newOutput = newOutput.replaceAll("// eslint-disable-next-line react-hooks/exhaustive-deps", "");
|
|
81
|
+
newOutput = newOutput.replaceAll("// eslint-disable-next-line @typescript-eslint/no-unused-vars", "");
|
|
82
|
+
newOutput = newOutput.replaceAll("/* eslint-disable react-hooks/rules-of-hooks */", "");
|
|
83
|
+
newOutput = newOutput.replaceAll("/* eslint-disable-next-line no-empty */", "");
|
|
84
|
+
newOutput = newOutput.replaceAll("// eslint-disable-next-line no-empty", "");
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
fs.writeFileSync(filePath, newOutput);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
console.log(`${chalk.green(`>> Code base was upgraded. You may still have some lint errors that need to be fixed manually.`)}`);
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
|
|
30
99
|
export const getCurrentOrOriginalQuestion = async () => {
|
|
31
100
|
addDebugLog("getCurrentOrOriginal", "", "");
|
|
32
101
|
|
|
@@ -22,10 +22,11 @@ import {
|
|
|
22
22
|
setConfigDevBuild,
|
|
23
23
|
getUseInputConfig,
|
|
24
24
|
getInputConfigForCommand,
|
|
25
|
-
convertYNToBoolean
|
|
25
|
+
convertYNToBoolean,
|
|
26
|
+
getComponents
|
|
26
27
|
} from '../../util.js';
|
|
27
28
|
|
|
28
|
-
import { getCreateLibComponentQuestions, getOkToProceedQuestion, updateAllComponentsConfig, getCurrentOrOriginalQuestion } from './helper.js';
|
|
29
|
+
import { getCreateLibComponentQuestions, getOkToProceedQuestion, updateAllComponentsConfig, getCurrentOrOriginalQuestion, updateAllMigrateToLibChanges } from './helper.js';
|
|
29
30
|
import { showCurrentStatus } from '../show-status/index.js';
|
|
30
31
|
|
|
31
32
|
export default async options => {
|
|
@@ -49,8 +50,9 @@ export default async options => {
|
|
|
49
50
|
const libraryName = inputConfig.libraryName;
|
|
50
51
|
let version = inputConfig.libraryVersion;
|
|
51
52
|
const currentOrOriginal = inputConfig.currentOrOriginal;
|
|
52
|
-
const isPermanent = inputConfig
|
|
53
|
+
const isPermanent = inputConfig?.isPermanent || "N";
|
|
53
54
|
let permBuild = convertYNToBoolean(isPermanent);
|
|
55
|
+
const okToUpgrade = convertYNToBoolean(inputConfig.okToUpgrade);
|
|
54
56
|
|
|
55
57
|
// if have store, then that means there is a current library, so
|
|
56
58
|
// store it before clearing out /src/components
|
|
@@ -97,6 +99,9 @@ export default async options => {
|
|
|
97
99
|
// update the config jsons
|
|
98
100
|
if (!hasArch) {
|
|
99
101
|
await updateAllComponentsConfig(version);
|
|
102
|
+
if (okToUpgrade) {
|
|
103
|
+
await updateAllMigrateToLibChanges();
|
|
104
|
+
}
|
|
100
105
|
}
|
|
101
106
|
|
|
102
107
|
console.log(`${chalk.bold.green(`\nLibrary ${newOrgLib}/${version} has been created!\n`)}`);
|
|
@@ -227,8 +232,38 @@ addDebugLog("createLibrary", "", "+");
|
|
|
227
232
|
|
|
228
233
|
// if didn't have an archive, in case you currently have components there
|
|
229
234
|
// update the config jsons
|
|
235
|
+
|
|
236
|
+
|
|
230
237
|
if (!hasArch) {
|
|
231
238
|
await updateAllComponentsConfig(version);
|
|
239
|
+
|
|
240
|
+
const componentList = await getComponents();
|
|
241
|
+
|
|
242
|
+
if (componentList && componentList.length > 0) {
|
|
243
|
+
console.log("");
|
|
244
|
+
console.log(`You are creating a new library with existing components in ${chalk.yellow(`/src/components`)}.`);
|
|
245
|
+
console.log("These components code base can be stale and may need ES Lint updates.");
|
|
246
|
+
console.log("Some of these updates can happen automatically during library creation.");
|
|
247
|
+
console.log("");
|
|
248
|
+
|
|
249
|
+
const upgradeAnswer = await inquirer.prompt([
|
|
250
|
+
{
|
|
251
|
+
name: 'upgrade',
|
|
252
|
+
message: 'Would you like to update your code ?',
|
|
253
|
+
type: 'confirm',
|
|
254
|
+
default: true
|
|
255
|
+
}
|
|
256
|
+
]);
|
|
257
|
+
|
|
258
|
+
if (upgradeAnswer.upgrade) {
|
|
259
|
+
await updateAllMigrateToLibChanges();
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
232
267
|
}
|
|
233
268
|
|
|
234
269
|
console.log(`${chalk.bold.green(`\nLibrary ${newOrgLib}/${version} has been created!\n`)}`);
|
|
@@ -61,7 +61,7 @@ addDebugLog("createVersion", "", "+");
|
|
|
61
61
|
|
|
62
62
|
if (convertYNToBoolean(inputConfig.okToContinue)) {
|
|
63
63
|
version = inputConfig.libraryVersion;
|
|
64
|
-
const isPermanent = inputConfig
|
|
64
|
+
const isPermanent = inputConfig?.isPermanent || "N";
|
|
65
65
|
permBuild = convertYNToBoolean(isPermanent);
|
|
66
66
|
copyExisting = convertYNToBoolean(inputConfig.copyComponents);
|
|
67
67
|
|
|
@@ -238,7 +238,7 @@ addDebugLog("deleteLibrary", "", "+");
|
|
|
238
238
|
const inputConfig = await getInputConfigForCommand("deleteLib");
|
|
239
239
|
libraryName = inputConfig.libraryName;
|
|
240
240
|
version = inputConfig.libraryVersion;
|
|
241
|
-
const isPermanent = inputConfig
|
|
241
|
+
const isPermanent = inputConfig?.isPermanent || "N";
|
|
242
242
|
let permBuild = convertYNToBoolean(isPermanent);
|
|
243
243
|
|
|
244
244
|
if (isLibraryBasedCL) {
|
|
@@ -42,7 +42,7 @@ addDebugLog("deleteVersion", "", "+");
|
|
|
42
42
|
if (useInputConfig) {
|
|
43
43
|
const inputConfig = await getInputConfigForCommand("deleteLibVersion");
|
|
44
44
|
version = inputConfig.libraryVersion;
|
|
45
|
-
const isPermanent = inputConfig
|
|
45
|
+
const isPermanent = inputConfig?.isPermanent || "N";
|
|
46
46
|
let permBuild = convertYNToBoolean(isPermanent);
|
|
47
47
|
|
|
48
48
|
if (isLibraryBasedCL) {
|
|
@@ -32,6 +32,7 @@ export default tseslint.config(
|
|
|
32
32
|
'**/mock.stories.js',
|
|
33
33
|
'**/demo.stories.tsx',
|
|
34
34
|
'**/demo.test.tsx',
|
|
35
|
+
'**/*.test.tsx',
|
|
35
36
|
'**/mock.stories.ts',
|
|
36
37
|
'**/*.mdx',
|
|
37
38
|
'**/webpack.config.js',
|
|
@@ -131,7 +132,6 @@ export default tseslint.config(
|
|
|
131
132
|
'no-alert': 'off',
|
|
132
133
|
'no-console': 'error',
|
|
133
134
|
'no-fallthrough': 'error',
|
|
134
|
-
'no-undef': 'error',
|
|
135
135
|
'no-unused-vars': 'off',
|
|
136
136
|
'no-var': 'off',
|
|
137
137
|
yoda: 'error',
|
|
@@ -155,7 +155,6 @@ export default tseslint.config(
|
|
|
155
155
|
'react/no-unused-prop-types': 'error',
|
|
156
156
|
'react/static-property-placement': 'error',
|
|
157
157
|
'array-callback-return': 'error',
|
|
158
|
-
camelcase: 'error',
|
|
159
158
|
'func-names': 'error',
|
|
160
159
|
'no-case-declarations': 'error',
|
|
161
160
|
'no-lonely-if': 'error',
|
|
@@ -208,7 +207,6 @@ export default tseslint.config(
|
|
|
208
207
|
{
|
|
209
208
|
files: ['**/*.@(ts|tsx)'],
|
|
210
209
|
rules: {
|
|
211
|
-
'no-undef': 'error',
|
|
212
210
|
'no-console': 'off',
|
|
213
211
|
'import/prefer-default-export': 'off',
|
|
214
212
|
'import/no-relative-packages': 'off',
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"@babel/preset-react": "^7.27.1",
|
|
108
108
|
"@babel/preset-typescript": "^7.27.1",
|
|
109
109
|
"@pega/configs": "^0.16.3",
|
|
110
|
-
"@pega/custom-dx-components": "~0.25.
|
|
110
|
+
"@pega/custom-dx-components": "~0.25.36",
|
|
111
111
|
"@pega/pcore-pconnect-typedefs": "^4.1.0-alpha.1",
|
|
112
112
|
"@storybook/addon-actions": "^8.6.12",
|
|
113
113
|
"@storybook/addon-essentials": "^8.6.12",
|
|
@@ -20,7 +20,8 @@ import {
|
|
|
20
20
|
checkAccessTokenExpiration,
|
|
21
21
|
checkJWTExpiration,
|
|
22
22
|
getConfigDefaults,
|
|
23
|
-
getInputConfigForCommand
|
|
23
|
+
getInputConfigForCommand,
|
|
24
|
+
convertYNToBoolean} from '../../util.js';
|
|
24
25
|
|
|
25
26
|
import { getPublishComponentQuestions, publishComponentToServer, zipComponent } from './helper.js';
|
|
26
27
|
import { default as buildLibrary } from '../build-lib/index.js';
|
|
@@ -66,11 +67,14 @@ addDebugLog("publish", "", "+");
|
|
|
66
67
|
if (useInputConfig) {
|
|
67
68
|
const inputConfig = await getInputConfigForCommand("publish");
|
|
68
69
|
|
|
70
|
+
const okToPubPerm = inputConfig?.okToPublishPermanent || "Y";
|
|
71
|
+
const okToPublishPerm = convertYNToBoolean(okToPubPerm);
|
|
72
|
+
|
|
69
73
|
// console.log("Input config: ");
|
|
70
74
|
// console.log(inputConfig);
|
|
71
75
|
|
|
72
76
|
if (inputConfig.okToPublish ) {
|
|
73
|
-
if (devBuild || (!devBuild &&
|
|
77
|
+
if (devBuild || (!devBuild && okToPublishPerm)) {
|
|
74
78
|
okToPublish = true;
|
|
75
79
|
}
|
|
76
80
|
|
|
@@ -67,7 +67,7 @@ addDebugLog("switchLibrary", "", "+");
|
|
|
67
67
|
const newLibraryName = inputConfig.libraryName;
|
|
68
68
|
newOrgLib = `${orgLib.organization}_${newLibraryName}`;
|
|
69
69
|
version = inputConfig.libraryVersion;
|
|
70
|
-
const isPermanent = inputConfig
|
|
70
|
+
const isPermanent = inputConfig?.isPermanent || "N";
|
|
71
71
|
let permBuild = convertYNToBoolean(isPermanent);
|
|
72
72
|
|
|
73
73
|
if (isLibraryBasedCL) {
|
|
@@ -66,7 +66,7 @@ addDebugLog("switchVersion", "", "+");
|
|
|
66
66
|
okToContinue = convertYNToBoolean(inputConfig.okToContinue);
|
|
67
67
|
if (okToContinue) {
|
|
68
68
|
version = inputConfig.libraryVersion;
|
|
69
|
-
const isPermanent = inputConfig
|
|
69
|
+
const isPermanent = inputConfig?.isPermanent || "N";
|
|
70
70
|
let permBuild = convertYNToBoolean(isPermanent);
|
|
71
71
|
|
|
72
72
|
if (isLibraryBasedCL) {
|
package/src/util.js
CHANGED
|
@@ -1677,9 +1677,7 @@ if (showDebug) addDebugLog("getC11NB2STokenAndStaticServer", "", "");
|
|
|
1677
1677
|
if (OAuthData) {
|
|
1678
1678
|
const { C11NB2S, appStaticContentServer, access_token } = JSON.parse(OAuthData)
|
|
1679
1679
|
|
|
1680
|
-
|
|
1681
|
-
return ({ C11NB2S, appStaticContentServer, access_token});
|
|
1682
|
-
}
|
|
1680
|
+
return ({ C11NB2S, appStaticContentServer, access_token});
|
|
1683
1681
|
|
|
1684
1682
|
}
|
|
1685
1683
|
return ({});
|