@pega/custom-dx-components 0.24.15 → 0.242.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 +1 -1
- package/src/cli.js +32 -2
- package/src/constants.js +9 -0
- package/src/tasks/authenticate/index.js +12 -1
- package/src/tasks/build-lib/helper.js +71 -0
- package/src/tasks/build-lib/index.js +165 -0
- package/src/tasks/create/index.js +59 -6
- package/src/tasks/create/templates/Constellation/Field/Icon-Button-URL/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/Avatar.tsx.mustache +78 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/HighlightRender.tsx.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Template/DETAILS/Operator.tsx.mustache +218 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.tsx.mustache +46 -13
- package/src/tasks/create/templates/Constellation/Template/DETAILS/index.tsx.mustache +2 -2
- package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.ts.mustache +55 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/Avatar.tsx.mustache +78 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/HighlightRender.tsx.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/Operator.tsx.mustache +218 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.tsx.mustache +46 -12
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.tsx.mustache +2 -2
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.ts.mustache +55 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/index.tsx.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Template/FORM-region/index.tsx.mustache +2 -2
- package/src/tasks/create/templates/Constellation/Widget/PAGE/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Launchpad/Field/Icon-Button-URL/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Launchpad/Widget/PAGE/index.tsx.mustache +1 -0
- package/src/tasks/create-all/index.js +57 -6
- package/src/tasks/delete/index.js +8 -2
- package/src/tasks/delete-all/index.js +8 -2
- package/src/tasks/delete-lib/helper.js +75 -0
- package/src/tasks/delete-lib/index.js +97 -0
- package/src/tasks/index.js +5 -0
- package/src/tasks/init/template/package.json.mustache +32 -9
- package/src/tasks/init/template/tasks.config.json +3 -2
- package/src/tasks/list/index.js +9 -3
- package/src/tasks/list-lib/helper.js +72 -0
- package/src/tasks/list-lib/index.js +75 -0
- package/src/tasks/promote-webpack/index.js +8 -1
- package/src/tasks/promote-webpack/webpack.config.js +26 -0
- package/src/tasks/publish/index.js +8 -1
- package/src/tasks/publish-all/index.js +8 -1
- package/src/tasks/publish-lib/helper.js +53 -0
- package/src/tasks/publish-lib/index.js +212 -0
- package/src/tasks/rename-lib/index.js +353 -0
- package/src/tasks/revert-webpack/index.js +8 -1
- package/src/util.js +201 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/Avatar.tsx +78 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/Operator.tsx +215 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/demo.stories.tsx +46 -13
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/index.tsx +2 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/mock.ts +55 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyForm/index.tsx +1 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/Avatar.tsx +78 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/Operator.tsx +215 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/demo.stories.tsx +46 -12
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/index.tsx +2 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/mock.ts +55 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnForm/index.tsx +2 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/Avatar.tsx +78 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/Operator.tsx +215 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/demo.stories.tsx +46 -13
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/index.tsx +2 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/mock.ts +55 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyForm/index.tsx +1 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/Avatar.tsx +78 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/Operator.tsx +215 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/demo.stories.tsx +46 -12
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/index.tsx +2 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/mock.ts +55 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnForm/index.tsx +2 -2
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"rulesetName": "CustomDXComponents",
|
|
5
5
|
"rulesetVersion": "01-01-01",
|
|
6
6
|
"sourceOfComponents": "Server",
|
|
7
|
-
"devBuild":
|
|
7
|
+
"devBuild": true,
|
|
8
8
|
"serverType": "infinity",
|
|
9
9
|
"server": "https://localhost:1080/prweb",
|
|
10
10
|
"clientId": "10095186356008396159",
|
|
@@ -35,5 +35,6 @@
|
|
|
35
35
|
"description": "",
|
|
36
36
|
"icon": ""
|
|
37
37
|
},
|
|
38
|
-
"usePromotedWebPack": false
|
|
38
|
+
"usePromotedWebPack": false,
|
|
39
|
+
"libraryBased": false
|
|
39
40
|
}
|
package/src/tasks/list/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import inquirer from 'inquirer';
|
|
|
2
2
|
import ora from 'ora';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
|
|
5
|
-
import { showVersion, getPegaServerConfig } from '../../util.js';
|
|
5
|
+
import { showVersion, getPegaServerConfig, getLibraryBased } from '../../util.js';
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
listLocalComponents,
|
|
@@ -13,6 +13,9 @@ import {
|
|
|
13
13
|
getListComponentsQuestions
|
|
14
14
|
} from './helper.js';
|
|
15
15
|
|
|
16
|
+
const isLibraryBased = await getLibraryBased();
|
|
17
|
+
|
|
18
|
+
|
|
16
19
|
const getList = async (sourceOfComponents, answers) => {
|
|
17
20
|
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
18
21
|
const isLaunchpad = defaultPegaServerConfig.serverType === 'launchpad';
|
|
@@ -69,8 +72,11 @@ export default async (options) => {
|
|
|
69
72
|
showVersion();
|
|
70
73
|
|
|
71
74
|
let sourceOfComponentsOption = SOURCE_OF_COMPONENT_TYPES.LOCAL;
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
if (isLibraryBased) {
|
|
76
|
+
sourceOfComponentsOption = SOURCE_OF_COMPONENT_TYPES.LOCAL;
|
|
77
|
+
await getList(sourceOfComponentsOption);
|
|
78
|
+
}
|
|
79
|
+
else if (options.params[3] === SOURCE_OF_COMPONENT_TYPES.LOCAL) {
|
|
74
80
|
sourceOfComponentsOption = options.params[3];
|
|
75
81
|
await getList(sourceOfComponentsOption);
|
|
76
82
|
} else if (options.params[3] === SOURCE_OF_COMPONENT_TYPES.SERVER) {
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
getPegaServerConfig,
|
|
7
|
+
checkPathAccess,
|
|
8
|
+
getComponentDefaults
|
|
9
|
+
} from '../../util.js';
|
|
10
|
+
import { TASKS_CONFIG_JSON_FILENAME, COMPONENTS_DIRECTORY_PATH, COMPONENTS_PATH } from '../../constants.js';
|
|
11
|
+
|
|
12
|
+
export const SOURCE_OF_COMPONENT_TYPES = {
|
|
13
|
+
SERVER: 'Server',
|
|
14
|
+
LOCAL: 'Local'
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const pegaConfigJsonPath = path.join(path.resolve(), TASKS_CONFIG_JSON_FILENAME);
|
|
18
|
+
|
|
19
|
+
export const getOrgLib = async () => {
|
|
20
|
+
const defaultPegaConfig = await getPegaServerConfig();
|
|
21
|
+
|
|
22
|
+
await checkPathAccess(pegaConfigJsonPath);
|
|
23
|
+
|
|
24
|
+
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
25
|
+
data = data && JSON.parse(data);
|
|
26
|
+
|
|
27
|
+
if (!data[COMPONENTS_DIRECTORY_PATH]) {
|
|
28
|
+
console.error(`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const componentData = data[COMPONENTS_PATH];
|
|
33
|
+
|
|
34
|
+
let library;
|
|
35
|
+
({ library } = componentData);
|
|
36
|
+
let { organization } = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'));
|
|
37
|
+
|
|
38
|
+
const componentDefaults = await getComponentDefaults();
|
|
39
|
+
componentDefaults.library = library;
|
|
40
|
+
componentDefaults.organization = organization;
|
|
41
|
+
|
|
42
|
+
return componentDefaults;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const getListLibraryQuestions = async (libraryName) => {
|
|
46
|
+
const defaultPegaConfig = await getPegaServerConfig();
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
return [
|
|
50
|
+
{
|
|
51
|
+
name: 'sourceOfLibrary',
|
|
52
|
+
type: 'rawlist',
|
|
53
|
+
message: `List library ${chalk.bold.green(`${libraryName}`)} from Server or Local ?`,
|
|
54
|
+
choices: Object.values(SOURCE_OF_COMPONENT_TYPES),
|
|
55
|
+
default: defaultPegaConfig.sourceOfComponents,
|
|
56
|
+
}
|
|
57
|
+
];
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
export const getLibraryVersionQuestion = async(libraryName, libVersions) => {
|
|
62
|
+
|
|
63
|
+
return [
|
|
64
|
+
{
|
|
65
|
+
name: 'version',
|
|
66
|
+
type: 'rawlist',
|
|
67
|
+
message: `Select ${chalk.green.bold(`${libraryName}`)} library version (or ALL) to delete`,
|
|
68
|
+
choices: libVersions
|
|
69
|
+
}
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import inquirer from 'inquirer';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
|
|
4
|
+
import {showVersion, getC11NB2STokenAndStaticServer, getLibraryVersions, getLibraryBased } from '../../util.js';
|
|
5
|
+
|
|
6
|
+
import { listLib } from '@pega/constellation-dx-components-build-utils/index.js';
|
|
7
|
+
|
|
8
|
+
import { getListLibraryQuestions, getLibraryVersionQuestion, getOrgLib, SOURCE_OF_COMPONENT_TYPES } from './helper.js';
|
|
9
|
+
|
|
10
|
+
const isLibraryBased = await getLibraryBased();
|
|
11
|
+
|
|
12
|
+
export default async (options) => {
|
|
13
|
+
if (!isLibraryBased) {
|
|
14
|
+
console.log(`Command only supported for ${chalk.bold.green('library based')} components.`)
|
|
15
|
+
process.exit();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
showVersion();
|
|
19
|
+
|
|
20
|
+
let sourceOfLibrary;
|
|
21
|
+
let organization;
|
|
22
|
+
let library;
|
|
23
|
+
|
|
24
|
+
const compDef = await getOrgLib();
|
|
25
|
+
organization = compDef.organization;
|
|
26
|
+
library = compDef.library;
|
|
27
|
+
const libraryName = organization.concat("_").concat(library);
|
|
28
|
+
|
|
29
|
+
if (options.params.length >= 4) {
|
|
30
|
+
sourceOfLibrary = options.param[3];
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
|
|
35
|
+
const questions = await getListLibraryQuestions(libraryName);
|
|
36
|
+
const answers = await inquirer.prompt(questions);
|
|
37
|
+
({ sourceOfLibrary } = answers);
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (sourceOfLibrary === SOURCE_OF_COMPONENT_TYPES.LOCAL ) {
|
|
42
|
+
// local
|
|
43
|
+
|
|
44
|
+
let libVersions = await getLibraryVersions(libraryName);
|
|
45
|
+
|
|
46
|
+
if (libVersions.length > 0) {
|
|
47
|
+
libVersions = libVersions.map((name) => ({ 'Version': name}));
|
|
48
|
+
console.log(chalk.bold.blueBright(`\nList of ${libraryName} library versions`));
|
|
49
|
+
console.table(libVersions, ['Version']);
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
// No library with that name
|
|
54
|
+
console.log(chalk.redBright(`No local library named: ${libraryName} exists.`));
|
|
55
|
+
process.exit(1);
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
// server
|
|
62
|
+
const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
|
|
63
|
+
|
|
64
|
+
if (tokenAndStaticServer.C11NB2S === undefined) {
|
|
65
|
+
console.log(chalk.redBright("Need to authenticate, missing services token.\nDeleting a library requires authentication to acquire a token to delete."));
|
|
66
|
+
process.e
|
|
67
|
+
exit(1);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
await listLib(tokenAndStaticServer.C11NB2S, tokenAndStaticServer.appStaticContentServer);
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return true;
|
|
75
|
+
};
|
|
@@ -10,7 +10,8 @@ import {
|
|
|
10
10
|
convertIntoPascalCase,
|
|
11
11
|
checkPathAccess,
|
|
12
12
|
showVersion,
|
|
13
|
-
updateUseWebPackPromotion
|
|
13
|
+
updateUseWebPackPromotion,
|
|
14
|
+
getLibraryBased
|
|
14
15
|
} from '../../util.js';
|
|
15
16
|
|
|
16
17
|
import {
|
|
@@ -21,6 +22,7 @@ import {
|
|
|
21
22
|
BUILDER_DIR_FILE_PATH
|
|
22
23
|
} from '../../constants.js';
|
|
23
24
|
|
|
25
|
+
const isLibraryBased = await getLibraryBased();
|
|
24
26
|
|
|
25
27
|
|
|
26
28
|
export const copyWebPack = async () => {
|
|
@@ -92,6 +94,11 @@ export const copyWebPack = async () => {
|
|
|
92
94
|
|
|
93
95
|
|
|
94
96
|
export default async options => {
|
|
97
|
+
if (isLibraryBased) {
|
|
98
|
+
console.log(`Command only supported for ${chalk.bold.green('non library based')} components.`)
|
|
99
|
+
process.exit();
|
|
100
|
+
}
|
|
101
|
+
|
|
95
102
|
showVersion();
|
|
96
103
|
|
|
97
104
|
await copyWebPack();
|
|
@@ -345,6 +345,7 @@ module.exports = (
|
|
|
345
345
|
resourceRegExp: /^\.\/locale$/,
|
|
346
346
|
contextRegExp: /moment$/
|
|
347
347
|
}),
|
|
348
|
+
/* cosmos 4.x and below */
|
|
348
349
|
/* Ignore cosmos icons */
|
|
349
350
|
new webpack.IgnorePlugin({
|
|
350
351
|
resourceRegExp: /^\.\/icons$/,
|
|
@@ -357,6 +358,31 @@ module.exports = (
|
|
|
357
358
|
contextRegExp: /@pega\\cosmos-react-core\\lib\\components\\Icon$/
|
|
358
359
|
}),
|
|
359
360
|
|
|
361
|
+
/* Ignore cosmos streamline-icons */
|
|
362
|
+
new webpack.IgnorePlugin({
|
|
363
|
+
resourceRegExp: /^\.\/streamline-icons$/,
|
|
364
|
+
contextRegExp: /@pega\/cosmos-react-core\/lib\/components\/Icon$/
|
|
365
|
+
}),
|
|
366
|
+
|
|
367
|
+
/* Ignore cosmos streamline-icons - windows */
|
|
368
|
+
new webpack.IgnorePlugin({
|
|
369
|
+
resourceRegExp: /^\.\/streamline-icons$/,
|
|
370
|
+
contextRegExp: /@pega\\cosmos-react-core\\lib\\components\\Icon$/
|
|
371
|
+
}),
|
|
372
|
+
|
|
373
|
+
/* cosmos 6.x and above */
|
|
374
|
+
/* Ignore cosmos icons */
|
|
375
|
+
new webpack.IgnorePlugin({
|
|
376
|
+
resourceRegExp: /^\.\/.*\/.*\.icon$/,
|
|
377
|
+
contextRegExp: /@pega\/cosmos-react-core\/lib\/components\/Icon$/
|
|
378
|
+
}),
|
|
379
|
+
|
|
380
|
+
/* Ignore cosmos icons - windows */
|
|
381
|
+
new webpack.IgnorePlugin({
|
|
382
|
+
resourceRegExp: /^\.\/.*\/.*\.icon$/,
|
|
383
|
+
contextRegExp: /@pega\\cosmos-react-core\\lib\\components\\Icon$/
|
|
384
|
+
}),
|
|
385
|
+
|
|
360
386
|
new webpack.optimize.LimitChunkCountPlugin({
|
|
361
387
|
maxChunks: 1
|
|
362
388
|
}),
|
|
@@ -5,11 +5,18 @@ import chalk from 'chalk';
|
|
|
5
5
|
import validate from '../validator/index.js';
|
|
6
6
|
import bundleComponent from '../bundle/index.js';
|
|
7
7
|
import { lintComponent } from '../linter/index.js';
|
|
8
|
-
import { getComponentDirectoryPath, showVersion } from '../../util.js';
|
|
8
|
+
import { getComponentDirectoryPath, showVersion, getLibraryBased } from '../../util.js';
|
|
9
9
|
|
|
10
10
|
import { getPublishComponentQuestions, publishComponentToServer, zipComponent } from './helper.js';
|
|
11
11
|
|
|
12
|
+
const isLibraryBased = await getLibraryBased();
|
|
13
|
+
|
|
12
14
|
export default async options => {
|
|
15
|
+
if (isLibraryBased) {
|
|
16
|
+
console.log(`Command only supported for ${chalk.bold.green('non library based')} components.`)
|
|
17
|
+
process.exit();
|
|
18
|
+
}
|
|
19
|
+
|
|
13
20
|
showVersion();
|
|
14
21
|
|
|
15
22
|
let componentKey;
|
|
@@ -5,7 +5,7 @@ import chalk from 'chalk';
|
|
|
5
5
|
import validate from '../validator/index.js';
|
|
6
6
|
import bundleComponent from '../bundle/index.js';
|
|
7
7
|
import { lintComponent } from '../linter/index.js';
|
|
8
|
-
import { getComponents, getComponentDirectoryPath, showVersion } from '../../util.js';
|
|
8
|
+
import { getComponents, getComponentDirectoryPath, showVersion, getLibraryBased } from '../../util.js';
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
11
|
getPublishComponentQuestions,
|
|
@@ -14,6 +14,8 @@ import {
|
|
|
14
14
|
cleanUp
|
|
15
15
|
} from './helper.js';
|
|
16
16
|
|
|
17
|
+
const isLibraryBased = await getLibraryBased();
|
|
18
|
+
|
|
17
19
|
export function getCustomTasks(componentKey, sourceMap, devBuild, content, options) {
|
|
18
20
|
const sDevBuild = devBuild ? '(dev build)' : '';
|
|
19
21
|
// eslint-disable no-unneeded-ternary,no-nested-ternary
|
|
@@ -60,6 +62,11 @@ export function getCustomTasks(componentKey, sourceMap, devBuild, content, optio
|
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
export default async options => {
|
|
65
|
+
if (isLibraryBased) {
|
|
66
|
+
console.log(`Command only supported for ${chalk.bold.green('non library based')} components.`)
|
|
67
|
+
process.exit();
|
|
68
|
+
}
|
|
69
|
+
|
|
63
70
|
showVersion();
|
|
64
71
|
|
|
65
72
|
const components = await getComponents();
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
getPegaServerConfig,
|
|
7
|
+
checkPathAccess,
|
|
8
|
+
getComponentDefaults
|
|
9
|
+
} from '../../util.js';
|
|
10
|
+
import { TASKS_CONFIG_JSON_FILENAME, COMPONENTS_DIRECTORY_PATH, COMPONENTS_PATH } from '../../constants.js';
|
|
11
|
+
|
|
12
|
+
const pegaConfigJsonPath = path.join(path.resolve(), TASKS_CONFIG_JSON_FILENAME);
|
|
13
|
+
|
|
14
|
+
export const getOrgLib = async () => {
|
|
15
|
+
const defaultPegaConfig = await getPegaServerConfig();
|
|
16
|
+
|
|
17
|
+
await checkPathAccess(pegaConfigJsonPath);
|
|
18
|
+
|
|
19
|
+
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
20
|
+
data = data && JSON.parse(data);
|
|
21
|
+
|
|
22
|
+
if (!data[COMPONENTS_DIRECTORY_PATH]) {
|
|
23
|
+
console.error(`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const componentData = data[COMPONENTS_PATH];
|
|
28
|
+
|
|
29
|
+
let library;
|
|
30
|
+
({ library } = componentData);
|
|
31
|
+
let { organization } = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'));
|
|
32
|
+
|
|
33
|
+
const componentDefaults = await getComponentDefaults();
|
|
34
|
+
componentDefaults.library = library;
|
|
35
|
+
componentDefaults.organization = organization;
|
|
36
|
+
|
|
37
|
+
return componentDefaults;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
export const getLibraryVersionQuestion = async(libVersions) => {
|
|
43
|
+
|
|
44
|
+
return [
|
|
45
|
+
{
|
|
46
|
+
name: 'version',
|
|
47
|
+
type: 'rawlist',
|
|
48
|
+
message: 'Select library version to publish',
|
|
49
|
+
choices: libVersions
|
|
50
|
+
}
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import inquirer from 'inquirer';
|
|
2
|
+
import { Listr } from 'listr2';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
|
|
5
|
+
import validate from '../validator/index.js';
|
|
6
|
+
import { lintComponent } from '../linter/index.js';
|
|
7
|
+
import { getComponentDirectoryPath, showVersion, getC11NB2STokenAndStaticServer, getLibraryVersions, getLibraryBased } from '../../util.js';
|
|
8
|
+
|
|
9
|
+
import { publishLib, listLibJSONResponse, deleteLibVersion } from '@pega/constellation-dx-components-build-utils/index.js';
|
|
10
|
+
|
|
11
|
+
import { getLibraryVersionQuestion, getOrgLib } from './helper.js';
|
|
12
|
+
;
|
|
13
|
+
|
|
14
|
+
const isLibraryBased = await getLibraryBased();
|
|
15
|
+
|
|
16
|
+
export function getCustomTasks(componentKey, sourceMap, devBuild, options) {
|
|
17
|
+
|
|
18
|
+
const sDevBuild = devBuild ? '(dev build)' : '';
|
|
19
|
+
return new Listr(
|
|
20
|
+
[
|
|
21
|
+
{
|
|
22
|
+
title: 'Validate config schema',
|
|
23
|
+
task: async () => {
|
|
24
|
+
await validate(componentKey);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
title: 'Lint component',
|
|
29
|
+
task: async () => {
|
|
30
|
+
const targetDirectory = await getComponentDirectoryPath(componentKey);
|
|
31
|
+
// console.log(`in buildComponent Lint component task: componentKey: ${componentKey} targetDirectory: ${targetDirectory}`);
|
|
32
|
+
await lintComponent(targetDirectory);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
],
|
|
37
|
+
{ concurrent: false, exitOnError: true }
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const doesLibraryExist = async (libraryName, libraryVersion) => {
|
|
44
|
+
|
|
45
|
+
const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
|
|
46
|
+
const libList = await listLibJSONResponse(tokenAndStaticServer.C11NB2S, tokenAndStaticServer.appStaticContentServer);
|
|
47
|
+
const oList = JSON.parse(libList);
|
|
48
|
+
|
|
49
|
+
let libVersionExists = false;
|
|
50
|
+
let overrideExisting = false;
|
|
51
|
+
if (oList && Object.keys(oList).length !== 0 ) {
|
|
52
|
+
// need to parse data to find versions
|
|
53
|
+
let versionList = oList[libraryName];
|
|
54
|
+
|
|
55
|
+
if (versionList && versionList.includes(libraryVersion)) {
|
|
56
|
+
libVersionExists = true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return libVersionExists;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
export const publishNewLibraryAsync = async (libraryName, version, checkDeleted = false) => {
|
|
65
|
+
|
|
66
|
+
const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
|
|
67
|
+
|
|
68
|
+
if (checkDeleted ) {
|
|
69
|
+
console.log(chalk.yellow(`Verifying library has been deleted..`));
|
|
70
|
+
let libExists = await doesLibraryExist(libraryName, version);
|
|
71
|
+
let count = 0;
|
|
72
|
+
while (libExists) {
|
|
73
|
+
// keep checking until no longer exists
|
|
74
|
+
libExists = await doesLibraryExist(libraryName, version);
|
|
75
|
+
count ++;
|
|
76
|
+
|
|
77
|
+
if (count > 100) {
|
|
78
|
+
console.log(chalk.red.bold(`Library hasn't been deleted, can't proceed.`));
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
console.log(chalk.green(`Deleted..`));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
console.log(chalk.green.bold(`Publishing Library ${libraryName}:${version} ... `));
|
|
89
|
+
publishLib(libraryName, version, tokenAndStaticServer.C11NB2S, tokenAndStaticServer.appStaticContentServer);
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
export default async (options) => {
|
|
95
|
+
if (!isLibraryBased) {
|
|
96
|
+
console.log(`Command only supported for ${chalk.bold.green('library based')} components.`)
|
|
97
|
+
process.exit();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
showVersion();
|
|
101
|
+
|
|
102
|
+
let organization;
|
|
103
|
+
let library;
|
|
104
|
+
let version;
|
|
105
|
+
let devBuild;
|
|
106
|
+
|
|
107
|
+
let libraryName;
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
if (options.params.length >= 6) {
|
|
111
|
+
organization = options.params[3];
|
|
112
|
+
library = options.params[4];
|
|
113
|
+
version = options.params[5];
|
|
114
|
+
libraryName = organization.concat("_").concat(library);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
|
|
118
|
+
const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
|
|
119
|
+
|
|
120
|
+
if (tokenAndStaticServer.C11NB2S === undefined) {
|
|
121
|
+
console.log(chalk.redBright("Need to authenticate, missing services token.\nPublishing a library requires authentication to acquire a token to publish."));
|
|
122
|
+
process.exit(1);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const compDef = await getOrgLib();
|
|
126
|
+
organization = compDef.organization;
|
|
127
|
+
library = compDef.library;
|
|
128
|
+
|
|
129
|
+
libraryName = organization.concat("_").concat(library);
|
|
130
|
+
|
|
131
|
+
console.log(`\nLibrary ${chalk.bold.green(libraryName)} `)
|
|
132
|
+
|
|
133
|
+
const libVersions = await getLibraryVersions(libraryName);
|
|
134
|
+
|
|
135
|
+
if (libVersions.length > 0) {
|
|
136
|
+
const versionQuestions = await getLibraryVersionQuestion(libVersions);
|
|
137
|
+
const versionAnswers = await inquirer.prompt(versionQuestions);
|
|
138
|
+
|
|
139
|
+
({version} = versionAnswers);
|
|
140
|
+
|
|
141
|
+
let okToPublish = true;
|
|
142
|
+
if (!version.includes("-dev")) {
|
|
143
|
+
okToPublish = false;
|
|
144
|
+
const publishAnswers = await inquirer.prompt([
|
|
145
|
+
|
|
146
|
+
{
|
|
147
|
+
name: 'confirmPublish',
|
|
148
|
+
type: 'confirm',
|
|
149
|
+
message: 'You are about to publish a PRODUCTION version which can NOT be deleted, proceed ?',
|
|
150
|
+
default: false
|
|
151
|
+
}
|
|
152
|
+
]);
|
|
153
|
+
if (publishAnswers.confirmPublish) {
|
|
154
|
+
okToPublish = true;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (okToPublish) {
|
|
159
|
+
|
|
160
|
+
let libVersionExists = await doesLibraryExist(libraryName, version);
|
|
161
|
+
let overrideExisting = false;
|
|
162
|
+
let checkDeleted = false;
|
|
163
|
+
|
|
164
|
+
if (libVersionExists) {
|
|
165
|
+
console.log("\nLibrary " + chalk.bold.yellow(`${libraryName}:${version}`) + " already exists.");
|
|
166
|
+
const questions = [
|
|
167
|
+
{
|
|
168
|
+
name: 'override',
|
|
169
|
+
type: 'confirm',
|
|
170
|
+
message: `Do you wish to overrite it`,
|
|
171
|
+
default: false
|
|
172
|
+
}
|
|
173
|
+
];
|
|
174
|
+
|
|
175
|
+
await inquirer.prompt(questions).then(async answers => {
|
|
176
|
+
overrideExisting = answers.override;
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
if (libVersionExists) {
|
|
183
|
+
if (overrideExisting) {
|
|
184
|
+
console.log("\nDeleting existing library " + chalk.bold.yellow(`${libraryName}:${version}`) + " ...");
|
|
185
|
+
await deleteLibVersion(libraryName, version, tokenAndStaticServer.C11NB2S, tokenAndStaticServer.appStaticContentServer);
|
|
186
|
+
|
|
187
|
+
checkDeleted = true;
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
// don't override, so end
|
|
191
|
+
console.log(chalk.yellow(`You will need to increment your library version to publish`));
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// need a timeout to give services time to delete the library
|
|
197
|
+
setTimeout( function(){ publishNewLibraryAsync(libraryName, version, checkDeleted)}, 700 );
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
console.log(chalk.bold.redBright(`No library versions in ${libraryName}`));
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return true;
|
|
212
|
+
};
|