@pega/custom-dx-components 0.242.56 → 0.242.58
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 +6 -0
- package/src/tasks/build-lib/index.js +7 -1
- package/src/tasks/create-lib/helper.js +2 -1
- package/src/tasks/create-lib/index.js +9 -2
- package/src/tasks/index.js +1 -0
- package/src/tasks/init/template/package.json.mustache +3 -2
- package/src/tasks/publish/index.js +18 -0
- package/src/tasks/restore-config/index.js +56 -0
- package/src/util.js +66 -3
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
renameComponent,
|
|
32
32
|
moveComponent,
|
|
33
33
|
renameLibrary,
|
|
34
|
+
restoreConfig,
|
|
34
35
|
revertWebPack,
|
|
35
36
|
promoteWebPack,
|
|
36
37
|
showStatus,
|
|
@@ -61,6 +62,7 @@ const TASKS = {
|
|
|
61
62
|
PUBLISH_LIB: 'publishLibrary',
|
|
62
63
|
RENAME: 'rename',
|
|
63
64
|
RENAME_LIB: 'renameLibrary',
|
|
65
|
+
RESTORE_CONFIG: 'restoreConfig',
|
|
64
66
|
QUARANTINE: 'quarantine',
|
|
65
67
|
MOVE: 'moveComponent',
|
|
66
68
|
LIST: 'list',
|
|
@@ -164,6 +166,10 @@ export default async (args = []) => {
|
|
|
164
166
|
renameLibrary(options);
|
|
165
167
|
break;
|
|
166
168
|
}
|
|
169
|
+
case TASKS.RESTORE_CONFIG: {
|
|
170
|
+
restoreConfig(options);
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
167
173
|
case TASKS.QUARANTINE: {
|
|
168
174
|
quarantine(options);
|
|
169
175
|
break;
|
|
@@ -19,7 +19,8 @@ import {
|
|
|
19
19
|
checkLibraryAndArchives,
|
|
20
20
|
getConfigDevBuild,
|
|
21
21
|
checkJWTExpiration,
|
|
22
|
-
getConfigDefaults
|
|
22
|
+
getConfigDefaults,
|
|
23
|
+
getLibraryBased
|
|
23
24
|
} from '../../util.js';
|
|
24
25
|
import bundleComponent from '../bundle/index.js';
|
|
25
26
|
|
|
@@ -125,6 +126,11 @@ addDebugLog("buildLib", "services end", "");
|
|
|
125
126
|
}
|
|
126
127
|
|
|
127
128
|
export default async options => {
|
|
129
|
+
const isLibraryBased = getLibraryBased();
|
|
130
|
+
if (!isLibraryBased) {
|
|
131
|
+
console.log(`Command only supported for ${chalk.bold.green('library based')} components.`)
|
|
132
|
+
process.exit();
|
|
133
|
+
}
|
|
128
134
|
|
|
129
135
|
if (options.params.length != 4) {
|
|
130
136
|
// internal so already called
|
|
@@ -54,7 +54,7 @@ addDebugLog("getCreateLibComponentQuestions", "", "");
|
|
|
54
54
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
export const getCreateLibComponentQuestions = async () => {
|
|
57
|
+
export const getCreateLibComponentQuestions = async (libraryName = "") => {
|
|
58
58
|
addDebugLog("getCreateLibComponentQuestions", "", "");
|
|
59
59
|
const archDirectories = await getLibraryArchiveDirectories();
|
|
60
60
|
const orgLib = getConfigDefaults();
|
|
@@ -64,6 +64,7 @@ addDebugLog("getCreateLibComponentQuestions", "", "");
|
|
|
64
64
|
{
|
|
65
65
|
name: 'libraryName',
|
|
66
66
|
message: 'Enter libray name',
|
|
67
|
+
default: libraryName,
|
|
67
68
|
validate: value => {
|
|
68
69
|
/* value should not be empty
|
|
69
70
|
It should not have spaces
|
|
@@ -34,7 +34,7 @@ export default async options => {
|
|
|
34
34
|
await cleanUpTemp();
|
|
35
35
|
|
|
36
36
|
addDebugLog("createLibrary", "", "+");
|
|
37
|
-
let libraryName;
|
|
37
|
+
let libraryName = "";
|
|
38
38
|
let version;
|
|
39
39
|
// permBuild is the opposite of devBuild
|
|
40
40
|
let permBuild;
|
|
@@ -56,6 +56,7 @@ addDebugLog("createLibrary", "", "+");
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
|
|
59
60
|
if (options.params.length >= 7) {
|
|
60
61
|
libraryName = options.params[3];
|
|
61
62
|
version = options.params[4];
|
|
@@ -63,7 +64,13 @@ addDebugLog("createLibrary", "", "+");
|
|
|
63
64
|
currentOrOriginal = options.params[6];
|
|
64
65
|
permBuild = !!(dPerm === 'Y' || dPerm === 'y' || dPerm === true || dPerm === 'true');
|
|
65
66
|
} else {
|
|
66
|
-
|
|
67
|
+
|
|
68
|
+
if (!hasArch) {
|
|
69
|
+
// if no archives, get library name from tasks.config as default
|
|
70
|
+
libraryName = orgLib.library;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const questions = await getCreateLibComponentQuestions(libraryName);
|
|
67
74
|
const answers = await inquirer.prompt(questions);
|
|
68
75
|
({ libraryName, version, permBuild } = answers);
|
|
69
76
|
}
|
package/src/tasks/index.js
CHANGED
|
@@ -37,3 +37,4 @@ export { default as buildComponent } from './build-comp/index.js';
|
|
|
37
37
|
export { default as buildAllComponents } from './build-all/index.js';
|
|
38
38
|
export { default as buildLibrary } from './build-lib/index.js';
|
|
39
39
|
export { default as buildJestAssets } from './build-jest-assets/index.js';
|
|
40
|
+
export { default as restoreConfig } from './restore-config/index.js';
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"_internal-build-jest-assets": "custom-dx-components buildJestAssets",
|
|
54
54
|
"_internal-buildLibrary": "custom-dx-components buildLibrary",
|
|
55
55
|
"_internal-publishLibrary": "custom-dx-components publishLibrary",
|
|
56
|
+
"_internal-restoreConfig": "custom-dx-components restoreConfig",
|
|
56
57
|
"_internal-test-quarantine": "custom-dx-components quarantine",
|
|
57
58
|
"_lint:styles": "stylelint \"./**/*.@(js|jsx|ts|tsx)\"",
|
|
58
59
|
"_lint:format": "prettier -c .",
|
|
@@ -100,8 +101,8 @@
|
|
|
100
101
|
},
|
|
101
102
|
"devDependencies": {
|
|
102
103
|
"@pega/configs": "^0.15.1",
|
|
103
|
-
"@pega/custom-dx-components": "~0.242.
|
|
104
|
-
"@pega/pcore-pconnect-typedefs": "~3.2.0-alpha.
|
|
104
|
+
"@pega/custom-dx-components": "~0.242.58",
|
|
105
|
+
"@pega/pcore-pconnect-typedefs": "~3.2.0-alpha.2",
|
|
105
106
|
"@storybook/addon-actions": "^7.6.19",
|
|
106
107
|
"@storybook/addon-essentials": "^7.6.19",
|
|
107
108
|
"@storybook/addon-knobs": "^7.1.1",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import inquirer from 'inquirer';
|
|
2
2
|
import { Listr } from 'listr2';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
|
+
import fs from 'fs';
|
|
4
5
|
|
|
5
6
|
import validate from '../validator/index.js';
|
|
6
7
|
import bundleComponent from '../bundle/index.js';
|
|
@@ -11,6 +12,10 @@ import { getPublishComponentQuestions, publishComponentToServer, zipComponent }
|
|
|
11
12
|
import { default as buildLibrary } from '../build-lib/index.js';
|
|
12
13
|
import { default as publishLibrary } from '../publish-lib/index.js';
|
|
13
14
|
|
|
15
|
+
import {
|
|
16
|
+
TOKEN_PATH
|
|
17
|
+
} from '../../constants.js';
|
|
18
|
+
|
|
14
19
|
export default async options => {
|
|
15
20
|
|
|
16
21
|
await showVersion();
|
|
@@ -74,6 +79,19 @@ addDebugLog("publish", "", "+");
|
|
|
74
79
|
}
|
|
75
80
|
|
|
76
81
|
|
|
82
|
+
let OauthData;
|
|
83
|
+
try {
|
|
84
|
+
OauthData = fs.readFileSync(TOKEN_PATH, 'utf8');
|
|
85
|
+
}
|
|
86
|
+
catch (ex) {
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (!OauthData) {
|
|
91
|
+
console.log(chalk.redBright("Need to authenticate, missing services token."));
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
|
|
77
95
|
// non library based publish
|
|
78
96
|
let componentKey;
|
|
79
97
|
let sourceMap;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { promisify } from 'util';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
|
|
6
|
+
import inquirer from 'inquirer';
|
|
7
|
+
import ncp from 'ncp';
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
|
|
10
|
+
import { restoreTopLevelConfigFilesFromTemplate,
|
|
11
|
+
restoreDependenciesFromTemplate,
|
|
12
|
+
getLibraryBased,
|
|
13
|
+
showVersion,
|
|
14
|
+
addDebugLog
|
|
15
|
+
} from '../../util.js';
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
export default async options => {
|
|
21
|
+
addDebugLog("restoreConfig", "", "+");
|
|
22
|
+
const isLibraryBased = getLibraryBased();
|
|
23
|
+
if (!isLibraryBased) {
|
|
24
|
+
console.log(`Command only supported for ${chalk.bold.green('library based')} components.`);
|
|
25
|
+
process.exit();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
await showVersion();
|
|
29
|
+
|
|
30
|
+
const restoreAns = await inquirer.prompt([
|
|
31
|
+
|
|
32
|
+
{
|
|
33
|
+
name: 'restoreDev',
|
|
34
|
+
type: 'confirm',
|
|
35
|
+
message: 'Also restore package dependencies/devDepencies ?',
|
|
36
|
+
default: false
|
|
37
|
+
},
|
|
38
|
+
]);
|
|
39
|
+
|
|
40
|
+
await restoreTopLevelConfigFilesFromTemplate();
|
|
41
|
+
console.log(chalk.green("Original config files restored."));
|
|
42
|
+
|
|
43
|
+
if (restoreAns.restoreDev) {
|
|
44
|
+
await restoreDependenciesFromTemplate();
|
|
45
|
+
console.log(chalk.green("Package dependencies and devDependencies restored."));
|
|
46
|
+
|
|
47
|
+
console.log('\n***************************************************************');
|
|
48
|
+
console.log(chalk.bold.yellow('Dependencies have changed, recommend updating.'));
|
|
49
|
+
console.log(`>>> PLEASE run ${chalk.bold.yellow("'npm update'")}.`);
|
|
50
|
+
console.log('***************************************************************\n');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
addDebugLog("restoreConfig", "END", "-");
|
|
55
|
+
|
|
56
|
+
};
|
package/src/util.js
CHANGED
|
@@ -558,7 +558,13 @@ if (showDebug) addDebugLog("removeTopLevelConfigFiles", `directory: ${directory}
|
|
|
558
558
|
|
|
559
559
|
if (configFiles && configFiles.length > 0) {
|
|
560
560
|
for (const configF of configFiles) {
|
|
561
|
-
|
|
561
|
+
// don't remove these files, otherwise, remove it
|
|
562
|
+
if (configF !== "package-lock.json" &&
|
|
563
|
+
configF !== "package.json" &&
|
|
564
|
+
configF !== "tasks.config.json" &&
|
|
565
|
+
configF !== ".gitignore" &&
|
|
566
|
+
configF !== ".npmrc" &&
|
|
567
|
+
configF !== ".prettierignore") {
|
|
562
568
|
fs.rmSync( join(directory, configF), { recursive: true, force: true, maxRetries: 2 });
|
|
563
569
|
}
|
|
564
570
|
}
|
|
@@ -1716,7 +1722,7 @@ if (showDebug) addDebugLog("restoreDependenciesFromPackage", "", "");
|
|
|
1716
1722
|
retrievedPackageData = fs.readFileSync(tempPackagePath);
|
|
1717
1723
|
}
|
|
1718
1724
|
catch (ex) {
|
|
1719
|
-
console.log(
|
|
1725
|
+
console.log(chalk.red(`\nUnable to retrieve package.json from store.`))
|
|
1720
1726
|
process.exit(1);
|
|
1721
1727
|
}
|
|
1722
1728
|
|
|
@@ -1724,7 +1730,7 @@ if (showDebug) addDebugLog("restoreDependenciesFromPackage", "", "");
|
|
|
1724
1730
|
currentPackageData = fs.readFileSync(currentPackagePath);
|
|
1725
1731
|
}
|
|
1726
1732
|
catch (ex) {
|
|
1727
|
-
console.log(
|
|
1733
|
+
console.log(chalk.red(`\nUnable to retrieve current package.json.`))
|
|
1728
1734
|
process.exit(1);
|
|
1729
1735
|
}
|
|
1730
1736
|
|
|
@@ -1789,6 +1795,63 @@ if (showDebug) addDebugLog("restoreDependenciesFromPackage", "", "");
|
|
|
1789
1795
|
|
|
1790
1796
|
}
|
|
1791
1797
|
|
|
1798
|
+
|
|
1799
|
+
export const restoreDependenciesFromTemplate = async () => {
|
|
1800
|
+
if (showDebug) addDebugLog("restoreDependenciesFromTemplate", "", "");
|
|
1801
|
+
const currentDirectory = process.cwd();
|
|
1802
|
+
const currentPackagePath = join(currentDirectory, PACKAGE_JSON_FILENAME);
|
|
1803
|
+
|
|
1804
|
+
let currentPackageData;
|
|
1805
|
+
|
|
1806
|
+
// reset
|
|
1807
|
+
haveDependencyDifference = true;
|
|
1808
|
+
|
|
1809
|
+
try {
|
|
1810
|
+
currentPackageData = fs.readFileSync(currentPackagePath);
|
|
1811
|
+
}
|
|
1812
|
+
catch (ex) {
|
|
1813
|
+
console.log(chalk.red(`\nUnable to retrieve current package.json.`))
|
|
1814
|
+
process.exit(1);
|
|
1815
|
+
}
|
|
1816
|
+
|
|
1817
|
+
|
|
1818
|
+
let cData = JSON.parse(currentPackageData);
|
|
1819
|
+
|
|
1820
|
+
|
|
1821
|
+
// we can't loose devDep that is part of install, so go get the template mustache and push
|
|
1822
|
+
// those in, replacing any changes there, but allowing additional, an keeping it updated
|
|
1823
|
+
// so won't loose new function if an old archive
|
|
1824
|
+
const initDir = join(currentDirectory, "node_modules", "@pega", "custom-dx-components", "src", "tasks", "init");
|
|
1825
|
+
const templateDir = join(initDir, "template");
|
|
1826
|
+
const packageTemplateJsonPath = path.join(templateDir, 'package.json.mustache');
|
|
1827
|
+
let retrievedTemplateData;
|
|
1828
|
+
try {
|
|
1829
|
+
retrievedTemplateData = fs.readFileSync(packageTemplateJsonPath);
|
|
1830
|
+
}
|
|
1831
|
+
catch (ex) {
|
|
1832
|
+
console.log($chalk.red(`\nUnable to retrieve package.json.mustache from code.`))
|
|
1833
|
+
process.exit(1);
|
|
1834
|
+
}
|
|
1835
|
+
const tData = JSON.parse(retrievedTemplateData);
|
|
1836
|
+
const tDevDep = tData.devDependencies;
|
|
1837
|
+
const tDep = tData.dependencies;
|
|
1838
|
+
|
|
1839
|
+
for (const [key, value] of Object.entries(tDevDep)) {
|
|
1840
|
+
cData.devDependencies[key] = value;
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
for (const [key, value] of Object.entries(tDep)) {
|
|
1844
|
+
cData.dependencies[key] = value;
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
|
|
1848
|
+
// update current package json file
|
|
1849
|
+
fs.writeFileSync(currentPackagePath, JSON.stringify(cData, null, 4), { encoding: 'utf8',flag:'w' });
|
|
1850
|
+
|
|
1851
|
+
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
|
|
1792
1855
|
export const restoreDependenciesFromPackage_old = async () => {
|
|
1793
1856
|
if (showDebug) addDebugLog("restoreDependenciesFromPackage", "", "");
|
|
1794
1857
|
const currentDirectory = process.cwd();
|