@pega/custom-dx-components 0.25.47 → 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 +21 -21
- package/src/tasks/bundle/builder/index.js +15 -15
- package/src/tasks/create-lib/helper.js +2 -0
- package/src/tasks/delete-pub/index.js +1 -1
- package/src/tasks/import-archive/index.js +12 -12
- package/src/tasks/init/index.js +59 -62
- package/src/tasks/init/template/package.json.mustache +1 -2
- package/src/tasks/list-pub/index.js +3 -2
- package/src/tasks/publish/index.js +4 -0
- package/src/tasks/show-status/index.js +18 -6
- package/src/util.js +35 -11
package/package.json
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pega/custom-dx-components",
|
|
3
|
-
"version": "0.25.
|
|
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.
|
|
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.
|
|
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.
|
|
35
|
-
"execa": "^9.
|
|
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.
|
|
55
|
+
"postcss": "^8.5.6",
|
|
50
56
|
"postcss-loader": "8.1.1",
|
|
51
|
-
"postcss-preset-env": "10.
|
|
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.
|
|
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.
|
|
74
|
-
"@pega/configs": "^0.
|
|
75
|
-
"@pega/prettier-config": "^0.
|
|
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.
|
|
83
|
-
"ts-jest": "^29.
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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) {
|
|
@@ -97,7 +97,9 @@ export const updateAllMigrateToLibChanges = async() => {
|
|
|
97
97
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
console.log();
|
|
100
101
|
console.log(`${chalk.green(`>> Code base was upgraded. You may still have some lint errors that need to be fixed manually.`)}`);
|
|
102
|
+
console.log(`${chalk.green(`>> Run ${chalk.bold(`npm run validateAll`)} to check for issues.`)}`);
|
|
101
103
|
|
|
102
104
|
}
|
|
103
105
|
|
|
@@ -150,7 +150,7 @@ addDebugLog("deletePublished", "END", "-");
|
|
|
150
150
|
// No library with that name
|
|
151
151
|
const serverConfig = await getPegaServerConfig();
|
|
152
152
|
console.log("");
|
|
153
|
-
console.log(chalk.redBright(`No server component libraries exist in current
|
|
153
|
+
console.log(chalk.redBright(`No server component libraries exist in current application ${chalk.redBright.bold(`${app_name} - ${app_version}`)}.`));
|
|
154
154
|
|
|
155
155
|
addDebugLog("listPublished", "END", "-");
|
|
156
156
|
process.exit(1);
|
|
@@ -382,19 +382,19 @@ export const importArch = async(filePath, fileName, hadArchive) => {
|
|
|
382
382
|
if (hadArchive) {
|
|
383
383
|
|
|
384
384
|
if (orgLibName === configDef.currentOrgLib && version === configDef.version) {
|
|
385
|
-
console.log(`\n${chalk.green(`${fileName}`)} has been imported!`);
|
|
385
|
+
console.log(`\n${chalk.bold.green(`${fileName}`)} has been imported!`);
|
|
386
386
|
console.log(`It is the same library/version as your current source.`);
|
|
387
|
-
console.log(`--> You can retrieve and replace current source via ${chalk.green(`npm run restoreLibVersion`)}.`);
|
|
387
|
+
console.log(`--> You can retrieve and replace current source via ${chalk.bold.green(`npm run restoreLibVersion`)}.`);
|
|
388
388
|
console.log("\n");
|
|
389
389
|
}
|
|
390
390
|
else if (orgLibName === configDef.currentOrgLib && version != configDef.version) {
|
|
391
|
-
console.log(`\n${chalk.green(`${fileName}`)} has been imported!`);
|
|
392
|
-
console.log(`--> You can switch to ${chalk.green(`${orgLibName}/${version}`)} via ${chalk.green(`npm run switchLibVersion`)}.`);
|
|
391
|
+
console.log(`\n${chalk.bold.green(`${fileName}`)} has been imported!`);
|
|
392
|
+
console.log(`--> You can switch to ${chalk.bold.green(`${orgLibName}/${version}`)} via ${chalk.bold.green(`npm run switchLibVersion`)}.`);
|
|
393
393
|
console.log("\n");
|
|
394
394
|
}
|
|
395
395
|
else {
|
|
396
|
-
console.log(`\n${chalk.green(`${fileName}`)} has been imported!`);
|
|
397
|
-
console.log(`--> You can switch to ${chalk.green(`${orgLibName}/${version}`)} via ${chalk.green(`npm run switchLib`)}.`);
|
|
396
|
+
console.log(`\n${chalk.bold.green(`${fileName}`)} has been imported!`);
|
|
397
|
+
console.log(`--> You can switch to ${chalk.bold.green(`${orgLibName}/${version}`)} via ${chalk.bold.green(`npm run switchLib`)}.`);
|
|
398
398
|
console.log("\n");
|
|
399
399
|
}
|
|
400
400
|
|
|
@@ -595,19 +595,19 @@ addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
|
|
|
595
595
|
|
|
596
596
|
if (hadArchive) {
|
|
597
597
|
if (orgLibName === configDef.currentOrgLib && version === configDef.version) {
|
|
598
|
-
console.log(`\n${chalk.green(`${fileName}`)} has been imported!`);
|
|
598
|
+
console.log(`\n${chalk.bold.green(`${fileName}`)} has been imported!`);
|
|
599
599
|
console.log(`It is the same library/version as your current source.`);
|
|
600
|
-
console.log(`--> You can retrieve and replace current source via ${chalk.green(`npm run restoreLibVersion`)}.`);
|
|
600
|
+
console.log(`--> You can retrieve and replace current source via ${chalk.bold.green(`npm run restoreLibVersion`)}.`);
|
|
601
601
|
console.log("\n");
|
|
602
602
|
}
|
|
603
603
|
else if (orgLibName === configDef.currentOrgLib && version != configDef.version) {
|
|
604
|
-
console.log(`\n${chalk.green(`${fileName}`)} has been imported!`);
|
|
605
|
-
console.log(`--> You can switch to ${chalk.green(`${orgLibName}/${version}`)} via ${chalk.green(`npm run switchLibVersion`)}.`);
|
|
604
|
+
console.log(`\n${chalk.bold.green(`${fileName}`)} has been imported!`);
|
|
605
|
+
console.log(`--> You can switch to ${chalk.bold.green(`${orgLibName}/${version}`)} via ${chalk.bold.green(`npm run switchLibVersion`)}.`);
|
|
606
606
|
console.log("\n");
|
|
607
607
|
}
|
|
608
608
|
else {
|
|
609
|
-
console.log(`\n${chalk.green(`${fileName}`)} has been imported!`);
|
|
610
|
-
console.log(`--> You can switch to ${chalk.green(`${orgLibName}/${version}`)} via ${chalk.green(`npm run switchLib`)}.`);
|
|
609
|
+
console.log(`\n${chalk.bold.green(`${fileName}`)} has been imported!`);
|
|
610
|
+
console.log(`--> You can switch to ${chalk.bold.green(`${orgLibName}/${version}`)} via ${chalk.bold.green(`npm run switchLib`)}.`);
|
|
611
611
|
console.log("\n");
|
|
612
612
|
}
|
|
613
613
|
|
package/src/tasks/init/index.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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
|
-
|
|
38
|
+
await fs.promises.writeFile(targetPath, licenseContent, 'utf8');
|
|
43
39
|
};
|
|
44
40
|
|
|
41
|
+
|
|
45
42
|
const copyProjectTemplate = async options => {
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
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.
|
|
68
|
-
fs.
|
|
69
|
-
|
|
70
|
-
//
|
|
71
|
-
|
|
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
|
-
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
options
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
|
|
135
|
+
execa('npm', ['i', '--force', '--production=false'], { cwd: options.targetDirectory })
|
|
142
136
|
},
|
|
143
137
|
*/
|
|
144
138
|
{
|
|
145
139
|
title: installDependenciesText,
|
|
146
140
|
task: () =>
|
|
147
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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: () =>
|
|
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: () =>
|
|
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.
|
|
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",
|
|
@@ -162,6 +162,7 @@ addDebugLog("listPublished", "", "+");
|
|
|
162
162
|
const isLibraryBasedCL = getLibraryBasedCL();
|
|
163
163
|
if (isLibraryBasedCL) {
|
|
164
164
|
const arLibs = await getInfinityLibraries();
|
|
165
|
+
const {app_name, app_version } = await getApplicationAndVersionFromToken();
|
|
165
166
|
|
|
166
167
|
if (arLibs && arLibs.pxResults && arLibs.pxResults.length > 0) {
|
|
167
168
|
|
|
@@ -169,7 +170,7 @@ addDebugLog("listPublished", "", "+");
|
|
|
169
170
|
const libs = arLibs.pxResults.map((oLib, index) => ({ name: oLib.pyLabel + " (" + oLib.pyRuleSet + ":" + oLib.pyRuleSetVersion + ")", value: index}));
|
|
170
171
|
|
|
171
172
|
|
|
172
|
-
|
|
173
|
+
|
|
173
174
|
const serverConfig = await getPegaServerConfig();
|
|
174
175
|
console.log(`\nServer ${chalk.green.bold(`${serverConfig.server}`)}.`);
|
|
175
176
|
console.log(`List of libraries (including built on) for Application: ${chalk.bold.green(`${app_name} - ${app_version}`)}`);
|
|
@@ -207,7 +208,7 @@ addDebugLog("listPublished", "", "+");
|
|
|
207
208
|
else {
|
|
208
209
|
// No library with that name
|
|
209
210
|
const serverConfig = await getPegaServerConfig();
|
|
210
|
-
console.log(chalk.redBright(`No server component libraries exist in
|
|
211
|
+
console.log(chalk.redBright(`No server component libraries exist in application ${chalk.redBright.bold(`${app_name} - ${app_version}`)}.`));
|
|
211
212
|
// console.log(chalk.redBright(`No server component libraries exist in given ruleset ${chalk.bold(`${serverConfig.rulesetName}:${serverConfig.rulesetVersion}`)}`));
|
|
212
213
|
console.log(chalk.redBright(`You need to publish a library to a ruleset in this application first.`));
|
|
213
214
|
addDebugLog("listPublished", "END", "-");
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
getInputConfigForCommand,
|
|
24
24
|
convertYNToBoolean,
|
|
25
25
|
checkForBranch,
|
|
26
|
+
getApplicationAndVersionFromToken,
|
|
26
27
|
applyPegaData } from '../../util.js';
|
|
27
28
|
|
|
28
29
|
import { getPublishComponentQuestions, publishComponentToServer, zipComponent } from './helper.js';
|
|
@@ -64,10 +65,13 @@ addDebugLog("publish", "", "+");
|
|
|
64
65
|
const serverConfg = await getPegaServerConfig();
|
|
65
66
|
let configJson = {};
|
|
66
67
|
await applyPegaData(configJson);
|
|
68
|
+
const {app_name, app_version, sub } = await getApplicationAndVersionFromToken();
|
|
67
69
|
|
|
68
70
|
console.log();
|
|
69
71
|
console.log(`Publishing to server: ${chalk.green.bold(`${serverConfg.server}`)}`);
|
|
70
72
|
console.log(`Cosmos version: ${chalk.green.bold(`${configJson.packageCosmosVersion}`)}`);
|
|
73
|
+
console.log(`Application: ${chalk.green.bold(`${app_name} - ${app_version}`)} for ${chalk.magentaBright.bold(`${sub}`)}`);
|
|
74
|
+
console.log();
|
|
71
75
|
|
|
72
76
|
if (useInputConfig) {
|
|
73
77
|
const inputConfig = await getInputConfigForCommand("publish");
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
checkLibraryAndArchives,
|
|
9
9
|
getPegaServerConfig,
|
|
10
10
|
getLibraryBasedCL,
|
|
11
|
-
|
|
11
|
+
getApplicationAndVersionFromToken } from '../../util.js';
|
|
12
12
|
|
|
13
13
|
export const showCurrentStatus = async () => {
|
|
14
14
|
|
|
@@ -17,6 +17,7 @@ export const showCurrentStatus = async () => {
|
|
|
17
17
|
const isLibraryBased = getLibraryBased();
|
|
18
18
|
const isLibraryBasedCL = getLibraryBasedCL();
|
|
19
19
|
const pegaServer = await getPegaServerConfig(true);
|
|
20
|
+
const { app_name, app_version } = await getApplicationAndVersionFromToken();
|
|
20
21
|
|
|
21
22
|
console.log("");
|
|
22
23
|
console.log("\tCurrent status");
|
|
@@ -33,7 +34,13 @@ export const showCurrentStatus = async () => {
|
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
if (componentList.length === 0) {
|
|
38
|
+
console.log(`\tComponent count: ${chalk.bold.yellow(`${componentList.length}`)}`);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
console.log(`\tComponent count: ${chalk.bold.green(`${componentList.length}`)}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
37
44
|
|
|
38
45
|
console.log("");
|
|
39
46
|
|
|
@@ -42,10 +49,15 @@ export const showCurrentStatus = async () => {
|
|
|
42
49
|
}
|
|
43
50
|
else {
|
|
44
51
|
|
|
45
|
-
console.log(`\tPublish
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
console.log(`\tPublish configuration`)
|
|
53
|
+
console.log(`\t Server:\t ${chalk.bold.green(`${pegaServer.server}`)} `);
|
|
54
|
+
if (app_name === "**") {
|
|
55
|
+
console.log(`\t Application:\t ${chalk.bold.yellow(`Need to authenticate`)}`);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
console.log(`\t Application:\t ${chalk.bold.green(`${app_name} - ${app_version}`)}`);
|
|
59
|
+
}
|
|
60
|
+
console.log(`\t Ruleset:\t ${chalk.bold.green(`${pegaServer.rulesetName}:`)}${chalk.bold.magenta(`${pegaServer.rulesetVersion}`)}`);
|
|
49
61
|
console.log("");
|
|
50
62
|
}
|
|
51
63
|
|
package/src/util.js
CHANGED
|
@@ -75,6 +75,7 @@ let defaultConfigs = {
|
|
|
75
75
|
useInputConfig: false
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
+
|
|
78
79
|
let pegaConfig = null;
|
|
79
80
|
let pegaData = null;
|
|
80
81
|
let sPegaData;
|
|
@@ -407,9 +408,11 @@ export const checkJWTExpiration = async () => {
|
|
|
407
408
|
const isLibraryBased = getLibraryBased();
|
|
408
409
|
const isLibraryBasedCL = getLibraryBasedCL();
|
|
409
410
|
|
|
410
|
-
if (
|
|
411
|
-
|
|
412
|
-
|
|
411
|
+
if (!isLibraryBasedCL && isLibraryBased) {
|
|
412
|
+
if (tokenAndStaticServer.C11NB2S === undefined) {
|
|
413
|
+
console.log(chalk.redBright("Need to authenticate, missing services token.\nBuilding a library requires authentication to acquire a token to build."));
|
|
414
|
+
process.exit(1);
|
|
415
|
+
}
|
|
413
416
|
}
|
|
414
417
|
|
|
415
418
|
const jwt = jwtDecode(tokenAndStaticServer.C11NB2S);
|
|
@@ -444,26 +447,36 @@ export const checkAccessTokenExpiration = async() => {
|
|
|
444
447
|
}
|
|
445
448
|
|
|
446
449
|
const jwt = jwtDecode(tokenAndStaticServer.access_token);
|
|
447
|
-
const { exp, customer_org } = jwt;
|
|
450
|
+
const { exp, customer_org, sub, app_name, app_version, operator_access } = jwt;
|
|
451
|
+
|
|
452
|
+
|
|
448
453
|
if (exp < (new Date().getTime() + 1) / 1000) {
|
|
449
454
|
console.log(chalk.redBright("Authentication token has expired, please reauthenticate."));
|
|
450
455
|
process.exit(1);
|
|
451
456
|
}
|
|
452
457
|
|
|
453
458
|
|
|
459
|
+
|
|
454
460
|
}
|
|
455
461
|
|
|
462
|
+
|
|
463
|
+
|
|
456
464
|
export const getApplicationAndVersionFromToken = async() => {
|
|
457
465
|
const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
|
|
458
466
|
|
|
459
467
|
if (tokenAndStaticServer.access_token === undefined) {
|
|
460
|
-
console.log(chalk.redBright("Need to authenticate, missing token.\n"));
|
|
461
|
-
process.exit(1);
|
|
468
|
+
// console.log(chalk.redBright("Need to authenticate, missing token.\n"));
|
|
469
|
+
// process.exit(1);
|
|
470
|
+
const app_name = "**";
|
|
471
|
+
const app_version = "**";
|
|
472
|
+
const sub = "**";
|
|
473
|
+
const operator_access = "**";
|
|
474
|
+
return { app_name, app_version, sub, operator_access};
|
|
462
475
|
}
|
|
463
476
|
|
|
464
477
|
const jwt = jwtDecode(tokenAndStaticServer.access_token);
|
|
465
|
-
const { app_name, app_version } = jwt;
|
|
466
|
-
return { app_name, app_version };
|
|
478
|
+
const { app_name, app_version, sub, operator_access } = jwt;
|
|
479
|
+
return { app_name, app_version, sub, operator_access};
|
|
467
480
|
|
|
468
481
|
}
|
|
469
482
|
|
|
@@ -767,7 +780,8 @@ if (showDebug) addDebugLog("restoreTopLevelConfigFiles", `directory: ${directory
|
|
|
767
780
|
|
|
768
781
|
if (configFiles && configFiles.length > 0) {
|
|
769
782
|
for (const configF of configFiles) {
|
|
770
|
-
|
|
783
|
+
// don't want to restore package, package-lock or an archive file
|
|
784
|
+
if (configF !== "package-lock.json" && configF !== "package.json" && (configF.indexOf(".zip") < 0) ) {
|
|
771
785
|
fs.copyFileSync(join(tempDirectory, configF), join(directory, configF));
|
|
772
786
|
}
|
|
773
787
|
}
|
|
@@ -2261,8 +2275,12 @@ if (showDebug) addDebugLog("updateComponentTaskConfig", "", "");
|
|
|
2261
2275
|
// restore ruleset and verion
|
|
2262
2276
|
originalContentsData["server-config"].rulesetName = orgRuleset;
|
|
2263
2277
|
originalContentsData["server-config"].rulesetVersion = orgRulesetVersion;
|
|
2264
|
-
|
|
2265
|
-
|
|
2278
|
+
|
|
2279
|
+
// replace if exists
|
|
2280
|
+
if (orgArchiveRuleset) {
|
|
2281
|
+
originalContentsData["server-config"].archiveRulesetName = orgArchiveRuleset;
|
|
2282
|
+
originalContentsData["server-config"].archiveRulesetVersion = orgArchiveRulesetVersion;
|
|
2283
|
+
}
|
|
2266
2284
|
|
|
2267
2285
|
|
|
2268
2286
|
// if we don't have a devServerPort, add the default
|
|
@@ -2825,5 +2843,11 @@ export const isComponentValidLength = (componentKey) => {
|
|
|
2825
2843
|
return false;
|
|
2826
2844
|
}
|
|
2827
2845
|
|
|
2846
|
+
|
|
2847
|
+
export const emptyDirSync = dir => (
|
|
2848
|
+
fs.rmSync(dir, { recursive: true, force: true }),
|
|
2849
|
+
fs.mkdirSync(dir, { recursive: true })
|
|
2850
|
+
)
|
|
2851
|
+
|
|
2828
2852
|
// init
|
|
2829
2853
|
await forceDefaultsUpdate();
|