@pega/custom-dx-components 0.242.34 → 0.242.35

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/custom-dx-components",
3
- "version": "0.242.34",
3
+ "version": "0.242.35",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
package/src/cli.js CHANGED
@@ -19,6 +19,7 @@ import {
19
19
  deleteVersion,
20
20
  importArchive,
21
21
  exportArchive,
22
+ importComponent,
22
23
  initProject,
23
24
  listComponents,
24
25
  listLibrary,
@@ -76,6 +77,7 @@ const TASKS = {
76
77
  DELETE_VERSION: 'deleteVersion',
77
78
  IMPORT_ARCHIVE: 'importArchive',
78
79
  EXPORT_ARCHIVE: 'exportArchive',
80
+ IMPORT_COMP: 'importComponent',
79
81
  AUTHENTICATE: 'authenticate',
80
82
  UPGRADE: 'upgrade',
81
83
  BUILD_JEST_ASSETS: 'buildJestAssets'
@@ -212,6 +214,10 @@ export default async (args = []) => {
212
214
  exportArchive(options);
213
215
  break;
214
216
  }
217
+ case TASKS.IMPORT_COMP: {
218
+ importComponent(options);
219
+ break;
220
+ }
215
221
  case TASKS.VALIDATE_SCHEMA: {
216
222
  validate(options);
217
223
  break;
@@ -15,7 +15,8 @@ import {
15
15
  setConfigDevBuild,
16
16
  checkLibraryAndArchives,
17
17
  getConfigDefaults,
18
- forceDefaultsUpdate
18
+ forceDefaultsUpdate,
19
+ modAddAboutData
19
20
  } from '../../util.js';
20
21
 
21
22
  import { getCreateVersionComponentQuestions, updateAllComponentsConfig } from './helper.js';
@@ -47,6 +48,14 @@ addDebugLog("createVersion", "", "+");
47
48
  version = options.params[3];
48
49
  const dPerm = options.params[4];
49
50
  const copyExist = options.params[5]
51
+
52
+ // if have [6] will be "NoAbout" from Jest, to turn off build date
53
+ if (options.params.length >= 7 ) {
54
+ if (options.params[6] === "NoAbout") {
55
+ modAddAboutData(false);
56
+ }
57
+ }
58
+
50
59
  permBuild = !!(dPerm === 'Y' || dPerm === 'y' || dPerm === true || dPerm === 'true');
51
60
  copyExisting = !!(copyExist === 'Y' || copyExist === 'y' || copyExist === true || copyExist === 'true');
52
61
 
@@ -0,0 +1,49 @@
1
+ import chalk from 'chalk';
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ import { join } from 'path';
5
+ import { Listr } from 'listr2';
6
+ import { addDebugLog, getConfigDefaults, convertIntoPascalCase, getComponents, getComponentDirectoryPath, getDirectoryFiles } from '../../util.js';
7
+ import { TASKS_CONFIG_JSON_FILENAME, TEMP_PATH, PACKAGE_JSON_FILENAME } from '../../constants.js';
8
+
9
+
10
+ export const getFilePathQuestions = async () => {
11
+ addDebugLog("getFilePathQuestions", "", "");
12
+
13
+ console.log("\nFile path examples:");
14
+ if (path.sep === "/") {
15
+ console.log("\tMac OS/Unix:\t/Users/name/...\n");
16
+ }
17
+ else {
18
+ console.log("\tWindows:\tC:\\Users\\name\\...\n");
19
+ }
20
+
21
+ const currentDirectory = process.cwd();
22
+ const arPathParts = currentDirectory.split(path.sep);
23
+ let defaultPath = join(arPathParts[0], arPathParts[1], arPathParts[2], "Downloads");
24
+ if (path.sep === "/") {
25
+ defaultPath = "/".concat(defaultPath);
26
+ }
27
+
28
+
29
+ return [
30
+ {
31
+ name: 'filePath',
32
+ message: 'Enter full file path of zip file location:',
33
+ default: defaultPath
34
+ }
35
+ ];
36
+ };
37
+
38
+ export const getFileNameQuestions = async (zipFileList) => {
39
+ addDebugLog("getFileNameQuestions", "", "");
40
+
41
+ return [
42
+ {
43
+ name: 'fileName',
44
+ type: 'rawlist',
45
+ message: `Select zip file`,
46
+ choices: zipFileList
47
+ },
48
+ ];
49
+ };
@@ -0,0 +1,321 @@
1
+ import fs from 'fs';
2
+ import { promisify } from 'util';
3
+ import { join } from 'path';
4
+
5
+ import inquirer from 'inquirer';
6
+ import ncp from 'ncp';
7
+ import chalk from 'chalk';
8
+
9
+ import {
10
+ sanitize,
11
+ checkPathAccess,
12
+ showVersion,
13
+ getDirectoryFiles,
14
+ addDebugLog,
15
+ checkLibraryAndArchives,
16
+ getConfigDefaults,
17
+ getComponents
18
+ } from '../../util.js';
19
+ import { TASKS_CONFIG_JSON_FILENAME } from '../../constants.js';
20
+ import { getFilePathQuestions, getFileNameQuestions } from './helper.js';
21
+
22
+ export const DXCB_CONFIG_INTERNAL_JSON_FILENAME = 'src/dxcb.config.json';
23
+ const currentDirectory = process.cwd();
24
+ const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
25
+
26
+ import {
27
+ convertIntoPascalCase,
28
+ getComponentDirectoryPath
29
+ } from '../../util.js';
30
+ import Choice from 'inquirer/lib/objects/choice.js';
31
+
32
+
33
+ const copy = promisify(ncp);
34
+
35
+ let gFilePath = "";
36
+
37
+
38
+ export const updateConfig = async (
39
+ {
40
+ oldComponentKey,
41
+ newComponentKey,
42
+ library,
43
+ version,
44
+ targetDirectory,
45
+ newLabel = "",
46
+ },
47
+ options,
48
+ onlyCompanion = false
49
+ ) => {
50
+
51
+ addDebugLog("updateConfig", `oldComponentKey: ${oldComponentKey}, newComponentKey: ${newComponentKey}`, "");
52
+
53
+ let configData = fs.readFileSync(join(targetDirectory, "/config.json"), { encoding: 'utf8' });
54
+ configData = configData && JSON.parse(configData);
55
+
56
+ configData.name = newComponentKey;
57
+ if (configData.componentKey) configData.componentKey = newComponentKey;
58
+ configData.library = library;
59
+ configData.version = version;
60
+
61
+ if (newLabel != "") {
62
+ configData.label = newLabel;
63
+ configData.description = newLabel;
64
+ }
65
+
66
+ // stringify "4", makes the json string look like JSON in the file, formated instead of a single line
67
+ fs.writeFileSync(join(targetDirectory, "/config.json"), JSON.stringify(configData, null, 4), { encoding: 'utf8' });
68
+
69
+ };
70
+
71
+ export const updateFile = async (
72
+ fileName,
73
+ oldComponentKeyPC,
74
+ newComponentKeyPC,
75
+ targetDirectory,
76
+ ) => {
77
+
78
+ addDebugLog("updateFile", `fileName: ${fileName}, oldComponentKeyPC: ${oldComponentKeyPC}, newComponentKeyPC: ${newComponentKeyPC}, targetDirectory: ${targetDirectory}`, "");
79
+
80
+ let fileData = fs.readFileSync(join(targetDirectory, "/", fileName), { encoding: 'utf8' });
81
+
82
+ if (fileData.indexOf(oldComponentKeyPC) >= 0) {
83
+ fileData = fileData.replaceAll(oldComponentKeyPC, newComponentKeyPC);
84
+
85
+ fs.writeFileSync(join(targetDirectory, "/", fileName), fileData, { encoding: 'utf8' });
86
+ }
87
+
88
+ };
89
+
90
+
91
+ // rename the component
92
+ export const renameComponent = async (
93
+ componentKey,
94
+ library,
95
+ version,
96
+ newName = "",
97
+ newLabel = "",
98
+ options
99
+ ) => {
100
+
101
+ addDebugLog("renameComponent", `library: ${library}, componentKey: ${componentKey}`, "");
102
+
103
+ const componentName = newName != "" ? newName : componentKey.split("_")[2];
104
+ const newComponentKey = `${library}_${componentName}`;
105
+ const oldComponentKey = componentKey;
106
+ const newComponentKeyPC = convertIntoPascalCase(newComponentKey);
107
+ const oldComponentKeyPC = convertIntoPascalCase(oldComponentKey);
108
+
109
+ const currentDirectory = await getComponentDirectoryPath(componentKey);
110
+ const targetDirectory = await getComponentDirectoryPath(newComponentKey);
111
+
112
+ // custom component
113
+ try {
114
+ fs.renameSync(currentDirectory, targetDirectory);
115
+ } catch(err) {
116
+ console.log(err)
117
+ }
118
+
119
+ const targetFileList = await getDirectoryFiles(targetDirectory);
120
+
121
+ for (var fileIndex in targetFileList) {
122
+ const fileName = targetFileList[fileIndex];
123
+
124
+ if (fileName === "config.json") {
125
+ await updateConfig(
126
+ {
127
+ oldComponentKey,
128
+ newComponentKey,
129
+ componentName,
130
+ library,
131
+ version,
132
+ targetDirectory,
133
+ newLabel
134
+ },
135
+ options
136
+ );
137
+ }
138
+ else {
139
+ await updateFile(
140
+ fileName,
141
+ oldComponentKeyPC,
142
+ newComponentKeyPC,
143
+ targetDirectory );
144
+
145
+ }
146
+
147
+ } // for
148
+
149
+
150
+ return newComponentKey;
151
+
152
+ };
153
+
154
+
155
+ export const importComp = async(filePath, fileName) => {
156
+ addDebugLog("importComp", `filePath: ${filePath}, fileName: ${fileName}`, "");
157
+
158
+ const currentDirectory = process.cwd();
159
+ const compDirectory = join(currentDirectory, "src", "components");
160
+ const copyFilePath = join(filePath, fileName);
161
+
162
+ const configDef = getConfigDefaults();
163
+ const copyDir = join(compDirectory, fileName);
164
+
165
+ if (fs.existsSync(copyFilePath)) {
166
+ fs.cpSync(copyFilePath, copyDir, { recursive: true, force: true });
167
+ }
168
+
169
+ let configData = fs.readFileSync(join(copyDir, "/config.json"), { encoding: 'utf8' });
170
+ configData = configData && JSON.parse(configData);
171
+
172
+ const compName = configData.componentKey.split("_")[2];
173
+ const potentialCompKey = `${configDef.currentOrgLib}_${compName}`;
174
+ const currentCompList = await getComponents();
175
+ let newName = "";
176
+ let newLabel = "";
177
+
178
+ if (currentCompList && currentCompList.includes(potentialCompKey)) {
179
+ console.log(`\nComponent ${chalk.yellow(`${potentialCompKey}`)} already exists.`);
180
+ const proceedAnswers = await inquirer.prompt([
181
+
182
+ {
183
+ name: 'proceedAs',
184
+ type: 'rawlist',
185
+ message: `Proceed as ?`,
186
+ default: 'No import',
187
+ choices: ['No import', 'Overwrite', 'New name']
188
+ },
189
+ {
190
+ name: 'componentName',
191
+ message: 'Enter component name (required)',
192
+ when(answers) {
193
+ return answers.proceedAs === 'New name';
194
+ },
195
+ validate: value => {
196
+ /* value should not be empty
197
+ It should not have spaces
198
+ It should not start with a number
199
+ Only case-insensitive alphanumeric values are allowed
200
+ */
201
+ if (value && !/^\d/.test(value) && value === sanitize(value)) {
202
+ return true;
203
+ }
204
+ return 'Only alphanumeric values are allowed, starting with alphabets, no spaces.';
205
+ }
206
+ },
207
+ {
208
+ name: 'componentLabel',
209
+ message: 'Enter component label for display (required)',
210
+ when(answers) {
211
+ return answers.proceedAs === 'New name';
212
+ },
213
+ validate: value => {
214
+ if (value) {
215
+ return true;
216
+ }
217
+ return 'Please provide value for label';
218
+ }
219
+ }
220
+ ]);
221
+
222
+ switch (proceedAnswers.proceedAs) {
223
+ case 'No import':
224
+ // removed copied
225
+ fs.rmSync(copyDir, { recursive: true, force: true, maxRetries: 2 });
226
+ process.exit();
227
+ break;
228
+ case 'Overwrite':
229
+ // remove existing
230
+ const exitingComp = join(compDirectory, potentialCompKey);
231
+ fs.rmSync(exitingComp, { recursive: true, force: true, maxRetries: 2 });
232
+ break;
233
+ case 'New name':
234
+ newName = proceedAnswers.componentName;
235
+ newLabel = proceedAnswers.componentLabel;
236
+ break;
237
+ }
238
+
239
+ }
240
+
241
+ const newCompKey = await renameComponent(configData.componentKey, configDef.currentOrgLib, configDef.buildVersion, newName, newLabel, null);
242
+ console.log(`\n${chalk.green(`${fileName}`)} has been imported as ${chalk.green(`${newCompKey}`)}`);
243
+
244
+
245
+ }
246
+
247
+
248
+ export const getFolderList = async (filePath) => {
249
+ addDebugLog("getFolderList", `filePath: ${filePath}`, "");
250
+ if (fs.existsSync(filePath)) {
251
+ return fs
252
+ .readdirSync(filePath, { withFileTypes: true })
253
+ .filter(dirent => dirent.isDirectory())
254
+ .map(dirent => dirent.name);
255
+ }
256
+ else {
257
+ console.log(chalk.red.bold(`File path: ${filePath} does not exist or no permissions.`));
258
+ process.exit(1);
259
+ }
260
+ }
261
+
262
+ export const hasConfig = (dir) => {
263
+ const configPath = join(gFilePath, dir, "config.json");
264
+ if (fs.existsSync(configPath)) {
265
+ return true;
266
+ }
267
+
268
+ return false;
269
+ }
270
+
271
+ export const getComponentList = async(filePath) => {
272
+ addDebugLog("getComponentList", `filePath: ${filePath}`, "");
273
+ let compList = await getFolderList(filePath);
274
+
275
+ gFilePath = filePath;
276
+
277
+ if (compList.length > 0) {
278
+ return compList.filter(hasConfig);
279
+ }
280
+
281
+ return compList;
282
+
283
+ }
284
+
285
+ export default async options => {
286
+ await showVersion();
287
+ await checkLibraryAndArchives();
288
+ await checkPathAccess(pegaConfigJsonPath);
289
+
290
+ addDebugLog("importComponent", "", "+");
291
+
292
+ if (options.params.length >= 5) {
293
+ const filePath = options.param[3];
294
+ const fileName = options.params[4];
295
+ await importComp( filePath, fileName);
296
+
297
+ }
298
+ else {
299
+
300
+ const filePathQuestions = await getFilePathQuestions();
301
+ const filePathAnswers = await inquirer.prompt(filePathQuestions);
302
+ const { filePath } = filePathAnswers;
303
+
304
+ const compFileList = await getComponentList(filePath);
305
+
306
+ if (!compFileList || compFileList.length === 0) {
307
+ console.log(chalk.red.bold(`No component files exist at path: ${filePath}`));
308
+ process.exit();
309
+ }
310
+
311
+ const fileNameQuestions = await getFileNameQuestions(compFileList);
312
+ const fileNameAnswers = await inquirer.prompt(fileNameQuestions);
313
+ const {fileName} = fileNameAnswers;
314
+
315
+ await importComp( filePath, fileName);
316
+
317
+ }
318
+
319
+ addDebugLog("importComponent", "END", "-");
320
+
321
+ };
@@ -27,6 +27,7 @@ export { default as setPermanent } from './set-perm/index.js';
27
27
  export { default as storeComponents } from './store/index.js';
28
28
  export { default as importArchive } from './import-archive/index.js';
29
29
  export { default as exportArchive } from './export-archive/index.js';
30
+ export { default as importComponent } from './import-comp/index.js';
30
31
  export { default as updateComponent } from './update/index.js';
31
32
  export { default as validate } from './validator/index.js';
32
33
  export { default as authenticate } from './authenticate/index.js';
@@ -19,6 +19,7 @@
19
19
  "update": "custom-dx-components update",
20
20
  "delete": "custom-dx-components delete",
21
21
  "deleteAll": "custom-dx-components deleteAll",
22
+ "importComponent": "custom-dx-components importComponent",
22
23
  "_***Component_mode_only***": "Component only commands",
23
24
  "publish": "custom-dx-components publish",
24
25
  "publishAll": "custom-dx-components publishAll",
@@ -34,7 +35,7 @@
34
35
  "deleteLib": "custom-dx-components deleteLibrary",
35
36
  "deletePublishedLib": "custom-dx-components deletePublished",
36
37
  "deleteLibVersion": "custom-dx-components deleteVersion",
37
- "moveLibVersion": "custom-dx-components moveComponent",
38
+ "move": "custom-dx-components moveComponent",
38
39
  "publishLibVersion": "custom-dx-components publish",
39
40
  "storeLibVersion": "custom-dx-components storeComponents",
40
41
  "showStatus": "custom-dx-components showStatus",
@@ -98,7 +99,7 @@
98
99
  },
99
100
  "devDependencies": {
100
101
  "@pega/configs": "^0.6.0",
101
- "@pega/custom-dx-components": "0.242.34",
102
+ "@pega/custom-dx-components": "0.242.35",
102
103
  "@pega/pcore-pconnect-typedefs": "~3.0.0",
103
104
  "@storybook/addon-actions": "^7.6.7",
104
105
  "@storybook/addon-essentials": "^7.6.19",
@@ -16,7 +16,6 @@ export default async (options) => {
16
16
  await checkLibraryAndArchives();
17
17
  addDebugLog("listLibrary", "", "+");
18
18
 
19
- let sourceOfLibrary;
20
19
  let organization;
21
20
  let library;
22
21
 
@@ -29,24 +28,28 @@ addDebugLog("listLibrary", "", "+");
29
28
  let libVersions = [];
30
29
 
31
30
  if (options.params.length >= 5) {
32
- // sourceOfLibrary = options.params[3];
33
- // selectedVersion = options.params[4];
31
+ libraryName = options.params[3];
32
+ selectedVersion = options.params[4];
34
33
 
35
- // libVersions.push(selectedVersion);
34
+ try {
35
+ libVersions = await getLibraryArchivesVersions(libraryName, "");
36
+ }
37
+ catch (ex) {}
36
38
 
37
39
  }
40
+ else {
38
41
 
39
- const questions = await getArchiveLibraryQuestions();
40
- const answers = await inquirer.prompt(questions);
41
- ({ libraryName } = answers);
42
+ const questions = await getArchiveLibraryQuestions();
43
+ const answers = await inquirer.prompt(questions);
44
+ ({ libraryName } = answers);
42
45
 
43
- try {
44
- libVersions = await getLibraryArchivesVersions(libraryName, "");
45
- }
46
- catch (ex) {}
46
+ try {
47
+ libVersions = await getLibraryArchivesVersions(libraryName, "");
48
+ }
49
+ catch (ex) {}
47
50
 
48
51
 
49
- if (libVersions.length > 0) {
52
+ if (libVersions.length > 0) {
50
53
 
51
54
  if (selectedVersion === undefined) {
52
55
  const libAnswers = await inquirer.prompt([
@@ -61,10 +64,14 @@ addDebugLog("listLibrary", "", "+");
61
64
 
62
65
  selectedVersion = libAnswers.libVersion;
63
66
  }
67
+ }
68
+ }
69
+
70
+ let data;
71
+ // get built on from first component if exists
72
+ let builtOn = "(date unavailable)";
64
73
 
65
- let data;
66
- // get built on from first component if exists
67
- let builtOn = "(date unavailable)";
74
+ if (libVersions.length > 0) {
68
75
 
69
76
  if (libraryName === compDef.currentOrgLib && selectedVersion === compDef.buildVersion) {
70
77
 
@@ -20,7 +20,7 @@ import {
20
20
  getLibraryArchivesVersions,
21
21
  getLibraryArchiveDirectories
22
22
  } from '../../util.js';
23
- import { TASKS_CONFIG_JSON_FILENAME, COMPONENTS_DIRECTORY_PATH, COMPONENTS_PATH, ARCHIVES_PATH, TEMP_PATH } from '../../constants.js';
23
+ import { TASKS_CONFIG_JSON_FILENAME, COMPONENTS_DIRECTORY_PATH, ARCHIVES_PATH, TEMP_PATH } from '../../constants.js';
24
24
  import { getComponentKeyQuestion, getLibraryQuestions, getLibraryVersionQuestion } from './helper.js';
25
25
 
26
26
  export const DXCB_CONFIG_INTERNAL_JSON_FILENAME = 'src/dxcb.config.json';
@@ -96,26 +96,21 @@ export const renameComponent = async (
96
96
 
97
97
  addDebugLog("renameComponent", `library: ${library}, componentKey: ${componentKey}`, "");
98
98
 
99
-
100
99
  const componentName = componentKey.split("_")[2];
101
-
102
- const configDef = getConfigDefaults();
103
-
104
100
  const newComponentKey = `${library}_${componentName}`;
105
-
106
101
  const oldComponentKey = componentKey;
107
102
  const newComponentKeyPC = convertIntoPascalCase(newComponentKey);
108
103
  const oldComponentKeyPC = convertIntoPascalCase(oldComponentKey);
109
104
 
110
- const currentDirectory = await getComponentDirectoryPath(componentKey);
111
- const targetDirectory = await getComponentDirectoryPath(newComponentKey);
112
-
113
-
105
+ const currentDirectory = process.cwd();
106
+ const tempDirectory = join(currentDirectory, TEMP_PATH, "src", "components");
107
+ const existingDirectory = await getComponentDirectoryPath(componentKey);
108
+ const targetDirectory = await getComponentDirectoryPath(newComponentKey, tempDirectory);
114
109
 
115
110
  if (copyMove === "Move") {
116
111
  // custom component
117
112
  try {
118
- fs.renameSync(currentDirectory, targetDirectory);
113
+ fs.renameSync(existingDirectory, targetDirectory);
119
114
  } catch(err) {
120
115
  console.log(err)
121
116
  }
@@ -124,15 +119,12 @@ addDebugLog("renameComponent", `library: ${library}, componentKey: ${componentKe
124
119
  // copy
125
120
  // custom component
126
121
  try {
127
- fs.cpSync(currentDirectory, targetDirectory, { recursive: true});
122
+ fs.cpSync(existingDirectory, targetDirectory, { recursive: true});
128
123
  } catch(err) {
129
124
  console.log(err)
130
125
  }
131
126
  }
132
127
 
133
-
134
-
135
-
136
128
  const targetFileList = await getDirectoryFiles(targetDirectory);
137
129
 
138
130
  for (var fileIndex in targetFileList) {
@@ -214,18 +206,9 @@ export const moveComp = async(componentKey, copyMove, orgLibName, version, copyS
214
206
  // delete temp directory
215
207
  fs.rmSync(tempDirectory, { recursive: true, force: true, maxRetries: 5 });
216
208
 
217
-
218
-
219
209
  }
220
210
  else {
221
211
 
222
- // if (copyMove === "Move") {
223
- // await localMoveComp(componentKey, orgLibName, version, currentDirectory, tempDirectory);
224
- // }
225
- // else {
226
- // await localCopyComp(componentKey, orgLibName, version, currentDirectory, tempDirectory);
227
- // }
228
-
229
212
  const newComponentKey = await localMoveCopyComp(componentKey, orgLibName, version, copyMove, currentDirectory, tempDirectory);
230
213
 
231
214
  if (newComponentKey) {
@@ -237,7 +220,6 @@ export const moveComp = async(componentKey, copyMove, orgLibName, version, copyS
237
220
  fs.cpSync(currentSharedPath, targetSharedPatah, { recursive: true, force: true });
238
221
  }
239
222
 
240
-
241
223
  console.log(`\n${copiedOrMoved} ${chalk.green(`${componentKey}`)} to ${chalk.green(`${orgLibName}/${version}`)} as ${chalk.green(`${newComponentKey}`)}\n`);
242
224
 
243
225
  // rearchive temp directory
@@ -247,7 +229,6 @@ export const moveComp = async(componentKey, copyMove, orgLibName, version, copyS
247
229
  console.log(chalk.yellow(`No components were ${copiedOrMoved}`));
248
230
  }
249
231
 
250
-
251
232
  // delete temp directory
252
233
  fs.rmSync(tempDirectory, { recursive: true, force: true, maxRetries: 5 });
253
234
  }
@@ -276,24 +257,15 @@ export const localMoveCopyComp = async(componentKey, orgLibName, version, copyMo
276
257
  if (!answers.confirmOverride) {
277
258
  return null;
278
259
  }
260
+ else {
261
+ // delete the one in the temp directory, so can move/copy latest
262
+ fs.rmSync(tempDirComp, { recursive: true, force: true, maxRetries: 2 });
263
+ }
279
264
  }
280
265
 
281
-
282
266
  // rename the component
283
267
  const newComponentKey = await renameComponent(componentKey, orgLibName, version, copyMove);
284
268
 
285
-
286
-
287
-
288
- const currentComponentsPath = join(currentCompPath, `${newComponentKey}`);
289
- const tempDirectoryComponents = join(tempCompPath, `${newComponentKey}`);
290
-
291
- // copy component into temp directory
292
- fs.cpSync(currentComponentsPath, tempDirectoryComponents, { recursive: true, force: true });
293
-
294
- // remove from components
295
- fs.rmSync(currentComponentsPath, { recursive: true, force: true, maxRetries: 2 });
296
-
297
269
  return newComponentKey;
298
270
  }
299
271
 
@@ -337,8 +309,8 @@ addDebugLog("move", "", "+");
337
309
  }
338
310
 
339
311
  if (options.params.length >= 8) {
340
- componentKey = options.params[3];
341
- copyMove = options.param[4];
312
+ copyMove = options.params[3];
313
+ componentKey = options.params[4];
342
314
  orgLibName = options.params[5];
343
315
  version = options.params[6];
344
316
  copyShared = options.params[7];
@@ -43,6 +43,7 @@ export const showHelpV1 = () => {
43
43
  console.log(`${chalk.cyan('npm run buildAllComponents')}\tvalidate and build a component before publishing, checking for errors`);
44
44
  console.log(`${chalk.cyan('npm run validateAll ')}\tvalidate and build ALL components before publishing, checking for errors`);
45
45
  console.log(`${chalk.cyan('npm run rename ')}\trename a component`);
46
+ console.log(`${chalk.cyan('npm run importComponent ')}\timport a component from a path`);
46
47
  console.log(`${chalk.cyan('npm run startStorybook ')}\tstorybook components for testing`);
47
48
 
48
49
  console.log(`\n${chalk.underline(`Local and Server`)}`);
@@ -79,8 +80,7 @@ export const showHelpV2 = () => {
79
80
  console.log(`${chalk.cyan('npm run createLibVersion')}\tcreate a new version within the current library`);
80
81
  console.log(`${chalk.cyan('npm run switchLibVersion')}\tswitch to different version within the current library`);
81
82
  console.log(`${chalk.cyan('npm run deleteLibVersion')}\tdelete current version, move to another version`);
82
- console.log(`${chalk.cyan('npm run moveLibVersion ')}\tmove (or copy) single component or ALL in current version to another version or library`);
83
- console.log(`${chalk.cyan('npm run storeLibVersion ')}\tstore current version to local storage`);
83
+ console.log(`${chalk.cyan('npm run storeLibVersion ')}\tstore current version to local storage (must SAVE before)`);
84
84
  console.log(`${chalk.cyan('npm run exportLibVersion')}\texport currnet version as a zip file to a given local path`);
85
85
  console.log(`${chalk.cyan('npm run importLibVersion')}\timport a zip file (created by export) from a given local path`);
86
86
  console.log(`${chalk.cyan('npm run setPermanent ')}\tmake current version permanent or non permanent upon publish`);
@@ -96,6 +96,8 @@ export const showHelpV2 = () => {
96
96
  console.log(`${chalk.cyan('npm run validate ')}\t\tvalidate a component before publishing, checking for errors`);
97
97
  console.log(`${chalk.cyan('npm run validateAll')}\t\tvalidate ALL components before publishing, checking for errors`);
98
98
  console.log(`${chalk.cyan('npm run rename ')}\t\trename a component`);
99
+ console.log(`${chalk.cyan('npm run move ')}\t\tmove (or copy) single component or ALL in current version to another version or library`);
100
+ console.log(`${chalk.cyan('npm run importComponent')}\t\timport a component from a path`);
99
101
  console.log(`${chalk.cyan('npm run list ')}\t\tget list of components`);
100
102
  console.log(`${chalk.cyan('npm run delete ')}\t\tdelete a component`);
101
103
  console.log(`${chalk.cyan('npm run deleteAll ')}\t\tdelete ALL components`);
@@ -105,8 +107,8 @@ export const showHelpV2 = () => {
105
107
  console.log(`\n${chalk.underline(`Notes`)}`);
106
108
  console.log(`The following commands will store existing version in storage before executing the command:`);
107
109
  console.log(`${chalk.cyan(`createLib, switchLib, createLibVersion, switchLibVersion, publishLibVersion, exportLibVersion`)}`);
108
- console.log(`\nWhen in an IDE, always ${chalk.yellow("SAVE")} changes to components before doing a library/version context switch`);
109
- console.log(`or changes will be lost.`);
110
+ console.log(`\nWhen editing in an IDE, always ${chalk.yellow("SAVE")} changes to components before doing a library/version context switch`);
111
+ console.log(`or changes will be lost!`);
110
112
  console.log("");
111
113
  }
112
114
 
@@ -16,7 +16,8 @@ import {
16
16
  checkLibraryAndArchives,
17
17
  getConfigDefaults,
18
18
  getHaveDependencyDifference,
19
- forceDefaultsUpdate
19
+ forceDefaultsUpdate,
20
+ modAddAboutData
20
21
  } from '../../util.js';
21
22
 
22
23
  import { getSwitchVersionComponentQuestions } from './helper.js';
@@ -49,6 +50,13 @@ addDebugLog("switchVersion", "", "+");
49
50
  const okToCont = options.params[3];
50
51
  version = options.params[4];
51
52
 
53
+ // if have [5] will be "NoAbout" from Jest, to turn off build date
54
+ if (options.params.length >= 6 ) {
55
+ if (options.params[5] === "NoAbout") {
56
+ modAddAboutData(false);
57
+ }
58
+ }
59
+
52
60
  okToContinue = !!(okToCont === 'Y' || okToCont === 'y' || okToCont === true || okToCont === 'true');
53
61
 
54
62
  } else {
package/src/util.js CHANGED
@@ -42,6 +42,7 @@ const access = promisify(fs.access);
42
42
  let showDebug = false;
43
43
  let debugLevel = 1;
44
44
  let haveDependencyDifference = false;
45
+ let addAboutData = true;
45
46
 
46
47
  // updated upon start
47
48
  let defaultConfigs = {
@@ -62,6 +63,11 @@ let pegaData = null;
62
63
  let sPegaData;
63
64
  let sPegaServerConfig;
64
65
 
66
+ export const modAddAboutData = (addInAboutData) => {
67
+ // used by jest to not put in to match assets without aboutData
68
+ addAboutData = addInAboutData;
69
+ }
70
+
65
71
  export const addDebugLog = (sFunctionName, sLogData, sIncDec) => {
66
72
 
67
73
  let sLog;
@@ -703,33 +709,42 @@ if (showDebug) addDebugLog("updateConfigVersion", `componentKey: ${componentKey}
703
709
  }
704
710
  }
705
711
 
706
- if (foundProp) {
707
- foundProp.label = aboutData;
708
- }
709
- else {
710
- // don't have "About"
711
- const aboutLabelJSON = {
712
- "format": "LABEL",
713
- "label": "About",
714
- "name": "PegaAboutLabel",
715
- "variant": "h3"
716
- };
717
- const aboutDataJSON = {
718
- "format": "LABEL",
719
- "label": aboutData,
720
- "name": "PegaAboutData",
721
- "variant": "primary"
712
+ if (addAboutData) {
713
+ if (foundProp) {
714
+ foundProp.label = aboutData;
715
+ }
716
+ else {
717
+ // don't have "About"
718
+ const aboutLabelJSON = {
719
+ "format": "LABEL",
720
+ "label": "About",
721
+ "name": "PegaAboutLabel",
722
+ "variant": "h3"
723
+ };
724
+ const aboutDataJSON = {
725
+ "format": "LABEL",
726
+ "label": aboutData,
727
+ "name": "PegaAboutData",
728
+ "variant": "primary"
729
+ }
730
+ properties.push(aboutLabelJSON);
731
+ properties.push(aboutDataJSON);
722
732
  }
723
- properties.push(aboutLabelJSON);
724
- properties.push(aboutDataJSON);
725
733
  }
734
+
735
+
726
736
  }
727
737
  } catch (er) {
728
738
  throw new Error(`Invalid schema json in config.json: ${er}`);
729
739
  }
730
740
 
731
741
  data.version = buildVersion;
732
- data.buildDate = dateStamp;
742
+
743
+ if (addAboutData) {
744
+ data.buildDate = dateStamp;
745
+ }
746
+
747
+
733
748
 
734
749
  // write back file
735
750
  fs.writeFileSync(configFile, JSON.stringify(data, null, 4), { encoding: 'utf8' });