@pega/dx-component-builder-sdk 0.1.1 → 0.1.2

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/dx-component-builder-sdk",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
package/src/constants.js CHANGED
@@ -252,8 +252,8 @@ export const COMPONENT_SCHEMA = {
252
252
  value: 'URL'
253
253
  },
254
254
  {
255
- name: 'User Referene',
256
- value: 'UserRefernece'
255
+ name: 'User Reference',
256
+ value: 'UserReference'
257
257
  }
258
258
  ],
259
259
  designSystemExtensions: [
@@ -6,7 +6,7 @@ import chalk from 'chalk';
6
6
  import inquirer from 'inquirer';
7
7
  import fetch from 'node-fetch';
8
8
 
9
- import { checkPathAccess, getTokenUrl } from '../../util.js';
9
+ import { checkPathAccess, getTokenUrl, showVersion } from '../../util.js';
10
10
  import { TOKEN_PATH } from '../../constants.js';
11
11
 
12
12
  import { getAuthQuestions } from './helper.js';
@@ -57,6 +57,8 @@ const generateAccessToken = async config => {
57
57
  };
58
58
 
59
59
  export default async options => {
60
+ showVersion();
61
+
60
62
  await checkPathAccess(pegaConfigJsonPath);
61
63
 
62
64
  let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
@@ -7,9 +7,11 @@ import validate from '../validator/index.js';
7
7
  import bundleComponent from '../bundle/index.js';
8
8
  import lintComponent from '../linter/index.js';
9
9
  import { getBuildComponentQuestions, getBuildCategory, getOptionsCategory } from './helper.js';
10
- import { getComponentDirectoryPath } from '../../util.js';
10
+ import { getComponentDirectoryPath, showVersion } from '../../util.js';
11
11
 
12
12
  export default async options => {
13
+ showVersion();
14
+
13
15
  const catQuestion = await getBuildCategory(options);
14
16
  const catAnwers = await inquirer.prompt(catQuestion);
15
17
 
@@ -2,14 +2,13 @@ import path from 'path';
2
2
  import { URL, fileURLToPath } from 'url';
3
3
  import fs from 'fs';
4
4
  import { promisify } from 'util';
5
- import { createRequire } from "module";
6
5
  import { join } from 'path';
7
6
 
8
7
  import inquirer from 'inquirer';
9
8
  import ncp from 'ncp';
10
9
  import chalk from 'chalk';
11
10
 
12
- import { checkPathAccess, getTokenUrl } from '../../util.js';
11
+ import { checkPathAccess, getTokenUrl, showVersion } from '../../util.js';
13
12
 
14
13
 
15
14
  export const DXCB_CONFIG_JSON_FILENAME = 'dxcb.config.json';
@@ -186,6 +185,8 @@ const validateCompile = async (
186
185
  };
187
186
 
188
187
  export default async options => {
188
+ showVersion();
189
+
189
190
  if (options.params[10]) {
190
191
  const componentName = options.params[3];
191
192
  const componentLabel = options.params[4];
@@ -343,11 +344,6 @@ export default async options => {
343
344
  }
344
345
  ];
345
346
 
346
- // get package version, so can display at create
347
- const require = createRequire(import.meta.url);
348
- const pData = require("../../../package.json");
349
-
350
- console.log(chalk.green("DX Component Builder - SDK v" + pData.version));
351
347
  await inquirer.prompt(questions).then(async answers => {
352
348
  const {
353
349
  componentName,
@@ -1,6 +1,7 @@
1
1
  import inquirer from 'inquirer';
2
2
  import ora from 'ora';
3
3
  import chalk from 'chalk';
4
+ import { showVersion } from '../../util.js';
4
5
 
5
6
  import {
6
7
  deleteLocalComponents,
@@ -30,6 +31,8 @@ const deleteComponentsFn = async (sourceOfComponents, answers) => {
30
31
  };
31
32
 
32
33
  export default async options => {
34
+ showVersion();
35
+
33
36
  let sourceOfComponentsOption = SOURCE_OF_COMPONENT_TYPES.LOCAL;
34
37
  if (options.params[4] === SOURCE_OF_COMPONENT_TYPES.LOCAL) {
35
38
  sourceOfComponentsOption = options.params[3];
@@ -10,6 +10,8 @@ import {
10
10
  getOptionsCategory
11
11
  } from './helper.js';
12
12
 
13
+ import { showVersion } from '../../util.js';
14
+
13
15
  const deleteComponentsFn = async (sourceOfComponents, answers) => {
14
16
  switch (sourceOfComponents) {
15
17
  case SOURCE_OF_COMPONENT_TYPES.LOCAL: {
@@ -28,6 +30,8 @@ const deleteComponentsFn = async (sourceOfComponents, answers) => {
28
30
  };
29
31
 
30
32
  export default async options => {
33
+ showVersion();
34
+
31
35
  let sourceOfComponentsOption = SOURCE_OF_COMPONENT_TYPES.LOCAL;
32
36
  if (options.params[3] === SOURCE_OF_COMPONENT_TYPES.LOCAL) {
33
37
  sourceOfComponentsOption = options.params[3];
@@ -11,6 +11,8 @@ import {
11
11
  getOptionsCategory
12
12
  } from './helper.js';
13
13
 
14
+ import { showVersion } from '../../util.js';
15
+
14
16
 
15
17
  const getList = async (sourceOfComponents, answers) => {
16
18
  switch (sourceOfComponents) {
@@ -35,6 +37,8 @@ const getList = async (sourceOfComponents, answers) => {
35
37
 
36
38
  export default async options => {
37
39
 
40
+ showVersion();
41
+
38
42
  let sourceOfComponentsOption = SOURCE_OF_COMPONENT_TYPES.LOCAL;
39
43
 
40
44
  if (options.params[4] === SOURCE_OF_COMPONENT_TYPES.LOCAL) {
@@ -10,7 +10,7 @@ import ncp from 'ncp';
10
10
  import chalk from 'chalk';
11
11
  import { updateComponentMap } from '../map/map.js';
12
12
 
13
- import { checkPathAccess, getTokenUrl } from '../../util.js';
13
+ import { checkPathAccess, getTokenUrl, showVersion } from '../../util.js';
14
14
 
15
15
 
16
16
  export const DXCB_CONFIG_JSON_FILENAME = 'dxcb.config.json';
@@ -87,6 +87,7 @@ const validateCompile = async (
87
87
  };
88
88
 
89
89
  export default async options => {
90
+ showVersion();
90
91
 
91
92
  let promptType = null;
92
93
  if (options.params[3]) {
@@ -188,11 +189,6 @@ export default async options => {
188
189
 
189
190
  ];
190
191
 
191
- // get package version, so can display at create
192
- const require = createRequire(import.meta.url);
193
- const pData = require("@pega/dx-component-builder-sdk/package.json");
194
-
195
- console.log(chalk.green("DX Component Builder - SDK vt" + pData.version));
196
192
  await inquirer.prompt(questions).then(async answers => {
197
193
  let {
198
194
  componentName,
@@ -3,7 +3,7 @@ import Listr from 'listr';
3
3
  import chalk from 'chalk';
4
4
 
5
5
  import validate from '../validator/index.js';
6
- import { getComponentDirectoryPath } from '../../util.js';
6
+ import { getComponentDirectoryPath, showVersion } from '../../util.js';
7
7
  import bundleComponent from '../bundle/index.js';
8
8
  import { updateComponentMap } from '../map/map.js';
9
9
  import { lintComponent } from '../linter/index.js';
@@ -11,6 +11,8 @@ import { lintComponent } from '../linter/index.js';
11
11
  import { getPublishComponentQuestions, publishComponentToServer, zipComponent } from './helper.js';
12
12
 
13
13
  export default async options => {
14
+ showVersion();
15
+
14
16
  const questions = await getPublishComponentQuestions();
15
17
  const answers = await inquirer.prompt(questions);
16
18
  const { componentKey, sourceMap, devBuild } = answers;
@@ -9,12 +9,15 @@ import { updateComponentMap } from '../map/map.js';
9
9
 
10
10
  import { getPublishComponentQuestions, publishComponentToServer, zipComponent } from './helper.js';
11
11
  import {
12
- getComponentsObj,
13
- getComponentDirectoryPath
12
+ getComponentsObj,
13
+ getComponentDirectoryPath,
14
+ showVersion
14
15
  } from '../../util.js';
15
16
  import { lintComponent } from '../linter/index.js';
16
17
 
17
18
  export default async options => {
19
+ showVersion();
20
+
18
21
  const components = await getComponentsObj();
19
22
  const questions = await getPublishComponentQuestions();
20
23
  const answers = await inquirer.prompt(questions);
package/src/util.js CHANGED
@@ -3,6 +3,8 @@ import { join } from 'path';
3
3
  import { promisify } from 'util';
4
4
  import https from 'https';
5
5
  import inquirer from 'inquirer';
6
+ import { createRequire } from "module";
7
+ import { URL, fileURLToPath } from 'url';
6
8
 
7
9
  import chalk from 'chalk';
8
10
  import mustache from 'mustache';
@@ -535,6 +537,14 @@ export const validateRulesetVersion = str => {
535
537
  return regex.test(str);
536
538
  };
537
539
 
540
+ export const showVersion = () => {
541
+ // get package version, so can display at start
542
+ const require = createRequire(import.meta.url);
543
+ const pData = require("@pega/dx-component-builder-sdk/package.json");
544
+
545
+ console.log(chalk.green("DX Component Builder - SDK v" + pData.version));
546
+ }
547
+
538
548
  export const getOOTBComponents = async () => {
539
549
  return new Promise((resolve, reject) => {
540
550
  fs.readFile(OOTB_COMPONENTS, 'utf-8', async (err, data) => {